Qt 4.8
Classes | Macros | Typedefs | Functions | Variables
qnetworkproxy_win.cpp File Reference
#include "qnetworkproxy.h"
#include <qmutex.h>
#include <qstringlist.h>
#include <qregexp.h>
#include <qurl.h>
#include <qnetworkinterface.h>
#include <string.h>
#include <qt_windows.h>
#include <wininet.h>
#include <private/qsystemlibrary_p.h>
#include "qnetworkfunctions_wince.h"

Go to the source code of this file.

Classes

class  QWindowsSystemProxy
 
struct  WINHTTP_AUTOPROXY_OPTIONS
 
struct  WINHTTP_CURRENT_USER_IE_PROXY_CONFIG
 
struct  WINHTTP_PROXY_INFO
 

Macros

#define ERROR_WINHTTP_AUTODETECTION_FAILED   (WINHTTP_ERROR_BASE + 180)
 
#define ERROR_WINHTTP_LOGIN_FAILURE   (WINHTTP_ERROR_BASE + 15)
 
#define ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT   (WINHTTP_ERROR_BASE + 167)
 
#define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY   0
 
#define WINHTTP_ACCESS_TYPE_NAMED_PROXY   3
 
#define WINHTTP_ACCESS_TYPE_NO_PROXY   1
 
#define WINHTTP_AUTO_DETECT_TYPE_DHCP   0x00000001
 
#define WINHTTP_AUTO_DETECT_TYPE_DNS_A   0x00000002
 
#define WINHTTP_AUTOPROXY_AUTO_DETECT   0x00000001
 
#define WINHTTP_AUTOPROXY_CONFIG_URL   0x00000002
 
#define WINHTTP_ERROR_BASE   12000
 
#define WINHTTP_NO_PROXY_BYPASS   NULL
 
#define WINHTTP_NO_PROXY_NAME   NULL
 

Typedefs

typedef BOOL(WINAPI * PtrCloseServiceHandle) (SC_HANDLE hSCObject)
 
typedef 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)
 
