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

#include <qnetworkconfigmanager_p.h>

Inheritance diagram for QNetworkConfigurationManagerPrivate:
QObject

Public Slots

static void addPostRoutine ()
 
void updateConfigurations ()
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void configurationAdded (const QNetworkConfiguration &config)
 
void configurationChanged (const QNetworkConfiguration &config)
 
void configurationRemoved (const QNetworkConfiguration &config)
 
void configurationUpdateComplete ()
 
void onlineStateChanged (bool isOnline)
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

QList< QNetworkConfigurationallConfigurations (QNetworkConfiguration::StateFlags filter) const
 
QNetworkConfigurationManager::Capabilities capabilities () const
 
void cleanup ()
 
QNetworkConfiguration configurationFromIdentifier (const QString &identifier) const
 
QNetworkConfiguration defaultConfiguration () const
 
void disablePolling ()
 
void enablePolling ()
 
QList< QBearerEngine * > engines () const
 
void initialize ()
 
bool isOnline () const
 
void performAsyncConfigurationUpdate ()
 
 QNetworkConfigurationManagerPrivate ()
 
virtual ~QNetworkConfigurationManagerPrivate ()
 
- 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 configurationAdded (QNetworkConfigurationPrivatePointer ptr)
 
void configurationChanged (QNetworkConfigurationPrivatePointer ptr)
 
void configurationRemoved (QNetworkConfigurationPrivatePointer ptr)
 
void pollEngines ()
 

Private Functions

Q_INVOKABLE void startPolling ()
 

Properties

QThreadbearerThread
 
bool firstUpdate
 
int forcedPolling
 
QMutex mutex
 
QSet< QStringonlineConfigurations
 
QSet< QBearerEngine * > pollingEngines
 
QTimerpollTimer
 
QList< QBearerEngine * > sessionEngines
 
bool updating
 
QSet< QBearerEngine * > updatingEngines
 

Additional Inherited Members

- 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 QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 69 of file qnetworkconfigmanager_p.h.

Constructors and Destructors

◆ QNetworkConfigurationManagerPrivate()

QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate ( )

Referenced by connManager().

◆ ~QNetworkConfigurationManagerPrivate()

QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate ( )
virtual

Definition at line 79 of file qnetworkconfigmanager_p.cpp.

80 {
81  QMutexLocker locker(&mutex);
82 
84  if (bearerThread)
85  bearerThread->quit();
86 }
void quit()
Tells the thread&#39;s event loop to exit with return code 0 (success).
Definition: qthread.cpp:614
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

Functions

◆ addPostRoutine

void QNetworkConfigurationManagerPrivate::addPostRoutine ( )
staticslot

Definition at line 71 of file qnetworkconfigmanager.cpp.

Referenced by connManager().

72 {
74 }
void qAddPostRoutine(QtCleanUpFunction p)
static void connManager_cleanup()

◆ allConfigurations()

QList< QNetworkConfiguration > QNetworkConfigurationManagerPrivate::allConfigurations ( QNetworkConfiguration::StateFlags  filter) const

Definition at line 213 of file qnetworkconfigmanager_p.cpp.

Referenced by QNetworkConfigurationManager::allConfigurations().

214 {
216 
217  QMutexLocker locker(&mutex);
218 
219  foreach (QBearerEngine *engine, sessionEngines) {
222 
223  QMutexLocker locker(&engine->mutex);
224 
225  //find all InternetAccessPoints
226  for (it = engine->accessPointConfigurations.begin(),
227  end = engine->accessPointConfigurations.end(); it != end; ++it) {
229 
230  QMutexLocker configLocker(&ptr->mutex);
231 
232  if ((ptr->state & filter) == filter) {
234  pt.d = ptr;
235  result << pt;
236  }
237  }
238 
239  //find all service networks
240  for (it = engine->snapConfigurations.begin(),
241  end = engine->snapConfigurations.end(); it != end; ++it) {
243 
244  QMutexLocker configLocker(&ptr->mutex);
245 
246  if ((ptr->state & filter) == filter) {
248  pt.d = ptr;
249  result << pt;
250  }
251  }
252  }
253 
254  return result;
255 }
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > d
#define it(className, varName)
QNetworkConfiguration::StateFlags state
T & value() const
Returns a modifiable reference to the current item&#39;s value.
Definition: qhash.h:348
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
const T * ptr(const T &t)
QHash< QString, QNetworkConfigurationPrivatePointer > snapConfigurations
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
static const KeyPair *const end
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ capabilities()

