- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qnetworkproxy.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtNetwork module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QNETWORKPROXY_H
    00043 #define QNETWORKPROXY_H
    00044
    00045 #include <QtNetwork/qhostaddress.h>
    00046 #include <QtCore/qshareddata.h>
    00047
    00048 #ifndef QT_NO_NETWORKPROXY
    00049
    00050 QT_BEGIN_HEADER
    00051
    00052 QT_BEGIN_NAMESPACE
    00053
    00054 QT_MODULE(Network)
    00055
    00056 class QUrl;
    00057
    00058 class QNetworkProxyQueryPrivate;
    00059 class Q_NETWORK_EXPORT QNetworkProxyQuery
    00060 {
    00061 public:
    00062     enum QueryType {
    00063         TcpSocket,
    00064         UdpSocket,
    00065         TcpServer = 100,
    00066         UrlRequest
    00067     };
    00068
    00069     QNetworkProxyQuery();
    00070     QNetworkProxyQuery(const QUrl &requestUrl, QueryType queryType = UrlRequest);
    00071     QNetworkProxyQuery(const QString &hostname, int port, const QString &protocolTag = QString(),
    00072                        QueryType queryType = TcpSocket);
    00073     QNetworkProxyQuery(quint16 bindPort, const QString &protocolTag = QString(),
    00074                        QueryType queryType = TcpServer);
    00075     QNetworkProxyQuery(const QNetworkProxyQuery &other);
    00076     ~QNetworkProxyQuery();
    00077     QNetworkProxyQuery &operator=(const QNetworkProxyQuery &other);
    00078     bool operator==(const QNetworkProxyQuery &other) const;
    00079     inline bool operator!=(const QNetworkProxyQuery &other) const
    00080     { return !(*this == other); }
    00081
    00082     QueryType queryType() const;
    00083     void setQueryType(QueryType type);
    00084
    00085     int peerPort() const;
    00086     void setPeerPort(int port);
    00087
    00088     QString peerHostName() const;
    00089     void setPeerHostName(const QString &hostname);
    00090
    00091     int localPort() const;
    00092     void setLocalPort(int port);
    00093
    00094     QString protocolTag() const;
    00095     void setProtocolTag(const QString &protocolTag);
    00096
    00097     QUrl url() const;
    00098     void setUrl(const QUrl &url);
    00099
    00100 private:
    00101     QSharedDataPointer<QNetworkProxyQueryPrivate> d;
    00102 };
    00103 Q_DECLARE_TYPEINFO(QNetworkProxyQuery, Q_MOVABLE_TYPE);
    00104
    00105 class QNetworkProxyPrivate;
    00106
    00107 class Q_NETWORK_EXPORT QNetworkProxy
    00108 {
    00109 public:
    00110     enum ProxyType {
    00111         DefaultProxy,
    00112         Socks5Proxy,
    00113         NoProxy,
    00114         HttpProxy,
    00115         HttpCachingProxy,
    00116         FtpCachingProxy
    00117     };
    00118
    00119     enum Capability {
    00120         TunnelingCapability = 0x0001,
    00121         ListeningCapability = 0x0002,
    00122         UdpTunnelingCapability = 0x0004,
    00123         CachingCapability = 0x0008,
    00124         HostNameLookupCapability = 0x0010
    00125     };
    00126     Q_DECLARE_FLAGS(Capabilities, Capability)
    00127
    00128     QNetworkProxy();
    00129     QNetworkProxy(ProxyType type, const QString &hostName = QString(), quint16 port = 0,
    00130                   const QString &user = QString(), const QString &password = QString());
    00131     QNetworkProxy(const QNetworkProxy &other);
    00132     QNetworkProxy &operator=(const QNetworkProxy &other);
    00133     ~QNetworkProxy();
    00134     bool operator==(const QNetworkProxy &other) const;
    00135     inline bool operator!=(const QNetworkProxy &other) const
    00136     { return !(*this == other); }
    00137
    00138     void setType(QNetworkProxy::ProxyType type);
    00139     QNetworkProxy::ProxyType type() const;
    00140
    00141     void setCapabilities(Capabilities capab);
    00142     Capabilities capabilities() const;
    00143     bool isCachingProxy() const;
    00144     bool isTransparentProxy() const;
    00145
    00146     void setUser(const QString &userName);
    00147     QString user() const;
    00148
    00149     void setPassword(const QString &password);
    00150     QString password() const;
    00151
    00152     void setHostName(const QString &hostName);
    00153     QString hostName() const;
    00154
    00155     void setPort(quint16 port);
    00156     quint16 port() const;
    00157
    00158     static void setApplicationProxy(const QNetworkProxy &proxy);
    00159     static QNetworkProxy applicationProxy();
    00160
    00161 private:
    00162     QSharedDataPointer<QNetworkProxyPrivate> d;
    00163 };
    00164 Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkProxy::Capabilities)
    00165
    00166 class Q_NETWORK_EXPORT QNetworkProxyFactory
    00167 {
    00168 public:
    00169     QNetworkProxyFactory();
    00170     virtual ~QNetworkProxyFactory();
    00171
    00172     virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) = 0;
    00173
    00174     static void setUseSystemConfiguration(bool enable);
    00175     static void setApplicationProxyFactory(QNetworkProxyFactory *factory);
    00176     static QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query);
    00177     static QList<QNetworkProxy> systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery());
    00178 };
    00179
    00180 QT_END_NAMESPACE
    00181
    00182 QT_END_HEADER
    00183
    00184 #endif // QT_NO_NETWORKPROXY
    00185
    00186 #endif // QHOSTINFO_H