1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtNetwork module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QNETWORKACCESSMANAGER_H
43 #define QNETWORKACCESSMANAGER_H
45 #include <QtCore/QObject>
53 class QAbstractNetworkCache;
56 template<typename T> class QList;
58 class QNetworkCookieJar;
59 class QNetworkRequest;
62 class QNetworkProxyFactory;
64 #ifndef QT_NO_BEARERMANAGEMENT
65 class QNetworkConfiguration;
69 class QNetworkReplyImplPrivate;
70 class QNetworkAccessManagerPrivate;
71 class Q_NETWORK_EXPORT QNetworkAccessManager: public QObject
75 #ifndef QT_NO_BEARERMANAGEMENT
76 Q_PROPERTY(NetworkAccessibility networkAccessible READ networkAccessible WRITE setNetworkAccessible NOTIFY networkAccessibleChanged)
91 #ifndef QT_NO_BEARERMANAGEMENT
92 enum NetworkAccessibility {
93 UnknownAccessibility = -1,
99 explicit QNetworkAccessManager(QObject *parent = 0);
100 ~QNetworkAccessManager();
102 void clearAccessCache();
104 #ifndef QT_NO_NETWORKPROXY
105 QNetworkProxy proxy() const;
106 void setProxy(const QNetworkProxy &proxy);
107 QNetworkProxyFactory *proxyFactory() const;
108 void setProxyFactory(QNetworkProxyFactory *factory);
111 QAbstractNetworkCache *cache() const;
112 void setCache(QAbstractNetworkCache *cache);
114 QNetworkCookieJar *cookieJar() const;
115 void setCookieJar(QNetworkCookieJar *cookieJar);
117 QNetworkReply *head(const QNetworkRequest &request);
118 QNetworkReply *get(const QNetworkRequest &request);
119 QNetworkReply *post(const QNetworkRequest &request, QIODevice *data);
120 QNetworkReply *post(const QNetworkRequest &request, const QByteArray &data);
121 QNetworkReply *post(const QNetworkRequest &request, QHttpMultiPart *multiPart);
122 QNetworkReply *put(const QNetworkRequest &request, QIODevice *data);
123 QNetworkReply *put(const QNetworkRequest &request, const QByteArray &data);
124 QNetworkReply *put(const QNetworkRequest &request, QHttpMultiPart *multiPart);
125 QNetworkReply *deleteResource(const QNetworkRequest &request);
126 QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data = 0);
128 #ifndef QT_NO_BEARERMANAGEMENT
129 void setConfiguration(const QNetworkConfiguration &config);
130 QNetworkConfiguration configuration() const;
131 QNetworkConfiguration activeConfiguration() const;
133 void setNetworkAccessible(NetworkAccessibility accessible);
134 NetworkAccessibility networkAccessible() const;
138 #ifndef QT_NO_NETWORKPROXY
139 void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
141 void authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);
142 void finished(QNetworkReply *reply);
144 void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
147 #ifndef QT_NO_BEARERMANAGEMENT
148 void networkSessionConnected();
150 void networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible);
154 virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
155 QIODevice *outgoingData = 0);
158 friend class QNetworkReplyImplPrivate;
159 friend class QNetworkReplyHttpImpl;
160 friend class QNetworkReplyHttpImplPrivate;
162 Q_DECLARE_PRIVATE(QNetworkAccessManager)
163 Q_PRIVATE_SLOT(d_func(), void _q_replyFinished())
164 Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
165 #ifndef QT_NO_BEARERMANAGEMENT
166 Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed())
167 Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State))