QNetworkConfigurationManager::Capabilities QNetworkConfigurationManagerPrivate::capabilities ( ) const

Definition at line 288 of file qnetworkconfigmanager_p.cpp.

Referenced by QNetworkConfigurationManager::capabilities().

289 {
290  QMutexLocker locker(&mutex);
291 
292  QNetworkConfigurationManager::Capabilities capFlags;
293 
294  foreach (QBearerEngine *engine, sessionEngines)
295  capFlags |= engine->capabilities();
296 
297  return capFlags;
298 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
virtual QNetworkConfigurationManager::Capabilities capabilities() const =0

◆ cleanup()

void QNetworkConfigurationManagerPrivate::cleanup ( )

Definition at line 88 of file qnetworkconfigmanager_p.cpp.

Referenced by connManager_cleanup().

89 {
91  deleteLater();
92  if(thread->wait(5000))
93  delete thread;
94 }
bool wait(unsigned long time=ULONG_MAX)
Blocks the thread until either of these conditions is met:
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419
The QThread class provides a platform-independent way to manage threads.
Definition: qthread.h:59
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145

◆ configurationAdded [1/2]

void QNetworkConfigurationManagerPrivate::configurationAdded ( const QNetworkConfiguration config)
signal

◆ configurationAdded [2/2]

void QNetworkConfigurationManagerPrivate::configurationAdded ( QNetworkConfigurationPrivatePointer  ptr)
privateslot

Definition at line 300 of file qnetworkconfigmanager_p.cpp.

301 {
302  QMutexLocker locker(&mutex);
303 
304  if (!firstUpdate) {
306  item.d = ptr;
307  emit configurationAdded(item);
308  }
309 
310  ptr->mutex.lock();
311  if (ptr->state == QNetworkConfiguration::Active) {
312  ptr->mutex.unlock();
314  if (!firstUpdate && onlineConfigurations.count() == 1)
315  emit onlineStateChanged(true);
316  } else {
317  ptr->mutex.unlock();
318  }
319 }
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > d
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QNetworkConfiguration::StateFlags state
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
void onlineStateChanged(bool isOnline)
#define emit
Definition: qobjectdefs.h:76
const_iterator insert(const T &value)
Definition: qset.h:179
int count() const
Definition: qset.h:178
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
void configurationAdded(const QNetworkConfiguration &config)

◆ configurationChanged [1/2]

void QNetworkConfigurationManagerPrivate::configurationChanged ( const QNetworkConfiguration config)
signal

◆ configurationChanged [2/2]

void QNetworkConfigurationManagerPrivate::configurationChanged ( QNetworkConfigurationPrivatePointer  ptr)
privateslot

Definition at line 340 of file qnetworkconfigmanager_p.cpp.

341 {
342  QMutexLocker locker(&mutex);
343 
344  if (!firstUpdate) {
346  item.d = ptr;
348  }
349 
350  bool previous = !onlineConfigurations.isEmpty();
351 
352  ptr->mutex.lock();
355  else
357  ptr->mutex.unlock();
358 
359  bool online = !onlineConfigurations.isEmpty();
360 
361  if (!firstUpdate && online != previous)
362  emit onlineStateChanged(online);
363 }
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > d
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QNetworkConfiguration::StateFlags state
bool remove(const T &value)
Definition: qset.h:89
bool isEmpty() const
Definition: qset.h:77
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
void onlineStateChanged(bool isOnline)
#define emit
Definition: qobjectdefs.h:76
const_iterator insert(const T &value)
Definition: qset.h:179
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
void configurationChanged(const QNetworkConfiguration &config)

◆ configurationFromIdentifier()

QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier ( const QString identifier) const

Definition at line 257 of file qnetworkconfigmanager_p.cpp.

Referenced by QNetworkConfigurationManager::configurationFromIdentifier().

258 {
260 
261  QMutexLocker locker(&mutex);
262 
263  foreach (QBearerEngine *engine, sessionEngines) {
264  QMutexLocker locker(&engine->mutex);
265 
266  if (engine->accessPointConfigurations.contains(identifier))
267  item.d = engine->accessPointConfigurations[identifier];
268  else if (engine->snapConfigurations.contains(identifier))
269  item.d = engine->snapConfigurations[identifier];
270  else if (engine->userChoiceConfigurations.contains(identifier))
271  item.d = engine->userChoiceConfigurations[identifier];
272  else
273  continue;
274 
275  return item;
276  }
277 
278  return item;
279 }
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > d
QHash< QString, QNetworkConfigurationPrivatePointer > userChoiceConfigurations
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
QHash< QString, QNetworkConfigurationPrivatePointer > snapConfigurations
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
if(void) toggleToolbarShown

◆ configurationRemoved [1/2]

void QNetworkConfigurationManagerPrivate::configurationRemoved ( const QNetworkConfiguration config)
signal

◆ configurationRemoved [2/2]

void QNetworkConfigurationManagerPrivate::configurationRemoved ( QNetworkConfigurationPrivatePointer  ptr)
privateslot

Definition at line 321 of file qnetworkconfigmanager_p.cpp.

322 {
323  QMutexLocker locker(&mutex);
324 
325  ptr->mutex.lock();
326  ptr->isValid = false;
327  ptr->mutex.unlock();
328 
329  if (!firstUpdate) {
331  item.d = ptr;
333  }
334 
337  emit onlineStateChanged(false);
338 }
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > d
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
bool remove(const T &value)
Definition: qset.h:89
bool isEmpty() const
Definition: qset.h:77
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
void onlineStateChanged(bool isOnline)
#define emit
Definition: qobjectdefs.h:76
const T * ptr(const T &t)
void configurationRemoved(const QNetworkConfiguration &config)
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

◆ configurationUpdateComplete

void QNetworkConfigurationManagerPrivate::configurationUpdateComplete ( )
signal

◆ defaultConfiguration()

QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration ( ) const

Definition at line 96 of file qnetworkconfigmanager_p.cpp.

Referenced by QNetworkConfigurationManager::defaultConfiguration().

97 {
98  QMutexLocker locker(&mutex);
99 
100  foreach (QBearerEngine *engine, sessionEngines) {
102  if (ptr) {
103  QNetworkConfiguration config;
104  config.d = ptr;
105  return config;
106  }
107  }
108 
109  // Engines don't have a default configuration.
110 
111  // Return first active snap
113 
114  foreach (QBearerEngine *engine, sessionEngines) {
117 
118  QMutexLocker locker(&engine->mutex);
119 
120  for (it = engine->snapConfigurations.begin(),
121  end = engine->snapConfigurations.end(); it != end; ++it) {
123 
124  QMutexLocker configLocker(&ptr->mutex);
125 
127  QNetworkConfiguration config;
128  config.d = ptr;
129  return config;
130  } else if (!defaultConfiguration) {
132  defaultConfiguration = ptr;
133  }
134  }
135  }
136 
137  // No Active SNAPs return first Discovered SNAP.
138  if (defaultConfiguration) {
139  QNetworkConfiguration config;
140  config.d = defaultConfiguration;
141  return config;
142  }
143 
144  /*
145  No Active or Discovered SNAPs, find the perferred access point.
146  The following priority order is used:
147 
148  1. Active Ethernet
149  2. Active WLAN
150  3. Active Other
151  4. Discovered Ethernet
152  5. Discovered WLAN
153  6. Discovered Other
154  */
155 
156  foreach (QBearerEngine *engine, sessionEngines) {
159 
160  QMutexLocker locker(&engine->mutex);
161 
162  for (it = engine->accessPointConfigurations.begin(),
163  end = engine->accessPointConfigurations.end(); it != end; ++it) {
165 
166  QMutexLocker configLocker(&ptr->mutex);
168 
170  if (!defaultConfiguration) {
171  defaultConfiguration = ptr;
172  } else {
173  QMutexLocker defaultConfigLocker(&defaultConfiguration->mutex);
174 
175  if (defaultConfiguration->state == ptr->state) {
176  switch (defaultConfiguration->bearerType) {
178  // do nothing
179  break;
181  // Ethernet beats WLAN
182  defaultConfiguration = ptr;
183  break;
184  default:
185  // Ethernet and WLAN beats other
186  if (bearerType == QNetworkConfiguration::BearerEthernet ||
187  bearerType == QNetworkConfiguration::BearerWLAN) {
188  defaultConfiguration = ptr;
189  }
190  }
191  } else {
192  // active beats discovered
193  if ((defaultConfiguration->state & QNetworkConfiguration::Active) !=
195  defaultConfiguration = ptr;
196  }
197  }
198  }
199  }
200  }
201  }
202 
203  // No Active InternetAccessPoint return first Discovered InternetAccessPoint.
204  if (defaultConfiguration) {
205  QNetworkConfiguration config;
206  config.d = defaultConfiguration;
207  return config;
208  }
209 
210  return QNetworkConfiguration();
211 }
BearerType
Specifies the type of bearer used by a configuration.
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > d
#define it(className, varName)
QNetworkConfiguration::StateFlags state
T & value() const
Returns a modifiable reference to the current item&#39;s value.
Definition: qhash.h:348
QNetworkConfiguration::BearerType bearerType
QNetworkConfiguration defaultConfiguration() const
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
const T * ptr(const T &t)
QHash< QString, QNetworkConfigurationPrivatePointer > snapConfigurations
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
virtual QNetworkConfigurationPrivatePointer defaultConfiguration()=0
static const KeyPair *const end

