diff options
author | Liang Qi <liang.qi@qt.io> | 2016-09-15 19:47:57 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-09-15 19:47:57 +0200 |
commit | 40a1f69e8663fb79560c26cfad5ead45b1b3ee5f (patch) | |
tree | a8ceb093a098a38b29c0fe27e41af480ae10b876 /src/network | |
parent | 446afc10451d5097d7bd20b1b8d20325c4d54fa5 (diff) | |
parent | 6b2071c697d4c48f0cd289b28b443ebffc3432e6 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
configure.json
mkspecs/macx-tvos-clang/qmake.conf
mkspecs/macx-watchos-clang/qmake.conf
Change-Id: Iaf32339ace59dff9ed344972472744c55d75025c
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/configure.json | 274 | ||||
-rw-r--r-- | src/network/configure.pri | 12 | ||||
-rw-r--r-- | src/network/kernel/qnetworkproxy_mac.cpp | 80 | ||||
-rw-r--r-- | src/network/kernel/qtnetworkglobal.h | 1 | ||||
-rw-r--r-- | src/network/kernel/qtnetworkglobal_p.h | 1 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_winrt.cpp | 2 | ||||
-rw-r--r-- | src/network/ssl/qsslcertificate.cpp | 2 |
7 files changed, 325 insertions, 47 deletions
diff --git a/src/network/configure.json b/src/network/configure.json new file mode 100644 index 0000000000..97bf92167d --- /dev/null +++ b/src/network/configure.json @@ -0,0 +1,274 @@ +{ + "module": "network", + "depends": [ + "core" + ], + "testDir": "../../config.tests", + + "commandline": { + "assignments": { + "OPENSSL_LIBS": "openssl.libs", + "OPENSSL_LIBS_DEBUG": "openssl.libs.debug", + "OPENSSL_LIBS_RELEASE": "openssl.libs.release", + "OPENSSL_PATH": "openssl.prefix" + }, + "options": { + "libproxy": "boolean", + "openssl": { "type": "optionalString", "values": [ "no", "yes", "linked", "runtime" ] }, + "openssl-linked": { "type": "void", "name": "openssl", "value": "linked" }, + "openssl-runtime": { "type": "void", "name": "openssl", "value": "runtime" }, + "sctp": "boolean", + "securetransport": "boolean", + "ssl": "boolean", + "system-proxies": "boolean" + } + }, + + "libraries": { + "corewlan": { + "label": "CoreWLan", + "export": "", + "test": "mac/corewlan", + "sources": [ + "-framework CoreWLAN -framework Foundation" + ] + }, + "network": { + "export": "", + "sources": [ + { "type": "makeSpec", "spec": "NETWORK" } + ] + }, + "libproxy": { + "label": "libproxy", + "test": "common/libproxy", + "sources": [ + "-lproxy" + ] + }, + "openssl": { + "label": "OpenSSL Libraries", + "export": "", + "sources": [ + { "type": "openssl" }, + { + "comment": "placeholder for OPENSSL_LIBS{,_{DEBUG,RELEASE}}", + "libs": "", + "builds": { + "debug": "", + "release": "" + }, + "condition": "config.win32 && !features.shared" + }, + { "libs": "-lssleay32 -llibeay32", "condition": "config.win32 && features.shared" }, + { "libs": "-lssl -lcrypto", "condition": "!config.win32" } + ] + } + }, + + "tests": { + "getaddrinfo": { + "label": "getaddrinfo()", + "type": "compile", + "test": "unix/getaddrinfo", + "use": "network" + }, + "getifaddrs": { + "label": "getifaddrs()", + "type": "compile", + "test": "unix/getifaddrs", + "use": "network" + }, + "ipv6ifname": { + "label": "IPv6 ifname", + "type": "compile", + "test": "unix/ipv6ifname", + "use": "network" + }, + "openssl": { + "label": "OpenSSL", + "type": "compile", + "test": "unix/openssl" + }, + "sctp": { + "label": "SCTP support", + "type": "compile", + "test": "unix/sctp", + "use": "network" + } + }, + + "features": { + "corewlan": { + "label": "CoreWLan", + "condition": "libs.corewlan", + "emitIf": "config.darwin", + "output": [ "feature", "privateFeature" ] + }, + "getaddrinfo": { + "label": "getaddrinfo()", + "condition": "tests.getaddrinfo", + "output": [ "feature" ] + }, + "getifaddrs": { + "label": "getifaddrs()", + "condition": "tests.getifaddrs", + "output": [ "feature" ] + }, + "ipv6ifname": { + "label": "IPv6 ifname", + "condition": "tests.ipv6ifname", + "output": [ "feature" ] + }, + "libproxy": { + "label": "libproxy", + "autoDetect": false, + "condition": "libs.libproxy", + "output": [ "privateFeature" ] + }, + "openssl": { + "label": "OpenSSL", + "enable": "input.openssl == 'yes' || input.openssl == 'linked' || input.openssl == 'runtime'", + "disable": "input.openssl == 'no' || input.ssl == 'no'", + "autoDetect": "!config.winrt", + "condition": "!features.securetransport && tests.openssl", + "output": [ + "privateFeature", + { "type": "publicQtConfig", "condition": "!features.openssl-linked" }, + { "type": "define", "negative": true, "name": "QT_NO_OPENSSL" } + ] + }, + "openssl-linked": { + "label": " Qt directly linked to OpenSSL", + "enable": "input.openssl == 'linked'", + "disable": "input.openssl != 'linked'", + "condition": "features.openssl && libs.openssl", + "output": [ + "privateFeature", + { "type": "varAssign", "name": "OPENSSL_LIBS", "value": "libs.openssl.libs", "eval": "true" }, + { "type": "varAssign", "name": "OPENSSL_LIBS_DEBUG", "value": "libs.openssl.builds.debug.libs", + "eval": "true", "condition": "config.win32" }, + { "type": "varAssign", "name": "OPENSSL_LIBS_RELEASE", "value": "libs.openssl.builds.release.libs", + "eval": "true", "condition": "config.win32" }, + { "type": "define", "name": "QT_LINKED_OPENSSL" } + ] + }, + "securetransport": { + "label": "SecureTransport", + "disable": "input.securetransport == 'no' || input.ssl == 'no'", + "condition": "config.darwin && (input.openssl == '' || input.openssl == 'no')", + "output": [ + "privateFeature", + { "type": "define", "name": "QT_SECURETRANSPORT" } + ] + }, + "ssl": { + "label": "SSL", + "condition": "config.winrt || features.securetransport || features.openssl", + "output": [ "publicFeature", "feature" ] + }, + "sctp": { + "label": "SCTP", + "autoDetect": false, + "condition": "tests.sctp", + "output": [ "publicFeature", "feature" ] + }, + "system-proxies": { + "label": "Use system proxies", + "output": [ "privateFeature" ] + }, + "ftp": { + "label": "FTP", + "purpose": "Provides support for the File Transfer Protocol in QNetworkAccessManager.", + "section": "Networking", + "condition": "features.textdate", + "output": [ "publicFeature", "feature" ] + }, + "http": { + "label": "HTTP", + "purpose": "Provides support for the Hypertext Transfer Protocol in QNetworkAccessManager.", + "section": "Networking", + "output": [ "publicFeature", "feature" ] + }, + "udpsocket": { + "label": "QUdpSocket", + "purpose": "Provides access to UDP sockets.", + "section": "Networking", + "output": [ "publicFeature", "feature" ] + }, + "networkproxy": { + "label": "QNetworkProxy", + "purpose": "Provides network proxy support.", + "section": "Networking", + "output": [ "publicFeature", "feature" ] + }, + "socks5": { + "label": "SOCKS5", + "purpose": "Provides SOCKS5 support in QNetworkProxy.", + "section": "Networking", + "output": [ "publicFeature", "feature" ] + }, + "networkinterface": { + "label": "QNetworkInterface", + "purpose": "Supports enumerating a host's IP addresses and network interfaces.", + "section": "Networking", + "output": [ "publicFeature", "feature" ] + }, + "networkdiskcache": { + "label": "QNetworkDiskCache", + "purpose": "Provides a disk cache for network resources.", + "section": "Networking", + "condition": "features.temporaryfile", + "output": [ "publicFeature", "feature" ] + }, + "bearermanagement": { + "label": "Bearer management", + "purpose": "Provides bearer management for the network stack.", + "section": "Networking", + "condition": "features.library && features.networkinterface && features.properties", + "output": [ "publicFeature", "feature" ] + }, + "localserver": { + "label": "QLocalServer", + "purpose": "Provides a local socket based server.", + "section": "Networking", + "condition": "features.temporaryfile", + "output": [ "publicFeature", "feature" ] + } + }, + + "report": [ + { + "type": "note", + "condition": "features.openssl-linked && libs.openssl.source != 0 + && input.openssl.prefix == '' && input.openssl.libs == '' && input.openssl.libs.debug == ''", + "message": "When linking against OpenSSL, you can override the default +library names through OPENSSL_LIBS. +For example: + OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked" + } + ], + + "summary": [ + { + "section": "Qt Network", + "entries": [ + { + "type": "feature", + "args": "corewlan", + "condition": "config.darwin" + }, + "getaddrinfo", "getifaddrs", "ipv6ifname", "libproxy", + { + "type": "feature", + "args": "securetransport", + "condition": "config.darwin" + }, + "openssl", + "openssl-linked", + "sctp", + "system-proxies" + ] + } + ] +} diff --git a/src/network/configure.pri b/src/network/configure.pri new file mode 100644 index 0000000000..57568902e4 --- /dev/null +++ b/src/network/configure.pri @@ -0,0 +1,12 @@ +# custom tests + +defineTest(qtConfLibrary_openssl) { + libs = $$getenv("OPENSSL_LIBS") + !isEmpty(libs) { + $${1}.libs = $$libs + export($${1}.libs) + return(true) + } + return(false) +} + diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp index 37126298c6..76a2d2df9f 100644 --- a/src/network/kernel/qnetworkproxy_mac.cpp +++ b/src/network/kernel/qnetworkproxy_mac.cpp @@ -180,31 +180,23 @@ static QNetworkProxy proxyFromDictionary(CFDictionaryRef dict) return QNetworkProxy(proxyType, hostName, port, user, password); } -const char * cfurlErrorDescription(SInt32 errorCode) +namespace { +struct PACInfo { + QCFType<CFArrayRef> proxies; + QCFType<CFErrorRef> error; + bool done = false; +}; + +void proxyAutoConfigCallback(void *client, CFArrayRef proxylist, CFErrorRef error) { - switch (errorCode) { - case kCFURLUnknownError: - return "Unknown Error"; - case kCFURLUnknownSchemeError: - return "Unknown Scheme"; - case kCFURLResourceNotFoundError: - return "Resource Not Found"; - case kCFURLResourceAccessViolationError: - return "Resource Access Violation"; - case kCFURLRemoteHostUnavailableError: - return "Remote Host Unavailable"; - case kCFURLImproperArgumentsError: - return "Improper Arguments"; - case kCFURLUnknownPropertyKeyError: - return "Unknown Property Key"; - case kCFURLPropertyKeyUnavailableError: - return "Property Key Unavailable"; - case kCFURLTimeoutError: - return "Timeout"; - default: - return "Really Unknown Error"; - } + PACInfo *info = reinterpret_cast<PACInfo *>(reinterpret_cast<CFStreamClientContext *>(client)->info); + info->done = true; + if (proxylist) + CFRetain(proxylist); + info->proxies = proxylist; + info->error = error; } +} // anon namespace QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query) { @@ -240,23 +232,6 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query) qWarning("Invalid PAC URL \"%s\"", qPrintable(QCFString::toQString(cfPacLocation))); return result; } - SInt32 errorCode; - if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, pacUrl, &pacData, NULL, NULL, &errorCode)) { - QString pacLocation = QCFString::toQString(cfPacLocation); - qWarning("Unable to get the PAC script at \"%s\" (%s)", qPrintable(pacLocation), cfurlErrorDescription(errorCode)); - return result; - } - if (!pacData) { - qWarning("\"%s\" returned an empty PAC script", qPrintable(QCFString::toQString(cfPacLocation))); - return result; - } - QCFType<CFStringRef> pacScript = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, pacData, kCFStringEncodingISOLatin1); - if (!pacScript) { - // This should never happen, but the documentation says it may return NULL if there was a problem creating the object. - QString pacLocation = QCFString::toQString(cfPacLocation); - qWarning("Unable to read the PAC script at \"%s\"", qPrintable(pacLocation)); - return result; - } QByteArray encodedURL = query.url().toEncoded(); // converted to UTF-8 if (encodedURL.isEmpty()) { @@ -268,18 +243,31 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query) return result; // URL creation problem, abort } - QCFType<CFErrorRef> pacError; - QCFType<CFArrayRef> proxies = CFNetworkCopyProxiesForAutoConfigurationScript(pacScript, targetURL, &pacError); - if (!proxies) { + CFStreamClientContext pacCtx; + pacCtx.version = 0; + PACInfo pacInfo; + pacCtx.info = &pacInfo; + pacCtx.retain = NULL; + pacCtx.release = NULL; + pacCtx.copyDescription = NULL; + + static CFStringRef pacRunLoopMode = CFSTR("qtPACRunLoopMode"); + + QCFType<CFRunLoopSourceRef> pacRunLoopSource = CFNetworkExecuteProxyAutoConfigurationURL(pacUrl, targetURL, &proxyAutoConfigCallback, &pacCtx); + CFRunLoopAddSource(CFRunLoopGetCurrent(), pacRunLoopSource, pacRunLoopMode); + while (!pacInfo.done) + CFRunLoopRunInMode(pacRunLoopMode, 1000, /*returnAfterSourceHandled*/ true); + + if (!pacInfo.proxies) { QString pacLocation = QCFString::toQString(cfPacLocation); - QCFType<CFStringRef> pacErrorDescription = CFErrorCopyDescription(pacError); + QCFType<CFStringRef> pacErrorDescription = CFErrorCopyDescription(pacInfo.error); qWarning("Execution of PAC script at \"%s\" failed: %s", qPrintable(pacLocation), qPrintable(QCFString::toQString(pacErrorDescription))); return result; } - CFIndex size = CFArrayGetCount(proxies); + CFIndex size = CFArrayGetCount(pacInfo.proxies); for (CFIndex i = 0; i < size; ++i) { - CFDictionaryRef proxy = (CFDictionaryRef)CFArrayGetValueAtIndex(proxies, i); + CFDictionaryRef proxy = (CFDictionaryRef)CFArrayGetValueAtIndex(pacInfo.proxies, i); result << proxyFromDictionary(proxy); } return result; diff --git a/src/network/kernel/qtnetworkglobal.h b/src/network/kernel/qtnetworkglobal.h index 192601970a..586b847816 100644 --- a/src/network/kernel/qtnetworkglobal.h +++ b/src/network/kernel/qtnetworkglobal.h @@ -41,6 +41,7 @@ #define QTNETWORKGLOBAL_H #include <QtCore/qglobal.h> +#include <QtNetwork/qtnetwork-config.h> QT_BEGIN_NAMESPACE diff --git a/src/network/kernel/qtnetworkglobal_p.h b/src/network/kernel/qtnetworkglobal_p.h index 51347e440d..859e3d9ebd 100644 --- a/src/network/kernel/qtnetworkglobal_p.h +++ b/src/network/kernel/qtnetworkglobal_p.h @@ -53,5 +53,6 @@ #include <QtNetwork/qtnetworkglobal.h> #include <QtCore/private/qglobal_p.h> +#include <QtNetwork/private/qtnetwork-config_p.h> #endif // QTNETWORKGLOBAL_P_H diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 641863b4fd..6b71912838 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -1306,10 +1306,12 @@ HRESULT QNativeSocketEnginePrivate::handleConnectOpFinished(IAsyncAction *action if (socketType != QAbstractSocket::TcpSocket) return S_OK; +#ifndef QT_NO_SSL // Delay the reader so that the SSL socket can upgrade if (sslSocket) QObject::connect(qobject_cast<QSslSocket *>(sslSocket), &QSslSocket::encrypted, q, &QNativeSocketEngine::establishRead); else +#endif q->establishRead(); return S_OK; } diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 96ba68089d..ce78399e01 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -111,7 +111,7 @@ \value EmailAddress The email address associated with the certificate */ -#include <QtCore/qglobal.h> +#include <QtNetwork/qtnetworkglobal.h> #ifndef QT_NO_OPENSSL #include "qsslsocket_openssl_symbols_p.h" #endif |