From 0ef1cda1724e973c36c76e07763f681cb14bd597 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Fri, 27 May 2016 20:59:40 +0600 Subject: CLOUD: Add FolderDownloadRequest Uses Storage's listDirectory() and download() methods to download contents. --- backends/cloud/folderdownloadrequest.h | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 backends/cloud/folderdownloadrequest.h (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h new file mode 100644 index 0000000000..038dc642ef --- /dev/null +++ b/backends/cloud/folderdownloadrequest.h @@ -0,0 +1,59 @@ +/* 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. +* +*/ + +#ifndef BACKENDS_CLOUD_FOLDERDOWNLOADREQUEST_H +#define BACKENDS_CLOUD_FOLDERDOWNLOADREQUEST_H + +#include "backends/networking/curl/request.h" +#include "backends/networking/curl/networkreadstream.h" +#include "backends/cloud/storage.h" +#include "common/file.h" + +namespace Cloud { + +class FolderDownloadRequest: public Networking::Request { + Storage *_storage; + Storage::FileArrayCallback _fileArrayCallback; + Common::String _remoteDirectoryPath, _localDirectoryPath; + bool _recursive; + Common::Array _files, _failedFiles; + StorageFile _currentFile; + Request *_workingRequest; + bool _ignoreCallback; + + void start(); + void directoryListedCallback(Storage::FileArrayResponse pair); + void fileDownloadedCallback(Storage::BoolResponse pair); + void downloadNextFile(); + void finishFiles(Common::Array &files); +public: + FolderDownloadRequest(Storage *storage, Storage::FileArrayCallback callback, Common::String remoteDirectoryPath, Common::String localDirectoryPath, bool recursive); + virtual ~FolderDownloadRequest() {} + + virtual void handle() {} + virtual void restart() { start(); } + virtual void finish(); +}; + +} //end of namespace Cloud + +#endif -- cgit v1.2.3 From b74d7a6861dbb5d0fafec0e6587deb7637b0ab12 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sat, 28 May 2016 01:18:37 +0600 Subject: CLOUD: Fix Requests destructors I forgot to delete callbacks! --- backends/cloud/folderdownloadrequest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index 038dc642ef..949bcad6ee 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -47,7 +47,7 @@ class FolderDownloadRequest: public Networking::Request { void finishFiles(Common::Array &files); public: FolderDownloadRequest(Storage *storage, Storage::FileArrayCallback callback, Common::String remoteDirectoryPath, Common::String localDirectoryPath, bool recursive); - virtual ~FolderDownloadRequest() {} + virtual ~FolderDownloadRequest(); virtual void handle() {} virtual void restart() { start(); } -- cgit v1.2.3 From 81c34adaef269524b1f53adcac722aa6a9730075 Mon Sep 17 00:00:00 2001 From: Peter Bozsó Date: Sat, 28 May 2016 20:10:38 +0200 Subject: Fix comment formatting --- backends/cloud/folderdownloadrequest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index 949bcad6ee..33fa5992c6 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -54,6 +54,6 @@ public: virtual void finish(); }; -} //end of namespace Cloud +} // End of namespace Cloud #endif -- cgit v1.2.3 From aa987e5c52899bfafff4f1f84479a67761569109 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Mon, 30 May 2016 18:13:31 +0600 Subject: CLOUD: Add ListDirectoryStatus struct It contains flags to indicate whether Request was interrupted or failed, so dependent Requests may see that list is incomplete. --- backends/cloud/folderdownloadrequest.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index 33fa5992c6..779ea3334f 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -26,7 +26,6 @@ #include "backends/networking/curl/request.h" #include "backends/networking/curl/networkreadstream.h" #include "backends/cloud/storage.h" -#include "common/file.h" namespace Cloud { @@ -41,7 +40,7 @@ class FolderDownloadRequest: public Networking::Request { bool _ignoreCallback; void start(); - void directoryListedCallback(Storage::FileArrayResponse pair); + void directoryListedCallback(Storage::ListDirectoryResponse pair); void fileDownloadedCallback(Storage::BoolResponse pair); void downloadNextFile(); void finishFiles(Common::Array &files); -- cgit v1.2.3 From eb63b50b7f0841e40365f3fbafa9810e8b190872 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 31 May 2016 01:51:32 +0600 Subject: CLOUD: Refactor Request Added ErrorResponse and ErrorCallback. Each Request now has an ErrorCallback, which should be called instead of usual callback in case of failure. --- backends/cloud/folderdownloadrequest.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index 779ea3334f..8fa3b1188b 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -40,17 +40,18 @@ class FolderDownloadRequest: public Networking::Request { bool _ignoreCallback; void start(); - void directoryListedCallback(Storage::ListDirectoryResponse pair); - void fileDownloadedCallback(Storage::BoolResponse pair); + void directoryListedCallback(Storage::ListDirectoryResponse response); + void directoryListedErrorCallback(Networking::ErrorResponse error); + void fileDownloadedCallback(Storage::BoolResponse response); + void fileDownloadedErrorCallback(Networking::ErrorResponse error); void downloadNextFile(); - void finishFiles(Common::Array &files); + void finishSuccess(Common::Array &files); public: - FolderDownloadRequest(Storage *storage, Storage::FileArrayCallback callback, Common::String remoteDirectoryPath, Common::String localDirectoryPath, bool recursive); + FolderDownloadRequest(Storage *storage, Storage::FileArrayCallback callback, Networking::ErrorCallback ecb, Common::String remoteDirectoryPath, Common::String localDirectoryPath, bool recursive); virtual ~FolderDownloadRequest(); - virtual void handle() {} - virtual void restart() { start(); } - virtual void finish(); + virtual void handle(); + virtual void restart(); }; } // End of namespace Cloud -- cgit v1.2.3 From f3a392359be2f6d05bac107a5f7bd168c178e428 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 21 Jun 2016 17:07:23 +0600 Subject: CLOUD: Fix finishSuccess() warning --- backends/cloud/folderdownloadrequest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index 8fa3b1188b..bf55567b2d 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -45,7 +45,7 @@ class FolderDownloadRequest: public Networking::Request { void fileDownloadedCallback(Storage::BoolResponse response); void fileDownloadedErrorCallback(Networking::ErrorResponse error); void downloadNextFile(); - void finishSuccess(Common::Array &files); + void finishDownload(Common::Array &files); public: FolderDownloadRequest(Storage *storage, Storage::FileArrayCallback callback, Networking::ErrorCallback ecb, Common::String remoteDirectoryPath, Common::String localDirectoryPath, bool recursive); virtual ~FolderDownloadRequest(); -- cgit v1.2.3 From b8ee9d4e7d32d0cc0dd832cbd0ffec5c5d08db34 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Mon, 4 Jul 2016 16:14:30 +0600 Subject: 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. --- backends/cloud/folderdownloadrequest.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index bf55567b2d..83d3432746 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -26,10 +26,11 @@ #include "backends/networking/curl/request.h" #include "backends/networking/curl/networkreadstream.h" #include "backends/cloud/storage.h" +#include "gui/object.h" namespace Cloud { -class FolderDownloadRequest: public Networking::Request { +class FolderDownloadRequest: public Networking::Request, public GUI::CommandSender { Storage *_storage; Storage::FileArrayCallback _fileArrayCallback; Common::String _remoteDirectoryPath, _localDirectoryPath; @@ -51,7 +52,10 @@ public: virtual ~FolderDownloadRequest(); virtual void handle(); - virtual void restart(); + virtual void restart(); + + /** Returns a number in range [0, 1], where 1 is "complete". */ + double getProgress(); }; } // End of namespace Cloud -- cgit v1.2.3 From ddb1a6ccb6238aaed599b271506a94a7c0f18844 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Mon, 4 Jul 2016 17:11:58 +0600 Subject: GUI: Upgrade DownloadDialog It now shows the remote and local directories and a progress bar. Storage now shows OSD messages on download success and failure. --- backends/cloud/folderdownloadrequest.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index 83d3432746..41eacc2afe 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -39,6 +39,7 @@ class FolderDownloadRequest: public Networking::Request, public GUI::CommandSend StorageFile _currentFile; Request *_workingRequest; bool _ignoreCallback; + uint32 _totalFiles; void start(); void directoryListedCallback(Storage::ListDirectoryResponse response); @@ -56,6 +57,12 @@ public: /** Returns a number in range [0, 1], where 1 is "complete". */ double getProgress(); + + /** Returns remote directory path. */ + Common::String getRemotePath() { return _remoteDirectoryPath; } + + /** Returns local directory path. */ + Common::String getLocalPath() { return _localDirectoryPath; } }; } // End of namespace Cloud -- cgit v1.2.3 From dfd68306de6f655a7bd2c68cea0b9299956ce8fc Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Thu, 14 Jul 2016 10:17:26 +0600 Subject: CLOUD: Upgrade FolderDownloadRequest::getProgress() Now NetworkReadStream, which is used in DownloadRequest, which is used in FolderDownloadRequest, returns progress information provided by libcurl. --- backends/cloud/folderdownloadrequest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index 41eacc2afe..a5f13b740b 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -56,7 +56,7 @@ public: virtual void restart(); /** Returns a number in range [0, 1], where 1 is "complete". */ - double getProgress(); + double getProgress() const; /** Returns remote directory path. */ Common::String getRemotePath() { return _remoteDirectoryPath; } -- cgit v1.2.3 From 7951a2ea167dee8c380ade40fefa95bb4d9baec1 Mon Sep 17 00:00:00 2001 From: Peter Bozsó Date: Thu, 14 Jul 2016 10:00:34 +0200 Subject: CLOUD: Rename _files to _pendingFiles in FolderDownloadRequest --- backends/cloud/folderdownloadrequest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index a5f13b740b..ee17de08dc 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -35,7 +35,7 @@ class FolderDownloadRequest: public Networking::Request, public GUI::CommandSend Storage::FileArrayCallback _fileArrayCallback; Common::String _remoteDirectoryPath, _localDirectoryPath; bool _recursive; - Common::Array _files, _failedFiles; + Common::Array _pendingFiles, _failedFiles; StorageFile _currentFile; Request *_workingRequest; bool _ignoreCallback; -- cgit v1.2.3 From 0ca791709329c3e7f24f68fa2da7c86c87dac557 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Thu, 14 Jul 2016 15:29:47 +0600 Subject: CLOUD: Update FolderDownloadRequest It now keeps track of downloaded bytes. --- backends/cloud/folderdownloadrequest.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index ee17de08dc..1a67f32165 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -40,6 +40,7 @@ class FolderDownloadRequest: public Networking::Request, public GUI::CommandSend Request *_workingRequest; bool _ignoreCallback; uint32 _totalFiles; + uint64 _downloadedBytes, _totalBytes; void start(); void directoryListedCallback(Storage::ListDirectoryResponse response); @@ -58,6 +59,12 @@ public: /** Returns a number in range [0, 1], where 1 is "complete". */ double getProgress() const; + /** Returns a number of downloaded bytes. */ + uint64 getDownloadedBytes() const; + + /** Returns a total number of bytes to download. */ + uint64 getTotalBytesToDownload() const; + /** Returns remote directory path. */ Common::String getRemotePath() { return _remoteDirectoryPath; } -- cgit v1.2.3 From c431ae6d84be1ef73c44b84c58ee3d9edff3d5e3 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Thu, 14 Jul 2016 16:01:05 +0600 Subject: CLOUD: Calculate FolderDownload download speed --- backends/cloud/folderdownloadrequest.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index 1a67f32165..9d8dea4d20 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -40,7 +40,7 @@ class FolderDownloadRequest: public Networking::Request, public GUI::CommandSend Request *_workingRequest; bool _ignoreCallback; uint32 _totalFiles; - uint64 _downloadedBytes, _totalBytes; + uint64 _downloadedBytes, _totalBytes, _wasDownloadedBytes, _currentDownloadSpeed; void start(); void directoryListedCallback(Storage::ListDirectoryResponse response); @@ -65,6 +65,9 @@ public: /** Returns a total number of bytes to download. */ uint64 getTotalBytesToDownload() const; + /** Returns average download speed for the last second. */ + uint64 getDownloadSpeed() const; + /** Returns remote directory path. */ Common::String getRemotePath() { return _remoteDirectoryPath; } -- cgit v1.2.3 From b180c73675846f45abab2190b39e0b9d0d6addbf Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 20 Jul 2016 18:47:34 +0600 Subject: CLOUD: Do some refactoring/cleanup Nothing really major. --- backends/cloud/folderdownloadrequest.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'backends/cloud/folderdownloadrequest.h') diff --git a/backends/cloud/folderdownloadrequest.h b/backends/cloud/folderdownloadrequest.h index 9d8dea4d20..08fa193e07 100644 --- a/backends/cloud/folderdownloadrequest.h +++ b/backends/cloud/folderdownloadrequest.h @@ -24,7 +24,6 @@ #define BACKENDS_CLOUD_FOLDERDOWNLOADREQUEST_H #include "backends/networking/curl/request.h" -#include "backends/networking/curl/networkreadstream.h" #include "backends/cloud/storage.h" #include "gui/object.h" @@ -69,10 +68,10 @@ public: uint64 getDownloadSpeed() const; /** Returns remote directory path. */ - Common::String getRemotePath() { return _remoteDirectoryPath; } + Common::String getRemotePath() const { return _remoteDirectoryPath; } /** Returns local directory path. */ - Common::String getLocalPath() { return _localDirectoryPath; } + Common::String getLocalPath() const { return _localDirectoryPath; } }; } // End of namespace Cloud -- cgit v1.2.3