Detailed Description
The QNetworkConnection class provides monitoring of network connections.
Each QNetworkDevice can only be connected to one remote network at a time. However some devices can potentially connect to different remote networks without the need to reconfigure. An example are WLAN devices which maintain an internal list of known WLAN access points. QNetworkConnection exposes the connection state based on the connection partner. Thus a single WLAN QNetworkDevice may actually have several QNetworkConnections with distinct identities associated to it . Consequently if the QNetworkDevice is connected only one associated QNetworkConnection is online. Use QNetworkConnection::Identity to distinguish network connections.
In order to keep track of network connections the QNetworkConnectionManager should be used.
QNetworkConnectionManager manager;
QNetworkConnection::Identities idents = manager.connections();
QNetworkConnection connection( idents.at(0) );
The validity of a QNetworkConnection object depends on the validity of its network connection identity. The validity can be checked with isValid(). Once a connection is invalid it can never become valid anymore. This can occur if the user deletes a network interface or he removes a WLAN access point configuration. It is then required to reacquire a new identity via QNetworkConnectionManager::connections().
See also QNetworkConnectionManager.
Member Type Documentation
typedef QNetworkConnection::Identities
This is a convenience typedef to encapsulate a list of QNetworkConnection::Identity objects. The exact type is:
QList<QNetwork::Identity>
Member Function Documentation
QNetworkConnection::QNetworkConnection ( const Identity & ident, QObject * parent = 0 )
Constrcuts a new QNetworkConnection based on ident with the given parent. References to Network identities can be obtained via QNetworkConnectionManager.
QNetworkConnection::~QNetworkConnection () [virtual]
Destroys a QNetworkConnection instance.
void QNetworkConnection::connectivityChanged ( bool isConnected ) [signal]
This signal is emitted when the connection changes from offline to online and vice versa.
isConnected is true when the associated network device's state is equal to QtopiaNetworkInterface::Up. If it is required to keep track of the precise device state QNetworkDevice should be used.
Identity QNetworkConnection::identity () const
Returns the idenity object associated to this network connection. The identity object provides further details about this network connection object.
bool QNetworkConnection::isConnected () const
This function returns true if the connection is established. A connection is considered to be established if the underlying device state is equal to QtopiaNetworkInterface::Up.
If it is necessary to distinguish the various types of connectivity QNetworkDevice::state() should be used.
bool QNetworkConnection::isValid () const
Returns true if this network connection is valid; otherwise false.
An invalid QNetworkConnection has an invalid identity. This may happen when initialising this object with an invalid identity or when the underlying network configuration has been deleted (e.g. the user removed the configuration for WLAN with ESSID "xyz").
A transition from a valid to an invalid state can be noticed by connecting to the QNetworkConnectionManager::connectionRemoved() signal.