aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud/storage.h
AgeCommit message (Collapse)Author
2016-09-03JANITORIAL: Make GPL headers uniformEugene Sandulenko
2016-08-24CLOUD: Fix code formattingPeter Bozsó
2016-08-24JANITORIAL: Remove spaces at the end of the lineAlexander Tkachev
I knew there were some, but I wanted to fix them once, instead of doing it all the time.
2016-08-24CLOUD: Do some refactoring/cleanupAlexander Tkachev
Nothing really major.
2016-08-24CLOUD: Add default SavesSync callbacksAlexander Tkachev
With OSD messages indicating whether saves sync is complete, cancelled or failed.
2016-08-24CLOUD: Calculate FolderDownload download speedAlexander Tkachev
2016-08-24CLOUD: Update FolderDownloadRequestAlexander Tkachev
It now keeps track of downloaded bytes.
2016-08-24CLOUD: Cleanup in StoragesAlexander Tkachev
2016-08-24CLOUD: Add Storage::uploadStreamSupported()Alexander Tkachev
Box uses POST multipart/form requests for uploading. Such requests could be sent with libcurl if we either have a file available or a buffer with this file's contents. SavesSyncRequest was using Storage::upload(ReadStream *), which couldn't be implemented in BoxStorage. Thus I've added a method to test whether such upload is supported and, if it's not, SavesSyncRequest uses the other.
2016-08-24GUI: Upgrade DownloadDialogAlexander Tkachev
It now shows the remote and local directories and a progress bar. Storage now shows OSD messages on download success and failure.
2016-08-24CLOUD: Add FolderDownload-related methods in StorageAlexander Tkachev
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.
2016-08-24CLOUD: Make Storage::savesSync() restartAlexander Tkachev
If Storage::syncSaves() is called when sync is running, another sync would be automatically scheduled in the end of the current one. That could be helpful when we want to specify that we changed something during sync (created new save slot, for example).
2016-08-24GUI: Add Refresh button in Options Cloud tabAlexander Tkachev
Commit changes CloudManager and Storages so they would automatically refresh the fields when the could.
2016-08-24CLOUD: Update CloudManager and StorageAlexander Tkachev
* Storage::name(); * CloudManager::getStorageName(); * CloudManager::getStorageIndex(); * CloudManager::listStorages(); * CloudManager::switchStorage().
2016-08-24CLOUD: Update downloading in StoragesAlexander Tkachev
Id should be used everywhere.
2016-08-24CLOUD: Update Requests to use StorageFile::id()Alexander Tkachev
Only two places to update, as others still require id resolving.
2016-08-24CLOUD: Make ProgressDialog display downloading progressAlexander Tkachev
2016-08-24GUI: Add SaveLoadCloudSyncProgressDialogAlexander Tkachev
It's shown by SaveLoadChooserDialog when files are downloaded and some save slots are locked. One can hide that dialog to interact with non-locked slots or cancel saves sync completely. Dialog's label shows current sync progress. Dialog automatically hides itself when all files are downloaded. WARNING: right now that results in a crash!
2016-08-24CLOUD: Update syncSaves() to return SavesSyncRequest *Alexander Tkachev
So other classes could use that information without casting.
2016-08-24CLOUD: Extend Storage & SavesSyncRequestAlexander Tkachev
Now one can learn whether SavesSyncRequest is running, its progress and which files are being synced.
2016-08-24CLOUD: Add mutexes in StorageAlexander Tkachev
2016-08-24CLOUD: Implement Storage's isWorking()Alexander Tkachev
It now keeps track of how many Requests are running. To achieve that, we had to pass a callback to ConnectionManager, so each Request has a callback paired with it. If that's one of Storage's Requests, it has a callback, which would decrease a counter. When Storage adds a Request, it also increases a counter and passes that callback. Callback is called by ConnMan when Request is deleted. isWorking() returns true if there is at least one Request running.
2016-08-24CLOUD: Shorten Cloud APIAlexander Tkachev
touch() and isSyncing() are not needed. remove() is not needed too, but it could be used in the future.
2016-08-24CLOUD: Move download methods into StorageAlexander Tkachev
DownloadRequest and FolderDownloadRequest are using other Storage's methods. Thus, download() and downloadFolder() could be implemented in base Storage class.
2016-08-24CLOUD: Make syncSaves() common for all StoragesAlexander Tkachev
As it uses SavesSyncRequest and this request is using Storage's upload(), download() and listDirectory(), there is no need to make storage-dependent version of that request and so method could be implemented in base Storage.
2016-08-24CLOUD: Make SavesSyncRequest work with OneDriveAlexander Tkachev
It actually works fine, but small Storage::savesDirectoryPath() was added, because Dropbox's directories must start with a slash, and OneDrive's directories must not. Saves sync tested and it works fine with OneDrive.
2016-08-24CLOUD: Add OneDriveUploadRequestAlexander Tkachev
Doesn't support server's requested ranges yet. Commit also adds some PUT-related code in NetworkReadStream and CurlRequest.
2016-08-24CLOUD: Refactor RequestAlexander Tkachev
Added ErrorResponse and ErrorCallback. Each Request now has an ErrorCallback, which should be called instead of usual callback in case of failure.
2016-08-24CLOUD: Add ListDirectoryStatus structAlexander Tkachev
It contains flags to indicate whether Request was interrupted or failed, so dependent Requests may see that list is incomplete.
2016-08-24CLOUD: Add UploadStatus structAlexander Tkachev
It contains not just "success" flag, but also "file" struct, so the caller can find out some information about uploaded file - like timestamp.
2016-08-24CLOUD: Add DropboxUploadRequestAlexander Tkachev
2016-08-24Fix comment formattingPeter Bozsó
2016-08-24CLOUD: Add OneDriveStorage::downloadFolder()Alexander Tkachev
Just uses FolderDownloadRequest the way DropboxStorage does.
2016-08-24CLOUD: Refactor ConnectionManager/Requests systemAlexander Tkachev
ConnectionManager now storages Request * (not generates ids for it), Requests have control on their RequestState, RequestIdPair is now called Response and storages Request * with some response together. All related classes are changed to use it in more clean and understandable way. Request, RequestState and Response are carefully commented/documented.
2016-08-24CLOUD: Make OneDriveStorage::download() work fineAlexander Tkachev
Well, it takes two API calls instead of one now, but there are no problems with expired token because of it. This commit changes Storage::streamFile() to pass NetworkReadStream * through callback.
2016-08-24CLOUD: Add RequestIdPair structAlexander Tkachev
Can be used with Callback<T> (means it's still type safe). It's used to pass not only Request id to user's callback, but also a value user wanted. void *data field is removed from RequestInfo.
2016-08-24CLOUD: Add Requests idAlexander Tkachev
(Upgrading ConnectionManager step by step.)
2016-08-24CLOUD: Make DownloadRequest write to local fileAlexander Tkachev
Tested with .jpg file. Transfer complete, CRC-32 is the same.
2016-08-24CLOUD: Add DownloadRequest stubAlexander Tkachev
It reads the passed NetworkReadStream and prints its contents onto console (for now). It would be writing contents into file. To simplify work with raw NetworkReadStream there is a new CurlRequest. It basically does nothing, but as ConnMan handles transfers only if there is an active Request, you need some Request to get NetworkReadStream working. Thus, there is a CurlRequest, which is active until NetworkReadStream is completely read. CurlRequest also has useful addHeader() and addPostField() methods in order to customize the request easily. Use execute() method to get its NetworkReadStream. DropboxStorage implements streamFile() and download() API methods. As DownloadRequest is incomplete, it is not actually downloading a file, though.
2016-08-24CLOUD: Add DropboxStorage::listDirectory sketchAlexander Tkachev
It doesn't support any "has_more", doesn't call user's callback and just prints JSON instead of parsing in into an array of files. I believe it would become DropboxListDirectoryRequest in the next commit.
2016-08-24CLOUD: Add Storage saving mechanismAlexander Tkachev
In this commit CloudManager starts supporting multiple Storage. Now, in its init() it loads all the Storages and determines the current one. It now also has save() method. In that method all Storages are saved with their new saveConfig() method. CloudManager::save() not called from anywhere, though. The only one Storage that could be added is DropboxStorage in case you have no cloud-related config keys or you have no storages connected.
2016-08-24CLOUD: Add Callback typedefsAlexander Tkachev
And do some minor cleanup work.
2016-08-24CLOUD: Polish CallbacksAlexander Tkachev
Cleaned up all example code and old callbacks. New Callback classes are introduced in "common/callback.h" and documented.
2016-08-24CLOUD: Add complex callbacksAlexander Tkachev
Originally, I intended to add Storage API, StorageFile and StorageInfo stubs. When I tried to implement a simple info() call, I ended up fixing Request to contain some pointer field and all callbacks to have Request* parameter. And, now I have to place callback pointer into Request. which calls another callback. And, eventually, these "simple" callbacks would again require another pointer (to some caller class).
2016-08-24CLOUD: Make ConnectionManager singletonAlexander Tkachev
With ConnectionManager singleton one can start their Requests without creating Storage instance. Moreover, Storage instance should contain cloud API, not Requests-related handling and timer starting methods. Thus, these methods were moved into ConnectionManager itself.
2016-08-24CLOUD: Add Dropbox into CloudManager's configsAlexander Tkachev
This commit adds: * ConfMan's new "cloud" domain; * CloudManager's init() method, where it loads keys from "cloud" configs domain; * CurlJsonRequest's addHeader() and addPostField() methods; * temporary Storage's printInfo() method; * DropboxStorage's implementation of printInfo(), which is using access token and user id; * DropboxStorage's loadFromConfig() static method to load access token and user id from configs and create a Storage instance with those; * temporary DropboxStorage's authThroughConsole() static method, which guides user through auth process from the console. So, in CloudManager's init() implementation ScummVM checks that there is "current_storage_type" key in "cloud" domain of configs, and loads corresponding storage if there is such key. If there is no such key, ScummVM offers user to auth with Dropbox. That's done through console, and thus it's temporary (it also requires restarting ScummVM twice and manually editing config.ini file).
2016-08-24CLOUD: Rewrite NetworkReadStreamAlexander Tkachev
Now it is based on MemoryReadWriteStream, which is introduced by this commit. This stream is using ring buffer and is dynamically increasing its size when necessary.
2016-08-24CLOUD: Add ConnectionManager and NetworkReadStreamAlexander Tkachev
NetworkReadStream actually saves whole response in the memory now. There is a pause mechanism in libcurl, but if libcurl is requesting something compressed, it would have to uncompress data as it goes even if we paused the request. Even though our own stream won't be notified about this data when when "pause" the request, libcurl's own buffer wound be expanding.
2016-08-24CLOUD: Add first RequestAlexander Tkachev
Just fooling around with the example Request, but the idea works well.
2016-08-24CLOUD: Do minor fixesAlexander Tkachev