diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/networking/sdl_net/indexpagehandler.cpp | 28 | ||||
-rw-r--r-- | backends/networking/sdl_net/indexpagehandler.h | 1 | ||||
-rw-r--r-- | backends/networking/wwwroot.zip | bin | 228232 -> 230835 bytes | |||
-rw-r--r-- | backends/networking/wwwroot/files.html | 50 | ||||
-rw-r--r-- | backends/networking/wwwroot/style.css | 64 |
5 files changed, 142 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); diff --git a/backends/networking/wwwroot.zip b/backends/networking/wwwroot.zip Binary files differindex 403385ba2e..1a301f5db5 100644 --- a/backends/networking/wwwroot.zip +++ b/backends/networking/wwwroot.zip diff --git a/backends/networking/wwwroot/files.html b/backends/networking/wwwroot/files.html new file mode 100644 index 0000000000..8a2788905a --- /dev/null +++ b/backends/networking/wwwroot/files.html @@ -0,0 +1,50 @@ +<!doctype html> +<html> + <head> + <title>ScummVM</title> + <meta charset="utf-8"/> + <link rel="stylesheet" type="text/css" href="style.css"/> + </head> + <body> + <div class="container"> + <div class='header'> + <center><img src="logo.png"/></center> + </div> + <div class="controls"> + <table class="buttons"><tr> + <td><a href="javascript:show('create_directory');">{create_directory_button}</a></td> + <td><a href="javascript:show('upload_file');">{upload_files_button}</a></td> + </tr></table> + <div id="create_directory" class="modal"> + <p>{create_directory_desc}</p> + <form action="create"> + <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" method="post"> + <input type="file" name="upload_file"/> + <input type="submit" value="{upload_file_button}"/> + </form> + </div> + </div> + <div class="content"> + {content} + </div> + </div> + <script> + function show(id) { + var e = document.getElementById(id); + var visible = (e.style.display == "block"); + if (visible) id = ""; //hide + + e = document.getElementById("create_directory"); + e.style.display = (e.id == id ? "block" : "none"); + e = document.getElementById("upload_file"); + e.style.display = (e.id == id ? "block" : "none"); + } + </script> + </body> +</html>
\ No newline at end of file diff --git a/backends/networking/wwwroot/style.css b/backends/networking/wwwroot/style.css index 75c8378229..59d96671db 100644 --- a/backends/networking/wwwroot/style.css +++ b/backends/networking/wwwroot/style.css @@ -22,3 +22,67 @@ html { } .content p { margin: 0 0 6pt 0; } + +.controls { + padding: 8pt; + background: #FFF; + font-family: Tahoma; + font-size: 16pt; +} + +.controls .buttons { + width: 100%; + max-width: 500pt; + margin: -8pt auto; + border: 0; + border-spacing: 0; +} + +.controls .buttons td { + width: 50%; + text-align: center; + margin: 0; + padding: 0; +} + +.controls .buttons a { + display: block; + height: 40pt; + line-height: 38pt; + vertical-align: middle; + color: #000; + text-decoration: none; +} + +.controls .buttons a:hover { + background: #F3F3F3; +} + +.modal { + margin-top: 10pt; + display: none; +} + +.modal p { margin: 0 0 6pt 0; } + +#create_directory input[type="text"], #upload_file input[type="file"] { + width: calc(100% - 2 * 5pt); +} + +.modal input { + border: 1px solid #EEE; + padding: 5pt; + font-size: 12pt; +} + +.modal input[type="submit"] { + display: block; + margin: 6pt auto; + background: #DDD; + border: 0; +} + +.modal input[type="submit"]:hover { + background: #F3F3F3; + cursor: pointer; +}
\ No newline at end of file |