diff options
Diffstat (limited to 'src/Server/RequestHandlers/UserRequestHandlerGroup.cpp')
-rw-r--r-- | src/Server/RequestHandlers/UserRequestHandlerGroup.cpp | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp index 34fae36..6378e08 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp @@ -30,43 +30,41 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Comm boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > info = application->getUserManager()->getUserList(); ret->setType("OK"); - ret->addList("users"); + Common::XmlPacket::List *list = ret->createList("users"); for(std::map<unsigned long, Common::UserInfo>::iterator user = info->begin(); user != info->end(); ++user) { - (*ret)["users"].addEntry(); - Common::XmlPacket::Entry &entry = (*ret)["users"].back(); + Common::XmlPacket::List::iterator entry = list->addEntry(); - entry.add("uid", user->second.getUid()); - entry.add("gid", user->second.getGid()); - entry.add("username", user->second.getUsername()); - entry.add("fullName", user->second.getFullName()); + entry->set("uid", user->second.getUid()); + entry->set("gid", user->second.getGid()); + entry->set("username", user->second.getUsername()); + entry->set("fullName", user->second.getFullName()); } } 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)["uid"]); + boost::shared_ptr<Common::UserInfo> info = application->getUserManager()->getUserInfo(packet->get<unsigned long>("uid")); ret->setType("OK"); - ret->add("uid", info->getUid()); - ret->add("gid", info->getGid()); - ret->add("username", info->getUsername()); - ret->add("fullName", info->getFullName()); + ret->set("uid", info->getUid()); + ret->set("gid", info->getGid()); + ret->set("username", info->getUsername()); + ret->set("fullName", info->getFullName()); } 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((unsigned long)(*packet)["uid"]); + boost::shared_ptr<std::set<unsigned long> > groups = application->getUserManager()->getUserGroupList(packet->get<unsigned long>("uid")); ret->setType("OK"); - ret->addList("groups"); + Common::XmlPacket::List *list = ret->createList("groups"); for(std::set<unsigned long>::iterator group = groups->begin(); group != groups->end(); ++group) { - (*ret)["groups"].addEntry(); - Common::XmlPacket::Entry &entry = (*ret)["groups"].back(); + Common::XmlPacket::List::iterator entry = list->addEntry(); - entry.add("gid", *group); + entry->set("gid", *group); } } @@ -75,29 +73,27 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Com boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > info = application->getUserManager()->getGroupList(); ret->setType("OK"); - ret->addList("groups"); + Common::XmlPacket::List *list = ret->createList("groups"); for(std::map<unsigned long, Common::GroupInfo>::iterator group = info->begin(); group != info->end(); ++group) { - (*ret)["groups"].addEntry(); - Common::XmlPacket::Entry &entry = (*ret)["groups"].back(); + Common::XmlPacket::List::iterator entry = list->addEntry(); - entry.add("gid", group->second.getGid()); - entry.add("name", group->second.getName()); + entry->set("gid", group->second.getGid()); + entry->set("name", group->second.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((unsigned long)(*packet)["gid"]); + boost::shared_ptr<std::set<unsigned long> > users = application->getUserManager()->getGroupUserList(packet->get<unsigned long>("gid")); ret->setType("OK"); - ret->addList("users"); + Common::XmlPacket::List *list = ret->createList("users"); for(std::set<unsigned long>::iterator user = users->begin(); user != users->end(); ++user) { - (*ret)["users"].addEntry(); - Common::XmlPacket::Entry &entry = (*ret)["users"].back(); + Common::XmlPacket::List::iterator entry = list->addEntry(); - entry.add("uid", *user); + entry->set("uid", *user); } } |