Commit Graph
70 Commits
Author SHA1 Message Date
Eugene Sandulenko fab199d37e JANITORIAL: Make GPL headers uniform 2016-09-03 12:46:38 +02:00
Alexander Tkachev 364c74df93 CLOUD: Update DropboxStorage
JSON checks added.
2016-08-24 16:07:55 +06:00
Alexander Tkachev 0b97aff866 CLOUD: Minor TODO fix 2016-08-24 16:07:55 +06:00
Alexander Tkachev 6dd10f3a68 CLOUD: Add KEY/SECRET override code
The following constants must be defined if ENABLE_RELEASE is:
* RELEASE_DROPBOX_KEY,
* RELEASE_DROPBOX_SECRET,
* RELEASE_ONEDRIVE_KEY,
* RELEASE_ONEDRIVE_SECRET,
* RELEASE_GOOGLE_DRIVE_KEY,
* RELEASE_GOOGLE_DRIVE_SECRET,
* RELEASE_BOX_KEY,
* RELEASE_BOX_SECRET.
2016-08-24 16:07:55 +06:00
Alexander Tkachev 15c6772ff7 ALL: Fix debug, warning and error usage
Added prefixes, used debug(9).
2016-08-24 16:07:55 +06:00
Alexander Tkachev d57e0c89b5 CLOUD: #define all OAuth2/API-related URLs 2016-08-24 16:07:55 +06:00
Eugene SandulenkoandAlexander Tkachev d57fca4665 CLOUD: JANITORIAL: Fix code formatting 2016-08-24 16:07:55 +06:00
Alexander Tkachev 772d8ee42b CLOUD: Fix redirect_uri selection code
Now it's not hardcoded based on USE_SDL_NET, but one or another value is
used depending on currently selected LocalWebserver's port.
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 a449ddce15 CLOUD: Fix Cppcheck warnings 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 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 b4e9e35e07 CLOUD: Cleanup in Storages 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 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
Peter BozsóandAlexander Tkachev 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
Peter BozsóandAlexander Tkachev 219e565c32 CLOUD: Introduce CloudConfigHelper 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óandAlexander Tkachev 2a2beaebc5 Fix DropboxStorage::codeFlowComplete() 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 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 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 f0d61084da CLOUD: Update downloading in Storages
Id should be used everywhere.
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 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 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 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
Peter BozsóandAlexander Tkachev 81c34adaef Fix comment formatting 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 98150beb38 CLOUD: Refactor ConnectionManager/Requests system
ConnectionManager now storages Request * (not generates ids for it),
Requests have control on their RequestState, RequestIdPair is now called
Response and storages Request * with some response together.

All related classes are changed to use it in more clean and
understandable way.

Request, RequestState and Response are carefully commented/documented.
2016-08-24 16:07:55 +06:00
Alexander Tkachev 83b349a033 CLOUD: Make OneDriveStorage::download() work fine
Well, it takes two API calls instead of one now, but there are no
problems with expired token because of it.

This commit changes Storage::streamFile() to pass NetworkReadStream *
through callback.
2016-08-24 16:07:55 +06:00
Alexander Tkachev b246c17850 CLOUD: Fix CurlJsonRequest to use JsonCallback
Type safety first.
2016-08-24 16:07:55 +06:00
Alexander Tkachev f4547f44df CLOUD: Add RequestIdPair struct
Can be used with Callback<T> (means it's still type safe). It's used to
pass not only Request id to user's callback, but also a value user
wanted.

void *data field is removed from RequestInfo.
2016-08-24 16:07:55 +06:00
Alexander Tkachev eda575a660 CLOUD: Add Requests id
(Upgrading ConnectionManager step by step.)
2016-08-24 16:07:55 +06:00
Alexander Tkachev ae8e7f39f5 CLOUD: Make download() create necessary directories
DumpFile::open() with createPath=true create would create the missing
directories from the path before opening a file. Thus, one can easily
create a file and avoid "can't open a file" error.
2016-08-24 16:07:55 +06:00