summaryrefslogtreecommitdiffstats
path: root/src/Core/Requests/CommandRequest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/Requests/CommandRequest.cpp')
-rw-r--r--src/Core/Requests/CommandRequest.cpp16
1 files changed, 10 insertions, 6 deletions
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);
}
}