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 QNETWORKREPLY_H |
43 | #define QNETWORKREPLY_H |
44 | |
45 | #include <QtCore/QIODevice> |
46 | #include <QtCore/QString> |
47 | #include <QtCore/QVariant> |
48 | |
49 | #include <QtNetwork/QNetworkRequest> |
50 | #include <QtNetwork/QNetworkAccessManager> |
51 | |
52 | QT_BEGIN_HEADER |
53 | |
54 | QT_BEGIN_NAMESPACE |
55 | |
56 | QT_MODULE(Network) |
57 | |
58 | class QUrl; |
59 | class QVariant; |
60 | class QAuthenticator; |
61 | class QSslConfiguration; |
62 | class QSslError; |
63 | |
64 | class QNetworkReplyPrivate; |
65 | class Q_NETWORK_EXPORT QNetworkReply: public QIODevice |
66 | { |
67 | Q_OBJECT |
68 | Q_ENUMS(NetworkError) |
69 | public: |
70 | enum NetworkError { |
71 | NoError = 0, |
72 | |
73 | // network layer errors [relating to the destination server] (1-99): |
74 | ConnectionRefusedError = 1, |
75 | RemoteHostClosedError, |
76 | HostNotFoundError, |
77 | TimeoutError, |
78 | OperationCanceledError, |
79 | SslHandshakeFailedError, |
80 | TemporaryNetworkFailureError, |
81 | UnknownNetworkError = 99, |
82 | |
83 | // proxy errors (101-199): |
84 | ProxyConnectionRefusedError = 101, |
85 | ProxyConnectionClosedError, |
86 | ProxyNotFoundError, |
87 | ProxyTimeoutError, |
88 | ProxyAuthenticationRequiredError, |
89 | UnknownProxyError = 199, |
90 | |
91 | // content errors (201-299): |
92 | ContentAccessDenied = 201, |
93 | ContentOperationNotPermittedError, |
94 | ContentNotFoundError, |
95 | AuthenticationRequiredError, |
96 | ContentReSendError, |
97 | UnknownContentError = 299, |
98 | |
99 | // protocol errors |
100 | ProtocolUnknownError = 301, |
101 | ProtocolInvalidOperationError, |
102 | ProtocolFailure = 399 |
103 | }; |
104 | |
105 | ~QNetworkReply(); |
106 | virtual void abort() = 0; |
107 | |
108 | // reimplemented from QIODevice |
109 | virtual void close(); |
110 | virtual bool isSequential() const; |
111 | |
112 | // like QAbstractSocket: |
113 | qint64 readBufferSize() const; |
114 | virtual void setReadBufferSize(qint64 size); |
115 | |
116 | QNetworkAccessManager *manager() const; |
117 | QNetworkAccessManager::Operation operation() const; |
118 | QNetworkRequest request() const; |
119 | NetworkError error() const; |
120 | bool isFinished() const; |
121 | bool isRunning() const; |
122 | QUrl url() const; |
123 | |
124 | // "cooked" headers |
125 | QVariant (QNetworkRequest::KnownHeaders ) const; |
126 | |
127 | // raw headers: |
128 | bool (const QByteArray &) const; |
129 | QList<QByteArray> () const; |
130 | QByteArray (const QByteArray &) const; |
131 | |
132 | typedef QPair<QByteArray, QByteArray> ; |
133 | const QList<RawHeaderPair>& () const; |
134 | |
135 | // attributes |
136 | QVariant attribute(QNetworkRequest::Attribute code) const; |
137 | |
138 | #ifndef QT_NO_OPENSSL |
139 | QSslConfiguration sslConfiguration() const; |
140 | void setSslConfiguration(const QSslConfiguration &configuration); |
141 | void ignoreSslErrors(const QList<QSslError> &errors); |
142 | #endif |
143 | |
144 | public Q_SLOTS: |
145 | virtual void ignoreSslErrors(); |
146 | |
147 | Q_SIGNALS: |
148 | void metaDataChanged(); |
149 | void finished(); |
150 | void error(QNetworkReply::NetworkError); |
151 | #ifndef QT_NO_OPENSSL |
152 | void sslErrors(const QList<QSslError> &errors); |
153 | #endif |
154 | |
155 | void uploadProgress(qint64 bytesSent, qint64 bytesTotal); |
156 | void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); |
157 | |
158 | protected: |
159 | QNetworkReply(QObject *parent = 0); |
160 | QNetworkReply(QNetworkReplyPrivate &dd, QObject *parent); |
161 | virtual qint64 writeData(const char *data, qint64 len); |
162 | |
163 | void setOperation(QNetworkAccessManager::Operation operation); |
164 | void setRequest(const QNetworkRequest &request); |
165 | void setError(NetworkError errorCode, const QString &errorString); |
166 | void setFinished(bool); |
167 | void setUrl(const QUrl &url); |
168 | void (QNetworkRequest::KnownHeaders , const QVariant &value); |
169 | void (const QByteArray &, const QByteArray &value); |
170 | void setAttribute(QNetworkRequest::Attribute code, const QVariant &value); |
171 | |
172 | private: |
173 | Q_DECLARE_PRIVATE(QNetworkReply) |
174 | }; |
175 | |
176 | QT_END_NAMESPACE |
177 | |
178 | QT_END_HEADER |
179 | |
180 | #endif |
181 | |