ScummVM API documentation
request.h
1
/* ScummVM - Graphic Adventure Engine
2
*
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*
20
*/
21
22
#ifndef BACKENDS_NETWORKING_CURL_REQUEST_H
23
#define BACKENDS_NETWORKING_CURL_REQUEST_H
24
25
#include "common/callback.h"
26
#include "common/scummsys.h"
27
#include "common/str.h"
28
29
namespace
Networking
{
30
31
class
Request;
32
47
template
<
typename
T>
struct
Response
{
48
const
Request
*request;
49
T value;
50
51
Response
(
const
Request
*rq, T v) : request(rq), value(v) {}
52
};
53
73
struct
ErrorResponse
{
74
Request
*request;
75
bool
interrupted;
76
bool
failed;
77
Common::String
response;
78
long
httpResponseCode;
79
80
ErrorResponse
(
Request
*rq,
const
Common::String
&resp);
81
ErrorResponse
(
Request
*rq,
bool
interrupt,
bool
failure,
const
Common::String
&resp,
long
httpCode);
82
};
83
84
typedef
Response<void *>
DataResponse
;
85
typedef
Common::BaseCallback<const DataResponse &>
*
DataCallback
;
86
typedef
Common::BaseCallback<const ErrorResponse &>
*
ErrorCallback
;
87
112
enum
RequestState {
113
PROCESSING,
114
PAUSED,
115
RETRY,
116
FINISHED
117
};
118
119
class
Request
{
120
protected
:
128
DataCallback
_callback
;
129
135
ErrorCallback
_errorCallback
;
136
145
RequestState
_state
;
146
148
uint32
_retryInSeconds
;
149
151
virtual
void
finishError(
const
ErrorResponse
&
error
, RequestState state = FINISHED);
152
154
virtual
void
finishSuccess();
155
156
public
:
157
Request
(DataCallback cb, ErrorCallback ecb);
158
virtual
~
Request
();
159
161
virtual
void
handle() = 0;
162
164
virtual
void
handleRetry();
165
167
virtual
void
restart() = 0;
168
170
virtual
void
pause();
171
177
virtual
void
finish();
178
180
virtual
void
retry(uint32 seconds);
181
183
RequestState state()
const
;
184
197
virtual
Common::String
date()
const
;
198
};
199
200
}
// End of namespace Networking
201
202
#endif
Common::String
Definition:
str.h:59
Networking
Definition:
scummvmcloud.h:31
Networking::ErrorResponse
Definition:
request.h:73
Networking::Response
Definition:
request.h:47
Networking::Request::_callback
DataCallback _callback
Definition:
request.h:128
Common::BaseCallback< const DataResponse & >
Networking::Request::_errorCallback
ErrorCallback _errorCallback
Definition:
request.h:135
error
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Networking::Request::_state
RequestState _state
Definition:
request.h:145
Networking::Request::_retryInSeconds
uint32 _retryInSeconds
Definition:
request.h:148
Networking::Request
Definition:
request.h:119
backends
networking
curl
request.h
Generated on Sun Dec 22 2024 09:04:09 for ScummVM API documentation by
1.8.13