Qt 4.8
Signals | Public Functions | Private Slots | Private Functions | Properties | List of all members
QIcdEngine Class Reference

#include <qicdengine.h>

Inheritance diagram for QIcdEngine:
QBearerEngine QObject

Signals

void iapStateChanged (const QString &iapid, uint icd_connection_state)
 
- Signals inherited from QBearerEngine
void configurationAdded (QNetworkConfigurationPrivatePointer config)
 
void configurationChanged (QNetworkConfigurationPrivatePointer config)
 
void configurationRemoved (QNetworkConfigurationPrivatePointer config)
 
void updateCompleted ()
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

void addConfiguration (QString &iap_id)
 
void addSessionConfiguration (QNetworkConfigurationPrivatePointer ptr)
 
QNetworkConfigurationManager::Capabilities capabilities () const
 
void changedSessionConfiguration (QNetworkConfigurationPrivatePointer ptr)
 
void cleanup ()
 
QNetworkConfigurationPrivatePointer configuration (const QString &id)
 
QNetworkSessionPrivatecreateSessionBackend ()
 
QNetworkConfigurationPrivatePointer defaultConfiguration ()
 
void deleteConfiguration (const QString &iap_id)
 
bool hasIdentifier (const QString &id)
 
Q_INVOKABLE void initialize ()
 
 QIcdEngine (QObject *parent=0)
 
Q_INVOKABLE void requestUpdate ()
 
 ~QIcdEngine ()
 
- Public Functions inherited from QBearerEngine
bool configurationsInUse () const
 
 QBearerEngine (QObject *parent=0)
 
virtual bool requiresPolling () const
 
virtual ~QBearerEngine ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Slots

void asyncUpdateConfigurationsSlot (QDBusMessage msg)
 
void connectionStateSignalsSlot (QDBusMessage msg)
 
void finishAsyncConfigurationUpdate ()
 
void icdServiceOwnerChanged (const QString &serviceName, const QString &oldOwner, const QString &newOwner)
 

Private Functions

void cancelAsyncConfigurationUpdate ()
 
void doRequestUpdate (QList< Maemo::IcdScanResult > scanned=QList< Maemo::IcdScanResult >())
 
bool ensureDBusConnection ()
 
void getIcdInitialState ()
 
void startListeningStateSignalsForAllConnections ()
 

Properties

bool firstUpdate
 
IapMonitoriapMonitor
 
QDBusInterfacem_dbusInterface
 
QDBusServiceWatcherm_icdServiceWatcher
 
QString m_onlineIapId
 
bool m_scanGoingOn
 
QList< Maemo::IcdScanResultm_scanResult
 
QTimer m_scanTimer
 
QStringList m_typesToBeScanned
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QBearerEngine
QHash< QString, QNetworkConfigurationPrivatePointeraccessPointConfigurations
 
QMutex mutex
 
QHash< QString, QNetworkConfigurationPrivatePointersnapConfigurations
 
QHash< QString, QNetworkConfigurationPrivatePointeruserChoiceConfigurations
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 97 of file qicdengine.h.

Constructors and Destructors

◆ QIcdEngine()

QIcdEngine::QIcdEngine ( QObject parent = 0)

QIcdEngine implementation

Definition at line 231 of file qicdengine.cpp.

233  firstUpdate(true), m_scanGoingOn(false)
234 {
235 }
QDBusServiceWatcher * m_icdServiceWatcher
Definition: qicdengine.h:169
bool firstUpdate
Definition: qicdengine.h:171
QBearerEngine(QObject *parent=0)
QDBusInterface * m_dbusInterface
Definition: qicdengine.h:163
IapMonitor * iapMonitor
Definition: qicdengine.h:162
bool m_scanGoingOn
Definition: qicdengine.h:172

◆ ~QIcdEngine()

QIcdEngine::~QIcdEngine ( )

Definition at line 237 of file qicdengine.cpp.

238 {
239  cleanup();
240  delete iapMonitor;
241 }
void cleanup()
IapMonitor * iapMonitor
Definition: qicdengine.h:162

Functions

◆ addConfiguration()

void QIcdEngine::addConfiguration ( QString iap_id)

Definition at line 412 of file qicdengine.cpp.

