From d08a98b8304eb2c831907254095d6829fb98a95b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 16 Sep 2008 04:54:36 +0200 Subject: Korrekte Reaktion auf Fehler in DaemonStatusRequest --- src/Client/Requests/DaemonStatusRequest.cpp | 13 +++++++++++-- src/Client/Requests/DaemonStatusRequest.h | 8 +++++++- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src/Client/Requests') diff --git a/src/Client/Requests/DaemonStatusRequest.cpp b/src/Client/Requests/DaemonStatusRequest.cpp index 7a7b47e..719ae5c 100644 --- a/src/Client/Requests/DaemonStatusRequest.cpp +++ b/src/Client/Requests/DaemonStatusRequest.cpp @@ -19,16 +19,20 @@ #include "DaemonStatusRequest.h" #include +#include #include namespace Mad { namespace Client { namespace Requests { -bool DaemonStatusRequest::send(Net::Connection *connection, const sigc::slot &callback, const std::string &daemon0) { +bool DaemonStatusRequest::send(Net::Connection *connection, const sigc::slot &callback, + const sigc::slot &errorCallback, const std::string &daemon0) +{ DaemonStatusRequest *request = new DaemonStatusRequest(daemon0); request->finished.connect(callback); + request->error.connect(errorCallback); if(Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, request)) return true; @@ -45,7 +49,12 @@ bool DaemonStatusRequest::sendRequest(Net::Connection *connection, uint16_t requ } void DaemonStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) { - if(packet.getType() != Net::Packet::OK) { + if(packet.getType() == Net::Packet::ERROR) { + error(Net::Packets::ErrorPacket(packet).getException()); + signalFinished().emit(); + return; + } + else if(packet.getType() != Net::Packet::OK) { signalFinished().emit(); return; // TODO Logging } diff --git a/src/Client/Requests/DaemonStatusRequest.h b/src/Client/Requests/DaemonStatusRequest.h index 34d3a90..f5c130d 100644 --- a/src/Client/Requests/DaemonStatusRequest.h +++ b/src/Client/Requests/DaemonStatusRequest.h @@ -27,6 +27,10 @@ namespace Mad { +namespace Common { +class Exception; +} + namespace Net { namespace Packets { class HostStatusPacket; @@ -39,13 +43,15 @@ namespace Requests { class DaemonStatusRequest : public Common::Request { private: sigc::signal finished; + sigc::signal error; std::string daemon; DaemonStatusRequest(const std::string &daemon0) : daemon(daemon0) {} public: - static bool send(Net::Connection *connection, const sigc::slot &callback, const std::string &daemon0); + static bool send(Net::Connection *connection, const sigc::slot &callback, + const sigc::slot &errorCallback, const std::string &daemon0); virtual bool sendRequest(Net::Connection *connection, uint16_t requestId); virtual void handlePacket(Net::Connection*, const Net::Packet &packet); -- cgit v1.2.3