aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud
diff options
context:
space:
mode:
authorPeter Bozsó2016-06-12 22:12:15 +0200
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commitfc3e7dec1a786c5990e37bd963838c235fba098b (patch)
tree0346c40d768c666dd12c374b2c804cf1c7eb7041 /backends/cloud
parent98788a5e7d0879d9f64e11e3d2308af2b03bc1de (diff)
downloadscummvm-rg350-fc3e7dec1a786c5990e37bd963838c235fba098b.tar.gz
scummvm-rg350-fc3e7dec1a786c5990e37bd963838c235fba098b.tar.bz2
scummvm-rg350-fc3e7dec1a786c5990e37bd963838c235fba098b.zip
CLOUD: Introduce kStoragePrefix in CloudManager
Diffstat (limited to 'backends/cloud')
-rw-r--r--backends/cloud/cloudmanager.cpp28
-rw-r--r--backends/cloud/cloudmanager.h2
2 files changed, 17 insertions, 13 deletions
diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp
index 8d12c0ff3a..83b06d9405 100644
--- a/backends/cloud/cloudmanager.cpp
+++ b/backends/cloud/cloudmanager.cpp
@@ -36,6 +36,8 @@ DECLARE_SINGLETON(Cloud::CloudManager);
namespace Cloud {
+const char *const CloudManager::kStoragePrefix = "storage_";
+
CloudManager::CloudManager() : _currentStorageIndex(0), _activeStorage(nullptr) {}
CloudManager::~CloudManager() {
@@ -57,13 +59,13 @@ Common::String CloudManager::getStorageConfigName(uint32 index) const {
void CloudManager::loadStorage() {
switch (_currentStorageIndex) {
case kStorageDropboxId:
- _activeStorage = Dropbox::DropboxStorage::loadFromConfig("storage_" + getStorageConfigName(_currentStorageIndex) + "_");
+ _activeStorage = Dropbox::DropboxStorage::loadFromConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
break;
case kStorageOneDriveId:
- _activeStorage = OneDrive::OneDriveStorage::loadFromConfig("storage_" + getStorageConfigName(_currentStorageIndex) + "_");
+ _activeStorage = OneDrive::OneDriveStorage::loadFromConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
break;
case kStorageGoogleDriveId:
- _activeStorage = GoogleDrive::GoogleDriveStorage::loadFromConfig("storage_" + getStorageConfigName(_currentStorageIndex) + "_");
+ _activeStorage = GoogleDrive::GoogleDriveStorage::loadFromConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
break;
default:
_activeStorage = nullptr;
@@ -83,12 +85,12 @@ void CloudManager::init() {
config.username = "";
config.lastSyncDate = "";
config.usedBytes = 0;
- if (ConfMan.hasKey("storage_" + name + "_username", "cloud"))
- config.username = ConfMan.get("storage_" + name + "_username", "cloud");
- if (ConfMan.hasKey("storage_" + name + "_lastSync", "cloud"))
- config.lastSyncDate = ConfMan.get("storage_" + name + "_lastSync", "cloud");
- if (ConfMan.hasKey("storage_" + name + "_usedBytes", "cloud"))
- config.usedBytes = ConfMan.get("storage_" + name + "_usedBytes", "cloud").asUint64();
+ if (ConfMan.hasKey(kStoragePrefix + name + "_username", "cloud"))
+ config.username = ConfMan.get(kStoragePrefix + name + "_username", "cloud");
+ if (ConfMan.hasKey(kStoragePrefix + name + "_lastSync", "cloud"))
+ config.lastSyncDate = ConfMan.get(kStoragePrefix + name + "_lastSync", "cloud");
+ if (ConfMan.hasKey(kStoragePrefix + name + "_usedBytes", "cloud"))
+ config.usedBytes = ConfMan.get(kStoragePrefix + name + "_usedBytes", "cloud").asUint64();
_storages.push_back(config);
}
@@ -104,14 +106,14 @@ void CloudManager::save() {
for (uint32 i = 0; i < _storages.size(); ++i) {
if (i == kStorageNoneId) continue;
Common::String name = getStorageConfigName(i);
- ConfMan.set("storage_" + name + "_username", _storages[i].username, "cloud");
- ConfMan.set("storage_" + name + "_lastSync", _storages[i].lastSyncDate, "cloud");
- ConfMan.set("storage_" + name + "_usedBytes", Common::String::format("%llu", _storages[i].usedBytes), "cloud");
+ ConfMan.set(kStoragePrefix + name + "_username", _storages[i].username, "cloud");
+ ConfMan.set(kStoragePrefix + name + "_lastSync", _storages[i].lastSyncDate, "cloud");
+ ConfMan.set(kStoragePrefix + name + "_usedBytes", Common::String::format("%llu", _storages[i].usedBytes), "cloud");
}
ConfMan.set("current_storage", Common::String::format("%d", _currentStorageIndex), "cloud");
if (_activeStorage)
- _activeStorage->saveConfig("storage_" + getStorageConfigName(_currentStorageIndex) + "_");
+ _activeStorage->saveConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
ConfMan.flushToDisk();
}
diff --git a/backends/cloud/cloudmanager.h b/backends/cloud/cloudmanager.h
index 48182dcde0..8e4c60eb4b 100644
--- a/backends/cloud/cloudmanager.h
+++ b/backends/cloud/cloudmanager.h
@@ -47,6 +47,8 @@ enum StorageID {
};
class CloudManager : public Common::Singleton<CloudManager> {
+ static const char *const kStoragePrefix;
+
struct StorageConfig {
Common::String name, username;
uint64 usedBytes;