summaryrefslogtreecommitdiffstats
path: root/src/Core/Requests
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-03-01 00:51:00 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-03-01 00:51:00 +0100
commit63907817cb057f497f03a28016d408885cbe41ea (patch)
treea9ad6b0b19bff7722b21375137ba6e53c8869c91 /src/Core/Requests
parent46c110f7a14e4b5d0e8bd27259f7744ae8a36382 (diff)
downloadmad-63907817cb057f497f03a28016d408885cbe41ea.tar
mad-63907817cb057f497f03a28016d408885cbe41ea.zip
Alle uebrigen Requests ausser GSSAPIAuthRequest in XmlRequests umgewandelt
Diffstat (limited to 'src/Core/Requests')
-rw-r--r--src/Core/Requests/CommandRequest.cpp16
-rw-r--r--src/Core/Requests/CommandRequest.h8
2 files changed, 14 insertions, 10 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);
}
}
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 <Common/Request.h>
+#include <Common/XmlRequest.h>
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) {}
};
}