From 78db15a780cc5389fc6e01d500d5c91bdd8bc422 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 19 Sep 2009 18:12:26 +0200 Subject: UserListManager: Added user list diff support. --- src/modules/UserListManager/UserListManager.cpp | 35 ++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/modules/UserListManager/UserListManager.cpp') diff --git a/src/modules/UserListManager/UserListManager.cpp b/src/modules/UserListManager/UserListManager.cpp index 18ed83c..e947e24 100644 --- a/src/modules/UserListManager/UserListManager.cpp +++ b/src/modules/UserListManager/UserListManager.cpp @@ -22,6 +22,7 @@ #include "Util.h" #include "RequestHandlers/UserListRequestHandlerGroup.h" #include "RequestHandlers/UserListUploadRequestHandler.h" +#include "RequestHandlers/UserListDiffUploadRequestHandler.h" #include #include @@ -39,6 +40,7 @@ UserListManager::UserListManager(Server::Application *application0) : applicatio UserListManager::~UserListManager() { application->getRequestManager()->unregisterPacketType("UploadUserList"); + application->getRequestManager()->unregisterPacketType("UploadUserListDiff"); application->getRequestManager()->unregisterRequestHandlerGroup(requestHandlerGroup); application->getConfigManager()->unregisterConfigurable(this); } @@ -46,17 +48,13 @@ UserListManager::~UserListManager() { 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); } - -const std::set& UserListManager::getUserLists() const { - return userLists; -} - - bool UserListManager::existsUserList(const std::string &name) { return application->getStorageManager()->exists("UserList", name); } @@ -81,6 +79,31 @@ 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::removeUserListDiff(const std::string &name) { + application->getStorageManager()->remove("UserListDiff", name); +} + boost::shared_ptr UserListManager::getCurrentUserList() { boost::shared_ptr list(new UserList); -- cgit v1.2.3