diff options
author | Alexander Tkachev | 2016-06-08 18:51:00 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 870e96eb9ca6e69bea5f47a215d171fd58ab1265 (patch) | |
tree | 57516a6cc7bf5f2c6912e15b5ad4045c4b151c9e /backends/cloud/cloudmanager.cpp | |
parent | 1479d126520a9f3472797c1bb98b534f0b2a6b97 (diff) | |
download | scummvm-rg350-870e96eb9ca6e69bea5f47a215d171fd58ab1265.tar.gz scummvm-rg350-870e96eb9ca6e69bea5f47a215d171fd58ab1265.tar.bz2 scummvm-rg350-870e96eb9ca6e69bea5f47a215d171fd58ab1265.zip |
CLOUD: Update CloudManager and Storage
* Storage::name();
* CloudManager::getStorageName();
* CloudManager::getStorageIndex();
* CloudManager::listStorages();
* CloudManager::switchStorage().
Diffstat (limited to 'backends/cloud/cloudmanager.cpp')
-rw-r--r-- | backends/cloud/cloudmanager.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp index 7613b2cbbf..a9baac5d02 100644 --- a/backends/cloud/cloudmanager.cpp +++ b/backends/cloud/cloudmanager.cpp @@ -26,6 +26,7 @@ #include "backends/cloud/googledrive/googledrivestorage.h" #include "common/config-manager.h" #include "common/debug.h" +#include "common/translation.h" namespace Common { @@ -106,12 +107,47 @@ void CloudManager::addStorage(Storage *storage, bool makeCurrent, bool saveConfi if (saveConfig) save(); } -Storage *CloudManager::getCurrentStorage() { +Storage *CloudManager::getCurrentStorage() const { if (_currentStorageIndex < _storages.size()) return _storages[_currentStorageIndex]; return nullptr; } +Common::String CloudManager::getStorageName() const { + Storage *storage = getCurrentStorage(); + if (storage) return storage->name(); + return _("No active storage"); +} + +uint32 CloudManager::getStorageIndex() const { + return _currentStorageIndex; +} + +Common::StringArray CloudManager::listStorages() const { + Common::StringArray result; + for (uint32 i = 0; i < _storages.size(); ++i) { + result.push_back(_storages[i]->name()); + } + return result; +} + +bool CloudManager::switchStorage(uint32 index) { + if (index < 0 || index > _storages.size()) { + warning("CloudManager::switchStorage: invalid index passed"); + return false; + } + + Storage *storage = getCurrentStorage(); + if (storage && storage->isWorking()) { + warning("CloudManager::switchStorage: another storage is working now"); + return false; + } + + _currentStorageIndex = index; + save(); + return true; +} + void CloudManager::printBool(Storage::BoolResponse response) const { debug("bool = %s", (response.value ? "true" : "false")); } |