Qt 4.8
Public Types | Public Slots | Signals | Public Functions | List of all members
QNetworkConfigurationManager Class Reference

The QNetworkConfigurationManager class manages the network configurations provided by the system. More...

#include <qnetworkconfigmanager.h>

Inheritance diagram for QNetworkConfigurationManager:
QObject

Public Types

enum  Capability {
  CanStartAndStopInterfaces = 0x00000001, DirectConnectionRouting = 0x00000002, SystemSessionSupport = 0x00000004, ApplicationLevelRoaming = 0x00000008,
  ForcedRoaming = 0x00000010, DataStatistics = 0x00000020, NetworkSessionRequired = 0x00000040
}
 Specifies the system capabilities of the bearer API. More...
 

Public Slots

void updateConfigurations ()
 Initiates an update of all configurations. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void configurationAdded (const QNetworkConfiguration &config)
 This signal is emitted whenever a new network configuration is added to the system. More...
 
void configurationChanged (const QNetworkConfiguration &config)
 This signal is emitted when the QNetworkConfiguration::state(){state} of config changes. More...
 
void configurationRemoved (const QNetworkConfiguration &config)
 This signal is emitted when a configuration is about to be removed from the system. More...
 
void onlineStateChanged (bool isOnline)
 This signal is emitted when the device changes from online to offline mode or vice versa. More...
 
void updateCompleted ()
 This signal is emitted when the configuration update has been completed. More...
 
- 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 flags=0) const
 Returns the list of configurations which comply with the given filter. More...
 
QNetworkConfigurationManager::Capabilities capabilities () const
 Returns the capabilities supported by the current platform. More...
 
QNetworkConfiguration configurationFromIdentifier (const QString &identifier) const
 Returns the QNetworkConfiguration for identifier; otherwise returns an invalid QNetworkConfiguration. More...
 
QNetworkConfiguration defaultConfiguration () const
 Returns the default configuration to be used. More...
 
bool isOnline () const
 Returns true if the system is considered to be connected to another device via an active network interface; otherwise returns false. More...
 
 QNetworkConfigurationManager (QObject *parent=0)
 Constructs a QNetworkConfigurationManager with the given parent. More...
 
virtual ~QNetworkConfigurationManager ()
 Frees the resources associated with the QNetworkConfigurationManager object. More...
 
- 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...
 

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

The QNetworkConfigurationManager class manages the network configurations provided by the system.

Since
4.7
Attention
Module: QtNetwork

QNetworkConfigurationManager provides access to the network configurations known to the system and enables applications to detect the system capabilities (with regards to network sessions) at runtime.

A QNetworkConfiguration abstracts a set of configuration options describing how a network interface has to be configured to connect to a particular target network. QNetworkConfigurationManager maintains and updates the global list of QNetworkConfigurations. Applications can access and filter this list via allConfigurations(). If a new configuration is added or an existing one is removed or changed the configurationAdded(), configurationRemoved() and configurationChanged() signals are emitted respectively.

The defaultConfiguration() can be used when intending to immediately create a new network session without caring about the particular configuration. It returns a QNetworkConfiguration::Discovered configuration. If there are not any discovered ones an invalid configuration is returned.

Some configuration updates may require some time to perform updates. A WLAN scan is such an example. Unless the platform performs internal updates it may be required to manually trigger configuration updates via QNetworkConfigurationManager::updateConfigurations(). The completion of the update process is indicated by emitting the updateCompleted() signal. The update process ensures that every existing QNetworkConfiguration instance is updated. There is no need to ask for a renewed configuration list via allConfigurations().

See also
QNetworkConfiguration

Definition at line 66 of file qnetworkconfigmanager.h.

Enumerations

◆ Capability

Specifies the system capabilities of the bearer API.

The possible values are:

  • CanStartAndStopInterfaces Network sessions and their underlying access points can be started and stopped. If this flag is not set QNetworkSession can only monitor but not influence the state of access points. On some platforms this feature may require elevated user permissions. This option is platform specific and may not always be available.
  • DirectConnectionRouting Network sessions and their sockets can be bound to a particular network interface. Any packet that passes through the socket goes to the specified network interface and thus disregards standard routing table entries. This may be useful when two interfaces can reach overlapping IP ranges or an application has specific needs in regards to target networks. This option is platform specific and may not always be available.
  • SystemSessionSupport If this flag is set the underlying platform ensures that a network interface is not shut down until the last network session has been closed(). This works across multiple processes. If the platform session support is missing this API can only ensure the above behavior for network sessions within the same process. In general mobile platforms (such as Symbian/S60) have such support whereas most desktop platform lack this capability.
  • ApplicationLevelRoaming The system gives applications control over the systems roaming behavior. Applications can initiate roaming (in case the current link is not suitable) and are consulted if the system has identified a more suitable access point.
  • ForcedRoaming The system disconnects an existing access point and reconnects via a more suitable one. The application does not have any control over this process and has to reconnect its active sockets.
  • DataStatistics If this flag is set QNetworkSession can provide statistics about transmitted and received data.
  • NetworkSessionRequired If this flag is set the platform requires that a network session is created before network operations can be performed.
