Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QNetworkConfigurationManager Class

TheQNetworkConfigurationManager class manages the network configurations provided by the system.More...

Header:#include <QNetworkConfigurationManager>
Since: Qt 4.7
Inherits:QObject

Public Types

flagsCapabilities
enumCapability { CanStartAndStopInterfaces, DirectConnectionRouting, SystemSessionSupport, ApplicationLevelRoaming, ..., NetworkSessionRequired }

Public Functions

QNetworkConfigurationManager(QObject * parent = 0)
virtual~QNetworkConfigurationManager()
QList<QNetworkConfiguration>allConfigurations(QNetworkConfiguration::StateFlags filter = 0) const
QNetworkConfigurationManager::Capabilitiescapabilities() const
QNetworkConfigurationconfigurationFromIdentifier(const QString & identifier) const
QNetworkConfigurationdefaultConfiguration() const
boolisOnline() const
  • 29 public functions inherited fromQObject

Public Slots

  • 1 public slot inherited fromQObject

Signals

voidconfigurationAdded(const QNetworkConfiguration & config)
voidconfigurationChanged(const QNetworkConfiguration & config)
voidconfigurationRemoved(const QNetworkConfiguration & config)
voidonlineStateChanged(bool isOnline)
voidupdateCompleted()

Additional Inherited Members

  • 1 property inherited fromQObject
  • 7 static public members inherited fromQObject
  • 8 protected functions inherited fromQObject

Detailed Description

TheQNetworkConfigurationManager 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.

AQNetworkConfiguration 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 viaallConfigurations(). If a new configuration is added or an existing one is removed or changed theconfigurationAdded(),configurationRemoved() andconfigurationChanged() signals are emitted respectively.

ThedefaultConfiguration() can be used when intending to immediately create a new network session without caring about the particular configuration. It returns aQNetworkConfiguration::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 viaQNetworkConfigurationManager::updateConfigurations(). The completion of the update process is indicated by emitting theupdateCompleted() signal. The update process ensures that every existingQNetworkConfiguration instance is updated. There is no need to ask for a renewed configuration list viaallConfigurations().

See alsoQNetworkConfiguration.

Member Type Documentation

enum QNetworkConfigurationManager::Capability
flags QNetworkConfigurationManager::Capabilities

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

ConstantValueDescription
QNetworkConfigurationManager::CanStartAndStopInterfaces0x00000001Network sessions and their underlying access points can be started and stopped. If this flag is not setQNetworkSession 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 beenclosed(). 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.
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 setQNetworkSession 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.

The Capabilities type is a typedef forQFlags<Capability>. It stores an OR combination of Capability values.

Member Function Documentation

QNetworkConfigurationManager::QNetworkConfigurationManager(QObject * parent = 0)

Constructs aQNetworkConfigurationManager with the givenparent.

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

[virtual]QNetworkConfigurationManager::~QNetworkConfigurationManager()

Frees the resources associated with theQNetworkConfigurationManager object.

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

Returns the list of configurations which comply with the givenfilter.

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.

Iffilter 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 stateupdateConfigurations() should be used to update each configuration's state. Note that such an update may require some time. It's completion is signalled byupdateCompleted(). 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 thatupdateConfigurations() is called once afterQNetworkConfigurationManager 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.

QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabilities() const

Returns the capabilities supported by the current platform.

[signal]void QNetworkConfigurationManager::configurationAdded(constQNetworkConfiguration & config)

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

[signal]void QNetworkConfigurationManager::configurationChanged(constQNetworkConfiguration & config)

This signal is emitted when thestate ofconfig changes.

QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier(constQString & identifier) const

Returns theQNetworkConfiguration foridentifier; otherwise returns an invalidQNetworkConfiguration.

See alsoQNetworkConfiguration::identifier().

[signal]void QNetworkConfigurationManager::configurationRemoved(constQNetworkConfiguration & config)

This signal is emitted when a configuration is about to be removed from the system. The removed configuration, specified byconfig, is invalid but retains name and identifier.

This function was introduced in Qt 4.8.

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 callupdateConfigurations() and wait for theupdateCompleted() signal before calling this function.

See alsoallConfigurations().

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:

QNetworkConfigurationManager mgr;QList<QNetworkConfiguration> activeConfigs= mgr.allConfigurations(QNetworkConfiguration::Active)if (activeConfigs.count()>0)Q_ASSERT(mgr.isOnline())elseQ_ASSERT(!mgr.isOnline())

See alsoonlineStateChanged().

[signal]void QNetworkConfigurationManager::onlineStateChanged(bool isOnline)

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 asallConfigurations(QNetworkConfiguration::Active) returns a list with at least one entry.

[signal]void QNetworkConfigurationManager::updateCompleted()

This signal is emitted when the configuration update has been completed. Such an update can be initiated viaupdateConfigurations().

[slot]void QNetworkConfigurationManager::updateConfigurations()

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 theupdateCompleted() 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 multipleconfigurationAdded(),configurationRemoved() andconfigurationChanged() signals.

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

See alsoallConfigurations().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp