0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtNetwork module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
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 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
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 |
UnknownNetworkError = 99,
|
|
81 |
|
|
82 |
// proxy errors (101-199):
|
|
83 |
ProxyConnectionRefusedError = 101,
|
|
84 |
ProxyConnectionClosedError,
|
|
85 |
ProxyNotFoundError,
|
|
86 |
ProxyTimeoutError,
|
|
87 |
ProxyAuthenticationRequiredError,
|
|
88 |
UnknownProxyError = 199,
|
|
89 |
|
|
90 |
// content errors (201-299):
|
|
91 |
ContentAccessDenied = 201,
|
|
92 |
ContentOperationNotPermittedError,
|
|
93 |
ContentNotFoundError,
|
|
94 |
AuthenticationRequiredError,
|
|
95 |
ContentReSendError,
|
|
96 |
UnknownContentError = 299,
|
|
97 |
|
|
98 |
// protocol errors
|
|
99 |
ProtocolUnknownError = 301,
|
|
100 |
ProtocolInvalidOperationError,
|
|
101 |
ProtocolFailure = 399
|
|
102 |
};
|
|
103 |
|
|
104 |
~QNetworkReply();
|
|
105 |
virtual void abort() = 0;
|
|
106 |
|
|
107 |
// reimplemented from QIODevice
|
|
108 |
virtual void close();
|
|
109 |
virtual bool isSequential() const;
|
|
110 |
|
|
111 |
// like QAbstractSocket:
|
|
112 |
qint64 readBufferSize() const;
|
|
113 |
virtual void setReadBufferSize(qint64 size);
|
|
114 |
|
|
115 |
QNetworkAccessManager *manager() const;
|
|
116 |
QNetworkAccessManager::Operation operation() const;
|
|
117 |
QNetworkRequest request() const;
|
|
118 |
NetworkError error() const;
|
|
119 |
bool isFinished() const;
|
|
120 |
bool isRunning() const;
|
|
121 |
QUrl url() const;
|
|
122 |
|
|
123 |
// "cooked" headers
|
|
124 |
QVariant header(QNetworkRequest::KnownHeaders header) const;
|
|
125 |
|
|
126 |
// raw headers:
|
|
127 |
bool hasRawHeader(const QByteArray &headerName) const;
|
|
128 |
QList<QByteArray> rawHeaderList() const;
|
|
129 |
QByteArray rawHeader(const QByteArray &headerName) const;
|
|
130 |
|
|
131 |
// attributes
|
|
132 |
QVariant attribute(QNetworkRequest::Attribute code) const;
|
|
133 |
|
|
134 |
#ifndef QT_NO_OPENSSL
|
|
135 |
QSslConfiguration sslConfiguration() const;
|
|
136 |
void setSslConfiguration(const QSslConfiguration &configuration);
|
|
137 |
void ignoreSslErrors(const QList<QSslError> &errors);
|
|
138 |
#endif
|
|
139 |
|
|
140 |
public Q_SLOTS:
|
|
141 |
virtual void ignoreSslErrors();
|
|
142 |
|
|
143 |
Q_SIGNALS:
|
|
144 |
void metaDataChanged();
|
|
145 |
void finished();
|
|
146 |
void error(QNetworkReply::NetworkError);
|
|
147 |
#ifndef QT_NO_OPENSSL
|
|
148 |
void sslErrors(const QList<QSslError> &errors);
|
|
149 |
#endif
|
|
150 |
|
|
151 |
void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
|
|
152 |
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
|
153 |
|
|
154 |
protected:
|
|
155 |
QNetworkReply(QObject *parent = 0);
|
|
156 |
QNetworkReply(QNetworkReplyPrivate &dd, QObject *parent);
|
|
157 |
virtual qint64 writeData(const char *data, qint64 len);
|
|
158 |
|
|
159 |
void setOperation(QNetworkAccessManager::Operation operation);
|
|
160 |
void setRequest(const QNetworkRequest &request);
|
|
161 |
void setError(NetworkError errorCode, const QString &errorString);
|
|
162 |
void setUrl(const QUrl &url);
|
|
163 |
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value);
|
|
164 |
void setRawHeader(const QByteArray &headerName, const QByteArray &value);
|
|
165 |
void setAttribute(QNetworkRequest::Attribute code, const QVariant &value);
|
|
166 |
|
|
167 |
private:
|
|
168 |
Q_DECLARE_PRIVATE(QNetworkReply)
|
|
169 |
};
|
|
170 |
|
|
171 |
QT_END_NAMESPACE
|
|
172 |
|
|
173 |
QT_END_HEADER
|
|
174 |
|
|
175 |
#endif
|