Commit graph

267 commits

Author SHA1 Message Date
Alexander Tkachev
b180c73675 CLOUD: Do some refactoring/cleanup
Nothing really major.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
a449ddce15 CLOUD: Fix Cppcheck warnings 2016-08-24 16:07:55 +06:00
Alexander Tkachev
b1264df120 CLOUD: Check whether Storage is working when replacing it
We do that in CloudManager::replaceStorage(), but I've tried to
eliminate such possibility by adding a check in the StorageWizardDialog.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
f743b31963 CLOUD: Fix CloudManager::connectStorage() memory leak 2016-08-24 16:07:55 +06:00
Alexander Tkachev
1d78d20fcf CLOUD: Fix Dropbox and Google Drive UploadRequests
Possible segfault there too.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
ab0f2d1a03 CLOUD: Fix OneDriveUploadRequest
Segfault when given stream is nullptr.
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
0c1c274abd CLOUD: Fix OneDriveUploadRequest
OneDrive doesn't accept empty files, so UploadRequest just skips such.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
d0c54cdd64 CLOUD: Fix DropboxCreateDirectoryRequest
It now calls success callback with `false` on Dropbox's
"path/conflict/folder", indicating that the directory already exists.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
55568d757c CLOUD: Move Dropbox to API v2
We had a few places where their deprecated API v1 was used.
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
85adefdb86 CLOUD: Update FolderDownloadRequest::getProgress()
It now is based on downloaded size, not number of files.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
479c76bbd2 CLOUD: Fix IdDownloadRequest
Wrong value was returned in getProgress() on nullptr there.
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
ca33c0a0a8 CLOUD: Fix FolderDownloadRequest
It now sends kDownloadEndedCmd on success without waiting to be
destructed.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
d863dad055 CLOUD: Fix FolderDownloadRequest::getProgress()
Now it doesn't stop on 100 % on last file and it ignores the
directories, so it doesn't "jump" suddenly as there are no directories
to skip.
2016-08-24 16:07:55 +06:00
Peter Bozsó
7951a2ea16 CLOUD: Rename _files to _pendingFiles in FolderDownloadRequest 2016-08-24 16:07:55 +06:00
Alexander Tkachev
dfd68306de CLOUD: Upgrade FolderDownloadRequest::getProgress()
Now NetworkReadStream, which is used in DownloadRequest, which is used
in FolderDownloadRequest, returns progress information provided by
libcurl.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
1a53dccf51 CLOUD: Update DownloadRequest
It now uses a dynamically allocated 1 MB buffer.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b4e9e35e07 CLOUD: Cleanup in Storages 2016-08-24 16:07:55 +06:00
Alexander Tkachev
0b5bd18d85 CLOUD: Update GoogleDriveStorage
It now derives from IdStorage, so lots of GoogleDrive*Request classes
are removed and replaced with generic IdStorage*Request ones.
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
d96cdacb38 CLOUD: Add BoxUploadRequest 2016-08-24 16:07:55 +06:00
Alexander Tkachev
16ed625dfe CLOUD: Remove BoxStorage::streamFileById debug() call 2016-08-24 16:07:55 +06:00
Alexander Tkachev
19ae61dffc CLOUD: Add IdDownloadRequest and IdStreamFileRequest
Used for downloading files in Box.
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
d943d7c3a8 CLOUD: Add IdCreateDirectoryRequest
Box gets createDirectoryWithParentId(), so now creating directories
works there.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
2b3caf1efa CLOUD: Add IdStorage
This is a special base class for Storages which are using ids instead of
paths in their APIs, like Box or Google Drive.

This commit makes Box derived from IdStorage.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
e0a6b2135d CLOUD: Add BoxListDirectoryRequest
And used in it BoxResolveIdRequest.

TODO: make some generic ResolveIdRequest and ListDirectoryRequest for
id-based storages. It's really similar, I just had to change a few
details in GoogleDrive ListDirectory and ResolveId requests.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
eb269e137f CLOUD: Add BoxListDirectoryByIdRequest
Similarly to Google Drive, Box uses only ids of files. That means id
resolving would be slow.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
85f1ce8ece CLOUD: Add BoxTokenRefresher and BoxStorage::info()
BoxTokenRefresher does refresh if HTTP 401 is returned by the server.

To test refresher, BoxStorage::info() was added.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b37b392fa0 CLOUD: Add BoxStorage sketch 2016-08-24 16:07:55 +06:00
Alexander Tkachev
1cfdb96616 CLOUD: Fix FolderDownloadRequest
Actually, I'm not completely sure, but this fixed the segfault when user
closes ScummVM during the download. Even if that's not a fix, these
lines must be in this method anyway.
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
10250af251 CLOUD: Fix CloudManager's methods
Were not returning created Request.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
dc0a956172 CLOUD: Add CloudManager::downloadFolder() 2016-08-24 16:07:55 +06:00
Alexander Tkachev
a37c639986 CLOUD: Make Google Drive sort files list
GoogleDriveListDirectoryByIdRequest now uses "orderBy" field to specify
that we want the commonly used "alphabetical, folders first" order.

That's mostly needed for RemoteBrowserDialog, because Requests don't
care about the order, and this one is more user-friendly.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
f3a392359b CLOUD: Fix finishSuccess() warning 2016-08-24 16:07:55 +06:00
Alexander Tkachev
fa3ea83165 CLOUD: Fix some warnings
Mostly on format string
2016-08-24 16:07:55 +06:00
Alexander Tkachev
4c381dafa3 CLOUD: Delete the incomplete file (when downloading) 2016-08-24 16:07:55 +06:00
Alexander Tkachev
65e87c6c70 CLOUD: Update save's timestamp on rewrite
This commit moves save/load timestamps static methods into
DefaultSaveFileManager and fixes a few related bugs.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
39eb76f8c2 CLOUD: Fix "zero-length format string" warning 2016-08-24 16:07:55 +06:00
Alexander Tkachev
b908b286b9 CLOUD: Fix "signed/unsigned integers" warning
The "comparison between signed and unsigned integer expressions" one.

Note that in UploadRequests size() and pos() are acutally signed,
because they could return -1. This commit implies that Requests are
working with such Streams which doesn't.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
1addefad7e CLOUD: Use correct redirect_uris
Usage of #ifdef there (and in StorageWizardDialog) means that ScummVM
doesn't support both local webserver and scummvm.org paths at the same
time. It's either built with SDL_net (thus supporting localhost path) or
without it (thus using scummvm.org).
2016-08-24 16:07:55 +06:00
Alexander Tkachev
0af97e59bc CLOUD: Add LocalWebserver
Available as LocalServer singleton. It's being started and stopped by
StorageWizardDialog. It doesn't handle clients yet, though.
2016-08-24 16:07:55 +06:00
Peter Bozsó
c1ffb09fb0 CLOUD: Fix configuration handling in CloudManager 2016-08-24 16:07:55 +06:00
Peter Bozsó
a8eebbe851 CLOUD: Get rid of CloudConfigHelper, use kCloudDomain where approriate 2016-08-24 16:07:55 +06:00
Alexander Tkachev
8a84263d2b CLOUD: Do saves sync on Storage connect 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