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
|
@ -26,7 +26,8 @@
|
|||
#include "backends/cloud/googledrive/googledrivestorage.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/translation.h"
|
||||
#include "backends/cloud/cloudconfighelper.h"
|
||||
#include "common/config-manager.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
|
@ -77,6 +78,9 @@ void CloudManager::loadStorage() {
|
|||
}
|
||||
|
||||
void CloudManager::init() {
|
||||
Common::String oldDomain = ConfMan.getActiveDomainName();
|
||||
ConfMan.setActiveDomain(ConfMan.kCloudDomain);
|
||||
|
||||
//init configs structs
|
||||
for (uint32 i = 0; i < kStorageTotal; ++i) {
|
||||
Common::String name = getStorageConfigName(i);
|
||||
|
@ -85,36 +89,43 @@ void CloudManager::init() {
|
|||
config.username = "";
|
||||
config.lastSyncDate = "";
|
||||
config.usedBytes = 0;
|
||||
if (CloudConfig.hasKey(kStoragePrefix + name + "_username"))
|
||||
config.username = CloudConfig.get(kStoragePrefix + name + "_username");
|
||||
if (CloudConfig.hasKey(kStoragePrefix + name + "_lastSync"))
|
||||
config.lastSyncDate = CloudConfig.get(kStoragePrefix + name + "_lastSync");
|
||||
if (CloudConfig.hasKey(kStoragePrefix + name + "_usedBytes"))
|
||||
config.usedBytes = CloudConfig.get(kStoragePrefix + name + "_usedBytes").asUint64();
|
||||
if (ConfMan.hasKey(kStoragePrefix + name + "_username"))
|
||||
config.username = ConfMan.get(kStoragePrefix + name + "_username");
|
||||
if (ConfMan.hasKey(kStoragePrefix + name + "_lastSync"))
|
||||
config.lastSyncDate = ConfMan.get(kStoragePrefix + name + "_lastSync");
|
||||
if (ConfMan.hasKey(kStoragePrefix + name + "_usedBytes"))
|
||||
config.usedBytes = ConfMan.get(kStoragePrefix + name + "_usedBytes").asUint64();
|
||||
_storages.push_back(config);
|
||||
}
|
||||
|
||||
//load an active storage if there is any
|
||||
_currentStorageIndex = kStorageNoneId;
|
||||
if (CloudConfig.hasKey("current_storage"))
|
||||
_currentStorageIndex = CloudConfig.getInt("current_storage");
|
||||
if (ConfMan.hasKey("current_storage"))
|
||||
_currentStorageIndex = ConfMan.getInt("current_storage");
|
||||
|
||||
loadStorage();
|
||||
|
||||
ConfMan.setActiveDomain(oldDomain);
|
||||
}
|
||||
|
||||
void CloudManager::save() {
|
||||
Common::String oldDomain = ConfMan.getActiveDomainName();
|
||||
ConfMan.setActiveDomain(ConfMan.kCloudDomain);
|
||||
|
||||
for (uint32 i = 0; i < _storages.size(); ++i) {
|
||||
if (i == kStorageNoneId) continue;
|
||||
Common::String name = getStorageConfigName(i);
|
||||
CloudConfig.set(kStoragePrefix + name + "_username", _storages[i].username);
|
||||
CloudConfig.set(kStoragePrefix + name + "_lastSync", _storages[i].lastSyncDate);
|
||||
CloudConfig.set(kStoragePrefix + name + "_usedBytes", Common::String::format("%llu", _storages[i].usedBytes));
|
||||
ConfMan.set(kStoragePrefix + name + "_username", _storages[i].username);
|
||||
ConfMan.set(kStoragePrefix + name + "_lastSync", _storages[i].lastSyncDate);
|
||||
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)
|
||||
_activeStorage->saveConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
|
||||
CloudConfig.flushToDisk();
|
||||
ConfMan.flushToDisk();
|
||||
|
||||
ConfMan.setActiveDomain(oldDomain);
|
||||
}
|
||||
|
||||
void CloudManager::replaceStorage(Storage *storage, uint32 index) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue