Changeset 561 for trunk/src/network/kernel
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 26 edited
- 2 copied
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/kernel.pri
r160 r561 21 21 kernel/qnetworkinterface.cpp 22 22 23 unix:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp 23 symbian: SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_symbian.cpp 24 unix:!symbian:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp 24 25 win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp 25 26 os2:SOURCES += kernel/qhostinfo_os2.cpp kernel/qnetworkinterface_os2.cpp 26 27 27 mac:LIBS += -framework SystemConfiguration28 mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation 28 29 mac:SOURCES += kernel/qnetworkproxy_mac.cpp 29 30 else:win32:SOURCES += kernel/qnetworkproxy_win.cpp -
trunk/src/network/kernel/qauthenticator.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 47 47 #include <qcryptographichash.h> 48 48 #include <qhttp.h> 49 #include <qiodevice.h> 49 50 #include <qdatastream.h> 50 51 #include <qendian.h> … … 64 65 65 66 \reentrant 66 \ingroup io67 \ingroup network 67 68 \inmodule QtNetwork 68 69 69 70 The QAuthenticator class is usually used in the 70 \l{Q Http::}{authenticationRequired()} and71 \l{Q Http::}{proxyAuthenticationRequired()} signals of QHttpand71 \l{QNetworkAccessManager::}{authenticationRequired()} and 72 \l{QNetworkAccessManager::}{proxyAuthenticationRequired()} signals of QNetworkAccessManager and 72 73 QAbstractSocket. The class provides a way to pass back the required 73 74 authentication information to the socket when accessing services that 74 75 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. 75 85 76 86 \sa QSslSocket … … 503 513 if (!opaque.isEmpty()) 504 514 credentials += "opaque=\"" + opaque + "\", "; 505 credentials += "response=\"" + response + "\"";515 credentials += "response=\"" + response + '\"'; 506 516 if (!options.value("algorithm").isEmpty()) 507 517 credentials += ", algorithm=" + options.value("algorithm"); … … 509 519 credentials += ", qop=" + qop + ", "; 510 520 credentials += "nc=" + nonceCountString + ", "; 511 credentials += "cnonce=\"" + cnonce + "\"";521 credentials += "cnonce=\"" + cnonce + '\"'; 512 522 } 513 523 -
trunk/src/network/kernel/qauthenticator.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/network/kernel/qauthenticator_p.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/network/kernel/qhostaddress.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 420 420 \class QHostAddress 421 421 \brief The QHostAddress class provides an IP address. 422 \ingroup io422 \ingroup network 423 423 \inmodule QtNetwork 424 424 … … 432 432 using isIPv4Address() or isIPv6Address(), and retrieved with 433 433 toIPv4Address(), toIPv6Address(), or toString(). 434 435 \note Please note that QHostAddress does not do DNS lookups. 436 QHostInfo is needed for that. 434 437 435 438 The class also supports common predefined addresses: \l Null, \l … … 524 527 */ 525 528 QHostAddress::QHostAddress(const QHostAddress &address) 526 : d(new QHostAddressPrivate(*address.d ))529 : d(new QHostAddressPrivate(*address.d.data())) 527 530 { 528 531 } … … 560 563 QHostAddress::~QHostAddress() 561 564 { 562 delete d;563 565 } 564 566 … … 569 571 QHostAddress &QHostAddress::operator=(const QHostAddress &address) 570 572 { 571 *d = *address.d;573 *d.data() = *address.d.data(); 572 574 return *this; 573 575 } … … 1079 1081 QDebug operator<<(QDebug d, const QHostAddress &address) 1080 1082 { 1081 d.maybeSpace() << "QHostAddress(" << address.toString() << ")";1083 d.maybeSpace() << "QHostAddress(" << address.toString() << ')'; 1082 1084 return d.space(); 1083 1085 } -
trunk/src/network/kernel/qhostaddress.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 45 45 #include <QtCore/qpair.h> 46 46 #include <QtCore/qstring.h> 47 #include <QtCore/qscopedpointer.h> 47 48 #include <QtNetwork/qabstractsocket.h> 48 49 … … 131 132 132 133 protected: 133 Q HostAddressPrivate *d;134 QScopedPointer<QHostAddressPrivate> d; 134 135 }; 135 136 -
trunk/src/network/kernel/qhostaddress_p.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/network/kernel/qhostinfo.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 43 43 #include "qhostinfo_p.h" 44 44 45 #include "QtCore/qscopedpointer.h" 45 46 #include <qabstracteventdispatcher.h> 46 47 #include <private/qunicodetables_p.h> … … 60 61 QT_BEGIN_NAMESPACE 61 62 62 Q_GLOBAL_STATIC(QHostInfoAgent, theAgent) 63 void QHostInfoAgent::staticCleanup() 64 { 65 theAgent()->cleanup(); 66 } 63 #ifndef QT_NO_THREAD 64 Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager) 65 #endif 67 66 68 67 //#define QHOSTINFO_DEBUG … … 74 73 \reentrant 75 74 \inmodule QtNetwork 76 \ingroup io75 \ingroup network 77 76 78 77 QHostInfo uses the lookup mechanisms provided by the operating … … 142 141 143 142 \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(). 144 146 145 147 \sa abortHostLookup(), addresses(), error(), fromName() … … 159 161 qRegisterMetaType<QHostInfo>("QHostInfo"); 160 162 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); 163 187 #endif 164 188 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 */ 197 void QHostInfo::abortHostLookup(int id) 198 { 199 #ifndef QT_NO_THREAD 200 theHostInfoLookupManager()->abortLookup(id); 190 201 #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); 195 204 #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);208 205 } 209 206 … … 227 224 #endif 228 225 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); 300 227 } 301 228 … … 328 255 */ 329 256 QHostInfo::QHostInfo(const QHostInfo &other) 330 : d(new QHostInfoPrivate(*other.d ))257 : d(new QHostInfoPrivate(*other.d.data())) 331 258 { 332 259 } … … 338 265 QHostInfo &QHostInfo::operator=(const QHostInfo &other) 339 266 { 340 *d = *other.d;267 *d.data() = *other.d.data(); 341 268 return *this; 342 269 } … … 347 274 QHostInfo::~QHostInfo() 348 275 { 349 delete d;350 276 } 351 277 … … 477 403 */ 478 404 405 #ifndef QT_NO_THREAD 406 QHostInfoRunnable::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 412 void 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 445 QHostInfoLookupManager::QHostInfoLookupManager() : mutex(QMutex::Recursive), wasDeleted(false) 446 { 447 moveToThread(QCoreApplicationPrivate::mainThread()); 448 threadPool.setMaxThreadCount(5); // do 5 DNS lookups in parallel 449 } 450 451 QHostInfoLookupManager::~QHostInfoLookupManager() 452 { 453 wasDeleted = true; 454 } 455 456 void 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 530 void 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 541 void 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 552 bool 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 562 void 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 479 575 QT_END_NAMESPACE -
trunk/src/network/kernel/qhostinfo.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 44 44 45 45 #include <QtCore/qlist.h> 46 #include <QtCore/qscopedpointer.h> 46 47 #include <QtNetwork/qhostaddress.h> 47 48 … … 92 93 93 94 private: 94 Q HostInfoPrivate *d;95 QScopedPointer<QHostInfoPrivate> d; 95 96 }; 96 97 -
trunk/src/network/kernel/qhostinfo_p.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 48 48 // 49 49 // This file is not part of the Qt API. It exists for the convenience 50 // of the Q Libraryclass. This header file may change from50 // of the QHostInfo class. This header file may change from 51 51 // version to version without notice, or even be removed. 52 52 // … … 62 62 #include "QtCore/qpointer.h" 63 63 64 #if !definedQT_NO_THREAD64 #ifndef QT_NO_THREAD 65 65 #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" 69 71 #endif 70 72 71 73 QT_BEGIN_NAMESPACE 72 73 static const int QHOSTINFO_THREAD_WAIT = 250; // ms74 74 75 75 class QHostInfoResult : public QObject … … 80 80 { 81 81 emit resultsReady(info); 82 if (autoDelete)83 delete this;84 82 } 85 83 86 84 Q_SIGNALS: 87 void resultsReady(const QHostInfo &info); 88 89 public: 90 int lookupId; 91 bool autoDelete; 85 void resultsReady(const QHostInfo info); 92 86 }; 93 87 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() 89 class QHostInfoAgent : public QObject 106 90 { 107 91 Q_OBJECT 108 92 public: 109 inline QHostInfoAgent()110 {111 // There is a chance that there will be two instances of112 // QHostInfoAgent if two threads try to get Q_GLOBAL_STATIC113 // object at the same time. The second object will be deleted114 // immediately before anyone uses it, but we need to be115 // 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();127 93 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_THREAD164 if (!wait(QHOSTINFO_THREAD_WAIT))165 terminate();166 wait();167 #endif168 }169 170 private:171 QList<QHostInfoQuery *> queries;172 QMutex mutex;173 QWaitCondition cond;174 volatile bool quit;175 int pendingQueryId;176 94 }; 177 95 … … 181 99 inline QHostInfoPrivate() 182 100 : err(QHostInfo::NoError), 183 errorStr(QLatin1String(QT_TRANSLATE_NOOP("QHostInfo", "Unknown error"))) 101 errorStr(QLatin1String(QT_TRANSLATE_NOOP("QHostInfo", "Unknown error"))), 102 lookupId(0) 184 103 { 185 104 } … … 192 111 }; 193 112 113 #ifndef QT_NO_THREAD 114 // the following classes are used for the (normal) case: We use multiple threads to lookup DNS 115 116 class QHostInfoRunnable : public QRunnable 117 { 118 public: 119 QHostInfoRunnable (QString hn, int i); 120 void run(); 121 122 QString toBeLookedUp; 123 int id; 124 QHostInfoResult resultEmitter; 125 }; 126 127 class QHostInfoLookupManager : public QObject 128 { 129 Q_OBJECT 130 public: 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 144 protected: 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 194 159 QT_END_NAMESPACE 195 160 -
trunk/src/network/kernel/qhostinfo_unix.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 41 41 42 42 //#define QHOSTINFO_DEBUG 43 44 static const int RESOLVER_TIMEOUT = 2000;45 43 46 44 #include "qplatformdefs.h" … … 53 51 #include <qfile.h> 54 52 #include <private/qmutexpool_p.h> 55 56 extern "C" { 53 #include <private/qnet_unix_p.h> 54 57 55 #include <sys/types.h> 58 56 #include <netdb.h> 59 57 #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 62 63 63 64 #if defined (QT_NO_GETADDRINFO) … … 122 123 { 123 124 QHostInfo results; 124 results.setHostName(hostName);125 125 126 126 #if defined(QHOSTINFO_DEBUG) … … 149 149 // Reverse lookup 150 150 // 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) 152 152 sockaddr_in sa4; 153 153 #ifndef QT_NO_IPV6 … … 174 174 175 175 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)); 182 178 #else 183 in_addr_t inetaddr = inet_addr(hostName.toLatin1().constData());179 in_addr_t inetaddr = qt_safe_inet_addr(hostName.toLatin1().constData()); 184 180 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; 192 198 } 193 199 … … 203 209 #endif 204 210 205 int result = getaddrinfo( hostName.toLatin1().constData(), 0, &hints, &res);211 int result = getaddrinfo(aceHostname.constData(), 0, &hints, &res); 206 212 # ifdef Q_ADDRCONFIG 207 213 if (result == EAI_BADFLAGS) { 208 214 // if the lookup failed with AI_ADDRCONFIG set, try again without it 209 215 hints.ai_flags = 0; 210 result = getaddrinfo( hostName.toLatin1().constData(), 0, &hints, &res);216 result = getaddrinfo(aceHostname.constData(), 0, &hints, &res); 211 217 } 212 218 # endif … … 262 268 // must be provided. 263 269 QMutexLocker locker(::getHostByNameMutex()); 264 hostent *result = gethostbyname( hostName.toLatin1().constData());270 hostent *result = gethostbyname(aceHostname.constData()); 265 271 if (result) { 266 272 if (result->h_addrtype == AF_INET) { … … 277 283 results.setErrorString(tr("Unknown address type")); 278 284 } 285 #if !defined(Q_OS_VXWORKS) 279 286 } else if (h_errno == HOST_NOT_FOUND || h_errno == NO_DATA 280 287 || h_errno == NO_ADDRESS) { 281 288 results.setError(QHostInfo::HostNotFound); 282 289 results.setErrorString(tr("Host not found")); 290 #endif 283 291 } else { 284 292 results.setError(QHostInfo::UnknownError); … … 317 325 QString QHostInfo::localDomainName() 318 326 { 327 #if !defined(Q_OS_VXWORKS) 319 328 resolveLibrary(); 320 329 if (local_res_ninit) { 321 330 // using thread-safe version 322 331 res_state_ptr state = res_state_ptr(qMalloc(sizeof(*state))); 332 Q_CHECK_PTR(state); 323 333 memset(state, 0, sizeof(*state)); 324 334 local_res_ninit(state); … … 346 356 return domainName; 347 357 } 348 358 #endif 349 359 // nothing worked, try doing it by ourselves: 350 360 QFile resolvconf; -
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 (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 53 53 #include <qtimer.h> 54 54 #include <qmutex.h> 55 #include <qurl.h> 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(aceHostname.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(aceHostname.constData()); 237 224 if (ent) { 238 225 char **p; -
trunk/src/network/kernel/qnetworkinterface.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 129 129 if (i) 130 130 result += QLatin1Char(':'); 131 131 132 132 char buf[3]; 133 133 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400 … … 149 149 \since 4.2 150 150 \reentrant 151 \ingroup io151 \ingroup network 152 152 153 153 Each network interface can contain zero or more IP addresses, which … … 171 171 */ 172 172 QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other) 173 : d(new QNetworkAddressEntryPrivate(*other.d ))173 : d(new QNetworkAddressEntryPrivate(*other.d.data())) 174 174 { 175 175 } … … 180 180 QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry &other) 181 181 { 182 *d = *other.d;182 *d.data() = *other.d.data(); 183 183 return *this; 184 184 } … … 189 189 QNetworkAddressEntry::~QNetworkAddressEntry() 190 190 { 191 delete d;192 191 } 193 192 … … 334 333 \since 4.2 335 334 \reentrant 336 \ingroup io335 \ingroup network 337 336 338 337 QNetworkInterface represents one network interface attached to the … … 398 397 399 398 /*! 400 Creates a copy of the theQNetworkInterface object contained in \a399 Creates a copy of the QNetworkInterface object contained in \a 401 400 other. 402 401 */ … … 595 594 if (!entry.broadcast().isNull()) 596 595 debug.nospace() << ", broadcast = " << entry.broadcast(); 597 debug.nospace() << ")";596 debug.nospace() << ')'; 598 597 return debug.space(); 599 598 } … … 605 604 << ", flags = "; 606 605 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 607 610 debug.nospace() << ", entries = " << networkInterface.addressEntries() 608 611 << ")\n"; 612 #endif 609 613 return debug.space(); 610 614 } -
trunk/src/network/kernel/qnetworkinterface.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 44 44 45 45 #include <QtCore/qshareddata.h> 46 #include <QtCore/qscopedpointer.h> 46 47 #include <QtNetwork/qhostaddress.h> 47 48 … … 80 81 81 82 private: 82 Q NetworkAddressEntryPrivate *d;83 QScopedPointer<QNetworkAddressEntryPrivate> d; 83 84 }; 84 85 -
trunk/src/network/kernel/qnetworkinterface_p.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/network/kernel/qnetworkinterface_unix.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 44 44 #include "qnetworkinterface_p.h" 45 45 #include "qalgorithms.h" 46 #include "private/qnet_unix_p.h" 46 47 47 48 #ifndef QT_NO_NETWORKINTERFACE … … 124 125 125 126 // get the interface list 126 if ( ::ioctl(socket, SIOCGIFCONF, &interfaceList) >= 0) {127 if (qt_safe_ioctl(socket, SIOCGIFCONF, &interfaceList) >= 0) { 127 128 if (int(interfaceList.ifc_len + sizeof(ifreq) + 64) < storageBuffer.size()) { 128 129 // if the buffer was big enough, break … … 199 200 // Get the canonical name 200 201 QByteArray oldName = req.ifr_name; 201 if ( ::ioctl(socket, SIOCGIFNAME, &req) >= 0) {202 if (qt_safe_ioctl(socket, SIOCGIFNAME, &req) >= 0) { 202 203 iface->name = QString::fromLatin1(req.ifr_name); 203 204 … … 212 213 213 214 // Get interface flags 214 if ( ::ioctl(socket, SIOCGIFFLAGS, &req) >= 0) {215 if (qt_safe_ioctl(socket, SIOCGIFFLAGS, &req) >= 0) { 215 216 iface->flags = convertFlags(req.ifr_flags); 216 217 } … … 218 219 #ifdef SIOCGIFHWADDR 219 220 // Get the HW address 220 if ( ::ioctl(socket, SIOCGIFHWADDR, &req) >= 0) {221 if (qt_safe_ioctl(socket, SIOCGIFHWADDR, &req) >= 0) { 221 222 uchar *addr = (uchar *)&req.ifr_addr; 222 223 iface->hardwareAddress = iface->makeHwAddress(6, addr); … … 233 234 234 235 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) 236 237 return interfaces; // error 237 238 … … 248 249 QNetworkAddressEntry entry; 249 250 if (iface->flags & QNetworkInterface::CanBroadcast) { 250 if ( ::ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) {251 if (qt_safe_ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) { 251 252 sockaddr *sa = &req.ifr_addr; 252 253 if (sa->sa_family == AF_INET) … … 256 257 257 258 // Get the interface netmask 258 if ( ::ioctl(socket, SIOCGIFNETMASK, &req) >= 0) {259 if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) { 259 260 sockaddr *sa = &req.ifr_addr; 260 261 entry.setNetmask(addressFromSockaddr(sa)); … … 262 263 263 264 // Get the address of the interface 264 if ( ::ioctl(socket, SIOCGIFADDR, &req) >= 0) {265 if (qt_safe_ioctl(socket, SIOCGIFADDR, &req) >= 0) { 265 266 sockaddr *sa = &req.ifr_addr; 266 267 entry.setIp(addressFromSockaddr(sa)); … … 393 394 394 395 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) 396 397 return interfaces; // error 397 398 -
trunk/src/network/kernel/qnetworkinterface_win.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 67 67 done = true; 68 68 69 HINSTANCE iphlpapiHnd; 70 QT_WA({ 71 iphlpapiHnd = LoadLibraryW(L"iphlpapi"); 72 }, { 73 iphlpapiHnd = LoadLibraryA("iphlpapi"); 74 }); 69 HINSTANCE iphlpapiHnd = LoadLibrary(L"iphlpapi"); 75 70 if (iphlpapiHnd == NULL) 76 return; // failed to load, probably Windows 9571 return; 77 72 78 73 #if defined(Q_OS_WINCE) 79 ptrGetAdaptersInfo = (PtrGetAdaptersInfo)GetProcAddress W(iphlpapiHnd, L"GetAdaptersInfo");80 ptrGetAdaptersAddresses = (PtrGetAdaptersAddresses)GetProcAddress W(iphlpapiHnd, L"GetAdaptersAddresses");81 ptrGetNetworkParams = (PtrGetNetworkParams)GetProcAddress W(iphlpapiHnd, L"GetNetworkParams");74 ptrGetAdaptersInfo = (PtrGetAdaptersInfo)GetProcAddress(iphlpapiHnd, L"GetAdaptersInfo"); 75 ptrGetAdaptersAddresses = (PtrGetAdaptersAddresses)GetProcAddress(iphlpapiHnd, L"GetAdaptersAddresses"); 76 ptrGetNetworkParams = (PtrGetNetworkParams)GetProcAddress(iphlpapiHnd, L"GetNetworkParams"); 82 77 #else 83 78 ptrGetAdaptersInfo = (PtrGetAdaptersInfo)GetProcAddress(iphlpapiHnd, "GetAdaptersInfo"); … … 116 111 // need more memory 117 112 pAdapter = (IP_ADAPTER_INFO *)qMalloc(bufSize); 113 if (!pAdapter) 114 return ipv4netmasks; 118 115 // try again 119 116 if (ptrGetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) { … … 157 154 // need more memory 158 155 pAdapter = (IP_ADAPTER_ADDRESSES *)qMalloc(bufSize); 159 156 if (!pAdapter) 157 return interfaces; 160 158 // try again 161 159 if (ptrGetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAdapter, &bufSize) != ERROR_SUCCESS) { … … 237 235 // need more memory 238 236 pAdapter = (IP_ADAPTER_INFO *)qMalloc(bufSize); 239 237 if (!pAdapter) 238 return interfaces; 240 239 // try again 241 240 if (ptrGetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) { … … 307 306 if (ptrGetNetworkParams(pinfo, &bufSize) == ERROR_BUFFER_OVERFLOW) { 308 307 pinfo = (FIXED_INFO *)qMalloc(bufSize); 309 308 if (!pinfo) 309 return QString(); 310 310 // try again 311 311 if (ptrGetNetworkParams(pinfo, &bufSize) != ERROR_SUCCESS) { -
trunk/src/network/kernel/qnetworkinterface_win_p.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 55 55 56 56 #include <winsock2.h> 57 #include < windows.h>57 #include <qt_windows.h> 58 58 #include <time.h> 59 59 -
trunk/src/network/kernel/qnetworkproxy.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 49 49 50 50 \reentrant 51 \ingroup io51 \ingroup network 52 52 \inmodule QtNetwork 53 53 … … 55 55 proxy support to the Qt network classes. The currently supported 56 56 classes are QAbstractSocket, QTcpSocket, QUdpSocket, QTcpServer, 57 Q Http and QFtp. The proxy support is designed to be as transparent58 as possible. This means that existing network-enabled applications59 that you have written should automatically support network proxy60 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. 61 61 62 62 \snippet doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp 0 … … 87 87 The supported authentication methods are no authentication and 88 88 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: 93 94 94 95 With QUdpSocket, a call to \l {QUdpSocket::bind()}{bind()} may fail … … 160 161 \o Caching-only HTTP 161 162 \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) 164 164 \o CachingCapability, HostNameLookupCapability 165 165 … … 221 221 #ifndef QT_NO_NETWORKPROXY 222 222 223 #include "private/qnetworkproxy_p.h" 223 224 #include "private/qsocks5socketengine_p.h" 224 225 #include "private/qhttpsocketengine_p.h" … … 324 325 } 325 326 326 Q_GLOBAL_STATIC(QGlobalNetworkProxy, globalNetworkProxy) ;327 Q_GLOBAL_STATIC(QGlobalNetworkProxy, globalNetworkProxy) 327 328 328 329 namespace { … … 366 367 }; 367 368 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; 369 371 return QNetworkProxy::Capabilities(defaults[int(type)]); 370 372 } … … 379 381 quint16 port; 380 382 QNetworkProxy::ProxyType type; 383 bool capabilitiesSet; 381 384 382 385 inline QNetworkProxyPrivate(QNetworkProxy::ProxyType t = QNetworkProxy::DefaultProxy, … … 388 391 capabilities(defaultCapabilitiesForType(t)), 389 392 port(p), 390 type(t) 393 type(t), 394 capabilitiesSet(false) 391 395 { } 392 396 … … 491 495 492 496 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(). 494 499 495 500 \sa type(), setCapabilities() … … 498 503 { 499 504 d->type = type; 505 if (!d->capabilitiesSet) 506 d->capabilities = defaultCapabilitiesForType(type); 500 507 } 501 508 … … 520 527 { 521 528 d->capabilities = capabilities; 529 d->capabilitiesSet = true; 522 530 } 523 531 … … 1112 1120 \since 4.5 1113 1121 1114 \ingroup io1122 \ingroup network 1115 1123 \inmodule QtNetwork 1116 1124 … … 1148 1156 QNetworkProxyFactory::~QNetworkProxyFactory() 1149 1157 { 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 */ 1174 void QNetworkProxyFactory::setUseSystemConfiguration(bool enable) 1175 { 1176 if (enable) { 1177 setApplicationProxyFactory(new QSystemConfigurationProxyFactory); 1178 } else { 1179 setApplicationProxyFactory(0); 1180 } 1150 1181 } 1151 1182 … … 1251 1282 } 1252 1283 1284 QT_END_NAMESPACE 1285 1253 1286 #endif // QT_NO_NETWORKPROXY 1254 1255 QT_END_NAMESPACE -
trunk/src/network/kernel/qnetworkproxy.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 172 172 virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) = 0; 173 173 174 static void setUseSystemConfiguration(bool enable); 174 175 static void setApplicationProxyFactory(QNetworkProxyFactory *factory); 175 176 static QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query); -
trunk/src/network/kernel/qnetworkproxy_generic.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/network/kernel/qnetworkproxy_mac.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 171 171 QString url = QCFString::toQString(pacUrl); 172 172 173 // ### Use PAC somehow 174 qDebug("Mac system proxy: found PAC script at \"%s\"", qPrintable(url)); 173 // ### TODO: Use PAC somehow 175 174 } 176 175 } -
trunk/src/network/kernel/qnetworkproxy_win.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 43 43 44 44 #ifndef QT_NO_NETWORKPROXY 45 46 #if defined(UNICODE)47 45 48 46 #include <qmutex.h> … … 52 50 53 51 #include <string.h> 54 #include < windows.h>52 #include <qt_windows.h> 55 53 #include <wininet.h> 56 54 … … 270 268 return; 271 269 initialized = true; 272 if (QSysInfo::windowsVersion() & QSysInfo::WV_DOS_based)273 return; // no point, this library is only available on 2k, XP and up274 270 275 271 #ifdef Q_OS_WINCE … … 278 274 #else 279 275 // load the winhttp.dll library 280 HINSTANCE winhttpHnd = LoadLibrary W(L"winhttp");276 HINSTANCE winhttpHnd = LoadLibrary(L"winhttp"); 281 277 if (!winhttpHnd) 282 278 return; // failed to load … … 296 292 } 297 293 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)); 299 298 GlobalFree(ieProxyConfig.lpszProxy); 300 299 } … … 368 367 WINHTTP_PROXY_INFO proxyInfo; 369 368 370 // try to get the proxy config for the URL , if we have a URL369 // try to get the proxy config for the URL 371 370 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; 372 376 if (query.queryType() != QNetworkProxyQuery::UrlRequest) { 373 377 // change the scheme to https, maybe it'll work … … 399 403 return sp->defaultResult; 400 404 401 returnparseServerList(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 413 QT_END_NAMESPACE 410 414 411 415 #endif 412 413 QT_END_NAMESPACE414 415 #endif -
trunk/src/network/kernel/qurlinfo.cpp
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 86 86 87 87 \ingroup io 88 \ingroup misc88 \ingroup network 89 89 90 90 The information about a URL that can be retrieved includes name(), … … 216 216 /*! 217 217 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". 219 219 220 220 If you call this function for an invalid URL info, this function … … 727 727 } 728 728 729 QT_END_NAMESPACE 730 729 731 #endif // QT_NO_URLINFO 730 731 QT_END_NAMESPACE -
trunk/src/network/kernel/qurlinfo.h
r2 r561 2 2 ** 3 3 ** 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) 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 have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 **
Note:
See TracChangeset
for help on using the changeset viewer.