diff options
-rw-r--r-- | backends/cloud/cloudmanager.cpp | 31 | ||||
-rw-r--r-- | backends/cloud/cloudmanager.h | 27 | ||||
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.cpp | 5 | ||||
-rw-r--r-- | backends/cloud/googledrive/googledrivestorage.cpp | 3 | ||||
-rw-r--r-- | backends/cloud/onedrive/onedrivestorage.cpp | 2 |
5 files changed, 67 insertions, 1 deletions
diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp index 5c69e30520..a1b1ed1525 100644 --- a/backends/cloud/cloudmanager.cpp +++ b/backends/cloud/cloudmanager.cpp @@ -114,6 +114,14 @@ void CloudManager::init() { } 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("current_storage", Common::String::format("%d", _currentStorageIndex), "cloud"); if (_activeStorage) _activeStorage->saveConfig("storage_" + getStorageConfigName(_currentStorageIndex) + "_"); @@ -179,13 +187,34 @@ Common::String CloudManager::getStorageLastSync(uint32 index) { return _storages[index].lastSyncDate; } +void CloudManager::setStorageUsername(uint32 index, Common::String name) { + if (index >= _storages.size()) return; + _storages[index].username = name; + save(); +} + +void CloudManager::setStorageUsedSpace(uint32 index, uint64 used) { + if (index >= _storages.size()) return; + _storages[index].usedBytes = used; + save(); +} + +void CloudManager::setStorageLastSync(uint32 index, Common::String date) { + if (index >= _storages.size()) return; + _storages[index].lastSyncDate = date; + save(); +} + void CloudManager::printBool(Storage::BoolResponse response) const { debug("bool = %s", (response.value ? "true" : "false")); } SavesSyncRequest *CloudManager::syncSaves(Storage::BoolCallback callback, Networking::ErrorCallback errorCallback) { Storage *storage = getCurrentStorage(); - if (storage) return storage->syncSaves(callback, errorCallback); + if (storage) { + setStorageLastSync(_currentStorageIndex, "???"); //TODO get the date + return storage->syncSaves(callback, errorCallback); + } return nullptr; } diff --git a/backends/cloud/cloudmanager.h b/backends/cloud/cloudmanager.h index 5e26ece088..7ce7e925da 100644 --- a/backends/cloud/cloudmanager.h +++ b/backends/cloud/cloudmanager.h @@ -144,6 +144,33 @@ public: Common::String getStorageLastSync(uint32 index); /** + * Set Storage's username. + * Automatically saves changes to the config. + * + * @param index Storage's index. + * @param name username to set + */ + void setStorageUsername(uint32 index, Common::String name); + + /** + * Set Storage's used space field. + * Automatically saves changes to the config. + * + * @param index Storage's index. + * @param used value to set + */ + void setStorageUsedSpace(uint32 index, uint64 used); + + /** + * Set Storage's last sync date. + * Automatically saves changes to the config. + * + * @param index Storage's index. + * @param date date to set + */ + void setStorageLastSync(uint32 index, Common::String date); + + /** * Starts saves syncing process in currently active storage if there is any. */ SavesSyncRequest *syncSaves(Cloud::Storage::BoolCallback callback = nullptr, Networking::ErrorCallback errorCallback = nullptr); diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index af73138a4f..e59e19eef9 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -25,6 +25,7 @@ #include "backends/cloud/dropbox/dropboxcreatedirectoryrequest.h" #include "backends/cloud/dropbox/dropboxlistdirectoryrequest.h" #include "backends/cloud/dropbox/dropboxuploadrequest.h" +#include "backends/cloud/cloudmanager.h" #include "backends/networking/curl/connectionmanager.h" #include "backends/networking/curl/curljsonrequest.h" #include "common/config-manager.h" @@ -171,6 +172,10 @@ void DropboxStorage::infoInnerCallback(StorageInfoCallback outerCallback, Networ uint64 quotaNormal = quota.getVal("normal")->asIntegerNumber(); uint64 quotaShared = quota.getVal("shared")->asIntegerNumber(); uint64 quotaAllocated = quota.getVal("quota")->asIntegerNumber(); + + CloudMan.setStorageUsedSpace(kStorageDropboxId, quotaNormal + quotaShared); //TODO that's not ScummVM's actually + CloudMan.setStorageUsername(kStorageDropboxId, email); + (*outerCallback)(StorageInfoResponse(nullptr, StorageInfo(uid, name, email, quotaNormal+quotaShared, quotaAllocated))); delete outerCallback; } diff --git a/backends/cloud/googledrive/googledrivestorage.cpp b/backends/cloud/googledrive/googledrivestorage.cpp index 18ddca5e94..143b7ac52c 100644 --- a/backends/cloud/googledrive/googledrivestorage.cpp +++ b/backends/cloud/googledrive/googledrivestorage.cpp @@ -180,6 +180,9 @@ void GoogleDriveStorage::infoInnerCallback(StorageInfoCallback outerCallback, Ne quotaAllocated = atoull(limit); } + CloudMan.setStorageUsedSpace(kStorageGoogleDriveId, quotaUsed); //TODO that's not ScummVM's actually + CloudMan.setStorageUsername(kStorageGoogleDriveId, email); + (*outerCallback)(StorageInfoResponse(nullptr, StorageInfo(uid, name, email, quotaUsed, quotaAllocated))); delete outerCallback; } diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp index d73bcdbe34..82681756c4 100644 --- a/backends/cloud/onedrive/onedrivestorage.cpp +++ b/backends/cloud/onedrive/onedrivestorage.cpp @@ -159,6 +159,8 @@ void OneDriveStorage::infoInnerCallback(StorageInfoCallback outerCallback, Netwo quotaUsed = info.getVal("size")->asIntegerNumber(); } + CloudMan.setStorageUsedSpace(kStorageOneDriveId, quotaUsed); //TODO that's not ScummVM's actually + CloudMan.setStorageUsername(kStorageOneDriveId, email); (*outerCallback)(StorageInfoResponse(nullptr, StorageInfo(uid, name, email, quotaUsed, quotaAllocated))); delete outerCallback; } |