Qt 4.8
|
The QNetworkConfigurationManager class manages the network configurations provided by the system. More...
#include <qnetworkconfigmanager.h>
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< QNetworkConfiguration > | allConfigurations (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 QObjectList & | children () 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< QByteArray > | dynamicPropertyNames () 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 > | |
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 QMetaObject * | metaObject () 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 |
QObject * | parent () 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... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (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... | |
QObject * | sender () 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< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QNetworkConfigurationManager class manages the network configurations provided by the system.
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().
Definition at line 66 of file qnetworkconfigmanager.h.
Specifies the system capabilities of the bearer API.
The possible values are:
Enumerator | |
---|---|
CanStartAndStopInterfaces | |
DirectConnectionRouting | |
SystemSessionSupport | |
ApplicationLevelRoaming | |
ForcedRoaming | |
DataStatistics | |
NetworkSessionRequired |
Definition at line 71 of file qnetworkconfigmanager.h.
|
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.
|
virtual |
Frees the resources associated with the QNetworkConfigurationManager object.
Definition at line 273 of file qnetworkconfigmanager.cpp.
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.
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().
|
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().
|
signal |
This signal is emitted when the QNetworkConfiguration::state(){state} of config changes.
Referenced by QNetworkConfigurationManager().
QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier | ( | const QString & | identifier | ) | const |
Returns the QNetworkConfiguration for identifier; otherwise returns an invalid QNetworkConfiguration.
Definition at line 339 of file qnetworkconfigmanager.cpp.
Referenced by QNetworkAccessManager::activeConfiguration(), QNetworkAccessManager::createRequest(), QNetworkAccessBackend::start(), and QNetworkSessionPrivateImpl::syncStateWithInterface().
|
signal |
This signal is emitted when a configuration is about to be removed from the system.
The removed configuration, specified by config, is invalid but retains name and identifier.
Referenced by QNetworkConfigurationManager().
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.
Definition at line 290 of file qnetworkconfigmanager.cpp.
Referenced by QNetworkAccessManager::createRequest().
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:
Definition at line 358 of file qnetworkconfigmanager.cpp.
|
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().
|
signal |
This signal is emitted when the configuration update has been completed.
Such an update can be initiated via updateConfigurations() .
Referenced by QNetworkConfigurationManager().
|
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.
Definition at line 393 of file qnetworkconfigmanager.cpp.