summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Client/CMakeLists.txt5
-rw-r--r--src/Client/Requests/CMakeLists.txt5
-rw-r--r--src/Common/CMakeLists.txt27
-rw-r--r--src/Common/RequestHandlerGroup.h (renamed from src/Server/RequestHandlers/UserGroupListRequestHandler.h)28
-rw-r--r--src/Common/RequestHandlers/CMakeLists.txt4
-rw-r--r--src/Common/RequestManager.cpp25
-rw-r--r--src/Common/RequestManager.h50
-rw-r--r--src/Common/Requests/CMakeLists.txt11
-rw-r--r--src/Daemon/CMakeLists.txt6
-rw-r--r--src/Daemon/RequestHandlers/CMakeLists.txt2
-rw-r--r--src/Daemon/Requests/CMakeLists.txt2
-rw-r--r--src/Net/CMakeLists.txt16
-rw-r--r--src/Server/CMakeLists.txt6
-rw-r--r--src/Server/ConnectionManager.cpp22
-rw-r--r--src/Server/ConnectionManager.h2
-rw-r--r--src/Server/RequestHandlers/CMakeLists.txt14
-rw-r--r--src/Server/RequestHandlers/GroupListRequestHandler.cpp77
-rw-r--r--src/Server/RequestHandlers/GroupListRequestHandler.h38
-rw-r--r--src/Server/RequestHandlers/GroupUserListRequestHandler.cpp74
-rw-r--r--src/Server/RequestHandlers/GroupUserListRequestHandler.h38
-rw-r--r--src/Server/RequestHandlers/UserGroupListRequestHandler.cpp74
-rw-r--r--src/Server/RequestHandlers/UserInfoRequestHandler.cpp71
-rw-r--r--src/Server/RequestHandlers/UserInfoRequestHandler.h38
-rw-r--r--src/Server/RequestHandlers/UserListRequestHandler.cpp77
-rw-r--r--src/Server/RequestHandlers/UserListRequestHandler.h38
-rw-r--r--src/Server/RequestHandlers/UserRequestHandlerGroup.cpp156
-rw-r--r--src/Server/RequestHandlers/UserRequestHandlerGroup.h69
-rw-r--r--src/Server/Requests/CMakeLists.txt5
-rw-r--r--src/modules/FileLogger/CMakeLists.txt2
-rw-r--r--src/modules/SystemBackendPosix/CMakeLists.txt2
-rw-r--r--src/modules/SystemBackendProc/CMakeLists.txt2
-rw-r--r--src/modules/UserBackendMysql/CMakeLists.txt2
32 files changed, 388 insertions, 600 deletions
diff --git a/src/Client/CMakeLists.txt b/src/Client/CMakeLists.txt
index 00b72c5..e86a839 100644
--- a/src/Client/CMakeLists.txt
+++ b/src/Client/CMakeLists.txt
@@ -2,5 +2,8 @@ add_subdirectory(Requests)
include_directories(${INCLUDES})
-add_library(Client CommandParser.cpp InformationManager.cpp)
+add_library(Client
+ CommandParser.cpp CommandParser.h
+ InformationManager.cpp InformationManager.h
+)
target_link_libraries(Client ClientRequests Common)
diff --git a/src/Client/Requests/CMakeLists.txt b/src/Client/Requests/CMakeLists.txt
index ef8b275..86acaf5 100644
--- a/src/Client/Requests/CMakeLists.txt
+++ b/src/Client/Requests/CMakeLists.txt
@@ -1,5 +1,8 @@
include_directories(${INCLUDES})
add_library(ClientRequests STATIC
- DaemonCommandRequest.cpp DaemonFSInfoRequest.cpp DaemonStatusRequest.cpp
+ DaemonCommandRequest.cpp DaemonCommandRequest.h
+ DaemonFSInfoRequest.cpp DaemonFSInfoRequest.h
+ DaemonListRequest.h
+ DaemonStatusRequest.cpp DaemonStatusRequest.h
)
diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt
index de6dfc7..25c3dee 100644
--- a/src/Common/CMakeLists.txt
+++ b/src/Common/CMakeLists.txt
@@ -6,9 +6,28 @@ include_directories(${INCLUDES})
link_directories(${LTDL_LIBRARY_DIR})
add_library(Common
- Base64Encoder.cpp ClientConnection.cpp ConfigEntry.cpp
- ConfigManager.cpp Connection.cpp Initializable.cpp Logger.cpp LogManager.cpp
- ModuleManager.cpp Request.cpp RequestHandler.cpp RequestManager.cpp SystemManager.cpp
- Tokenizer.cpp XmlPacket.cpp
+ Base64Encoder.cpp Base64Encoder.h
+ ClientConnection.cpp ClientConnection.h
+ ConfigEntry.cpp ConfigEntry.h
+ ConfigManager.cpp ConfigManager.h
+ Configurable.h
+ Connection.cpp Connection.h
+ Initializable.cpp Initializable.h
+ GroupInfo.h
+ HostInfo.h
+ Logger.cpp Logger.h
+ LoggerBase.h
+ LogManager.cpp LogManager.h
+ ModuleManager.cpp ModuleManager.h
+ RemoteLogger.h
+ Request.cpp Request.h
+ RequestHandler.cpp RequestHandler.h
+ RequestHandlerGroup.h
+ RequestManager.cpp RequestManager.h
+ SystemBackend.h
+ SystemManager.cpp SystemManager.h
+ Tokenizer.cpp Tokenizer.h
+ UserInfo.h
+ XmlPacket.cpp XmlPacket.h
)
target_link_libraries(Common RequestHandlers Requests Net ${LIBXML2_LIBRARIES} ${LTDL_LIBRARIES})
diff --git a/src/Server/RequestHandlers/UserGroupListRequestHandler.h b/src/Common/RequestHandlerGroup.h
index 35ff2eb..c9f57eb 100644
--- a/src/Server/RequestHandlers/UserGroupListRequestHandler.h
+++ b/src/Common/RequestHandlerGroup.h
@@ -1,5 +1,5 @@
/*
- * UserGroupListRequestHandler.h
+ * RequestHandlerGroup.h
*
* Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
*
@@ -17,22 +17,30 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_SERVER_REQUESTHANDLERS_USERGROUPLISTREQUESTHANDLER_H_
-#define MAD_SERVER_REQUESTHANDLERS_USERGROUPLISTREQUESTHANDLER_H_
+#ifndef MAD_COMMON_REQUESTHANDLERGROUP_H_
+#define MAD_COMMON_REQUESTHANDLERGROUP_H_
-#include <Common/RequestHandler.h>
+#include "RequestHandler.h"
+
+#include <set>
+#include <string>
namespace Mad {
-namespace Server {
-namespace RequestHandlers {
+namespace Common {
-class UserGroupListRequestHandler : public Common::RequestHandler {
+class RequestHandlerGroup {
protected:
- virtual void handlePacket(boost::shared_ptr<const Common::XmlPacket> packet);
+ RequestHandlerGroup() {}
+
+ public:
+ virtual const std::set<std::string>& getPacketTypes() = 0;
+
+ virtual boost::shared_ptr<RequestHandler> createRequestHandler(const std::string &type) = 0;
+ virtual ~RequestHandlerGroup() {}
};
}
-}
+
}
-#endif /* MAD_SERVER_REQUESTHANDLERS_USERGROUPLISTREQUESTHANDLER_H_ */
+#endif /* MAD_COMMON_REQUESTHANDLERGROUP_H_ */
diff --git a/src/Common/RequestHandlers/CMakeLists.txt b/src/Common/RequestHandlers/CMakeLists.txt
index f774e14..5788ada 100644
--- a/src/Common/RequestHandlers/CMakeLists.txt
+++ b/src/Common/RequestHandlers/CMakeLists.txt
@@ -1,6 +1,8 @@
include_directories(${INCLUDES})
add_library(RequestHandlers STATIC
- DisconnectRequestHandler.cpp FSInfoRequestHandler.cpp StatusRequestHandler.cpp
+ DisconnectRequestHandler.cpp DisconnectRequestHandler.h
+ FSInfoRequestHandler.cpp FSInfoRequestHandler.h
+ StatusRequestHandler.cpp StatusRequestHandler.h
)
target_link_libraries(RequestHandlers Common)
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index 3785b3f..b443292 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -108,21 +108,24 @@ void RequestManager::receiveHandler(Connection *connection, boost::shared_ptr<co
return;
}
- std::map<std::string, boost::shared_ptr<RequestHandlerFactory> >::iterator factoryIt = requestHandlerFactories.find(packet->getType());
- if(factoryIt != requestHandlerFactories.end()) {
- {
- boost::upgrade_to_unique_lock<boost::shared_mutex> upgradeLock(lock);
+ std::map<std::string, boost::shared_ptr<RequestHandlerGroup> >::iterator rgh = requestHandlerGroups.find(packet->getType());
+ if(rgh != requestHandlerGroups.end()) {
+ request = rgh->second->createRequestHandler(packet->getType());
- request = factoryIt->second->createRequestHandler();
- requestMap.addRequest(connection, requestId, request);
- request->connectSignalFinished(boost::bind(&RequestManager::handleRequestFinished, this, connection, requestId));
+ if(request) {
+ {
+ boost::upgrade_to_unique_lock<boost::shared_mutex> upgradeLock(lock);
- }
+ requestMap.addRequest(connection, requestId, request);
+ request->connectSignalFinished(boost::bind(&RequestManager::handleRequestFinished, this, connection, requestId));
- lock.unlock();
- Net::ThreadManager::get()->pushWork(boost::bind(&RequestHandler::handlePacket, request, packet));
+ }
- return;
+ lock.unlock();
+ Net::ThreadManager::get()->pushWork(boost::bind(&RequestHandler::handlePacket, request, packet));
+
+ return;
+ }
}
lock.unlock();
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index 07a7c05..e66b0c1 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -21,6 +21,7 @@
#define MAD_COMMON_REQUESTMANAGER_H_
#include "Request.h"
+#include "RequestHandlerGroup.h"
#include <map>
#include <memory>
@@ -69,18 +70,20 @@ class RequestManager : boost::noncopyable {
- class RequestHandlerFactory {
- protected:
- RequestHandlerFactory() {}
+ template<class T> class RequestHandlerFactory : public RequestHandlerGroup {
+ private:
+ std::set<std::string> types;
public:
- virtual boost::shared_ptr<RequestHandler> createRequestHandler() = 0;
- virtual ~RequestHandlerFactory() {}
- };
+ RequestHandlerFactory(const std::string &type) {
+ types.insert(type);
+ }
- template<class T> class SpecificRequestHandlerFactory : public RequestHandlerFactory {
- public:
- virtual boost::shared_ptr<RequestHandler> createRequestHandler() {
+ virtual const std::set<std::string>& getPacketTypes() {
+ return types;
+ }
+
+ virtual boost::shared_ptr<RequestHandler> createRequestHandler(const std::string &type _UNUSED_PARAMETER_) {
return boost::shared_ptr<RequestHandler>(new T());
}
};
@@ -94,7 +97,7 @@ class RequestManager : boost::noncopyable {
bool server;
boost::uint16_t lastRequestId;
- std::map<std::string, boost::shared_ptr<RequestHandlerFactory> > requestHandlerFactories;
+ std::map<std::string, boost::shared_ptr<RequestHandlerGroup> > requestHandlerGroups;
boost::uint16_t _getRequestId() {
return lastRequestId+=2;
@@ -141,14 +144,35 @@ class RequestManager : boost::noncopyable {
requestMap.unregisterConnection(connection);
}
- template <class T> void registerPacketType(const std::string &type) {
+ void registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerGroup> requestHandlerGroup) {
boost::lock_guard<boost::shared_mutex> lock(mutex);
- requestHandlerFactories.insert(std::make_pair(type, boost::shared_ptr<SpecificRequestHandlerFactory<T> >(new SpecificRequestHandlerFactory<T>())));
+
+ const std::set<std::string> &types = requestHandlerGroup->getPacketTypes();
+ for(std::set<std::string>::const_iterator type = types.begin(); type != types.end(); ++type)
+ requestHandlerGroups.insert(std::make_pair(*type, requestHandlerGroup));
+ }
+
+ void unregisterRequestHandlerGroup(boost::shared_ptr<RequestHandlerGroup> requestHandlerGroup) {
+ boost::lock_guard<boost::shared_mutex> lock(mutex);
+
+ const std::set<std::string> &types = requestHandlerGroup->getPacketTypes();
+ for(std::set<std::string>::const_iterator type = types.begin(); type != types.end(); ++type) {
+ std::map<std::string, boost::shared_ptr<RequestHandlerGroup> >::iterator it = requestHandlerGroups.find(*type);
+
+ if(it == requestHandlerGroups.end() || it->second != requestHandlerGroup)
+ continue;
+
+ requestHandlerGroups.erase(it);
+ }
+ }
+
+ template <class T> void registerPacketType(const std::string &type) {
+ registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerFactory<T> >(new RequestHandlerFactory<T>(type)));
}
void unregisterPacketType(const std::string &type) {
boost::lock_guard<boost::shared_mutex> lock(mutex);
- requestHandlerFactories.erase(type);
+ requestHandlerGroups.erase(type);
}
bool sendRequest(Connection *connection, boost::shared_ptr<Request> request);
diff --git a/src/Common/Requests/CMakeLists.txt b/src/Common/Requests/CMakeLists.txt
index ef1d4d9..b6ff90c 100644
--- a/src/Common/Requests/CMakeLists.txt
+++ b/src/Common/Requests/CMakeLists.txt
@@ -1,6 +1,15 @@
include_directories(${INCLUDES})
add_library(Requests STATIC
- DisconnectRequest.cpp GroupUserListRequest.cpp IdentifyRequest.cpp SimpleRequest.cpp UserGroupListRequest.cpp UserInfoRequest.cpp
+ DisconnectRequest.cpp DisconnectRequest.h
+ FSInfoRequest.h
+ GroupListRequest.h
+ GroupUserListRequest.cpp GroupUserListRequest.h
+ IdentifyRequest.cpp IdentifyRequest.h
+ SimpleRequest.cpp SimpleRequest.h
+ StatusRequest.h
+ UserGroupListRequest.cpp UserGroupListRequest.h
+ UserInfoRequest.cpp UserInfoRequest.h
+ UserListRequest.h
)
target_link_libraries(Requests ${KRB5_LIBRARIES})
diff --git a/src/Daemon/CMakeLists.txt b/src/Daemon/CMakeLists.txt
index 4f49d48..68c5f5d 100644
--- a/src/Daemon/CMakeLists.txt
+++ b/src/Daemon/CMakeLists.txt
@@ -3,5 +3,9 @@ add_subdirectory(Requests)
include_directories(${INCLUDES})
-add_library(Daemon Daemon.cpp)
+add_library(Daemon
+ Backends/NetworkLogger.h
+
+ Daemon.cpp
+)
target_link_libraries(Daemon DaemonRequestHandlers DaemonRequests Common)
diff --git a/src/Daemon/RequestHandlers/CMakeLists.txt b/src/Daemon/RequestHandlers/CMakeLists.txt
index 4794405..21a2fbb 100644
--- a/src/Daemon/RequestHandlers/CMakeLists.txt
+++ b/src/Daemon/RequestHandlers/CMakeLists.txt
@@ -1,5 +1,5 @@
include_directories(${INCLUDES})
add_library(DaemonRequestHandlers STATIC
- CommandRequestHandler.cpp
+ CommandRequestHandler.cpp CommandRequestHandler.h
)
diff --git a/src/Daemon/Requests/CMakeLists.txt b/src/Daemon/Requests/CMakeLists.txt
index 9bb941f..90eb542 100644
--- a/src/Daemon/Requests/CMakeLists.txt
+++ b/src/Daemon/Requests/CMakeLists.txt
@@ -1,5 +1,5 @@
include_directories(${INCLUDES})
add_library(DaemonRequests STATIC
- LogRequest.cpp
+ LogRequest.cpp LogRequest.h
)
diff --git a/src/Net/CMakeLists.txt b/src/Net/CMakeLists.txt
index fae358b..6bf700e 100644
--- a/src/Net/CMakeLists.txt
+++ b/src/Net/CMakeLists.txt
@@ -2,7 +2,19 @@ include_directories(${INCLUDES})
link_directories(${Boost_LIBRARY_DIRS})
add_library(Net
- ClientConnection.cpp Connection.cpp Exception.cpp Listener.cpp
- Packet.cpp ThreadManager.cpp
+ Signals/Connection.h
+ Signals/GenericSignal.h
+ Signals/Signal0.h
+ Signals/Signal1.h
+ Signals/Signal2.h
+ Signals/SignalBase.h
+ Signals/Signals.h
+
+ ClientConnection.cpp ClientConnection.h
+ Connection.cpp Connection.h
+ Exception.cpp Exception.h
+ Listener.cpp Listener.h
+ Packet.cpp Packet.h
+ ThreadManager.cpp ThreadManager.h
)
target_link_libraries(Net ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES})
diff --git a/src/Server/CMakeLists.txt b/src/Server/CMakeLists.txt
index 1c5885f..e38d860 100644
--- a/src/Server/CMakeLists.txt
+++ b/src/Server/CMakeLists.txt
@@ -3,5 +3,9 @@ add_subdirectory(Requests)
include_directories(${INCLUDES})
-add_library(Server ConnectionManager.cpp UserManager.cpp)
+add_library(Server
+ ConnectionManager.cpp ConnectionManager.h
+ UserBackend.h
+ UserManager.cpp UserManager.h
+)
target_link_libraries(Server ServerRequestHandlers ServerRequests Common)
diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp
index 3743e43..0a60ff4 100644
--- a/src/Server/ConnectionManager.cpp
+++ b/src/Server/ConnectionManager.cpp
@@ -29,13 +29,9 @@
#include "RequestHandlers/DaemonListRequestHandler.h"
#include "RequestHandlers/DaemonStatusRequestHandler.h"
//#include "RequestHandlers/GSSAPIAuthRequestHandler.h"
-#include "RequestHandlers/GroupListRequestHandler.h"
-#include "RequestHandlers/GroupUserListRequestHandler.h"
#include "RequestHandlers/IdentifyRequestHandler.h"
#include "RequestHandlers/LogRequestHandler.h"
-#include "RequestHandlers/UserGroupListRequestHandler.h"
-#include "RequestHandlers/UserInfoRequestHandler.h"
-#include "RequestHandlers/UserListRequestHandler.h"
+#include "RequestHandlers/UserRequestHandlerGroup.h"
#include <Net/Packet.h>
#include <Net/Listener.h>
@@ -189,6 +185,8 @@ void ConnectionManager::handleDisconnect(boost::shared_ptr<ServerConnection> con
void ConnectionManager::doInit() {
Common::RequestManager::get()->setServer(true);
+ userRequestHandlerGroup.reset(new RequestHandlers::UserRequestHandlerGroup);
+
//Common::RequestManager::get()->registerPacketType<RequestHandlers::GSSAPIAuthRequestHandler>("AuthGSSAPI");
Common::RequestManager::get()->registerPacketType<RequestHandlers::DaemonCommandRequestHandler>("DaemonCommand");
Common::RequestManager::get()->registerPacketType<RequestHandlers::DaemonFSInfoRequestHandler>("DaemonFSInfo");
@@ -197,17 +195,16 @@ void ConnectionManager::doInit() {
Common::RequestManager::get()->registerPacketType<RequestHandlers::DaemonStatusRequestHandler>("GetDaemonStatus");
Common::RequestManager::get()->registerPacketType<RequestHandlers::IdentifyRequestHandler>("Identify");
Common::RequestManager::get()->registerPacketType<RequestHandlers::DaemonListRequestHandler>("ListHosts");
- Common::RequestManager::get()->registerPacketType<RequestHandlers::UserInfoRequestHandler>("GetUserInfo");
- Common::RequestManager::get()->registerPacketType<RequestHandlers::UserListRequestHandler>("ListUsers");
- Common::RequestManager::get()->registerPacketType<RequestHandlers::UserGroupListRequestHandler>("ListUserGroups");
- Common::RequestManager::get()->registerPacketType<RequestHandlers::GroupListRequestHandler>("ListGroups");
- Common::RequestManager::get()->registerPacketType<RequestHandlers::GroupUserListRequestHandler>("ListGroupUsers");
Common::RequestManager::get()->registerPacketType<RequestHandlers::LogRequestHandler>("Log");
+
+ Common::RequestManager::get()->registerRequestHandlerGroup(userRequestHandlerGroup);
}
void ConnectionManager::doDeinit() {
connections.clear();
+ Common::RequestManager::get()->unregisterRequestHandlerGroup(userRequestHandlerGroup);
+
//Common::RequestManager::get()->unregisterPacketType("AuthGSSAPI");
Common::RequestManager::get()->unregisterPacketType("DaemonCommand");
Common::RequestManager::get()->unregisterPacketType("DaemonFSInfo");
@@ -216,11 +213,6 @@ void ConnectionManager::doDeinit() {
Common::RequestManager::get()->unregisterPacketType("GetDaemonStatus");
Common::RequestManager::get()->unregisterPacketType("Identify");
Common::RequestManager::get()->unregisterPacketType("ListHosts");
- Common::RequestManager::get()->unregisterPacketType("GetUserInfo");
- Common::RequestManager::get()->unregisterPacketType("ListUsers");
- Common::RequestManager::get()->unregisterPacketType("ListUserGroups");
- Common::RequestManager::get()->unregisterPacketType("ListGroups");
- Common::RequestManager::get()->unregisterPacketType("ListGroupUsers");
Common::RequestManager::get()->unregisterPacketType("Log");
}
diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h
index 92cce11..0c4e76d 100644
--- a/src/Server/ConnectionManager.h
+++ b/src/Server/ConnectionManager.h
@@ -100,6 +100,8 @@ class ConnectionManager : public Common::Configurable, public Common::Initializa
std::map<std::string,Common::HostInfo> daemonInfo;
+ boost::shared_ptr<Common::RequestHandlerGroup> userRequestHandlerGroup;
+
void updateState(Common::HostInfo *hostInfo, Common::HostInfo::State state);
ConnectionManager() {}
diff --git a/src/Server/RequestHandlers/CMakeLists.txt b/src/Server/RequestHandlers/CMakeLists.txt
index fe4e71d..b57b9fe 100644
--- a/src/Server/RequestHandlers/CMakeLists.txt
+++ b/src/Server/RequestHandlers/CMakeLists.txt
@@ -1,10 +1,12 @@
include_directories(${INCLUDES})
-add_library(ServerRequestHandlers
- DaemonCommandRequestHandler.cpp DaemonFSInfoRequestHandler.cpp
- DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp
- GroupListRequestHandler.cpp GroupUserListRequestHandler.cpp IdentifyRequestHandler.cpp
- LogRequestHandler.cpp UserGroupListRequestHandler.cpp UserInfoRequestHandler.cpp
- UserListRequestHandler.cpp
+add_library(ServerRequestHandlers STATIC
+ DaemonCommandRequestHandler.cpp DaemonCommandRequestHandler.h
+ DaemonFSInfoRequestHandler.cpp DaemonFSInfoRequestHandler.h
+ DaemonListRequestHandler.cpp DaemonListRequestHandler.h
+ DaemonStatusRequestHandler.cpp DaemonStatusRequestHandler.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/GroupListRequestHandler.cpp b/src/Server/RequestHandlers/GroupListRequestHandler.cpp
deleted file mode 100644
index 453f4c2..0000000
--- a/src/Server/RequestHandlers/GroupListRequestHandler.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * GroupListRequestHandler.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 "GroupListRequestHandler.h"
-#include "../UserManager.h"
-#include <Net/Exception.h>
-#include <Common/Logger.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-void GroupListRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) {
- if(packet->getType() != "ListGroups") {
- Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
-
- Common::XmlPacket ret;
- ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
-
- sendPacket(ret);
-
- signalFinished();
- return;
- }
-
- // TODO Require authentication
-
-
-
- Common::XmlPacket ret;
-
- try {
- boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > info = UserManager::get()->getGroupList();
-
- ret.setType("OK");
- ret.addList("groups");
-
- for(std::map<unsigned long, Common::GroupInfo>::iterator group = info->begin(); group != info->end(); ++group) {
- ret["groups"].addEntry();
- Common::XmlPacket::Entry &entry = ret["groups"].back();
-
- entry.add("gid", group->second.getGid());
- entry.add("name", group->second.getName());
- }
- }
- catch(Net::Exception e) {
- ret.setType("Error");
- ret.add("ErrorCode", e.getErrorCode());
- ret.add("SubCode", e.getSubCode());
- ret.add("SubSubCode", e.getSubSubCode());
- ret.add("Where", e.getWhere());
- }
-
- sendPacket(ret);
- signalFinished();
-}
-
-}
-}
-}
diff --git a/src/Server/RequestHandlers/GroupListRequestHandler.h b/src/Server/RequestHandlers/GroupListRequestHandler.h
deleted file mode 100644
index 8654708..0000000
--- a/src/Server/RequestHandlers/GroupListRequestHandler.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * GroupListRequestHandler.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_GROUPLISTREQUESTHANDLER_H_
-#define MAD_SERVER_REQUESTHANDLERS_GROUPLISTREQUESTHANDLER_H_
-
-#include <Common/RequestHandler.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-class GroupListRequestHandler : public Common::RequestHandler {
- protected:
- virtual void handlePacket(boost::shared_ptr<const Common::XmlPacket> packet);
-};
-
-}
-}
-}
-
-#endif /* MAD_SERVER_REQUESTHANDLERS_GROUPLISTREQUESTHANDLER_H_ */
diff --git a/src/Server/RequestHandlers/GroupUserListRequestHandler.cpp b/src/Server/RequestHandlers/GroupUserListRequestHandler.cpp
deleted file mode 100644
index f862e8b..0000000
--- a/src/Server/RequestHandlers/GroupUserListRequestHandler.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * GroupUserListRequestHandler.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 "GroupUserListRequestHandler.h"
-#include "../UserManager.h"
-#include <Net/Exception.h>
-#include <Common/Logger.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-void GroupUserListRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) {
- if(packet->getType() != "ListGroupUsers") {
- Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
-
- Common::XmlPacket ret;
- ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
-
- sendPacket(ret);
-
- signalFinished();
- return;
- }
-
- // TODO Require authentication
-
- Common::XmlPacket ret;
-
- try {
- boost::shared_ptr<std::set<unsigned long> > users = UserManager::get()->getGroupUserList((unsigned long)(*packet)["gid"]);
-
- ret.setType("OK");
- ret.addList("users");
-
- for(std::set<unsigned long>::iterator user = users->begin(); user != users->end(); ++user) {
- ret["users"].addEntry();
- Common::XmlPacket::Entry &entry = ret["users"].back();
-
- entry.add("uid", *user);
- }
- }
- catch(Net::Exception e) {
- ret.setType("Error");
- ret.add("ErrorCode", e.getErrorCode());
- ret.add("SubCode", e.getSubCode());
- ret.add("SubSubCode", e.getSubSubCode());
- ret.add("Where", e.getWhere());
- }
-
- sendPacket(ret);
- signalFinished();
-}
-
-}
-}
-}
diff --git a/src/Server/RequestHandlers/GroupUserListRequestHandler.h b/src/Server/RequestHandlers/GroupUserListRequestHandler.h
deleted file mode 100644
index 2220565..0000000
--- a/src/Server/RequestHandlers/GroupUserListRequestHandler.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * GroupUserListRequestHandler.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_GROUPUSERLISTREQUESTHANDLER_H_
-#define MAD_SERVER_REQUESTHANDLERS_GROUPUSERLISTREQUESTHANDLER_H_
-
-#include <Common/RequestHandler.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-class GroupUserListRequestHandler : public Common::RequestHandler {
- protected:
- virtual void handlePacket(boost::shared_ptr<const Common::XmlPacket> packet);
-};
-
-}
-}
-}
-
-#endif /* MAD_SERVER_REQUESTHANDLERS_GROUPUSERLISTREQUESTHANDLER_H_ */
diff --git a/src/Server/RequestHandlers/UserGroupListRequestHandler.cpp b/src/Server/RequestHandlers/UserGroupListRequestHandler.cpp
deleted file mode 100644
index f5a3f7e..0000000
--- a/src/Server/RequestHandlers/UserGroupListRequestHandler.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * UserGroupListRequestHandler.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 "UserGroupListRequestHandler.h"
-#include "../UserManager.h"
-#include <Net/Exception.h>
-#include <Common/Logger.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-void UserGroupListRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) {
- if(packet->getType() != "ListUserGroups") {
- Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
-
- Common::XmlPacket ret;
- ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
-
- sendPacket(ret);
-
- signalFinished();
- return;
- }
-
- // TODO Require authentication
-
- Common::XmlPacket ret;
-
- try {
- boost::shared_ptr<std::set<unsigned long> > groups = UserManager::get()->getUserGroupList((unsigned long)(*packet)["uid"]);
-
- ret.setType("OK");
- ret.addList("groups");
-
- for(std::set<unsigned long>::iterator group = groups->begin(); group != groups->end(); ++group) {
- ret["groups"].addEntry();
- Common::XmlPacket::Entry &entry = ret["groups"].back();
-
- entry.add("gid", *group);
- }
- }
- catch(Net::Exception e) {
- ret.setType("Error");
- ret.add("ErrorCode", e.getErrorCode());
- ret.add("SubCode", e.getSubCode());
- ret.add("SubSubCode", e.getSubSubCode());
- ret.add("Where", e.getWhere());
- }
-
- sendPacket(ret);
- signalFinished();
-}
-
-}
-}
-}
diff --git a/src/Server/RequestHandlers/UserInfoRequestHandler.cpp b/src/Server/RequestHandlers/UserInfoRequestHandler.cpp
deleted file mode 100644
index e9e0716..0000000
--- a/src/Server/RequestHandlers/UserInfoRequestHandler.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * UserInfoRequestHandler.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 "UserInfoRequestHandler.h"
-#include "../UserManager.h"
-#include <Net/Exception.h>
-#include <Common/Logger.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-void UserInfoRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) {
- if(packet->getType() != "GetUserInfo") {
- Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
-
- Common::XmlPacket ret;
- ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
-
- sendPacket(ret);
-
- signalFinished();
- return;
- }
-
- // TODO Require authentication
-
- Common::XmlPacket ret;
-
- try {
- boost::shared_ptr<Common::UserInfo> info = UserManager::get()->getUserInfo((*packet)["uid"]);
-
- ret.setType("OK");
-
- ret.add("uid", info->getUid());
- ret.add("gid", info->getGid());
- ret.add("username", info->getUsername());
- ret.add("fullName", info->getFullName());
- }
- catch(Net::Exception e) {
- ret.setType("Error");
- ret.add("ErrorCode", e.getErrorCode());
- ret.add("SubCode", e.getSubCode());
- ret.add("SubSubCode", e.getSubSubCode());
- ret.add("Where", e.getWhere());
- }
-
- sendPacket(ret);
- signalFinished();
-}
-
-}
-}
-}
diff --git a/src/Server/RequestHandlers/UserInfoRequestHandler.h b/src/Server/RequestHandlers/UserInfoRequestHandler.h
deleted file mode 100644
index af11678..0000000
--- a/src/Server/RequestHandlers/UserInfoRequestHandler.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * UserInfoRequestHandler.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_USERINFOREQUESTHANDLER_H_
-#define MAD_SERVER_REQUESTHANDLERS_USERINFOREQUESTHANDLER_H_
-
-#include <Common/RequestHandler.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-class UserInfoRequestHandler : public Common::RequestHandler {
- protected:
- virtual void handlePacket(boost::shared_ptr<const Common::XmlPacket> packet);
-};
-
-}
-}
-}
-
-#endif /* MAD_SERVER_REQUESTHANDLERS_USERINFOREQUESTHANDLER_H_ */
diff --git a/src/Server/RequestHandlers/UserListRequestHandler.cpp b/src/Server/RequestHandlers/UserListRequestHandler.cpp
deleted file mode 100644
index 4164f22..0000000
--- a/src/Server/RequestHandlers/UserListRequestHandler.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * UserListRequestHandler.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 "UserListRequestHandler.h"
-#include "../UserManager.h"
-#include <Net/Exception.h>
-#include <Common/Logger.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-void UserListRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) {
- if(packet->getType() != "ListUsers") {
- Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
-
- Common::XmlPacket ret;
- ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
-
- sendPacket(ret);
-
- signalFinished();
- return;
- }
-
- // TODO Require authentication
-
- Common::XmlPacket ret;
-
- try {
- boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > info = UserManager::get()->getUserList();
-
- ret.setType("OK");
- ret.addList("users");
-
- for(std::map<unsigned long, Common::UserInfo>::iterator user = info->begin(); user != info->end(); ++user) {
- ret["users"].addEntry();
- Common::XmlPacket::Entry &entry = ret["users"].back();
-
- entry.add("uid", user->second.getUid());
- entry.add("gid", user->second.getGid());
- entry.add("username", user->second.getUsername());
- entry.add("fullName", user->second.getFullName());
- }
- }
- catch(Net::Exception e) {
- ret.setType("Error");
- ret.add("ErrorCode", e.getErrorCode());
- ret.add("SubCode", e.getSubCode());
- ret.add("SubSubCode", e.getSubSubCode());
- ret.add("Where", e.getWhere());
- }
-
- sendPacket(ret);
- signalFinished();
-}
-
-}
-}
-}
diff --git a/src/Server/RequestHandlers/UserListRequestHandler.h b/src/Server/RequestHandlers/UserListRequestHandler.h
deleted file mode 100644
index 36cef00..0000000
--- a/src/Server/RequestHandlers/UserListRequestHandler.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * UserListRequestHandler.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_USERLISTREQUESTHANDLER_H_
-#define MAD_SERVER_REQUESTHANDLERS_USERLISTREQUESTHANDLER_H_
-
-#include <Common/RequestHandler.h>
-
-namespace Mad {
-namespace Server {
-namespace RequestHandlers {
-
-class UserListRequestHandler : public Common::RequestHandler {
- protected:
- virtual void handlePacket(boost::shared_ptr<const Common::XmlPacket> packet);
-};
-
-}
-}
-}
-
-#endif /* MAD_SERVER_REQUESTHANDLERS_USERLISTREQUESTHANDLER_H_ */
diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
new file mode 100644
index 0000000..1b6dd3d
--- /dev/null
+++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
@@ -0,0 +1,156 @@
+/*
+ * UserRequestHandlerGroup.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 "UserRequestHandlerGroup.h"
+
+#include <Common/Logger.h>
+#include "../UserManager.h"
+
+namespace Mad {
+namespace Server {
+namespace RequestHandlers {
+
+void UserRequestHandlerGroup::RequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) {
+ if(packet->getType() != type) {
+ Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
+
+ Common::XmlPacket ret;
+ ret.setType("Error");
+ ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
+
+ sendPacket(ret);
+
+ signalFinished();
+ return;
+ }
+
+ // TODO Require authentication
+
+ Common::XmlPacket ret;
+
+ try {
+ handler(packet, &ret);
+ }
+ catch(Net::Exception e) {
+ ret.setType("Error");
+ ret.add("ErrorCode", e.getErrorCode());
+ ret.add("SubCode", e.getSubCode());
+ ret.add("SubSubCode", e.getSubSubCode());
+ ret.add("Where", e.getWhere());
+ }
+
+ sendPacket(ret);
+ signalFinished();
+}
+
+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();
+
+ ret->setType("OK");
+ ret->addList("users");
+
+ for(std::map<unsigned long, Common::UserInfo>::iterator user = info->begin(); user != info->end(); ++user) {
+ (*ret)["users"].addEntry();
+ Common::XmlPacket::Entry &entry = (*ret)["users"].back();
+
+ entry.add("uid", user->second.getUid());
+ entry.add("gid", user->second.getGid());
+ entry.add("username", user->second.getUsername());
+ entry.add("fullName", user->second.getFullName());
+ }
+}
+
+void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret) {
+ boost::shared_ptr<Common::UserInfo> info = UserManager::get()->getUserInfo((*packet)["uid"]);
+
+ ret->setType("OK");
+
+ ret->add("uid", info->getUid());
+ ret->add("gid", info->getGid());
+ ret->add("username", info->getUsername());
+ 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"]);
+
+ ret->setType("OK");
+ ret->addList("groups");
+
+ for(std::set<unsigned long>::iterator group = groups->begin(); group != groups->end(); ++group) {
+ (*ret)["groups"].addEntry();
+ Common::XmlPacket::Entry &entry = (*ret)["groups"].back();
+
+ entry.add("gid", *group);
+ }
+}
+
+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();
+
+ ret->setType("OK");
+ ret->addList("groups");
+
+ for(std::map<unsigned long, Common::GroupInfo>::iterator group = info->begin(); group != info->end(); ++group) {
+ (*ret)["groups"].addEntry();
+ Common::XmlPacket::Entry &entry = (*ret)["groups"].back();
+
+ entry.add("gid", group->second.getGid());
+ entry.add("name", group->second.getName());
+ }
+}
+
+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"]);
+
+ ret->setType("OK");
+ ret->addList("users");
+
+ for(std::set<unsigned long>::iterator user = users->begin(); user != users->end(); ++user) {
+ (*ret)["users"].addEntry();
+ Common::XmlPacket::Entry &entry = (*ret)["users"].back();
+
+ entry.add("uid", *user);
+ }
+}
+
+UserRequestHandlerGroup::UserRequestHandlerGroup() {
+ registerHandler("ListUsers", &UserRequestHandlerGroup::handleUserListRequest);
+ registerHandler("GetUserInfo", &UserRequestHandlerGroup::handleUserInfoRequest);
+ registerHandler("ListUserGroups", &UserRequestHandlerGroup::handleUserGroupListRequest);
+ registerHandler("ListGroups", &UserRequestHandlerGroup::handleGroupListRequest);
+ registerHandler("ListGroupUsers", &UserRequestHandlerGroup::handleGroupUserListRequest);
+}
+
+const std::set<std::string>& UserRequestHandlerGroup::getPacketTypes() {
+ return types;
+}
+
+boost::shared_ptr<Common::RequestHandler> UserRequestHandlerGroup::createRequestHandler(const std::string &type) {
+ std::map<std::string, boost::function2<void, boost::shared_ptr<const Common::XmlPacket>, Common::XmlPacket*> >::iterator handler = handlers.find(type);
+
+ if(handler == handlers.end())
+ return boost::shared_ptr<Common::RequestHandler>();
+ else
+ return boost::shared_ptr<RequestHandler>(new RequestHandler(type, handler->second));
+}
+
+}
+}
+}
diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.h b/src/Server/RequestHandlers/UserRequestHandlerGroup.h
new file mode 100644
index 0000000..c24d502
--- /dev/null
+++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.h
@@ -0,0 +1,69 @@
+/*
+ * UserRequestHandlerGroup.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_USERREQUESTHANDLERGROUP_H_
+#define MAD_SERVER_REQUESTHANDLERS_USERREQUESTHANDLERGROUP_H_
+
+#include <Common/RequestHandlerGroup.h>
+
+namespace Mad {
+namespace Server {
+namespace RequestHandlers {
+
+class UserRequestHandlerGroup : public Common::RequestHandlerGroup {
+ private:
+ class RequestHandler : public Common::RequestHandler {
+ private:
+ std::string type;
+ boost::function2<void, boost::shared_ptr<const Common::XmlPacket>, Common::XmlPacket*> handler;
+
+ protected:
+ virtual void handlePacket(boost::shared_ptr<const Common::XmlPacket> packet);
+
+ public:
+ RequestHandler(const std::string &type0, const boost::function2<void, boost::shared_ptr<const Common::XmlPacket>, Common::XmlPacket*> &handler0) : type(type0), handler(handler0) {}
+ };
+
+
+ std::set<std::string> types;
+ std::map<std::string, boost::function2<void, boost::shared_ptr<const Common::XmlPacket>, Common::XmlPacket*> > handlers;
+
+ void registerHandler(const std::string &type, const boost::function2<void, boost::shared_ptr<const Common::XmlPacket>, Common::XmlPacket*> &handler) {
+ types.insert(type);
+ handlers.insert(std::make_pair(type, handler));
+ }
+
+ 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);
+
+ public:
+ UserRequestHandlerGroup();
+
+ virtual const std::set<std::string>& getPacketTypes();
+ virtual boost::shared_ptr<Common::RequestHandler> createRequestHandler(const std::string &type);
+};
+
+}
+}
+}
+
+#endif /* MAD_SERVER_REQUESTHANDLERS_USERREQUESTHANDLERGROUP_H_ */
diff --git a/src/Server/Requests/CMakeLists.txt b/src/Server/Requests/CMakeLists.txt
index 5522809..6c5c8c5 100644
--- a/src/Server/Requests/CMakeLists.txt
+++ b/src/Server/Requests/CMakeLists.txt
@@ -1,5 +1,6 @@
include_directories(${INCLUDES})
-add_library(ServerRequests
- CommandRequest.cpp DaemonStateUpdateRequest.cpp
+add_library(ServerRequests STATIC
+ CommandRequest.cpp CommandRequest.h
+ DaemonStateUpdateRequest.cpp DaemonStateUpdateRequest.h
)
diff --git a/src/modules/FileLogger/CMakeLists.txt b/src/modules/FileLogger/CMakeLists.txt
index 39459d3..7d90028 100644
--- a/src/modules/FileLogger/CMakeLists.txt
+++ b/src/modules/FileLogger/CMakeLists.txt
@@ -1,5 +1,5 @@
include_directories(${INCLUDES})
add_library(FileLogger MODULE
- FileLogger.cpp
+ FileLogger.cpp FileLogger.h
)
diff --git a/src/modules/SystemBackendPosix/CMakeLists.txt b/src/modules/SystemBackendPosix/CMakeLists.txt
index 02b0ef6..223960b 100644
--- a/src/modules/SystemBackendPosix/CMakeLists.txt
+++ b/src/modules/SystemBackendPosix/CMakeLists.txt
@@ -1,5 +1,5 @@
include_directories(${INCLUDES})
add_library(SystemBackendPosix MODULE
- SystemBackendPosix.cpp
+ SystemBackendPosix.cpp SystemBackendPosix.h
)
diff --git a/src/modules/SystemBackendProc/CMakeLists.txt b/src/modules/SystemBackendProc/CMakeLists.txt
index b524265..ba5642c 100644
--- a/src/modules/SystemBackendProc/CMakeLists.txt
+++ b/src/modules/SystemBackendProc/CMakeLists.txt
@@ -1,5 +1,5 @@
include_directories(${INCLUDES})
add_library(SystemBackendProc MODULE
- SystemBackendProc.cpp
+ SystemBackendProc.cpp SystemBackendProc.h
)
diff --git a/src/modules/UserBackendMysql/CMakeLists.txt b/src/modules/UserBackendMysql/CMakeLists.txt
index 5af1f1d..b185c13 100644
--- a/src/modules/UserBackendMysql/CMakeLists.txt
+++ b/src/modules/UserBackendMysql/CMakeLists.txt
@@ -1,7 +1,7 @@
include_directories(${INCLUDES} ${MYSQL_INCLUDE_DIR})
add_library(UserBackendMysql MODULE
- UserBackendMysql.cpp
+ UserBackendMysql.cpp UserBackendMysql.h
)
target_link_libraries(UserBackendMysql ${MYSQL_LIBRARIES}) \ No newline at end of file