ScummVM API documentation
storage.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_CLOUD_STORAGE_H
23#define BACKENDS_CLOUD_STORAGE_H
24
25#include "backends/cloud/storagefile.h"
26#include "backends/cloud/storageinfo.h"
27#include "backends/networking/http/request.h"
28#include "backends/networking/http/httprequest.h"
29#include "common/array.h"
30#include "common/callback.h"
31#include "common/mutex.h"
32#include "common/path.h"
33#include "common/stream.h"
34#include "common/str.h"
35
36namespace GUI {
37
38class CommandReceiver;
39
40}
41
42namespace Cloud {
43
44class SavesSyncRequest;
45class FolderDownloadRequest;
46
47class Storage {
48public:
54
60
61protected:
64 Common::Mutex _runningRequestsMutex;
65
68 bool _syncRestartRequestsed;
69
72
75
78
81
90
96 virtual void requestFinishedCallback(Networking::Request *invalidRequestPointer);
97
98public:
99 Storage();
100 virtual ~Storage();
101
113 virtual void saveConfig(const Common::String &keyPrefix) = 0;
114
119 virtual Common::String name() const = 0;
120
124 bool isEnabled() const;
125
129 void enable();
130
140 virtual Networking::Request *listDirectory(const Common::String &path, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive = false) = 0;
141
144 virtual Networking::Request *upload(const Common::String &remotePath, const Common::Path &localPath, UploadCallback callback, Networking::ErrorCallback errorCallback);
145
147 virtual bool uploadStreamSupported();
148
151 virtual Networking::Request *streamFileById(const Common::String &id, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback) = 0;
152
154 virtual Networking::Request *download(const Common::String &remotePath, const Common::Path &localPath, BoolCallback callback, Networking::ErrorCallback errorCallback);
155 virtual Networking::Request *downloadById(const Common::String &remoteId, const Common::Path &localPath, BoolCallback callback, Networking::ErrorCallback errorCallback);
156
158 virtual Networking::Request *downloadFolder(const Common::String &remotePath, const Common::Path &localPath, FileArrayCallback callback, Networking::ErrorCallback errorCallback, bool recursive = false);
159
162
165
174
177
179 virtual bool isWorking();
180
182
184 virtual bool isSyncing();
185
188
190 uint64 bytesDownloaded = 0, bytesToDownload = 0;
191 uint64 filesDownloaded = 0, filesToDownload = 0;
192 bool inProgress = false;
193 };
194
197
199 virtual double getSyncProgress();
200
203
205 virtual void cancelSync();
206
207protected:
209 virtual void savesSyncDefaultCallback(const BoolResponse &response);
210
213
214public:
216
218 virtual bool startDownload(const Common::String &remotePath, const Common::Path &localPath);
219
221 virtual void cancelDownload();
222
225
227 virtual bool isDownloading();
228
230 virtual double getDownloadingProgress();
231
233 virtual uint64 getDownloadBytesNumber();
234
237
239 virtual uint64 getDownloadSpeed();
240
243
246
247protected:
249 virtual void directoryDownloadedCallback(const FileArrayResponse &response);
250
253};
254
255} // End of namespace Cloud
256
257#endif
Definition: folderdownloadrequest.h:31
Definition: savessyncrequest.h:32
Definition: storage.h:47
virtual uint64 getDownloadTotalBytesNumber()
virtual Common::String name() const =0
SavesSyncRequest * _savesSyncRequest
Definition: storage.h:67
virtual double getSyncProgress()
virtual Networking::Request * addRequest(Networking::Request *request)
bool isEnabled() const
virtual Networking::Request * listDirectory(const Common::String &path, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive=false)=0
uint32 _runningRequestsCount
Definition: storage.h:63
virtual bool isSyncing()
virtual Common::String getDownloadRemoteDirectory()
virtual Networking::Request * downloadFolder(const Common::String &remotePath, const Common::Path &localPath, FileArrayCallback callback, Networking::ErrorCallback errorCallback, bool recursive=false)
virtual Networking::Request * info(StorageInfoCallback callback, Networking::ErrorCallback errorCallback)=0
virtual Networking::Request * upload(const Common::String &path, Common::SeekableReadStream *contents, UploadCallback callback, Networking::ErrorCallback errorCallback)=0
virtual Networking::ErrorCallback getErrorPrintingCallback()
virtual bool isDownloading()
virtual Networking::Request * streamFile(const Common::String &path, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback)
virtual SavesSyncRequest * syncSaves(BoolCallback callback, Networking::ErrorCallback errorCallback)
virtual uint64 getDownloadBytesNumber()
virtual void saveConfig(const Common::String &keyPrefix)=0
virtual Common::Path getDownloadLocalDirectory()
virtual uint64 getDownloadSpeed()
virtual Common::String savesDirectoryPath()=0
virtual void printErrorResponse(const Networking::ErrorResponse &error)
virtual void requestFinishedCallback(Networking::Request *invalidRequestPointer)
virtual void savesSyncDefaultErrorCallback(const Networking::ErrorResponse &error)
virtual Networking::Request * createDirectory(const Common::String &path, BoolCallback callback, Networking::ErrorCallback errorCallback)=0
virtual void directoryDownloadedErrorCallback(const Networking::ErrorResponse &error)
virtual void setDownloadTarget(GUI::CommandReceiver *target)
virtual bool isWorking()
virtual void cancelDownload()
virtual double getDownloadingProgress()
virtual Common::Array< Common::String > getSyncingFiles()
virtual void cancelSync()
virtual void savesSyncDefaultCallback(const BoolResponse &response)
virtual bool uploadStreamSupported()
virtual bool startDownload(const Common::String &remotePath, const Common::Path &localPath)
virtual double getSyncDownloadingProgress()
virtual Networking::Request * download(const Common::String &remotePath, const Common::Path &localPath, BoolCallback callback, Networking::ErrorCallback errorCallback)
virtual void directoryDownloadedCallback(const FileArrayResponse &response)
bool _isEnabled
Definition: storage.h:74
FolderDownloadRequest * _downloadFolderRequest
Definition: storage.h:71
virtual void getSyncDownloadingInfo(SyncDownloadingInfo &info)
Definition: mutex.h:67
Definition: path.h:52
Definition: stream.h:745
Definition: str.h:59
Definition: object.h:33
Definition: request.h:119
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: storage.h:189
Definition: request.h:73
Definition: request.h:47