From 3915dd40b967fbf96a53820a8130342280a5b299 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 5 Apr 2011 16:30:19 +0100 Subject: QHostInfo symbian backend finalisation For reverse lookups, don't report errors, instead just return the IP address as a string for the host name (for behavioural compability with the windows and unix backends) Don't sort IP4 addresses before IP6 addresses for the same host. The symbian host resolver internally sorts the list so the usable addresses are returned first. (usable means has a valid route) Task-number: QTBUG-18135 Reviewed-by: Markus Goetz --- src/network/kernel/qhostinfo_symbian.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/network/kernel/qhostinfo_symbian.cpp b/src/network/kernel/qhostinfo_symbian.cpp index 40ede54..2a8de1d 100644 --- a/src/network/kernel/qhostinfo_symbian.cpp +++ b/src/network/kernel/qhostinfo_symbian.cpp @@ -117,11 +117,13 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName, QSharedPointer() << address); } + results.setAddresses(QList() << address); return results; } @@ -188,8 +190,7 @@ QString QHostInfo::localHostName() RSocketServ socketServ(qt_symbianGetSocketServer()); RHostResolver hostResolver; - // Will return both IPv4 and IPv6 - // TODO: Pass RHostResolver.Open() the global RConnection + // RConnection not required to get the host name int err = hostResolver.Open(socketServ, KAfInet, KProtocolInetUdp); if (err) return QString(); @@ -420,13 +421,7 @@ void QSymbianHostResolver::processNameResult() // Ensure that record is valid (not an alias and with length greater than 0) if (!(iNameResult().iFlags & TNameRecord::EAlias) && !(hostAdd.IsUnspecified())) { - if (iNameResult().iAddr.Family() == KAfInet) { - // IPv4 - prepend - iHostAddresses.prepend(QHostAddress(qt_TDesC2QString(ipAddr))); - } else { - // IPv6 - append - iHostAddresses.append(QHostAddress(qt_TDesC2QString(ipAddr))); - } + iHostAddresses.append(QHostAddress(qt_TDesC2QString(ipAddr))); } iState = EGetByName; @@ -453,11 +448,13 @@ void QSymbianHostResolver::processAddressResult() TInt err = iStatus.Int(); if (err < 0) { - setError_helper(iResults, err); + //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); } + iResults.setAddresses(QList() << iAddress); returnResults(); } @@ -523,6 +520,7 @@ void QSymbianHostInfoLookupManager::runNextLookup() // if spare capacity, try to start another one if (iCurrentLookups.count() >= KMaxConcurrentLookups) break; + i--; //compensate for removeAt } } } -- cgit v0.12