summaryrefslogtreecommitdiffstats
path: root/src/Core
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-02-24 23:08:23 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-02-24 23:08:23 +0100
commit8f85624a76934b14e0ba0f49413f471f8f4aa4f1 (patch)
tree9fc387bb5523a56d1b4c1d45e3cbccb90c0584b2 /src/Core
parent35ab037e7e6ac08e214b053de8ed87e3f35586fc (diff)
downloadmad-8f85624a76934b14e0ba0f49413f471f8f4aa4f1.tar
mad-8f85624a76934b14e0ba0f49413f471f8f4aa4f1.zip
LogRequest ist jetzt ein XmlRequest
Diffstat (limited to 'src/Core')
-rw-r--r--src/Core/ConnectionManager.cpp4
-rw-r--r--src/Core/RequestHandlers/LogRequestHandler.cpp23
-rw-r--r--src/Core/RequestHandlers/LogRequestHandler.h6
3 files changed, 19 insertions, 14 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index 6362314..f46939d 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -142,11 +142,11 @@ void ConnectionManager::doInit() {
Common::RequestManager::get()->registerPacketType<RequestHandlers::DaemonListRequestHandler>(Net::Packet::LIST_DAEMONS);
Common::RequestManager::get()->registerPacketType<RequestHandlers::GSSAPIAuthRequestHandler>(Net::Packet::GSSAPI_AUTH);
Common::RequestManager::get()->registerPacketType<RequestHandlers::IdentifyRequestHandler>(Net::Packet::IDENTIFY);
- Common::RequestManager::get()->registerPacketType<RequestHandlers::LogRequestHandler>(Net::Packet::LOG);
Common::RequestManager::get()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>("GetStatus");
Common::RequestManager::get()->registerPacketType<RequestHandlers::DaemonStatusRequestHandler>("GetDaemonStatus");
Common::RequestManager::get()->registerPacketType<RequestHandlers::UserListRequestHandler>("ListUsers");
+ Common::RequestManager::get()->registerPacketType<RequestHandlers::LogRequestHandler>("Log");
}
void ConnectionManager::doDeinit() {
@@ -163,11 +163,11 @@ void ConnectionManager::doDeinit() {
Common::RequestManager::get()->unregisterPacketType(Net::Packet::LIST_DAEMONS);
Common::RequestManager::get()->unregisterPacketType(Net::Packet::GSSAPI_AUTH);
Common::RequestManager::get()->unregisterPacketType(Net::Packet::IDENTIFY);
- Common::RequestManager::get()->unregisterPacketType(Net::Packet::LOG);
Common::RequestManager::get()->unregisterPacketType("GetStatus");
Common::RequestManager::get()->unregisterPacketType("GetDaemonStatus");
Common::RequestManager::get()->unregisterPacketType("ListUsers");
+ Common::RequestManager::get()->unregisterPacketType("Log");
Net::Connection::deinit();
}
diff --git a/src/Core/RequestHandlers/LogRequestHandler.cpp b/src/Core/RequestHandlers/LogRequestHandler.cpp
index e28ac8e..77be876 100644
--- a/src/Core/RequestHandlers/LogRequestHandler.cpp
+++ b/src/Core/RequestHandlers/LogRequestHandler.cpp
@@ -20,19 +20,23 @@
#include "LogRequestHandler.h"
#include <Common/Logger.h>
#include <Common/LogManager.h>
+#include <Common/XmlPacket.h>
#include "../ConnectionManager.h"
#include <Net/Connection.h>
-#include <Net/Packets/ErrorPacket.h>
-#include <Net/Packets/LogPacket.h>
namespace Mad {
namespace Core {
namespace RequestHandlers {
-void LogRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(packet.getType() != Net::Packet::LOG) {
+void LogRequestHandler::handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet) {
+ if(packet.getType() != "Log") {
Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
- connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
+
+ Common::XmlPacket ret;
+ ret.setType("Error");
+ ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET);
+
+ connection->send(ret.encode(requestId));
signalFinished().emit();
return;
@@ -40,17 +44,18 @@ void LogRequestHandler::handlePacket(Net::Connection *connection, const Net::Pac
// TODO Require authentication
- Net::Packets::LogPacket logPacket(packet);
-
try {
- Common::LogManager::get()->log(logPacket.getCategory(), logPacket.getLevel(), logPacket.getTimestamp(), logPacket.getMessage().c_str(),
+ Common::LogManager::get()->log(packet["category"], packet["level"], packet["timestamp"], packet["message"],
ConnectionManager::get()->getDaemonName(connection));
}
catch(Common::Exception &e) {
Common::Logger::logf(Common::Logger::ERROR, "Can't determine daemon name: %s", e.strerror().c_str());
}
- connection->send(Net::Packet(Net::Packet::OK, packet.getRequestId()));
+ Common::XmlPacket ret;
+ ret.setType("OK");
+
+ connection->send(ret.encode(requestId));
signalFinished().emit();
}
diff --git a/src/Core/RequestHandlers/LogRequestHandler.h b/src/Core/RequestHandlers/LogRequestHandler.h
index b82f24b..1c84248 100644
--- a/src/Core/RequestHandlers/LogRequestHandler.h
+++ b/src/Core/RequestHandlers/LogRequestHandler.h
@@ -20,15 +20,15 @@
#ifndef MAD_CORE_REQUESTHANDLERS_LOGREQUESTHANDLER_H_
#define MAD_CORE_REQUESTHANDLERS_LOGREQUESTHANDLER_H_
-#include <Common/RequestHandler.h>
+#include <Common/XmlRequestHandler.h>
namespace Mad {
namespace Core {
namespace RequestHandlers {
-class LogRequestHandler : public Common::RequestHandler {
+class LogRequestHandler : public Common::XmlRequestHandler {
protected:
- virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet);
+ virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet);
public:
LogRequestHandler() {}