qnetworkaccessmanager.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 QNETWORKACCESSMANAGER_H
00043 #define QNETWORKACCESSMANAGER_H
00044 
00045 #include <QtCore/QObject>
00046 
00047 QT_BEGIN_HEADER
00048 
00049 QT_BEGIN_NAMESPACE
00050 
00051 QT_MODULE(Network)
00052 
00053 class QIODevice;
00054 class QAbstractNetworkCache;
00055 class QAuthenticator;
00056 class QByteArray;
00057 template<typename T> class QList;
00058 class QNetworkCookie;
00059 class QNetworkCookieJar;
00060 class QNetworkRequest;
00061 class QNetworkReply;
00062 class QNetworkProxy;
00063 class QNetworkProxyFactory;
00064 class QSslError;
00065 #if !defined(QT_NO_BEARERMANAGEMENT) && !defined(QT_MOBILITY_BEARER)
00066 class QNetworkConfiguration;
00067 #endif
00068 
00069 class QNetworkReplyImplPrivate;
00070 class QNetworkAccessManagerPrivate;
00071 class Q_NETWORK_EXPORT QNetworkAccessManager: public QObject
00072 {
00073     Q_OBJECT
00074 
00075 #ifndef QT_NO_BEARERMANAGEMENT
00076     Q_PROPERTY(NetworkAccessibility networkAccessible READ networkAccessible WRITE setNetworkAccessible NOTIFY networkAccessibleChanged)
00077 #endif
00078 
00079 public:
00080     enum Operation {
00081         HeadOperation = 1,
00082         GetOperation,
00083         PutOperation,
00084         PostOperation,
00085         DeleteOperation,
00086         CustomOperation,
00087 
00088         UnknownOperation = 0
00089     };
00090 
00091 #ifndef QT_NO_BEARERMANAGEMENT
00092     enum NetworkAccessibility {
00093         UnknownAccessibility = -1,
00094         NotAccessible = 0,
00095         Accessible = 1
00096     };
00097 #endif
00098 
00099     explicit QNetworkAccessManager(QObject *parent = 0);
00100     ~QNetworkAccessManager();
00101 
00102 #ifndef QT_NO_NETWORKPROXY
00103     QNetworkProxy proxy() const;
00104     void setProxy(const QNetworkProxy &proxy);
00105     QNetworkProxyFactory *proxyFactory() const;
00106     void setProxyFactory(QNetworkProxyFactory *factory);
00107 #endif
00108 
00109     QAbstractNetworkCache *cache() const;
00110     void setCache(QAbstractNetworkCache *cache);
00111 
00112     QNetworkCookieJar *cookieJar() const;
00113     void setCookieJar(QNetworkCookieJar *cookieJar);
00114 
00115     QNetworkReply *head(const QNetworkRequest &request);
00116     QNetworkReply *get(const QNetworkRequest &request);
00117     QNetworkReply *post(const QNetworkRequest &request, QIODevice *data);
00118     QNetworkReply *post(const QNetworkRequest &request, const QByteArray &data);
00119     QNetworkReply *put(const QNetworkRequest &request, QIODevice *data);
00120     QNetworkReply *put(const QNetworkRequest &request, const QByteArray &data);
00121     QNetworkReply *deleteResource(const QNetworkRequest &request);
00122     QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data = 0);
00123 
00124 #if !defined(QT_NO_BEARERMANAGEMENT) && !defined(QT_MOBILITY_BEARER)
00125     void setConfiguration(const QNetworkConfiguration &config);
00126     QNetworkConfiguration configuration() const;
00127     QNetworkConfiguration activeConfiguration() const;
00128 #endif
00129 
00130 #ifndef QT_NO_BEARERMANAGEMENT
00131     void setNetworkAccessible(NetworkAccessibility accessible);
00132     NetworkAccessibility networkAccessible() const;
00133 #endif
00134 
00135 Q_SIGNALS:
00136 #ifndef QT_NO_NETWORKPROXY
00137     void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
00138 #endif
00139     void authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);
00140     void finished(QNetworkReply *reply);
00141 #ifndef QT_NO_OPENSSL
00142     void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
00143 #endif
00144 
00145 #if !defined(QT_NO_BEARERMANAGEMENT) && !defined(QT_MOBILITY_BEARER)
00146     void networkSessionConnected();
00147 #endif
00148 
00149 #ifndef QT_NO_BEARERMANAGEMENT
00150     void networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible);
00151 #endif
00152 
00153 protected:
00154     virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
00155                                          QIODevice *outgoingData = 0);
00156 
00157 private:
00158     friend class QNetworkReplyImplPrivate;
00159     Q_DECLARE_PRIVATE(QNetworkAccessManager)
00160     Q_PRIVATE_SLOT(d_func(), void _q_replyFinished())
00161     Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
00162 #if !defined(QT_NO_BEARERMANAGEMENT) && !defined(QT_MOBILITY_BEARER)
00163     Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed())
00164     Q_PRIVATE_SLOT(d_func(), void _q_networkSessionNewConfigurationActivated())
00165     Q_PRIVATE_SLOT(d_func(), void _q_networkSessionPreferredConfigurationChanged(QNetworkConfiguration,bool))
00166     Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State))
00167 #endif
00168 };
00169 
00170 QT_END_NAMESPACE
00171 
00172 QT_END_HEADER
00173 
00174 #endif