summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qhostinfo_win.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2009-08-21 15:56:57 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2009-08-21 15:56:57 +0300
commit34679dd23213881a9632e21e4858377ff90a9006 (patch)
treedeb9ebf681d4954b2d44858ca1a14d251c31e8eb /src/network/kernel/qhostinfo_win.cpp
parent7669f91c33328505fbe52f4913bd3f8745b76d31 (diff)
parent4aa6869877d4906fcfaac5388294748512cace25 (diff)
Merge branch 'master' of git@scm.dev.troll.no:qt/qt-s60-public
Conflicts: src/corelib/io/qfilesystemwatcher_symbian.cpp src/corelib/io/qfilesystemwatcher_symbian_p.h
Diffstat (limited to 'src/network/kernel/qhostinfo_win.cpp')
-rw-r--r--src/network/kernel/qhostinfo_win.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index 93dc7204e..c5dc2d2ae 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -52,6 +52,7 @@
#include <qlibrary.h>
#include <qtimer.h>
#include <qmutex.h>
+#include <qurl.h>
#include <private/qmutexpool_p.h>
QT_BEGIN_NAMESPACE
@@ -129,7 +130,6 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
}
QHostInfo results;
- results.setHostName(hostName);
#if defined(QHOSTINFO_DEBUG)
qDebug("QHostInfoAgent::fromName(%p): looking up \"%s\" (IPv6 support is %s)",
@@ -178,12 +178,28 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
}
}
+ // IDN support
+ QByteArray aceHostname;
+ if (results.hostName().isEmpty()) {
+ // it's a hostname resolution
+ aceHostname = QUrl::toAce(hostName);
+ results.setHostName(hostName);
+ if (aceHostname.isEmpty()) {
+ results.setError(QHostInfo::HostNotFound);
+ results.setErrorString(hostName.isEmpty() ? QObject::tr("No host name given") : QObject::tr("Invalid hostname"));
+ return results;
+ }
+ } else {
+ // it's an IP reverse resolution
+ aceHostname = results.hostName().toLatin1();
+ }
+
if (local_getaddrinfo && local_freeaddrinfo) {
// Call getaddrinfo, and place all IPv4 addresses at the start
// and the IPv6 addresses at the end of the address list in
// results.
qt_addrinfo *res;
- int err = local_getaddrinfo(hostName.toLatin1().constData(), 0, 0, &res);
+ int err = local_getaddrinfo(aceHostname.constData(), 0, 0, &res);
if (err == 0) {
QList<QHostAddress> addresses;
for (qt_addrinfo *p = res; p != 0; p = p->ai_next) {
@@ -218,7 +234,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
}
} else {
// Fall back to gethostbyname, which only supports IPv4.
- hostent *ent = gethostbyname(hostName.toLatin1().constData());
+ hostent *ent = gethostbyname(aceHostname.constData());
if (ent) {
char **p;
QList<QHostAddress> addresses;