Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/network/kernel/qhostinfo_win.cpp

    r2 r561  
    22**
    33** 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])
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5353#include <qtimer.h>
    5454#include <qmutex.h>
     55
    5556#include <private/qmutexpool_p.h>
    5657
     
    7172    sockaddr *ai_addr;
    7273    qt_addrinfo *ai_next;
    73 };
    74 
    75 // sockaddr_in6 size changed between old and new SDK
    76 // Only the new version is the correct one, so always
    77 // 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 */
    8874};
    8975
     
    120106QMutex qPrivCEMutex;
    121107#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
    127109QHostInfo QHostInfoAgent::fromName(const QString &hostName)
    128110{
     
    145127
    146128    QHostInfo results;
    147     results.setHostName(hostName);
    148129
    149130#if defined(QHOSTINFO_DEBUG)
     
    176157
    177158            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));
    184161        } else {
    185162            unsigned long addr = inet_addr(hostName.toLatin1().constData());
    186163            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;
    194181    }
    195182
     
    199186        // results.
    200187        qt_addrinfo *res;
    201         int err = local_getaddrinfo(hostName.toLatin1().constData(), 0, 0, &res);
     188        int err = local_getaddrinfo(.constData(), 0, 0, &res);
    202189        if (err == 0) {
    203190            QList<QHostAddress> addresses;
     
    234221    } else {
    235222        // Fall back to gethostbyname, which only supports IPv4.
    236         hostent *ent = gethostbyname(hostName.toLatin1().constData());
     223        hostent *ent = gethostbyname(.constData());
    237224        if (ent) {
    238225            char **p;
Note: See TracChangeset for help on using the changeset viewer.