diff options
Diffstat (limited to 'src/Server')
-rw-r--r-- | src/Server/RequestHandlers/UserRequestHandlerGroup.cpp | 42 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserRequestHandlerGroup.h | 2 |
2 files changed, 35 insertions, 9 deletions
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<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret, Common::Connection *connection _UNUSED_PARAMETER_) { - boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > info = application->getUserManager()->getUserList(); + boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > info = application->getUserManager()->getUserList(); ret->setType("OK"); Common::XmlPacket::List *list = ret->createList("users"); - for(std::map<unsigned long, Common::UserInfo>::iterator user = info->begin(); user != info->end(); ++user) { + for(std::map<unsigned long, Common::UserInfo>::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<const Comm void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection _UNUSED_PARAMETER_) { - boost::shared_ptr<Common::UserInfo> info = application->getUserManager()->getUserInfo(packet->get<unsigned long>("uid")); + boost::shared_ptr<const Common::UserInfo> info; + + unsigned long uid = packet->get<unsigned long>("uid"); + if(uid) + info = application->getUserManager()->getUserInfo(uid); + else + info = application->getUserManager()->getUserInfoByName(packet->get<const std::string&>("name")); ret->setType("OK"); @@ -56,12 +62,12 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Comm void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection _UNUSED_PARAMETER_) { - boost::shared_ptr<std::set<unsigned long> > groups = application->getUserManager()->getUserGroupList(packet->get<unsigned long>("uid")); + boost::shared_ptr<const std::set<unsigned long> > groups = application->getUserManager()->getUserGroupList(packet->get<unsigned long>("uid")); ret->setType("OK"); Common::XmlPacket::List *list = ret->createList("groups"); - for(std::set<unsigned long>::iterator group = groups->begin(); group != groups->end(); ++group) { + for(std::set<unsigned long>::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<const void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret, Common::Connection *connection _UNUSED_PARAMETER_) { - boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > info = application->getUserManager()->getGroupList(); + boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > info = application->getUserManager()->getGroupList(); ret->setType("OK"); Common::XmlPacket::List *list = ret->createList("groups"); - for(std::map<unsigned long, Common::GroupInfo>::iterator group = info->begin(); group != info->end(); ++group) { + for(std::map<unsigned long, Common::GroupInfo>::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<const Com } } +void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, + Common::Connection *connection _UNUSED_PARAMETER_) { + boost::shared_ptr<const Common::GroupInfo> info; + + unsigned long gid = packet->get<unsigned long>("gid"); + if(gid) + info = application->getUserManager()->getGroupInfo(gid); + else + info = application->getUserManager()->getGroupInfoByName(packet->get<const std::string&>("name")); + + ret->setType("OK"); + + ret->set("gid", info->getGid()); + ret->set("name", info->getName()); +} + void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection _UNUSED_PARAMETER_) { - boost::shared_ptr<std::set<unsigned long> > users = application->getUserManager()->getGroupUserList(packet->get<unsigned long>("gid")); + boost::shared_ptr<const std::set<unsigned long> > users = application->getUserManager()->getGroupUserList(packet->get<unsigned long>("gid")); ret->setType("OK"); Common::XmlPacket::List *list = ret->createList("users"); - for(std::set<unsigned long>::iterator user = users->begin(); user != users->end(); ++user) { + for(std::set<unsigned long>::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<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection); void handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection); void handleUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection); + void handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection); + void handleGroupInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection); void handleGroupUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection); public: |