From 039c218a7b1f2eae4f8e8305bc8e8bf70a67beab Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 17 Sep 2008 05:33:01 +0200 Subject: Interface der Request-Klassen verbessert; muss noch vereinfacht werden --- src/Core/Requests/DaemonStatusRequest.cpp | 25 ++++--------------------- src/Core/Requests/DaemonStatusRequest.h | 17 +++++------------ 2 files changed, 9 insertions(+), 33 deletions(-) (limited to 'src/Core/Requests') diff --git a/src/Core/Requests/DaemonStatusRequest.cpp b/src/Core/Requests/DaemonStatusRequest.cpp index 86ef3c6..1741731 100644 --- a/src/Core/Requests/DaemonStatusRequest.cpp +++ b/src/Core/Requests/DaemonStatusRequest.cpp @@ -25,34 +25,17 @@ namespace Mad { namespace Core { namespace Requests { -bool DaemonStatusRequest::send(Net::Connection *connection, const sigc::slot &callback) { - DaemonStatusRequest *request = new DaemonStatusRequest(); - - request->finished.connect(callback); - - if(Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, request)) - return true; - - delete request; - return false; -} - -bool DaemonStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { - if(!connection->send(Net::Packet(Net::Packet::STATUS, requestId))) - return false; - - return true; +void DaemonStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { + connection->send(Net::Packet(Net::Packet::STATUS, requestId)); } void DaemonStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) { if(packet.getType() != Net::Packet::OK) { - signalFinished().emit(); + finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET)); return; // TODO Logging } - finished(Net::Packets::HostStatusPacket(packet)); - - signalFinished().emit(); + finish(Net::Packets::HostStatusPacket(packet)); } } diff --git a/src/Core/Requests/DaemonStatusRequest.h b/src/Core/Requests/DaemonStatusRequest.h index ce6e4f7..baeb847 100644 --- a/src/Core/Requests/DaemonStatusRequest.h +++ b/src/Core/Requests/DaemonStatusRequest.h @@ -22,9 +22,6 @@ #include -#include -#include - namespace Mad { namespace Net { @@ -36,17 +33,13 @@ class HostStatusPacket; namespace Core { namespace Requests { -class DaemonStatusRequest : public Common::Request { - private: - sigc::signal finished; - - DaemonStatusRequest() {} +class DaemonStatusRequest : public Common::Request { + protected: + virtual void sendRequest(Net::Connection *connection, uint16_t requestId); + virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); public: - static bool send(Net::Connection *connection, const sigc::slot &callback); - - virtual bool sendRequest(Net::Connection *connection, uint16_t requestId); - virtual void handlePacket(Net::Connection*, const Net::Packet &packet); + DaemonStatusRequest(slot_type slot) : Common::Request(slot) {} }; } -- cgit v1.2.3