ScummVM API documentation
googledrivestorage.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_GOOGLEDRIVE_GOOGLEDRIVESTORAGE_H
23 #define BACKENDS_CLOUD_GOOGLEDRIVE_GOOGLEDRIVESTORAGE_H
24 
25 #include "backends/cloud/id/idstorage.h"
26 #include "backends/networking/curl/curljsonrequest.h"
27 
28 namespace Cloud {
29 namespace GoogleDrive {
30 
33  GoogleDriveStorage(const Common::String &token, const Common::String &refreshToken, bool enabled);
34 
36  void infoInnerCallback(StorageInfoCallback outerCallback, const Networking::JsonResponse &json);
37 
39  void createDirectoryInnerCallback(BoolCallback outerCallback, const Networking::JsonResponse &json);
40 
41  void printInfo(const StorageInfoResponse &response);
42 
43 protected:
47  Common::String cloudProvider() override;
48 
52  uint32 storageIndex() override;
53 
54  bool needsRefreshToken() override;
55 
56  bool canReuseRefreshToken() override;
57 
58 public:
61 
64 
65  ~GoogleDriveStorage() override;
66 
78  void saveConfig(const Common::String &keyPrefix) override;
79 
84  Common::String name() const override;
85 
90 
92  Networking::Request *upload(const Common::String &path, Common::SeekableReadStream *contents, UploadCallback callback, Networking::ErrorCallback errorCallback) override;
93 
96 
98  Networking::Request *createDirectoryWithParentId(const Common::String &parentId, const Common::String &directoryName, BoolCallback callback, Networking::ErrorCallback errorCallback) override;
99 
101  Networking::Request *info(StorageInfoCallback callback, Networking::ErrorCallback errorCallback) override;
102 
105 
110  static GoogleDriveStorage *loadFromConfig(const Common::String &keyPrefix);
111 
115  static void removeFromConfig(const Common::String &keyPrefix);
116 
117  Common::String getRootDirectoryId() override;
118 
119  Common::String accessToken() const { return _token; }
120 };
121 
122 } // End of namespace GoogleDrive
123 } // End of namespace Cloud
124 
125 #endif
Networking::Request * createDirectoryWithParentId(const Common::String &parentId, const Common::String &directoryName, BoolCallback callback, Networking::ErrorCallback errorCallback) override
Definition: str.h:59
Definition: basestorage.h:28
Common::String cloudProvider() override
static GoogleDriveStorage * loadFromConfig(const Common::String &keyPrefix)
Definition: request.h:47
Definition: stream.h:745
Networking::Request * streamFileById(const Common::String &id, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback) override
Common::String name() const override
void saveConfig(const Common::String &keyPrefix) override
Common::String _token
Definition: basestorage.h:33
Networking::Request * listDirectoryById(const Common::String &id, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback) override
Definition: callback.h:49
Common::String savesDirectoryPath() override
static void removeFromConfig(const Common::String &keyPrefix)
Definition: idstorage.h:45
Networking::Request * upload(const Common::String &path, Common::SeekableReadStream *contents, UploadCallback callback, Networking::ErrorCallback errorCallback) override
Networking::Request * info(StorageInfoCallback callback, Networking::ErrorCallback errorCallback) override
Definition: googledrivestorage.h:31
Definition: request.h:119