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

Last change on this file since 67 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtNetwork module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** 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 are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
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 setApplicationProxyFactory(QNetworkProxyFactory *factory);
175 static QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query);
176 static QList<QNetworkProxy> systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery());
177};
178
179QT_END_NAMESPACE
180
181QT_END_HEADER
182
183#endif // QT_NO_NETWORKPROXY
184
185#endif // QHOSTINFO_H
Note: See TracBrowser for help on using the repository browser.