ScummVM API documentation
folderdownloadrequest.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BACKENDS_CLOUD_FOLDERDOWNLOADREQUEST_H
23 #define BACKENDS_CLOUD_FOLDERDOWNLOADREQUEST_H
24 
25 #include "backends/networking/curl/request.h"
26 #include "backends/cloud/storage.h"
27 #include "gui/object.h"
28 
29 namespace Cloud {
30 
32  Storage *_storage;
33  Storage::FileArrayCallback _fileArrayCallback;
34  Common::String _remoteDirectoryPath;
35  Common::Path _localDirectoryPath;
36  bool _recursive;
37  Common::Array<StorageFile> _pendingFiles, _failedFiles;
38  StorageFile _currentFile;
39  Request *_workingRequest;
40  bool _ignoreCallback;
41  uint32 _totalFiles;
42  uint64 _downloadedBytes, _totalBytes, _wasDownloadedBytes, _currentDownloadSpeed;
43 
44  void start();
45  void directoryListedCallback(const Storage::ListDirectoryResponse &response);
46  void directoryListedErrorCallback(const Networking::ErrorResponse &error);
47  void fileDownloadedCallback(const Storage::BoolResponse &response);
48  void fileDownloadedErrorCallback(const Networking::ErrorResponse &error);
49  void downloadNextFile();
50  void finishDownload(Common::Array<StorageFile> &files);
51 public:
52  FolderDownloadRequest(Storage *storage, Storage::FileArrayCallback callback, Networking::ErrorCallback ecb, const Common::String &remoteDirectoryPath, const Common::Path &localDirectoryPath, bool recursive);
53  ~FolderDownloadRequest() override;
54 
55  void handle() override;
56  void restart() override;
57 
59  double getProgress() const;
60 
62  uint64 getDownloadedBytes() const;
63 
65  uint64 getTotalBytesToDownload() const;
66 
68  uint64 getDownloadSpeed() const;
69 
71  Common::String getRemotePath() const { return _remoteDirectoryPath; }
72 
74  Common::Path getLocalPath() const { return _localDirectoryPath; }
75 };
76 
77 } // End of namespace Cloud
78 
79 #endif
Definition: str.h:59
Common::String getRemotePath() const
Definition: folderdownloadrequest.h:71
Definition: basestorage.h:28
Definition: storage.h:47
Definition: request.h:73
Definition: array.h:52
Definition: path.h:52
Definition: request.h:47
uint64 getDownloadSpeed() const
Common::Path getLocalPath() const
Definition: folderdownloadrequest.h:74
Definition: callback.h:49
Definition: folderdownloadrequest.h:31
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: storagefile.h:42
uint64 getDownloadedBytes() const
uint64 getTotalBytesToDownload() const
Definition: object.h:40
Definition: request.h:119