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

#include <qconnmanengine.h>

Inheritance diagram for QConnmanEngine:
QBearerEngineImpl QBearerEngine QObject

Public Functions

virtual quint64 bytesReceived (const QString &id)
 
virtual quint64 bytesWritten (const QString &id)
 
virtual QNetworkConfigurationManager::Capabilities capabilities () const
 
void configurationChange (const QString &id)
 
virtual void connectToId (const QString &id)
 
bool connmanAvailable () const
 
QNetworkSessionPrivatecreateSessionBackend ()
 
virtual QNetworkConfigurationPrivatePointer defaultConfiguration ()
 
virtual void disconnectFromId (const QString &id)
 
QList< QNetworkConfigurationPrivate * > getConfigurations ()
 
virtual QString getInterfaceFromId (const QString &id)
 
bool hasIdentifier (const QString &id)
 
Q_INVOKABLE void initialize ()
 
 QConnmanEngine (QObject *parent=0)
 
Q_INVOKABLE void requestUpdate ()
 
QNetworkSession::State sessionStateForId (const QString &id)
 
virtual quint64 startTime (const QString &id)
 
 ~QConnmanEngine ()
 
- Public Functions inherited from QBearerEngineImpl
 QBearerEngineImpl (QObject *parent=0)
 
 ~QBearerEngineImpl ()
 
- Public Functions inherited from QBearerEngine
bool configurationsInUse () const
 
 QBearerEngine (QObject *parent=0)
 
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...
 

Protected Functions

bool requiresPolling () const
 
- 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...
 

Private Slots

void doRequestUpdate ()
 
void propertyChangedContext (const QString &, const QString &, const QDBusVariant &)
 
void servicePropertyChangedContext (const QString &, const QString &, const QDBusVariant &)
 
void technologyPropertyChangedContext (const QString &, const QString &, const QDBusVariant &)
 

Private Functions

void addServiceConfiguration (const QString &servicePath)
 
QNetworkConfiguration::StateFlags getStateForService (const QString &service)
 
bool isRoamingAllowed (const QString &context)
 
QString networkFromId (const QString &id)
 
QNetworkConfiguration::BearerType ofonoTechToBearerType (const QString &type)
 
void removeConfiguration (const QString &servicePath)
 
QString serviceFromId (const QString &id)
 
QNetworkConfiguration::BearerType typeToBearer (const QString &type)
 

Properties

QDateTime activeTime
 
QMap< QString, QStringconfigInterfaces
 
QConnmanManagerInterfaceconnmanManager
 
QList< QNetworkConfigurationPrivate * > foundConfigurations
 
QList< QStringserviceNetworks
 
QMap< QString, QConnmanTechnologyInterface * > technologies
 

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 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 qconnmanengine.h.

Constructors and Destructors

◆ QConnmanEngine()

QConnmanEngine::QConnmanEngine ( QObject parent = 0)

Definition at line 64 of file qconnmanengine.cpp.

65 : QBearerEngineImpl(parent),
67 {
68 }
QBearerEngineImpl(QObject *parent=0)
QConnmanManagerInterface * connmanManager

◆ ~QConnmanEngine()

QConnmanEngine::~QConnmanEngine ( )

Definition at line 70 of file qconnmanengine.cpp.

71 {
72 }

Functions

◆ addServiceConfiguration()

void QConnmanEngine::addServiceConfiguration ( const QString servicePath)
private

Definition at line 524 of file qconnmanengine.cpp.

Referenced by initialize(), and propertyChangedContext().

