ScummVM API documentation
idstorage.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_ID_IDSTORAGE_H
23#define BACKENDS_CLOUD_ID_IDSTORAGE_H
24
25#include "backends/cloud/basestorage.h"
26#include "backends/networking/http/httpjsonrequest.h"
27
28/*
29 * Id::IdStorage is a special base class, which is created
30 * to simplify adding new storages which use ids instead of
31 * paths in their API.
32 *
33 * Some Requests are already implemented, and Storage based
34 * on IdStorage needs to override/implement a few basic things.
35 *
36 * For example, ListDirectoryRequest and ResolveIdRequests are
37 * based on listDirectoryById() and getRootDirectoryId() methods.
38 * Implementing these you'll get id resolving and directory
39 * listing by path.
40 */
41
42namespace Cloud {
43namespace Id {
44
46protected:
47 void printFiles(const FileArrayResponse &response);
48 void printBool(const BoolResponse &response);
49 void printFile(const UploadResponse &response);
50
51 ListDirectoryCallback getPrintFilesCallback();
52
53public:
54 IdStorage();
55 IdStorage(const Common::String &token, const Common::String &refreshToken, bool enabled);
56 ~IdStorage() override;
57
62
64 Networking::Request *listDirectory(const Common::String &path, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive = false) override;
65 virtual Networking::Request *listDirectoryById(const Common::String &id, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback) = 0;
66
69 virtual Networking::Request *createDirectoryWithParentId(const Common::String &parentId, const Common::String &name, BoolCallback callback, Networking::ErrorCallback errorCallback) = 0;
70
73 Networking::Request *streamFileById(const Common::String &id, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback) override = 0;
74
76 Networking::Request *download(const Common::String &remotePath, const Common::Path &localPath, BoolCallback callback, Networking::ErrorCallback errorCallback) override;
77
78 virtual Common::String getRootDirectoryId() = 0;
79};
80
81} // End of namespace Id
82} // End of namespace Cloud
83
84#endif
Definition: basestorage.h:30
Definition: idstorage.h:45
Networking::Request * listDirectory(const Common::String &path, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive=false) override
Networking::Request * download(const Common::String &remotePath, const Common::Path &localPath, BoolCallback callback, Networking::ErrorCallback errorCallback) override
Networking::Request * createDirectory(const Common::String &path, BoolCallback callback, Networking::ErrorCallback errorCallback) override
Networking::Request * streamFile(const Common::String &path, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback) override
virtual Networking::Request * resolveFileId(const Common::String &path, UploadCallback callback, Networking::ErrorCallback errorCallback)
virtual Common::String name() const =0
Definition: path.h:52
Definition: str.h:59
Definition: request.h:119
Definition: request.h:47