aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-19 13:41:25 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commitda229dd84c5761f80b16c25edba7bfb738fc835f (patch)
treed52f1815a56e718675a0ff9298b99f6ab05ef939
parente6caa482e1e7c0e6d9f8201331332b9f5425b79d (diff)
downloadscummvm-rg350-da229dd84c5761f80b16c25edba7bfb738fc835f.tar.gz
scummvm-rg350-da229dd84c5761f80b16c25edba7bfb738fc835f.tar.bz2
scummvm-rg350-da229dd84c5761f80b16c25edba7bfb738fc835f.zip
CLOUD: Add "ajax" parameter for "/create" and "/upload"
If it's set, these redirect to "/filesAJAX" instead of "/files".
-rw-r--r--backends/networking/sdl_net/handlers/createdirectoryhandler.cpp4
-rw-r--r--backends/networking/sdl_net/handlers/filesajaxpagehandler.cpp14
-rw-r--r--backends/networking/sdl_net/uploadfileclienthandler.cpp8
-rw-r--r--backends/networking/wwwroot.zipbin241872 -> 241963 bytes
-rw-r--r--backends/networking/wwwroot/.filesAJAX.html7
5 files changed, 26 insertions, 7 deletions
diff --git a/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp b/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp
index 97d75fcf14..fc02b643c1 100644
--- a/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp
+++ b/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp
@@ -85,7 +85,9 @@ void CreateDirectoryHandler::handle(Client &client) {
client.queryParameter("path").c_str(),
_("Back to parent directory")
),
- "/files?path=" + LocalWebserver::urlEncodeQueryParameterValue(client.queryParameter("path"))
+
+ (client.queryParameter("ajax") == "true" ? "/filesAJAX?path=" : "/files?path=") +
+ LocalWebserver::urlEncodeQueryParameterValue(client.queryParameter("path"))
);
}
diff --git a/backends/networking/sdl_net/handlers/filesajaxpagehandler.cpp b/backends/networking/sdl_net/handlers/filesajaxpagehandler.cpp
index 17be7faad2..df4482166a 100644
--- a/backends/networking/sdl_net/handlers/filesajaxpagehandler.cpp
+++ b/backends/networking/sdl_net/handlers/filesajaxpagehandler.cpp
@@ -33,6 +33,19 @@ FilesAjaxPageHandler::FilesAjaxPageHandler() {}
FilesAjaxPageHandler::~FilesAjaxPageHandler() {}
+namespace {
+Common::String encodeDoubleQuotesAndSlashes(Common::String s) {
+ Common::String result = "";
+ for (uint32 i = 0; i < s.size(); ++i)
+ if (s[i] == '"') {
+ result += "\\\"";
+ } else if (s[i] == '\\') {
+ result += "\\\\";
+ } else result += s[i];
+ return result;
+}
+}
+
void FilesAjaxPageHandler::handle(Client &client) {
// load stylish response page from the archive
Common::SeekableReadStream *const stream = HandlerUtils::getArchiveFile(FILES_PAGE_NAME);
@@ -55,6 +68,7 @@ void FilesAjaxPageHandler::handle(Client &client) {
replace(response, "{index_of}", _("Index of "));
replace(response, "{loading}", _("Loading..."));
replace(response, "{error}", _("Error occurred"));
+ replace(response, "{start_path}", encodeDoubleQuotesAndSlashes(path));
LocalWebserver::setClientGetHandler(client, response);
}
diff --git a/backends/networking/sdl_net/uploadfileclienthandler.cpp b/backends/networking/sdl_net/uploadfileclienthandler.cpp
index 7cbb11874c..7e93573ca5 100644
--- a/backends/networking/sdl_net/uploadfileclienthandler.cpp
+++ b/backends/networking/sdl_net/uploadfileclienthandler.cpp
@@ -159,9 +159,11 @@ void UploadFileClientHandler::handleBlockContent(Client *client) {
_("Uploaded successfully!"),
client->queryParameter("path").c_str(),
_("Back to parent directory")
- ),
- "/files?path=" + LocalWebserver::urlEncodeQueryParameterValue(client->queryParameter("path"))
- );
+ ),
+
+ (client->queryParameter("ajax") == "true" ? "/filesAJAX?path=" : "/files?path=") +
+ LocalWebserver::urlEncodeQueryParameterValue(client->queryParameter("path"))
+ );
_state = UFH_STOP;
return;
}
diff --git a/backends/networking/wwwroot.zip b/backends/networking/wwwroot.zip
index 7e53969589..6f821d9090 100644
--- a/backends/networking/wwwroot.zip
+++ b/backends/networking/wwwroot.zip
Binary files differ
diff --git a/backends/networking/wwwroot/.filesAJAX.html b/backends/networking/wwwroot/.filesAJAX.html
index 16a4b5417d..d648466d2c 100644
--- a/backends/networking/wwwroot/.filesAJAX.html
+++ b/backends/networking/wwwroot/.filesAJAX.html
@@ -19,13 +19,14 @@
<p>{create_directory_desc}</p>
<form action="create" id="create_directory_form">
<input type="hidden" name="path" value="{path}"/>
+ <input type="hidden" name="ajax" value="true"/>
<input type="text" name="directory_name" value=""/>
<input type="submit" value="{create_directory_button}"/>
</form>
</div>
<div id="upload_file" class="modal">
<p>{upload_file_desc}</p>
- <form action="upload?path={path}" method="post" enctype="multipart/form-data" id="files_upload_form">
+ <form action="upload?path={path}&ajax=true" method="post" enctype="multipart/form-data" id="files_upload_form">
<!-- we don't need "[]" in the name, as our webserver is not using PHP -->
<!-- "allowdirs" is a proposal, not implemented yet -->
<input type="file" name="upload_file-f" allowdirs multiple/>
@@ -59,7 +60,7 @@
<script src="ajax.js"></script>
<script>
window.onload = function () {
- showDirectory("/");
+ showDirectory("{start_path}");
}
function showDirectory(path) {
@@ -112,7 +113,7 @@
function openDirectory(path, items) {
// update path
document.getElementById("create_directory_form").elements["path"].value = path;
- document.getElementById("files_upload_form").action = "upload?path=" + path;
+ document.getElementById("files_upload_form").action = "upload?path=" + path + "&ajax=true";
// update table contents
listDirectory(path, items);