diff options
Diffstat (limited to 'src/modules/UserListManager/UserListManager.cpp')
-rw-r--r-- | src/modules/UserListManager/UserListManager.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
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 <Server/Application.h> #include <Common/RequestManager.h> @@ -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<RequestHandlers::UserListUploadRequestHandler>("UploadUserList", this); + application->getRequestManager()->registerPacketType<RequestHandlers::UserListDiffUploadRequestHandler>("UploadUserListDiff", this); } - -const std::set<std::string>& 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<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 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<UserList> UserListManager::getCurrentUserList() { boost::shared_ptr<UserList> list(new UserList); |