Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtNetwork.QNetworkSession Class Reference

The QNetworkSession class provides control over the system's access points and enables session management for cases when multiple clients access the same access point. More...

Inheritance diagram for QtNetwork.QNetworkSession:
Collaboration diagram for QtNetwork.QNetworkSession:

Public Types

enum  SessionError {
  InvalidConfigurationError = 4, OperationNotSupportedError = 3, RoamingError = 2, SessionAbortedError = 1,
  UnknownSessionError = 0
}
  More...
 
enum  State {
  Closing = 4, Connected = 3, Connecting = 2, Disconnected = 5,
  Invalid = 0, NotAvailable = 1, Roaming = 6
}
  More...
 

Public Member Functions

 QNetworkSession (QNetworkConfiguration connConfig, QObject parent=null)
 
 
override void CreateProxy ()
 
new void Accept ()
 
 
new ulong ActiveTime ()
 
 
new ulong BytesReceived ()
 
 
new ulong BytesWritten ()
 
 
new void Close ()
 
 
new QNetworkConfiguration Configuration ()
 
 
new QNetworkSession.SessionError OnError ()
 
 
new string ErrorString ()
 
 
new void Ignore ()
 
 
new QNetworkInterface Interface ()
 
 
new bool IsOpen ()
 
 
new void Migrate ()
 
 
new void Open ()
 
 
new void Reject ()
 
 
new object SessionProperty (string key)
 
 
new void SetSessionProperty (string key, object value)
 
 
new QNetworkSession.State state ()
 
 
new void Stop ()
 
 
new bool WaitForOpened (int msecs=30000)
 
 
new void Dispose ()
 
- Public Member Functions inherited from QtCore.QObject
 QObject (QObject parent=null)
 
 
new bool BlockSignals (bool b)
 
 
new
System.Collections.Generic.List
< QObject
Children ()
 
 
new bool Connect (QObject sender, string signal, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection)
 
 
new void DeleteLater ()
 
 
new bool Disconnect (QObject receiver, string member=null)
 
 
new bool Disconnect (string signal=null, QObject receiver=null, string member=null)
 
 
new void DumpObjectInfo ()
 
 
new void DumpObjectTree ()
 
 
new
System.Collections.Generic.List
< QByteArray
DynamicPropertyNames ()
 
 
virtual bool OnEvent (QEvent arg1)
 
 
virtual bool EventFilter (QObject arg1, QEvent arg2)
 
 
new bool Inherits (string classname)
 
 
new void InstallEventFilter (QObject arg1)
 
 
new bool IsWidgetType ()
 
 
new void KillTimer (int id)
 
 
new object Property (string name)
 
 
new void RemoveEventFilter (QObject arg1)
 
 
new bool SetProperty (string name, object value)
 
 
new void SetUserData (uint id, QObjectUserData data)
 
new bool SignalsBlocked ()
 
 
new int StartTimer (int interval)
 
 
new QObjectUserData UserData (uint id)
 
new void Dispose ()
 
- Public Member Functions inherited from QtCore.Qt
delegate QTextStream FuncQTextStreamQTextStream (QTextStream qTextStream)
 
delegate string FuncStringQByteArray (QByteArray qByteArray)
 
delegate QByteArray FuncQByteArrayString (string @string)
 
delegate void ActionQtMsgTypeString (QtMsgType qtMsgType, string @string)
 
delegate QObject FuncQObject ()
 

Static Public Member Functions

static string Tr (string s, string c=null)
 
static string Tr (string s, string c, int n)
 
static string TrUtf8 (string s, string c=null)
 
static string TrUtf8 (string s, string c, int n)
 
- Static Public Member Functions inherited from QtCore.QObject
static bool Connect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod method, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection)
 
 
static bool Connect (QObject sender, string signal, QObject receiver, string member, Qt.ConnectionType arg5=Qt.ConnectionType.AutoConnection)
 
 
static bool Disconnect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod member)
 
 
static bool Disconnect (QObject sender, string signal, QObject receiver, string member)
 
 
static uint RegisterUserData ()
 
