42 Commits

Author SHA1 Message Date
Eugene Sandulenko
abea37c9bb
ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Orgad Shaneh
44219dfa1a BACKENDS: Use nullptr
Using clang-tidy modernize-use-nullptr
2021-11-14 15:51:59 +02:00
Bastien Bouclet
6fa7322a6a NETWORKING: Try loading the CA bundle from DATA_PATH 2019-11-03 19:48:34 +02:00
Bastien Bouclet
47b67342d6 NETWORKING: Improve libcurl error handling
Error messages for failed requests are now printed as warnings.
2019-11-03 19:48:34 +02:00
Alexander Tkachev
c1124c9cda CLOUD: Handle Cloud requests more frequently
ConnectionManager used to poll Cloud requests every second, while curl
requests were polled every 1/20th of a second. If curl request was over
at, say, frame #21, corresponding Cloud request would've only work with
that at frame #40 (950 ms later), which was making everything
cloud-related slower than it could be. This commit fixes it by making
Cloud polling period the same as curl polling period, and additionally
raises FPS to 25.
2019-07-30 14:51:41 -04:00
SupSuper
272d4105b2 WIN32: Fix libcurl redefining ARRAYSIZE
libcurl pulls in Windows headers, so let's include it first to avoid clashing with common headers
2018-12-17 12:28:33 +02:00
Eugene Sandulenko
940b2a20f1 Revert "COMMON: Change way the Singleton instances are instantiated"
This reverts commit eefa72afa1978a9dea10f5b1833fcc8f58a3468e.

With this patch ConfigManager is broken.
2017-07-10 21:17:41 +02:00
Thierry Crozat
eefa72afa1 COMMON: Change way the Singleton instances are instantiated
This fixes tons of warnings with clang from a recent xcode version on
macOS (and possibly other systems) complaining that an instantiation
of _singleton is required but no definition is available.
2017-07-10 21:11:20 +02:00
Thierry Crozat
9a8aea0585 CLOUD: Fix compilation with old curl vesions 2017-04-29 22:10:16 +01:00
Bastien Bouclet
1a1a5b5f69 CLOUD: Change the cloud icon to be updated by the main thread
The cloud manager registers itself as an event source as a mean to be polled
periodically by the GUI or engine code. The periodical polling is used to
update the OSD icon indicating background sync activity.

Also move the cloud icon from ConnectionManager to CloudManager,
allowing to decouple icon handling from network connections updates.
2016-09-18 17:54:12 +02: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
01161ae7dd CLOUD: Do some refactoring/cleanup in Networking 2016-08-24 16:07:55 +06:00
Alexander Tkachev
1b56f59add GUI: Update DownloadDialog
It now has download size and speed labels.

Commit also fixes minor mistake in ConnMan.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
c431ae6d84 CLOUD: Calculate FolderDownload download speed 2016-08-24 16:07:55 +06:00
Peter Bozsó
cff183536b CLOUD: Fix crash on exiting ScummVM while ConnMan is active 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
74a3eba8d6 CLOUD: Fix ConnectionManager
It now keeps newly added Requests in separate array, so iterators don't
break when one adds a Request while ConnMan iterates its array.

The array is also shielded with mutex.
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
45e83d06c2 CLOUD: Fix CloudIcon
It's not a Request again, but still it controls ConnMan's timer.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
cec93e2c03 CLOUD: Make CloudIcon switch ConnMan's timer off
CloudIcon is now a Request which is automatically added once first
Request is added to ConnMan. When icon decides it should disappear, it
gets FINISHED, so ConnMan would switch off the timer if it was the last
Request.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
135f7d09a8 CLOUD: Make CloudIcon pulsate, fade in and fade out
That required ConnMan's timer stopping. Would be fixed in the next
commit.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b32c2be78d CLOUD: Fix ConnectionManager a little
I didn't like how FINISHED Requests were waiting until the next
interateRequests() call to be removed when we could easily remove those
after they changed their state in their handle().
2016-08-24 16:07:55 +06:00
Alexander Tkachev
9d186929e1 CLOUD: Add CloudIcon
To achieve smoother animation, ConnectionManager's timer now is 20 times
more frequent.

