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:
26 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/network/kernel/kernel.pri

    r160 r561  
    2121           kernel/qnetworkinterface.cpp
    2222
    23 unix:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
     23symbian: SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_symbian.cpp
     24unix:!symbian:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
    2425win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp
    2526os2:SOURCES += kernel/qhostinfo_os2.cpp kernel/qnetworkinterface_os2.cpp
    2627
    27 mac:LIBS+= -framework SystemConfiguration
     28mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation
    2829mac:SOURCES += kernel/qnetworkproxy_mac.cpp
    2930else:win32:SOURCES += kernel/qnetworkproxy_win.cpp
  • trunk/src/network/kernel/qauthenticator.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4747#include <qcryptographichash.h>
    4848#include <qhttp.h>
     49#include <qiodevice.h>
    4950#include <qdatastream.h>
    5051#include <qendian.h>
     
    6465
    6566  \reentrant
    66   \ingroup io
     67  \ingroup network
    6768  \inmodule QtNetwork
    6869
    6970  The QAuthenticator class is usually used in the
    70   \l{QHttp::}{authenticationRequired()} and
    71   \l{QHttp::}{proxyAuthenticationRequired()} signals of QHttp and
     71  \l{QNetworkAccessManager::}{authenticationRequired()} and
     72  \l{QNetworkAccessManager::}{proxyAuthenticationRequired()} signals of QNetworkAccessManager and
    7273  QAbstractSocket. The class provides a way to pass back the required
    7374  authentication information to the socket when accessing services that
    7475  require authentication.
     76
     77  QAuthenticator supports the following authentication methods:
     78  \list
     79    \o Basic
     80    \o NTLM version 1
     81    \o Digest-MD5
     82  \endlist
     83
     84  Note that, in particular, NTLM version 2 is not supported.
    7585
    7686  \sa QSslSocket
     
    503513    if (!opaque.isEmpty())
    504514        credentials += "opaque=\"" + opaque + "\", ";
    505     credentials += "response=\"" + response + "\"";
     515    credentials += "response=\"" + response + '\"';
    506516    if (!options.value("algorithm").isEmpty())
    507517        credentials += ", algorithm=" + options.value("algorithm");
     
    509519        credentials += ", qop=" + qop + ", ";
    510520        credentials += "nc=" + nonceCountString + ", ";
    511         credentials += "cnonce=\"" + cnonce + "\"";
     521        credentials += "cnonce=\"" + cnonce + '\"';
    512522    }
    513523
  • trunk/src/network/kernel/qauthenticator.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/network/kernel/qauthenticator_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/network/kernel/qhostaddress.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    420420    \class QHostAddress
    421421    \brief The QHostAddress class provides an IP address.
    422     \ingroup io
     422    \ingroup network
    423423    \inmodule QtNetwork
    424424
     
    432432    using isIPv4Address() or isIPv6Address(), and retrieved with
    433433    toIPv4Address(), toIPv6Address(), or toString().
     434
     435    \note Please note that QHostAddress does not do DNS lookups.
     436    QHostInfo is needed for that.
    434437
    435438    The class also supports common predefined addresses: \l Null, \l
     
    524527*/
    525528QHostAddress::QHostAddress(const QHostAddress &address)
    526     : d(new QHostAddressPrivate(*address.d))
     529    : d(new QHostAddressPrivate(*address.d.data()))
    527530{
    528531}
     
    560563QHostAddress::~QHostAddress()
    561564{
    562     delete d;
    563565}
    564566
     
    569571QHostAddress &QHostAddress::operator=(const QHostAddress &address)
    570572{
    571     *d = *address.d;
     573    *d.data() = *address.d.data();
    572574    return *this;
    573575}
     
    10791081QDebug operator<<(QDebug d, const QHostAddress &address)
    10801082{
    1081     d.maybeSpace() << "QHostAddress(" << address.toString() << ")";
     1083    d.maybeSpace() << "QHostAddress(" << address.toString() << ')';
    10821084    return d.space();
    10831085}
  • trunk/src/network/kernel/qhostaddress.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545#include <QtCore/qpair.h>
    4646#include <QtCore/qstring.h>
     47#include <QtCore/qscopedpointer.h>
    4748#include <QtNetwork/qabstractsocket.h>
    4849
     
    131132
    132133protected:
    133     QHostAddressPrivate *d;
     134    QScopedPointer<QHostAddressPrivate> d;
    134135};
    135136
  • trunk/src/network/kernel/qhostaddress_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/network/kernel/qhostinfo.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4343#include "qhostinfo_p.h"
    4444
     45#include "QtCore/qscopedpointer.h"
    4546#include <qabstracteventdispatcher.h>
    4647#include <private/qunicodetables_p.h>
     
    6061QT_BEGIN_NAMESPACE
    6162
    62 Q_GLOBAL_STATIC(QHostInfoAgent, theAgent)
    63 void QHostInfoAgent::staticCleanup()
    64 {
    65     theAgent()->cleanup();
    66 }
     63#ifndef QT_NO_THREAD
     64Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager)
     65#endif
    6766
    6867//#define QHOSTINFO_DEBUG
     
    7473    \reentrant
    7574    \inmodule QtNetwork
    76     \ingroup io
     75    \ingroup network
    7776
    7877    QHostInfo uses the lookup mechanisms provided by the operating
     
    142141
    143142    \snippet doc/src/snippets/code/src_network_kernel_qhostinfo.cpp 4
     143
     144    \note There is no guarantee on the order the signals will be emitted
     145    if you start multiple requests with lookupHost().
    144146
    145147    \sa abortHostLookup(), addresses(), error(), fromName()
     
    159161    qRegisterMetaType<QHostInfo>("QHostInfo");
    160162
    161 #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
    162     QWindowsSockInit bust; // makes sure WSAStartup was callled
     163    int id = theIdCounter.fetchAndAddRelaxed(1); // generate unique ID
     164
     165    if (name.isEmpty()) {
     166        QHostInfo hostInfo(id);
     167        hostInfo.setError(QHostInfo::HostNotFound);
     168        hostInfo.setErrorString(QObject::tr("No host name given"));
     169        QScopedPointer<QHostInfoResult> result(new QHostInfoResult);
     170        QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
     171                         receiver, member, Qt::QueuedConnection);
     172        result.data()->emitResultsReady(hostInfo);
     173        return id;
     174    }
     175
     176#ifdef QT_NO_THREAD
     177    QHostInfo hostInfo = QHostInfoAgent::fromName(name);
     178    hostInfo.setLookupId(id);
     179    QScopedPointer<QHostInfoResult> result(new QHostInfoResult);
     180    QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
     181                     receiver, member, Qt::QueuedConnection);
     182    result.data()->emitResultsReady(hostInfo);
     183#else
     184    QHostInfoRunnable* runnable = new QHostInfoRunnable(name, id);
     185    QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
     186    theHostInfoLookupManager()->scheduleLookup(runnable);
    163187#endif
    164188
    165     // Support for IDNA
    166     QString lookup = QString::fromLatin1(QUrl::toAce(name));
    167 
    168     QHostInfoResult *result = new QHostInfoResult;
    169     result->autoDelete = false;
    170     QObject::connect(result, SIGNAL(resultsReady(QHostInfo)),
    171                      receiver, member);
    172     int id = result->lookupId = theIdCounter.fetchAndAddRelaxed(1);
    173 
    174     if (lookup.isEmpty()) {
    175         QHostInfo info(id);
    176         info.setError(QHostInfo::HostNotFound);
    177         info.setErrorString(QObject::tr("No host name given"));
    178         QMetaObject::invokeMethod(result, "emitResultsReady", Qt::QueuedConnection,
    179                                   Q_ARG(QHostInfo, info));
    180         result->autoDelete = true;
    181         return id;
    182     }
    183 
    184     QHostInfoAgent *agent = theAgent();
    185     agent->addHostName(lookup, result);
    186 
    187 #if !defined QT_NO_THREAD
    188     if (!agent->isRunning())
    189         agent->start();
     189    return id;
     190}
     191
     192/*!
     193    Aborts the host lookup with the ID \a id, as returned by lookupHost().
     194
     195    \sa lookupHost(), lookupId()
     196*/
     197void QHostInfo::abortHostLookup(int id)
     198{
     199#ifndef QT_NO_THREAD
     200    theHostInfoLookupManager()->abortLookup(id);
    190201#else
    191 //    if (!agent->isRunning())
    192         agent->run();
    193 //    else
    194 //      agent->wakeOne();
     202    // we cannot abort if it was non threaded.. the result signal has already been posted
     203    Q_UNUSED(id);
    195204#endif
    196     return id;
    197 }
    198 
    199 /*!
    200     Aborts the host lookup with the ID \a id, as returned by lookupHost().
    201 
    202     \sa lookupHost(), lookupId()
    203 */
    204 void QHostInfo::abortHostLookup(int id)
    205 {
    206     QHostInfoAgent *agent = theAgent();
    207     agent->abortLookup(id);
    208205}
    209206
     
    227224#endif
    228225
    229     if (!name.isEmpty())
    230         return QHostInfoAgent::fromName(QLatin1String(QUrl::toAce(name)));
    231 
    232     QHostInfo retval;
    233     retval.d->err = HostNotFound;
    234     retval.d->errorStr = QObject::tr("No host name given");
    235     return retval;
    236 }
    237 
    238 /*!
    239     \internal
    240     Pops a query off the queries list, performs a blocking call to
    241     QHostInfoAgent::lookupHost(), and emits the resultsReady()
    242     signal. This process repeats until the queries list is empty.
    243 */
    244 void QHostInfoAgent::run()
    245 {
    246 #ifndef QT_NO_THREAD
    247     // Dont' allow thread termination during event delivery, but allow it
    248     // during the actual blocking host lookup stage.
    249     setTerminationEnabled(false);
    250     forever
    251 #endif
    252     {
    253         QHostInfoQuery *query;
    254         {
    255 #ifndef QT_NO_THREAD
    256             // the queries list is shared between threads. lock all
    257             // access to it.
    258             QMutexLocker locker(&mutex);
    259             if (!quit && queries.isEmpty())
    260                 cond.wait(&mutex);
    261             if (quit) {
    262                 // Reset the quit variable in case QCoreApplication is
    263                 // destroyed and recreated.
    264                 quit = false;
    265                 break;
    266             }
    267             if (queries.isEmpty())
    268                 continue;
    269 #else
    270             if (queries.isEmpty())
    271                 return;
    272 #endif
    273             query = queries.takeFirst();
    274             pendingQueryId = query->object->lookupId;
    275         }
    276 
    277 #if defined(QHOSTINFO_DEBUG)
    278         qDebug("QHostInfoAgent::run(%p): looking up \"%s\"", this,
    279                query->hostName.toLatin1().constData());
    280 #endif
    281 
    282 #ifndef QT_NO_THREAD
    283         // Start query - allow termination at this point, but not outside. We
    284         // don't want to all termination during event delivery, but we don't
    285         // want the lookup to prevent the app from quitting (the agent
    286         // destructor terminates the thread).
    287         setTerminationEnabled(true);
    288 #endif
    289         QHostInfo info = fromName(query->hostName);
    290 #ifndef QT_NO_THREAD
    291         setTerminationEnabled(false);
    292 #endif
    293 
    294         int id = query->object->lookupId;
    295         info.setLookupId(id);
    296         if (pendingQueryId == id)
    297             query->object->emitResultsReady(info);
    298         delete query;
    299     }
     226    return QHostInfoAgent::fromName(name);
    300227}
    301228
     
    328255*/
    329256QHostInfo::QHostInfo(const QHostInfo &other)
    330     : d(new QHostInfoPrivate(*other.d))
     257    : d(new QHostInfoPrivate(*other.d.data()))
    331258{
    332259}
     
    338265QHostInfo &QHostInfo::operator=(const QHostInfo &other)
    339266{
    340     *d = *other.d;
     267    *d.data() = *other.d.data();
    341268    return *this;
    342269}
     
    347274QHostInfo::~QHostInfo()
    348275{
    349     delete d;
    350276}
    351277
     
    477403*/
    478404
     405#ifndef QT_NO_THREAD
     406QHostInfoRunnable::QHostInfoRunnable(QString hn, int i) : toBeLookedUp(hn), id(i)
     407{
     408    setAutoDelete(true);
     409}
     410
     411// the QHostInfoLookupManager will at some point call this via a QThreadPool
     412void QHostInfoRunnable::run()
     413{
     414    QHostInfoLookupManager *manager = theHostInfoLookupManager();
     415    // check aborted
     416    if (manager->wasAborted(id)) {
     417        manager->lookupFinished(this);
     418        return;
     419    }
     420
     421    // check cache
     422    // FIXME
     423
     424    // if not in cache: OS lookup
     425    QHostInfo hostInfo = QHostInfoAgent::fromName(toBeLookedUp);
     426
     427    // save to cache
     428    // FIXME
     429
     430    // check aborted again
     431    if (manager->wasAborted(id)) {
     432        manager->lookupFinished(this);
     433        return;
     434    }
     435
     436    // signal emission
     437    hostInfo.setLookupId(id);
     438    resultEmitter.emitResultsReady(hostInfo);
     439
     440    manager->lookupFinished(this);
     441
     442    // thread goes back to QThreadPool
     443}
     444
     445QHostInfoLookupManager::QHostInfoLookupManager() : mutex(QMutex::Recursive), wasDeleted(false)
     446{
     447    moveToThread(QCoreApplicationPrivate::mainThread());
     448    threadPool.setMaxThreadCount(5); // do 5 DNS lookups in parallel
     449}
     450
     451QHostInfoLookupManager::~QHostInfoLookupManager()
     452{
     453    wasDeleted = true;
     454}
     455
     456void QHostInfoLookupManager::work()
     457{
     458    if (wasDeleted)
     459        return;
     460
     461    // goals of this function:
     462    //  - launch new lookups via the thread pool
     463    //  - make sure only one lookup per host/IP is in progress
     464
     465    QMutexLocker locker(&mutex);
     466
     467    if (!finishedLookups.isEmpty()) {
     468        // remove ID from aborted if it is in there
     469        for (int i = 0; i < finishedLookups.length(); i++) {
     470           abortedLookups.removeAll(finishedLookups.at(i)->id);
     471        }
     472
     473        finishedLookups.clear();
     474    }
     475
     476    if (!postponedLookups.isEmpty()) {
     477        // try to start the postponed ones
     478
     479        QMutableListIterator<QHostInfoRunnable*> iterator(postponedLookups);
     480        while (iterator.hasNext()) {
     481            QHostInfoRunnable* postponed = iterator.next();
     482
     483            // check if none of the postponed hostnames is currently running
     484            bool alreadyRunning = false;
     485            for (int i = 0; i < currentLookups.length(); i++) {
     486                if (currentLookups.at(i)->toBeLookedUp == postponed->toBeLookedUp) {
     487                    alreadyRunning = true;
     488                    break;
     489                }
     490            }
     491            if (!alreadyRunning) {
     492                iterator.remove();
     493                scheduledLookups.prepend(postponed); // prepend! we want to finish it ASAP
     494            }
     495        }
     496    }
     497
     498    if (!scheduledLookups.isEmpty()) {
     499        // try to start the new ones
     500        QMutableListIterator<QHostInfoRunnable*> iterator(scheduledLookups);
     501        while (iterator.hasNext()) {
     502            QHostInfoRunnable *scheduled = iterator.next();
     503
     504            // check if a lookup for this host is already running, then postpone
     505            for (int i = 0; i < currentLookups.size(); i++) {
     506                if (currentLookups.at(i)->toBeLookedUp == scheduled->toBeLookedUp) {
     507                    iterator.remove();
     508                    postponedLookups.append(scheduled);
     509                    scheduled = 0;
     510                    break;
     511                }
     512            }
     513
     514            if (scheduled && threadPool.tryStart(scheduled)) {
     515                // runnable now running in new thread, track this in currentLookups
     516                iterator.remove();
     517                currentLookups.append(scheduled);
     518            } else if (scheduled) {
     519                // wanted to start, but could not because thread pool is busy
     520                break;
     521            } else {
     522                // was postponed, continue iterating
     523                continue;
     524            }
     525        };
     526    }
     527}
     528
     529// called by QHostInfo
     530void QHostInfoLookupManager::scheduleLookup(QHostInfoRunnable *r)
     531{
     532    if (wasDeleted)
     533        return;
     534
     535    QMutexLocker locker(&this->mutex);
     536    scheduledLookups.enqueue(r);
     537    work();
     538}
     539
     540// called by QHostInfo
     541void QHostInfoLookupManager::abortLookup(int id)
     542{
     543    if (wasDeleted)
     544        return;
     545
     546    QMutexLocker locker(&this->mutex);
     547    if (!abortedLookups.contains(id))
     548        abortedLookups.append(id);
     549}
     550
     551// called from QHostInfoRunnable
     552bool QHostInfoLookupManager::wasAborted(int id)
     553{
     554    if (wasDeleted)
     555        return true;
     556
     557    QMutexLocker locker(&this->mutex);
     558    return abortedLookups.contains(id);
     559}
     560
     561// called from QHostInfoRunnable
     562void QHostInfoLookupManager::lookupFinished(QHostInfoRunnable *r)
     563{
     564    if (wasDeleted)
     565        return;
     566
     567    QMutexLocker locker(&this->mutex);
     568    currentLookups.removeOne(r);
     569    finishedLookups.append(r);
     570    work();
     571}
     572
     573#endif // QT_NO_THREAD
     574
    479575QT_END_NAMESPACE
  • trunk/src/network/kernel/qhostinfo.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4444
    4545#include <QtCore/qlist.h>
     46#include <QtCore/qscopedpointer.h>
    4647#include <QtNetwork/qhostaddress.h>
    4748
     
    9293
    9394private:
    94     QHostInfoPrivate *d;
     95    QScopedPointer<QHostInfoPrivate> d;
    9596};
    9697
  • trunk/src/network/kernel/qhostinfo_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4848//
    4949// This file is not part of the Qt API.  It exists for the convenience
    50 // of the QLibrary class.  This header file may change from
     50// of the QHostInfo class.  This header file may change from
    5151// version to version without notice, or even be removed.
    5252//
     
    6262#include "QtCore/qpointer.h"
    6363
    64 #if !defined QT_NO_THREAD
     64#ifndef QT_NO_THREAD
    6565#include "QtCore/qthread.h"
    66 #    define QHostInfoAgentBase QThread
    67 #else
    68 #    define QHostInfoAgentBase QObject
     66#include "QtCore/qthreadpool.h"
     67#include "QtCore/qmutex.h"
     68#include "QtCore/qrunnable.h"
     69#include "QtCore/qlist.h"
     70#include "QtCore/qqueue.h"
    6971#endif
    7072
    7173QT_BEGIN_NAMESPACE
    72 
    73 static const int QHOSTINFO_THREAD_WAIT = 250; // ms
    7474
    7575class QHostInfoResult : public QObject
     
    8080    {
    8181        emit resultsReady(info);
    82         if (autoDelete)
    83             delete this;
    8482    }
    8583
    8684Q_SIGNALS:
    87     void resultsReady(const QHostInfo &info);
    88 
    89 public:
    90     int lookupId;
    91     bool autoDelete;
     85    void resultsReady(const QHostInfo info);
    9286};
    9387
    94 struct QHostInfoQuery
    95 {
    96     inline QHostInfoQuery() : object(0) {}
    97     inline ~QHostInfoQuery() { delete object; }
    98     inline QHostInfoQuery(const QString &name, QHostInfoResult *result)
    99         : hostName(name), object(result) {}
    100 
    101     QString hostName;
    102     QHostInfoResult *object;
    103 };
    104 
    105 class QHostInfoAgent : public QHostInfoAgentBase
     88// needs to be QObject because fromName calls tr()
     89class QHostInfoAgent : public QObject
    10690{
    10791    Q_OBJECT
    10892public:
    109     inline QHostInfoAgent()
    110     {
    111         // There is a chance that there will be two instances of
    112         // QHostInfoAgent if two threads try to get Q_GLOBAL_STATIC
    113         // object at the same time. The second object will be deleted
    114         // immediately before anyone uses it, but we need to be
    115         // careful about what we do in the constructor.
    116         static QBasicAtomicInt done = Q_BASIC_ATOMIC_INITIALIZER(0);
    117         if (done.testAndSetRelaxed(0, 1))
    118             qAddPostRoutine(staticCleanup);
    119         moveToThread(QCoreApplicationPrivate::mainThread());
    120         quit = false;
    121         pendingQueryId = -1;
    122     }
    123     inline ~QHostInfoAgent()
    124     { cleanup(); }
    125 
    126     void run();
    12793    static QHostInfo fromName(const QString &hostName);
    128 
    129     inline void addHostName(const QString &name, QHostInfoResult *result)
    130     {
    131         QMutexLocker locker(&mutex);
    132         queries << new QHostInfoQuery(name, result);
    133         cond.wakeOne();
    134     }
    135 
    136     inline void abortLookup(int id)
    137     {
    138         QMutexLocker locker(&mutex);
    139         for (int i = 0; i < queries.size(); ++i) {
    140             QHostInfoResult *result = queries.at(i)->object;
    141             if (result->lookupId == id) {
    142                 result->disconnect();
    143                 delete queries.takeAt(i);
    144                 return;
    145             }
    146         }
    147         if (pendingQueryId == id)
    148             pendingQueryId = -1;
    149     }
    150 
    151     static void staticCleanup();
    152 
    153 public Q_SLOTS:
    154     inline void cleanup()
    155     {
    156         {
    157             QMutexLocker locker(&mutex);
    158             qDeleteAll(queries);
    159             queries.clear();
    160             quit = true;
    161             cond.wakeOne();
    162         }
    163 #ifndef QT_NO_THREAD
    164         if (!wait(QHOSTINFO_THREAD_WAIT))
    165             terminate();
    166         wait();
    167 #endif
    168     }
    169 
    170 private:
    171     QList<QHostInfoQuery *> queries;
    172     QMutex mutex;
    173     QWaitCondition cond;
    174     volatile bool quit;
    175     int pendingQueryId;
    17694};
    17795
     
    18199    inline QHostInfoPrivate()
    182100        : err(QHostInfo::NoError),
    183           errorStr(QLatin1String(QT_TRANSLATE_NOOP("QHostInfo", "Unknown error")))
     101          errorStr(QLatin1String(QT_TRANSLATE_NOOP("QHostInfo", "Unknown error"))),
     102          lookupId(0)
    184103    {
    185104    }
     
    192111};
    193112
     113#ifndef QT_NO_THREAD
     114// the following classes are used for the (normal) case: We use multiple threads to lookup DNS
     115
     116class QHostInfoRunnable : public QRunnable
     117{
     118public:
     119    QHostInfoRunnable (QString hn, int i);
     120    void run();
     121
     122    QString toBeLookedUp;
     123    int id;
     124    QHostInfoResult resultEmitter;
     125};
     126
     127class QHostInfoLookupManager : public QObject
     128{
     129    Q_OBJECT
     130public:
     131    QHostInfoLookupManager();
     132    ~QHostInfoLookupManager();
     133
     134    void work();
     135
     136    // called from QHostInfo
     137    void scheduleLookup(QHostInfoRunnable *r);
     138    void abortLookup(int id);
     139
     140    // called from QHostInfoRunnable
     141    void lookupFinished(QHostInfoRunnable *r);
     142    bool wasAborted(int id);
     143
     144protected:
     145    QList<QHostInfoRunnable*> currentLookups; // in progress
     146    QList<QHostInfoRunnable*> postponedLookups; // postponed because in progress for same host
     147    QQueue<QHostInfoRunnable*> scheduledLookups; // not yet started
     148    QList<QHostInfoRunnable*> finishedLookups; // recently finished
     149    QList<int> abortedLookups; // ids of aborted lookups
     150
     151    QThreadPool threadPool;
     152
     153    QMutex mutex;
     154
     155    bool wasDeleted;
     156};
     157#endif
     158
    194159QT_END_NAMESPACE
    195160
  • trunk/src/network/kernel/qhostinfo_unix.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4141
    4242//#define QHOSTINFO_DEBUG
    43 
    44 static const int RESOLVER_TIMEOUT = 2000;
    4543
    4644#include "qplatformdefs.h"
     
    5351#include <qfile.h>
    5452#include <private/qmutexpool_p.h>
    55 
    56 extern "C" {
     53#include <private/qnet_unix_p.h>
     54
    5755#include <sys/types.h>
    5856#include <netdb.h>
    5957#include <arpa/inet.h>
    60 #include <resolv.h>
    61 }
     58#if defined(Q_OS_VXWORKS)
     59#  include <hostLib.h>
     60#else
     61#  include <resolv.h>
     62#endif
    6263
    6364#if defined (QT_NO_GETADDRINFO)
     
    122123{
    123124    QHostInfo results;
    124     results.setHostName(hostName);
    125125
    126126#if defined(QHOSTINFO_DEBUG)
     
    149149        // Reverse lookup
    150150// Reverse lookups using getnameinfo are broken on darwin, use gethostbyaddr instead.
    151 #if !defined (QT_NO_GETADDRINFO) && !defined (Q_OS_DARWIN)
     151#if !defined (QT_NO_GETADDRINFO) && !defined (Q_OS_DARWIN) && !defined (Q_OS_SYMBIAN)
    152152        sockaddr_in sa4;
    153153#ifndef QT_NO_IPV6
     
    174174
    175175        char hbuf[NI_MAXHOST];
    176         if (!sa || getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) != 0) {
    177             results.setError(QHostInfo::HostNotFound);
    178             results.setErrorString(tr("Host not found"));
    179             return results;
    180         }
    181         results.setHostName(QString::fromLatin1(hbuf));
     176        if (sa && getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) == 0)
     177            results.setHostName(QString::fromLatin1(hbuf));
    182178#else
    183         in_addr_t inetaddr = inet_addr(hostName.toLatin1().constData());
     179        in_addr_t inetaddr = qt_safe_inet_addr(hostName.toLatin1().constData());
    184180        struct hostent *ent = gethostbyaddr((const char *)&inetaddr, sizeof(inetaddr), AF_INET);
    185         if (!ent) {
    186             results.setError(QHostInfo::HostNotFound);
    187             results.setErrorString(tr("Host not found"));
    188             return results;
    189         }
    190         results.setHostName(QString::fromLatin1(ent->h_name));
    191 #endif
     181        if (ent)
     182            results.setHostName(QString::fromLatin1(ent->h_name));
     183#endif
     184
     185        if (results.hostName().isEmpty())
     186            results.setHostName(address.toString());
     187        results.setAddresses(QList<QHostAddress>() << address);
     188        return results;
     189    }
     190
     191    // IDN support
     192    QByteArray aceHostname = QUrl::toAce(hostName);
     193    results.setHostName(hostName);
     194    if (aceHostname.isEmpty()) {
     195        results.setError(QHostInfo::HostNotFound);
     196        results.setErrorString(hostName.isEmpty() ? QObject::tr("No host name given") : QObject::tr("Invalid hostname"));
     197        return results;
    192198    }
    193199
     
    203209#endif
    204210
    205     int result = getaddrinfo(hostName.toLatin1().constData(), 0, &hints, &res);
     211    int result = getaddrinfo(aceHostname.constData(), 0, &hints, &res);
    206212# ifdef Q_ADDRCONFIG
    207213    if (result == EAI_BADFLAGS) {
    208214        // if the lookup failed with AI_ADDRCONFIG set, try again without it
    209215        hints.ai_flags = 0;
    210         result = getaddrinfo(hostName.toLatin1().constData(), 0, &hints, &res);
     216        result = getaddrinfo(aceHostname.constData(), 0, &hints, &res);
    211217    }
    212218# endif
     
    262268    // must be provided.
    263269    QMutexLocker locker(::getHostByNameMutex());
    264     hostent *result = gethostbyname(hostName.toLatin1().constData());
     270    hostent *result = gethostbyname(aceHostname.constData());
    265271    if (result) {
    266272        if (result->h_addrtype == AF_INET) {
     
    277283            results.setErrorString(tr("Unknown address type"));
    278284        }
     285#if !defined(Q_OS_VXWORKS)
    279286    } else if (h_errno == HOST_NOT_FOUND || h_errno == NO_DATA
    280287               || h_errno == NO_ADDRESS) {
    281288        results.setError(QHostInfo::HostNotFound);
    282289        results.setErrorString(tr("Host not found"));
     290#endif
    283291    } else {
    284292        results.setError(QHostInfo::UnknownError);
     
    317325QString QHostInfo::localDomainName()
    318326{
     327#if !defined(Q_OS_VXWORKS)
    319328    resolveLibrary();
    320329    if (local_res_ninit) {
    321330        // using thread-safe version
    322331        res_state_ptr state = res_state_ptr(qMalloc(sizeof(*state)));
     332        Q_CHECK_PTR(state);
    323333        memset(state, 0, sizeof(*state));
    324334        local_res_ninit(state);
     
    346356        return domainName;
    347357    }
    348 
     358#endif
    349359    // nothing worked, try doing it by ourselves:
    350360    QFile resolvconf;
  • 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 (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5353#include <qtimer.h>
    5454#include <qmutex.h>
     55#include <qurl.h>
    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(aceHostname.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(aceHostname.constData());
    237224        if (ent) {
    238225            char **p;
  • trunk/src/network/kernel/qnetworkinterface.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    129129        if (i)
    130130            result += QLatin1Char(':');
    131        
     131
    132132        char buf[3];
    133133#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400
     
    149149    \since 4.2
    150150    \reentrant
    151     \ingroup io
     151    \ingroup network
    152152
    153153    Each network interface can contain zero or more IP addresses, which
     
    171171*/
    172172QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other)
    173     : d(new QNetworkAddressEntryPrivate(*other.d))
     173    : d(new QNetworkAddressEntryPrivate(*other.d.data()))
    174174{
    175175}
     
    180180QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry &other)
    181181{
    182     *d = *other.d;
     182    *d.data() = *other.d.data();
    183183    return *this;
    184184}
     
    189189QNetworkAddressEntry::~QNetworkAddressEntry()
    190190{
    191     delete d;
    192191}
    193192
     
    334333    \since 4.2
    335334    \reentrant
    336     \ingroup io
     335    \ingroup network
    337336
    338337    QNetworkInterface represents one network interface attached to the
     
    398397
    399398/*!
    400     Creates a copy of the the QNetworkInterface object contained in \a
     399    Creates a copy of the QNetworkInterface object contained in \a
    401400    other.
    402401*/
     
    595594    if (!entry.broadcast().isNull())
    596595        debug.nospace() << ", broadcast = " << entry.broadcast();
    597     debug.nospace() << ")";
     596    debug.nospace() << ')';
    598597    return debug.space();
    599598}
     
    605604                    << ", flags = ";
    606605    flagsDebug(debug, networkInterface.flags());
     606#if defined(Q_CC_RVCT)
     607    // RVCT gets confused with << networkInterface.addressEntries(), reason unknown.
     608    debug.nospace() << ")\n";
     609#else
    607610    debug.nospace() << ", entries = " << networkInterface.addressEntries()
    608611                    << ")\n";
     612#endif
    609613    return debug.space();
    610614}
  • trunk/src/network/kernel/qnetworkinterface.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4444
    4545#include <QtCore/qshareddata.h>
     46#include <QtCore/qscopedpointer.h>
    4647#include <QtNetwork/qhostaddress.h>
    4748
     
    8081
    8182private:
    82     QNetworkAddressEntryPrivate *d;
     83    QScopedPointer<QNetworkAddressEntryPrivate> d;
    8384};
    8485
  • trunk/src/network/kernel/qnetworkinterface_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/network/kernel/qnetworkinterface_unix.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4444#include "qnetworkinterface_p.h"
    4545#include "qalgorithms.h"
     46#include "private/qnet_unix_p.h"
    4647
    4748#ifndef QT_NO_NETWORKINTERFACE
     
    124125
    125126        // get the interface list
    126         if (::ioctl(socket, SIOCGIFCONF, &interfaceList) >= 0) {
     127        if (qt_safe_ioctl(socket, SIOCGIFCONF, &interfaceList) >= 0) {
    127128            if (int(interfaceList.ifc_len + sizeof(ifreq) + 64) < storageBuffer.size()) {
    128129                // if the buffer was big enough, break
     
    199200        // Get the canonical name
    200201        QByteArray oldName = req.ifr_name;
    201         if (::ioctl(socket, SIOCGIFNAME, &req) >= 0) {
     202        if (qt_safe_ioctl(socket, SIOCGIFNAME, &req) >= 0) {
    202203            iface->name = QString::fromLatin1(req.ifr_name);
    203204
     
    212213
    213214        // Get interface flags
    214         if (::ioctl(socket, SIOCGIFFLAGS, &req) >= 0) {
     215        if (qt_safe_ioctl(socket, SIOCGIFFLAGS, &req) >= 0) {
    215216            iface->flags = convertFlags(req.ifr_flags);
    216217        }
     
    218219#ifdef SIOCGIFHWADDR
    219220        // Get the HW address
    220         if (::ioctl(socket, SIOCGIFHWADDR, &req) >= 0) {
     221        if (qt_safe_ioctl(socket, SIOCGIFHWADDR, &req) >= 0) {
    221222            uchar *addr = (uchar *)&req.ifr_addr;
    222223            iface->hardwareAddress = iface->makeHwAddress(6, addr);
     
    233234
    234235    int socket;
    235     if ((socket = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) == -1)
     236    if ((socket = qt_safe_socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) == -1)
    236237        return interfaces;      // error
    237238
     
    248249        QNetworkAddressEntry entry;
    249250        if (iface->flags & QNetworkInterface::CanBroadcast) {
    250             if (::ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) {
     251            if (qt_safe_ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) {
    251252                sockaddr *sa = &req.ifr_addr;
    252253                if (sa->sa_family == AF_INET)
     
    256257
    257258        // Get the interface netmask
    258         if (::ioctl(socket, SIOCGIFNETMASK, &req) >= 0) {
     259        if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) {
    259260            sockaddr *sa = &req.ifr_addr;
    260261            entry.setNetmask(addressFromSockaddr(sa));
     
    262263
    263264        // Get the address of the interface
    264         if (::ioctl(socket, SIOCGIFADDR, &req) >= 0) {
     265        if (qt_safe_ioctl(socket, SIOCGIFADDR, &req) >= 0) {
    265266            sockaddr *sa = &req.ifr_addr;
    266267            entry.setIp(addressFromSockaddr(sa));
     
    393394
    394395    int socket;
    395     if ((socket = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) == -1)
     396    if ((socket = qt_safe_socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) == -1)
    396397        return interfaces;      // error
    397398
  • trunk/src/network/kernel/qnetworkinterface_win.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6767        done = true;
    6868
    69         HINSTANCE iphlpapiHnd;
    70         QT_WA({
    71                 iphlpapiHnd = LoadLibraryW(L"iphlpapi");
    72             }, {
    73                 iphlpapiHnd = LoadLibraryA("iphlpapi");
    74             });
     69        HINSTANCE iphlpapiHnd = LoadLibrary(L"iphlpapi");
    7570        if (iphlpapiHnd == NULL)
    76             return;             // failed to load, probably Windows 95
     71            return;
    7772
    7873#if defined(Q_OS_WINCE)
    79         ptrGetAdaptersInfo = (PtrGetAdaptersInfo)GetProcAddressW(iphlpapiHnd, L"GetAdaptersInfo");
    80         ptrGetAdaptersAddresses = (PtrGetAdaptersAddresses)GetProcAddressW(iphlpapiHnd, L"GetAdaptersAddresses");
    81         ptrGetNetworkParams = (PtrGetNetworkParams)GetProcAddressW(iphlpapiHnd, L"GetNetworkParams");
     74        ptrGetAdaptersInfo = (PtrGetAdaptersInfo)GetProcAddress(iphlpapiHnd, L"GetAdaptersInfo");
     75        ptrGetAdaptersAddresses = (PtrGetAdaptersAddresses)GetProcAddress(iphlpapiHnd, L"GetAdaptersAddresses");
     76        ptrGetNetworkParams = (PtrGetNetworkParams)GetProcAddress(iphlpapiHnd, L"GetNetworkParams");
    8277#else
    8378        ptrGetAdaptersInfo = (PtrGetAdaptersInfo)GetProcAddress(iphlpapiHnd, "GetAdaptersInfo");
     
    116111        // need more memory
    117112        pAdapter = (IP_ADAPTER_INFO *)qMalloc(bufSize);
     113        if (!pAdapter)
     114            return ipv4netmasks;
    118115        // try again
    119116        if (ptrGetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) {
     
    157154        // need more memory
    158155        pAdapter = (IP_ADAPTER_ADDRESSES *)qMalloc(bufSize);
    159 
     156        if (!pAdapter)
     157            return interfaces;
    160158        // try again
    161159        if (ptrGetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAdapter, &bufSize) != ERROR_SUCCESS) {
     
    237235        // need more memory
    238236        pAdapter = (IP_ADAPTER_INFO *)qMalloc(bufSize);
    239 
     237        if (!pAdapter)
     238            return interfaces;
    240239        // try again
    241240        if (ptrGetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) {
     
    307306    if (ptrGetNetworkParams(pinfo, &bufSize) == ERROR_BUFFER_OVERFLOW) {
    308307        pinfo = (FIXED_INFO *)qMalloc(bufSize);
    309 
     308        if (!pinfo)
     309            return QString();
    310310        // try again
    311311        if (ptrGetNetworkParams(pinfo, &bufSize) != ERROR_SUCCESS) {
  • trunk/src/network/kernel/qnetworkinterface_win_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5555
    5656#include <winsock2.h>
    57 #include <windows.h>
     57#include <qt_windows.h>
    5858#include <time.h>
    5959
  • trunk/src/network/kernel/qnetworkproxy.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4949
    5050    \reentrant
    51     \ingroup io
     51    \ingroup network
    5252    \inmodule QtNetwork
    5353
     
    5555    proxy support to the Qt network classes. The currently supported
    5656    classes are QAbstractSocket, QTcpSocket, QUdpSocket, QTcpServer,
    57     QHttp and QFtp. The proxy support is designed to be as transparent
    58     as possible. This means that existing network-enabled applications
    59     that you have written should automatically support network proxy
    60     using the following code.
     57    QNetworkAccessManager and QFtp. The proxy support is designed to
     58    be as transparent as possible. This means that existing
     59    network-enabled applications that you have written should
     60    automatically support network proxy using the following code.
    6161
    6262    \snippet doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp 0
     
    8787    The supported authentication methods are no authentication and
    8888    username/password authentication.  Both IPv4 and IPv6 are
    89     supported, but domain name resolution via the SOCKS server is not
    90     supported; i.e. all domain names are resolved locally. There are
    91     several things to remember when using SOCKS5 with QUdpSocket and
    92     QTcpServer:
     89    supported. Domain names are resolved through the SOCKS5 server if
     90    the QNetworkProxy::HostNameLookupCapability is enabled, otherwise
     91    they are resolved locally and the IP address is sent to the
     92    server. There are several things to remember when using SOCKS5
     93    with QUdpSocket and QTcpServer:
    9394
    9495    With QUdpSocket, a call to \l {QUdpSocket::bind()}{bind()} may fail
     
    160161        \o Caching-only HTTP
    161162        \o Implemented using normal HTTP commands, it is useful only
    162            in the context of HTTP requests (see QHttp,
    163            QNetworkAccessManager)
     163           in the context of HTTP requests (see QNetworkAccessManager)
    164164        \o CachingCapability, HostNameLookupCapability
    165165
     
    221221#ifndef QT_NO_NETWORKPROXY
    222222
     223#include "private/qnetworkproxy_p.h"
    223224#include "private/qsocks5socketengine_p.h"
    224225#include "private/qhttpsocketengine_p.h"
     
    324325}
    325326
    326 Q_GLOBAL_STATIC(QGlobalNetworkProxy, globalNetworkProxy);
     327Q_GLOBAL_STATIC(QGlobalNetworkProxy, globalNetworkProxy)
    327328
    328329namespace {
     
    366367    };
    367368
    368     Q_ASSERT(int(type) >= 0 && int(type) <= int(QNetworkProxy::FtpCachingProxy));
     369    if (int(type) < 0 || int(type) > int(QNetworkProxy::FtpCachingProxy))
     370        type = QNetworkProxy::DefaultProxy;
    369371    return QNetworkProxy::Capabilities(defaults[int(type)]);
    370372}
     
    379381    quint16 port;
    380382    QNetworkProxy::ProxyType type;
     383    bool capabilitiesSet;
    381384
    382385    inline QNetworkProxyPrivate(QNetworkProxy::ProxyType t = QNetworkProxy::DefaultProxy,
     
    388391          capabilities(defaultCapabilitiesForType(t)),
    389392          port(p),
    390           type(t)
     393          type(t),
     394          capabilitiesSet(false)
    391395    { }
    392396
     
    491495
    492496    Note that changing the type of a proxy does not change
    493     the set of capabilities this QNetworkProxy object holds.
     497    the set of capabilities this QNetworkProxy object holds if any
     498    capabilities have been set with setCapabilities().
    494499
    495500    \sa type(), setCapabilities()
     
    498503{
    499504    d->type = type;
     505    if (!d->capabilitiesSet)
     506        d->capabilities = defaultCapabilitiesForType(type);
    500507}
    501508
     
    520527{
    521528    d->capabilities = capabilities;
     529    d->capabilitiesSet = true;
    522530}
    523531
     
    11121120    \since 4.5
    11131121
    1114     \ingroup io
     1122    \ingroup network
    11151123    \inmodule QtNetwork
    11161124
     
    11481156QNetworkProxyFactory::~QNetworkProxyFactory()
    11491157{
     1158}
     1159
     1160
     1161/*!
     1162    Enables the use of the platform-specific proxy settings, and only those.
     1163    See systemProxyForQuery() for more information.
     1164
     1165    Internally, this method (when called with \a enable set to true)
     1166    sets an application-wide proxy factory. For this reason, this method
     1167    is mutually exclusive with setApplicationProxyFactory: calling
     1168    setApplicationProxyFactory overrides the use of the system-wide proxy,
     1169    and calling setUseSystemConfiguration overrides any
     1170    application proxy or proxy factory that was previously set.
     1171
     1172    \since 4.6
     1173*/
     1174void QNetworkProxyFactory::setUseSystemConfiguration(bool enable)
     1175{
     1176    if (enable) {
     1177        setApplicationProxyFactory(new QSystemConfigurationProxyFactory);
     1178    } else {
     1179        setApplicationProxyFactory(0);
     1180    }
    11501181}
    11511182
     
    12511282}
    12521283
     1284QT_END_NAMESPACE
     1285
    12531286#endif // QT_NO_NETWORKPROXY
    1254 
    1255 QT_END_NAMESPACE
  • trunk/src/network/kernel/qnetworkproxy.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    172172    virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) = 0;
    173173
     174    static void setUseSystemConfiguration(bool enable);
    174175    static void setApplicationProxyFactory(QNetworkProxyFactory *factory);
    175176    static QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query);
  • trunk/src/network/kernel/qnetworkproxy_generic.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/network/kernel/qnetworkproxy_mac.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    171171            QString url = QCFString::toQString(pacUrl);
    172172
    173             // ### Use PAC somehow
    174             qDebug("Mac system proxy: found PAC script at \"%s\"", qPrintable(url));
     173            // ### TODO: Use PAC somehow
    175174        }
    176175    }
  • trunk/src/network/kernel/qnetworkproxy_win.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4343
    4444#ifndef QT_NO_NETWORKPROXY
    45 
    46 #if defined(UNICODE)
    4745
    4846#include <qmutex.h>
     
    5250
    5351#include <string.h>
    54 #include <windows.h>
     52#include <qt_windows.h>
    5553#include <wininet.h>
    5654
     
    270268        return;
    271269    initialized = true;
    272     if (QSysInfo::windowsVersion() & QSysInfo::WV_DOS_based)
    273         return;                 // no point, this library is only available on 2k, XP and up
    274270
    275271#ifdef Q_OS_WINCE
     
    278274#else
    279275    // load the winhttp.dll library
    280     HINSTANCE winhttpHnd = LoadLibraryW(L"winhttp");
     276    HINSTANCE winhttpHnd = LoadLibrary(L"winhttp");
    281277    if (!winhttpHnd)
    282278        return;                 // failed to load
     
    296292        }
    297293        if (ieProxyConfig.lpszProxy) {
    298             proxyServerList << QString::fromWCharArray(ieProxyConfig.lpszProxy);
     294            // http://msdn.microsoft.com/en-us/library/aa384250%28VS.85%29.aspx speaks only about a "proxy URL",
     295            // not multiple URLs. However we tested this and it can return multiple URLs. So we use splitSpaceSemicolon
     296            // on it.
     297            proxyServerList = splitSpaceSemicolon(QString::fromWCharArray(ieProxyConfig.lpszProxy));
    299298            GlobalFree(ieProxyConfig.lpszProxy);
    300299        }
     
    368367        WINHTTP_PROXY_INFO proxyInfo;
    369368
    370         // try to get the proxy config for the URL, if we have a URL
     369        // try to get the proxy config for the URL
    371370        QUrl url = query.url();
     371        // url could be empty, e.g. from QNetworkProxy::applicationProxy(), that's fine,
     372        // we'll still ask for the proxy.
     373        // But for a file url, we know we don't need one.
     374        if (url.scheme() == QLatin1String("file") || url.scheme() == QLatin1String("qrc"))
     375            return sp->defaultResult;
    372376        if (query.queryType() != QNetworkProxyQuery::UrlRequest) {
    373377            // change the scheme to https, maybe it'll work
     
    399403        return sp->defaultResult;
    400404
    401     return parseServerList(query, sp->proxyServerList);
    402 }
    403 
    404 #else  // !UNICODE
    405 
    406 QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &)
    407 {
    408     return QList<QNetworkProxy>() << QNetworkProxy::NoProxy;
    409 }
     405    QList<QNetworkProxy> result = parseServerList(query, sp->proxyServerList);
     406    // In some cases, this was empty. See SF task 00062670
     407    if (result.isEmpty())
     408        return sp->defaultResult;
     409
     410    return result;
     411}
     412
     413QT_END_NAMESPACE
    410414
    411415#endif
    412 
    413 QT_END_NAMESPACE
    414 
    415 #endif
  • trunk/src/network/kernel/qurlinfo.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    8686
    8787    \ingroup io
    88     \ingroup misc
     88    \ingroup network
    8989
    9090    The information about a URL that can be retrieved includes name(),
     
    216216/*!
    217217    Sets the name of the URL to \a name. The name is the full text,
    218     for example, "http://doc.trolltech.com/qurlinfo.html".
     218    for example, "http://qt.nokia.com/doc/qurlinfo.html".
    219219
    220220    If you call this function for an invalid URL info, this function
     
    727727}
    728728
     729QT_END_NAMESPACE
     730
    729731#endif // QT_NO_URLINFO
    730 
    731 QT_END_NAMESPACE
  • trunk/src/network/kernel/qurlinfo.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
Note: See TracChangeset for help on using the changeset viewer.