typedef SC_HANDLE(WINAPI * PtrOpenSCManager) (LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
 
typedef BOOL(WINAPI * PtrWinHttpCloseHandle) (HINTERNET)
 
typedef BOOL(WINAPI * PtrWinHttpGetDefaultProxyConfiguration) (WINHTTP_PROXY_INFO *)
 
typedef BOOL(WINAPI * PtrWinHttpGetIEProxyConfigForCurrentUser) (WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *)
 
typedef BOOL(WINAPI * PtrWinHttpGetProxyForUrl) (HINTERNET, LPCWSTR, WINHTTP_AUTOPROXY_OPTIONS *, WINHTTP_PROXY_INFO *)
 
typedef HINTERNET(WINAPI * PtrWinHttpOpen) (LPCWSTR, DWORD, LPCWSTR, LPCWSTR, DWORD)
 

Functions

static bool currentProcessIsService ()
 
static QList< QNetworkProxyfilterProxyListByCapabilities (const QList< QNetworkProxy > &proxyList, const QNetworkProxyQuery &query)
 
static bool isBypassed (const QString &host, const QStringList &bypassList)
 
static QList< QNetworkProxyparseServerList (const QNetworkProxyQuery &query, const QStringList &proxyList)
 
static QList< QNetworkProxyremoveDuplicateProxies (const QList< QNetworkProxy > &proxyList)
 
static QStringList splitSpaceSemicolon (const QString &source)
 

Variables

static PtrCloseServiceHandle ptrCloseServiceHandle = 0
 
static PtrEnumServicesStatusEx ptrEnumServicesStatusEx = 0
 
static PtrOpenSCManager ptrOpenSCManager = 0
 
static PtrWinHttpCloseHandle ptrWinHttpCloseHandle = 0
 
static PtrWinHttpGetDefaultProxyConfiguration ptrWinHttpGetDefaultProxyConfiguration = 0
 
static PtrWinHttpGetIEProxyConfigForCurrentUser ptrWinHttpGetIEProxyConfigForCurrentUser = 0
 
static PtrWinHttpGetProxyForUrl ptrWinHttpGetProxyForUrl = 0
 
static PtrWinHttpOpen ptrWinHttpOpen = 0
 

Macro Definition Documentation

◆ ERROR_WINHTTP_AUTODETECTION_FAILED

#define ERROR_WINHTTP_AUTODETECTION_FAILED   (WINHTTP_ERROR_BASE + 180)

Definition at line 109 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ ERROR_WINHTTP_LOGIN_FAILURE

#define ERROR_WINHTTP_LOGIN_FAILURE   (WINHTTP_ERROR_BASE + 15)

Definition at line 107 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT

#define ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT   (WINHTTP_ERROR_BASE + 167)

Definition at line 108 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ WINHTTP_ACCESS_TYPE_DEFAULT_PROXY

#define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY   0

Definition at line 99 of file qnetworkproxy_win.cpp.

◆ WINHTTP_ACCESS_TYPE_NAMED_PROXY

#define WINHTTP_ACCESS_TYPE_NAMED_PROXY   3

Definition at line 101 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ WINHTTP_ACCESS_TYPE_NO_PROXY

#define WINHTTP_ACCESS_TYPE_NO_PROXY   1

Definition at line 100 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ WINHTTP_AUTO_DETECT_TYPE_DHCP

#define WINHTTP_AUTO_DETECT_TYPE_DHCP   0x00000001

Definition at line 96 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ WINHTTP_AUTO_DETECT_TYPE_DNS_A

#define WINHTTP_AUTO_DETECT_TYPE_DNS_A   0x00000002

Definition at line 97 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ WINHTTP_AUTOPROXY_AUTO_DETECT

#define WINHTTP_AUTOPROXY_AUTO_DETECT   0x00000001

Definition at line 93 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ WINHTTP_AUTOPROXY_CONFIG_URL

#define WINHTTP_AUTOPROXY_CONFIG_URL   0x00000002

Definition at line 94 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ WINHTTP_ERROR_BASE

#define WINHTTP_ERROR_BASE   12000

Definition at line 106 of file qnetworkproxy_win.cpp.

◆ WINHTTP_NO_PROXY_BYPASS

#define WINHTTP_NO_PROXY_BYPASS   NULL

Definition at line 104 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ WINHTTP_NO_PROXY_NAME

#define WINHTTP_NO_PROXY_NAME   NULL

Definition at line 103 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

Typedef Documentation

◆ PtrCloseServiceHandle

typedef BOOL(WINAPI * PtrCloseServiceHandle) (SC_HANDLE hSCObject)

Definition at line 121 of file qnetworkproxy_win.cpp.

◆ PtrEnumServicesStatusEx

typedef 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)

Definition at line 119 of file qnetworkproxy_win.cpp.

◆ PtrOpenSCManager

typedef SC_HANDLE(WINAPI * PtrOpenSCManager) (LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)

Definition at line 118 of file qnetworkproxy_win.cpp.

◆ PtrWinHttpCloseHandle

typedef BOOL(WINAPI * PtrWinHttpCloseHandle) (HINTERNET)

Definition at line 117 of file qnetworkproxy_win.cpp.

◆ PtrWinHttpGetDefaultProxyConfiguration

typedef BOOL(WINAPI * PtrWinHttpGetDefaultProxyConfiguration) (WINHTTP_PROXY_INFO *)

Definition at line 115 of file qnetworkproxy_win.cpp.

◆ PtrWinHttpGetIEProxyConfigForCurrentUser

typedef BOOL(WINAPI * PtrWinHttpGetIEProxyConfigForCurrentUser) (WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *)

Definition at line 116 of file qnetworkproxy_win.cpp.

◆ PtrWinHttpGetProxyForUrl

typedef BOOL(WINAPI * PtrWinHttpGetProxyForUrl) (HINTERNET, LPCWSTR, WINHTTP_AUTOPROXY_OPTIONS *, WINHTTP_PROXY_INFO *)

Definition at line 113 of file qnetworkproxy_win.cpp.

◆ PtrWinHttpOpen

typedef HINTERNET(WINAPI * PtrWinHttpOpen) (LPCWSTR, DWORD, LPCWSTR, LPCWSTR, DWORD)

Definition at line 114 of file qnetworkproxy_win.cpp.

Function Documentation

◆ currentProcessIsService()

static bool currentProcessIsService ( )
static

