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

#include <qnetworkmanagerengine.h>

Inheritance diagram for QNetworkManagerEngine:
QBearerEngineImpl QBearerEngine QObject

Public Functions

quint64 bytesReceived (const QString &id)
 
quint64 bytesWritten (const QString &id)
 
QNetworkConfigurationManager::Capabilities capabilities () const
 
void connectToId (const QString &id)
 
QNetworkSessionPrivatecreateSessionBackend ()
 
QNetworkConfigurationPrivatePointer defaultConfiguration ()
 
void disconnectFromId (const QString &id)
 
QString getInterfaceFromId (const QString &id)
 
bool hasIdentifier (const QString &id)
 
Q_INVOKABLE void initialize ()
 
bool networkManagerAvailable () const
 
 QNetworkManagerEngine (QObject *parent=0)
 
Q_INVOKABLE void requestUpdate ()
 
QNetworkSession::State sessionStateForId (const QString &id)
 
quint64 startTime (const QString &id)
 
 ~QNetworkManagerEngine ()
 
- Public Functions inherited from QBearerEngineImpl
 QBearerEngineImpl (QObject *parent=0)
 
 ~QBearerEngineImpl ()
 
- 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 activationFinished (QDBusPendingCallWatcher *watcher)
 
void activeConnectionPropertiesChanged (const QString &path, const QMap< QString, QVariant > &properties)
 
void deviceAdded (const QDBusObjectPath &path)
 
void devicePropertiesChanged (const QString &path, const QMap< QString, QVariant > &properties)
 
void deviceRemoved (const QDBusObjectPath &path)
 
void interfacePropertiesChanged (const QString &path, const QMap< QString, QVariant > &properties)
 
void newAccessPoint (const QString &path, const QDBusObjectPath &objectPath)
 
void newConnection (const QDBusObjectPath &path, QNetworkManagerSettings *settings=0)
 
void removeAccessPoint (const QString &path, const QDBusObjectPath &objectPath)
 
void removeConnection (const QString &path)
 
void updateAccessPoint (const QMap< QString, QVariant > &map)
 
void updateConnection (const QNmSettingsMap &settings)
 

Private Functions

QNetworkManagerSettingsConnectionconnectionFromId (const QString &id) const
 
QNetworkConfigurationPrivateparseConnection (const QString &service, const QString &settingsPath, const QNmSettingsMap &map)
 

Properties

QList< QNetworkManagerInterfaceAccessPoint * > accessPoints
 
QHash< QString, QNetworkManagerConnectionActive * > activeConnections
 
QList< QNetworkManagerInterfaceAccessPoint * > configuredAccessPoints
 
QList< QNetworkManagerSettingsConnection * > connections
 
QNetworkManagerInterfaceinterface
 
QNetworkManagerSettingssystemSettings
 
QNetworkManagerSettingsuserSettings
 
QHash< QString, QNetworkManagerInterfaceDeviceWireless * > wirelessDevices
 

Additional Inherited Members

- Public Types inherited from QBearerEngineImpl
enum  ConnectionError { InterfaceLookupError = 0, ConnectError, OperationNotSupported, DisconnectionError }
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QBearerEngineImpl
void connectionError (const QString &id, QBearerEngineImpl::ConnectionError error)
 
- 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...
 
- 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 68 of file qnetworkmanagerengine.h.

Constructors and Destructors

◆ QNetworkManagerEngine()

QNetworkManagerEngine::QNetworkManagerEngine ( QObject parent = 0)

Definition at line 64 of file qnetworkmanagerengine.cpp.

65 : QBearerEngineImpl(parent),
69 {
70  if (!interface->isValid())
71  return;
72 
78 #if 0
79  connect(interface, SIGNAL(stateChanged(const QString,quint32)),
80  this, SIGNAL(configurationsChanged()));
81 #endif
86 
87  qDBusRegisterMetaType<QNmSettingsMap>();
88 
92 
96 }
QNetworkManagerInterface * interface
void deviceRemoved(const QDBusObjectPath &path)
QBearerEngineImpl(QObject *parent=0)
#define SLOT(a)
Definition: qobjectdefs.h:226
#define NM_DBUS_SERVICE_SYSTEM_SETTINGS
The QDBusPendingCallWatcher class provides a convenient way for waiting for asynchronous replies...
The QString class provides a Unicode character string.
Definition: qstring.h:83
void activationFinished(QDBusPendingCallWatcher *watcher)
void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings=0)
QNetworkManagerSettings * systemSettings
#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
void interfacePropertiesChanged(const QString &path, const QMap< QString, QVariant > &properties)
void deviceAdded(const QDBusObjectPath &path)
#define NM_DBUS_SERVICE_USER_SETTINGS
QNetworkManagerSettings * userSettings
unsigned int quint32
Definition: qglobal.h:938
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...

◆ ~QNetworkManagerEngine()

QNetworkManagerEngine::~QNetworkManagerEngine ( )

Definition at line 98 of file qnetworkmanagerengine.cpp.