525 {
526  QMutexLocker locker(&mutex);
528  serv = new QConnmanServiceInterface(servicePath);
529 
530  const QString id = QString::number(qHash(servicePath));
531 
532  if (!accessPointConfigurations.contains(id)) {
533  serviceNetworks.append(servicePath);
534 
538 
539  QString networkName = serv->getName();
540 
541  const QString connectionType = serv->getType();
542  if (connectionType == "ethernet") {
544  } else if (connectionType == "wifi") {
546  } else if (connectionType == "cellular") {
547  cpPriv->bearerType = ofonoTechToBearerType("cellular");
548  if(servicePath.isEmpty()) {
549  networkName = serv->getAPN();
550  if(networkName.isEmpty()) {
551  networkName = serv->getName();
552  }
553  }
554  cpPriv->roamingSupported = isRoamingAllowed(servicePath);
555  } else if (connectionType == "wimax") {
557  } else {
559  }
560 
561  cpPriv->name = networkName;
562  cpPriv->isValid = true;
563  cpPriv->id = id;
565 
566  if(serv->getSecurity() == "none") {
568  } else {
570  }
571 
572  cpPriv->state = getStateForService(servicePath);
573 
575  accessPointConfigurations.insert(ptr->id, ptr);
576  foundConfigurations.append(cpPriv);
577  configInterfaces[cpPriv->id] = serv->getInterface();
578 
579  locker.unlock();
581  locker.relock();
583  }
584 }
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
QList< QString > serviceNetworks
bool isRoamingAllowed(const QString &context)
QNetworkConfiguration::StateFlags state
QNetworkConfiguration::StateFlags getStateForService(const QString &service)
#define SLOT(a)
Definition: qobjectdefs.h:226
void updateCompleted()
The QString class provides a Unicode character string.
Definition: qstring.h:83
QMap< QString, QString > configInterfaces
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
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
#define emit
Definition: qobjectdefs.h:76
void configurationAdded(QNetworkConfigurationPrivatePointer config)
QList< QNetworkConfigurationPrivate * > foundConfigurations
const T * ptr(const T &t)
void servicePropertyChangedContext(const QString &, const QString &, const QDBusVariant &)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QNetworkConfiguration::Purpose purpose
QNetworkConfiguration::Type type
void propertyChangedContext(const QString &, const QString &, const QDBusVariant &)
QNetworkConfiguration::BearerType ofonoTechToBearerType(const QString &type)
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus type...

◆ bytesReceived()

quint64 QConnmanEngine::bytesReceived ( const QString id)
virtual

Reimplemented from QBearerEngineImpl.

Definition at line 267 of file qconnmanengine.cpp.

268 {//TODO use connman counter API
269  QMutexLocker locker(&mutex);
270  quint64 result = 0;
271  QString devFile = getInterfaceFromId(id);
272  QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes");
273  if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) {
274  QTextStream in(&rx);
275  in >> result;
276  rx.close();
277  }
278  return result;
279 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
unsigned __int64 quint64
Definition: qglobal.h:943
virtual QString getInterfaceFromId(const QString &id)
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

◆ bytesWritten()

quint64 QConnmanEngine::bytesWritten ( const QString id)
virtual

Reimplemented from QBearerEngineImpl.

Definition at line 252 of file qconnmanengine.cpp.

253 {//TODO use connman counter API
254  QMutexLocker locker(&mutex);
255  quint64 result = 0;
256  QString devFile = getInterfaceFromId(id);
257  QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes");
258  if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
259  QTextStream in(&tx);
260  in >> result;
261  tx.close();
262  }
263 
264  return result;
265 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
unsigned __int64 quint64
Definition: qglobal.h:943
virtual QString getInterfaceFromId(const QString &id)
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

◆ capabilities()

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

◆ configurationChange()

void QConnmanEngine::configurationChange ( const QString id)

Definition at line 372 of file qconnmanengine.cpp.

Referenced by servicePropertyChangedContext().

373 {
374  QMutexLocker locker(&mutex);
375 
376  if (accessPointConfigurations.contains(id)) {
377 
379 
380  QString servicePath = serviceFromId(id);
382  serv = new QConnmanServiceInterface(servicePath);
383  QString networkName = serv->getName();
384 
385  QNetworkConfiguration::StateFlags curState = getStateForService(servicePath);
386 
387  ptr->mutex.lock();
388 
389  if (!ptr->isValid) {
390  ptr->isValid = true;
391  }
392 
393  if (ptr->name != networkName) {
394  ptr->name = networkName;
395  }
396 
397  if (ptr->state != curState) {
398  ptr->state = curState;
399  }
400 
401  ptr->mutex.unlock();
402 
403  locker.unlock();
405  locker.relock();
406  }
407 
408  locker.unlock();
410 }
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QNetworkConfiguration::StateFlags state
QNetworkConfiguration::StateFlags getStateForService(const QString &service)
void configurationChanged(QNetworkConfigurationPrivatePointer config)
void updateCompleted()
The QString class provides a Unicode character string.
Definition: qstring.h:83
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
#define emit
Definition: qobjectdefs.h:76
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
QString serviceFromId(const QString &id)

◆ connectToId()

void QConnmanEngine::connectToId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 145 of file qconnmanengine.cpp.

