summaryrefslogtreecommitdiffstats
path: root/src/Client/InformationManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Client/InformationManager.cpp')
-rw-r--r--src/Client/InformationManager.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp
index a4a63fb..a618eb3 100644
--- a/src/Client/InformationManager.cpp
+++ b/src/Client/InformationManager.cpp
@@ -35,9 +35,9 @@ void InformationManager::DaemonStateUpdateRequestHandler::handleRequest(boost::s
{
boost::lock_guard<boost::mutex> lock(informationManager->mutex);
- std::map<std::string, Common::HostInfo>::iterator host = informationManager->daemons.find((*packet)["name"]);
+ std::map<std::string, Common::HostInfo>::iterator host = informationManager->daemons.find(packet->get<const std::string&>("name"));
if(host != informationManager->daemons.end())
- host->second.setState((*packet)["state"]);
+ host->second.setState(packet->get<Common::HostInfo::State>("state"));
else
getApplication()->log(Core::LoggerBase::WARNING, "Received a state update for an unknown host.");
}
@@ -75,17 +75,19 @@ void InformationManager::daemonListRequestFinished(boost::shared_ptr<const Commo
application->logf(Core::LoggerBase::CRITICAL, "Host list request failed: %s", error.strerror().c_str());
}
else {
- const Common::XmlPacket::Element &hostInfo = (*packet)["hosts"];
+ const Common::XmlPacket::List *list = packet->getList("hosts");
daemons.clear();
- for(size_t i = 0; i < hostInfo.getSize(); ++i) {
- Common::HostInfo info;
- info.setName(hostInfo[i]["name"]);
- info.setIP(hostInfo[i]["address"]);
- info.setState(hostInfo[i]["state"]);
+ if(list) {
+ for(Common::XmlPacket::List::const_iterator entry = list->begin(); entry != list->end(); ++entry) {
+ Common::HostInfo info;
+ info.setName(entry->get<const std::string&>("name"));
+ info.setIP(entry->get<const std::string&>("address"));
+ info.setState(entry->get<Common::HostInfo::State>("state"));
- daemons.insert(std::make_pair(info.getName(), info));
+ daemons.insert(std::make_pair(info.getName(), info));
+ }
}
}