static string Tr (string s, string c=null)
 
 
static string Tr (string s, string c, int n)
 
 
static string TrUtf8 (string s, string c=null)
 
 
static string TrUtf8 (string s, string c, int n)
 
 
- Static Public Member Functions inherited from QtCore.Qt
static QDataStream Write (QDataStream s, object p)
 
static QDataStream Write (QDataStream arg1, QSizeF arg2)
 
static QTextStream Write (QTextStream s, Qt.FuncQTextStreamQTextStream f)
 
static QDataStream Write (QDataStream arg1, QPoint arg2)
 
static QDataStream Write (QDataStream arg1, QLineF arg2)
 
static QDataStream Write (QDataStream arg1, QPointF arg2)
 
static QDataStream Write (QDataStream arg1, QChar arg2)
 
static QDataStream Write (QDataStream arg1, QByteArray arg2)
 
static QDataStream Write (QDataStream arg1, QEasingCurve arg2)
 
static QDataStream Write (QDataStream arg1, QRectF arg2)
 
static QDataStream Write (QDataStream arg1, QDateTime arg2)
 
static QDataStream Write (QDataStream arg1, QUrl arg2)
 
static QDataStream Write (QDataStream arg1, QTime arg2)
 
static QDataStream Write (QDataStream arg1, QLocale arg2)
 
static QDataStream Write (QDataStream arg1, QBitArray arg2)
 
static QDataStream Write (QDataStream arg1, QUuid arg2)
 
static QDataStream Write (QDataStream arg1, QLine arg2)
 
static QDataStream Write (QDataStream arg1, QDate arg2)
 
static QDataStream Write (QDataStream @out, QRegExp regExp)
 
static QDataStream Write (QDataStream arg1, QRect arg2)
 
static QDataStream Write (QDataStream arg1, QSize arg2)
 
static QDataStream Write (QDataStream s, QVariant.Type p)
 
static QDataStream Write (QDataStream arg1, string arg2)
 
static QDataStream Write (QDataStream @out, System.Collections.Generic.List< string > list)
 
static QDataStream Read (QDataStream arg1, QChar arg2)
 
static QDataStream Read (QDataStream arg1, QLocale arg2)
 
static QDataStream Read (QDataStream arg1, QRect arg2)
 
static QDataStream Read (QDataStream arg1, QEasingCurve arg2)
 
static QDataStream Read (QDataStream arg1, QDate arg2)
 
static QDataStream Read (QDataStream arg1, QUrl arg2)
 
static QDataStream Read (QDataStream arg1, QUuid arg2)
 
static QTextStream Read (QTextStream s, Qt.FuncQTextStreamQTextStream f)
 
static QDataStream Read (QDataStream arg1, QLineF arg2)
 
static QDataStream Read (QDataStream arg1, QRectF arg2)
 
static QDataStream Read (QDataStream arg1, QPointF arg2)
 
static QDataStream Read (QDataStream arg1, QLine arg2)
 
static QDataStream Read (QDataStream arg1, QBitArray arg2)
 
static QDataStream Read (QDataStream arg1, QSize arg2)
 
static QDataStream Read (QDataStream arg1, QDateTime arg2)
 
static QDataStream Read (QDataStream arg1, QTime arg2)
 
static QDataStream Read (QDataStream arg1, QPoint arg2)
 
static QDataStream Read (QDataStream @in, QRegExp regExp)
 
static QDataStream Read (QDataStream s, object p)
 
static QDataStream Read (QDataStream arg1, QByteArray arg2)
 
static QDataStream Read (QDataStream arg1, QSizeF arg2)
 
static QDataStream Read (QDataStream arg1, string arg2)
 
static QDataStream Read (QDataStream s, QVariant.Type p)
 
static QDataStream Read (QDataStream @in, System.Collections.Generic.List< string > list)
 
static double qAcos (double v)
 
static void qAddPostRoutine (System.Action arg1)
 
static string qAppName ()
 
static double qAsin (double v)
 
static double qAtan (double v)
 
static double qAtan2 (double x, double y)
 
static void qBadAlloc ()
 
static int qCeil (double v)
 
static ushort qChecksum (string s, uint len)
 