413 {
414  // Note: When new IAP is created, this function gets called multiple times
415  // in a row.
416  // For example: Empty type & name for WLAN was stored into newly
417  // created IAP data in gconf when this function gets
418  // called for the first time.
419  // WLAN type & name are updated into IAP data in gconf
420  // as soon as WLAN connection is up and running.
421  // => And this function gets called again.
422 
423  QMutexLocker locker(&mutex);
424 
425  if (!accessPointConfigurations.contains(iap_id)) {
426  Maemo::IAPConf saved_iap(iap_id);
427  QString iap_type = saved_iap.value("type").toString();
428  QString iap_name = saved_iap.value("name").toString();
429  QByteArray ssid = saved_iap.value("wlan_ssid").toByteArray();
430  if (!iap_type.isEmpty() && !iap_name.isEmpty()) {
431  // Check if new IAP is actually Undefined WLAN configuration
432  // Note: SSID is used as an iap id for Undefined WLAN configurations
433  // => configuration must be searched using SSID
434  if (!ssid.isEmpty() && accessPointConfigurations.contains(ssid)) {
436  if (ptr) {
437  ptr->mutex.lock();
438  ptr->id = iap_id;
439  toIcdConfig(ptr)->iap_type = iap_type;
440  ptr->bearerType = bearerTypeFromIapType(iap_type);
441  toIcdConfig(ptr)->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString());
442  toIcdConfig(ptr)->network_id = ssid;
443  toIcdConfig(ptr)->service_id = saved_iap.value("service_id").toString();
444  toIcdConfig(ptr)->service_type = saved_iap.value("service_type").toString();
445  if (m_onlineIapId == iap_id) {
447  } else {
449  }
450  ptr->mutex.unlock();
451  accessPointConfigurations.insert(iap_id, ptr);
452 
453  locker.unlock();
455  locker.relock();
456  }
457  } else {
459  cpPriv->name = saved_iap.value("name").toString();
460  if (cpPriv->name.isEmpty())
461  cpPriv->name = iap_id;
462  cpPriv->isValid = true;
463  cpPriv->id = iap_id;
464  cpPriv->iap_type = iap_type;
465  cpPriv->bearerType = bearerTypeFromIapType(iap_type);
466  cpPriv->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString());
467  cpPriv->service_id = saved_iap.value("service_id").toString();
468  cpPriv->service_type = saved_iap.value("service_type").toString();
469  if (iap_type.startsWith(QLatin1String("WLAN"))) {
470  QByteArray ssid = saved_iap.value("wlan_ssid").toByteArray();
471  if (ssid.isEmpty()) {
472  qWarning() << "Cannot get ssid for" << iap_id;
473  }
474  cpPriv->network_id = ssid;
475  }
477  if (m_onlineIapId == iap_id) {
479  } else {
481  }
482 
484  accessPointConfigurations.insert(iap_id, ptr);
485 
486 #ifdef BEARER_MANAGEMENT_DEBUG
487  qDebug("IAP: %s, name: %s, added to known list", iap_id.toAscii().data(), cpPriv->name.toAscii().data());
488 #endif
489  locker.unlock();
491  locker.relock();
492  }
493  } else {
494  qWarning("IAP %s does not have \"type\" or \"name\" fields defined, skipping this IAP.", iap_id.toAscii().data());
495  }
496  } else {
497 #ifdef BEARER_MANAGEMENT_DEBUG
498  qDebug() << "IAP" << iap_id << "already in db.";
499 #endif
500 
501  /* Check if the data in db changed and update configuration accordingly
502  */
504  if (ptr) {
505  Maemo::IAPConf changed_iap(iap_id);
506  QString iap_type = changed_iap.value("type").toString();
507  bool update_needed = false; /* if IAP type or ssid changed, we need to change the state */
508 
509  QMutexLocker configLocker(&ptr->mutex);
510 
511  toIcdConfig(ptr)->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString());
512  toIcdConfig(ptr)->service_id = changed_iap.value("service_id").toString();
513  toIcdConfig(ptr)->service_type = changed_iap.value("service_type").toString();
514 
515  if (!iap_type.isEmpty()) {
516  ptr->name = changed_iap.value("name").toString();
517  if (ptr->name.isEmpty())
518  ptr->name = iap_id;
519  ptr->isValid = true;
520  if (toIcdConfig(ptr)->iap_type != iap_type) {
521  toIcdConfig(ptr)->iap_type = iap_type;
522  ptr->bearerType = bearerTypeFromIapType(iap_type);
523  update_needed = true;
524  }
525  if (iap_type.startsWith(QLatin1String("WLAN"))) {
526  QByteArray ssid = changed_iap.value("wlan_ssid").toByteArray();
527  if (ssid.isEmpty()) {
528  qWarning() << "Cannot get ssid for" << iap_id;
529  }
530  if (toIcdConfig(ptr)->network_id != ssid) {
531  toIcdConfig(ptr)->network_id = ssid;
532  update_needed = true;
533  }
534  }
535  }
536 
537  if (update_needed) {
539  if (m_onlineIapId == iap_id) {
542 
543  configLocker.unlock();
544  locker.unlock();
546  locker.relock();
547  }
548  } else if (ptr->state < QNetworkConfiguration::Defined) {
550 
551  configLocker.unlock();
552  locker.unlock();
554  locker.relock();
555  }
556  }
557  } else {
558  qWarning("Cannot find IAP %s from current configuration although it should be there.", iap_id.toAscii().data());
559  }
560  }
561 }
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
QNetworkConfiguration::StateFlags state
void configurationChanged(QNetworkConfigurationPrivatePointer config)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString m_onlineIapId
Definition: qicdengine.h:165
QNetworkConfiguration::BearerType bearerType
Q_CORE_EXPORT void qDebug(const char *,...)
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define emit
Definition: qobjectdefs.h:76
void configurationAdded(QNetworkConfigurationPrivatePointer config)
Q_CORE_EXPORT void qWarning(const char *,...)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
const T * ptr(const T &t)
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
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
QNetworkConfiguration::Type type
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014
if(void) toggleToolbarShown
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static quint32 getNetworkAttrs(bool is_iap_id, const QString &iap_id, const QString &iap_type, QString security_method)
Definition: qicdengine.cpp:367
QNetworkConfiguration::BearerType bearerTypeFromIapType(const QString &iapType)
Definition: qicdengine.h:58

◆ addSessionConfiguration()

void QIcdEngine::addSessionConfiguration ( QNetworkConfigurationPrivatePointer  ptr)
inline

Definition at line 125 of file qicdengine.h.

Referenced by QNetworkSessionPrivateImpl::stateChange(), and QNetworkSessionPrivateImpl::syncStateWithInterface().

126  {
127  QMutexLocker locker(&mutex);
128 
129  accessPointConfigurations.insert(ptr->id, ptr);
130 
131  locker.unlock();
133  }
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
#define emit
Definition: qobjectdefs.h:76
void configurationAdded(QNetworkConfigurationPrivatePointer config)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ asyncUpdateConfigurationsSlot

void QIcdEngine::asyncUpdateConfigurationsSlot ( QDBusMessage  msg)
privateslot

Definition at line 1064 of file qicdengine.cpp.

Referenced by cancelAsyncConfigurationUpdate(), and requestUpdate().

