| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 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 [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 |
|
|---|
| 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 |
|
|---|
|
|---|