diff options
Diffstat (limited to 'src/Common')
22 files changed, 290 insertions, 82 deletions
diff --git a/src/Common/ClientConnection.cpp b/src/Common/ClientConnection.cpp new file mode 100644 index 0000000..e030bfc --- /dev/null +++ b/src/Common/ClientConnection.cpp @@ -0,0 +1,66 @@ +/* + * SimpleConnection.cpp + * + * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "ClientConnection.h" +#include <Net/ClientConnection.h> + +namespace Mad { +namespace Common { + +ClientConnection::ClientConnection() : connection(new Net::ClientConnection) { + connection->signalReceive().connect(sigc::mem_fun(this, &ClientConnection::receive)); +} + +bool ClientConnection::send(const Net::Packet &packet) { + return connection->send(packet); +} + +void ClientConnection::connect(const Net::IPAddress &address, bool daemon) throw(Common::Exception) { + connection->connect(address, daemon); +} + +bool ClientConnection::isConnecting() const { + return connection->isConnecting(); +} + +bool ClientConnection::isConnected() const { + return connection->isConnected(); +} + +bool ClientConnection::disconnect() { + connection->disconnect(); + return true; +} + +void* ClientConnection::getCertificate(size_t *size) const { + const gnutls_datum_t *cert = connection->getCertificate(); + + *size = cert->size; + return cert->data; +} + +void* ClientConnection::getPeerCertificate(size_t *size) const { + const gnutls_datum_t *cert = connection->getPeerCertificate(); + + *size = cert->size; + return cert->data; +} + +} +} diff --git a/src/Common/ClientConnection.h b/src/Common/ClientConnection.h new file mode 100644 index 0000000..7e422b0 --- /dev/null +++ b/src/Common/ClientConnection.h @@ -0,0 +1,59 @@ +/* + * ClientConnection.h + * + * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef MAD_COMMON_CLIENTCONNECTION_H_ +#define MAD_COMMON_CLIENTCONNECTION_H_ + +#include "Connection.h" +#include "Exception.h" + +namespace Mad { + +namespace Net { +class ClientConnection; +class IPAddress; +} + +namespace Common { + +class ClientConnection : public Connection { + private: + Net::ClientConnection *connection; + + protected: + virtual bool send(const Net::Packet &packet); + + public: + ClientConnection(); + virtual ~ClientConnection() {} + + void connect(const Net::IPAddress &address, bool daemon = false) throw(Common::Exception); + + bool isConnecting() const; + bool isConnected() const; + + virtual bool disconnect(); + virtual void* getCertificate(size_t *size) const; + virtual void* getPeerCertificate(size_t *size) const; +}; + +} +} + +#endif /* MAD_COMMON_CLIENTCONNECTION_H_ */ diff --git a/src/Common/RequestHandler.cpp b/src/Common/Connection.cpp index 3e0eabc..b4e5db4 100644 --- a/src/Common/RequestHandler.cpp +++ b/src/Common/Connection.cpp @@ -1,5 +1,5 @@ /* - * RequestHandler.cpp + * Connection.cpp * * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> * @@ -17,14 +17,19 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "RequestHandler.h" -#include <Net/Connection.h> +#include "Connection.h" +#include "XmlPacket.h" + namespace Mad { namespace Common { -bool RequestHandler::sendPacket(const XmlPacket &packet) { - return connection->send(packet.encode(requestId)); +void Connection::receive(const Net::Packet &packet) { + signal(XmlPacket(packet), packet.getRequestId()); +} + +bool Connection::sendPacket(const XmlPacket &packet, uint16_t requestId) { + return send(packet.encode(requestId)); } } diff --git a/src/Common/Connection.h b/src/Common/Connection.h new file mode 100644 index 0000000..860c044 --- /dev/null +++ b/src/Common/Connection.h @@ -0,0 +1,82 @@ +/* + * Connection.h + * + * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef MAD_COMMON_CONNECTION_H_ +#define MAD_COMMON_CONNECTION_H_ + +#include <stdint.h> +#include <sys/types.h> + +#include <sigc++/signal.h> + +namespace Mad { + +namespace Net { +class Packet; +} + +namespace Common { + +class XmlPacket; + +class Connection { + private: + bool authenticated; + + sigc::signal<void, const XmlPacket&, uint16_t> signal; + + // Prevent shallow copy + Connection(const Connection &o); + Connection& operator=(const Connection &o); + + protected: + Connection() : authenticated(0) {} + + void receive(const Net::Packet &packet); + + virtual bool send(const Net::Packet &packet) = 0; + + public: + virtual ~Connection() {} + + bool sendPacket(const XmlPacket &packet, uint16_t requestId); + + sigc::signal<void, const XmlPacket&, uint16_t> signalReceive() const { + return signal; + } + + virtual bool disconnect() = 0; + virtual void* getCertificate(size_t *size) const = 0; + virtual void* getPeerCertificate(size_t *size) const = 0; + + virtual + + void setAuthenticated() { + authenticated = true; + } + + bool isAuthenticated() const { + return authenticated; + } +}; + +} +} + +#endif /* MAD_COMMON_CONNECTION_H_ */ diff --git a/src/Common/Makefile.am b/src/Common/Makefile.am index 9f31371..51593d7 100644 --- a/src/Common/Makefile.am +++ b/src/Common/Makefile.am @@ -1,12 +1,13 @@ SUBDIRS = Requests RequestHandlers noinst_LTLIBRARIES = libcommon.la -libcommon_la_SOURCES = ActionManager.cpp ConfigEntry.cpp ConfigManager.cpp Exception.cpp Initializable.cpp \ - Logger.cpp LogManager.cpp ModuleManager.cpp Request.cpp RequestHandler.cpp \ - RequestManager.cpp SystemBackend.cpp Tokenizer.cpp XmlPacket.cpp +libcommon_la_SOURCES = ActionManager.cpp ClientConnection.cpp ConfigEntry.cpp ConfigManager.cpp \ + Connection.cpp Exception.cpp Initializable.cpp Logger.cpp LogManager.cpp \ + ModuleManager.cpp Request.cpp RequestManager.cpp SystemBackend.cpp \ + Tokenizer.cpp XmlPacket.cpp 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 Request.h RequestHandler.h RequestManager.h \ - SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h +noinst_HEADERS = ActionManager.h ClientConnection.h ConfigEntry.h ConfigManager.h \ + Configurable.h Connection.h Exception.h HostInfo.h Initializable.h Logger.h \ + LoggerBase.h LogManager.h ModuleManager.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 6f2595f..45fc07f 100644 --- a/src/Common/Makefile.in +++ b/src/Common/Makefile.in @@ -53,10 +53,11 @@ CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libcommon_la_DEPENDENCIES = Requests/librequests.la \ RequestHandlers/librequesthandlers.la ../../lib/libgnu.la -am_libcommon_la_OBJECTS = ActionManager.lo ConfigEntry.lo \ - ConfigManager.lo Exception.lo Initializable.lo Logger.lo \ - LogManager.lo ModuleManager.lo Request.lo RequestHandler.lo \ - RequestManager.lo SystemBackend.lo Tokenizer.lo XmlPacket.lo +am_libcommon_la_OBJECTS = ActionManager.lo ClientConnection.lo \ + ConfigEntry.lo ConfigManager.lo Connection.lo Exception.lo \ + Initializable.lo Logger.lo LogManager.lo ModuleManager.lo \ + Request.lo RequestManager.lo SystemBackend.lo Tokenizer.lo \ + XmlPacket.lo libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp @@ -238,15 +239,16 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = Requests RequestHandlers noinst_LTLIBRARIES = libcommon.la -libcommon_la_SOURCES = ActionManager.cpp ConfigEntry.cpp ConfigManager.cpp Exception.cpp Initializable.cpp \ - Logger.cpp LogManager.cpp ModuleManager.cpp Request.cpp RequestHandler.cpp \ - RequestManager.cpp SystemBackend.cpp Tokenizer.cpp XmlPacket.cpp +libcommon_la_SOURCES = ActionManager.cpp ClientConnection.cpp ConfigEntry.cpp ConfigManager.cpp \ + Connection.cpp Exception.cpp Initializable.cpp Logger.cpp LogManager.cpp \ + ModuleManager.cpp Request.cpp RequestManager.cpp SystemBackend.cpp \ + Tokenizer.cpp XmlPacket.cpp 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 Request.h RequestHandler.h RequestManager.h \ - SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h +noinst_HEADERS = ActionManager.h ClientConnection.h ConfigEntry.h ConfigManager.h \ + Configurable.h Connection.h Exception.h HostInfo.h Initializable.h Logger.h \ + LoggerBase.h LogManager.h ModuleManager.h RemoteLogger.h Request.h \ + RequestHandler.h RequestManager.h SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h all: all-recursive @@ -300,15 +302,16 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ActionManager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClientConnection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfigEntry.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfigManager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Connection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exception.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Initializable.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogManager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Logger.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ModuleManager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestManager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemBackend.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Tokenizer.Plo@am__quote@ diff --git a/src/Common/Request.h b/src/Common/Request.h index 2c6c8d4..7048a4e 100644 --- a/src/Common/Request.h +++ b/src/Common/Request.h @@ -42,7 +42,7 @@ class Request : public RequestHandler { typedef sigc::slot<void,const Request&> slot_type; protected: - Request(Net::Connection *connection, uint16_t requestId, slot_type slot) + Request(Connection *connection, uint16_t requestId, slot_type slot) : RequestHandler(connection, requestId), exp(Exception::NOT_FINISHED) { finished.connect(slot); finished.connect(sigc::hide(signalFinished().make_slot())); diff --git a/src/Common/RequestHandler.h b/src/Common/RequestHandler.h index f36aae5..a0922a7 100644 --- a/src/Common/RequestHandler.h +++ b/src/Common/RequestHandler.h @@ -20,26 +20,23 @@ #ifndef MAD_COMMON_XMLREQUESTHANDLER_H_ #define MAD_COMMON_XMLREQUESTHANDLER_H_ +#include "Connection.h" #include "XmlPacket.h" #include <sigc++/signal.h> #include <stdint.h> namespace Mad { - -namespace Net { -class Connection; -} - namespace Common { +class Connection; class RequestManager; class RequestHandler { private: sigc::signal<void> finished; - Net::Connection *connection; + Connection *connection; uint16_t requestId; // Prevent shallow copy @@ -47,11 +44,11 @@ class RequestHandler { RequestHandler& operator=(const RequestHandler &o); protected: - RequestHandler(Net::Connection *connection0, uint16_t requestId0) : connection(connection0), requestId(requestId0) {} + RequestHandler(Connection *connection0, uint16_t requestId0) : connection(connection0), requestId(requestId0) {} sigc::signal<void> signalFinished() {return finished;} - Net::Connection* getConnection() const { + Connection* getConnection() const { return connection; } @@ -59,7 +56,9 @@ class RequestHandler { return requestId; } - bool sendPacket(const XmlPacket &packet); + bool sendPacket(const XmlPacket &packet) { + return connection->sendPacket(packet, requestId); + } virtual void handlePacket(const XmlPacket &packet) = 0; diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp index 031853a..9204f43 100644 --- a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp +++ b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp @@ -20,7 +20,6 @@ #include "DisconnectRequestHandler.h" #include "../Exception.h" #include "../Logger.h" -#include <Net/Connection.h> namespace Mad { namespace Common { diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.h b/src/Common/RequestHandlers/DisconnectRequestHandler.h index b90c96e..05b9c50 100644 --- a/src/Common/RequestHandlers/DisconnectRequestHandler.h +++ b/src/Common/RequestHandlers/DisconnectRequestHandler.h @@ -31,7 +31,7 @@ class DisconnectRequestHandler : public RequestHandler { virtual void handlePacket(const XmlPacket &packet); public: - DisconnectRequestHandler(Net::Connection *connection, uint16_t requestId) + DisconnectRequestHandler(Connection *connection, uint16_t requestId) : RequestHandler(connection, requestId) {} }; diff --git a/src/Common/RequestHandlers/FSInfoRequestHandler.h b/src/Common/RequestHandlers/FSInfoRequestHandler.h index 6fcf524..0eda797 100644 --- a/src/Common/RequestHandlers/FSInfoRequestHandler.h +++ b/src/Common/RequestHandlers/FSInfoRequestHandler.h @@ -37,7 +37,7 @@ class FSInfoRequestHandler : public RequestHandler { virtual void handlePacket(const XmlPacket &packet); public: - FSInfoRequestHandler(Net::Connection *connection, uint16_t requestId) + FSInfoRequestHandler(Connection *connection, uint16_t requestId) : RequestHandler(connection, requestId) {} }; diff --git a/src/Common/RequestHandlers/StatusRequestHandler.h b/src/Common/RequestHandlers/StatusRequestHandler.h index ddaaae4..8c7d124 100644 --- a/src/Common/RequestHandlers/StatusRequestHandler.h +++ b/src/Common/RequestHandlers/StatusRequestHandler.h @@ -60,7 +60,7 @@ class StatusRequestHandler : public RequestHandler { virtual void handlePacket(const XmlPacket &packet); public: - StatusRequestHandler(Net::Connection *connection, uint16_t requestId) + StatusRequestHandler(Connection *connection, uint16_t requestId) : RequestHandler(connection, requestId), needUptime(true), needMemory(true), needLoad(true), sent(false), uptime(0), idleTime(0), totalMem(0), freeMem(0), totalSwap(0), freeSwap(0), diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp index 9d50865..23f620f 100644 --- a/src/Common/RequestManager.cpp +++ b/src/Common/RequestManager.cpp @@ -21,8 +21,6 @@ #include "RequestHandlers/DisconnectRequestHandler.h" #include "Logger.h" -#include <Net/Connection.h> - #include <sigc++/bind.h> #include <sigc++/retype_return.h> @@ -66,10 +64,8 @@ bool RequestManager::RequestMap::deleteRequest(uint16_t id) { } -void RequestManager::receiveHandler(Net::Connection *connection, const Net::Packet &packet) { - XmlPacket xmlPacket(packet); - - std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection); +void RequestManager::receiveHandler(Connection *connection, const XmlPacket &packet, uint16_t requestId) { + std::map<Connection*,RequestMap*>::iterator it = requestMaps.find(connection); if(it == requestMaps.end()) { // TODO: Error Logger::log(Logger::ERROR, "Received a packet from an unregistered connection."); @@ -78,34 +74,34 @@ void RequestManager::receiveHandler(Net::Connection *connection, const Net::Pack } RequestMap *requestMap = it->second; - RequestHandler *request = requestMap->findRequest(packet.getRequestId()); + RequestHandler *request = requestMap->findRequest(requestId); if(request) { - request->handlePacket(xmlPacket); + request->handlePacket(packet); return; } - std::map<std::string,RequestHandlerFactory*>::iterator factoryIt = requestHandlerFactories.find(xmlPacket.getType()); + std::map<std::string,RequestHandlerFactory*>::iterator factoryIt = requestHandlerFactories.find(packet.getType()); if(factoryIt != requestHandlerFactories.end()) { - request = factoryIt->second->createRequestHandler(connection, packet.getRequestId()); + request = factoryIt->second->createRequestHandler(connection, requestId); - requestMap->addRequest(packet.getRequestId(), request); - request->handlePacket(xmlPacket); + requestMap->addRequest(requestId, request); + request->handlePacket(packet); return; } - Logger::logf(Logger::ERROR, "Received an unexpected packet with type '%s'.", xmlPacket.getType().c_str()); + Logger::logf(Logger::ERROR, "Received an unexpected packet with type '%s'.", packet.getType().c_str()); XmlPacket ret; ret.setType("Error"); ret.add("ErrorCode", Exception::UNEXPECTED_PACKET); - connection->send(ret.encode(packet.getRequestId())); + connection->sendPacket(ret, requestId); } -RequestManager::RequestMap* RequestManager::getUnusedRequestId(Net::Connection *connection, uint16_t *requestId) { - std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection); +RequestManager::RequestMap* RequestManager::getUnusedRequestId(Connection *connection, uint16_t *requestId) { + std::map<Connection*,RequestMap*>::iterator it = requestMaps.find(connection); if(it == requestMaps.end()) { Logger::log(Logger::CRITICAL, "Trying to send a request over an unregistered connecion."); @@ -121,14 +117,14 @@ RequestManager::RequestMap* RequestManager::getUnusedRequestId(Net::Connection * return requestMap; } -void RequestManager::registerConnection(Net::Connection *connection) { +void RequestManager::registerConnection(Connection *connection) { requestMaps.insert(std::make_pair(connection, new RequestMap())); - connection->signalReceive().connect(sigc::mem_fun(this, &RequestManager::receiveHandler)); + connection->signalReceive().connect(sigc::bind<0>(sigc::mem_fun(this, &RequestManager::receiveHandler), connection)); } -void RequestManager::unregisterConnection(Net::Connection *connection) { - std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection); +void RequestManager::unregisterConnection(Connection *connection) { + std::map<Connection*,RequestMap*>::iterator it = requestMaps.find(connection); if(it != requestMaps.end()) { delete it->second; @@ -154,7 +150,7 @@ RequestManager::RequestManager() : core(false), lastRequestId(-1) { RequestManager::~RequestManager() { unregisterPacketType("Disconnect"); - for(std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.begin(); it != requestMaps.end(); ++it) + for(std::map<Connection*,RequestMap*>::iterator it = requestMaps.begin(); it != requestMaps.end(); ++it) delete it->second; for(std::map<std::string,RequestHandlerFactory*>::iterator it = requestHandlerFactories.begin(); it != requestHandlerFactories.end(); ++it) diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h index c38435b..82a00f6 100644 --- a/src/Common/RequestManager.h +++ b/src/Common/RequestManager.h @@ -31,7 +31,6 @@ namespace Mad { namespace Net { -class Connection; class Packet; } @@ -59,20 +58,20 @@ class RequestManager { RequestHandlerFactory() {} public: - virtual RequestHandler* createRequestHandler(Net::Connection *connection, int16_t requestId) = 0; + virtual RequestHandler* createRequestHandler(Connection *connection, int16_t requestId) = 0; virtual ~RequestHandlerFactory() {} }; template<class T> class SpecificRequestHandlerFactory : public RequestHandlerFactory { public: - virtual RequestHandler* createRequestHandler(Net::Connection *connection, int16_t requestId) { + virtual RequestHandler* createRequestHandler(Connection *connection, int16_t requestId) { return new T(connection, requestId); } }; static RequestManager requestManager; - std::map<Net::Connection*,RequestMap*> requestMaps; + std::map<Connection*,RequestMap*> requestMaps; bool core; uint16_t lastRequestId; @@ -86,9 +85,9 @@ class RequestManager { RequestManager(const RequestManager &o); RequestManager& operator=(const RequestManager &o); - void receiveHandler(Net::Connection *connection, const Net::Packet &packet); + void receiveHandler(Connection *connection, const XmlPacket &packet, uint16_t requestId); - RequestMap* getUnusedRequestId(Net::Connection *connection, uint16_t *requestId); + RequestMap* getUnusedRequestId(Connection *connection, uint16_t *requestId); bool send(Request *request); @@ -109,8 +108,8 @@ class RequestManager { lastRequestId |= 0x01; } - void registerConnection(Net::Connection *connection); - void unregisterConnection(Net::Connection *connection); + void registerConnection(Connection *connection); + void unregisterConnection(Connection *connection); template <class T> void registerPacketType(const std::string &type) { requestHandlerFactories.insert(std::make_pair(type, new SpecificRequestHandlerFactory<T>())); @@ -119,7 +118,7 @@ class RequestManager { void unregisterPacketType(const std::string &type); template <class T> - bool sendRequest(Net::Connection *connection, Request::slot_type slot) { + bool sendRequest(Connection *connection, Request::slot_type slot) { RequestMap *requestMap; uint16_t requestId; @@ -136,7 +135,7 @@ class RequestManager { } template <class T, typename T1> - bool sendRequest(Net::Connection *connection, Request::slot_type slot, T1 t1) { + bool sendRequest(Connection *connection, Request::slot_type slot, T1 t1) { RequestMap *requestMap; uint16_t requestId; @@ -153,7 +152,7 @@ class RequestManager { } template <class T, typename T1, typename T2> - bool sendRequest(Net::Connection *connection, Request::slot_type slot, T1 t1, T2 t2) { + bool sendRequest(Connection *connection, Request::slot_type slot, T1 t1, T2 t2) { RequestMap *requestMap; uint16_t requestId; @@ -170,7 +169,7 @@ class RequestManager { } template <class T, typename T1, typename T2, typename T3> - bool sendRequest(Net::Connection *connection, Request::slot_type slot, T1 t1, T2 t2, T3 t3) { + bool sendRequest(Connection *connection, Request::slot_type slot, T1 t1, T2 t2, T3 t3) { RequestMap *requestMap; uint16_t requestId; @@ -187,7 +186,7 @@ class RequestManager { } template <class T, typename T1, typename T2, typename T3, typename T4> - bool sendRequest(Net::Connection *connection, Request::slot_type slot, T1 t1, T2 t2, T3 t3, T4 t4) { + bool sendRequest(Connection *connection, Request::slot_type slot, T1 t1, T2 t2, T3 t3, T4 t4) { RequestMap *requestMap; uint16_t requestId; diff --git a/src/Common/Requests/DisconnectRequest.cpp b/src/Common/Requests/DisconnectRequest.cpp index ec8719d..248f8b1 100644 --- a/src/Common/Requests/DisconnectRequest.cpp +++ b/src/Common/Requests/DisconnectRequest.cpp @@ -18,7 +18,6 @@ */ #include "DisconnectRequest.h" -#include <Net/Connection.h> namespace Mad { namespace Common { diff --git a/src/Common/Requests/DisconnectRequest.h b/src/Common/Requests/DisconnectRequest.h index 22ff16b..b4fd4db 100644 --- a/src/Common/Requests/DisconnectRequest.h +++ b/src/Common/Requests/DisconnectRequest.h @@ -32,7 +32,7 @@ class DisconnectRequest : public Request { virtual void handlePacket(const XmlPacket &packet); public: - DisconnectRequest(Net::Connection *connection, uint16_t requestId, slot_type slot) + DisconnectRequest(Connection *connection, uint16_t requestId, slot_type slot) : Request(connection, requestId, slot) {} }; diff --git a/src/Common/Requests/FSInfoRequest.h b/src/Common/Requests/FSInfoRequest.h index 285f662..1db7753 100644 --- a/src/Common/Requests/FSInfoRequest.h +++ b/src/Common/Requests/FSInfoRequest.h @@ -28,7 +28,7 @@ namespace Requests { class FSInfoRequest : public SimpleRequest { public: - FSInfoRequest(Net::Connection *connection, uint16_t requestId, slot_type slot) + FSInfoRequest(Connection *connection, uint16_t requestId, slot_type slot) : SimpleRequest(connection, requestId, slot, "FSInfo") {} }; diff --git a/src/Common/Requests/GSSAPIAuthRequest.cpp b/src/Common/Requests/GSSAPIAuthRequest.cpp index 07e516f..f10bf9b 100644 --- a/src/Common/Requests/GSSAPIAuthRequest.cpp +++ b/src/Common/Requests/GSSAPIAuthRequest.cpp @@ -19,7 +19,6 @@ #include "GSSAPIAuthRequest.h" #include "../Logger.h" -#include <Net/Connection.h> #include <cstring> @@ -127,10 +126,11 @@ void GSSAPIAuthRequest::handlePacket(const XmlPacket &packet) { recvBuffer.value = std::malloc(recvBuffer.length); std::memcpy(recvBuffer.value, pkgData, recvBuffer.length); - const gnutls_datum_t *cert = getConnection()->getPeerCertificate(); + /*const gnutls_datum_t *cert = getConnection()->getPeerCertificate(); sendBuffer.length = cert->size; - sendBuffer.value = cert->data; + sendBuffer.value = cert->data;*/ + sendBuffer.value = getConnection()->getPeerCertificate(&sendBuffer.length); majStat = gss_verify_mic(&minStat, gssContext, &sendBuffer, &recvBuffer, 0); diff --git a/src/Common/Requests/GSSAPIAuthRequest.h b/src/Common/Requests/GSSAPIAuthRequest.h index 104af0c..a4f8c43 100644 --- a/src/Common/Requests/GSSAPIAuthRequest.h +++ b/src/Common/Requests/GSSAPIAuthRequest.h @@ -42,7 +42,7 @@ class GSSAPIAuthRequest : public Request { virtual void handlePacket(const XmlPacket &packet); public: - GSSAPIAuthRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, const std::string &serviceName0) + GSSAPIAuthRequest(Connection *connection, uint16_t requestId, slot_type slot, const std::string &serviceName0) : Request(connection, requestId, slot), serviceName(serviceName0), gssServiceName(GSS_C_NO_NAME), gssContext(GSS_C_NO_CONTEXT), gssContinue(true) {} virtual ~GSSAPIAuthRequest(); }; diff --git a/src/Common/Requests/SimpleRequest.h b/src/Common/Requests/SimpleRequest.h index ca95eca..2c3070a 100644 --- a/src/Common/Requests/SimpleRequest.h +++ b/src/Common/Requests/SimpleRequest.h @@ -34,7 +34,7 @@ class SimpleRequest : public Request { virtual void sendRequest(); - SimpleRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, const std::string &type0) + SimpleRequest(Connection *connection, uint16_t requestId, slot_type slot, const std::string &type0) : Request(connection, requestId, slot), type(type0) {} }; diff --git a/src/Common/Requests/StatusRequest.h b/src/Common/Requests/StatusRequest.h index ad89ec4..0663fc4 100644 --- a/src/Common/Requests/StatusRequest.h +++ b/src/Common/Requests/StatusRequest.h @@ -28,7 +28,7 @@ namespace Requests { class StatusRequest : public SimpleRequest { public: - StatusRequest(Net::Connection *connection, uint16_t requestId, slot_type slot) + StatusRequest(Connection *connection, uint16_t requestId, slot_type slot) : SimpleRequest(connection, requestId, slot, "GetStatus") {} }; diff --git a/src/Common/Requests/UserListRequest.h b/src/Common/Requests/UserListRequest.h index 69b0f05..7ab3ec7 100644 --- a/src/Common/Requests/UserListRequest.h +++ b/src/Common/Requests/UserListRequest.h @@ -28,7 +28,7 @@ namespace Requests { class UserListRequest : public SimpleRequest { public: - UserListRequest(Net::Connection *connection, uint16_t requestId, slot_type slot) + UserListRequest(Connection *connection, uint16_t requestId, slot_type slot) : SimpleRequest(connection, requestId, slot, "ListUsers") {} }; |