summaryrefslogtreecommitdiffstats
path: root/src/Daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/Daemon')
-rw-r--r--src/Daemon/Application.cpp (renamed from src/Daemon/Daemon.cpp)11
-rw-r--r--src/Daemon/Application.h36
-rw-r--r--src/Daemon/Backends/NetworkLogger.h8
-rw-r--r--src/Daemon/CMakeLists.txt2
-rw-r--r--src/Daemon/RequestHandlers/CommandRequestHandler.cpp4
-rw-r--r--src/Daemon/RequestHandlers/CommandRequestHandler.h5
-rw-r--r--src/Daemon/Requests/LogRequest.h9
7 files changed, 59 insertions, 16 deletions
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Application.cpp
index 3725498..d31cbf5 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Application.cpp
@@ -1,5 +1,5 @@
/*
- * Daemon.cpp
+ * Application.cpp
*
* Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
*
@@ -17,5 +17,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Application.h"
-// Empty...
+namespace Mad {
+namespace Daemon {
+
+Application::Application() : Common::Application(false) {}
+
+}
+}
diff --git a/src/Daemon/Application.h b/src/Daemon/Application.h
new file mode 100644
index 0000000..4be7f22
--- /dev/null
+++ b/src/Daemon/Application.h
@@ -0,0 +1,36 @@
+/*
+ * Application.h
+ *
+ * Copyright (C) 2009 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_APPLICATION_H_
+#define MAD_DAEMON_APPLICATION_H_
+
+#include <Common/Application.h>
+
+namespace Mad {
+namespace Daemon {
+
+class Application : public Common::Application {
+ public:
+ Application();
+};
+
+}
+}
+
+#endif /* MAD_DAEMON_APPLICATION_H_ */
diff --git a/src/Daemon/Backends/NetworkLogger.h b/src/Daemon/Backends/NetworkLogger.h
index c0b123a..557cc14 100644
--- a/src/Daemon/Backends/NetworkLogger.h
+++ b/src/Daemon/Backends/NetworkLogger.h
@@ -20,7 +20,6 @@
#ifndef MAD_DAEMON_BACKENDS_NETWORKLOGGER_H_
#define MAD_DAEMON_BACKENDS_NETWORKLOGGER_H_
-#include <Core/Logger.h>
#include <Common/RequestManager.h>
#include <Daemon/Requests/LogRequest.h>
@@ -30,16 +29,17 @@ namespace Backends {
class NetworkLogger : public Core::Logger {
private:
+ Common::Application *application;
Common::Connection *connection;
protected:
virtual void logMessage(Core::Logger::MessageCategory category, Core::Logger::MessageLevel level, time_t messageTimestamp, const std::string &message) {
- boost::shared_ptr<Requests::LogRequest> request(new Requests::LogRequest(category, level, messageTimestamp, message));
- Common::RequestManager::get()->sendRequest(connection, request);
+ boost::shared_ptr<Requests::LogRequest> request(new Requests::LogRequest(application, category, level, messageTimestamp, message));
+ application->getRequestManager()->sendRequest(connection, request);
}
public:
- NetworkLogger(Common::Connection *connection0) : connection(connection0) {}
+ NetworkLogger(Common::Application *application0, Common::Connection *connection0) : application(application0), connection(connection0) {}
};
}
diff --git a/src/Daemon/CMakeLists.txt b/src/Daemon/CMakeLists.txt
index 68c5f5d..151c229 100644
--- a/src/Daemon/CMakeLists.txt
+++ b/src/Daemon/CMakeLists.txt
@@ -6,6 +6,6 @@ include_directories(${INCLUDES})
add_library(Daemon
Backends/NetworkLogger.h
- Daemon.cpp
+ Application.cpp Application.h
)
target_link_libraries(Daemon DaemonRequestHandlers DaemonRequests Common)
diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp
index d00c415..ae11de5 100644
--- a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp
+++ b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp
@@ -31,9 +31,9 @@ void CommandRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPac
std::string command = (*packet)["command"];
if(command == "reboot")
- Common::SystemManager::get()->reboot();
+ getApplication()->getSystemManager()->reboot();
else
- Common::SystemManager::get()->shutdown();
+ getApplication()->getSystemManager()->shutdown();
ret->setType("OK");
}
diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.h b/src/Daemon/RequestHandlers/CommandRequestHandler.h
index 22c7a4b..db7b3d4 100644
--- a/src/Daemon/RequestHandlers/CommandRequestHandler.h
+++ b/src/Daemon/RequestHandlers/CommandRequestHandler.h
@@ -28,10 +28,11 @@ namespace RequestHandlers {
class CommandRequestHandler : public Common::RequestHandlers::SimpleRequestHandler {
private:
- static void handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
+ void handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
public:
- CommandRequestHandler() : Common::RequestHandlers::SimpleRequestHandler("Command", &CommandRequestHandler::handleRequest) {}
+ CommandRequestHandler(Common::Application *application)
+ : Common::RequestHandlers::SimpleRequestHandler(application, "Command", boost::bind(&CommandRequestHandler::handleRequest, this, _1, _2)) {}
};
}
diff --git a/src/Daemon/Requests/LogRequest.h b/src/Daemon/Requests/LogRequest.h
index 6ee3b3d..a3cda41 100644
--- a/src/Daemon/Requests/LogRequest.h
+++ b/src/Daemon/Requests/LogRequest.h
@@ -21,7 +21,6 @@
#define MAD_DAEMON_REQUESTS_LOGREQUEST_H_
#include <Common/Request.h>
-#include <Core/Logger.h>
#include <ctime>
namespace Mad {
@@ -30,8 +29,8 @@ namespace Requests {
class LogRequest : public Common::Request {
private:
- Core::Logger::MessageCategory category;
- Core::Logger::MessageLevel level;
+ Core::LoggerBase::MessageCategory category;
+ Core::LoggerBase::MessageLevel level;
time_t messageTimestamp;
std::string message;
@@ -39,8 +38,8 @@ class LogRequest : public Common::Request {
virtual void sendRequest();
public:
- LogRequest(Core::Logger::MessageCategory category0, Core::Logger::MessageLevel level0, time_t messageTimestamp0, const std::string &message0)
- : category(category0), level(level0), messageTimestamp(messageTimestamp0), message(message0) {}
+ LogRequest(Common::Application *application, Core::LoggerBase::MessageCategory category0, Core::LoggerBase::MessageLevel level0, time_t messageTimestamp0, const std::string &message0)
+ : Common::Request(application), category(category0), level(level0), messageTimestamp(messageTimestamp0), message(message0) {}
};
}