summaryrefslogtreecommitdiffstats
path: root/src/Server/RequestHandlers
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-06-18 22:03:02 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-06-18 22:03:02 +0200
commit7234fe326d16d6bf9f4374a09ddc6ef790e6723f (patch)
tree437d4c40eeb1e9b34b369e4b82064a1572c7dac9 /src/Server/RequestHandlers
parentbf561f8226e97f4ace4f04bddf198175e91ee7f0 (diff)
downloadmad-7234fe326d16d6bf9f4374a09ddc6ef790e6723f.tar
mad-7234fe326d16d6bf9f4374a09ddc6ef790e6723f.zip
Globale Variablen durch Application-Klasse ersetzt
Diffstat (limited to 'src/Server/RequestHandlers')
-rw-r--r--src/Server/RequestHandlers/CMakeLists.txt4
-rw-r--r--src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp79
-rw-r--r--src/Server/RequestHandlers/ConnectionRequestHandlerGroup.h48
-rw-r--r--src/Server/RequestHandlers/DaemonListRequestHandler.cpp46
-rw-r--r--src/Server/RequestHandlers/DaemonListRequestHandler.h41
-rw-r--r--src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp19
-rw-r--r--src/Server/RequestHandlers/DaemonRequestHandlerGroup.h9
-rw-r--r--src/Server/RequestHandlers/IdentifyRequestHandler.cpp39
-rw-r--r--src/Server/RequestHandlers/IdentifyRequestHandler.h41
-rw-r--r--src/Server/RequestHandlers/LogRequestHandler.cpp44
-rw-r--r--src/Server/RequestHandlers/LogRequestHandler.h41
-rw-r--r--src/Server/RequestHandlers/UserRequestHandlerGroup.cpp38
-rw-r--r--src/Server/RequestHandlers/UserRequestHandlerGroup.h17
13 files changed, 178 insertions, 288 deletions
diff --git a/src/Server/RequestHandlers/CMakeLists.txt b/src/Server/RequestHandlers/CMakeLists.txt
index 9b9b9ea..065a85d 100644
--- a/src/Server/RequestHandlers/CMakeLists.txt
+++ b/src/Server/RequestHandlers/CMakeLists.txt
@@ -1,10 +1,8 @@
include_directories(${INCLUDES})
add_library(ServerRequestHandlers STATIC
- DaemonListRequestHandler.cpp DaemonListRequestHandler.h
+ ConnectionRequestHandlerGroup.cpp ConnectionRequestHandlerGroup.h
DaemonRequestHandlerGroup.cpp DaemonRequestHandlerGroup.h
- IdentifyRequestHandler.cpp IdentifyRequestHandler.h
- LogRequestHandler.cpp LogRequestHandler.h
UserRequestHandlerGroup.cpp UserRequestHandlerGroup.h
)
target_link_libraries(ServerRequestHandlers Server ${KRB5_LIBRARIES})
diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp
new file mode 100644
index 0000000..3af5439
--- /dev/null
+++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp
@@ -0,0 +1,79 @@
+/*
+ * ConnectionRequestHandlerGroup.cpp
+ *
+ * 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/>.
+ */
+
+#include "ConnectionRequestHandlerGroup.h"
+#include "../Application.h"
+#include "../ConnectionManager.h"
+
+#include <Core/LogManager.h>
+
+namespace Mad {
+namespace Server {
+namespace RequestHandlers {
+
+void ConnectionRequestHandlerGroup::handleDaemonListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret,
+ Common::Connection *connection _UNUSED_PARAMETER_) {
+ // TODO Require authentication
+
+ ret->setType("OK");
+ ret->addList("hosts");
+
+ std::vector<Common::HostInfo> daemons = application->getConnectionManager()->getDaemonList();
+
+ for(std::vector<Common::HostInfo>::iterator daemon = daemons.begin(); daemon != daemons.end(); ++daemon) {
+ (*ret)["hosts"].addEntry();
+
+ (*ret)["hosts"].back().add("name", daemon->getName());
+ (*ret)["hosts"].back().add("address", daemon->getIP());
+ (*ret)["hosts"].back().add("state", daemon->getState());
+ }
+}
+
+void ConnectionRequestHandlerGroup::handleIdentifyRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) {
+ if((*packet)["hostname"].isEmpty())
+ application->getConnectionManager()->identifyClientConnection(connection);
+ else
+ application->getConnectionManager()->identifyDaemonConnection(connection, (*packet)["hostname"]);
+
+ ret->setType("OK");
+}
+
+void ConnectionRequestHandlerGroup::handleLogRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) {
+ // TODO Require authentication
+
+ try {
+ application->getLogManager()->log((*packet)["category"], (*packet)["level"], (*packet)["timestamp"], (*packet)["message"],
+ application->getConnectionManager()->getDaemonName(connection));
+ }
+ catch(Core::Exception &e) {
+ application->logf(Core::LoggerBase::ERROR, "Can't determine daemon name: %s", e.strerror().c_str());
+ }
+
+ ret->setType("OK");
+}
+
+ConnectionRequestHandlerGroup::ConnectionRequestHandlerGroup(Application *application0) : application(application0) {
+ registerHandler("ListHosts", boost::bind(&ConnectionRequestHandlerGroup::handleDaemonListRequest, this, _1, _2, _3));
+ registerHandler("Identify", boost::bind(&ConnectionRequestHandlerGroup::handleIdentifyRequest, this, _1, _2, _3));
+ registerHandler("Log", boost::bind(&ConnectionRequestHandlerGroup::handleLogRequest, this, _1, _2, _3));
+}
+
+}
+}
+}
diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.h b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.h
new file mode 100644
index 0000000..6efa021
--- /dev/null
+++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.h
@@ -0,0 +1,48 @@
+/*
+ * ConnectionRequestHandlerGroup.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_SERVER_REQUESTHANDLERS_CONNECTIONREQUESTHANDLERGROUP_H_
+#define MAD_SERVER_REQUESTHANDLERS_CONNECTIONREQUESTHANDLERGROUP_H_
+
+#include <Common/RequestHandlers/SimpleRequestHandlerGroup.h>
+
+namespace Mad {
+namespace Server {
+
+class Application;
+
+namespace RequestHandlers {
+
+class ConnectionRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHandlerGroup {
+ private:
+ Application *application;
+
+ void handleDaemonListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
+ void handleIdentifyRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
+ void handleLogRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
+
+ public:
+ ConnectionRequestHandlerGroup(Application *application0);
+};
+
+}
+}
+}
+
+#endif /* MAD_SERVER_REQUESTHANDLERS_CONNECTIONREQUESTHANDLERGROUP_H_ */
diff --git a/src/Server/RequestHandlers/DaemonListRequestHandler.cpp b/src/Server/RequestHandlers/DaemonListRequestHandler.cpp
deleted file mode 100644
index fc6900c..0000000
--- a/src/Server/RequestHandlers/DaemonListRequestHandler.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * DaemonListRequestHandler.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 "DaemonListRequestHandler.h"
-#include "../ConnectionManager.h"
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-void DaemonListRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret) {
- // TODO Require authentication
-
- ret->setType("OK");
- ret->addList("hosts");
-
- std::vector<Common::HostInfo> daemons = ConnectionManager::get()->getDaemonList();
-
- for(std::vector<Common::HostInfo>::iterator daemon = daemons.begin(); daemon != daemons.end(); ++daemon) {
- (*ret)["hosts"].addEntry();
-
- (*ret)["hosts"].back().add("name", daemon->getName());
- (*ret)["hosts"].back().add("address", daemon->getIP());
- (*ret)["hosts"].back().add("state", daemon->getState());
- }
-}
-
-}
-}
-}
diff --git a/src/Server/RequestHandlers/DaemonListRequestHandler.h b/src/Server/RequestHandlers/DaemonListRequestHandler.h
deleted file mode 100644
index 45eebc8..0000000
--- a/src/Server/RequestHandlers/DaemonListRequestHandler.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * DaemonListRequestHandler.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_SERVER_REQUESTHANDLERS_DAEMONLISTREQUESTHANDLER_H_
-#define MAD_SERVER_REQUESTHANDLERS_DAEMONLISTREQUESTHANDLER_H_
-
-#include <Common/RequestHandlers/SimpleRequestHandler.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-class DaemonListRequestHandler : public Common::RequestHandlers::SimpleRequestHandler {
- private:
- static void handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
-
- public:
- DaemonListRequestHandler() : Common::RequestHandlers::SimpleRequestHandler("ListHosts", &DaemonListRequestHandler::handleRequest) {}
-};
-
-}
-}
-}
-
-#endif /* MAD_SERVER_REQUESTHANDLERS_DAEMONLISTREQUESTHANDLER_H_ */
diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp
index 0e21fdd..344cf4c 100644
--- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp
+++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp
@@ -18,10 +18,11 @@
*/
#include "DaemonRequestHandlerGroup.h"
+#include "../Application.h"
#include "../ConnectionManager.h"
#include "../Requests/CommandRequest.h"
-#include <Core/Logger.h>
+#include <Common/RequestManager.h>
#include <Common/Requests/FSInfoRequest.h>
#include <Common/Requests/StatusRequest.h>
@@ -31,7 +32,7 @@ namespace RequestHandlers {
void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) {
if(packet->getType() != type) {
- Core::Logger::log(Core::Logger::ERROR, "Received an unexpected packet.");
+ getApplication()->log(Core::LoggerBase::ERROR, "Received an unexpected packet.");
Common::XmlPacket ret;
ret.setType("Error");
@@ -46,18 +47,18 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared
// TODO Require authentication
try {
- boost::shared_ptr<Common::Connection> daemonCon = ConnectionManager::get()->getDaemonConnection((*packet)["daemon"]);
+ boost::shared_ptr<Common::Connection> daemonCon = dynamic_cast<Application&>(*getApplication()).getConnectionManager()->getDaemonConnection((*packet)["daemon"]);
boost::shared_ptr<Common::Request> request;
if(type == "DaemonCommand")
- request.reset(new Requests::CommandRequest((std::string&)((*packet)["command"]) == "reboot"));
+ request.reset(new Requests::CommandRequest(getApplication(), (std::string&)((*packet)["command"]) == "reboot"));
else if(type == "DaemonFSInfo")
- request.reset(new Common::Requests::FSInfoRequest);
+ request.reset(new Common::Requests::FSInfoRequest(getApplication()));
else // type == "GetDaemonStatus"
- request.reset(new Common::Requests::StatusRequest);
+ request.reset(new Common::Requests::StatusRequest(getApplication()));
request->connectSignalFinished(boost::bind(&DaemonRequestHandlerGroup::DaemonRequestHandler::requestFinished, this, _1, _2));
- Common::RequestManager::get()->sendRequest(daemonCon.get(), request);
+ getRequestManager()->sendRequest(daemonCon.get(), request);
}
catch(Core::Exception &e) {
Common::XmlPacket ret;
@@ -97,11 +98,11 @@ DaemonRequestHandlerGroup::DaemonRequestHandlerGroup() {
types.insert("GetDaemonStatus");
}
-boost::shared_ptr<Common::RequestHandler> DaemonRequestHandlerGroup::createRequestHandler(const std::string &type) {
+boost::shared_ptr<Common::RequestHandler> DaemonRequestHandlerGroup::createRequestHandler(Common::Application *application, const std::string &type) {
if(types.find(type) == types.end())
return boost::shared_ptr<Common::RequestHandler>();
else
- return boost::shared_ptr<DaemonRequestHandler>(new DaemonRequestHandler(type));
+ return boost::shared_ptr<DaemonRequestHandler>(new DaemonRequestHandler(application, type));
}
}
diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h
index 7a709f4..524baac 100644
--- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h
+++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h
@@ -25,6 +25,8 @@
namespace Mad {
namespace Server {
+class ConnectionManager;
+
namespace RequestHandlers {
class DaemonRequestHandlerGroup : public Common::RequestHandlerGroup {
@@ -39,9 +41,12 @@ class DaemonRequestHandlerGroup : public Common::RequestHandlerGroup {
virtual void handlePacket(boost::shared_ptr<const Common::XmlPacket> packet);
public:
- DaemonRequestHandler(const std::string &type0) : type(type0) {}
+ DaemonRequestHandler(Common::Application *application, const std::string &type0)
+ : Common::RequestHandler(application), type(type0) {}
};
+ ConnectionManager *connectionManager;
+
std::set<std::string> types;
public:
@@ -51,7 +56,7 @@ class DaemonRequestHandlerGroup : public Common::RequestHandlerGroup {
return types;
}
- virtual boost::shared_ptr<Common::RequestHandler> createRequestHandler(const std::string &type);
+ virtual boost::shared_ptr<Common::RequestHandler> createRequestHandler(Common::Application *application, const std::string &type);
};
}
diff --git a/src/Server/RequestHandlers/IdentifyRequestHandler.cpp b/src/Server/RequestHandlers/IdentifyRequestHandler.cpp
deleted file mode 100644
index e48563b..0000000
--- a/src/Server/RequestHandlers/IdentifyRequestHandler.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * IdentifyRequestHandler.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 "IdentifyRequestHandler.h"
-#include "../ConnectionManager.h"
-
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-void IdentifyRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret) {
- if((*packet)["hostname"].isEmpty())
- ConnectionManager::get()->identifyClientConnection(getConnection());
- else
- ConnectionManager::get()->identifyDaemonConnection(getConnection(), (*packet)["hostname"]);
-
- ret->setType("OK");
-}
-
-}
-}
-}
diff --git a/src/Server/RequestHandlers/IdentifyRequestHandler.h b/src/Server/RequestHandlers/IdentifyRequestHandler.h
deleted file mode 100644
index d9954a3..0000000
--- a/src/Server/RequestHandlers/IdentifyRequestHandler.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * IdentifyRequestHandler.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_SERVER_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_
-#define MAD_SERVER_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_
-
-#include <Common/RequestHandlers/SimpleRequestHandler.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-class IdentifyRequestHandler : public Common::RequestHandlers::SimpleRequestHandler {
- private:
- void handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
-
- public:
- IdentifyRequestHandler() : Common::RequestHandlers::SimpleRequestHandler("Identify", boost::bind(&IdentifyRequestHandler::handleRequest, this, _1, _2)) {}
-};
-
-}
-}
-}
-
-#endif /* MAD_SERVER_REQUESTHANDLERS_IDENTIFYREQUESTHANDLER_H_ */
diff --git a/src/Server/RequestHandlers/LogRequestHandler.cpp b/src/Server/RequestHandlers/LogRequestHandler.cpp
deleted file mode 100644
index f33aad4..0000000
--- a/src/Server/RequestHandlers/LogRequestHandler.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * LogRequestHandler.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 "LogRequestHandler.h"
-#include <Core/LogManager.h>
-#include "../ConnectionManager.h"
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-void LogRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret) {
- // TODO Require authentication
-
- try {
- Core::LogManager::get()->log((*packet)["category"], (*packet)["level"], (*packet)["timestamp"], (*packet)["message"],
- ConnectionManager::get()->getDaemonName(getConnection()));
- }
- catch(Core::Exception &e) {
- Core::Logger::logf(Core::Logger::ERROR, "Can't determine daemon name: %s", e.strerror().c_str());
- }
-
- ret->setType("OK");
-}
-
-}
-}
-}
diff --git a/src/Server/RequestHandlers/LogRequestHandler.h b/src/Server/RequestHandlers/LogRequestHandler.h
deleted file mode 100644
index cf1ce34..0000000
--- a/src/Server/RequestHandlers/LogRequestHandler.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * LogRequestHandler.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_SERVER_REQUESTHANDLERS_LOGREQUESTHANDLER_H_
-#define MAD_SERVER_REQUESTHANDLERS_LOGREQUESTHANDLER_H_
-
-#include <Common/RequestHandlers/SimpleRequestHandler.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-class LogRequestHandler : public Common::RequestHandlers::SimpleRequestHandler {
- private:
- void handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
-
- public:
- LogRequestHandler() : Common::RequestHandlers::SimpleRequestHandler("Log", boost::bind(&LogRequestHandler::handleRequest, this, _1, _2)) {}
-};
-
-}
-}
-}
-
-#endif /* MAD_SERVER_REQUESTHANDLERS_LOGREQUESTHANDLER_H_ */
diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
index 7836c34..3aaa576 100644
--- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
+++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
@@ -18,14 +18,16 @@
*/
#include "UserRequestHandlerGroup.h"
+#include "../Application.h"
#include "../UserManager.h"
namespace Mad {
namespace Server {
namespace RequestHandlers {
-void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret) {
- boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > info = UserManager::get()->getUserList();
+void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret,
+ Common::Connection *connection _UNUSED_PARAMETER_) {
+ boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > info = application->getUserManager()->getUserList();
ret->setType("OK");
ret->addList("users");
@@ -41,8 +43,9 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Comm
}
}
-void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret) {
- boost::shared_ptr<Common::UserInfo> info = UserManager::get()->getUserInfo((*packet)["uid"]);
+void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
+ Common::Connection *connection _UNUSED_PARAMETER_) {
+ boost::shared_ptr<Common::UserInfo> info = application->getUserManager()->getUserInfo((*packet)["uid"]);
ret->setType("OK");
@@ -52,8 +55,9 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Comm
ret->add("fullName", info->getFullName());
}
-void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret) {
- boost::shared_ptr<std::set<unsigned long> > groups = UserManager::get()->getUserGroupList((unsigned long)(*packet)["uid"]);
+void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
+ Common::Connection *connection _UNUSED_PARAMETER_) {
+ boost::shared_ptr<std::set<unsigned long> > groups = application->getUserManager()->getUserGroupList((unsigned long)(*packet)["uid"]);
ret->setType("OK");
ret->addList("groups");
@@ -66,8 +70,9 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const
}
}
-void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret) {
- boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > info = UserManager::get()->getGroupList();
+void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret,
+ Common::Connection *connection _UNUSED_PARAMETER_) {
+ boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > info = application->getUserManager()->getGroupList();
ret->setType("OK");
ret->addList("groups");
@@ -81,8 +86,9 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Com
}
}
-void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret) {
- boost::shared_ptr<std::set<unsigned long> > users = UserManager::get()->getGroupUserList((unsigned long)(*packet)["gid"]);
+void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
+ Common::Connection *connection _UNUSED_PARAMETER_) {
+ boost::shared_ptr<std::set<unsigned long> > users = application->getUserManager()->getGroupUserList((unsigned long)(*packet)["gid"]);
ret->setType("OK");
ret->addList("users");
@@ -95,12 +101,12 @@ void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const
}
}
-UserRequestHandlerGroup::UserRequestHandlerGroup() {
- registerHandler("ListUsers", &UserRequestHandlerGroup::handleUserListRequest);
- registerHandler("GetUserInfo", &UserRequestHandlerGroup::handleUserInfoRequest);
- registerHandler("ListUserGroups", &UserRequestHandlerGroup::handleUserGroupListRequest);
- registerHandler("ListGroups", &UserRequestHandlerGroup::handleGroupListRequest);
- registerHandler("ListGroupUsers", &UserRequestHandlerGroup::handleGroupUserListRequest);
+UserRequestHandlerGroup::UserRequestHandlerGroup(Application *application0) : application(application0) {
+ registerHandler("ListUsers", boost::bind(&UserRequestHandlerGroup::handleUserListRequest, this, _1, _2, _3));
+ registerHandler("GetUserInfo", boost::bind(&UserRequestHandlerGroup::handleUserInfoRequest, this, _1, _2, _3));
+ registerHandler("ListUserGroups", boost::bind(&UserRequestHandlerGroup::handleUserGroupListRequest, this, _1, _2, _3));
+ registerHandler("ListGroups", boost::bind(&UserRequestHandlerGroup::handleGroupListRequest, this, _1, _2, _3));
+ registerHandler("ListGroupUsers", boost::bind(&UserRequestHandlerGroup::handleGroupUserListRequest, this, _1, _2, _3));
}
}
diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.h b/src/Server/RequestHandlers/UserRequestHandlerGroup.h
index 52965dd..2a17a9a 100644
--- a/src/Server/RequestHandlers/UserRequestHandlerGroup.h
+++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.h
@@ -24,18 +24,23 @@
namespace Mad {
namespace Server {
+
+class Application;
+
namespace RequestHandlers {
class UserRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHandlerGroup {
private:
- static void handleUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
- static void handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
- static void handleUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
- static void handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
- static void handleGroupUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret);
+ Application *application;
+
+ void handleUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
+ void handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
+ void handleUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
+ void handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
+ void handleGroupUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
public:
- UserRequestHandlerGroup();
+ UserRequestHandlerGroup(Application *application0);
};
}