static QByteArray qCompress (QByteArray data)
 
static QByteArray qCompress (QByteArray data, int compressionLevel=-1)
 
static QByteArray qCompress (Pointer< byte > data, int nbytes)
 
static QByteArray qCompress (Pointer< byte > data, int nbytes, int compressionLevel=-1)
 
static double qCos (double v)
 
static double qExp (double v)
 
static double qFabs (double v)
 
static double qFastCos (double x)
 
static double qFastSin (double x)
 
static string qFlagLocation (string method)
 
static int qFloor (double v)
 
static bool qFuzzyCompare (double p1, double p2)
 
static bool qFuzzyCompare (float p1, float p2)
 
static bool qFuzzyIsNull (double d)
 
static bool qFuzzyIsNull (float f)
 
static uint qHash (QBitArray key)
 
static uint qHash (QChar key)
 
static uint qHash (QStringRef key)
 
static uint qHash (QUrl url)
 
static uint qHash (QPersistentModelIndex index)
 
static uint qHash (QByteArray key)
 
static uint qHash (QModelIndex index)
 
static uint qHash (uint key)
 
static uint qHash (sbyte key)
 
static uint qHash (byte key)
 
static uint qHash (short key)
 
static uint qHash (NativeLong key)
 
static uint qHash (ushort key)
 
static uint qHash (long key)
 
static uint qHash (ulong key)
 
static uint qHash (int key)
 
static uint qHash (string key)
 
static uint qHash (NativeULong key)
 
static double qInf ()
 
static Qt.ActionQtMsgTypeString qInstallMsgHandler (Qt.ActionQtMsgTypeString arg1)
 
static int qIntCast (float f)
 
static int qIntCast (double f)
 
static bool qIsFinite (double d)
 
static bool qIsFinite (float f)
 
static bool qIsInf (float f)
 
static bool qIsInf (double d)
 
static bool qIsNaN (float f)
 
static bool qIsNaN (double d)
 
static bool qIsNull (float f)
 
static bool qIsNull (double d)
 
static double qLn (double v)
 
static double qPow (double x, double y)
 
static double qQNaN ()
 
static void qRegisterStaticPluginInstanceFunction (Qt.FuncQObject function)
 
static void qRemovePostRoutine (System.Action arg1)
 
static int qRound (double d)
 
static long qRound64 (double d)
 
static double qSNaN ()
 
static bool qSharedBuild ()
 
static double qSin (double v)
 
static double qSqrt (double v)
 
static bool qStringComparisonHelper (QStringRef s1, string s2)
 
static double qTan (double v)
 
static QByteArray qUncompress (QByteArray data)
 
static QByteArray qUncompress (Pointer< byte > data, int nbytes)
 
static string qVersion ()
 
static void Qbswap_helper (Pointer< byte > src, Pointer< byte > dest, int size)
 
static QByteArray Qgetenv (string varName)
 
static bool Qputenv (string varName, QByteArray value)
 
static int Qrand ()
 
static void Qsrand (uint seed)
 
static int Qstrcmp (QByteArray str1, QByteArray str2)
 
static int Qstrcmp (QByteArray str1, string str2)
 
static int Qstrcmp (string str1, QByteArray str2)
 
static int Qstrcmp (string str1, string str2)
 
static Pointer< sbyte > Qstrcpy (Pointer< sbyte > dst, string src)
 
static Pointer< sbyte > Qstrdup (string arg1)
 
static int Qstricmp (string arg1, string arg2)
 
static uint Qstrlen (string str)
 
static int Qstrncmp (string str1, string str2, uint len)
 
static Pointer< sbyte > Qstrncpy (Pointer< sbyte > dst, string src, uint len)
 
static int Qstrnicmp (string arg1, string arg2, uint len)
 
static uint Qstrnlen (string str, uint maxlen)
 
static string QtTrId (string id, int n=-1)
 

Protected Member Functions

 QNetworkSession (System.Type dummy)
 
