From c235aa29f997b9bd000be5424662b114957f1640 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sun, 29 May 2016 23:25:08 +0600 Subject: CLOUD: Add SavesSyncRequest sketch Never tested it, actually. It requires Storage to implement upload() method and me to find some way to get saves' ReadStream. The saveTimestamps() and loadTimestamps() part should be tested, other parts should work fine. --- backends/cloud/savessyncrequest.h | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 backends/cloud/savessyncrequest.h (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h new file mode 100644 index 0000000000..a8c54d44ad --- /dev/null +++ b/backends/cloud/savessyncrequest.h @@ -0,0 +1,63 @@ +/* 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_SAVESSYNCREQUEST_H +#define BACKENDS_CLOUD_SAVESSYNCREQUEST_H + +#include "backends/networking/curl/request.h" +#include "backends/cloud/storage.h" +#include "common/hashmap.h" + +namespace Cloud { + +class SavesSyncRequest: public Networking::Request { + Storage *_storage; + Storage::BoolCallback _boolCallback; + Common::HashMap _localFilesTimestamps; + Common::Array _filesToDownload; + Common::Array _filesToUpload; + StorageFile _currentDownloadingFile; + Common::String _currentUploadingFile; + Request *_workingRequest; + bool _ignoreCallback; + + void start(); + void directoryListedCallback(Storage::FileArrayResponse pair); + void fileDownloadedCallback(Storage::BoolResponse pair); + void fileUploadedCallback(Storage::BoolResponse pair); + void downloadNextFile(); + void uploadNextFile(); + void finishBool(bool success); + void loadTimestamps(); + void saveTimestamps(); +public: + SavesSyncRequest(Storage *storage, Storage::BoolCallback callback); + virtual ~SavesSyncRequest(); + + virtual void handle(); + virtual void restart(); + virtual void finish(); +}; + +} // End of namespace Cloud + +#endif -- cgit v1.2.3 From d917592099381402c2681b291d379bda78a1c3f7 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Mon, 30 May 2016 02:23:29 +0600 Subject: CLOUD: Add DropboxUploadRequest --- backends/cloud/savessyncrequest.h | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index a8c54d44ad..dd43cab2a0 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -26,6 +26,7 @@ #include "backends/networking/curl/request.h" #include "backends/cloud/storage.h" #include "common/hashmap.h" +#include "common/hash-str.h" namespace Cloud { -- cgit v1.2.3 From b9e3730ccd9a76101ef0cb8812f41c371a24d0d6 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Mon, 30 May 2016 13:35:53 +0600 Subject: CLOUD: Add UploadStatus struct It contains not just "success" flag, but also "file" struct, so the caller can find out some information about uploaded file - like timestamp. --- backends/cloud/savessyncrequest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index dd43cab2a0..dca1fb750b 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -44,7 +44,7 @@ class SavesSyncRequest: public Networking::Request { void start(); void directoryListedCallback(Storage::FileArrayResponse pair); void fileDownloadedCallback(Storage::BoolResponse pair); - void fileUploadedCallback(Storage::BoolResponse pair); + void fileUploadedCallback(Storage::UploadResponse pair); void downloadNextFile(); void uploadNextFile(); void finishBool(bool success); -- 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/savessyncrequest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index dca1fb750b..f2f2aba403 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -42,7 +42,7 @@ class SavesSyncRequest: public Networking::Request { bool _ignoreCallback; void start(); - void directoryListedCallback(Storage::FileArrayResponse pair); + void directoryListedCallback(Storage::ListDirectoryResponse pair); void fileDownloadedCallback(Storage::BoolResponse pair); void fileUploadedCallback(Storage::UploadResponse pair); void downloadNextFile(); -- cgit v1.2.3 From af37ecca3430c871ec8a03bcada90303e6bf9877 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Mon, 30 May 2016 21:21:31 +0600 Subject: CLOUD: Make SavesSyncRequest work It now actually read the "timestamps" file, loads and saves files as it should, ignores Dropbox's "not_found" error. --- backends/cloud/savessyncrequest.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index f2f2aba403..da7b27e9b6 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -31,6 +31,9 @@ namespace Cloud { class SavesSyncRequest: public Networking::Request { + const uint32 INVALID_TIMESTAMP = UINT_MAX; + static const char *TIMESTAMPS_FILENAME; + Storage *_storage; Storage::BoolCallback _boolCallback; Common::HashMap _localFilesTimestamps; @@ -49,7 +52,8 @@ class SavesSyncRequest: public Networking::Request { void uploadNextFile(); void finishBool(bool success); void loadTimestamps(); - void saveTimestamps(); + void saveTimestamps(); + Common::String concatWithSavesPath(Common::String name); public: SavesSyncRequest(Storage *storage, Storage::BoolCallback callback); virtual ~SavesSyncRequest(); -- 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/savessyncrequest.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index da7b27e9b6..bf44b70390 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -45,22 +45,25 @@ class SavesSyncRequest: public Networking::Request { bool _ignoreCallback; void start(); - void directoryListedCallback(Storage::ListDirectoryResponse pair); - void fileDownloadedCallback(Storage::BoolResponse pair); - void fileUploadedCallback(Storage::UploadResponse pair); + void directoryListedCallback(Storage::ListDirectoryResponse response); + void directoryListedErrorCallback(Networking::ErrorResponse error); + void fileDownloadedCallback(Storage::BoolResponse response); + void fileDownloadedErrorCallback(Networking::ErrorResponse error); + void fileUploadedCallback(Storage::UploadResponse response); + void fileUploadedErrorCallback(Networking::ErrorResponse error); void downloadNextFile(); void uploadNextFile(); - void finishBool(bool success); + virtual void finishError(Networking::ErrorResponse error); + void finishSuccess(bool success); void loadTimestamps(); void saveTimestamps(); Common::String concatWithSavesPath(Common::String name); public: - SavesSyncRequest(Storage *storage, Storage::BoolCallback callback); + SavesSyncRequest(Storage *storage, Storage::BoolCallback callback, Networking::ErrorCallback ecb); virtual ~SavesSyncRequest(); virtual void handle(); - virtual void restart(); - virtual void finish(); + virtual void restart(); }; } // End of namespace Cloud -- cgit v1.2.3 From 06163cb8b907e30f8463b2b9700d136c73b19a33 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 31 May 2016 21:47:57 +0600 Subject: CLOUD: Fix SavesSyncRequest to create saves folder --- backends/cloud/savessyncrequest.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index bf44b70390..0e20159845 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -47,6 +47,8 @@ class SavesSyncRequest: public Networking::Request { void start(); void directoryListedCallback(Storage::ListDirectoryResponse response); void directoryListedErrorCallback(Networking::ErrorResponse error); + void directoryCreatedCallback(Storage::BoolResponse response); + void directoryCreatedErrorCallback(Networking::ErrorResponse error); void fileDownloadedCallback(Storage::BoolResponse response); void fileDownloadedErrorCallback(Networking::ErrorResponse error); void fileUploadedCallback(Storage::UploadResponse response); -- cgit v1.2.3 From e98b0b12adc9ac6440ec4940d595095115f00d23 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sun, 5 Jun 2016 00:06:36 +0600 Subject: CLOUD: Extend Storage & SavesSyncRequest Now one can learn whether SavesSyncRequest is running, its progress and which files are being synced. --- backends/cloud/savessyncrequest.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index 0e20159845..ad656107c9 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -43,6 +43,7 @@ class SavesSyncRequest: public Networking::Request { Common::String _currentUploadingFile; Request *_workingRequest; bool _ignoreCallback; + uint32 _totalFilesToHandle; void start(); void directoryListedCallback(Storage::ListDirectoryResponse response); @@ -65,7 +66,13 @@ public: virtual ~SavesSyncRequest(); virtual void handle(); - virtual void restart(); + virtual void restart(); + + /** Returns a number in range [0, 1], where 1 is "complete". */ + double getProgress(); + + /** Returns an array of saves names which are not uploaded yet. */ + Common::Array getFilesToUpload(); }; } // End of namespace Cloud -- cgit v1.2.3 From 5a695040d8cbd4e840e7c21e415d2225f9318ea2 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sun, 5 Jun 2016 00:13:33 +0600 Subject: CLOUD: Fix SavesSyncRequest to return right files Files we need are files to be downloaded, because that's what blocks us from reading/writing in those. --- backends/cloud/savessyncrequest.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index ad656107c9..6e74688493 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -71,8 +71,8 @@ public: /** Returns a number in range [0, 1], where 1 is "complete". */ double getProgress(); - /** Returns an array of saves names which are not uploaded yet. */ - Common::Array getFilesToUpload(); + /** Returns an array of saves names which are not downloaded yet. */ + Common::Array getFilesToDownload(); }; } // End of namespace Cloud -- cgit v1.2.3 From e7763700e2e2016f4573e3feb77b5fab69268683 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sun, 5 Jun 2016 15:44:05 +0600 Subject: CLOUD: Make Save/Load dialog start saves sync It also shows a "sync disabled" icon in case it has a savepath override. --- backends/cloud/savessyncrequest.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index 6e74688493..397a8cbcac 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -27,10 +27,11 @@ #include "backends/cloud/storage.h" #include "common/hashmap.h" #include "common/hash-str.h" +#include "gui/object.h" namespace Cloud { -class SavesSyncRequest: public Networking::Request { +class SavesSyncRequest: public Networking::Request, public GUI::CommandSender { const uint32 INVALID_TIMESTAMP = UINT_MAX; static const char *TIMESTAMPS_FILENAME; -- cgit v1.2.3 From 0ce7be17d3fec380f726c1ff16c559344b3e24c1 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sun, 5 Jun 2016 21:07:55 +0600 Subject: CLOUD: Make ProgressDialog display downloading progress --- backends/cloud/savessyncrequest.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index 397a8cbcac..569feb4e45 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -69,6 +69,9 @@ public: virtual void handle(); virtual void restart(); + /** Returns a number in range [0, 1], where 1 is "complete". */ + double getDownloadingProgress(); + /** Returns a number in range [0, 1], where 1 is "complete". */ double getProgress(); -- cgit v1.2.3 From 3e6503743c2f5d90c64bf37e943338c33fc58d2b Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Fri, 10 Jun 2016 15:01:56 +0600 Subject: CLOUD: Add Request::date() Used in SavesSyncRequest to update Storage's last sync date. --- backends/cloud/savessyncrequest.h | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index 569feb4e45..1a615e80a1 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -45,6 +45,7 @@ class SavesSyncRequest: public Networking::Request, public GUI::CommandSender { Request *_workingRequest; bool _ignoreCallback; uint32 _totalFilesToHandle; + Common::String _date; void start(); void directoryListedCallback(Storage::ListDirectoryResponse response); -- cgit v1.2.3 From a966de42a97dff932b6292f5021b7eb278310d1d Mon Sep 17 00:00:00 2001 From: Peter BozsoĢ Date: Sat, 11 Jun 2016 11:18:13 +0200 Subject: CLOUD: Fix compilation error in savesyncrequest.h "savessyncrequest.h:35:35: error: use of undeclared identifier 'UINT_MAX'" --- backends/cloud/savessyncrequest.h | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index 1a615e80a1..105d7f7f65 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -28,6 +28,7 @@ #include "common/hashmap.h" #include "common/hash-str.h" #include "gui/object.h" +#include namespace Cloud { -- cgit v1.2.3 From 65e87c6c70fc1e5af8f0c3fb762ca13e6aa6a8e4 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sat, 18 Jun 2016 19:35:57 +0600 Subject: CLOUD: Update save's timestamp on rewrite This commit moves save/load timestamps static methods into DefaultSaveFileManager and fixes a few related bugs. --- backends/cloud/savessyncrequest.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index 105d7f7f65..19e67d9dd8 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -28,14 +28,10 @@ #include "common/hashmap.h" #include "common/hash-str.h" #include "gui/object.h" -#include namespace Cloud { class SavesSyncRequest: public Networking::Request, public GUI::CommandSender { - const uint32 INVALID_TIMESTAMP = UINT_MAX; - static const char *TIMESTAMPS_FILENAME; - Storage *_storage; Storage::BoolCallback _boolCallback; Common::HashMap _localFilesTimestamps; @@ -61,9 +57,7 @@ class SavesSyncRequest: public Networking::Request, public GUI::CommandSender { void uploadNextFile(); virtual void finishError(Networking::ErrorResponse error); void finishSuccess(bool success); - void loadTimestamps(); - void saveTimestamps(); - Common::String concatWithSavesPath(Common::String name); + public: SavesSyncRequest(Storage *storage, Storage::BoolCallback callback, Networking::ErrorCallback ecb); virtual ~SavesSyncRequest(); -- 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/savessyncrequest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index 19e67d9dd8..d1a9d4a44c 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -56,7 +56,7 @@ class SavesSyncRequest: public Networking::Request, public GUI::CommandSender { void downloadNextFile(); void uploadNextFile(); virtual void finishError(Networking::ErrorResponse error); - void finishSuccess(bool success); + void finishSync(bool success); public: SavesSyncRequest(Storage *storage, Storage::BoolCallback callback, Networking::ErrorCallback ecb); -- 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/savessyncrequest.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index d1a9d4a44c..304c44407c 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -66,10 +66,10 @@ public: virtual void restart(); /** Returns a number in range [0, 1], where 1 is "complete". */ - double getDownloadingProgress(); + double getDownloadingProgress() const; /** Returns a number in range [0, 1], where 1 is "complete". */ - double getProgress(); + double getProgress() const; /** Returns an array of saves names which are not downloaded yet. */ Common::Array getFilesToDownload(); -- cgit v1.2.3 From 438ba985a4a97a8695a6e6fdda6930694976c07b Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Thu, 21 Jul 2016 11:44:36 +0600 Subject: JANITORIAL: Remove spaces at the end of the line I knew there were some, but I wanted to fix them once, instead of doing it all the time. --- backends/cloud/savessyncrequest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/cloud/savessyncrequest.h') diff --git a/backends/cloud/savessyncrequest.h b/backends/cloud/savessyncrequest.h index 304c44407c..e891e93969 100644 --- a/backends/cloud/savessyncrequest.h +++ b/backends/cloud/savessyncrequest.h @@ -57,7 +57,7 @@ class SavesSyncRequest: public Networking::Request, public GUI::CommandSender { void uploadNextFile(); virtual void finishError(Networking::ErrorResponse error); void finishSync(bool success); - + public: SavesSyncRequest(Storage *storage, Storage::BoolCallback callback, Networking::ErrorCallback ecb); virtual ~SavesSyncRequest(); -- cgit v1.2.3