From f0fc18d2ee02c61524486aa1e73b781a6f64ef23 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Fri, 8 Jul 2016 16:00:11 +0600 Subject: CLOUD: Add UploadFileHandler --- .../sdl_net/handlers/uploadfilehandler.h | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 backends/networking/sdl_net/handlers/uploadfilehandler.h (limited to 'backends/networking/sdl_net/handlers/uploadfilehandler.h') diff --git a/backends/networking/sdl_net/handlers/uploadfilehandler.h b/backends/networking/sdl_net/handlers/uploadfilehandler.h new file mode 100644 index 0000000000..6300a13e8d --- /dev/null +++ b/backends/networking/sdl_net/handlers/uploadfilehandler.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef BACKENDS_NETWORKING_SDL_NET_UPLOADFILEHANDLER_H +#define BACKENDS_NETWORKING_SDL_NET_UPLOADFILEHANDLER_H + +#include "backends/networking/sdl_net/handlers/filesbasehandler.h" + +namespace Networking { + +class UploadFileHandler: public FilesBaseHandler { + void handle(Client &client); + void handleErrorMessage(Client &client, Common::String message); + + /** + * Uploads file. + * + * Fills on failure. + * + * Returns true on success. + */ + bool uploadFile(Client &client, Common::String &errorMessage); +public: + UploadFileHandler(); + virtual ~UploadFileHandler(); + + virtual ClientHandlerCallback getHandler(); +}; + +} // End of namespace Networking + +#endif -- cgit v1.2.3 From e4bb7c4e750d53434140a8d1a401e7fa6ee221ab Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sat, 9 Jul 2016 15:49:18 +0600 Subject: CLOUD: Add UploadFileClientHandler Now Client reads the first headers block, then LocalWebserver decides which Handler to use. In case of "/upload", UploadFileHandler is used. But now it only knows the "path" parameter. If that's valid, actual UploadFileClientHandler is created, which reads the contents of the request and, when finds there an "upload_file" field, starts saving it in the directory specified by "path". With that we don't need temp files approach from Reader class. --- backends/networking/sdl_net/handlers/uploadfilehandler.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'backends/networking/sdl_net/handlers/uploadfilehandler.h') diff --git a/backends/networking/sdl_net/handlers/uploadfilehandler.h b/backends/networking/sdl_net/handlers/uploadfilehandler.h index 6300a13e8d..bba7fdfc02 100644 --- a/backends/networking/sdl_net/handlers/uploadfilehandler.h +++ b/backends/networking/sdl_net/handlers/uploadfilehandler.h @@ -29,16 +29,7 @@ namespace Networking { class UploadFileHandler: public FilesBaseHandler { void handle(Client &client); - void handleErrorMessage(Client &client, Common::String message); - - /** - * Uploads file. - * - * Fills on failure. - * - * Returns true on success. - */ - bool uploadFile(Client &client, Common::String &errorMessage); + public: UploadFileHandler(); virtual ~UploadFileHandler(); -- cgit v1.2.3 From 438ba985a4a97a8695a6e6fdda6930694976c07b Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Thu, 21 Jul 2016 11:44:36 +0600 Subject: JANITORIAL: Remove spaces at the end of the line I knew there were some, but I wanted to fix them once, instead of doing it all the time. --- backends/networking/sdl_net/handlers/uploadfilehandler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/networking/sdl_net/handlers/uploadfilehandler.h') diff --git a/backends/networking/sdl_net/handlers/uploadfilehandler.h b/backends/networking/sdl_net/handlers/uploadfilehandler.h index bba7fdfc02..4cd6115182 100644 --- a/backends/networking/sdl_net/handlers/uploadfilehandler.h +++ b/backends/networking/sdl_net/handlers/uploadfilehandler.h @@ -29,7 +29,7 @@ namespace Networking { class UploadFileHandler: public FilesBaseHandler { void handle(Client &client); - + public: UploadFileHandler(); virtual ~UploadFileHandler(); -- cgit v1.2.3 From a1de322c18d9efdf885ea5b760a404237dcdc0a8 Mon Sep 17 00:00:00 2001 From: Peter Bozsó Date: Sat, 30 Jul 2016 08:45:11 +0200 Subject: CLOUD: Use overriden handle() instead of ClientHandlerCallback in page handlers Using a dedicated callback object for this was an unnecessary overhead. --- backends/networking/sdl_net/handlers/uploadfilehandler.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'backends/networking/sdl_net/handlers/uploadfilehandler.h') diff --git a/backends/networking/sdl_net/handlers/uploadfilehandler.h b/backends/networking/sdl_net/handlers/uploadfilehandler.h index 4cd6115182..cbff215156 100644 --- a/backends/networking/sdl_net/handlers/uploadfilehandler.h +++ b/backends/networking/sdl_net/handlers/uploadfilehandler.h @@ -28,13 +28,11 @@ namespace Networking { class UploadFileHandler: public FilesBaseHandler { - void handle(Client &client); - public: UploadFileHandler(); virtual ~UploadFileHandler(); - virtual ClientHandlerCallback getHandler(); + virtual void handle(Client &client); }; } // End of namespace Networking -- cgit v1.2.3