From dff7c00a0c2c3fcb64efd611d70398d711ad861b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 24 Jun 2009 00:04:28 +0200 Subject: NetworkUserBackend implementiert --- .../RequestHandlers/UserRequestHandlerGroup.cpp | 42 +++++++++++++++++----- .../RequestHandlers/UserRequestHandlerGroup.h | 2 ++ 2 files changed, 35 insertions(+), 9 deletions(-) (limited to 'src/Server/RequestHandlers') diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp index 6378e08..31d2c16 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp @@ -27,12 +27,12 @@ namespace RequestHandlers { void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr packet _UNUSED_PARAMETER_, Common::XmlPacket *ret, Common::Connection *connection _UNUSED_PARAMETER_) { - boost::shared_ptr > info = application->getUserManager()->getUserList(); + boost::shared_ptr > info = application->getUserManager()->getUserList(); ret->setType("OK"); Common::XmlPacket::List *list = ret->createList("users"); - for(std::map::iterator user = info->begin(); user != info->end(); ++user) { + for(std::map::const_iterator user = info->begin(); user != info->end(); ++user) { Common::XmlPacket::List::iterator entry = list->addEntry(); entry->set("uid", user->second.getUid()); @@ -44,7 +44,13 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr packet, Common::XmlPacket *ret, Common::Connection *connection _UNUSED_PARAMETER_) { - boost::shared_ptr info = application->getUserManager()->getUserInfo(packet->get("uid")); + boost::shared_ptr info; + + unsigned long uid = packet->get("uid"); + if(uid) + info = application->getUserManager()->getUserInfo(uid); + else + info = application->getUserManager()->getUserInfoByName(packet->get("name")); ret->setType("OK"); @@ -56,12 +62,12 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr packet, Common::XmlPacket *ret, Common::Connection *connection _UNUSED_PARAMETER_) { - boost::shared_ptr > groups = application->getUserManager()->getUserGroupList(packet->get("uid")); + boost::shared_ptr > groups = application->getUserManager()->getUserGroupList(packet->get("uid")); ret->setType("OK"); Common::XmlPacket::List *list = ret->createList("groups"); - for(std::set::iterator group = groups->begin(); group != groups->end(); ++group) { + for(std::set::const_iterator group = groups->begin(); group != groups->end(); ++group) { Common::XmlPacket::List::iterator entry = list->addEntry(); entry->set("gid", *group); @@ -70,12 +76,12 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr packet _UNUSED_PARAMETER_, Common::XmlPacket *ret, Common::Connection *connection _UNUSED_PARAMETER_) { - boost::shared_ptr > info = application->getUserManager()->getGroupList(); + boost::shared_ptr > info = application->getUserManager()->getGroupList(); ret->setType("OK"); Common::XmlPacket::List *list = ret->createList("groups"); - for(std::map::iterator group = info->begin(); group != info->end(); ++group) { + for(std::map::const_iterator group = info->begin(); group != info->end(); ++group) { Common::XmlPacket::List::iterator entry = list->addEntry(); entry->set("gid", group->second.getGid()); @@ -83,14 +89,30 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr packet, Common::XmlPacket *ret, + Common::Connection *connection _UNUSED_PARAMETER_) { + boost::shared_ptr info; + + unsigned long gid = packet->get("gid"); + if(gid) + info = application->getUserManager()->getGroupInfo(gid); + else + info = application->getUserManager()->getGroupInfoByName(packet->get("name")); + + ret->setType("OK"); + + ret->set("gid", info->getGid()); + ret->set("name", info->getName()); +} + void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr packet, Common::XmlPacket *ret, Common::Connection *connection _UNUSED_PARAMETER_) { - boost::shared_ptr > users = application->getUserManager()->getGroupUserList(packet->get("gid")); + boost::shared_ptr > users = application->getUserManager()->getGroupUserList(packet->get("gid")); ret->setType("OK"); Common::XmlPacket::List *list = ret->createList("users"); - for(std::set::iterator user = users->begin(); user != users->end(); ++user) { + for(std::set::const_iterator user = users->begin(); user != users->end(); ++user) { Common::XmlPacket::List::iterator entry = list->addEntry(); entry->set("uid", *user); @@ -101,7 +123,9 @@ UserRequestHandlerGroup::UserRequestHandlerGroup(Application *application0) : ap registerHandler("ListUsers", boost::bind(&UserRequestHandlerGroup::handleUserListRequest, this, _1, _2, _3)); registerHandler("GetUserInfo", boost::bind(&UserRequestHandlerGroup::handleUserInfoRequest, this, _1, _2, _3)); registerHandler("ListUserGroups", boost::bind(&UserRequestHandlerGroup::handleUserGroupListRequest, this, _1, _2, _3)); + registerHandler("ListGroups", boost::bind(&UserRequestHandlerGroup::handleGroupListRequest, this, _1, _2, _3)); + registerHandler("GetGroupInfo", boost::bind(&UserRequestHandlerGroup::handleGroupInfoRequest, this, _1, _2, _3)); registerHandler("ListGroupUsers", boost::bind(&UserRequestHandlerGroup::handleGroupUserListRequest, this, _1, _2, _3)); } diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.h b/src/Server/RequestHandlers/UserRequestHandlerGroup.h index 2a17a9a..744f895 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.h +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.h @@ -36,7 +36,9 @@ class UserRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHan void handleUserListRequest(boost::shared_ptr packet, Common::XmlPacket *ret, Common::Connection *connection); void handleUserInfoRequest(boost::shared_ptr packet, Common::XmlPacket *ret, Common::Connection *connection); void handleUserGroupListRequest(boost::shared_ptr packet, Common::XmlPacket *ret, Common::Connection *connection); + void handleGroupListRequest(boost::shared_ptr packet, Common::XmlPacket *ret, Common::Connection *connection); + void handleGroupInfoRequest(boost::shared_ptr packet, Common::XmlPacket *ret, Common::Connection *connection); void handleGroupUserListRequest(boost::shared_ptr packet, Common::XmlPacket *ret, Common::Connection *connection); public: -- cgit v1.2.3