summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2010-04-27 13:54:40 -0700
committerJames Cook <james@lindenlab.com>2010-04-27 13:54:40 -0700
commit56f5a6909d8a665531e3f6ede380cad57e313728 (patch)
treeff8ec9b0441a800336030f207e41fc2bc703a7a3 /indra/llmessage
parent6d239f7cfae65e6c8354d9f94061e81e82112a44 (diff)
Menu item to disable display names for testing works again
Start up cache in not-running state on viewer. Set cache running when idle() is called. Explicitly refresh name tags when toggled. Reviewed with Simon
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llavatarnamecache.cpp50
-rw-r--r--indra/llmessage/llavatarnamecache.h13
2 files changed, 44 insertions, 19 deletions
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp
index 5acecd1dcb..85775f19da 100644
--- a/indra/llmessage/llavatarnamecache.cpp
+++ b/indra/llmessage/llavatarnamecache.cpp
@@ -44,9 +44,13 @@
namespace LLAvatarNameCache
{
- // Will be turned on and off based on service availability, sometimes
- // in the middle of a session.
+ // 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;
// Base lookup URL for name service.
// On simulator, loaded from indra.xml
@@ -318,8 +322,9 @@ void LLAvatarNameCache::requestNamesViaLegacy()
// JAMESDEBUG TODO
}
-void LLAvatarNameCache::initClass()
+void LLAvatarNameCache::initClass(bool running)
{
+ sRunning = running;
}
void LLAvatarNameCache::cleanupClass()
@@ -375,8 +380,16 @@ void LLAvatarNameCache::setNameLookupURL(const std::string& name_lookup_url)
sNameLookupURL = name_lookup_url;
}
+bool LLAvatarNameCache::hasNameLookupURL()
+{
+ return !sNameLookupURL.empty();
+}
+
void LLAvatarNameCache::idle()
{
+ // By convention, start running at first idle() call
+ sRunning = true;
+
// 100 ms is the threshold for "user speed" operations, so we can
// stall for about that long to batch up requests.
const F32 SECS_BETWEEN_REQUESTS = 0.1f;
@@ -405,7 +418,6 @@ void LLAvatarNameCache::idle()
{
// ...fall back to legacy name cache system
requestNamesViaLegacy();
- llwarns << "JAMESDEBUG legacy lookup call" << llendl;
}
// Move requests from Ask queue to Pending queue
@@ -451,11 +463,15 @@ void LLAvatarNameCache::eraseExpired()
bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
{
- std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id);
- if (it != sCache.end())
+ if (sRunning)
{
- *av_name = it->second;
- return true;
+ // ...only do immediate lookups when cache is running
+ std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id);
+ if (it != sCache.end())
+ {
+ *av_name = it->second;
+ return true;
+ }
}
if (!isRequestPending(agent_id))
@@ -468,14 +484,18 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot)
{
- std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id);
- if (it != sCache.end())
+ if (sRunning)
{
- // ...name already exists in cache, fire callback now
- callback_signal_t signal;
- signal.connect(slot);
- signal(agent_id, it->second);
- return;
+ // ...only do immediate lookups when cache is running
+ std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id);
+ if (it != sCache.end())
+ {
+ // ...name already exists in cache, fire callback now
+ callback_signal_t signal;
+ signal.connect(slot);
+ signal(agent_id, it->second);
+ return;
+ }
}
// schedule a request
diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h
index 68a6c28b7b..26cecc5ab5 100644
--- a/indra/llmessage/llavatarnamecache.h
+++ b/indra/llmessage/llavatarnamecache.h
@@ -42,7 +42,10 @@ class LLUUID;
namespace LLAvatarNameCache
{
- void initClass();
+ // Until the cache is set running, immediate lookups will fail and
+ // async lookups will be queued. This allows us to block requests
+ // until we know if the first region supports display names.
+ void initClass(bool running);
void cleanupClass();
void importFile(std::istream& istr);
@@ -52,6 +55,10 @@ namespace LLAvatarNameCache
// If empty, name cache will fall back to using legacy name
// lookup system
void setNameLookupURL(const std::string& name_lookup_url);
+
+ // Do we have a valid lookup URL, hence are we trying to use the
+ // new display name lookup system?
+ bool hasNameLookupURL();
// Periodically makes a batch request for display names not already in
// cache. Call once per frame.
@@ -71,9 +78,7 @@ namespace LLAvatarNameCache
// If name information is in cache, callback will be called immediately.
void get(const LLUUID& agent_id, callback_slot_t slot);
- // JAMESDEBUG TODO: collapse this with setNameLookupUrl?
- // Not all grids support display names. If display names are disabled,
- // fall back to old name lookup system.
+ // Allow display names to be explicitly disabled for testing.
void setUseDisplayNames(bool use);
bool useDisplayNames();