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/http/httpjsonrequest.h"
27
28namespace Cloud {
29
31protected:
33 Common::String _token, _refreshToken;
34
39 virtual void getAccessToken(const Common::String &code, Networking::ErrorCallback callback);
40
46
52
58
64 virtual uint32 storageIndex() = 0;
65
69 virtual bool needsRefreshToken() = 0;
70
74 virtual bool canReuseRefreshToken() = 0;
75
76private:
77 void tokenRefreshed(BoolCallback callback, const Networking::JsonResponse &response);
78
79protected:
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
89public:
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: basestorage.h:30
static void removeIsEnabledFlag(const Common::String &keyPrefix)
Common::String _token
Definition: basestorage.h:33
virtual void refreshAccessToken(BoolCallback callback, Networking::ErrorCallback errorCallback=nullptr)
virtual void codeFlowComplete(Networking::ErrorCallback callback, const Networking::JsonResponse &response)
virtual void codeFlowFailed(Networking::ErrorCallback callback, const Networking::ErrorResponse &error)
virtual bool canReuseRefreshToken()=0
virtual void getAccessToken(const Common::String &code, Networking::ErrorCallback callback)
static bool loadIsEnabledFlag(const Common::String &keyPrefix)
virtual Common::String cloudProvider()=0
virtual uint32 storageIndex()=0
virtual bool needsRefreshToken()=0
void saveIsEnabledFlag(const Common::String &keyPrefix) const
Definition: storage.h:47
Definition: str.h:59
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: request.h:73
Definition: request.h:47