summaryrefslogtreecommitdiffstats
path: root/src/Common/RequestHandlers
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-09-15 06:26:15 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-09-15 06:26:15 +0200
commit9ca70bbfa460fe1c6c31b8e685be6df24935ab73 (patch)
tree8fe0a6e164d7d2f4e5f23e073c0a80a0b29daf94 /src/Common/RequestHandlers
parent30bec92571ba23f1f2aa6b12149f6545a4ef0d7e (diff)
downloadmad-9ca70bbfa460fe1c6c31b8e685be6df24935ab73.tar
mad-9ca70bbfa460fe1c6c31b8e685be6df24935ab73.zip
Kann jetzt Status von Daemons abfragen
Diffstat (limited to 'src/Common/RequestHandlers')
-rw-r--r--src/Common/RequestHandlers/DisconnectRequestHandler.cpp5
-rw-r--r--src/Common/RequestHandlers/Makefile.am4
-rw-r--r--src/Common/RequestHandlers/Makefile.in8
-rw-r--r--src/Common/RequestHandlers/StatusRequestHandler.cpp49
-rw-r--r--src/Common/RequestHandlers/StatusRequestHandler.h40
5 files changed, 97 insertions, 9 deletions
diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
index 967649e..aa98c04 100644
--- a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
+++ b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
@@ -25,9 +25,6 @@ namespace Common {
namespace RequestHandlers {
bool DisconnectRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
if(packet.getType() != Net::Packet::DISCONNECT)
return false; // TODO Logging
@@ -36,7 +33,7 @@ bool DisconnectRequestHandler::handlePacket(Net::Connection *connection, const N
connection->disconnect();
- setFinished();
+ signalFinished().emit();
return true;
}
diff --git a/src/Common/RequestHandlers/Makefile.am b/src/Common/RequestHandlers/Makefile.am
index 9133148..4a266e8 100644
--- a/src/Common/RequestHandlers/Makefile.am
+++ b/src/Common/RequestHandlers/Makefile.am
@@ -1,5 +1,5 @@
noinst_LTLIBRARIES = librequesthandlers.la
-librequesthandlers_la_SOURCES = DisconnectRequestHandler.cpp
+librequesthandlers_la_SOURCES = DisconnectRequestHandler.cpp StatusRequestHandler.cpp
-noinst_HEADERS = DisconnectRequestHandler.h
+noinst_HEADERS = DisconnectRequestHandler.h StatusRequestHandler.h
diff --git a/src/Common/RequestHandlers/Makefile.in b/src/Common/RequestHandlers/Makefile.in
index c55394a..c933082 100644
--- a/src/Common/RequestHandlers/Makefile.in
+++ b/src/Common/RequestHandlers/Makefile.in
@@ -45,7 +45,8 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librequesthandlers_la_LIBADD =
-am_librequesthandlers_la_OBJECTS = DisconnectRequestHandler.lo
+am_librequesthandlers_la_OBJECTS = DisconnectRequestHandler.lo \
+ StatusRequestHandler.lo
librequesthandlers_la_OBJECTS = $(am_librequesthandlers_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -184,8 +185,8 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = librequesthandlers.la
-librequesthandlers_la_SOURCES = DisconnectRequestHandler.cpp
-noinst_HEADERS = DisconnectRequestHandler.h
+librequesthandlers_la_SOURCES = DisconnectRequestHandler.cpp StatusRequestHandler.cpp
+noinst_HEADERS = DisconnectRequestHandler.h StatusRequestHandler.h
all: all-am
.SUFFIXES:
@@ -238,6 +239,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DisconnectRequestHandler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StatusRequestHandler.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/src/Common/RequestHandlers/StatusRequestHandler.cpp b/src/Common/RequestHandlers/StatusRequestHandler.cpp
new file mode 100644
index 0000000..0a437fa
--- /dev/null
+++ b/src/Common/RequestHandlers/StatusRequestHandler.cpp
@@ -0,0 +1,49 @@
+/*
+ * StatusRequestHandler.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 "StatusRequestHandler.h"
+#include "../SystemBackend.h"
+#include <Net/Connection.h>
+#include <Net/Packets/HostStatusPacket.h>
+
+namespace Mad {
+namespace Common {
+namespace RequestHandlers {
+
+bool StatusRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::STATUS)
+ return false; // TODO Logging
+
+ // TODO Require authentication
+
+ SystemBackend::UptimeInfo uptimeInfo = SystemBackend::getBackend()->getUptimeInfo();
+ SystemBackend::MemoryInfo memInfo = SystemBackend::getBackend()->getMemoryInfo();
+
+ if(!connection->send(Net::Packets::HostStatusPacket(Net::Packet::OK, packet.getRequestId(), uptimeInfo.uptime, uptimeInfo.idleTime,
+ memInfo.totalMem, memInfo.freeMem, memInfo.totalSwap, memInfo.freeSwap)))
+ return false;
+
+ signalFinished().emit();
+
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Common/RequestHandlers/StatusRequestHandler.h b/src/Common/RequestHandlers/StatusRequestHandler.h
new file mode 100644
index 0000000..db2176a
--- /dev/null
+++ b/src/Common/RequestHandlers/StatusRequestHandler.h
@@ -0,0 +1,40 @@
+/*
+ * StatusRequestHandler.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_COMMON_REQUESTHANDLERS_STATUSREQUESTHANDLER_H_
+#define MAD_COMMON_REQUESTHANDLERS_STATUSREQUESTHANDLER_H_
+
+#include "../RequestHandler.h"
+
+namespace Mad {
+namespace Common {
+namespace RequestHandlers {
+
+class StatusRequestHandler : public RequestHandler {
+ public:
+ StatusRequestHandler() {}
+
+ virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
+};
+
+}
+}
+}
+
+#endif /* MAD_COMMON_REQUESTHANDLERS_STATUSREQUESTHANDLER_H_ */