Qt 4.8
qicdengine.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QICDENGINE_H
43 #define QICDENGINE_H
44 
45 #include <QtNetwork/private/qbearerengine_p.h>
46 
47 #include <QtCore/qtimer.h>
48 
49 #include "maemo_icd.h"
50 
52 
54 class IapMonitor;
55 class QDBusInterface;
57 
59 {
60  if (iapType == QLatin1String("WLAN_INFRA") ||
61  iapType == QLatin1String("WLAN_ADHOC")) {
63  } else if (iapType == QLatin1String("GPRS")) {
65  } else {
67  }
68 }
69 
71 {
72 public:
75 
76  virtual QString bearerTypeName() const;
77 
78  // In Maemo the id field (defined in QNetworkConfigurationPrivate)
79  // is the IAP id (which typically is UUID)
80  QByteArray network_id; // typically WLAN ssid or similar
81  QString iap_type; // is this one WLAN or GPRS
82 
86 
87  // Network attributes for this IAP, this is the value returned by icd and
88  // passed to it when connecting.
90 };
91 
93 {
94  return static_cast<IcdNetworkConfigurationPrivate *>(ptr.data());
95 }
96 
97 class QIcdEngine : public QBearerEngine
98 {
99  Q_OBJECT
100 
101 public:
102  QIcdEngine(QObject *parent = 0);
103  ~QIcdEngine();
104 
105  bool hasIdentifier(const QString &id);
106 
107  Q_INVOKABLE void initialize();
108  Q_INVOKABLE void requestUpdate();
109 
110  QNetworkConfigurationManager::Capabilities capabilities() const;
111 
112  QNetworkSessionPrivate *createSessionBackend();
113 
114  QNetworkConfigurationPrivatePointer defaultConfiguration();
115 
116  void deleteConfiguration(const QString &iap_id);
117 
119  {
120  QMutexLocker locker(&mutex);
121 
122  return accessPointConfigurations.value(id);
123  }
124 
126  {
127  QMutexLocker locker(&mutex);
128 
129  accessPointConfigurations.insert(ptr->id, ptr);
130 
131  locker.unlock();
132  emit configurationAdded(ptr);
133  }
134 
136  {
137  emit configurationChanged(ptr);
138  }
139 
140  void cleanup();
141 
142  void addConfiguration(QString &iap_id);
143 
144 Q_SIGNALS:
145  void iapStateChanged(const QString& iapid, uint icd_connection_state);
146 
147 private Q_SLOTS:
148  void finishAsyncConfigurationUpdate();
149  void asyncUpdateConfigurationsSlot(QDBusMessage msg);
150  void connectionStateSignalsSlot(QDBusMessage msg);
151  void icdServiceOwnerChanged(const QString &serviceName, const QString &oldOwner,
152  const QString &newOwner);
153 
154 private:
155  void startListeningStateSignalsForAllConnections();
156  void doRequestUpdate(QList<Maemo::IcdScanResult> scanned = QList<Maemo::IcdScanResult>());
157  void cancelAsyncConfigurationUpdate();
158  void getIcdInitialState();
159  bool ensureDBusConnection();
160 
161 private:
168 
170 
173 };
174 
176 
177 #endif // QICDENGINE_H
BearerType
Specifies the type of bearer used by a configuration.
QList< Maemo::IcdScanResult > m_scanResult
Definition: qicdengine.h:167
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QDBusServiceWatcher * m_icdServiceWatcher
Definition: qicdengine.h:169
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define Q_INVOKABLE
Definition: qobjectdefs.h:90
void unlock()
Unlocks this mutex locker.
Definition: qmutex.h:117
The QDBusInterface class is a proxy for interfaces on remote objects.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual QString bearerTypeName() const
Definition: qicdengine.cpp:63
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString m_onlineIapId
Definition: qicdengine.h:165
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
void addSessionConfiguration(QNetworkConfigurationPrivatePointer ptr)
Definition: qicdengine.h:125
bool firstUpdate
Definition: qicdengine.h:171
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define emit
Definition: qobjectdefs.h:76
QStringList m_typesToBeScanned
Definition: qicdengine.h:166
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
unsigned int uint
Definition: qglobal.h:996
void changedSessionConfiguration(QNetworkConfigurationPrivatePointer ptr)
Definition: qicdengine.h:135
const T * ptr(const T &t)
QDBusInterface * m_dbusInterface
Definition: qicdengine.h:163
QTimer m_scanTimer
Definition: qicdengine.h:164
#define Q_OBJECT
Definition: qobjectdefs.h:157
IapMonitor * iapMonitor
Definition: qicdengine.h:162
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
IcdNetworkConfigurationPrivate * toIcdConfig(QNetworkConfigurationPrivatePointer ptr)
Definition: qicdengine.h:92
bool m_scanGoingOn
Definition: qicdengine.h:172
unsigned int quint32
Definition: qglobal.h:938
static void cleanup()
Definition: qpicture.cpp:1508
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
The QDBusServiceWatcher class allows the user to watch for a bus service change.
QNetworkConfiguration::BearerType bearerTypeFromIapType(const QString &iapType)
Definition: qicdengine.h:58
QNetworkConfigurationPrivatePointer configuration(const QString &id)
Definition: qicdengine.h:118