Definition at line 132 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

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 }
static mach_timebase_info_data_t info
static PtrEnumServicesStatusEx ptrEnumServicesStatusEx
static PtrCloseServiceHandle ptrCloseServiceHandle
#define SERVICE_ACTIVE
#define SC_MANAGER_ENUMERATE_SERVICE
#define SC_MANAGER_CONNECT
static PtrOpenSCManager ptrOpenSCManager

◆ filterProxyListByCapabilities()

static QList<QNetworkProxy> filterProxyListByCapabilities ( const QList< QNetworkProxy > &  proxyList,
const QNetworkProxyQuery query 
)
static

Definition at line 229 of file qnetworkproxy_win.cpp.

Referenced by parseServerList().

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 }
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
Capabilities capabilities() const
Returns the capabilities of this proxy server.

◆ isBypassed()

static bool isBypassed ( const QString host,
const QStringList bypassList 
)
static

Definition at line 185 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

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 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QHostAddress ip() const
This function returns one IPv4 or IPv6 address found, that was found in a network interface...
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
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...
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...
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.
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
QList< QNetworkAddressEntry > addressEntries() const
Returns the list of IP addresses that this interface possesses along with their associated netmasks a...
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.

◆ parseServerList()

static QList<QNetworkProxy> parseServerList ( const QNetworkProxyQuery query,
const QStringList proxyList 
)
static

Definition at line 274 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

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 }
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
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
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
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 contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
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)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QStringRef leftRef(int n) const Q_REQUIRED_RESULT
Returns a substring reference to the n leftmost characters of the string.
Definition: qstring.cpp:9045
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
QString protocolTag() const
Returns the protocol tag for this QNetworkProxyQuery object, or an empty QString in case the protocol...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
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
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
void clear()
Removes all items from the list.
Definition: qlist.h:764
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
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
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
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
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
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
ProxyType
This enum describes the types of network proxying provided in Qt.

◆ removeDuplicateProxies()

static QList<QNetworkProxy> removeDuplicateProxies ( const QList< QNetworkProxy > &  proxyList)
static

Definition at line 254 of file qnetworkproxy_win.cpp.

Referenced by parseServerList().

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 }
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QNetworkProxy class provides a network layer proxy.
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
quint16 port() const
Returns the port of the proxy host.
QString hostName() const
Returns the host name of the proxy host.

◆ splitSpaceSemicolon()

static QStringList splitSpaceSemicolon ( const QString source)
static

Definition at line 161 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

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 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
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 const KeyPair *const end
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

Variable Documentation

◆ ptrCloseServiceHandle

PtrCloseServiceHandle ptrCloseServiceHandle = 0
static

Definition at line 129 of file qnetworkproxy_win.cpp.

Referenced by currentProcessIsService(), and QWindowsSystemProxy::init().

◆ ptrEnumServicesStatusEx

PtrEnumServicesStatusEx ptrEnumServicesStatusEx = 0
static

Definition at line 128 of file qnetworkproxy_win.cpp.

Referenced by currentProcessIsService(), and QWindowsSystemProxy::init().

◆ ptrOpenSCManager

PtrOpenSCManager ptrOpenSCManager = 0
static

Definition at line 127 of file qnetworkproxy_win.cpp.

Referenced by currentProcessIsService(), and QWindowsSystemProxy::init().

◆ ptrWinHttpCloseHandle

PtrWinHttpCloseHandle ptrWinHttpCloseHandle = 0
static

◆ ptrWinHttpGetDefaultProxyConfiguration

PtrWinHttpGetDefaultProxyConfiguration ptrWinHttpGetDefaultProxyConfiguration = 0
static

Definition at line 124 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ ptrWinHttpGetIEProxyConfigForCurrentUser

PtrWinHttpGetIEProxyConfigForCurrentUser ptrWinHttpGetIEProxyConfigForCurrentUser = 0
static

Definition at line 125 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ ptrWinHttpGetProxyForUrl

PtrWinHttpGetProxyForUrl ptrWinHttpGetProxyForUrl = 0
static

Definition at line 122 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().

◆ ptrWinHttpOpen

PtrWinHttpOpen ptrWinHttpOpen = 0
static

Definition at line 123 of file qnetworkproxy_win.cpp.

Referenced by QWindowsSystemProxy::init().