Enumerator
CanStartAndStopInterfaces 
DirectConnectionRouting 
SystemSessionSupport 
ApplicationLevelRoaming 
ForcedRoaming 
DataStatistics 
NetworkSessionRequired 

Definition at line 71 of file qnetworkconfigmanager.h.

Constructors and Destructors

◆ QNetworkConfigurationManager()

QNetworkConfigurationManager::QNetworkConfigurationManager ( QObject parent = 0)
explicit

Constructs a QNetworkConfigurationManager with the given parent.

Note that to ensure a valid list of current configurations immediately available, updating is done during construction which causes some delay.

Definition at line 251 of file qnetworkconfigmanager.cpp.

252  : QObject(parent)
253 {
255 
262  connect(priv, SIGNAL(onlineStateChanged(bool)),
263  this, SIGNAL(onlineStateChanged(bool)));
264  connect(priv, SIGNAL(configurationUpdateComplete()),
265  this, SIGNAL(updateCompleted()));
266 
267  priv->enablePolling();
268 }
void configurationChanged(const QNetworkConfiguration &config)
This signal is emitted when the QNetworkConfiguration::state(){state} of config changes.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
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
QNetworkConfigurationManagerPrivate * qNetworkConfigurationManagerPrivate()
void onlineStateChanged(bool isOnline)
This signal is emitted when the device changes from online to offline mode or vice versa...
void configurationRemoved(const QNetworkConfiguration &config)
This signal is emitted when a configuration is about to be removed from the system.
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
static const QMetaObjectPrivate * priv(const uint *data)
void updateCompleted()
This signal is emitted when the configuration update has been completed.
void configurationAdded(const QNetworkConfiguration &config)
This signal is emitted whenever a new network configuration is added to the system.

◆ ~QNetworkConfigurationManager()

QNetworkConfigurationManager::~QNetworkConfigurationManager ( )
virtual

Frees the resources associated with the QNetworkConfigurationManager object.

Definition at line 273 of file qnetworkconfigmanager.cpp.

274 {
276  if (priv)
277  priv->disablePolling();
278 }
static QNetworkConfigurationManagerPrivate * connManager()
static const QMetaObjectPrivate * priv(const uint *data)

Functions

◆ allConfigurations()

QList< QNetworkConfiguration > QNetworkConfigurationManager::allConfigurations ( QNetworkConfiguration::StateFlags  filter = 0) const

Returns the list of configurations which comply with the given filter.

By default this function returns all (defined and undefined) configurations.

A wireless network with a particular SSID may only be accessible in a certain area despite the fact that the system has a valid configuration for it. Therefore the filter flag may be used to limit the list to discovered and possibly connected configurations only.

If filter is set to zero this function returns all possible configurations.

Note that this function returns the states for all configurations as they are known at the time of this function call. If for instance a configuration of type WLAN is defined the system may have to perform a WLAN scan in order to determine whether it is actually available. To obtain the most accurate state updateConfigurations() should be used to update each configuration's state. Note that such an update may require some time. It's completion is signalled by updateCompleted(). In the absence of a configuration update this function returns the best estimate at the time of the call. Therefore, if WLAN configurations are of interest, it is recommended that updateConfigurations() is called once after QNetworkConfigurationManager instantiation (WLAN scans are too time consuming to perform in constructor). After this the data is kept automatically up-to-date as the system reports any changes.

Definition at line 324 of file qnetworkconfigmanager.cpp.

325 {
327  if (priv)
328  return priv->allConfigurations(filter);
329 
331 }
static QNetworkConfigurationManagerPrivate * connManager()
QList< QNetworkConfiguration > allConfigurations(QNetworkConfiguration::StateFlags filter) const
static const QMetaObjectPrivate * priv(const uint *data)
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ capabilities()

QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabilities ( ) const

Returns the capabilities supported by the current platform.

Definition at line 370 of file qnetworkconfigmanager.cpp.

Referenced by QNetworkAccessManager::createRequest().

