Commit Graph
6575 Commits
Author SHA1 Message Date
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 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 3da38ca60b CLOUD: Replace USE_CLOUD with USE_LIBCURL
In most cases that's the right one to check. USE_CLOUD is defined when
either USE_LIBCURL or USE_SDL_NET are, which means if there is no curl,
USE_CLOUD still could be defined and linking errors would appear.
2016-08-24 16:07:55 +06:00
Alexander Tkachev 1cfdb96616 CLOUD: Fix FolderDownloadRequest
Actually, I'm not completely sure, but this fixed the segfault when user
closes ScummVM during the download. Even if that's not a fix, these
lines must be in this method anyway.
2016-08-24 16:07:55 +06:00
Alexander Tkachev ddb1a6ccb6 GUI: Upgrade DownloadDialog
It now shows the remote and local directories and a progress bar.

Storage now shows OSD messages on download success and failure.
2016-08-24 16:07:55 +06:00
Alexander Tkachev b8ee9d4e7d CLOUD: Add FolderDownload-related methods in Storage
CloudManager's shortcuts are added too.

The idea is to keep FolderDownload request within Storage, and provide
necessary means to access it. The download is started and cancelled
through the DownloadDialog.
2016-08-24 16:07:55 +06:00
Alexander Tkachev 10250af251 CLOUD: Fix CloudManager's methods
Were not returning created Request.
2016-08-24 16:07:55 +06:00
Alexander Tkachev dc0a956172 CLOUD: Add CloudManager::downloadFolder() 2016-08-24 16:07:55 +06:00
Alexander Tkachev a37c639986 CLOUD: Make Google Drive sort files list
GoogleDriveListDirectoryByIdRequest now uses "orderBy" field to specify
that we want the commonly used "alphabetical, folders first" order.

That's mostly needed for RemoteBrowserDialog, because Requests don't
care about the order, and this one is more user-friendly.
2016-08-24 16:07:55 +06:00
Alexander Tkachev acce1c89ab CLOUD: Fix saves sync
Tested that on actual unix system and found out a few minor bugs related
to paths.
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 4c381dafa3 CLOUD: Delete the incomplete file (when downloading) 2016-08-24 16:07:55 +06:00
Alexander Tkachev 65e87c6c70 CLOUD: Update save's timestamp on rewrite
This commit moves save/load timestamps static methods into
DefaultSaveFileManager and fixes a few related bugs.
2016-08-24 16:07:55 +06:00
Alexander Tkachev aee713141b CLOUD: Make OutSaveFile start saves sync
It had to become a proxy class in order to do that.
finalize() starts the saves sync.
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 39eb76f8c2 CLOUD: Fix "zero-length format string" warning 2016-08-24 16:07:55 +06:00