diff options
Diffstat (limited to 'src/Server/RequestHandlers')
3 files changed, 46 insertions, 46 deletions
diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp index 3af5439..dafbaa8 100644 --- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp @@ -32,24 +32,24 @@ void ConnectionRequestHandlerGroup::handleDaemonListRequest(boost::shared_ptr<co // TODO Require authentication ret->setType("OK"); - ret->addList("hosts"); + Common::XmlPacket::List *list = ret->createList("hosts"); std::vector<Common::HostInfo> daemons = application->getConnectionManager()->getDaemonList(); for(std::vector<Common::HostInfo>::iterator daemon = daemons.begin(); daemon != daemons.end(); ++daemon) { - (*ret)["hosts"].addEntry(); + Common::XmlPacket::List::iterator entry = list->addEntry(); - (*ret)["hosts"].back().add("name", daemon->getName()); - (*ret)["hosts"].back().add("address", daemon->getIP()); - (*ret)["hosts"].back().add("state", daemon->getState()); + entry->set("name", daemon->getName()); + entry->set("address", daemon->getIP()); + entry->set("state", daemon->getState()); } } void ConnectionRequestHandlerGroup::handleIdentifyRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if((*packet)["hostname"].isEmpty()) + if(packet->get<const std::string&>("hostname").empty()) application->getConnectionManager()->identifyClientConnection(connection); else - application->getConnectionManager()->identifyDaemonConnection(connection, (*packet)["hostname"]); + application->getConnectionManager()->identifyDaemonConnection(connection, packet->get<const std::string&>("hostname")); ret->setType("OK"); } @@ -58,7 +58,11 @@ void ConnectionRequestHandlerGroup::handleLogRequest(boost::shared_ptr<const Com // TODO Require authentication try { - application->getLogManager()->log((*packet)["category"], (*packet)["level"], (*packet)["timestamp"], (*packet)["message"], + application->getLogManager()->log( + packet->get<Core::LoggerBase::MessageCategory>("category"), + packet->get<Core::LoggerBase::MessageLevel>("level"), + packet->get<time_t>("timestamp"), + packet->get<const std::string&>("message"), application->getConnectionManager()->getDaemonName(connection)); } catch(Core::Exception &e) { diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp index 344cf4c..0105707 100644 --- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp @@ -36,7 +36,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Core::Exception::UNEXPECTED_PACKET); + ret.set("ErrorCode", Core::Exception::UNEXPECTED_PACKET); sendPacket(ret); @@ -47,11 +47,11 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared // TODO Require authentication try { - boost::shared_ptr<Common::Connection> daemonCon = dynamic_cast<Application&>(*getApplication()).getConnectionManager()->getDaemonConnection((*packet)["daemon"]); + boost::shared_ptr<Common::Connection> daemonCon = dynamic_cast<Application&>(*getApplication()).getConnectionManager()->getDaemonConnection(packet->get<const std::string&>("daemon")); boost::shared_ptr<Common::Request> request; if(type == "DaemonCommand") - request.reset(new Requests::CommandRequest(getApplication(), (std::string&)((*packet)["command"]) == "reboot")); + request.reset(new Requests::CommandRequest(getApplication(), (packet->get<const std::string&>("command") == "reboot"))); else if(type == "DaemonFSInfo") request.reset(new Common::Requests::FSInfoRequest(getApplication())); else // type == "GetDaemonStatus" @@ -63,10 +63,10 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared catch(Core::Exception &e) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", e.getErrorCode()); - ret.add("SubCode", e.getSubCode()); - ret.add("SubSubCode", e.getSubSubCode()); - ret.add("Where", e.getWhere()); + ret.set("ErrorCode", e.getErrorCode()); + ret.set("SubCode", e.getSubCode()); + ret.set("SubSubCode", e.getSubSubCode()); + ret.set("Where", e.getWhere()); sendPacket(ret); signalFinished(); @@ -77,10 +77,10 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::requestFinished(boost::sha if(error) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", error.getErrorCode()); - ret.add("SubCode", error.getSubCode()); - ret.add("SubSubCode", error.getSubSubCode()); - ret.add("Where", error.getWhere()); + ret.set("ErrorCode", error.getErrorCode()); + ret.set("SubCode", error.getSubCode()); + ret.set("SubSubCode", error.getSubSubCode()); + ret.set("Where", error.getWhere()); sendPacket(ret); } 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); } } |