<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QNetworkConfigurationManager Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QNetworkConfigurationManager Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QNetworkConfigurationManager class manages the network configurations provided by the system. <a href="#details">More...</a></p> <p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Types</h3><ul><li><div class="fn" />class <b><a href="qnetworkconfigurationmanager-capabilities.html">Capabilities</a></b></li><li><div class="fn" />enum <b><a href="qnetworkconfigurationmanager.html#Capability-enum">Capability</a></b> { CanStartAndStopInterfaces, DirectConnectionRouting, SystemSessionSupport, ApplicationLevelRoaming, ..., NetworkSessionRequired }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qnetworkconfigurationmanager.html#QNetworkConfigurationManager">__init__</a></b> (<i>self</i>, QObject <i>parent</i> = None)</li><li><div class="fn" />list-of-QNetworkConfiguration <b><a href="qnetworkconfigurationmanager.html#allConfigurations">allConfigurations</a></b> (<i>self</i>, QNetworkConfiguration.StateFlags <i>flags</i> = 0)</li><li><div class="fn" />Capabilities <b><a href="qnetworkconfigurationmanager.html#capabilities">capabilities</a></b> (<i>self</i>)</li><li><div class="fn" />QNetworkConfiguration <b><a href="qnetworkconfigurationmanager.html#configurationFromIdentifier">configurationFromIdentifier</a></b> (<i>self</i>, QString <i>identifier</i>)</li><li><div class="fn" />QNetworkConfiguration <b><a href="qnetworkconfigurationmanager.html#defaultConfiguration">defaultConfiguration</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qnetworkconfigurationmanager.html#isOnline">isOnline</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qnetworkconfigurationmanager.html#updateConfigurations">updateConfigurations</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qnetworkconfigurationmanager.html#configurationAdded">configurationAdded</a></b> (const QNetworkConfiguration&)</li><li><div class="fn" />void <b><a href="qnetworkconfigurationmanager.html#configurationChanged">configurationChanged</a></b> (const QNetworkConfiguration&)</li><li><div class="fn" />void <b><a href="qnetworkconfigurationmanager.html#configurationRemoved">configurationRemoved</a></b> (const QNetworkConfiguration&)</li><li><div class="fn" />void <b><a href="qnetworkconfigurationmanager.html#onlineStateChanged">onlineStateChanged</a></b> (bool)</li><li><div class="fn" />void <b><a href="qnetworkconfigurationmanager.html#updateCompleted">updateCompleted</a></b> ()</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QNetworkConfigurationManager class manages the network configurations provided by the system.</p> <p>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.</p> <p>A <a href="qnetworkconfiguration.html">QNetworkConfiguration</a> 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 <a href="qnetworkconfigurationmanager.html#allConfigurations">allConfigurations</a>(). If a new configuration is added or an existing one is removed or changed the <a href="qnetworkconfigurationmanager.html#configurationAdded">configurationAdded</a>(), <a href="qnetworkconfigurationmanager.html#configurationRemoved">configurationRemoved</a>() and <a href="qnetworkconfigurationmanager.html#configurationChanged">configurationChanged</a>() signals are emitted respectively.</p> <p>The <a href="qnetworkconfigurationmanager.html#defaultConfiguration">defaultConfiguration</a>() can be used when intending to immediately create a new network session without caring about the particular configuration. It returns a <a href="qnetworkconfiguration.html#StateFlag-enum">QNetworkConfiguration.Discovered</a> configuration. If there are not any discovered ones an invalid configuration is returned.</p> <p>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 <a href="qnetworkconfigurationmanager.html#updateConfigurations">QNetworkConfigurationManager.updateConfigurations</a>(). The completion of the update process is indicted by emitting the <a href="qnetworkconfigurationmanager.html#updateCompleted">updateCompleted</a>() signal. The update process ensures that every existing <a href="qnetworkconfiguration.html">QNetworkConfiguration</a> instance is updated. There is no need to ask for a renewed configuration list via <a href="qnetworkconfigurationmanager.html#allConfigurations">allConfigurations</a>().</p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="Capability-enum" />QNetworkConfigurationManager.Capability</h3><p>Specifies the system capabilities of the bearer API. The possible values are:</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"> <tt>QNetworkConfigurationManager.CanStartAndStopInterfaces</tt></td> <td class="topAlign"><tt>0x00000001</tt></td> <td class="topAlign">Network sessions and their underlying access points can be started and stopped. If this flag is not set <a href="qnetworksession.html">QNetworkSession</a> 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.</td> </tr> <tr> <td class="topAlign"> <tt>QNetworkConfigurationManager.DirectConnectionRouting</tt></td> <td class="topAlign"><tt>0x00000002</tt></td> <td class="topAlign">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.</td> </tr> <tr> <td class="topAlign"> <tt>QNetworkConfigurationManager.SystemSessionSupport</tt></td> <td class="topAlign"><tt>0x00000004</tt></td> <td class="topAlign">If this flag is set the underlying platform ensures that a network interface is not shut down until the last network session has been <a href="qnetworksession.html#close">closed()</a>. 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.</td> </tr> <tr> <td class="topAlign"> <tt>QNetworkConfigurationManager.ApplicationLevelRoaming</tt></td> <td class="topAlign"><tt>0x00000008</tt></td> <td class="topAlign">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.</td> </tr> <tr> <td class="topAlign"> <tt>QNetworkConfigurationManager.ForcedRoaming</tt></td> <td class="topAlign"><tt>0x00000010</tt></td> <td class="topAlign">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.</td> </tr> <tr> <td class="topAlign"> <tt>QNetworkConfigurationManager.DataStatistics</tt></td> <td class="topAlign"><tt>0x00000020</tt></td> <td class="topAlign">If this flag is set <a href="qnetworksession.html">QNetworkSession</a> can provide statistics about transmitted and received data.</td> </tr> <tr> <td class="topAlign"> <tt>QNetworkConfigurationManager.NetworkSessionRequired</tt></td> <td class="topAlign"><tt>0x00000040</tt></td> <td class="topAlign">If this flag is set the platform requires that a network session is created before network operations can be performed.</td> </tr> </table> <p>The Capabilities type is a typedef for <a href="qflags.html">QFlags</a><Capability>. It stores an OR combination of Capability values.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QNetworkConfigurationManager" />QNetworkConfigurationManager.__init__ (<i>self</i>, <a href="qobject.html">QObject</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qnetworkconfigurationmanager.html">QNetworkConfigurationManager</a> with the given <i>parent</i>.</p> <p>Note that to ensure a valid list of current configurations immediately available, updating is done during construction which causes some delay.</p> <h3 class="fn"><a name="allConfigurations" />list-of-QNetworkConfiguration QNetworkConfigurationManager.allConfigurations (<i>self</i>, <a href="qnetworkconfiguration-stateflags.html">QNetworkConfiguration.StateFlags</a> <i>flags</i> = 0)</h3><p>Returns the list of configurations which comply with the given <i>filter</i>.</p> <p>By default this function returns all (defined and undefined) configurations.</p> <p>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.</p> <p>If <i>filter</i> is set to zero this function returns all possible configurations.</p> <p>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 <a href="qnetworkconfigurationmanager.html#updateConfigurations">updateConfigurations</a>() should be used to update each configuration's state. Note that such an update may require some time. It's completion is signalled by <a href="qnetworkconfigurationmanager.html#updateCompleted">updateCompleted</a>(). 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 <a href="qnetworkconfigurationmanager.html#updateConfigurations">updateConfigurations</a>() is called once after <a href="qnetworkconfigurationmanager.html">QNetworkConfigurationManager</a> 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.</p> <h3 class="fn"><a name="capabilities" /><a href="qnetworkconfigurationmanager-capabilities.html">Capabilities</a> QNetworkConfigurationManager.capabilities (<i>self</i>)</h3><p>Returns the capabilities supported by the current platform.</p> <h3 class="fn"><a name="configurationFromIdentifier" /><a href="qnetworkconfiguration.html">QNetworkConfiguration</a> QNetworkConfigurationManager.configurationFromIdentifier (<i>self</i>, QString <i>identifier</i>)</h3><p>Returns the <a href="qnetworkconfiguration.html">QNetworkConfiguration</a> for <i>identifier</i>; otherwise returns an invalid <a href="qnetworkconfiguration.html">QNetworkConfiguration</a>.</p> <p><b>See also</b> <a href="qnetworkconfiguration.html#identifier">QNetworkConfiguration.identifier</a>().</p> <h3 class="fn"><a name="defaultConfiguration" /><a href="qnetworkconfiguration.html">QNetworkConfiguration</a> QNetworkConfigurationManager.defaultConfiguration (<i>self</i>)</h3><p>Returns the default configuration to be used. This function always returns a discovered configuration; otherwise an invalid configuration.</p> <p>In some cases it may be required to call <a href="qnetworkconfigurationmanager.html#updateConfigurations">updateConfigurations</a>() and wait for the <a href="qnetworkconfigurationmanager.html#updateCompleted">updateCompleted</a>() signal before calling this function.</p> <p><b>See also</b> <a href="qnetworkconfigurationmanager.html#allConfigurations">allConfigurations</a>().</p> <h3 class="fn"><a name="isOnline" />bool QNetworkConfigurationManager.isOnline (<i>self</i>)</h3><p>Returns true if the system is considered to be connected to another device via an active network interface; otherwise returns false.</p> <p>This is equivalent to the following code snippet:</p> <pre class="cpp"> <span class="type"><a href="qnetworkconfigurationmanager.html">QNetworkConfigurationManager</a></span> mgr; <span class="type"><a href="qlist.html">QList</a></span><span class="operator"><</span><span class="type"><a href="qnetworkconfiguration.html">QNetworkConfiguration</a></span><span class="operator">></span> activeConfigs <span class="operator">=</span> mgr<span class="operator">.</span><a href="qnetworkconfigurationmanager.html#allConfigurations">allConfigurations</a>(<span class="type"><a href="qnetworkconfiguration.html">QNetworkConfiguration</a></span><span class="operator">.</span>Active) <span class="keyword">if</span> (activeConfigs<span class="operator">.</span>count() <span class="operator">></span> <span class="number">0</span>) <a href="qtcore.html#Q_ASSERT">Q_ASSERT</a>(mgr<span class="operator">.</span>isOnline()) <span class="keyword">else</span> <a href="qtcore.html#Q_ASSERT">Q_ASSERT</a>(<span class="operator">!</span>mgr<span class="operator">.</span>isOnline()) </pre> <p><b>See also</b> <a href="qnetworkconfigurationmanager.html#onlineStateChanged">onlineStateChanged</a>().</p> <h3 class="fn"><a name="updateConfigurations" />QNetworkConfigurationManager.updateConfigurations (<i>self</i>)</h3><p>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.</p> <p>This call is asynchronous. On completion of this update the <a href="qnetworkconfigurationmanager.html#updateCompleted">updateCompleted</a>() 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 <a href="qnetworkconfigurationmanager.html#configurationAdded">configurationAdded</a>(), <a href="qnetworkconfigurationmanager.html#configurationRemoved">configurationRemoved</a>() and <a href="qnetworkconfigurationmanager.html#configurationChanged">configurationChanged</a>() signals.</p> <p>If a configuration state changes as a result of this update all existing <a href="qnetworkconfiguration.html">QNetworkConfiguration</a> instances are updated automatically.</p> <p><b>See also</b> <a href="qnetworkconfigurationmanager.html#allConfigurations">allConfigurations</a>().</p> <hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="configurationAdded" />void configurationAdded (const QNetworkConfiguration&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever a new network configuration is added to the system. The new configuration is specified by <i>config</i>.</p> <h3 class="fn"><a name="configurationChanged" />void configurationChanged (const QNetworkConfiguration&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the <a href="qnetworkconfiguration.html#state">state</a> of <i>config</i> changes.</p> <h3 class="fn"><a name="configurationRemoved" />void configurationRemoved (const QNetworkConfiguration&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when a configuration is about to be removed from the system. The removed configuration, specified by <i>config</i>, is invalid but retains name and identifier.</p> <p>This function was introduced in Qt 4.8.</p> <h3 class="fn"><a name="onlineStateChanged" />void onlineStateChanged (bool)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the device changes from online to offline mode or vice versa. <i>isOnline</i> represents the new state of the device.</p> <p>The state is considered to be online for as long as <a href="qnetworkconfigurationmanager.html#allConfigurations">allConfigurations</a>(<a href="qnetworkconfiguration.html#StateFlag-enum">QNetworkConfiguration.Active</a>) returns a list with at least one entry.</p> <h3 class="fn"><a name="updateCompleted" />void updateCompleted ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the configuration update has been completed. Such an update can be initiated via <a href="qnetworkconfigurationmanager.html#updateConfigurations">updateConfigurations</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>