99 {
104 }
QHash< QString, QNetworkManagerConnectionActive * > activeConnections
QList< QNetworkManagerInterfaceAccessPoint * > accessPoints
QHash< QString, QNetworkManagerInterfaceDeviceWireless * > wirelessDevices
QList< QNetworkManagerSettingsConnection * > connections
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

Functions

◆ activationFinished

void QNetworkManagerEngine::activationFinished ( QDBusPendingCallWatcher watcher)
privateslot

Definition at line 515 of file qnetworkmanagerengine.cpp.

Referenced by QNetworkManagerEngine().

516 {
517  QMutexLocker locker(&mutex);
518 
519  QDBusPendingReply<QDBusObjectPath> reply = *watcher;
520  if (!reply.isError()) {
521  QDBusObjectPath result = reply.value();
522 
523  QNetworkManagerConnectionActive activeConnection(result.path());
524 
525  const QString id = QString::number(qHash(activeConnection.serviceName() + ' ' +
526  activeConnection.connection().path()));
527 
529  if (ptr) {
530  ptr->mutex.lock();
531  if (activeConnection.state() == 2 &&
534  ptr->mutex.unlock();
535 
536  locker.unlock();
538  locker.relock();
539  } else {
540  ptr->mutex.unlock();
541  }
542  }
543  }
544 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QNetworkConfiguration::StateFlags state
void configurationChanged(QNetworkConfigurationPrivatePointer config)
T1 value() const
Returns the first argument in this reply, cast to type T1 (the first template parameter of this class...
bool isError() const
Returns true if the reply contains an error message, false if it contains a normal method reply...
The QString class provides a Unicode character string.
Definition: qstring.h:83
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
#define emit
Definition: qobjectdefs.h:76
QString path() const
Returns this object path.
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
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
The QDBusPendingReply class contains the reply to an asynchronous method call.

◆ activeConnectionPropertiesChanged

void QNetworkManagerEngine::activeConnectionPropertiesChanged ( const QString path,
const QMap< QString, QVariant > &  properties 
)
privateslot

Definition at line 334 of file qnetworkmanagerengine.cpp.

Referenced by initialize(), and interfacePropertiesChanged().

336 {
337  QMutexLocker locker(&mutex);
338 
339  Q_UNUSED(properties)
340 
341  QNetworkManagerConnectionActive *activeConnection = activeConnections.value(path);
342 
343  if (!activeConnection)
344  return;
345 
346  const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' +
347  activeConnection->connection().path()));
348 
350  if (ptr) {
351  ptr->mutex.lock();
352  if (activeConnection->state() == 2 &&
355  ptr->mutex.unlock();
356 
357  locker.unlock();
359  locker.relock();
360  } else {
361  ptr->mutex.unlock();
362  }
363  }
364 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QNetworkConfiguration::StateFlags state
void configurationChanged(QNetworkConfigurationPrivatePointer config)
QHash< QString, QNetworkManagerConnectionActive * > activeConnections
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
#define emit
Definition: qobjectdefs.h:76
QString path() const
Returns this object path.
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
#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

◆ bytesReceived()

quint64 QNetworkManagerEngine::bytesReceived ( const QString id)
virtual

Reimplemented from QBearerEngineImpl.

Definition at line 853 of file qnetworkmanagerengine.cpp.

854 {
855  QMutexLocker locker(&mutex);
856 
859  const QString networkInterface = getInterfaceFromId(id);
860  if (!networkInterface.isEmpty()) {
861  const QString devFile = QLatin1String("/sys/class/net/") +
862  networkInterface +
863  QLatin1String("/statistics/rx_bytes");
864 
865  quint64 result = Q_UINT64_C(0);
866 
867  QFile tx(devFile);
868  if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
869  QTextStream in(&tx);
870  in >> result;
871  tx.close();
872  }
873 
874  return result;
875  }
876  }
877 
878  return Q_UINT64_C(0);
879 }
QString getInterfaceFromId(const QString &id)
QNetworkConfiguration::StateFlags state
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
unsigned __int64 quint64
Definition: qglobal.h:943
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T * ptr(const T &t)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
The QTextStream class provides a convenient interface for reading and writing text.
Definition: qtextstream.h:73
#define Q_UINT64_C(c)
Definition: qglobal.h:941

◆ bytesWritten()

quint64 QNetworkManagerEngine::bytesWritten ( const QString id)
virtual

Reimplemented from QBearerEngineImpl.

Definition at line 825 of file qnetworkmanagerengine.cpp.

826 {
827  QMutexLocker locker(&mutex);
828 
831  const QString networkInterface = getInterfaceFromId(id);
832  if (!networkInterface.isEmpty()) {
833  const QString devFile = QLatin1String("/sys/class/net/") +
834  networkInterface +
835  QLatin1String("/statistics/tx_bytes");
836 
837  quint64 result = Q_UINT64_C(0);
838 
839  QFile tx(devFile);
840  if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
841  QTextStream in(&tx);
842  in >> result;
843  tx.close();
844  }
845 
846  return result;
847  }
848  }
849 
850  return Q_UINT64_C(0);
851 }
QString getInterfaceFromId(const QString &id)
QNetworkConfiguration::StateFlags state
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
unsigned __int64 quint64
Definition: qglobal.h:943
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T * ptr(const T &t)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
The QTextStream class provides a convenient interface for reading and writing text.
Definition: qtextstream.h:73
#define Q_UINT64_C(c)
Definition: qglobal.h:941

