QtNetwork/qnetworkaccessmanager.h Source File

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 
70 class QNetworkReplyImplPrivate;
71 class QNetworkAccessManagerPrivate;
72 class 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 
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:
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 
174 
176 
177 #endif
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
State
The state the media producing object is in at the moment.
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:880
#define Q_OBJECT
Definition: qobjectdefs.h:157
GLXFBConfig config
Definition: GLee.h:10233
#define QT_END_HEADER
Definition: qglobal.h:142