◆ disablePolling()

void QNetworkConfigurationManagerPrivate::disablePolling ( )

Definition at line 506 of file qnetworkconfigmanager_p.cpp.

Referenced by QNetworkConfigurationManager::~QNetworkConfigurationManager().

507 {
508  QMutexLocker locker(&mutex);
509 
510  --forcedPolling;
511 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ enablePolling()

void QNetworkConfigurationManagerPrivate::enablePolling ( )

Definition at line 496 of file qnetworkconfigmanager_p.cpp.

Referenced by QNetworkConfigurationManager::QNetworkConfigurationManager().

497 {
498  QMutexLocker locker(&mutex);
499 
500  ++forcedPolling;
501 
502  if (forcedPolling == 1)
503  QMetaObject::invokeMethod(this, "startPolling");
504 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
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.

◆ engines()

QList< QBearerEngine * > QNetworkConfigurationManagerPrivate::engines ( ) const

Definition at line 455 of file qnetworkconfigmanager_p.cpp.

Referenced by getEngineFromId(), and QNetworkSession::QNetworkSession().

456 {
457  QMutexLocker locker(&mutex);
458 
459  return sessionEngines;
460 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ initialize()

void QNetworkConfigurationManagerPrivate::initialize ( )

Definition at line 69 of file qnetworkconfigmanager_p.cpp.

Referenced by connManager().

70 {
71  //Two stage construction, because we only want to do this heavyweight work for the winner of the Q_GLOBAL_STATIC race.
72  bearerThread = new QThread();
73  bearerThread->moveToThread(QCoreApplicationPrivate::mainThread()); // because cleanup() is called in main thread context.
77 }
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
Definition: qobject.cpp:1458
static QThread * mainThread()
void start(Priority=InheritPriority)
Begins execution of the thread by calling run().
The QThread class provides a platform-independent way to manage threads.
Definition: qthread.h:59

◆ isOnline()

bool QNetworkConfigurationManagerPrivate::isOnline ( ) const

Definition at line 281 of file qnetworkconfigmanager_p.cpp.

Referenced by QNetworkConfigurationManager::isOnline().

282 {
283  QMutexLocker locker(&mutex);
284 
285  return !onlineConfigurations.isEmpty();
286 }
bool isEmpty() const
Definition: qset.h:77
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ onlineStateChanged

void QNetworkConfigurationManagerPrivate::onlineStateChanged ( bool  isOnline)
signal

◆ performAsyncConfigurationUpdate()

void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate ( )

Definition at line 438 of file qnetworkconfigmanager_p.cpp.

Referenced by QNetworkConfigurationManager::updateConfigurations().

439 {
440  QMutexLocker locker(&mutex);
441 
442  if (sessionEngines.isEmpty()) {
444  return;
445  }
446 
447  updating = true;
448 
449  foreach (QBearerEngine *engine, sessionEngines) {
450  updatingEngines.insert(engine);
451  QMetaObject::invokeMethod(engine, "requestUpdate");
452  }
453 }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
#define emit
Definition: qobjectdefs.h:76
const_iterator insert(const T &value)
Definition: qset.h:179
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
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.

◆ pollEngines

void QNetworkConfigurationManagerPrivate::pollEngines ( )
privateslot

Definition at line 484 of file qnetworkconfigmanager_p.cpp.

Referenced by startPolling().

485 {
486  QMutexLocker locker(&mutex);
487 
488  foreach (QBearerEngine *engine, sessionEngines) {
489  if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
490  pollingEngines.insert(engine);
491  QMetaObject::invokeMethod(engine, "requestUpdate");
492  }
493  }
494 }
const_iterator insert(const T &value)
Definition: qset.h:179
virtual bool requiresPolling() const
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
bool configurationsInUse() const
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.

◆ startPolling()

void QNetworkConfigurationManagerPrivate::startPolling ( )
private

Definition at line 462 of file qnetworkconfigmanager_p.cpp.

Referenced by updateConfigurations().

463 {
464  QMutexLocker locker(&mutex);
465 
466  if(!pollTimer) {
467  pollTimer = new QTimer(this);
468  pollTimer->setInterval(10000);
469  pollTimer->setSingleShot(true);
470  connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines()));
471  }
472 
473  if(pollTimer->isActive())
474  return;
475 
476  foreach (QBearerEngine *engine, sessionEngines) {
477  if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
478  pollTimer->start();
479  break;
480  }
481  }
482 }
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
#define SLOT(a)
Definition: qobjectdefs.h:226
#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
bool isActive() const
Returns true if the timer is running (pending); otherwise returns false.
Definition: qtimer.h:69
void setInterval(int msec)
Definition: qtimer.cpp:419
virtual bool requiresPolling() const
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
bool configurationsInUse() const
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition: qtimer.cpp:249

