summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qhostinfo_unix.cpp
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-10-21 00:43:19 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-10-21 00:43:19 (GMT)
commitf6b1582d726f97d8be4b30f0f6da2350220f27c5 (patch)
tree64bcea1b8b3cc8f94073a9e83b36b2b40ad990e8 /src/network/kernel/qhostinfo_unix.cpp
parent110c58a20f3158143d83ebea4f2ece4f7925f913 (diff)
parent7bd7f5ec6eb520b7d9940a24817b17132d9ed6a2 (diff)
downloadQt-f6b1582d726f97d8be4b30f0f6da2350220f27c5.zip
Qt-f6b1582d726f97d8be4b30f0f6da2350220f27c5.tar.gz
Qt-f6b1582d726f97d8be4b30f0f6da2350220f27c5.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/network/kernel/qhostinfo_unix.cpp')
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp40
1 files changed, 15 insertions, 25 deletions
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index b4ac3d2..7e6e522 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -173,38 +173,28 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
#endif
char hbuf[NI_MAXHOST];
- if (!sa || getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) != 0) {
- results.setError(QHostInfo::HostNotFound);
- results.setErrorString(tr("Host not found"));
- return results;
- }
- results.setHostName(QString::fromLatin1(hbuf));
+ if (sa && getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) == 0)
+ results.setHostName(QString::fromLatin1(hbuf));
#else
in_addr_t inetaddr = qt_safe_inet_addr(hostName.toLatin1().constData());
struct hostent *ent = gethostbyaddr((const char *)&inetaddr, sizeof(inetaddr), AF_INET);
- if (!ent) {
- results.setError(QHostInfo::HostNotFound);
- results.setErrorString(tr("Host not found"));
- return results;
- }
- results.setHostName(QString::fromLatin1(ent->h_name));
+ if (ent)
+ results.setHostName(QString::fromLatin1(ent->h_name));
#endif
+
+ if (results.hostName().isEmpty())
+ results.setHostName(address.toString());
+ results.setAddresses(QList<QHostAddress>() << address);
+ return results;
}
// 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();
+ QByteArray 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;
}
#if !defined (QT_NO_GETADDRINFO)