1/****************************************************************************
2**
3** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/
5**
6** This file is part of the QtNetwork module of the Qt Toolkit.
7**
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.
16**
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.
20**
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.
28**
29** Other Usage
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.
32**
33**
34**
35**
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QNETWORKACCESSMANAGER_H
43#define QNETWORKACCESSMANAGER_H
44
45#include <QtCore/QObject>
46
47QT_BEGIN_HEADER
48
49QT_BEGIN_NAMESPACE
50
51QT_MODULE(Network)
52
53class QIODevice;
54class QAbstractNetworkCache;
55class QAuthenticator;
56class QByteArray;
57template<typename T> class QList;
58class QNetworkCookie;
59class QNetworkCookieJar;
60class QNetworkRequest;
61class QNetworkReply;
62class QNetworkProxy;
63class QNetworkProxyFactory;
64class QSslError;
65#if !defined(QT_NO_BEARERMANAGEMENT) && !defined(QT_MOBILITY_BEARER)
66class QNetworkConfiguration;
67#endif
68class QHttpMultiPart;
69
70class QNetworkReplyImplPrivate;
71class QNetworkAccessManagerPrivate;
72class Q_NETWORK_EXPORT QNetworkAccessManager: public QObject
73{
74 Q_OBJECT
75
76#ifndef QT_NO_BEARERMANAGEMENT
77 Q_PROPERTY(NetworkAccessibility networkAccessible READ networkAccessible WRITE setNetworkAccessible NOTIFY networkAccessibleChanged)
78#endif
79
80public:
81 enum Operation {
82 HeadOperation = 1,
83 GetOperation,
84 PutOperation,
85 PostOperation,
86 DeleteOperation,
87 CustomOperation,
88
89 UnknownOperation = 0
90 };
91
92#ifndef QT_NO_BEARERMANAGEMENT
93 enum NetworkAccessibility {
94 UnknownAccessibility = -1,
95 NotAccessible = 0,
96 Accessible = 1
97 };
98#endif
99
100 explicit QNetworkAccessManager(QObject *parent = 0);
101 ~QNetworkAccessManager();
102
103#ifndef QT_NO_NETWORKPROXY
104 QNetworkProxy proxy() const;
105 void setProxy(const QNetworkProxy &proxy);
106 QNetworkProxyFactory *proxyFactory() const;
107 void setProxyFactory(QNetworkProxyFactory *factory);
108#endif
109
110 QAbstractNetworkCache *cache() const;
111 void setCache(QAbstractNetworkCache *cache);
112
113 QNetworkCookieJar *cookieJar() const;
114 void setCookieJar(QNetworkCookieJar *cookieJar);
115
116 QNetworkReply *head(const QNetworkRequest &request);
117 QNetworkReply *get(const QNetworkRequest &request);
118 QNetworkReply *post(const QNetworkRequest &request, QIODevice *data);
119 QNetworkReply *post(const QNetworkRequest &request, const QByteArray &data);
120 QNetworkReply *post(const QNetworkRequest &request, QHttpMultiPart *multiPart);
121 QNetworkReply *put(const QNetworkRequest &request, QIODevice *data);
122 QNetworkReply *put(const QNetworkRequest &request, const QByteArray &data);
123 QNetworkReply *put(const QNetworkRequest &request, QHttpMultiPart *multiPart);
124 QNetworkReply *deleteResource(const QNetworkRequest &request);
125 QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data = 0);
126
127#if !defined(QT_NO_BEARERMANAGEMENT) && !defined(QT_MOBILITY_BEARER)
128 void setConfiguration(const QNetworkConfiguration &config);
129 QNetworkConfiguration configuration() const;
130 QNetworkConfiguration activeConfiguration() const;
131#endif
132
133#ifndef QT_NO_BEARERMANAGEMENT
134 void setNetworkAccessible(NetworkAccessibility accessible);
135 NetworkAccessibility networkAccessible() const;
136#endif
137
138Q_SIGNALS:
139#ifndef QT_NO_NETWORKPROXY
140 void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
141#endif
142 void authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);
143 void finished(QNetworkReply *reply);
144#ifndef QT_NO_OPENSSL
145 void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
146#endif
147
148#if !defined(QT_NO_BEARERMANAGEMENT) && !defined(QT_MOBILITY_BEARER)
149 void networkSessionConnected();
150#endif
151
152#ifndef QT_NO_BEARERMANAGEMENT
153 void networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible);
154#endif
155
156protected:
157 virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
158 QIODevice *outgoingData = 0);
159
160private:
161 friend class QNetworkReplyImplPrivate;
162 friend class QNetworkAccessHttpBackend;
163
164 Q_DECLARE_PRIVATE(QNetworkAccessManager)
165 Q_PRIVATE_SLOT(d_func(), void _q_replyFinished())
166 Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
167#if !defined(QT_NO_BEARERMANAGEMENT) && !defined(QT_MOBILITY_BEARER)
168 Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed())
169 Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State))
170#endif
171};
172
173QT_END_NAMESPACE
174
175QT_END_HEADER
176
177#endif
178