146 {
147  QMutexLocker locker(&mutex);
148  QString servicePath = serviceFromId(id);
149  QConnmanServiceInterface serv(servicePath);
150  if(!serv.isValid()) {
152  } else {
153  if(serv.getType() != "cellular") {
154 
155  serv.connect();
156  } else {
157  QOfonoManagerInterface ofonoManager(0);
158  QString modemPath = ofonoManager.currentModem().path();
159  QOfonoDataConnectionManagerInterface dc(modemPath,0);
160  foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
161  if(dcPath.path().contains(servicePath.section("_",-1))) {
162  QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0);
163  primaryContext.setActive(true);
164  }
165  }
166  }
167  }
168 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
Definition: qstring.h:781
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define emit
Definition: qobjectdefs.h:76
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...
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)
QString serviceFromId(const QString &id)

◆ connmanAvailable()

bool QConnmanEngine::connmanAvailable ( ) const

Definition at line 74 of file qconnmanengine.cpp.

Referenced by QConnmanEnginePlugin::create().

75 {
76  QMutexLocker locker(&mutex);
77  return connmanManager->isValid();
78 }
bool isValid() const
Returns true if this is a valid reference to a remote object.
QConnmanManagerInterface * connmanManager
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ createSessionBackend()

QNetworkSessionPrivate * QConnmanEngine::createSessionBackend ( )
virtual

Implements QBearerEngine.

Definition at line 298 of file qconnmanengine.cpp.

◆ defaultConfiguration()

QNetworkConfigurationPrivatePointer QConnmanEngine::defaultConfiguration ( )
virtual

Implements QBearerEngine.

Definition at line 303 of file qconnmanengine.cpp.

304 {
306 }
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > QNetworkConfigurationPrivatePointer

◆ disconnectFromId()

void QConnmanEngine::disconnectFromId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 170 of file qconnmanengine.cpp.

171 {
172  QMutexLocker locker(&mutex);
173  QString servicePath = serviceFromId(id);
174  QConnmanServiceInterface serv(servicePath);
175  if(!serv.isValid()) {
177  } else {
178  if(serv.getType() != "cellular") {
179  serv.disconnect();
180  } else {
181  QOfonoManagerInterface ofonoManager(0);
182  QString modemPath = ofonoManager.currentModem().path();
183  QOfonoDataConnectionManagerInterface dc(modemPath,0);
184  foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
185  if(dcPath.path().contains(servicePath.section("_",-1))) {
186  QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0);
187  primaryContext.setActive(false);
188  }
189  }
190  }
191  }
192 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
Definition: qstring.h:781
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define emit
Definition: qobjectdefs.h:76
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...
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)
QString serviceFromId(const QString &id)

◆ doRequestUpdate

void QConnmanEngine::doRequestUpdate ( )
privateslot

Definition at line 126 of file qconnmanengine.cpp.

Referenced by requestUpdate().

127 {
131 }
void updateCompleted()
QConnmanManagerInterface * connmanManager
QList< QNetworkConfigurationPrivate * > getConfigurations()
#define emit
Definition: qobjectdefs.h:76
bool requestScan(const QString &type)

◆ getConfigurations()

QList< QNetworkConfigurationPrivate * > QConnmanEngine::getConfigurations ( )

Definition at line 101 of file qconnmanengine.cpp.

Referenced by doRequestUpdate(), and initialize().

102 {
103  QMutexLocker locker(&mutex);
104  QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
105  QNetworkConfigurationPrivate* cpPriv = 0;
106 
107  for (int i = 0; i < foundConfigurations.count(); ++i) {
109  cpPriv = foundConfigurations.at(i);
110 
111  config->name = cpPriv->name;
112  config->isValid = cpPriv->isValid;
113  config->id = cpPriv->id;
114  config->state = cpPriv->state;
115  config->type = cpPriv->type;
116  config->roamingSupported = cpPriv->roamingSupported;
117  config->purpose = cpPriv->purpose;
118  config->bearerType = cpPriv->bearerType;
119 
120  fetchedConfigurations.append(config);
121  delete config;
122  }
123  return fetchedConfigurations;
124 }
QNetworkConfiguration::StateFlags state
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QNetworkConfiguration::BearerType bearerType
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QNetworkConfigurationPrivate * > foundConfigurations
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QNetworkConfiguration::Purpose purpose
QNetworkConfiguration::Type type
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ getInterfaceFromId()

QString QConnmanEngine::getInterfaceFromId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 133 of file qconnmanengine.cpp.

Referenced by bytesReceived(), and bytesWritten().