1065 {
1066  QMutexLocker locker(&mutex);
1067 
1068  QList<QVariant> arguments = msg.arguments();
1069  uint icd_scan_status = arguments.takeFirst().toUInt();
1070  if (icd_scan_status == ICD_SCAN_COMPLETE) {
1071  m_typesToBeScanned.removeOne(arguments[6].toString());
1072  if (!m_typesToBeScanned.count()) {
1073  locker.unlock();
1075  locker.relock();
1076  }
1077  } else {
1078  Maemo::IcdScanResult scanResult;
1079  scanResult.status = icd_scan_status;
1080  scanResult.timestamp = arguments.takeFirst().toUInt();
1081  scanResult.scan.service_type = arguments.takeFirst().toString();
1082  scanResult.service_name = arguments.takeFirst().toString();
1083  scanResult.scan.service_attrs = arguments.takeFirst().toUInt();
1084  scanResult.scan.service_id = arguments.takeFirst().toString();
1085  scanResult.service_priority = arguments.takeFirst().toInt();
1086  scanResult.scan.network_type = arguments.takeFirst().toString();
1087  scanResult.network_name = arguments.takeFirst().toString();
1088  scanResult.scan.network_attrs = arguments.takeFirst().toUInt();
1089  scanResult.scan.network_id = arguments.takeFirst().toByteArray();
1090  scanResult.network_priority = arguments.takeFirst().toInt();
1091  scanResult.signal_strength = arguments.takeFirst().toInt();
1092  scanResult.station_id = arguments.takeFirst().toString();
1093  scanResult.signal_dB = arguments.takeFirst().toInt();
1094 
1095  m_scanResult.append(scanResult);
1096  }
1097 }
QList< Maemo::IcdScanResult > m_scanResult
Definition: qicdengine.h:167
QString network_name
Definition: maemo_icd.h:80
QString service_id
Definition: maemo_icd.h:69
struct CommonParams scan
Definition: maemo_icd.h:82
QByteArray network_id
Definition: maemo_icd.h:72
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796
static QString toString(Register *reg, int type, bool *ok=0)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QVariant > arguments() const
Returns the list of arguments that are going to be sent or were received from D-Bus.
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
QStringList m_typesToBeScanned
Definition: qicdengine.h:166
unsigned int uint
Definition: qglobal.h:996
QString service_name
Definition: maemo_icd.h:78
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
void finishAsyncConfigurationUpdate()
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
Definition: qvariant.cpp:2644
QString service_type
Definition: maemo_icd.h:67
QString network_type
Definition: maemo_icd.h:70

◆ cancelAsyncConfigurationUpdate()

void QIcdEngine::cancelAsyncConfigurationUpdate ( )
private

Definition at line 1030 of file qicdengine.cpp.

Referenced by finishAsyncConfigurationUpdate().

