ScummVM API documentation
sessionrequest.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_SESSIONREQUEST_H
23
#define BACKENDS_NETWORKING_CURL_SESSIONREQUEST_H
24
25
#include "backends/networking/curl/curlrequest.h"
26
#include "common/memstream.h"
27
28
namespace
Common
{
29
class
DumpFile;
30
class
JSONValue;
31
class
Path
;
32
}
33
34
namespace
Networking
{
35
36
#define CURL_SESSION_REQUEST_BUFFER_SIZE 512 * 1024
37
38
struct
SessionFileResponse
{
39
byte *buffer;
40
uint32 len;
41
bool
eos;
42
};
43
50
class
SessionRequest
:
public
CurlRequest
{
51
protected
:
52
Common::MemoryWriteStreamDynamic
_contentsStream;
53
byte *_buffer;
54
char
*_text;
55
bool
_started, _complete, _success;
56
bool
_binary;
57
Common::DumpFile
*_localFile;
58
SessionFileResponse
_response;
59
60
bool
reuseStream();
61
63
char
*getPreparedContents();
64
65
void
finishError(
const
ErrorResponse
&
error
, RequestState state = PAUSED)
override
;
66
void
finishSuccess()
override
;
67
void
openLocalFile(
const
Common::Path
&localFile);
68
69
public
:
70
SessionRequest
(
const
Common::String
&url,
const
Common::Path
&localFile,
DataCallback
cb =
nullptr
,
ErrorCallback
ecb =
nullptr
,
bool
binary =
false
);
71
~
SessionRequest
()
override
;
72
73
void
start();
74
void
startAndWait();
75
76
void
reuse(
const
Common::String
&url,
const
Common::Path
&localFile,
DataCallback
cb =
nullptr
,
ErrorCallback
ecb =
nullptr
,
bool
binary =
false
);
77
78
void
handle()
override
;
79
void
restart()
override
;
80
82
void
close();
83
88
void
abortRequest();
89
90
bool
complete();
91
bool
success();
92
93
char
*text();
94
Common::JSONValue
*json();
95
96
byte *getData() {
return
_contentsStream.getData(); }
97
uint32 getSize() {
return
_contentsStream.
size
(); }
98
99
};
100
101
}
// End of namespace Networking
102
103
#endif
Common::String
Definition:
str.h:59
Networking
Definition:
scummvmcloud.h:31
Networking::ErrorResponse
Definition:
request.h:73
Common::MemoryWriteStreamDynamic::size
int64 size() const override
Definition:
memstream.h:250
Common::MemoryWriteStreamDynamic
Definition:
memstream.h:194
Common::Path
Definition:
path.h:52
Common::DumpFile
Definition:
file.h:145
Common::JSONValue
Definition:
json.h:90
Hugo::Path
Path
Definition:
game.h:75
Common
Definition:
algorithm.h:29
Common::BaseCallback
Definition:
callback.h:49
Networking::SessionRequest
Class for reading file and storing locally.
Definition:
sessionrequest.h:50
error
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Networking::SessionFileResponse
Definition:
sessionrequest.h:38
Networking::CurlRequest
Definition:
curlrequest.h:41
backends
networking
curl
sessionrequest.h
Generated on Fri Nov 15 2024 09:04:37 for ScummVM API documentation by
1.8.13