|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtNetwork module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QNETWORKPROXY_H |
|
43 #define QNETWORKPROXY_H |
|
44 |
|
45 #include <QtNetwork/qhostaddress.h> |
|
46 #include <QtCore/qshareddata.h> |
|
47 |
|
48 #ifndef QT_NO_NETWORKPROXY |
|
49 |
|
50 QT_BEGIN_HEADER |
|
51 |
|
52 QT_BEGIN_NAMESPACE |
|
53 |
|
54 QT_MODULE(Network) |
|
55 |
|
56 class QUrl; |
|
57 |
|
58 class QNetworkProxyQueryPrivate; |
|
59 class Q_NETWORK_EXPORT QNetworkProxyQuery |
|
60 { |
|
61 public: |
|
62 enum QueryType { |
|
63 TcpSocket, |
|
64 UdpSocket, |
|
65 TcpServer = 100, |
|
66 UrlRequest |
|
67 }; |
|
68 |
|
69 QNetworkProxyQuery(); |
|
70 QNetworkProxyQuery(const QUrl &requestUrl, QueryType queryType = UrlRequest); |
|
71 QNetworkProxyQuery(const QString &hostname, int port, const QString &protocolTag = QString(), |
|
72 QueryType queryType = TcpSocket); |
|
73 QNetworkProxyQuery(quint16 bindPort, const QString &protocolTag = QString(), |
|
74 QueryType queryType = TcpServer); |
|
75 QNetworkProxyQuery(const QNetworkProxyQuery &other); |
|
76 ~QNetworkProxyQuery(); |
|
77 QNetworkProxyQuery &operator=(const QNetworkProxyQuery &other); |
|
78 bool operator==(const QNetworkProxyQuery &other) const; |
|
79 inline bool operator!=(const QNetworkProxyQuery &other) const |
|
80 { return !(*this == other); } |
|
81 |
|
82 QueryType queryType() const; |
|
83 void setQueryType(QueryType type); |
|
84 |
|
85 int peerPort() const; |
|
86 void setPeerPort(int port); |
|
87 |
|
88 QString peerHostName() const; |
|
89 void setPeerHostName(const QString &hostname); |
|
90 |
|
91 int localPort() const; |
|
92 void setLocalPort(int port); |
|
93 |
|
94 QString protocolTag() const; |
|
95 void setProtocolTag(const QString &protocolTag); |
|
96 |
|
97 QUrl url() const; |
|
98 void setUrl(const QUrl &url); |
|
99 |
|
100 private: |
|
101 QSharedDataPointer<QNetworkProxyQueryPrivate> d; |
|
102 }; |
|
103 Q_DECLARE_TYPEINFO(QNetworkProxyQuery, Q_MOVABLE_TYPE); |
|
104 |
|
105 class QNetworkProxyPrivate; |
|
106 |
|
107 class Q_NETWORK_EXPORT QNetworkProxy |
|
108 { |
|
109 public: |
|
110 enum ProxyType { |
|
111 DefaultProxy, |
|
112 Socks5Proxy, |
|
113 NoProxy, |
|
114 HttpProxy, |
|
115 HttpCachingProxy, |
|
116 FtpCachingProxy |
|
117 }; |
|
118 |
|
119 enum Capability { |
|
120 TunnelingCapability = 0x0001, |
|
121 ListeningCapability = 0x0002, |
|
122 UdpTunnelingCapability = 0x0004, |
|
123 CachingCapability = 0x0008, |
|
124 HostNameLookupCapability = 0x0010 |
|
125 }; |
|
126 Q_DECLARE_FLAGS(Capabilities, Capability) |
|
127 |
|
128 QNetworkProxy(); |
|
129 QNetworkProxy(ProxyType type, const QString &hostName = QString(), quint16 port = 0, |
|
130 const QString &user = QString(), const QString &password = QString()); |
|
131 QNetworkProxy(const QNetworkProxy &other); |
|
132 QNetworkProxy &operator=(const QNetworkProxy &other); |
|
133 ~QNetworkProxy(); |
|
134 bool operator==(const QNetworkProxy &other) const; |
|
135 inline bool operator!=(const QNetworkProxy &other) const |
|
136 { return !(*this == other); } |
|
137 |
|
138 void setType(QNetworkProxy::ProxyType type); |
|
139 QNetworkProxy::ProxyType type() const; |
|
140 |
|
141 void setCapabilities(Capabilities capab); |
|
142 Capabilities capabilities() const; |
|
143 bool isCachingProxy() const; |
|
144 bool isTransparentProxy() const; |
|
145 |
|
146 void setUser(const QString &userName); |
|
147 QString user() const; |
|
148 |
|
149 void setPassword(const QString &password); |
|
150 QString password() const; |
|
151 |
|
152 void setHostName(const QString &hostName); |
|
153 QString hostName() const; |
|
154 |
|
155 void setPort(quint16 port); |
|
156 quint16 port() const; |
|
157 |
|
158 static void setApplicationProxy(const QNetworkProxy &proxy); |
|
159 static QNetworkProxy applicationProxy(); |
|
160 |
|
161 private: |
|
162 QSharedDataPointer<QNetworkProxyPrivate> d; |
|
163 }; |
|
164 Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkProxy::Capabilities) |
|
165 |
|
166 class Q_NETWORK_EXPORT QNetworkProxyFactory |
|
167 { |
|
168 public: |
|
169 QNetworkProxyFactory(); |
|
170 virtual ~QNetworkProxyFactory(); |
|
171 |
|
172 virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) = 0; |
|
173 |
|
174 static void setUseSystemConfiguration(bool enable); |
|
175 static void setApplicationProxyFactory(QNetworkProxyFactory *factory); |
|
176 static QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query); |
|
177 static QList<QNetworkProxy> systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery()); |
|
178 }; |
|
179 |
|
180 QT_END_NAMESPACE |
|
181 |
|
182 QT_END_HEADER |
|
183 |
|
184 #endif // QT_NO_NETWORKPROXY |
|
185 |
|
186 #endif // QHOSTINFO_H |