<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QNetworkProxyFactory Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QNetworkProxyFactory Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QNetworkProxyFactory class provides fine-grained proxy selection. <a href="#details">More...</a></p> <h3>Methods</h3><ul><li><div class="fn" /><b><a href="qnetworkproxyfactory.html#QNetworkProxyFactory">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qnetworkproxyfactory.html#QNetworkProxyFactory-2">__init__</a></b> (<i>self</i>, QNetworkProxyFactory)</li><li><div class="fn" />list-of-QNetworkProxy <b><a href="qnetworkproxyfactory.html#queryProxy">queryProxy</a></b> (<i>self</i>, QNetworkProxyQuery <i>query</i> = QNetworkProxyQuery())</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />list-of-QNetworkProxy <b><a href="qnetworkproxyfactory.html#proxyForQuery">proxyForQuery</a></b> (QNetworkProxyQuery <i>query</i>)</li><li><div class="fn" /><b><a href="qnetworkproxyfactory.html#setApplicationProxyFactory">setApplicationProxyFactory</a></b> (QNetworkProxyFactory <i>factory</i>)</li><li><div class="fn" /><b><a href="qnetworkproxyfactory.html#setUseSystemConfiguration">setUseSystemConfiguration</a></b> (bool <i>enable</i>)</li><li><div class="fn" />list-of-QNetworkProxy <b><a href="qnetworkproxyfactory.html#systemProxyForQuery">systemProxyForQuery</a></b> (QNetworkProxyQuery <i>query</i> = QNetworkProxyQuery())</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QNetworkProxyFactory class provides fine-grained proxy selection.</p> <p>QNetworkProxyFactory is an extension to <a href="qnetworkproxy.html">QNetworkProxy</a>, allowing applications to have a more fine-grained control over which proxy servers are used, depending on the socket requesting the proxy. This allows an application to apply different settings, according to the protocol or destination hostname, for instance.</p> <p>QNetworkProxyFactory can be set globally for an application, in which case it will override any global proxies set with <a href="qnetworkproxy.html#setApplicationProxy">QNetworkProxy.setApplicationProxy</a>(). If set globally, any sockets created with Qt will query the factory to determine the proxy to be used.</p> <p>A factory can also be set in certain frameworks that support multiple connections, such as <a href="qnetworkaccessmanager.html">QNetworkAccessManager</a>. When set on such object, the factory will be queried for sockets created by that framework only.</p> <a id="system-proxies" name="system-proxies" /> <h3>System Proxies</h3> <p>You can configure a factory to use the system proxy's settings. Call the <a href="qnetworkproxyfactory.html#setUseSystemConfiguration">setUseSystemConfiguration</a>() function with true to enable this behavior, or false to disable it.</p> <p>Similarly, you can use a factory to make queries directly to the system proxy by calling its <a href="qnetworkproxyfactory.html#systemProxyForQuery">systemProxyForQuery</a>() function.</p> <p><b>Warning:</b> Depending on the configuration of the user's system, the use of system proxy features on certain platforms may be subject to limitations. The <a href="qnetworkproxyfactory.html#systemProxyForQuery">systemProxyForQuery</a>() documentation contains a list of these limitations for those platforms that are affected.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QNetworkProxyFactory" />QNetworkProxyFactory.__init__ (<i>self</i>)</h3><p>Creates a <a href="qnetworkproxyfactory.html">QNetworkProxyFactory</a> object.</p> <p>Since <a href="qnetworkproxyfactory.html">QNetworkProxyFactory</a> is an abstract class, you cannot create objects of type <a href="qnetworkproxyfactory.html">QNetworkProxyFactory</a> directly.</p> <h3 class="fn"><a name="QNetworkProxyFactory-2" />QNetworkProxyFactory.__init__ (<i>self</i>, <a href="qnetworkproxyfactory.html">QNetworkProxyFactory</a>)</h3><h3 class="fn"><a name="proxyForQuery" />list-of-QNetworkProxy QNetworkProxyFactory.proxyForQuery (<a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> <i>query</i>)</h3><p>This function takes the query request, <i>query</i>, examines the details of the type of socket or request and returns a list of <a href="qnetworkproxy.html">QNetworkProxy</a> objects that indicate the proxy servers to be used, in order of preference.</p> <h3 class="fn"><a name="queryProxy" />list-of-QNetworkProxy QNetworkProxyFactory.queryProxy (<i>self</i>, <a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> <i>query</i> = QNetworkProxyQuery())</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This function takes the query request, <i>query</i>, examines the details of the type of socket or request and returns a list of <a href="qnetworkproxy.html">QNetworkProxy</a> objects that indicate the proxy servers to be used, in order of preference.</p> <p>When reimplementing this class, take care to return at least one element.</p> <p>If you cannot determine a better proxy alternative, use <a href="qnetworkproxy.html#ProxyType-enum">QNetworkProxy.DefaultProxy</a>, which tells the code querying for a proxy to use a higher alternative. For example, if this factory is set to a <a href="qnetworkaccessmanager.html">QNetworkAccessManager</a> object, DefaultProxy will tell it to query the application-level proxy settings.</p> <p>If this factory is set as the application proxy factory, DefaultProxy and NoProxy will have the same meaning.</p> <h3 class="fn"><a name="setApplicationProxyFactory" />QNetworkProxyFactory.setApplicationProxyFactory (<a href="qnetworkproxyfactory.html">QNetworkProxyFactory</a> <i>factory</i>)</h3><p>The <i>factory</i> argument has it's ownership transferred to Qt.</p><p>Sets the application-wide proxy factory to be <i>factory</i>. This function will take ownership of that object and will delete it when necessary.</p> <p>The application-wide proxy is used as a last-resort when all other proxy selection requests returned <a href="qnetworkproxy.html#ProxyType-enum">QNetworkProxy.DefaultProxy</a>. For example, <a href="qtcpsocket.html">QTcpSocket</a> objects can have a proxy set with QTcpSocket.setProxy, but if none is set, the proxy factory class set with this function will be queried.</p> <p>If you set a proxy factory with this function, any application level proxies set with QNetworkProxy.setApplicationProxy will be overridden.</p> <p><b>See also</b> <a href="qnetworkproxy.html#setApplicationProxy">QNetworkProxy.setApplicationProxy</a>(), <a href="qabstractsocket.html#proxy">QAbstractSocket.proxy</a>(), and <a href="qabstractsocket.html#setProxy">QAbstractSocket.setProxy</a>().</p> <h3 class="fn"><a name="setUseSystemConfiguration" />QNetworkProxyFactory.setUseSystemConfiguration (bool <i>enable</i>)</h3><p>Enables the use of the platform-specific proxy settings, and only those. See <a href="qnetworkproxyfactory.html#systemProxyForQuery">systemProxyForQuery</a>() for more information.</p> <p>Internally, this method (when called with <i>enable</i> set to true) sets an application-wide proxy factory. For this reason, this method is mutually exclusive with <a href="qnetworkproxyfactory.html#setApplicationProxyFactory">setApplicationProxyFactory</a>(): calling <a href="qnetworkproxyfactory.html#setApplicationProxyFactory">setApplicationProxyFactory</a>() overrides the use of the system-wide proxy, and calling setUseSystemConfiguration() overrides any application proxy or proxy factory that was previously set.</p> <p><b>Note:</b> See the <a href="qnetworkproxyfactory.html#systemProxyForQuery">systemProxyForQuery</a>() documentation for a list of limitations related to the use of system proxies.</p> <p>This function was introduced in Qt 4.6.</p> <h3 class="fn"><a name="systemProxyForQuery" />list-of-QNetworkProxy QNetworkProxyFactory.systemProxyForQuery (<a href="qnetworkproxyquery.html">QNetworkProxyQuery</a> <i>query</i> = QNetworkProxyQuery())</h3><p>This function takes the query request, <i>query</i>, examines the details of the type of socket or request and returns a list of <a href="qnetworkproxy.html">QNetworkProxy</a> objects that indicate the proxy servers to be used, in order of preference.</p> <p>This function can be used to determine the platform-specific proxy settings. This function will use the libraries provided by the operating system to determine the proxy for a given connection, if such libraries exist. If they don't, this function will just return a <a href="qnetworkproxy.html">QNetworkProxy</a> of type <a href="qnetworkproxy.html#ProxyType-enum">QNetworkProxy.NoProxy</a>.</p> <p>On Windows, this function will use the WinHTTP DLL functions. Despite its name, Microsoft suggests using it for all applications that require network connections, not just HTTP. This will respect the proxy settings set on the registry with the proxycfg.exe tool. If those settings are not found, this function will attempt to obtain Internet Explorer's settings and use them.</p> <p>On MacOS X, this function will obtain the proxy settings using the SystemConfiguration framework from Apple. It will apply the FTP, HTTP and HTTPS proxy configurations for queries that contain the protocol tag "ftp", "http" and "https", respectively. If the SOCKS proxy is enabled in that configuration, this function will use the SOCKS server for all queries. If SOCKS isn't enabled, it will use the HTTPS proxy for all TcpSocket and UrlRequest queries.</p> <p>On BlackBerry, this function obtains proxy settings for the default configuration using system configuration. The type will be set based on protocol tag "http", "https", "ftp", respectively. By default, it assumes http type. Proxy username and password are also set during the query using system configuration.</p> <p>On other systems, this function will pick up proxy settings from the "http_proxy" environment variable. This variable must be a URL using one of the following schemes: "http", "socks5" or "socks5h".</p> <a id="limitations" name="limitations" /> <h4>Limitations</h4> <p>These are the limitations for the current version of this function. Future versions of Qt may lift some of the limitations listed here.</p> <ul> <li>On MacOS X, this function will ignore the Proxy Auto Configuration settings, since it cannot execute the associated ECMAScript code.</li> <li>On Windows platforms, this function may take several seconds to execute depending on the configuration of the user's system. <p><b class="redFont"><code>\li</code></b>On BlackBerry, only UrlRequest and TcpSocket queries are supported. SOCKS is not supported. The proxy credentials are only retrieved for the default configuration.</p> </li> </ul> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>