134 {
135  QMutexLocker locker(&mutex);
136  return configInterfaces.value(id);
137 }
QMap< QString, QString > configInterfaces
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ getStateForService()

QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService ( const QString service)
private

Definition at line 412 of file qconnmanengine.cpp.

Referenced by addServiceConfiguration(), and configurationChange().

413 {
414  QMutexLocker locker(&mutex);
415  QConnmanServiceInterface serv(service);
416  QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
417  if( serv.getType() == "cellular") {
418  if(serv.isSetupRequired()) {
419  flag = ( flag | QNetworkConfiguration::Defined);
420  } else {
421  flag = ( flag | QNetworkConfiguration::Discovered);
422  }
423  } else {
424  if(serv.isFavorite()) {
425  flag = ( flag | QNetworkConfiguration::Discovered);
426  } else {
428  }
429  }
430 
431  if(serv.getState() == "ready" || serv.getState() == "online") {
432  flag = ( flag | QNetworkConfiguration::Active);
433  }
434 
435  return flag;
436 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ hasIdentifier()

bool QConnmanEngine::hasIdentifier ( const QString id)
virtual

Implements QBearerEngine.

Definition at line 139 of file qconnmanengine.cpp.

140 {
141  QMutexLocker locker(&mutex);
142  return accessPointConfigurations.contains(id);
143 }
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ initialize()

void QConnmanEngine::initialize ( )

Definition at line 80 of file qconnmanengine.cpp.

81 {
84 
85  foreach(const QString techPath, connmanManager->getTechnologies()) {
87  tech = new QConnmanTechnologyInterface(techPath, this);
88 
91  }
92 
93  foreach(const QString servPath, connmanManager->getServices()) {
94  addServiceConfiguration(servPath);
95  }
96 
97  // Get current list of access points.
99 }
void addServiceConfiguration(const QString &servicePath)
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
QConnmanManagerInterface * connmanManager
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QList< QNetworkConfigurationPrivate * > getConfigurations()
void technologyPropertyChangedContext(const QString &, const QString &, const QDBusVariant &)
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 propertyChangedContext(const QString &, const QString &, const QDBusVariant &)
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus type...

◆ isRoamingAllowed()

bool QConnmanEngine::isRoamingAllowed ( const QString context)
private

Definition at line 490 of file qconnmanengine.cpp.

Referenced by addServiceConfiguration().

491 {
492  QOfonoManagerInterface ofonoManager(this);
493  QString modemPath = ofonoManager.currentModem().path();
494  QOfonoDataConnectionManagerInterface dc(modemPath,this);
495  foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
496  if(dcPath.path().contains(context.section("_",-1))) {
497  return dc.isRoamingAllowed();
498  }
499  }
500  return false;
501 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
Definition: qstring.h:781
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString path() const
Returns this object path.
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...

◆ networkFromId()

QString QConnmanEngine::networkFromId ( const QString id)
private

◆ ofonoTechToBearerType()

QNetworkConfiguration::BearerType QConnmanEngine::ofonoTechToBearerType ( const QString type)
private

Definition at line 458 of file qconnmanengine.cpp.

Referenced by addServiceConfiguration(), and typeToBearer().

459 {
460  QOfonoManagerInterface ofonoManager(this);
461  QOfonoNetworkRegistrationInterface ofonoNetwork(ofonoManager.currentModem().path(),this);
462 
463  if(ofonoNetwork.isValid()) {
464  foreach(const QDBusObjectPath op,ofonoNetwork.getOperators() ) {
465  QOfonoNetworkOperatorInterface opIface(op.path(),this);
466 
467  foreach(const QString opTech, opIface.getTechnologies()) {
468 
469  if(opTech == "gsm") {
471  }
472  if(opTech == "edge"){
473  return QNetworkConfiguration::BearerCDMA2000; //wrong, I know
474  }
475  if(opTech == "umts"){
477  }
478  if(opTech == "hspa"){
480  }
481  if(opTech == "lte"){
482  return QNetworkConfiguration::BearerWiMAX; //not exact
483  }
484  }
485  }
486  }
488 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString path() const
Returns this object path.
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...

◆ propertyChangedContext

void QConnmanEngine::propertyChangedContext ( const QString path,
const QString item,
const QDBusVariant value 
)
privateslot

Definition at line 308 of file qconnmanengine.cpp.

Referenced by addServiceConfiguration(), initialize(), removeConfiguration(), and technologyPropertyChangedContext().

309 {
310  Q_UNUSED(path);
311 
312  QMutexLocker locker(&mutex);
313  if(item == "Services") {
315  QStringList list = qdbus_cast<QStringList>(arg);
316 
317  if(list.count() > accessPointConfigurations.count()) {
318  foreach(const QString service, list) {
319  addServiceConfiguration(service);
320  }
321  }
322  }
323 
324  if(item == "Technologies") {
326  QStringList newlist = qdbus_cast<QStringList>(arg);
327  if(newlist.count() > 0) {
329 
330  foreach(const QString listPath, newlist) {
331  if(!oldtech.contains(listPath)) {
333  tech = new QConnmanTechnologyInterface(listPath,this);
336  technologies.insert(listPath, tech);
337  }
338  }
339  }
340  }
341  if(item == "State") {
342 // qDebug() << value.variant();
343  }
344 }
T qdbus_cast(const QDBusArgument &arg)
void addServiceConfiguration(const QString &servicePath)
The QDBusArgument class is used to marshall and demarshall D-Bus arguments.
Definition: qdbusargument.h:69
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void technologyPropertyChangedContext(const QString &, const QString &, const QDBusVariant &)
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
QMap< QString, QConnmanTechnologyInterface * > technologies
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
QVariant variant() const
Returns this D-Bus variant as a QVariant object.
void propertyChangedContext(const QString &, const QString &, const QDBusVariant &)
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
#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 QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus type...
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67

◆ removeConfiguration()

void QConnmanEngine::removeConfiguration ( const QString servicePath)
private

Definition at line 503 of file qconnmanengine.cpp.

504 {
505  QMutexLocker locker(&mutex);
506 
507  if (accessPointConfigurations.contains(id)) {
508 
509  QString service = serviceFromId(id);
510  QConnmanServiceInterface serv(service);
511 
514 
515  serviceNetworks.removeOne(service);
516 
518  locker.unlock();
520  locker.relock();
521  }
522 }
QList< QString > serviceNetworks
#define SLOT(a)
Definition: qobjectdefs.h:226
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
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
#define emit
Definition: qobjectdefs.h:76
const T * ptr(const T &t)
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.
Definition: qobject.cpp:2895
void servicePropertyChangedContext(const QString &, const QString &, const QDBusVariant &)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
void configurationRemoved(QNetworkConfigurationPrivatePointer config)
void propertyChangedContext(const QString &, const QString &, const QDBusVariant &)
QString serviceFromId(const QString &id)
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus type...

◆ requestUpdate()

void QConnmanEngine::requestUpdate ( )

Definition at line 194 of file qconnmanengine.cpp.

195 {
196  QMutexLocker locker(&mutex);
198 }
#define SLOT(a)
Definition: qobjectdefs.h:226
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
bool singleShot
This static function calls a slot after a given time interval.
Definition: qtimer.h:59

◆ requiresPolling()

bool QConnmanEngine::requiresPolling ( ) const
protectedvirtual

Reimplemented from QBearerEngine.

Definition at line 586 of file qconnmanengine.cpp.

587 {
588  return false;
589 }

◆ serviceFromId()

QString QConnmanEngine::serviceFromId ( const QString id)
private

Definition at line 200 of file qconnmanengine.cpp.

Referenced by configurationChange(), connectToId(), disconnectFromId(), removeConfiguration(), and sessionStateForId().

201 {
202  QMutexLocker locker(&mutex);
203  foreach(const QString service, serviceNetworks) {
204  if (id == QString::number(qHash(service)))
205  return service;
206  }
207 
208  return QString();
209 }
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
QList< QString > serviceNetworks
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ servicePropertyChangedContext

void QConnmanEngine::servicePropertyChangedContext ( const QString path,
const QString item,
const QDBusVariant value 
)
privateslot

Definition at line 346 of file qconnmanengine.cpp.

Referenced by addServiceConfiguration(), and removeConfiguration().

347 {
348  QMutexLocker locker(&mutex);
349  if(item == "State") {
351 
352  if(value.variant().toString() == "failure") {
353  QConnmanServiceInterface serv(path);
355  }
356  }
357 }
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 toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
#define emit
Definition: qobjectdefs.h:76
void configurationChange(const QString &id)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QVariant variant() const
Returns this D-Bus variant as a QVariant object.
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)

◆ sessionStateForId()

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

Implements QBearerEngineImpl.

Definition at line 211 of file qconnmanengine.cpp.

212 {
213  QMutexLocker locker(&mutex);
214 
216 
217  if (!ptr)
219 
220  if (!ptr->isValid) {
222 
223  }
224  QString service = serviceFromId(id);
225  QConnmanServiceInterface serv(service);
226  QString servState = serv.getState();
227 
228  if(serv.isFavorite() && (servState == "idle" || servState == "failure")) {
230  }
231 
232  if(servState == "association" || servState == "configuration" || servState == "login") {
234  }
235  if(servState == "ready" || servState == "online") {
237  }
238 
244  } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
247  }
248 
250 }
QNetworkConfiguration::StateFlags state
The QString class provides a Unicode character string.
Definition: qstring.h:83
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
const T * ptr(const T &t)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QString serviceFromId(const QString &id)

