diff options
-rw-r--r-- | indra/llcommon/llavatarname.cpp | 10 | ||||
-rw-r--r-- | indra/llcommon/llavatarname.h | 2 | ||||
-rw-r--r-- | indra/llmessage/llavatarnamecache.cpp | 53 | ||||
-rw-r--r-- | indra/llmessage/llavatarnamecache.h | 11 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 36 | ||||
-rw-r--r-- | indra/newview/llviewerdisplayname.cpp | 14 | ||||
-rw-r--r-- | indra/newview/llviewerregion.cpp | 17 | ||||
-rw-r--r-- | indra/newview/llviewerregion.h | 6 |
8 files changed, 93 insertions, 56 deletions
diff --git a/indra/llcommon/llavatarname.cpp b/indra/llcommon/llavatarname.cpp index 62ba7cb112..c35b8380b8 100644 --- a/indra/llcommon/llavatarname.cpp +++ b/indra/llcommon/llavatarname.cpp @@ -35,12 +35,15 @@ #include "llavatarname.h" +#include "lldate.h" +#include "llsd.h" + // Store these in pre-built std::strings to avoid memory allocations in // LLSD map lookups static const std::string SL_ID("sl_id"); static const std::string DISPLAY_NAME("display_name"); static const std::string IS_DISPLAY_NAME_DEFAULT("is_display_name_default"); -static const std::string EXPIRES("expires"); +static const std::string DISPLAY_NAME_EXPIRES("display_name_expires"); LLAvatarName::LLAvatarName() : mSLID(), @@ -64,7 +67,7 @@ LLSD LLAvatarName::asLLSD() const sd[SL_ID] = mSLID; sd[DISPLAY_NAME] = mDisplayName; sd[IS_DISPLAY_NAME_DEFAULT] = mIsDisplayNameDefault; - sd[EXPIRES] = mExpires; + sd[DISPLAY_NAME_EXPIRES] = LLDate(mExpires); return sd; } @@ -73,5 +76,6 @@ void LLAvatarName::fromLLSD(const LLSD& sd) mSLID = sd[SL_ID].asString(); mDisplayName = sd[DISPLAY_NAME].asString(); mIsDisplayNameDefault = sd[IS_DISPLAY_NAME_DEFAULT].asBoolean(); - mExpires = sd[EXPIRES].asReal(); + LLDate expires = sd[DISPLAY_NAME_EXPIRES]; + mExpires = expires.secondsSinceEpoch(); } diff --git a/indra/llcommon/llavatarname.h b/indra/llcommon/llavatarname.h index 11bd5f30b7..b30dca6e6e 100644 --- a/indra/llcommon/llavatarname.h +++ b/indra/llcommon/llavatarname.h @@ -63,7 +63,7 @@ public: // Names can change, so need to keep track of when name was // last checked. - // Unix time-from-epoch seconds + // Unix time-from-epoch seconds for efficiency F64 mExpires; // Can be a viewer UI image name ("Person_Check") or a server-side diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 6455286770..72498111fd 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -48,9 +48,6 @@ namespace LLAvatarNameCache // in the middle of a session. bool sUseDisplayNames = true; - // While false, buffer requests for later. Used during viewer startup. - bool sRunning = false; - // Base lookup URL for name service. // On simulator, loaded from indra.xml // On viewer, usually a simulator capability (at People API team's request) @@ -85,7 +82,8 @@ namespace LLAvatarNameCache LLFrameTimer sEraseExpiredTimer; void processNameFromService(const LLSD& row); - void requestNames(); + void requestNamesViaCapability(); + void requestNamesViaLegacy(); bool isRequestPending(const LLUUID& agent_id); // Erase expired names from cache @@ -203,7 +201,7 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row) } } -void LLAvatarNameCache::requestNames() +void LLAvatarNameCache::requestNamesViaCapability() { // URL format is like: // http://pdp60.lindenlab.com:8000/agents/?ids=3941037e-78ab-45f0-b421-bd6e77c1804d&ids=0012809d-7d2d-4c24-9609-af1230a37715&ids=0019aaba-24af-4f0a-aa72-6457953cf7f0 @@ -252,9 +250,13 @@ void LLAvatarNameCache::requestNames() } } -void LLAvatarNameCache::initClass(bool running) +void LLAvatarNameCache::requestNamesViaLegacy() +{ + // JAMESDEBUG TODO +} + +void LLAvatarNameCache::initClass() { - sRunning = running; } void LLAvatarNameCache::cleanupClass() @@ -307,18 +309,8 @@ void LLAvatarNameCache::setNameLookupURL(const std::string& name_lookup_url) sNameLookupURL = name_lookup_url; } -void LLAvatarNameCache::setRunning(bool running) -{ - sRunning = running; -} - void LLAvatarNameCache::idle() { - if (!sRunning) - { - return; - } - // 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; @@ -334,18 +326,21 @@ void LLAvatarNameCache::idle() eraseExpired(); } - if (sNameLookupURL.empty()) + if (sAskQueue.empty()) { - // ...viewer has not yet received capability from region return; } - if (sAskQueue.empty()) + if (!sNameLookupURL.empty()) { - return; + requestNamesViaCapability(); + } + else + { + // ...fall back to legacy name cache system + requestNamesViaLegacy(); + llwarns << "JAMESDEBUG legacy lookup call" << llendl; } - - requestNames(); // Move requests from Ask queue to Pending queue F64 now = LLFrameTimer::getTotalSeconds(); @@ -460,3 +455,15 @@ void LLAvatarNameCache::erase(const LLUUID& agent_id) { sCache.erase(agent_id); } + +void LLAvatarNameCache::fetch(const LLUUID& agent_id) +{ + // re-request, even if request is already pending + sAskQueue.insert(agent_id); +} + +void LLAvatarNameCache::insert(const LLUUID& agent_id, const LLAvatarName& av_name) +{ + // *TODO: update timestamp if zero? + sCache[agent_id] = av_name; +} diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 4aabacd1f3..68a6c28b7b 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -42,21 +42,16 @@ class LLUUID; namespace LLAvatarNameCache { - // On the viewer, name cache starts in a non-running state until we - // know if we have the name lookup capability for the agent's region. - // In that state it buffers requests for later. - void initClass(bool running); + void initClass(); void cleanupClass(); void importFile(std::istream& istr); void exportFile(std::ostream& ostr); // On the viewer, usually a simulator capabilitity + // If empty, name cache will fall back to using legacy name + // lookup system void setNameLookupURL(const std::string& name_lookup_url); - - // Once we know if the lookup service is available we can start - // requesting names. - void setRunning(bool running); // Periodically makes a batch request for display names not already in // cache. Call once per frame. diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index ac9672858d..e160951b91 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3906,6 +3906,11 @@ void LLAppViewer::idleNameCache() // deal with any queued name requests and replies. gCacheName->processPending(); + // Can't run the new cache until we have the list of capabilities + // for the agent region, and can therefore decide whether to use + // display names or fall back to the old name system. + if (!region->capabilitiesReceived()) return; + // Agent may have moved to a different region, so need to update cap URL // for name lookups. Can't do this in the cap grant code, as caps are // granted to neighbor regions before the main agent gets there. Can't @@ -3914,21 +3919,26 @@ void LLAppViewer::idleNameCache() std::string name_lookup_url; name_lookup_url.reserve(128); // avoid a memory allocation below name_lookup_url = region->getCapability("GetDisplayNames"); - - // Ensure capability has been granted - U32 url_size = name_lookup_url.size(); - if (url_size > 0) - { - // capabilities require URLs with slashes before query params: - // https://<host>:<port>/cap/<uuid>/?ids=<blah> - // but the caps are granted like: - // https://<host>:<port>/cap/<uuid> - if (name_lookup_url[url_size-1] != '/') - { - name_lookup_url += '/'; - } + if (!name_lookup_url.empty()) + { + // we have support for display names, use it + U32 url_size = name_lookup_url.size(); + // capabilities require URLs with slashes before query params: + // https://<host>:<port>/cap/<uuid>/?ids=<blah> + // but the caps are granted like: + // https://<host>:<port>/cap/<uuid> + if (url_size > 0 && name_lookup_url[url_size-1] != '/') + { + name_lookup_url += '/'; + } LLAvatarNameCache::setNameLookupURL(name_lookup_url); } + else + { + // Display names not available on this region + LLAvatarNameCache::setNameLookupURL( std::string() ); + } + LLAvatarNameCache::idle(); } diff --git a/indra/newview/llviewerdisplayname.cpp b/indra/newview/llviewerdisplayname.cpp index 1cfada48ad..8bed501c6e 100644 --- a/indra/newview/llviewerdisplayname.cpp +++ b/indra/newview/llviewerdisplayname.cpp @@ -120,20 +120,22 @@ class LLDisplayNameUpdate : public LLHTTPNode { LLSD body = input["body"]; LLUUID agent_id = body["agent_id"]; - std::string slid = body["sl_id"]; std::string old_display_name = body["old_display_name"]; - std::string new_display_name = body["new_display_name"]; + // By convention this record is called "agent" in the People API + std::string name_data = body["agent"]; - // force re-request of this agent's name data - LLAvatarNameCache::erase(agent_id); + // Inject the new name data into cache + LLAvatarName av_name; + av_name.fromLLSD( name_data ); + LLAvatarNameCache::insert(agent_id, av_name); // force name tag to update LLVOAvatar::invalidateNameTag(agent_id); LLSD args; args["OLD_NAME"] = old_display_name; - args["SLID"] = slid; - args["NEW_NAME"] = new_display_name; + args["SLID"] = av_name.mSLID; + args["NEW_NAME"] = av_name.mDisplayName; LLNotificationsUtil::add("DisplayNameUpdate", args); } }; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 502fc87e41..9e877bc1af 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -175,7 +175,9 @@ public: mRegion->showReleaseNotes(); } } - + + mRegion->setCapabilitiesReceived(true); + if (STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState()) { LLStartUp::setStartupState( STATE_SEED_CAP_GRANTED ); @@ -232,7 +234,8 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, // LLCapabilityListener binds all the globals it expects to need at // construction time. mCapabilityListener(host.getString(), gMessageSystem, *this, - gAgent.getID(), gAgent.getSessionID()) + gAgent.getID(), gAgent.getSessionID()), + mCapabilitiesReceived(false) { mWidth = region_width_meters; mOriginGlobal = from_region_handle(handle); @@ -1557,6 +1560,16 @@ std::string LLViewerRegion::getCapability(const std::string& name) const return iter->second; } +bool LLViewerRegion::capabilitiesReceived() const +{ + return mCapabilitiesReceived; +} + +void LLViewerRegion::setCapabilitiesReceived(bool received) +{ + mCapabilitiesReceived = received; +} + void LLViewerRegion::logActiveCapabilities() const { int count = 0; diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 49d0900f2a..5f6c754187 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -232,6 +232,11 @@ public: void setCapability(const std::string& name, const std::string& url); // implements LLCapabilityProvider virtual std::string getCapability(const std::string& name) const; + + // has region received its final (not seed) capability list? + bool capabilitiesReceived() const; + void setCapabilitiesReceived(bool received); + static bool isSpecialCapabilityName(const std::string &name); void logActiveCapabilities() const; @@ -412,6 +417,7 @@ private: private: bool mAlive; // can become false if circuit disconnects + bool mCapabilitiesReceived; //spatial partitions for objects in this region std::vector<LLSpatialPartition*> mObjectPartition; |