ScummVM API documentation
basestorage.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_BASE_STORAGE_H
23 #define BACKENDS_CLOUD_BASE_STORAGE_H
24 
25 #include "backends/cloud/storage.h"
26 #include "backends/networking/curl/curljsonrequest.h"
27 
28 namespace Cloud {
29 
30 class BaseStorage: public Cloud::Storage {
31 protected:
33  Common::String _token, _refreshToken;
34 
39  virtual void getAccessToken(const Common::String &code, Networking::ErrorCallback callback);
40 
45  virtual void codeFlowComplete(Networking::ErrorCallback callback, const Networking::JsonResponse &response);
46 
52 
57  virtual Common::String cloudProvider() = 0;
58 
64  virtual uint32 storageIndex() = 0;
65 
69  virtual bool needsRefreshToken() = 0;
70 
74  virtual bool canReuseRefreshToken() = 0;
75 
76 private:
77  void tokenRefreshed(BoolCallback callback, const Networking::JsonResponse &response);
78 
79 protected:
81  void saveIsEnabledFlag(const Common::String &keyPrefix) const;
82 
84  static bool loadIsEnabledFlag(const Common::String &keyPrefix);
85 
87  static void removeIsEnabledFlag(const Common::String &keyPrefix);
88 
89 public:
90  BaseStorage();
91  BaseStorage(const Common::String &token, const Common::String &refreshToken, bool enabled = false);
92  ~BaseStorage() override;
93 
98  virtual void refreshAccessToken(BoolCallback callback, Networking::ErrorCallback errorCallback = nullptr);
99 };
100 
101 } // End of namespace Cloud
102 
103 #endif
Definition: str.h:59
Definition: basestorage.h:28
Definition: storage.h:47
Definition: request.h:73
Definition: request.h:47
virtual uint32 storageIndex()=0
static bool loadIsEnabledFlag(const Common::String &keyPrefix)
static void removeIsEnabledFlag(const Common::String &keyPrefix)
virtual void refreshAccessToken(BoolCallback callback, Networking::ErrorCallback errorCallback=nullptr)
Common::String _token
Definition: basestorage.h:33
Definition: callback.h:49
virtual Common::String cloudProvider()=0
virtual void codeFlowComplete(Networking::ErrorCallback callback, const Networking::JsonResponse &response)
virtual bool needsRefreshToken()=0
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
virtual void getAccessToken(const Common::String &code, Networking::ErrorCallback callback)
void saveIsEnabledFlag(const Common::String &keyPrefix) const
virtual void codeFlowFailed(Networking::ErrorCallback callback, const Networking::ErrorResponse &error)
virtual bool canReuseRefreshToken()=0
Definition: basestorage.h:30