◆ updateConfigurations

void QNetworkConfigurationManagerPrivate::updateConfigurations ( )
slot

Definition at line 365 of file qnetworkconfigmanager_p.cpp.

Referenced by initialize().

366 {
367  QMutexLocker locker(&mutex);
368 
369  if (firstUpdate) {
370  if (qobject_cast<QBearerEngine *>(sender()))
371  return;
372 
373  updating = false;
374 
375 #ifndef QT_NO_LIBRARY
376  QBearerEngine *generic = 0;
377 
378  QFactoryLoader *l = loader();
379  foreach (const QString &key, l->keys()) {
381  if (plugin) {
382  QBearerEngine *engine = plugin->create(key);
383  if (!engine)
384  continue;
385 
386  if (key == QLatin1String("generic"))
387  generic = engine;
388  else
389  sessionEngines.append(engine);
390 
391  engine->moveToThread(bearerThread);
392 
393  connect(engine, SIGNAL(updateCompleted()),
394  this, SLOT(updateConfigurations()),
405  }
406  }
407 
408  if (generic)
409  sessionEngines.append(generic);
410 #endif // QT_NO_LIBRARY
411  }
412 
414  if (engine && !updatingEngines.isEmpty())
415  updatingEngines.remove(engine);
416 
417  if (updating && updatingEngines.isEmpty()) {
418  updating = false;
420  }
421 
422  if (engine && !pollingEngines.isEmpty()) {
423  pollingEngines.remove(engine);
424  if (pollingEngines.isEmpty())
425  startPolling();
426  }
427 
428  if (firstUpdate) {
429  firstUpdate = false;
430  QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex
431  locker.unlock();
432  foreach (QBearerEngine* engine, enginesToInitialize) {
434  }
435  }
436 }
bool remove(const T &value)
Definition: qset.h:89
bool isEmpty() const
Definition: qset.h:77
#define SLOT(a)
Definition: qobjectdefs.h:226
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
virtual QBearerEngine * create(const QString &key) const =0
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
QStringList keys() const
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 moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
Definition: qobject.cpp:1458
void configurationRemoved(const QNetworkConfiguration &config)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QObject * instance(const QString &key) const
int key
void configurationAdded(const QNetworkConfiguration &config)
QFactoryLoader * l
void configurationChanged(const QNetworkConfiguration &config)
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.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

Properties

◆ bearerThread

QThread* QNetworkConfigurationManagerPrivate::bearerThread
private

◆ firstUpdate

bool QNetworkConfigurationManagerPrivate::firstUpdate
private

◆ forcedPolling

int QNetworkConfigurationManagerPrivate::forcedPolling
private

◆ mutex

QMutex QNetworkConfigurationManagerPrivate::mutex
mutableprivate

◆ onlineConfigurations

QSet<QString> QNetworkConfigurationManagerPrivate::onlineConfigurations
private

◆ pollingEngines

QSet<QBearerEngine *> QNetworkConfigurationManagerPrivate::pollingEngines
private

Definition at line 126 of file qnetworkconfigmanager_p.h.

Referenced by pollEngines(), and updateConfigurations().

◆ pollTimer

QTimer* QNetworkConfigurationManagerPrivate::pollTimer
private

Definition at line 116 of file qnetworkconfigmanager_p.h.

Referenced by startPolling().

◆ sessionEngines

QList<QBearerEngine *> QNetworkConfigurationManagerPrivate::sessionEngines
private

◆ updating

bool QNetworkConfigurationManagerPrivate::updating
private

◆ updatingEngines

QSet<QBearerEngine *> QNetworkConfigurationManagerPrivate::updatingEngines
private

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