214 Commits

Author SHA1 Message Date
Peter Bozsó
fc3e7dec1a CLOUD: Introduce kStoragePrefix in CloudManager 2016-08-24 16:07:55 +06:00
Peter Bozsó
98788a5e7d CLOUD: Remove unnecessary blank lines in switch statement 2016-08-24 16:07:55 +06:00
Peter Bozsó
1403cf006c CLOUD: Make enum StorageIDs' name singular 2016-08-24 16:07:55 +06:00
Peter Bozsó
c068b74f30 CLOUD: Force handling of all StorageIDs values in CloudManager::getStorageConfigName() 2016-08-24 16:07:55 +06:00
Alexander Tkachev
dbafbf2569 CLOUD: Fix getAccessToken()
KEY and SECRET should now load before getAccessToken() uses them, so it
should work now.
2016-08-24 16:07:55 +06:00
Peter Bozsó
2a2beaebc5 Fix DropboxStorage::codeFlowComplete() 2016-08-24 16:07:55 +06:00
Peter Bozsó
a966de42a9 CLOUD: Fix compilation error in savesyncrequest.h
"savessyncrequest.h:35:35: error: use of undeclared identifier 'UINT_MAX'"
2016-08-24 16:07:55 +06:00
Alexander Tkachev
9ee2eb4e60 GUI: Add EditText in StorageWizardDialog
One can enter the code, press 'Connect' button and get a working
Storage!
2016-08-24 16:07:55 +06:00
Alexander Tkachev
3e6503743c CLOUD: Add Request::date()
Used in SavesSyncRequest to update Storage's last sync date.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
6a93e8dd09 CLOUD: Add ConnMan::urlEncode()
Tried to use it everywhere I should've use it.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
c99b24c16d COMMON: Add String::asUint64()
Instead of all these atoull() I've added everywhere.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
e6242b0be8 GUI: Add Refresh button in Options Cloud tab
Commit changes CloudManager and Storages so they would automatically
refresh the fields when the could.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
9b15ec9989 CLOUD: Update CloudManager
It now has methods to update Storage's information.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
af9930482e CLOUD: Update CloudManager
It now supports only one storage of each type. Only one Storage could be
loaded to the memory as well.

Options' Cloud tab now changes the Storage only when user pressed OK
button, giving the ability to look through the Storages without actually
changing them.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
4ff1ed5fe9 GUI: Add Cloud tab information labels
And corresponding stub implementations in CloudManager.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
870e96eb9c CLOUD: Update CloudManager and Storage
* Storage::name();
* CloudManager::getStorageName();
* CloudManager::getStorageIndex();
* CloudManager::listStorages();
* CloudManager::switchStorage().
2016-08-24 16:07:55 +06:00
Alexander Tkachev
1479d12652 CLOUD: Minor GoogleDriveUploadRequest fix
Just checked that out on cloud sync: Google Drive is officially
supported!
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b29497effe CLOUD: Add GoogleDriveUploadRequest
Includes NetworkReadStream PATCH method and Headers remembering feature.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
e273e3d6e8 CLOUD: Add GoogleDrive download-related requests
GoogleDriveDownloadRequest, which resolves file id and then downloads it
with GoogleDriveStorage::downloadById().

GoogleDriveStreamFileRequest, which resolves file id and then returns
file stream with GoogleDriveStorage::streamFileById().

This commit also adds GoogleDriveStorage::streamFileById() itself.

A minor GoogleDriveResolveIdRequest fix added.

With these one can download files from Google Drive.
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
7e6a89c141 CLOUD: Update GoogleDriveStorage and StorageFile
Because of the Google Drive StorageFile now contains yet another field,
`id`. For other storages `id` == `path`, and thus all common Requests
(such as SavesSyncRequest, DownloadFolderRequest, etc) must be using
id() instead of path(). That way these Requests won't cause id resolving
which could be quite slow (when you call it for all files in the folder,
for example).
2016-08-24 16:07:55 +06:00
Alexander Tkachev
bf71ba9a1c CLOUD: Update GoogleDriveCreateDirectoryRequest
Now it also creates the "base" ScummVM directory if there is no such
directory yet. This way SavesSyncRequest works fine when no "ScummVM" or
"ScummVM/Saves" folder exist in the Google Drive.
2016-08-24 16:07:55 +06:00
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