summaryrefslogtreecommitdiffstats
path: root/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp')
-rw-r--r--src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp b/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp
index 98d2815..99d2818 100644
--- a/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp
+++ b/src/modules/UserListManager/RequestHandlers/UserListRequestHandlerGroup.cpp
@@ -64,11 +64,55 @@ void UserListRequestHandlerGroup::handleUserListRemoveRequest(boost::shared_ptr<
ret->setType("OK");
}
+
+void UserListRequestHandlerGroup::handleUserListDiffListRequest(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> &userListDiffs = userListManager->getUserListDiffs();
+
+ ret->setType("OK");
+ Common::XmlData::List *list = ret->createList("userListDiffs");
+
+ for(std::set<std::string>::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<const Common::XmlData> packet, Common::XmlData *ret, Common::Connection *connection) {
+ if(!connection->isAuthenticated())
+ throw(Core::Exception(Core::Exception::PERMISSION));
+
+ boost::shared_ptr<UserListDiff> diff = userListManager->loadUserListDiff(packet->get<const std::string&>("name"));
+ if(!diff)
+ throw(Core::Exception(Core::Exception::NOT_FOUND));
+
+ ret->setType("OK");
+ Util::serializeUserListDiff(diff.get(), ret);
+}
+
+void UserListRequestHandlerGroup::handleUserListDiffRemoveRequest(boost::shared_ptr<const Common::XmlData> packet, Common::XmlData *ret, Common::Connection *connection) {
+ if(!connection->isAuthenticated())
+ throw(Core::Exception(Core::Exception::PERMISSION));
+
+ userListManager->removeUserListDiff(packet->get<const std::string&>("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("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("RemoveUserListDiff", boost::bind(&UserListRequestHandlerGroup::handleUserListDiffRemoveRequest, this, _1, _2, _3));
}
}