summaryrefslogtreecommitdiffstats
path: root/src/Daemon/RequestHandlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Daemon/RequestHandlers')
-rw-r--r--src/Daemon/RequestHandlers/CommandRequestHandler.cpp18
-rw-r--r--src/Daemon/RequestHandlers/CommandRequestHandler.h7
2 files changed, 11 insertions, 14 deletions
diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp
index 3f4ef17..b0856c1 100644
--- a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp
+++ b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp
@@ -21,16 +21,12 @@
#include <Common/Exception.h>
#include <Common/Logger.h>
#include <Common/SystemBackend.h>
-#include <Common/XmlPacket.h>
-#include <Net/Connection.h>
-
-#include <sigc++/bind.h>
namespace Mad {
namespace Daemon {
namespace RequestHandlers {
-void CommandRequestHandler::handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet) {
+void CommandRequestHandler::handlePacket(const Common::XmlPacket &packet) {
if(packet.getType() != "Command") {
Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
@@ -38,7 +34,7 @@ void CommandRequestHandler::handlePacket(Net::Connection *connection, uint16_t r
ret.setType("Error");
ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET);
- connection->send(ret.encode(requestId));
+ sendPacket(ret);
signalFinished().emit();
return;
@@ -50,11 +46,11 @@ void CommandRequestHandler::handlePacket(Net::Connection *connection, uint16_t r
std::string command = packet["command"];
if(command == "reboot") {
- if(Common::SystemBackend::shutdown(sigc::bind(sigc::mem_fun(this, &CommandRequestHandler::sendReply), connection, requestId)))
+ if(Common::SystemBackend::shutdown(sigc::mem_fun(this, &CommandRequestHandler::sendReply)))
return;
}
else {
- if(Common::SystemBackend::reboot(sigc::bind(sigc::mem_fun(this, &CommandRequestHandler::sendReply), connection, requestId)))
+ if(Common::SystemBackend::reboot(sigc::mem_fun(this, &CommandRequestHandler::sendReply)))
return;
}
@@ -62,16 +58,16 @@ void CommandRequestHandler::handlePacket(Net::Connection *connection, uint16_t r
ret.setType("Error");
ret.add("ErrorCode", Common::Exception::NOT_IMPLEMENTED);
- connection->send(ret.encode(requestId));
+ sendPacket(ret);
signalFinished().emit();
}
-void CommandRequestHandler::sendReply(Net::Connection *connection, uint16_t requestId) {
+void CommandRequestHandler::sendReply() {
Common::XmlPacket packet;
packet.setType("OK");
- connection->send(packet.encode(requestId));
+ sendPacket(packet);
signalFinished().emit();
}
diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.h b/src/Daemon/RequestHandlers/CommandRequestHandler.h
index 408dbcf..230a8f5 100644
--- a/src/Daemon/RequestHandlers/CommandRequestHandler.h
+++ b/src/Daemon/RequestHandlers/CommandRequestHandler.h
@@ -29,13 +29,14 @@ namespace RequestHandlers {
class CommandRequestHandler : public Common::RequestHandler {
private:
- void sendReply(Net::Connection *connection, uint16_t requestId);
+ void sendReply();
protected:
- virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet);
+ virtual void handlePacket(const Common::XmlPacket &packet);
public:
- CommandRequestHandler() {}
+ CommandRequestHandler(Net::Connection *connection, uint16_t requestId)
+ : RequestHandler(connection, requestId) {}
};
}