File: qnetworkproxy.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (88 lines) | stat: -rw-r--r-- 14,809 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?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>QNetworkProxy 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">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QNetworkProxy Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QNetworkProxy class provides a network layer proxy. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qnetworkproxy.html#ProxyType-enum">ProxyType</a></b> { DefaultProxy, Socks5Proxy, NoProxy }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qnetworkproxy.html#QNetworkProxy">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qnetworkproxy.html#QNetworkProxy-2">__init__</a></b> (<i>self</i>, ProxyType&#160;<i>type</i>, QString&#160;<i>hostName</i>&#160;=&#160;QString(), unsigned long&#160;<i>port</i>&#160;=&#160;0, QString&#160;<i>user</i>&#160;=&#160;QString(), QString&#160;<i>password</i>&#160;=&#160;QString())</li><li><div class="fn" /><b><a href="qnetworkproxy.html#QNetworkProxy-3">__init__</a></b> (<i>self</i>, QNetworkProxy&#160;<i>other</i>)</li><li><div class="fn" />QString <b><a href="qnetworkproxy.html#hostName">hostName</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qnetworkproxy.html#password">password</a></b> (<i>self</i>)</li><li><div class="fn" />unsigned long <b><a href="qnetworkproxy.html#port">port</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qnetworkproxy.html#setHostName">setHostName</a></b> (<i>self</i>, QString&#160;<i>hostName</i>)</li><li><div class="fn" /><b><a href="qnetworkproxy.html#setPassword">setPassword</a></b> (<i>self</i>, QString&#160;<i>password</i>)</li><li><div class="fn" /><b><a href="qnetworkproxy.html#setPort">setPort</a></b> (<i>self</i>, unsigned long&#160;<i>port</i>)</li><li><div class="fn" /><b><a href="qnetworkproxy.html#setType">setType</a></b> (<i>self</i>, ProxyType&#160;<i>type</i>)</li><li><div class="fn" /><b><a href="qnetworkproxy.html#setUser">setUser</a></b> (<i>self</i>, QString&#160;<i>userName</i>)</li><li><div class="fn" />ProxyType <b><a href="qnetworkproxy.html#type">type</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qnetworkproxy.html#user">user</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />QNetworkProxy <b><a href="qnetworkproxy.html#applicationProxy">applicationProxy</a></b> ()</li><li><div class="fn" /><b><a href="qnetworkproxy.html#setApplicationProxy">setApplicationProxy</a></b> (QNetworkProxy&#160;<i>proxy</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QNetworkProxy class provides a network layer proxy.</p>
<p>QNetworkProxy provides the method for configuring network layer proxy support to the Qt network classes. The currently supported classes are <a href="qabstractsocket.html">QAbstractSocket</a>, <a href="qtcpsocket.html">QTcpSocket</a>, <a href="qudpsocket.html">QUdpSocket</a>, <a href="qtcpserver.html">QTcpServer</a>, <a href="qhttp.html">QHttp</a> and <a href="qftp.html">QFtp</a>. The proxy support is designed to be as transparent as possible. This means that existing network-enabled applications that you have written should automatically support network proxy using the following code.</p>
<pre>
    QNetworkProxy proxy;
    proxy.setType(QNetworkProxy.Socks5Proxy);
    proxy.setHostName("proxy.example.com");
    proxy.setPort(1080);
    proxy.setUser("username");
    proxy.setPassword("password");
    QNetworkProxy.setApplicationProxy(proxy);
</pre>
<p>An alternative to setting an application wide proxy is to specify the proxy for individual sockets using <a href="qabstractsocket.html#setProxy">QAbstractSocket.setProxy</a>() and <a href="qtcpserver.html#setProxy">QTcpServer.setProxy</a>(). In this way, it is possible to disable the use of a proxy for specific sockets using the following code:</p>
<pre>
    serverSocket-&gt;setProxy(QNetworkProxy.NoProxy);