◆ startTime()

quint64 QConnmanEngine::startTime ( const QString id)
virtual

Reimplemented from QBearerEngineImpl.

Definition at line 281 of file qconnmanengine.cpp.

282 {
283  // TODO
284  QMutexLocker locker(&mutex);
285  if (activeTime.isNull()) {
286  return 0;
287  }
289 }
bool isNull() const
Returns true if both the date and the time are null; otherwise returns false.
Definition: qdatetime.cpp:2334
QDateTime activeTime
int secsTo(const QDateTime &) const
Returns the number of seconds from this datetime to the other datetime.
Definition: qdatetime.cpp:2914
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static QDateTime currentDateTime()
Returns the current datetime, as reported by the system clock, in the local time zone.
Definition: qdatetime.cpp:3138

◆ technologyPropertyChangedContext

void QConnmanEngine::technologyPropertyChangedContext ( const QString path,
const QString item,
const QDBusVariant value 
)
privateslot

Definition at line 359 of file qconnmanengine.cpp.

Referenced by initialize(), and propertyChangedContext().

360 {
361  if(item == "State") {
362  if(value.variant().toString() == "offline") {
363  QConnmanTechnologyInterface tech(path);
366 
367  technologies.remove(path);
368  }
369  }
370 }
#define SLOT(a)
Definition: qobjectdefs.h:226
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void technologyPropertyChangedContext(const QString &, const QString &, const QDBusVariant &)
QMap< QString, QConnmanTechnologyInterface * > technologies
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.
Definition: qobject.cpp:2895
int remove(const Key &key)
Removes all the items that have the key key from the map.
Definition: qmap.h:662
QVariant variant() const
Returns this D-Bus variant as a QVariant object.
void propertyChangedContext(const QString &, const QString &, const QDBusVariant &)
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus type...

