diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-03-12 00:53:32 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-03-12 03:48:16 (GMT) |
commit | aa4ab19776a67f882b901b488de8664811df8ae5 (patch) | |
tree | f8d415e64d0615b2455069ed6427983a4f815bc0 /src/network | |
parent | e1dfaf37a1411d1afaaa63684b54a443d19df7e2 (diff) | |
download | Qt-aa4ab19776a67f882b901b488de8664811df8ae5.zip Qt-aa4ab19776a67f882b901b488de8664811df8ae5.tar.gz Qt-aa4ab19776a67f882b901b488de8664811df8ae5.tar.bz2 |
Only enable BM by default in QNAM for appropriate platforms.
Bearer Management is of little use on desktop platforms. Change
QNetworkAccessManager to only create a QNetworkSession for the default
configuration on platorms where it is useful (Symbian & Maemo). On other
platforms Bearer Management is still available, but needs to be
explicitly enabled by the application developer by calling
QNetworkAccessManager::setConfiguration().
Use of Bearer Management by default from QNetworkAccessManager is
controlled by the QT_QNAM_BEARERMANAGEMENT_ENABLED define.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 26 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager_p.h | 4 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 789d57b..1940dd1 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -880,15 +880,18 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera return new QDisabledNetworkReply(this, req, op); } +#ifdef QT_QNAM_DEFAULT_NETWORK_SESSION if (!d->networkSession && (d->initializeSession || !d->networkConfiguration.isEmpty())) { QNetworkConfigurationManager manager; if (d->networkConfiguration.isEmpty()) d->createSession(manager.defaultConfiguration()); else d->createSession(manager.configurationFromIdentifier(d->networkConfiguration)); - } else if (d->networkSession) { - d->networkSession->setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), -1); } +#endif + + if (d->networkSession) + d->networkSession->setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), -1); QNetworkRequest request = req; if (!request.header(QNetworkRequest::ContentLengthHeader).isValid() && @@ -1205,7 +1208,9 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co { Q_Q(QNetworkAccessManager); +#ifdef QT_QNAM_DEFAULT_NETWORK_SESSION initializeSession = false; +#endif if (networkSession) delete networkSession; @@ -1229,24 +1234,29 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co void QNetworkAccessManagerPrivate::_q_networkSessionClosed() { - networkConfiguration = networkSession->configuration().identifier(); + if (networkSession) { + networkConfiguration = networkSession->configuration().identifier(); - delete networkSession; - networkSession = 0; + networkSession->deleteLater(); + networkSession = 0; + } } void QNetworkAccessManagerPrivate::_q_networkSessionNewConfigurationActivated() { Q_Q(QNetworkAccessManager); - networkSession->accept(); + if (networkSession) { + networkSession->accept(); - emit q->networkSessionOnline(); + emit q->networkSessionOnline(); + } } void QNetworkAccessManagerPrivate::_q_networkSessionPreferredConfigurationChanged(const QNetworkConfiguration &, bool) { - networkSession->migrate(); + if (networkSession) + networkSession->migrate(); } QT_END_NAMESPACE diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h index 0140268..4a2a840 100644 --- a/src/network/access/qnetworkaccessmanager_p.h +++ b/src/network/access/qnetworkaccessmanager_p.h @@ -77,7 +77,9 @@ public: #endif networkSession(0), networkAccessEnabled(true), +#ifdef QT_QNAM_DEFAULT_NETWORK_SESSION initializeSession(true), +#endif cookieJarCreated(false) { } ~QNetworkAccessManagerPrivate(); @@ -124,7 +126,9 @@ public: QNetworkSession *networkSession; QString networkConfiguration; bool networkAccessEnabled; +#ifdef QT_QNAM_DEFAULT_NETWORK_SESSION bool initializeSession; +#endif bool cookieJarCreated; |