From d6844595c9b47dab1db4b970ff6cc7fb3f64f107 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 20 Sep 2009 16:14:19 +0200 Subject: UserListManager: Added copy and rename requests --- .../UserListRequestHandlerGroup.cpp | 40 ++++++++++++++++++++++ .../RequestHandlers/UserListRequestHandlerGroup.h | 4 +++ src/modules/UserListManager/UserListManager.cpp | 16 +++++++++ src/modules/UserListManager/UserListManager.h | 4 +++ 4 files changed, 64 insertions(+) diff --git a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp b/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp index 99d2818..61bbf07 100644 --- a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp +++ b/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp @@ -55,6 +55,24 @@ void UserListRequestHandlerGroup::handleUserListDownloadRequest(boost::shared_pt 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)); @@ -94,6 +112,24 @@ void UserListRequestHandlerGroup::handleUserListDiffDownloadRequest(boost::share 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)); @@ -108,10 +144,14 @@ UserListRequestHandlerGroup::UserListRequestHandlerGroup(Server::Application *ap : 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 index 105621b..61f4c7d 100644 --- a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.h +++ b/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.h @@ -44,10 +44,14 @@ class MAD_MODULE_EXPORT UserListRequestHandlerGroup : public Common::RequestHan 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: diff --git a/src/modules/UserListManager/UserListManager.cpp b/src/modules/UserListManager/UserListManager.cpp index e947e24..deb6214 100644 --- a/src/modules/UserListManager/UserListManager.cpp +++ b/src/modules/UserListManager/UserListManager.cpp @@ -75,6 +75,14 @@ void UserListManager::storeUserList(const std::string &name, const UserList *lis 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); } @@ -100,6 +108,14 @@ void UserListManager::storeUserListDiff(const std::string &name, const UserListD 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); } diff --git a/src/modules/UserListManager/UserListManager.h b/src/modules/UserListManager/UserListManager.h index 6d2599b..6763dae 100644 --- a/src/modules/UserListManager/UserListManager.h +++ b/src/modules/UserListManager/UserListManager.h @@ -70,6 +70,8 @@ class MAD_MODULE_EXPORT UserListManager : private Core::Configurable, private bo 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 { @@ -79,6 +81,8 @@ class MAD_MODULE_EXPORT UserListManager : private Core::Configurable, private bo 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(); -- cgit v1.2.3