I'm encountering some strange libcurl.dll segfault problem when I close
the application while some Requests are active. It's not
CloudIcon-related, so it's more likely related to this 20 FPS timer.
This problem shows up only in Visual Studio for me.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
b02b16ab98 CLOUD: Document ConnectionManager's onDeleteCallback 2016-08-24 16:07:55 +06:00
Alexander Tkachev
1f974a7a2a CLOUD: Fix ConnectionManager's destructor
It now terminates active Requests.
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
Peter Bozsó
81c34adaef Fix comment formatting 2016-08-24 16:07:55 +06:00
Alexander Tkachev
1dfa73b8f8 CLOUD: Fix ConnectionManager singleton warning 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
24007c029b CLOUD: Add OneDriveStorage::download()
Doesn't work when token is invalid, though.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
8f6bcdf55d CLOUD: Add OneDriveTokenRefresher
OneDriveTokenRefresher is a CurlJsonRequest replacement for
OneDriveStorage methods. It behaves very similarly, but checks received
JSON before passing it to user. If it contains "error" key, it attempts
to refresh the token through OneDriveStorage, and then restarts the
original request, so user won't notice that there ever was an error.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
62ccf1f902 CLOUD: Add RequestInfo struct
ConnectionManager upgrade: it now contains a special struct for each
request, so you can access request status and data by request id.
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
826a2a921c CLOUD: Add DownloadRequest stub
It reads the passed NetworkReadStream and prints its contents onto
console (for now). It would be writing contents into file.

To simplify work with raw NetworkReadStream there is a new CurlRequest.
It basically does nothing, but as ConnMan handles transfers only if
there is an active Request, you need some Request to get
NetworkReadStream working. Thus, there is a CurlRequest, which is active
until NetworkReadStream is completely read. CurlRequest also has useful
addHeader() and addPostField() methods in order to customize the request
easily. Use execute() method to get its NetworkReadStream.

DropboxStorage implements streamFile() and download() API methods. As
DownloadRequest is incomplete, it is not actually downloading a file,
though.
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
e743a65636 CLOUD: Add Dropbox into CloudManager's configs
This commit adds:
* ConfMan's new "cloud" domain;
* CloudManager's init() method, where it loads keys from "cloud" configs
domain;
* CurlJsonRequest's addHeader() and addPostField() methods;
* temporary Storage's printInfo() method;
* DropboxStorage's implementation of printInfo(), which is using access
token and user id;
* DropboxStorage's loadFromConfig() static method to load access token
and user id from configs and create a Storage instance with those;
* temporary DropboxStorage's authThroughConsole() static method, which
guides user through auth process from the console.

So, in CloudManager's init() implementation ScummVM checks that there is
"current_storage_type" key in "cloud" domain of configs, and loads
corresponding storage if there is such key.

If there is no such key, ScummVM offers user to auth with Dropbox.
That's done through console, and thus it's temporary (it also requires
restarting ScummVM twice and manually editing config.ini file).
2016-08-24 16:07:55 +06:00
Alexander Tkachev
5df8c51402 CLOUD: Fix CurlJsonRequest
It's using MemoryWriteStreamDynamic instead of String and it prepares
raw byte contents of this stream for JSON::parse().
2016-08-24 16:07:55 +06:00
Alexander Tkachev
03217cd5c3 CLOUD: Add CurlJsonRequest
Now we can do REST API request by creating CurlJsonRequest and waiting
for it to call our callback. Passed pointer is Common::JSONValue.

This commit also does some minor variable renaming fixes.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
9c22b7cc64 CLOUD: Rewrite NetworkReadStream
Now it is based on MemoryReadWriteStream, which is introduced by this
commit. This stream is using ring buffer and is dynamically increasing
its size when necessary.
2016-08-24 16:07:55 +06:00