new void OnClosed ()
 
 
override void ConnectNotify (string signal)
 
 
override void DisconnectNotify (string signal)
 
 
new void OnError (QNetworkSession.SessionError arg1)
 
 
new void OnNewConfigurationActivated ()
 
 
new void OnOpened ()
 
 
new void OnPreferredConfigurationChanged (QNetworkConfiguration config, bool isSeamless)
 
 
new void OnStateChanged (QNetworkSession.State arg1)
 
 
- Protected Member Functions inherited from QtCore.QObject
 QObject (System.Type dummy)
 
virtual void OnChildEvent (QChildEvent arg1)
 
 
virtual void OnCustomEvent (QEvent arg1)
 
 
new void OnDestroyed (QObject arg1=null)
 
 
new int Receivers (string signal)
 
 
new QObject Sender ()
 
 
new int SenderSignalIndex ()
 
 
virtual void OnTimerEvent (QTimerEvent arg1)
 
 

Properties

Slot< QNetworkSession.StateStateChanged
 
 
Slot Opened
 
 
Slot Closed
 
 
Slot
< QNetworkSession.SessionError
Error
 
 
Slot< QNetworkConfiguration,
System.Boolean > 
PreferredConfigurationChanged
 
 
Slot NewConfigurationActivated
 
 
static new QMetaObject StaticMetaObject [get]
 
new IQNetworkSessionSignals Emit [get]
 
- Properties inherited from QtCore.QObject
virtual EventHandler
< QEventArgs< QChildEvent > > 
ChildEvent
 
 
virtual EventHandler
< QEventArgs< QEvent > > 
CustomEvent
 
 
virtual EventHandler
< QEventArgs< QEvent > > 
Event
 
 
virtual EventHandler
< QEventArgs< QTimerEvent > > 
TimerEvent
 
 
Slot< QObjectDestroyedQObject
 
