summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Client/CommandParser.cpp120
-rw-r--r--src/Client/CommandParser.h5
-rw-r--r--src/Client/Requests/CoreStatusRequest.cpp15
-rw-r--r--src/Client/Requests/DaemonListRequest.cpp9
-rw-r--r--src/Client/Requests/DaemonStatusRequest.cpp59
-rw-r--r--src/Client/Requests/DaemonStatusRequest.h58
-rw-r--r--src/Client/Requests/Makefile.am4
-rw-r--r--src/Client/Requests/Makefile.in8
-rw-r--r--src/Common/Request.h10
-rw-r--r--src/Common/RequestHandler.h10
-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.cpp (renamed from src/Core/RequestHandlers/CoreStatusRequestHandler.cpp)21
-rw-r--r--src/Common/RequestHandlers/StatusRequestHandler.h (renamed from src/Core/RequestHandlers/CoreStatusRequestHandler.h)16
-rw-r--r--src/Common/RequestManager.cpp20
-rw-r--r--src/Common/RequestManager.h5
-rw-r--r--src/Common/Requests/DisconnectRequest.cpp9
-rw-r--r--src/Common/Requests/GSSAPIAuthRequest.cpp9
-rw-r--r--src/Common/Requests/IdentifyRequest.cpp9
-rw-r--r--src/Core/ConnectionManager.cpp4
-rw-r--r--src/Core/Makefile.am4
-rw-r--r--src/Core/Makefile.in7
-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
-rw-r--r--src/Core/Requests/DaemonStatusRequest.cpp59
-rw-r--r--src/Core/Requests/DaemonStatusRequest.h56
-rw-r--r--src/Core/Requests/Makefile.am4
-rw-r--r--src/Core/Requests/Makefile.in446
-rw-r--r--src/Makefile.am6
-rw-r--r--src/Makefile.in23
-rw-r--r--src/Net/Packet.h2
-rw-r--r--src/mad.cpp6
38 files changed, 882 insertions, 208 deletions
diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp
index badbef7..30a0c16 100644
--- a/src/Client/CommandParser.cpp
+++ b/src/Client/CommandParser.cpp
@@ -20,6 +20,7 @@
#include "CommandParser.h"
#include "Requests/CoreStatusRequest.h"
#include "Requests/DaemonListRequest.h"
+#include "Requests/DaemonStatusRequest.h"
#include <Common/Requests/DisconnectRequest.h>
#include <Net/Packets/HostStatusPacket.h>
#include <Net/Packets/NameListPacket.h>
@@ -57,57 +58,7 @@ void CommandParser::printUsage(const std::string& command) {
std::cerr << "Usage: " << cmd->cmdline << std::endl;
}
-void CommandParser::helpCommand(const std::vector<std::string> &args) {
- if(args.size() == 1) {
- std::cout << "Available commands:" << std::endl << std::endl;
-
- for(int i = 0; commands[i].commands[0] != 0; ++i) {
- std::cout << commands[i].commands[0];
-
- for(int j = 1; commands[i].commands[j] != 0; ++j)
- std::cout << ", " << commands[i].commands[j];
-
- std::cout << std::endl << "\t" << commands[i].desc << std::endl;
- }
- }
- else if(args.size() == 2) {
- const Command* command = findCommand(args[1]);
-
- if(command) {
- std::cout << "Usage: " << command->cmdline << std::endl << std::endl;
- std::cout << command->longdesc << std::endl;
- }
- else
- std::cerr << args[0] << ": Command '" << args[1] << "' doesn't exist." << std::endl;
- }
- else {
- std::cerr << args[0] << ": Too many arguments." << std::endl;
- printUsage("help");
- }
-}
-
-void CommandParser::listHostsCommand(const std::vector<std::string>&) {
- activeRequests++;
-
- Requests::DaemonListRequest::send(connection, sigc::mem_fun(this, &CommandParser::daemonListRequestFinished));
-}
-
-void CommandParser::statusCommand(const std::vector<std::string>&) {
- activeRequests++;
-
- Requests::CoreStatusRequest::send(connection, sigc::mem_fun(this, &CommandParser::coreStatusRequestFinished));
-}
-
-void CommandParser::exitCommand(const std::vector<std::string>&) {
- activeRequests++;
- disconnect = true;
-
- Common::Requests::DisconnectRequest::send(connection, sigc::mem_fun(this, &CommandParser::requestFinished));
-}
-
-void CommandParser::coreStatusRequestFinished(const Net::Packets::HostStatusPacket &packet) {
- std::cout << "Server status:" << std::endl;
-
+void CommandParser::printHostStatus(const Net::Packets::HostStatusPacket &packet) {
if(packet.getUptime()) {
unsigned long days = packet.getUptime()/86400;
unsigned long hours = (packet.getUptime()%86400)/3600;
@@ -158,6 +109,65 @@ void CommandParser::coreStatusRequestFinished(const Net::Packets::HostStatusPack
std::printf("\n");
}
+}
+
+void CommandParser::helpCommand(const std::vector<std::string> &args) {
+ if(args.size() == 1) {
+ std::cout << "Available commands:" << std::endl << std::endl;
+
+ for(int i = 0; commands[i].commands[0] != 0; ++i) {
+ std::cout << commands[i].commands[0];
+
+ for(int j = 1; commands[i].commands[j] != 0; ++j)
+ std::cout << ", " << commands[i].commands[j];
+
+ std::cout << std::endl << "\t" << commands[i].desc << std::endl;
+ }
+ }
+ else if(args.size() == 2) {
+ const Command* command = findCommand(args[1]);
+
+ if(command) {
+ std::cout << "Usage: " << command->cmdline << std::endl << std::endl;
+ std::cout << command->longdesc << std::endl;
+ }
+ else
+ std::cerr << args[0] << ": Command '" << args[1] << "' doesn't exist." << std::endl;
+ }
+ else {
+ std::cerr << args[0] << ": Too many arguments." << std::endl;
+ printUsage("help");
+ }
+}
+
+void CommandParser::listHostsCommand(const std::vector<std::string>&) {
+ activeRequests++;
+
+ Requests::DaemonListRequest::send(connection, sigc::mem_fun(this, &CommandParser::daemonListRequestFinished));
+}
+
+void CommandParser::statusCommand(const std::vector<std::string> &args) {
+ if(args.size() == 1)
+ Requests::CoreStatusRequest::send(connection, sigc::mem_fun(this, &CommandParser::coreStatusRequestFinished));
+ else if(args.size() == 2)
+ Requests::DaemonStatusRequest::send(connection, sigc::mem_fun(this, &CommandParser::daemonStatusRequestFinished), args[1]);
+ else
+ return;
+
+ activeRequests++;
+}
+
+void CommandParser::exitCommand(const std::vector<std::string>&) {
+ activeRequests++;
+ disconnect = true;
+
+ Common::Requests::DisconnectRequest::send(connection, sigc::mem_fun(this, &CommandParser::requestFinished));
+}
+
+void CommandParser::coreStatusRequestFinished(const Net::Packets::HostStatusPacket &packet) {
+ std::cout << "Server status:" << std::endl;
+
+ printHostStatus(packet);
requestFinished();
}
@@ -180,6 +190,14 @@ void CommandParser::daemonListRequestFinished(const Net::Packets::NameListPacket
requestFinished();
}
+void CommandParser::daemonStatusRequestFinished(const Net::Packets::HostStatusPacket &packet) {
+ std::cout << "Host status:" << std::endl;
+
+ printHostStatus(packet);
+
+ requestFinished();
+}
+
bool CommandParser::split(const std::string &str, std::vector<std::string> &ret) {
std::string temp;
bool quoteSingle = false, quoteDouble = false, escape = false;
diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h
index 40d36a7..e2b4d58 100644
--- a/src/Client/CommandParser.h
+++ b/src/Client/CommandParser.h
@@ -63,13 +63,16 @@ class CommandParser {
const Command* findCommand(const std::string& command);
void printUsage(const std::string& command);
+ void printHostStatus(const Net::Packets::HostStatusPacket &packet);
+
void helpCommand(const std::vector<std::string> &args);
void listHostsCommand(const std::vector<std::string>&);
- void statusCommand(const std::vector<std::string>&);
+ void statusCommand(const std::vector<std::string> &args);
void exitCommand(const std::vector<std::string>&);
void coreStatusRequestFinished(const Net::Packets::HostStatusPacket &packet);
void daemonListRequestFinished(const Net::Packets::NameListPacket &packet);
+ void daemonStatusRequestFinished(const Net::Packets::HostStatusPacket &packet);
void requestFinished() {
activeRequests--;
diff --git a/src/Client/Requests/CoreStatusRequest.cpp b/src/Client/Requests/CoreStatusRequest.cpp
index af34752..1c477b8 100644
--- a/src/Client/Requests/CoreStatusRequest.cpp
+++ b/src/Client/Requests/CoreStatusRequest.cpp
@@ -38,27 +38,20 @@ bool CoreStatusRequest::send(Net::Connection *connection, const sigc::slot<void,
}
bool CoreStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(isSent())
+ if(!connection->send(Net::Packet(Net::Packet::STATUS, requestId)))
return false;
- if(!connection->send(Net::Packet(Net::Packet::CORE_STATUS, requestId)))
- return false;
-
- setSent();
return true;
}
bool CoreStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
if(packet.getType() != Net::Packet::OK)
return false; // TODO Logging
- finished(Net::Packets::HostStatusPacket(packet));
+ finished(Net::Packets::HostStatusPacket(packet));
- setFinished();
- return true;
+ signalFinished().emit();
+ return true;
}
}
diff --git a/src/Client/Requests/DaemonListRequest.cpp b/src/Client/Requests/DaemonListRequest.cpp
index a0e4cf1..97ee335 100644
--- a/src/Client/Requests/DaemonListRequest.cpp
+++ b/src/Client/Requests/DaemonListRequest.cpp
@@ -38,26 +38,19 @@ bool DaemonListRequest::send(Net::Connection *connection, const sigc::slot<void,
}
bool DaemonListRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(isSent())
- return false;
-
if(!connection->send(Net::Packet(Net::Packet::LIST_DAEMONS, requestId)))
return false;
- setSent();
return true;
}
bool DaemonListRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
if(packet.getType() != Net::Packet::OK)
return false; // TODO Logging
finished(Net::Packets::NameListPacket(packet));
- setFinished();
+ signalFinished().emit();
return true;
}
diff --git a/src/Client/Requests/DaemonStatusRequest.cpp b/src/Client/Requests/DaemonStatusRequest.cpp
new file mode 100644
index 0000000..8308e96
--- /dev/null
+++ b/src/Client/Requests/DaemonStatusRequest.cpp
@@ -0,0 +1,59 @@
+/*
+ * DaemonStatusRequest.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 "DaemonStatusRequest.h"
+#include <Common/RequestManager.h>
+#include <Net/Packets/HostStatusPacket.h>
+
+namespace Mad {
+namespace Client {
+namespace Requests {
+
+bool DaemonStatusRequest::send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback, const std::string &daemon0) {
+ DaemonStatusRequest *request = new DaemonStatusRequest(daemon0);
+
+ request->finished.connect(callback);
+
+ if(Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, request))
+ return true;
+
+ delete request;
+ return false;
+}
+
+bool DaemonStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ if(!connection->send(Net::Packet(Net::Packet::DAEMON_STATUS, requestId, daemon.c_str(), daemon.length())))
+ return false;
+
+ return true;
+}
+
+bool DaemonStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::OK)
+ return false; // TODO Logging
+
+ finished(Net::Packets::HostStatusPacket(packet));
+
+ signalFinished().emit();
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Client/Requests/DaemonStatusRequest.h b/src/Client/Requests/DaemonStatusRequest.h
new file mode 100644
index 0000000..0aff41b
--- /dev/null
+++ b/src/Client/Requests/DaemonStatusRequest.h
@@ -0,0 +1,58 @@
+/*
+ * DaemonStatusRequest.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_CLIENT_REQUESTS_DAEMONSTATUSREQUEST_H_
+#define MAD_CLIENT_REQUESTS_DAEMONSTATUSREQUEST_H_
+
+#include <Common/Request.h>
+
+#include <string>
+#include <sigc++/signal.h>
+
+namespace Mad {
+
+namespace Net {
+namespace Packets {
+class HostStatusPacket;
+}
+}
+
+namespace Client {
+namespace Requests {
+
+class DaemonStatusRequest : public Common::Request {
+ private:
+ sigc::signal<void,const Net::Packets::HostStatusPacket&> finished;
+
+ std::string daemon;
+
+ DaemonStatusRequest(const std::string &daemon0) : daemon(daemon0) {}
+
+ public:
+ static bool send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback, const std::string &daemon0);
+
+ virtual bool sendRequest(Net::Connection *connection, uint16_t requestId);
+ virtual bool handlePacket(Net::Connection*, const Net::Packet &packet);
+};
+
+}
+}
+}
+
+#endif /* MAD_CLIENT_REQUESTS_DAEMONSTATUSREQUEST_H_ */
diff --git a/src/Client/Requests/Makefile.am b/src/Client/Requests/Makefile.am
index bf15a08..e8e72d4 100644
--- a/src/Client/Requests/Makefile.am
+++ b/src/Client/Requests/Makefile.am
@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = librequests.la
-librequests_la_SOURCES = CoreStatusRequest.cpp DaemonListRequest.cpp
+librequests_la_SOURCES = CoreStatusRequest.cpp DaemonListRequest.cpp DaemonStatusRequest.cpp
-noinst_HEADERS = CoreStatusRequest.h DaemonListRequest.h
+noinst_HEADERS = CoreStatusRequest.h DaemonListRequest.h DaemonStatusRequest.h
diff --git a/src/Client/Requests/Makefile.in b/src/Client/Requests/Makefile.in
index 81f6cec..7ebd73d 100644
--- a/src/Client/Requests/Makefile.in
+++ b/src/Client/Requests/Makefile.in
@@ -45,7 +45,8 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librequests_la_LIBADD =
-am_librequests_la_OBJECTS = CoreStatusRequest.lo DaemonListRequest.lo
+am_librequests_la_OBJECTS = CoreStatusRequest.lo DaemonListRequest.lo \
+ DaemonStatusRequest.lo
librequests_la_OBJECTS = $(am_librequests_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 = librequests.la
-librequests_la_SOURCES = CoreStatusRequest.cpp DaemonListRequest.cpp
-noinst_HEADERS = CoreStatusRequest.h DaemonListRequest.h
+librequests_la_SOURCES = CoreStatusRequest.cpp DaemonListRequest.cpp DaemonStatusRequest.cpp
+noinst_HEADERS = CoreStatusRequest.h DaemonListRequest.h DaemonStatusRequest.h
all: all-am
.SUFFIXES:
@@ -239,6 +240,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoreStatusRequest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonListRequest.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonStatusRequest.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/src/Common/Request.h b/src/Common/Request.h
index 17e5eab..3d4be63 100644
--- a/src/Common/Request.h
+++ b/src/Common/Request.h
@@ -27,17 +27,7 @@ namespace Mad {
namespace Common {
class Request : public RequestHandler {
- private:
- bool sent;
-
- protected:
- Request() : sent(false) {}
-
- void setSent() {sent = true;}
-
public:
- bool isSent() const {return sent;}
-
virtual bool sendRequest(Net::Connection *connection, uint16_t requestId) = 0;
};
diff --git a/src/Common/RequestHandler.h b/src/Common/RequestHandler.h
index 4a72bd5..305836c 100644
--- a/src/Common/RequestHandler.h
+++ b/src/Common/RequestHandler.h
@@ -20,6 +20,8 @@
#ifndef MAD_COMMON_REQUESTHANDLER_H_
#define MAD_COMMON_REQUESTHANDLER_H_
+#include <sigc++/signal.h>
+
namespace Mad {
namespace Net {
@@ -33,17 +35,15 @@ class RequestManager;
class RequestHandler {
private:
- bool finished;
+ sigc::signal<void> finished;
protected:
- RequestHandler() : finished(false) {}
-
- void setFinished() {finished = true;}
+ RequestHandler() {}
public:
virtual ~RequestHandler() {}
- bool isFinished() const {return finished;}
+ sigc::signal<void> signalFinished() {return finished;}
virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet) = 0;
};
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/Core/RequestHandlers/CoreStatusRequestHandler.cpp b/src/Common/RequestHandlers/StatusRequestHandler.cpp
index 352de86..0a437fa 100644
--- a/src/Core/RequestHandlers/CoreStatusRequestHandler.cpp
+++ b/src/Common/RequestHandlers/StatusRequestHandler.cpp
@@ -1,5 +1,5 @@
/*
- * CoreStatusRequestHandler.cpp
+ * StatusRequestHandler.cpp
*
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
*
@@ -17,32 +17,29 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "CoreStatusRequestHandler.h"
-#include <Common/SystemBackend.h>
+#include "StatusRequestHandler.h"
+#include "../SystemBackend.h"
#include <Net/Connection.h>
#include <Net/Packets/HostStatusPacket.h>
namespace Mad {
-namespace Core {
+namespace Common {
namespace RequestHandlers {
-bool CoreStatusRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::CORE_STATUS)
+bool StatusRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::STATUS)
return false; // TODO Logging
// TODO Require authentication
- Common::SystemBackend::UptimeInfo uptimeInfo = Common::SystemBackend::getBackend()->getUptimeInfo();
- Common::SystemBackend::MemoryInfo memInfo = Common::SystemBackend::getBackend()->getMemoryInfo();
+ 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;
- setFinished();
+ signalFinished().emit();
return true;
}
diff --git a/src/Core/RequestHandlers/CoreStatusRequestHandler.h b/src/Common/RequestHandlers/StatusRequestHandler.h
index c9d3199..db2176a 100644
--- a/src/Core/RequestHandlers/CoreStatusRequestHandler.h
+++ b/src/Common/RequestHandlers/StatusRequestHandler.h
@@ -1,5 +1,5 @@
/*
- * CoreStatusRequestHandler.h
+ * StatusRequestHandler.h
*
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
*
@@ -17,18 +17,18 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_CORE_REQUESTHANDLERS_CORESTATUSREQUESTHANDLER_H_
-#define MAD_CORE_REQUESTHANDLERS_CORESTATUSREQUESTHANDLER_H_
+#ifndef MAD_COMMON_REQUESTHANDLERS_STATUSREQUESTHANDLER_H_
+#define MAD_COMMON_REQUESTHANDLERS_STATUSREQUESTHANDLER_H_
-#include <Common/RequestHandler.h>
+#include "../RequestHandler.h"
namespace Mad {
-namespace Core {
+namespace Common {
namespace RequestHandlers {
-class CoreStatusRequestHandler : public Common::RequestHandler {
+class StatusRequestHandler : public RequestHandler {
public:
- CoreStatusRequestHandler() {}
+ StatusRequestHandler() {}
virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
};
@@ -37,4 +37,4 @@ class CoreStatusRequestHandler : public Common::RequestHandler {
}
}
-#endif /* MAD_CORE_REQUESTHANDLERS_CORESTATUSREQUESTHANDLER_H_ */
+#endif /* MAD_COMMON_REQUESTHANDLERS_STATUSREQUESTHANDLER_H_ */
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index 8ebfce0..e2864b1 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -21,6 +21,8 @@
#include "Request.h"
#include "RequestHandlers/DisconnectRequestHandler.h"
+#include <sigc++/bind.h>
+#include <sigc++/retype_return.h>
#include <iostream>
namespace Mad {
@@ -29,6 +31,15 @@ namespace Common {
std::auto_ptr<RequestManager> RequestManager::requestManager;
+bool RequestManager::RequestMap::addRequest(uint16_t id, RequestHandler *info) {
+ if(!insert(std::make_pair(id, info)).second)
+ return false;
+
+ info->signalFinished().connect(sigc::hide_return(sigc::bind(sigc::mem_fun(this, &RequestManager::RequestMap::deleteRequest), id)));
+
+ return true;
+}
+
RequestHandler* RequestManager::RequestMap::findRequest(uint16_t id) {
iterator it = find(id);
if(it == end())
@@ -65,22 +76,15 @@ void RequestManager::receiveHandler(Net::Connection *connection, const Net::Pack
if(request) {
request->handlePacket(connection, packet);
- if(request->isFinished())
- requestMap->deleteRequest(packet.getRequestId());
-
return;
}
std::map<Net::Packet::Type,RequestHandlerFactory*>::iterator factoryIt = requestHandlerFactories.find(packet.getType());
if(factoryIt != requestHandlerFactories.end()) {
request = factoryIt->second->createRequestHandler();
+ requestMap->addRequest(packet.getRequestId(), request);
request->handlePacket(connection, packet);
- if(!request->isFinished())
- requestMap->addRequest(packet.getRequestId(), request);
- else
- delete request;
-
return;
}
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index 795f277..c050d1d 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -47,10 +47,7 @@ class RequestManager {
delete it->second;
}
- bool addRequest(uint16_t id, RequestHandler *info) {
- return insert(std::make_pair(id, info)).second;
- }
-
+ bool addRequest(uint16_t id, RequestHandler *info);
RequestHandler* findRequest(uint16_t id);
bool deleteRequest(uint16_t id);
};
diff --git a/src/Common/Requests/DisconnectRequest.cpp b/src/Common/Requests/DisconnectRequest.cpp
index 0b6e3bc..090b840 100644
--- a/src/Common/Requests/DisconnectRequest.cpp
+++ b/src/Common/Requests/DisconnectRequest.cpp
@@ -37,20 +37,13 @@ bool DisconnectRequest::send(Net::Connection *connection, const sigc::slot<void>
}
bool DisconnectRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(isSent())
- return false;
-
if(!connection->send(Net::Packet(Net::Packet::DISCONNECT, requestId)))
return false;
- setSent();
return true;
}
bool DisconnectRequest::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
if(packet.getType() != Net::Packet::OK)
return false; // TODO Logging
@@ -58,7 +51,7 @@ bool DisconnectRequest::handlePacket(Net::Connection *connection, const Net::Pac
finished();
- setFinished();
+ signalFinished().emit();
return true;
}
diff --git a/src/Common/Requests/GSSAPIAuthRequest.cpp b/src/Common/Requests/GSSAPIAuthRequest.cpp
index 705db41..a4a1b17 100644
--- a/src/Common/Requests/GSSAPIAuthRequest.cpp
+++ b/src/Common/Requests/GSSAPIAuthRequest.cpp
@@ -48,9 +48,6 @@ bool GSSAPIAuthRequest::send(Net::Connection *connection, const std::string &ser
}
bool GSSAPIAuthRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(isSent())
- return false;
-
OM_uint32 majStat, minStat;
gss_buffer_desc buffer;
@@ -86,14 +83,10 @@ bool GSSAPIAuthRequest::sendRequest(Net::Connection *connection, uint16_t reques
gss_release_buffer(&minStat, &buffer);
- setSent();
return true;
}
bool GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
if(packet.getType() != Net::Packet::GSSAPI_AUTH)
return false; // TODO Logging
@@ -160,7 +153,7 @@ bool GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Pac
gss_release_buffer(&minStat, &sendBuffer);
- setFinished();
+ signalFinished().emit();
}
return true;
diff --git a/src/Common/Requests/IdentifyRequest.cpp b/src/Common/Requests/IdentifyRequest.cpp
index 54d49e2..9214baf 100644
--- a/src/Common/Requests/IdentifyRequest.cpp
+++ b/src/Common/Requests/IdentifyRequest.cpp
@@ -36,24 +36,17 @@ bool IdentifyRequest::send(Net::Connection *connection, const std::string &hostn
}
bool IdentifyRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(isSent())
- return false;
-
if(!connection->send(Net::Packet(Net::Packet::IDENTIFY, requestId, hostname.c_str(), hostname.length())))
return false;
- setSent();
return true;
}
bool IdentifyRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
if(packet.getType() != Net::Packet::OK)
return false; // TODO Logging
- setFinished();
+ signalFinished().emit();
return true;
}
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index 9cbda90..60f3ac4 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -19,7 +19,7 @@
#include "ConnectionManager.h"
#include "ConfigManager.h"
-#include "RequestHandlers/CoreStatusRequestHandler.h"
+#include <Common/RequestHandlers/StatusRequestHandler.h>
#include "RequestHandlers/DaemonListRequestHandler.h"
#include "RequestHandlers/DaemonStatusRequestHandler.h"
#include "RequestHandlers/GSSAPIAuthRequestHandler.h"
@@ -66,7 +66,7 @@ void ConnectionManager::refreshPollfds() {
ConnectionManager::ConnectionManager() {
Common::RequestManager::init(true);
- Common::RequestManager::getRequestManager()->registerPacketType<RequestHandlers::CoreStatusRequestHandler>(Net::Packet::CORE_STATUS);
+ Common::RequestManager::getRequestManager()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>(Net::Packet::STATUS);
Common::RequestManager::getRequestManager()->registerPacketType<RequestHandlers::DaemonListRequestHandler>(Net::Packet::LIST_DAEMONS);
Common::RequestManager::getRequestManager()->registerPacketType<RequestHandlers::DaemonStatusRequestHandler>(Net::Packet::DAEMON_STATUS);
Common::RequestManager::getRequestManager()->registerPacketType<RequestHandlers::GSSAPIAuthRequestHandler>(Net::Packet::GSSAPI_AUTH);
diff --git a/src/Core/Makefile.am b/src/Core/Makefile.am
index fcbcd60..b72f766 100644
--- a/src/Core/Makefile.am
+++ b/src/Core/Makefile.am
@@ -1,8 +1,8 @@
-SUBDIRS = RequestHandlers
+SUBDIRS = Requests RequestHandlers
noinst_LTLIBRARIES = libcore.la
libcore_la_SOURCES = ConfigManager.cpp ConnectionManager.cpp
-libcore_la_LIBADD = RequestHandlers/librequesthandlers.la
+libcore_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandlers.la
noinst_HEADERS = ConfigManager.h ConnectionManager.h
diff --git a/src/Core/Makefile.in b/src/Core/Makefile.in
index be0493b..5489dce 100644
--- a/src/Core/Makefile.in
+++ b/src/Core/Makefile.in
@@ -44,7 +44,8 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
-libcore_la_DEPENDENCIES = RequestHandlers/librequesthandlers.la
+libcore_la_DEPENDENCIES = Requests/librequests.la \
+ RequestHandlers/librequesthandlers.la
am_libcore_la_OBJECTS = ConfigManager.lo ConnectionManager.lo
libcore_la_OBJECTS = $(am_libcore_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
@@ -193,10 +194,10 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = RequestHandlers
+SUBDIRS = Requests RequestHandlers
noinst_LTLIBRARIES = libcore.la
libcore_la_SOURCES = ConfigManager.cpp ConnectionManager.cpp
-libcore_la_LIBADD = RequestHandlers/librequesthandlers.la
+libcore_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandlers.la
noinst_HEADERS = ConfigManager.h ConnectionManager.h
all: all-recursive
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@
diff --git a/src/Core/Requests/DaemonStatusRequest.cpp b/src/Core/Requests/DaemonStatusRequest.cpp
new file mode 100644
index 0000000..118203f
--- /dev/null
+++ b/src/Core/Requests/DaemonStatusRequest.cpp
@@ -0,0 +1,59 @@
+/*
+ * DaemonStatusRequest.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 "DaemonStatusRequest.h"
+#include <Common/RequestManager.h>
+#include <Net/Packets/HostStatusPacket.h>
+
+namespace Mad {
+namespace Core {
+namespace Requests {
+
+bool DaemonStatusRequest::send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback) {
+ DaemonStatusRequest *request = new DaemonStatusRequest();
+
+ request->finished.connect(callback);
+
+ if(Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, request))
+ return true;
+
+ delete request;
+ return false;
+}
+
+bool DaemonStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ if(!connection->send(Net::Packet(Net::Packet::STATUS, requestId)))
+ return false;
+
+ return true;
+}
+
+bool DaemonStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::OK)
+ return false; // TODO Logging
+
+ finished(Net::Packets::HostStatusPacket(packet));
+
+ signalFinished().emit();
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Core/Requests/DaemonStatusRequest.h b/src/Core/Requests/DaemonStatusRequest.h
new file mode 100644
index 0000000..b9ec401
--- /dev/null
+++ b/src/Core/Requests/DaemonStatusRequest.h
@@ -0,0 +1,56 @@
+/*
+ * DaemonStatusRequest.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_REQUESTS_DAEMONSTATUSREQUEST_H_
+#define MAD_CORE_REQUESTS_DAEMONSTATUSREQUEST_H_
+
+#include <Common/Request.h>
+
+#include <string>
+#include <sigc++/signal.h>
+
+namespace Mad {
+
+namespace Net {
+namespace Packets {
+class HostStatusPacket;
+}
+}
+
+namespace Core {
+namespace Requests {
+
+class DaemonStatusRequest : public Common::Request {
+ private:
+ sigc::signal<void,const Net::Packets::HostStatusPacket&> finished;
+
+ DaemonStatusRequest() {}
+
+ public:
+ static bool send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback);
+
+ virtual bool sendRequest(Net::Connection *connection, uint16_t requestId);
+ virtual bool handlePacket(Net::Connection*, const Net::Packet &packet);
+};
+
+}
+}
+}
+
+#endif /* MAD_CORE_REQUESTS_DAEMONSTATUSREQUEST_H_ */
diff --git a/src/Core/Requests/Makefile.am b/src/Core/Requests/Makefile.am
new file mode 100644
index 0000000..d220dd6
--- /dev/null
+++ b/src/Core/Requests/Makefile.am
@@ -0,0 +1,4 @@
+noinst_LTLIBRARIES = librequests.la
+librequests_la_SOURCES = DaemonStatusRequest.cpp
+
+noinst_HEADERS = DaemonStatusRequest.h
diff --git a/src/Core/Requests/Makefile.in b/src/Core/Requests/Makefile.in
new file mode 100644
index 0000000..7421c2f
--- /dev/null
+++ b/src/Core/Requests/Makefile.in
@@ -0,0 +1,446 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/Core/Requests
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+librequests_la_LIBADD =
+am_librequests_la_OBJECTS = DaemonStatusRequest.lo
+librequests_la_OBJECTS = $(am_librequests_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(librequests_la_SOURCES)
+DIST_SOURCES = $(librequests_la_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GSSAPI_LIBS = @GSSAPI_LIBS@
+GnuTLS_CFLAGS = @GnuTLS_CFLAGS@
+GnuTLS_LIBS = @GnuTLS_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NMEDIT = @NMEDIT@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCRECPP_CFLAGS = @PCRECPP_CFLAGS@
+PCRECPP_LIBS = @PCRECPP_LIBS@
+PKG_CONFIG = @PKG_CONFIG@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sigc_CFLAGS = @sigc_CFLAGS@
+sigc_LIBS = @sigc_LIBS@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = librequests.la
+librequests_la_SOURCES = DaemonStatusRequest.cpp
+noinst_HEADERS = DaemonStatusRequest.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Core/Requests/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Core/Requests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+librequests.la: $(librequests_la_OBJECTS) $(librequests_la_DEPENDENCIES)
+ $(CXXLINK) $(librequests_la_OBJECTS) $(librequests_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DaemonStatusRequest.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/Makefile.am b/src/Makefile.am
index 85cf9fe..d2822a3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,10 +3,10 @@ SUBDIRS = Common Client Core Daemon Net
bin_PROGRAMS = mad madc mad-core
mad_SOURCES = mad.cpp
-mad_LDADD = Daemon/libdaemon.la Net/libnet.la Common/libcommon.la $(sigc_LIBS) $(GnuTLS_LIBS)
+mad_LDADD = Daemon/libdaemon.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(PCRECPP_LIBS)
madc_SOURCES = madc.cpp
-madc_LDADD = Client/libclient.la Net/libnet.la Common/libcommon.la $(sigc_LIBS) $(GnuTLS_LIBS) $(READLINE_LIBS)
+madc_LDADD = Client/libclient.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(READLINE_LIBS)
mad_core_SOURCES = mad-core.cpp
-mad_core_LDADD = Core/libcore.la Net/libnet.la Common/libcommon.la $(sigc_LIBS) $(GnuTLS_LIBS) $(PCRECPP_LIBS) $(GSSAPI_LIBS)
+mad_core_LDADD = Core/libcore.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(PCRECPP_LIBS) $(GSSAPI_LIBS)
diff --git a/src/Makefile.in b/src/Makefile.in
index 687b889..d3d780e 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -49,20 +49,19 @@ PROGRAMS = $(bin_PROGRAMS)
am_mad_OBJECTS = mad.$(OBJEXT)
mad_OBJECTS = $(am_mad_OBJECTS)
am__DEPENDENCIES_1 =
-mad_DEPENDENCIES = Daemon/libdaemon.la Net/libnet.la \
- Common/libcommon.la $(am__DEPENDENCIES_1) \
+mad_DEPENDENCIES = Daemon/libdaemon.la Common/libcommon.la \
+ Net/libnet.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
am_mad_core_OBJECTS = mad-core.$(OBJEXT)
mad_core_OBJECTS = $(am_mad_core_OBJECTS)
-mad_core_DEPENDENCIES = Core/libcore.la Net/libnet.la \
- Common/libcommon.la $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+mad_core_DEPENDENCIES = Core/libcore.la Common/libcommon.la \
+ Net/libnet.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am_madc_OBJECTS = madc.$(OBJEXT)
madc_OBJECTS = $(am_madc_OBJECTS)
-madc_DEPENDENCIES = Client/libclient.la Net/libnet.la \
- Common/libcommon.la $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+madc_DEPENDENCIES = Client/libclient.la Common/libcommon.la \
+ Net/libnet.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -210,11 +209,11 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = Common Client Core Daemon Net
mad_SOURCES = mad.cpp
-mad_LDADD = Daemon/libdaemon.la Net/libnet.la Common/libcommon.la $(sigc_LIBS) $(GnuTLS_LIBS)
+mad_LDADD = Daemon/libdaemon.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(PCRECPP_LIBS)
madc_SOURCES = madc.cpp
-madc_LDADD = Client/libclient.la Net/libnet.la Common/libcommon.la $(sigc_LIBS) $(GnuTLS_LIBS) $(READLINE_LIBS)
+madc_LDADD = Client/libclient.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(READLINE_LIBS)
mad_core_SOURCES = mad-core.cpp
-mad_core_LDADD = Core/libcore.la Net/libnet.la Common/libcommon.la $(sigc_LIBS) $(GnuTLS_LIBS) $(PCRECPP_LIBS) $(GSSAPI_LIBS)
+mad_core_LDADD = Core/libcore.la Common/libcommon.la Net/libnet.la $(sigc_LIBS) $(GnuTLS_LIBS) $(PCRECPP_LIBS) $(GSSAPI_LIBS)
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
diff --git a/src/Net/Packet.h b/src/Net/Packet.h
index 59e794d..9c23132 100644
--- a/src/Net/Packet.h
+++ b/src/Net/Packet.h
@@ -34,7 +34,7 @@ class Packet {
OK = 0x0000, ERROR = 0x0001, DISCONNECT = 0x0002,
GSSAPI_AUTH = 0x0010, IDENTIFY = 0x0011,
LIST_DAEMONS = 0x0020,
- CORE_STATUS = 0x0030, DAEMON_STATUS = 0x0031
+ STATUS = 0x0030, DAEMON_STATUS = 0x0031
};
struct Data {
diff --git a/src/mad.cpp b/src/mad.cpp
index a70be5a..3b1a9d8 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -19,8 +19,10 @@
#include "Net/ClientConnection.h"
#include "Net/IPAddress.h"
+#include "Common/Backends/SystemBackendProc.h"
#include "Common/RequestManager.h"
#include "Common/Requests/IdentifyRequest.h"
+#include "Common/RequestHandlers/StatusRequestHandler.h"
#include <iostream>
#include <unistd.h>
@@ -30,6 +32,10 @@ int main() {
Mad::Net::Connection::init();
Mad::Common::RequestManager::init(false);
+ Mad::Common::RequestManager::getRequestManager()->registerPacketType<Mad::Common::RequestHandlers::StatusRequestHandler>(Mad::Net::Packet::STATUS);
+
+ Mad::Common::Backends::SystemBackendProc::useBackend();
+
Mad::Net::ClientConnection *connection = new Mad::Net::ClientConnection;
try {