diff options
author | Aaron Tunney <ext-aaron.2.tunney@nokia.com> | 2011-03-09 14:26:43 (GMT) |
---|---|---|
committer | Aaron Tunney <ext-aaron.2.tunney@nokia.com> | 2011-03-17 14:26:45 (GMT) |
commit | 6f7076d6fe80f656d8d2f7f1b005dc138b05bef3 (patch) | |
tree | 6fd42f51a9c05a267c675b739b9979b63c9238ce /src/network/kernel/qhostinfo_p.h | |
parent | 8f239f0b0cb7faa580ba66197f56fb3d8109aaf7 (diff) | |
download | Qt-6f7076d6fe80f656d8d2f7f1b005dc138b05bef3.zip Qt-6f7076d6fe80f656d8d2f7f1b005dc138b05bef3.tar.gz Qt-6f7076d6fe80f656d8d2f7f1b005dc138b05bef3.tar.bz2 |
Implementation of async DNS lookup.
Reviewed-by: Shane Kearns
Diffstat (limited to 'src/network/kernel/qhostinfo_p.h')
-rw-r--r-- | src/network/kernel/qhostinfo_p.h | 115 |
1 files changed, 112 insertions, 3 deletions
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index b568ec2..ec7a63e 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -69,9 +69,18 @@ #include <QElapsedTimer> #include <QCache> +#include <QNetworkSession> + +#ifdef Q_OS_SYMBIAN +// Symbian Headers +#include <es_sock.h> +#include <in_sock.h> +#endif + QT_BEGIN_NAMESPACE + class QHostInfoResult : public QObject { Q_OBJECT @@ -91,6 +100,12 @@ class QHostInfoAgent : public QObject Q_OBJECT public: static QHostInfo fromName(const QString &hostName); + static QHostInfo fromName(const QString &hostName, QSharedPointer<QNetworkSession> networkSession); + +#ifdef Q_OS_SYMBIAN + static int lookupHost(const QString &name, QObject *receiver, const char *member); + static void abortHostLookup(int lookupId); +#endif }; class QHostInfoPrivate @@ -151,7 +166,25 @@ public: QHostInfoResult resultEmitter; }; -class QHostInfoLookupManager : public QObject + +class QAbstractHostInfoLookupManger : public QObject +{ + Q_OBJECT + +public: + ~QAbstractHostInfoLookupManger() {} + virtual void clear() = 0; + + QHostInfoCache cache; + +protected: + QAbstractHostInfoLookupManger() {} + static QAbstractHostInfoLookupManger* globalInstance(); + +}; + +#ifndef Q_OS_SYMBIAN +class QHostInfoLookupManager : public QAbstractInfoLookupManager { Q_OBJECT public: @@ -169,8 +202,6 @@ public: void lookupFinished(QHostInfoRunnable *r); bool wasAborted(int id); - QHostInfoCache cache; - friend class QHostInfoRunnable; protected: QList<QHostInfoRunnable*> currentLookups; // in progress @@ -189,6 +220,84 @@ private slots: void waitForThreadPoolDone() { threadPool.waitForDone(); } }; +#else + +class QSymbianHostResolver : public CActive +{ +public: + QSymbianHostResolver(const QString &hostName, int id); + ~QSymbianHostResolver(); + + QHostInfo requestHostLookup(); + int id(); + + QHostInfoResult resultEmitter; + +private: + void DoCancel(); + void RunL(); + void run(); + TInt RunError(TInt aError); + + void processNameResults(); + void processAddressResults(); + +private: + int iId; + + const QString iHostName; + + RSocketServ& iSocketServ; + RHostResolver iHostResolver; + + TRequestStatus iStatus; + + TNameEntry iNameResult; + QHostAddress iAddress; + + QHostInfo iResults; + + enum { + EIdle, + EGetByName, + EGetByAddress + } iState; +}; + +class QSymbianHostInfoLookupManger : public QAbstractHostInfoLookupManger +{ + Q_OBJECT +public: + QSymbianHostInfoLookupManger(); + ~QSymbianHostInfoLookupManger(); + + static QSymbianHostInfoLookupManger* globalInstance(); + + int id(); + void clear(); + + // called from QHostInfo + void scheduleLookup(QSymbianHostResolver *r); + void abortLookup(int id); + + // called from QSymbianHostResolver + void lookupFinished(QSymbianHostResolver *r); + +private: + void runNextLookup(); + + static const int KMaxConcurrentLookups = 5; + + RPointerArray<QSymbianHostResolver> iCurrentLookups; + RPointerArray<QSymbianHostResolver> iScheduledLookups; + RPointerArray<QSymbianHostResolver> iFinishedLookups; + + QMutex mutex; +}; +#endif + + + QT_END_NAMESPACE #endif // QHOSTINFO_P_H |