diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-09-22 18:24:26 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-09-22 18:24:26 +0200 |
commit | 1af3eab2b23c67795b188e5edaf83bf47a8879bd (patch) | |
tree | 949611a5591a20533db9526a66272c7a693a15fd /src/Core/RequestHandlers | |
parent | fe6d06a7df225e79756229131f128981bbb83b40 (diff) | |
download | mad-1af3eab2b23c67795b188e5edaf83bf47a8879bd.tar mad-1af3eab2b23c67795b188e5edaf83bf47a8879bd.zip |
NetworkLogger implementiert
Diffstat (limited to 'src/Core/RequestHandlers')
-rw-r--r-- | src/Core/RequestHandlers/IdentifyRequestHandler.h | 6 | ||||
-rw-r--r-- | src/Core/RequestHandlers/LogRequestHandler.cpp | 51 | ||||
-rw-r--r-- | src/Core/RequestHandlers/LogRequestHandler.h | 41 | ||||
-rw-r--r-- | src/Core/RequestHandlers/Makefile.am | 4 | ||||
-rw-r--r-- | src/Core/RequestHandlers/Makefile.in | 7 |
5 files changed, 101 insertions, 8 deletions
diff --git a/src/Core/RequestHandlers/IdentifyRequestHandler.h b/src/Core/RequestHandlers/IdentifyRequestHandler.h index 58f10ba..f38fff6 100644 --- a/src/Core/RequestHandlers/IdentifyRequestHandler.h +++ b/src/Core/RequestHandlers/IdentifyRequestHandler.h @@ -17,8 +17,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_COMMON_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_ -#define MAD_COMMON_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_ +#ifndef MAD_CORE_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_ +#define MAD_CORE_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_ #include <Common/RequestHandler.h> @@ -38,4 +38,4 @@ class IdentifyRequestHandler : public Common::RequestHandler { } } -#endif /* MAD_COMMON_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_ */ +#endif /* MAD_CORE_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_ */ diff --git a/src/Core/RequestHandlers/LogRequestHandler.cpp b/src/Core/RequestHandlers/LogRequestHandler.cpp new file mode 100644 index 0000000..f2021b2 --- /dev/null +++ b/src/Core/RequestHandlers/LogRequestHandler.cpp @@ -0,0 +1,51 @@ +/* + * LogRequestHandler.cpp + * + * Copyright (C) 2008 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 "LogRequestHandler.h" +#include <Common/Logger.h> +#include <Net/Connection.h> +#include <Net/Packets/ErrorPacket.h> +#include <Net/Packets/LogPacket.h> + +namespace Mad { +namespace Core { +namespace RequestHandlers { + +void LogRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) { + if(packet.getType() != Net::Packet::LOG) { + Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); + connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET))); + + signalFinished().emit(); + return; + } + + // TODO Require authentication + + Net::Packets::LogPacket logPacket(packet); + Common::Logger::logf(logPacket.getCategory(), logPacket.getLevel(), "Remote log: %s", logPacket.getMessage().c_str()); + + connection->send(Net::Packet(Net::Packet::OK, packet.getRequestId())); + + signalFinished().emit(); +} + +} +} +} diff --git a/src/Core/RequestHandlers/LogRequestHandler.h b/src/Core/RequestHandlers/LogRequestHandler.h new file mode 100644 index 0000000..b82f24b --- /dev/null +++ b/src/Core/RequestHandlers/LogRequestHandler.h @@ -0,0 +1,41 @@ +/* + * LogRequestHandler.h + * + * Copyright (C) 2008 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_CORE_REQUESTHANDLERS_LOGREQUESTHANDLER_H_ +#define MAD_CORE_REQUESTHANDLERS_LOGREQUESTHANDLER_H_ + +#include <Common/RequestHandler.h> + +namespace Mad { +namespace Core { +namespace RequestHandlers { + +class LogRequestHandler : public Common::RequestHandler { + protected: + virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); + + public: + LogRequestHandler() {} +}; + +} +} +} + +#endif /* MAD_CORE_REQUESTHANDLERS_LOGREQUESTHANDLER_H_ */ diff --git a/src/Core/RequestHandlers/Makefile.am b/src/Core/RequestHandlers/Makefile.am index 2c65ceb..3c52634 100644 --- a/src/Core/RequestHandlers/Makefile.am +++ b/src/Core/RequestHandlers/Makefile.am @@ -1,4 +1,4 @@ noinst_LTLIBRARIES = librequesthandlers.la -librequesthandlers_la_SOURCES = DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp +librequesthandlers_la_SOURCES = DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp LogRequestHandler.cpp -noinst_HEADERS = DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h +noinst_HEADERS = DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h LogRequestHandler.h diff --git a/src/Core/RequestHandlers/Makefile.in b/src/Core/RequestHandlers/Makefile.in index af6ffb4..a450ea0 100644 --- a/src/Core/RequestHandlers/Makefile.in +++ b/src/Core/RequestHandlers/Makefile.in @@ -50,7 +50,7 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) librequesthandlers_la_LIBADD = am_librequesthandlers_la_OBJECTS = DaemonListRequestHandler.lo \ DaemonStatusRequestHandler.lo GSSAPIAuthRequestHandler.lo \ - IdentifyRequestHandler.lo + IdentifyRequestHandler.lo LogRequestHandler.lo librequesthandlers_la_OBJECTS = $(am_librequesthandlers_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -189,8 +189,8 @@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = librequesthandlers.la -librequesthandlers_la_SOURCES = DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp -noinst_HEADERS = DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h +librequesthandlers_la_SOURCES = DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp LogRequestHandler.cpp +noinst_HEADERS = DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h LogRequestHandler.h all: all-am .SUFFIXES: @@ -246,6 +246,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonStatusRequestHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSSAPIAuthRequestHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IdentifyRequestHandler.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogRequestHandler.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |