summaryrefslogtreecommitdiffstats
path: root/src/Daemon/Requests
diff options
context:
space:
mode:
Diffstat (limited to 'src/Daemon/Requests')
-rw-r--r--src/Daemon/Requests/LogRequest.cpp43
-rw-r--r--src/Daemon/Requests/LogRequest.h49
-rw-r--r--src/Daemon/Requests/Makefile.am4
-rw-r--r--src/Daemon/Requests/Makefile.in7
4 files changed, 98 insertions, 5 deletions
diff --git a/src/Daemon/Requests/LogRequest.cpp b/src/Daemon/Requests/LogRequest.cpp
new file mode 100644
index 0000000..62115cc
--- /dev/null
+++ b/src/Daemon/Requests/LogRequest.cpp
@@ -0,0 +1,43 @@
+/*
+ * LogRequest.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 "LogRequest.h"
+#include <Net/Connection.h>
+#include <Net/Packets/LogPacket.h>
+
+namespace Mad {
+namespace Daemon {
+namespace Requests {
+
+void LogRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ connection->send(Net::Packets::LogPacket(Net::Packet::LOG, requestId, category, level, message));
+}
+
+void LogRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::OK) {
+ finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET));
+ return; // TODO Logging
+ }
+
+ finish();
+}
+
+}
+}
+}
diff --git a/src/Daemon/Requests/LogRequest.h b/src/Daemon/Requests/LogRequest.h
new file mode 100644
index 0000000..a0a2e44
--- /dev/null
+++ b/src/Daemon/Requests/LogRequest.h
@@ -0,0 +1,49 @@
+/*
+ * LogRequest.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_DAEMON_REQUESTS_LOGREQUEST_H_
+#define MAD_DAEMON_REQUESTS_LOGREQUEST_H_
+
+#include <Common/Request.h>
+#include <Common/Logger.h>
+
+namespace Mad {
+namespace Daemon {
+namespace Requests {
+
+class LogRequest : public Common::Request<> {
+ private:
+ Common::Logger::MessageCategory category;
+ Common::Logger::MessageLevel level;
+ std::string message;
+
+ protected:
+ virtual void sendRequest(Net::Connection *connection, uint16_t requestId);
+ virtual void handlePacket(Net::Connection*, const Net::Packet &packet);
+
+ public:
+ LogRequest(Common::Logger::MessageCategory category0, Common::Logger::MessageLevel level0, const std::string &message0, slot_type slot)
+ : Common::Request<>(slot), category(category0), level(level0), message(message0) {}
+};
+
+}
+}
+}
+
+#endif /* MAD_DAEMON_REQUESTS_LOGREQUEST_H_ */
diff --git a/src/Daemon/Requests/Makefile.am b/src/Daemon/Requests/Makefile.am
index 5de84de..6ea9548 100644
--- a/src/Daemon/Requests/Makefile.am
+++ b/src/Daemon/Requests/Makefile.am
@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = librequests.la
-librequests_la_SOURCES = IdentifyRequest.cpp
+librequests_la_SOURCES = IdentifyRequest.cpp LogRequest.cpp
-noinst_HEADERS = IdentifyRequest.h
+noinst_HEADERS = IdentifyRequest.h LogRequest.h
diff --git a/src/Daemon/Requests/Makefile.in b/src/Daemon/Requests/Makefile.in
index 9a63acc..d915874 100644
--- a/src/Daemon/Requests/Makefile.in
+++ b/src/Daemon/Requests/Makefile.in
@@ -48,7 +48,7 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librequests_la_LIBADD =
-am_librequests_la_OBJECTS = IdentifyRequest.lo
+am_librequests_la_OBJECTS = IdentifyRequest.lo LogRequest.lo
librequests_la_OBJECTS = $(am_librequests_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -187,8 +187,8 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = librequests.la
-librequests_la_SOURCES = IdentifyRequest.cpp
-noinst_HEADERS = IdentifyRequest.h
+librequests_la_SOURCES = IdentifyRequest.cpp LogRequest.cpp
+noinst_HEADERS = IdentifyRequest.h LogRequest.h
all: all-am
.SUFFIXES:
@@ -241,6 +241,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IdentifyRequest.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogRequest.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<