◆ capabilities()

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

◆ connectionFromId()

QNetworkManagerSettingsConnection * QNetworkManagerEngine::connectionFromId ( const QString id) const
private

Definition at line 769 of file qnetworkmanagerengine.cpp.

Referenced by connectToId(), hasIdentifier(), and startTime().

770 {
771  for (int i = 0; i < connections.count(); ++i) {
773  const QString service = connection->connectionInterface()->service();
774  const QString settingsPath = connection->connectionInterface()->path();
775 
776  const QString identifier = QString::number(qHash(service + ' ' + settingsPath));
777 
778  if (id == identifier)
779  return connection;
780  }
781 
782  return 0;
783 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
QString path() const
Returns the object path that this interface is associated with.
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
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDBusInterface * connectionInterface() const
QList< QNetworkManagerSettingsConnection * > connections
QString service() const
Returns the name of the service this interface is associated with.

◆ connectToId()

void QNetworkManagerEngine::connectToId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 192 of file qnetworkmanagerengine.cpp.

193 {
194  QMutexLocker locker(&mutex);
195 
197 
198  if (!connection)
199  return;
200 
201  QNmSettingsMap map = connection->getSettings();
202  const QString connectionType = map.value("connection").value("type").toString();
203 
204  QString dbusDevicePath;
205  foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
206  QNetworkManagerInterfaceDevice device(devicePath.path());
207  if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET &&
208  connectionType == QLatin1String("802-3-ethernet")) {
209  dbusDevicePath = devicePath.path();
210  break;
211  } else if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS &&
212  connectionType == QLatin1String("802-11-wireless")) {
213  dbusDevicePath = devicePath.path();
214  break;
215  }
216  else if (device.deviceType() == DEVICE_TYPE_GSM &&
217  connectionType == QLatin1String("gsm")) {
218  dbusDevicePath = devicePath.path();
219  break;
220  }
221  }
222 
223  const QString service = connection->connectionInterface()->service();
224  const QString settingsPath = connection->connectionInterface()->path();
225 
226  interface->activateConnection(service, QDBusObjectPath(settingsPath),
227  QDBusObjectPath(dbusDevicePath), QDBusObjectPath("/"));
228 }
QNetworkManagerInterface * interface
QString path() const
Returns the object path that this interface is associated with.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
void activateConnection(const QString &serviceName, QDBusObjectPath connection, QDBusObjectPath device, QDBusObjectPath specificObject)
QString path() const
Returns this object path.
QList< QDBusObjectPath > getDevices() const
QDBusInterface * connectionInterface() const
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
QString service() const
Returns the name of the service this interface is associated with.
QNetworkManagerSettingsConnection * connectionFromId(const QString &id) const

◆ createSessionBackend()

QNetworkSessionPrivate * QNetworkManagerEngine::createSessionBackend ( )
virtual

Implements QBearerEngine.

Definition at line 898 of file qnetworkmanagerengine.cpp.

◆ defaultConfiguration()

QNetworkConfigurationPrivatePointer QNetworkManagerEngine::defaultConfiguration ( )
virtual

Implements QBearerEngine.

Definition at line 903 of file qnetworkmanagerengine.cpp.

904 {
906 }
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > QNetworkConfigurationPrivatePointer

◆ deviceAdded

void QNetworkManagerEngine::deviceAdded ( const QDBusObjectPath path)
privateslot

Definition at line 373 of file qnetworkmanagerengine.cpp.

Referenced by initialize(), and QNetworkManagerEngine().