1031 {
1032  if (!ensureDBusConnection())
1033  return;
1034 
1035  if (!m_scanGoingOn)
1036  return;
1037 
1038  m_scanGoingOn = false;
1039 
1040  if (m_scanTimer.isActive())
1041  m_scanTimer.stop();
1042 
1043  m_dbusInterface->connection().disconnect(ICD_DBUS_API_INTERFACE,
1044  ICD_DBUS_API_PATH,
1045  ICD_DBUS_API_INTERFACE,
1046  ICD_DBUS_API_SCAN_SIG,
1048 
1049  // Stop scanning rounds by calling ICD_DBUS_API_SCAN_CANCEL
1050  // <=> If ICD_DBUS_API_SCAN_CANCEL is not called, new scanning round will
1051  // be started after the module scan timeout.
1052  m_dbusInterface->call(ICD_DBUS_API_SCAN_CANCEL);
1053 }
void asyncUpdateConfigurationsSlot(QDBusMessage msg)
QDBusConnection connection() const
Returns the connection this interface is assocated with.
#define SLOT(a)
Definition: qobjectdefs.h:226
bool ensureDBusConnection()
Definition: qicdengine.cpp:251
bool isActive() const
Returns true if the timer is running (pending); otherwise returns false.
Definition: qtimer.h:69
QDBusInterface * m_dbusInterface
Definition: qicdengine.h:163
QTimer m_scanTimer
Definition: qicdengine.h:164
bool m_scanGoingOn
Definition: qicdengine.h:172
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
void stop()
Stops the timer.
Definition: qtimer.cpp:284
bool disconnect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
Disconnects the signal specified by the service, path, interface and name parameters from the slot sl...
QDBusMessage call(const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
Calls the method method on this interface and passes the parameters to this function to the method...

◆ capabilities()

QNetworkConfigurationManager::Capabilities QIcdEngine::capabilities ( ) const
virtual

◆ changedSessionConfiguration()

void QIcdEngine::changedSessionConfiguration ( QNetworkConfigurationPrivatePointer  ptr)
inline

Definition at line 135 of file qicdengine.h.

Referenced by QNetworkSessionPrivateImpl::stateChange(), and QNetworkSessionPrivateImpl::syncStateWithInterface().

136  {
138  }
void configurationChanged(QNetworkConfigurationPrivatePointer config)
#define emit
Definition: qobjectdefs.h:76

◆ cleanup()

void QIcdEngine::cleanup ( )

Definition at line 1099 of file qicdengine.cpp.

Referenced by icdServiceOwnerChanged(), and ~QIcdEngine().

1100 {
1101  if (m_scanGoingOn) {
1102  m_scanTimer.stop();
1103  m_dbusInterface->call(ICD_DBUS_API_SCAN_CANCEL);
1104  }
1105  if (iapMonitor)
1106  iapMonitor->cleanup();
1107 }
QDBusInterface * m_dbusInterface
Definition: qicdengine.h:163
QTimer m_scanTimer
Definition: qicdengine.h:164
IapMonitor * iapMonitor
Definition: qicdengine.h:162
bool m_scanGoingOn
Definition: qicdengine.h:172
void cleanup()
Definition: qicdengine.cpp:201
void stop()
Stops the timer.
Definition: qtimer.cpp:284
QDBusMessage call(const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
Calls the method method on this interface and passes the parameters to this function to the method...

◆ configuration()

QNetworkConfigurationPrivatePointer QIcdEngine::configuration ( const QString id)
inline

Definition at line 118 of file qicdengine.h.

Referenced by QNetworkSessionPrivateImpl::stateChange().

119  {
120  QMutexLocker locker(&mutex);
121 
122  return accessPointConfigurations.value(id);
123  }
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ connectionStateSignalsSlot

void QIcdEngine::connectionStateSignalsSlot ( QDBusMessage  msg)
privateslot

Definition at line 881 of file qicdengine.cpp.

Referenced by startListeningStateSignalsForAllConnections().

882 {
883  QMutexLocker locker(&mutex);
884 
885  QList<QVariant> arguments = msg.arguments();
886  if (arguments[1].toUInt() != 0 || arguments.count() < 8) {
887  return;
888  }
889 
890  QString iapid = arguments[5].toByteArray().data();
891  uint icd_connection_state = arguments[7].toUInt();
892 
893  switch (icd_connection_state) {
894  case ICD_STATE_CONNECTED:
895  {
897  if (ptr) {
898  QMutexLocker configLocker(&ptr->mutex);
899 
901  if (ptr->state != QNetworkConfiguration::Active) {
903 
904  configLocker.unlock();
905  locker.unlock();
907  locker.relock();
908 
909  m_onlineIapId = iapid;
910  }
911  } else {
912  // This gets called when new WLAN IAP is created using Connection dialog
913  // At this point Undefined WLAN configuration has SSID as iap id
914  // => Because of that configuration can not be found from
915  // accessPointConfigurations using correct iap id
916  m_onlineIapId = iapid;
917  }
918  break;
919  }
920  case ICD_STATE_DISCONNECTED:
921  {
923  if (ptr) {
924  QMutexLocker configLocker(&ptr->mutex);
925 
927  if (ptr->state == QNetworkConfiguration::Active) {
929 
930  configLocker.unlock();
931  locker.unlock();
932  emit iapStateChanged(iapid, icd_connection_state);
934  locker.relock();
935 
936  // Note: If ICD switches used IAP from one to another:
937  // 1) new IAP is reported to be online first
938  // 2) old IAP is reported to be offline then
939  // => Device can be reported to be offline only
940  // if last known online IAP is reported to be disconnected
941  if (iapid == m_onlineIapId) {
942  // It's known that there is only one global ICD connection
943  // => Because ICD state was reported to be DISCONNECTED, Device is offline
945  }
946  }
947  } else {
948  // Disconnected IAP was not found from accessPointConfigurations
949  // => Reason: Online IAP was removed which resulted ICD to disconnect
950  if (iapid == m_onlineIapId) {
951  // It's known that there is only one global ICD connection
952  // => Because ICD state was reported to be DISCONNECTED, Device is offline
954  }
955  }
956  break;
957  }
958  default:
959  break;
960  }
961 
962  locker.unlock();
963  emit iapStateChanged(iapid, icd_connection_state);
964  locker.relock();
965 }
QNetworkConfiguration::StateFlags state
void configurationChanged(QNetworkConfigurationPrivatePointer config)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString m_onlineIapId
Definition: qicdengine.h:165
QList< QVariant > arguments() const
Returns the list of arguments that are going to be sent or were received from D-Bus.
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
#define emit
Definition: qobjectdefs.h:76
unsigned int uint
Definition: qglobal.h:996
void iapStateChanged(const QString &iapid, uint icd_connection_state)
const T * ptr(const T &t)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
QNetworkConfiguration::Type type

◆ createSessionBackend()

QNetworkSessionPrivate * QIcdEngine::createSessionBackend ( )
virtual

Implements QBearerEngine.

Definition at line 1118 of file qicdengine.cpp.

1119 {
1120  return new QNetworkSessionPrivateImpl(this);
1121 }

◆ defaultConfiguration()

QNetworkConfigurationPrivatePointer QIcdEngine::defaultConfiguration ( )
virtual

Implements QBearerEngine.

Definition at line 818 of file qicdengine.cpp.

819 {
820  QMutexLocker locker(&mutex);
821 
822  if (!ensureDBusConnection())
824 
825  // Here we just return [ANY] request to icd and let the icd decide which IAP to connect.
826  return userChoiceConfigurations.value(OSSO_IAP_ANY);
827 }
QHash< QString, QNetworkConfigurationPrivatePointer > userChoiceConfigurations
bool ensureDBusConnection()
Definition: qicdengine.cpp:251
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > QNetworkConfigurationPrivatePointer

◆ deleteConfiguration()

void QIcdEngine::deleteConfiguration ( const QString iap_id)

Definition at line 343 of file qicdengine.cpp.

344 {
345  QMutexLocker locker(&mutex);
346 
347  /* Called when IAPs are deleted in db, in this case we do not scan
348  * or read all the IAPs from db because it might take too much power
349  * (multiple applications would need to scan and read all IAPs from db)
350  */
352  if (ptr) {
353 #ifdef BEARER_MANAGEMENT_DEBUG
354  qDebug() << "IAP" << iap_id << "was removed from storage.";
355 #endif
356 
357  locker.unlock();
359  } else {
360 #ifdef BEARER_MANAGEMENT_DEBUG
361  qDebug("IAP: %s, already missing from the known list", iap_id.toAscii().data());
362 #endif
363  }
364 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
Q_CORE_EXPORT void qDebug(const char *,...)
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
#define emit
Definition: qobjectdefs.h:76
const T * ptr(const T &t)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
void configurationRemoved(QNetworkConfigurationPrivatePointer config)
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014

◆ doRequestUpdate()

void QIcdEngine::doRequestUpdate ( QList< Maemo::IcdScanResult scanned = QList<Maemo::IcdScanResult>())
private

Definition at line 563 of file qicdengine.cpp.

Referenced by ensureDBusConnection(), and finishAsyncConfigurationUpdate().

564 {
565  /* Contains all known iap_ids from storage */
566  QList<QString> knownConfigs = accessPointConfigurations.keys();
567 
568  /* Contains all known WLAN network ids (like ssid) from storage */
569  QMultiHash<QByteArray, SSIDInfo* > notDiscoveredWLANConfigs;
570 
571  QList<QString> all_iaps;
572  Maemo::IAPConf::getAll(all_iaps);
573 
574  foreach (const QString &iap_id, all_iaps) {
575  QByteArray ssid;
576 
577  Maemo::IAPConf saved_ap(iap_id);
578  bool is_temporary = saved_ap.value("temporary").toBool();
579  if (is_temporary) {
580 #ifdef BEARER_MANAGEMENT_DEBUG
581  qDebug() << "IAP" << iap_id << "is temporary, skipping it.";
582 #endif
583  continue;
584  }
585 
586  QString iap_type = saved_ap.value("type").toString();
587  if (iap_type.startsWith(QLatin1String("WLAN"))) {
588  ssid = saved_ap.value("wlan_ssid").toByteArray();
589  if (ssid.isEmpty())
590  continue;
591 
592  QString security_method = saved_ap.value("wlan_security").toString();
593  SSIDInfo *info = new SSIDInfo;
594  info->iap_id = iap_id;
595  info->wlan_security = security_method;
596  notDiscoveredWLANConfigs.insert(ssid, info);
597  } else if (iap_type.isEmpty()) {
598  continue;
599  } else {
600 #ifdef BEARER_MANAGEMENT_DEBUG
601  qDebug() << "IAP" << iap_id << "network type is" << iap_type;
602 #endif
603  ssid.clear();
604  }
605 
606  if (!accessPointConfigurations.contains(iap_id)) {
608 
609  cpPriv->name = saved_ap.value("name").toString();
610  if (cpPriv->name.isEmpty()) {
611  if (!ssid.isEmpty() && ssid.size() > 0)
612  cpPriv->name = ssid.data();
613  else
614  cpPriv->name = iap_id;
615  }
616  cpPriv->isValid = true;
617  cpPriv->id = iap_id;
618  cpPriv->network_id = ssid;
619  cpPriv->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString());
620  cpPriv->iap_type = iap_type;
621  cpPriv->bearerType = bearerTypeFromIapType(iap_type);
622  cpPriv->service_id = saved_ap.value("service_id").toString();
623  cpPriv->service_type = saved_ap.value("service_type").toString();
626 
628  accessPointConfigurations.insert(iap_id, ptr);
629 
630  mutex.unlock();
632  mutex.lock();
633 
634 #ifdef BEARER_MANAGEMENT_DEBUG
635  qDebug("IAP: %s, name: %s, ssid: %s, added to known list",
636  iap_id.toAscii().data(), ptr->name.toAscii().data(),
637  !ssid.isEmpty() ? ssid.data() : "-");
638 #endif
639  } else {
640  knownConfigs.removeOne(iap_id);
641 #ifdef BEARER_MANAGEMENT_DEBUG
642  qDebug("IAP: %s, ssid: %s, already exists in the known list",
643  iap_id.toAscii().data(), !ssid.isEmpty() ? ssid.data() : "-");
644 #endif
645  }
646  }
647 
648  /* This is skipped in the first update as scanned size is zero */
649  if (!scanned.isEmpty()) {
650  for (int i=0; i<scanned.size(); ++i) {
651  const Maemo::IcdScanResult ap = scanned.at(i);
652 
653  if (ap.scan.network_attrs & ICD_NW_ATTR_IAPNAME) {
654  /* The network_id is IAP id, so the IAP is a known one */
655  QString iapid = ap.scan.network_id.data();
657  if (ptr) {
658  bool changed = false;
659 
660  ptr->mutex.lock();
661 
662  if (!ptr->isValid) {
663  ptr->isValid = true;
664  changed = true;
665  }
666 
667  /* If this config is the current active one, we do not set it
668  * to discovered.
669  */
673  changed = true;
674  }
675 
680 
681 #ifdef BEARER_MANAGEMENT_DEBUG
682  qDebug("IAP: %s, ssid: %s, discovered",
683  iapid.toAscii().data(), toIcdConfig(ptr)->network_id.data());
684 #endif
685 
686  ptr->mutex.unlock();
687 
688  if (changed) {
689  mutex.unlock();
691  mutex.lock();
692  }
693 
694  if (!ap.scan.network_type.startsWith(QLatin1String("WLAN")))
695  continue; // not a wlan AP
696 
697  /* Remove scanned AP from discovered WLAN configurations so that we can
698  * emit configurationRemoved signal later
699  */
700  ptr->mutex.lock();
701  QList<SSIDInfo* > known_iaps = notDiscoveredWLANConfigs.values(toIcdConfig(ptr)->network_id);
702 rescan_list:
703  if (!known_iaps.isEmpty()) {
704  for (int k=0; k<known_iaps.size(); ++k) {
705  SSIDInfo *iap = known_iaps.at(k);
706 
707  if (iap->wlan_security ==
709  /* Remove IAP from the list */
710  notDiscoveredWLANConfigs.remove(toIcdConfig(ptr)->network_id, iap);
711 #ifdef BEARER_MANAGEMENT_DEBUG
712  qDebug() << "Removed IAP" << iap->iap_id << "from unknown config";
713 #endif
714  known_iaps.removeAt(k);
715  delete iap;
716  goto rescan_list;
717  }
718  }
719  }
720  ptr->mutex.unlock();
721  }
722  } else {
723  /* Non saved access point data */
724  QByteArray scanned_ssid = ap.scan.network_id;
725  if (!accessPointConfigurations.contains(scanned_ssid)) {
727  QString hrs = scanned_ssid.data();
728 
729  cpPriv->name = ap.network_name.isEmpty() ? hrs : ap.network_name;
730  cpPriv->isValid = true;
731  cpPriv->id = scanned_ssid.data(); // Note: id is now ssid, it should be set to IAP id if the IAP is saved
732  cpPriv->network_id = scanned_ssid;
733  cpPriv->iap_type = ap.scan.network_type;
734  cpPriv->bearerType = bearerTypeFromIapType(cpPriv->iap_type);
735  cpPriv->network_attrs = ap.scan.network_attrs;
736  cpPriv->service_id = ap.scan.service_id;
737  cpPriv->service_type = ap.scan.service_type;
738  cpPriv->service_attrs = ap.scan.service_attrs;
739 
742 
743 #ifdef BEARER_MANAGEMENT_DEBUG
744  qDebug() << "IAP with network id" << cpPriv->id << "was found in the scan.";
745 #endif
746 
748  accessPointConfigurations.insert(ptr->id, ptr);
749 
750  mutex.unlock();
752  mutex.lock();
753  } else {
754  knownConfigs.removeOne(scanned_ssid);
755  }
756  }
757  }
758  }
759 
760  if (!firstUpdate) {
761  // Update Defined status to all defined WLAN IAPs which
762  // could not be found when access points were scanned
763  QHashIterator<QByteArray, SSIDInfo* > i(notDiscoveredWLANConfigs);
764  while (i.hasNext()) {
765  i.next();
766  SSIDInfo *iap = i.value();
767  QString iap_id = iap->iap_id;
768  //qDebug() << i.key() << ": " << iap_id;
769 
771  if (ptr) {
772  QMutexLocker configLocker(&ptr->mutex);
773 
774  // WLAN AccessPoint configuration could not be Discovered
775  // => Make sure that configuration state is Defined
778 
779  configLocker.unlock();
780  mutex.unlock();
782  mutex.lock();
783  }
784  }
785  }
786 
787  /* Remove non existing iaps since last update */
788  foreach (const QString &oldIface, knownConfigs) {
790  if (ptr) {
791  mutex.unlock();
793  mutex.lock();
794  //if we would have SNAP support we would have to remove the references
795  //from existing ServiceNetworks to the removed access point configuration
796  }
797  }
798  }
799 
800  QMutableHashIterator<QByteArray, SSIDInfo* > i(notDiscoveredWLANConfigs);
801  while (i.hasNext()) {
802  i.next();
803  SSIDInfo *iap = i.value();
804  delete iap;
805  i.remove();
806  }
807 
808  if (!firstUpdate) {
809  mutex.unlock();
811  mutex.lock();
812  }
813 
814  if (firstUpdate)
815  firstUpdate = false;
816 }
The QMultiHash class is a convenience QHash subclass that provides multi-valued hashes.
Definition: qcontainerfwd.h:58
static mach_timebase_info_data_t info
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
QNetworkConfiguration::StateFlags state
QString network_name
Definition: maemo_icd.h:80
void configurationChanged(QNetworkConfigurationPrivatePointer config)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString service_id
Definition: maemo_icd.h:69
struct CommonParams scan
Definition: maemo_icd.h:82
QByteArray network_id
Definition: maemo_icd.h:72
void updateCompleted()
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
QNetworkConfiguration::BearerType bearerType
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
Q_CORE_EXPORT void qDebug(const char *,...)
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796
bool firstUpdate
Definition: qicdengine.h:171
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QString network_attrs_to_security(uint network_attrs)
Definition: qicdengine.cpp:321
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
void configurationAdded(QNetworkConfigurationPrivatePointer config)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
const T * ptr(const T &t)
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
QHash< Key, T >::iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:934
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
int remove(const Key &key, const T &value)
Removes all the items that have the key and the value value from the hash.
Definition: qhash.h:1006
IcdNetworkConfigurationPrivate * toIcdConfig(QNetworkConfigurationPrivatePointer ptr)
Definition: qicdengine.h:92
QNetworkConfiguration::Type type
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
Definition: qhash.h:693
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void configurationRemoved(QNetworkConfigurationPrivatePointer config)
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014
static void getAll(QList< QString > &all_iaps, bool return_path=false)
Definition: iapconf.cpp:226
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
QString iap_id
Definition: qicdengine.cpp:338
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
QString service_type
Definition: maemo_icd.h:67
QString wlan_security
Definition: qicdengine.cpp:339
void clear()
Clears the contents of the byte array and makes it empty.
static quint32 getNetworkAttrs(bool is_iap_id, const QString &iap_id, const QString &iap_type, QString security_method)
Definition: qicdengine.cpp:367
QNetworkConfiguration::BearerType bearerTypeFromIapType(const QString &iapType)
Definition: qicdengine.h:58
QString network_type
Definition: maemo_icd.h:70
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ ensureDBusConnection()

bool QIcdEngine::ensureDBusConnection ( )
private

Definition at line 251 of file qicdengine.cpp.

Referenced by cancelAsyncConfigurationUpdate(), defaultConfiguration(), icdServiceOwnerChanged(), initialize(), and requestUpdate().

252 {
253  if (m_dbusInterface)
254  return true;
255 
256  // Setup DBus Interface for ICD
257  m_dbusInterface = new QDBusInterface(ICD_DBUS_API_INTERFACE,
258  ICD_DBUS_API_PATH,
259  ICD_DBUS_API_INTERFACE,
261  this);
262 
263  if (!m_dbusInterface->isValid()) {
264  delete m_dbusInterface;
265  m_dbusInterface = 0;
266 
267  if (!m_icdServiceWatcher) {
268  m_icdServiceWatcher = new QDBusServiceWatcher(ICD_DBUS_API_INTERFACE,
271  this);
272 
273  connect(m_icdServiceWatcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
275  }
276 
277  return false;
278  }
279 
282 
283  /* Turn on IAP state monitoring */
285 
286  /* Turn on IAP add/remove monitoring */
287  iapMonitor = new IapMonitor;
288  iapMonitor->setup(this);
289 
290  /* We create a default configuration which is a pseudo config */
292  cpPriv->name = "UserChoice";
294  cpPriv->isValid = true;
295  cpPriv->id = OSSO_IAP_ANY;
298  cpPriv->roamingSupported = false;
299 
301  userChoiceConfigurations.insert(cpPriv->id, ptr);
302 
303  doRequestUpdate();
304 
306 
307  return true;
308 }
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
QHash< QString, QNetworkConfigurationPrivatePointer > userChoiceConfigurations
QNetworkConfiguration::StateFlags state
bool isValid() const
Returns true if this is a valid reference to a remote object.
QDBusServiceWatcher * m_icdServiceWatcher
Definition: qicdengine.h:169
#define SLOT(a)
Definition: qobjectdefs.h:226
void icdServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner)
Definition: qicdengine.cpp:967
The QDBusInterface class is a proxy for interfaces on remote objects.
static QDBusConnection systemBus()
Returns a QDBusConnection object opened with the system bus.
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
const T * ptr(const T &t)
QDBusInterface * m_dbusInterface
Definition: qicdengine.h:163
QTimer m_scanTimer
Definition: qicdengine.h:164
IapMonitor * iapMonitor
Definition: qicdengine.h:162
QNetworkConfiguration::Purpose purpose
void finishAsyncConfigurationUpdate()
QNetworkConfiguration::Type type
void startListeningStateSignalsForAllConnections()
Definition: qicdengine.cpp:829
void setup(QIcdEngine *d)
Definition: qicdengine.cpp:192
The QDBusServiceWatcher class allows the user to watch for a bus service change.
void doRequestUpdate(QList< Maemo::IcdScanResult > scanned=QList< Maemo::IcdScanResult >())
Definition: qicdengine.cpp:563
void getIcdInitialState()
Definition: qicdengine.cpp:839

◆ finishAsyncConfigurationUpdate

void QIcdEngine::finishAsyncConfigurationUpdate ( )
privateslot

Definition at line 1055 of file qicdengine.cpp.

Referenced by asyncUpdateConfigurationsSlot(), and ensureDBusConnection().

1056 {
1057  QMutexLocker locker(&mutex);
1058 
1061  m_scanResult.clear();
1062 }
QList< Maemo::IcdScanResult > m_scanResult
Definition: qicdengine.h:167
void clear()
Removes all items from the list.
Definition: qlist.h:764
void cancelAsyncConfigurationUpdate()
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
void doRequestUpdate(QList< Maemo::IcdScanResult > scanned=QList< Maemo::IcdScanResult >())
Definition: qicdengine.cpp:563

◆ getIcdInitialState()

void QIcdEngine::getIcdInitialState ( )
private

Definition at line 839 of file qicdengine.cpp.

Referenced by ensureDBusConnection().

840 {
841  /* Instead of requesting ICD status asynchronously, we ask it synchronously.
842  * It ensures that we always get right icd status BEFORE initialize() ends.
843  * If not, initialize() might end before we got icd status and
844  * QNetworkConfigurationManager::updateConfigurations()
845  * call from user might also end before receiving icd status.
846  * In such case, we come up to a bug:
847  * QNetworkConfigurationManagerPrivate::isOnline() will be false even
848  * if we are connected.
849  */
850  Maemo::Icd icd;
851  QList<Maemo::IcdStateResult> state_results;
853 
854  if (icd.state(state_results) && !state_results.isEmpty()) {
855 
856  if (!(state_results.first().params.network_attrs == 0 &&
857  state_results.first().params.network_id.isEmpty())) {
858 
859  switch (state_results.first().state) {
860  case ICD_STATE_CONNECTED:
861  m_onlineIapId = state_results.first().params.network_id;
862 
864  if (ptr) {
865  QMutexLocker configLocker(&ptr->mutex);
867  configLocker.unlock();
868 
869  mutex.unlock();
871  mutex.lock();
872  }
873  break;
874  default:
875  break;
876  }
877  }
878  }
879 }
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QNetworkConfiguration::StateFlags state
void configurationChanged(QNetworkConfigurationPrivatePointer config)
QByteArray network_id
Definition: maemo_icd.h:72
QString m_onlineIapId
Definition: qicdengine.h:165
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
#define emit
Definition: qobjectdefs.h:76
const T * ptr(const T &t)
struct CommonParams params
Definition: maemo_icd.h:95
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
uint state(QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdStateResult &state_result)
Definition: maemo_icd.cpp:798
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ hasIdentifier()

bool QIcdEngine::hasIdentifier ( const QString id)
virtual

Implements QBearerEngine.

Definition at line 1109 of file qicdengine.cpp.

Referenced by QNetworkSessionPrivateImpl::stateChange(), and QNetworkSessionPrivateImpl::syncStateWithInterface().

1110 {
1111  QMutexLocker locker(&mutex);
1112 
1113  return accessPointConfigurations.contains(id) ||
1114  snapConfigurations.contains(id) ||
1115  userChoiceConfigurations.contains(id);
1116 }
QHash< QString, QNetworkConfigurationPrivatePointer > userChoiceConfigurations
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
QHash< QString, QNetworkConfigurationPrivatePointer > snapConfigurations
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ iapStateChanged

void QIcdEngine::iapStateChanged ( const QString iapid,
uint  icd_connection_state 
)
signal

◆ icdServiceOwnerChanged

void QIcdEngine::icdServiceOwnerChanged ( const QString serviceName,
const QString oldOwner,
const QString newOwner 
)
privateslot

Definition at line 967 of file qicdengine.cpp.

Referenced by ensureDBusConnection().

969 {
970  Q_UNUSED(serviceName);
971  Q_UNUSED(oldOwner);
972 
973  QMutexLocker locker(&mutex);
974 
975  if (newOwner.isEmpty()) {
976  // Disconnected from ICD, remove all configurations
977  cleanup();
978  delete iapMonitor;
979  iapMonitor = 0;
980  delete m_dbusInterface;
981  m_dbusInterface = 0;
982 
983  QMutableHashIterator<QString, QNetworkConfigurationPrivatePointer> i(accessPointConfigurations);
984  while (i.hasNext()) {
985  i.next();
986 
988  i.remove();
989 
990  locker.unlock();
992  locker.relock();
993  }
994 
995  userChoiceConfigurations.clear();
996  } else {
997  // Connected to ICD ensure connection.
999  }
1000 }
QHash< QString, QNetworkConfigurationPrivatePointer > userChoiceConfigurations
bool ensureDBusConnection()
Definition: qicdengine.cpp:251
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define emit
Definition: qobjectdefs.h:76
void cleanup()
const T * ptr(const T &t)
QDBusInterface * m_dbusInterface
Definition: qicdengine.h:163
IapMonitor * iapMonitor
Definition: qicdengine.h:162
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
void configurationRemoved(QNetworkConfigurationPrivatePointer config)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ initialize()

void QIcdEngine::initialize ( )

Definition at line 310 of file qicdengine.cpp.

311 {
312  QMutexLocker locker(&mutex);
313 
314  if (!ensureDBusConnection()) {
315  locker.unlock();
317  locker.relock();
318  }
319 }
void updateCompleted()
bool ensureDBusConnection()
Definition: qicdengine.cpp:251
#define emit
Definition: qobjectdefs.h:76
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ requestUpdate()

void QIcdEngine::requestUpdate ( )

Definition at line 1002 of file qicdengine.cpp.

1003 {
1004  QMutexLocker locker(&mutex);
1005 
1006  if (!ensureDBusConnection()) {
1007  locker.unlock();
1009  locker.relock();
1010  return;
1011  }
1012 
1013  if (m_scanGoingOn)
1014  return;
1015 
1016  m_scanGoingOn = true;
1017 
1018  m_dbusInterface->connection().connect(ICD_DBUS_API_INTERFACE,
1019  ICD_DBUS_API_PATH,
1020  ICD_DBUS_API_INTERFACE,
1021  ICD_DBUS_API_SCAN_SIG,
1023 
1024  QDBusMessage msg = m_dbusInterface->call(ICD_DBUS_API_SCAN_REQ,
1025  (uint)ICD_SCAN_REQUEST_ACTIVE);
1028 }
void asyncUpdateConfigurationsSlot(QDBusMessage msg)
QDBusConnection connection() const
Returns the connection this interface is assocated with.
#define SLOT(a)
Definition: qobjectdefs.h:226
void updateCompleted()
bool ensureDBusConnection()
Definition: qicdengine.cpp:251
QList< QVariant > arguments() const
Returns the list of arguments that are going to be sent or were received from D-Bus.
#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
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
QDBusInterface * m_dbusInterface
Definition: qicdengine.h:163
QTimer m_scanTimer
Definition: qicdengine.h:164
#define ICD_SHORT_SCAN_TIMEOUT
Definition: maemo_icd.h:60
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
Connects the signal specified by the service, path, interface and name parameters to the slot slot in...
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
bool m_scanGoingOn
Definition: qicdengine.h:172
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition: qtimer.cpp:249
QDBusMessage call(const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
Calls the method method on this interface and passes the parameters to this function to the method...

◆ startListeningStateSignalsForAllConnections()

void QIcdEngine::startListeningStateSignalsForAllConnections ( )
private

Definition at line 829 of file qicdengine.cpp.

Referenced by ensureDBusConnection().

830 {
831  // Start listening ICD_DBUS_API_STATE_SIG signals
832  m_dbusInterface->connection().connect(ICD_DBUS_API_INTERFACE,
833  ICD_DBUS_API_PATH,
834  ICD_DBUS_API_INTERFACE,
835  ICD_DBUS_API_STATE_SIG,
837 }
QDBusConnection connection() const
Returns the connection this interface is assocated with.
#define SLOT(a)
Definition: qobjectdefs.h:226
void connectionStateSignalsSlot(QDBusMessage msg)
Definition: qicdengine.cpp:881
QDBusInterface * m_dbusInterface
Definition: qicdengine.h:163
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
Connects the signal specified by the service, path, interface and name parameters to the slot slot in...
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59

Properties

◆ firstUpdate

bool QIcdEngine::firstUpdate
private

Definition at line 171 of file qicdengine.h.

Referenced by doRequestUpdate().

◆ iapMonitor

IapMonitor* QIcdEngine::iapMonitor
private

Definition at line 162 of file qicdengine.h.

Referenced by cleanup(), ensureDBusConnection(), icdServiceOwnerChanged(), and ~QIcdEngine().

◆ m_dbusInterface

QDBusInterface* QIcdEngine::m_dbusInterface
private

◆ m_icdServiceWatcher

QDBusServiceWatcher* QIcdEngine::m_icdServiceWatcher
private

Definition at line 169 of file qicdengine.h.

Referenced by ensureDBusConnection().

◆ m_onlineIapId

QString QIcdEngine::m_onlineIapId
private

Definition at line 165 of file qicdengine.h.

Referenced by addConfiguration(), connectionStateSignalsSlot(), and getIcdInitialState().

◆ m_scanGoingOn

bool QIcdEngine::m_scanGoingOn
private

Definition at line 172 of file qicdengine.h.

Referenced by cancelAsyncConfigurationUpdate(), cleanup(), and requestUpdate().

◆ m_scanResult

QList<Maemo::IcdScanResult> QIcdEngine::m_scanResult
private

Definition at line 167 of file qicdengine.h.

Referenced by asyncUpdateConfigurationsSlot(), and finishAsyncConfigurationUpdate().

◆ m_scanTimer

QTimer QIcdEngine::m_scanTimer
private

◆ m_typesToBeScanned

QStringList QIcdEngine::m_typesToBeScanned
private

Definition at line 166 of file qicdengine.h.

Referenced by asyncUpdateConfigurationsSlot(), and requestUpdate().


The documentation for this class was generated from the following files: