241 Commits

Author SHA1 Message Date
Alexander Tkachev
c968f0143c CLOUD: Make GoogleDriveResolveIdRequest case-insensitive 2016-08-24 16:07:55 +06:00
Alexander Tkachev
505d3764cb CLOUD: Fix GoogleDriveStorage to work with root folder
Now it needs another scope and uses "root" instead of "appDataFolder".
2016-08-24 16:07:55 +06:00
Alexander Tkachev
d1d71afb07 CLOUD: Add GoogleDriveListDirectoryRequest
When listing directories, you get a list of StorageFiles, which path()
is actually Google Drive id. Thus, if you list a directory recursively,
you won't be able to determine whether all files are within one
directory or have some hierarchy. I'd fix that as soon as it would be
needed.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b4b6ee0186 CLOUD: Add GoogleDriveCreateDirectory
Now we can create directories in Google Drive by path, not parent id +
directory name!
2016-08-24 16:07:55 +06:00
Alexander Tkachev
bb207ae513 CLOUD: Add GoogleDriveResolveIdRequest
GoogleDriveResolveIdRequest gets a lowercase path and searches for the
specified file's id. To do that it lists path's subdirectories one by
one with GoogleDriveListDirectoryByIdRequest.

GoogleDriveListDirectoryByIdRequest gets a Google Drive id and lists
that directory (not recursively).
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b614869de8 CLOUD: Minor fixes 2016-08-24 16:07:55 +06:00
Alexander Tkachev
6c5a8f34ea CLOUD: Add SaveLoadCloudSyncProgress enum
It's common for Save/Load dialogs and SavesSyncRequest.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
9eb4aad7fd CLOUD: Make DefaultSaveFileManager ignore syncing files
MetaEngines don't get "locked" files in the list, so won't try to open
these.

Save/Load dialog updates save list every time SavesSyncRequest tells it
to.
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
e7763700e2 CLOUD: Make Save/Load dialog start saves sync
It also shows a "sync disabled" icon in case it has a savepath override.
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
69aed03c4f CLOUD: Add new CloudManager shortcuts
CloudIcon can easily use CloudMan.isWorking()
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
1c823b6c1d CLOUD: Fix SavesSyncRequest
Now it would finish with error if spawned Request is nullptr.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
da3b7bd8d9 CLOUD: Add GoogleDriveStorage
It has its own GoogleDriveTokenRefresher and knows how to do info().

This commit also contains JSON int -> long long int fix and
CurlJsonRequest '\n' -> ' ' fix.
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
b3bf532211 CLOUD: Make CloudManager singleton
It's needed to ::destroy() it in main().
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
4b3a8be0b9 CLOUD: Shorten Cloud API
touch() and isSyncing() are not needed.

remove() is not needed too, but it could be used in the future.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
06163cb8b9 CLOUD: Fix SavesSyncRequest to create saves folder 2016-08-24 16:07:55 +06:00
Alexander Tkachev
8cdde307f7 CLOUD: Add OneDriveCreateDirectoryRequest 2016-08-24 16:07:55 +06:00
Alexander Tkachev
4e7dec5500 CLOUD: Add DropboxCreateDirectoryRequest
Also add CloudManager::testFeature(), because syncSaves() now works fine
and I don't want to break it again and again with my testing requests.
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
ca85d4482a CLOUD: Use uint64 in StorageInfo
There was a warning regarding 25 GB constant.

By the way, I'm not sure how to print uint64 (%llu is available in C99
only, and gcc produces a warning about that).
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
13351a730d CLOUD: Add OneDrive::info()
Unfortunately, OneDrive doesn't share quota information anymore because
of some reason. I had to get as much information as I could.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
3638c8348d CLOUD: Make SavesSyncRequest work with OneDrive
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-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
eb63b50b7f CLOUD: Refactor Request
Added ErrorResponse and ErrorCallback. Each Request now has an
ErrorCallback, which should be called instead of usual callback in case
of failure.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
001b417f33 CLOUD: Fix OneDriveTokenRefresher
It was calling finish(), causing stack overflow.

Some minor changes are added also.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
af37ecca34 CLOUD: Make SavesSyncRequest work
It now actually read the "timestamps" file, loads and saves files as it
should, ignores Dropbox's "not_found" error.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
aa987e5c52 CLOUD: Add ListDirectoryStatus struct
It contains flags to indicate whether Request was interrupted or failed,
so dependent Requests may see that list is incomplete.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
a19fc52c32 CLOUD: Make DropboxUploadRequest use "/upload" too
If file could be uploaded in one API call, no need to create a session
(which requires at least two calls: to start and then to finish it).
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b9e3730ccd CLOUD: Add UploadStatus struct
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-24 16:07:55 +06:00
Alexander Tkachev
d917592099 CLOUD: Add DropboxUploadRequest 2016-08-24 16:07:55 +06:00
Alexander Tkachev
c235aa29f9 CLOUD: Add SavesSyncRequest sketch
Never tested it, actually. It requires Storage to implement upload()
method and me to find some way to get saves' ReadStream.

The saveTimestamps() and loadTimestamps() part should be tested, other
parts should work fine.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
1747f8ec42 CLOUD: Add "device_id" into configuration file 2016-08-24 16:07:55 +06:00
Peter Bozsó
86d5b1b2e1 Remove some unnecessary blank lines 2016-08-24 16:07:55 +06:00
Peter Bozsó
81c34adaef Fix comment formatting 2016-08-24 16:07:55 +06:00
Peter Bozsó
f4dfaed19d Replace 0 constant with nullptr in getCurrentStorage() 2016-08-24 16:07:55 +06:00
Alexander Tkachev
6f35fc4272 CLOUD: Add OneDriveStorage::downloadFolder()
Just uses FolderDownloadRequest the way DropboxStorage does.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b74d7a6861 CLOUD: Fix Requests destructors
I forgot to delete callbacks!
2016-08-24 16:07:55 +06:00
Alexander Tkachev
827c7e43da CLOUD: Add OneDriveListDirectoryRequest
Works as charm.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
14d60e62f8 CLOUD: Fix format string warnings
I get 'warning: ISO C++98 does not support the '%lg' ms_printf format'
warning though.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
8aa87815a6 CLOUD: Fix "global destructor" warning
Plain char * is used instead of Common::String in DropboxStorage and
OneDriveStorage's KEY and SECRET.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
0ef1cda172 CLOUD: Add FolderDownloadRequest
Uses Storage's listDirectory() and download() methods to download
contents.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
6c01edc57a CLOUD: Simplify OneDriveTokenRefresher
It now just extends CurlJsonRequest, not wraps one.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
dcbaeb57c4 CLOUD: Fix OneDriveTokenRefresher
Failed to update token in header when "Bearer" was used instead of
"bearer".
2016-08-24 16:07:55 +06:00