Qt 4.8
qnetworkproxy_win.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtNetwork module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qnetworkproxy.h"
43 
44 #ifndef QT_NO_NETWORKPROXY
45 
46 #include <qmutex.h>
47 #include <qstringlist.h>
48 #include <qregexp.h>
49 #include <qurl.h>
50 #include <qnetworkinterface.h>
51 
52 #include <string.h>
53 #include <qt_windows.h>
54 #include <wininet.h>
55 #include <private/qsystemlibrary_p.h>
57 
58 /*
59  * Information on the WinHTTP DLL:
60  * http://msdn.microsoft.com/en-us/library/aa384122(VS.85).aspx example for WPAD
61  *
62  * http://msdn.microsoft.com/en-us/library/aa384097(VS.85).aspx WinHttpGetProxyForUrl
63  * http://msdn.microsoft.com/en-us/library/aa384096(VS.85).aspx WinHttpGetIEProxyConfigForCurrentUs
64  * http://msdn.microsoft.com/en-us/library/aa384095(VS.85).aspx WinHttpGetDefaultProxyConfiguration
65  */
66 
67 // We don't want to include winhttp.h because that's not
68 // present in some Windows SDKs (I don't know why)
69 // So, instead, copy the definitions here
70 
71 typedef struct {
72  DWORD dwFlags;
75  LPVOID lpvReserved;
76  DWORD dwReserved;
79 
80 typedef struct {
81  DWORD dwAccessType;
82  LPWSTR lpszProxy;
85 
86 typedef struct {
89  LPWSTR lpszProxy;
92 
93 #define WINHTTP_AUTOPROXY_AUTO_DETECT 0x00000001
94 #define WINHTTP_AUTOPROXY_CONFIG_URL 0x00000002
95 
96 #define WINHTTP_AUTO_DETECT_TYPE_DHCP 0x00000001
97 #define WINHTTP_AUTO_DETECT_TYPE_DNS_A 0x00000002
98 
99 #define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY 0
100 #define WINHTTP_ACCESS_TYPE_NO_PROXY 1
101 #define WINHTTP_ACCESS_TYPE_NAMED_PROXY 3
102 
103 #define WINHTTP_NO_PROXY_NAME NULL
104 #define WINHTTP_NO_PROXY_BYPASS NULL
105 
106 #define WINHTTP_ERROR_BASE 12000
107 #define ERROR_WINHTTP_LOGIN_FAILURE (WINHTTP_ERROR_BASE + 15)
108 #define ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT (WINHTTP_ERROR_BASE + 167)
109 #define ERROR_WINHTTP_AUTODETECTION_FAILED (WINHTTP_ERROR_BASE + 180)
110 
112 
113 typedef BOOL (WINAPI * PtrWinHttpGetProxyForUrl)(HINTERNET, LPCWSTR, WINHTTP_AUTOPROXY_OPTIONS*, WINHTTP_PROXY_INFO*);
114 typedef HINTERNET (WINAPI * PtrWinHttpOpen)(LPCWSTR, DWORD, LPCWSTR, LPCWSTR,DWORD);
117 typedef BOOL (WINAPI * PtrWinHttpCloseHandle)(HINTERNET);
118 typedef SC_HANDLE (WINAPI * PtrOpenSCManager)(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess);
119 typedef BOOL (WINAPI * PtrEnumServicesStatusEx)(SC_HANDLE hSCManager, SC_ENUM_TYPE InfoLevel, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded,
120  LPDWORD lpServicesReturned, LPDWORD lpResumeHandle, LPCWSTR pszGroupName);
121 typedef BOOL (WINAPI * PtrCloseServiceHandle)(SC_HANDLE hSCObject);
130 
131 
133 {
135  return false;
136 
138  if (!hSCM)
139  return false;
140 
141  ULONG bufSize = 0;
142  ULONG nbServices = 0;
143  if (ptrEnumServicesStatusEx(hSCM, SC_ENUM_PROCESS_INFO, SERVICE_WIN32, SERVICE_ACTIVE, 0, bufSize, &bufSize, &nbServices, 0, 0))
144  return false; //error case
145 
146  LPENUM_SERVICE_STATUS_PROCESS info = reinterpret_cast<LPENUM_SERVICE_STATUS_PROCESS>(malloc(bufSize));
147  bool foundService = false;
148  if (ptrEnumServicesStatusEx(hSCM, SC_ENUM_PROCESS_INFO, SERVICE_WIN32, SERVICE_ACTIVE, (LPBYTE)info, bufSize, &bufSize, &nbServices, 0, 0)) {
149  DWORD currProcId = GetCurrentProcessId();
150  for (ULONG i = 0; i < nbServices && !foundService; i++) {
151  if (info[i].ServiceStatusProcess.dwProcessId == currProcId)
152  foundService = true;
153  }
154  }
155 
156  ptrCloseServiceHandle(hSCM);
157  free(info);
158  return foundService;
159 }
160 
162 {
163  QStringList list;
164  int start = 0;
165  int end;
166  while (true) {
167  int space = source.indexOf(QLatin1Char(' '), start);
168  int semicolon = source.indexOf(QLatin1Char(';'), start);
169  end = space;
170  if (semicolon != -1 && (end == -1 || semicolon < end))
171  end = semicolon;
172 
173  if (end == -1) {
174  if (start != source.length())
175  list.append(source.mid(start));
176  return list;
177  }
178  if (start != end)
179  list.append(source.mid(start, end - start));
180  start = end + 1;
181  }
182  return list;
183 }
184 
185 static bool isBypassed(const QString &host, const QStringList &bypassList)
186 {
187  if (host.isEmpty())
188  return false;
189 
190  bool isSimple = !host.contains(QLatin1Char('.')) && !host.contains(QLatin1Char(':'));
191 
192  QHostAddress ipAddress;
193  bool isIpAddress = ipAddress.setAddress(host);
194 
195  // always exclude loopback
196  if (isIpAddress && (ipAddress == QHostAddress::LocalHost || ipAddress == QHostAddress::LocalHostIPv6))
197  return true;
198 
199  // does it match the list of exclusions?
200  foreach (const QString &entry, bypassList) {
201  if (entry == QLatin1String("<local>")) {
202  if (isSimple)
203  return true;
204  if (isIpAddress) {
205  //exclude all local subnets
206  foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) {
207  foreach (const QNetworkAddressEntry netaddr, iface.addressEntries()) {
208  if (ipAddress.isInSubnet(netaddr.ip(), netaddr.prefixLength())) {
209  return true;
210  }
211  }
212  }
213  }
214  }
215  if (isIpAddress && ipAddress.isInSubnet(QHostAddress::parseSubnet(entry))) {
216  return true; // excluded
217  } else {
218  // do wildcard matching
220  if (rx.exactMatch(host))
221  return true;
222  }
223  }
224 
225  // host was not excluded
226  return false;
227 }
228 
230 {
231  QNetworkProxy::Capabilities requiredCaps;
232  switch (query.queryType()) {
234  requiredCaps = QNetworkProxy::TunnelingCapability;
235  break;
238  break;
240  requiredCaps = QNetworkProxy::ListeningCapability;
241  break;
242  default:
243  return proxyList;
244  break;
245  }
246  QList<QNetworkProxy> result;
247  foreach (const QNetworkProxy& proxy, proxyList) {
248  if (proxy.capabilities() & requiredCaps)
249  result.append(proxy);
250  }
251  return result;
252 }
253 
255 {
256  QList<QNetworkProxy> result;
257  foreach (QNetworkProxy proxy, proxyList) {
258  bool append = true;
259  for (int i=0; i < result.count(); i++) {
260  if (proxy.hostName() == result.at(i).hostName()
261  && proxy.port() == result.at(i).port()) {
262  append = false;
263  // HttpProxy trumps FtpCachingProxy or HttpCachingProxy on the same host/port
264  if (proxy.type() == QNetworkProxy::HttpProxy)
265  result[i] = proxy;
266  }
267  }
268  if (append)
269  result.append(proxy);
270  }
271  return result;
272 }
273 
275 {
276  // Reference documentation from Microsoft:
277  // http://msdn.microsoft.com/en-us/library/aa383912(VS.85).aspx
278  //
279  // According to the website, the proxy server list is
280  // one or more of the space- or semicolon-separated strings in the format:
281  // ([<scheme>=][<scheme>"://"]<server>[":"<port>])
282  // The first scheme relates to the protocol tag
283  // The second scheme, if present, overrides the proxy type
284 
285  QList<QNetworkProxy> result;
286  QHash<QString, QNetworkProxy> taggedProxies;
287  const QString requiredTag = query.protocolTag();
288  bool checkTags = !requiredTag.isEmpty() && query.queryType() != QNetworkProxyQuery::TcpServer; //windows tags are only for clients
289  foreach (const QString &entry, proxyList) {
290  int server = 0;
291 
293  quint16 port = 8080;
294 
295  int pos = entry.indexOf(QLatin1Char('='));
296  QStringRef scheme;
297  QStringRef protocolTag;
298  if (pos != -1) {
299  scheme = protocolTag = entry.leftRef(pos);
300  server = pos + 1;
301  }
302  pos = entry.indexOf(QLatin1String("://"), server);
303  if (pos != -1) {
304  scheme = entry.midRef(server, pos - server);
305  server = pos + 3;
306  }
307 
308  if (!scheme.isEmpty()) {
309  if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) {
310  // no-op
311  // defaults are above
312  } else if (scheme == QLatin1String("socks") || scheme == QLatin1String("socks5")) {
313  proxyType = QNetworkProxy::Socks5Proxy;
314  port = 1080;
315  } else if (scheme == QLatin1String("ftp")) {
316  proxyType = QNetworkProxy::FtpCachingProxy;
317  port = 2121;
318  } else {
319  // unknown proxy type
320  continue;
321  }
322  }
323 
324  pos = entry.indexOf(QLatin1Char(':'), server);
325  if (pos != -1) {
326  bool ok;
327  uint value = entry.mid(pos + 1).toUInt(&ok);
328  if (!ok || value > 65535)
329  continue; // invalid port number
330 
331  port = value;
332  } else {
333  pos = entry.length();
334  }
335 
336  result << QNetworkProxy(proxyType, entry.mid(server, pos - server), port);
337  if (!protocolTag.isEmpty())
338  taggedProxies.insert(protocolTag.toString(), result.last());
339  }
340 
341  if (checkTags && taggedProxies.contains(requiredTag)) {
342  if (query.queryType() == QNetworkProxyQuery::UrlRequest) {
343  result.clear();
344  result.append(taggedProxies.value(requiredTag));
345  return result;
346  } else {
347  result.prepend(taggedProxies.value(requiredTag));
348  }
349  }
350  if (!checkTags || requiredTag != QLatin1String("http")) {
351  // if there are different http proxies for http and https, prefer the https one (more likely to be capable of CONNECT)
352  QNetworkProxy httpProxy = taggedProxies.value(QLatin1String("http"));
353  QNetworkProxy httpsProxy = taggedProxies.value(QLatin1String("http"));
354  if (httpProxy != httpsProxy && httpProxy.type() == QNetworkProxy::HttpProxy && httpsProxy.type() == QNetworkProxy::HttpProxy) {
355  for (int i = 0; i < result.count(); i++) {
356  if (httpProxy == result.at(i))
357  result[i].setType(QNetworkProxy::HttpCachingProxy);
358  }
359  }
360  }
361  result = filterProxyListByCapabilities(result, query);
362  return removeDuplicateProxies(result);
363 }
364 
366 {
367 public:
370  void init();
371 
373 
374  HINTERNET hHttpSession;
376 
381 
385 };
386 
388 
390  : hHttpSession(0), initialized(false), functional(false), isAutoConfig(false)
391 {
393 }
394 
396 {
397  if (hHttpSession)
399 }
400 
402 {
403  if (initialized)
404  return;
405  initialized = true;
406 
407 #ifdef Q_OS_WINCE
408  // Windows CE does not have any of the following API
409  return;
410 #else
411  // load the winhttp.dll library
412  QSystemLibrary lib(L"winhttp");
413  if (!lib.load())
414  return; // failed to load
415 
416  ptrWinHttpOpen = (PtrWinHttpOpen)lib.resolve("WinHttpOpen");
417  ptrWinHttpCloseHandle = (PtrWinHttpCloseHandle)lib.resolve("WinHttpCloseHandle");
418  ptrWinHttpGetProxyForUrl = (PtrWinHttpGetProxyForUrl)lib.resolve("WinHttpGetProxyForUrl");
419  ptrWinHttpGetDefaultProxyConfiguration = (PtrWinHttpGetDefaultProxyConfiguration)lib.resolve("WinHttpGetDefaultProxyConfiguration");
420  ptrWinHttpGetIEProxyConfigForCurrentUser = (PtrWinHttpGetIEProxyConfigForCurrentUser)lib.resolve("WinHttpGetIEProxyConfigForCurrentUser");
421  ptrOpenSCManager = (PtrOpenSCManager) QSystemLibrary(L"advapi32").resolve("OpenSCManagerW");
422  ptrEnumServicesStatusEx = (PtrEnumServicesStatusEx) QSystemLibrary(L"advapi32").resolve("EnumServicesStatusExW");
423  ptrCloseServiceHandle = (PtrCloseServiceHandle) QSystemLibrary(L"advapi32").resolve("CloseServiceHandle");
424 
425  // Try to obtain the Internet Explorer configuration.
427  const bool hasIEConfig = ptrWinHttpGetIEProxyConfigForCurrentUser(&ieProxyConfig);
428  if (hasIEConfig) {
429  if (ieProxyConfig.lpszAutoConfigUrl) {
431  GlobalFree(ieProxyConfig.lpszAutoConfigUrl);
432  }
433  if (ieProxyConfig.lpszProxy) {
434  // http://msdn.microsoft.com/en-us/library/aa384250%28VS.85%29.aspx speaks only about a "proxy URL",
435  // not multiple URLs. However we tested this and it can return multiple URLs. So we use splitSpaceSemicolon
436  // on it.
438  GlobalFree(ieProxyConfig.lpszProxy);
439  }
440  if (ieProxyConfig.lpszProxyBypass) {
442  GlobalFree(ieProxyConfig.lpszProxyBypass);
443  }
444  }
445 
446  if (!hasIEConfig ||
448  // no user configuration
449  // attempt to get the default configuration instead
450  // that config will serve as default if WPAD fails
451  WINHTTP_PROXY_INFO proxyInfo;
452  if (ptrWinHttpGetDefaultProxyConfiguration(&proxyInfo) &&
454  // we got information from the registry
455  // overwrite the IE configuration, if any
456 
459  }
460 
461  if (proxyInfo.lpszProxy)
462  GlobalFree(proxyInfo.lpszProxy);
463  if (proxyInfo.lpszProxyBypass)
464  GlobalFree(proxyInfo.lpszProxyBypass);
465  }
466 
467  hHttpSession = NULL;
468  if (ieProxyConfig.fAutoDetect || !autoConfigUrl.isEmpty()) {
469  // open the handle and obtain the options
470  hHttpSession = ptrWinHttpOpen(L"Qt System Proxy access/1.0",
474  0);
475  if (!hHttpSession)
476  return;
477 
478  isAutoConfig = true;
479  memset(&autoProxyOptions, 0, sizeof autoProxyOptions);
481  //Although it is possible to specify dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT | WINHTTP_AUTOPROXY_CONFIG_URL
482  //this has poor performance (WPAD is attempted for every url, taking 2.5 seconds per interface,
483  //before the configured pac file is used)
484  if (ieProxyConfig.fAutoDetect) {
488  } else {
491  }
492  }
493 
495 #endif
496 }
497 
499 {
500  QWindowsSystemProxy *sp = systemProxy();
501  if (!sp)
502  return QList<QNetworkProxy>() << QNetworkProxy();
503 
504  QMutexLocker locker(&sp->mutex);
505  sp->init();
506  if (!sp->functional)
507  return sp->defaultResult;
508 
509  if (sp->isAutoConfig) {
510  WINHTTP_PROXY_INFO proxyInfo;
511 
512  // try to get the proxy config for the URL
513  QUrl url = query.url();
514  // url could be empty, e.g. from QNetworkProxy::applicationProxy(), that's fine,
515  // we'll still ask for the proxy.
516  // But for a file url, we know we don't need one.
517  if (url.scheme() == QLatin1String("file") || url.scheme() == QLatin1String("qrc"))
518  return sp->defaultResult;
520  // change the scheme to https, maybe it'll work
521  url.setScheme(QLatin1String("https"));
522  }
523 
524  bool getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
525  (LPCWSTR)url.toString().utf16(),
526  &sp->autoProxyOptions,
527  &proxyInfo);
528  DWORD getProxyError = GetLastError();
529 
530  if (!getProxySucceeded
531  && (ERROR_WINHTTP_AUTODETECTION_FAILED == getProxyError)) {
532  // WPAD failed
533  if (sp->autoConfigUrl.isEmpty()) {
534  //No config file could be retrieved on the network.
535  //Don't search for it next time again.
536  sp->isAutoConfig = false;
537  } else {
538  //pac file URL is specified as well, try using that
541  getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
542  (LPCWSTR)url.toString().utf16(),
543  &sp->autoProxyOptions,
544  &proxyInfo);
545  getProxyError = GetLastError();
546  }
547  }
548 
549  if (!getProxySucceeded
550  && (ERROR_WINHTTP_LOGIN_FAILURE == getProxyError)) {
551  // We first tried without AutoLogon, because this might prevent caching the result.
552  // But now we've to enable it (http://msdn.microsoft.com/en-us/library/aa383153%28v=VS.85%29.aspx)
554  getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
555  (LPCWSTR)url.toString().utf16(),
556  &sp->autoProxyOptions,
557  &proxyInfo);
558  getProxyError = GetLastError();
559  }
560 
561  if (!getProxySucceeded
562  && (ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT == getProxyError)) {
563  // PAC file url is not connectable, or server returned error (e.g. http 404)
564  //Don't search for it next time again.
565  sp->isAutoConfig = false;
566  }
567 
568  if (getProxySucceeded) {
569  // yes, we got a config for this URL
572  if (proxyInfo.lpszProxy)
573  GlobalFree(proxyInfo.lpszProxy);
574  if (proxyInfo.lpszProxyBypass)
575  GlobalFree(proxyInfo.lpszProxyBypass);
576 
578  return sp->defaultResult; //i.e. the PAC file result was "DIRECT"
579  if (isBypassed(query.peerHostName(), splitSpaceSemicolon(proxyBypass)))
580  return sp->defaultResult;
581  return parseServerList(query, proxyServerList);
582  }
583 
584  // GetProxyForUrl failed, fall back to static configuration
585  }
586 
587  // static configuration
588  if (isBypassed(query.peerHostName(), sp->proxyBypass))
589  return sp->defaultResult;
590 
592  // In some cases, this was empty. See SF task 00062670
593  if (result.isEmpty())
594  return sp->defaultResult;
595 
596  return result;
597 }
598 
600 
601 #endif
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
#define WINHTTP_NO_PROXY_NAME
static QList< QNetworkProxy > filterProxyListByCapabilities(const QList< QNetworkProxy > &proxyList, const QNetworkProxyQuery &query)
QString toString() const
Returns a copy of the string reference as a QString object.
Definition: qstring.cpp:8653
static QList< QNetworkProxy > parseServerList(const QNetworkProxyQuery &query, const QStringList &proxyList)
static mach_timebase_info_data_t info
static PtrEnumServicesStatusEx ptrEnumServicesStatusEx
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QHostAddress ip() const
This function returns one IPv4 or IPv6 address found, that was found in a network interface...
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
static QStringList splitSpaceSemicolon(const QString &source)
static PtrCloseServiceHandle ptrCloseServiceHandle
BOOL(WINAPI * PtrWinHttpGetProxyForUrl)(HINTERNET, LPCWSTR, WINHTTP_AUTOPROXY_OPTIONS *, WINHTTP_PROXY_INFO *)
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
static PtrWinHttpCloseHandle ptrWinHttpCloseHandle
QString peerHostName() const
Returns the host name or IP address being of the outgoing connection being requested, or an empty string if the remote hostname is not known.
#define SERVICE_ACTIVE
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
BOOL(WINAPI * PtrWinHttpCloseHandle)(HINTERNET)
#define SC_MANAGER_ENUMERATE_SERVICE
static QList< QNetworkProxy > systemProxyForQuery(const QNetworkProxyQuery &query=QNetworkProxyQuery())
This function takes the query request, query, examines the details of the type of socket or request a...
#define WINHTTP_AUTOPROXY_AUTO_DETECT
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
BOOL(WINAPI * PtrEnumServicesStatusEx)(SC_HANDLE hSCManager, SC_ENUM_TYPE InfoLevel, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned, LPDWORD lpResumeHandle, LPCWSTR pszGroupName)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
bool load(bool onlySystemDirectory=true)
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
#define WINHTTP_AUTO_DETECT_TYPE_DHCP
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static QList< QNetworkProxy > removeDuplicateProxies(const QList< QNetworkProxy > &proxyList)
static bool currentProcessIsService()
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QList< QNetworkProxy > defaultResult
QStringRef leftRef(int n) const Q_REQUIRED_RESULT
Returns a substring reference to the n leftmost characters of the string.
Definition: qstring.cpp:9045
SC_HANDLE(WINAPI * PtrOpenSCManager)(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
static bool isBypassed(const QString &host, const QStringList &bypassList)
#define WINHTTP_ACCESS_TYPE_NAMED_PROXY
BOOL(WINAPI * PtrWinHttpGetIEProxyConfigForCurrentUser)(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *)
WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions
The QNetworkProxy class provides a network layer proxy.
QueryType queryType() const
Returns the query type.
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define ERROR_WINHTTP_AUTODETECTION_FAILED
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QString protocolTag() const
Returns the protocol tag for this QNetworkProxyQuery object, or an empty QString in case the protocol...
Capabilities capabilities() const
Returns the capabilities of this proxy server.
HINTERNET(WINAPI * PtrWinHttpOpen)(LPCWSTR, DWORD, LPCWSTR, LPCWSTR, DWORD)
#define WINHTTP_ACCESS_TYPE_NO_PROXY
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QPair< QHostAddress, int > parseSubnet(const QString &subnet)
Parses the IP and subnet information contained in subnet and returns the network prefix for that netw...
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
unsigned short quint16
Definition: qglobal.h:936
bool isEmpty() const
Returns true if the string reference has no characters; otherwise returns false.
Definition: qstring.h:1169
unsigned int uint
Definition: qglobal.h:996
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
#define SC_MANAGER_CONNECT
#define WINHTTP_AUTO_DETECT_TYPE_DNS_A
static PtrOpenSCManager ptrOpenSCManager
void clear()
Removes all items from the list.
Definition: qlist.h:764
BOOL(WINAPI * PtrWinHttpGetDefaultProxyConfiguration)(WINHTTP_PROXY_INFO *)
bool isInSubnet(const QHostAddress &subnet, int netmask) const
Returns true if this IP is in the subnet described by the network prefix subnet and netmask netmask...
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
#define ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT
The QNetworkProxyQuery class is used to query the proxy settings for a socket.
Definition: qnetworkproxy.h:60
#define TRUE
Synonym for true.
Definition: qglobal.h:1018
QStringRef midRef(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a substring reference to n characters of this string, starting at the specified position...
Definition: qstring.cpp:9099
BOOL(WINAPI * PtrCloseServiceHandle)(SC_HANDLE hSCObject)
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
static QAuServer & server()
Definition: qsound.cpp:79
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
void * resolve(const char *symbol)
static PtrWinHttpGetDefaultProxyConfiguration ptrWinHttpGetDefaultProxyConfiguration
void setAddress(quint32 ip4Addr)
Set the IPv4 address specified by ip4Addr.
static QList< QNetworkInterface > allInterfaces()
Returns a listing of all the network interfaces found on the host machine.
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
quint16 port() const
Returns the port of the proxy host.
uint toUInt(bool *ok=0, int base=10) const
Returns the string converted to an unsigned int using base base, which is 10 by default and must be b...
Definition: qstring.cpp:6120
if(void) toggleToolbarShown
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
Definition: qurl.cpp:4533
QUrl url() const
Returns the URL component of this QNetworkProxyQuery object in case of a query of type QNetworkProxyQ...
bool exactMatch(const QString &str) const
Returns true if str is matched exactly by this regular expression; otherwise returns false...
Definition: qregexp.cpp:4094
#define WINHTTP_AUTOPROXY_CONFIG_URL
static PtrWinHttpOpen ptrWinHttpOpen
The QNetworkInterface class provides a listing of the host&#39;s IP addresses and network interfaces...
The QHostAddress class provides an IP address.
Definition: qhostaddress.h:70
#define WINHTTP_NO_PROXY_BYPASS
static PtrWinHttpGetIEProxyConfigForCurrentUser ptrWinHttpGetIEProxyConfigForCurrentUser
static const KeyPair *const end
enum _SC_ENUM_TYPE SC_ENUM_TYPE
#define ERROR_WINHTTP_LOGIN_FAILURE
QList< QNetworkAddressEntry > addressEntries() const
Returns the list of IP addresses that this interface possesses along with their associated netmasks a...
static PtrWinHttpGetProxyForUrl ptrWinHttpGetProxyForUrl
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QNetworkAddressEntry class stores one IP address supported by a network interface, along with its associated netmask and broadcast address.
int prefixLength() const
Returns the prefix length of this IP address.
ProxyType
This enum describes the types of network proxying provided in Qt.
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290
QString hostName() const
Returns the host name of the proxy host.