ScummVM API documentation
boxstorage.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_BOX_BOXSTORAGE_H
23 #define BACKENDS_CLOUD_BOX_BOXSTORAGE_H
24 
25 #include "backends/cloud/id/idstorage.h"
26 #include "backends/networking/curl/curljsonrequest.h"
27 
28 namespace Cloud {
29 namespace Box {
30 
31 class BoxStorage: public Id::IdStorage {
33  BoxStorage(const Common::String &token, const Common::String &refreshToken, bool enabled);
34 
36  void infoInnerCallback(StorageInfoCallback outerCallback, const Networking::JsonResponse &json);
37 
38  void createDirectoryInnerCallback(BoolCallback outerCallback, const Networking::JsonResponse &response);
39 
40 protected:
44  Common::String cloudProvider() override;
45 
49  uint32 storageIndex() override;
50 
51  bool needsRefreshToken() override;
52 
53  bool canReuseRefreshToken() override;
54 
55 public:
58 
61 
62  ~BoxStorage() override;
63 
75  void saveConfig(const Common::String &keyPrefix) override;
76 
81  Common::String name() const override;
82 
86  Networking::Request *createDirectoryWithParentId(const Common::String &parentId, const Common::String &directoryName, BoolCallback callback, Networking::ErrorCallback errorCallback) override;
87 
89  Networking::Request *upload(const Common::String &remotePath, const Common::Path &localPath, UploadCallback callback, Networking::ErrorCallback errorCallback) override;
90  Networking::Request *upload(const Common::String &path, Common::SeekableReadStream *contents, UploadCallback callback, Networking::ErrorCallback errorCallback) override;
91 
93  bool uploadStreamSupported() override;
94 
97 
99  Networking::Request *info(StorageInfoCallback callback, Networking::ErrorCallback errorCallback) override;
100 
103 
108  static BoxStorage *loadFromConfig(const Common::String &keyPrefix);
109 
113  static void removeFromConfig(const Common::String &keyPrefix);
114 
115  Common::String getRootDirectoryId() override;
116 
117  Common::String accessToken() const { return _token; }
118 };
119 
120 } // End of namespace Box
121 } // End of namespace Cloud
122 
123 #endif
bool uploadStreamSupported() override
Definition: str.h:59
Common::String name() const override
Definition: basestorage.h:28
static void removeFromConfig(const Common::String &keyPrefix)
uint32 storageIndex() override
Definition: path.h:52
Definition: boxstorage.h:31
Definition: request.h:47
Definition: stream.h:745
Common::String savesDirectoryPath() override
Networking::Request * info(StorageInfoCallback callback, Networking::ErrorCallback errorCallback) override
bool needsRefreshToken() override
Networking::Request * upload(const Common::String &remotePath, const Common::Path &localPath, UploadCallback callback, Networking::ErrorCallback errorCallback) override
Common::String _token
Definition: basestorage.h:33
static BoxStorage * loadFromConfig(const Common::String &keyPrefix)
Definition: callback.h:49
Networking::Request * listDirectoryById(const Common::String &id, ListDirectoryCallback callback, Networking::ErrorCallback errorCallback) override
Definition: idstorage.h:45
bool canReuseRefreshToken() override
Networking::Request * streamFileById(const Common::String &path, Networking::NetworkReadStreamCallback callback, Networking::ErrorCallback errorCallback) override
Common::String cloudProvider() override
void saveConfig(const Common::String &keyPrefix) override
Definition: request.h:119