From 4329030b77dc2faf267cecc0a8b03ce3ed3437cf Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 1 Nov 2011 14:20:19 +0100 Subject: network: remove Symbian specific code removes several files and cleans up the code, removing all Symbian specific #ifdef's etc. Change-Id: Ie457e54cb4b3a992f251383320d47822259c38f1 Reviewed-by: Lars Knoll --- src/network/kernel/kernel.pri | 6 +- src/network/kernel/qhostinfo.cpp | 43 -- src/network/kernel/qhostinfo_p.h | 101 ---- src/network/kernel/qhostinfo_symbian.cpp | 600 ----------------------- src/network/kernel/qnetworkinterface_symbian.cpp | 266 ---------- src/network/kernel/qnetworkproxy_symbian.cpp | 272 ---------- 6 files changed, 1 insertion(+), 1287 deletions(-) delete mode 100644 src/network/kernel/qhostinfo_symbian.cpp delete mode 100644 src/network/kernel/qnetworkinterface_symbian.cpp delete mode 100644 src/network/kernel/qnetworkproxy_symbian.cpp (limited to 'src/network/kernel') diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index bb98305173..d6e099701d 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -20,15 +20,11 @@ SOURCES += kernel/qauthenticator.cpp \ kernel/qnetworkproxy.cpp \ kernel/qnetworkinterface.cpp -symbian: SOURCES += kernel/qhostinfo_symbian.cpp kernel/qnetworkinterface_symbian.cpp -unix:!symbian:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp +unix:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp integrity:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation mac:SOURCES += kernel/qnetworkproxy_mac.cpp else:win32:SOURCES += kernel/qnetworkproxy_win.cpp -else:symbian:SOURCES += kernel/qnetworkproxy_symbian.cpp else:SOURCES += kernel/qnetworkproxy_generic.cpp - -symbian: LIBS += -lcommsdat diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index d42c2598f8..465345c085 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -59,11 +59,7 @@ QT_BEGIN_NAMESPACE //#define QHOSTINFO_DEBUG -#ifndef Q_OS_SYMBIAN Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager) -#else -Q_GLOBAL_STATIC(QSymbianHostInfoLookupManager, theHostInfoLookupManager) -#endif /*! \class QHostInfo @@ -178,7 +174,6 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver, return id; } -#ifndef Q_OS_SYMBIAN QHostInfoLookupManager *manager = theHostInfoLookupManager(); if (manager) { @@ -201,39 +196,6 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver, QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection); manager->scheduleLookup(runnable); } -#else - QSymbianHostInfoLookupManager *manager = theHostInfoLookupManager(); - - if (manager) { - // the application is still alive - if (manager->cache.isEnabled()) { - // check cache first - bool valid = false; - QHostInfo info = manager->cache.get(name, &valid); - if (valid) { - info.setLookupId(id); - QHostInfoResult result; - QObject::connect(&result, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection); - result.emitResultsReady(info); - return id; - } - } - - // cache is not enabled or it was not in the cache, do normal lookup -#ifndef QT_NO_BEARERMANAGEMENT - QSharedPointer networkSession; - QVariant v(receiver->property("_q_networksession")); - if (v.isValid()) - networkSession = qvariant_cast< QSharedPointer >(v); -#endif - - QSymbianHostResolver *symbianResolver = 0; - QT_TRAP_THROWING(symbianResolver = new QSymbianHostResolver(name, id, networkSession)); - QObject::connect(&symbianResolver->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection); - manager->scheduleLookup(symbianResolver); - } -#endif - return id; } @@ -286,13 +248,10 @@ QHostInfo QHostInfoPrivate::fromName(const QString &name, QSharedPointer) { return QHostInfoAgent::fromName(hostName); } -#endif /*! @@ -471,7 +430,6 @@ void QHostInfo::setErrorString(const QString &str) \sa hostName() */ -#ifndef Q_OS_SYMBIAN QHostInfoRunnable::QHostInfoRunnable(QString hn, int i) : toBeLookedUp(hn), id(i) { setAutoDelete(true); @@ -699,7 +657,6 @@ void QHostInfoLookupManager::lookupFinished(QHostInfoRunnable *r) finishedLookups.append(r); work(); } -#endif // This function returns immediately when we had a result in the cache, else it will later emit a signal QHostInfo qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id) diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 035aa0126a..fb7ae37c53 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -72,12 +72,6 @@ #include #include -#ifdef Q_OS_SYMBIAN -// Symbian Headers -#include -#include -#endif - QT_BEGIN_NAMESPACE @@ -102,11 +96,6 @@ class QHostInfoAgent : public QObject public: static QHostInfo fromName(const QString &hostName); static QHostInfo fromName(const QString &hostName, QSharedPointer networkSession); - -#ifdef Q_OS_SYMBIAN - static int lookupHost(const QString &name, QObject *receiver, const char *member); - static void abortHostLookup(int lookupId); -#endif }; class QHostInfoPrivate @@ -188,7 +177,6 @@ protected: }; -#ifndef Q_OS_SYMBIAN class QHostInfoLookupManager : public QAbstractHostInfoLookupManager { Q_OBJECT @@ -225,95 +213,6 @@ private slots: void waitForThreadPoolDone() { threadPool.waitForDone(); } }; -#else - -class QSymbianHostResolver : public CActive -{ -public: - QSymbianHostResolver(const QString &hostName, int id, QSharedPointer networkSession); - ~QSymbianHostResolver(); - - void requestHostLookup(); - void abortHostLookup(); - int id(); - - void returnResults(); - - QHostInfoResult resultEmitter; - -private: - void DoCancel(); - void RunL(); - void run(); - TInt RunError(TInt aError); - - void processNameResult(); - void nextNameResult(); - void processAddressResult(); - -private: - int iId; - - const QString iHostName; - QString iEncodedHostName; - TPtrC iHostNamePtr; - - RSocketServ& iSocketServ; - RHostResolver iHostResolver; - QSharedPointer iNetworkSession; - - TNameEntry iNameResult; - TInetAddr IpAdd; - - QHostAddress iAddress; - - QHostInfo iResults; - - QList iHostAddresses; - - enum { - EIdle, - EGetByName, - EGetByAddress, - ECompleteFromCache, - EError - } iState; -}; - -class QSymbianHostInfoLookupManager : public QAbstractHostInfoLookupManager -{ - Q_OBJECT -public: - QSymbianHostInfoLookupManager(); - ~QSymbianHostInfoLookupManager(); - - static QSymbianHostInfoLookupManager* 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(); - - // this is true for single threaded use, with multiple threads the max is ((number of threads) + KMaxConcurrentLookups - 1) - static const int KMaxConcurrentLookups = 5; - - QList iCurrentLookups; - QList iScheduledLookups; - - QMutex mutex; -}; -#endif - - - QT_END_NAMESPACE #endif // QHOSTINFO_P_H diff --git a/src/network/kernel/qhostinfo_symbian.cpp b/src/network/kernel/qhostinfo_symbian.cpp deleted file mode 100644 index 042899d9a4..0000000000 --- a/src/network/kernel/qhostinfo_symbian.cpp +++ /dev/null @@ -1,600 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//#define QHOSTINFO_DEBUG - -// Qt Headers -#include -#include -#include - -#include "qplatformdefs.h" - -#include "qhostinfo_p.h" -#include -#include -#include - -// Header does not exist in the S60 5.0 SDK -//#include -const TInt KErrDndNameNotFound = -5120; // Returned when no data found for GetByName -const TInt KErrDndAddrNotFound = -5121; // Returned when no data found for GetByAddr - -QT_BEGIN_NAMESPACE - -static void setError_helper(QHostInfo &info, TInt symbianError) -{ - switch (symbianError) { - case KErrDndNameNotFound: - case KErrDndAddrNotFound: - case KErrNotFound: - case KErrEof: - // various "no more results" error codes - info.setError(QHostInfo::HostNotFound); - info.setErrorString(QObject::tr("Host not found")); - break; - default: - // Unknown error - info.setError(QHostInfo::UnknownError); - info.setErrorString(QSystemError(symbianError, QSystemError::NativeError).toString()); - break; - } -} - -QHostInfo QHostInfoAgent::fromName(const QString &hostName, QSharedPointer networkSession) -{ - QHostInfo results; - - // Connect to ESOCK - RSocketServ socketServ(qt_symbianGetSocketServer()); - RHostResolver hostResolver; - - - int err; - if (networkSession) - err = QNetworkSessionPrivate::nativeOpenHostResolver(*networkSession, hostResolver, KAfInet, KProtocolInetUdp); - else - err = hostResolver.Open(socketServ, KAfInet, KProtocolInetUdp); - if (err) { - setError_helper(results, err); - return results; - } - - TNameEntry nameResult; - -#if defined(QHOSTINFO_DEBUG) - qDebug("QHostInfoAgent::fromName(%s) looking up...", - hostName.toLatin1().constData()); -#endif - - QHostAddress address; - if (address.setAddress(hostName)) { - // Reverse lookup -#if defined(QHOSTINFO_DEBUG) - qDebug("(reverse lookup)"); -#endif - TInetAddr IpAdd; - IpAdd.Input(qt_QString2TPtrC(hostName)); - - // Synchronous request. nameResult returns Host Name. - err = hostResolver.GetByAddress(IpAdd, nameResult); - if (err) { - //for behavioural compatibility with Qt 4.7 and unix/windows - //backends: don't report error, return ip address as host name - results.setHostName(address.toString()); - } else { - results.setHostName(qt_TDesC2QString(nameResult().iName)); - } - results.setAddresses(QList() << address); - return results; - } - - // IDN support - QByteArray aceHostname = QUrl::toAce(hostName); - results.setHostName(hostName); - if (aceHostname.isEmpty()) { - results.setError(QHostInfo::HostNotFound); - results.setErrorString(hostName.isEmpty() ? - QCoreApplication::translate("QHostInfoAgent", "No host name given") : - QCoreApplication::translate("QHostInfoAgent", "Invalid hostname")); - return results; - } - - - // Call RHostResolver::GetByAddress, and place all IPv4 addresses at the start and - // the IPv6 addresses at the end of the address list in results. - - // Synchronous request. - err = hostResolver.GetByName(qt_QString2TPtrC(QString::fromLatin1(aceHostname)), nameResult); - if (err) { - setError_helper(results, err); - return results; - } - - QList hostAddresses; - - TInetAddr hostAdd = nameResult().iAddr; - // 39 is the maximum length of an IPv6 address. - TBuf<39> ipAddr; - - // Fill ipAddr with the IP address from hostAdd - hostAdd.Output(ipAddr); - if (ipAddr.Length() > 0) - hostAddresses.append(QHostAddress(qt_TDesC2QString(ipAddr))); - - // Check if there's more than one IP address linkd to this name - while (hostResolver.Next(nameResult) == KErrNone) { - hostAdd = nameResult().iAddr; - hostAdd.Output(ipAddr); - - // Ensure that record is valid (not an alias and with length greater than 0) - if (!(nameResult().iFlags & TNameRecord::EAlias) && !(hostAdd.IsUnspecified())) { - hostAddresses.append(QHostAddress(qt_TDesC2QString(ipAddr))); - } - } - - hostResolver.Close(); - - results.setAddresses(hostAddresses); - return results; -} - -QHostInfo QHostInfoAgent::fromName(const QString &hostName) -{ - // null shared pointer - QSharedPointer networkSession; - return fromName(hostName, networkSession); -} - -QString QHostInfo::localHostName() -{ - // Connect to ESOCK - RSocketServ socketServ(qt_symbianGetSocketServer()); - RHostResolver hostResolver; - - // RConnection not required to get the host name - int err = hostResolver.Open(socketServ, KAfInet, KProtocolInetUdp); - if (err) - return QString(); - - THostName hostName; - err = hostResolver.GetHostName(hostName); - if (err) - return QString(); - - hostResolver.Close(); - - return qt_TDesC2QString(hostName); -} - -QString QHostInfo::localDomainName() -{ - // This concept does not exist on Symbian OS because the device can be on - // multiple networks with multiple "local domain" names. - // For now, return a null string. - return QString(); -} - - -QSymbianHostResolver::QSymbianHostResolver(const QString &hostName, int identifier, QSharedPointer networkSession) - : CActive(CActive::EPriorityStandard), iHostName(hostName), - iSocketServ(qt_symbianGetSocketServer()), iNetworkSession(networkSession), iResults(identifier) -{ - CActiveScheduler::Add(this); -} - -QSymbianHostResolver::~QSymbianHostResolver() -{ -#if defined(QHOSTINFO_DEBUG) - qDebug() << "QSymbianHostInfoLookupManager::~QSymbianHostResolver" << id(); -#endif - Cancel(); - iHostResolver.Close(); -} - -// Async equivalent to QHostInfoAgent::fromName() -void QSymbianHostResolver::requestHostLookup() -{ - -#if defined(QHOSTINFO_DEBUG) - qDebug("QSymbianHostResolver::requestHostLookup(%s) looking up... (id = %d)", - iHostName.toLatin1().constData(), id()); -#endif - - QSymbianHostInfoLookupManager *manager = QSymbianHostInfoLookupManager::globalInstance(); - if (manager->cache.isEnabled()) { - //check if name has been put in the cache while this request was queued - bool valid; - QHostInfo cachedResult = manager->cache.get(iHostName, &valid); - if (valid) { -#if defined(QHOSTINFO_DEBUG) - qDebug("...found in cache"); -#endif - iResults = cachedResult; - iState = ECompleteFromCache; - SetActive(); - TRequestStatus* stat = &iStatus; - User::RequestComplete(stat, KErrNone); - return; - } - } - - int err; - if (iNetworkSession) { - err = QNetworkSessionPrivate::nativeOpenHostResolver(*iNetworkSession, iHostResolver, KAfInet, KProtocolInetUdp); -#if defined(QHOSTINFO_DEBUG) - qDebug("using resolver from session (err = %d)", err); -#endif - } else { - err = iHostResolver.Open(iSocketServ, KAfInet, KProtocolInetUdp); -#if defined(QHOSTINFO_DEBUG) - qDebug("using default resolver (err = %d)", err); -#endif - } - if (err) { - setError_helper(iResults, err); - } else { - - if (iAddress.setAddress(iHostName)) { - // Reverse lookup - IpAdd.Input(qt_QString2TPtrC(iHostName)); - - // Asynchronous request. - iHostResolver.GetByAddress(IpAdd, iNameResult, iStatus); // <---- ASYNC - iState = EGetByAddress; - - } else { - - // IDN support - QByteArray aceHostname = QUrl::toAce(iHostName); - iResults.setHostName(iHostName); - if (aceHostname.isEmpty()) { - iResults.setError(QHostInfo::HostNotFound); - iResults.setErrorString(iHostName.isEmpty() ? - QCoreApplication::translate("QHostInfoAgent", "No host name given") : - QCoreApplication::translate("QHostInfoAgent", "Invalid hostname")); - - err = KErrArgument; - } else { - iEncodedHostName = QString::fromLatin1(aceHostname); - iHostNamePtr.Set(qt_QString2TPtrC(iEncodedHostName)); - - // Asynchronous request. - iHostResolver.GetByName(iHostNamePtr, iNameResult, iStatus); - iState = EGetByName; - } - } - } - SetActive(); - if (err) { - iHostResolver.Close(); - - //self complete so that RunL can inform manager without causing recursion - iState = EError; - TRequestStatus* stat = &iStatus; - User::RequestComplete(stat, err); - } -} - -void QSymbianHostResolver::abortHostLookup() -{ - if (resultEmitter.thread() == QThread::currentThread()) { -#ifdef QHOSTINFO_DEBUG - qDebug("QSymbianHostResolver::abortHostLookup - deleting %d", id()); -#endif - //normal case, abort from same thread it was started - delete this; //will cancel outstanding request - } else { -#ifdef QHOSTINFO_DEBUG - qDebug("QSymbianHostResolver::abortHostLookup - detaching %d", id()); -#endif - //abort from different thread, carry on but don't report the results - resultEmitter.disconnect(); - } -} - -void QSymbianHostResolver::DoCancel() -{ -#if defined(QHOSTINFO_DEBUG) - qDebug() << "QSymbianHostResolver::DoCancel" << QThread::currentThreadId() << id() << (int)iState << this; -#endif - if (iState == EGetByAddress || iState == EGetByName) { - //these states have made an async request to host resolver - iHostResolver.Cancel(); - } else { - //for the self completing states there is nothing to cancel - Q_ASSERT(iState == EError || iState == ECompleteFromCache); - } -} - -void QSymbianHostResolver::RunL() -{ - QT_TRYCATCH_LEAVING(run()); -} - -void QSymbianHostResolver::run() -{ - switch (iState) { - case EGetByName: - processNameResult(); - break; - case EGetByAddress: - processAddressResult(); - break; - case ECompleteFromCache: - case EError: - returnResults(); - break; - default: - qWarning("QSymbianHostResolver internal error, bad state in run()"); - iResults.setError(QHostInfo::UnknownError); - iResults.setErrorString(QSystemError(KErrCorrupt,QSystemError::NativeError).toString()); - returnResults(); - } -} - -void QSymbianHostResolver::returnResults() -{ -#if defined(QHOSTINFO_DEBUG) - qDebug() << "QSymbianHostResolver::returnResults" << iResults.error() << iResults.errorString(); - foreach (QHostAddress addr, iResults.addresses()) - qDebug() << addr; -#endif - iState = EIdle; - - QSymbianHostInfoLookupManager *manager = QSymbianHostInfoLookupManager::globalInstance(); - if (manager->cache.isEnabled()) { - manager->cache.put(iHostName, iResults); - } - manager->lookupFinished(this); - - resultEmitter.emitResultsReady(iResults); - - delete this; -} - -TInt QSymbianHostResolver::RunError(TInt aError) -{ - QT_TRY { - iState = EIdle; - - QSymbianHostInfoLookupManager *manager = QSymbianHostInfoLookupManager::globalInstance(); - manager->lookupFinished(this); - - setError_helper(iResults, aError); - - resultEmitter.emitResultsReady(iResults); - } - QT_CATCH(...) {} - - delete this; - - return KErrNone; -} - -void QSymbianHostResolver::processNameResult() -{ - if (iStatus.Int() == KErrNone) { - TInetAddr hostAdd = iNameResult().iAddr; - // 39 is the maximum length of an IPv6 address. - TBuf<39> ipAddr; - - hostAdd.Output(ipAddr); - - // Ensure that record is valid (not an alias and with length greater than 0) - if (!(iNameResult().iFlags & TNameRecord::EAlias) && !(hostAdd.IsUnspecified())) { - iHostAddresses.append(QHostAddress(qt_TDesC2QString(ipAddr))); - } - - iState = EGetByName; - iHostResolver.Next(iNameResult, iStatus); - SetActive(); - } - else { - // No more addresses, so return the results (or an error if there aren't any). -#if defined(QHOSTINFO_DEBUG) - qDebug() << "QSymbianHostResolver::processNameResult with err=" << iStatus.Int() << "count=" << iHostAddresses.count(); -#endif - if (iHostAddresses.count() > 0) { - iResults.setAddresses(iHostAddresses); - } else { - iState = EError; - setError_helper(iResults, iStatus.Int()); - } - returnResults(); - } -} - -void QSymbianHostResolver::processAddressResult() -{ - TInt err = iStatus.Int(); - - if (err < 0) { - //For behavioural compatibility with Qt 4.7, don't report errors on reverse lookup, - //return the address as a string (same as unix/windows backends) - iResults.setHostName(iAddress.toString()); - } else { - iResults.setHostName(qt_TDesC2QString(iNameResult().iName)); - } - iResults.setAddresses(QList() << iAddress); - returnResults(); -} - - -int QSymbianHostResolver::id() -{ - return iResults.lookupId(); -} - -QSymbianHostInfoLookupManager::QSymbianHostInfoLookupManager() -{ -} - -QSymbianHostInfoLookupManager::~QSymbianHostInfoLookupManager() -{ -} - -void QSymbianHostInfoLookupManager::clear() -{ - QMutexLocker locker(&mutex); -#if defined(QHOSTINFO_DEBUG) - qDebug() << "QSymbianHostInfoLookupManager::clear" << QThread::currentThreadId(); -#endif - foreach (QSymbianHostResolver *hr, iCurrentLookups) - hr->abortHostLookup(); - iCurrentLookups.clear(); - qDeleteAll(iScheduledLookups); - cache.clear(); -} - -void QSymbianHostInfoLookupManager::lookupFinished(QSymbianHostResolver *r) -{ - QMutexLocker locker(&mutex); - -#if defined(QHOSTINFO_DEBUG) - qDebug() << "QSymbianHostInfoLookupManager::lookupFinished" << QThread::currentThreadId() << r->id() << "current" << iCurrentLookups.count() << "queued" << iScheduledLookups.count(); -#endif - // remove finished lookup from array and destroy - TInt count = iCurrentLookups.count(); - for (TInt i = 0; i < count; i++) { - if (iCurrentLookups[i]->id() == r->id()) { - iCurrentLookups.removeAt(i); - break; - } - } - - runNextLookup(); -} - -void QSymbianHostInfoLookupManager::runNextLookup() -{ -#if defined(QHOSTINFO_DEBUG) - qDebug() << "QSymbianHostInfoLookupManager::runNextLookup" << QThread::currentThreadId() << "current" << iCurrentLookups.count() << "queued" << iScheduledLookups.count(); -#endif - // check to see if there are any scheduled lookups - for (int i=0; iresultEmitter.thread() == QThread::currentThread()) { - // if so, move one to the current lookups and run it - iCurrentLookups.append(hostResolver); - iScheduledLookups.removeAt(i); - hostResolver->requestHostLookup(); - // if spare capacity, try to start another one - if (iCurrentLookups.count() >= KMaxConcurrentLookups) - break; - i--; //compensate for removeAt - } - } -} - -// called from QHostInfo -void QSymbianHostInfoLookupManager::scheduleLookup(QSymbianHostResolver* r) -{ - QMutexLocker locker(&mutex); - -#if defined(QHOSTINFO_DEBUG) - qDebug() << "QSymbianHostInfoLookupManager::scheduleLookup" << QThread::currentThreadId() << r->id() << "current" << iCurrentLookups.count() << "queued" << iScheduledLookups.count(); -#endif - // Check to see if we have space on the current lookups pool. - bool defer = false; - if (iCurrentLookups.count() >= KMaxConcurrentLookups) { - // busy, defer unless there are no request in this thread - // at least one active request per thread with queued requests is needed - for (int i=0; i < iCurrentLookups.count();i++) { - if (iCurrentLookups.at(i)->resultEmitter.thread() == QThread::currentThread()) { - defer = true; - break; - } - } - } - if (defer) { - // If no, schedule for later. - iScheduledLookups.append(r); -#if defined(QHOSTINFO_DEBUG) - qDebug(" - scheduled"); -#endif - return; - } else { - // If yes, add it to the current lookups. - iCurrentLookups.append(r); - - // ... and trigger the async call. - r->requestHostLookup(); - } -} - -void QSymbianHostInfoLookupManager::abortLookup(int id) -{ - QMutexLocker locker(&mutex); - -#if defined(QHOSTINFO_DEBUG) - qDebug() << "QSymbianHostInfoLookupManager::abortLookup" << QThread::currentThreadId() << id << "current" << iCurrentLookups.count() << "queued" << iScheduledLookups.count(); -#endif - int i = 0; - // Find the aborted lookup by ID. - // First in the current lookups. - for (i = 0; i < iCurrentLookups.count(); i++) { - if (id == iCurrentLookups[i]->id()) { - QSymbianHostResolver* r = iCurrentLookups.at(i); - iCurrentLookups.removeAt(i); - r->abortHostLookup(); - runNextLookup(); - return; - } - } - // Then in the scheduled lookups. - for (i = 0; i < iScheduledLookups.count(); i++) { - if (id == iScheduledLookups[i]->id()) { - QSymbianHostResolver* r = iScheduledLookups.at(i); - iScheduledLookups.removeAt(i); - delete r; - return; - } - } -} - -QSymbianHostInfoLookupManager* QSymbianHostInfoLookupManager::globalInstance() -{ - return static_cast - (QAbstractHostInfoLookupManager::globalInstance()); -} - -QT_END_NAMESPACE diff --git a/src/network/kernel/qnetworkinterface_symbian.cpp b/src/network/kernel/qnetworkinterface_symbian.cpp deleted file mode 100644 index e7d3ca9d99..0000000000 --- a/src/network/kernel/qnetworkinterface_symbian.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtNetwork of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//#define QNETWORKINTERFACE_DEBUG - -#include "qnetworkinterface.h" -#include "qnetworkinterface_p.h" -#include - -#ifndef QT_NO_NETWORKINTERFACE - -#include -#include -#include - -QT_BEGIN_NAMESPACE - - -static QNetworkInterface::InterfaceFlags convertFlags(const TSoInetInterfaceInfo& aInfo) -{ - QNetworkInterface::InterfaceFlags flags = 0; - flags |= (aInfo.iState == EIfUp) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0); - // We do not have separate flag for running in Symbian OS - flags |= (aInfo.iState == EIfUp) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0); - flags |= (aInfo.iFeatures & KIfCanBroadcast) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0); - flags |= (aInfo.iFeatures & KIfIsLoopback) ? QNetworkInterface::IsLoopBack : QNetworkInterface::InterfaceFlag(0); - flags |= (aInfo.iFeatures & KIfIsPointToPoint) ? QNetworkInterface::IsPointToPoint : QNetworkInterface::InterfaceFlag(0); - flags |= (aInfo.iFeatures & KIfCanMulticast) ? QNetworkInterface::CanMulticast : QNetworkInterface::InterfaceFlag(0); - return flags; -} - -//TODO: share this, at least QHostInfo needs to do the same thing -static QHostAddress qt_QHostAddressFromTInetAddr(const TInetAddr& addr) -{ - //TODO: do we want to call v4 mapped addresses v4 or v6 outside of this file? - if (addr.IsV4Mapped() || addr.Family() == KAfInet) { - //convert v4 host address - return QHostAddress(addr.Address()); - } else { - //convert v6 host address - return QHostAddress((quint8 *)(addr.Ip6Address().u.iAddr8)); - } -} - -static QList interfaceListing() -{ - TInt err(KErrNone); - QList interfaces; - QList addressesWithEstimatedNetmasks; - - // Open dummy socket for interface queries - RSocket socket; - err = socket.Open(qt_symbianGetSocketServer(), _L("udp")); - if (err) { - return interfaces; - } - - // Ask socket to start enumerating interfaces - err = socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl); - if (err) { - socket.Close(); - return interfaces; - } - - int ifindex = 0; - TPckgBuf infoPckg; - TSoInetInterfaceInfo &info = infoPckg(); - while (socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, infoPckg) == KErrNone) { - if (info.iName != KNullDesC) { - TName address; - QNetworkAddressEntry entry; - QNetworkInterfacePrivate *iface = 0; - - iface = new QNetworkInterfacePrivate; - iface->index = ifindex++; - interfaces << iface; - iface->name = qt_TDesC2QString(info.iName); - iface->flags = convertFlags(info); - - if (/*info.iFeatures&KIfHasHardwareAddr &&*/ info.iHwAddr.Family() != KAFUnspec) { - for (TInt i = sizeof(SSockAddr); i < sizeof(SSockAddr) + info.iHwAddr.GetUserLen(); i++) { - address.AppendNumFixedWidth(info.iHwAddr[i], EHex, 2); - if ((i + 1) < sizeof(SSockAddr) + info.iHwAddr.GetUserLen()) - address.Append(_L(":")); - } - address.UpperCase(); - iface->hardwareAddress = qt_TDesC2QString(address); - } - - // Get the address of the interface - entry.setIp(qt_QHostAddressFromTInetAddr(info.iAddress)); - -#if defined(QNETWORKINTERFACE_DEBUG) - qDebug() << "address is" << info.iAddress.Family() << entry.ip(); - qDebug() << "netmask is" << info.iNetMask.Family() << qt_QHostAddressFromTInetAddr( info.iNetMask ); -#endif - - // Get the interface netmask - if (info.iNetMask.IsUnspecified()) { - // For some reason netmask is always 0.0.0.0 for IPv4 interfaces - // and loopback interfaces (which we statically know) - if (info.iAddress.IsV4Mapped()) { - if (info.iFeatures & KIfIsLoopback) { - entry.setPrefixLength(32); - } else { - // Workaround: Let Symbian determine netmask based on IP address class (IPv4 only API) - TInetAddr netmask; - netmask.NetMask(info.iAddress); - entry.setNetmask(QHostAddress(netmask.Address())); //binary convert v4 address - addressesWithEstimatedNetmasks << entry.ip(); -#if defined(QNETWORKINTERFACE_DEBUG) - qDebug() << "address class determined netmask" << entry.netmask(); -#endif - } - } else { - // For IPv6 interfaces - if (info.iFeatures & KIfIsLoopback) { - entry.setPrefixLength(128); - } else if (info.iNetMask.IsUnspecified()) { - //Don't see this error for IPv6, but try to handle it if it happens - entry.setPrefixLength(64); //most common -#if defined(QNETWORKINTERFACE_DEBUG) - qDebug() << "total guess netmask" << entry.netmask(); -#endif - addressesWithEstimatedNetmasks << entry.ip(); - } - } - } else { - //Expected code path for IPv6 non loopback interfaces (IPv4 could come here if symbian is fixed) - entry.setNetmask(qt_QHostAddressFromTInetAddr(info.iNetMask)); -#if defined(QNETWORKINTERFACE_DEBUG) - qDebug() << "reported netmask" << entry.netmask(); -#endif - } - - // broadcast address is determined from the netmask in postProcess() - - // Add new entry to interface address entries - iface->addressEntries << entry; - -#if defined(QNETWORKINTERFACE_DEBUG) - qDebug("\n Found network interface %s, interface flags:\n\ - IsUp = %d, IsRunning = %d, CanBroadcast = %d,\n\ - IsLoopBack = %d, IsPointToPoint = %d, CanMulticast = %d, \n\ - ip = %s, netmask = %s, broadcast = %s,\n\ - hwaddress = %s", - iface->name.toLatin1().constData(), - iface->flags & QNetworkInterface::IsUp, iface->flags & QNetworkInterface::IsRunning, iface->flags & QNetworkInterface::CanBroadcast, - iface->flags & QNetworkInterface::IsLoopBack, iface->flags & QNetworkInterface::IsPointToPoint, iface->flags & QNetworkInterface::CanMulticast, - entry.ip().toString().toLatin1().constData(), entry.netmask().toString().toLatin1().constData(), entry.broadcast().toString().toLatin1().constData(), - iface->hardwareAddress.toLatin1().constData()); -#endif - } - } - - // if we didn't have to guess any netmasks, then we're done. - if (addressesWithEstimatedNetmasks.isEmpty()) { - socket.Close(); - return interfaces; - } - - // we will try to use routing info to detect more precisely - // estimated netmasks and then ::postProcess() should calculate - // broadcast addresses - - // use dummy socket to start enumerating routes - err = socket.SetOpt(KSoInetEnumRoutes, KSolInetRtCtrl); - if (err) { - socket.Close(); - // return what we have - // up to this moment - return interfaces; - } - - TSoInetRouteInfo routeInfo; - TPckg routeInfoPkg(routeInfo); - while (socket.GetOpt(KSoInetNextRoute, KSolInetRtCtrl, routeInfoPkg) == KErrNone) { - // get interface address - QHostAddress ifAddr(qt_QHostAddressFromTInetAddr(routeInfo.iIfAddr)); - if (ifAddr.isNull()) - continue; - if (!addressesWithEstimatedNetmasks.contains(ifAddr)) { -#if defined(QNETWORKINTERFACE_DEBUG) - qDebug() << "skipping route from" << ifAddr << "because it wasn't an estimated netmask"; -#endif - continue; - } - - QHostAddress destination(qt_QHostAddressFromTInetAddr(routeInfo.iDstAddr)); -#if defined(QNETWORKINTERFACE_DEBUG) - qDebug() << "route from" << ifAddr << "to" << destination; -#endif - if (destination.isNull() || destination != ifAddr) - continue; - - // search interfaces - for (int ifindex = 0; ifindex < interfaces.size(); ++ifindex) { - QNetworkInterfacePrivate *iface = interfaces.at(ifindex); - for (int eindex = 0; eindex < iface->addressEntries.size(); ++eindex) { - QNetworkAddressEntry entry = iface->addressEntries.at(eindex); - if (entry.ip() != ifAddr) { - continue; - } else if (!routeInfo.iNetMask.IsUnspecified()) { - //the route may also return 0.0.0.0 netmask, in which case don't use it. - QHostAddress netmask(qt_QHostAddressFromTInetAddr(routeInfo.iNetMask)); - entry.setNetmask(netmask); -#if defined(QNETWORKINTERFACE_DEBUG) - qDebug() << " - route netmask" << routeInfo.iNetMask.Family() << netmask << " (using route determined netmask)"; -#endif - iface->addressEntries.replace(eindex, entry); - } - } - } - } - - socket.Close(); - - return interfaces; -} - -QList QNetworkInterfaceManager::scan() -{ - return interfaceListing(); -} - -QT_END_NAMESPACE - -#endif // QT_NO_NETWORKINTERFACE diff --git a/src/network/kernel/qnetworkproxy_symbian.cpp b/src/network/kernel/qnetworkproxy_symbian.cpp deleted file mode 100644 index 1be8de3aad..0000000000 --- a/src/network/kernel/qnetworkproxy_symbian.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/** - * Some notes about the code: - * - * ** It is assumed that the system proxies are for url based requests - * ie. HTTP/HTTPS based. - * ** It is assumed that proxies don't use authentication. - * ** It is assumed that there is no exceptions to proxy use (Symbian side - * does have the field for it but it is not user modifiable by default). - * ** There is no checking for protocol name. - */ - -#include - -#ifndef QT_NO_NETWORKPROXY - -#include // CMDBSession -#include // CCDIAPRecord, CCDProxiesRecord -#include // KCDTIdIAPRecord, KCDTIdProxiesRecord -#include -#include -#include - -using namespace CommsDat; - -QT_BEGIN_NAMESPACE - -class SymbianIapId -{ -public: - enum State{ - NotValid, - Valid - }; - Q_DECLARE_FLAGS(States, State) - SymbianIapId() {} - ~SymbianIapId() {} - void setIapId(TUint32 iapId) { iapState |= Valid; id = iapId; } - bool isValid() { return iapState == Valid; } - TUint32 iapId() { return id; } -private: - QFlags iapState; - TUint32 id; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(SymbianIapId::States) - -class SymbianProxyQuery -{ -public: - static QNetworkConfiguration findCurrentConfiguration(QNetworkConfigurationManager& configurationManager); - static SymbianIapId getIapId(QNetworkConfigurationManager &configurationManager, const QNetworkProxyQuery &query); - static CCDIAPRecord *getIapRecordLC(TUint32 aIAPId, CMDBSession &aDb); - static CMDBRecordSet *prepareQueryLC(TUint32 serviceId, TDesC& serviceType); - static QList proxyQueryL(TUint32 aIAPId, const QNetworkProxyQuery &query); -}; - -QNetworkConfiguration SymbianProxyQuery::findCurrentConfiguration(QNetworkConfigurationManager& configurationManager) -{ - QList activeConfigurations = configurationManager.allConfigurations( - QNetworkConfiguration::Active); - QNetworkConfiguration currentConfig; - if (activeConfigurations.count() > 0) { - currentConfig = activeConfigurations.at(0); - } else { - // No active configurations, try default one - QNetworkConfiguration defaultConfiguration = configurationManager.defaultConfiguration(); - if (defaultConfiguration.isValid()) { - switch (defaultConfiguration.type()) { - case QNetworkConfiguration::InternetAccessPoint: - currentConfig = defaultConfiguration; - break; - case QNetworkConfiguration::ServiceNetwork: - { - // Note: This code assumes that the only unambigious way to - // find current proxy config is if there is only one access point - // or if the found access point is immediately usable. - QList childConfigurations = defaultConfiguration.children(); - if (childConfigurations.count() == 1) { - currentConfig = childConfigurations.at(0); - } else { - for (int index = 0; index < childConfigurations.count(); index++) { - QNetworkConfiguration childConfig = childConfigurations.at(index); - if (childConfig.isValid() && childConfig.state() == QNetworkConfiguration::Discovered) { - currentConfig = childConfig; - break; - } - } - } - } - break; - case QNetworkConfiguration::UserChoice: - // User choice is not a valid configuration for proxy discovery - break; - } - } - } - return currentConfig; -} - -SymbianIapId SymbianProxyQuery::getIapId(QNetworkConfigurationManager& configurationManager, const QNetworkProxyQuery &query) -{ - SymbianIapId iapId; - - QNetworkConfiguration currentConfig = query.networkConfiguration(); - if (!currentConfig.isValid()) { - //If config is not specified, then try to find out an active or default one - currentConfig = findCurrentConfiguration(configurationManager); - } - if (currentConfig.isValid()) { - // Note: the following code assumes that the identifier is in format - // I_xxxx where xxxx is the identifier of IAP. This is meant as a - // temporary solution until there is a support for returning - // implementation specific identifier. - const int generalPartLength = 2; - const int identifierNumberLength = currentConfig.identifier().length() - generalPartLength; - QString idString(currentConfig.identifier().right(identifierNumberLength)); - bool success; - uint id = idString.toUInt(&success); - if (success) - iapId.setIapId(id); - else - qWarning() << "Failed to convert identifier to access point identifier: " - << currentConfig.identifier(); - } - - return iapId; -} - -CCDIAPRecord *SymbianProxyQuery::getIapRecordLC(TUint32 aIAPId, CMDBSession &aDb) -{ - CCDIAPRecord *iap = static_cast (CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord)); - CleanupStack::PushL(iap); - iap->SetRecordId(aIAPId); - iap->LoadL(aDb); - return iap; -} - -CMDBRecordSet *SymbianProxyQuery::prepareQueryLC(TUint32 serviceId, TDesC& serviceType) -{ - // Create a recordset of type CCDProxiesRecord - // for priming search. - // This will ultimately contain record(s) - // matching the priming record attributes - CMDBRecordSet *proxyRecords = new (ELeave) CMDBRecordSet ( - KCDTIdProxiesRecord); - CleanupStack::PushL(proxyRecords); - - CCDProxiesRecord *primingProxyRecord = - static_cast (CCDRecordBase::RecordFactoryL(KCDTIdProxiesRecord)); - CleanupStack::PushL(primingProxyRecord); - - primingProxyRecord->iServiceType.SetMaxLengthL(serviceType.Length()); - primingProxyRecord->iServiceType = serviceType; - primingProxyRecord->iService = serviceId; - primingProxyRecord->iUseProxyServer = ETrue; - - proxyRecords->iRecords.AppendL(primingProxyRecord); - // Ownership of primingProxyRecord is transferred to - // proxyRecords, just remove it from the CleanupStack - CleanupStack::Pop(primingProxyRecord); - return proxyRecords; -} - -QList SymbianProxyQuery::proxyQueryL(TUint32 aIAPId, const QNetworkProxyQuery &query) -{ - QList foundProxies; - if (query.queryType() != QNetworkProxyQuery::UrlRequest) { - return foundProxies; - } - - CMDBSession *iDb = CMDBSession::NewLC(KCDVersion1_1); - CCDIAPRecord *iap = getIapRecordLC(aIAPId, *iDb); - - // Read service table id and service type - // from the IAP record found - TUint32 serviceId = iap->iService; - RBuf serviceType; - serviceType.CreateL(iap->iServiceType); - CleanupStack::PopAndDestroy(iap); - CleanupClosePushL(serviceType); - - CMDBRecordSet *proxyRecords = prepareQueryLC(serviceId, serviceType); - - // Now to find a proxy table matching our criteria - if (proxyRecords->FindL(*iDb)) { - TInt count = proxyRecords->iRecords.Count(); - for(TInt index = 0; index < count; index++) { - CCDProxiesRecord *proxyRecord = static_cast (proxyRecords->iRecords[index]); - RBuf serverName; - serverName.CreateL(proxyRecord->iServerName); - CleanupClosePushL(serverName); - if (serverName.Length() == 0) - User::Leave(KErrNotFound); - QString serverNameQt((const QChar*)serverName.Ptr(), serverName.Length()); - CleanupStack::Pop(); // serverName - TUint32 port = proxyRecord->iPortNumber; - - QNetworkProxy proxy(QNetworkProxy::HttpProxy, serverNameQt, port); - foundProxies.append(proxy); - } - } - - CleanupStack::PopAndDestroy(proxyRecords); - CleanupStack::Pop(); // serviceType - CleanupStack::PopAndDestroy(iDb); - - return foundProxies; -} - -QList QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &query) -{ - QList proxies; - SymbianIapId iapId; - TInt error; - QNetworkConfigurationManager manager; - iapId = SymbianProxyQuery::getIapId(manager, query); - if (iapId.isValid()) { - TRAP(error, proxies = SymbianProxyQuery::proxyQueryL(iapId.iapId(), query)) - if (error != KErrNone) { - qWarning() << "Error while retrieving proxies: '" << error << '"'; - proxies.clear(); - } - } - proxies << QNetworkProxy::NoProxy; - - return proxies; -} - -QT_END_NAMESPACE - -#endif -- cgit v1.2.3