summaryrefslogtreecommitdiffstats
path: root/src/Core/RequestHandlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/RequestHandlers')
-rw-r--r--src/Core/RequestHandlers/CoreStatusRequestHandler.cpp52
-rw-r--r--src/Core/RequestHandlers/CoreStatusRequestHandler.h40
-rw-r--r--src/Core/RequestHandlers/DaemonListRequestHandler.cpp5
-rw-r--r--src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp23
-rw-r--r--src/Core/RequestHandlers/DaemonStatusRequestHandler.h16
-rw-r--r--src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp5
-rw-r--r--src/Core/RequestHandlers/IdentifyRequestHandler.cpp5
-rw-r--r--src/Core/RequestHandlers/Makefile.am4
-rw-r--r--src/Core/RequestHandlers/Makefile.in11
9 files changed, 40 insertions, 121 deletions
diff --git a/src/Core/RequestHandlers/CoreStatusRequestHandler.cpp b/src/Core/RequestHandlers/CoreStatusRequestHandler.cpp
deleted file mode 100644
index 352de86..0000000
--- a/src/Core/RequestHandlers/CoreStatusRequestHandler.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * CoreStatusRequestHandler.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 "CoreStatusRequestHandler.h"
-#include <Common/SystemBackend.h>
-#include <Net/Connection.h>
-#include <Net/Packets/HostStatusPacket.h>
-
-namespace Mad {
-namespace Core {
-namespace RequestHandlers {
-
-bool CoreStatusRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::CORE_STATUS)
- return false; // TODO Logging
-
- // TODO Require authentication
-
- Common::SystemBackend::UptimeInfo uptimeInfo = Common::SystemBackend::getBackend()->getUptimeInfo();
- Common::SystemBackend::MemoryInfo memInfo = Common::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;
-
- setFinished();
-
- return true;
-}
-
-}
-}
-}
diff --git a/src/Core/RequestHandlers/CoreStatusRequestHandler.h b/src/Core/RequestHandlers/CoreStatusRequestHandler.h
deleted file mode 100644
index c9d3199..0000000
--- a/src/Core/RequestHandlers/CoreStatusRequestHandler.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * CoreStatusRequestHandler.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_CORESTATUSREQUESTHANDLER_H_
-#define MAD_CORE_REQUESTHANDLERS_CORESTATUSREQUESTHANDLER_H_
-
-#include <Common/RequestHandler.h>
-
-namespace Mad {
-namespace Core {
-namespace RequestHandlers {
-
-class CoreStatusRequestHandler : public Common::RequestHandler {
- public:
- CoreStatusRequestHandler() {}
-
- virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
-};
-
-}
-}
-}
-
-#endif /* MAD_CORE_REQUESTHANDLERS_CORESTATUSREQUESTHANDLER_H_ */
diff --git a/src/Core/RequestHandlers/DaemonListRequestHandler.cpp b/src/Core/RequestHandlers/DaemonListRequestHandler.cpp
index 00ee0ff..1f137ad 100644
--- a/src/Core/RequestHandlers/DaemonListRequestHandler.cpp
+++ b/src/Core/RequestHandlers/DaemonListRequestHandler.cpp
@@ -27,9 +27,6 @@ namespace Core {
namespace RequestHandlers {
bool DaemonListRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
if(packet.getType() != Net::Packet::LIST_DAEMONS)
return false; // TODO Logging
@@ -44,7 +41,7 @@ bool DaemonListRequestHandler::handlePacket(Net::Connection *connection, const N
if(!connection->send(Net::Packets::NameListPacket(Net::Packet::OK, packet.getRequestId(), names)))
return false;
- setFinished();
+ signalFinished().emit();
return true;
}
diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
index 81f066d..0179ecc 100644
--- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
+++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
@@ -19,32 +19,39 @@
#include "DaemonStatusRequestHandler.h"
#include "../ConnectionManager.h"
-#include <Net/Packet.h>
+#include <Core/Requests/DaemonStatusRequest.h>
+#include <Net/Packets/HostStatusPacket.h>
namespace Mad {
namespace Core {
namespace RequestHandlers {
-bool DaemonStatusRequestHandler::handlePacket(Net::Connection*, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
+bool DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
if(packet.getType() != Net::Packet::DAEMON_STATUS)
return false; // TODO Logging
// TODO Require authentication
+ con = connection;
+ requestId = packet.getRequestId();
+
std::string daemonName((char*)packet.getData(), packet.getLength());
- /*Net::Connection *daemonCon = connectionManager->getDaemonConnection(daemonName);
+ Net::Connection *daemonCon = ConnectionManager::getConnectionManager()->getDaemonConnection(daemonName);
if(!daemonCon)
- return false;*/
-
+ return false;
+ Requests::DaemonStatusRequest::send(daemonCon, sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished));
return true;
}
+void DaemonStatusRequestHandler::requestFinished(const Net::Packets::HostStatusPacket &packet) {
+ con->send(Net::Packet(Net::Packet::OK, requestId, packet.getData(), packet.getLength()));
+
+ signalFinished().emit();
+}
+
}
}
}
diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h
index accc990..5d755bd 100644
--- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h
+++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h
@@ -21,8 +21,16 @@
#define MAD_CORE_REQUESTHANDLERS_DAEMONSTATUSREQUESTHANDLER_H_
#include <Common/RequestHandler.h>
+#include <stdint.h>
namespace Mad {
+
+namespace Net {
+namespace Packets {
+class HostStatusPacket;
+}
+}
+
namespace Core {
class ConnectionManager;
@@ -30,10 +38,16 @@ class ConnectionManager;
namespace RequestHandlers {
class DaemonStatusRequestHandler : public Common::RequestHandler {
+ private:
+ Net::Connection *con;
+ uint16_t requestId;
+
+ void requestFinished(const Net::Packets::HostStatusPacket &packet);
+
public:
DaemonStatusRequestHandler() {}
- virtual bool handlePacket(Net::Connection*, const Net::Packet &packet);
+ virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
};
}
diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
index c1b7e7c..94098b9 100644
--- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
+++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
@@ -31,9 +31,6 @@ namespace RequestHandlers {
// TODO Error handling
bool GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
if(packet.getType() != Net::Packet::GSSAPI_AUTH)
return false; // TODO Logging
@@ -102,7 +99,7 @@ bool GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const N
if(majStat != GSS_S_COMPLETE)
return false;
- setFinished();
+ signalFinished().emit();
}
return true;
diff --git a/src/Core/RequestHandlers/IdentifyRequestHandler.cpp b/src/Core/RequestHandlers/IdentifyRequestHandler.cpp
index 9a80959..48fccf2 100644
--- a/src/Core/RequestHandlers/IdentifyRequestHandler.cpp
+++ b/src/Core/RequestHandlers/IdentifyRequestHandler.cpp
@@ -26,9 +26,6 @@ namespace Core {
namespace RequestHandlers {
bool IdentifyRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
if(packet.getType() != Net::Packet::IDENTIFY)
return false; // TODO Logging
@@ -39,7 +36,7 @@ bool IdentifyRequestHandler::handlePacket(Net::Connection *connection, const Net
if(!connection->send(Net::Packet(Net::Packet::OK, packet.getRequestId())))
return false;
- setFinished();
+ signalFinished().emit();
return true;
}
diff --git a/src/Core/RequestHandlers/Makefile.am b/src/Core/RequestHandlers/Makefile.am
index 8155a80..2c65ceb 100644
--- a/src/Core/RequestHandlers/Makefile.am
+++ b/src/Core/RequestHandlers/Makefile.am
@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = librequesthandlers.la
-librequesthandlers_la_SOURCES = CoreStatusRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp
+librequesthandlers_la_SOURCES = DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp
-noinst_HEADERS = CoreStatusRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h
+noinst_HEADERS = DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h
diff --git a/src/Core/RequestHandlers/Makefile.in b/src/Core/RequestHandlers/Makefile.in
index 88e1ca3..1729c8b 100644
--- a/src/Core/RequestHandlers/Makefile.in
+++ b/src/Core/RequestHandlers/Makefile.in
@@ -45,9 +45,9 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librequesthandlers_la_LIBADD =
-am_librequesthandlers_la_OBJECTS = CoreStatusRequestHandler.lo \
- DaemonListRequestHandler.lo DaemonStatusRequestHandler.lo \
- GSSAPIAuthRequestHandler.lo IdentifyRequestHandler.lo
+am_librequesthandlers_la_OBJECTS = DaemonListRequestHandler.lo \
+ DaemonStatusRequestHandler.lo GSSAPIAuthRequestHandler.lo \
+ IdentifyRequestHandler.lo
librequesthandlers_la_OBJECTS = $(am_librequesthandlers_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -186,8 +186,8 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = librequesthandlers.la
-librequesthandlers_la_SOURCES = CoreStatusRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp
-noinst_HEADERS = CoreStatusRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h
+librequesthandlers_la_SOURCES = DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp IdentifyRequestHandler.cpp
+noinst_HEADERS = DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h IdentifyRequestHandler.h
all: all-am
.SUFFIXES:
@@ -239,7 +239,6 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoreStatusRequestHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonListRequestHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonStatusRequestHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSSAPIAuthRequestHandler.Plo@am__quote@