From 40fc1a3ca3b7050f317513cf69dd89a01479e098 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 21 Mar 2011 18:53:42 +0000 Subject: Implement network session support for synchronous QHostInfo Private API, QHostInfoPrivate::fromName, which is called from QAbstractSocket when the network session property is set. Reviewed-by: Markus Goetz --- src/network/kernel/qhostinfo.cpp | 14 ++++++++++++++ src/network/kernel/qhostinfo_p.h | 5 +++++ src/network/kernel/qhostinfo_symbian.cpp | 15 +++++---------- src/network/socket/qabstractsocket.cpp | 9 +++++++++ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 1ae0bbd..aff55d9 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -272,6 +272,20 @@ QHostInfo QHostInfo::fromName(const QString &name) return hostInfo; } +#ifndef QT_NO_BEARERMANAGEMENT +QHostInfo QHostInfoPrivate::fromName(const QString &name, QSharedPointer session) +{ +#if defined QHOSTINFO_DEBUG + qDebug("QHostInfoPrivate::fromName(\"%s\") with session %p",name.toLatin1().constData(), session.data()); +#endif + + QHostInfo hostInfo = QHostInfoAgent::fromName(name, session); + QAbstractHostInfoLookupManger* manager = theHostInfoLookupManager(); + manager->cache.put(name, hostInfo); + return hostInfo; +} +#endif + /*! \enum QHostInfo::HostInfoError diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index e3f7f19..a40104a 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -70,6 +70,7 @@ #include #include +#include #ifdef Q_OS_SYMBIAN // Symbian Headers @@ -117,6 +118,10 @@ public: lookupId(0) { } +#ifndef QT_NO_BEARERMANAGEMENT + //not a public API yet + static QHostInfo fromName(const QString &hostName, QSharedPointer networkSession); +#endif QHostInfo::HostInfoError err; QString errorStr; diff --git a/src/network/kernel/qhostinfo_symbian.cpp b/src/network/kernel/qhostinfo_symbian.cpp index 347bf67..65c3d62 100644 --- a/src/network/kernel/qhostinfo_symbian.cpp +++ b/src/network/kernel/qhostinfo_symbian.cpp @@ -66,16 +66,11 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName, QSharedPointer #include @@ -1786,6 +1787,14 @@ bool QAbstractSocket::waitForConnected(int msecs) #endif QHostInfo::abortHostLookup(d->hostLookupId); d->hostLookupId = -1; +#ifndef QT_NO_BEARERMANAGEMENT + QSharedPointer networkSession; + QVariant v(property("_q_networksession")); + if (v.isValid()) { + networkSession = qvariant_cast< QSharedPointer >(v); + d->_q_startConnecting(QHostInfoPrivate::fromName(d->hostName, networkSession)); + } else +#endif d->_q_startConnecting(QHostInfo::fromName(d->hostName)); } if (state() == UnconnectedState) -- cgit v0.12