371 {
373  if (priv)
374  return priv->capabilities();
375 
376  return QNetworkConfigurationManager::Capabilities(0);
377 }
static QNetworkConfigurationManagerPrivate * connManager()
static const QMetaObjectPrivate * priv(const uint *data)
QNetworkConfigurationManager::Capabilities capabilities() const

◆ configurationAdded

void QNetworkConfigurationManager::configurationAdded ( const QNetworkConfiguration config)
signal

This signal is emitted whenever a new network configuration is added to the system.

The new configuration is specified by config.

Referenced by QNetworkConfigurationManager().

◆ configurationChanged

void QNetworkConfigurationManager::configurationChanged ( const QNetworkConfiguration config)
signal

This signal is emitted when the QNetworkConfiguration::state(){state} of config changes.

Referenced by QNetworkConfigurationManager().

◆ configurationFromIdentifier()

QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier ( const QString identifier) const

Returns the QNetworkConfiguration for identifier; otherwise returns an invalid QNetworkConfiguration.

See also
QNetworkConfiguration::identifier()

Definition at line 339 of file qnetworkconfigmanager.cpp.

Referenced by QNetworkAccessManager::activeConfiguration(), QNetworkAccessManager::createRequest(), QNetworkAccessBackend::start(), and QNetworkSessionPrivateImpl::syncStateWithInterface().

340 {
342  if (priv)
343  return priv->configurationFromIdentifier(identifier);
344 
345  return QNetworkConfiguration();
346 }
static QNetworkConfigurationManagerPrivate * connManager()
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
static const QMetaObjectPrivate * priv(const uint *data)
QNetworkConfiguration configurationFromIdentifier(const QString &identifier) const

◆ configurationRemoved

void QNetworkConfigurationManager::configurationRemoved ( const QNetworkConfiguration config)
signal

This signal is emitted when a configuration is about to be removed from the system.

Since
4.8

The removed configuration, specified by config, is invalid but retains name and identifier.

Referenced by QNetworkConfigurationManager().

◆ defaultConfiguration()

QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration ( ) const

Returns the default configuration to be used.

This function always returns a discovered configuration; otherwise an invalid configuration.

In some cases it may be required to call updateConfigurations() and wait for the updateCompleted() signal before calling this function.

See also
allConfigurations()

Definition at line 290 of file qnetworkconfigmanager.cpp.

Referenced by QNetworkAccessManager::createRequest().

291 {
293  if (priv)
294  return priv->defaultConfiguration();
295 
296  return QNetworkConfiguration();
297 }
static QNetworkConfigurationManagerPrivate * connManager()
QNetworkConfiguration defaultConfiguration() const
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
static const QMetaObjectPrivate * priv(const uint *data)

◆ isOnline()

bool QNetworkConfigurationManager::isOnline ( ) const

Returns true if the system is considered to be connected to another device via an active network interface; otherwise returns false.

This is equivalent to the following code snippet:

See also
onlineStateChanged()

Definition at line 358 of file qnetworkconfigmanager.cpp.

359 {
361  if (priv)
362  return priv->isOnline();
363 
364  return false;
365 }
static QNetworkConfigurationManagerPrivate * connManager()
static const QMetaObjectPrivate * priv(const uint *data)

◆ onlineStateChanged

void QNetworkConfigurationManager::onlineStateChanged ( bool  isOnline)
signal

This signal is emitted when the device changes from online to offline mode or vice versa.

isOnline represents the new state of the device.

The state is considered to be online for as long as allConfigurations(QNetworkConfiguration::Active) returns a list with at least one entry.

Referenced by QNetworkConfigurationManager().

◆ updateCompleted

void QNetworkConfigurationManager::updateCompleted ( )
signal

This signal is emitted when the configuration update has been completed.

Such an update can be initiated via updateConfigurations() .

Referenced by QNetworkConfigurationManager().

◆ updateConfigurations

void QNetworkConfigurationManager::updateConfigurations ( )
slot

Initiates an update of all configurations.

This may be used to initiate WLAN scans or other time consuming updates which may be required to obtain the correct state for configurations.

This call is asynchronous. On completion of this update the updateCompleted() signal is emitted. If new configurations are discovered or old ones were removed or changed the update process may trigger the emission of one or multiple configurationAdded(), configurationRemoved() and configurationChanged() signals.

If a configuration state changes as a result of this update all existing QNetworkConfiguration instances are updated automatically.

See also
allConfigurations()

Definition at line 393 of file qnetworkconfigmanager.cpp.

394 {
396  if (priv)
398 }
static QNetworkConfigurationManagerPrivate * connManager()
static const QMetaObjectPrivate * priv(const uint *data)

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