◆ typeToBearer()

QNetworkConfiguration::BearerType QConnmanEngine::typeToBearer ( const QString type)
private

Definition at line 438 of file qconnmanengine.cpp.

439 {
440  if (type == "wifi")
442  if (type == "ethernet")
444  if (type == "bluetooth")
446  if (type == "cellular") {
447  return ofonoTechToBearerType(type);
448  }
449  if (type == "wimax")
451 
452 // if(type == "gps")
453 // if(type == "vpn")
454 
456 }
QNetworkConfiguration::BearerType ofonoTechToBearerType(const QString &type)

Properties

◆ activeTime

QDateTime QConnmanEngine::activeTime
private

Definition at line 122 of file qconnmanengine.h.

Referenced by startTime().

◆ configInterfaces

QMap<QString,QString> QConnmanEngine::configInterfaces
private

Definition at line 126 of file qconnmanengine.h.

Referenced by addServiceConfiguration(), and getInterfaceFromId().

◆ connmanManager

QConnmanManagerInterface* QConnmanEngine::connmanManager
private

Definition at line 110 of file qconnmanengine.h.

Referenced by connmanAvailable(), doRequestUpdate(), and initialize().

◆ foundConfigurations

QList<QNetworkConfigurationPrivate *> QConnmanEngine::foundConfigurations
private

Definition at line 112 of file qconnmanengine.h.

Referenced by addServiceConfiguration(), and getConfigurations().

◆ serviceNetworks

QList<QString> QConnmanEngine::serviceNetworks
private

Definition at line 127 of file qconnmanengine.h.

Referenced by addServiceConfiguration(), removeConfiguration(), and serviceFromId().

◆ technologies

QMap<QString,QConnmanTechnologyInterface *> QConnmanEngine::technologies
private

Definition at line 125 of file qconnmanengine.h.

Referenced by propertyChangedContext(), and technologyPropertyChangedContext().


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