From 69aed03c4f6b23302836315502cd9abbb395415e Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sun, 5 Jun 2016 11:35:18 +0600 Subject: CLOUD: Add new CloudManager shortcuts CloudIcon can easily use CloudMan.isWorking() --- backends/cloud/cloudmanager.cpp | 24 ++++++++++++++++++++++++ backends/cloud/cloudmanager.h | 12 ++++++++++++ backends/networking/curl/cloudicon.cpp | 5 ++--- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp index 92e45e8811..20d75726af 100644 --- a/backends/cloud/cloudmanager.cpp +++ b/backends/cloud/cloudmanager.cpp @@ -126,4 +126,28 @@ void CloudManager::testFeature() { if (storage) storage->info(nullptr, nullptr); } +bool CloudManager::isWorking() { + Storage *storage = getCurrentStorage(); + if (storage) return storage->isWorking(); + return false; +} + +bool CloudManager::isSyncing() { + Storage *storage = getCurrentStorage(); + if (storage) return storage->isSyncing(); + return false; +} + +double CloudManager::getSyncProgress() { + Storage *storage = getCurrentStorage(); + if (storage) return storage->getSyncProgress(); + return 1; +} + +Common::Array CloudManager::getSyncingFiles() { + Storage *storage = getCurrentStorage(); + if (storage) return storage->getSyncingFiles(); + return Common::Array(); +} + } // End of namespace Common diff --git a/backends/cloud/cloudmanager.h b/backends/cloud/cloudmanager.h index a13eeebb94..fa3a87de8b 100644 --- a/backends/cloud/cloudmanager.h +++ b/backends/cloud/cloudmanager.h @@ -77,6 +77,18 @@ public: * Starts feature testing (the one I'm working on currently). (Temporary) */ void testFeature(); + + /** Returns whether there are any requests running. */ + bool isWorking(); + + /** Returns whether there is a SavesSyncRequest running. */ + bool isSyncing(); + + /** Returns a number in [0, 1] range which represents current sync progress (1 = complete). */ + double getSyncProgress(); + + /** Returns an array of saves names which are not yet synced (thus cannot be used). */ + Common::Array getSyncingFiles(); }; /** Shortcut for accessing the connection manager. */ diff --git a/backends/networking/curl/cloudicon.cpp b/backends/networking/curl/cloudicon.cpp index d6a6b517ba..882b0ab34c 100644 --- a/backends/networking/curl/cloudicon.cpp +++ b/backends/networking/curl/cloudicon.cpp @@ -43,9 +43,8 @@ CloudIcon::~CloudIcon() {} bool CloudIcon::draw() { bool stop = false; initIcons(); - - Cloud::Storage *storage = CloudMan.getCurrentStorage(); - if (storage && storage->isWorking()) { + + if (CloudMan.isWorking()) { if (g_system) { if (!_wasVisible) { g_system->clearOSD(); -- cgit v1.2.3