source: trunk/src/network/kernel/qnetworkproxy.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 5.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 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** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
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
50QT_BEGIN_HEADER
51
52QT_BEGIN_NAMESPACE
53
54QT_MODULE(Network)
55
56class QUrl;
57
58class QNetworkProxyQueryPrivate;
59class Q_NETWORK_EXPORT QNetworkProxyQuery
60{
61public:
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
100private:
101 QSharedDataPointer<QNetworkProxyQueryPrivate> d;
102};
103Q_DECLARE_TYPEINFO(QNetworkProxyQuery, Q_MOVABLE_TYPE);
104
105class QNetworkProxyPrivate;
106
107class Q_NETWORK_EXPORT QNetworkProxy
108{
109public:
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
161private:
162 QSharedDataPointer<QNetworkProxyPrivate> d;
163};
164Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkProxy::Capabilities)
165
166class Q_NETWORK_EXPORT QNetworkProxyFactory
167{
168public:
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
180QT_END_NAMESPACE
181
182QT_END_HEADER
183
184#endif // QT_NO_NETWORKPROXY
185
186#endif // QHOSTINFO_H
Note: See TracBrowser for help on using the repository browser.