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