diff options
author | Shane Kearns <ext-shane.2.kearns@nokia.com> | 2012-04-04 18:11:42 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-11 22:19:21 +0200 |
commit | 6957b8d1ede105c88c22045685e3b9ce845c3c0c (patch) | |
tree | fb8f97b036d76c211b47a0d4cf4b9670752be2a0 /src/network/bearer/qnetworksession.cpp | |
parent | ad73c3505a088260541143e1549d94d35e4bd8f6 (diff) |
Define usagePolicies API in QNetworkSession
This allows the system to publish usage restrictions to applications
related to the network in use.
Currently there is only one restriction defined:
NoBackgroundTrafficPolicy, which means that non user initiated traffic
should be avoided (e.g. background downloads).
For example this policy could be applied to save battery or data transfer
charges.
Change-Id: I49e26c0f3650d2b92f4ec51981aae9435b717b49
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/network/bearer/qnetworksession.cpp')
-rw-r--r-- | src/network/bearer/qnetworksession.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp index ccf794633d..1a3c25a97f 100644 --- a/src/network/bearer/qnetworksession.cpp +++ b/src/network/bearer/qnetworksession.cpp @@ -149,6 +149,17 @@ QT_BEGIN_NAMESPACE */ /*! + \enum QNetworkSession::UsagePolicies + + These flags allow the system to inform the application of network usage restrictions that + may be in place. + + \value NoPolicy No policy in force, usage is unrestricted. + \value NoBackgroundTrafficPolicy Background network traffic (not user initiated) should be avoided + for example to save battery or data charges +*/ + +/*! \fn void QNetworkSession::stateChanged(QNetworkSession::State state) This signal is emitted whenever the state of the network session changes. @@ -222,6 +233,12 @@ QT_BEGIN_NAMESPACE */ /*! + \fn void QNetworkSession::usagePoliciesChanged(UsagePolicies) + + This signal is emitted when the usage policies in force are changed by the system. +*/ + +/*! Constructs a session based on \a connectionConfig with the given \a parent. \sa QNetworkConfiguration @@ -247,6 +264,8 @@ QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig, this, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))); connect(d, SIGNAL(newConfigurationActivated()), this, SIGNAL(newConfigurationActivated())); + connect(d, SIGNAL(usagePoliciesChanged(QNetworkSession::UsagePolicies)), + this, SIGNAL(usagePoliciesChanged(QNetworkSession::UsagePolicies))); break; } } @@ -254,6 +273,7 @@ QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig, qRegisterMetaType<QNetworkSession::State>(); qRegisterMetaType<QNetworkSession::SessionError>(); + qRegisterMetaType<QNetworkSession::UsagePolicies>(); } /*! @@ -654,6 +674,26 @@ quint64 QNetworkSession::activeTime() const } /*! + Returns the network usage policies currently in force by the system. +*/ +QNetworkSession::UsagePolicies QNetworkSession::usagePolicies() const +{ + return d ? d->usagePolicies() : QNetworkSession::NoPolicy; +} + +/*! + \internal + Change usage policies for unit testing. + In normal use, the policies are published by the bearer plugin +*/ +void QNetworkSessionPrivate::setUsagePolicies(QNetworkSession &session, QNetworkSession::UsagePolicies policies) +{ + if (!session.d) + return; + session.d->setUsagePolicies(policies); +} + +/*! \internal This function is required to detect whether the client wants to control |