Commit graph

36 commits

Author SHA1 Message Date
Bastien Bouclet
edf82fea97 CLOUD: Remove the saves sync finished OSD message
It's not very good for immersion when it appears after an autosave. The
cloud icon is a good enough indication that cloud synchronization
happened.
2019-11-15 19:32:59 +01:00
Alexander Tkachev
f6a17e679f CLOUD: Ask user to manually enable Storage
For more security, newly connected Storage only gets username/used space
information and is disabled until user manually presses the button.
2019-07-30 14:51:41 -04:00
Thierry Crozat
8906868ee0 CLOUD: Use OSDMessageQueue to post OSD messages from the cloud thread 2016-10-29 15:13:32 +01:00
Thierry Crozat
a87a702eb2 ALL: Homogeneize use of 'saved game' in messages 2016-09-18 16:40:34 +01:00
Eugene Sandulenko
fab199d37e JANITORIAL: Make GPL headers uniform 2016-09-03 12:46:38 +02:00
Alexander Tkachev
15c6772ff7 ALL: Fix debug, warning and error usage
Added prefixes, used debug(9).
2016-08-24 16:07:55 +06:00
Eugene Sandulenko
d57fca4665 CLOUD: JANITORIAL: Fix code formatting 2016-08-24 16:07:55 +06:00
Alexander Tkachev
438ba985a4 JANITORIAL: Remove spaces at the end of the line
I knew there were some, but I wanted to fix them once, instead of doing
it all the time.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b180c73675 CLOUD: Do some refactoring/cleanup
Nothing really major.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
6753c18d6f CLOUD: Add default SavesSync callbacks
With OSD messages indicating whether saves sync is complete, cancelled
or failed.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
c431ae6d84 CLOUD: Calculate FolderDownload download speed 2016-08-24 16:07:55 +06:00
Alexander Tkachev
0ca7917093 CLOUD: Update FolderDownloadRequest
It now keeps track of downloaded bytes.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
5cbb3e8705 CLOUD: Add Storage::uploadStreamSupported()
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-24 16:07:55 +06:00
Alexander Tkachev
34ee1d29d5 CLOUD: Fix Storage::streamFile() 2016-08-24 16:07:55 +06:00
Alexander Tkachev
ddb1a6ccb6 GUI: Upgrade DownloadDialog
It now shows the remote and local directories and a progress bar.

Storage now shows OSD messages on download success and failure.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b8ee9d4e7d CLOUD: Add FolderDownload-related methods in Storage
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-24 16:07:55 +06:00
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