diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-02-17 13:27:45 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2011-02-17 13:39:08 (GMT) |
commit | 44ef44bc3826c78a10bcf02d3357bf6332c6c3ed (patch) | |
tree | 53053bdacc56009825ab24d3ed313390a9a40d4f /src/network/access | |
parent | 42adaaa0dffa9df387a145181bc97ee3bb9a4c7b (diff) | |
download | Qt-44ef44bc3826c78a10bcf02d3357bf6332c6c3ed.zip Qt-44ef44bc3826c78a10bcf02d3357bf6332c6c3ed.tar.gz Qt-44ef44bc3826c78a10bcf02d3357bf6332c6c3ed.tar.bz2 |
Explicit network session for QNetworkAccessManager
Implemented a tunnel to get the QNetworkSession from QNetworkAccessManager
down to the socket engine. This is currently a private API for QNAM.
This patch only implements the FTP backend - the other backends are to
follow.
On Symbian, the native socket engine will extract the native session
(RConnection) from the QNetworkSession implementation, and use that to
open sockets using the explicitly specified session.
When no session is specified on the socket (default for networking usage
outside of QNAM) then the socket is opened with no RConnection specified,
which allows the IP stack to find any route via an open interface.
The QFtp autotest is enhanced to test QFtp with an explicit session as well
as implicit connectivity (where a QNetworkSession is opened by the user,
and then QFtp is used without a specified connection).
This autotest gives better coverage than the FTP test cases in QNetworkReply.
Reviewed-by: Markus Goetz
Diffstat (limited to 'src/network/access')
-rw-r--r-- | src/network/access/qftp.cpp | 17 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessbackend.cpp | 7 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessftpbackend.cpp | 4 |
3 files changed, 27 insertions, 1 deletions
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index ccc20e6..45fc11f 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -319,6 +319,10 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port) socket = 0; } socket = new QTcpSocket(this); +#ifndef QT_NO_BEARERMANAGEMENT + //copy network session down to the socket + socket->setProperty("_q_networksession", property("_q_networksession")); +#endif socket->setObjectName(QLatin1String("QFtpDTP Passive state socket")); connect(socket, SIGNAL(connected()), SLOT(socketConnected())); connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); @@ -331,6 +335,10 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port) int QFtpDTP::setupListener(const QHostAddress &address) { +#ifndef QT_NO_BEARERMANAGEMENT + //copy network session down to the socket + listener.setProperty("_q_networksession", property("_q_networksession")); +#endif if (!listener.isListening() && !listener.listen(address, 0)) return -1; return listener.serverPort(); @@ -808,6 +816,11 @@ QFtpPI::QFtpPI(QObject *parent) : void QFtpPI::connectToHost(const QString &host, quint16 port) { emit connectState(QFtp::HostLookup); +#ifndef QT_NO_BEARERMANAGEMENT + //copy network session down to the socket & DTP + commandSocket.setProperty("_q_networksession", property("_q_networksession")); + dtp.setProperty("_q_networksession", property("_q_networksession")); +#endif commandSocket.connectToHost(host, port); } @@ -2240,6 +2253,10 @@ void QFtpPrivate::_q_startNextCommand() c->rawCmds.clear(); _q_piFinished(QLatin1String("Proxy set to ") + proxyHost + QLatin1Char(':') + QString::number(proxyPort)); } else if (c->command == QFtp::ConnectToHost) { +#ifndef QT_NO_BEARERMANAGEMENT + //copy network session down to the PI + pi.setProperty("_q_networksession", q->property("_q_networksession")); +#endif if (!proxyHost.isEmpty()) { host = c->rawCmds[0]; port = c->rawCmds[1].toUInt(); diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index fd1fa60..de40256 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -46,7 +46,7 @@ #include "qnetworkreply_p.h" #include "QtCore/qhash.h" #include "QtCore/qmutex.h" -#include "QtNetwork/qnetworksession.h" +#include "QtNetwork/private/qnetworksession_p.h" #include "qnetworkaccesscachebackend_p.h" #include "qabstractnetworkcache.h" @@ -96,6 +96,11 @@ QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessM QNetworkAccessBackend *backend = (*it)->create(op, request); if (backend) { backend->manager = this; +#ifndef QT_NO_BEARERMANAGEMENT + //copy network session down to the backend + if (networkSession) + backend->setProperty("_q_networksession", QVariant::fromValue(networkSession)); +#endif return backend; // found a factory that handled our request } ++it; diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index e34e6bb..3ad1961 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -153,6 +153,10 @@ void QNetworkAccessFtpBackend::open() if (!objectCache->requestEntry(cacheKey, this, SLOT(ftpConnectionReady(QNetworkAccessCache::CacheableObject*)))) { ftp = new QNetworkAccessCachedFtpConnection; +#ifndef QT_NO_BEARERMANAGEMENT + //copy network session down to the QFtp + ftp->setProperty("_q_networksession", property("_q_networksession")); +#endif #ifndef QT_NO_NETWORKPROXY if (proxy.type() == QNetworkProxy::FtpCachingProxy) ftp->setProxy(proxy.hostName(), proxy.port()); |