diff options
author | Alexander Tkachev | 2016-07-21 14:50:24 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | bd8f2ed8250f902b9061f2c3688857390ceebe97 (patch) | |
tree | 37cd4cb8f00f5cad2bae0832628599c7b389d3ee /backends | |
parent | 8c62993769dd12d3ee96eba84f3b35d8c63f9269 (diff) | |
download | scummvm-rg350-bd8f2ed8250f902b9061f2c3688857390ceebe97.tar.gz scummvm-rg350-bd8f2ed8250f902b9061f2c3688857390ceebe97.tar.bz2 scummvm-rg350-bd8f2ed8250f902b9061f2c3688857390ceebe97.zip |
CLOUD: Fix some TODOs in CloudManager
"No Storage connected!" error message is passed to the error callback
now when there is no Storage connected to the CloudManager.
Diffstat (limited to 'backends')
-rw-r--r-- | backends/cloud/cloudmanager.cpp | 16 | ||||
-rw-r--r-- | backends/cloud/cloudmanager.h | 3 |
2 files changed, 15 insertions, 4 deletions
diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp index f5b7c97afc..056eb086c5 100644 --- a/backends/cloud/cloudmanager.cpp +++ b/backends/cloud/cloudmanager.cpp @@ -45,7 +45,6 @@ const char *const CloudManager::kStoragePrefix = "storage_"; CloudManager::CloudManager() : _currentStorageIndex(0), _activeStorage(nullptr) {} CloudManager::~CloudManager() { - //TODO: do we have to save storages on manager destruction? delete _activeStorage; freeStorages(); } @@ -161,6 +160,11 @@ void CloudManager::freeStorages() { _storagesToRemove.clear(); } +void CloudManager::passNoStorageConnected(Networking::ErrorCallback errorCallback) const { + if (errorCallback == nullptr) return; + (*errorCallback)(Networking::ErrorResponse(nullptr, false, true, "No Storage connected!", -1)); +} + Storage *CloudManager::getCurrentStorage() const { return _activeStorage; } @@ -249,9 +253,9 @@ Networking::Request *CloudManager::listDirectory(Common::String path, Storage::L Storage *storage = getCurrentStorage(); if (storage) return storage->listDirectory(path, callback, errorCallback, recursive); else { + passNoStorageConnected(errorCallback); delete callback; delete errorCallback; - //TODO: should we call errorCallback? } return nullptr; } @@ -260,9 +264,9 @@ Networking::Request *CloudManager::downloadFolder(Common::String remotePath, Com Storage *storage = getCurrentStorage(); if (storage) return storage->downloadFolder(remotePath, localPath, callback, errorCallback, recursive); else { + passNoStorageConnected(errorCallback); delete callback; delete errorCallback; - //TODO: should we call errorCallback? } return nullptr; } @@ -271,9 +275,9 @@ Networking::Request *CloudManager::info(Storage::StorageInfoCallback callback, N Storage *storage = getCurrentStorage(); if (storage) return storage->info(callback, errorCallback); else { + passNoStorageConnected(errorCallback); delete callback; delete errorCallback; - //TODO: should we call errorCallback? } return nullptr; } @@ -289,6 +293,10 @@ SavesSyncRequest *CloudManager::syncSaves(Storage::BoolCallback callback, Networ if (storage) { setStorageLastSync(_currentStorageIndex, "???"); //TODO get the date return storage->syncSaves(callback, errorCallback); + } else { + passNoStorageConnected(errorCallback); + delete callback; + delete errorCallback; } return nullptr; } diff --git a/backends/cloud/cloudmanager.h b/backends/cloud/cloudmanager.h index aad01338a9..c504ff39cb 100644 --- a/backends/cloud/cloudmanager.h +++ b/backends/cloud/cloudmanager.h @@ -68,6 +68,9 @@ class CloudManager : public Common::Singleton<CloudManager> { /** Frees memory used by storages which failed to connect. */ void freeStorages(); + /** Calls the error callback with a special "no storage connected" message. */ + void passNoStorageConnected(Networking::ErrorCallback errorCallback) const; + public: CloudManager(); virtual ~CloudManager(); |