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/RequestHandlers/DaemonListRequestHandler.h | 5 +++-- src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp | 12 +++++++++--- src/Core/RequestHandlers/DaemonStatusRequestHandler.h | 8 +++++--- src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h | 5 +++-- src/Core/RequestHandlers/IdentifyRequestHandler.h | 5 +++-- 5 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src/Core/RequestHandlers') diff --git a/src/Core/RequestHandlers/DaemonListRequestHandler.h b/src/Core/RequestHandlers/DaemonListRequestHandler.h index 1aabe5b..205ad02 100644 --- a/src/Core/RequestHandlers/DaemonListRequestHandler.h +++ b/src/Core/RequestHandlers/DaemonListRequestHandler.h @@ -27,10 +27,11 @@ namespace Core { namespace RequestHandlers { class DaemonListRequestHandler : public Common::RequestHandler { + protected: + virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); + public: DaemonListRequestHandler() {} - - virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); }; } diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp index bb5d45f..efdf3ea 100644 --- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp +++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp @@ -48,15 +48,21 @@ void DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, const try { Net::Connection *daemonCon = ConnectionManager::getConnectionManager()->getDaemonConnection(daemonName); - Requests::DaemonStatusRequest::send(daemonCon, sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished)); + Common::RequestManager::getRequestManager()->sendRequest(daemonCon, std::auto_ptr(new Requests::DaemonStatusRequest(sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished)))); } catch(Common::Exception &e) { connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), e)); } } -void DaemonStatusRequestHandler::requestFinished(const Net::Packets::HostStatusPacket &packet) { - con->send(Net::Packet(Net::Packet::OK, requestId, packet.getData(), packet.getLength())); +void DaemonStatusRequestHandler::requestFinished(const Common::Request &request) { + try { + const Net::Packet &packet = request.getResult(); + con->send(Net::Packet(Net::Packet::OK, requestId, packet.getData(), packet.getLength())); + } + catch(Common::Exception &e) { + con->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, requestId, e)); + } signalFinished().emit(); } diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h index 916a3ec..d8edc41 100644 --- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h +++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h @@ -21,6 +21,7 @@ #define MAD_CORE_REQUESTHANDLERS_DAEMONSTATUSREQUESTHANDLER_H_ #include +#include #include namespace Mad { @@ -42,12 +43,13 @@ class DaemonStatusRequestHandler : public Common::RequestHandler { Net::Connection *con; uint16_t requestId; - void requestFinished(const Net::Packets::HostStatusPacket &packet); + void requestFinished(const Common::Request &request); + + protected: + virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); public: DaemonStatusRequestHandler() {} - - virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); }; } diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h index 2a7884b..e222fef 100644 --- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h +++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h @@ -33,10 +33,11 @@ class GSSAPIAuthRequestHandler : public Common::RequestHandler { bool gssContinue, sentSignature; + protected: + virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); + public: GSSAPIAuthRequestHandler() : gssContext(GSS_C_NO_CONTEXT), gssContinue(true), sentSignature(false) {} - - virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); }; } diff --git a/src/Core/RequestHandlers/IdentifyRequestHandler.h b/src/Core/RequestHandlers/IdentifyRequestHandler.h index 74ffd54..58f10ba 100644 --- a/src/Core/RequestHandlers/IdentifyRequestHandler.h +++ b/src/Core/RequestHandlers/IdentifyRequestHandler.h @@ -27,10 +27,11 @@ namespace Core { namespace RequestHandlers { class IdentifyRequestHandler : public Common::RequestHandler { + protected: + virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); + public: IdentifyRequestHandler() {} - - virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); }; } -- cgit v1.2.3