diff options
author | Alexander Tkachev | 2016-07-04 16:14:30 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | b8ee9d4e7d32d0cc0dd832cbd0ffec5c5d08db34 (patch) | |
tree | 8394f3ff0b9e272acd8840df82c56f316698e129 /gui | |
parent | 71a326493b351b845ea800ae88495238b1a61066 (diff) | |
download | scummvm-rg350-b8ee9d4e7d32d0cc0dd832cbd0ffec5c5d08db34.tar.gz scummvm-rg350-b8ee9d4e7d32d0cc0dd832cbd0ffec5c5d08db34.tar.bz2 scummvm-rg350-b8ee9d4e7d32d0cc0dd832cbd0ffec5c5d08db34.zip |
CLOUD: Add FolderDownload-related methods in Storage
CloudManager's shortcuts are added too.
The idea is to keep FolderDownload request within Storage, and provide
necessary means to access it. The download is started and cancelled
through the DownloadDialog.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/downloaddialog.cpp | 50 | ||||
-rw-r--r-- | gui/downloaddialog.h | 7 |
2 files changed, 6 insertions, 51 deletions
diff --git a/gui/downloaddialog.cpp b/gui/downloaddialog.cpp index d4c44e53ff..ac3b3d3c72 100644 --- a/gui/downloaddialog.cpp +++ b/gui/downloaddialog.cpp @@ -38,8 +38,7 @@ enum { }; DownloadDialog::DownloadDialog(uint32 storageId): - Dialog("GlobalOptions_Cloud_DownloadDialog"), _close(false), - _workingRequest(nullptr), _ignoreCallback(false) { + Dialog("GlobalOptions_Cloud_DownloadDialog"), _close(false) { _backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain; _browser = new BrowserDialog(_("Select directory where to download game data"), true); @@ -51,31 +50,13 @@ DownloadDialog::DownloadDialog(uint32 storageId): updateButtons(); } -DownloadDialog::~DownloadDialog() { - if (_workingRequest) { - _ignoreCallback = true; - _workingRequest->finish(); - } -} - -void DownloadDialog::close() { - if (_workingRequest) { - _ignoreCallback = true; - _workingRequest->finish(); - _ignoreCallback = false; - } - Dialog::close(); -} - void DownloadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case kDownloadDialogButtonCmd: { - if (_workingRequest == nullptr) { - selectDirectories(); + if (CloudMan.isDownloading()) { + CloudMan.cancelDownload(); } else { - _ignoreCallback = true; - _workingRequest->finish(); - _ignoreCallback = false; + selectDirectories(); } reflowLayout(); @@ -135,26 +116,7 @@ void DownloadDialog::selectDirectories() { if (backslashes > 0) localPath += '\\' + remoteDirectory.name(); else localPath += '/' + remoteDirectory.name(); - _workingRequest = CloudMan.downloadFolder( - remoteDirectory.path(), localPath, - new Common::Callback<DownloadDialog, Cloud::Storage::FileArrayResponse>(this, &DownloadDialog::directoryDownloadedCallback), - new Common::Callback<DownloadDialog, Networking::ErrorResponse>(this, &DownloadDialog::directoryDownloadedErrorCallback), - true - ); -} - -void DownloadDialog::directoryDownloadedCallback(Cloud::Storage::FileArrayResponse response) { - _workingRequest = nullptr; - if (_ignoreCallback) return; - - //TODO: show response.value (if not empty), show message on OSD -} - -void DownloadDialog::directoryDownloadedErrorCallback(Networking::ErrorResponse error) { - _workingRequest = nullptr; - if (_ignoreCallback) return; - - //TODO: _showError = true; + CloudMan.startDownload(remoteDirectory.path(), localPath); } void DownloadDialog::handleTickle() { @@ -172,7 +134,7 @@ void DownloadDialog::reflowLayout() { } void DownloadDialog::updateButtons() { - if (_workingRequest != nullptr) { + if (CloudMan.isDownloading()) { _messageText->setLabel(_("Press the button to cancel the download")); _mainButton->setLabel(_("Cancel the download")); } else { diff --git a/gui/downloaddialog.h b/gui/downloaddialog.h index 6836b38bb5..508e91adcb 100644 --- a/gui/downloaddialog.h +++ b/gui/downloaddialog.h @@ -46,19 +46,12 @@ class DownloadDialog : public Dialog { bool _close; - Networking::Request *_workingRequest; - bool _ignoreCallback; - void updateButtons(); void selectDirectories(); - void directoryDownloadedCallback(Cloud::Storage::FileArrayResponse response); - void directoryDownloadedErrorCallback(Networking::ErrorResponse error); public: DownloadDialog(uint32 storageId); - virtual ~DownloadDialog(); - virtual void close(); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void handleTickle(); virtual void reflowLayout(); |