diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2011-06-24 09:12:15 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-06-24 09:12:15 (GMT) |
commit | 11cc0f661911628fb51c92d30c684eb1cea01145 (patch) | |
tree | 3f89e82669b12ea49e0586d3ff14c0d01594301e /src/network | |
parent | 9d5b0e31f287ce502eaf9a2c0876d900424c80ab (diff) | |
parent | 164728f711136356a6c3482f762321b01c9d82dd (diff) | |
download | Qt-11cc0f661911628fb51c92d30c684eb1cea01145.zip Qt-11cc0f661911628fb51c92d30c684eb1cea01145.tar.gz Qt-11cc0f661911628fb51c92d30c684eb1cea01145.tar.bz2 |
Merge remote-tracking branch 'origin/4.8'
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qhttpmultipart.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 4 | ||||
-rw-r--r-- | src/network/access/qnetworkcookiejar.cpp | 27 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager.cpp | 2 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.cpp | 15 | ||||
-rw-r--r-- | src/network/kernel/kernel.pri | 2 | ||||
-rw-r--r-- | src/network/socket/qhttpsocketengine.cpp | 2 | ||||
-rw-r--r-- | src/network/socket/qsocks5socketengine.cpp | 2 | ||||
-rw-r--r-- | src/network/socket/qsymbiansocketengine.cpp | 33 | ||||
-rw-r--r-- | src/network/socket/qsymbiansocketengine_p.h | 5 | ||||
-rw-r--r-- | src/network/ssl/qsslsocket.cpp | 4 | ||||
-rw-r--r-- | src/network/ssl/qsslsocket_openssl.cpp | 10 | ||||
-rw-r--r-- | src/network/ssl/qsslsocket_p.h | 4 |
13 files changed, 67 insertions, 45 deletions
diff --git a/src/network/access/qhttpmultipart.cpp b/src/network/access/qhttpmultipart.cpp index 80ec723..7545658 100644 --- a/src/network/access/qhttpmultipart.cpp +++ b/src/network/access/qhttpmultipart.cpp @@ -256,7 +256,7 @@ void QHttpPart::setBodyDevice(QIODevice *device) /*! Constructs a QHttpMultiPart with content type MixedType and sets - parent as the parent object. + \a parent as the parent object. \sa QHttpMultiPart::ContentType */ diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index f64fcb6..8fc8eb7 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -301,6 +301,10 @@ static void ensureInitialized() again, without emitting the authenticationRequired() signal. If it rejects the credentials, this signal will be emitted again. + \note It is not possible to use a QueuedConnection to connect to + this signal, as the connection will fail if the authenticator has + not been filled in with new information when the signal returns. + \sa proxyAuthenticationRequired() */ diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp index a2fa689..1a5f73b 100644 --- a/src/network/access/qnetworkcookiejar.cpp +++ b/src/network/access/qnetworkcookiejar.cpp @@ -220,20 +220,33 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieLis continue; // not accepted } - QList<QNetworkCookie>::Iterator it = d->allCookies.begin(), - end = d->allCookies.end(); - for ( ; it != end; ++it) + for (int i = 0; i < d->allCookies.size(); ++i) { // does this cookie already exist? - if (cookie.name() == it->name() && - cookie.domain() == it->domain() && - cookie.path() == it->path()) { + const QNetworkCookie ¤t = d->allCookies.at(i); + if (cookie.name() == current.name() && + cookie.domain() == current.domain() && + cookie.path() == current.path()) { // found a match - d->allCookies.erase(it); + d->allCookies.removeAt(i); break; } + } // did not find a match if (!isDeletion) { + int countForDomain = 0; + for (int i = d->allCookies.size() - 1; i >= 0; --i) { + // Start from the end and delete the oldest cookies to keep a maximum count of 50. + const QNetworkCookie ¤t = d->allCookies.at(i); + if (isParentDomain(cookie.domain(), current.domain()) + || isParentDomain(current.domain(), cookie.domain())) { + if (countForDomain >= 49) + d->allCookies.removeAt(i); + else + ++countForDomain; + } + } + d->allCookies += cookie; ++added; } diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index 2791eed..666aba7 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -128,7 +128,7 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate() \fn void QNetworkConfigurationManager::configurationRemoved(const QNetworkConfiguration &config) This signal is emitted when a configuration is about to be removed from the system. The removed - \a configuration is invalid but retains name and identifier. + configuration, specified by \a config, is invalid but retains name and identifier. */ /*! diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 54cd898..d468bc4 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -385,6 +385,8 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); + + QMetaObject::invokeMethod(engine, "initialize"); } } @@ -408,19 +410,8 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() startPolling(); } - if (firstUpdate) { + if (firstUpdate) firstUpdate = false; - QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex - Qt::ConnectionType connectionType; - if (QCoreApplicationPrivate::mainThread() == QThread::currentThread()) - connectionType = Qt::DirectConnection; - else - connectionType = Qt::BlockingQueuedConnection; - locker.unlock(); - foreach (QBearerEngine* engine, enginesToInitialize) { - QMetaObject::invokeMethod(engine, "initialize", connectionType); - } - } } void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate() diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index bb98305..e5d33bb 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -26,7 +26,7 @@ win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp integrity:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation -mac:SOURCES += kernel/qnetworkproxy_mac.cpp +mac:contains(QT_CONFIG, coreservices) SOURCES += kernel/qnetworkproxy_mac.cpp else:win32:SOURCES += kernel/qnetworkproxy_win.cpp else:symbian:SOURCES += kernel/qnetworkproxy_symbian.cpp else:SOURCES += kernel/qnetworkproxy_generic.cpp diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 5f5db17..5c672ec 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -149,6 +149,8 @@ bool QHttpSocketEngine::connectInternal() // Handshake isn't done. If unconnected, start connecting. if (d->state == None && d->socket->state() == QAbstractSocket::UnconnectedState) { setState(QAbstractSocket::ConnectingState); + //limit buffer in internal socket, data is buffered in the external socket under application control + d->socket->setReadBufferSize(65536); d->socket->connectToHost(d->proxy.hostName(), d->proxy.port()); } diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 575c0bc..ab75798 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1126,6 +1126,8 @@ bool QSocks5SocketEngine::connectInternal() if (d->socks5State == QSocks5SocketEnginePrivate::Uninitialized && d->socketState != QAbstractSocket::ConnectingState) { setState(QAbstractSocket::ConnectingState); + //limit buffer in internal socket, data is buffered in the external socket under application control + d->data->controlSocket->setReadBufferSize(65536); d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); return false; } diff --git a/src/network/socket/qsymbiansocketengine.cpp b/src/network/socket/qsymbiansocketengine.cpp index 15635ff..edd5d6e 100644 --- a/src/network/socket/qsymbiansocketengine.cpp +++ b/src/network/socket/qsymbiansocketengine.cpp @@ -196,8 +196,14 @@ bool QSymbianSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType so #ifdef QNATIVESOCKETENGINE_DEBUG qDebug() << "QSymbianSocketEnginePrivate::createNewSocket - _q_networksession was set" << err; #endif - } else - err = nativeSocket.Open(socketServer, family, type, protocol); //TODO: FIXME - deprecated API, make sure we always have a connection instead + } else { +#ifdef QNATIVESOCKETENGINE_DEBUG + qDebug() << "QSymbianSocketEnginePrivate::createNewSocket - _q_networksession was not set, using implicit connection"; +#endif + // using implicit connection allows localhost connections without starting any RConnection, see QTBUG-16155 and QTBUG-16843 + // when a remote address is used, socket server will start the system default connection if there is no route. + err = nativeSocket.Open(socketServer, family, type, protocol); + } if (err != KErrNone) { switch (err) { @@ -564,12 +570,12 @@ bool QSymbianSocketEngine::connectToHostByName(const QString &name, quint16 port If there's a connection activity on the socket, process it. Then notify our parent if there really was activity. */ -void QSymbianSocketEngine::connectionNotification() +void QSymbianSocketEngine::connectionComplete() { - // FIXME check if we really need to do it like that in Symbian Q_D(QSymbianSocketEngine); Q_ASSERT(state() == QAbstractSocket::ConnectingState); + // as it was a non blocking connect, call again to find the result. connectToHost(d->peerAddress, d->peerPort); if (state() != QAbstractSocket::ConnectingState) { // we changed states @@ -906,7 +912,6 @@ qint64 QSymbianSocketEngine::writeDatagram(const char *data, qint64 len, return sentBytes(); } -// FIXME check where the native socket engine called that.. bool QSymbianSocketEnginePrivate::fetchConnectionParameters() { localPort = 0; @@ -990,9 +995,15 @@ void QSymbianSocketEngine::close() d->asyncSelect = 0; } - //TODO: call nativeSocket.Shutdown(EImmediate) in some cases? + //RSocket::Shutdown(EImmediate) performs a fast disconnect. For TCP, + //this would mean sending RST rather than FIN so we don't do that. + //Qt's disconnectFromHost() API doesn't expose this choice. + //RSocket::Close will internally do a normal shutdown of the socket. if (d->socketType == QAbstractSocket::UdpSocket) { - //TODO: Close hangs without this, but only for UDP - why? + //RSocket::Close has been observed to block for a long time with + //UDP sockets. Doing an immediate shutdown first works around this + //problem. Since UDP is connectionless, there should be no difference + //at the network interface. TRequestStatus stat; d->nativeSocket.Shutdown(RSocket::EImmediate, stat); User::WaitForRequest(stat); @@ -1189,7 +1200,6 @@ int QSymbianSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool #endif } if (err) { - //TODO: avoidable cast? //set the error here, because read won't always return the same error again as select. const_cast<QSymbianSocketEnginePrivate*>(this)->setError(err); //restart asynchronous notifier (only one IOCTL allowed at a time) @@ -1265,7 +1275,7 @@ bool QSymbianSocketEnginePrivate::multicastGroupMembershipHelper(const QHostAddr QNetworkInterface QSymbianSocketEngine::multicastInterface() const { - //TODO + //### symbian 3 has no API equivalent to this const Q_D(QSymbianSocketEngine); Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::multicastInterface(), QNetworkInterface()); Q_CHECK_TYPE(QSymbianSocketEngine::multicastInterface(), QAbstractSocket::UdpSocket, QNetworkInterface()); @@ -1274,7 +1284,8 @@ QNetworkInterface QSymbianSocketEngine::multicastInterface() const bool QSymbianSocketEngine::setMulticastInterface(const QNetworkInterface &iface) { - //TODO - this is possibly a unix'ism as the RConnection on which the socket was created is probably controlling this + //### symbian 3 has no API equivalent to this + //this is possibly a unix'ism as the RConnection on which the socket was created is probably controlling this Q_D(QSymbianSocketEngine); Q_CHECK_VALID_SOCKETLAYER(QSymbianSocketEngine::setMulticastInterface(), false); Q_CHECK_TYPE(QSymbianSocketEngine::setMulticastInterface(), QAbstractSocket::UdpSocket, false); @@ -1711,7 +1722,7 @@ void QAsyncSelect::run() if (engine && engine->isWriteNotificationEnabled() && ((m_selectBuf() & KSockSelectWrite) || iStatus != KErrNone)) { if (engine->state() == QAbstractSocket::ConnectingState) - engine->connectionNotification(); + engine->connectionComplete(); else engine->writeNotification(); } diff --git a/src/network/socket/qsymbiansocketengine_p.h b/src/network/socket/qsymbiansocketengine_p.h index 81156fc..3b39096 100644 --- a/src/network/socket/qsymbiansocketengine_p.h +++ b/src/network/socket/qsymbiansocketengine_p.h @@ -136,10 +136,7 @@ public: Q_INVOKABLE void startNotifications(); -public Q_SLOTS: - // TODO: Why do we do this? This is private Qt implementation stuff anyway, no need for it - // non-virtual override; - void connectionNotification(); + void connectionComplete(); private: Q_DECLARE_PRIVATE(QSymbianSocketEngine) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index b659289..df61fb6 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -675,8 +675,8 @@ QString QSslSocket::peerVerifyName() const /*! \since 4.8 - Sets a different hostname for the certificate validation instead of the one used for the TCP - connection. + Sets a different host name, given by \a hostName, for the certificate + validation instead of the one used for the TCP connection. \sa connectToHostEncrypted() */ diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index fb41b7c..9a137a6 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -68,7 +68,7 @@ #endif QT_BEGIN_NAMESPACE -#if defined(Q_OS_MAC) +#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES) #define kSecTrustSettingsDomainSystem 2 // so we do not need to include the header file PtrSecCertificateGetData QSslSocketPrivate::ptrSecCertificateGetData = 0; PtrSecTrustSettingsCopyCertificates QSslSocketPrivate::ptrSecTrustSettingsCopyCertificates = 0; @@ -532,7 +532,7 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded() resetDefaultCiphers(); //load symbols needed to receive certificates from system store -#if defined(Q_OS_MAC) +#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES) QLibrary securityLib("/System/Library/Frameworks/Security.framework/Versions/Current/Security"); if (securityLib.load()) { ptrSecCertificateGetData = (PtrSecCertificateGetData) securityLib.resolve("SecCertificateGetData"); @@ -813,7 +813,7 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates() timer.start(); #endif QList<QSslCertificate> systemCerts; -#if defined(Q_OS_MAC) +#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES) CFArrayRef cfCerts; OSStatus status = 1; @@ -1338,9 +1338,9 @@ bool QSslSocketBackendPrivate::startHandshake() sslErrors.clear(); } - // if we have a max read buffer size, reset the plain socket's to 1k + // if we have a max read buffer size, reset the plain socket's to 32k if (readBufferMaxSize) - plainSocket->setReadBufferSize(1024); + plainSocket->setReadBufferSize(32768); connectionEncrypted = true; emit q->encrypted(); diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index 86ecba0..ee6361f 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -69,9 +69,11 @@ QT_BEGIN_NAMESPACE #if defined(Q_OS_MAC) #include <Security/SecCertificate.h> #include <CoreFoundation/CFArray.h> +#ifndef QT_NO_CORESERVICES typedef OSStatus (*PtrSecCertificateGetData)(SecCertificateRef, CSSM_DATA_PTR); typedef OSStatus (*PtrSecTrustSettingsCopyCertificates)(int, CFArrayRef*); typedef OSStatus (*PtrSecTrustCopyAnchorCertificates)(CFArrayRef*); +#endif #elif defined(Q_OS_WIN) #include <windows.h> #include <wincrypt.h> @@ -132,7 +134,7 @@ public: static void addDefaultCaCertificate(const QSslCertificate &cert); static void addDefaultCaCertificates(const QList<QSslCertificate> &certs); -#if defined(Q_OS_MAC) +#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES) static PtrSecCertificateGetData ptrSecCertificateGetData; static PtrSecTrustSettingsCopyCertificates ptrSecTrustSettingsCopyCertificates; static PtrSecTrustCopyAnchorCertificates ptrSecTrustCopyAnchorCertificates; |