diff options
author | James Cook <james@lindenlab.com> | 2010-04-20 17:05:49 -0700 |
---|---|---|
committer | James Cook <james@lindenlab.com> | 2010-04-20 17:05:49 -0700 |
commit | 022a598694cd37bebff3322054324c7d27afd5ff (patch) | |
tree | 81fbb61a86ee00c8b3287eaedd7da2af39da188f /indra/llmessage/llavatarnamecache.cpp | |
parent | 257c3ed2a3747256500f704f6e06e7631af3c08e (diff) |
Viewer caches avatar display names between sessions
Reviewed with Simon
Diffstat (limited to 'indra/llmessage/llavatarnamecache.cpp')
-rw-r--r-- | indra/llmessage/llavatarnamecache.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 69770c1f2a..d10958d09d 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -37,6 +37,7 @@ #include "llframetimer.h" #include "llhttpclient.h" #include "llsd.h" +#include "llsdserialize.h" #include <map> #include <set> @@ -243,10 +244,43 @@ void LLAvatarNameCache::cleanupClass() void LLAvatarNameCache::importFile(std::istream& istr) { + LLSD data; + S32 parse_count = LLSDSerialize::fromXMLDocument(data, istr); + if (parse_count < 1) return; + + // by convention LLSD storage is a map + // we only store one entry in the map + LLSD agents = data["agents"]; + + LLUUID agent_id; + LLAvatarName av_name; + LLSD::map_const_iterator it = agents.beginMap(); + for ( ; it != agents.endMap(); ++it) + { + agent_id.set(it->first); + av_name.fromLLSD( it->second ); + sCache[agent_id] = av_name; + } + // entries may have expired since we last ran the viewer, just + // clean them out now + eraseExpired(); + llinfos << "loaded " << sCache.size() << llendl; } void LLAvatarNameCache::exportFile(std::ostream& ostr) { + LLSD agents; + cache_t::const_iterator it = sCache.begin(); + for ( ; it != sCache.end(); ++it) + { + const LLUUID& agent_id = it->first; + const LLAvatarName& av_name = it->second; + // key must be a string + agents[agent_id.asString()] = av_name.asLLSD(); + } + LLSD data; + data["agents"] = agents; + LLSDSerialize::toPrettyXML(data, ostr); } void LLAvatarNameCache::setNameLookupURL(const std::string& name_lookup_url) |