Qt 4.8
qnetworkproxy.h
Go to the documentation of this file.
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 
51 
53 
54 QT_MODULE(Network)
55 
56 class QUrl;
58 
61 {
62 public:
63  enum QueryType {
66  TcpServer = 100,
67  UrlRequest
68  };
69 
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);
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
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:
118 };
120 
122 
124 {
125 public:
126  enum ProxyType {
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);
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:
179 };
180 Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkProxy::Capabilities)
181 
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 
197 
199 
200 #endif // QT_NO_NETWORKPROXY
201 
202 #endif // QHOSTINFO_H
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
QSharedDataPointer< QNetworkProxyPrivate > d
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QNetworkProxyFactory class provides fine-grained proxy selection.
QueryType
Describes the type of one QNetworkProxyQuery query.
Definition: qnetworkproxy.h:63
bool operator!=(const QNetworkProxyQuery &other) const
Returns true if this QNetworkProxyQuery object does not contain the same data as other.
Definition: qnetworkproxy.h:90
The QNetworkProxy class provides a network layer proxy.
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QSharedDataPointer< QNetworkProxyQueryPrivate > d
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
Capability
These flags indicate the capabilities that a given proxy server supports.
unsigned short quint16
Definition: qglobal.h:936
The QNetworkProxyQuery class is used to query the proxy settings for a socket.
Definition: qnetworkproxy.h:60
Q_DECLARE_TYPEINFO(QNetworkProxyQuery, Q_MOVABLE_TYPE)
#define Q_NETWORK_EXPORT
Definition: qglobal.h:1452
#define class
#define QT_END_HEADER
Definition: qglobal.h:137
bool operator==(QBool b1, bool b2)
Definition: qglobal.h:2023
bool operator!=(const QNetworkProxy &other) const
Compares the value of this network proxy to other and returns true if they differ.
ProxyType
This enum describes the types of network proxying provided in Qt.