-
Notifications
You must be signed in to change notification settings - Fork 33
/
qRestAPI_p.h
111 lines (84 loc) · 2.66 KB
/
qRestAPI_p.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*==============================================================================
Library: qRestAPI
Copyright (c) 2010 Kitware Inc.
See Doc/copyright/copyright.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
and was partially funded by NIH grant 3P41RR013218-12S1
==============================================================================*/
#ifndef __qRestAPI_p_h
#define __qRestAPI_p_h
// Qt includes
#include <QFile>
#if QT_VERSION >= 0x050000
#include <QHash>
#endif
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QSslError>
// qRestAPI includes
#include "qRestAPI.h"
class QIODevice;
#if (QT_VERSION < QT_VERSION_CHECK(5, 3, 0))
#ifdef QT_NO_OPENSSL
#define QRESTAPI_QT_NO_SSL
#endif
#else
#ifdef QT_NO_SSL
#define QRESTAPI_QT_NO_SSL
#endif
#endif
#ifdef QRESTAPI_QT_NO_SSL
struct QSslError{};
#endif
// --------------------------------------------------------------------------
class qRestAPIPrivate : public QObject
{
Q_OBJECT
Q_DECLARE_PUBLIC(qRestAPI);
qRestAPI* const q_ptr;
private:
static struct StaticInit
{
StaticInit()
{
qRestAPIPrivate::staticInit();
}
} _staticInit;
static void staticInit();
public:
qRestAPIPrivate(qRestAPI* object);
~qRestAPIPrivate();
virtual void init();
public slots:
void processReply(QNetworkReply* reply);
/// Called when a query hasn't had any progress for a given TimeOut time.
/// Note: sender() is used.
void queryTimeOut();
void queryProgress(qint64 bytesReceived, qint64 bytesTotal);
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
void onSslErrors(QNetworkReply* reply, const QList<QSslError>& errors);
// void onAuthenticationRequired(QNetworkReply* reply, QAuthenticator* authenticator);
public:
QString ServerUrl;
QNetworkAccessManager* NetworkManager;
int TimeOut;
qRestAPI::RawHeaders DefaultRawHeaders;
bool SuppressSslErrors;
qRestAPI::ErrorType ErrorCode;
QString ErrorString;
// In Qt5 QHash should be used. QUuid does not have a hash function in Qt4,
// so the QUuid's would be converted to QString what is expensive.
#if QT_VERSION >= 0x050000
QHash<QUuid, qRestResult*> results;
#else
QMap<QUuid, qRestResult*> results;
#endif
};
#endif