Slot Destroyed
 
 
new QObject Parent [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 
new string ObjectName [get, set]
 
 
static new QMetaObject StaticMetaObject [get]
 
 
static new QMetaObject StaticQtMetaObject [get]
 
new IQObjectSignals Emit [get]
 

Additional Inherited Members

- Protected Attributes inherited from QtCore.QObject
object Q_EMIT = null
 
SmokeInvocation interceptor
 
readonly List< QEventHandler > eventFilters = new List<QEventHandler>()
 

Detailed Description

The QNetworkSession class provides control over the system's access points and enables session management for cases when multiple clients access the same access point.

A QNetworkSession enables control over the system's network interfaces. The session's configuration parameter are determined via the QNetworkConfiguration object to which it is bound. Depending on the type of the session (single access point or service network) a session may be linked to one or more network interfaces. By means of opening and closing of network sessions a developer can start and stop the systems network interfaces. If the configuration represents multiple access points (see QNetworkConfiguration::ServiceNetwork) more advanced features such as roaming may be supported.

QNetworkSession supports session management within the same process and depending on the platform's capabilities may support out-of-process sessions. If the same network configuration is used by multiple open sessions the underlying network interface is only terminated once the last session has been closed.

Roaming

Applications may connect to the preferredConfigurationChanged() signal in order to receive notifications when a more suitable access point becomes available. In response to this signal the application must either initiate the roaming via migrate() or ignore() the new access point. Once the session has roamed the newConfigurationActivated() signal is emitted. The application may now test the carrier and must either accept() or reject() it. The session will return to the previous access point if the roaming was rejected. The subsequent state diagram depicts the required state transitions.

Some platforms may distinguish forced roaming and application level roaming (ALR). ALR implies that the application controls (via migrate(), ignore(), accept() and reject()) whether a network session can roam from one access point to the next. Such control is useful if the application maintains stateful socket connections and wants to control the transition from one interface to the next. Forced roaming implies that the system automatically roams to the next network without consulting the application. This has the advantage that the application can make use of roaming features without actually being aware of it. It is expected that the application detects that the underlying socket is broken and automatically reconnects via the new network link.

If the platform supports both modes of roaming, an application indicates its preference by connecting to the preferredConfigurationChanged() signal. Connecting to this signal means that the application wants to take control over the roaming behavior and therefore implies application level roaming. If the client does not connect to the preferredConfigurationChanged(), forced roaming is used. If forced roaming is not supported the network session will not roam by default.

Some applications may want to suppress any form of roaming altogether. Possible use cases may be high priority downloads or remote services which cannot handle a roaming enabled client. Clients can suppress roaming by connecting to the preferredConfigurationChanged() signal and answer each signal emission with ignore().

See also QNetworkConfiguration and QNetworkConfigurationManager.

Member Enumeration Documentation

This enum describes the session errors that can occur.

Enumerator:
InvalidConfigurationError 

The operation cannot currently be performed for the current configuration.

OperationNotSupportedError 

The operation is not supported for current configuration.

RoamingError 

The session cannot roam to a new configuration.

SessionAbortedError 

The session was aborted by the user or system.

UnknownSessionError 

An unidentified error occurred.

This enum describes the connectivity state of the session. If the session is based on a single access point configuration the state of the session is the same as the state of the associated network interface.

Enumerator:
Closing 

The network session is in the process of being shut down.

Connected 

The network session is connected. If the current process wishes to use this session it has to register its interest by calling open(). A network session is considered to be ready for socket operations if it isOpen() and connected.

Connecting 

The network session is being established.

Disconnected 

The network session is not connected. The associated QNetworkConfiguration has the state QNetworkConfiguration::Discovered.

Invalid 

The session is invalid due to an invalid configuration. This may happen due to a removed access point or a configuration that was invalid to begin with.

NotAvailable 

The session is based on a defined but not yet discovered QNetworkConfiguration (see QNetworkConfiguration::StateFlag).

Roaming 

The network session is roaming from one access point to another access point.

Constructor & Destructor Documentation

QtNetwork.QNetworkSession.QNetworkSession ( System.Type  dummy)
protected
QtNetwork.QNetworkSession.QNetworkSession ( QNetworkConfiguration  connConfig,
QObject  parent = null 
)

Constructs a session based on connectionConfig with the given parent.

See also QNetworkConfiguration.

Member Function Documentation

new void QtNetwork.QNetworkSession.Accept ( )

Instructs the session to permanently accept the new access point. Once this function has been called the session may not return to the old access point.

The old access point may be closed in the process if there are no other network sessions for it. Therefore any open socket that still uses the old access point may become unusable and should be closed before completing the migration.

new ulong QtNetwork.QNetworkSession.ActiveTime ( )

Returns the number of seconds that the session has been active.

new ulong QtNetwork.QNetworkSession.BytesReceived ( )

Returns the amount of data received in bytes; otherwise 0.

This field value includes the usage across all open network sessions which use the same network interface.

If the session is based on a service network configuration the number of sent bytes across all active member configurations are returned.

This function may not always be supported on all platforms and returns 0. The platform capability can be detected via QNetworkConfigurationManager::DataStatistics.

Note: On some platforms this function may run the main event loop.

new ulong QtNetwork.QNetworkSession.BytesWritten ( )

Returns the amount of data sent in bytes; otherwise 0.

This field value includes the usage across all open network sessions which use the same network interface.

If the session is based on a service network configuration the number of sent bytes across all active member configurations are returned.

This function may not always be supported on all platforms and returns 0. The platform capability can be detected via QNetworkConfigurationManager::DataStatistics.

Note: On some platforms this function may run the main event loop.

new void QtNetwork.QNetworkSession.Close ( )

Decreases the session counter on the associated network configuration. If the session counter reaches zero the active network interface is shut down. This also means that state() will only change from Connected to Disconnected if the current session was the last open session.

If the platform does not support out-of-process sessions calling this function does not stop the interface. In this case stop() has to be used to force a shut down. The platform capabilities can be detected via QNetworkConfigurationManager::capabilities().

Note that this call is asynchronous. Depending on the outcome of this call the results can be enquired by connecting to the stateChanged(), opened() or error() signals.

See also open(), stop(), and isOpen().

new QNetworkConfiguration QtNetwork.QNetworkSession.Configuration ( )

Returns the QNetworkConfiguration that this network session object is based on.

See also QNetworkConfiguration.

override void QtNetwork.QNetworkSession.ConnectNotify ( string  signal)
protectedvirtual

This virtual function is called when something has been connected to signal in this object.

If you want to compare signal with a specific signal, use QLatin1String and the SIGNAL() macro as follows:

if (QLatin1String(signal) == SIGNAL(valueChanged(int))) {

// signal is valueChanged(int)

}

If the signal contains multiple parameters or parameters that contain spaces, call QMetaObject::normalizedSignature() on the result of the SIGNAL() macro.

Warning: This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.

See also connect() and disconnectNotify().

Reimplemented from QtCore.QObject.

override void QtNetwork.QNetworkSession.CreateProxy ( )
virtual

Reimplemented from QtCore.QObject.

override void QtNetwork.QNetworkSession.DisconnectNotify ( string  signal)
protectedvirtual

This virtual function is called when something has been disconnected from signal in this object.

See connectNotify() for an example of how to compare signal with a specific signal.

Warning: This function violates the object-oriented principle of modularity. However, it might be useful for optimizing access to expensive resources.

See also disconnect() and connectNotify().

Reimplemented from QtCore.QObject.

new void QtNetwork.QNetworkSession.Dispose ( )
new string QtNetwork.QNetworkSession.ErrorString ( )

Returns a human-readable description of the last device error that occurred.

See also error().

new void QtNetwork.QNetworkSession.Ignore ( )

This function indicates that the application does not wish to roam the session.

See also migrate().

new QNetworkInterface QtNetwork.QNetworkSession.Interface ( )

Returns the network interface that is used by this session.

This function only returns a valid QNetworkInterface when this session is Connected.

The returned interface may change as a result of a roaming process.

Note: this function does not work in Symbian emulator due to the way the connectivity is emulated on Windows.

See also state().

new bool QtNetwork.QNetworkSession.IsOpen ( )

Returns true if this session is open. If the number of all open sessions is greater than zero the underlying network interface will remain connected/up.

The session can be controlled via open() and close().

new void QtNetwork.QNetworkSession.Migrate ( )

Instructs the session to roam to the new access point. The old access point remains active until the application calls accept().

The newConfigurationActivated() signal is emitted once roaming has been completed.

See also accept().

new void QtNetwork.QNetworkSession.OnClosed ( )
protected

This signal is emitted when the network session has been closed.

new QNetworkSession.SessionError QtNetwork.QNetworkSession.OnError ( )

Returns the type of error that last occurred.

See also state() and errorString().

new void QtNetwork.QNetworkSession.OnError ( QNetworkSession.SessionError  arg1)
protected

Returns the type of error that last occurred.

See also state() and errorString().

new void QtNetwork.QNetworkSession.OnNewConfigurationActivated ( )
protected

This signal is emitted once the session has roamed to the new access point. The application may reopen its socket and test the suitability of the new network link. Subsequently it must either accept() or reject() the new access point.

See also accept() and reject().

new void QtNetwork.QNetworkSession.OnOpened ( )
protected

This signal is emitted when the network session has been opened.

The underlying network interface will not be shut down as long as the session remains open. Note that this feature is dependent on system wide session support.

new void QtNetwork.QNetworkSession.OnPreferredConfigurationChanged ( QNetworkConfiguration  config,
bool  isSeamless 
)
protected

This signal is emitted when the preferred configuration/access point for the session changes. Only sessions which are based on service network configurations may emit this signal. config can be used to determine access point specific details such as proxy settings and isSeamless indicates whether roaming will break the sessions IP address.

As a consequence to this signal the application must either start the roaming process by calling migrate() or choose to ignore() the new access point.

If the roaming process is non-seamless the IP address will change which means that a socket becomes invalid. However seamless mobility can ensure that the local IP address does not change. This is achieved by using a virtual IP address which is bound to the actual link address. During the roaming process the virtual address is attached to the new link address.

Some platforms may support the concept of Forced Roaming and Application Level Roaming (ALR). Forced roaming implies that the platform may simply roam to a new configuration without consulting applications. It is up to the application to detect the link layer loss and reestablish its sockets. In contrast ALR provides the opportunity to prevent the system from roaming. If this session is based on a configuration that supports roaming the application can choose whether it wants to be consulted (ALR use case) by connecting to this signal. For as long as this signal connection remains the session remains registered as a roaming stakeholder; otherwise roaming will be enforced by the platform.

See also migrate(), ignore(), and QNetworkConfiguration::isRoamingAvailable().

new void QtNetwork.QNetworkSession.OnStateChanged ( QNetworkSession.State  arg1)
protected

This signal is emitted whenever the state of the network session changes. The state parameter is the new state.

See also state().

new void QtNetwork.QNetworkSession.Open ( )

Creates an open session which increases the session counter on the underlying network interface. The system will not terminate a network interface until the session reference counter reaches zero. Therefore an open session allows an application to register its use of the interface.

As a result of calling open() the interface will be started if it is not connected/up yet. Some platforms may not provide support for out-of-process sessions. On such platforms the session counter ignores any sessions held by another process. The platform capabilities can be detected via QNetworkConfigurationManager::capabilities().

Note that this call is asynchronous. Depending on the outcome of this call the results can be enquired by connecting to the stateChanged(), opened() or error() signals.

It is not a requirement to open a session in order to monitor the underlying network interface.

See also close(), stop(), and isOpen().

new void QtNetwork.QNetworkSession.Reject ( )

The new access point is not suitable for the application. By calling this function the session returns to the previous access point/configuration. This action may invalidate any socket that has been created via the not desired access point.

See also accept().

new object QtNetwork.QNetworkSession.SessionProperty ( string  key)

Returns the value for property key.

A network session can have properties attached which may describe the session in more details. This function can be used to gain access to those properties.

The following property keys are guaranteed to be specified on all platforms:

KeyDescription

ActiveConfiguration If the session isOpen() this property returns the identifier of the QNetworkConfiguration that is used by this session; otherwise an empty string.The main purpose of this key is to determine which Internet access point is used if the session is based on a ServiceNetwork. The following code snippet highlights the difference:

QNetworkConfigurationManager mgr;

QNetworkConfiguration ap = mgr.defaultConfiguration();

QNetworkSession *session = new QNetworkSession(ap);

... //code activates session

QString ident = session->sessionProperty("ActiveConfiguration").toString();

if ( ap.type() == QNetworkConfiguration::ServiceNetwork ) {

Q_ASSERT( ap.identifier() != ident );

Q_ASSERT( ap.children().contains( mgr.configurationFromIdentifier(ident) ) );

} else if ( ap.type() == QNetworkConfiguration::InternetAccessPoint ) {

Q_ASSERT( ap.identifier() == ident );

}

UserChoiceConfiguration If the session isOpen() and is bound to a QNetworkConfiguration of type UserChoice, this property returns the identifier of the QNetworkConfiguration that the configuration resolved to when open() was called; otherwise an empty string.The purpose of this key is to determine the real QNetworkConfiguration that the session is using. This key is different from ActiveConfiguration in that this key may return an identifier for either a service network or a Internet access points configurations, whereas ActiveConfiguration always returns identifiers to Internet access points configurations.

ConnectInBackground Setting this property to true before calling open() implies that the connection attempt is made but if no connection can be established, the user is not connsulted and asked to select a suitable connection. This property is not set by default and support for it depends on the platform.

AutoCloseSessionTimeout If the session requires polling to keep its state up to date, this property holds the timeout in milliseconds before the session will automatically close. If the value of this property is -1 the session will not automatically close. This property is set to -1 by default.The purpose of this property is to minimize resource use on platforms that use polling to update the state of the session. Applications can set the value of this property to the desired timeout before the session is closed. In response to the closed() signal the network session should be deleted to ensure that all polling is stopped. The session can then be recreated once it is required again. This property has no effect for sessions that do not require polling.

new void QtNetwork.QNetworkSession.SetSessionProperty ( string  key,
object  value 
)

Sets the property value on the session. The property is identified using key. Removing an already set property can be achieved by passing an invalid QVariant.

Note that the UserChoiceConfiguration and ActiveConfiguration properties are read only and cannot be changed using this method.

See also sessionProperty().

new QNetworkSession.State QtNetwork.QNetworkSession.state ( )

Returns the state of the session.

If the session is based on a single access point configuration the state of the session is the same as the state of the associated network interface. Therefore a network session object can be used to monitor network interfaces.

A QNetworkConfiguration::ServiceNetwork based session summarizes the state of all its children and therefore returns the Connected state if at least one of the service network's children() configurations is active.

Note that it is not required to hold an open session in order to obtain the network interface state. A connected but closed session may be used to monitor network interfaces whereas an open and connected session object may prevent the network interface from being shut down.

See also error() and stateChanged().

new void QtNetwork.QNetworkSession.Stop ( )

Invalidates all open sessions against the network interface and therefore stops the underlying network interface. This function always changes the session's state() flag to Disconnected.

On Symbian platform, a 'NetworkControl' capability is required for full interface-level stop (without the capability, only the current session is stopped).

See also open() and close().

static string QtNetwork.QNetworkSession.Tr ( string  s,
string  c = null 
)
static
static string QtNetwork.QNetworkSession.Tr ( string  s,
string  c,
int  n 
)
static
static string QtNetwork.QNetworkSession.TrUtf8 ( string  s,
string  c = null 
)
static
static string QtNetwork.QNetworkSession.TrUtf8 ( string  s,
string  c,
int  n 
)
static
new bool QtNetwork.QNetworkSession.WaitForOpened ( int  msecs = 30000)

Waits until the session has been opened, up to msecs milliseconds. If the session has been opened, this function returns true; otherwise it returns false. In the case where it returns false, you can call error() to determine the cause of the error.

The following example waits up to one second for the session to be opened:

session->open();

if (session->waitForOpened(1000))

qDebug("Open!");

If msecs is -1, this function will not time out.

See also open() and error().

Property Documentation

Slot QtNetwork.QNetworkSession.Closed
addremove

This signal is emitted when the network session has been closed.

new IQNetworkSessionSignals QtNetwork.QNetworkSession.Emit
getprotected
Slot<QNetworkSession.SessionError> QtNetwork.QNetworkSession.Error
addremove

Returns the type of error that last occurred.

See also state() and errorString().

Slot QtNetwork.QNetworkSession.NewConfigurationActivated
addremove

This signal is emitted once the session has roamed to the new access point. The application may reopen its socket and test the suitability of the new network link. Subsequently it must either accept() or reject() the new access point.

See also accept() and reject().

Slot QtNetwork.QNetworkSession.Opened
addremove

This signal is emitted when the network session has been opened.

The underlying network interface will not be shut down as long as the session remains open. Note that this feature is dependent on system wide session support.

Slot<QNetworkConfiguration,System.Boolean> QtNetwork.QNetworkSession.PreferredConfigurationChanged
addremove

This signal is emitted when the preferred configuration/access point for the session changes. Only sessions which are based on service network configurations may emit this signal. config can be used to determine access point specific details such as proxy settings and isSeamless indicates whether roaming will break the sessions IP address.

As a consequence to this signal the application must either start the roaming process by calling migrate() or choose to ignore() the new access point.

If the roaming process is non-seamless the IP address will change which means that a socket becomes invalid. However seamless mobility can ensure that the local IP address does not change. This is achieved by using a virtual IP address which is bound to the actual link address. During the roaming process the virtual address is attached to the new link address.

Some platforms may support the concept of Forced Roaming and Application Level Roaming (ALR). Forced roaming implies that the platform may simply roam to a new configuration without consulting applications. It is up to the application to detect the link layer loss and reestablish its sockets. In contrast ALR provides the opportunity to prevent the system from roaming. If this session is based on a configuration that supports roaming the application can choose whether it wants to be consulted (ALR use case) by connecting to this signal. For as long as this signal connection remains the session remains registered as a roaming stakeholder; otherwise roaming will be enforced by the platform.

See also migrate(), ignore(), and QNetworkConfiguration::isRoamingAvailable().

Slot<QNetworkSession.State> QtNetwork.QNetworkSession.StateChanged
addremove

This signal is emitted whenever the state of the network session changes. The state parameter is the new state.

See also state().

new QMetaObject QtNetwork.QNetworkSession.StaticMetaObject
staticget