374 {
375  QNetworkManagerInterfaceDevice device(path.path());
376  if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
378  new QNetworkManagerInterfaceDeviceWireless(device.connectionInterface()->path());
379 
380  wirelessDevice->setConnections();
381  connect(wirelessDevice, SIGNAL(accessPointAdded(QString,QDBusObjectPath)),
383  connect(wirelessDevice, SIGNAL(accessPointRemoved(QString,QDBusObjectPath)),
385  connect(wirelessDevice, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
387 
388  foreach (const QDBusObjectPath &apPath, wirelessDevice->getAccessPoints())
389  newAccessPoint(QString(), apPath);
390 
391  mutex.lock();
392  wirelessDevices.insert(path.path(), wirelessDevice);
393  mutex.unlock();
394  }
395 }
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
QHash< QString, QNetworkManagerInterfaceDeviceWireless * > wirelessDevices
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#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
QString path() const
Returns this object path.
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
void devicePropertiesChanged(const QString &path, const QMap< QString, QVariant > &properties)
void newAccessPoint(const QString &path, const QDBusObjectPath &objectPath)
void removeAccessPoint(const QString &path, const QDBusObjectPath &objectPath)

◆ devicePropertiesChanged

void QNetworkManagerEngine::devicePropertiesChanged ( const QString path,
const QMap< QString, QVariant > &  properties 
)
privateslot

Definition at line 366 of file qnetworkmanagerengine.cpp.

Referenced by deviceAdded().

368 {
369  Q_UNUSED(path);
370  Q_UNUSED(properties);
371 }
#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

◆ deviceRemoved

void QNetworkManagerEngine::deviceRemoved ( const QDBusObjectPath path)
privateslot

Definition at line 397 of file qnetworkmanagerengine.cpp.

Referenced by QNetworkManagerEngine().

398 {
399  QMutexLocker locker(&mutex);
400 
401  delete wirelessDevices.take(path.path());
402 }
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it...
Definition: qhash.h:807
QHash< QString, QNetworkManagerInterfaceDeviceWireless * > wirelessDevices
QString path() const
Returns this object path.
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ disconnectFromId()

void QNetworkManagerEngine::disconnectFromId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 230 of file qnetworkmanagerengine.cpp.

231 {
232  QMutexLocker locker(&mutex);
233 
234  foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
235  QNetworkManagerConnectionActive activeConnection(acPath.path());
236 
237  const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' +
238  activeConnection.connection().path()));
239 
240  if (id == identifier && accessPointConfigurations.contains(id)) {
242  break;
243  }
244  }
245 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QList< QDBusObjectPath > activeConnections() const
QNetworkManagerInterface * interface
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
The QString class provides a Unicode character string.
Definition: qstring.h:83
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
QString path() const
Returns this object path.
void deactivateConnection(QDBusObjectPath connectionPath) const
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...

◆ getInterfaceFromId()

QString QNetworkManagerEngine::getInterfaceFromId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 148 of file qnetworkmanagerengine.cpp.

Referenced by bytesReceived(), and bytesWritten().

149 {
150  QMutexLocker locker(&mutex);
151 
152  foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
153  QNetworkManagerConnectionActive activeConnection(acPath.path());
154 
155  const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' +
156  activeConnection.connection().path()));
157 
158  if (id == identifier) {
159  QList<QDBusObjectPath> devices = activeConnection.devices();
160 
161  if (devices.isEmpty())
162  continue;
163 
164  QNetworkManagerInterfaceDevice device(devices.at(0).path());
165  return device.networkInterface();
166  }
167  }
168 
169  return QString();
170 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QList< QDBusObjectPath > activeConnections() const
QNetworkManagerInterface * interface
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QString path() const
Returns this object path.
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ hasIdentifier()

bool QNetworkManagerEngine::hasIdentifier ( const QString id)
virtual

Implements QBearerEngine.

Definition at line 172 of file qnetworkmanagerengine.cpp.

173 {
174  QMutexLocker locker(&mutex);
175 
176  if (connectionFromId(id))
177  return true;
178 
179  for (int i = 0; i < accessPoints.count(); ++i) {
181 
182  const QString identifier =
183  QString::number(qHash(accessPoint->connectionInterface()->path()));
184 
185  if (id == identifier)
186  return true;
187  }
188 
189  return false;
190 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
QString path() const
Returns the object path that this interface is associated with.
QList< QNetworkManagerInterfaceAccessPoint * > accessPoints
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
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QNetworkManagerSettingsConnection * connectionFromId(const QString &id) const

◆ initialize()

void QNetworkManagerEngine::initialize ( )

Definition at line 106 of file qnetworkmanagerengine.cpp.

107 {
108  QMutexLocker locker(&mutex);
109 
110  // Get current list of access points.
111  foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
112  locker.unlock();
113  deviceAdded(devicePath);
114  locker.relock();
115  }
116 
117  // Get connections.
118  foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) {
119  locker.unlock();
120  newConnection(settingsPath, systemSettings);
121  locker.relock();
122  }
123  foreach (const QDBusObjectPath &settingsPath, userSettings->listConnections()) {
124  locker.unlock();
125  newConnection(settingsPath, userSettings);
126  locker.relock();
127  }
128 
129  // Get active connections.
130  foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
131  QNetworkManagerConnectionActive *activeConnection =
133  activeConnections.insert(acPath.path(), activeConnection);
134 
135  activeConnection->setConnections();
136  connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
138  }
139 }
QList< QDBusObjectPath > activeConnections() const
QNetworkManagerInterface * interface
QHash< QString, QNetworkManagerConnectionActive * > activeConnections
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings=0)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QNetworkManagerSettings * systemSettings
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QList< QDBusObjectPath > listConnections()
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
void activeConnectionPropertiesChanged(const QString &path, const QMap< QString, QVariant > &properties)
QString path() const
Returns this object path.
QList< QDBusObjectPath > getDevices() const
void deviceAdded(const QDBusObjectPath &path)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QNetworkManagerSettings * userSettings
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...

◆ interfacePropertiesChanged

void QNetworkManagerEngine::interfacePropertiesChanged ( const QString path,
const QMap< QString, QVariant > &  properties 
)
privateslot

