aboutsummaryrefslogtreecommitdiff
path: root/backends/networking/sdl_net
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-05 20:42:57 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commitc409d29f66057a1a2c0e405e60cc8aa5623bc52f (patch)
treefbfacd7040e44466911f533dc48ed9ef4efdda91 /backends/networking/sdl_net
parenteae57728d17beb74e4631c488ad8d1b4aaea7aea (diff)
downloadscummvm-rg350-c409d29f66057a1a2c0e405e60cc8aa5623bc52f.tar.gz
scummvm-rg350-c409d29f66057a1a2c0e405e60cc8aa5623bc52f.tar.bz2
scummvm-rg350-c409d29f66057a1a2c0e405e60cc8aa5623bc52f.zip
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.
Diffstat (limited to 'backends/networking/sdl_net')
-rw-r--r--backends/networking/sdl_net/indexpagehandler.cpp28
-rw-r--r--backends/networking/sdl_net/indexpagehandler.h1
2 files changed, 28 insertions, 1 deletions
diff --git a/backends/networking/sdl_net/indexpagehandler.cpp b/backends/networking/sdl_net/indexpagehandler.cpp
index 2d1f2c2cd7..c2ea470802 100644
--- a/backends/networking/sdl_net/indexpagehandler.cpp
+++ b/backends/networking/sdl_net/indexpagehandler.cpp
@@ -33,11 +33,13 @@ namespace Networking {
#define ARCHIVE_NAME "wwwroot.zip"
#define INDEX_PAGE_NAME "index.html"
+#define FILES_PAGE_NAME "files.html"
IndexPageHandler::IndexPageHandler(): CommandSender(nullptr) {}
IndexPageHandler::~IndexPageHandler() {
LocalServer.removePathHandler("/");
+ LocalServer.removePathHandler("/files/");
Common::ArchiveMemberList fileList = listArchive();
for (Common::ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) {
@@ -68,6 +70,28 @@ void IndexPageHandler::handle(Client &client) {
LocalWebserver::setClientGetHandler(client, response);
}
+void IndexPageHandler::handleFiles(Client &client) {
+ Common::String response = "<html><head><title>ScummVM</title></head><body>{content}</body></html>"; //TODO
+
+ // load stylish response page from the archive
+ Common::SeekableReadStream *const stream = getArchiveFile(FILES_PAGE_NAME);
+ if (stream) response = readEverythingFromStream(stream);
+
+ // TODO: list specified directory
+ Common::String path = client.queryParameter("path");
+ Common::String content = "";
+
+ //these occur twice:
+ replace(response, "{create_directory_button}", _("Create directory"));
+ replace(response, "{create_directory_button}", _("Create directory"));
+ replace(response, "{upload_files_button}", _("Upload files")); //tab
+ replace(response, "{upload_file_button}", _("Upload files")); //button in the tab
+ replace(response, "{create_directory_desc}", _("Type new directory name:"));
+ replace(response, "{upload_file_desc}", _("Select a file to upload:"));
+ replace(response, "{content}", content);
+ LocalWebserver::setClientGetHandler(client, response);
+}
+
void IndexPageHandler::handleResource(Client &client) {
Common::String filename = client.path();
filename.deleteChar(0);
@@ -80,11 +104,13 @@ void IndexPageHandler::addPathHandler(LocalWebserver &server) {
// we can't use LocalServer yet, because IndexPageHandler is created while LocalWebserver is created
// (thus no _instance is available and it causes stack overflow)
server.addPathHandler("/", new Common::Callback<IndexPageHandler, Client &>(this, &IndexPageHandler::handle));
+ server.addPathHandler("/files", new Common::Callback<IndexPageHandler, Client &>(this, &IndexPageHandler::handleFiles));
Common::ArchiveMemberList fileList = listArchive();
for (Common::ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) {
Common::ArchiveMember const &m = **it;
- if (m.getName() == INDEX_PAGE_NAME) continue;
+ if (m.getName() == INDEX_PAGE_NAME) continue;
+ if (m.getName() == FILES_PAGE_NAME) continue;
server.addPathHandler("/" + m.getName(), new Common::Callback<IndexPageHandler, Client &>(this, &IndexPageHandler::handleResource));
}
}
diff --git a/backends/networking/sdl_net/indexpagehandler.h b/backends/networking/sdl_net/indexpagehandler.h
index cbcc6dab6e..e70ffd5236 100644
--- a/backends/networking/sdl_net/indexpagehandler.h
+++ b/backends/networking/sdl_net/indexpagehandler.h
@@ -34,6 +34,7 @@ class IndexPageHandler: public GUI::CommandSender {
Common::String _code;
void handle(Client &client);
+ void handleFiles(Client &client);
void handleResource(Client &client);
void replace(Common::String &source, const Common::String &what, const Common::String &with);