Commit Graph

102 Commits

Author SHA1 Message Date
Alexander Tkachev
29e6020574 CLOUD: Update "/files" hardcoded response template 2016-08-24 16:07:55 +06:00
Alexander Tkachev
3064b44b92 CLOUD: Switch to "multiple" files uploading
Still doesn't support directories uploading.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
35b2471290 CLOUD: Fix '\' encoding back 2016-08-24 16:07:55 +06:00
Alexander Tkachev
30430b379f CLOUD: Fix Client's buffer 2016-08-24 16:07:55 +06:00
Alexander Tkachev
36b0069e95 CLOUD: Cleanup in Handlers
Simplified some stuff here and there by using HandlerUtils static
methods.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
f1830645d0 CLOUD: Cleanup in LocalWebserver 2016-08-24 16:07:55 +06:00
Alexander Tkachev
34dd84f429 CLOUD: More cleanup in Client 2016-08-24 16:07:55 +06:00
Alexander Tkachev
d1b5a64020 CLOUD: Cleanup in Reader and Client 2016-08-24 16:07:55 +06:00
Alexander Tkachev
7fcdcc10cb CLOUD: Cleanup in UploadFileClientHandler
Adds Client::noMoreContent() and Reader::noMoreContent(), which return
true when whole client's request was read.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
abae5c4371 CLOUD: Cleanup in UploadFileHandler 2016-08-24 16:07:55 +06:00
Alexander Tkachev
e4bb7c4e75 CLOUD: Add UploadFileClientHandler
Now Client reads the first headers block, then LocalWebserver decides
which Handler to use. In case of "/upload", UploadFileHandler is used.

But now it only knows the "path" parameter. If that's valid, actual
UploadFileClientHandler is created, which reads the contents of the
request and, when finds there  an "upload_file" field, starts saving it
in the directory specified by "path".

With that we don't need temp files approach from Reader class.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
a424ebbc28 CLOUD: Fix quotes encoding 2016-08-24 16:07:55 +06:00
Alexander Tkachev
eaa5fb1759 CLOUD: Put "/upload" "path" parameter in the URL 2016-08-24 16:07:55 +06:00
Alexander Tkachev
f0fc18d2ee CLOUD: Add UploadFileHandler 2016-08-24 16:07:55 +06:00
Alexander Tkachev
f3ee9e3272 CLOUD: Fix minor Reader-related bugs 2016-08-24 16:07:55 +06:00
Alexander Tkachev
b69cc3effb CLOUD: Update Reader to delete temp files 2016-08-24 16:07:55 +06:00
Alexander Tkachev
bca05b2720 CLOUD: Save files fields into temp files
Instead of keeping them in memory. Temp file name is generated to point
into ScummVM's working directory. That means that if user wanted to
upload file to the place with sufficient size, it would instead be
uploaded to ScummVM's working directory. Yet it's too early to parse the
target directory, so there is no way to generate temp file name within
that directory.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
80cc3469e7 CLOUD: Add Reader::readOneByteInStream() 2016-08-24 16:07:55 +06:00
Alexander Tkachev
83957c9666 CLOUD: Determine file's name in POST 2016-08-24 16:07:55 +06:00
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
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
fa3ea83165 CLOUD: Fix some warnings
Mostly on format string
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
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