Definition at line 252 of file qnetworkmanagerengine.cpp.

Referenced by QNetworkManagerEngine().

254 {
255  QMutexLocker locker(&mutex);
256 
257  Q_UNUSED(path)
258 
259  QMapIterator<QString, QVariant> i(properties);
260  while (i.hasNext()) {
261  i.next();
262 
263  if (i.key() == QLatin1String("ActiveConnections")) {
264  // Active connections changed, update configurations.
265 
267  qdbus_cast<QList<QDBusObjectPath> >(i.value().value<QDBusArgument>());
268 
269  QStringList identifiers = accessPointConfigurations.keys();
270  foreach (const QString &id, identifiers)
272 
273  QStringList priorActiveConnections = this->activeConnections.keys();
274 
275  foreach (const QDBusObjectPath &acPath, activeConnections) {
276  priorActiveConnections.removeOne(acPath.path());
277  QNetworkManagerConnectionActive *activeConnection =
278  this->activeConnections.value(acPath.path());
279  if (!activeConnection) {
280  activeConnection = new QNetworkManagerConnectionActive(acPath.path());
281  this->activeConnections.insert(acPath.path(), activeConnection);
282 
283  activeConnection->setConnections();
284  connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
286  }
287 
288  const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' +
289  activeConnection->connection().path()));
290 
291  identifiers.removeOne(id);
292 
294  if (ptr) {
295  ptr->mutex.lock();
296  if (activeConnection->state() == 2 &&
299  ptr->mutex.unlock();
300 
301  locker.unlock();
303  locker.relock();
304  } else {
305  ptr->mutex.unlock();
306  }
307  }
308  }
309 
310  while (!priorActiveConnections.isEmpty())
311  delete this->activeConnections.take(priorActiveConnections.takeFirst());
312 
313  while (!identifiers.isEmpty()) {
314  // These configurations are not active
316  accessPointConfigurations.value(identifiers.takeFirst());
317 
318  ptr->mutex.lock();
321  ptr->mutex.unlock();
322 
323  locker.unlock();
325  locker.relock();
326  } else {
327  ptr->mutex.unlock();
328  }
329  }
330  }
331  }
332 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
T qdbus_cast(const QDBusArgument &arg)
QNetworkConfiguration::StateFlags state
The QDBusArgument class is used to marshall and demarshall D-Bus arguments.
Definition: qdbusargument.h:69
void configurationChanged(QNetworkConfigurationPrivatePointer config)
QHash< QString, QNetworkManagerConnectionActive * > activeConnections
#define SLOT(a)
Definition: qobjectdefs.h:226
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
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
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
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
void activeConnectionPropertiesChanged(const QString &path, const QMap< QString, QVariant > &properties)
#define emit
Definition: qobjectdefs.h:76
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QString path() const
Returns this object path.
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
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
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
#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
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ networkManagerAvailable()

bool QNetworkManagerEngine::networkManagerAvailable ( ) const

Definition at line 141 of file qnetworkmanagerengine.cpp.

Referenced by QNetworkManagerEnginePlugin::create().

142 {
143  QMutexLocker locker(&mutex);
144 
145  return interface->isValid();
146 }
QNetworkManagerInterface * interface
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ newAccessPoint

void QNetworkManagerEngine::newAccessPoint ( const QString path,
const QDBusObjectPath objectPath 
)
privateslot

Definition at line 546 of file qnetworkmanagerengine.cpp.

Referenced by deviceAdded().

