diff options
author | Alexander Tkachev | 2016-06-10 15:01:56 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 3e6503743c2f5d90c64bf37e943338c33fc58d2b (patch) | |
tree | 3255606a88811badf45f14b4fa8cbbdc56d30964 /backends/cloud | |
parent | 6a93e8dd09ae2eeab616d14189a58633fd928c07 (diff) | |
download | scummvm-rg350-3e6503743c2f5d90c64bf37e943338c33fc58d2b.tar.gz scummvm-rg350-3e6503743c2f5d90c64bf37e943338c33fc58d2b.tar.bz2 scummvm-rg350-3e6503743c2f5d90c64bf37e943338c33fc58d2b.zip |
CLOUD: Add Request::date()
Used in SavesSyncRequest to update Storage's last sync date.
Diffstat (limited to 'backends/cloud')
16 files changed, 56 insertions, 0 deletions
diff --git a/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp b/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp index c077d8df11..61cc9ddfcd 100644 --- a/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp +++ b/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp @@ -68,6 +68,7 @@ void DropboxCreateDirectoryRequest::responseCallback(Networking::JsonResponse re delete json; return; } + if (response.request) _date = response.request->date(); Networking::ErrorResponse error(this); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; @@ -93,6 +94,7 @@ void DropboxCreateDirectoryRequest::responseCallback(Networking::JsonResponse re void DropboxCreateDirectoryRequest::errorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (error.request) _date = error.request->date(); finishError(error); } @@ -100,6 +102,8 @@ void DropboxCreateDirectoryRequest::handle() {} void DropboxCreateDirectoryRequest::restart() { start(); } +Common::String DropboxCreateDirectoryRequest::date() const { return _date; } + void DropboxCreateDirectoryRequest::finishSuccess(bool success) { Request::finishSuccess(); if (_boolCallback) (*_boolCallback)(Storage::BoolResponse(this, success)); diff --git a/backends/cloud/dropbox/dropboxcreatedirectoryrequest.h b/backends/cloud/dropbox/dropboxcreatedirectoryrequest.h index ea3175bb50..e8599c7df9 100644 --- a/backends/cloud/dropbox/dropboxcreatedirectoryrequest.h +++ b/backends/cloud/dropbox/dropboxcreatedirectoryrequest.h @@ -36,6 +36,7 @@ class DropboxCreateDirectoryRequest: public Networking::Request { Storage::BoolCallback _boolCallback; Request *_workingRequest; bool _ignoreCallback; + Common::String _date; void start(); void responseCallback(Networking::JsonResponse response); @@ -47,6 +48,7 @@ public: virtual void handle(); virtual void restart(); + virtual Common::String date() const; }; } // End of namespace Dropbox diff --git a/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp b/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp index d782f81a69..933ea2bd8e 100644 --- a/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp +++ b/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp @@ -71,6 +71,8 @@ void DropboxListDirectoryRequest::responseCallback(Networking::JsonResponse resp _workingRequest = nullptr; if (_ignoreCallback) return; + if (response.request) _date = response.request->date(); + Networking::ErrorResponse error(this); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq && rq->getNetworkReadStream()) @@ -137,6 +139,7 @@ void DropboxListDirectoryRequest::responseCallback(Networking::JsonResponse resp void DropboxListDirectoryRequest::errorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (error.request) _date = error.request->date(); finishError(error); } @@ -144,6 +147,8 @@ void DropboxListDirectoryRequest::handle() {} void DropboxListDirectoryRequest::restart() { start(); } +Common::String DropboxListDirectoryRequest::date() const { return _date; } + void DropboxListDirectoryRequest::finishSuccess(Common::Array<StorageFile> &files) { Request::finishSuccess(); if (_listDirectoryCallback) (*_listDirectoryCallback)(Storage::ListDirectoryResponse(this, files)); diff --git a/backends/cloud/dropbox/dropboxlistdirectoryrequest.h b/backends/cloud/dropbox/dropboxlistdirectoryrequest.h index 3a83af06aa..0d96edd1e6 100644 --- a/backends/cloud/dropbox/dropboxlistdirectoryrequest.h +++ b/backends/cloud/dropbox/dropboxlistdirectoryrequest.h @@ -40,6 +40,7 @@ class DropboxListDirectoryRequest: public Networking::Request { Common::Array<StorageFile> _files; Request *_workingRequest; bool _ignoreCallback; + Common::String _date; void start(); void responseCallback(Networking::JsonResponse response); @@ -51,6 +52,7 @@ public: virtual void handle(); virtual void restart(); + virtual Common::String date() const; }; } // End of namespace Dropbox diff --git a/backends/cloud/googledrive/googledrivecreatedirectoryrequest.cpp b/backends/cloud/googledrive/googledrivecreatedirectoryrequest.cpp index 54eff3d6ad..2b7a805bb9 100644 --- a/backends/cloud/googledrive/googledrivecreatedirectoryrequest.cpp +++ b/backends/cloud/googledrive/googledrivecreatedirectoryrequest.cpp @@ -63,12 +63,14 @@ void GoogleDriveCreateDirectoryRequest::start() { void GoogleDriveCreateDirectoryRequest::createdBaseDirectoryCallback(Storage::BoolResponse response) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (response.request) _date = response.request->date(); resolveId(); } void GoogleDriveCreateDirectoryRequest::createdBaseDirectoryErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (error.request) _date = error.request->date(); finishError(error); } @@ -85,6 +87,7 @@ void GoogleDriveCreateDirectoryRequest::resolveId() { void GoogleDriveCreateDirectoryRequest::idResolvedCallback(Storage::UploadResponse response) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (response.request) _date = response.request->date(); //resolved => folder already exists finishSuccess(false); @@ -93,6 +96,7 @@ void GoogleDriveCreateDirectoryRequest::idResolvedCallback(Storage::UploadRespon void GoogleDriveCreateDirectoryRequest::idResolveFailedCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (error.request) _date = error.request->date(); //not resolved => folder not exists if (error.response.contains("no such file found in its parent directory")) { @@ -116,12 +120,14 @@ void GoogleDriveCreateDirectoryRequest::idResolveFailedCallback(Networking::Erro void GoogleDriveCreateDirectoryRequest::createdDirectoryCallback(Storage::BoolResponse response) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (response.request) _date = response.request->date(); finishSuccess(response.value); } void GoogleDriveCreateDirectoryRequest::createdDirectoryErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (error.request) _date = error.request->date(); finishError(error); } @@ -129,6 +135,8 @@ void GoogleDriveCreateDirectoryRequest::handle() {} void GoogleDriveCreateDirectoryRequest::restart() { start(); } +Common::String GoogleDriveCreateDirectoryRequest::date() const { return _date; } + void GoogleDriveCreateDirectoryRequest::finishSuccess(bool success) { Request::finishSuccess(); if (_boolCallback) (*_boolCallback)(Storage::BoolResponse(this, success)); diff --git a/backends/cloud/googledrive/googledrivecreatedirectoryrequest.h b/backends/cloud/googledrive/googledrivecreatedirectoryrequest.h index ede84277de..f71afeb888 100644 --- a/backends/cloud/googledrive/googledrivecreatedirectoryrequest.h +++ b/backends/cloud/googledrive/googledrivecreatedirectoryrequest.h @@ -39,6 +39,7 @@ class GoogleDriveCreateDirectoryRequest: public Networking::Request { Storage::BoolCallback _boolCallback; Request *_workingRequest; bool _ignoreCallback; + Common::String _date; void start(); void createdBaseDirectoryCallback(Storage::BoolResponse response); @@ -55,6 +56,7 @@ public: virtual void handle(); virtual void restart(); + virtual Common::String date() const; }; } // End of namespace GoogleDrive diff --git a/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp b/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp index 86494e8c13..2530bab557 100644 --- a/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp +++ b/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp @@ -70,6 +70,7 @@ void GoogleDriveListDirectoryByIdRequest::makeRequest(Common::String pageToken) void GoogleDriveListDirectoryByIdRequest::responseCallback(Networking::JsonResponse response) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (response.request) _date = response.request->date(); Networking::ErrorResponse error(this); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; @@ -131,6 +132,7 @@ void GoogleDriveListDirectoryByIdRequest::responseCallback(Networking::JsonRespo void GoogleDriveListDirectoryByIdRequest::errorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (error.request) _date = error.request->date(); finishError(error); } @@ -138,6 +140,8 @@ void GoogleDriveListDirectoryByIdRequest::handle() {} void GoogleDriveListDirectoryByIdRequest::restart() { start(); } +Common::String GoogleDriveListDirectoryByIdRequest::date() const { return _date; } + void GoogleDriveListDirectoryByIdRequest::finishSuccess(Common::Array<StorageFile> &files) { Request::finishSuccess(); if (_listDirectoryCallback) (*_listDirectoryCallback)(Storage::ListDirectoryResponse(this, files)); diff --git a/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.h b/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.h index 569984520a..ceb533e635 100644 --- a/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.h +++ b/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.h @@ -41,6 +41,7 @@ class GoogleDriveListDirectoryByIdRequest: public Networking::Request { Common::Array<StorageFile> _files; Request *_workingRequest; bool _ignoreCallback; + Common::String _date; void start(); void makeRequest(Common::String pageToken); @@ -53,6 +54,7 @@ public: virtual void handle(); virtual void restart(); + virtual Common::String date() const; }; } // End of namespace GoogleDrive diff --git a/backends/cloud/googledrive/googledrivelistdirectoryrequest.cpp b/backends/cloud/googledrive/googledrivelistdirectoryrequest.cpp index 8811ffc938..3387b43418 100644 --- a/backends/cloud/googledrive/googledrivelistdirectoryrequest.cpp +++ b/backends/cloud/googledrive/googledrivelistdirectoryrequest.cpp @@ -58,6 +58,7 @@ void GoogleDriveListDirectoryRequest::start() { void GoogleDriveListDirectoryRequest::idResolvedCallback(Storage::UploadResponse response) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (response.request) _date = response.request->date(); StorageFile directory = response.value; directory.setPath(_requestedPath); @@ -68,6 +69,7 @@ void GoogleDriveListDirectoryRequest::idResolvedCallback(Storage::UploadResponse void GoogleDriveListDirectoryRequest::idResolveErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (error.request) _date = error.request->date(); finishError(error); } @@ -88,6 +90,7 @@ void GoogleDriveListDirectoryRequest::listNextDirectory() { void GoogleDriveListDirectoryRequest::listedDirectoryCallback(Storage::FileArrayResponse response) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (response.request) _date = response.request->date(); for (uint32 i = 0; i < response.value.size(); ++i) { StorageFile &file = response.value[i]; @@ -107,6 +110,7 @@ void GoogleDriveListDirectoryRequest::listedDirectoryCallback(Storage::FileArray void GoogleDriveListDirectoryRequest::listedDirectoryErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (error.request) _date = error.request->date(); finishError(error); } @@ -114,6 +118,8 @@ void GoogleDriveListDirectoryRequest::handle() {} void GoogleDriveListDirectoryRequest::restart() { start(); } +Common::String GoogleDriveListDirectoryRequest::date() const { return _date; } + void GoogleDriveListDirectoryRequest::finishSuccess(Common::Array<StorageFile> &files) { Request::finishSuccess(); if (_listDirectoryCallback) (*_listDirectoryCallback)(Storage::ListDirectoryResponse(this, files)); diff --git a/backends/cloud/googledrive/googledrivelistdirectoryrequest.h b/backends/cloud/googledrive/googledrivelistdirectoryrequest.h index bea195f70a..b3d8ff6c93 100644 --- a/backends/cloud/googledrive/googledrivelistdirectoryrequest.h +++ b/backends/cloud/googledrive/googledrivelistdirectoryrequest.h @@ -43,6 +43,7 @@ class GoogleDriveListDirectoryRequest: public Networking::Request { StorageFile _currentDirectory; Request *_workingRequest; bool _ignoreCallback; + Common::String _date; void start(); void idResolvedCallback(Storage::UploadResponse response); @@ -57,6 +58,7 @@ public: virtual void handle(); virtual void restart(); + virtual Common::String date() const; }; } // End of namespace GoogleDrive diff --git a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp index fe1128bd5b..2c644c42c5 100644 --- a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp +++ b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp @@ -87,6 +87,7 @@ void OneDriveCreateDirectoryRequest::responseCallback(Networking::JsonResponse r delete json; return; } + if (response.request) _date = response.request->date(); Networking::ErrorResponse error(this); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; @@ -112,6 +113,7 @@ void OneDriveCreateDirectoryRequest::responseCallback(Networking::JsonResponse r void OneDriveCreateDirectoryRequest::errorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (error.request) _date = error.request->date(); finishError(error); } @@ -119,6 +121,8 @@ void OneDriveCreateDirectoryRequest::handle() {} void OneDriveCreateDirectoryRequest::restart() { start(); } +Common::String OneDriveCreateDirectoryRequest::date() const { return _date; } + void OneDriveCreateDirectoryRequest::finishSuccess(bool success) { Request::finishSuccess(); if (_boolCallback) (*_boolCallback)(Storage::BoolResponse(this, success)); diff --git a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.h b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.h index 4bf0d9ef36..880e94e8db 100644 --- a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.h +++ b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.h @@ -38,6 +38,7 @@ class OneDriveCreateDirectoryRequest: public Networking::Request { Storage::BoolCallback _boolCallback; Request *_workingRequest; bool _ignoreCallback; + Common::String _date; void start(); void responseCallback(Networking::JsonResponse response); @@ -49,6 +50,7 @@ public: virtual void handle(); virtual void restart(); + virtual Common::String date() const; }; } // End of namespace OneDrive diff --git a/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp b/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp index 040ef153db..be6fcb70e7 100644 --- a/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp +++ b/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp @@ -94,6 +94,8 @@ void OneDriveListDirectoryRequest::listedDirectoryCallback(Networking::JsonRespo return; } + if (response.request) _date = response.request->date(); + Networking::ErrorResponse error(this); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq && rq->getNetworkReadStream()) @@ -138,6 +140,7 @@ void OneDriveListDirectoryRequest::listedDirectoryCallback(Networking::JsonRespo void OneDriveListDirectoryRequest::listedDirectoryErrorCallback(Networking::ErrorResponse error) { _workingRequest = nullptr; if (_ignoreCallback) return; + if (error.request) _date = error.request->date(); finishError(error); } @@ -145,6 +148,8 @@ void OneDriveListDirectoryRequest::handle() {} void OneDriveListDirectoryRequest::restart() { start(); } +Common::String OneDriveListDirectoryRequest::date() const { return _date; } + void OneDriveListDirectoryRequest::finishSuccess(Common::Array<StorageFile> &files) { Request::finishSuccess(); if (_listDirectoryCallback) (*_listDirectoryCallback)(Storage::ListDirectoryResponse(this, files)); diff --git a/backends/cloud/onedrive/onedrivelistdirectoryrequest.h b/backends/cloud/onedrive/onedrivelistdirectoryrequest.h index b8adfe7ef0..5e80f4f561 100644 --- a/backends/cloud/onedrive/onedrivelistdirectoryrequest.h +++ b/backends/cloud/onedrive/onedrivelistdirectoryrequest.h @@ -43,6 +43,7 @@ class OneDriveListDirectoryRequest: public Networking::Request { Common::String _currentDirectory; Request *_workingRequest; bool _ignoreCallback; + Common::String _date; void start(); void listNextDirectory(); @@ -56,6 +57,7 @@ public: virtual void handle(); virtual void restart(); + virtual Common::String date() const; }; } // End of namespace OneDrive diff --git a/backends/cloud/savessyncrequest.cpp b/backends/cloud/savessyncrequest.cpp index e1739f9693..f059e29a8d 100644 --- a/backends/cloud/savessyncrequest.cpp +++ b/backends/cloud/savessyncrequest.cpp @@ -76,6 +76,8 @@ void SavesSyncRequest::directoryListedCallback(Storage::ListDirectoryResponse re _workingRequest = nullptr; if (_ignoreCallback) return; + if (response.request) _date = response.request->date(); + Common::HashMap<Common::String, bool> localFileNotAvailableInCloud; for (Common::HashMap<Common::String, uint32>::iterator i = _localFilesTimestamps.begin(); i != _localFilesTimestamps.end(); ++i) { localFileNotAvailableInCloud[i->_key] = true; @@ -352,6 +354,9 @@ void SavesSyncRequest::finishSuccess(bool success) { //save updated timestamps (even if Request failed, there would be only valid timestamps) saveTimestamps(); + //update last successful sync date + CloudMan.setStorageLastSync(CloudMan.getStorageIndex(), _date); + if (_boolCallback) (*_boolCallback)(Storage::BoolResponse(this, success)); } 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); |