2016-05-11 01:10:37 +06:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-06-01 16:22:42 +06:00
|
|
|
#include "backends/cloud/cloudmanager.h"
|
2016-07-13 00:33:35 +06:00
|
|
|
#include "backends/cloud/box/boxstorage.h"
|
2016-05-11 20:24:53 +06:00
|
|
|
#include "backends/cloud/dropbox/dropboxstorage.h"
|
2016-05-29 20:12:22 +06:00
|
|
|
#include "backends/cloud/onedrive/onedrivestorage.h"
|
2016-06-03 15:14:12 +06:00
|
|
|
#include "backends/cloud/googledrive/googledrivestorage.h"
|
2016-06-08 18:51:00 +06:00
|
|
|
#include "common/translation.h"
|
2016-06-14 20:47:03 +02:00
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/str.h"
|
2016-07-21 12:06:00 +06:00
|
|
|
#ifdef USE_SDL_NET
|
|
|
|
#include "backends/networking/sdl_net/localwebserver.h"
|
|
|
|
#endif
|
2016-05-11 01:10:37 +06:00
|
|
|
|
2016-06-01 16:22:42 +06:00
|
|
|
namespace Common {
|
|
|
|
|
|
|
|
DECLARE_SINGLETON(Cloud::CloudManager);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-11 20:24:53 +06:00
|
|
|
namespace Cloud {
|
2016-05-11 15:15:23 +06:00
|
|
|
|
2016-06-12 22:12:15 +02:00
|
|
|
const char *const CloudManager::kStoragePrefix = "storage_";
|
|
|
|
|
2016-06-09 13:49:52 +06:00
|
|
|
CloudManager::CloudManager() : _currentStorageIndex(0), _activeStorage(nullptr) {}
|
2016-05-11 15:15:23 +06:00
|
|
|
|
2016-06-01 16:22:42 +06:00
|
|
|
CloudManager::~CloudManager() {
|
2016-07-21 11:44:36 +06:00
|
|
|
//TODO: do we have to save storages on manager destruction?
|
2016-06-09 13:49:52 +06:00
|
|
|
delete _activeStorage;
|
2016-07-20 14:44:24 +06:00
|
|
|
freeStorages();
|
2016-05-23 11:23:33 +06:00
|
|
|
}
|
2016-05-11 15:15:23 +06:00
|
|
|
|
2016-06-09 13:49:52 +06:00
|
|
|
Common::String CloudManager::getStorageConfigName(uint32 index) const {
|
|
|
|
switch (index) {
|
|
|
|
case kStorageNoneId: return "<none>";
|
|
|
|
case kStorageDropboxId: return "Dropbox";
|
|
|
|
case kStorageOneDriveId: return "OneDrive";
|
|
|
|
case kStorageGoogleDriveId: return "GoogleDrive";
|
2016-07-13 00:33:35 +06:00
|
|
|
case kStorageBoxId: return "Box";
|
2016-06-09 13:49:52 +06:00
|
|
|
}
|
2016-06-12 21:32:29 +02:00
|
|
|
assert(false); // Unhandled StorageID value
|
2016-06-12 21:28:16 +02:00
|
|
|
return "";
|
2016-06-09 13:49:52 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CloudManager::loadStorage() {
|
|
|
|
switch (_currentStorageIndex) {
|
|
|
|
case kStorageDropboxId:
|
2016-06-12 22:12:15 +02:00
|
|
|
_activeStorage = Dropbox::DropboxStorage::loadFromConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
|
2016-06-09 13:49:52 +06:00
|
|
|
break;
|
|
|
|
case kStorageOneDriveId:
|
2016-06-12 22:12:15 +02:00
|
|
|
_activeStorage = OneDrive::OneDriveStorage::loadFromConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
|
2016-06-09 13:49:52 +06:00
|
|
|
break;
|
|
|
|
case kStorageGoogleDriveId:
|
2016-06-12 22:12:15 +02:00
|
|
|
_activeStorage = GoogleDrive::GoogleDriveStorage::loadFromConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
|
2016-06-09 13:49:52 +06:00
|
|
|
break;
|
2016-07-13 00:33:35 +06:00
|
|
|
case kStorageBoxId:
|
|
|
|
_activeStorage = Box::BoxStorage::loadFromConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
|
|
|
|
break;
|
2016-06-09 13:49:52 +06:00
|
|
|
default:
|
|
|
|
_activeStorage = nullptr;
|
2016-05-18 14:08:05 +06:00
|
|
|
}
|
2016-06-09 13:49:52 +06:00
|
|
|
|
|
|
|
if (!_activeStorage) {
|
|
|
|
_currentStorageIndex = kStorageNoneId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloudManager::init() {
|
|
|
|
//init configs structs
|
|
|
|
for (uint32 i = 0; i < kStorageTotal; ++i) {
|
|
|
|
Common::String name = getStorageConfigName(i);
|
|
|
|
StorageConfig config;
|
|
|
|
config.name = _(name);
|
|
|
|
config.username = "";
|
|
|
|
config.lastSyncDate = "";
|
|
|
|
config.usedBytes = 0;
|
2016-06-14 21:16:18 +02:00
|
|
|
if (ConfMan.hasKey(kStoragePrefix + name + "_username", ConfMan.kCloudDomain))
|
|
|
|
config.username = ConfMan.get(kStoragePrefix + name + "_username", ConfMan.kCloudDomain);
|
|
|
|
if (ConfMan.hasKey(kStoragePrefix + name + "_lastSync", ConfMan.kCloudDomain))
|
|
|
|
config.lastSyncDate = ConfMan.get(kStoragePrefix + name + "_lastSync", ConfMan.kCloudDomain);
|
|
|
|
if (ConfMan.hasKey(kStoragePrefix + name + "_usedBytes", ConfMan.kCloudDomain))
|
|
|
|
config.usedBytes = ConfMan.get(kStoragePrefix + name + "_usedBytes", ConfMan.kCloudDomain).asUint64();
|
2016-06-09 13:49:52 +06:00
|
|
|
_storages.push_back(config);
|
2016-05-18 14:08:05 +06:00
|
|
|
}
|
2016-06-09 13:49:52 +06:00
|
|
|
|
|
|
|
//load an active storage if there is any
|
|
|
|
_currentStorageIndex = kStorageNoneId;
|
2016-06-14 21:16:18 +02:00
|
|
|
if (ConfMan.hasKey("current_storage", ConfMan.kCloudDomain))
|
|
|
|
_currentStorageIndex = ConfMan.getInt("current_storage", ConfMan.kCloudDomain);
|
2016-06-09 13:49:52 +06:00
|
|
|
|
|
|
|
loadStorage();
|
2016-05-18 14:08:05 +06:00
|
|
|
}
|
|
|
|
|
2016-06-01 16:22:42 +06:00
|
|
|
void CloudManager::save() {
|
2016-06-09 14:23:14 +06:00
|
|
|
for (uint32 i = 0; i < _storages.size(); ++i) {
|
|
|
|
if (i == kStorageNoneId) continue;
|
|
|
|
Common::String name = getStorageConfigName(i);
|
2016-06-14 21:16:18 +02:00
|
|
|
ConfMan.set(kStoragePrefix + name + "_username", _storages[i].username, ConfMan.kCloudDomain);
|
|
|
|
ConfMan.set(kStoragePrefix + name + "_lastSync", _storages[i].lastSyncDate, ConfMan.kCloudDomain);
|
2016-06-21 16:58:09 +06:00
|
|
|
ConfMan.set(kStoragePrefix + name + "_usedBytes", Common::String::format("%llu", _storages[i].usedBytes), ConfMan.kCloudDomain);
|
2016-06-09 14:23:14 +06:00
|
|
|
}
|
|
|
|
|
2016-06-21 16:58:09 +06:00
|
|
|
ConfMan.set("current_storage", Common::String::format("%u", _currentStorageIndex), ConfMan.kCloudDomain);
|
2016-06-09 13:49:52 +06:00
|
|
|
if (_activeStorage)
|
2016-06-12 22:12:15 +02:00
|
|
|
_activeStorage->saveConfig(kStoragePrefix + getStorageConfigName(_currentStorageIndex) + "_");
|
2016-06-14 20:47:03 +02:00
|
|
|
ConfMan.flushToDisk();
|
2016-05-23 11:23:33 +06:00
|
|
|
}
|
|
|
|
|
2016-06-09 13:49:52 +06:00
|
|
|
void CloudManager::replaceStorage(Storage *storage, uint32 index) {
|
2016-07-20 14:44:24 +06:00
|
|
|
freeStorages();
|
2016-06-09 13:49:52 +06:00
|
|
|
if (!storage) error("CloudManager::replaceStorage: NULL storage passed");
|
|
|
|
if (index >= kStorageTotal) error("CloudManager::replaceStorage: invalid index passed");
|
2016-07-20 15:00:44 +06:00
|
|
|
if (_activeStorage != nullptr && _activeStorage->isWorking()) {
|
|
|
|
warning("CloudManager::replaceStorage: replacing Storage while the other is working");
|
|
|
|
if (_activeStorage->isDownloading()) _activeStorage->cancelDownload();
|
|
|
|
if (_activeStorage->isSyncing()) _activeStorage->cancelSync();
|
|
|
|
removeStorage(_activeStorage);
|
|
|
|
} else {
|
|
|
|
delete _activeStorage;
|
|
|
|
}
|
2016-06-09 13:49:52 +06:00
|
|
|
_activeStorage = storage;
|
|
|
|
_currentStorageIndex = index;
|
|
|
|
save();
|
2016-06-14 21:16:11 +06:00
|
|
|
|
|
|
|
//do what should be done on first Storage connect
|
|
|
|
if (_activeStorage) {
|
|
|
|
_activeStorage->info(nullptr, nullptr); //automatically calls setStorageUsername()
|
|
|
|
_activeStorage->syncSaves(nullptr, nullptr);
|
|
|
|
}
|
2016-05-24 16:19:22 +06:00
|
|
|
}
|
|
|
|
|
2016-07-20 14:44:24 +06:00
|
|
|
void CloudManager::removeStorage(Storage *storage) {
|
|
|
|
// can't just delete it as it's mostly likely the one who calls the method
|
|
|
|
// it would be freed on freeStorages() call (on next Storage connect or replace)
|
|
|
|
_storagesToRemove.push_back(storage);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloudManager::freeStorages() {
|
|
|
|
for (uint32 i = 0; i < _storagesToRemove.size(); ++i)
|
|
|
|
delete _storagesToRemove[i];
|
|
|
|
_storagesToRemove.clear();
|
|
|
|
}
|
|
|
|
|
2016-06-08 18:51:00 +06:00
|
|
|
Storage *CloudManager::getCurrentStorage() const {
|
2016-06-09 13:49:52 +06:00
|
|
|
return _activeStorage;
|
2016-06-08 18:51:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CloudManager::getStorageIndex() const {
|
|
|
|
return _currentStorageIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::StringArray CloudManager::listStorages() const {
|
|
|
|
Common::StringArray result;
|
|
|
|
for (uint32 i = 0; i < _storages.size(); ++i) {
|
2016-06-09 13:49:52 +06:00
|
|
|
result.push_back(_storages[i].name);
|
2016-06-08 18:51:00 +06:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CloudManager::switchStorage(uint32 index) {
|
2016-06-09 12:41:51 +06:00
|
|
|
if (index >= _storages.size()) {
|
2016-06-08 18:51:00 +06:00
|
|
|
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;
|
2016-06-09 13:49:52 +06:00
|
|
|
loadStorage();
|
2016-06-08 18:51:00 +06:00
|
|
|
save();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-09 12:41:51 +06:00
|
|
|
Common::String CloudManager::getStorageUsername(uint32 index) {
|
|
|
|
if (index >= _storages.size()) return "";
|
2016-06-09 13:49:52 +06:00
|
|
|
return _storages[index].username;
|
2016-06-09 12:41:51 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
uint64 CloudManager::getStorageUsedSpace(uint32 index) {
|
|
|
|
if (index >= _storages.size()) return 0;
|
2016-06-09 13:49:52 +06:00
|
|
|
return _storages[index].usedBytes;
|
2016-06-09 12:41:51 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::String CloudManager::getStorageLastSync(uint32 index) {
|
|
|
|
if (index >= _storages.size()) return "";
|
2016-06-09 13:49:52 +06:00
|
|
|
if (index == _currentStorageIndex && isSyncing()) return "";
|
|
|
|
return _storages[index].lastSyncDate;
|
2016-06-09 12:41:51 +06:00
|
|
|
}
|
|
|
|
|
2016-06-09 14:23:14 +06:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2016-06-10 16:35:23 +06:00
|
|
|
void CloudManager::connectStorage(uint32 index, Common::String code) {
|
2016-07-20 14:44:24 +06:00
|
|
|
freeStorages();
|
|
|
|
|
2016-06-10 16:35:23 +06:00
|
|
|
Storage *storage = nullptr;
|
|
|
|
switch (index) {
|
|
|
|
case kStorageDropboxId: storage = new Dropbox::DropboxStorage(code); break;
|
|
|
|
case kStorageOneDriveId: storage = new OneDrive::OneDriveStorage(code); break;
|
|
|
|
case kStorageGoogleDriveId: storage = new GoogleDrive::GoogleDriveStorage(code); break;
|
2016-07-13 00:33:35 +06:00
|
|
|
case kStorageBoxId: storage = new Box::BoxStorage(code); break;
|
2016-06-10 16:35:23 +06:00
|
|
|
}
|
2016-07-20 14:44:24 +06:00
|
|
|
// in these constructors Storages request token using the passed code
|
|
|
|
// when the token is received, they call replaceStorage()
|
|
|
|
// or removeStorage(), if some error occurred
|
2016-07-20 17:30:19 +06:00
|
|
|
// thus, no memory leak happens
|
2016-06-10 16:35:23 +06:00
|
|
|
}
|
|
|
|
|
2016-06-09 18:49:17 +06:00
|
|
|
Networking::Request *CloudManager::listDirectory(Common::String path, Storage::ListDirectoryCallback callback, Networking::ErrorCallback errorCallback, bool recursive) {
|
|
|
|
Storage *storage = getCurrentStorage();
|
2016-07-04 15:23:13 +06:00
|
|
|
if (storage) return storage->listDirectory(path, callback, errorCallback, recursive);
|
2016-06-09 18:49:17 +06:00
|
|
|
else {
|
|
|
|
delete callback;
|
|
|
|
delete errorCallback;
|
|
|
|
//TODO: should we call errorCallback?
|
2016-07-04 15:11:07 +06:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
Networking::Request *CloudManager::downloadFolder(Common::String remotePath, Common::String localPath, Storage::FileArrayCallback callback, Networking::ErrorCallback errorCallback, bool recursive) {
|
|
|
|
Storage *storage = getCurrentStorage();
|
2016-07-04 15:23:13 +06:00
|
|
|
if (storage) return storage->downloadFolder(remotePath, localPath, callback, errorCallback, recursive);
|
2016-07-04 15:11:07 +06:00
|
|
|
else {
|
|
|
|
delete callback;
|
|
|
|
delete errorCallback;
|
|
|
|
//TODO: should we call errorCallback?
|
2016-06-09 18:49:17 +06:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
Networking::Request *CloudManager::info(Storage::StorageInfoCallback callback, Networking::ErrorCallback errorCallback) {
|
|
|
|
Storage *storage = getCurrentStorage();
|
2016-07-19 15:27:26 +06:00
|
|
|
if (storage) return storage->info(callback, errorCallback);
|
2016-06-09 18:49:17 +06:00
|
|
|
else {
|
|
|
|
delete callback;
|
|
|
|
delete errorCallback;
|
|
|
|
//TODO: should we call errorCallback?
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::String CloudManager::savesDirectoryPath() {
|
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->savesDirectoryPath();
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2016-06-05 15:22:26 +06:00
|
|
|
SavesSyncRequest *CloudManager::syncSaves(Storage::BoolCallback callback, Networking::ErrorCallback errorCallback) {
|
2016-05-23 11:23:33 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
2016-06-09 14:23:14 +06:00
|
|
|
if (storage) {
|
|
|
|
setStorageLastSync(_currentStorageIndex, "???"); //TODO get the date
|
|
|
|
return storage->syncSaves(callback, errorCallback);
|
|
|
|
}
|
2016-06-05 15:22:26 +06:00
|
|
|
return nullptr;
|
2016-05-11 20:24:53 +06:00
|
|
|
}
|
2016-05-11 01:10:37 +06:00
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
bool CloudManager::isWorking() const {
|
2016-06-05 11:35:18 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->isWorking();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-21 12:06:00 +06:00
|
|
|
bool CloudManager::couldUseLocalServer() {
|
|
|
|
#ifdef USE_SDL_NET
|
|
|
|
return Networking::LocalWebserver::getPort() == Networking::LocalWebserver::DEFAULT_SERVER_PORT;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-07-04 16:14:30 +06:00
|
|
|
///// SavesSyncRequest-related /////
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
bool CloudManager::isSyncing() const {
|
2016-06-05 11:35:18 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->isSyncing();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
double CloudManager::getSyncDownloadingProgress() const {
|
2016-06-05 21:07:55 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->getSyncDownloadingProgress();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
double CloudManager::getSyncProgress() const {
|
2016-06-05 11:35:18 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->getSyncProgress();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
Common::Array<Common::String> CloudManager::getSyncingFiles() const {
|
2016-06-05 11:35:18 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->getSyncingFiles();
|
|
|
|
return Common::Array<Common::String>();
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
void CloudManager::cancelSync() const {
|
2016-06-05 20:20:22 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) storage->cancelSync();
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
void CloudManager::setSyncTarget(GUI::CommandReceiver *target) const {
|
2016-06-05 20:20:22 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) storage->setSyncTarget(target);
|
|
|
|
}
|
|
|
|
|
2016-07-04 16:14:30 +06:00
|
|
|
///// DownloadFolderRequest-related /////
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
bool CloudManager::startDownload(Common::String remotePath, Common::String localPath) const {
|
2016-07-04 16:14:30 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->startDownload(remotePath, localPath);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
void CloudManager::cancelDownload() const {
|
2016-07-04 16:14:30 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) storage->cancelDownload();
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
void CloudManager::setDownloadTarget(GUI::CommandReceiver *target) const {
|
2016-07-04 16:14:30 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) storage->setDownloadTarget(target);
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
bool CloudManager::isDownloading() const {
|
2016-07-04 16:14:30 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->isDownloading();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
double CloudManager::getDownloadingProgress() const {
|
2016-07-04 16:14:30 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->getDownloadingProgress();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
uint64 CloudManager::getDownloadBytesNumber() const {
|
2016-07-14 15:29:47 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->getDownloadBytesNumber();
|
2016-07-14 16:01:05 +06:00
|
|
|
return 0;
|
2016-07-14 15:29:47 +06:00
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
uint64 CloudManager::getDownloadTotalBytesNumber() const {
|
2016-07-14 15:29:47 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->getDownloadTotalBytesNumber();
|
2016-07-14 16:01:05 +06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
uint64 CloudManager::getDownloadSpeed() const {
|
2016-07-14 16:01:05 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->getDownloadSpeed();
|
|
|
|
return 0;
|
2016-07-14 15:29:47 +06:00
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
Common::String CloudManager::getDownloadRemoteDirectory() const {
|
2016-07-04 17:11:58 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->getDownloadRemoteDirectory();
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2016-07-20 18:47:34 +06:00
|
|
|
Common::String CloudManager::getDownloadLocalDirectory() const {
|
2016-07-04 17:11:58 +06:00
|
|
|
Storage *storage = getCurrentStorage();
|
|
|
|
if (storage) return storage->getDownloadLocalDirectory();
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2016-06-12 22:29:23 +02:00
|
|
|
} // End of namespace Cloud
|