547 {
548  QMutexLocker locker(&mutex);
549 
550  Q_UNUSED(path)
551 
553  new QNetworkManagerInterfaceAccessPoint(objectPath.path());
554  accessPoints.append(accessPoint);
555 
556  accessPoint->setConnections();
557  connect(accessPoint, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
559 
560  // Check if configuration for this SSID already exists.
561  for (int i = 0; i < accessPoints.count(); ++i) {
562  if (accessPoint != accessPoints.at(i) &&
563  accessPoint->ssid() == accessPoints.at(i)->ssid()) {
564  return;
565  }
566  }
567 
568  // Check if configuration exists for connection.
569  if (!accessPoint->ssid().isEmpty()) {
570  for (int i = 0; i < connections.count(); ++i) {
572 
573  if (accessPoint->ssid() == connection->getSsid()) {
574  const QString service = connection->connectionInterface()->service();
575  const QString settingsPath = connection->connectionInterface()->path();
576  const QString connectionId = QString::number(qHash(service + ' ' + settingsPath));
577 
579  accessPointConfigurations.value(connectionId);
580  ptr->mutex.lock();
582  ptr->mutex.unlock();
583 
584  locker.unlock();
586  return;
587  }
588  }
589  }
590 
591  // New access point.
593 
594  ptr->name = accessPoint->ssid();
595  ptr->isValid = true;
596  ptr->id = QString::number(qHash(objectPath.path()));
598  if(accessPoint->flags() == NM_802_11_AP_FLAGS_PRIVACY) {
600  } else {
602  }
605 
606  accessPointConfigurations.insert(ptr->id, ptr);
607 
608  locker.unlock();
610 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QString path() const
Returns the object path that this interface is associated with.
QNetworkConfiguration::StateFlags state
void configurationChanged(QNetworkConfigurationPrivatePointer config)
#define SLOT(a)
Definition: qobjectdefs.h:226
QList< QNetworkManagerInterfaceAccessPoint * > accessPoints
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
QNetworkConfiguration::BearerType bearerType
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void updateAccessPoint(const QMap< QString, QVariant > &map)
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
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
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
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)
QString path() const
Returns this object path.
const T * ptr(const T &t)
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
QDBusInterface * connectionInterface() const
QList< QNetworkManagerSettingsConnection * > connections
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QNetworkConfiguration::Purpose purpose
QNetworkConfiguration::Type type
QString service() const
Returns the name of the service this interface is associated with.
#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
#define NM_802_11_AP_FLAGS_PRIVACY

◆ newConnection

void QNetworkManagerEngine::newConnection ( const QDBusObjectPath path,
QNetworkManagerSettings settings = 0 
)
privateslot

Definition at line 404 of file qnetworkmanagerengine.cpp.

Referenced by initialize(), and QNetworkManagerEngine().

406 {
407  QMutexLocker locker(&mutex);
408 
409  if (!settings)
411 
412  if (!settings)
413  return;
414 
417  path.path());
418  connections.append(connection);
419 
420  connect(connection, SIGNAL(removed(QString)), this, SLOT(removeConnection(QString)));
421  connect(connection, SIGNAL(updated(const QNmSettingsMap&)),
422  this, SLOT(updateConnection(const QNmSettingsMap&)));
423 
424  const QString service = connection->connectionInterface()->service();
425  const QString settingsPath = connection->connectionInterface()->path();
426 
428  parseConnection(service, settingsPath, connection->getSettings());
429 
430  // Check if connection is active.
431  foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
432  QNetworkManagerConnectionActive activeConnection(acPath.path());
433 
434  if (activeConnection.serviceName() == service &&
435  activeConnection.connection().path() == settingsPath &&
436  activeConnection.state() == 2) {
438  break;
439  }
440  }
441 
443  accessPointConfigurations.insert(ptr->id, ptr);
444 
445  locker.unlock();
447 }
QList< QDBusObjectPath > activeConnections() const
QNetworkManagerInterface * interface
QString path() const
Returns the object path that this interface is associated with.
QNetworkConfiguration::StateFlags state
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void updateConnection(const QNmSettingsMap &settings)
QDBusInterface * connectionInterface() const
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
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
#define emit
Definition: qobjectdefs.h:76
void configurationAdded(QNetworkConfigurationPrivatePointer config)
QString path() const
Returns this object path.
const T * ptr(const T &t)
QDBusInterface * connectionInterface() const
QList< QNetworkManagerSettingsConnection * > connections
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
void removeConnection(const QString &path)
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
QString service() const
Returns the name of the service this interface is associated with.
QNetworkConfigurationPrivate * parseConnection(const QString &service, const QString &settingsPath, const QNmSettingsMap &map)

◆ parseConnection()

QNetworkConfigurationPrivate * QNetworkManagerEngine::parseConnection ( const QString service,
const QString settingsPath,
const QNmSettingsMap map 
)
private

Definition at line 699 of file qnetworkmanagerengine.cpp.

Referenced by newConnection(), and updateConnection().

702 {
704  cpPriv->name = map.value("connection").value("id").toString();
705  cpPriv->isValid = true;
706  cpPriv->id = QString::number(qHash(service + ' ' + settingsPath));
708 
710 
712 
713  const QString connectionType = map.value("connection").value("type").toString();
714 
715  if (connectionType == QLatin1String("802-3-ethernet")) {
718 
719  foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
720  QNetworkManagerInterfaceDevice device(devicePath.path());
721  if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET) {
722  QNetworkManagerInterfaceDeviceWired wiredDevice(device.connectionInterface()->path());
723  if (wiredDevice.carrier()) {
725  break;
726  }
727 
728  }
729  }
730  } else if (connectionType == QLatin1String("802-11-wireless")) {
732 
733  const QString connectionSsid = map.value("802-11-wireless").value("ssid").toString();
734  const QString connectionSecurity = map.value("802-11-wireless").value("security").toString();
735  if(!connectionSecurity.isEmpty()) {
737  } else {
739  }
740  for (int i = 0; i < accessPoints.count(); ++i) {
741  if (connectionSsid == accessPoints.at(i)->ssid()) {
745 
746  const QString accessPointId =
749  accessPointConfigurations.take(accessPointId);
750 
751  if (ptr) {
752  mutex.unlock();
754  mutex.lock();
755  }
756  }
757  break;
758  }
759  }
760  } else if (connectionType == "gsm") {
762  } else if (connectionType == "cdma") {
764  }
765 
766  return cpPriv;
767 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QNetworkManagerInterface * interface
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QString path() const
Returns the object path that this interface is associated with.
QNetworkConfiguration::StateFlags state
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QList< QNetworkManagerInterfaceAccessPoint * > accessPoints
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
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
QNetworkConfiguration::BearerType bearerType
QList< QNetworkManagerInterfaceAccessPoint * > configuredAccessPoints
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
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
QString path() const
Returns this object path.
const T * ptr(const T &t)
QList< QDBusObjectPath > getDevices() const
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
QNetworkConfiguration::Purpose purpose
QNetworkConfiguration::Type type
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
void configurationRemoved(QNetworkConfigurationPrivatePointer config)

