Changeset 561 for trunk/src/network/kernel/qhostinfo_win.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/network/kernel/qhostinfo_win.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 53 53 #include <qtimer.h> 54 54 #include <qmutex.h> 55 55 56 #include <private/qmutexpool_p.h> 56 57 … … 71 72 sockaddr *ai_addr; 72 73 qt_addrinfo *ai_next; 73 };74 75 // sockaddr_in6 size changed between old and new SDK76 // Only the new version is the correct one, so always77 // use this structure.78 struct qt_in6_addr {79 uchar qt_s6_addr[16];80 };81 82 struct qt_sockaddr_in6 {83 short sin6_family; /* AF_INET6 */84 u_short sin6_port; /* Transport level port number */85 u_long sin6_flowinfo; /* IPv6 flow information */86 struct qt_in6_addr sin6_addr; /* IPv6 address */87 u_long sin6_scope_id; /* set of interfaces for a scope */88 74 }; 89 75 … … 120 106 QMutex qPrivCEMutex; 121 107 #endif 122 /* 123 Performs a blocking call to gethostbyname or getaddrinfo, stores 124 the results in a QHostInfo structure and emits the 125 resultsReady() signal. 126 */ 108 127 109 QHostInfo QHostInfoAgent::fromName(const QString &hostName) 128 110 { … … 145 127 146 128 QHostInfo results; 147 results.setHostName(hostName);148 129 149 130 #if defined(QHOSTINFO_DEBUG) … … 176 157 177 158 char hbuf[NI_MAXHOST]; 178 if (local_getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) != 0) { 179 results.setError(QHostInfo::HostNotFound); 180 results.setErrorString(tr("Host not found")); 181 return results; 182 } 183 results.setHostName(QString::fromLatin1(hbuf)); 159 if (local_getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) == 0) 160 results.setHostName(QString::fromLatin1(hbuf)); 184 161 } else { 185 162 unsigned long addr = inet_addr(hostName.toLatin1().constData()); 186 163 struct hostent *ent = gethostbyaddr((const char*)&addr, sizeof(addr), AF_INET); 187 if (!ent) { 188 results.setError(QHostInfo::HostNotFound); 189 results.setErrorString(tr("Host not found")); 190 return results; 191 } 192 results.setHostName(QString::fromLatin1(ent->h_name)); 193 } 164 if (ent) 165 results.setHostName(QString::fromLatin1(ent->h_name)); 166 } 167 168 if (results.hostName().isEmpty()) 169 results.setHostName(address.toString()); 170 results.setAddresses(QList<QHostAddress>() << address); 171 return results; 172 } 173 174 // IDN support 175 QByteArray aceHostname = QUrl::toAce(hostName); 176 results.setHostName(hostName); 177 if (aceHostname.isEmpty()) { 178 results.setError(QHostInfo::HostNotFound); 179 results.setErrorString(hostName.isEmpty() ? tr("No host name given") : tr("Invalid hostname")); 180 return results; 194 181 } 195 182 … … 199 186 // results. 200 187 qt_addrinfo *res; 201 int err = local_getaddrinfo( hostName.toLatin1().constData(), 0, 0, &res);188 int err = local_getaddrinfo(.constData(), 0, 0, &res); 202 189 if (err == 0) { 203 190 QList<QHostAddress> addresses; … … 234 221 } else { 235 222 // Fall back to gethostbyname, which only supports IPv4. 236 hostent *ent = gethostbyname( hostName.toLatin1().constData());223 hostent *ent = gethostbyname(.constData()); 237 224 if (ent) { 238 225 char **p;
Note:
See TracChangeset
for help on using the changeset viewer.