diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-09-23 09:44:02 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-09-23 09:44:02 +0200 |
commit | 0eddc28a331437ef95a60418ed1fc6de4e9b63c1 (patch) | |
tree | 17dcb71adbca54b47e12b32fb313597f971709f5 | |
parent | d6844595c9b47dab1db4b970ff6cc7fb3f64f107 (diff) | |
download | mad-0eddc28a331437ef95a60418ed1fc6de4e9b63c1.tar mad-0eddc28a331437ef95a60418ed1fc6de4e9b63c1.zip |
UserListManager: Moved module into libCommon and libServer
-rw-r--r-- | src/Common/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/Common/UserLists/UserList.h (renamed from src/modules/UserListManager/UserList.h) | 10 | ||||
-rw-r--r-- | src/Common/UserLists/UserListDiff.cpp (renamed from src/modules/UserListManager/UserListDiff.cpp) | 4 | ||||
-rw-r--r-- | src/Common/UserLists/UserListDiff.h (renamed from src/modules/UserListManager/UserListDiff.h) | 12 | ||||
-rw-r--r-- | src/Common/UserLists/UserListEntry.h (renamed from src/modules/UserListManager/UserListEntry.h) | 10 | ||||
-rw-r--r-- | src/Common/UserLists/Util.cpp (renamed from src/modules/UserListManager/Util.cpp) | 34 | ||||
-rw-r--r-- | src/Common/UserLists/Util.h (renamed from src/modules/UserListManager/Util.h) | 26 | ||||
-rw-r--r-- | src/Server/Application.cpp | 5 | ||||
-rw-r--r-- | src/Server/Application.h | 6 | ||||
-rw-r--r-- | src/Server/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp (renamed from src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.cpp) | 12 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h (renamed from src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.h) | 14 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp (renamed from src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp) | 36 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserListRequestHandlerGroup.h (renamed from src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.h) | 23 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserListUploadRequestHandler.cpp (renamed from src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.cpp) | 12 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserListUploadRequestHandler.h (renamed from src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.h) | 14 | ||||
-rw-r--r-- | src/Server/UserListManager.cpp (renamed from src/modules/UserListManager/UserListManager.cpp) | 42 | ||||
-rw-r--r-- | src/Server/UserListManager.h (renamed from src/modules/UserListManager/UserListManager.h) | 40 | ||||
-rw-r--r-- | src/mad-server.conf | 4 | ||||
-rw-r--r-- | src/modules/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/modules/UserListManager/CMakeLists.txt | 16 | ||||
-rw-r--r-- | src/modules/UserListManager/Module.cpp | 39 | ||||
-rw-r--r-- | src/modules/UserListManager/Module.h | 44 |
23 files changed, 157 insertions, 257 deletions
diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt index dd12a36..a99f9be 100644 --- a/src/Common/CMakeLists.txt +++ b/src/Common/CMakeLists.txt @@ -18,6 +18,11 @@ mad_library(Common Requests/SimpleRequest.cpp Requests/SimpleRequest.h Requests/StatusRequest.h + UserLists/UserList.h + UserLists/UserListDiff.cpp UserLists/UserListDiff.h + UserLists/UserListEntry.h + UserLists/Util.cpp UserLists/Util.h + Application.cpp Application.h AuthBackend.h AuthContext.h diff --git a/src/modules/UserListManager/UserList.h b/src/Common/UserLists/UserList.h index 6ca3de4..e80abaf 100644 --- a/src/modules/UserListManager/UserList.h +++ b/src/Common/UserLists/UserList.h @@ -17,16 +17,16 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_MODULES_USERLISTMANAGER_USERLIST_H_ -#define MAD_MODULES_USERLISTMANAGER_USERLIST_H_ +#ifndef MAD_COMMON_USERLISTS_USERLIST_H_ +#define MAD_COMMON_USERLISTS_USERLIST_H_ #include "UserListEntry.h" #include <list> namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Common { +namespace UserLists { class UserList : public std::list<UserListEntry> { public: @@ -37,4 +37,4 @@ class UserList : public std::list<UserListEntry> { } } -#endif /* MAD_MODULES_USERLISTMANAGER_USERLIST_H_ */ +#endif /* MAD_COMMON_USERLISTS_USERLIST_H_ */ diff --git a/src/modules/UserListManager/UserListDiff.cpp b/src/Common/UserLists/UserListDiff.cpp index a7b5f2f..e763afe 100644 --- a/src/modules/UserListManager/UserListDiff.cpp +++ b/src/Common/UserLists/UserListDiff.cpp @@ -21,8 +21,8 @@ #include "UserList.h" namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Common { +namespace UserLists { UserListDiff::UserListDiff(const UserList *oldList, const UserList *newList) { for(UserList::const_iterator user = oldList->begin(); user != oldList->end(); ++user) diff --git a/src/modules/UserListManager/UserListDiff.h b/src/Common/UserLists/UserListDiff.h index de881bd..41b8e81 100644 --- a/src/modules/UserListManager/UserListDiff.h +++ b/src/Common/UserLists/UserListDiff.h @@ -17,8 +17,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_MODULES_USERLISTMANAGER_USERLISTDIFF_H_ -#define MAD_MODULES_USERLISTMANAGER_USERLISTDIFF_H_ +#ifndef MAD_COMMON_USERLISTS_USERLISTDIFF_H_ +#define MAD_COMMON_USERLISTS_USERLISTDIFF_H_ #include "../export.h" @@ -28,12 +28,12 @@ #include <set> namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Common { +namespace UserLists { class UserList; -class MAD_MODULE_EXPORT UserListDiff { +class MAD_COMMON_EXPORT UserListDiff { private: std::set<UserListEntry> addedUsers; std::set<UserListEntry> deletedUsers; @@ -85,4 +85,4 @@ class MAD_MODULE_EXPORT UserListDiff { } } -#endif /* MAD_MODULES_USERLISTMANAGER_USERLISTDIFF_H_ */ +#endif /* MAD_COMMON_USERLISTS_USERLISTDIFF_H_ */ diff --git a/src/modules/UserListManager/UserListEntry.h b/src/Common/UserLists/UserListEntry.h index 59776d6..8642275 100644 --- a/src/modules/UserListManager/UserListEntry.h +++ b/src/Common/UserLists/UserListEntry.h @@ -17,8 +17,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_MODULES_USERLISTMANAGER_USERLISTENTRY_H_ -#define MAD_MODULES_USERLISTMANAGER_USERLISTENTRY_H_ +#ifndef MAD_COMMON_USERLISTS_USERLISTENTRY_H_ +#define MAD_COMMON_USERLISTS_USERLISTENTRY_H_ #include <map> #include <set> @@ -26,8 +26,8 @@ namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Common { +namespace UserLists { class UserListEntry { private: @@ -90,4 +90,4 @@ class UserListEntry { } } -#endif /* MAD_MODULES_USERLISTMANAGER_USERLISTENTRY_H_ */ +#endif /* MAD_COMMON_USERLISTS_USERLISTENTRY_H_ */ diff --git a/src/modules/UserListManager/Util.cpp b/src/Common/UserLists/Util.cpp index 9b986d8..812c2c7 100644 --- a/src/modules/UserListManager/Util.cpp +++ b/src/Common/UserLists/Util.cpp @@ -21,13 +21,11 @@ #include "UserList.h" #include "UserListDiff.h" -#include <Common/XmlData.h> - namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Common { +namespace UserLists { -void Util::serializeUserListEntry(const UserListEntry *user, Common::XmlData::List::iterator entry) { +void Util::serializeUserListEntry(const UserListEntry *user, XmlData::List::iterator entry) { std::set<std::string> details = user->getDetailList(); for(std::set<std::string>::iterator detail = details.begin(); detail != details.end(); ++detail) entry->set(*detail, user->getDetail(*detail)); @@ -36,7 +34,7 @@ void Util::serializeUserListEntry(const UserListEntry *user, Common::XmlData::Li entry->set("group", user->getGroup()); } -UserListEntry Util::deserializeUserListEntry(Common::XmlData::List::const_iterator entry) { +UserListEntry Util::deserializeUserListEntry(XmlData::List::const_iterator entry) { UserListEntry user(entry->get<const std::string&>("name"), entry->get<const std::string&>("group")); std::set<std::string> details = entry->getChildren(); @@ -50,28 +48,28 @@ UserListEntry Util::deserializeUserListEntry(Common::XmlData::List::const_iterat return user; } -void Util::serializeUserList(const UserList *list, Common::XmlData *data) { - Common::XmlData::List *userList = data->createList("users"); +void Util::serializeUserList(const UserList *list, XmlData *data) { + XmlData::List *userList = data->createList("users"); for(UserList::const_iterator user = list->begin(); user != list->end(); ++user) serializeUserListEntry(&*user, userList->addEntry()); } -boost::shared_ptr<UserList> Util::deserializeUserList(const Common::XmlData *data) { +boost::shared_ptr<UserList> Util::deserializeUserList(const XmlData *data) { boost::shared_ptr<UserList> users(new UserList); - const Common::XmlData::List *userList = data->getList("users"); + const XmlData::List *userList = data->getList("users"); if(userList) { - for(Common::XmlData::List::const_iterator user = userList->begin(); user != userList->end(); ++user) + for(XmlData::List::const_iterator user = userList->begin(); user != userList->end(); ++user) users->push_back(deserializeUserListEntry(user)); } return users; } -void Util::serializeUserListDiff(const UserListDiff *diff, Common::XmlData *data) { - Common::XmlData::List *userList = data->createList("addedUsers"); +void Util::serializeUserListDiff(const UserListDiff *diff, XmlData *data) { + XmlData::List *userList = data->createList("addedUsers"); for(std::set<UserListEntry>::const_iterator user = diff->getAddedUsers().begin(); user != diff->getAddedUsers().end(); ++user) serializeUserListEntry(&*user, userList->addEntry()); @@ -84,24 +82,24 @@ void Util::serializeUserListDiff(const UserListDiff *diff, Common::XmlData *data serializeUserListEntry(&*user, userList->addEntry()); } -boost::shared_ptr<UserListDiff> Util::deserializeUserListDiff(const Common::XmlData *data) { +boost::shared_ptr<UserListDiff> Util::deserializeUserListDiff(const XmlData *data) { boost::shared_ptr<UserListDiff> diff(new UserListDiff); - const Common::XmlData::List *userList = data->getList("addedUsers"); + const XmlData::List *userList = data->getList("addedUsers"); if(userList) { - for(Common::XmlData::List::const_iterator user = userList->begin(); user != userList->end(); ++user) + for(XmlData::List::const_iterator user = userList->begin(); user != userList->end(); ++user) diff->insertAddedUser(deserializeUserListEntry(user)); } userList = data->getList("deletedUsers"); if(userList) { - for(Common::XmlData::List::const_iterator user = userList->begin(); user != userList->end(); ++user) + for(XmlData::List::const_iterator user = userList->begin(); user != userList->end(); ++user) diff->insertDeletedUser(deserializeUserListEntry(user)); } userList = data->getList("unchangedUsers"); if(userList) { - for(Common::XmlData::List::const_iterator user = userList->begin(); user != userList->end(); ++user) + for(XmlData::List::const_iterator user = userList->begin(); user != userList->end(); ++user) diff->insertUnchangedUser(deserializeUserListEntry(user)); } diff --git a/src/modules/UserListManager/Util.h b/src/Common/UserLists/Util.h index c9b9a2c..df7f203 100644 --- a/src/modules/UserListManager/Util.h +++ b/src/Common/UserLists/Util.h @@ -17,39 +17,39 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_MODULES_USERLISTMANAGER_UTIL_H_ -#define MAD_MODULES_USERLISTMANAGER_UTIL_H_ +#ifndef MAD_COMMON_USERLISTS_UTIL_H_ +#define MAD_COMMON_USERLISTS_UTIL_H_ #include "../export.h" -#include <Common/XmlData.h> +#include "../XmlData.h" #include <boost/shared_ptr.hpp> namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Common { +namespace UserLists { class UserList; class UserListDiff; class UserListEntry; -class MAD_MODULE_EXPORT Util { +class MAD_COMMON_EXPORT Util { private: - static void serializeUserListEntry(const UserListEntry *user, Common::XmlData::List::iterator entry); - static UserListEntry deserializeUserListEntry(Common::XmlData::List::const_iterator entry); + static void serializeUserListEntry(const UserListEntry *user, XmlData::List::iterator entry); + static UserListEntry deserializeUserListEntry(XmlData::List::const_iterator entry); Util(); public: - static void serializeUserList(const UserList *list, Common::XmlData *data); - static boost::shared_ptr<UserList> deserializeUserList(const Common::XmlData *data); + static void serializeUserList(const UserList *list, XmlData *data); + static boost::shared_ptr<UserList> deserializeUserList(const XmlData *data); - static void serializeUserListDiff(const UserListDiff *diff, Common::XmlData *data); - static boost::shared_ptr<UserListDiff> deserializeUserListDiff(const Common::XmlData *data); + static void serializeUserListDiff(const UserListDiff *diff, XmlData *data); + static boost::shared_ptr<UserListDiff> deserializeUserListDiff(const XmlData *data); }; } } } -#endif /* MAD_MODULES_USERLISTMANAGER_UTIL_H_ */ +#endif /* MAD_COMMON_USERLISTS_UTIL_H_ */ diff --git a/src/Server/Application.cpp b/src/Server/Application.cpp index f8340d5..157f5b6 100644 --- a/src/Server/Application.cpp +++ b/src/Server/Application.cpp @@ -19,13 +19,16 @@ #include "Application.h" #include "ConnectionManager.h" +#include "UserListManager.h" namespace Mad { namespace Server { -Application::Application() : Common::Application(true), connectionManager(new ConnectionManager(this)) {} +Application::Application() : Common::Application(true), connectionManager(new ConnectionManager(this)), + userListManager(new UserListManager(this)) {} Application::~Application() { + delete userListManager; delete connectionManager; } diff --git a/src/Server/Application.h b/src/Server/Application.h index 205d398..5dc1e63 100644 --- a/src/Server/Application.h +++ b/src/Server/Application.h @@ -28,10 +28,12 @@ namespace Mad { namespace Server { class ConnectionManager; +class UserListManager; class MAD_SERVER_EXPORT Application : public Common::Application { private: ConnectionManager *connectionManager; + UserListManager *userListManager; public: Application(); @@ -40,6 +42,10 @@ class MAD_SERVER_EXPORT Application : public Common::Application { ConnectionManager* getConnectionManager() const { return connectionManager; } + + UserListManager* getUserListManager() const { + return userListManager; + } }; } diff --git a/src/Server/CMakeLists.txt b/src/Server/CMakeLists.txt index 80cf25d..4414bd8 100644 --- a/src/Server/CMakeLists.txt +++ b/src/Server/CMakeLists.txt @@ -5,6 +5,9 @@ mad_library(Server RequestHandlers/ConnectionRequestHandlerGroup.cpp RequestHandlers/ConnectionRequestHandlerGroup.h RequestHandlers/DaemonRequestHandlerGroup.cpp RequestHandlers/DaemonRequestHandlerGroup.h + RequestHandlers/UserListDiffUploadRequestHandler.cpp RequestHandlers/UserListDiffUploadRequestHandler.h + RequestHandlers/UserListRequestHandlerGroup.cpp RequestHandlers/UserListRequestHandlerGroup.h + RequestHandlers/UserListUploadRequestHandler.cpp RequestHandlers/UserListUploadRequestHandler.h RequestHandlers/UserRequestHandlerGroup.cpp RequestHandlers/UserRequestHandlerGroup.h Requests/CommandRequest.cpp Requests/CommandRequest.h @@ -12,5 +15,6 @@ mad_library(Server Application.cpp Application.h ConnectionManager.cpp ConnectionManager.h + UserListManager.cpp UserListManager.h ) target_link_libraries(Server Common Net Core) diff --git a/src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.cpp b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp index 4660850..05aadf8 100644 --- a/src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.cpp +++ b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp @@ -18,14 +18,15 @@ */ #include "UserListDiffUploadRequestHandler.h" +#include "../Application.h" #include "../UserListManager.h" -#include "../Util.h" + +#include <Common/UserLists/Util.h> #include <boost/date_time/posix_time/posix_time.hpp> namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Server { namespace RequestHandlers { void UserListDiffUploadRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlData> packet) { @@ -53,6 +54,8 @@ void UserListDiffUploadRequestHandler::handlePacket(boost::shared_ptr<const Comm if(!getConnection()->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); + UserListManager *userListManager = dynamic_cast<Application*>(getApplication())->getUserListManager(); + if(name.empty()) { // Request name = packet->get<const std::string&>("name"); @@ -65,7 +68,7 @@ void UserListDiffUploadRequestHandler::handlePacket(boost::shared_ptr<const Comm sendPacket(ret); } else { // Upload - boost::shared_ptr<UserListDiff> diff = Util::deserializeUserListDiff(packet.get()); + boost::shared_ptr<Common::UserLists::UserListDiff> diff = Common::UserLists::Util::deserializeUserListDiff(packet.get()); userListManager->storeUserListDiff(name, diff.get()); Common::XmlData ret; @@ -79,4 +82,3 @@ void UserListDiffUploadRequestHandler::handlePacket(boost::shared_ptr<const Comm } } } -} diff --git a/src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.h b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h index 205a87f..3d74253 100644 --- a/src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.h +++ b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h @@ -17,14 +17,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTDIFFUPLOADREQUESTHANDLER_H_ -#define MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTDIFFUPLOADREQUESTHANDLER_H_ +#ifndef MAD_SERVER_REQUESTHANDLERS_USERLISTDIFFUPLOADREQUESTHANDLER_H_ +#define MAD_SERVER_REQUESTHANDLERS_USERLISTDIFFUPLOADREQUESTHANDLER_H_ #include <Common/RequestHandler.h> namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Server { class UserListManager; @@ -34,18 +33,15 @@ class UserListDiffUploadRequestHandler : public Common::RequestHandler { private: std::string name; - UserListManager *userListManager; - protected: virtual void handlePacket(boost::shared_ptr<const Common::XmlData> packet); public: - UserListDiffUploadRequestHandler(Common::Application *application, UserListManager *userListManager0) : Common::RequestHandler(application), userListManager(userListManager0) {} + UserListDiffUploadRequestHandler(Common::Application *application) : Common::RequestHandler(application) {} }; } } } -} -#endif /* MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTDIFFUPLOADREQUESTHANDLER_H_ */ +#endif /* MAD_SERVER_REQUESTHANDLERS_USERLISTDIFFUPLOADREQUESTHANDLER_H_ */ diff --git a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp index 61bbf07..bb18194 100644 --- a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp @@ -18,19 +18,20 @@ */ #include "UserListRequestHandlerGroup.h" +#include "../Application.h" #include "../UserListManager.h" -#include "../Util.h" + +#include <Common/UserLists/Util.h> namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Server { namespace RequestHandlers { void UserListRequestHandlerGroup::handleUserListListRequest(boost::shared_ptr<const Common::XmlData> /*packet*/, Common::XmlData *ret, Common::Connection *connection) { if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - const std::set<std::string> &userLists = userListManager->getUserLists(); + const std::set<std::string> &userLists = application->getUserListManager()->getUserLists(); ret->setType("OK"); Common::XmlData::List *list = ret->createList("userLists"); @@ -47,19 +48,19 @@ void UserListRequestHandlerGroup::handleUserListDownloadRequest(boost::shared_pt if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::shared_ptr<UserList> userList = userListManager->loadUserList(packet->get<const std::string&>("name")); + boost::shared_ptr<Common::UserLists::UserList> userList = application->getUserListManager()->loadUserList(packet->get<const std::string&>("name")); if(!userList) throw(Core::Exception(Core::Exception::NOT_FOUND)); ret->setType("OK"); - Util::serializeUserList(userList.get(), ret); + Common::UserLists::Util::serializeUserList(userList.get(), ret); } void UserListRequestHandlerGroup::handleUserListCopyRequest(boost::shared_ptr<const Common::XmlData> packet, Common::XmlData *ret, Common::Connection *connection) { if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - userListManager->copyUserList(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); + application->getUserListManager()->copyUserList(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); ret->setType("OK"); } @@ -68,7 +69,7 @@ void UserListRequestHandlerGroup::handleUserListRenameRequest(boost::shared_ptr< if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - userListManager->renameUserList(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); + application->getUserListManager()->renameUserList(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); ret->setType("OK"); } @@ -77,7 +78,7 @@ void UserListRequestHandlerGroup::handleUserListRemoveRequest(boost::shared_ptr< if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - userListManager->removeUserList(packet->get<const std::string&>("name")); + application->getUserListManager()->removeUserList(packet->get<const std::string&>("name")); ret->setType("OK"); } @@ -87,7 +88,7 @@ void UserListRequestHandlerGroup::handleUserListDiffListRequest(boost::shared_pt if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - const std::set<std::string> &userListDiffs = userListManager->getUserListDiffs(); + const std::set<std::string> &userListDiffs = application->getUserListManager()->getUserListDiffs(); ret->setType("OK"); Common::XmlData::List *list = ret->createList("userListDiffs"); @@ -104,19 +105,19 @@ void UserListRequestHandlerGroup::handleUserListDiffDownloadRequest(boost::share if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::shared_ptr<UserListDiff> diff = userListManager->loadUserListDiff(packet->get<const std::string&>("name")); + boost::shared_ptr<Common::UserLists::UserListDiff> diff = application->getUserListManager()->loadUserListDiff(packet->get<const std::string&>("name")); if(!diff) throw(Core::Exception(Core::Exception::NOT_FOUND)); ret->setType("OK"); - Util::serializeUserListDiff(diff.get(), ret); + Common::UserLists::Util::serializeUserListDiff(diff.get(), ret); } void UserListRequestHandlerGroup::handleUserListDiffCopyRequest(boost::shared_ptr<const Common::XmlData> packet, Common::XmlData *ret, Common::Connection *connection) { if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - userListManager->copyUserListDiff(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); + application->getUserListManager()->copyUserListDiff(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); ret->setType("OK"); } @@ -125,7 +126,7 @@ void UserListRequestHandlerGroup::handleUserListDiffRenameRequest(boost::shared_ if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - userListManager->renameUserListDiff(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); + application->getUserListManager()->renameUserListDiff(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); ret->setType("OK"); } @@ -134,14 +135,14 @@ void UserListRequestHandlerGroup::handleUserListDiffRemoveRequest(boost::shared_ if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - userListManager->removeUserListDiff(packet->get<const std::string&>("name")); + application->getUserListManager()->removeUserListDiff(packet->get<const std::string&>("name")); ret->setType("OK"); } -UserListRequestHandlerGroup::UserListRequestHandlerGroup(Server::Application *application0, UserListManager *userListManager0) -: application(application0), userListManager(userListManager0) { +UserListRequestHandlerGroup::UserListRequestHandlerGroup(Application *application0) +: application(application0) { registerHandler("ListUserLists", boost::bind(&UserListRequestHandlerGroup::handleUserListListRequest, this, _1, _2, _3)); registerHandler("DownloadUserList", boost::bind(&UserListRequestHandlerGroup::handleUserListDownloadRequest, this, _1, _2, _3)); registerHandler("CopyUserList", boost::bind(&UserListRequestHandlerGroup::handleUserListCopyRequest, this, _1, _2, _3)); @@ -158,4 +159,3 @@ UserListRequestHandlerGroup::UserListRequestHandlerGroup(Server::Application *ap } } } -} diff --git a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.h b/src/Server/RequestHandlers/UserListRequestHandlerGroup.h index 61f4c7d..a7e09b3 100644 --- a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.h +++ b/src/Server/RequestHandlers/UserListRequestHandlerGroup.h @@ -17,30 +17,24 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTREQUESTHANDLERGROUP_H_ -#define MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTREQUESTHANDLERGROUP_H_ +#ifndef MAD_SERVER_REQUESTHANDLERS_USERLISTREQUESTHANDLERGROUP_H_ +#define MAD_SERVER_REQUESTHANDLERS_USERLISTREQUESTHANDLERGROUP_H_ -#include "../../export.h" +#include "../export.h" #include <Common/RequestHandlers/SimpleRequestHandlerGroup.h> namespace Mad { - namespace Server { -class Application; -} - -namespace Modules { -namespace UserListManager { +class Application; class UserListManager; namespace RequestHandlers { -class MAD_MODULE_EXPORT UserListRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHandlerGroup { +class MAD_SERVER_EXPORT UserListRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHandlerGroup { private: - Server::Application *application; - UserListManager *userListManager; + Application *application; void handleUserListListRequest(boost::shared_ptr<const Common::XmlData> packet, Common::XmlData *ret, Common::Connection *connection); void handleUserListDownloadRequest(boost::shared_ptr<const Common::XmlData> packet, Common::XmlData *ret, Common::Connection *connection); @@ -55,12 +49,11 @@ class MAD_MODULE_EXPORT UserListRequestHandlerGroup : public Common::RequestHan void handleUserListDiffRemoveRequest(boost::shared_ptr<const Common::XmlData> packet, Common::XmlData *ret, Common::Connection *connection); public: - UserListRequestHandlerGroup(Server::Application *application0, UserListManager *userListManager0); + UserListRequestHandlerGroup(Application *application0); }; } } } -} -#endif /* MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTREQUESTHANDLERGROUP_H_ */ +#endif /* MAD_SERVER_REQUESTHANDLERS_USERLISTREQUESTHANDLERGROUP_H_ */ diff --git a/src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.cpp b/src/Server/RequestHandlers/UserListUploadRequestHandler.cpp index 9d01b5e..307863a 100644 --- a/src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.cpp +++ b/src/Server/RequestHandlers/UserListUploadRequestHandler.cpp @@ -18,15 +18,16 @@ */ #include "UserListUploadRequestHandler.h" +#include "../Application.h" #include "../UserListManager.h" -#include "../Util.h" + +#include <Common/UserLists/Util.h> #include <boost/date_time/posix_time/posix_time.hpp> namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Server { namespace RequestHandlers { void UserListUploadRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlData> packet) { @@ -54,6 +55,8 @@ void UserListUploadRequestHandler::handlePacket(boost::shared_ptr<const Common:: if(!getConnection()->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); + UserListManager *userListManager = dynamic_cast<Application*>(getApplication())->getUserListManager(); + if(name.empty()) { // Request name = packet->get<const std::string&>("name"); @@ -66,7 +69,7 @@ void UserListUploadRequestHandler::handlePacket(boost::shared_ptr<const Common:: sendPacket(ret); } else { // Upload - boost::shared_ptr<UserList> userList = Util::deserializeUserList(packet.get()); + boost::shared_ptr<Common::UserLists::UserList> userList = Common::UserLists::Util::deserializeUserList(packet.get()); userListManager->storeUserList(name, userList.get()); Common::XmlData ret; @@ -80,4 +83,3 @@ void UserListUploadRequestHandler::handlePacket(boost::shared_ptr<const Common:: } } } -} diff --git a/src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.h b/src/Server/RequestHandlers/UserListUploadRequestHandler.h index 933d4a5..4a20a4c 100644 --- a/src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.h +++ b/src/Server/RequestHandlers/UserListUploadRequestHandler.h @@ -17,14 +17,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTUPLOADREQUESTHANDLER_H_ -#define MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTUPLOADREQUESTHANDLER_H_ +#ifndef MAD_SERVER_REQUESTHANDLERS_USERLISTUPLOADREQUESTHANDLER_H_ +#define MAD_SERVER_REQUESTHANDLERS_USERLISTUPLOADREQUESTHANDLER_H_ #include <Common/RequestHandler.h> namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Server { class UserListManager; @@ -34,18 +33,15 @@ class UserListUploadRequestHandler : public Common::RequestHandler { private: std::string name; - UserListManager *userListManager; - protected: virtual void handlePacket(boost::shared_ptr<const Common::XmlData> packet); public: - UserListUploadRequestHandler(Common::Application *application, UserListManager *userListManager0) : Common::RequestHandler(application), userListManager(userListManager0) {} + UserListUploadRequestHandler(Common::Application *application) : Common::RequestHandler(application) {} }; } } } -} -#endif /* MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTUPLOADREQUESTHANDLER_H_ */ +#endif /* MAD_SERVER_REQUESTHANDLERS_USERLISTUPLOADREQUESTHANDLER_H_ */ diff --git a/src/modules/UserListManager/UserListManager.cpp b/src/Server/UserListManager.cpp index deb6214..d1a6e31 100644 --- a/src/modules/UserListManager/UserListManager.cpp +++ b/src/Server/UserListManager.cpp @@ -18,23 +18,22 @@ */ #include "UserListManager.h" -#include "UserList.h" -#include "Util.h" +#include "Application.h" #include "RequestHandlers/UserListRequestHandlerGroup.h" #include "RequestHandlers/UserListUploadRequestHandler.h" #include "RequestHandlers/UserListDiffUploadRequestHandler.h" -#include <Server/Application.h> #include <Common/RequestManager.h> #include <Common/StorageManager.h> #include <Common/UserManager.h> +#include <Common/UserLists/UserList.h> +#include <Common/UserLists/Util.h> #include <Core/ConfigManager.h> namespace Mad { -namespace Modules { -namespace UserListManager { +namespace Server { -UserListManager::UserListManager(Server::Application *application0) : application(application0), requestHandlerGroup(new RequestHandlers::UserListRequestHandlerGroup(application, this)) { +UserListManager::UserListManager(Application *application0) : application(application0), requestHandlerGroup(new RequestHandlers::UserListRequestHandlerGroup(application)) { application->getConfigManager()->registerConfigurable(this); } @@ -51,27 +50,27 @@ void UserListManager::configFinished() { userListDiffs = application->getStorageManager()->list("UserListDiff"); application->getRequestManager()->registerRequestHandlerGroup(requestHandlerGroup); - application->getRequestManager()->registerPacketType<RequestHandlers::UserListUploadRequestHandler>("UploadUserList", this); - application->getRequestManager()->registerPacketType<RequestHandlers::UserListDiffUploadRequestHandler>("UploadUserListDiff", this); + application->getRequestManager()->registerPacketType<RequestHandlers::UserListUploadRequestHandler>("UploadUserList"); + application->getRequestManager()->registerPacketType<RequestHandlers::UserListDiffUploadRequestHandler>("UploadUserListDiff"); } bool UserListManager::existsUserList(const std::string &name) { return application->getStorageManager()->exists("UserList", name); } -boost::shared_ptr<UserList> UserListManager::loadUserList(const std::string &name) { +boost::shared_ptr<Common::UserLists::UserList> UserListManager::loadUserList(const std::string &name) { boost::shared_ptr<Common::XmlData> data = application->getStorageManager()->load("UserList", name); if(!data) - return boost::shared_ptr<UserList>(); + return boost::shared_ptr<Common::UserLists::UserList>(); - return Util::deserializeUserList(data.get()); + return Common::UserLists::Util::deserializeUserList(data.get()); } -void UserListManager::storeUserList(const std::string &name, const UserList *list) { +void UserListManager::storeUserList(const std::string &name, const Common::UserLists::UserList *list) { Common::XmlData data; - Util::serializeUserList(list, &data); + Common::UserLists::Util::serializeUserList(list, &data); application->getStorageManager()->store("UserList", name, &data); } @@ -92,19 +91,19 @@ bool UserListManager::existsUserListDiff(const std::string &name) { return application->getStorageManager()->exists("UserListDiff", name); } -boost::shared_ptr<UserListDiff> UserListManager::loadUserListDiff(const std::string &name) { +boost::shared_ptr<Common::UserLists::UserListDiff> UserListManager::loadUserListDiff(const std::string &name) { boost::shared_ptr<Common::XmlData> data = application->getStorageManager()->load("UserListDiff", name); if(!data) - return boost::shared_ptr<UserListDiff>(); + return boost::shared_ptr<Common::UserLists::UserListDiff>(); - return Util::deserializeUserListDiff(data.get()); + return Common::UserLists::Util::deserializeUserListDiff(data.get()); } -void UserListManager::storeUserListDiff(const std::string &name, const UserListDiff *list) { +void UserListManager::storeUserListDiff(const std::string &name, const Common::UserLists::UserListDiff *list) { Common::XmlData data; - Util::serializeUserListDiff(list, &data); + Common::UserLists::Util::serializeUserListDiff(list, &data); application->getStorageManager()->store("UserListDiff", name, &data); } @@ -120,8 +119,8 @@ void UserListManager::removeUserListDiff(const std::string &name) { application->getStorageManager()->remove("UserListDiff", name); } -boost::shared_ptr<UserList> UserListManager::getCurrentUserList() { - boost::shared_ptr<UserList> list(new UserList); +boost::shared_ptr<Common::UserLists::UserList> UserListManager::getCurrentUserList() { + boost::shared_ptr<Common::UserLists::UserList> list(new Common::UserLists::UserList); boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > userList = application->getUserManager()->getUserList(); boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > groupList = application->getUserManager()->getGroupList(); @@ -139,7 +138,7 @@ boost::shared_ptr<UserList> UserListManager::getCurrentUserList() { groupname = stream.str(); } - UserListEntry entry(user->second.getUsername(), groupname); + Common::UserLists::UserListEntry entry(user->second.getUsername(), groupname); entry.setDetail("Full name", user->second.getFullName()); list->push_back(entry); @@ -150,4 +149,3 @@ boost::shared_ptr<UserList> UserListManager::getCurrentUserList() { } } -} diff --git a/src/modules/UserListManager/UserListManager.h b/src/Server/UserListManager.h index 6763dae..1651d42 100644 --- a/src/modules/UserListManager/UserListManager.h +++ b/src/Server/UserListManager.h @@ -17,10 +17,10 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_MODULES_USERLISTMANAGER_USERLISTMANAGER_H_ -#define MAD_MODULES_USERLISTMANAGER_USERLISTMANAGER_H_ +#ifndef MAD_SERVER_USERLISTMANAGER_H_ +#define MAD_SERVER_USERLISTMANAGER_H_ -#include "../export.h" +#include "export.h" #include <Core/Configurable.h> @@ -31,23 +31,24 @@ namespace Mad { -namespace Server { -class Application; +namespace Common { +namespace UserLists { +class UserList; +class UserListDiff; +} } -namespace Modules { -namespace UserListManager { +namespace Server { + +class Application; namespace RequestHandlers { class UserListRequestHandlerGroup; } -class UserList; -class UserListDiff; - -class MAD_MODULE_EXPORT UserListManager : private Core::Configurable, private boost::noncopyable { +class MAD_SERVER_EXPORT UserListManager : private Core::Configurable, private boost::noncopyable { private: - Server::Application *application; + Application *application; boost::shared_ptr<RequestHandlers::UserListRequestHandlerGroup> requestHandlerGroup; @@ -60,7 +61,7 @@ class MAD_MODULE_EXPORT UserListManager : private Core::Configurable, private bo public: virtual int getPriority() const {return -1;} - UserListManager(Server::Application *application0); + UserListManager(Application *application0); virtual ~UserListManager(); const std::set<std::string>& getUserLists() const { @@ -68,8 +69,8 @@ class MAD_MODULE_EXPORT UserListManager : private Core::Configurable, private bo } bool existsUserList(const std::string &name); - boost::shared_ptr<UserList> loadUserList(const std::string &name); - void storeUserList(const std::string &name, const UserList *list); + boost::shared_ptr<Common::UserLists::UserList> loadUserList(const std::string &name); + void storeUserList(const std::string &name, const Common::UserLists::UserList *list); void copyUserList(const std::string &fromName, const std::string &toName); void renameUserList(const std::string &fromName, const std::string &toName); void removeUserList(const std::string &name); @@ -79,17 +80,16 @@ class MAD_MODULE_EXPORT UserListManager : private Core::Configurable, private bo } bool existsUserListDiff(const std::string &name); - boost::shared_ptr<UserListDiff> loadUserListDiff(const std::string &name); - void storeUserListDiff(const std::string &name, const UserListDiff *list); + boost::shared_ptr<Common::UserLists::UserListDiff> loadUserListDiff(const std::string &name); + void storeUserListDiff(const std::string &name, const Common::UserLists::UserListDiff *list); void copyUserListDiff(const std::string &fromName, const std::string &toName); void renameUserListDiff(const std::string &fromName, const std::string &toName); void removeUserListDiff(const std::string &name); - boost::shared_ptr<UserList> getCurrentUserList(); + boost::shared_ptr<Common::UserLists::UserList> getCurrentUserList(); }; } } -} -#endif /* MAD_MODULES_USERLISTMANAGER_USERLISTMANAGER_H_ */ +#endif /* MAD_SERVER_USERLISTMANAGER_H_ */ diff --git a/src/mad-server.conf b/src/mad-server.conf index d83f9b4..ad2a955 100644 --- a/src/mad-server.conf +++ b/src/mad-server.conf @@ -13,8 +13,6 @@ LoadModule "UserDBBackendMysql" LoadModule "UserConfigBackendHome" LoadModule "UserConfigBackendKrb5" -LoadModule "UserListManager" - Log Console { Level "verbose" } @@ -36,7 +34,7 @@ AuthProviderFile { } Storage { - Root "/tmp/storage" + Root "/home/neoraider/.mad/storage" } UserManager { diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 6681ad7..2f497de 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -53,8 +53,6 @@ if(MYSQL_FOUND) add_subdirectory(UserDBBackendMysql) endif(MYSQL_FOUND) -add_subdirectory(UserListManager) - SET(STATIC_MODULE_LOADERS "") SET(STATIC_MODULE_LIST "") diff --git a/src/modules/UserListManager/CMakeLists.txt b/src/modules/UserListManager/CMakeLists.txt deleted file mode 100644 index f8e72ce..0000000 --- a/src/modules/UserListManager/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -include_directories(${INCLUDES}) - -mad_module(UserListManager - RequestHandlers/UserListDiffUploadRequestHandler.cpp RequestHandlers/UserListDiffUploadRequestHandler.h - RequestHandlers/UserListRequestHandlerGroup.cpp RequestHandlers/UserListRequestHandlerGroup.h - RequestHandlers/UserListUploadRequestHandler.cpp RequestHandlers/UserListUploadRequestHandler.h - - Module.cpp Module.h - UserList.h - UserListDiff.cpp UserListDiff.h - UserListEntry.h - UserListManager.cpp UserListManager.h - Util.cpp Util.h -) - -mad_module_libraries(UserListManager) diff --git a/src/modules/UserListManager/Module.cpp b/src/modules/UserListManager/Module.cpp deleted file mode 100644 index 2145a32..0000000 --- a/src/modules/UserListManager/Module.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Module.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 Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "../export.h" - -#include "Module.h" - -#include <Server/Application.h> - -extern "C" { - -MAD_MODULE_EXPORT Mad::Common::Module* UserListManager_create(Mad::Common::Application *application) { - Mad::Server::Application *serverApp = dynamic_cast<Mad::Server::Application*>(application); - - if(!serverApp) { - application->log(Mad::Core::Logger::LOG_ERROR, "UserListManager: This module can be used with mad-server only."); - return 0; - } - - return new Mad::Modules::UserListManager::Module(serverApp); -} - -} diff --git a/src/modules/UserListManager/Module.h b/src/modules/UserListManager/Module.h deleted file mode 100644 index 035cdaa..0000000 --- a/src/modules/UserListManager/Module.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Module.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 Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef MAD_MODULES_USERLISTMANAGER_MODULE_H_ -#define MAD_MODULES_USERLISTMANAGER_MODULE_H_ - -#include "UserListManager.h" -#include <Common/Module.h> - -#include <boost/scoped_ptr.hpp> - -namespace Mad { -namespace Modules { -namespace UserListManager { - -class Module : public Common::Module { - private: - boost::scoped_ptr<UserListManager> userListManager; - - public: - Module(Server::Application *application) : userListManager(new UserListManager(application)) {} -}; - -} -} -} - -#endif /* MAD_MODULES_USERLISTMANAGER_MODULE_H_ */ |