From 63907817cb057f497f03a28016d408885cbe41ea Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 1 Mar 2009 00:51:00 +0100 Subject: Alle uebrigen Requests ausser GSSAPIAuthRequest in XmlRequests umgewandelt --- src/Core/Requests/CommandRequest.cpp | 16 ++++++++++------ src/Core/Requests/CommandRequest.h | 8 ++++---- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/Core/Requests') diff --git a/src/Core/Requests/CommandRequest.cpp b/src/Core/Requests/CommandRequest.cpp index 35d4dd2..a34a551 100644 --- a/src/Core/Requests/CommandRequest.cpp +++ b/src/Core/Requests/CommandRequest.cpp @@ -26,20 +26,24 @@ namespace Core { namespace Requests { void CommandRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { - connection->send(Net::Packet(reboot ? Net::Packet::COMMAND_REBOOT : Net::Packet::COMMAND_SHUTDOWN, requestId)); + Common::XmlPacket packet; + packet.setType("Command"); + packet.add("command", reboot ? "reboot" : "shutdown"); + + connection->send(packet.encode(requestId)); } -void CommandRequest::handlePacket(Net::Connection*, const Net::Packet &packet) { - if(packet.getType() == Net::Packet::ERROR) { - finishWithError(Net::Packets::ErrorPacket(packet).getException()); +void CommandRequest::handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet) { + if(packet.getType() == "Error") { + finishWithError(Common::Exception(packet["Where"], packet["ErrorCode"], packet["SubCode"], packet["SubSubCode"])); return; } - else if(packet.getType() != Net::Packet::OK) { + else if(packet.getType() != "OK") { finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET)); return; // TODO Logging } - finish(); + finish(packet); } } diff --git a/src/Core/Requests/CommandRequest.h b/src/Core/Requests/CommandRequest.h index 181fa4d..534fcef 100644 --- a/src/Core/Requests/CommandRequest.h +++ b/src/Core/Requests/CommandRequest.h @@ -20,22 +20,22 @@ #ifndef MAD_CORE_REQUESTS_COMMANDREQUEST_H_ #define MAD_CORE_REQUESTS_COMMANDREQUEST_H_ -#include +#include namespace Mad { namespace Core { namespace Requests { -class CommandRequest : public Common::Request<> { +class CommandRequest : public Common::XmlRequest { private: bool reboot; protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); - virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); + virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - CommandRequest(bool reboot0, slot_type slot) : Common::Request<>(slot), reboot(reboot0) {} + CommandRequest(bool reboot0, slot_type slot) : Common::XmlRequest(slot), reboot(reboot0) {} }; } -- cgit v1.2.3