2016-05-29 23:25:08 +06:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2016-09-03 12:46:38 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2021-12-26 18:47:58 +01:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-09-03 12:46:38 +02:00
|
|
|
*
|
|
|
|
* 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
|
2021-12-26 18:47:58 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-09-03 12:46:38 +02:00
|
|
|
*
|
|
|
|
*/
|
2016-05-29 23:25:08 +06:00
|
|
|
|
|
|
|
#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"
|
2016-05-30 02:23:29 +06:00
|
|
|
#include "common/hash-str.h"
|
2016-05-29 23:25:08 +06:00
|
|
|
|
|
|
|
namespace Cloud {
|
|
|
|
|
2022-07-31 14:45:13 +03:00
|
|
|
class SavesSyncRequest: public Networking::Request {
|
2016-05-29 23:25:08 +06:00
|
|
|
Storage *_storage;
|
|
|
|
Storage::BoolCallback _boolCallback;
|
|
|
|
Common::HashMap<Common::String, uint32> _localFilesTimestamps;
|
|
|
|
Common::Array<StorageFile> _filesToDownload;
|
|
|
|
Common::Array<Common::String> _filesToUpload;
|
|
|
|
StorageFile _currentDownloadingFile;
|
|
|
|
Common::String _currentUploadingFile;
|
|
|
|
Request *_workingRequest;
|
|
|
|
bool _ignoreCallback;
|
2016-06-05 00:06:36 +06:00
|
|
|
uint32 _totalFilesToHandle;
|
2016-06-10 15:01:56 +06:00
|
|
|
Common::String _date;
|
2022-07-31 18:08:29 +03:00
|
|
|
uint32 _bytesToDownload, _bytesDownloaded;
|
2016-05-29 23:25:08 +06:00
|
|
|
|
|
|
|
void start();
|
2016-05-31 01:51:32 +06:00
|
|
|
void directoryListedCallback(Storage::ListDirectoryResponse response);
|
|
|
|
void directoryListedErrorCallback(Networking::ErrorResponse error);
|
2016-05-31 21:47:57 +06:00
|
|
|
void directoryCreatedCallback(Storage::BoolResponse response);
|
|
|
|
void directoryCreatedErrorCallback(Networking::ErrorResponse error);
|
2016-05-31 01:51:32 +06:00
|
|
|
void fileDownloadedCallback(Storage::BoolResponse response);
|
|
|
|
void fileDownloadedErrorCallback(Networking::ErrorResponse error);
|
|
|
|
void fileUploadedCallback(Storage::UploadResponse response);
|
|
|
|
void fileUploadedErrorCallback(Networking::ErrorResponse error);
|
2016-05-29 23:25:08 +06:00
|
|
|
void downloadNextFile();
|
|
|
|
void uploadNextFile();
|
2021-11-17 00:50:16 +01:00
|
|
|
virtual void finishError(Networking::ErrorResponse error, Networking::RequestState state = Networking::FINISHED);
|
2016-06-21 17:07:23 +06:00
|
|
|
void finishSync(bool success);
|
2016-07-21 11:44:36 +06:00
|
|
|
|
2022-08-02 01:42:08 +03:00
|
|
|
uint32 getDownloadedBytes() const;
|
|
|
|
uint32 getBytesToDownload() const;
|
|
|
|
|
2016-05-29 23:25:08 +06:00
|
|
|
public:
|
2016-05-31 01:51:32 +06:00
|
|
|
SavesSyncRequest(Storage *storage, Storage::BoolCallback callback, Networking::ErrorCallback ecb);
|
2016-05-29 23:25:08 +06:00
|
|
|
virtual ~SavesSyncRequest();
|
|
|
|
|
|
|
|
virtual void handle();
|
2016-06-05 00:06:36 +06:00
|
|
|
virtual void restart();
|
|
|
|
|
2016-06-05 21:07:55 +06:00
|
|
|
/** Returns a number in range [0, 1], where 1 is "complete". */
|
2016-07-20 18:47:34 +06:00
|
|
|
double getDownloadingProgress() const;
|
2016-06-05 21:07:55 +06:00
|
|
|
|
2022-08-02 01:42:08 +03:00
|
|
|
/** Fills a struct with numbers about current sync downloading progress. */
|
|
|
|
void getDownloadingInfo(Storage::SyncDownloadingInfo &info) const;
|
|
|
|
|
2016-06-05 00:06:36 +06:00
|
|
|
/** Returns a number in range [0, 1], where 1 is "complete". */
|
2016-07-20 18:47:34 +06:00
|
|
|
double getProgress() const;
|
2016-06-05 00:06:36 +06:00
|
|
|
|
2016-06-05 00:13:33 +06:00
|
|
|
/** Returns an array of saves names which are not downloaded yet. */
|
|
|
|
Common::Array<Common::String> getFilesToDownload();
|
2016-05-29 23:25:08 +06:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Cloud
|
|
|
|
|
|
|
|
#endif
|