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 | #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 | class QNetworkConfiguration; |
58 | |
59 | class QNetworkProxyQueryPrivate; |
60 | class Q_NETWORK_EXPORT QNetworkProxyQuery |
61 | { |
62 | public: |
63 | enum QueryType { |
64 | TcpSocket, |
65 | UdpSocket, |
66 | TcpServer = 100, |
67 | UrlRequest |
68 | }; |
69 | |
70 | QNetworkProxyQuery(); |
71 | QNetworkProxyQuery(const QUrl &requestUrl, QueryType queryType = UrlRequest); |
72 | QNetworkProxyQuery(const QString &hostname, int port, const QString &protocolTag = QString(), |
73 | QueryType queryType = TcpSocket); |
74 | QNetworkProxyQuery(quint16 bindPort, const QString &protocolTag = QString(), |
75 | QueryType queryType = TcpServer); |
76 | QNetworkProxyQuery(const QNetworkProxyQuery &other); |
77 | #ifndef QT_NO_BEARERMANAGEMENT |
78 | QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration, |
79 | const QUrl &requestUrl, QueryType queryType = UrlRequest); |
80 | QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration, |
81 | const QString &hostname, int port, const QString &protocolTag = QString(), |
82 | QueryType queryType = TcpSocket); |
83 | QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration, |
84 | quint16 bindPort, const QString &protocolTag = QString(), |
85 | QueryType queryType = TcpServer); |
86 | #endif |
87 | ~QNetworkProxyQuery(); |
88 | QNetworkProxyQuery &operator=(const QNetworkProxyQuery &other); |
89 | bool operator==(const QNetworkProxyQuery &other) const; |
90 | inline bool operator!=(const QNetworkProxyQuery &other) const |
91 | { return !(*this == other); } |
92 | |
93 | QueryType queryType() const; |
94 | void setQueryType(QueryType type); |
95 | |
96 | int peerPort() const; |
97 | void setPeerPort(int port); |
98 | |
99 | QString peerHostName() const; |
100 | void setPeerHostName(const QString &hostname); |
101 | |
102 | int localPort() const; |
103 | void setLocalPort(int port); |
104 | |
105 | QString protocolTag() const; |
106 | void setProtocolTag(const QString &protocolTag); |
107 | |
108 | QUrl url() const; |
109 | void setUrl(const QUrl &url); |
110 | |
111 | #ifndef QT_NO_BEARERMANAGEMENT |
112 | QNetworkConfiguration networkConfiguration() const; |
113 | void setNetworkConfiguration(const QNetworkConfiguration &networkConfiguration); |
114 | #endif |
115 | |
116 | private: |
117 | QSharedDataPointer<QNetworkProxyQueryPrivate> d; |
118 | }; |
119 | Q_DECLARE_TYPEINFO(QNetworkProxyQuery, Q_MOVABLE_TYPE); |
120 | |
121 | class QNetworkProxyPrivate; |
122 | |
123 | class Q_NETWORK_EXPORT QNetworkProxy |
124 | { |
125 | public: |
126 | enum ProxyType { |
127 | DefaultProxy, |
128 | Socks5Proxy, |
129 | NoProxy, |
130 | HttpProxy, |
131 | HttpCachingProxy, |
132 | FtpCachingProxy |
133 | }; |
134 | |
135 | enum Capability { |
136 | TunnelingCapability = 0x0001, |
137 | ListeningCapability = 0x0002, |
138 | UdpTunnelingCapability = 0x0004, |
139 | CachingCapability = 0x0008, |
140 | HostNameLookupCapability = 0x0010 |
141 | }; |
142 | Q_DECLARE_FLAGS(Capabilities, Capability) |
143 | |
144 | QNetworkProxy(); |
145 | QNetworkProxy(ProxyType type, const QString &hostName = QString(), quint16 port = 0, |
146 | const QString &user = QString(), const QString &password = QString()); |
147 | QNetworkProxy(const QNetworkProxy &other); |
148 | QNetworkProxy &operator=(const QNetworkProxy &other); |
149 | ~QNetworkProxy(); |
150 | bool operator==(const QNetworkProxy &other) const; |
151 | inline bool operator!=(const QNetworkProxy &other) const |
152 | { return !(*this == other); } |
153 | |
154 | void setType(QNetworkProxy::ProxyType type); |
155 | QNetworkProxy::ProxyType type() const; |
156 | |
157 | void setCapabilities(Capabilities capab); |
158 | Capabilities capabilities() const; |
159 | bool isCachingProxy() const; |
160 | bool isTransparentProxy() const; |
161 | |
162 | void setUser(const QString &userName); |
163 | QString user() const; |
164 | |
165 | void setPassword(const QString &password); |
166 | QString password() const; |
167 | |
168 | void setHostName(const QString &hostName); |
169 | QString hostName() const; |
170 | |
171 | void setPort(quint16 port); |
172 | quint16 port() const; |
173 | |
174 | static void setApplicationProxy(const QNetworkProxy &proxy); |
175 | static QNetworkProxy applicationProxy(); |
176 | |
177 | private: |
178 | QSharedDataPointer<QNetworkProxyPrivate> d; |
179 | }; |
180 | Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkProxy::Capabilities) |
181 | |
182 | class Q_NETWORK_EXPORT QNetworkProxyFactory |
183 | { |
184 | public: |
185 | QNetworkProxyFactory(); |
186 | virtual ~QNetworkProxyFactory(); |
187 | |
188 | virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) = 0; |
189 | |
190 | static void setUseSystemConfiguration(bool enable); |
191 | static void setApplicationProxyFactory(QNetworkProxyFactory *factory); |
192 | static QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query); |
193 | static QList<QNetworkProxy> systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery()); |
194 | }; |
195 | |
196 | QT_END_NAMESPACE |
197 | |
198 | QT_END_HEADER |
199 | |
200 | #endif // QT_NO_NETWORKPROXY |
201 | |
202 | #endif // QHOSTINFO_H |
203 | |