CopperSpice API  1.7.2
QNetworkConfigurationManager Class Reference

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

Inheritance diagram for QNetworkConfigurationManager:
QObject

Public Typedefs

using Capabilities = QFlags< Capability >
 

Public Types

enum  Capability
 

Public Signals

void configurationAdded (const QNetworkConfiguration &config)
 
void configurationChanged (const QNetworkConfiguration &config)
 
void configurationRemoved (const QNetworkConfiguration &config)
 
void onlineStateChanged (bool isOnline)
 
void updateCompleted ()
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

void updateConfigurations ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QNetworkConfigurationManager (QObject *parent=nullptr)
 
virtual ~QNetworkConfigurationManager ()
 
QList< QNetworkConfigurationallConfigurations (QNetworkConfiguration::StateFlags flags=QNetworkConfiguration::StateFlags ()) const
 
QNetworkConfigurationManager::Capabilities capabilities () const
 
QNetworkConfiguration configurationFromIdentifier (const QString &identifier) const
 
QNetworkConfiguration defaultConfiguration () const
 
bool isOnline () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &objName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Additional Inherited Members

- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

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().

See also
QNetworkConfiguration

Member Typedef Documentation

Member Enumeration Documentation

Specifies the system capabilities of the bearer API. The possible values are:

Constant Value Description
QNetworkConfigurationManager::CanStartAndStopInterfaces0x00000001Network 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.
QNetworkConfigurationManager::DirectConnectionRouting0x00000002Network 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.
QNetworkConfigurationManager::SystemSessionSupport0x00000004If 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 have such support whereas most desktop platform lack this capability.
QNetworkConfigurationManager::ApplicationLevelRoaming0x00000008The 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.
QNetworkConfigurationManager::ForcedRoaming0x00000010The 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.
QNetworkConfigurationManager::DataStatistics0x00000020If this flag is set QNetworkSession can provide statistics about transmitted and received data.
QNetworkConfigurationManager::NetworkSessionRequired0x00000040If this flag is set the platform requires that a network session is created before network operations can be performed.

Constructor & Destructor Documentation

QNetworkConfigurationManager::QNetworkConfigurationManager ( QObject parent = nullptr)
explicit

Constructs a QNetworkConfigurationManager with the given parent. To ensure a valid list of current configurations are immediately available, updating is done during construction which causes some delay.

QNetworkConfigurationManager::~QNetworkConfigurationManager ( )
virtual

Frees the resources associated with the QNetworkConfigurationManager object.

Method Documentation

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

Returns the list of configurations which comply with the given flags. By default this method returns a list of all the defined and undefined configurations. If flags is empty this method returns all possible 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.

This method returns the states for all configurations as they are known at the time of this method call. If 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. This operation may be slow. The completion is signalled by updateCompleted().

In the absence of a configuration update this method 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 todate as the system reports any changes.

QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabilities ( ) const

Returns the capabilities supported by the current platform.

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.

void QNetworkConfigurationManager::configurationChanged ( const QNetworkConfiguration config)
signal

This signal is emitted when the state of config changes.

QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier ( const QString identifier) const

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

See also
QNetworkConfiguration::identifier()
void QNetworkConfigurationManager::configurationRemoved ( const QNetworkConfiguration config)
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.

QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration ( ) const

Returns the default configuration to be used. This method 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 method.

See also
allConfigurations()
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 example.

QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active)
if (activeConfigs.count() > 0) {
} else {
Q_ASSERT( !mgr.isOnline())
}
See also
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.

void QNetworkConfigurationManager::updateCompleted ( )
signal

This signal is emitted when the configuration update has been completed. Such an update can be initiated via 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()