CLOUD: Get rid of CloudConfigHelper, use kCloudDomain where approriate
This commit is contained in:
parent
8a84263d2b
commit
a8eebbe851
7 changed files with 70 additions and 166 deletions
|
@ -1,58 +0,0 @@
|
||||||
/* ScummVM - Graphic Adventure Engine
|
|
||||||
*
|
|
||||||
* ScummVM is the legal property of its developers, whose names
|
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
||||||
* file distributed with this source distribution.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "backends/cloud/cloudconfighelper.h"
|
|
||||||
#include "common/config-manager.h"
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
DECLARE_SINGLETON(Cloud::CloudConfigHelper);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Cloud {
|
|
||||||
|
|
||||||
bool CloudConfigHelper::hasKey(const Common::String &key) const {
|
|
||||||
return ConfMan.hasKey(key, ConfMan.kCloudDomain);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudConfigHelper::removeKey(const Common::String &key) {
|
|
||||||
ConfMan.removeKey(key, ConfMan.kCloudDomain);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Common::String &CloudConfigHelper::get(const Common::String &key) const {
|
|
||||||
return ConfMan.get(key, ConfMan.kCloudDomain);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CloudConfigHelper::getInt(const Common::String &key) const {
|
|
||||||
return ConfMan.getInt(key, ConfMan.kCloudDomain);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudConfigHelper::set(const Common::String &key, const Common::String &value) {
|
|
||||||
ConfMan.set(key, value, ConfMan.kCloudDomain);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudConfigHelper::flushToDisk() {
|
|
||||||
ConfMan.flushToDisk();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End of namespace Cloud
|
|
|
@ -1,49 +0,0 @@
|
||||||
/* ScummVM - Graphic Adventure Engine
|
|
||||||
*
|
|
||||||
* ScummVM is the legal property of its developers, whose names
|
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
||||||
* file distributed with this source distribution.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CLOUD_CLOUDCONFIGHELPER_H
|
|
||||||
#define CLOUD_CLOUDCONFIGHELPER_H
|
|
||||||
|
|
||||||
#include "common/singleton.h"
|
|
||||||
#include "common/str.h"
|
|
||||||
|
|
||||||
namespace Cloud {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience wrapper around ConfMan for the cloud backend.
|
|
||||||
*/
|
|
||||||
class CloudConfigHelper : public Common::Singleton<CloudConfigHelper> {
|
|
||||||
public:
|
|
||||||
bool hasKey(const Common::String &key) const;
|
|
||||||
void removeKey(const Common::String &key);
|
|
||||||
const Common::String &get(const Common::String &key) const;
|
|
||||||
int getInt(const Common::String &key) const;
|
|
||||||
void set(const Common::String &key, const Common::String &value);
|
|
||||||
void flushToDisk();
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Shortcut for accessing the cloud configuration helper. */
|
|
||||||
#define CloudConfig Cloud::CloudConfigHelper::instance()
|
|
||||||
|
|
||||||
} // End of namespace Cloud
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -26,7 +26,8 @@
|
||||||
#include "backends/cloud/googledrive/googledrivestorage.h"
|
#include "backends/cloud/googledrive/googledrivestorage.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
#include "common/translation.h"
|
#include "common/translation.h"
|
||||||
#include "backends/cloud/cloudconfighelper.h"
|
#include "common/config-manager.h"
|
||||||
|
#include "common/str.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
|
@ -77,6 +78,9 @@ void CloudManager::loadStorage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloudManager::init() {
|
void CloudManager::init() {
|
||||||
|
Common::String oldDomain = ConfMan.getActiveDomainName();
|
||||||
|
ConfMan.setActiveDomain(ConfMan.kCloudDomain);
|
||||||
|
|
||||||
//init configs structs
|
//init configs structs
|
||||||
for (uint32 i = 0; i < kStorageTotal; ++i) {
|
for (uint32 i = 0; i < kStorageTotal; ++i) {
|
||||||
Common::String name = getStorageConfigName(i);
|
Common::String name = getStorageConfigName(i);
|
||||||
|
@ -85,36 +89,43 @@ void CloudManager::init() {
|
||||||
config.username = "";
|
config.username = "";
|
||||||
config.lastSyncDate = "";
|
config.lastSyncDate = "";
|
||||||
config.usedBytes = 0;
|
config.usedBytes = 0;
|
||||||
if (CloudConfig.hasKey(kStoragePrefix + name + "_username"))
|
if (ConfMan.hasKey(kStoragePrefix + name + "_username"))
|
||||||
config.username = CloudConfig.get(kStoragePrefix + name + "_username");
|
config.username = ConfMan.get(kStoragePrefix + name + "_username");
|
||||||
if (CloudConfig.hasKey(kStoragePrefix + name + "_lastSync"))
|
if (ConfMan.hasKey(kStoragePrefix + name + "_lastSync"))
|
||||||
config.lastSyncDate = CloudConfig.get(kStoragePrefix + name + "_lastSync");
|
config.lastSyncDate = ConfMan.get(kStoragePrefix + name + "_lastSync");
|
||||||
if (CloudConfig.hasKey(kStoragePrefix + name + "_usedBytes"))
|
if (ConfMan.hasKey(kStoragePrefix + name + "_usedBytes"))
|
||||||
config.usedBytes = CloudConfig.get(kStoragePrefix + name + "_usedBytes").asUint64();
|
config.usedBytes = ConfMan.get(kStoragePrefix + name + "_usedBytes").asUint64();
|
||||||
_storages.push_back(config);
|
_storages.push_back(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
//load an active storage if there is any
|
//load an active storage if there is any
|
||||||
_currentStorageIndex = kStorageNoneId;
|
_currentStorageIndex = kStorageNoneId;
|
||||||
if (CloudConfig.hasKey("current_storage"))
|
if (ConfMan.hasKey("current_storage"))
|
||||||
_currentStorageIndex = CloudConfig.getInt("current_storage");
|
_currentStorageIndex = ConfMan.getInt("current_storage");
|
||||||
|
|
||||||
loadStorage();
|
loadStorage();
|
||||||
|
|
||||||
|
ConfMan.setActiveDomain(oldDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloudManager::save() {
|
void CloudManager::save() {
|
||||||
|
Common::String oldDomain = ConfMan.getActiveDomainName();
|
||||||
|
ConfMan.setActiveDomain(ConfMan.kCloudDomain);
|
||||||
|
|
||||||
for (uint32 i = 0; i < _storages.size(); ++i) {
|
for (uint32 i = 0; i < _storages.size(); ++i) {
|
||||||
if (i == kStorageNoneId) continue;
|
if (i == kStorageNoneId) continue;
|
||||||
Common::String name = getStorageConfigName(i);
|
Common::String name = getStorageConfigName(i);
|
||||||
CloudConfig.set(kStoragePrefix + name + "_username", _storages[i].username);
|
ConfMan.set(kStoragePrefix + name + "_username", _storages[i].username);
|
||||||
CloudConfig.set(kStoragePrefix + name + "_lastSync", _storages[i].lastSyncDate);
|
ConfMan.set(kStoragePrefix + name + "_lastSync", _storages[i].lastSyncDate);
|
||||||
CloudConfig.set(kStoragePrefix + name + "_usedBytes", Common::String::format("%llu", _storages[i].usedBytes));
|
ConfMan.set(kStoragePrefix + name + "_usedBytes", Common::String::format("%llu", _storages[i].usedBytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
CloudConfig.set("current_storage", Common::String::format("%d", _currentStorageIndex));
|
ConfMan.set("current_storage", Common::String::format("%d", _currentStorageIndex));
|
||||||
if (_activeStorage)
|
if (_activeStorage)
|
||||||
_activeStorage->saveConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
|
_activeStorage->saveConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
|
||||||
CloudConfig.flushToDisk();
|
ConfMan.flushToDisk();
|
||||||
|
|
||||||
|
ConfMan.setActiveDomain(oldDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloudManager::replaceStorage(Storage *storage, uint32 index) {
|
void CloudManager::replaceStorage(Storage *storage, uint32 index) {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
#include "common/json.h"
|
#include "common/json.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include "backends/cloud/cloudconfighelper.h"
|
#include "common/config-manager.h"
|
||||||
|
|
||||||
namespace Cloud {
|
namespace Cloud {
|
||||||
namespace Dropbox {
|
namespace Dropbox {
|
||||||
|
@ -40,12 +40,12 @@ char *DropboxStorage::KEY = nullptr; //can't use CloudConfig there yet, loading
|
||||||
char *DropboxStorage::SECRET = nullptr; //TODO: hide these secrets somehow
|
char *DropboxStorage::SECRET = nullptr; //TODO: hide these secrets somehow
|
||||||
|
|
||||||
void DropboxStorage::loadKeyAndSecret() {
|
void DropboxStorage::loadKeyAndSecret() {
|
||||||
Common::String k = CloudConfig.get("DROPBOX_KEY");
|
Common::String k = ConfMan.get("DROPBOX_KEY", ConfMan.kCloudDomain);
|
||||||
KEY = new char[k.size() + 1];
|
KEY = new char[k.size() + 1];
|
||||||
memcpy(KEY, k.c_str(), k.size());
|
memcpy(KEY, k.c_str(), k.size());
|
||||||
KEY[k.size()] = 0;
|
KEY[k.size()] = 0;
|
||||||
|
|
||||||
k = CloudConfig.get("DROPBOX_SECRET");
|
k = ConfMan.get("DROPBOX_SECRET", ConfMan.kCloudDomain);
|
||||||
SECRET = new char[k.size() + 1];
|
SECRET = new char[k.size() + 1];
|
||||||
memcpy(SECRET, k.c_str(), k.size());
|
memcpy(SECRET, k.c_str(), k.size());
|
||||||
SECRET[k.size()] = 0;
|
SECRET[k.size()] = 0;
|
||||||
|
@ -81,9 +81,9 @@ void DropboxStorage::codeFlowComplete(Networking::JsonResponse response) {
|
||||||
} else {
|
} else {
|
||||||
_token = result.getVal("access_token")->asString();
|
_token = result.getVal("access_token")->asString();
|
||||||
_uid = result.getVal("uid")->asString();
|
_uid = result.getVal("uid")->asString();
|
||||||
CloudConfig.removeKey("dropbox_code");
|
ConfMan.removeKey("dropbox_code", ConfMan.kCloudDomain);
|
||||||
CloudMan.replaceStorage(this, kStorageDropboxId);
|
CloudMan.replaceStorage(this, kStorageDropboxId);
|
||||||
CloudConfig.flushToDisk();
|
ConfMan.flushToDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete json;
|
delete json;
|
||||||
|
@ -93,8 +93,8 @@ void DropboxStorage::codeFlowComplete(Networking::JsonResponse response) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropboxStorage::saveConfig(Common::String keyPrefix) {
|
void DropboxStorage::saveConfig(Common::String keyPrefix) {
|
||||||
CloudConfig.set(keyPrefix + "access_token", _token);
|
ConfMan.set(keyPrefix + "access_token", _token, ConfMan.kCloudDomain);
|
||||||
CloudConfig.set(keyPrefix + "user_id", _uid);
|
ConfMan.set(keyPrefix + "user_id", _uid, ConfMan.kCloudDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String DropboxStorage::name() const {
|
Common::String DropboxStorage::name() const {
|
||||||
|
@ -198,18 +198,19 @@ void DropboxStorage::infoMethodCallback(StorageInfoResponse response) {
|
||||||
DropboxStorage *DropboxStorage::loadFromConfig(Common::String keyPrefix) {
|
DropboxStorage *DropboxStorage::loadFromConfig(Common::String keyPrefix) {
|
||||||
loadKeyAndSecret();
|
loadKeyAndSecret();
|
||||||
|
|
||||||
if (!CloudConfig.hasKey(keyPrefix + "access_token")) {
|
if (!ConfMan.hasKey(keyPrefix + "access_token", ConfMan.kCloudDomain)) {
|
||||||
warning("No access_token found");
|
warning("No access_token found");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CloudConfig.hasKey(keyPrefix + "user_id")) {
|
if (!ConfMan.hasKey(keyPrefix + "user_id", ConfMan.kCloudDomain)) {
|
||||||
warning("No user_id found");
|
warning("No user_id found");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String accessToken = CloudConfig.get(keyPrefix + "access_token");
|
Common::String accessToken = ConfMan.get(keyPrefix + "access_token", ConfMan.kCloudDomain);
|
||||||
Common::String userId = CloudConfig.get(keyPrefix + "user_id");
|
Common::String userId = ConfMan.get(keyPrefix + "user_id", ConfMan.kCloudDomain);
|
||||||
|
|
||||||
return new DropboxStorage(accessToken, userId);
|
return new DropboxStorage(accessToken, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include "googledrivestreamfilerequest.h"
|
#include "googledrivestreamfilerequest.h"
|
||||||
#include "googledrivedownloadrequest.h"
|
#include "googledrivedownloadrequest.h"
|
||||||
#include "googledriveuploadrequest.h"
|
#include "googledriveuploadrequest.h"
|
||||||
#include "backends/cloud/cloudconfighelper.h"
|
#include "common/config-manager.h"
|
||||||
|
|
||||||
namespace Cloud {
|
namespace Cloud {
|
||||||
namespace GoogleDrive {
|
namespace GoogleDrive {
|
||||||
|
@ -46,12 +46,12 @@ char *GoogleDriveStorage::KEY = nullptr; //can't use CloudConfig there yet, load
|
||||||
char *GoogleDriveStorage::SECRET = nullptr; //TODO: hide these secrets somehow
|
char *GoogleDriveStorage::SECRET = nullptr; //TODO: hide these secrets somehow
|
||||||
|
|
||||||
void GoogleDriveStorage::loadKeyAndSecret() {
|
void GoogleDriveStorage::loadKeyAndSecret() {
|
||||||
Common::String k = CloudConfig.get("GOOGLE_DRIVE_KEY");
|
Common::String k = ConfMan.get("GOOGLE_DRIVE_KEY", ConfMan.kCloudDomain);
|
||||||
KEY = new char[k.size() + 1];
|
KEY = new char[k.size() + 1];
|
||||||
memcpy(KEY, k.c_str(), k.size());
|
memcpy(KEY, k.c_str(), k.size());
|
||||||
KEY[k.size()] = 0;
|
KEY[k.size()] = 0;
|
||||||
|
|
||||||
k = CloudConfig.get("GOOGLE_DRIVE_SECRET");
|
k = ConfMan.get("GOOGLE_DRIVE_SECRET", ConfMan.kCloudDomain);
|
||||||
SECRET = new char[k.size() + 1];
|
SECRET = new char[k.size() + 1];
|
||||||
memcpy(SECRET, k.c_str(), k.size());
|
memcpy(SECRET, k.c_str(), k.size());
|
||||||
SECRET[k.size()] = 0;
|
SECRET[k.size()] = 0;
|
||||||
|
@ -122,14 +122,14 @@ void GoogleDriveStorage::codeFlowComplete(BoolResponse response) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CloudConfig.removeKey("googledrive_code");
|
ConfMan.removeKey("googledrive_code", ConfMan.kCloudDomain);
|
||||||
CloudMan.replaceStorage(this, kStorageGoogleDriveId);
|
CloudMan.replaceStorage(this, kStorageGoogleDriveId);
|
||||||
CloudConfig.flushToDisk();
|
ConfMan.flushToDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GoogleDriveStorage::saveConfig(Common::String keyPrefix) {
|
void GoogleDriveStorage::saveConfig(Common::String keyPrefix) {
|
||||||
CloudConfig.set(keyPrefix + "access_token", _token);
|
ConfMan.set(keyPrefix + "access_token", _token, ConfMan.kCloudDomain);
|
||||||
CloudConfig.set(keyPrefix + "refresh_token", _refreshToken);
|
ConfMan.set(keyPrefix + "refresh_token", _refreshToken, ConfMan.kCloudDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String GoogleDriveStorage::name() const {
|
Common::String GoogleDriveStorage::name() const {
|
||||||
|
@ -337,18 +337,18 @@ Common::String GoogleDriveStorage::savesDirectoryPath() { return "scummvm/saves/
|
||||||
GoogleDriveStorage *GoogleDriveStorage::loadFromConfig(Common::String keyPrefix) {
|
GoogleDriveStorage *GoogleDriveStorage::loadFromConfig(Common::String keyPrefix) {
|
||||||
loadKeyAndSecret();
|
loadKeyAndSecret();
|
||||||
|
|
||||||
if (!CloudConfig.hasKey(keyPrefix + "access_token")) {
|
if (!ConfMan.hasKey(keyPrefix + "access_token", ConfMan.kCloudDomain)) {
|
||||||
warning("No access_token found");
|
warning("No access_token found");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CloudConfig.hasKey(keyPrefix + "refresh_token")) {
|
if (!ConfMan.hasKey(keyPrefix + "refresh_token", ConfMan.kCloudDomain)) {
|
||||||
warning("No refresh_token found");
|
warning("No refresh_token found");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String accessToken = CloudConfig.get(keyPrefix + "access_token");
|
Common::String accessToken = ConfMan.get(keyPrefix + "access_token", ConfMan.kCloudDomain);
|
||||||
Common::String refreshToken = CloudConfig.get(keyPrefix + "refresh_token");
|
Common::String refreshToken = ConfMan.get(keyPrefix + "refresh_token", ConfMan.kCloudDomain);
|
||||||
return new GoogleDriveStorage(accessToken, refreshToken);
|
return new GoogleDriveStorage(accessToken, refreshToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,16 +363,16 @@ Common::String GoogleDriveStorage::getAuthLink() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GoogleDriveStorage::authThroughConsole() {
|
void GoogleDriveStorage::authThroughConsole() {
|
||||||
if (!CloudConfig.hasKey("GOOGLE_DRIVE_KEY") || !CloudConfig.hasKey("GOOGLE_DRIVE_SECRET")) {
|
if (!ConfMan.hasKey("GOOGLE_DRIVE_KEY", ConfMan.kCloudDomain) || !ConfMan.hasKey("GOOGLE_DRIVE_SECRET", ConfMan.kCloudDomain)) {
|
||||||
warning("No Google Drive keys available, cannot do auth");
|
warning("No Google Drive keys available, cannot do auth");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadKeyAndSecret();
|
loadKeyAndSecret();
|
||||||
|
|
||||||
if (CloudConfig.hasKey("googledrive_code")) {
|
if (ConfMan.hasKey("googledrive_code", ConfMan.kCloudDomain)) {
|
||||||
//phase 2: get access_token using specified code
|
//phase 2: get access_token using specified code
|
||||||
new GoogleDriveStorage(CloudConfig.get("googledrive_code"));
|
new GoogleDriveStorage(ConfMan.get("googledrive_code", ConfMan.kCloudDomain));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
#include "common/json.h"
|
#include "common/json.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include "backends/cloud/cloudconfighelper.h"
|
#include "common/config-manager.h"
|
||||||
|
|
||||||
namespace Cloud {
|
namespace Cloud {
|
||||||
namespace OneDrive {
|
namespace OneDrive {
|
||||||
|
@ -42,12 +42,12 @@ char *OneDriveStorage::KEY = nullptr; //can't use CloudConfig there yet, loading
|
||||||
char *OneDriveStorage::SECRET = nullptr; //TODO: hide these secrets somehow
|
char *OneDriveStorage::SECRET = nullptr; //TODO: hide these secrets somehow
|
||||||
|
|
||||||
void OneDriveStorage::loadKeyAndSecret() {
|
void OneDriveStorage::loadKeyAndSecret() {
|
||||||
Common::String k = CloudConfig.get("ONEDRIVE_KEY");
|
Common::String k = ConfMan.get("ONEDRIVE_KEY", ConfMan.kCloudDomain);
|
||||||
KEY = new char[k.size() + 1];
|
KEY = new char[k.size() + 1];
|
||||||
memcpy(KEY, k.c_str(), k.size());
|
memcpy(KEY, k.c_str(), k.size());
|
||||||
KEY[k.size()] = 0;
|
KEY[k.size()] = 0;
|
||||||
|
|
||||||
k = CloudConfig.get("ONEDRIVE_SECRET");
|
k = ConfMan.get("ONEDRIVE_SECRET", ConfMan.kCloudDomain);
|
||||||
SECRET = new char[k.size() + 1];
|
SECRET = new char[k.size() + 1];
|
||||||
memcpy(SECRET, k.c_str(), k.size());
|
memcpy(SECRET, k.c_str(), k.size());
|
||||||
SECRET[k.size()] = 0;
|
SECRET[k.size()] = 0;
|
||||||
|
@ -116,15 +116,15 @@ void OneDriveStorage::codeFlowComplete(BoolResponse response) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CloudConfig.removeKey("onedrive_code");
|
ConfMan.removeKey("onedrive_code", ConfMan.kCloudDomain);
|
||||||
CloudMan.replaceStorage(this, kStorageOneDriveId);
|
CloudMan.replaceStorage(this, kStorageOneDriveId);
|
||||||
CloudConfig.flushToDisk();
|
ConfMan.flushToDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneDriveStorage::saveConfig(Common::String keyPrefix) {
|
void OneDriveStorage::saveConfig(Common::String keyPrefix) {
|
||||||
CloudConfig.set(keyPrefix + "access_token", _token);
|
ConfMan.set(keyPrefix + "access_token", _token, ConfMan.kCloudDomain);
|
||||||
CloudConfig.set(keyPrefix + "user_id", _uid);
|
ConfMan.set(keyPrefix + "user_id", _uid, ConfMan.kCloudDomain);
|
||||||
CloudConfig.set(keyPrefix + "refresh_token", _refreshToken);
|
ConfMan.set(keyPrefix + "refresh_token", _refreshToken, ConfMan.kCloudDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String OneDriveStorage::name() const {
|
Common::String OneDriveStorage::name() const {
|
||||||
|
@ -260,24 +260,24 @@ Common::String OneDriveStorage::savesDirectoryPath() { return "saves/"; }
|
||||||
OneDriveStorage *OneDriveStorage::loadFromConfig(Common::String keyPrefix) {
|
OneDriveStorage *OneDriveStorage::loadFromConfig(Common::String keyPrefix) {
|
||||||
loadKeyAndSecret();
|
loadKeyAndSecret();
|
||||||
|
|
||||||
if (!CloudConfig.hasKey(keyPrefix + "access_token")) {
|
if (!ConfMan.hasKey(keyPrefix + "access_token", ConfMan.kCloudDomain)) {
|
||||||
warning("No access_token found");
|
warning("No access_token found");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CloudConfig.hasKey(keyPrefix + "user_id")) {
|
if (!ConfMan.hasKey(keyPrefix + "user_id", ConfMan.kCloudDomain)) {
|
||||||
warning("No user_id found");
|
warning("No user_id found");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CloudConfig.hasKey(keyPrefix + "refresh_token")) {
|
if (!ConfMan.hasKey(keyPrefix + "refresh_token", ConfMan.kCloudDomain)) {
|
||||||
warning("No refresh_token found");
|
warning("No refresh_token found");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String accessToken = CloudConfig.get(keyPrefix + "access_token");
|
Common::String accessToken = ConfMan.get(keyPrefix + "access_token", ConfMan.kCloudDomain);
|
||||||
Common::String userId = CloudConfig.get(keyPrefix + "user_id");
|
Common::String userId = ConfMan.get(keyPrefix + "user_id", ConfMan.kCloudDomain);
|
||||||
Common::String refreshToken = CloudConfig.get(keyPrefix + "refresh_token");
|
Common::String refreshToken = ConfMan.get(keyPrefix + "refresh_token", ConfMan.kCloudDomain);
|
||||||
return new OneDriveStorage(accessToken, userId, refreshToken);
|
return new OneDriveStorage(accessToken, userId, refreshToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,16 +292,16 @@ Common::String OneDriveStorage::getAuthLink() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneDriveStorage::authThroughConsole() {
|
void OneDriveStorage::authThroughConsole() {
|
||||||
if (!CloudConfig.hasKey("ONEDRIVE_KEY") || !CloudConfig.hasKey("ONEDRIVE_SECRET")) {
|
if (!ConfMan.hasKey("ONEDRIVE_KEY", ConfMan.kCloudDomain) || !ConfMan.hasKey("ONEDRIVE_SECRET", ConfMan.kCloudDomain)) {
|
||||||
warning("No OneDrive keys available, cannot do auth");
|
warning("No OneDrive keys available, cannot do auth");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadKeyAndSecret();
|
loadKeyAndSecret();
|
||||||
|
|
||||||
if (CloudConfig.hasKey("onedrive_code")) {
|
if (ConfMan.hasKey("onedrive_code", ConfMan.kCloudDomain)) {
|
||||||
//phase 2: get access_token using specified code
|
//phase 2: get access_token using specified code
|
||||||
new OneDriveStorage(CloudConfig.get("onedrive_code"));
|
new OneDriveStorage(ConfMan.get("onedrive_code", ConfMan.kCloudDomain));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ MODULE_OBJS := \
|
||||||
|
|
||||||
ifdef USE_CLOUD
|
ifdef USE_CLOUD
|
||||||
MODULE_OBJS += \
|
MODULE_OBJS += \
|
||||||
cloud/cloudconfighelper.o \
|
|
||||||
cloud/cloudmanager.o \
|
cloud/cloudmanager.o \
|
||||||
cloud/iso8601.o \
|
cloud/iso8601.o \
|
||||||
cloud/storage.o \
|
cloud/storage.o \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue