ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

filesajaxpagehandler.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "backends/networking/sdl_net/handlers/filesajaxpagehandler.h"
00024 #include "backends/networking/sdl_net/handlerutils.h"
00025 #include "backends/networking/sdl_net/localwebserver.h"
00026 #include "common/translation.h"
00027 
00028 namespace Networking {
00029 
00030 #define FILES_PAGE_NAME ".filesAJAX.html"
00031 
00032 FilesAjaxPageHandler::FilesAjaxPageHandler() {}
00033 
00034 FilesAjaxPageHandler::~FilesAjaxPageHandler() {}
00035 
00036 namespace {
00037 
00038 Common::String encodeDoubleQuotesAndSlashes(Common::String s) {
00039     Common::String result = "";
00040     for (uint32 i = 0; i < s.size(); ++i)
00041         if (s[i] == '"') {
00042             result += "\\\"";
00043         } else if (s[i] == '\\') {
00044             result += "\\\\";
00045         } else {
00046             result += s[i];
00047         }
00048     return result;
00049 }
00050 
00051 }
00052 
00054 
00055 void FilesAjaxPageHandler::handle(Client &client) {
00056     // load stylish response page from the archive
00057     Common::SeekableReadStream *const stream = HandlerUtils::getArchiveFile(FILES_PAGE_NAME);
00058     if (stream == nullptr) {
00059         HandlerUtils::setFilesManagerErrorMessageHandler(client, _("The page is not available without the resources."));
00060         return;
00061     }
00062 
00063     Common::String response = HandlerUtils::readEverythingFromStream(stream);
00064     Common::String path = client.queryParameter("path");
00065 
00066     //these occur twice:
00067     replace(response, "{create_directory_button}", _("Create directory"));
00068     replace(response, "{create_directory_button}", _("Create directory"));
00069     replace(response, "{upload_files_button}", _("Upload files")); //tab
00070     replace(response, "{upload_file_button}", _("Upload files")); //button in the tab
00071     replace(response, "{create_directory_desc}", _("Type new directory name:"));
00072     replace(response, "{upload_file_desc}", _("Select a file to upload:"));
00073     replace(response, "{or_upload_directory_desc}", _("Or select a directory (works in Chrome only):"));
00074     replace(response, "{index_of}", _("Index of "));
00075     replace(response, "{loading}", _("Loading..."));
00076     replace(response, "{error}", _("Error occurred"));
00077     replace(response, "{start_path}", encodeDoubleQuotesAndSlashes(path));
00078     LocalWebserver::setClientGetHandler(client, response);
00079 }
00080 
00081 } // End of namespace Networking


Generated on Sat Sep 14 2019 05:01:00 for ResidualVM by doxygen 1.7.1
curved edge   curved edge