From 73667d1102735c42cf385442aeb2a1735bb67d6a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 21 May 2009 01:42:33 +0200 Subject: SystemBackend-Interface ueberarbeitet --- .../RequestHandlers/CommandRequestHandler.cpp | 34 +++++++++------------- src/Daemon/RequestHandlers/CommandRequestHandler.h | 6 +--- 2 files changed, 14 insertions(+), 26 deletions(-) (limited to 'src/Daemon') diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp index f7f21de..952837c 100644 --- a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp +++ b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp @@ -22,8 +22,6 @@ #include #include -#include - namespace Mad { namespace Daemon { namespace RequestHandlers { @@ -47,30 +45,24 @@ void CommandRequestHandler::handlePacket(const Common::XmlPacket &packet) { std::string command = packet["command"]; - if(command == "reboot") { - if(Common::SystemManager::get()->shutdown(boost::bind(&CommandRequestHandler::sendReply, this))) - return; + bool ok; + + if(command == "reboot") + ok = Common::SystemManager::get()->shutdown(); + else + ok = Common::SystemManager::get()->reboot(); + + Common::XmlPacket ret; + + if(ok) { + ret.setType("OK"); } else { - if(Common::SystemManager::get()->reboot(boost::bind(&CommandRequestHandler::sendReply, this))) - return; + ret.setType("Error"); + ret.add("ErrorCode", Net::Exception::NOT_IMPLEMENTED); } - Common::XmlPacket ret; - ret.setType("Error"); - ret.add("ErrorCode", Net::Exception::NOT_IMPLEMENTED); - sendPacket(ret); - - signalFinished()(); -} - -void CommandRequestHandler::sendReply() { - Common::XmlPacket packet; - packet.setType("OK"); - - sendPacket(packet); - signalFinished()(); } diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.h b/src/Daemon/RequestHandlers/CommandRequestHandler.h index 73aced0..a033c75 100644 --- a/src/Daemon/RequestHandlers/CommandRequestHandler.h +++ b/src/Daemon/RequestHandlers/CommandRequestHandler.h @@ -21,21 +21,17 @@ #define MAD_DAEMON_REQUESTHANDLERS_COMMANDREQUESTHANDLER_H_ #include -#include namespace Mad { namespace Daemon { namespace RequestHandlers { class CommandRequestHandler : public Common::RequestHandler { - private: - void sendReply(); - protected: virtual void handlePacket(const Common::XmlPacket &packet); public: - CommandRequestHandler(Common::Connection *connection, uint16_t requestId) + CommandRequestHandler(Common::Connection *connection, boost::uint16_t requestId) : RequestHandler(connection, requestId) {} }; -- cgit v1.2.3