</pre>
<p>Network proxy is used if the address used in <a href="qabstractsocket.html#connectToHost">connectToHost()</a>, <a href="qudpsocket.html#bind">bind()</a> or <a href="qtcpserver.html#listen">listen()</a> is equivalent to <a href="qhostaddress.html#SpecialAddress-enum">QHostAddress.LocalHost</a> or <a href="qhostaddress.html#SpecialAddress-enum">QHostAddress.LocalHostIPv6</a>.</p>
<p>Each type of proxy support has certain restrictions associated with it. You should read the <a href="qnetworkproxy.html#ProxyType-enum">ProxyType</a> documentation carefully before selecting a proxy type to use.</p>
<a id="socks5" name="socks5" />
<h3>SOCKS5</h3>
<p>The SOCKS5 support in Qt 4 is based on <a href="http://www.rfc-editor.org/rfc/rfc1928.txt">RFC 1928</a> and <a href="http://www.rfc-editor.org/rfc/rfc1929.txt">RFC 1929</a>. The supported authentication methods are no authentication and username/password authentication. Both IPv4 and IPv6 are supported, but domain name resolution via the SOCKS server is not supported; i.e. all domain names are resolved locally. There are several things to remmber when using SOCKS5 with <a href="qudpsocket.html">QUdpSocket</a> and <a href="qtcpserver.html">QTcpServer</a>:</p>
<p>With <a href="qudpsocket.html">QUdpSocket</a>, a call to <a href="qudpsocket.html#bind">bind()</a> may fail with a timeout error. If a port number other than 0 is passed to <a href="qudpsocket.html#bind">bind()</a>, it is not guaranteed that it is the specified port that will be used. Use <a href="qabstractsocket.html#localPort">localPort()</a> and <a href="qabstractsocket.html#localAddress">localAddress()</a> to get the actual address and port number in use. Because proxied UDP goes through two UDP connections, it is more likely that packets will be dropped.</p>
<p>With <a href="qtcpserver.html">QTcpServer</a> a call to <a href="qtcpserver.html#listen">listen()</a> may fail with a timeout error. If a port number other than 0 is passed to <a href="qtcpserver.html#listen">listen()</a>, then it is not guaranteed that it is the specified port that will be used. Use <a href="qtcpserver.html#serverPort">serverPort()</a> and <a href="qtcpserver.html#serverAddress">serverAddress()</a> to get the actual address and port used to listen for connections. SOCKS5 only supports one accepted connection per call to <a href="qtcpserver.html#listen">listen()</a>, and each call is likely to result in a different <a href="qtcpserver.html#serverPort">serverPort()</a> being used.</p>
<p>See also <a href="qabstractsocket.html">QAbstractSocket</a> and <a href="qtcpserver.html">QTcpServer</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="ProxyType-enum" />QNetworkProxy.ProxyType</h3><p>This enum describes the types of network proxying provided in Qt.</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<tr>
<td valign="top"><tt>QNetworkProxy.DefaultProxy</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
<td valign="top">Proxy is determined based on the application proxy set using <a href="qnetworkproxy.html#setApplicationProxy">setApplicationProxy</a>()</td>
</tr>
<tr>
<td valign="top"><tt>QNetworkProxy.Socks5Proxy</tt></td>
<td align="center" valign="top"><tt>1</tt></td>
<td valign="top"><a href="qnetworkproxy.html#socks5">Socks5</a> proxying is used</td>
</tr>
<tr>
<td valign="top"><tt>QNetworkProxy.NoProxy</tt></td>
<td align="center" valign="top"><tt>2</tt></td>
<td valign="top">No proxying is used</td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qnetworkproxy.html#setType">setType</a>() and <a href="qnetworkproxy.html#type">type</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QNetworkProxy" />QNetworkProxy.__init__ (<i>self</i>)</h3><p>Constructs a <a href="qnetworkproxy.html">QNetworkProxy</a> with <a href="qnetworkproxy.html#ProxyType-enum">QNetworkProxy.DefaultProxy</a> type.</p>
<h3 class="fn"><a name="QNetworkProxy-2" />QNetworkProxy.__init__ (<i>self</i>, <a href="qnetworkproxy.html#ProxyType-enum">ProxyType</a>&#160;<i>type</i>, <a href="qstring.html">QString</a>&#160;<i>hostName</i>&#160;=&#160;QString(), unsigned long&#160;<i>port</i>&#160;=&#160;0, <a href="qstring.html">QString</a>&#160;<i>user</i>&#160;=&#160;QString(), <a href="qstring.html">QString</a>&#160;<i>password</i>&#160;=&#160;QString())</h3><p>Constructs a <a href="qnetworkproxy.html">QNetworkProxy</a> with <i>type</i>, <i>hostName</i>, <i>port</i>, <i>user</i> and <i>password</i>.</p>
<h3 class="fn"><a name="QNetworkProxy-3" />QNetworkProxy.__init__ (<i>self</i>, <a href="qnetworkproxy.html">QNetworkProxy</a>&#160;<i>other</i>)</h3><p>Constructs a copy of <i>other</i>.</p>
<h3 class="fn"><a name="applicationProxy" /><a href="qnetworkproxy.html">QNetworkProxy</a> QNetworkProxy.applicationProxy ()</h3><p>Returns the application level network proxying.</p>
<p>If a <a href="qabstractsocket.html">QAbstractSocket</a> or <a href="qtcpsocket.html">QTcpSocket</a> has the <a href="qnetworkproxy.html#ProxyType-enum">QNetworkProxy.DefaultProxy</a> type, then the <a href="qnetworkproxy.html">QNetworkProxy</a> returned by this function is used.</p>
<p>See also <a href="qnetworkproxy.html#setApplicationProxy">setApplicationProxy</a>(), <a href="qabstractsocket.html#proxy">QAbstractSocket.proxy</a>(), and <a href="qtcpserver.html#proxy">QTcpServer.proxy</a>().</p>
<h3 class="fn"><a name="hostName" /><a href="qstring.html">QString</a> QNetworkProxy.hostName (<i>self</i>)</h3><p>Returns the host name of the proxy host.</p>
<p>See also <a href="qnetworkproxy.html#setHostName">setHostName</a>(), <a href="qnetworkproxy.html#setPort">setPort</a>(), and <a href="qnetworkproxy.html#port">port</a>().</p>
<h3 class="fn"><a name="password" /><a href="qstring.html">QString</a> QNetworkProxy.password (<i>self</i>)</h3><p>Returns the password used for authentication.</p>
<p>See also <a href="qnetworkproxy.html#user">user</a>(), <a href="qnetworkproxy.html#setPassword">setPassword</a>(), and <a href="qnetworkproxy.html#setUser">setUser</a>().</p>
<h3 class="fn"><a name="port" />unsigned long QNetworkProxy.port (<i>self</i>)</h3><p>Returns the port of the proxy host.</p>
<p>See also <a href="qnetworkproxy.html#setHostName">setHostName</a>(), <a href="qnetworkproxy.html#setPort">setPort</a>(), and <a href="qnetworkproxy.html#hostName">hostName</a>().</p>
<h3 class="fn"><a name="setApplicationProxy" />QNetworkProxy.setApplicationProxy (<a href="qnetworkproxy.html">QNetworkProxy</a>&#160;<i>proxy</i>)</h3><p>Sets the application level network proxying to be <i>networkProxy</i>.</p>
<p>If a <a href="qabstractsocket.html">QAbstractSocket</a> or <a href="qtcpsocket.html">QTcpSocket</a> has the <a href="qnetworkproxy.html#ProxyType-enum">QNetworkProxy.DefaultProxy</a> type, then the <a href="qnetworkproxy.html">QNetworkProxy</a> set with this function is used.</p>
<p>See also <a href="qnetworkproxy.html#applicationProxy">applicationProxy</a>(), <a href="qabstractsocket.html#setProxy">QAbstractSocket.setProxy</a>(), and <a href="qtcpserver.html#setProxy">QTcpServer.setProxy</a>().</p>
<h3 class="fn"><a name="setHostName" />QNetworkProxy.setHostName (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>hostName</i>)</h3><p>Sets the host name of the proxy host to be <i>hostName</i>.</p>
<p>See also <a href="qnetworkproxy.html#hostName">hostName</a>(), <a href="qnetworkproxy.html#setPort">setPort</a>(), and <a href="qnetworkproxy.html#port">port</a>().</p>
<h3 class="fn"><a name="setPassword" />QNetworkProxy.setPassword (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>password</i>)</h3><p>Sets the password for proxy authentication to be <i>password</i>.</p>
<p>See also <a href="qnetworkproxy.html#user">user</a>(), <a href="qnetworkproxy.html#setUser">setUser</a>(), and <a href="qnetworkproxy.html#password">password</a>().</p>
<h3 class="fn"><a name="setPort" />QNetworkProxy.setPort (<i>self</i>, unsigned long&#160;<i>port</i>)</h3><p>Sets the port of the proxy host to be <i>port</i>.</p>
<p>See also <a href="qnetworkproxy.html#hostName">hostName</a>(), <a href="qnetworkproxy.html#setHostName">setHostName</a>(), and <a href="qnetworkproxy.html#port">port</a>().</p>
<h3 class="fn"><a name="setType" />QNetworkProxy.setType (<i>self</i>, <a href="qnetworkproxy.html#ProxyType-enum">ProxyType</a>&#160;<i>type</i>)</h3><p>Sets the proxy type for this instance to be <i>type</i>.</p>
<p>See also <a href="qnetworkproxy.html#type">type</a>().</p>
<h3 class="fn"><a name="setUser" />QNetworkProxy.setUser (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>userName</i>)</h3><p>Sets the user name for proxy authentication to be <i>user</i>.</p>
<p>See also <a href="qnetworkproxy.html#user">user</a>(), <a href="qnetworkproxy.html#setPassword">setPassword</a>(), and <a href="qnetworkproxy.html#password">password</a>().</p>
<h3 class="fn"><a name="type" /><a href="qnetworkproxy.html#ProxyType-enum">ProxyType</a> QNetworkProxy.type (<i>self</i>)</h3><p>Returns the proxy type for this instance.</p>
<p>See also <a href="qnetworkproxy.html#setType">setType</a>().</p>
<h3 class="fn"><a name="user" /><a href="qstring.html">QString</a> QNetworkProxy.user (<i>self</i>)</h3><p>Returns the user name used for authentication.</p>
<p>See also <a href="qnetworkproxy.html#setUser">setUser</a>(), <a href="qnetworkproxy.html#setPassword">setPassword</a>(), and <a href="qnetworkproxy.html#password">password</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>