From 0eddc28a331437ef95a60418ed1fc6de4e9b63c1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 23 Sep 2009 09:44:02 +0200 Subject: UserListManager: Moved module into libCommon and libServer --- src/modules/UserListManager/CMakeLists.txt | 16 -- src/modules/UserListManager/Module.cpp | 39 ----- src/modules/UserListManager/Module.h | 44 ------ .../UserListDiffUploadRequestHandler.cpp | 82 ----------- .../UserListDiffUploadRequestHandler.h | 51 ------- .../UserListRequestHandlerGroup.cpp | 161 --------------------- .../RequestHandlers/UserListRequestHandlerGroup.h | 66 --------- .../UserListUploadRequestHandler.cpp | 83 ----------- .../RequestHandlers/UserListUploadRequestHandler.h | 51 ------- src/modules/UserListManager/UserList.h | 40 ----- src/modules/UserListManager/UserListDiff.cpp | 46 ------ src/modules/UserListManager/UserListDiff.h | 88 ----------- src/modules/UserListManager/UserListEntry.h | 93 ------------ src/modules/UserListManager/UserListManager.cpp | 153 -------------------- src/modules/UserListManager/UserListManager.h | 95 ------------ src/modules/UserListManager/Util.cpp | 113 --------------- src/modules/UserListManager/Util.h | 55 ------- 17 files changed, 1276 deletions(-) delete mode 100644 src/modules/UserListManager/CMakeLists.txt delete mode 100644 src/modules/UserListManager/Module.cpp delete mode 100644 src/modules/UserListManager/Module.h delete mode 100644 src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.cpp delete mode 100644 src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.h delete mode 100644 src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp delete mode 100644 src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.h delete mode 100644 src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.cpp delete mode 100644 src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.h delete mode 100644 src/modules/UserListManager/UserList.h delete mode 100644 src/modules/UserListManager/UserListDiff.cpp delete mode 100644 src/modules/UserListManager/UserListDiff.h delete mode 100644 src/modules/UserListManager/UserListEntry.h delete mode 100644 src/modules/UserListManager/UserListManager.cpp delete mode 100644 src/modules/UserListManager/UserListManager.h delete mode 100644 src/modules/UserListManager/Util.cpp delete mode 100644 src/modules/UserListManager/Util.h (limited to 'src/modules/UserListManager') 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 - * - * 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 . - */ - -#include "../export.h" - -#include "Module.h" - -#include - -extern "C" { - -MAD_MODULE_EXPORT Mad::Common::Module* UserListManager_create(Mad::Common::Application *application) { - Mad::Server::Application *serverApp = dynamic_cast(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 - * - * 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 . - */ - -#ifndef MAD_MODULES_USERLISTMANAGER_MODULE_H_ -#define MAD_MODULES_USERLISTMANAGER_MODULE_H_ - -#include "UserListManager.h" -#include - -#include - -namespace Mad { -namespace Modules { -namespace UserListManager { - -class Module : public Common::Module { - private: - boost::scoped_ptr userListManager; - - public: - Module(Server::Application *application) : userListManager(new UserListManager(application)) {} -}; - -} -} -} - -#endif /* MAD_MODULES_USERLISTMANAGER_MODULE_H_ */ diff --git a/src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.cpp b/src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.cpp deleted file mode 100644 index 4660850..0000000 --- a/src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * UserListDiffUploadRequestHandler.cpp - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#include "UserListDiffUploadRequestHandler.h" -#include "../UserListManager.h" -#include "../Util.h" - -#include - -namespace Mad { -namespace Modules { -namespace UserListManager { -namespace RequestHandlers { - -void UserListDiffUploadRequestHandler::handlePacket(boost::shared_ptr packet) { - if(packet->getType() == "Cancel") { - Common::XmlData ret; - ret.setType("OK"); - sendPacket(ret); - - signalFinished(); - return; - } - else if(packet->getType() != "UploadUserListDiff") { - getApplication()->log(Core::Logger::LOG_ERROR, "Received an unexpected packet."); - - Common::XmlData ret; - ret.setType("Error"); - ret.set("ErrorCode", Core::Exception::UNEXPECTED_PACKET); - - sendPacket(ret); - - signalFinished(); - return; - } - - if(!getConnection()->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - if(name.empty()) { // Request - name = packet->get("name"); - - if(name.empty()) - name = boost::posix_time::to_simple_string(boost::posix_time::second_clock::universal_time()); - - Common::XmlData ret; - ret.setType("Continue"); - ret.set("exists", userListManager->existsUserListDiff(name)); - sendPacket(ret); - } - else { // Upload - boost::shared_ptr diff = Util::deserializeUserListDiff(packet.get()); - userListManager->storeUserListDiff(name, diff.get()); - - Common::XmlData ret; - ret.setType("OK"); - sendPacket(ret); - - signalFinished(); - } -} - -} -} -} -} diff --git a/src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.h b/src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.h deleted file mode 100644 index 205a87f..0000000 --- a/src/modules/UserListManager/RequestHandlers/UserListDiffUploadRequestHandler.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * UserListDiffUploadRequestHandler.h - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#ifndef MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTDIFFUPLOADREQUESTHANDLER_H_ -#define MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTDIFFUPLOADREQUESTHANDLER_H_ - -#include - -namespace Mad { -namespace Modules { -namespace UserListManager { - -class UserListManager; - -namespace RequestHandlers { - -class UserListDiffUploadRequestHandler : public Common::RequestHandler { - private: - std::string name; - - UserListManager *userListManager; - - protected: - virtual void handlePacket(boost::shared_ptr packet); - - public: - UserListDiffUploadRequestHandler(Common::Application *application, UserListManager *userListManager0) : Common::RequestHandler(application), userListManager(userListManager0) {} -}; - -} -} -} -} - -#endif /* MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTDIFFUPLOADREQUESTHANDLER_H_ */ diff --git a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp b/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp deleted file mode 100644 index 61bbf07..0000000 --- a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * UserListRequestHandlerGroup.cpp - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#include "UserListRequestHandlerGroup.h" -#include "../UserListManager.h" -#include "../Util.h" - -namespace Mad { -namespace Modules { -namespace UserListManager { -namespace RequestHandlers { - -void UserListRequestHandlerGroup::handleUserListListRequest(boost::shared_ptr /*packet*/, Common::XmlData *ret, Common::Connection *connection) { - if(!connection->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - const std::set &userLists = userListManager->getUserLists(); - - ret->setType("OK"); - Common::XmlData::List *list = ret->createList("userLists"); - - for(std::set::const_iterator userList = userLists.begin(); userList != userLists.end(); ++userList) { - Common::XmlData::List::iterator entry = list->addEntry(); - - entry->set("name", *userList); - } - -} - -void UserListRequestHandlerGroup::handleUserListDownloadRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection) { - if(!connection->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - boost::shared_ptr userList = userListManager->loadUserList(packet->get("name")); - if(!userList) - throw(Core::Exception(Core::Exception::NOT_FOUND)); - - ret->setType("OK"); - Util::serializeUserList(userList.get(), ret); -} - -void UserListRequestHandlerGroup::handleUserListCopyRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection) { - if(!connection->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - userListManager->copyUserList(packet->get("fromName"), packet->get("toName")); - - ret->setType("OK"); -} - -void UserListRequestHandlerGroup::handleUserListRenameRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection) { - if(!connection->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - userListManager->renameUserList(packet->get("fromName"), packet->get("toName")); - - ret->setType("OK"); -} - -void UserListRequestHandlerGroup::handleUserListRemoveRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection) { - if(!connection->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - userListManager->removeUserList(packet->get("name")); - - ret->setType("OK"); -} - - -void UserListRequestHandlerGroup::handleUserListDiffListRequest(boost::shared_ptr /*packet*/, Common::XmlData *ret, Common::Connection *connection) { - if(!connection->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - const std::set &userListDiffs = userListManager->getUserListDiffs(); - - ret->setType("OK"); - Common::XmlData::List *list = ret->createList("userListDiffs"); - - for(std::set::const_iterator diff = userListDiffs.begin(); diff != userListDiffs.end(); ++diff) { - Common::XmlData::List::iterator entry = list->addEntry(); - - entry->set("name", *diff); - } - -} - -void UserListRequestHandlerGroup::handleUserListDiffDownloadRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection) { - if(!connection->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - boost::shared_ptr diff = userListManager->loadUserListDiff(packet->get("name")); - if(!diff) - throw(Core::Exception(Core::Exception::NOT_FOUND)); - - ret->setType("OK"); - Util::serializeUserListDiff(diff.get(), ret); -} - -void UserListRequestHandlerGroup::handleUserListDiffCopyRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection) { - if(!connection->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - userListManager->copyUserListDiff(packet->get("fromName"), packet->get("toName")); - - ret->setType("OK"); -} - -void UserListRequestHandlerGroup::handleUserListDiffRenameRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection) { - if(!connection->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - userListManager->renameUserListDiff(packet->get("fromName"), packet->get("toName")); - - ret->setType("OK"); -} - -void UserListRequestHandlerGroup::handleUserListDiffRemoveRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection) { - if(!connection->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - userListManager->removeUserListDiff(packet->get("name")); - - ret->setType("OK"); -} - - -UserListRequestHandlerGroup::UserListRequestHandlerGroup(Server::Application *application0, UserListManager *userListManager0) -: application(application0), userListManager(userListManager0) { - 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)); - registerHandler("RenameUserList", boost::bind(&UserListRequestHandlerGroup::handleUserListRenameRequest, this, _1, _2, _3)); - registerHandler("RemoveUserList", boost::bind(&UserListRequestHandlerGroup::handleUserListRemoveRequest, this, _1, _2, _3)); - - registerHandler("ListUserListDiffs", boost::bind(&UserListRequestHandlerGroup::handleUserListDiffListRequest, this, _1, _2, _3)); - registerHandler("DownloadUserListDiff", boost::bind(&UserListRequestHandlerGroup::handleUserListDiffDownloadRequest, this, _1, _2, _3)); - registerHandler("CopyUserListDiff", boost::bind(&UserListRequestHandlerGroup::handleUserListDiffCopyRequest, this, _1, _2, _3)); - registerHandler("RenameUserListDiff", boost::bind(&UserListRequestHandlerGroup::handleUserListDiffRenameRequest, this, _1, _2, _3)); - registerHandler("RemoveUserListDiff", boost::bind(&UserListRequestHandlerGroup::handleUserListDiffRemoveRequest, this, _1, _2, _3)); -} - -} -} -} -} diff --git a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.h b/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.h deleted file mode 100644 index 61f4c7d..0000000 --- a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * UserListRequestHandlerGroup.h - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#ifndef MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTREQUESTHANDLERGROUP_H_ -#define MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTREQUESTHANDLERGROUP_H_ - -#include "../../export.h" - -#include - -namespace Mad { - -namespace Server { -class Application; -} - -namespace Modules { -namespace UserListManager { - -class UserListManager; - -namespace RequestHandlers { - -class MAD_MODULE_EXPORT UserListRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHandlerGroup { - private: - Server::Application *application; - UserListManager *userListManager; - - void handleUserListListRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection); - void handleUserListDownloadRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection); - void handleUserListCopyRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection); - void handleUserListRenameRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection); - void handleUserListRemoveRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection); - - void handleUserListDiffListRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection); - void handleUserListDiffDownloadRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection); - void handleUserListDiffCopyRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection); - void handleUserListDiffRenameRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection); - void handleUserListDiffRemoveRequest(boost::shared_ptr packet, Common::XmlData *ret, Common::Connection *connection); - - public: - UserListRequestHandlerGroup(Server::Application *application0, UserListManager *userListManager0); -}; - -} -} -} -} - -#endif /* MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTREQUESTHANDLERGROUP_H_ */ diff --git a/src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.cpp b/src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.cpp deleted file mode 100644 index 9d01b5e..0000000 --- a/src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * UserListUploadRequestHandler.cpp - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#include "UserListUploadRequestHandler.h" -#include "../UserListManager.h" -#include "../Util.h" - -#include - - -namespace Mad { -namespace Modules { -namespace UserListManager { -namespace RequestHandlers { - -void UserListUploadRequestHandler::handlePacket(boost::shared_ptr packet) { - if(packet->getType() == "Cancel") { - Common::XmlData ret; - ret.setType("OK"); - sendPacket(ret); - - signalFinished(); - return; - } - else if(packet->getType() != "UploadUserList") { - getApplication()->log(Core::Logger::LOG_ERROR, "Received an unexpected packet."); - - Common::XmlData ret; - ret.setType("Error"); - ret.set("ErrorCode", Core::Exception::UNEXPECTED_PACKET); - - sendPacket(ret); - - signalFinished(); - return; - } - - if(!getConnection()->isAuthenticated()) - throw(Core::Exception(Core::Exception::PERMISSION)); - - if(name.empty()) { // Request - name = packet->get("name"); - - if(name.empty()) - name = boost::posix_time::to_simple_string(boost::posix_time::second_clock::universal_time()); - - Common::XmlData ret; - ret.setType("Continue"); - ret.set("exists", userListManager->existsUserList(name)); - sendPacket(ret); - } - else { // Upload - boost::shared_ptr userList = Util::deserializeUserList(packet.get()); - userListManager->storeUserList(name, userList.get()); - - Common::XmlData ret; - ret.setType("OK"); - sendPacket(ret); - - signalFinished(); - } -} - -} -} -} -} diff --git a/src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.h b/src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.h deleted file mode 100644 index 933d4a5..0000000 --- a/src/modules/UserListManager/RequestHandlers/UserListUploadRequestHandler.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * UserListUploadRequestHandler.h - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#ifndef MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTUPLOADREQUESTHANDLER_H_ -#define MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTUPLOADREQUESTHANDLER_H_ - -#include - -namespace Mad { -namespace Modules { -namespace UserListManager { - -class UserListManager; - -namespace RequestHandlers { - -class UserListUploadRequestHandler : public Common::RequestHandler { - private: - std::string name; - - UserListManager *userListManager; - - protected: - virtual void handlePacket(boost::shared_ptr packet); - - public: - UserListUploadRequestHandler(Common::Application *application, UserListManager *userListManager0) : Common::RequestHandler(application), userListManager(userListManager0) {} -}; - -} -} -} -} - -#endif /* MAD_MODULES_USERLISTMANAGER_REQUESTHANDLERS_USERLISTUPLOADREQUESTHANDLER_H_ */ diff --git a/src/modules/UserListManager/UserList.h b/src/modules/UserListManager/UserList.h deleted file mode 100644 index 6ca3de4..0000000 --- a/src/modules/UserListManager/UserList.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * UserList.h - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#ifndef MAD_MODULES_USERLISTMANAGER_USERLIST_H_ -#define MAD_MODULES_USERLISTMANAGER_USERLIST_H_ - -#include "UserListEntry.h" - -#include - -namespace Mad { -namespace Modules { -namespace UserListManager { - -class UserList : public std::list { - public: - UserList() {} -}; - -} -} -} - -#endif /* MAD_MODULES_USERLISTMANAGER_USERLIST_H_ */ diff --git a/src/modules/UserListManager/UserListDiff.cpp b/src/modules/UserListManager/UserListDiff.cpp deleted file mode 100644 index a7b5f2f..0000000 --- a/src/modules/UserListManager/UserListDiff.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * UserListDiff.cpp - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#include "UserListDiff.h" -#include "UserList.h" - -namespace Mad { -namespace Modules { -namespace UserListManager { - -UserListDiff::UserListDiff(const UserList *oldList, const UserList *newList) { - for(UserList::const_iterator user = oldList->begin(); user != oldList->end(); ++user) - deletedUsers.insert(*user); - - for(UserList::const_iterator user = newList->begin(); user != newList->end(); ++user) { - std::set::const_iterator it = deletedUsers.find(*user); - - if(it != deletedUsers.end()) { - deletedUsers.erase(it); - unchangedUsers.insert(*user); - } - else { - addedUsers.insert(*user); - } - } -} - -} -} -} diff --git a/src/modules/UserListManager/UserListDiff.h b/src/modules/UserListManager/UserListDiff.h deleted file mode 100644 index de881bd..0000000 --- a/src/modules/UserListManager/UserListDiff.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * UserListDiff.h - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#ifndef MAD_MODULES_USERLISTMANAGER_USERLISTDIFF_H_ -#define MAD_MODULES_USERLISTMANAGER_USERLISTDIFF_H_ - -#include "../export.h" - -#include "UserListEntry.h" -#include - -#include - -namespace Mad { -namespace Modules { -namespace UserListManager { - -class UserList; - -class MAD_MODULE_EXPORT UserListDiff { - private: - std::set addedUsers; - std::set deletedUsers; - std::set unchangedUsers; - - public: - UserListDiff() {} - UserListDiff(const UserList *oldList, const UserList *newList); - - void invert() { - addedUsers.swap(deletedUsers); - } - - const std::set& getAddedUsers() const { - return addedUsers; - } - - const std::set& getDeletedUsers() const { - return deletedUsers; - } - - const std::set& getUnchangedUsers() const { - return unchangedUsers; - } - - bool insertAddedUser(UserListEntry user) { - if(deletedUsers.count(user) || unchangedUsers.count(user)) - return false; - - return addedUsers.insert(user).second; - } - - bool insertDeletedUser(UserListEntry user) { - if(addedUsers.count(user) || unchangedUsers.count(user)) - return false; - - return deletedUsers.insert(user).second; - } - - bool insertUnchangedUser(UserListEntry user) { - if(addedUsers.count(user) || deletedUsers.count(user)) - return false; - - return unchangedUsers.insert(user).second; - } -}; - -} -} -} - -#endif /* MAD_MODULES_USERLISTMANAGER_USERLISTDIFF_H_ */ diff --git a/src/modules/UserListManager/UserListEntry.h b/src/modules/UserListManager/UserListEntry.h deleted file mode 100644 index 59776d6..0000000 --- a/src/modules/UserListManager/UserListEntry.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * UserListEntry.h - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#ifndef MAD_MODULES_USERLISTMANAGER_USERLISTENTRY_H_ -#define MAD_MODULES_USERLISTMANAGER_USERLISTENTRY_H_ - -#include -#include -#include - - -namespace Mad { -namespace Modules { -namespace UserListManager { - -class UserListEntry { - private: - std::string name; - std::string group; - - std::map details; - - public: - UserListEntry(const std::string &name0 = std::string(), const std::string &group0 = std::string()) : name(name0), group(group0) {} - - const std::string& getName() const { - return name; - } - - void setName(const std::string &newName) { - name = newName; - } - - const std::string& getGroup() const { - return group; - } - - void setGroup(const std::string &newGroup) { - group = newGroup; - } - - std::set getDetailList() const { - std::set ret; - - for(std::map::const_iterator it = details.begin(); it != details.end(); ++it) - ret.insert(it->first); - - return ret; - } - - std::string getDetail(const std::string &name) const { - std::map::const_iterator it = details.find(name); - if(it != details.end()) - return it->second; - else - return std::string(); - } - - void setDetail(const std::string &name, const std::string &value) { - details.erase(name); - details.insert(std::make_pair(name, value)); - } - - void unsetDetail(const std::string &name) { - details.erase(name); - } - - bool operator<(const UserListEntry o) const { - return (name < o.name); - } -}; - -} -} -} - -#endif /* MAD_MODULES_USERLISTMANAGER_USERLISTENTRY_H_ */ diff --git a/src/modules/UserListManager/UserListManager.cpp b/src/modules/UserListManager/UserListManager.cpp deleted file mode 100644 index deb6214..0000000 --- a/src/modules/UserListManager/UserListManager.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * UserListManager.cpp - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#include "UserListManager.h" -#include "UserList.h" -#include "Util.h" -#include "RequestHandlers/UserListRequestHandlerGroup.h" -#include "RequestHandlers/UserListUploadRequestHandler.h" -#include "RequestHandlers/UserListDiffUploadRequestHandler.h" - -#include -#include -#include -#include -#include - -namespace Mad { -namespace Modules { -namespace UserListManager { - -UserListManager::UserListManager(Server::Application *application0) : application(application0), requestHandlerGroup(new RequestHandlers::UserListRequestHandlerGroup(application, this)) { - application->getConfigManager()->registerConfigurable(this); -} - -UserListManager::~UserListManager() { - application->getRequestManager()->unregisterPacketType("UploadUserList"); - application->getRequestManager()->unregisterPacketType("UploadUserListDiff"); - application->getRequestManager()->unregisterRequestHandlerGroup(requestHandlerGroup); - application->getConfigManager()->unregisterConfigurable(this); -} - - -void UserListManager::configFinished() { - userLists = application->getStorageManager()->list("UserList"); - userListDiffs = application->getStorageManager()->list("UserListDiff"); - - application->getRequestManager()->registerRequestHandlerGroup(requestHandlerGroup); - application->getRequestManager()->registerPacketType("UploadUserList", this); - application->getRequestManager()->registerPacketType("UploadUserListDiff", this); -} - -bool UserListManager::existsUserList(const std::string &name) { - return application->getStorageManager()->exists("UserList", name); -} - -boost::shared_ptr UserListManager::loadUserList(const std::string &name) { - boost::shared_ptr data = application->getStorageManager()->load("UserList", name); - - if(!data) - return boost::shared_ptr(); - - return Util::deserializeUserList(data.get()); -} - -void UserListManager::storeUserList(const std::string &name, const UserList *list) { - Common::XmlData data; - - Util::serializeUserList(list, &data); - application->getStorageManager()->store("UserList", name, &data); -} - -void UserListManager::copyUserList(const std::string &fromName, const std::string &toName) { - application->getStorageManager()->copy("UserList", fromName, toName); -} - -void UserListManager::renameUserList(const std::string &fromName, const std::string &toName) { - application->getStorageManager()->rename("UserList", fromName, toName); -} - -void UserListManager::removeUserList(const std::string &name) { - application->getStorageManager()->remove("UserList", name); -} - - -bool UserListManager::existsUserListDiff(const std::string &name) { - return application->getStorageManager()->exists("UserListDiff", name); -} - -boost::shared_ptr UserListManager::loadUserListDiff(const std::string &name) { - boost::shared_ptr data = application->getStorageManager()->load("UserListDiff", name); - - if(!data) - return boost::shared_ptr(); - - return Util::deserializeUserListDiff(data.get()); -} - -void UserListManager::storeUserListDiff(const std::string &name, const UserListDiff *list) { - Common::XmlData data; - - Util::serializeUserListDiff(list, &data); - application->getStorageManager()->store("UserListDiff", name, &data); -} - -void UserListManager::copyUserListDiff(const std::string &fromName, const std::string &toName) { - application->getStorageManager()->copy("UserListDiff", fromName, toName); -} - -void UserListManager::renameUserListDiff(const std::string &fromName, const std::string &toName) { - application->getStorageManager()->rename("UserListDiff", fromName, toName); -} - -void UserListManager::removeUserListDiff(const std::string &name) { - application->getStorageManager()->remove("UserListDiff", name); -} - -boost::shared_ptr UserListManager::getCurrentUserList() { - boost::shared_ptr list(new UserList); - - boost::shared_ptr > userList = application->getUserManager()->getUserList(); - boost::shared_ptr > groupList = application->getUserManager()->getGroupList(); - - for(std::map::const_iterator user = userList->begin(); user != userList->end(); ++user) { - std::map::const_iterator group = groupList->find(user->second.getGid()); - std::string groupname; - - if(group != groupList->end()) { - groupname = group->second.getName(); - } - else { - std::ostringstream stream; - stream << user->second.getGid(); - groupname = stream.str(); - } - - UserListEntry entry(user->second.getUsername(), groupname); - entry.setDetail("Full name", user->second.getFullName()); - - list->push_back(entry); - } - - return list; -} - -} -} -} diff --git a/src/modules/UserListManager/UserListManager.h b/src/modules/UserListManager/UserListManager.h deleted file mode 100644 index 6763dae..0000000 --- a/src/modules/UserListManager/UserListManager.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * UserListManager.h - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#ifndef MAD_MODULES_USERLISTMANAGER_USERLISTMANAGER_H_ -#define MAD_MODULES_USERLISTMANAGER_USERLISTMANAGER_H_ - -#include "../export.h" - -#include - -#include -#include - -#include - -namespace Mad { - -namespace Server { -class Application; -} - -namespace Modules { -namespace UserListManager { - -namespace RequestHandlers { -class UserListRequestHandlerGroup; -} - -class UserList; -class UserListDiff; - -class MAD_MODULE_EXPORT UserListManager : private Core::Configurable, private boost::noncopyable { - private: - Server::Application *application; - - boost::shared_ptr requestHandlerGroup; - - std::set userLists; - std::set userListDiffs; - - protected: - virtual void configFinished(); - - public: - virtual int getPriority() const {return -1;} - - UserListManager(Server::Application *application0); - virtual ~UserListManager(); - - const std::set& getUserLists() const { - return userLists; - } - - bool existsUserList(const std::string &name); - boost::shared_ptr loadUserList(const std::string &name); - void storeUserList(const std::string &name, const 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); - - const std::set& getUserListDiffs() const { - return userListDiffs; - } - - bool existsUserListDiff(const std::string &name); - boost::shared_ptr loadUserListDiff(const std::string &name); - void storeUserListDiff(const std::string &name, const 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 getCurrentUserList(); -}; - -} -} -} - -#endif /* MAD_MODULES_USERLISTMANAGER_USERLISTMANAGER_H_ */ diff --git a/src/modules/UserListManager/Util.cpp b/src/modules/UserListManager/Util.cpp deleted file mode 100644 index 9b986d8..0000000 --- a/src/modules/UserListManager/Util.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Util.cpp - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#include "Util.h" -#include "UserList.h" -#include "UserListDiff.h" - -#include - -namespace Mad { -namespace Modules { -namespace UserListManager { - -void Util::serializeUserListEntry(const UserListEntry *user, Common::XmlData::List::iterator entry) { - std::set details = user->getDetailList(); - for(std::set::iterator detail = details.begin(); detail != details.end(); ++detail) - entry->set(*detail, user->getDetail(*detail)); - - entry->set("name", user->getName()); - entry->set("group", user->getGroup()); -} - -UserListEntry Util::deserializeUserListEntry(Common::XmlData::List::const_iterator entry) { - UserListEntry user(entry->get("name"), entry->get("group")); - - std::set details = entry->getChildren(); - for(std::set::iterator detail = details.begin(); detail != details.end(); ++detail) { - if(*detail == "user" || *detail == "group") - continue; - - user.setDetail(*detail, entry->get(*detail)); - } - - return user; -} - -void Util::serializeUserList(const UserList *list, Common::XmlData *data) { - Common::XmlData::List *userList = data->createList("users"); - - for(UserList::const_iterator user = list->begin(); user != list->end(); ++user) - serializeUserListEntry(&*user, userList->addEntry()); -} - -boost::shared_ptr Util::deserializeUserList(const Common::XmlData *data) { - boost::shared_ptr users(new UserList); - - const Common::XmlData::List *userList = data->getList("users"); - - if(userList) { - for(Common::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"); - for(std::set::const_iterator user = diff->getAddedUsers().begin(); user != diff->getAddedUsers().end(); ++user) - serializeUserListEntry(&*user, userList->addEntry()); - - userList = data->createList("deletedUsers"); - for(std::set::const_iterator user = diff->getDeletedUsers().begin(); user != diff->getDeletedUsers().end(); ++user) - serializeUserListEntry(&*user, userList->addEntry()); - - userList = data->createList("unchangedUsers"); - for(std::set::const_iterator user = diff->getUnchangedUsers().begin(); user != diff->getUnchangedUsers().end(); ++user) - serializeUserListEntry(&*user, userList->addEntry()); -} - -boost::shared_ptr Util::deserializeUserListDiff(const Common::XmlData *data) { - boost::shared_ptr diff(new UserListDiff); - - const Common::XmlData::List *userList = data->getList("addedUsers"); - if(userList) { - for(Common::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) - diff->insertDeletedUser(deserializeUserListEntry(user)); - } - - userList = data->getList("unchangedUsers"); - if(userList) { - for(Common::XmlData::List::const_iterator user = userList->begin(); user != userList->end(); ++user) - diff->insertUnchangedUser(deserializeUserListEntry(user)); - } - - return diff; -} - -} -} -} diff --git a/src/modules/UserListManager/Util.h b/src/modules/UserListManager/Util.h deleted file mode 100644 index c9b9a2c..0000000 --- a/src/modules/UserListManager/Util.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Util.h - * - * Copyright (C) 2009 Matthias Schiffer - * - * 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 . - */ - -#ifndef MAD_MODULES_USERLISTMANAGER_UTIL_H_ -#define MAD_MODULES_USERLISTMANAGER_UTIL_H_ - -#include "../export.h" - -#include -#include - -namespace Mad { -namespace Modules { -namespace UserListManager { - -class UserList; -class UserListDiff; -class UserListEntry; - -class MAD_MODULE_EXPORT Util { - private: - static void serializeUserListEntry(const UserListEntry *user, Common::XmlData::List::iterator entry); - static UserListEntry deserializeUserListEntry(Common::XmlData::List::const_iterator entry); - - Util(); - - public: - static void serializeUserList(const UserList *list, Common::XmlData *data); - static boost::shared_ptr deserializeUserList(const Common::XmlData *data); - - static void serializeUserListDiff(const UserListDiff *diff, Common::XmlData *data); - static boost::shared_ptr deserializeUserListDiff(const Common::XmlData *data); -}; - -} -} -} - -#endif /* MAD_MODULES_USERLISTMANAGER_UTIL_H_ */ -- cgit v1.2.3