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

resourcehandler.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/resourcehandler.h"
00024 #include "backends/networking/sdl_net/handlerutils.h"
00025 #include "backends/networking/sdl_net/localwebserver.h"
00026 
00027 namespace Networking {
00028 
00029 ResourceHandler::ResourceHandler() {}
00030 
00031 ResourceHandler::~ResourceHandler() {}
00032 
00033 const char *ResourceHandler::determineMimeType(Common::String &filename) {
00034     // text
00035     if (filename.hasSuffix(".html")) return "text/html";
00036     if (filename.hasSuffix(".css")) return "text/css";
00037     if (filename.hasSuffix(".txt")) return "text/plain";
00038     if (filename.hasSuffix(".js")) return "application/javascript";
00039 
00040     // images
00041     if (filename.hasSuffix(".jpeg") || filename.hasSuffix(".jpg") || filename.hasSuffix(".jpe")) return "image/jpeg";
00042     if (filename.hasSuffix(".gif")) return "image/gif";
00043     if (filename.hasSuffix(".png")) return "image/png";
00044     if (filename.hasSuffix(".svg")) return "image/svg+xml";
00045     if (filename.hasSuffix(".tiff")) return "image/tiff";
00046     if (filename.hasSuffix(".ico")) return "image/vnd.microsoft.icon";
00047     if (filename.hasSuffix(".wbmp")) return "image/vnd.wap.wbmp";
00048 
00049     if (filename.hasSuffix(".zip")) return "application/zip";
00050     return "application/octet-stream";
00051 }
00052 
00054 
00055 void ResourceHandler::handle(Client &client) {
00056     Common::String filename = client.path();
00057     filename.deleteChar(0);
00058 
00059     // if archive hidden file is requested, ignore
00060     if (filename.size() && filename[0] == '.')
00061         return;
00062 
00063     // if file not found, don't set handler either
00064     Common::SeekableReadStream *file = HandlerUtils::getArchiveFile(filename);
00065     if (file == nullptr)
00066         return;
00067 
00068     LocalWebserver::setClientGetHandler(client, file, 200, determineMimeType(filename));
00069 }
00070 
00071 bool ResourceHandler::minimalModeSupported() {
00072     return true;
00073 }
00074 
00075 } // End of namespace Networking


Generated on Sat Feb 23 2019 05:01:15 for ResidualVM by doxygen 1.7.1
curved edge   curved edge