Commit Graph
189 Commits
Author SHA1 Message Date
Alexander Tkachev c82ed40fdd CLOUD: Move method/path/etc info in Reader
Query parameters are now parsed once and then just searched in the
HashMap.
2016-08-24 16:07:55 +06:00
Alexander Tkachev f91bb39192 CLOUD: Use Reader in Client
Instead of copy-pasting it I'm just "integrating" it in.
2016-08-24 16:07:55 +06:00
Alexander Tkachev 589b4cd457 CLOUD: Use "multipart/form-data" in upload form 2016-08-24 16:07:55 +06:00
Alexander Tkachev bb67b81d04 CLOUD: Update Reader to support pausing
That means that if current buffer is over, reader will stop reading and
it's safe to call readResponse() again, so it would continue from the
place it left.
2016-08-24 16:07:55 +06:00
Alexander Tkachev 79b39bf0d0 CLOUD: Add Reader sketch
That should be part of the Client, I guess. Reader is not ready to
continue reading from place it stopped, but it already works as it
should for the case when whole content is available.
2016-08-24 16:07:55 +06:00
Alexander Tkachev 4d88f51de9 CLOUD: Add query parameters URL encoding
In local webserver's links.

Fixed URL decoding to understand '+', by the way. Firefox sends these
instead of spaces and "%2B" instead of '+'.
2016-08-24 16:07:55 +06:00
Alexander Tkachev 89a1a54982 CLOUD: Update GetClientHandler's buffer
It's not static now and it's increased to 1 MB.
2016-08-24 16:07:55 +06:00
Alexander Tkachev b40bfaa046 CLOUD: Add "/download" handler
Now one can download files from the device through browser!
2016-08-24 16:07:55 +06:00
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