aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud/cloudmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/cloud/cloudmanager.cpp')
-rw-r--r--backends/cloud/cloudmanager.cpp52
1 files changed, 47 insertions, 5 deletions
diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp
index 20c279323c..432a63b040 100644
--- a/backends/cloud/cloudmanager.cpp
+++ b/backends/cloud/cloudmanager.cpp
@@ -148,6 +148,12 @@ void CloudManager::replaceStorage(Storage *storage, uint32 index) {
}
_activeStorage = storage;
_currentStorageIndex = index;
+ if (_storages[index].username == "") {
+ // options' Cloud tab believes Storage is connected once it has non-empty username
+ _storages[index].username = _("<syncing...>");
+ _storages[index].lastSyncDate = _("<right now>");
+ _storages[index].usedBytes = 0;
+ }
save();
//do what should be done on first Storage connect
@@ -250,21 +256,21 @@ void CloudManager::setStorageLastSync(uint32 index, Common::String date) {
save();
}
-void CloudManager::connectStorage(uint32 index, Common::String code) {
+void CloudManager::connectStorage(uint32 index, Common::String code, Networking::ErrorCallback cb) {
freeStorages();
switch (index) {
case kStorageDropboxId:
- new Dropbox::DropboxStorage(code);
+ new Dropbox::DropboxStorage(code, cb);
break;
case kStorageOneDriveId:
- new OneDrive::OneDriveStorage(code);
+ new OneDrive::OneDriveStorage(code, cb);
break;
case kStorageGoogleDriveId:
- new GoogleDrive::GoogleDriveStorage(code);
+ new GoogleDrive::GoogleDriveStorage(code, cb);
break;
case kStorageBoxId:
- new Box::BoxStorage(code);
+ new Box::BoxStorage(code, cb);
break;
}
// in these constructors Storages request token using the passed code
@@ -273,6 +279,42 @@ void CloudManager::connectStorage(uint32 index, Common::String code) {
// thus, no memory leak happens
}
+void CloudManager::disconnectStorage(uint32 index) {
+ if (index >= kStorageTotal)
+ error("CloudManager::disconnectStorage: invalid index passed");
+
+ Common::String name = getStorageConfigName(index);
+ switch (index) {
+ case kStorageDropboxId:
+ Dropbox::DropboxStorage::removeFromConfig(kStoragePrefix + name + "_");
+ break;
+ case kStorageOneDriveId:
+ OneDrive::OneDriveStorage::removeFromConfig(kStoragePrefix + name + "_");
+ break;
+ case kStorageGoogleDriveId:
+ GoogleDrive::GoogleDriveStorage::removeFromConfig(kStoragePrefix + name + "_");
+ break;
+ case kStorageBoxId:
+ Box::BoxStorage::removeFromConfig(kStoragePrefix + name + "_");
+ break;
+ }
+
+ switchStorage(kStorageNoneId);
+
+ ConfMan.removeKey(kStoragePrefix + name + "_username", ConfMan.kCloudDomain);
+ ConfMan.removeKey(kStoragePrefix + name + "_lastSync", ConfMan.kCloudDomain);
+ ConfMan.removeKey(kStoragePrefix + name + "_usedBytes", ConfMan.kCloudDomain);
+
+ StorageConfig config;
+ config.name = _(name);
+ config.username = "";
+ config.lastSyncDate = "";
+ config.usedBytes = 0;
+
+ _storages[index] = config;
+}
+
+
Networking::Request *CloudManager::listDirectory(Common::String path, Storage::ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive) {
Storage *storage = getCurrentStorage();
if (storage) {