181 Commits

Author SHA1 Message Date
Alexander Tkachev
8a9d126152 CLOUD: Move "/create" to separate Handler
It does redirect to "/files" on success, so user doesn't even see the
strange "/create" URL at all.

This commit is for keeping these handlers small, not making one
(FilesPageHandler in this case) do everything.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
ab4361a76b CLOUD: Make "/create" work
One can now create directories through browser.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
48e3fff6bc CLOUD: Refactor LocalWebserver
Its handlers are now more compact. This commit moves Handler classes in
handlers\ directory.

ResourceHandler ignores "hidden" files in the archive, and these are
used as markup templates in IndexPageHandler and FilesPageHandler.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
627bda9d82 COMMON: Add replace(String, String, String)
Searches for a substring in the string and replaces it with the other
string.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
e47b6c04b3 CLOUD: Make "/files" list directories
Including both virtual "/root" and "/saves" ones.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
c409d29f66 CLOUD: Add "/files" handler
Shows the page with controls, but doesn't actually list the directories,
create the specified ones or allows to upload files yet.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
eae57728d1 CLOUD: Resolve local machine's IP 2016-08-24 16:07:55 +06:00
Alexander Tkachev
e601c39802 CLOUD: Make "Run server" button active
It should show the real server's IP over there, but that doesn't work
yet.
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
Peter Bozsó
cff183536b CLOUD: Fix crash on exiting ScummVM while ConnMan is active 2016-08-24 16:07:55 +06:00
Alexander Tkachev
81106b0444 CLOUD: Update local server's style.css 2016-08-24 16:07:55 +06:00
Alexander Tkachev
8484273f36 CLOUD: Fix "-Wcast-qual"
The passed buffer is not changed, so could be `const`.

You might see that `postFields.c_str()` is `buffer`. Yet, as it's
`postFields`, it's used for POST in curl_easy_setopt(), which copies the
passed buffer. When `buffer` is used for upload, it's an actual bytes
buffer, kept in CurlRequest.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
caa53d9f6c CLOUD: Fix "-Wconversion-null"
That `false` came from TranslationManager's function, which was
returning bool, not a pointer. Somehow missed that line.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
04cef8928c CLOUD: Fix "type qualifiers ignored" warning 2016-08-24 16:07:55 +06:00
Alexander Tkachev
6ac69729d5 CLOUD: Add some mutexes in LocalWebserver 2016-08-24 16:07:55 +06:00
Alexander Tkachev
5e70f64e10 CLOUD: Embed cloud icons as byte arrays 2016-08-24 16:07:55 +06:00
Alexander Tkachev
a56c7a3bd6 CLOUD: Update IndexPageHandler to search wwwroot.zip
Now it also searches for that in themepath, not with SearchMan only.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
c2c2ba908f GUI: Hide StorageWizardDialog fields if server present 2016-08-24 16:07:55 +06:00
Alexander Tkachev
5176eaba81 CLOUD: Add wwwroot
wwwroot.zip contains ScummVM local webserver's resources, such as
template html pages, styles and images.

One can make it from wwwroot directory contents by running
make_archive.py script.

It's added to scummvm.rc, so it's included in the executable (it works
with MinGW, but I was unable to do that in VS yet).

IndexPageHandler is the one who returns these resources. It uses
index.html for "/". I'm replacing "{message}" with translated message,
so that's the way I thought the templates should work.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
43071c0972 CLOUD: Update LocalWebserver
* fix handling connections;
* fix idling strategy;
* add setClientGetHandler() for SeekableReadStream;
* add determineMimeType().
2016-08-24 16:07:55 +06:00
Alexander Tkachev
0def9c50a7 CLOUD: Fix Client
Cleanup in open()
2016-08-24 16:07:55 +06:00
Alexander Tkachev
5ac3adbd4f CLOUD: Add IndexPageHandler
This commit also adds LocalWebserver's stopOnIdle().
That means server is not stopped immediately, but only when all clients
are served.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
733d998e6a CLOUD: Minor Client fix 2016-08-24 16:07:55 +06:00
Alexander Tkachev
3946f23d17 CLOUD: Prepare code for path handlers
LocalWebserver would storage the handlers.

Client now has methods like path() or query() to access different parts
of the request.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
892c1bf84c CLOUD: Add HTTP response codes in GetClientHandler 2016-08-24 16:07:55 +06:00
Alexander Tkachev
6e1b667dd6 CLOUD: Minor Client fix 2016-08-24 16:07:55 +06:00
Alexander Tkachev
13c54f6685 CLOUD: Add GetClientHandler
That ClientHandler is made for responding GET requests. It calculates
stream's length, it allows to specify response code and headers, it can
be used to transfer any ReadStream.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
99c51380fd CLOUD: Add ClientState::BAD_REQUEST 2016-08-24 16:07:55 +06:00
Alexander Tkachev
6126435b64 CLOUD: Add Networking::Client
Keeps current client's state
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ó
bad2ec3ef4 CLOUD: Fix initialization of NetworkReadStream
"networkreadstream.cpp:51:2: error: delegating constructors are permitted only in C++11"
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
b29497effe CLOUD: Add GoogleDriveUploadRequest
Includes NetworkReadStream PATCH method and Headers remembering feature.
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
69aed03c4f CLOUD: Add new CloudManager shortcuts
CloudIcon can easily use CloudMan.isWorking()
2016-08-24 16:07:55 +06:00
Alexander Tkachev
1bcbab7ad2 CLOUD: Add new cloudicon.png 2016-08-24 16:07:55 +06:00
Alexander Tkachev
602d17f5fd CLOUD: Document CloudIcon::draw() more precisely 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
4874fafb15 CLOUD: Fix CloudIcon
Now it loads the surface once.
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
bcb2a5bd8d CLOUD: Fix CloudIcon to use clearOSD()
Now only icon is shown.
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
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
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