Commit graph

20 commits

Author SHA1 Message Date
Alexander Tkachev
0aea8db7e1 CLOUD: Make Storage::savesSync() restart
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-24 16:07:55 +06:00
Alexander Tkachev
f0d61084da CLOUD: Update downloading in Storages
Id should be used everywhere.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
60add0df1b CLOUD: Update Requests to use StorageFile::id()
Only two places to update, as others still require id resolving.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
0ce7be17d3 CLOUD: Make ProgressDialog display downloading progress 2016-08-24 16:07:55 +06:00
Alexander Tkachev
e9721976aa GUI: Add SaveLoadCloudSyncProgressDialog
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-24 16:07:55 +06:00
Alexander Tkachev
8de2862eaa CLOUD: Update syncSaves() to return SavesSyncRequest *
So other classes could use that information without casting.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
5a695040d8 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.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
e98b0b12ad CLOUD: Extend Storage & SavesSyncRequest
Now one can learn whether SavesSyncRequest is running, its progress and
which files are being synced.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
00d8d23236 CLOUD: Add mutexes in Storage 2016-08-24 16:07:55 +06:00
Alexander Tkachev
a66322408f CLOUD: Implement Storage's isWorking()
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-24 16:07:55 +06:00
Alexander Tkachev
675e7a6ed1 CLOUD: Move download methods into Storage
DownloadRequest and FolderDownloadRequest are using other Storage's
methods. Thus, download() and downloadFolder() could be implemented in
base Storage class.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
0d0033fb6a CLOUD: Make syncSaves() common for all Storages
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-24 16:07:55 +06:00
Alexander Tkachev
b39f46788a CLOUD: Add OneDriveUploadRequest
Doesn't support server's requested ranges yet.

Commit also adds some PUT-related code in NetworkReadStream and
CurlRequest.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
0a947618fb CLOUD: Make ConnectionManager singleton
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-24 16:07:55 +06:00
Alexander Tkachev
01abba4f1d CLOUD: Add ConnectionManager and NetworkReadStream
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-24 16:07:55 +06:00
Alexander Tkachev
8b585d631b CLOUD: Add CurlRequest
CurlRequest uses own multi_handle, in which it creates an easy_handle to
make a request.

Every time `handle()` is called it checks whether request is complete
and, if it is, stops.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
6ad983bb72 CLOUD: Fix GCC static cloudThread compile error
It's not static anymore.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
1b89e25580 CLOUD: Add first Request
Just fooling around with the example Request, but the idea works well.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b272bba751 CLOUD: Do minor fixes 2016-08-24 16:07:55 +06:00
Alexander Tkachev
ca2eeb2214 CLOUD: Add Cloud::Manager and Cloud::Storage
This commit introduces Common::CloudManager, which can be accessed from
OSystem.

The backend for this manager is Cloud::Manager (defined in
backends/cloud/manager.h). It should load all users storages from
configs and provide access to current Storage instance. For now it just
creates a new one.

Cloud::Storage (backends/cloud/storage.h) provides an API to interact
with cloud storage, for example, create new directory or sync files.
Right now it's not ready and has only two dummy methods: listDirectory()
and syncSaves().

There is Cloud::Dropbox::DropboxStorage backend
(backends/cloud/dropbox/dropboxstorage.h) for Cloud::Storage. Right now
it implements both listDirectory() and syncSaves() with starting timer
task and handling it by printing out some JSON examples.
2016-08-24 16:05:07 +06:00