Qt 4.8
qnetworkaccessmanager.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtNetwork module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QNETWORKACCESSMANAGER_H
43 #define QNETWORKACCESSMANAGER_H
44 
45 #include <QtCore/QObject>
46 
48 
50 
51 QT_MODULE(Network)
52 
53 class QIODevice;
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;
64 class QSslError;
65 #if !defined(QT_NO_BEARERMANAGEMENT) && !defined(QT_MOBILITY_BEARER)
67 #endif
68 class QHttpMultiPart;
69 
73 {
74  Q_OBJECT
75 
76 #ifndef QT_NO_BEARERMANAGEMENT
78 #endif
79 
80 public:
81  enum Operation {
82  HeadOperation = 1,
88 
89  UnknownOperation = 0
90  };
91 
92 #ifndef QT_NO_BEARERMANAGEMENT
94  UnknownAccessibility = -1,
95  NotAccessible = 0,
96  Accessible = 1
97  };
98 #endif
99 
100  explicit QNetworkAccessManager(QObject *parent = 0);
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 
138 Q_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 
156 protected:
157  virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
158  QIODevice *outgoingData = 0);
159 
160 private:
163 
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 
174 
176 
177 #endif
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
Definition: qnetworkreply.h:65
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Operation
Indicates the operation this reply is processing.
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
The QNetworkProxyFactory class provides fine-grained proxy selection.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
NetworkAccessibility
Indicates whether the network is accessible via this network access manager.
The QNetworkProxy class provides a network layer proxy.
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static const char * data(const QByteArray &arr)
The State element defines configurations of objects and properties.
The QNetworkAccessManager class allows the application to send network requests and receive replies...
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QAuthenticator class provides an authentication object.
The QNetworkCookieJar class implements a simple jar of QNetworkCookie objects.
The QNetworkCookie class holds one network cookie.
The QNetworkSession class provides control over the system&#39;s access points and enables session manage...
#define Q_NETWORK_EXPORT
Definition: qglobal.h:1452
NetworkAccessibility networkAccessible
whether the network is currently accessible via this network access manager.
The QHttpMultiPart class resembles a MIME multipart message to be sent over HTTP. ...
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QSslError class provides an SSL error.
Definition: qsslerror.h:58
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
#define QT_END_HEADER
Definition: qglobal.h:137
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
The QAbstractNetworkCache class provides the interface for cache implementations. ...