◆ removeAccessPoint

void QNetworkManagerEngine::removeAccessPoint ( const QString path,
const QDBusObjectPath objectPath 
)
privateslot

Definition at line 612 of file qnetworkmanagerengine.cpp.

Referenced by deviceAdded().

614 {
615  QMutexLocker locker(&mutex);
616 
617  Q_UNUSED(path)
618 
619  for (int i = 0; i < accessPoints.count(); ++i) {
621 
622  if (accessPoint->connectionInterface()->path() == objectPath.path()) {
623  accessPoints.removeOne(accessPoint);
624 
625  if (configuredAccessPoints.contains(accessPoint)) {
626  // find connection and change state to Defined
627  configuredAccessPoints.removeOne(accessPoint);
628  for (int i = 0; i < connections.count(); ++i) {
630 
631  if (accessPoint->ssid() == connection->getSsid()) {
632  const QString service = connection->connectionInterface()->service();
633  const QString settingsPath = connection->connectionInterface()->path();
634  const QString connectionId =
635  QString::number(qHash(service + ' ' + settingsPath));
636 
638  accessPointConfigurations.value(connectionId);
639  ptr->mutex.lock();
641  ptr->mutex.unlock();
642 
643  locker.unlock();
645  locker.relock();
646  break;
647  }
648  }
649  } else {
652 
653  if (ptr) {
654  locker.unlock();
656  locker.relock();
657  }
658  }
659 
660  delete accessPoint;
661 
662  break;
663  }
664  }
665 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QString path() const
Returns the object path that this interface is associated with.
QNetworkConfiguration::StateFlags state
void configurationChanged(QNetworkConfigurationPrivatePointer config)
QList< QNetworkManagerInterfaceAccessPoint * > accessPoints
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
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
QList< QNetworkManagerInterfaceAccessPoint * > configuredAccessPoints
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
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
QString path() const
Returns this object path.
const T * ptr(const T &t)
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
QDBusInterface * connectionInterface() const
QList< QNetworkManagerSettingsConnection * > connections
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
void configurationRemoved(QNetworkConfigurationPrivatePointer config)
QString service() const
Returns the name of the service this interface is associated with.
#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

◆ removeConnection

void QNetworkManagerEngine::removeConnection ( const QString path)
privateslot

Definition at line 449 of file qnetworkmanagerengine.cpp.

Referenced by newConnection().

450 {
451  QMutexLocker locker(&mutex);
452 
453  Q_UNUSED(path)
454 
457  if (!connection)
458  return;
459 
460  connections.removeAll(connection);
461 
462  const QString id = QString::number(qHash(connection->connectionInterface()->service() + ' ' +
463  connection->connectionInterface()->path()));
464 
466 
467  connection->deleteLater();
468 
469  locker.unlock();
471 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
QString path() const
Returns the object path that this interface is associated with.
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
#define emit
Definition: qobjectdefs.h:76
const T * ptr(const T &t)
QDBusInterface * connectionInterface() const
QList< QNetworkManagerSettingsConnection * > connections
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
void configurationRemoved(QNetworkConfigurationPrivatePointer config)
QString service() const
Returns the name of the service this interface is associated with.
#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
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770

◆ requestUpdate()

void QNetworkManagerEngine::requestUpdate ( )

Definition at line 247 of file qnetworkmanagerengine.cpp.

248 {
249  QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection);
250 }
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.

◆ sessionStateForId()

QNetworkSession::State QNetworkManagerEngine::sessionStateForId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 785 of file qnetworkmanagerengine.cpp.

786 {
787  QMutexLocker locker(&mutex);
788 
790 
791  if (!ptr)
793 
794  if (!ptr->isValid)
796 
797  foreach (const QString &acPath, activeConnections.keys()) {
798  QNetworkManagerConnectionActive *activeConnection = activeConnections.value(acPath);
799 
800  const QString identifier = QString::number(qHash(activeConnection->serviceName() + ' ' +
801  activeConnection->connection().path()));
802 
803  if (id == identifier) {
804  switch (activeConnection->state()) {
805  case 0:
807  case 1:
809  case 2:
811  }
812  }
813  }
814 
821 
823 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
QNetworkConfiguration::StateFlags state
QHash< QString, QNetworkManagerConnectionActive * > activeConnections
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
QString path() const
Returns this object path.
const T * ptr(const T &t)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
Definition: qhash.h:648

◆ startTime()

quint64 QNetworkManagerEngine::startTime ( const QString id)
virtual

Reimplemented from QBearerEngineImpl.

Definition at line 881 of file qnetworkmanagerengine.cpp.

882 {
883  QMutexLocker locker(&mutex);
884 
886  if (connection)
887  return connection->getTimestamp();
888  else
889  return Q_UINT64_C(0);
890 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
#define Q_UINT64_C(c)
Definition: qglobal.h:941
QNetworkManagerSettingsConnection * connectionFromId(const QString &id) const

◆ updateAccessPoint

void QNetworkManagerEngine::updateAccessPoint ( const QMap< QString, QVariant > &  map)
privateslot

Definition at line 667 of file qnetworkmanagerengine.cpp.

Referenced by newAccessPoint().

668 {
669  QMutexLocker locker(&mutex);
670 
671  Q_UNUSED(map)
672 
675  if (!accessPoint)
676  return;
677 
678  for (int i = 0; i < connections.count(); ++i) {
680 
681  if (accessPoint->ssid() == connection->getSsid()) {
682  const QString service = connection->connectionInterface()->service();
683  const QString settingsPath = connection->connectionInterface()->path();
684  const QString connectionId = QString::number(qHash(service + ' ' + settingsPath));
685 
687  accessPointConfigurations.value(connectionId);
688  ptr->mutex.lock();
690  ptr->mutex.unlock();
691 
692  locker.unlock();
694  return;
695  }
696  }
697 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QString path() const
Returns the object path that this interface is associated with.
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
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
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
const T * ptr(const T &t)
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
QDBusInterface * connectionInterface() const
QList< QNetworkManagerSettingsConnection * > connections
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QString service() const
Returns the name of the service this interface is associated with.
#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

◆ updateConnection

void QNetworkManagerEngine::updateConnection ( const QNmSettingsMap settings)
privateslot

Definition at line 473 of file qnetworkmanagerengine.cpp.

Referenced by newConnection().

474 {
475  QMutexLocker locker(&mutex);
476 
479  if (!connection)
480  return;
481 
482  const QString service = connection->connectionInterface()->service();
483  const QString settingsPath = connection->connectionInterface()->path();
484 
485  QNetworkConfigurationPrivate *cpPriv = parseConnection(service, settingsPath, settings);
486 
487  // Check if connection is active.
488  foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
489  QNetworkManagerConnectionActive activeConnection(acPath.path());
490 
491  if (activeConnection.serviceName() == service &&
492  activeConnection.connection().path() == settingsPath &&
493  activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
495  break;
496  }
497  }
498 
500 
501  ptr->mutex.lock();
502 
503  ptr->isValid = cpPriv->isValid;
504  ptr->name = cpPriv->name;
505  ptr->id = cpPriv->id;
506  ptr->state = cpPriv->state;
507 
508  ptr->mutex.unlock();
509 
510  locker.unlock();
512  delete cpPriv;
513 }
QList< QDBusObjectPath > activeConnections() const
QNetworkManagerInterface * interface
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QString path() const
Returns the object path that this interface is associated with.
QNetworkConfiguration::StateFlags state
void configurationChanged(QNetworkConfigurationPrivatePointer config)
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
#define emit
Definition: qobjectdefs.h:76
QString path() const
Returns this object path.
const T * ptr(const T &t)
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
QDBusInterface * connectionInterface() const
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
QString service() const
Returns the name of the service this interface is associated with.
QNetworkConfigurationPrivate * parseConnection(const QString &service, const QString &settingsPath, const QNmSettingsMap &map)

Properties

◆ accessPoints

QList<QNetworkManagerInterfaceAccessPoint *> QNetworkManagerEngine::accessPoints
private

◆ activeConnections

QHash<QString, QNetworkManagerConnectionActive *> QNetworkManagerEngine::activeConnections
private

◆ configuredAccessPoints

QList<QNetworkManagerInterfaceAccessPoint *> QNetworkManagerEngine::configuredAccessPoints
private

Definition at line 133 of file qnetworkmanagerengine.h.

Referenced by parseConnection(), and removeAccessPoint().

◆ connections

QList<QNetworkManagerSettingsConnection *> QNetworkManagerEngine::connections
private

◆ interface

QNetworkManagerInterface* QNetworkManagerEngine::interface
private

◆ systemSettings

QNetworkManagerSettings* QNetworkManagerEngine::systemSettings
private

Definition at line 127 of file qnetworkmanagerengine.h.

Referenced by initialize(), and QNetworkManagerEngine().

◆ userSettings

QNetworkManagerSettings* QNetworkManagerEngine::userSettings
private

Definition at line 128 of file qnetworkmanagerengine.h.

Referenced by initialize(), and QNetworkManagerEngine().

◆ wirelessDevices

QHash<QString, QNetworkManagerInterfaceDeviceWireless *> QNetworkManagerEngine::wirelessDevices
private

Definition at line 129 of file qnetworkmanagerengine.h.

Referenced by deviceAdded(), deviceRemoved(), and ~QNetworkManagerEngine().


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