aboutsummaryrefslogtreecommitdiff
path: root/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp
diff options
context:
space:
mode:
authorPeter Bozsó2016-07-30 08:45:11 +0200
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commita1de322c18d9efdf885ea5b760a404237dcdc0a8 (patch)
treee4f6e1ed65e2198f9420a86800c2cc5276351ef1 /backends/networking/sdl_net/handlers/createdirectoryhandler.cpp
parent712410496e4e59fe1ee1968a94eeb73b51223996 (diff)
downloadscummvm-rg350-a1de322c18d9efdf885ea5b760a404237dcdc0a8.tar.gz
scummvm-rg350-a1de322c18d9efdf885ea5b760a404237dcdc0a8.tar.bz2
scummvm-rg350-a1de322c18d9efdf885ea5b760a404237dcdc0a8.zip
CLOUD: Use overriden handle() instead of ClientHandlerCallback in page handlers
Using a dedicated callback object for this was an unnecessary overhead.
Diffstat (limited to 'backends/networking/sdl_net/handlers/createdirectoryhandler.cpp')
-rw-r--r--backends/networking/sdl_net/handlers/createdirectoryhandler.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp b/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp
index 474ac7465e..53e58b4ad2 100644
--- a/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp
+++ b/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp
@@ -25,6 +25,7 @@
#include "backends/networking/sdl_net/handlerutils.h"
#include "backends/networking/sdl_net/localwebserver.h"
#include "common/translation.h"
+#include <common/callback.h>
namespace Networking {
@@ -32,6 +33,24 @@ CreateDirectoryHandler::CreateDirectoryHandler() {}
CreateDirectoryHandler::~CreateDirectoryHandler() {}
+void CreateDirectoryHandler::handleError(Client &client, Common::String message) const {
+ if (client.queryParameter("answer_json") == "true")
+ setJsonResponseHandler(client, "error", message);
+ else
+ HandlerUtils::setFilesManagerErrorMessageHandler(client, message);
+}
+
+void CreateDirectoryHandler::setJsonResponseHandler(Client &client, Common::String type, Common::String message) const {
+ Common::JSONObject response;
+ response.setVal("type", new Common::JSONValue(type));
+ response.setVal("message", new Common::JSONValue(message));
+
+ Common::JSONValue json = response;
+ LocalWebserver::setClientGetHandler(client, json.stringify(true));
+}
+
+/// public
+
void CreateDirectoryHandler::handle(Client &client) {
Common::String path = client.queryParameter("path");
Common::String name = client.queryParameter("directory_name");
@@ -97,26 +116,4 @@ void CreateDirectoryHandler::handle(Client &client) {
);
}
-void CreateDirectoryHandler::handleError(Client &client, Common::String message) const {
- if (client.queryParameter("answer_json") == "true")
- setJsonResponseHandler(client, "error", message);
- else
- HandlerUtils::setFilesManagerErrorMessageHandler(client, message);
-}
-
-void CreateDirectoryHandler::setJsonResponseHandler(Client &client, Common::String type, Common::String message) const {
- Common::JSONObject response;
- response.setVal("type", new Common::JSONValue(type));
- response.setVal("message", new Common::JSONValue(message));
-
- Common::JSONValue json = response;
- LocalWebserver::setClientGetHandler(client, json.stringify(true));
-}
-
-/// public
-
-ClientHandlerCallback CreateDirectoryHandler::getHandler() {
- return new Common::Callback<CreateDirectoryHandler, Client &>(this, &CreateDirectoryHandler::handle);
-}
-
} // End of namespace Networking