summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2012-12-05 20:25:46 -0800
committerMerov Linden <merov@lindenlab.com>2012-12-05 20:25:46 -0800
commit3a49beed0e96a797a6d663bcae5e932437ca3661 (patch)
treee2d779e70cd9c1566c465a8215dbd99ad6f52cd2 /indra/llmessage
parentd48357f54765f84a35b73bbf28e88b978bcb5013 (diff)
CHUI-580 : WIP : Change the display name cache system, deprecating the old protocol and using the cap (People API) whenever available. Still has occurence of Resident as last name to clean up.
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llavatarnamecache.cpp56
-rw-r--r--indra/llmessage/llavatarnamecache.h2
-rw-r--r--indra/llmessage/llcachename.cpp6
3 files changed, 23 insertions, 41 deletions
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp
index 700525e1fa..329871d8eb 100644
--- a/indra/llmessage/llavatarnamecache.cpp
+++ b/indra/llmessage/llavatarnamecache.cpp
@@ -43,10 +43,6 @@ namespace LLAvatarNameCache
{
use_display_name_signal_t mUseDisplayNamesSignal;
- // Manual override for display names - can disable even if the region
- // supports it.
- bool sUseDisplayNames = true;
-
// Cache starts in a paused state until we can determine if the
// current region supports display names.
bool sRunning = false;
@@ -209,17 +205,8 @@ public:
// Use expiration time from header
av_name.mExpires = expires;
- // Some avatars don't have explicit display names set
- if (av_name.mDisplayName.empty())
- {
- av_name.mDisplayName = av_name.mUsername;
- }
-
- LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result for " << agent_id << " "
- << "user '" << av_name.mUsername << "' "
- << "display '" << av_name.mDisplayName << "' "
- << "expires in " << expires - now << " seconds"
- << LL_ENDL;
+ LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result for " << agent_id << LL_ENDL;
+ av_name.dump();
// cache it and fire signals
LLAvatarNameCache::processName(agent_id, av_name, true);
@@ -291,12 +278,9 @@ void LLAvatarNameCache::handleAgentError(const LLUUID& agent_id)
LLAvatarNameCache::sPendingQueue.erase(agent_id);
LLAvatarName& av_name = existing->second;
- LL_DEBUGS("AvNameCache") << "LLAvatarNameCache use cache for agent "
- << agent_id
- << "user '" << av_name.mUsername << "' "
- << "display '" << av_name.mDisplayName << "' "
- << "expires in " << av_name.mExpires - LLFrameTimer::getTotalSeconds() << " seconds"
- << LL_ENDL;
+ LL_DEBUGS("AvNameCache") << "LLAvatarNameCache use cache for agent " << agent_id << LL_ENDL;
+ av_name.dump();
+
av_name.mExpires = LLFrameTimer::getTotalSeconds() + TEMP_CACHE_ENTRY_LIFETIME; // reset expiry time so we don't constantly rerequest.
}
}
@@ -476,7 +460,7 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr)
const LLUUID& agent_id = it->first;
const LLAvatarName& av_name = it->second;
// Do not write temporary or expired entries to the stored cache
- if (!av_name.mIsTemporaryName && av_name.mExpires >= max_unrefreshed)
+ if (av_name.isValidName(max_unrefreshed))
{
// key must be a string
agents[agent_id.asString()] = av_name.asLLSD();
@@ -513,7 +497,7 @@ void LLAvatarNameCache::idle()
if (!sAskQueue.empty())
{
- if (useDisplayNames())
+ if (hasNameLookupURL())
{
requestNamesViaCapability();
}
@@ -565,7 +549,7 @@ void LLAvatarNameCache::eraseUnrefreshed()
{
const LLUUID& agent_id = it->first;
LL_DEBUGS("AvNameCache") << agent_id
- << " user '" << av_name.mUsername << "' "
+ << " user '" << av_name.getUserName() << "' "
<< "expired " << now - av_name.mExpires << " secs ago"
<< LL_ENDL;
sCache.erase(it++);
@@ -583,14 +567,12 @@ void LLAvatarNameCache::buildLegacyName(const std::string& full_name,
LLAvatarName* av_name)
{
llassert(av_name);
- av_name->mUsername = "";
- av_name->mDisplayName = full_name;
- av_name->mIsDisplayNameDefault = true;
- av_name->mIsTemporaryName = true;
- av_name->mExpires = LLFrameTimer::getTotalSeconds() + TEMP_CACHE_ENTRY_LIFETIME;
+ av_name->fromString(full_name,TEMP_CACHE_ENTRY_LIFETIME);
LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::buildLegacyName "
<< full_name
<< LL_ENDL;
+ // DEBUG ONLY!!! DO NOT COMMIT!!!
+ av_name->dump();
}
// fills in av_name if it has it in the cache, even if expired (can check expiry time)
@@ -600,7 +582,7 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
if (sRunning)
{
// ...only do immediate lookups when cache is running
- if (useDisplayNames())
+ if (hasNameLookupURL())
{
// ...use display names cache
std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id);
@@ -662,7 +644,7 @@ LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& ag
if (sRunning)
{
// ...only do immediate lookups when cache is running
- if (useDisplayNames())
+ if (hasNameLookupURL())
{
// ...use new cache
std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id);
@@ -720,20 +702,16 @@ LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& ag
void LLAvatarNameCache::setUseDisplayNames(bool use)
{
- if (use != sUseDisplayNames)
+ if (use != LLAvatarName::useDisplayNames())
{
- sUseDisplayNames = use;
- // flush our cache
- sCache.clear();
-
+ LLAvatarName::setUseDisplayNames(use);
mUseDisplayNamesSignal();
}
}
-bool LLAvatarNameCache::useDisplayNames()
+void LLAvatarNameCache::flushCache()
{
- // Must be both manually set on and able to look up names.
- return sUseDisplayNames && !sNameLookupURL.empty();
+ sCache.clear();
}
void LLAvatarNameCache::erase(const LLUUID& agent_id)
diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h
index 79f170f7c8..e172601432 100644
--- a/indra/llmessage/llavatarnamecache.h
+++ b/indra/llmessage/llavatarnamecache.h
@@ -81,6 +81,8 @@ namespace LLAvatarNameCache
void setUseDisplayNames(bool use);
bool useDisplayNames();
+ void flushCache();
+
void erase(const LLUUID& agent_id);
/// Provide some fallback for agents that return errors
diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp
index 479efabb5f..da07c9ae42 100644
--- a/indra/llmessage/llcachename.cpp
+++ b/indra/llmessage/llcachename.cpp
@@ -524,6 +524,7 @@ std::string LLCacheName::cleanFullName(const std::string& full_name)
}
//static
+// Transform hard-coded name provided by server to a more legible username
std::string LLCacheName::buildUsername(const std::string& full_name)
{
// rare, but handle hard-coded error names returned from server
@@ -549,8 +550,9 @@ std::string LLCacheName::buildUsername(const std::string& full_name)
return username;
}
- // if the input wasn't a correctly formatted legacy name just return it unchanged
- return full_name;
+ // if the input wasn't a correctly formatted legacy name, just return it
+ // cleaned up from a potential terminal "Resident"
+ return cleanFullName(full_name);
}
//static