From de5fa3867791bf4bf84a52de8cd09821f9ce28ab Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 4 Mar 2009 23:14:34 +0100 Subject: XmlRequest{,Handler} in Request{,Handler} umbenannt --- src/Client/CommandManager.cpp | 16 ++--- src/Client/CommandManager.h | 16 ++--- src/Client/CommandParser.cpp | 16 ++--- src/Client/InformationManager.cpp | 4 +- src/Client/InformationManager.h | 6 +- src/Client/Requests/DaemonCommandRequest.h | 6 +- src/Client/Requests/DaemonFSInfoRequest.h | 6 +- src/Client/Requests/DaemonListRequest.h | 6 +- src/Client/Requests/DaemonStatusRequest.h | 6 +- src/Common/Makefile.am | 4 +- src/Common/Makefile.in | 4 +- src/Common/Request.h | 69 ++++++++++++++++++++++ src/Common/RequestHandler.h | 61 +++++++++++++++++++ .../RequestHandlers/DisconnectRequestHandler.h | 4 +- src/Common/RequestHandlers/FSInfoRequestHandler.h | 4 +- src/Common/RequestHandlers/StatusRequestHandler.h | 4 +- src/Common/RequestManager.cpp | 60 +++++++++---------- src/Common/RequestManager.h | 38 ++++++------ src/Common/Requests/DisconnectRequest.h | 6 +- src/Common/Requests/FSInfoRequest.h | 6 +- src/Common/Requests/GSSAPIAuthRequest.h | 6 +- src/Common/Requests/StatusRequest.h | 6 +- src/Common/Requests/UserListRequest.h | 6 +- src/Common/XmlRequest.h | 69 ---------------------- src/Common/XmlRequestHandler.h | 61 ------------------- src/Core/ConnectionManager.cpp | 2 +- .../DaemonCommandRequestHandler.cpp | 4 +- .../RequestHandlers/DaemonCommandRequestHandler.h | 8 +-- .../RequestHandlers/DaemonFSInfoRequestHandler.cpp | 4 +- .../RequestHandlers/DaemonFSInfoRequestHandler.h | 8 +-- .../RequestHandlers/DaemonListRequestHandler.h | 4 +- .../RequestHandlers/DaemonStatusRequestHandler.cpp | 4 +- .../RequestHandlers/DaemonStatusRequestHandler.h | 8 +-- .../RequestHandlers/GSSAPIAuthRequestHandler.h | 4 +- src/Core/RequestHandlers/IdentifyRequestHandler.h | 4 +- src/Core/RequestHandlers/LogRequestHandler.h | 4 +- src/Core/RequestHandlers/UserListRequestHandler.h | 4 +- src/Core/Requests/CommandRequest.h | 6 +- src/Core/Requests/DaemonStateUpdateRequest.h | 6 +- src/Daemon/Backends/NetworkLogger.h | 2 +- src/Daemon/RequestHandlers/CommandRequestHandler.h | 4 +- src/Daemon/Requests/IdentifyRequest.h | 6 +- src/Daemon/Requests/LogRequest.h | 6 +- src/mad.cpp | 4 +- 44 files changed, 291 insertions(+), 291 deletions(-) create mode 100644 src/Common/Request.h create mode 100644 src/Common/RequestHandler.h delete mode 100644 src/Common/XmlRequest.h delete mode 100644 src/Common/XmlRequestHandler.h (limited to 'src') diff --git a/src/Client/CommandManager.cpp b/src/Client/CommandManager.cpp index bcb3429..3bfc3a6 100644 --- a/src/Client/CommandManager.cpp +++ b/src/Client/CommandManager.cpp @@ -20,7 +20,7 @@ #include "CommandManager.h" #include #include -#include +#include #include #include @@ -136,7 +136,7 @@ void CommandManager::printHostStatus(const Common::XmlPacket &packet) { } -void CommandManager::daemonCommandRequestFinished(const Common::XmlRequest &request) { +void CommandManager::daemonCommandRequestFinished(const Common::Request &request) { try { request.getResult(); } @@ -147,7 +147,7 @@ void CommandManager::daemonCommandRequestFinished(const Common::XmlRequest &requ requestFinished(); } -void CommandManager::daemonFSInfoRequestFinished(const Common::XmlRequest &request) { +void CommandManager::daemonFSInfoRequestFinished(const Common::Request &request) { try { const Common::XmlPacket &packet = request.getResult(); std::cout << "Host file system usage:" << std::endl; @@ -160,7 +160,7 @@ void CommandManager::daemonFSInfoRequestFinished(const Common::XmlRequest &reque requestFinished(); } -void CommandManager::daemonStatusRequestFinished(const Common::XmlRequest &request) { +void CommandManager::daemonStatusRequestFinished(const Common::Request &request) { try { const Common::XmlPacket &packet = request.getResult(); std::cout << "Host status:" << std::endl; @@ -173,7 +173,7 @@ void CommandManager::daemonStatusRequestFinished(const Common::XmlRequest &reque requestFinished(); } -void CommandManager::disconnectRequestFinished(const Common::XmlRequest &request) { +void CommandManager::disconnectRequestFinished(const Common::Request &request) { try { request.getResult(); disconnect = true; @@ -185,7 +185,7 @@ void CommandManager::disconnectRequestFinished(const Common::XmlRequest &request requestFinished(); } -void CommandManager::fsInfoRequestFinished(const Common::XmlRequest &request) { +void CommandManager::fsInfoRequestFinished(const Common::Request &request) { try { const Common::XmlPacket &packet = request.getResult(); std::cout << "Server file system usage:" << std::endl; @@ -198,7 +198,7 @@ void CommandManager::fsInfoRequestFinished(const Common::XmlRequest &request) { requestFinished(); } -void CommandManager::statusRequestFinished(const Common::XmlRequest &request) { +void CommandManager::statusRequestFinished(const Common::Request &request) { try { const Common::XmlPacket &packet = request.getResult(); std::cout << "Server status:" << std::endl; @@ -211,7 +211,7 @@ void CommandManager::statusRequestFinished(const Common::XmlRequest &request) { requestFinished(); } -void CommandManager::userListRequestFinished(const Common::XmlRequest &request) { +void CommandManager::userListRequestFinished(const Common::Request &request) { try { const Common::XmlPacket &packet = request.getResult(); diff --git a/src/Client/CommandManager.h b/src/Client/CommandManager.h index a49cda7..1c6e5fc 100644 --- a/src/Client/CommandManager.h +++ b/src/Client/CommandManager.h @@ -26,7 +26,7 @@ namespace Mad { namespace Common { class XmlPacket; -class XmlRequest; +class Request; } namespace Client { @@ -52,13 +52,13 @@ class CommandManager { void printFSInfo(const Common::XmlPacket &packet); void printHostStatus(const Common::XmlPacket &packet); - void daemonCommandRequestFinished(const Common::XmlRequest &request); - void daemonFSInfoRequestFinished(const Common::XmlRequest &request); - void daemonStatusRequestFinished(const Common::XmlRequest &request); - void disconnectRequestFinished(const Common::XmlRequest &request); - void fsInfoRequestFinished(const Common::XmlRequest &request); - void statusRequestFinished(const Common::XmlRequest &request); - void userListRequestFinished(const Common::XmlRequest &request); + void daemonCommandRequestFinished(const Common::Request &request); + void daemonFSInfoRequestFinished(const Common::Request &request); + void daemonStatusRequestFinished(const Common::Request &request); + void disconnectRequestFinished(const Common::Request &request); + void fsInfoRequestFinished(const Common::Request &request); + void statusRequestFinished(const Common::Request &request); + void userListRequestFinished(const Common::Request &request); CommandManager() : activeRequests(0), disconnect(false) {} diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp index 526f434..27aac78 100644 --- a/src/Client/CommandParser.cpp +++ b/src/Client/CommandParser.cpp @@ -110,9 +110,9 @@ std::map CommandParser::parseHostList(const std:: void CommandParser::fsinfoCommand(const std::vector &args) { if(args.size() == 1) - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Common::Requests::FSInfoRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::fsInfoRequestFinished)))); + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Common::Requests::FSInfoRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::fsInfoRequestFinished)))); else if(args.size() == 2) - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Requests::DaemonFSInfoRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonFSInfoRequestFinished)))); + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Requests::DaemonFSInfoRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonFSInfoRequestFinished)))); else { Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str()); printUsage("fsinfo"); @@ -213,7 +213,7 @@ void CommandParser::rebootCommand(const std::vector &args) { std::map hosts = parseHostList(std::vector(args.begin()+1, args.end()), true); for(std::map::iterator host = hosts.begin(); host != hosts.end(); ++host) { - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr( + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr( new Requests::DaemonCommandRequest(host->first, true, sigc::mem_fun(CommandManager::get(), &CommandManager::daemonCommandRequestFinished)) )); @@ -231,7 +231,7 @@ void CommandParser::shutdownCommand(const std::vector &args) { std::map hosts = parseHostList(std::vector(args.begin()+1, args.end()), true); for(std::map::iterator host = hosts.begin(); host != hosts.end(); ++host) { - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr( + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr( new Requests::DaemonCommandRequest(host->first, false, sigc::mem_fun(CommandManager::get(), &CommandManager::daemonCommandRequestFinished)) )); @@ -241,9 +241,9 @@ void CommandParser::shutdownCommand(const std::vector &args) { void CommandParser::statusCommand(const std::vector &args) { if(args.size() == 1) - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Common::Requests::StatusRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::statusRequestFinished)))); + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Common::Requests::StatusRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::statusRequestFinished)))); else if(args.size() == 2) - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonStatusRequestFinished)))); + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonStatusRequestFinished)))); else { Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str()); printUsage("status"); @@ -256,13 +256,13 @@ void CommandParser::statusCommand(const std::vector &args) { void CommandParser::listUsersCommand(const std::vector&) { ++CommandManager::get()->activeRequests; - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Common::Requests::UserListRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::userListRequestFinished)))); + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Common::Requests::UserListRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::userListRequestFinished)))); } void CommandParser::exitCommand(const std::vector&) { ++CommandManager::get()->activeRequests; - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Common::Requests::DisconnectRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::disconnectRequestFinished)))); + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Common::Requests::DisconnectRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::disconnectRequestFinished)))); } bool CommandParser::parse(const std::string &cmd) { diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp index 616e09b..cafe2fa 100644 --- a/src/Client/InformationManager.cpp +++ b/src/Client/InformationManager.cpp @@ -72,7 +72,7 @@ void InformationManager::updateDaemonList(Net::Connection *con) { return; Common::RequestManager::get()->sendRequest(con, - std::auto_ptr( + std::auto_ptr( new Requests::DaemonListRequest(sigc::mem_fun(this, &InformationManager::daemonListRequestFinished)) ) ); @@ -80,7 +80,7 @@ void InformationManager::updateDaemonList(Net::Connection *con) { updating = true; } -void InformationManager::daemonListRequestFinished(const Common::XmlRequest &request) { +void InformationManager::daemonListRequestFinished(const Common::Request &request) { try { const Common::XmlPacket &packet = request.getResult(); diff --git a/src/Client/InformationManager.h b/src/Client/InformationManager.h index 890622c..566eaf6 100644 --- a/src/Client/InformationManager.h +++ b/src/Client/InformationManager.h @@ -25,7 +25,7 @@ #include #include -#include +#include namespace Mad { @@ -42,7 +42,7 @@ namespace Client { class InformationManager : public Common::Initializable { private: - class DaemonStateUpdateRequestHandler : public Common::XmlRequestHandler { + class DaemonStateUpdateRequestHandler : public Common::RequestHandler { protected: virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet); @@ -62,7 +62,7 @@ class InformationManager : public Common::Initializable { InformationManager() : updating(false) {} - void daemonListRequestFinished(const Common::XmlRequest &request); + void daemonListRequestFinished(const Common::Request &request); protected: virtual void doInit(); diff --git a/src/Client/Requests/DaemonCommandRequest.h b/src/Client/Requests/DaemonCommandRequest.h index 8575123..13a6da6 100644 --- a/src/Client/Requests/DaemonCommandRequest.h +++ b/src/Client/Requests/DaemonCommandRequest.h @@ -20,14 +20,14 @@ #ifndef MAD_CLIENT_REQUEST_DAEMONCOMMANDREQUEST_H_ #define MAD_CLIENT_REQUEST_DAEMONCOMMANDREQUEST_H_ -#include +#include #include namespace Mad { namespace Client { namespace Requests { -class DaemonCommandRequest : public Common::XmlRequest { +class DaemonCommandRequest : public Common::Request { private: std::string daemon; bool reboot; @@ -37,7 +37,7 @@ class DaemonCommandRequest : public Common::XmlRequest { virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - DaemonCommandRequest(const std::string &daemon0, bool reboot0, slot_type slot) : Common::XmlRequest(slot), daemon(daemon0), reboot(reboot0) {} + DaemonCommandRequest(const std::string &daemon0, bool reboot0, slot_type slot) : Common::Request(slot), daemon(daemon0), reboot(reboot0) {} }; } diff --git a/src/Client/Requests/DaemonFSInfoRequest.h b/src/Client/Requests/DaemonFSInfoRequest.h index 48a201f..a42d85a 100644 --- a/src/Client/Requests/DaemonFSInfoRequest.h +++ b/src/Client/Requests/DaemonFSInfoRequest.h @@ -20,7 +20,7 @@ #ifndef MAD_CLIENT_REQUESTS_DAEMONFSINFOREQUEST_H_ #define MAD_CLIENT_REQUESTS_DAEMONFSINFOREQUEST_H_ -#include +#include #include @@ -28,7 +28,7 @@ namespace Mad { namespace Client { namespace Requests { -class DaemonFSInfoRequest : public Common::XmlRequest { +class DaemonFSInfoRequest : public Common::Request { private: std::string daemon; @@ -37,7 +37,7 @@ class DaemonFSInfoRequest : public Common::XmlRequest { virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - DaemonFSInfoRequest(const std::string &daemon0, slot_type slot) : Common::XmlRequest(slot), daemon(daemon0) {} + DaemonFSInfoRequest(const std::string &daemon0, slot_type slot) : Common::Request(slot), daemon(daemon0) {} }; } diff --git a/src/Client/Requests/DaemonListRequest.h b/src/Client/Requests/DaemonListRequest.h index ca37dbd..3b561d2 100644 --- a/src/Client/Requests/DaemonListRequest.h +++ b/src/Client/Requests/DaemonListRequest.h @@ -20,19 +20,19 @@ #ifndef MAD_CLIENT_REQUEST_DAEMONLISTREQUEST_H_ #define MAD_CLIENT_REQUEST_DAEMONLISTREQUEST_H_ -#include +#include namespace Mad { namespace Client { namespace Requests { -class DaemonListRequest : public Common::XmlRequest { +class DaemonListRequest : public Common::Request { protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - DaemonListRequest(slot_type slot) : Common::XmlRequest(slot) {} + DaemonListRequest(slot_type slot) : Common::Request(slot) {} }; } diff --git a/src/Client/Requests/DaemonStatusRequest.h b/src/Client/Requests/DaemonStatusRequest.h index b0982e6..2ccc9b2 100644 --- a/src/Client/Requests/DaemonStatusRequest.h +++ b/src/Client/Requests/DaemonStatusRequest.h @@ -20,7 +20,7 @@ #ifndef MAD_CLIENT_REQUESTS_DAEMONSTATUSREQUEST_H_ #define MAD_CLIENT_REQUESTS_DAEMONSTATUSREQUEST_H_ -#include +#include #include @@ -28,7 +28,7 @@ namespace Mad { namespace Client { namespace Requests { -class DaemonStatusRequest : public Common::XmlRequest { +class DaemonStatusRequest : public Common::Request { private: std::string daemon; @@ -37,7 +37,7 @@ class DaemonStatusRequest : public Common::XmlRequest { virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - DaemonStatusRequest(const std::string &daemon0, slot_type slot) : Common::XmlRequest(slot), daemon(daemon0) {} + DaemonStatusRequest(const std::string &daemon0, slot_type slot) : Common::Request(slot), daemon(daemon0) {} }; } diff --git a/src/Common/Makefile.am b/src/Common/Makefile.am index 79bc0b1..e1c22b9 100644 --- a/src/Common/Makefile.am +++ b/src/Common/Makefile.am @@ -8,5 +8,5 @@ libcommon_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandler noinst_HEADERS = ActionManager.h ConfigEntry.h ConfigManager.h Configurable.h Exception.h HostInfo.h \ Initializable.h Logger.h LoggerBase.h LogManager.h ModuleManager.h \ - RemoteLogger.h RequestManager.h \ - SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h XmlRequest.h XmlRequestHandler.h + RemoteLogger.h Request.h RequestHandler.h RequestManager.h \ + SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in index 1f7bca5..d70edc7 100644 --- a/src/Common/Makefile.in +++ b/src/Common/Makefile.in @@ -245,8 +245,8 @@ libcommon_la_SOURCES = ActionManager.cpp ConfigEntry.cpp ConfigManager.cpp Excep libcommon_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandlers.la ../../lib/libgnu.la noinst_HEADERS = ActionManager.h ConfigEntry.h ConfigManager.h Configurable.h Exception.h HostInfo.h \ Initializable.h Logger.h LoggerBase.h LogManager.h ModuleManager.h \ - RemoteLogger.h RequestManager.h \ - SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h XmlRequest.h XmlRequestHandler.h + RemoteLogger.h Request.h RequestHandler.h RequestManager.h \ + SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h all: all-recursive diff --git a/src/Common/Request.h b/src/Common/Request.h new file mode 100644 index 0000000..b0e6777 --- /dev/null +++ b/src/Common/Request.h @@ -0,0 +1,69 @@ +/* + * Request.h + * + * Copyright (C) 2008 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef MAD_COMMON_XMLREQUEST_H_ +#define MAD_COMMON_XMLREQUEST_H_ + +#include "XmlPacket.h" +#include "RequestHandler.h" +#include "Exception.h" + +#include +#include + +namespace Mad { +namespace Common { + +class Request : public RequestHandler { + private: + friend class RequestManager; + + sigc::signal finished; + + std::auto_ptr res; + Exception exp; + + public: + typedef sigc::slot slot_type; + + protected: + Request(slot_type slot) : exp(Exception::NOT_FINISHED) { + finished.connect(slot); + finished.connect(sigc::hide(signalFinished().make_slot())); + } + + void finish(std::auto_ptr result) {res = result; finished(*this);} + void finish(const XmlPacket& result) {res.reset(new XmlPacket(result)); finished(*this);} + void finishWithError(const Exception &e) {exp = e; finished(*this);} + + virtual void sendRequest(Net::Connection *connection, uint16_t requestId) = 0; + + public: + const XmlPacket& getResult() const throw(Exception) { + if(res.get()) + return *res; + + throw exp; + } +}; + +} +} + +#endif /* MAD_COMMON_XMLREQUEST_H_ */ diff --git a/src/Common/RequestHandler.h b/src/Common/RequestHandler.h new file mode 100644 index 0000000..b909e81 --- /dev/null +++ b/src/Common/RequestHandler.h @@ -0,0 +1,61 @@ +/* + * RequestHandler.h + * + * Copyright (C) 2008 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef MAD_COMMON_XMLREQUESTHANDLER_H_ +#define MAD_COMMON_XMLREQUESTHANDLER_H_ + +#include +#include + +namespace Mad { + +namespace Net { +class Connection; +} + +namespace Common { + +class RequestManager; +class XmlPacket; + +class RequestHandler { + private: + sigc::signal finished; + + // Prevent shallow copy + RequestHandler(const RequestHandler &o); + RequestHandler& operator=(const RequestHandler &o); + + protected: + RequestHandler() {} + + sigc::signal signalFinished() {return finished;} + + virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const XmlPacket &packet) = 0; + + public: + virtual ~RequestHandler() {} + + friend class RequestManager; +}; + +} +} + +#endif /* MAD_COMMON_XMLREQUESTHANDLER_H_ */ diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.h b/src/Common/RequestHandlers/DisconnectRequestHandler.h index 23d07dc..7544fd8 100644 --- a/src/Common/RequestHandlers/DisconnectRequestHandler.h +++ b/src/Common/RequestHandlers/DisconnectRequestHandler.h @@ -20,13 +20,13 @@ #ifndef MAD_COMMON_REQUESTHANDLERS_DISCONNECTREQUESTHANDLER_H_ #define MAD_COMMON_REQUESTHANDLERS_DISCONNECTREQUESTHANDLER_H_ -#include "../XmlRequestHandler.h" +#include "../RequestHandler.h" namespace Mad { namespace Common { namespace RequestHandlers { -class DisconnectRequestHandler : public XmlRequestHandler { +class DisconnectRequestHandler : public RequestHandler { protected: virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const XmlPacket &packet); diff --git a/src/Common/RequestHandlers/FSInfoRequestHandler.h b/src/Common/RequestHandlers/FSInfoRequestHandler.h index 32e7a08..a9ee120 100644 --- a/src/Common/RequestHandlers/FSInfoRequestHandler.h +++ b/src/Common/RequestHandlers/FSInfoRequestHandler.h @@ -20,7 +20,7 @@ #ifndef MAD_COMMON_REQUESTHANDLERS_FSINFOREQUESTHANDLER_H_ #define MAD_COMMON_REQUESTHANDLERS_FSINFOREQUESTHANDLER_H_ -#include "../XmlRequestHandler.h" +#include "../RequestHandler.h" #include "../SystemBackend.h" #include @@ -29,7 +29,7 @@ namespace Mad { namespace Common { namespace RequestHandlers { -class FSInfoRequestHandler : public XmlRequestHandler { +class FSInfoRequestHandler : public RequestHandler { private: Net::Connection *connection; uint16_t requestId; diff --git a/src/Common/RequestHandlers/StatusRequestHandler.h b/src/Common/RequestHandlers/StatusRequestHandler.h index 0b53db0..ce7ae6d 100644 --- a/src/Common/RequestHandlers/StatusRequestHandler.h +++ b/src/Common/RequestHandlers/StatusRequestHandler.h @@ -20,14 +20,14 @@ #ifndef MAD_COMMON_REQUESTHANDLERS_STATUSREQUESTHANDLER_H_ #define MAD_COMMON_REQUESTHANDLERS_STATUSREQUESTHANDLER_H_ -#include "../XmlRequestHandler.h" +#include "../RequestHandler.h" #include namespace Mad { namespace Common { namespace RequestHandlers { -class StatusRequestHandler : public XmlRequestHandler { +class StatusRequestHandler : public RequestHandler { private: Net::Connection *connection; uint16_t rid; diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp index de4f2ca..ac1909b 100644 --- a/src/Common/RequestManager.cpp +++ b/src/Common/RequestManager.cpp @@ -18,7 +18,7 @@ */ #include "RequestManager.h" -#include "XmlRequest.h" +#include "Request.h" #include "XmlPacket.h" #include "RequestHandlers/DisconnectRequestHandler.h" #include "Logger.h" @@ -32,21 +32,21 @@ namespace Common { RequestManager RequestManager::requestManager; -RequestManager::XmlRequestMap::~XmlRequestMap() { +RequestManager::RequestMap::~RequestMap() { for(iterator it = begin(); it != end(); ++it) delete it->second; } -bool RequestManager::XmlRequestMap::addRequest(uint16_t id, XmlRequestHandler *info) { +bool RequestManager::RequestMap::addRequest(uint16_t id, RequestHandler *info) { if(!insert(std::make_pair(id, info)).second) return false; - info->signalFinished().connect(sigc::hide_return(sigc::bind(sigc::mem_fun(this, &RequestManager::XmlRequestMap::deleteRequest), id))); + info->signalFinished().connect(sigc::hide_return(sigc::bind(sigc::mem_fun(this, &RequestManager::RequestMap::deleteRequest), id))); return true; } -XmlRequestHandler* RequestManager::XmlRequestMap::findRequest(uint16_t id) { +RequestHandler* RequestManager::RequestMap::findRequest(uint16_t id) { iterator it = find(id); if(it == end()) return 0; @@ -54,7 +54,7 @@ XmlRequestHandler* RequestManager::XmlRequestMap::findRequest(uint16_t id) { return it->second; } -bool RequestManager::XmlRequestMap::deleteRequest(uint16_t id) { +bool RequestManager::RequestMap::deleteRequest(uint16_t id) { iterator it = find(id); if(it == end()) return false; @@ -69,27 +69,27 @@ bool RequestManager::XmlRequestMap::deleteRequest(uint16_t id) { void RequestManager::receiveHandler(Net::Connection *connection, const Net::Packet &packet) { XmlPacket xmlPacket(packet); - std::map::iterator it = xmlRequestMaps.find(connection); - if(it == xmlRequestMaps.end()) { + std::map::iterator it = requestMaps.find(connection); + if(it == requestMaps.end()) { // TODO: Error Logger::log(Logger::ERROR, "Received a packet from an unregistered connection."); return; } - XmlRequestMap *xmlRequestMap = it->second; - XmlRequestHandler *xmlRequest = xmlRequestMap->findRequest(packet.getRequestId()); + RequestMap *requestMap = it->second; + RequestHandler *request = requestMap->findRequest(packet.getRequestId()); - if(xmlRequest) { - xmlRequest->handlePacket(connection, packet.getRequestId(), xmlPacket); + if(request) { + request->handlePacket(connection, packet.getRequestId(), xmlPacket); return; } - std::map::iterator factoryIt = xmlRequestHandlerFactories.find(xmlPacket.getType()); - if(factoryIt != xmlRequestHandlerFactories.end()) { - xmlRequest = factoryIt->second->createRequestHandler(); - xmlRequestMap->addRequest(packet.getRequestId(), xmlRequest); - xmlRequest->handlePacket(connection, packet.getRequestId(), xmlPacket); + std::map::iterator factoryIt = requestHandlerFactories.find(xmlPacket.getType()); + if(factoryIt != requestHandlerFactories.end()) { + request = factoryIt->second->createRequestHandler(); + requestMap->addRequest(packet.getRequestId(), request); + request->handlePacket(connection, packet.getRequestId(), xmlPacket); return; } @@ -103,15 +103,15 @@ void RequestManager::receiveHandler(Net::Connection *connection, const Net::Pack connection->send(ret.encode(requestId)); } -bool RequestManager::sendRequest(Net::Connection *connection, std::auto_ptr request) { - std::map::iterator it = xmlRequestMaps.find(connection); +bool RequestManager::sendRequest(Net::Connection *connection, std::auto_ptr request) { + std::map::iterator it = requestMaps.find(connection); - if(it == xmlRequestMaps.end()) { + if(it == requestMaps.end()) { Logger::log(Logger::CRITICAL, "Trying to send a request over an unregistered connecion."); return false; } - XmlRequestMap *requestMap = it->second; + RequestMap *requestMap = it->second; uint16_t id; do { @@ -126,29 +126,29 @@ bool RequestManager::sendRequest(Net::Connection *connection, std::auto_ptrsignalReceive().connect(sigc::mem_fun(this, &RequestManager::receiveHandler)); } void RequestManager::unregisterConnection(Net::Connection *connection) { - std::map::iterator it = xmlRequestMaps.find(connection); + std::map::iterator it = requestMaps.find(connection); - if(it != xmlRequestMaps.end()) { + if(it != requestMaps.end()) { delete it->second; - xmlRequestMaps.erase(it); + requestMaps.erase(it); } } void RequestManager::unregisterPacketType(const std::string &type) { - std::map::iterator it = xmlRequestHandlerFactories.find(type); + std::map::iterator it = requestHandlerFactories.find(type); - if(it == xmlRequestHandlerFactories.end()) + if(it == requestHandlerFactories.end()) return; delete it->second; - xmlRequestHandlerFactories.erase(it); + requestHandlerFactories.erase(it); } RequestManager::RequestManager() : core(false), requestId(-1) { @@ -158,10 +158,10 @@ RequestManager::RequestManager() : core(false), requestId(-1) { RequestManager::~RequestManager() { unregisterPacketType("Disconnect"); - for(std::map::iterator it = xmlRequestMaps.begin(); it != xmlRequestMaps.end(); ++it) + for(std::map::iterator it = requestMaps.begin(); it != requestMaps.end(); ++it) delete it->second; - for(std::map::iterator it = xmlRequestHandlerFactories.begin(); it != xmlRequestHandlerFactories.end(); ++it) + for(std::map::iterator it = requestHandlerFactories.begin(); it != requestHandlerFactories.end(); ++it) delete it->second; } diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h index 8a3d151..ee4f4d1 100644 --- a/src/Common/RequestManager.h +++ b/src/Common/RequestManager.h @@ -28,49 +28,49 @@ namespace Mad { namespace Common { -class XmlRequest; -class XmlRequestHandler; +class Request; +class RequestHandler; class RequestManager { private: - class XmlRequestMap : private std::map { + class RequestMap : private std::map { private: // Prevent shallow copy - XmlRequestMap(const XmlRequestMap &o); - XmlRequestMap& operator=(const XmlRequestMap &o); + RequestMap(const RequestMap &o); + RequestMap& operator=(const RequestMap &o); public: - XmlRequestMap() {} - ~XmlRequestMap(); + RequestMap() {} + ~RequestMap(); - bool addRequest(uint16_t id, XmlRequestHandler *info); - XmlRequestHandler* findRequest(uint16_t id); + bool addRequest(uint16_t id, RequestHandler *info); + RequestHandler* findRequest(uint16_t id); bool deleteRequest(uint16_t id); }; - class XmlRequestHandlerFactory { + class RequestHandlerFactory { protected: - XmlRequestHandlerFactory() {} + RequestHandlerFactory() {} public: - virtual XmlRequestHandler* createRequestHandler() = 0; - virtual ~XmlRequestHandlerFactory() {} + virtual RequestHandler* createRequestHandler() = 0; + virtual ~RequestHandlerFactory() {} }; - template class SpecificXmlRequestHandlerFactory : public XmlRequestHandlerFactory { + template class SpecificRequestHandlerFactory : public RequestHandlerFactory { public: - virtual XmlRequestHandler* createRequestHandler() { + virtual RequestHandler* createRequestHandler() { return new T(); } }; static RequestManager requestManager; - std::map xmlRequestMaps; + std::map requestMaps; bool core; uint16_t requestId; - std::map xmlRequestHandlerFactories; + std::map requestHandlerFactories; uint16_t getRequestId() { return requestId+=2; @@ -103,12 +103,12 @@ class RequestManager { void unregisterConnection(Net::Connection *connection); template void registerPacketType(const std::string &type) { - xmlRequestHandlerFactories.insert(std::make_pair(type, new SpecificXmlRequestHandlerFactory())); + requestHandlerFactories.insert(std::make_pair(type, new SpecificRequestHandlerFactory())); } void unregisterPacketType(const std::string &type); - bool sendRequest(Net::Connection *connection, std::auto_ptr request); + bool sendRequest(Net::Connection *connection, std::auto_ptr request); virtual ~RequestManager(); }; diff --git a/src/Common/Requests/DisconnectRequest.h b/src/Common/Requests/DisconnectRequest.h index 4f2cdf5..af7cca5 100644 --- a/src/Common/Requests/DisconnectRequest.h +++ b/src/Common/Requests/DisconnectRequest.h @@ -20,19 +20,19 @@ #ifndef MAD_COMMON_REQUESTS_DISCONNECTREQUEST_H_ #define MAD_COMMON_REQUESTS_DISCONNECTREQUEST_H_ -#include "../XmlRequest.h" +#include "../Request.h" namespace Mad { namespace Common { namespace Requests { -class DisconnectRequest : public XmlRequest { +class DisconnectRequest : public Request { protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); virtual void handlePacket(Net::Connection *connection, uint16_t, const XmlPacket &packet); public: - DisconnectRequest(slot_type slot) : XmlRequest(slot) {} + DisconnectRequest(slot_type slot) : Request(slot) {} }; } diff --git a/src/Common/Requests/FSInfoRequest.h b/src/Common/Requests/FSInfoRequest.h index 9a6ba14..39759ab 100644 --- a/src/Common/Requests/FSInfoRequest.h +++ b/src/Common/Requests/FSInfoRequest.h @@ -20,19 +20,19 @@ #ifndef MAD_COMMON_REQUESTS_FSINFOREQUEST_H_ #define MAD_COMMON_REQUESTS_FSINFOREQUEST_H_ -#include "../XmlRequest.h" +#include "../Request.h" namespace Mad { namespace Common { namespace Requests { -class FSInfoRequest : public XmlRequest { +class FSInfoRequest : public Request { protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - FSInfoRequest(slot_type slot) : XmlRequest(slot) {} + FSInfoRequest(slot_type slot) : Request(slot) {} }; } diff --git a/src/Common/Requests/GSSAPIAuthRequest.h b/src/Common/Requests/GSSAPIAuthRequest.h index d9f5c9c..ca6195b 100644 --- a/src/Common/Requests/GSSAPIAuthRequest.h +++ b/src/Common/Requests/GSSAPIAuthRequest.h @@ -20,7 +20,7 @@ #ifndef MAD_COMMON_REQUESTS_GSSAPIAUTHREQUEST_H_ #define MAD_COMMON_REQUESTS_GSSAPIAUTHREQUEST_H_ -#include "../XmlRequest.h" +#include "../Request.h" #include #include @@ -30,7 +30,7 @@ namespace Requests { // TODO Logging & error handling! -class GSSAPIAuthRequest : public XmlRequest { +class GSSAPIAuthRequest : public Request { private: std::string serviceName; gss_name_t gssServiceName; @@ -43,7 +43,7 @@ class GSSAPIAuthRequest : public XmlRequest { public: GSSAPIAuthRequest(const std::string &serviceName0, slot_type slot) - : XmlRequest(slot), serviceName(serviceName0), gssServiceName(GSS_C_NO_NAME), gssContext(GSS_C_NO_CONTEXT), gssContinue(true) {} + : Request(slot), serviceName(serviceName0), gssServiceName(GSS_C_NO_NAME), gssContext(GSS_C_NO_CONTEXT), gssContinue(true) {} virtual ~GSSAPIAuthRequest(); }; diff --git a/src/Common/Requests/StatusRequest.h b/src/Common/Requests/StatusRequest.h index e9c8a4c..eb24305 100644 --- a/src/Common/Requests/StatusRequest.h +++ b/src/Common/Requests/StatusRequest.h @@ -20,19 +20,19 @@ #ifndef MAD_COMMON_REQUESTS_STATUSREQUEST_H_ #define MAD_COMMON_REQUESTS_STATUSREQUEST_H_ -#include "../XmlRequest.h" +#include "../Request.h" namespace Mad { namespace Common { namespace Requests { -class StatusRequest : public XmlRequest { +class StatusRequest : public Request { protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); virtual void handlePacket(Net::Connection *connection, uint16_t, const XmlPacket &packet); public: - StatusRequest(slot_type slot) : XmlRequest(slot) {} + StatusRequest(slot_type slot) : Request(slot) {} }; } diff --git a/src/Common/Requests/UserListRequest.h b/src/Common/Requests/UserListRequest.h index 9702a42..bcd9578 100644 --- a/src/Common/Requests/UserListRequest.h +++ b/src/Common/Requests/UserListRequest.h @@ -20,19 +20,19 @@ #ifndef MAD_COMMON_REQUESTS_USERLISTREQUEST_H_ #define MAD_COMMON_REQUESTS_USERLISTREQUEST_H_ -#include "../XmlRequest.h" +#include "../Request.h" namespace Mad { namespace Common { namespace Requests { -class UserListRequest : public XmlRequest { +class UserListRequest : public Request { protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); virtual void handlePacket(Net::Connection *connection, uint16_t, const XmlPacket &packet); public: - UserListRequest(slot_type slot) : XmlRequest(slot) {} + UserListRequest(slot_type slot) : Request(slot) {} }; } diff --git a/src/Common/XmlRequest.h b/src/Common/XmlRequest.h deleted file mode 100644 index 66635c2..0000000 --- a/src/Common/XmlRequest.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Request.h - * - * Copyright (C) 2008 Matthias Schiffer - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef MAD_COMMON_XMLREQUEST_H_ -#define MAD_COMMON_XMLREQUEST_H_ - -#include "XmlPacket.h" -#include "XmlRequestHandler.h" -#include "Exception.h" - -#include -#include - -namespace Mad { -namespace Common { - -class XmlRequest : public XmlRequestHandler { - private: - friend class RequestManager; - - sigc::signal finished; - - std::auto_ptr res; - Exception exp; - - public: - typedef sigc::slot slot_type; - - protected: - XmlRequest(slot_type slot) : exp(Exception::NOT_FINISHED) { - finished.connect(slot); - finished.connect(sigc::hide(signalFinished().make_slot())); - } - - void finish(std::auto_ptr result) {res = result; finished(*this);} - void finish(const XmlPacket& result) {res.reset(new XmlPacket(result)); finished(*this);} - void finishWithError(const Exception &e) {exp = e; finished(*this);} - - virtual void sendRequest(Net::Connection *connection, uint16_t requestId) = 0; - - public: - const XmlPacket& getResult() const throw(Exception) { - if(res.get()) - return *res; - - throw exp; - } -}; - -} -} - -#endif /* MAD_COMMON_XMLREQUEST_H_ */ diff --git a/src/Common/XmlRequestHandler.h b/src/Common/XmlRequestHandler.h deleted file mode 100644 index 30438b7..0000000 --- a/src/Common/XmlRequestHandler.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * RequestHandler.h - * - * Copyright (C) 2008 Matthias Schiffer - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef MAD_COMMON_XMLREQUESTHANDLER_H_ -#define MAD_COMMON_XMLREQUESTHANDLER_H_ - -#include -#include - -namespace Mad { - -namespace Net { -class Connection; -} - -namespace Common { - -class RequestManager; -class XmlPacket; - -class XmlRequestHandler { - private: - sigc::signal finished; - - // Prevent shallow copy - XmlRequestHandler(const XmlRequestHandler &o); - XmlRequestHandler& operator=(const XmlRequestHandler &o); - - protected: - XmlRequestHandler() {} - - sigc::signal signalFinished() {return finished;} - - virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const XmlPacket &packet) = 0; - - public: - virtual ~XmlRequestHandler() {} - - friend class RequestManager; -}; - -} -} - -#endif /* MAD_COMMON_XMLREQUESTHANDLER_H_ */ diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp index f70f640..a6d80d0 100644 --- a/src/Core/ConnectionManager.cpp +++ b/src/Core/ConnectionManager.cpp @@ -50,7 +50,7 @@ void ConnectionManager::updateState(const std::string &name, Common::HostInfo::S daemonInfo[name].setState(state); for(std::list::iterator con = clientConnections.begin(); con != clientConnections.end(); ++con) { - Common::RequestManager::get()->sendRequest(*con, std::auto_ptr( + Common::RequestManager::get()->sendRequest(*con, std::auto_ptr( new Requests::DaemonStateUpdateRequest(name, state) )); } diff --git a/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp b/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp index 97a1bdc..1bfe3e4 100644 --- a/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp +++ b/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp @@ -49,7 +49,7 @@ void DaemonCommandRequestHandler::handlePacket(Net::Connection *connection, uint try { Net::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(packet["daemon"]); - Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr( + Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr( new Requests::CommandRequest(command == "reboot", sigc::mem_fun(this, &DaemonCommandRequestHandler::requestFinished)) )); } @@ -65,7 +65,7 @@ void DaemonCommandRequestHandler::handlePacket(Net::Connection *connection, uint } } -void DaemonCommandRequestHandler::requestFinished(const Common::XmlRequest &request) { +void DaemonCommandRequestHandler::requestFinished(const Common::Request &request) { try { const Common::XmlPacket &packet = request.getResult(); diff --git a/src/Core/RequestHandlers/DaemonCommandRequestHandler.h b/src/Core/RequestHandlers/DaemonCommandRequestHandler.h index 9570528..4ab7a3f 100644 --- a/src/Core/RequestHandlers/DaemonCommandRequestHandler.h +++ b/src/Core/RequestHandlers/DaemonCommandRequestHandler.h @@ -20,20 +20,20 @@ #ifndef MAD_CORE_REQUESTHANDLERS_DAEMONCOMMANDREQUESTHANDLER_H_ #define MAD_CORE_REQUESTHANDLERS_DAEMONCOMMANDREQUESTHANDLER_H_ -#include -#include +#include +#include #include namespace Mad { namespace Core { namespace RequestHandlers { -class DaemonCommandRequestHandler : public Common::XmlRequestHandler { +class DaemonCommandRequestHandler : public Common::RequestHandler { private: Net::Connection *con; uint16_t requestId; - void requestFinished(const Common::XmlRequest &request); + void requestFinished(const Common::Request &request); protected: virtual void handlePacket(Net::Connection *connection, uint16_t rid, const Common::XmlPacket &packet); diff --git a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp index c0e4b9f..b9dc030 100644 --- a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp +++ b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp @@ -48,7 +48,7 @@ void DaemonFSInfoRequestHandler::handlePacket(Net::Connection *connection, uint1 try { Net::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(packet["daemon"]); - Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr(new Common::Requests::FSInfoRequest(sigc::mem_fun(this, &DaemonFSInfoRequestHandler::requestFinished)))); + Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr(new Common::Requests::FSInfoRequest(sigc::mem_fun(this, &DaemonFSInfoRequestHandler::requestFinished)))); } catch(Common::Exception &e) { Common::XmlPacket ret; @@ -62,7 +62,7 @@ void DaemonFSInfoRequestHandler::handlePacket(Net::Connection *connection, uint1 } } -void DaemonFSInfoRequestHandler::requestFinished(const Common::XmlRequest &request) { +void DaemonFSInfoRequestHandler::requestFinished(const Common::Request &request) { try { const Common::XmlPacket &packet = request.getResult(); con->send(packet.encode(requestId)); diff --git a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h index 68b8760..820ef69 100644 --- a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h +++ b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h @@ -20,8 +20,8 @@ #ifndef MAD_CORE_REQUESTHANDLERS_DAEMONFSINFOREQUESTHANDLER_H_ #define MAD_CORE_REQUESTHANDLERS_DAEMONFSINFOREQUESTHANDLER_H_ -#include -#include +#include +#include #include namespace Mad { @@ -35,12 +35,12 @@ class FSInfoPacket; namespace Core { namespace RequestHandlers { -class DaemonFSInfoRequestHandler : public Common::XmlRequestHandler { +class DaemonFSInfoRequestHandler : public Common::RequestHandler { private: Net::Connection *con; uint16_t requestId; - void requestFinished(const Common::XmlRequest &request); + void requestFinished(const Common::Request &request); protected: virtual void handlePacket(Net::Connection *connection, uint16_t rid, const Common::XmlPacket &packet); diff --git a/src/Core/RequestHandlers/DaemonListRequestHandler.h b/src/Core/RequestHandlers/DaemonListRequestHandler.h index 6fe2517..26c46f8 100644 --- a/src/Core/RequestHandlers/DaemonListRequestHandler.h +++ b/src/Core/RequestHandlers/DaemonListRequestHandler.h @@ -20,13 +20,13 @@ #ifndef MAD_CORE_REQUESTHANDLERS_DAEMONLISTREQUESTHANDLER_H_ #define MAD_CORE_REQUESTHANDLERS_DAEMONLISTREQUESTHANDLER_H_ -#include +#include namespace Mad { namespace Core { namespace RequestHandlers { -class DaemonListRequestHandler : public Common::XmlRequestHandler { +class DaemonListRequestHandler : public Common::RequestHandler { protected: virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet); diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp index 11c9eb9..35daae4 100644 --- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp +++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp @@ -50,7 +50,7 @@ void DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, uint1 try { Net::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(daemonName); - Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr(new Common::Requests::StatusRequest(sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished)))); + Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr(new Common::Requests::StatusRequest(sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished)))); } catch(Common::Exception &e) { Common::XmlPacket ret; @@ -64,7 +64,7 @@ void DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, uint1 } } -void DaemonStatusRequestHandler::requestFinished(const Common::XmlRequest &request) { +void DaemonStatusRequestHandler::requestFinished(const Common::Request &request) { try { const Common::XmlPacket &packet = request.getResult(); con->send(packet.encode(rid)); diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h index 30b2ae1..92dac2f 100644 --- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h +++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h @@ -20,8 +20,8 @@ #ifndef MAD_CORE_REQUESTHANDLERS_DAEMONSTATUSREQUESTHANDLER_H_ #define MAD_CORE_REQUESTHANDLERS_DAEMONSTATUSREQUESTHANDLER_H_ -#include -#include +#include +#include #include namespace Mad { @@ -35,12 +35,12 @@ class HostStatusPacket; namespace Core { namespace RequestHandlers { -class DaemonStatusRequestHandler : public Common::XmlRequestHandler { +class DaemonStatusRequestHandler : public Common::RequestHandler { private: Net::Connection *con; uint16_t rid; - void requestFinished(const Common::XmlRequest &request); + void requestFinished(const Common::Request &request); protected: virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet); diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h index 7f8ce3b..7f29804 100644 --- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h +++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h @@ -20,14 +20,14 @@ #ifndef MAD_CORE_REQUESTHANDLERS_GSSAPIAUTHREQUESTHANDLER_H_ #define MAD_CORE_REQUESTHANDLERS_GSSAPIAUTHREQUESTHANDLER_H_ -#include +#include #include namespace Mad { namespace Core { namespace RequestHandlers { -class GSSAPIAuthRequestHandler : public Common::XmlRequestHandler { +class GSSAPIAuthRequestHandler : public Common::RequestHandler { private: gss_ctx_id_t gssContext; diff --git a/src/Core/RequestHandlers/IdentifyRequestHandler.h b/src/Core/RequestHandlers/IdentifyRequestHandler.h index 877ebf2..7bc5d7c 100644 --- a/src/Core/RequestHandlers/IdentifyRequestHandler.h +++ b/src/Core/RequestHandlers/IdentifyRequestHandler.h @@ -20,13 +20,13 @@ #ifndef MAD_CORE_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_ #define MAD_CORE_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_ -#include +#include namespace Mad { namespace Core { namespace RequestHandlers { -class IdentifyRequestHandler : public Common::XmlRequestHandler { +class IdentifyRequestHandler : public Common::RequestHandler { protected: virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet); diff --git a/src/Core/RequestHandlers/LogRequestHandler.h b/src/Core/RequestHandlers/LogRequestHandler.h index 1c84248..4a0f9cb 100644 --- a/src/Core/RequestHandlers/LogRequestHandler.h +++ b/src/Core/RequestHandlers/LogRequestHandler.h @@ -20,13 +20,13 @@ #ifndef MAD_CORE_REQUESTHANDLERS_LOGREQUESTHANDLER_H_ #define MAD_CORE_REQUESTHANDLERS_LOGREQUESTHANDLER_H_ -#include +#include namespace Mad { namespace Core { namespace RequestHandlers { -class LogRequestHandler : public Common::XmlRequestHandler { +class LogRequestHandler : public Common::RequestHandler { protected: virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet); diff --git a/src/Core/RequestHandlers/UserListRequestHandler.h b/src/Core/RequestHandlers/UserListRequestHandler.h index 7739809..a9c8ac6 100644 --- a/src/Core/RequestHandlers/UserListRequestHandler.h +++ b/src/Core/RequestHandlers/UserListRequestHandler.h @@ -20,7 +20,7 @@ #ifndef MAD_CORE_REQUESTHANDLERS_USERLISTREQUESTHANDLER_H_ #define MAD_CORE_REQUESTHANDLERS_USERLISTREQUESTHANDLER_H_ -#include +#include #include #include @@ -30,7 +30,7 @@ namespace Mad { namespace Core { namespace RequestHandlers { -class UserListRequestHandler : public Common::XmlRequestHandler { +class UserListRequestHandler : public Common::RequestHandler { private: Net::Connection *connection; uint16_t rid; diff --git a/src/Core/Requests/CommandRequest.h b/src/Core/Requests/CommandRequest.h index 534fcef..9c6c70d 100644 --- a/src/Core/Requests/CommandRequest.h +++ b/src/Core/Requests/CommandRequest.h @@ -20,13 +20,13 @@ #ifndef MAD_CORE_REQUESTS_COMMANDREQUEST_H_ #define MAD_CORE_REQUESTS_COMMANDREQUEST_H_ -#include +#include namespace Mad { namespace Core { namespace Requests { -class CommandRequest : public Common::XmlRequest { +class CommandRequest : public Common::Request { private: bool reboot; @@ -35,7 +35,7 @@ class CommandRequest : public Common::XmlRequest { virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - CommandRequest(bool reboot0, slot_type slot) : Common::XmlRequest(slot), reboot(reboot0) {} + CommandRequest(bool reboot0, slot_type slot) : Common::Request(slot), reboot(reboot0) {} }; } diff --git a/src/Core/Requests/DaemonStateUpdateRequest.h b/src/Core/Requests/DaemonStateUpdateRequest.h index 84c23e8..f1466b2 100644 --- a/src/Core/Requests/DaemonStateUpdateRequest.h +++ b/src/Core/Requests/DaemonStateUpdateRequest.h @@ -20,14 +20,14 @@ #ifndef MAD_CORE_REQUESTS_DAEMONSTATEUPDATEREQUEST_H_ #define MAD_CORE_REQUESTS_DAEMONSTATEUPDATEREQUEST_H_ -#include +#include #include namespace Mad { namespace Core { namespace Requests { -class DaemonStateUpdateRequest : public Common::XmlRequest { +class DaemonStateUpdateRequest : public Common::Request { private: std::string name; Common::HostInfo::State state; @@ -37,7 +37,7 @@ class DaemonStateUpdateRequest : public Common::XmlRequest { virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - DaemonStateUpdateRequest(const std::string &name0, Common::HostInfo::State state0) : Common::XmlRequest(slot_type()), name(name0), state(state0) {} + DaemonStateUpdateRequest(const std::string &name0, Common::HostInfo::State state0) : Common::Request(slot_type()), name(name0), state(state0) {} }; } diff --git a/src/Daemon/Backends/NetworkLogger.h b/src/Daemon/Backends/NetworkLogger.h index a07fd59..857d27c 100644 --- a/src/Daemon/Backends/NetworkLogger.h +++ b/src/Daemon/Backends/NetworkLogger.h @@ -37,7 +37,7 @@ class NetworkLogger : public Common::Logger { protected: virtual void logMessage(Common::Logger::MessageCategory category, Common::Logger::MessageLevel level, time_t messageTimestamp, const std::string &message) { Common::RequestManager::get()->sendRequest(connection, - std::auto_ptr(new Requests::LogRequest(category, level, messageTimestamp, message, Requests::LogRequest::slot_type())) + std::auto_ptr(new Requests::LogRequest(category, level, messageTimestamp, message, Requests::LogRequest::slot_type())) ); } diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.h b/src/Daemon/RequestHandlers/CommandRequestHandler.h index 86391f2..408dbcf 100644 --- a/src/Daemon/RequestHandlers/CommandRequestHandler.h +++ b/src/Daemon/RequestHandlers/CommandRequestHandler.h @@ -20,14 +20,14 @@ #ifndef MAD_DAEMON_REQUESTHANDLERS_COMMANDREQUESTHANDLER_H_ #define MAD_DAEMON_REQUESTHANDLERS_COMMANDREQUESTHANDLER_H_ -#include +#include #include namespace Mad { namespace Daemon { namespace RequestHandlers { -class CommandRequestHandler : public Common::XmlRequestHandler { +class CommandRequestHandler : public Common::RequestHandler { private: void sendReply(Net::Connection *connection, uint16_t requestId); diff --git a/src/Daemon/Requests/IdentifyRequest.h b/src/Daemon/Requests/IdentifyRequest.h index c3ab821..5009374 100644 --- a/src/Daemon/Requests/IdentifyRequest.h +++ b/src/Daemon/Requests/IdentifyRequest.h @@ -20,14 +20,14 @@ #ifndef MAD_DAEMON_REQUESTS_IDENTIFYREQUEST_H_ #define MAD_DAEMON_REQUESTS_IDENTIFYREQUEST_H_ -#include +#include #include namespace Mad { namespace Daemon { namespace Requests { -class IdentifyRequest : public Common::XmlRequest { +class IdentifyRequest : public Common::Request { private: std::string hostname; @@ -36,7 +36,7 @@ class IdentifyRequest : public Common::XmlRequest { virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - IdentifyRequest(const std::string &hostname0, slot_type slot) : Common::XmlRequest(slot), hostname(hostname0) {} + IdentifyRequest(const std::string &hostname0, slot_type slot) : Common::Request(slot), hostname(hostname0) {} }; } diff --git a/src/Daemon/Requests/LogRequest.h b/src/Daemon/Requests/LogRequest.h index 2a03ce3..1045a2f 100644 --- a/src/Daemon/Requests/LogRequest.h +++ b/src/Daemon/Requests/LogRequest.h @@ -20,7 +20,7 @@ #ifndef MAD_DAEMON_REQUESTS_LOGREQUEST_H_ #define MAD_DAEMON_REQUESTS_LOGREQUEST_H_ -#include +#include #include #include @@ -28,7 +28,7 @@ namespace Mad { namespace Daemon { namespace Requests { -class LogRequest : public Common::XmlRequest { +class LogRequest : public Common::Request { private: Common::Logger::MessageCategory category; Common::Logger::MessageLevel level; @@ -41,7 +41,7 @@ class LogRequest : public Common::XmlRequest { public: LogRequest(Common::Logger::MessageCategory category0, Common::Logger::MessageLevel level0, time_t messageTimestamp0, const std::string &message0, slot_type slot) - : Common::XmlRequest(slot), category(category0), level(level0), messageTimestamp(messageTimestamp0), message(message0) {} + : Common::Request(slot), category(category0), level(level0), messageTimestamp(messageTimestamp0), message(message0) {} }; } diff --git a/src/mad.cpp b/src/mad.cpp index bc218f6..3dfe379 100644 --- a/src/mad.cpp +++ b/src/mad.cpp @@ -36,7 +36,7 @@ using namespace Mad; -static void requestFinished(const Common::XmlRequest&) { +static void requestFinished(const Common::Request&) { Common::Logger::log("Identified."); } @@ -70,7 +70,7 @@ int main() { //char hostname[256]; //gethostname(hostname, sizeof(hostname)); //Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Daemon::Requests::IdentifyRequest(hostname, sigc::ptr_fun(requestFinished)))); - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Daemon::Requests::IdentifyRequest("test", sigc::ptr_fun(requestFinished)))); + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr(new Daemon::Requests::IdentifyRequest("test", sigc::ptr_fun(requestFinished)))); while(connection->isConnected()) Net::FdManager::get()->run(); -- cgit v1.2.3