diff options
Diffstat (limited to 'src/Common')
-rw-r--r-- | src/Common/Makefile.am | 4 | ||||
-rw-r--r-- | src/Common/Makefile.in | 4 | ||||
-rw-r--r-- | src/Common/Request.h (renamed from src/Common/XmlRequest.h) | 10 | ||||
-rw-r--r-- | src/Common/RequestHandler.h (renamed from src/Common/XmlRequestHandler.h) | 10 | ||||
-rw-r--r-- | src/Common/RequestHandlers/DisconnectRequestHandler.h | 4 | ||||
-rw-r--r-- | src/Common/RequestHandlers/FSInfoRequestHandler.h | 4 | ||||
-rw-r--r-- | src/Common/RequestHandlers/StatusRequestHandler.h | 4 | ||||
-rw-r--r-- | src/Common/RequestManager.cpp | 60 | ||||
-rw-r--r-- | src/Common/RequestManager.h | 38 | ||||
-rw-r--r-- | src/Common/Requests/DisconnectRequest.h | 6 | ||||
-rw-r--r-- | src/Common/Requests/FSInfoRequest.h | 6 | ||||
-rw-r--r-- | src/Common/Requests/GSSAPIAuthRequest.h | 6 | ||||
-rw-r--r-- | src/Common/Requests/StatusRequest.h | 6 | ||||
-rw-r--r-- | src/Common/Requests/UserListRequest.h | 6 |
14 files changed, 84 insertions, 84 deletions
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/XmlRequest.h b/src/Common/Request.h index 66635c2..b0e6777 100644 --- a/src/Common/XmlRequest.h +++ b/src/Common/Request.h @@ -21,7 +21,7 @@ #define MAD_COMMON_XMLREQUEST_H_ #include "XmlPacket.h" -#include "XmlRequestHandler.h" +#include "RequestHandler.h" #include "Exception.h" #include <memory> @@ -30,20 +30,20 @@ namespace Mad { namespace Common { -class XmlRequest : public XmlRequestHandler { +class Request : public RequestHandler { private: friend class RequestManager; - sigc::signal<void,const XmlRequest&> finished; + sigc::signal<void,const Request&> finished; std::auto_ptr<XmlPacket> res; Exception exp; public: - typedef sigc::slot<void,const XmlRequest&> slot_type; + typedef sigc::slot<void,const Request&> slot_type; protected: - XmlRequest(slot_type slot) : exp(Exception::NOT_FINISHED) { + Request(slot_type slot) : exp(Exception::NOT_FINISHED) { finished.connect(slot); finished.connect(sigc::hide(signalFinished().make_slot())); } diff --git a/src/Common/XmlRequestHandler.h b/src/Common/RequestHandler.h index 30438b7..b909e81 100644 --- a/src/Common/XmlRequestHandler.h +++ b/src/Common/RequestHandler.h @@ -34,23 +34,23 @@ namespace Common { class RequestManager; class XmlPacket; -class XmlRequestHandler { +class RequestHandler { private: sigc::signal<void> finished; // Prevent shallow copy - XmlRequestHandler(const XmlRequestHandler &o); - XmlRequestHandler& operator=(const XmlRequestHandler &o); + RequestHandler(const RequestHandler &o); + RequestHandler& operator=(const RequestHandler &o); protected: - XmlRequestHandler() {} + RequestHandler() {} sigc::signal<void> signalFinished() {return finished;} virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const XmlPacket &packet) = 0; public: - virtual ~XmlRequestHandler() {} + virtual ~RequestHandler() {} friend class RequestManager; }; 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 <stdint.h> @@ -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 <stdint.h> 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<Net::Connection*,XmlRequestMap*>::iterator it = xmlRequestMaps.find(connection); - if(it == xmlRequestMaps.end()) { + std::map<Net::Connection*,RequestMap*>::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<std::string,XmlRequestHandlerFactory*>::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<std::string,RequestHandlerFactory*>::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<XmlRequest> request) { - std::map<Net::Connection*,XmlRequestMap*>::iterator it = xmlRequestMaps.find(connection); +bool RequestManager::sendRequest(Net::Connection *connection, std::auto_ptr<Request> request) { + std::map<Net::Connection*,RequestMap*>::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_ptr<XmlR } void RequestManager::registerConnection(Net::Connection *connection) { - xmlRequestMaps.insert(std::make_pair(connection, new XmlRequestMap())); + requestMaps.insert(std::make_pair(connection, new RequestMap())); connection->signalReceive().connect(sigc::mem_fun(this, &RequestManager::receiveHandler)); } void RequestManager::unregisterConnection(Net::Connection *connection) { - std::map<Net::Connection*,XmlRequestMap*>::iterator it = xmlRequestMaps.find(connection); + std::map<Net::Connection*,RequestMap*>::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<std::string,XmlRequestHandlerFactory*>::iterator it = xmlRequestHandlerFactories.find(type); + std::map<std::string,RequestHandlerFactory*>::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<Net::Connection*,XmlRequestMap*>::iterator it = xmlRequestMaps.begin(); it != xmlRequestMaps.end(); ++it) + for(std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.begin(); it != requestMaps.end(); ++it) delete it->second; - for(std::map<std::string,XmlRequestHandlerFactory*>::iterator it = xmlRequestHandlerFactories.begin(); it != xmlRequestHandlerFactories.end(); ++it) + for(std::map<std::string,RequestHandlerFactory*>::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<uint16_t,XmlRequestHandler*> { + class RequestMap : private std::map<uint16_t,RequestHandler*> { 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 T> class SpecificXmlRequestHandlerFactory : public XmlRequestHandlerFactory { + template<class T> class SpecificRequestHandlerFactory : public RequestHandlerFactory { public: - virtual XmlRequestHandler* createRequestHandler() { + virtual RequestHandler* createRequestHandler() { return new T(); } }; static RequestManager requestManager; - std::map<Net::Connection*,XmlRequestMap*> xmlRequestMaps; + std::map<Net::Connection*,RequestMap*> requestMaps; bool core; uint16_t requestId; - std::map<std::string,XmlRequestHandlerFactory*> xmlRequestHandlerFactories; + std::map<std::string,RequestHandlerFactory*> requestHandlerFactories; uint16_t getRequestId() { return requestId+=2; @@ -103,12 +103,12 @@ class RequestManager { void unregisterConnection(Net::Connection *connection); template <class T> void registerPacketType(const std::string &type) { - xmlRequestHandlerFactories.insert(std::make_pair(type, new SpecificXmlRequestHandlerFactory<T>())); + requestHandlerFactories.insert(std::make_pair(type, new SpecificRequestHandlerFactory<T>())); } void unregisterPacketType(const std::string &type); - bool sendRequest(Net::Connection *connection, std::auto_ptr<XmlRequest> request); + bool sendRequest(Net::Connection *connection, std::auto_ptr<Request> 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 <string> #include <gssapi/gssapi.h> @@ -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) {} }; } |