From dd9bfb6d859c5848b5ff6c8fdebbc34ab65f92e7 Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 22 Jan 2010 16:52:53 -0800 Subject: LLCacheName and LLUrlEntryAgent now understand SLIDs - accounts with "Resident" as last name should not display that name. Also added test display names. --- indra/llmessage/llcachename.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 3078d80552..04b8ef9637 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -461,7 +461,7 @@ void LLCacheName::exportFile(std::ostream& ostr) // store it LLUUID id = iter->first; std::string id_str = id.asString(); - if(!entry->mFirstName.empty() && !entry->mLastName.empty()) + if(!entry->mFirstName.empty() /* && !entry->mLastName.empty() */ ) // IDEVO save SLIDs { data[AGENTS][id_str][FIRST] = entry->mFirstName; data[AGENTS][id_str][LAST] = entry->mLastName; @@ -506,6 +506,7 @@ BOOL LLCacheName::getName(const LLUUID& id, std::string& first, std::string& las } } + // static void LLCacheName::LocalizeCacheName(std::string key, std::string value) { @@ -519,7 +520,13 @@ BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) { std::string first_name, last_name; BOOL res = getName(id, first_name, last_name); - fullname = first_name + " " + last_name; + fullname = first_name; + if (!last_name.empty()) + { + // IDEVO legacy resident name, not SLID + fullname += " "; + fullname += last_name; + } return res; } @@ -916,6 +923,12 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) { msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_FirstName, entry->mFirstName, i); msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName, entry->mLastName, i); + + // IDEVO HACK - blank out last name + if (entry->mLastName == "Resident") + { + entry->mLastName = ""; + } } else { // is group -- cgit v1.2.3 From 146e9d5e4d9a9a4f33d9ccd47a901980972b7ab9 Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 1 Feb 2010 17:06:18 -0800 Subject: Support returning full_name (and SLID) for LLCacheName::get() calls Changed callback signature to full_name instead of first_name,last_name Eliminated all calls to legacy (non-signal/non-boost-bind) lookup mechanism Change Pay dialog names to SLURL links Tweaked layout of Pay Resident and Pay via Object floaters to make SLURLs fit Consolidate name first + " " + last concatenation in LLCacheName::buildFullName() Reviewed with Kelly --- indra/llmessage/llcachename.cpp | 58 +++++++++++++++++++++-------------- indra/llmessage/llcachename.h | 15 +++++---- indra/llmessage/mean_collision_data.h | 5 ++- 3 files changed, 46 insertions(+), 32 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 04b8ef9637..e1e5f5bc02 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -75,7 +75,7 @@ public: public: bool mIsGroup; U32 mCreateTime; // unix time_t - std::string mFirstName; + std::string mFirstName; // IDEVO TODO collapse to one field std::string mLastName; std::string mGroupName; }; @@ -520,13 +520,7 @@ BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) { std::string first_name, last_name; BOOL res = getName(id, first_name, last_name); - fullname = first_name; - if (!last_name.empty()) - { - // IDEVO legacy resident name, not SLID - fullname += " "; - fullname += last_name; - } + fullname = buildFullname(first_name, last_name); return res; } @@ -566,7 +560,7 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) BOOL LLCacheName::getUUID(const std::string& first, const std::string& last, LLUUID& id) { - std::string fullname = first + " " + last; + std::string fullname = buildFullname(first, last); return getUUID(fullname, id); } @@ -584,6 +578,19 @@ BOOL LLCacheName::getUUID(const std::string& fullname, LLUUID& id) } } +//static +std::string LLCacheName::buildFullname(const std::string& first, const std::string& last) +{ + std::string fullname = first; + if (!last.empty() + && last != "Resident") + { + fullname += ' '; + fullname += last; + } + return fullname; +} + // This is a little bit kludgy. LLCacheNameCallback is a slot instead of a function pointer. // The reason it is a slot is so that the legacy get() function below can bind an old callback // and pass it as a slot. The reason it isn't a boost::function is so that trackable behavior @@ -591,7 +598,7 @@ BOOL LLCacheName::getUUID(const std::string& fullname, LLUUID& id) // we call it immediately. -Steve // NOTE: Even though passing first and last name is a bit of extra overhead, it eliminates the // potential need for any parsing should any code need to handle first and last name independently. -boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, const LLCacheNameCallback& callback) +boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback) { boost::signals2::connection res; @@ -599,7 +606,7 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, co { LLCacheNameSignal signal; signal.connect(callback); - signal(id, sCacheName["nobody"], "", is_group); + signal(id, sCacheName["nobody"], is_group); return res; } @@ -611,11 +618,13 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, co // id found in map therefore we can call the callback immediately. if (entry->mIsGroup) { - signal(id, entry->mGroupName, "", entry->mIsGroup); + signal(id, entry->mGroupName, entry->mIsGroup); } else { - signal(id, entry->mFirstName, entry->mLastName, entry->mIsGroup); + std::string fullname = + buildFullname(entry->mFirstName, entry->mLastName); + signal(id, fullname, entry->mIsGroup); } } else @@ -637,9 +646,9 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, co return res; } -boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, old_callback_t callback, void* user_data) +boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, old_callback_t callback, void* user_data) { - return get(id, is_group, boost::bind(callback, _1, _2, _3, _4, user_data)); + return get(id, is_group, boost::bind(callback, _1, _2, _3, user_data)); } void LLCacheName::processPending() @@ -711,7 +720,7 @@ void LLCacheName::dump() { llinfos << iter->first << " = " - << entry->mFirstName << " " << entry->mLastName + << buildFullname(entry->mFirstName, entry->mLastName) << " @ " << entry->mCreateTime << llendl; } @@ -757,11 +766,13 @@ void LLCacheName::Impl::processPendingReplies() if (!entry->mIsGroup) { - (reply->mSignal)(reply->mID, entry->mFirstName, entry->mLastName, FALSE); + std::string fullname = + LLCacheName::buildFullname(entry->mFirstName, entry->mLastName); + (reply->mSignal)(reply->mID, fullname, false); } else { - (reply->mSignal)(reply->mID, entry->mGroupName, "", TRUE); + (reply->mSignal)(reply->mID, entry->mGroupName, true); } } @@ -924,7 +935,8 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_FirstName, entry->mFirstName, i); msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName, entry->mLastName, i); - // IDEVO HACK - blank out last name + // IDEVO blank out last name for storage to reduce string compares on + // retrieval. Eventually need to convert to single mName field. if (entry->mLastName == "Resident") { entry->mLastName = ""; @@ -938,13 +950,14 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) if (!isGroup) { - mSignal(id, entry->mFirstName, entry->mLastName, FALSE); - std::string fullname = entry->mFirstName + " " + entry->mLastName; + std::string fullname = + LLCacheName::buildFullname(entry->mFirstName, entry->mLastName); + mSignal(id, fullname, false); mReverseCache[fullname] = id; } else { - mSignal(id, entry->mGroupName, "", TRUE); + mSignal(id, entry->mGroupName, true); mReverseCache[entry->mGroupName] = id; } } @@ -973,4 +986,3 @@ void LLCacheName::Impl::handleUUIDGroupNameReply(LLMessageSystem* msg, void** us { ((LLCacheName::Impl*)userData)->processUUIDReply(msg, true); } - diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 111cc8b650..c7385204f5 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -42,13 +42,12 @@ class LLUUID; typedef boost::signals2::signal LLCacheNameSignal; + const std::string& name, + bool is_group)> LLCacheNameSignal; typedef LLCacheNameSignal::slot_type LLCacheNameCallback; // Old callback with user data for compatability -typedef void (*old_callback_t)(const LLUUID&, const std::string&, const std::string&, BOOL, void*); +typedef void (*old_callback_t)(const LLUUID&, const std::string&, bool, void*); // Here's the theory: // If you request a name that isn't in the cache, it returns "waiting" @@ -89,6 +88,10 @@ public: // Reverse lookup of UUID from name BOOL getUUID(const std::string& first, const std::string& last, LLUUID& id); BOOL getUUID(const std::string& fullname, LLUUID& id); + + // IDEVO Temporary code + // Clean up new-style "bobsmith123 Resident" names to "bobsmith123" for display + static std::string buildFullname(const std::string& first, const std::string& last); // If available, this method copies the group name into the string // provided. The caller must allocate at least @@ -100,10 +103,10 @@ public: // If the data is currently available, may call the callback immediatly // otherwise, will request the data, and will call the callback when // available. There is no garuntee the callback will ever be called. - boost::signals2::connection get(const LLUUID& id, BOOL is_group, const LLCacheNameCallback& callback); + boost::signals2::connection get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback); // LEGACY - boost::signals2::connection get(const LLUUID& id, BOOL is_group, old_callback_t callback, void* user_data); + boost::signals2::connection get(const LLUUID& id, bool is_group, old_callback_t callback, void* user_data); // This method needs to be called from time to time to send out // requests. void processPending(); diff --git a/indra/llmessage/mean_collision_data.h b/indra/llmessage/mean_collision_data.h index 03b96f9f90..a6c635e81e 100644 --- a/indra/llmessage/mean_collision_data.h +++ b/indra/llmessage/mean_collision_data.h @@ -61,7 +61,7 @@ public: LLMeanCollisionData(LLMeanCollisionData *mcd) : mVictim(mcd->mVictim), mPerp(mcd->mPerp), mTime(mcd->mTime), mType(mcd->mType), mMag(mcd->mMag), - mFirstName(mcd->mFirstName), mLastName(mcd->mLastName) + mFullName(mcd->mFullName) { } @@ -95,8 +95,7 @@ public: time_t mTime; EMeanCollisionType mType; F32 mMag; - std::string mFirstName; - std::string mLastName; + std::string mFullName; }; -- cgit v1.2.3 From 42176145c9e81dd99b65f88152df50a7b3ccf834 Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 8 Feb 2010 14:55:30 -0800 Subject: Converted names build from avatar object LLNameValue pairs to SLID Added temporary getDisplayName() to LLCacheName Moved temporary placeholder display names into LLCacheName Eliminated rarely used LLAgentUI::buildName in favor of buildFullName Standardized buildFullName capitalization --- indra/llmessage/llcachename.cpp | 88 +++++++++++++++++++++++++++++++++-------- indra/llmessage/llcachename.h | 15 ++++--- 2 files changed, 81 insertions(+), 22 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index e6233ecf97..2bdf112448 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -220,7 +220,9 @@ public: Impl(LLMessageSystem* msg); ~Impl(); - + + BOOL getName(const LLUUID& id, std::string& first, std::string& last); + boost::signals2::connection addPending(const LLUUID& id, const LLCacheNameCallback& callback); void addPending(const LLUUID& id, const LLHost& host); @@ -480,7 +482,7 @@ void LLCacheName::exportFile(std::ostream& ostr) } -BOOL LLCacheName::getName(const LLUUID& id, std::string& first, std::string& last) +BOOL LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::string& last) { if(id.isNull()) { @@ -489,7 +491,7 @@ BOOL LLCacheName::getName(const LLUUID& id, std::string& first, std::string& las return FALSE; } - LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id ); + LLCacheNameEntry* entry = get_ptr_in_map(mCache, id ); if (entry) { first = entry->mFirstName; @@ -500,9 +502,9 @@ BOOL LLCacheName::getName(const LLUUID& id, std::string& first, std::string& las { first = sCacheName["waiting"]; last.clear(); - if (!impl.isRequestPending(id)) + if (!isRequestPending(id)) { - impl.mAskNameQueue.insert(id); + mAskNameQueue.insert(id); } return FALSE; } @@ -521,11 +523,65 @@ void LLCacheName::LocalizeCacheName(std::string key, std::string value) BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) { std::string first_name, last_name; - BOOL res = getName(id, first_name, last_name); - fullname = buildFullname(first_name, last_name); + BOOL res = impl.getName(id, first_name, last_name); + fullname = buildFullName(first_name, last_name); return res; } +static std::map sDisplayNames; + +bool LLCacheName::getDisplayName(const LLUUID& id, std::string& display_name) +{ + if (sDisplayNames.empty()) + { + LLUUID id; + const unsigned char miyazaki_hayao_san[] + = { 0xE5, 0xAE, 0xAE, 0xE5, 0xB4, 0x8E, + 0xE9, 0xA7, 0xBF, + 0xE3, 0x81, 0x95, 0xE3, 0x82, 0x93, '\0' }; + id.set("27888d5f-4ddb-4df3-ad36-a1483ce0b3d9"); // miyazaki23 + sDisplayNames[id] = (const char*)miyazaki_hayao_san; + + id.set("3e5bf676-3577-c9ee-9fac-10df430015a1"); // Jim Linden + sDisplayNames[id] = "Jim Jenkins"; + + const unsigned char jose_sanchez[] = + { 'J','o','s',0xC3,0xA9,' ','S','a','n','c','h','e','z', '\0' }; + id.set("a2e76fcd-9360-4f6d-a924-938f923df11a"); // James Linden + sDisplayNames[id] = (const char*)jose_sanchez; + + id.set("3f7ced39-5e38-4fdd-90f2-423560b1e6e2"); // Hamilton Linden + sDisplayNames[id] = "Hamilton Hitchings"; + + id.set("537da1e1-a89f-4f9b-9056-b1f0757ccdd0"); // Rome Linden + sDisplayNames[id] = "Rome Portlock"; + + id.set("244195d6-c9b7-4fd6-9229-c3a8b2e60e81"); // M Linden + sDisplayNames[id] = "Mark Kingdon"; + + id.set("49856302-98d4-4e32-b5e9-035e5b4e83a4"); // T Linden + sDisplayNames[id] = "Tom Hale"; + + id.set("e6ed7825-708f-4c6b-b6a7-f3fe921a9176"); // Callen Linden + sDisplayNames[id] = "Christina Allen"; + + id.set("a7f0ac18-205f-41d2-b5b4-f75f096ae511"); // Crimp Linden + sDisplayNames[id] = "Chris Rimple"; + } + + std::map::iterator it = sDisplayNames.find(id); + if (it != sDisplayNames.end()) + { + display_name = it->second; + return true; + } + else + { + display_name = ""; + return false; + } +} + BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) { if(id.isNull()) @@ -562,7 +618,7 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) BOOL LLCacheName::getUUID(const std::string& first, const std::string& last, LLUUID& id) { - std::string fullname = buildFullname(first, last); + std::string fullname = buildFullName(first, last); return getUUID(fullname, id); } @@ -581,7 +637,7 @@ BOOL LLCacheName::getUUID(const std::string& fullname, LLUUID& id) } //static -std::string LLCacheName::buildFullname(const std::string& first, const std::string& last) +std::string LLCacheName::buildFullName(const std::string& first, const std::string& last) { std::string fullname = first; if (!last.empty() @@ -625,7 +681,7 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, co else { std::string fullname = - buildFullname(entry->mFirstName, entry->mLastName); + buildFullName(entry->mFirstName, entry->mLastName); signal(id, fullname, entry->mIsGroup); } } @@ -722,7 +778,7 @@ void LLCacheName::dump() { llinfos << iter->first << " = " - << buildFullname(entry->mFirstName, entry->mLastName) + << buildFullName(entry->mFirstName, entry->mLastName) << " @ " << entry->mCreateTime << llendl; } @@ -769,7 +825,7 @@ void LLCacheName::Impl::processPendingReplies() if (!entry->mIsGroup) { std::string fullname = - LLCacheName::buildFullname(entry->mFirstName, entry->mLastName); + LLCacheName::buildFullName(entry->mFirstName, entry->mLastName); (reply->mSignal)(reply->mID, fullname, false); } else @@ -952,10 +1008,10 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) if (!isGroup) { - std::string fullname = - LLCacheName::buildFullname(entry->mFirstName, entry->mLastName); - mSignal(id, fullname, false); - mReverseCache[fullname] = id; + std::string full_name = + LLCacheName::buildFullName(entry->mFirstName, entry->mLastName); + mSignal(id, full_name, false); + mReverseCache[full_name] = id; } else { diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index c7385204f5..76865928d3 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -77,13 +77,16 @@ public: bool importFile(std::istream& istr); void exportFile(std::ostream& ostr); - // If available, copies the first and last name into the strings provided. - // first must be at least DB_FIRST_NAME_BUF_SIZE characters. - // last must be at least DB_LAST_NAME_BUF_SIZE characters. + // If available, copies name ("bobsmith123" or "James Linden") into string // If not available, copies the string "waiting". // Returns TRUE iff available. - BOOL getName(const LLUUID& id, std::string& first, std::string& last); - BOOL getFullName(const LLUUID& id, std::string& fullname); + BOOL getFullName(const LLUUID& id, std::string& full_name); + + // IDEVO temporary code + // If available, copies display name (UTF-8) into string + // If not available, copies empty string + // Returns TRUE iff available + bool getDisplayName(const LLUUID& id, std::string& display_name); // Reverse lookup of UUID from name BOOL getUUID(const std::string& first, const std::string& last, LLUUID& id); @@ -91,7 +94,7 @@ public: // IDEVO Temporary code // Clean up new-style "bobsmith123 Resident" names to "bobsmith123" for display - static std::string buildFullname(const std::string& first, const std::string& last); + static std::string buildFullName(const std::string& first, const std::string& last); // If available, this method copies the group name into the string // provided. The caller must allocate at least -- cgit v1.2.3 From f3e4bd08c83714eac6a27cd73c3ac29f36800d37 Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 10 Feb 2010 12:03:09 -0800 Subject: Added Jose Sanchez as display name for bobsmith123 --- indra/llmessage/llcachename.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 2bdf112448..4b0cc299c7 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -550,6 +550,9 @@ bool LLCacheName::getDisplayName(const LLUUID& id, std::string& display_name) id.set("a2e76fcd-9360-4f6d-a924-938f923df11a"); // James Linden sDisplayNames[id] = (const char*)jose_sanchez; + id.set("a23fff6c-80ae-4997-9253-48272fd01d3c"); // bobsmith123 + sDisplayNames[id] = (const char*)jose_sanchez; + id.set("3f7ced39-5e38-4fdd-90f2-423560b1e6e2"); // Hamilton Linden sDisplayNames[id] = "Hamilton Hitchings"; -- cgit v1.2.3 From c2373fb5a6b08b2c32e5f93fa67b25f669e8b47f Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 11 Feb 2010 16:39:15 -0800 Subject: Created stub LLAvatarNameCache for display name lookup, as well as LLAvatarName base data object. Reviewed with Kelly. --- indra/llmessage/CMakeLists.txt | 2 + indra/llmessage/llavatarnamecache.cpp | 99 +++++++++++++++++++++++++++++++++++ indra/llmessage/llavatarnamecache.h | 58 ++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 indra/llmessage/llavatarnamecache.cpp create mode 100644 indra/llmessage/llavatarnamecache.h (limited to 'indra/llmessage') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 1f8ee26716..0d07015f24 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -25,6 +25,7 @@ set(llmessage_SOURCE_FILES llares.cpp llareslistener.cpp llassetstorage.cpp + llavatarnamecache.cpp llblowfishcipher.cpp llbuffer.cpp llbufferstream.cpp @@ -110,6 +111,7 @@ set(llmessage_HEADER_FILES llares.h llareslistener.h llassetstorage.h + llavatarnamecache.h llblowfishcipher.h llbuffer.h llbufferstream.h diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp new file mode 100644 index 0000000000..d837019e11 --- /dev/null +++ b/indra/llmessage/llavatarnamecache.cpp @@ -0,0 +1,99 @@ +/** + * @file llavatarnamecache.cpp + * @brief Provides lookup of avatar SLIDs ("bobsmith123") and display names + * ("James Cook") from avatar UUIDs. + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ +#include "linden_common.h" + +#include "llavatarnamecache.h" + +#include "llcachename.h" // until we get our own web service + +#include // tolower() + +static std::string slid_from_full_name(const std::string& full_name) +{ + std::string id = full_name; + std::string::size_type end = id.length(); + for (std::string::size_type i = 0; i < end; ++i) + { + if (id[i] == ' ') + id[i] = '.'; + else + id[i] = tolower(id[i]); + } + return id; +} + +void LLAvatarNameCache::initClass() +{ +} + +void LLAvatarNameCache::cleanupClass() +{ +} + +void LLAvatarNameCache::importFile(std::istream& istr) +{ +} + +void LLAvatarNameCache::exportFile(std::ostream& ostr) +{ +} + +void LLAvatarNameCache::idle() +{ +} + +bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) +{ + std::string full_name; + bool found = gCacheName->getFullName(agent_id, full_name); + if (found) + { + av_name->mSLID = slid_from_full_name(full_name); + + std::string display_name; + if (gCacheName->getDisplayName(agent_id, display_name)) + { + av_name->mDisplayName = display_name; + } + else + { + // ...no explicit display name, use legacy name + av_name->mDisplayName = full_name; + } + } + return found; +} + +void LLAvatarNameCache::get(const LLUUID& agent_id, name_cache_callback_t callback) +{ +} diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h new file mode 100644 index 0000000000..adf12bbbc6 --- /dev/null +++ b/indra/llmessage/llavatarnamecache.h @@ -0,0 +1,58 @@ +/** + * @file llavatarnamecache.h + * @brief Provides lookup of avatar SLIDs ("bobsmith123") and display names + * ("James Cook") from avatar UUIDs. + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ +#ifndef LLAVATARNAMECACHE_H +#define LLAVATARNAMECACHE_H + +#include "llavatarname.h" // for convenience + +namespace LLAvatarNameCache +{ + void initClass(); + void cleanupClass(); + + void importFile(std::istream& istr); + void exportFile(std::ostream& ostr); + + void idle(); + + // If name is in cache, returns true and fills in provided LLAvatarName + // otherwise returns false + bool get(const LLUUID& agent_id, LLAvatarName *av_name); + + // Fetches name information and calls callback. + // If name information is in cache, callback will be called immediately. + typedef void (*name_cache_callback_t)(const LLUUID& agent_id, const LLAvatarName& av_name); + void get(const LLUUID& agent_id, name_cache_callback_t callback); +} + +#endif -- cgit v1.2.3 From 4c4ba930029c34c6810c7e229b186e89b458053a Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 11 Feb 2010 16:44:42 -0800 Subject: Removed temporary LLCacheName::getDisplayName code --- indra/llmessage/llavatarnamecache.cpp | 60 +++++++++++++++++++++++++++++++++-- indra/llmessage/llcachename.cpp | 55 -------------------------------- indra/llmessage/llcachename.h | 6 ---- 3 files changed, 58 insertions(+), 63 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index d837019e11..16bfa37b0e 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -52,6 +52,62 @@ static std::string slid_from_full_name(const std::string& full_name) return id; } +static std::map sDisplayNames; + +// JAMESDEBUG HACK temporary IDEVO code +static std::string get_display_name(const LLUUID& id) +{ + if (sDisplayNames.empty()) + { + LLUUID id; + const unsigned char miyazaki_hayao_san[] + = { 0xE5, 0xAE, 0xAE, 0xE5, 0xB4, 0x8E, + 0xE9, 0xA7, 0xBF, + 0xE3, 0x81, 0x95, 0xE3, 0x82, 0x93, '\0' }; + id.set("27888d5f-4ddb-4df3-ad36-a1483ce0b3d9"); // miyazaki23 + sDisplayNames[id] = (const char*)miyazaki_hayao_san; + + id.set("3e5bf676-3577-c9ee-9fac-10df430015a1"); // Jim Linden + sDisplayNames[id] = "Jim Jenkins"; + + const unsigned char jose_sanchez[] = + { 'J','o','s',0xC3,0xA9,' ','S','a','n','c','h','e','z', '\0' }; + id.set("a2e76fcd-9360-4f6d-a924-938f923df11a"); // James Linden + sDisplayNames[id] = (const char*)jose_sanchez; + + id.set("a23fff6c-80ae-4997-9253-48272fd01d3c"); // bobsmith123 + sDisplayNames[id] = (const char*)jose_sanchez; + + id.set("3f7ced39-5e38-4fdd-90f2-423560b1e6e2"); // Hamilton Linden + sDisplayNames[id] = "Hamilton Hitchings"; + + id.set("537da1e1-a89f-4f9b-9056-b1f0757ccdd0"); // Rome Linden + sDisplayNames[id] = "Rome Portlock"; + + id.set("244195d6-c9b7-4fd6-9229-c3a8b2e60e81"); // M Linden + sDisplayNames[id] = "Mark Kingdon"; + + id.set("49856302-98d4-4e32-b5e9-035e5b4e83a4"); // T Linden + sDisplayNames[id] = "Tom Hale"; + + id.set("e6ed7825-708f-4c6b-b6a7-f3fe921a9176"); // Callen Linden + sDisplayNames[id] = "Christina Allen"; + + id.set("a7f0ac18-205f-41d2-b5b4-f75f096ae511"); // Crimp Linden + sDisplayNames[id] = "Chris Rimple"; + } + + std::map::iterator it = sDisplayNames.find(id); + if (it != sDisplayNames.end()) + { + return it->second; + } + else + { + return std::string(); + } +} + void LLAvatarNameCache::initClass() { } @@ -80,8 +136,8 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) { av_name->mSLID = slid_from_full_name(full_name); - std::string display_name; - if (gCacheName->getDisplayName(agent_id, display_name)) + std::string display_name = get_display_name(agent_id); + if (!display_name.empty()) { av_name->mDisplayName = display_name; } diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 4b0cc299c7..4e3c3630ab 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -528,62 +528,7 @@ BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) return res; } -static std::map sDisplayNames; -bool LLCacheName::getDisplayName(const LLUUID& id, std::string& display_name) -{ - if (sDisplayNames.empty()) - { - LLUUID id; - const unsigned char miyazaki_hayao_san[] - = { 0xE5, 0xAE, 0xAE, 0xE5, 0xB4, 0x8E, - 0xE9, 0xA7, 0xBF, - 0xE3, 0x81, 0x95, 0xE3, 0x82, 0x93, '\0' }; - id.set("27888d5f-4ddb-4df3-ad36-a1483ce0b3d9"); // miyazaki23 - sDisplayNames[id] = (const char*)miyazaki_hayao_san; - - id.set("3e5bf676-3577-c9ee-9fac-10df430015a1"); // Jim Linden - sDisplayNames[id] = "Jim Jenkins"; - - const unsigned char jose_sanchez[] = - { 'J','o','s',0xC3,0xA9,' ','S','a','n','c','h','e','z', '\0' }; - id.set("a2e76fcd-9360-4f6d-a924-938f923df11a"); // James Linden - sDisplayNames[id] = (const char*)jose_sanchez; - - id.set("a23fff6c-80ae-4997-9253-48272fd01d3c"); // bobsmith123 - sDisplayNames[id] = (const char*)jose_sanchez; - - id.set("3f7ced39-5e38-4fdd-90f2-423560b1e6e2"); // Hamilton Linden - sDisplayNames[id] = "Hamilton Hitchings"; - - id.set("537da1e1-a89f-4f9b-9056-b1f0757ccdd0"); // Rome Linden - sDisplayNames[id] = "Rome Portlock"; - - id.set("244195d6-c9b7-4fd6-9229-c3a8b2e60e81"); // M Linden - sDisplayNames[id] = "Mark Kingdon"; - - id.set("49856302-98d4-4e32-b5e9-035e5b4e83a4"); // T Linden - sDisplayNames[id] = "Tom Hale"; - - id.set("e6ed7825-708f-4c6b-b6a7-f3fe921a9176"); // Callen Linden - sDisplayNames[id] = "Christina Allen"; - - id.set("a7f0ac18-205f-41d2-b5b4-f75f096ae511"); // Crimp Linden - sDisplayNames[id] = "Chris Rimple"; - } - - std::map::iterator it = sDisplayNames.find(id); - if (it != sDisplayNames.end()) - { - display_name = it->second; - return true; - } - else - { - display_name = ""; - return false; - } -} BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) { diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 76865928d3..322ca4aa1a 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -82,12 +82,6 @@ public: // Returns TRUE iff available. BOOL getFullName(const LLUUID& id, std::string& full_name); - // IDEVO temporary code - // If available, copies display name (UTF-8) into string - // If not available, copies empty string - // Returns TRUE iff available - bool getDisplayName(const LLUUID& id, std::string& display_name); - // Reverse lookup of UUID from name BOOL getUUID(const std::string& first, const std::string& last, LLUUID& id); BOOL getUUID(const std::string& fullname, LLUUID& id); -- cgit v1.2.3 From c16591c046fa76fc5d13387efa3bcaec3422e593 Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 12 Feb 2010 16:12:12 -0800 Subject: Per-avatar customizable icons next to name links in text Changed LLUrlEntryAgent callbacks to handle both link label and icon Eliminated legacy LLNameCache file loading Reviewed with Kelly --- indra/llmessage/llavatarnamecache.cpp | 147 ++++++++++++++++++---------------- indra/llmessage/llcachename.cpp | 83 +------------------ indra/llmessage/llcachename.h | 5 +- 3 files changed, 80 insertions(+), 155 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 16bfa37b0e..610bc58057 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -38,6 +38,11 @@ #include // tolower() +namespace LLAvatarNameCache +{ + std::map sCache; +} + static std::string slid_from_full_name(const std::string& full_name) { std::string id = full_name; @@ -52,64 +57,67 @@ static std::string slid_from_full_name(const std::string& full_name) return id; } -static std::map sDisplayNames; - -// JAMESDEBUG HACK temporary IDEVO code -static std::string get_display_name(const LLUUID& id) -{ - if (sDisplayNames.empty()) - { - LLUUID id; - const unsigned char miyazaki_hayao_san[] - = { 0xE5, 0xAE, 0xAE, 0xE5, 0xB4, 0x8E, - 0xE9, 0xA7, 0xBF, - 0xE3, 0x81, 0x95, 0xE3, 0x82, 0x93, '\0' }; - id.set("27888d5f-4ddb-4df3-ad36-a1483ce0b3d9"); // miyazaki23 - sDisplayNames[id] = (const char*)miyazaki_hayao_san; - - id.set("3e5bf676-3577-c9ee-9fac-10df430015a1"); // Jim Linden - sDisplayNames[id] = "Jim Jenkins"; - - const unsigned char jose_sanchez[] = - { 'J','o','s',0xC3,0xA9,' ','S','a','n','c','h','e','z', '\0' }; - id.set("a2e76fcd-9360-4f6d-a924-938f923df11a"); // James Linden - sDisplayNames[id] = (const char*)jose_sanchez; - - id.set("a23fff6c-80ae-4997-9253-48272fd01d3c"); // bobsmith123 - sDisplayNames[id] = (const char*)jose_sanchez; - - id.set("3f7ced39-5e38-4fdd-90f2-423560b1e6e2"); // Hamilton Linden - sDisplayNames[id] = "Hamilton Hitchings"; - - id.set("537da1e1-a89f-4f9b-9056-b1f0757ccdd0"); // Rome Linden - sDisplayNames[id] = "Rome Portlock"; - - id.set("244195d6-c9b7-4fd6-9229-c3a8b2e60e81"); // M Linden - sDisplayNames[id] = "Mark Kingdon"; - - id.set("49856302-98d4-4e32-b5e9-035e5b4e83a4"); // T Linden - sDisplayNames[id] = "Tom Hale"; - - id.set("e6ed7825-708f-4c6b-b6a7-f3fe921a9176"); // Callen Linden - sDisplayNames[id] = "Christina Allen"; - - id.set("a7f0ac18-205f-41d2-b5b4-f75f096ae511"); // Crimp Linden - sDisplayNames[id] = "Chris Rimple"; - } - - std::map::iterator it = sDisplayNames.find(id); - if (it != sDisplayNames.end()) - { - return it->second; - } - else - { - return std::string(); - } -} - void LLAvatarNameCache::initClass() { + // HACK - prepopulate the cache + LLAvatarName name; + LLUUID id; + + name.mSLID = "miyazaki23"; + const unsigned char miyazaki_hayao_san[] + = { 0xE5, 0xAE, 0xAE, 0xE5, 0xB4, 0x8E, + 0xE9, 0xA7, 0xBF, + 0xE3, 0x81, 0x95, 0xE3, 0x82, 0x93, '\0' }; + name.mDisplayName = (const char*)miyazaki_hayao_san; + name.mBadge = "Person_Check"; + sCache[LLUUID("27888d5f-4ddb-4df3-ad36-a1483ce0b3d9")] = name; + + name.mSLID = "jim.linden"; + name.mDisplayName = "Jim Jenkins"; + name.mBadge = "Person_Star"; + sCache[LLUUID("3e5bf676-3577-c9ee-9fac-10df430015a1")] = name; + + name.mSLID = "james.linden"; + const unsigned char jose_sanchez[] = + { 'J','o','s',0xC3,0xA9,' ','S','a','n','c','h','e','z', '\0' }; + name.mDisplayName = (const char*)jose_sanchez; + name.mBadge = "35f217a3-f618-49cf-bbca-c86d486551a9"; // IMG_SHOT + sCache[LLUUID("a2e76fcd-9360-4f6d-a924-938f923df11a")] = name; + + name.mSLID = "bobsmith123"; + name.mDisplayName = (const char*)jose_sanchez; + name.mBadge = ""; + sCache[LLUUID("a23fff6c-80ae-4997-9253-48272fd01d3c")] = name; + + name.mSLID = "hamilton.linden"; + name.mDisplayName = "Hamilton Hitchings"; + name.mBadge = "Person_Star"; + sCache[LLUUID("3f7ced39-5e38-4fdd-90f2-423560b1e6e2")] = name; + + name.mSLID = "rome.linden"; + name.mDisplayName = "Rome Portlock"; + name.mBadge = "Person_Star"; + sCache[LLUUID("537da1e1-a89f-4f9b-9056-b1f0757ccdd0")] = name; + + name.mSLID = "m.linden"; + name.mDisplayName = "Mark Kingdon"; + name.mBadge = "Person_Star"; + sCache[LLUUID("244195d6-c9b7-4fd6-9229-c3a8b2e60e81")] = name; + + name.mSLID = "t.linden"; + name.mDisplayName = "Tom Hale"; + name.mBadge = "Person_Star"; + sCache[LLUUID("49856302-98d4-4e32-b5e9-035e5b4e83a4")] = name; + + name.mSLID = "callen.linden"; + name.mDisplayName = "Christina Allen"; + name.mBadge = "Person_Star"; + sCache[LLUUID("e6ed7825-708f-4c6b-b6a7-f3fe921a9176")] = name; + + name.mSLID = "crimp.linden"; + name.mDisplayName = "Chris Rimple"; + name.mBadge = "Person_Star"; + sCache[LLUUID("a7f0ac18-205f-41d2-b5b4-f75f096ae511")] = name; } void LLAvatarNameCache::cleanupClass() @@ -130,24 +138,23 @@ void LLAvatarNameCache::idle() bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) { + std::map::iterator it = sCache.find(agent_id); + if (it != sCache.end()) + { + *av_name = it->second; + return true; + } + std::string full_name; - bool found = gCacheName->getFullName(agent_id, full_name); - if (found) + if (gCacheName->getFullName(agent_id, full_name)) { av_name->mSLID = slid_from_full_name(full_name); - - std::string display_name = get_display_name(agent_id); - if (!display_name.empty()) - { - av_name->mDisplayName = display_name; - } - else - { - // ...no explicit display name, use legacy name - av_name->mDisplayName = full_name; - } + av_name->mDisplayName = full_name; + av_name->mBadge = "Generic_Person"; + return true; } - return found; + + return false; } void LLAvatarNameCache::get(const LLUUID& agent_id, name_cache_callback_t callback) diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 4e3c3630ab..b94788bd0c 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -308,89 +308,10 @@ boost::signals2::connection LLCacheName::addObserver(const LLCacheNameCallback& return impl.mSignal.connect(callback); } -void LLCacheName::importFile(LLFILE* fp) -{ - S32 count = 0; - - const S32 BUFFER_SIZE = 1024; - char buffer[BUFFER_SIZE]; /*Flawfinder: ignore*/ - - // *NOTE: These buffer sizes are hardcoded into sscanf() below - char id_string[MAX_STRING]; /*Flawfinder: ignore*/ - char firstname[MAX_STRING]; /*Flawfinder: ignore*/ - char lastname[MAX_STRING]; /*Flawfinder: ignore*/ - U32 create_time; - - // This is OK if the first line is actually a name. We just don't load it. - char* valid = fgets(buffer, BUFFER_SIZE, fp); - if (!valid) return; - - // *NOTE: This buffer size is hardcoded into sscanf() below - char version_string[BUFFER_SIZE]; /*Flawfinder: ignore*/ - S32 version = 0; - S32 match = sscanf( /* Flawfinder: ignore */ - buffer, - "%1023s %d", - version_string, &version); - if ( match != 2 - || strcmp(version_string, "version") - || version != CN_FILE_VERSION) - { - llwarns << "Ignoring old cache name file format" << llendl; - return; - } - - // We'll expire entries more than a week old - U32 now = (U32)time(NULL); - const U32 SECS_PER_DAY = 60 * 60 * 24; - U32 delete_before_time = now - (7 * SECS_PER_DAY); - - while(!feof(fp)) - { - valid = fgets(buffer, BUFFER_SIZE, fp); - if (!valid) break; - - match = sscanf( /* Flawfinder: ignore */ - buffer, - "%254s %u %254s %254s", - id_string, - &create_time, - firstname, - lastname); - if (4 != match) continue; - - LLUUID id(id_string); - if (id.isNull()) continue; - - // undo trivial XOR - S32 i; - for (i = 0; i < UUID_BYTES; i++) - { - id.mData[i] ^= 0x33; - } - - // Don't load entries that are more than a week old - if (create_time < delete_before_time) continue; - - LLCacheNameEntry* entry = new LLCacheNameEntry(); - entry->mIsGroup = false; - entry->mCreateTime = create_time; - entry->mFirstName = firstname; - entry->mLastName = lastname; - impl.mCache[id] = entry; - std::string fullname = entry->mFirstName + " " + entry->mLastName; - impl.mReverseCache[fullname] = id; - - count++; - } - - llinfos << "LLCacheName loaded " << count << " names" << llendl; -} - bool LLCacheName::importFile(std::istream& istr) { LLSD data; - if(LLSDSerialize::fromXML(data, istr) < 1) + if(LLSDSerialize::fromXMLDocument(data, istr) < 1) return false; // We'll expire entries more than a week old @@ -512,7 +433,7 @@ BOOL LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::strin } // static -void LLCacheName::LocalizeCacheName(std::string key, std::string value) +void LLCacheName::localizeCacheName(std::string key, std::string value) { if (key!="" && value!= "" ) sCacheName[key]=value; diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 322ca4aa1a..8d8e172c08 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -70,9 +70,6 @@ public: boost::signals2::connection addObserver(const LLCacheNameCallback& callback); - // janky old format. Remove after a while. Phoenix. 2008-01-30 - void importFile(LLFILE* fp); - // storing cache on disk; for viewer, in name.cache bool importFile(std::istream& istr); void exportFile(std::ostream& ostr); @@ -116,7 +113,7 @@ public: void dumpStats(); // Dumps the sizes of the cache and associated queues. static std::string getDefaultName(); - static void LocalizeCacheName(std::string key, std::string value); + static void localizeCacheName(std::string key, std::string value); static std::map sCacheName; private: -- cgit v1.2.3 From b34225a1918026ed8557a19cacf5925d107c134a Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 16 Feb 2010 10:40:53 -0800 Subject: Fix server to use updated LLCacheName API. Fixed callback signatures. Added LLCacheName::getDefaultLastName() to return "Resident" Reviewed with Huseby --- indra/llmessage/llcachename.cpp | 6 ++++++ indra/llmessage/llcachename.h | 5 +++++ 2 files changed, 11 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index b94788bd0c..90c1dedd10 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -672,6 +672,12 @@ std::string LLCacheName::getDefaultName() return sCacheName["waiting"]; } +//static +std::string LLCacheName::getDefaultLastName() +{ + return "Resident"; +} + void LLCacheName::Impl::processPendingAsks() { LLMemType mt_ppa(LLMemType::MTYPE_CACHE_PROCESS_PENDING_ASKS); diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 8d8e172c08..59ad03cfcc 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -113,6 +113,11 @@ public: void dumpStats(); // Dumps the sizes of the cache and associated queues. static std::string getDefaultName(); + + // Returns "Resident", the default last name for SLID-based accounts + // that have no last name. + static std::string getDefaultLastName(); + static void localizeCacheName(std::string key, std::string value); static std::map sCacheName; private: -- cgit v1.2.3 From 65d388d162dc14f5b8b3e0bfff1ae1125736f564 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 16 Feb 2010 11:58:21 -0800 Subject: Fix display of SLID-only accounts - prototype display name code was putting duplicate name in parentheses. --- indra/llmessage/llavatarnamecache.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 610bc58057..6dac25cd63 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -145,14 +145,15 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) return true; } - std::string full_name; - if (gCacheName->getFullName(agent_id, full_name)) - { - av_name->mSLID = slid_from_full_name(full_name); - av_name->mDisplayName = full_name; - av_name->mBadge = "Generic_Person"; - return true; - } + // JAMESDEBUG Enable when we turn on display names. + //std::string full_name; + //if (gCacheName->getFullName(agent_id, full_name)) + //{ + // av_name->mSLID = slid_from_full_name(full_name); + // av_name->mDisplayName = full_name; + // av_name->mBadge = "Generic_Person"; + // return true; + //} return false; } -- cgit v1.2.3 From a7041d0a442df98e5a1c938ce9b096f7279b96f7 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 16 Feb 2010 12:07:02 -0800 Subject: Fix Linux build warning/error for unused function --- indra/llmessage/llavatarnamecache.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 6dac25cd63..dbcb0d0c03 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -43,19 +43,20 @@ namespace LLAvatarNameCache std::map sCache; } -static std::string slid_from_full_name(const std::string& full_name) -{ - std::string id = full_name; - std::string::size_type end = id.length(); - for (std::string::size_type i = 0; i < end; ++i) - { - if (id[i] == ' ') - id[i] = '.'; - else - id[i] = tolower(id[i]); - } - return id; -} +// JAMESDEBUG re-enable when display names are turned on +//static std::string slid_from_full_name(const std::string& full_name) +//{ +// std::string id = full_name; +// std::string::size_type end = id.length(); +// for (std::string::size_type i = 0; i < end; ++i) +// { +// if (id[i] == ' ') +// id[i] = '.'; +// else +// id[i] = tolower(id[i]); +// } +// return id; +//} void LLAvatarNameCache::initClass() { -- cgit v1.2.3 From 6a69a696d20832973c4d1e9e607e7e3d6f3fce93 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 16 Feb 2010 16:59:34 -0800 Subject: Store last name Resident in cache for now, but don't use for reverse lookups --- indra/llmessage/llcachename.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 90c1dedd10..0e8f9f4828 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -75,7 +75,9 @@ public: public: bool mIsGroup; U32 mCreateTime; // unix time_t - std::string mFirstName; // IDEVO TODO collapse to one field + // IDEVO TODO collapse names to one field, which will eliminate + // many string compares on "Resident" + std::string mFirstName; std::string mLastName; std::string mGroupName; }; @@ -337,7 +339,7 @@ bool LLCacheName::importFile(std::istream& istr) entry->mFirstName = agent[FIRST].asString(); entry->mLastName = agent[LAST].asString(); impl.mCache[id] = entry; - std::string fullname = entry->mFirstName + " " + entry->mLastName; + std::string fullname = buildFullName(entry->mFirstName, entry->mLastName); impl.mReverseCache[fullname] = id; ++count; @@ -487,13 +489,13 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) BOOL LLCacheName::getUUID(const std::string& first, const std::string& last, LLUUID& id) { - std::string fullname = buildFullName(first, last); - return getUUID(fullname, id); + std::string full_name = buildFullName(first, last); + return getUUID(full_name, id); } -BOOL LLCacheName::getUUID(const std::string& fullname, LLUUID& id) +BOOL LLCacheName::getUUID(const std::string& full_name, LLUUID& id) { - ReverseCache::iterator iter = impl.mReverseCache.find(fullname); + ReverseCache::iterator iter = impl.mReverseCache.find(full_name); if (iter != impl.mReverseCache.end()) { id = iter->second; @@ -867,13 +869,6 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) { msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_FirstName, entry->mFirstName, i); msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName, entry->mLastName, i); - - // IDEVO blank out last name for storage to reduce string compares on - // retrieval. Eventually need to convert to single mName field. - if (entry->mLastName == "Resident") - { - entry->mLastName = ""; - } } else { // is group -- cgit v1.2.3 From 5774acb84e486c1eabad88093e80e3985d36dfcb Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 17 Feb 2010 09:19:06 -0800 Subject: Added function LLCacheName::cleanFullName() to strip " Resident" from strings --- indra/llmessage/llcachename.cpp | 6 ++++++ indra/llmessage/llcachename.h | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 0e8f9f4828..9ca0347f83 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -520,6 +520,12 @@ std::string LLCacheName::buildFullName(const std::string& first, const std::stri return fullname; } +//static +std::string LLCacheName::cleanFullName(const std::string& full_name) +{ + return full_name.substr(0, full_name.find(" Resident")); +} + // This is a little bit kludgy. LLCacheNameCallback is a slot instead of a function pointer. // The reason it is a slot is so that the legacy get() function below can bind an old callback // and pass it as a slot. The reason it isn't a boost::function is so that trackable behavior diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 59ad03cfcc..083975d4ca 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -86,6 +86,10 @@ public: // IDEVO Temporary code // Clean up new-style "bobsmith123 Resident" names to "bobsmith123" for display static std::string buildFullName(const std::string& first, const std::string& last); + + // Clean up legacy "bobsmith123 Resident" to "bobsmith123" + // If name does not contain "Resident" returns it unchanged. + static std::string cleanFullName(const std::string& full_name); // If available, this method copies the group name into the string // provided. The caller must allocate at least -- cgit v1.2.3 From 55bfb4435e1a2ffc34578bf30877eb24a5edaa29 Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 17 Feb 2010 16:55:58 -0800 Subject: Look up display names via a web service Also removed unused LLComboBox globals to reduce llappviewer.cpp include file burden. Review pending --- indra/llmessage/llavatarnamecache.cpp | 212 ++++++++++++++++++++++++++++------ indra/llmessage/llavatarnamecache.h | 2 + 2 files changed, 177 insertions(+), 37 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index dbcb0d0c03..a7ed20ac9b 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -35,15 +35,92 @@ #include "llavatarnamecache.h" #include "llcachename.h" // until we get our own web service +#include "llframetimer.h" +#include "llhttpclient.h" +#include "llsdserialize.h" // JAMESDEBUG #include // tolower() +#include namespace LLAvatarNameCache { - std::map sCache; + // base URL for name lookup service + std::string sNameServiceURL; + + // accumulated agent IDs for next query against service + typedef std::set ask_queue_t; + ask_queue_t sAskQueue; + + // agent IDs that have been requested, but with no reply + // maps agent ID to frame time request was made + typedef std::map pending_queue_t; + pending_queue_t sPendingQueue; + + // names we know about + typedef std::map cache_t; + cache_t sCache; + + // only need per-frame timing resolution + LLFrameTimer sRequestTimer; + + bool isRequestPending(const LLUUID& agent_id); } -// JAMESDEBUG re-enable when display names are turned on +class LLAvatarNameResponder : public LLHTTPClient::Responder +{ +public: + /*virtual*/ void result(const LLSD& content); + /*virtual*/ void error(U32 status, const std::string& reason); +}; + +void LLAvatarNameResponder::result(const LLSD& content) +{ + //std::ostringstream debug; + //LLSDSerialize::toPrettyXML(content, debug); + //llinfos << "JAMESDEBUG " << debug.str() << llendl; + + U32 now = (U32)LLFrameTimer::getTotalSeconds(); + LLSD::array_const_iterator it = content.beginArray(); + for ( ; it != content.endArray(); ++it) + { + const LLSD& row = *it; + + LLAvatarName av_name; + av_name.mSLID = row["slid"]; + av_name.mDisplayName = row["display_name"]; + av_name.mLastUpdate = now; + + // HACK for pretty stars + if (row["last_name"].asString() == "Linden") + { + av_name.mBadge = "Person_Star"; + } + + // Some avatars don't have explicit display names set + if (av_name.mDisplayName.empty()) + { + // make up a display name + std::string first_name = row["first_name"]; + std::string last_name = row["last_name"]; + av_name.mDisplayName = + LLCacheName::buildFullName(first_name, last_name); + } + + LLUUID agent_id = row["agent_id"]; + LLAvatarNameCache::sCache[agent_id] = av_name; + + LLAvatarNameCache::sPendingQueue.erase(agent_id); + + llinfos << "JAMESDEBUG fetched " << av_name.mDisplayName << llendl; + } +} + +void LLAvatarNameResponder::error(U32 status, const std::string& reason) +{ + llinfos << "JAMESDEBUG error " << status << " " << reason << llendl; +} + +// JAMESDEBUG re-enable when display names are turned on??? //static std::string slid_from_full_name(const std::string& full_name) //{ // std::string id = full_name; @@ -73,11 +150,6 @@ void LLAvatarNameCache::initClass() name.mBadge = "Person_Check"; sCache[LLUUID("27888d5f-4ddb-4df3-ad36-a1483ce0b3d9")] = name; - name.mSLID = "jim.linden"; - name.mDisplayName = "Jim Jenkins"; - name.mBadge = "Person_Star"; - sCache[LLUUID("3e5bf676-3577-c9ee-9fac-10df430015a1")] = name; - name.mSLID = "james.linden"; const unsigned char jose_sanchez[] = { 'J','o','s',0xC3,0xA9,' ','S','a','n','c','h','e','z', '\0' }; @@ -90,35 +162,41 @@ void LLAvatarNameCache::initClass() name.mBadge = ""; sCache[LLUUID("a23fff6c-80ae-4997-9253-48272fd01d3c")] = name; - name.mSLID = "hamilton.linden"; - name.mDisplayName = "Hamilton Hitchings"; - name.mBadge = "Person_Star"; - sCache[LLUUID("3f7ced39-5e38-4fdd-90f2-423560b1e6e2")] = name; - - name.mSLID = "rome.linden"; - name.mDisplayName = "Rome Portlock"; - name.mBadge = "Person_Star"; - sCache[LLUUID("537da1e1-a89f-4f9b-9056-b1f0757ccdd0")] = name; - - name.mSLID = "m.linden"; - name.mDisplayName = "Mark Kingdon"; - name.mBadge = "Person_Star"; - sCache[LLUUID("244195d6-c9b7-4fd6-9229-c3a8b2e60e81")] = name; - - name.mSLID = "t.linden"; - name.mDisplayName = "Tom Hale"; - name.mBadge = "Person_Star"; - sCache[LLUUID("49856302-98d4-4e32-b5e9-035e5b4e83a4")] = name; - - name.mSLID = "callen.linden"; - name.mDisplayName = "Christina Allen"; - name.mBadge = "Person_Star"; - sCache[LLUUID("e6ed7825-708f-4c6b-b6a7-f3fe921a9176")] = name; - - name.mSLID = "crimp.linden"; - name.mDisplayName = "Chris Rimple"; - name.mBadge = "Person_Star"; - sCache[LLUUID("a7f0ac18-205f-41d2-b5b4-f75f096ae511")] = name; + // These are served by the web service now + //name.mSLID = "jim.linden"; + //name.mDisplayName = "Jim Jenkins"; + //name.mBadge = "Person_Star"; + //sCache[LLUUID("3e5bf676-3577-c9ee-9fac-10df430015a1")] = name; + + //name.mSLID = "hamilton.linden"; + //name.mDisplayName = "Hamilton Hitchings"; + //name.mBadge = "Person_Star"; + //sCache[LLUUID("3f7ced39-5e38-4fdd-90f2-423560b1e6e2")] = name; + + //name.mSLID = "rome.linden"; + //name.mDisplayName = "Rome Portlock"; + //name.mBadge = "Person_Star"; + //sCache[LLUUID("537da1e1-a89f-4f9b-9056-b1f0757ccdd0")] = name; + + //name.mSLID = "m.linden"; + //name.mDisplayName = "Mark Kingdon"; + //name.mBadge = "Person_Star"; + //sCache[LLUUID("244195d6-c9b7-4fd6-9229-c3a8b2e60e81")] = name; + + //name.mSLID = "t.linden"; + //name.mDisplayName = "Tom Hale"; + //name.mBadge = "Person_Star"; + //sCache[LLUUID("49856302-98d4-4e32-b5e9-035e5b4e83a4")] = name; + + //name.mSLID = "callen.linden"; + //name.mDisplayName = "Christina Allen"; + //name.mBadge = "Person_Star"; + //sCache[LLUUID("e6ed7825-708f-4c6b-b6a7-f3fe921a9176")] = name; + + //name.mSLID = "crimp.linden"; + //name.mDisplayName = "Chris Rimple"; + //name.mBadge = "Person_Star"; + //sCache[LLUUID("a7f0ac18-205f-41d2-b5b4-f75f096ae511")] = name; } void LLAvatarNameCache::cleanupClass() @@ -135,6 +213,57 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr) void LLAvatarNameCache::idle() { + const F32 SECS_BETWEEN_REQUESTS = 0.5f; // JAMESDEBUG set to 0.1? + if (sRequestTimer.checkExpirationAndReset(SECS_BETWEEN_REQUESTS)) + { + return; + } + + if (sAskQueue.empty()) + { + return; + } + + LLSD body; + body["agent_ids"] = LLSD::emptyArray(); + LLSD& agent_ids = body["agent_ids"]; + + ask_queue_t::const_iterator it = sAskQueue.begin(); + for ( ; it != sAskQueue.end(); ++it) + { + agent_ids.append( LLSD( *it ) ); + } + + //std::ostringstream debug; + //LLSDSerialize::toPrettyXML(body, debug); + //LL_INFOS("JAMESDEBUG") << debug.str() << LL_ENDL; + + // *TODO: configure the base URL for this + std::string url = "http://pdp15.lindenlab.com:8050/my-service/agent/display-names/"; + LLHTTPClient::post(url, body, new LLAvatarNameResponder()); + + // Move requests from Ask queue to Pending queue + U32 now = (U32)LLFrameTimer::getTotalSeconds(); + for (it = sAskQueue.begin(); it != sAskQueue.end(); ++it) + { + sPendingQueue[*it] = now; + } + sAskQueue.clear(); +} + +bool LLAvatarNameCache::isRequestPending(const LLUUID& agent_id) +{ + const U32 PENDING_TIMEOUT_SECS = 5 * 60; + U32 now = (U32)LLFrameTimer::getTotalSeconds(); + U32 expire_time = now - PENDING_TIMEOUT_SECS; + + pending_queue_t::const_iterator it = sPendingQueue.find(agent_id); + if (it != sPendingQueue.end()) + { + bool expired = (it->second < expire_time); + return !expired; + } + return false; } bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) @@ -146,7 +275,7 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) return true; } - // JAMESDEBUG Enable when we turn on display names. + // JAMESDEBUG Enable when we turn on display names??? //std::string full_name; //if (gCacheName->getFullName(agent_id, full_name)) //{ @@ -156,6 +285,15 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) // return true; //} + if (!isRequestPending(agent_id)) + { + std::pair found = sAskQueue.insert(agent_id); + if (found.second) + { + LL_INFOS("JAMESDEBUG") << "added to ask queue " << agent_id << LL_ENDL; + } + } + return false; } diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index adf12bbbc6..a0e6abf303 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -43,6 +43,8 @@ namespace LLAvatarNameCache void importFile(std::istream& istr); void exportFile(std::ostream& ostr); + // Periodically makes a batch request for display names not already in + // cache. Call once per frame. void idle(); // If name is in cache, returns true and fills in provided LLAvatarName -- cgit v1.2.3 From 9cb30255b6b8827410a32c6bee1c22b8011de60e Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 17 Feb 2010 20:49:44 -0800 Subject: Fix Mac/Linux build Dang finicky LLSD map dereferences --- indra/llmessage/llavatarnamecache.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index a7ed20ac9b..0d6981a9d9 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -86,8 +86,8 @@ void LLAvatarNameResponder::result(const LLSD& content) const LLSD& row = *it; LLAvatarName av_name; - av_name.mSLID = row["slid"]; - av_name.mDisplayName = row["display_name"]; + av_name.mSLID = row["slid"].asString(); + av_name.mDisplayName = row["display_name"].asString(); av_name.mLastUpdate = now; // HACK for pretty stars @@ -100,13 +100,13 @@ void LLAvatarNameResponder::result(const LLSD& content) if (av_name.mDisplayName.empty()) { // make up a display name - std::string first_name = row["first_name"]; - std::string last_name = row["last_name"]; + std::string first_name = row["first_name"].asString(); + std::string last_name = row["last_name"].asString(); av_name.mDisplayName = LLCacheName::buildFullName(first_name, last_name); } - LLUUID agent_id = row["agent_id"]; + LLUUID agent_id = row["agent_id"].asUUID(); LLAvatarNameCache::sCache[agent_id] = av_name; LLAvatarNameCache::sPendingQueue.erase(agent_id); -- cgit v1.2.3 From ee81adb01b8619302898471fdbba5c93f716d10b Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 18 Feb 2010 18:46:41 -0800 Subject: Preference to set what fields name tags display, and first attempt at "use display names" menu item which doesn't work yet --- indra/llmessage/llavatarnamecache.cpp | 15 +++++++++++++-- indra/llmessage/llavatarnamecache.h | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 0d6981a9d9..0941dff0fa 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -44,8 +44,7 @@ namespace LLAvatarNameCache { - // base URL for name lookup service - std::string sNameServiceURL; + bool sUseDisplayNames = false; // accumulated agent IDs for next query against service typedef std::set ask_queue_t; @@ -300,3 +299,15 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) void LLAvatarNameCache::get(const LLUUID& agent_id, name_cache_callback_t callback) { } + +void LLAvatarNameCache::toggleDisplayNames() +{ + sUseDisplayNames = !sUseDisplayNames; + // flush our cache + sCache.clear(); +} + +bool LLAvatarNameCache::useDisplayNames() +{ + return sUseDisplayNames; +} diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index a0e6abf303..9f0472095d 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -55,6 +55,10 @@ namespace LLAvatarNameCache // If name information is in cache, callback will be called immediately. typedef void (*name_cache_callback_t)(const LLUUID& agent_id, const LLAvatarName& av_name); void get(const LLUUID& agent_id, name_cache_callback_t callback); + + // HACK: turn display names on and off + void toggleDisplayNames(); + bool useDisplayNames(); } #endif -- cgit v1.2.3 From fe1dc7dc7e8386a673ff11b1afac93affd14d875 Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 18 Feb 2010 18:47:25 -0800 Subject: Default using display names to on for now until I can fix the code to turn them off --- indra/llmessage/llavatarnamecache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 0941dff0fa..b991638f75 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -44,7 +44,7 @@ namespace LLAvatarNameCache { - bool sUseDisplayNames = false; + bool sUseDisplayNames = true; // accumulated agent IDs for next query against service typedef std::set ask_queue_t; -- cgit v1.2.3 From c1d7e7d5d961819255f6f2fe4de5ece3b80867db Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 19 Feb 2010 10:53:17 -0800 Subject: Added clear() method for debugging --- indra/llmessage/llcachename.cpp | 6 ++++++ indra/llmessage/llcachename.h | 1 + 2 files changed, 7 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 9ca0347f83..eed2beb859 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -674,6 +674,12 @@ void LLCacheName::dumpStats() << llendl; } +void LLCacheName::clear() +{ + for_each(impl.mCache.begin(), impl.mCache.end(), DeletePairedPointer()); + impl.mCache.clear(); +} + //static std::string LLCacheName::getDefaultName() { diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 083975d4ca..6b6bbde6ab 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -115,6 +115,7 @@ public: // Debugging void dump(); // Dumps the contents of the cache void dumpStats(); // Dumps the sizes of the cache and associated queues. + void clear(); // Deletes all entries from the cache static std::string getDefaultName(); -- cgit v1.2.3 From af8f8b4770eb45b4238d98ddd574ba726470f797 Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 19 Feb 2010 11:11:45 -0800 Subject: Improved support for toggling display names on/off Stop pre-populated name cache because we have a web service now for lookup Added mIsLegacy to LLAvatarName so we can colorize those name tags differently --- indra/llmessage/llavatarnamecache.cpp | 68 ++++------------------------------- 1 file changed, 7 insertions(+), 61 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index b991638f75..cd05a80bc1 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -44,7 +44,7 @@ namespace LLAvatarNameCache { - bool sUseDisplayNames = true; + bool sUseDisplayNames = false; // accumulated agent IDs for next query against service typedef std::set ask_queue_t; @@ -103,6 +103,7 @@ void LLAvatarNameResponder::result(const LLSD& content) std::string last_name = row["last_name"].asString(); av_name.mDisplayName = LLCacheName::buildFullName(first_name, last_name); + av_name.mIsLegacy = true; } LLUUID agent_id = row["agent_id"].asUUID(); @@ -136,66 +137,6 @@ void LLAvatarNameResponder::error(U32 status, const std::string& reason) void LLAvatarNameCache::initClass() { - // HACK - prepopulate the cache - LLAvatarName name; - LLUUID id; - - name.mSLID = "miyazaki23"; - const unsigned char miyazaki_hayao_san[] - = { 0xE5, 0xAE, 0xAE, 0xE5, 0xB4, 0x8E, - 0xE9, 0xA7, 0xBF, - 0xE3, 0x81, 0x95, 0xE3, 0x82, 0x93, '\0' }; - name.mDisplayName = (const char*)miyazaki_hayao_san; - name.mBadge = "Person_Check"; - sCache[LLUUID("27888d5f-4ddb-4df3-ad36-a1483ce0b3d9")] = name; - - name.mSLID = "james.linden"; - const unsigned char jose_sanchez[] = - { 'J','o','s',0xC3,0xA9,' ','S','a','n','c','h','e','z', '\0' }; - name.mDisplayName = (const char*)jose_sanchez; - name.mBadge = "35f217a3-f618-49cf-bbca-c86d486551a9"; // IMG_SHOT - sCache[LLUUID("a2e76fcd-9360-4f6d-a924-938f923df11a")] = name; - - name.mSLID = "bobsmith123"; - name.mDisplayName = (const char*)jose_sanchez; - name.mBadge = ""; - sCache[LLUUID("a23fff6c-80ae-4997-9253-48272fd01d3c")] = name; - - // These are served by the web service now - //name.mSLID = "jim.linden"; - //name.mDisplayName = "Jim Jenkins"; - //name.mBadge = "Person_Star"; - //sCache[LLUUID("3e5bf676-3577-c9ee-9fac-10df430015a1")] = name; - - //name.mSLID = "hamilton.linden"; - //name.mDisplayName = "Hamilton Hitchings"; - //name.mBadge = "Person_Star"; - //sCache[LLUUID("3f7ced39-5e38-4fdd-90f2-423560b1e6e2")] = name; - - //name.mSLID = "rome.linden"; - //name.mDisplayName = "Rome Portlock"; - //name.mBadge = "Person_Star"; - //sCache[LLUUID("537da1e1-a89f-4f9b-9056-b1f0757ccdd0")] = name; - - //name.mSLID = "m.linden"; - //name.mDisplayName = "Mark Kingdon"; - //name.mBadge = "Person_Star"; - //sCache[LLUUID("244195d6-c9b7-4fd6-9229-c3a8b2e60e81")] = name; - - //name.mSLID = "t.linden"; - //name.mDisplayName = "Tom Hale"; - //name.mBadge = "Person_Star"; - //sCache[LLUUID("49856302-98d4-4e32-b5e9-035e5b4e83a4")] = name; - - //name.mSLID = "callen.linden"; - //name.mDisplayName = "Christina Allen"; - //name.mBadge = "Person_Star"; - //sCache[LLUUID("e6ed7825-708f-4c6b-b6a7-f3fe921a9176")] = name; - - //name.mSLID = "crimp.linden"; - //name.mDisplayName = "Chris Rimple"; - //name.mBadge = "Person_Star"; - //sCache[LLUUID("a7f0ac18-205f-41d2-b5b4-f75f096ae511")] = name; } void LLAvatarNameCache::cleanupClass() @@ -305,6 +246,11 @@ void LLAvatarNameCache::toggleDisplayNames() sUseDisplayNames = !sUseDisplayNames; // flush our cache sCache.clear(); + // force re-lookups + if (gCacheName) + { + gCacheName->clear(); + } } bool LLAvatarNameCache::useDisplayNames() -- cgit v1.2.3 From 3791745054546dbebb3373371aaf7a0ddad608a3 Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 22 Feb 2010 16:41:56 -0800 Subject: Simple button to change your display name Talks to web service so other people can see the change, but for now they need to relog or toggle display names on/off to clear their cache. --- indra/llmessage/llavatarnamecache.cpp | 33 +++++++++++++++++++++++++++++++++ indra/llmessage/llavatarnamecache.h | 3 +++ 2 files changed, 36 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index cd05a80bc1..37b7a48244 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -241,6 +241,39 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, name_cache_callback_t callba { } +class LLSetNameResponder : public LLHTTPClient::Responder +{ +public: + LLUUID mAgentID; + + LLSetNameResponder(const LLUUID& agent_id) : mAgentID(agent_id) { } + + /*virtual*/ void result(const LLSD& content) + { + // force re-fetch + LLAvatarNameCache::sCache.erase(mAgentID); + llinfos << "JAMESDEBUG set names worked" << llendl; + } + + /*virtual*/ void error(U32 status, const std::string& reason) + { + llinfos << "JAMESDEBUG set names failed " << status + << " reason " << reason << llendl; + } +}; + +void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, const std::string& display_name) +{ + LLSD body; + body["display_name"] = display_name; + + // *TODO: configure the base URL for this + std::string url = "http://pdp15.lindenlab.com:8050/my-service/agent/"; + url += agent_id.asString(); + url += "/set-display-name/"; + LLHTTPClient::post(url, body, new LLSetNameResponder(agent_id)); +} + void LLAvatarNameCache::toggleDisplayNames() { sUseDisplayNames = !sUseDisplayNames; diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 9f0472095d..369c8f8fff 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -56,6 +56,9 @@ namespace LLAvatarNameCache typedef void (*name_cache_callback_t)(const LLUUID& agent_id, const LLAvatarName& av_name); void get(const LLUUID& agent_id, name_cache_callback_t callback); + // Sends an update to the server + void setDisplayName(const LLUUID& agent_id, const std::string& display_name); + // HACK: turn display names on and off void toggleDisplayNames(); bool useDisplayNames(); -- cgit v1.2.3 From 087736c1522f111bc6a4d4937db8541031ef4014 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 23 Feb 2010 16:33:26 -0800 Subject: Decreased delay between name lookup requests for slightly faster lookup times --- indra/llmessage/llavatarnamecache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 37b7a48244..162829da06 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -153,7 +153,7 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr) void LLAvatarNameCache::idle() { - const F32 SECS_BETWEEN_REQUESTS = 0.5f; // JAMESDEBUG set to 0.1? + const F32 SECS_BETWEEN_REQUESTS = 0.2f; // JAMESDEBUG set to 0.1? if (sRequestTimer.checkExpirationAndReset(SECS_BETWEEN_REQUESTS)) { return; -- cgit v1.2.3 From 4fafec91fb9e687861c520da0a520354a98bd522 Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 24 Feb 2010 11:03:27 -0800 Subject: Add asynchronous display name lookup with callback --- indra/llmessage/llavatarnamecache.cpp | 137 ++++++++++++++++++++++------------ indra/llmessage/llavatarnamecache.h | 10 ++- 2 files changed, 99 insertions(+), 48 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 162829da06..50bdc1e063 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -55,6 +55,13 @@ namespace LLAvatarNameCache typedef std::map pending_queue_t; pending_queue_t sPendingQueue; + // Callbacks to fire when we received a name. + // May have multiple callbacks for a single ID, which are + // represented as multiple slots bound to the signal. + // Avoid copying signals via pointers. + typedef std::map signal_map_t; + signal_map_t sSignalMap; + // names we know about typedef std::map cache_t; cache_t sCache; @@ -63,6 +70,7 @@ namespace LLAvatarNameCache LLFrameTimer sRequestTimer; bool isRequestPending(const LLUUID& agent_id); + void processResult(const LLSD& row); } class LLAvatarNameResponder : public LLHTTPClient::Responder @@ -78,40 +86,11 @@ void LLAvatarNameResponder::result(const LLSD& content) //LLSDSerialize::toPrettyXML(content, debug); //llinfos << "JAMESDEBUG " << debug.str() << llendl; - U32 now = (U32)LLFrameTimer::getTotalSeconds(); LLSD::array_const_iterator it = content.beginArray(); for ( ; it != content.endArray(); ++it) { const LLSD& row = *it; - - LLAvatarName av_name; - av_name.mSLID = row["slid"].asString(); - av_name.mDisplayName = row["display_name"].asString(); - av_name.mLastUpdate = now; - - // HACK for pretty stars - if (row["last_name"].asString() == "Linden") - { - av_name.mBadge = "Person_Star"; - } - - // Some avatars don't have explicit display names set - if (av_name.mDisplayName.empty()) - { - // make up a display name - std::string first_name = row["first_name"].asString(); - std::string last_name = row["last_name"].asString(); - av_name.mDisplayName = - LLCacheName::buildFullName(first_name, last_name); - av_name.mIsLegacy = true; - } - - LLUUID agent_id = row["agent_id"].asUUID(); - LLAvatarNameCache::sCache[agent_id] = av_name; - - LLAvatarNameCache::sPendingQueue.erase(agent_id); - - llinfos << "JAMESDEBUG fetched " << av_name.mDisplayName << llendl; + LLAvatarNameCache::processResult(row); } } @@ -120,6 +99,55 @@ void LLAvatarNameResponder::error(U32 status, const std::string& reason) llinfos << "JAMESDEBUG error " << status << " " << reason << llendl; } +void LLAvatarNameCache::processResult(const LLSD& row) +{ + U32 now = (U32)LLFrameTimer::getTotalSeconds(); + + LLAvatarName av_name; + av_name.mSLID = row["slid"].asString(); + av_name.mDisplayName = row["display_name"].asString(); + av_name.mLastUpdate = now; + + // HACK for pretty stars + if (row["last_name"].asString() == "Linden") + { + av_name.mBadge = "Person_Star"; + } + + // Some avatars don't have explicit display names set + if (av_name.mDisplayName.empty()) + { + // make up a display name + std::string first_name = row["first_name"].asString(); + std::string last_name = row["last_name"].asString(); + av_name.mDisplayName = + LLCacheName::buildFullName(first_name, last_name); + av_name.mIsLegacy = true; + } + + // add to cache + LLUUID agent_id = row["agent_id"].asUUID(); + sCache[agent_id] = av_name; + + sPendingQueue.erase(agent_id); + + // signal everyone waiting on this name + signal_map_t::iterator sig_it = sSignalMap.find(agent_id); + if (sig_it != sSignalMap.end()) + { + llinfos << "JAMESDEBUG firing signal" << llendl; + callback_signal_t* signal = sig_it->second; + (*signal)(agent_id, av_name); + + sSignalMap.erase(agent_id); + + delete signal; + signal = NULL; + } + + llinfos << "JAMESDEBUG fetched " << av_name.mDisplayName << llendl; +} + // JAMESDEBUG re-enable when display names are turned on??? //static std::string slid_from_full_name(const std::string& full_name) //{ @@ -215,30 +243,47 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) return true; } - // JAMESDEBUG Enable when we turn on display names??? - //std::string full_name; - //if (gCacheName->getFullName(agent_id, full_name)) - //{ - // av_name->mSLID = slid_from_full_name(full_name); - // av_name->mDisplayName = full_name; - // av_name->mBadge = "Generic_Person"; - // return true; - //} - if (!isRequestPending(agent_id)) { - std::pair found = sAskQueue.insert(agent_id); - if (found.second) - { - LL_INFOS("JAMESDEBUG") << "added to ask queue " << agent_id << LL_ENDL; - } + sAskQueue.insert(agent_id); } return false; } -void LLAvatarNameCache::get(const LLUUID& agent_id, name_cache_callback_t callback) +void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) { + std::map::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 + if (!isRequestPending(agent_id)) + { + sAskQueue.insert(agent_id); + } + + // always store additional callback, even if request is pending + signal_map_t::iterator sig_it = sSignalMap.find(agent_id); + if (sig_it == sSignalMap.end()) + { + // ...new callback for this id + callback_signal_t* signal = new callback_signal_t(); + signal->connect(slot); + sSignalMap[agent_id] = signal; + } + else + { + // ...existing callback, bind additional slot + callback_signal_t* signal = sig_it->second; + signal->connect(slot); + } } class LLSetNameResponder : public LLHTTPClient::Responder diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 369c8f8fff..e2166b568f 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -35,6 +35,8 @@ #include "llavatarname.h" // for convenience +#include + namespace LLAvatarNameCache { void initClass(); @@ -51,10 +53,14 @@ namespace LLAvatarNameCache // otherwise returns false bool get(const LLUUID& agent_id, LLAvatarName *av_name); + typedef boost::signals2::signal< + void (const LLUUID& agent_id, const LLAvatarName& av_name)> + callback_signal_t; + typedef callback_signal_t::slot_type callback_slot_t; + // Fetches name information and calls callback. // If name information is in cache, callback will be called immediately. - typedef void (*name_cache_callback_t)(const LLUUID& agent_id, const LLAvatarName& av_name); - void get(const LLUUID& agent_id, name_cache_callback_t callback); + void get(const LLUUID& agent_id, callback_slot_t slot); // Sends an update to the server void setDisplayName(const LLUUID& agent_id, const std::string& display_name); -- cgit v1.2.3 From 649bdf412f4cead9721b5393d3929b6fbd6df272 Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 24 Feb 2010 11:58:48 -0800 Subject: Clean up code after review with Roxie --- indra/llmessage/llavatarnamecache.cpp | 71 +++++++++++------------------------ 1 file changed, 22 insertions(+), 49 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 50bdc1e063..1a456e15be 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -34,18 +34,21 @@ #include "llavatarnamecache.h" -#include "llcachename.h" // until we get our own web service +#include "llcachename.h" // *TODO: remove #include "llframetimer.h" #include "llhttpclient.h" -#include "llsdserialize.h" // JAMESDEBUG -#include // tolower() +#include #include namespace LLAvatarNameCache { bool sUseDisplayNames = false; + // *TODO: configure the base URL for this in viewer with data + // from login.cgi + std::string sNameServiceBaseURL = "http://pdp15.lindenlab.com:8050/my-service/"; + // accumulated agent IDs for next query against service typedef std::set ask_queue_t; ask_queue_t sAskQueue; @@ -70,36 +73,29 @@ namespace LLAvatarNameCache LLFrameTimer sRequestTimer; bool isRequestPending(const LLUUID& agent_id); - void processResult(const LLSD& row); + void processNameFromService(const LLSD& row); } class LLAvatarNameResponder : public LLHTTPClient::Responder { public: - /*virtual*/ void result(const LLSD& content); - /*virtual*/ void error(U32 status, const std::string& reason); -}; - -void LLAvatarNameResponder::result(const LLSD& content) -{ - //std::ostringstream debug; - //LLSDSerialize::toPrettyXML(content, debug); - //llinfos << "JAMESDEBUG " << debug.str() << llendl; - - LLSD::array_const_iterator it = content.beginArray(); - for ( ; it != content.endArray(); ++it) + /*virtual*/ void result(const LLSD& content) { - const LLSD& row = *it; - LLAvatarNameCache::processResult(row); + LLSD::array_const_iterator it = content.beginArray(); + for ( ; it != content.endArray(); ++it) + { + const LLSD& row = *it; + LLAvatarNameCache::processNameFromService(row); + } } -} -void LLAvatarNameResponder::error(U32 status, const std::string& reason) -{ - llinfos << "JAMESDEBUG error " << status << " " << reason << llendl; -} + /*virtual*/ void error(U32 status, const std::string& reason) + { + llinfos << "JAMESDEBUG error " << status << " " << reason << llendl; + } +}; -void LLAvatarNameCache::processResult(const LLSD& row) +void LLAvatarNameCache::processNameFromService(const LLSD& row) { U32 now = (U32)LLFrameTimer::getTotalSeconds(); @@ -135,7 +131,6 @@ void LLAvatarNameCache::processResult(const LLSD& row) signal_map_t::iterator sig_it = sSignalMap.find(agent_id); if (sig_it != sSignalMap.end()) { - llinfos << "JAMESDEBUG firing signal" << llendl; callback_signal_t* signal = sig_it->second; (*signal)(agent_id, av_name); @@ -144,25 +139,8 @@ void LLAvatarNameCache::processResult(const LLSD& row) delete signal; signal = NULL; } - - llinfos << "JAMESDEBUG fetched " << av_name.mDisplayName << llendl; } -// JAMESDEBUG re-enable when display names are turned on??? -//static std::string slid_from_full_name(const std::string& full_name) -//{ -// std::string id = full_name; -// std::string::size_type end = id.length(); -// for (std::string::size_type i = 0; i < end; ++i) -// { -// if (id[i] == ' ') -// id[i] = '.'; -// else -// id[i] = tolower(id[i]); -// } -// return id; -//} - void LLAvatarNameCache::initClass() { } @@ -202,12 +180,8 @@ void LLAvatarNameCache::idle() agent_ids.append( LLSD( *it ) ); } - //std::ostringstream debug; - //LLSDSerialize::toPrettyXML(body, debug); - //LL_INFOS("JAMESDEBUG") << debug.str() << LL_ENDL; - // *TODO: configure the base URL for this - std::string url = "http://pdp15.lindenlab.com:8050/my-service/agent/display-names/"; + std::string url = sNameServiceBaseURL + "agent/display-names/"; LLHTTPClient::post(url, body, new LLAvatarNameResponder()); // Move requests from Ask queue to Pending queue @@ -297,7 +271,6 @@ public: { // force re-fetch LLAvatarNameCache::sCache.erase(mAgentID); - llinfos << "JAMESDEBUG set names worked" << llendl; } /*virtual*/ void error(U32 status, const std::string& reason) @@ -313,7 +286,7 @@ void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, const std::string body["display_name"] = display_name; // *TODO: configure the base URL for this - std::string url = "http://pdp15.lindenlab.com:8050/my-service/agent/"; + std::string url = sNameServiceBaseURL + "agent/"; url += agent_id.asString(); url += "/set-display-name/"; LLHTTPClient::post(url, body, new LLSetNameResponder(agent_id)); -- cgit v1.2.3 From f3e0e9a5264a80d146a1d4d77fd9c4f5d3070278 Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 24 Feb 2010 14:31:46 -0800 Subject: Hack to refresh name tags when I change my display name. Also fixes a crash when turning on display names. --- indra/llmessage/llavatarnamecache.cpp | 5 +++++ indra/llmessage/llavatarnamecache.h | 1 + 2 files changed, 6 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 1a456e15be..5384e1f067 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -308,3 +308,8 @@ bool LLAvatarNameCache::useDisplayNames() { return sUseDisplayNames; } + +void LLAvatarNameCache::erase(const LLUUID& agent_id) +{ + sCache.erase(agent_id); +} diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index e2166b568f..a09f549877 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -68,6 +68,7 @@ namespace LLAvatarNameCache // HACK: turn display names on and off void toggleDisplayNames(); bool useDisplayNames(); + void erase(const LLUUID& agent_id); } #endif -- cgit v1.2.3 From 822d042e0c04dba2cdaced8c81b50840972a7286 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 2 Mar 2010 11:15:28 -0800 Subject: Don't load cached names with blank last names, avoids data corruption --- indra/llmessage/llcachename.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index eed2beb859..8575332392 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -388,7 +388,8 @@ void LLCacheName::exportFile(std::ostream& ostr) // store it LLUUID id = iter->first; std::string id_str = id.asString(); - if(!entry->mFirstName.empty() /* && !entry->mLastName.empty() */ ) // IDEVO save SLIDs + // IDEVO TODO: Should we store SLIDs with last name "Resident" or not? + if(!entry->mFirstName.empty() && !entry->mLastName.empty()) { data[AGENTS][id_str][FIRST] = entry->mFirstName; data[AGENTS][id_str][LAST] = entry->mLastName; -- cgit v1.2.3 From d0632598632465850568789ce2d00dcc325e5ebe Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 3 Mar 2010 16:41:17 -0800 Subject: Work around bad usernames occasionally sent from server. --- indra/llmessage/llcachename.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 8575332392..d7d49eac8d 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -891,8 +891,21 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) if (!isGroup) { - std::string full_name = - LLCacheName::buildFullName(entry->mFirstName, entry->mLastName); + // NOTE: Very occasionally the server sends down a full name + // in the first name field with an empty last name, for example, + // first = "Ladanie1 Resident", last = "". + // I cannot reproduce this, nor can I find a bug in the server code. + // Ensure "Resident" does not appear via cleanFullName, because + // buildFullName only checks last name. JC + std::string full_name; + if (entry->mLastName.empty()) + { + full_name = cleanFullName(entry->mFirstName); + } + else + { + full_name = LLCacheName::buildFullName(entry->mFirstName, entry->mLastName); + } mSignal(id, full_name, false); mReverseCache[full_name] = id; } -- cgit v1.2.3 From 1f340919533db8c49755002311b72483057a56c9 Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 8 Mar 2010 16:41:08 -0800 Subject: Removed custom star badges for Lindens. Plan is to use avatar profile pictures for these. --- indra/llmessage/llavatarnamecache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 5384e1f067..5f9e600d47 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -105,10 +105,10 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row) av_name.mLastUpdate = now; // HACK for pretty stars - if (row["last_name"].asString() == "Linden") - { - av_name.mBadge = "Person_Star"; - } + //if (row["last_name"].asString() == "Linden") + //{ + // av_name.mBadge = "Person_Star"; + //} // Some avatars don't have explicit display names set if (av_name.mDisplayName.empty()) -- cgit v1.2.3 From 60aa61e1cc5d3c42f54368a2b0b9eccfe5d315ff Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 9 Mar 2010 12:23:43 -0800 Subject: Default display names to on for demo --- indra/llmessage/llavatarnamecache.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 5f9e600d47..eae4f62f26 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -43,7 +43,9 @@ namespace LLAvatarNameCache { - bool sUseDisplayNames = false; + // *TODO: Defaulted to true for demo, probably want false for initial + // release and turn it on based on data from login.cgi + bool sUseDisplayNames = true; // *TODO: configure the base URL for this in viewer with data // from login.cgi -- cgit v1.2.3 From 421fe9efa709db0fd870f4bfbdc61d4716767fe5 Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 10 Mar 2010 17:12:00 -0800 Subject: Freshly created SLID-only account now shows white tag, not yellow --- indra/llmessage/llavatarnamecache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index eae4f62f26..d7284c41a7 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -120,7 +120,7 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row) std::string last_name = row["last_name"].asString(); av_name.mDisplayName = LLCacheName::buildFullName(first_name, last_name); - av_name.mIsLegacy = true; + av_name.mIsLegacy = (last_name != "Resident"); } // add to cache -- cgit v1.2.3 From 639b234762133e4d09d6d7b1bac9d25c5a681926 Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 18 Mar 2010 17:19:57 -0700 Subject: Partial support for Set Name returning error msg from service --- indra/llmessage/llavatarnamecache.cpp | 20 +++++++++++++++++--- indra/llmessage/llavatarnamecache.h | 18 +++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index d7284c41a7..d49f1d3de5 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -37,6 +37,7 @@ #include "llcachename.h" // *TODO: remove #include "llframetimer.h" #include "llhttpclient.h" +#include "llsd.h" #include #include @@ -266,23 +267,36 @@ class LLSetNameResponder : public LLHTTPClient::Responder { public: LLUUID mAgentID; + LLAvatarNameCache::set_name_signal_t mSignal; - LLSetNameResponder(const LLUUID& agent_id) : mAgentID(agent_id) { } + LLSetNameResponder(const LLUUID& agent_id, + const LLAvatarNameCache::set_name_slot_t& slot) + : mAgentID(agent_id), + mSignal() + { + mSignal.connect(slot); + } /*virtual*/ void result(const LLSD& content) { // force re-fetch LLAvatarNameCache::sCache.erase(mAgentID); + + mSignal(true, "", content); } /*virtual*/ void error(U32 status, const std::string& reason) { llinfos << "JAMESDEBUG set names failed " << status << " reason " << reason << llendl; + + mSignal(false, reason, LLSD()); } }; -void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, const std::string& display_name) +void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, + const std::string& display_name, + const set_name_slot_t& slot) { LLSD body; body["display_name"] = display_name; @@ -291,7 +305,7 @@ void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, const std::string std::string url = sNameServiceBaseURL + "agent/"; url += agent_id.asString(); url += "/set-display-name/"; - LLHTTPClient::post(url, body, new LLSetNameResponder(agent_id)); + LLHTTPClient::post(url, body, new LLSetNameResponder(agent_id, slot)); } void LLAvatarNameCache::toggleDisplayNames() diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index a09f549877..8fc43860da 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -37,6 +37,9 @@ #include +class LLSD; +class LLUUID; + namespace LLAvatarNameCache { void initClass(); @@ -53,6 +56,7 @@ namespace LLAvatarNameCache // otherwise returns false bool get(const LLUUID& agent_id, LLAvatarName *av_name); + // Callback types for get() below typedef boost::signals2::signal< void (const LLUUID& agent_id, const LLAvatarName& av_name)> callback_signal_t; @@ -61,9 +65,17 @@ namespace LLAvatarNameCache // Fetches name information and calls callback. // If name information is in cache, callback will be called immediately. void get(const LLUUID& agent_id, callback_slot_t slot); - - // Sends an update to the server - void setDisplayName(const LLUUID& agent_id, const std::string& display_name); + + // Callback types for setDisplayName() below + typedef boost::signals2::signal< + void (bool success, const std::string& reason, const LLSD& content)> + set_name_signal_t; + typedef set_name_signal_t::slot_type set_name_slot_t; + + // Sends an update to the server to change a display name + // and calls back the application layer when done + void setDisplayName(const LLUUID& agent_id, const std::string& display_name, + const set_name_slot_t& slot); // HACK: turn display names on and off void toggleDisplayNames(); -- cgit v1.2.3 From d2f9e34598621f1dabad15025417efd6b81dddf0 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 23 Mar 2010 11:41:33 -0700 Subject: Part DEV-47695 route display name changes via sim for rebroadcast to nearby avatars for name tag updates and to update cached display name for LSL nonblocking functions --- indra/llmessage/llavatarnamecache.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 8fc43860da..17990ecab9 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -66,6 +66,9 @@ 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: remove code to set display name, handle in + // application layer because it's different for client and server + // Callback types for setDisplayName() below typedef boost::signals2::signal< void (bool success, const std::string& reason, const LLSD& content)> -- cgit v1.2.3 From 0b36c4181203e37d6fc3e59817d5b5abd2d7611e Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 8 Apr 2010 15:43:00 -0700 Subject: DEV-47529 Add expiration to display name cache for viewer Also synchronize LLAvatarNameCache with server version TODO: Get expiration time from web service --- indra/llmessage/llavatarnamecache.cpp | 80 +++++++++++++++++++++++++++-------- indra/llmessage/llavatarnamecache.h | 11 ++++- 2 files changed, 72 insertions(+), 19 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index d49f1d3de5..047e4fbfd9 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -48,9 +48,11 @@ namespace LLAvatarNameCache // release and turn it on based on data from login.cgi bool sUseDisplayNames = true; - // *TODO: configure the base URL for this in viewer with data + // Base lookup URL for name service. + // On simulator, loaded from indra.xml + // On viewer, sent down from login.cgi // from login.cgi - std::string sNameServiceBaseURL = "http://pdp15.lindenlab.com:8050/my-service/"; + std::string sNameServiceURL; // accumulated agent IDs for next query against service typedef std::set ask_queue_t; @@ -72,11 +74,18 @@ namespace LLAvatarNameCache typedef std::map cache_t; cache_t sCache; + // Send bulk lookup requests a few times a second at most // only need per-frame timing resolution LLFrameTimer sRequestTimer; + // Periodically clean out expired entries from the cache + LLFrameTimer sEraseExpiredTimer; + + void processNameFromService(const LLSD& row, U32 expires); bool isRequestPending(const LLUUID& agent_id); - void processNameFromService(const LLSD& row); + + // Erase expired names from cache + void eraseExpired(); } class LLAvatarNameResponder : public LLHTTPClient::Responder @@ -84,28 +93,32 @@ class LLAvatarNameResponder : public LLHTTPClient::Responder public: /*virtual*/ void result(const LLSD& content) { + // JAMESDEBUG TODO: get expiration from header + const U32 DEFAULT_EXPIRATION = 6 * 60 * 60; // 6 hours + U32 now = (U32)LLFrameTimer::getTotalSeconds(); + U32 expires = now + DEFAULT_EXPIRATION; + LLSD::array_const_iterator it = content.beginArray(); for ( ; it != content.endArray(); ++it) { const LLSD& row = *it; - LLAvatarNameCache::processNameFromService(row); + LLAvatarNameCache::processNameFromService(row, expires); } } /*virtual*/ void error(U32 status, const std::string& reason) { - llinfos << "JAMESDEBUG error " << status << " " << reason << llendl; + llinfos << "LLAvatarNameResponder error " << status << " " << reason << llendl; } }; -void LLAvatarNameCache::processNameFromService(const LLSD& row) +// "expires" is seconds-from-epoch +void LLAvatarNameCache::processNameFromService(const LLSD& row, U32 expires) { - U32 now = (U32)LLFrameTimer::getTotalSeconds(); - LLAvatarName av_name; av_name.mSLID = row["slid"].asString(); av_name.mDisplayName = row["display_name"].asString(); - av_name.mLastUpdate = now; + av_name.mExpires = expires; // HACK for pretty stars //if (row["last_name"].asString() == "Linden") @@ -144,8 +157,9 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row) } } -void LLAvatarNameCache::initClass() +void LLAvatarNameCache::initClass(const std::string& name_service_url) { + setNameServiceURL(name_service_url); } void LLAvatarNameCache::cleanupClass() @@ -160,14 +174,28 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr) { } +void LLAvatarNameCache::setNameServiceURL(const std::string& name_service_url) +{ + sNameServiceURL = name_service_url; +} + void LLAvatarNameCache::idle() { - const F32 SECS_BETWEEN_REQUESTS = 0.2f; // JAMESDEBUG set to 0.1? - if (sRequestTimer.checkExpirationAndReset(SECS_BETWEEN_REQUESTS)) + // 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; + if (!sRequestTimer.checkExpirationAndReset(SECS_BETWEEN_REQUESTS)) { return; } + // Must be large relative to above + const F32 ERASE_EXPIRED_TIMEOUT = 60.f; // seconds + if (sEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT)) + { + eraseExpired(); + } + if (sAskQueue.empty()) { return; @@ -183,8 +211,8 @@ void LLAvatarNameCache::idle() agent_ids.append( LLSD( *it ) ); } - // *TODO: configure the base URL for this - std::string url = sNameServiceBaseURL + "agent/display-names/"; + // *TODO: update for People API url formats + std::string url = sNameServiceURL + "agent/display-names/"; LLHTTPClient::post(url, body, new LLAvatarNameResponder()); // Move requests from Ask queue to Pending queue @@ -205,12 +233,28 @@ bool LLAvatarNameCache::isRequestPending(const LLUUID& agent_id) pending_queue_t::const_iterator it = sPendingQueue.find(agent_id); if (it != sPendingQueue.end()) { - bool expired = (it->second < expire_time); - return !expired; + bool request_expired = (it->second < expire_time); + return !request_expired; } return false; } +void LLAvatarNameCache::eraseExpired() +{ + U32 now = (U32)LLFrameTimer::getTotalSeconds(); + cache_t::iterator it = sCache.begin(); + while (it != sCache.end()) + { + cache_t::iterator cur = it; + ++it; + const LLAvatarName& av_name = cur->second; + if (av_name.mExpires < now) + { + sCache.erase(cur); + } + } +} + bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) { std::map::iterator it = sCache.find(agent_id); @@ -287,7 +331,7 @@ public: /*virtual*/ void error(U32 status, const std::string& reason) { - llinfos << "JAMESDEBUG set names failed " << status + llinfos << "LLSetNameResponder failed " << status << " reason " << reason << llendl; mSignal(false, reason, LLSD()); @@ -302,7 +346,7 @@ void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, body["display_name"] = display_name; // *TODO: configure the base URL for this - std::string url = sNameServiceBaseURL + "agent/"; + std::string url = sNameServiceURL + "agent/"; url += agent_id.asString(); url += "/set-display-name/"; LLHTTPClient::post(url, body, new LLSetNameResponder(agent_id, slot)); diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 17990ecab9..a4e101899a 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -42,12 +42,14 @@ class LLUUID; namespace LLAvatarNameCache { - void initClass(); + void initClass(const std::string& name_service_url); void cleanupClass(); void importFile(std::istream& istr); void exportFile(std::ostream& ostr); + void setNameServiceURL(const std::string& name_service_url); + // Periodically makes a batch request for display names not already in // cache. Call once per frame. void idle(); @@ -83,7 +85,14 @@ namespace LLAvatarNameCache // HACK: turn display names on and off void toggleDisplayNames(); bool useDisplayNames(); + void erase(const LLUUID& agent_id); + + // Force a re-fetch of the most recent data, but keep the current + // data in cache + void fetch(const LLUUID& agent_id); + + void insert(const LLUUID& agent_id, const LLAvatarName& av_name); } #endif -- cgit v1.2.3 From 65e565e0e1d7b964048a32a92f59a5dd8f74bb0c Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 12 Apr 2010 16:36:12 -0700 Subject: DEV-47529 Convert viewer to use final People API lookup URL format Reviewed with Simon --- indra/llmessage/llavatarnamecache.cpp | 139 +++++++++++++++++++++++++++------- 1 file changed, 111 insertions(+), 28 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 047e4fbfd9..ee57279e1f 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -52,6 +52,7 @@ namespace LLAvatarNameCache // On simulator, loaded from indra.xml // On viewer, sent down from login.cgi // from login.cgi + // Includes the trailing slash, like "http://pdp60.lindenlab.com:8000/" std::string sNameServiceURL; // accumulated agent IDs for next query against service @@ -82,12 +83,48 @@ namespace LLAvatarNameCache LLFrameTimer sEraseExpiredTimer; void processNameFromService(const LLSD& row, U32 expires); + void requestNames(); bool isRequestPending(const LLUUID& agent_id); // Erase expired names from cache void eraseExpired(); } +/* Sample response: + + + + agents + + + sl_id + mickbot390.llqabot + display_name + MickBot390 LLQABot + id + 0012809d-7d2d-4c24-9609-af1230a37715 + is_display_name_default + false + seconds_until_display_name_update + + + + sl_id + sardonyx.linden + display_name + Bjork Gudmundsdottir + id + 3941037e-78ab-45f0-b421-bd6e77c1804d + is_display_name_default + true + seconds_until_display_name_update + 46925 + + + + +*/ + class LLAvatarNameResponder : public LLHTTPClient::Responder { public: @@ -98,11 +135,12 @@ public: U32 now = (U32)LLFrameTimer::getTotalSeconds(); U32 expires = now + DEFAULT_EXPIRATION; - LLSD::array_const_iterator it = content.beginArray(); - for ( ; it != content.endArray(); ++it) + LLSD agents = content["agents"]; + LLSD::array_const_iterator it = agents.beginArray(); + for ( ; it != agents.endArray(); ++it) { - const LLSD& row = *it; - LLAvatarNameCache::processNameFromService(row, expires); + const LLSD& entry = *it; + LLAvatarNameCache::processNameFromService(entry, expires); } } @@ -116,8 +154,9 @@ public: void LLAvatarNameCache::processNameFromService(const LLSD& row, U32 expires) { LLAvatarName av_name; - av_name.mSLID = row["slid"].asString(); + av_name.mSLID = row["sl_id"].asString(); av_name.mDisplayName = row["display_name"].asString(); + //av_name.mIsDisplayNameDefault = row["is_display_name_default"].asBoolean(); av_name.mExpires = expires; // HACK for pretty stars @@ -129,16 +168,28 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row, U32 expires) // Some avatars don't have explicit display names set if (av_name.mDisplayName.empty()) { - // make up a display name - std::string first_name = row["first_name"].asString(); - std::string last_name = row["last_name"].asString(); - av_name.mDisplayName = - LLCacheName::buildFullName(first_name, last_name); - av_name.mIsLegacy = (last_name != "Resident"); + av_name.mDisplayName = av_name.mSLID; } + // HACK: Legacy users have '.' in their SLID + // JAMESDEBUG TODO: change to using is_display_name_default once that works + std::string mangled_name = av_name.mDisplayName; + for (U32 i = 0; i < mangled_name.size(); i++) + { + char c = mangled_name[i]; + if (c == ' ') + { + mangled_name[i] = '.'; + } + else + { + mangled_name[i] = tolower(c); + } + } + av_name.mIsDisplayNameDefault = (mangled_name == av_name.mSLID); + // add to cache - LLUUID agent_id = row["agent_id"].asUUID(); + LLUUID agent_id = row["id"].asUUID(); sCache[agent_id] = av_name; sPendingQueue.erase(agent_id); @@ -157,6 +208,49 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row, U32 expires) } } +void LLAvatarNameCache::requestNames() +{ + // 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 + // + // Apache can handle URLs of 4096 chars, but let's be conservative + const U32 NAME_URL_MAX = 4096; + const U32 NAME_URL_SEND_THRESHOLD = 3000; + std::string url; + url.reserve(NAME_URL_MAX); + + ask_queue_t::const_iterator it = sAskQueue.begin(); + for ( ; it != sAskQueue.end(); ++it) + { + if (url.empty()) + { + // ...starting new request + url += sNameServiceURL; + url += "agents/?ids="; + } + else + { + // ...continuing existing request + url += "&ids="; + } + url += it->asString(); + + if (url.size() > NAME_URL_SEND_THRESHOLD) + { + //llinfos << "requestNames " << url << llendl; + LLHTTPClient::get(url, new LLAvatarNameResponder()); + url.clear(); + } + } + + if (!url.empty()) + { + //llinfos << "requestNames " << url << llendl; + LLHTTPClient::get(url, new LLAvatarNameResponder()); + url.clear(); + } +} + void LLAvatarNameCache::initClass(const std::string& name_service_url) { setNameServiceURL(name_service_url); @@ -201,23 +295,12 @@ void LLAvatarNameCache::idle() return; } - LLSD body; - body["agent_ids"] = LLSD::emptyArray(); - LLSD& agent_ids = body["agent_ids"]; - - ask_queue_t::const_iterator it = sAskQueue.begin(); - for ( ; it != sAskQueue.end(); ++it) - { - agent_ids.append( LLSD( *it ) ); - } - - // *TODO: update for People API url formats - std::string url = sNameServiceURL + "agent/display-names/"; - LLHTTPClient::post(url, body, new LLAvatarNameResponder()); + requestNames(); // Move requests from Ask queue to Pending queue U32 now = (U32)LLFrameTimer::getTotalSeconds(); - for (it = sAskQueue.begin(); it != sAskQueue.end(); ++it) + ask_queue_t::const_iterator it = sAskQueue.begin(); + for ( ; it != sAskQueue.end(); ++it) { sPendingQueue[*it] = now; } @@ -307,6 +390,7 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) } } +// JAMESDEBUG TODO: Eliminate and only route changes through simulator class LLSetNameResponder : public LLHTTPClient::Responder { public: @@ -338,6 +422,7 @@ public: } }; +// JAMESDEBUG TODO: Eliminate and only route changes through simulator void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, const std::string& display_name, const set_name_slot_t& slot) @@ -345,10 +430,8 @@ void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, LLSD body; body["display_name"] = display_name; - // *TODO: configure the base URL for this std::string url = sNameServiceURL + "agent/"; url += agent_id.asString(); - url += "/set-display-name/"; LLHTTPClient::post(url, body, new LLSetNameResponder(agent_id, slot)); } -- cgit v1.2.3 From e390e4f2b5a1e8a938e7d66842bc6c29cfd19436 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 13 Apr 2010 11:54:06 -0700 Subject: DEV-47529 Display name expiration time sent from web service --- indra/llmessage/llavatarnamecache.cpp | 82 ++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index ee57279e1f..1fc6aa4cbd 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -82,7 +82,7 @@ namespace LLAvatarNameCache // Periodically clean out expired entries from the cache LLFrameTimer sEraseExpiredTimer; - void processNameFromService(const LLSD& row, U32 expires); + void processNameFromService(const LLSD& row); void requestNames(); bool isRequestPending(const LLUUID& agent_id); @@ -91,37 +91,41 @@ namespace LLAvatarNameCache } /* Sample response: - - - - agents - - - sl_id - mickbot390.llqabot - display_name - MickBot390 LLQABot - id - 0012809d-7d2d-4c24-9609-af1230a37715 - is_display_name_default - false - seconds_until_display_name_update - - - - sl_id - sardonyx.linden - display_name - Bjork Gudmundsdottir - id - 3941037e-78ab-45f0-b421-bd6e77c1804d - is_display_name_default - true - seconds_until_display_name_update - 46925 - - - + + + + agents + + + seconds_until_display_name_update + + display_name + MickBot390 LLQABot + seconds_until_display_name_expires + + sl_id + mickbot390.llqabot + id + 0012809d-7d2d-4c24-9609-af1230a37715 + is_display_name_default + false + + + seconds_until_display_name_update + + display_name + Bjork Gudmundsdottir + seconds_until_display_name_expires + 3600 + sl_id + sardonyx.linden + id + 3941037e-78ab-45f0-b421-bd6e77c1804d + is_display_name_default + true + + + */ @@ -130,17 +134,12 @@ class LLAvatarNameResponder : public LLHTTPClient::Responder public: /*virtual*/ void result(const LLSD& content) { - // JAMESDEBUG TODO: get expiration from header - const U32 DEFAULT_EXPIRATION = 6 * 60 * 60; // 6 hours - U32 now = (U32)LLFrameTimer::getTotalSeconds(); - U32 expires = now + DEFAULT_EXPIRATION; - LLSD agents = content["agents"]; LLSD::array_const_iterator it = agents.beginArray(); for ( ; it != agents.endArray(); ++it) { const LLSD& entry = *it; - LLAvatarNameCache::processNameFromService(entry, expires); + LLAvatarNameCache::processNameFromService(entry); } } @@ -151,13 +150,16 @@ public: }; // "expires" is seconds-from-epoch -void LLAvatarNameCache::processNameFromService(const LLSD& row, U32 expires) +void LLAvatarNameCache::processNameFromService(const LLSD& row) { LLAvatarName av_name; av_name.mSLID = row["sl_id"].asString(); av_name.mDisplayName = row["display_name"].asString(); //av_name.mIsDisplayNameDefault = row["is_display_name_default"].asBoolean(); - av_name.mExpires = expires; + + U32 now = (U32)LLFrameTimer::getTotalSeconds(); + S32 seconds_until_expires = row["seconds_until_display_name_expires"].asInteger(); + av_name.mExpires = now + seconds_until_expires; // HACK for pretty stars //if (row["last_name"].asString() == "Linden") -- cgit v1.2.3 From 80916b3f9597557811addc377d7b7b8c4b56c277 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 13 Apr 2010 12:05:12 -0700 Subject: Fix line endings --- indra/llmessage/llavatarnamecache.cpp | 70 +++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 1fc6aa4cbd..bb1f6fdb3a 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -91,41 +91,41 @@ namespace LLAvatarNameCache } /* Sample response: - - - - agents - - - seconds_until_display_name_update - - display_name - MickBot390 LLQABot - seconds_until_display_name_expires - - sl_id - mickbot390.llqabot - id - 0012809d-7d2d-4c24-9609-af1230a37715 - is_display_name_default - false - - - seconds_until_display_name_update - - display_name - Bjork Gudmundsdottir - seconds_until_display_name_expires - 3600 - sl_id - sardonyx.linden - id - 3941037e-78ab-45f0-b421-bd6e77c1804d - is_display_name_default - true - - - + + + + agents + + + seconds_until_display_name_update + + display_name + MickBot390 LLQABot + seconds_until_display_name_expires + + sl_id + mickbot390.llqabot + id + 0012809d-7d2d-4c24-9609-af1230a37715 + is_display_name_default + false + + + seconds_until_display_name_update + + display_name + Bjork Gudmundsdottir + seconds_until_display_name_expires + 3600 + sl_id + sardonyx.linden + id + 3941037e-78ab-45f0-b421-bd6e77c1804d + is_display_name_default + true + + + */ -- cgit v1.2.3 From 4218819951a5caa1499e79d8bd4f1bf08fe3b3cc Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 15 Apr 2010 16:22:15 -0700 Subject: DEV-47529 Viewer looks up display names via a sim cap Squire asked me to route display name lookups via a simulator capability using HTTP GET. This buys us authentication until the data services team can implement a public-facing authenticating web service for People API. --- indra/llmessage/llavatarnamecache.cpp | 87 ++++++----------------------------- indra/llmessage/llavatarnamecache.h | 19 ++------ 2 files changed, 18 insertions(+), 88 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index bb1f6fdb3a..8268624b84 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -50,10 +50,9 @@ namespace LLAvatarNameCache // Base lookup URL for name service. // On simulator, loaded from indra.xml - // On viewer, sent down from login.cgi - // from login.cgi - // Includes the trailing slash, like "http://pdp60.lindenlab.com:8000/" - std::string sNameServiceURL; + // On viewer, usually a simulator capability (at People API team's request) + // Includes the trailing slash, like "http://pdp60.lindenlab.com:8000/agents/" + std::string sNameLookupURL; // accumulated agent IDs for next query against service typedef std::set ask_queue_t; @@ -155,7 +154,7 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row) LLAvatarName av_name; av_name.mSLID = row["sl_id"].asString(); av_name.mDisplayName = row["display_name"].asString(); - //av_name.mIsDisplayNameDefault = row["is_display_name_default"].asBoolean(); + av_name.mIsDisplayNameDefault = row["is_display_name_default"].asBoolean(); U32 now = (U32)LLFrameTimer::getTotalSeconds(); S32 seconds_until_expires = row["seconds_until_display_name_expires"].asInteger(); @@ -173,23 +172,6 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row) av_name.mDisplayName = av_name.mSLID; } - // HACK: Legacy users have '.' in their SLID - // JAMESDEBUG TODO: change to using is_display_name_default once that works - std::string mangled_name = av_name.mDisplayName; - for (U32 i = 0; i < mangled_name.size(); i++) - { - char c = mangled_name[i]; - if (c == ' ') - { - mangled_name[i] = '.'; - } - else - { - mangled_name[i] = tolower(c); - } - } - av_name.mIsDisplayNameDefault = (mangled_name == av_name.mSLID); - // add to cache LLUUID agent_id = row["id"].asUUID(); sCache[agent_id] = av_name; @@ -227,8 +209,8 @@ void LLAvatarNameCache::requestNames() if (url.empty()) { // ...starting new request - url += sNameServiceURL; - url += "agents/?ids="; + url += sNameLookupURL; + url += "?ids="; } else { @@ -253,9 +235,8 @@ void LLAvatarNameCache::requestNames() } } -void LLAvatarNameCache::initClass(const std::string& name_service_url) +void LLAvatarNameCache::initClass() { - setNameServiceURL(name_service_url); } void LLAvatarNameCache::cleanupClass() @@ -270,9 +251,9 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr) { } -void LLAvatarNameCache::setNameServiceURL(const std::string& name_service_url) +void LLAvatarNameCache::setNameLookupURL(const std::string& name_lookup_url) { - sNameServiceURL = name_service_url; + sNameLookupURL = name_lookup_url; } void LLAvatarNameCache::idle() @@ -292,6 +273,12 @@ void LLAvatarNameCache::idle() eraseExpired(); } + if (sNameLookupURL.empty()) + { + // ...viewer has not yet received capability from region + return; + } + if (sAskQueue.empty()) { return; @@ -392,50 +379,6 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) } } -// JAMESDEBUG TODO: Eliminate and only route changes through simulator -class LLSetNameResponder : public LLHTTPClient::Responder -{ -public: - LLUUID mAgentID; - LLAvatarNameCache::set_name_signal_t mSignal; - - LLSetNameResponder(const LLUUID& agent_id, - const LLAvatarNameCache::set_name_slot_t& slot) - : mAgentID(agent_id), - mSignal() - { - mSignal.connect(slot); - } - - /*virtual*/ void result(const LLSD& content) - { - // force re-fetch - LLAvatarNameCache::sCache.erase(mAgentID); - - mSignal(true, "", content); - } - - /*virtual*/ void error(U32 status, const std::string& reason) - { - llinfos << "LLSetNameResponder failed " << status - << " reason " << reason << llendl; - - mSignal(false, reason, LLSD()); - } -}; - -// JAMESDEBUG TODO: Eliminate and only route changes through simulator -void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, - const std::string& display_name, - const set_name_slot_t& slot) -{ - LLSD body; - body["display_name"] = display_name; - - std::string url = sNameServiceURL + "agent/"; - url += agent_id.asString(); - LLHTTPClient::post(url, body, new LLSetNameResponder(agent_id, slot)); -} void LLAvatarNameCache::toggleDisplayNames() { diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index a4e101899a..111e56433b 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -42,13 +42,14 @@ class LLUUID; namespace LLAvatarNameCache { - void initClass(const std::string& name_service_url); + void initClass(); void cleanupClass(); void importFile(std::istream& istr); void exportFile(std::ostream& ostr); - void setNameServiceURL(const std::string& name_service_url); + // On the viewer, usually a simulator capabilitity + void setNameLookupURL(const std::string& name_lookup_url); // Periodically makes a batch request for display names not already in // cache. Call once per frame. @@ -68,20 +69,6 @@ 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: remove code to set display name, handle in - // application layer because it's different for client and server - - // Callback types for setDisplayName() below - typedef boost::signals2::signal< - void (bool success, const std::string& reason, const LLSD& content)> - set_name_signal_t; - typedef set_name_signal_t::slot_type set_name_slot_t; - - // Sends an update to the server to change a display name - // and calls back the application layer when done - void setDisplayName(const LLUUID& agent_id, const std::string& display_name, - const set_name_slot_t& slot); - // HACK: turn display names on and off void toggleDisplayNames(); bool useDisplayNames(); -- cgit v1.2.3 From 69de1f4eb7cdd063bbdd7b4019a6a9799fc5dc5f Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 16 Apr 2010 19:06:17 -0700 Subject: Accept expires timestamp as UTC datetime in LLSD --- indra/llmessage/llavatarnamecache.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 8268624b84..2c143266fe 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -60,7 +60,7 @@ namespace LLAvatarNameCache // agent IDs that have been requested, but with no reply // maps agent ID to frame time request was made - typedef std::map pending_queue_t; + typedef std::map pending_queue_t; pending_queue_t sPendingQueue; // Callbacks to fire when we received a name. @@ -96,12 +96,12 @@ namespace LLAvatarNameCache agents - seconds_until_display_name_update - + display_name_next_update + 2010-04-16T21:34:02+00:00Z + display_name_expires + 2010-04-16T21:32:26.142178+00:00Z display_name MickBot390 LLQABot - seconds_until_display_name_expires - sl_id mickbot390.llqabot id @@ -110,12 +110,12 @@ namespace LLAvatarNameCache false - seconds_until_display_name_update - + display_name_next_update + 2010-04-16T21:34:02+00:00Z + display_name_expires + 2010-04-16T21:32:26.142178+00:00Z display_name Bjork Gudmundsdottir - seconds_until_display_name_expires - 3600 sl_id sardonyx.linden id @@ -155,10 +155,9 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row) av_name.mSLID = row["sl_id"].asString(); av_name.mDisplayName = row["display_name"].asString(); av_name.mIsDisplayNameDefault = row["is_display_name_default"].asBoolean(); + av_name.mExpires = row["display_name_expires"].asReal(); - U32 now = (U32)LLFrameTimer::getTotalSeconds(); - S32 seconds_until_expires = row["seconds_until_display_name_expires"].asInteger(); - av_name.mExpires = now + seconds_until_expires; + llinfos << "JAMESDEBUG expires " << av_name.mExpires << " now " << LLFrameTimer::getTotalSeconds() << llendl; // HACK for pretty stars //if (row["last_name"].asString() == "Linden") @@ -287,7 +286,7 @@ void LLAvatarNameCache::idle() requestNames(); // Move requests from Ask queue to Pending queue - U32 now = (U32)LLFrameTimer::getTotalSeconds(); + F64 now = LLFrameTimer::getTotalSeconds(); ask_queue_t::const_iterator it = sAskQueue.begin(); for ( ; it != sAskQueue.end(); ++it) { @@ -298,9 +297,9 @@ void LLAvatarNameCache::idle() bool LLAvatarNameCache::isRequestPending(const LLUUID& agent_id) { - const U32 PENDING_TIMEOUT_SECS = 5 * 60; - U32 now = (U32)LLFrameTimer::getTotalSeconds(); - U32 expire_time = now - PENDING_TIMEOUT_SECS; + const F64 PENDING_TIMEOUT_SECS = 5.0 * 60.0; + F64 now = LLFrameTimer::getTotalSeconds(); + F64 expire_time = now - PENDING_TIMEOUT_SECS; pending_queue_t::const_iterator it = sPendingQueue.find(agent_id); if (it != sPendingQueue.end()) @@ -313,7 +312,7 @@ bool LLAvatarNameCache::isRequestPending(const LLUUID& agent_id) void LLAvatarNameCache::eraseExpired() { - U32 now = (U32)LLFrameTimer::getTotalSeconds(); + F64 now = LLFrameTimer::getTotalSeconds(); cache_t::iterator it = sCache.begin(); while (it != sCache.end()) { -- cgit v1.2.3 From fec933822888fd542c70fe11b5dcae02c0dc7523 Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 16 Apr 2010 19:08:35 -0700 Subject: Fix line endings --- indra/llmessage/llavatarnamecache.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 2c143266fe..62c2df90a9 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -96,9 +96,9 @@ namespace LLAvatarNameCache agents - display_name_next_update - 2010-04-16T21:34:02+00:00Z - display_name_expires + display_name_next_update + 2010-04-16T21:34:02+00:00Z + display_name_expires 2010-04-16T21:32:26.142178+00:00Z display_name MickBot390 LLQABot @@ -110,9 +110,9 @@ namespace LLAvatarNameCache false - display_name_next_update - 2010-04-16T21:34:02+00:00Z - display_name_expires + display_name_next_update + 2010-04-16T21:34:02+00:00Z + display_name_expires 2010-04-16T21:32:26.142178+00:00Z display_name Bjork Gudmundsdottir -- cgit v1.2.3 From d373dc8782e7085e313b3637c168c87c2b5a71ed Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 19 Apr 2010 17:09:37 -0700 Subject: Viewer asks login.cgi if the grid supports display names If not, turns off display names. Cleaned up name cache reset code. Alphabetized login auth param requests for easier merges going forward. --- indra/llmessage/llavatarnamecache.cpp | 13 +++++-------- indra/llmessage/llavatarnamecache.h | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 62c2df90a9..69770c1f2a 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -34,7 +34,6 @@ #include "llavatarnamecache.h" -#include "llcachename.h" // *TODO: remove #include "llframetimer.h" #include "llhttpclient.h" #include "llsd.h" @@ -379,15 +378,13 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) } -void LLAvatarNameCache::toggleDisplayNames() +void LLAvatarNameCache::setUseDisplayNames(bool use) { - sUseDisplayNames = !sUseDisplayNames; - // flush our cache - sCache.clear(); - // force re-lookups - if (gCacheName) + if (use != sUseDisplayNames) { - gCacheName->clear(); + sUseDisplayNames = use; + // flush our cache + sCache.clear(); } } diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 111e56433b..ad5ecc896e 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -69,8 +69,8 @@ namespace LLAvatarNameCache // If name information is in cache, callback will be called immediately. void get(const LLUUID& agent_id, callback_slot_t slot); - // HACK: turn display names on and off - void toggleDisplayNames(); + // Not all grids support display names + void setUseDisplayNames(bool use); bool useDisplayNames(); void erase(const LLUUID& agent_id); -- cgit v1.2.3 From 022a598694cd37bebff3322054324c7d27afd5ff Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 20 Apr 2010 17:05:49 -0700 Subject: Viewer caches avatar display names between sessions Reviewed with Simon --- indra/llmessage/llavatarnamecache.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'indra/llmessage') 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 #include @@ -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) -- cgit v1.2.3 From 61d79980d888a7bbac96df9955582f835b169a97 Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 22 Apr 2010 10:24:17 -0700 Subject: Starting to implement running switch and 503 error handling --- indra/llmessage/llavatarnamecache.cpp | 39 ++++++++++++++++++++++++++++++----- indra/llmessage/llavatarnamecache.h | 13 ++++++++++-- 2 files changed, 45 insertions(+), 7 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index d10958d09d..6455286770 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -44,9 +44,12 @@ namespace LLAvatarNameCache { - // *TODO: Defaulted to true for demo, probably want false for initial - // release and turn it on based on data from login.cgi + // Will be turned on and off based on service availability, sometimes + // 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 @@ -130,7 +133,16 @@ namespace LLAvatarNameCache class LLAvatarNameResponder : public LLHTTPClient::Responder { +private: + // need to store agent ids that are part of this request in case of + // an error, so we can flag them as unavailable + std::vector mAgentIDs; + public: + LLAvatarNameResponder(const std::vector& agent_ids) + : mAgentIDs(agent_ids) + { } + /*virtual*/ void result(const LLSD& content) { LLSD agents = content["agents"]; @@ -202,6 +214,9 @@ void LLAvatarNameCache::requestNames() std::string url; url.reserve(NAME_URL_MAX); + std::vector agent_ids; + agent_ids.reserve(128); + ask_queue_t::const_iterator it = sAskQueue.begin(); for ( ; it != sAskQueue.end(); ++it) { @@ -217,25 +232,29 @@ void LLAvatarNameCache::requestNames() url += "&ids="; } url += it->asString(); + agent_ids.push_back(*it); if (url.size() > NAME_URL_SEND_THRESHOLD) { //llinfos << "requestNames " << url << llendl; - LLHTTPClient::get(url, new LLAvatarNameResponder()); + LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids)); url.clear(); + agent_ids.clear(); } } if (!url.empty()) { //llinfos << "requestNames " << url << llendl; - LLHTTPClient::get(url, new LLAvatarNameResponder()); + LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids)); url.clear(); + agent_ids.clear(); } } -void LLAvatarNameCache::initClass() +void LLAvatarNameCache::initClass(bool running) { + sRunning = running; } void LLAvatarNameCache::cleanupClass() @@ -288,8 +307,18 @@ 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; diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index ad5ecc896e..4aabacd1f3 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -42,7 +42,10 @@ class LLUUID; namespace LLAvatarNameCache { - void initClass(); + // 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 cleanupClass(); void importFile(std::istream& istr); @@ -51,6 +54,10 @@ namespace LLAvatarNameCache // On the viewer, usually a simulator capabilitity 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. void idle(); @@ -69,7 +76,9 @@ namespace LLAvatarNameCache // If name information is in cache, callback will be called immediately. void get(const LLUUID& agent_id, callback_slot_t slot); - // Not all grids support display names + // JAMESDEBUG TODO: collapse this with setNameLookupUrl? + // Not all grids support display names. If display names are disabled, + // fall back to old name lookup system. void setUseDisplayNames(bool use); bool useDisplayNames(); -- cgit v1.2.3 From 98f5fc5ff006a82cacde47de0cbb564b6e703597 Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 22 Apr 2010 14:13:45 -0700 Subject: DEV-47529 Turn off display names if no capability from simulator, and Display name update broadcasts entire new name record to nearby viewers Display name update directly inserts new name into sim cache indra.xml has display_names_enabled setting to control cap Synchronized viewer and server versions of avatar name cache Reviewed with Ambroff --- indra/llmessage/llavatarnamecache.cpp | 53 ++++++++++++++++++++--------------- indra/llmessage/llavatarnamecache.h | 11 ++------ 2 files changed, 33 insertions(+), 31 deletions(-) (limited to 'indra/llmessage') 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. -- cgit v1.2.3 From c1ff7147974a031643776d8ea950f1bc1466737c Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 23 Apr 2010 15:11:33 -0700 Subject: DEV-47529 Name cache can handle People API 503 service unavailable It caches a dummy name "???" for a while and retries - soon for 503, longer delay for other errors. Reviewed with Simon. --- indra/llmessage/llavatarnamecache.cpp | 116 ++++++++++++++++++++++++++-------- 1 file changed, 89 insertions(+), 27 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 72498111fd..eabd311bb0 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -81,7 +81,9 @@ namespace LLAvatarNameCache // Periodically clean out expired entries from the cache LLFrameTimer sEraseExpiredTimer; - void processNameFromService(const LLSD& row); + // Handle name response off network + void processName(const LLUUID& agent_id, const LLAvatarName& av_name); + void requestNamesViaCapability(); void requestNamesViaLegacy(); bool isRequestPending(const LLUUID& agent_id); @@ -147,42 +149,102 @@ public: LLSD::array_const_iterator it = agents.beginArray(); for ( ; it != agents.endArray(); ++it) { - const LLSD& entry = *it; - LLAvatarNameCache::processNameFromService(entry); + const LLSD& row = *it; + LLUUID agent_id = row["id"].asUUID(); + + LLAvatarName av_name; + av_name.fromLLSD(row); + + // Some avatars don't have explicit display names set + if (av_name.mDisplayName.empty()) + { + av_name.mDisplayName = av_name.mSLID; + } + + LLAvatarNameCache::processName(agent_id, av_name); } } - /*virtual*/ void error(U32 status, const std::string& reason) + // This is called for both successful and failed requests, and is + // called _after_ result() above. + /*virtual*/ void completedHeader(U32 status, const std::string& reason, + const LLSD& headers) { - llinfos << "LLAvatarNameResponder error " << status << " " << reason << llendl; + // Only care about headers when there is an error + if (isGoodStatus(status)) return; + + // We're going to construct a dummy record and cache it for a while, + // either briefly for a 503 Service Unavailable, or longer for other + // errors. + F64 retry_timestamp = errorRetryTimestamp(status, headers); + + // *NOTE: "??" starts trigraphs in C/C++, escape the question marks. + const std::string DUMMY_NAME("\?\?\?"); + LLAvatarName av_name; + av_name.mSLID = DUMMY_NAME; + av_name.mDisplayName = DUMMY_NAME; + av_name.mIsDisplayNameDefault = false; + av_name.mExpires = retry_timestamp; + + // Add dummy records for all agent IDs in this request + std::vector::const_iterator it = mAgentIDs.begin(); + for ( ; it != mAgentIDs.end(); ++it) + { + const LLUUID& agent_id = *it; + LLAvatarNameCache::processName(agent_id, av_name); + } } -}; - -// "expires" is seconds-from-epoch -void LLAvatarNameCache::processNameFromService(const LLSD& row) -{ - LLAvatarName av_name; - av_name.mSLID = row["sl_id"].asString(); - av_name.mDisplayName = row["display_name"].asString(); - av_name.mIsDisplayNameDefault = row["is_display_name_default"].asBoolean(); - av_name.mExpires = row["display_name_expires"].asReal(); - llinfos << "JAMESDEBUG expires " << av_name.mExpires << " now " << LLFrameTimer::getTotalSeconds() << llendl; + // Return time to retry a request that generated an error, based on + // error type and headers. Return value is seconds-since-epoch. + F64 errorRetryTimestamp(S32 status, const LLSD& headers) + { + LLSD expires = headers["expires"]; + if (expires.isDefined()) + { + LLDate expires_date = expires.asDate(); + return expires_date.secondsSinceEpoch(); + } - // HACK for pretty stars - //if (row["last_name"].asString() == "Linden") - //{ - // av_name.mBadge = "Person_Star"; - //} + LLSD retry_after = headers["retry-after"]; + if (retry_after.isDefined()) + { + // does the header use the delta-seconds type? + S32 delta_seconds = retry_after.asInteger(); + if (delta_seconds > 0) + { + // ...valid delta-seconds + F64 now = LLFrameTimer::getTotalSeconds(); + return now + F64(delta_seconds); + } + else + { + // ...it's a date + LLDate expires_date = retry_after.asDate(); + return expires_date.secondsSinceEpoch(); + } + } - // Some avatars don't have explicit display names set - if (av_name.mDisplayName.empty()) - { - av_name.mDisplayName = av_name.mSLID; + // No information in header, make a guess + F64 now = LLFrameTimer::getTotalSeconds(); + if (status == 503) + { + // ...service unavailable, retry soon + const F64 SERVICE_UNAVAILABLE_DELAY = 600.0; // 10 min + return now + SERVICE_UNAVAILABLE_DELAY; + } + else + { + // ...other unexpected error + const F64 DEFAULT_DELAY = 3600.0; // 1 hour + return now + DEFAULT_DELAY; + } } +}; - // add to cache - LLUUID agent_id = row["id"].asUUID(); +void LLAvatarNameCache::processName(const LLUUID& agent_id, + const LLAvatarName& av_name) +{ sCache[agent_id] = av_name; sPendingQueue.erase(agent_id); -- cgit v1.2.3 From e4f2887983dc6f473c6657b8b653437557c638fa Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 26 Apr 2010 14:19:58 -0700 Subject: Don't save dummy records (from 503 errors) to disk cache --- indra/llmessage/llavatarnamecache.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index eabd311bb0..5acecd1dcb 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -184,6 +184,7 @@ public: av_name.mSLID = DUMMY_NAME; av_name.mDisplayName = DUMMY_NAME; av_name.mIsDisplayNameDefault = false; + av_name.mIsDummy = true; av_name.mExpires = retry_timestamp; // Add dummy records for all agent IDs in this request @@ -358,8 +359,11 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr) { const LLUUID& agent_id = it->first; const LLAvatarName& av_name = it->second; - // key must be a string - agents[agent_id.asString()] = av_name.asLLSD(); + if (!av_name.mIsDummy) + { + // key must be a string + agents[agent_id.asString()] = av_name.asLLSD(); + } } LLSD data; data["agents"] = agents; -- cgit v1.2.3 From 56f5a6909d8a665531e3f6ede380cad57e313728 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 27 Apr 2010 13:54:40 -0700 Subject: 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 --- indra/llmessage/llavatarnamecache.cpp | 50 ++++++++++++++++++++++++----------- indra/llmessage/llavatarnamecache.h | 13 ++++++--- 2 files changed, 44 insertions(+), 19 deletions(-) (limited to 'indra/llmessage') 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::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::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::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::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(); -- cgit v1.2.3 From 18106568b2f4d1f3d8dc019975ec38d650b5a1ec Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 28 Apr 2010 11:00:11 -0700 Subject: DEV-49489 Fall back to legacy names if display names unavailable Also made new names system wrap the old one to simplify call sites in the viewer --- indra/llmessage/llavatarnamecache.cpp | 177 ++++++++++++++++++++++++++++------ 1 file changed, 146 insertions(+), 31 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 85775f19da..919159b4ba 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -34,6 +34,7 @@ #include "llavatarnamecache.h" +#include "llcachename.h" // we wrap this system #include "llframetimer.h" #include "llhttpclient.h" #include "llsd.h" @@ -85,11 +86,36 @@ namespace LLAvatarNameCache // Periodically clean out expired entries from the cache LLFrameTimer sEraseExpiredTimer; - // Handle name response off network - void processName(const LLUUID& agent_id, const LLAvatarName& av_name); + //----------------------------------------------------------------------- + // Internal methods + //----------------------------------------------------------------------- + + // Handle name response off network. + // Optionally skip adding to cache, used when this is a fallback to the + // legacy name system. + void processName(const LLUUID& agent_id, + const LLAvatarName& av_name, + bool add_to_cache); void requestNamesViaCapability(); + + // Legacy name system callback + void legacyNameCallback(const LLUUID& agent_id, + const std::string& full_name, + bool is_group); + void requestNamesViaLegacy(); + + // Fill in an LLAvatarName with the legacy name data + void buildLegacyName(const std::string& full_name, + LLAvatarName* av_name); + + // Do a single callback to a given slot + void fireSignal(const LLUUID& agent_id, + const callback_slot_t& slot, + const LLAvatarName& av_name); + + // Is a request in-flight over the network? bool isRequestPending(const LLUUID& agent_id); // Erase expired names from cache @@ -165,7 +191,8 @@ public: av_name.mDisplayName = av_name.mSLID; } - LLAvatarNameCache::processName(agent_id, av_name); + // cache it and fire signals + LLAvatarNameCache::processName(agent_id, av_name, true); } } @@ -196,7 +223,8 @@ public: for ( ; it != mAgentIDs.end(); ++it) { const LLUUID& agent_id = *it; - LLAvatarNameCache::processName(agent_id, av_name); + // cache it and fire signals + LLAvatarNameCache::processName(agent_id, av_name, true); } } @@ -248,9 +276,13 @@ public: }; void LLAvatarNameCache::processName(const LLUUID& agent_id, - const LLAvatarName& av_name) + const LLAvatarName& av_name, + bool add_to_cache) { - sCache[agent_id] = av_name; + if (add_to_cache) + { + sCache[agent_id] = av_name; + } sPendingQueue.erase(agent_id); @@ -270,6 +302,8 @@ void LLAvatarNameCache::processName(const LLUUID& agent_id, void LLAvatarNameCache::requestNamesViaCapability() { + F64 now = LLFrameTimer::getTotalSeconds(); + // 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 // @@ -285,6 +319,8 @@ void LLAvatarNameCache::requestNamesViaCapability() ask_queue_t::const_iterator it = sAskQueue.begin(); for ( ; it != sAskQueue.end(); ++it) { + const LLUUID& agent_id = *it; + if (url.empty()) { // ...starting new request @@ -296,8 +332,11 @@ void LLAvatarNameCache::requestNamesViaCapability() // ...continuing existing request url += "&ids="; } - url += it->asString(); - agent_ids.push_back(*it); + url += agent_id.asString(); + agent_ids.push_back(agent_id); + + // mark request as pending + sPendingQueue[agent_id] = now; if (url.size() > NAME_URL_SEND_THRESHOLD) { @@ -315,11 +354,47 @@ void LLAvatarNameCache::requestNamesViaCapability() url.clear(); agent_ids.clear(); } + + // We've moved all asks to the pending request queue + sAskQueue.clear(); +} + +void LLAvatarNameCache::legacyNameCallback(const LLUUID& agent_id, + const std::string& full_name, + bool is_group) +{ + // Construct a dummy record for this name. By convention, SLID is blank + // Never expires, but not written to disk, so lasts until end of session. + LLAvatarName av_name; + buildLegacyName(full_name, &av_name); + + // Don't add to cache, the data already exists in the legacy name system + // cache and we don't want or need duplicate storage, because keeping the + // two copies in sync is complex. + processName(agent_id, av_name, false); } void LLAvatarNameCache::requestNamesViaLegacy() { - // JAMESDEBUG TODO + F64 now = LLFrameTimer::getTotalSeconds(); + std::string full_name; + ask_queue_t::const_iterator it = sAskQueue.begin(); + for (; it != sAskQueue.end(); ++it) + { + const LLUUID& agent_id = *it; + + // Mark as pending first, just in case the callback is immediately + // invoked below. This should never happen in practice. + sPendingQueue[agent_id] = now; + + gCacheName->get(agent_id, false, + boost::bind(&LLAvatarNameCache::legacyNameCallback, + _1, _2, _3)); + } + + // We've either answered immediately or moved all asks to the + // pending queue + sAskQueue.clear(); } void LLAvatarNameCache::initClass(bool running) @@ -410,7 +485,7 @@ void LLAvatarNameCache::idle() return; } - if (!sNameLookupURL.empty()) + if (useDisplayNames()) { requestNamesViaCapability(); } @@ -419,15 +494,6 @@ void LLAvatarNameCache::idle() // ...fall back to legacy name cache system requestNamesViaLegacy(); } - - // Move requests from Ask queue to Pending queue - F64 now = LLFrameTimer::getTotalSeconds(); - ask_queue_t::const_iterator it = sAskQueue.begin(); - for ( ; it != sAskQueue.end(); ++it) - { - sPendingQueue[*it] = now; - } - sAskQueue.clear(); } bool LLAvatarNameCache::isRequestPending(const LLUUID& agent_id) @@ -461,16 +527,41 @@ void LLAvatarNameCache::eraseExpired() } } +void LLAvatarNameCache::buildLegacyName(const std::string& full_name, + LLAvatarName* av_name) +{ + llassert(av_name); + av_name->mSLID = ""; + av_name->mDisplayName = full_name; + av_name->mIsDisplayNameDefault = true; + av_name->mIsDummy = true; + av_name->mExpires = F64_MAX; +} + bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) { if (sRunning) { // ...only do immediate lookups when cache is running - std::map::iterator it = sCache.find(agent_id); - if (it != sCache.end()) + if (useDisplayNames()) + { + // ...use display names cache + std::map::iterator it = sCache.find(agent_id); + if (it != sCache.end()) + { + *av_name = it->second; + return true; + } + } + else { - *av_name = it->second; - return true; + // ...use legacy names cache + std::string full_name; + if (gCacheName->getFullName(agent_id, full_name)) + { + buildLegacyName(full_name, av_name); + return true; + } } } @@ -482,19 +573,42 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) return false; } +void LLAvatarNameCache::fireSignal(const LLUUID& agent_id, + const callback_slot_t& slot, + const LLAvatarName& av_name) +{ + callback_signal_t signal; + signal.connect(slot); + signal(agent_id, av_name); +} + void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) { if (sRunning) { // ...only do immediate lookups when cache is running - std::map::iterator it = sCache.find(agent_id); - if (it != sCache.end()) + if (useDisplayNames()) { - // ...name already exists in cache, fire callback now - callback_signal_t signal; - signal.connect(slot); - signal(agent_id, it->second); - return; + // ...use new cache + std::map::iterator it = sCache.find(agent_id); + if (it != sCache.end()) + { + // ...name already exists in cache, fire callback now + fireSignal(agent_id, slot, it->second); + return; + } + } + else + { + // ...use old name system + std::string full_name; + if (gCacheName->getFullName(agent_id, full_name)) + { + LLAvatarName av_name; + buildLegacyName(full_name, &av_name); + fireSignal(agent_id, slot, av_name); + return; + } } } @@ -534,7 +648,8 @@ void LLAvatarNameCache::setUseDisplayNames(bool use) bool LLAvatarNameCache::useDisplayNames() { - return sUseDisplayNames; + // Must be both manually set on and able to look up names. + return sUseDisplayNames && !sNameLookupURL.empty(); } void LLAvatarNameCache::erase(const LLUUID& agent_id) -- cgit v1.2.3 From 5838494c504257e6fff9ea39c309fd4162dfdf60 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 4 May 2010 16:20:02 -0700 Subject: DEV-49633 WIP, Display name cache uses "Expires" headers for timeouts --- indra/llmessage/llavatarnamecache.cpp | 56 +++++++++++++++++++++++++++-------- indra/llmessage/llhttpclient.cpp | 2 +- 2 files changed, 45 insertions(+), 13 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 919159b4ba..560d0f48cf 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -167,14 +167,38 @@ private: // need to store agent ids that are part of this request in case of // an error, so we can flag them as unavailable std::vector mAgentIDs; + + // Need the headers to look up Expires: and Retry-After: + LLSD mHeaders; public: LLAvatarNameResponder(const std::vector& agent_ids) - : mAgentIDs(agent_ids) + : mAgentIDs(agent_ids), + mHeaders() { } + /*virtual*/ void completedHeader(U32 status, const std::string& reason, + const LLSD& headers) + { + mHeaders = headers; + } + /*virtual*/ void result(const LLSD& content) { + const F64 DEFAULT_EXPIRES = 24.0 * 60.0 * 60.0; + F64 now = LLFrameTimer::getTotalSeconds(); + + // With no expiration info, default to a day + F64 expires = now + DEFAULT_EXPIRES; + + // Allow the header to override the default + LLSD expires_header = mHeaders["expires"]; + if (expires_header.isDefined()) + { + LLDate expires_date = expires_header.asDate(); + expires = expires_date.secondsSinceEpoch(); + } + LLSD agents = content["agents"]; LLSD::array_const_iterator it = agents.beginArray(); for ( ; it != agents.endArray(); ++it) @@ -185,6 +209,20 @@ public: LLAvatarName av_name; av_name.fromLLSD(row); + // *TODO: Remove this once People API starts passing "Expires:" + // headers. + // Prefer per-row data for expiration times + LLSD expires_row = row["display_name_expires"]; + if (expires_row.isDefined()) + { + LLDate expires_date = expires_row.asDate(); + av_name.mExpires = expires_date.secondsSinceEpoch(); + } + else + { + av_name.mExpires = expires; + } + // Some avatars don't have explicit display names set if (av_name.mDisplayName.empty()) { @@ -196,18 +234,12 @@ public: } } - // This is called for both successful and failed requests, and is - // called _after_ result() above. - /*virtual*/ void completedHeader(U32 status, const std::string& reason, - const LLSD& headers) + /*virtual*/ void error(U32 status, const std::string& reason) { - // Only care about headers when there is an error - if (isGoodStatus(status)) return; - // We're going to construct a dummy record and cache it for a while, // either briefly for a 503 Service Unavailable, or longer for other // errors. - F64 retry_timestamp = errorRetryTimestamp(status, headers); + F64 retry_timestamp = errorRetryTimestamp(status); // *NOTE: "??" starts trigraphs in C/C++, escape the question marks. const std::string DUMMY_NAME("\?\?\?"); @@ -230,16 +262,16 @@ public: // Return time to retry a request that generated an error, based on // error type and headers. Return value is seconds-since-epoch. - F64 errorRetryTimestamp(S32 status, const LLSD& headers) + F64 errorRetryTimestamp(S32 status) { - LLSD expires = headers["expires"]; + LLSD expires = mHeaders["expires"]; if (expires.isDefined()) { LLDate expires_date = expires.asDate(); return expires_date.secondsSinceEpoch(); } - LLSD retry_after = headers["retry-after"]; + LLSD retry_after = mHeaders["retry-after"]; if (retry_after.isDefined()) { // does the header use the delta-seconds type? diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp index dd56e18caf..bd05c5d2c4 100644 --- a/indra/llmessage/llhttpclient.cpp +++ b/indra/llmessage/llhttpclient.cpp @@ -79,8 +79,8 @@ namespace { if (mResponder.get()) { - mResponder->completedRaw(mStatus, mReason, channels, buffer); mResponder->completedHeader(mStatus, mReason, mHeaderOutput); + mResponder->completedRaw(mStatus, mReason, channels, buffer); } } virtual void header(const std::string& header, const std::string& value) -- cgit v1.2.3 From c0257c7fff8dacc83e69d39afcf522b09bdf28e9 Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 6 May 2010 16:29:51 -0700 Subject: DEV-49633 fixed, use Cache-Control max-age for display name expiration We have no C++ libraries for parsing RFC 1123 dates, so parsing "Expires" headers is risky. max-age delta-seconds is easier to parse and equivalent for this use. Also added unit tests for max-age parsing. Pair-programmed with Huseby. --- indra/llmessage/CMakeLists.txt | 1 + indra/llmessage/llavatarnamecache.cpp | 113 +++++++++++++++++------ indra/llmessage/llavatarnamecache.h | 9 ++ indra/llmessage/tests/llavatarnamecache_test.cpp | 109 ++++++++++++++++++++++ 4 files changed, 206 insertions(+), 26 deletions(-) create mode 100644 indra/llmessage/tests/llavatarnamecache_test.cpp (limited to 'indra/llmessage') diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 0d07015f24..1cad0f6d22 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -250,6 +250,7 @@ if (LL_TESTS) "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llsdmessage_peer.py" ) + LL_ADD_INTEGRATION_TEST(llavatarnamecache "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llhost "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llpartdata "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llxfer_file "" "${test_libs}") diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 560d0f48cf..701f3931d0 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -40,6 +40,8 @@ #include "llsd.h" #include "llsdserialize.h" +#include + #include #include @@ -185,19 +187,8 @@ public: /*virtual*/ void result(const LLSD& content) { - const F64 DEFAULT_EXPIRES = 24.0 * 60.0 * 60.0; - F64 now = LLFrameTimer::getTotalSeconds(); - - // With no expiration info, default to a day - F64 expires = now + DEFAULT_EXPIRES; - - // Allow the header to override the default - LLSD expires_header = mHeaders["expires"]; - if (expires_header.isDefined()) - { - LLDate expires_date = expires_header.asDate(); - expires = expires_date.secondsSinceEpoch(); - } + // Pull expiration out of headers if available + F64 expires = LLAvatarNameCache::nameExpirationFromHeaders(mHeaders); LLSD agents = content["agents"]; LLSD::array_const_iterator it = agents.beginArray(); @@ -209,19 +200,8 @@ public: LLAvatarName av_name; av_name.fromLLSD(row); - // *TODO: Remove this once People API starts passing "Expires:" - // headers. - // Prefer per-row data for expiration times - LLSD expires_row = row["display_name_expires"]; - if (expires_row.isDefined()) - { - LLDate expires_date = expires_row.asDate(); - av_name.mExpires = expires_date.secondsSinceEpoch(); - } - else - { - av_name.mExpires = expires; - } + // Use expiration time from header + av_name.mExpires = expires; // Some avatars don't have explicit display names set if (av_name.mDisplayName.empty()) @@ -700,3 +680,84 @@ void LLAvatarNameCache::insert(const LLUUID& agent_id, const LLAvatarName& av_na // *TODO: update timestamp if zero? sCache[agent_id] = av_name; } + +F64 LLAvatarNameCache::nameExpirationFromHeaders(LLSD headers) +{ + // With no expiration info, default to a day + const F64 DEFAULT_EXPIRES = 24.0 * 60.0 * 60.0; + F64 now = LLFrameTimer::getTotalSeconds(); + F64 expires = now + DEFAULT_EXPIRES; + + // Allow the header to override the default + LLSD cache_control_header = headers["cache-control"]; + if (cache_control_header.isDefined()) + { + S32 max_age = 0; + std::string cache_control = cache_control_header.asString(); + if (max_age_from_cache_control(cache_control, &max_age)) + { + expires = now + (F64)max_age; + } + } + return expires; +} + +static const std::string MAX_AGE("max-age"); +static const boost::char_separator EQUALS_SEPARATOR("="); +static const boost::char_separator COMMA_SEPARATOR(","); + +bool max_age_from_cache_control(const std::string& cache_control, S32 *max_age) +{ + // Split the string on "," to get a list of directives + typedef boost::tokenizer > tokenizer; + tokenizer directives(cache_control, COMMA_SEPARATOR); + + tokenizer::iterator token_it = directives.begin(); + for ( ; token_it != directives.end(); ++token_it) + { + // Tokens may have leading or trailing whitespace + std::string token = *token_it; + LLStringUtil::trim(token); + + if (token.compare(0, MAX_AGE.size(), MAX_AGE) == 0) + { + // ...this token starts with max-age, so let's chop it up by "=" + tokenizer subtokens(token, EQUALS_SEPARATOR); + tokenizer::iterator subtoken_it = subtokens.begin(); + + // Must have a token + if (subtoken_it == subtokens.end()) return false; + std::string subtoken = *subtoken_it; + + // Must exactly equal "max-age" + LLStringUtil::trim(subtoken); + if (subtoken != MAX_AGE) return false; + + // Must have another token + ++subtoken_it; + if (subtoken_it == subtokens.end()) return false; + subtoken = *subtoken_it; + + // Must be a valid integer + // *NOTE: atoi() returns 0 for invalid values, so we have to + // check the string first. + // *TODO: Do servers ever send "0000" for zero? We don't handle it + LLStringUtil::trim(subtoken); + if (subtoken == "0") + { + *max_age = 0; + return true; + } + S32 val = atoi( subtoken.c_str() ); + if (val > 0 && val < S32_MAX) + { + *max_age = val; + return true; + } + return false; + } + } + return false; +} + + diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 26cecc5ab5..0a8b987b05 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -89,6 +89,15 @@ namespace LLAvatarNameCache void fetch(const LLUUID& agent_id); void insert(const LLUUID& agent_id, const LLAvatarName& av_name); + + // Compute name expiration time from HTTP Cache-Control header, + // or return default value, in seconds from epoch. + F64 nameExpirationFromHeaders(LLSD headers); } +// Parse a cache-control header to get the max-age delta-seconds. +// Returns true if header has max-age param and it parses correctly. +// Exported here to ease unit testing. +bool max_age_from_cache_control(const std::string& cache_control, S32 *max_age); + #endif diff --git a/indra/llmessage/tests/llavatarnamecache_test.cpp b/indra/llmessage/tests/llavatarnamecache_test.cpp new file mode 100644 index 0000000000..eeadb703d1 --- /dev/null +++ b/indra/llmessage/tests/llavatarnamecache_test.cpp @@ -0,0 +1,109 @@ +/** + * @file llhost_test.cpp + * @author Adroit + * @date 2007-02 + * @brief llhost test cases. + * + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "../llavatarnamecache.h" + +#include "../test/lltut.h" + +namespace tut +{ + struct avatarnamecache_data + { + }; + typedef test_group avatarnamecache_test; + typedef avatarnamecache_test::object avatarnamecache_object; + tut::avatarnamecache_test avatarnamecache_testcase("llavatarnamecache"); + + template<> template<> + void avatarnamecache_object::test<1>() + { + bool valid = false; + S32 max_age = 0; + + valid = max_age_from_cache_control("max-age=3600", &max_age); + ensure("typical input valid", valid); + ensure_equals("typical input parsed", max_age, 3600); + + valid = max_age_from_cache_control( + " max-age=600 , no-cache,private=\"stuff\" ", &max_age); + ensure("complex input valid", valid); + ensure_equals("complex input parsed", max_age, 600); + + valid = max_age_from_cache_control( + "no-cache, max-age = 123 ", &max_age); + ensure("complex input 2 valid", valid); + ensure_equals("complex input 2 parsed", max_age, 123); + } + + template<> template<> + void avatarnamecache_object::test<2>() + { + bool valid = false; + S32 max_age = -1; + + valid = max_age_from_cache_control("", &max_age); + ensure("empty input returns invalid", !valid); + ensure_equals("empty input doesn't change val", max_age, -1); + + valid = max_age_from_cache_control("no-cache", &max_age); + ensure("no max-age field returns invalid", !valid); + + valid = max_age_from_cache_control("max", &max_age); + ensure("just 'max' returns invalid", !valid); + + valid = max_age_from_cache_control("max-age", &max_age); + ensure("partial max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age=", &max_age); + ensure("longer partial max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age=FOO", &max_age); + ensure("invalid integer max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age 234", &max_age); + ensure("space separated max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age=0", &max_age); + ensure("zero max-age is valid", valid); + + // *TODO: Handle "0000" as zero + //valid = max_age_from_cache_control("max-age=0000", &max_age); + //ensure("multi-zero max-age is valid", valid); + + valid = max_age_from_cache_control("max-age=-123", &max_age); + ensure("less than zero max-age is invalid", !valid); + } +} -- cgit v1.2.3 From fa03333d5893f16318a33e9edfae782ca0125768 Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 7 May 2010 10:41:02 -0700 Subject: DEV-49633 Prefer Retry-After for error handling backoff Also, we can't parse Expires dates, so use Cache-Control max-age. Reviewed with Huseby. --- indra/llmessage/llavatarnamecache.cpp | 52 +++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 21 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 701f3931d0..fdbc28656e 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -122,6 +122,8 @@ namespace LLAvatarNameCache // Erase expired names from cache void eraseExpired(); + + bool expirationFromCacheControl(LLSD headers, F64 *expires); } /* Sample response: @@ -244,34 +246,29 @@ public: // error type and headers. Return value is seconds-since-epoch. F64 errorRetryTimestamp(S32 status) { - LLSD expires = mHeaders["expires"]; - if (expires.isDefined()) - { - LLDate expires_date = expires.asDate(); - return expires_date.secondsSinceEpoch(); - } + F64 now = LLFrameTimer::getTotalSeconds(); + // Retry-After takes priority LLSD retry_after = mHeaders["retry-after"]; if (retry_after.isDefined()) { - // does the header use the delta-seconds type? + // We only support the delta-seconds type S32 delta_seconds = retry_after.asInteger(); if (delta_seconds > 0) { // ...valid delta-seconds - F64 now = LLFrameTimer::getTotalSeconds(); return now + F64(delta_seconds); } - else - { - // ...it's a date - LLDate expires_date = retry_after.asDate(); - return expires_date.secondsSinceEpoch(); - } + } + + // If no Retry-After, look for Cache-Control max-age + F64 expires = 0.0; + if (LLAvatarNameCache::expirationFromCacheControl(mHeaders, &expires)) + { + return expires; } // No information in header, make a guess - F64 now = LLFrameTimer::getTotalSeconds(); if (status == 503) { // ...service unavailable, retry soon @@ -683,11 +680,22 @@ void LLAvatarNameCache::insert(const LLUUID& agent_id, const LLAvatarName& av_na F64 LLAvatarNameCache::nameExpirationFromHeaders(LLSD headers) { - // With no expiration info, default to a day - const F64 DEFAULT_EXPIRES = 24.0 * 60.0 * 60.0; - F64 now = LLFrameTimer::getTotalSeconds(); - F64 expires = now + DEFAULT_EXPIRES; + F64 expires = 0.0; + if (expirationFromCacheControl(headers, &expires)) + { + return expires; + } + else + { + // With no expiration info, default to a day + const F64 DEFAULT_EXPIRES = 24.0 * 60.0 * 60.0; + F64 now = LLFrameTimer::getTotalSeconds(); + return now + DEFAULT_EXPIRES; + } +} +bool LLAvatarNameCache::expirationFromCacheControl(LLSD headers, F64 *expires) +{ // Allow the header to override the default LLSD cache_control_header = headers["cache-control"]; if (cache_control_header.isDefined()) @@ -696,10 +704,12 @@ F64 LLAvatarNameCache::nameExpirationFromHeaders(LLSD headers) std::string cache_control = cache_control_header.asString(); if (max_age_from_cache_control(cache_control, &max_age)) { - expires = now + (F64)max_age; + F64 now = LLFrameTimer::getTotalSeconds(); + *expires = now + (F64)max_age; + return true; } } - return expires; + return false; } static const std::string MAX_AGE("max-age"); -- cgit v1.2.3 From 2af4875309450fa3d3e266426ada12330489a8c9 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Thu, 13 May 2010 17:26:06 -0700 Subject: DEV-50013 Friends in sidebar now correctly displaying names reviewed by James --- indra/llmessage/llavatarnamecache.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index fdbc28656e..2fc92ff36f 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -214,6 +214,27 @@ public: // cache it and fire signals LLAvatarNameCache::processName(agent_id, av_name, true); } + + // Same logic as error response case + LLSD unresolved_agents = content["bad_ids"]; + if (unresolved_agents.size() > 0) + { + const std::string DUMMY_NAME("\?\?\?"); + LLAvatarName av_name; + av_name.mSLID = DUMMY_NAME; + av_name.mDisplayName = DUMMY_NAME; + av_name.mIsDisplayNameDefault = false; + av_name.mIsDummy = true; + av_name.mExpires = expires; + + it = unresolved_agents.beginArray(); + for ( ; it != unresolved_agents.endArray(); ++it) + { + const LLUUID& agent_id = *it; + // cache it and fire signals + LLAvatarNameCache::processName(agent_id, av_name, true); + } + } } /*virtual*/ void error(U32 status, const std::string& reason) -- cgit v1.2.3 From f4148502e484d516b42c4a88603eee6889d45697 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 18 May 2010 16:00:45 -0700 Subject: Rename mSLID to mUsername to match the name of the field in the UI Product made a late-breaking request to change the name of this field. The wire protocol for People API has not yet changed. --- indra/llmessage/llavatarnamecache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 2fc92ff36f..4b41c7e5b1 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -208,7 +208,7 @@ public: // Some avatars don't have explicit display names set if (av_name.mDisplayName.empty()) { - av_name.mDisplayName = av_name.mSLID; + av_name.mDisplayName = av_name.mUsername; } // cache it and fire signals @@ -221,7 +221,7 @@ public: { const std::string DUMMY_NAME("\?\?\?"); LLAvatarName av_name; - av_name.mSLID = DUMMY_NAME; + av_name.mUsername = DUMMY_NAME; av_name.mDisplayName = DUMMY_NAME; av_name.mIsDisplayNameDefault = false; av_name.mIsDummy = true; @@ -247,7 +247,7 @@ public: // *NOTE: "??" starts trigraphs in C/C++, escape the question marks. const std::string DUMMY_NAME("\?\?\?"); LLAvatarName av_name; - av_name.mSLID = DUMMY_NAME; + av_name.mUsername = DUMMY_NAME; av_name.mDisplayName = DUMMY_NAME; av_name.mIsDisplayNameDefault = false; av_name.mIsDummy = true; @@ -561,7 +561,7 @@ void LLAvatarNameCache::buildLegacyName(const std::string& full_name, LLAvatarName* av_name) { llassert(av_name); - av_name->mSLID = ""; + av_name->mUsername = ""; av_name->mDisplayName = full_name; av_name->mIsDisplayNameDefault = true; av_name->mIsDummy = true; -- cgit v1.2.3 From 77e6fcd4230f7540c9f4d6f3d503737c6eaf408c Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 25 May 2010 11:39:06 -0700 Subject: DEV-50013 WIP gCacheName->getGroup() to distinguish from av lookups Helps with global finds looking for remaining calls to patch. Reviewed with Leyla. --- indra/llmessage/llcachename.cpp | 6 ++++++ indra/llmessage/llcachename.h | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 8e87b6f9b9..c6c189c7a1 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -582,6 +582,12 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, co return res; } +boost::signals2::connection LLCacheName::getGroup(const LLUUID& group_id, + const LLCacheNameCallback& callback) +{ + return get(group_id, true, callback); +} + boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, old_callback_t callback, void* user_data) { return get(id, is_group, boost::bind(callback, _1, _2, _3, user_data)); diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 6b6bbde6ab..45dae562ad 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -102,7 +102,12 @@ public: // otherwise, will request the data, and will call the callback when // available. There is no garuntee the callback will ever be called. boost::signals2::connection get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback); - + + // Convenience method for looking up a group name, so you can + // tell the difference between avatar lookup and group lookup + // in global searches + boost::signals2::connection getGroup(const LLUUID& group_id, const LLCacheNameCallback& callback); + // LEGACY boost::signals2::connection get(const LLUUID& id, bool is_group, old_callback_t callback, void* user_data); // This method needs to be called from time to time to send out -- cgit v1.2.3 From 6cb420b20bd509e7bf62c8450f12d433c5a81be2 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Thu, 27 May 2010 15:12:03 -0700 Subject: added function for building a username from a legacy name and fixed group notice panel reviewed by James --- indra/llmessage/llcachename.cpp | 24 ++++++++++++++++++++++++ indra/llmessage/llcachename.h | 5 +++++ 2 files changed, 29 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index c6c189c7a1..f8c0d05baa 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -527,6 +527,30 @@ std::string LLCacheName::cleanFullName(const std::string& full_name) return full_name.substr(0, full_name.find(" Resident")); } +//static +std::string LLCacheName::buildUsername(const std::string& full_name) +{ + std::string::size_type index = full_name.find(' '); + + if (index != std::string::npos) + { + std::string username; + username = full_name.substr(0, index); + std::string lastname = full_name.substr(index+1); + + if (lastname != "Resident") + { + username = username + "." + lastname; + } + + LLStringUtil::toLower(username); + return username; + } + + // if the input wasn't a correctly formatted legacy name just return it unchanged + return full_name; +} + // This is a little bit kludgy. LLCacheNameCallback is a slot instead of a function pointer. // The reason it is a slot is so that the legacy get() function below can bind an old callback // and pass it as a slot. The reason it isn't a boost::function is so that trackable behavior diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 45dae562ad..697bb27556 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -91,6 +91,11 @@ public: // If name does not contain "Resident" returns it unchanged. static std::string cleanFullName(const std::string& full_name); + // Converts a standard legacy name to a username + // "bobsmith123 Resident" -> "bobsmith" + // "Random Linden" -> "random.linden" + static std::string buildUsername(const std::string& name); + // If available, this method copies the group name into the string // provided. The caller must allocate at least // DB_GROUP_NAME_BUF_SIZE characters. If not available, this -- cgit v1.2.3 From 00e8b3548c931991d784f6f14c80ca29528a206d Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 27 May 2010 18:08:49 -0700 Subject: DEV-50013 Region debug top scripts/colliders display names --- indra/llmessage/llcachename.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index f8c0d05baa..ef60fd5c4e 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -530,6 +530,12 @@ std::string LLCacheName::cleanFullName(const std::string& full_name) //static std::string LLCacheName::buildUsername(const std::string& full_name) { + // rare, but handle hard-coded error names returned from server + if (full_name == "(\?\?\?) (\?\?\?)") + { + return "(\?\?\?)"; + } + std::string::size_type index = full_name.find(' '); if (index != std::string::npos) -- cgit v1.2.3 From b944a4792762bf61b7837a29c8580c9823c9670b Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 28 May 2010 09:59:47 -0700 Subject: DEV-50013 Script memory floater uses usernames --- indra/llmessage/llavatarnamecache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 4b41c7e5b1..0c577053a3 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -417,7 +417,7 @@ void LLAvatarNameCache::requestNamesViaLegacy() // invoked below. This should never happen in practice. sPendingQueue[agent_id] = now; - gCacheName->get(agent_id, false, + gCacheName->get(agent_id, false, // legacy compatibility boost::bind(&LLAvatarNameCache::legacyNameCallback, _1, _2, _3)); } -- cgit v1.2.3 From 88b9808de6bf576807435c4c74126bcda523d0b8 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 1 Jun 2010 11:06:16 -0700 Subject: DEV-50013 Don't add delays to batch up name requests In practice, bulk name requests are all added in a single frame, triggered for example by opening a group membership dialog. There's no point to waiting to batch up more requests, and this slows down the usual single-name lookup. Reviewed with Simon. --- indra/llmessage/llavatarnamecache.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 0c577053a3..912f34fcae 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -495,13 +495,14 @@ void LLAvatarNameCache::idle() // By convention, start running at first idle() call sRunning = true; + // *TODO: Possibly re-enabled this based on People API load measurements // 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; - if (!sRequestTimer.checkExpirationAndReset(SECS_BETWEEN_REQUESTS)) - { - return; - } + //const F32 SECS_BETWEEN_REQUESTS = 0.1f; + //if (!sRequestTimer.checkExpirationAndReset(SECS_BETWEEN_REQUESTS)) + //{ + // return; + //} // Must be large relative to above const F32 ERASE_EXPIRED_TIMEOUT = 60.f; // seconds -- cgit v1.2.3 From c7d49b4cb22ceac5778a8e178aa6ce62fa42c72e Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Wed, 4 Aug 2010 17:11:01 -0700 Subject: DEV-52354 Username shown in local chat if idle for over 90 seconds reviewd by richard --- indra/llmessage/llavatarnamecache.cpp | 36 +++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 912f34fcae..803d1e268d 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -86,7 +86,7 @@ namespace LLAvatarNameCache LLFrameTimer sRequestTimer; // Periodically clean out expired entries from the cache - LLFrameTimer sEraseExpiredTimer; + //LLFrameTimer sEraseExpiredTimer; //----------------------------------------------------------------------- // Internal methods @@ -505,11 +505,16 @@ void LLAvatarNameCache::idle() //} // Must be large relative to above - const F32 ERASE_EXPIRED_TIMEOUT = 60.f; // seconds - if (sEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT)) - { - eraseExpired(); - } + + // No longer deleting expired entries, just re-requesting in the get + // this way first synchronous get call on an expired entry won't return + // legacy name. LF + + //const F32 ERASE_EXPIRED_TIMEOUT = 60.f; // seconds + //if (sEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT)) + //{ + // eraseExpired(); + //} if (sAskQueue.empty()) { @@ -581,7 +586,12 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) if (it != sCache.end()) { *av_name = it->second; - return true; + + // re-request name if entry is expired, otherwise return + if (av_name->mExpires > LLFrameTimer::getTotalSeconds()) + { + return true; + } } } else @@ -624,9 +634,15 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) std::map::iterator it = sCache.find(agent_id); if (it != sCache.end()) { - // ...name already exists in cache, fire callback now - fireSignal(agent_id, slot, it->second); - return; + const LLAvatarName& av_name = it->second; + + if (av_name.mExpires > LLFrameTimer::getTotalSeconds()) + { + // ...name already exists in cache, fire callback now + fireSignal(agent_id, slot, av_name); + + return; + } } } else -- cgit v1.2.3 From c39d74ac985e789eef8ee988cf8ba80fb2402683 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Thu, 19 Aug 2010 14:23:14 -0700 Subject: synchronous llavatarcachename::get calls now return true even if entry is expired --- indra/llmessage/llavatarnamecache.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 803d1e268d..0571973c23 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -574,6 +574,8 @@ void LLAvatarNameCache::buildLegacyName(const std::string& full_name, av_name->mExpires = F64_MAX; } +// fills in av_name if it has it in the cache, even if expired (can check expiry time) +// returns bool specifying if av_name was filled, false otherwise bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) { if (sRunning) @@ -587,11 +589,16 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) { *av_name = it->second; - // re-request name if entry is expired, otherwise return - if (av_name->mExpires > LLFrameTimer::getTotalSeconds()) + // re-request name if entry is expired + if (av_name->mExpires < LLFrameTimer::getTotalSeconds()) { - return true; + if (!isRequestPending(agent_id)) + { + sAskQueue.insert(agent_id); + } } + + return true; } } else @@ -725,8 +732,8 @@ F64 LLAvatarNameCache::nameExpirationFromHeaders(LLSD headers) } else { - // With no expiration info, default to a day - const F64 DEFAULT_EXPIRES = 24.0 * 60.0 * 60.0; + // With no expiration info, default to an hour + const F64 DEFAULT_EXPIRES = 60.0 * 60.0; F64 now = LLFrameTimer::getTotalSeconds(); return now + DEFAULT_EXPIRES; } -- cgit v1.2.3 From e45b3c6884bc7d9bc457b9633932c8aad5a28430 Mon Sep 17 00:00:00 2001 From: Aimee Linden Date: Sat, 4 Sep 2010 19:35:27 +0100 Subject: Correct license on newly exported files to LGPL. --- indra/llmessage/llavatarnamecache.cpp | 36 +++++++++----------- indra/llmessage/llavatarnamecache.h | 37 +++++++++----------- indra/llmessage/tests/llavatarnamecache_test.cpp | 43 ++++++++++-------------- 3 files changed, 49 insertions(+), 67 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 0571973c23..8158c17974 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -3,31 +3,25 @@ * @brief Provides lookup of avatar SLIDs ("bobsmith123") and display names * ("James Cook") from avatar UUIDs. * - * $LicenseInfo:firstyear=2010&license=viewergpl$ - * - * Copyright (c) 2010, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ #include "linden_common.h" diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 0a8b987b05..6d199fd09a 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -3,33 +3,28 @@ * @brief Provides lookup of avatar SLIDs ("bobsmith123") and display names * ("James Cook") from avatar UUIDs. * - * $LicenseInfo:firstyear=2010&license=viewergpl$ - * - * Copyright (c) 2010, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ + #ifndef LLAVATARNAMECACHE_H #define LLAVATARNAMECACHE_H diff --git a/indra/llmessage/tests/llavatarnamecache_test.cpp b/indra/llmessage/tests/llavatarnamecache_test.cpp index eeadb703d1..96291e503a 100644 --- a/indra/llmessage/tests/llavatarnamecache_test.cpp +++ b/indra/llmessage/tests/llavatarnamecache_test.cpp @@ -1,34 +1,27 @@ /** - * @file llhost_test.cpp - * @author Adroit - * @date 2007-02 - * @brief llhost test cases. + * @file llavatarnamecache_test.cpp + * @author James Cook + * @brief LLAvatarNameCache test cases. * - * $LicenseInfo:firstyear=2007&license=viewergpl$ - * - * Copyright (c) 2007-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ -- cgit v1.2.3 From cfbb639aa60774dd1cac8ce53568e6a005d2acfb Mon Sep 17 00:00:00 2001 From: Aimee Linden Date: Sat, 4 Sep 2010 19:37:58 +0100 Subject: Standardize test name to match class name on LLAvatarNameCache --- indra/llmessage/tests/llavatarnamecache_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/tests/llavatarnamecache_test.cpp b/indra/llmessage/tests/llavatarnamecache_test.cpp index 96291e503a..ec6b65d483 100644 --- a/indra/llmessage/tests/llavatarnamecache_test.cpp +++ b/indra/llmessage/tests/llavatarnamecache_test.cpp @@ -38,7 +38,7 @@ namespace tut }; typedef test_group avatarnamecache_test; typedef avatarnamecache_test::object avatarnamecache_object; - tut::avatarnamecache_test avatarnamecache_testcase("llavatarnamecache"); + tut::avatarnamecache_test avatarnamecache_testcase("LLAvatarNameCache"); template<> template<> void avatarnamecache_object::test<1>() -- cgit v1.2.3 From a923da7fc78b44cd5368d26652b0204322f064a4 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Mon, 13 Sep 2010 14:59:31 -0700 Subject: DEV-52931 Toggling "View Display Names" doesn't take effect right away in the Friends list --- indra/llmessage/llavatarnamecache.cpp | 12 +++++++++++- indra/llmessage/llavatarnamecache.h | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 8158c17974..2f2d9099a3 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -41,6 +41,8 @@ namespace LLAvatarNameCache { + use_display_name_signal_t mUseDisplayNamesSignal; + // Manual override for display names - can disable even if the region // supports it. bool sUseDisplayNames = true; @@ -691,6 +693,8 @@ void LLAvatarNameCache::setUseDisplayNames(bool use) sUseDisplayNames = use; // flush our cache sCache.clear(); + + mUseDisplayNamesSignal(); } } @@ -751,6 +755,13 @@ bool LLAvatarNameCache::expirationFromCacheControl(LLSD headers, F64 *expires) return false; } + +void LLAvatarNameCache::addUseDisplayNamesCallback(const use_display_name_signal_t::slot_type& cb) +{ + mUseDisplayNamesSignal.connect(cb); +} + + static const std::string MAX_AGE("max-age"); static const boost::char_separator EQUALS_SEPARATOR("="); static const boost::char_separator COMMA_SEPARATOR(","); @@ -809,4 +820,3 @@ bool max_age_from_cache_control(const std::string& cache_control, S32 *max_age) return false; } - diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 6d199fd09a..8f21ace96a 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -37,6 +37,9 @@ class LLUUID; namespace LLAvatarNameCache { + + typedef boost::signals2::signal use_display_name_signal_t; + // 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. @@ -88,6 +91,8 @@ namespace LLAvatarNameCache // Compute name expiration time from HTTP Cache-Control header, // or return default value, in seconds from epoch. F64 nameExpirationFromHeaders(LLSD headers); + + void addUseDisplayNamesCallback(const use_display_name_signal_t::slot_type& cb); } // Parse a cache-control header to get the max-age delta-seconds. -- cgit v1.2.3 From cb5d8d1a9295076327f23e5f6d6c91fd0d4580ea Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Fri, 22 Oct 2010 17:41:06 -0700 Subject: DN-181 Chat & IM logs saved in unreadable .llsd instead of .txt --- indra/llmessage/llcachename.cpp | 27 +++++++++++++++++++++++++++ indra/llmessage/llcachename.h | 6 ++++++ 2 files changed, 33 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 4a66a31c35..522b99bc02 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -38,6 +38,8 @@ #include "message.h" #include "llmemtype.h" +#include + // llsd serialization constants static const std::string AGENTS("agents"); static const std::string GROUPS("groups"); @@ -551,6 +553,31 @@ std::string LLCacheName::buildUsername(const std::string& full_name) return full_name; } +//static +std::string LLCacheName::buildLegacyName(const std::string& complete_name) +{ + boost::regex complete_name_regex("(.+)( \\()([A-Za-z]+)(.[A-Za-z]+)*(\\))"); + boost::match_results name_results; + if (!boost::regex_match(complete_name, name_results, complete_name_regex)) return complete_name; + + std::string legacy_name = name_results[3]; + // capitalize the first letter + std::string cap_letter = legacy_name.substr(0, 1); + LLStringUtil::toUpper(cap_letter); + legacy_name = cap_letter + legacy_name.substr(1); + + if (name_results[4].matched) + { + std::string last_name = name_results[4]; + std::string cap_letter = last_name.substr(1, 1); + LLStringUtil::toUpper(cap_letter); + last_name = cap_letter + last_name.substr(2); + legacy_name = legacy_name + " " + last_name; + } + + return legacy_name; +} + // This is a little bit kludgy. LLCacheNameCallback is a slot instead of a function pointer. // The reason it is a slot is so that the legacy get() function below can bind an old callback // and pass it as a slot. The reason it isn't a boost::function is so that trackable behavior diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index b469803060..b108e37157 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -90,6 +90,12 @@ public: // "Random Linden" -> "random.linden" static std::string buildUsername(const std::string& name); + // Converts a complete display name to a legacy name + // if possible, otherwise returns the input + // "Alias (random.linden)" -> "Random Linden" + // "Something random" -> "Something random" + static std::string buildLegacyName(const std::string& name); + // If available, this method copies the group name into the string // provided. The caller must allocate at least // DB_GROUP_NAME_BUF_SIZE characters. If not available, this -- cgit v1.2.3 From 97164f010ce4ec56e5f63cd7ceed882ab12f145b Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Wed, 27 Oct 2010 15:24:22 -0700 Subject: DN-188 Inspectors and Profile images not available in IM history or local chat history --- indra/llmessage/llcachename.cpp | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 522b99bc02..deaa3e138e 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -556,25 +556,38 @@ std::string LLCacheName::buildUsername(const std::string& full_name) //static std::string LLCacheName::buildLegacyName(const std::string& complete_name) { - boost::regex complete_name_regex("(.+)( \\()([A-Za-z]+)(.[A-Za-z]+)*(\\))"); - boost::match_results name_results; - if (!boost::regex_match(complete_name, name_results, complete_name_regex)) return complete_name; + // regexp doesn't play nice with unicode, chop off the display name + S32 open_paren = complete_name.rfind(" ("); - std::string legacy_name = name_results[3]; + if (open_paren == std::string::npos) + { + return complete_name; + } + + std::string username = complete_name.substr(open_paren); + boost::regex complete_name_regex("( \\()([a-z0-9]+)(.[a-z]+)*(\\))"); + boost::match_results name_results; + if (!boost::regex_match(username, name_results, complete_name_regex)) return complete_name; + + std::string legacy_name = name_results[2]; // capitalize the first letter std::string cap_letter = legacy_name.substr(0, 1); LLStringUtil::toUpper(cap_letter); - legacy_name = cap_letter + legacy_name.substr(1); - - if (name_results[4].matched) - { - std::string last_name = name_results[4]; + legacy_name = cap_letter + legacy_name.substr(1); + + if (name_results[4].matched) + { + std::string last_name = name_results[3]; std::string cap_letter = last_name.substr(1, 1); LLStringUtil::toUpper(cap_letter); - last_name = cap_letter + last_name.substr(2); - legacy_name = legacy_name + " " + last_name; - } - + last_name = cap_letter + last_name.substr(2); + legacy_name = legacy_name + " " + last_name; + } + else + { + legacy_name = legacy_name + " Resident"; + } + return legacy_name; } -- cgit v1.2.3 From ebc8cdd6cbd8207a54314c71fd6abc6e8a49893b Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Fri, 29 Oct 2010 13:15:16 -0700 Subject: DN-154 Display Names only shown in Nearby Chat History when a user logs back in even if Usernames were shown in Chat during previous session --- indra/llmessage/llcachename.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index deaa3e138e..a8f53a38c3 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -575,7 +575,7 @@ std::string LLCacheName::buildLegacyName(const std::string& complete_name) LLStringUtil::toUpper(cap_letter); legacy_name = cap_letter + legacy_name.substr(1); - if (name_results[4].matched) + if (name_results[3].matched) { std::string last_name = name_results[3]; std::string cap_letter = last_name.substr(1, 1); -- cgit v1.2.3 From dfdd1abe513facad78f8169405879a05d6e8d56b Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Thu, 4 Nov 2010 11:51:45 -0700 Subject: DN-188 Fixed users with lastname residents not having inspectors in chat history --- indra/llmessage/llcachename.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index a8f53a38c3..4ab6bd2438 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -565,29 +565,25 @@ std::string LLCacheName::buildLegacyName(const std::string& complete_name) } std::string username = complete_name.substr(open_paren); - boost::regex complete_name_regex("( \\()([a-z0-9]+)(.[a-z]+)*(\\))"); - boost::match_results name_results; - if (!boost::regex_match(username, name_results, complete_name_regex)) return complete_name; - + boost::regex complete_name_regex("( \\()([a-z0-9]+)(.[a-z]+)*(\\))"); + boost::match_results name_results; + if (!boost::regex_match(username, name_results, complete_name_regex)) return complete_name; + std::string legacy_name = name_results[2]; // capitalize the first letter std::string cap_letter = legacy_name.substr(0, 1); LLStringUtil::toUpper(cap_letter); - legacy_name = cap_letter + legacy_name.substr(1); - - if (name_results[3].matched) - { + legacy_name = cap_letter + legacy_name.substr(1); + + if (name_results[3].matched) + { std::string last_name = name_results[3]; std::string cap_letter = last_name.substr(1, 1); LLStringUtil::toUpper(cap_letter); - last_name = cap_letter + last_name.substr(2); - legacy_name = legacy_name + " " + last_name; - } - else - { - legacy_name = legacy_name + " Resident"; - } - + last_name = cap_letter + last_name.substr(2); + legacy_name = legacy_name + " " + last_name; + } + return legacy_name; } -- cgit v1.2.3 From 76d708bdb5230aaeb9a15bb2fb475458d8bb996e Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Thu, 11 Nov 2010 15:53:13 -0800 Subject: Turning down dummy avatar name entry expiration to 2 minutes --- indra/llmessage/llavatarnamecache.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 2f2d9099a3..7396117d84 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -286,18 +286,8 @@ public: } // No information in header, make a guess - if (status == 503) - { - // ...service unavailable, retry soon - const F64 SERVICE_UNAVAILABLE_DELAY = 600.0; // 10 min - return now + SERVICE_UNAVAILABLE_DELAY; - } - else - { - // ...other unexpected error - const F64 DEFAULT_DELAY = 3600.0; // 1 hour - return now + DEFAULT_DELAY; - } + const F64 DEFAULT_DELAY = 120.0; // 2 mintues + return now + DEFAULT_DELAY; } }; -- cgit v1.2.3 From 424786d8d05093abd816a3decd86aace64816179 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 18 Nov 2010 15:55:53 -0800 Subject: Added viewer-side "object overlaps parcel" check encroachment returnabilty UI Reviewed with Falcon --- indra/llmessage/llregionflags.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llregionflags.h b/indra/llmessage/llregionflags.h index b9b974ec4f..d81051f413 100644 --- a/indra/llmessage/llregionflags.h +++ b/indra/llmessage/llregionflags.h @@ -42,8 +42,7 @@ const U32 REGION_FLAGS_RESET_HOME_ON_TELEPORT = (1 << 3); // Does the sun move? const U32 REGION_FLAGS_SUN_FIXED = (1 << 4); -// Tax free zone (no taxes on objects, land, etc.) -const U32 REGION_FLAGS_TAX_FREE = (1 << 5); +//const U32 REGION_FLAGS_TAX_FREE = (1 << 5); // legacy // Can't change the terrain heightfield, even on owned parcels, // but can plant trees and grass. @@ -54,17 +53,15 @@ const U32 REGION_FLAGS_BLOCK_LAND_RESELL = (1 << 7); // All content wiped once per night const U32 REGION_FLAGS_SANDBOX = (1 << 8); -const U32 REGION_FLAGS_NULL_LAYER = (1 << 9); -// const U32 REGION_FLAGS_SKIP_AGENT_ACTION = (1 << 10); -const U32 REGION_FLAGS_HARD_ALLOW_LAND_TRANSFER = (1 << 10); // Region allows land reselling -// const U32 REGION_FLAGS_SKIP_UPDATE_INTEREST_LIST= (1 << 11); -const U32 REGION_FLAGS_HARD_ALLOW_POST_CLASSIFIED = (1 << 11); // Region allows posting of classified ads +//const U32 REGION_FLAGS_NULL_LAYER = (1 << 9); +//const U32 REGION_FLAGS_HARD_ALLOW_LAND_TRANSFER = (1 << 10); +//const U32 REGION_FLAGS_SKIP_UPDATE_INTEREST_LIST= (1 << 11); const U32 REGION_FLAGS_SKIP_COLLISIONS = (1 << 12); // Pin all non agent rigid bodies const U32 REGION_FLAGS_SKIP_SCRIPTS = (1 << 13); const U32 REGION_FLAGS_SKIP_PHYSICS = (1 << 14); // Skip all physics const U32 REGION_FLAGS_EXTERNALLY_VISIBLE = (1 << 15); -//const U32 REGION_FLAGS_MAINLAND_VISIBLE = (1 << 16); -const U32 REGION_FLAGS_PUBLIC_ALLOWED = (1 << 17); +const U32 REGION_FLAGS_ALLOW_RETURN_ENCROACHING_OBJECT = (1 << 16); +const U32 REGION_FLAGS_ALLOW_RETURN_ENCROACHING_ESTATE_OBJECT = (1 << 17); const U32 REGION_FLAGS_BLOCK_DWELL = (1 << 18); // Is flight allowed? @@ -81,18 +78,22 @@ const U32 REGION_FLAGS_ESTATE_SKIP_SCRIPTS = (1 << 21); const U32 REGION_FLAGS_RESTRICT_PUSHOBJECT = (1 << 22); const U32 REGION_FLAGS_DENY_ANONYMOUS = (1 << 23); -// const U32 REGION_FLAGS_DENY_IDENTIFIED = (1 << 24); -// const U32 REGION_FLAGS_DENY_TRANSACTED = (1 << 25); +//const U32 REGION_FLAGS_DENY_IDENTIFIED = (1 << 24); +//const U32 REGION_FLAGS_DENY_TRANSACTED = (1 << 25); const U32 REGION_FLAGS_ALLOW_PARCEL_CHANGES = (1 << 26); -// const U32 REGION_FLAGS_ABUSE_EMAIL_TO_ESTATE_OWNER = (1 << 27); // We no longer support ELAR +// Deprecated. Phoeinx 2009-12-11 +// REGION_FLAGS_ABUSE_EMAIL_TO_ESTATE_OWNER is unused beyond viewer-1.23 +// but we leave uncommented because viewer-1.23 still uses it +//const U32 REGION_FLAGS_ABUSE_EMAIL_TO_ESTATE_OWNER = (1 << 27); const U32 REGION_FLAGS_ALLOW_VOICE = (1 << 28); const U32 REGION_FLAGS_BLOCK_PARCEL_SEARCH = (1 << 29); const U32 REGION_FLAGS_DENY_AGEUNVERIFIED = (1 << 30); -const U32 REGION_FLAGS_SKIP_MONO_SCRIPTS = (1 << 31); +//const U32 REGION_FLAGS_SKIP_MONO_SCRIPTS = (1 << 31); + const U32 REGION_FLAGS_DEFAULT = REGION_FLAGS_ALLOW_LANDMARK | REGION_FLAGS_ALLOW_SET_HOME | @@ -105,7 +106,6 @@ const U32 REGION_FLAGS_PRELUDE_UNSET = REGION_FLAGS_ALLOW_LANDMARK | REGION_FLAGS_ALLOW_SET_HOME; const U32 REGION_FLAGS_ESTATE_MASK = REGION_FLAGS_EXTERNALLY_VISIBLE - | REGION_FLAGS_PUBLIC_ALLOWED | REGION_FLAGS_SUN_FIXED | REGION_FLAGS_DENY_ANONYMOUS | REGION_FLAGS_DENY_AGEUNVERIFIED; -- cgit v1.2.3 From 739e4ac5414b270247237018c93028052d41e9cd Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Tue, 23 Nov 2010 11:25:40 -0800 Subject: DN-212 [crashhunters] LLCacheName::buildLegacyName --- indra/llmessage/llcachename.cpp | 50 ++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 4ab6bd2438..caeaaa3be9 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -556,35 +556,43 @@ std::string LLCacheName::buildUsername(const std::string& full_name) //static std::string LLCacheName::buildLegacyName(const std::string& complete_name) { - // regexp doesn't play nice with unicode, chop off the display name + //boost::regexp was showing up in the crashreporter, so doing + //painfully manual parsing using substr. LF S32 open_paren = complete_name.rfind(" ("); + S32 close_paren = complete_name.rfind(')'); - if (open_paren == std::string::npos) + if (open_paren != std::string::npos && + close_paren == complete_name.length()-1) { - return complete_name; - } + S32 length = close_paren - open_paren - 2; + std::string legacy_name = complete_name.substr(open_paren+2, length); + + if (legacy_name.length() > 0) + { + std::string cap_letter = legacy_name.substr(0, 1); + LLStringUtil::toUpper(cap_letter); + legacy_name = cap_letter + legacy_name.substr(1); + + S32 separator = legacy_name.find('.'); - std::string username = complete_name.substr(open_paren); - boost::regex complete_name_regex("( \\()([a-z0-9]+)(.[a-z]+)*(\\))"); - boost::match_results name_results; - if (!boost::regex_match(username, name_results, complete_name_regex)) return complete_name; + if (separator != std::string::npos) + { + std::string last_name = legacy_name.substr(separator+1); + legacy_name = legacy_name.substr(0, separator); - std::string legacy_name = name_results[2]; - // capitalize the first letter - std::string cap_letter = legacy_name.substr(0, 1); - LLStringUtil::toUpper(cap_letter); - legacy_name = cap_letter + legacy_name.substr(1); + if (last_name.length() > 0) + { + cap_letter = last_name.substr(0, 1); + LLStringUtil::toUpper(cap_letter); + legacy_name = legacy_name + " " + cap_letter + last_name.substr(1); + } + } - if (name_results[3].matched) - { - std::string last_name = name_results[3]; - std::string cap_letter = last_name.substr(1, 1); - LLStringUtil::toUpper(cap_letter); - last_name = cap_letter + last_name.substr(2); - legacy_name = legacy_name + " " + last_name; + return legacy_name; + } } - return legacy_name; + return complete_name; } // This is a little bit kludgy. LLCacheNameCallback is a slot instead of a function pointer. -- cgit v1.2.3 From c489f33169bdf88df24c430c278038b2f5a0630a Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Tue, 30 Nov 2010 16:37:31 -0800 Subject: DN-217 Changing between View Display Names on and off during a conference call session put viewer in a state where last name resident was shown in viewer everywhere for user in conference call with last name resident. --- indra/llmessage/llcachename.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index caeaaa3be9..479efabb5f 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -975,6 +975,10 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) if (entry->mLastName.empty()) { full_name = cleanFullName(entry->mFirstName); + + //fix what we are putting in the cache + entry->mFirstName = full_name; + entry->mLastName = "Resident"; } else { -- cgit v1.2.3 From 089665ce4eab97d0ab58e08914f852219ed3fae7 Mon Sep 17 00:00:00 2001 From: leyla_linden Date: Thu, 9 Dec 2010 15:26:03 -0800 Subject: Falling back to legacy cache on display name fetch error --- indra/llmessage/llavatarnamecache.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 7396117d84..03c28eb2a5 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -235,27 +235,21 @@ public: /*virtual*/ void error(U32 status, const std::string& reason) { - // We're going to construct a dummy record and cache it for a while, - // either briefly for a 503 Service Unavailable, or longer for other - // errors. - F64 retry_timestamp = errorRetryTimestamp(status); - - // *NOTE: "??" starts trigraphs in C/C++, escape the question marks. - const std::string DUMMY_NAME("\?\?\?"); - LLAvatarName av_name; - av_name.mUsername = DUMMY_NAME; - av_name.mDisplayName = DUMMY_NAME; - av_name.mIsDisplayNameDefault = false; - av_name.mIsDummy = true; - av_name.mExpires = retry_timestamp; + // If there's an error, it might be caused by PeopleApi, + // or when loading textures on startup and using a very slow + // network, this query may time out. Fallback to the legacy + // cache. + + llwarns << "LLAvatarNameResponder error " << status << " " << reason << llendl; // Add dummy records for all agent IDs in this request std::vector::const_iterator it = mAgentIDs.begin(); for ( ; it != mAgentIDs.end(); ++it) { const LLUUID& agent_id = *it; - // cache it and fire signals - LLAvatarNameCache::processName(agent_id, av_name, true); + gCacheName->get(agent_id, false, // legacy compatibility + boost::bind(&LLAvatarNameCache::legacyNameCallback, + _1, _2, _3)); } } @@ -357,7 +351,7 @@ void LLAvatarNameCache::requestNamesViaCapability() if (url.size() > NAME_URL_SEND_THRESHOLD) { //llinfos << "requestNames " << url << llendl; - LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids)); + LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));//, LLSD(), 10.0f); url.clear(); agent_ids.clear(); } @@ -366,7 +360,7 @@ void LLAvatarNameCache::requestNamesViaCapability() if (!url.empty()) { //llinfos << "requestNames " << url << llendl; - LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids)); + LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));//, LLSD(), 10.0f); url.clear(); agent_ids.clear(); } -- cgit v1.2.3 From 4bab98f5cd2a815d10fe494a0a7e51cc237adb4a Mon Sep 17 00:00:00 2001 From: Monty Brandenberg Date: Fri, 10 Dec 2010 16:05:19 -0500 Subject: ESC-228 ESC-227 Corrections for metrics counters and send-on-quit delivery. Wanted to avoid computing metrics for duplicate requests as much as possible, they artificially depress averages but missed an opportunity and was including them in the counts. The non-texture case is solid. Textures are.... confounding still. Do a better job of trying to send one last packet to the grid when quitting. It is succeeding now, at least sometimes. Put a comment in base llassetstorage.cpp pointing to cut-n-paste derivation in llviewerassetstorage.cpp so that changes can be replicated. Hate doing this but current design forces it. --- indra/llmessage/llassetstorage.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp index b26d412e9f..27a368df3d 100644 --- a/indra/llmessage/llassetstorage.cpp +++ b/indra/llmessage/llassetstorage.cpp @@ -513,6 +513,10 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, LL } +// +// *NOTE: Logic here is replicated in LLViewerAssetStorage::_queueDataRequest. +// Changes here may need to be replicated in the viewer's derived class. +// void LLAssetStorage::_queueDataRequest(const LLUUID& uuid, LLAssetType::EType atype, LLGetAssetCallback callback, void *user_data, BOOL duplicate, -- cgit v1.2.3 From c8457f266423370e6f8e84c1b23ef95ed69a2997 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 10 Jan 2011 18:01:16 -0800 Subject: STORM-807 : Clean up code as discussed with Andrew --- indra/llmessage/llregionflags.h | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llregionflags.h b/indra/llmessage/llregionflags.h index aa47f1b524..7b796a0fa8 100644 --- a/indra/llmessage/llregionflags.h +++ b/indra/llmessage/llregionflags.h @@ -42,8 +42,6 @@ const U32 REGION_FLAGS_RESET_HOME_ON_TELEPORT = (1 << 3); // Does the sun move? const U32 REGION_FLAGS_SUN_FIXED = (1 << 4); -//const U32 REGION_FLAGS_TAX_FREE = (1 << 5); // legacy - // Can't change the terrain heightfield, even on owned parcels, // but can plant trees and grass. const U32 REGION_FLAGS_BLOCK_TERRAFORM = (1 << 6); @@ -53,9 +51,6 @@ const U32 REGION_FLAGS_BLOCK_LAND_RESELL = (1 << 7); // All content wiped once per night const U32 REGION_FLAGS_SANDBOX = (1 << 8); -//const U32 REGION_FLAGS_NULL_LAYER = (1 << 9); -//const U32 REGION_FLAGS_HARD_ALLOW_LAND_TRANSFER = (1 << 10); -//const U32 REGION_FLAGS_SKIP_UPDATE_INTEREST_LIST= (1 << 11); const U32 REGION_FLAGS_SKIP_COLLISIONS = (1 << 12); // Pin all non agent rigid bodies const U32 REGION_FLAGS_SKIP_SCRIPTS = (1 << 13); const U32 REGION_FLAGS_SKIP_PHYSICS = (1 << 14); // Skip all physics @@ -78,21 +73,13 @@ const U32 REGION_FLAGS_ESTATE_SKIP_SCRIPTS = (1 << 21); const U32 REGION_FLAGS_RESTRICT_PUSHOBJECT = (1 << 22); const U32 REGION_FLAGS_DENY_ANONYMOUS = (1 << 23); -//const U32 REGION_FLAGS_DENY_IDENTIFIED = (1 << 24); -//const U32 REGION_FLAGS_DENY_TRANSACTED = (1 << 25); const U32 REGION_FLAGS_ALLOW_PARCEL_CHANGES = (1 << 26); -// Deprecated. Phoeinx 2009-12-11 -// REGION_FLAGS_ABUSE_EMAIL_TO_ESTATE_OWNER is unused beyond viewer-1.23 -//const U32 REGION_FLAGS_ABUSE_EMAIL_TO_ESTATE_OWNER = (1 << 27); - const U32 REGION_FLAGS_ALLOW_VOICE = (1 << 28); const U32 REGION_FLAGS_BLOCK_PARCEL_SEARCH = (1 << 29); const U32 REGION_FLAGS_DENY_AGEUNVERIFIED = (1 << 30); -//const U32 REGION_FLAGS_SKIP_MONO_SCRIPTS = (1 << 31); - const U32 REGION_FLAGS_DEFAULT = REGION_FLAGS_ALLOW_LANDMARK | REGION_FLAGS_ALLOW_SET_HOME | -- cgit v1.2.3 From c5d8624ba4fb303ad534a0bb9258c89cafe77303 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Sat, 15 Jan 2011 09:09:41 -0500 Subject: renamed temp name flag member in name cache to avoid confusion with similar names in other classes --- indra/llmessage/llavatarnamecache.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 03c28eb2a5..d9cb83c089 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -220,7 +220,7 @@ public: av_name.mUsername = DUMMY_NAME; av_name.mDisplayName = DUMMY_NAME; av_name.mIsDisplayNameDefault = false; - av_name.mIsDummy = true; + av_name.mIsTemporaryName = true; av_name.mExpires = expires; it = unresolved_agents.beginArray(); @@ -449,7 +449,7 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr) { const LLUUID& agent_id = it->first; const LLAvatarName& av_name = it->second; - if (!av_name.mIsDummy) + if (!av_name.mIsTemporaryName) { // key must be a string agents[agent_id.asString()] = av_name.asLLSD(); @@ -490,12 +490,6 @@ void LLAvatarNameCache::idle() // this way first synchronous get call on an expired entry won't return // legacy name. LF - //const F32 ERASE_EXPIRED_TIMEOUT = 60.f; // seconds - //if (sEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT)) - //{ - // eraseExpired(); - //} - if (sAskQueue.empty()) { return; @@ -550,7 +544,7 @@ void LLAvatarNameCache::buildLegacyName(const std::string& full_name, av_name->mUsername = ""; av_name->mDisplayName = full_name; av_name->mIsDisplayNameDefault = true; - av_name->mIsDummy = true; + av_name->mIsTemporaryName = true; av_name->mExpires = F64_MAX; } -- cgit v1.2.3 From e1066784220adb9a2e731001e72c444582fc997f Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Sun, 16 Jan 2011 21:41:08 -0500 Subject: DN-202: Make avatar name caching more aggressive and error handling more uniform Add logging (mostly at DEBUG level) --- indra/llmessage/llavatarnamecache.cpp | 258 ++++++++++++++++++++-------------- indra/llmessage/llavatarnamecache.h | 3 + 2 files changed, 158 insertions(+), 103 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index d9cb83c089..ab4785569d 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -38,6 +38,7 @@ #include #include +#include namespace LLAvatarNameCache { @@ -81,8 +82,11 @@ namespace LLAvatarNameCache // only need per-frame timing resolution LLFrameTimer sRequestTimer; - // Periodically clean out expired entries from the cache - //LLFrameTimer sEraseExpiredTimer; + /// Maximum time an unrefreshed cache entry is allowed + const F64 MAX_UNREFRESHED_TIME = 20.0 * 60.0; + + /// Time when unrefreshed cached names were checked last + static F64 sLastExpireCheck; //----------------------------------------------------------------------- // Internal methods @@ -99,8 +103,9 @@ namespace LLAvatarNameCache // Legacy name system callback void legacyNameCallback(const LLUUID& agent_id, - const std::string& full_name, - bool is_group); + const std::string& full_name, + bool is_group + ); void requestNamesViaLegacy(); @@ -117,7 +122,7 @@ namespace LLAvatarNameCache bool isRequestPending(const LLUUID& agent_id); // Erase expired names from cache - void eraseExpired(); + void eraseUnrefreshed(); bool expirationFromCacheControl(LLSD headers, F64 *expires); } @@ -187,6 +192,7 @@ public: { // Pull expiration out of headers if available F64 expires = LLAvatarNameCache::nameExpirationFromHeaders(mHeaders); + F64 now = LLFrameTimer::getTotalSeconds(); LLSD agents = content["agents"]; LLSD::array_const_iterator it = agents.beginArray(); @@ -207,84 +213,91 @@ public: 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; + // cache it and fire signals LLAvatarNameCache::processName(agent_id, av_name, true); } // Same logic as error response case LLSD unresolved_agents = content["bad_ids"]; - if (unresolved_agents.size() > 0) + S32 num_unresolved = unresolved_agents.size(); + if (num_unresolved > 0) { - const std::string DUMMY_NAME("\?\?\?"); - LLAvatarName av_name; - av_name.mUsername = DUMMY_NAME; - av_name.mDisplayName = DUMMY_NAME; - av_name.mIsDisplayNameDefault = false; - av_name.mIsTemporaryName = true; - av_name.mExpires = expires; - + LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result " << num_unresolved << " unresolved ids; " + << "expires in " << expires - now << " seconds" + << LL_ENDL; it = unresolved_agents.beginArray(); for ( ; it != unresolved_agents.endArray(); ++it) { const LLUUID& agent_id = *it; - // cache it and fire signals - LLAvatarNameCache::processName(agent_id, av_name, true); + + LL_WARNS("AvNameCache") << "LLAvatarNameResponder::result " + << "failed id " << agent_id + << LL_ENDL; + + LLAvatarNameCache::handleAgentError(agent_id); } } - } + LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result " + << LLAvatarNameCache::sCache.size() << " cached names" + << LL_ENDL; + } /*virtual*/ void error(U32 status, const std::string& reason) { // If there's an error, it might be caused by PeopleApi, // or when loading textures on startup and using a very slow - // network, this query may time out. Fallback to the legacy - // cache. - - llwarns << "LLAvatarNameResponder error " << status << " " << reason << llendl; + // network, this query may time out. + // What we should do depends on whether or not we have a cached name + LL_WARNS("AvNameCache") << "LLAvatarNameResponder::error " << status << " " << reason + << LL_ENDL; - // Add dummy records for all agent IDs in this request + // Add dummy records for any agent IDs in this request that we do not have cached already std::vector::const_iterator it = mAgentIDs.begin(); for ( ; it != mAgentIDs.end(); ++it) { const LLUUID& agent_id = *it; - gCacheName->get(agent_id, false, // legacy compatibility - boost::bind(&LLAvatarNameCache::legacyNameCallback, - _1, _2, _3)); + LLAvatarNameCache::handleAgentError(agent_id); } } - - // Return time to retry a request that generated an error, based on - // error type and headers. Return value is seconds-since-epoch. - F64 errorRetryTimestamp(S32 status) - { - F64 now = LLFrameTimer::getTotalSeconds(); - - // Retry-After takes priority - LLSD retry_after = mHeaders["retry-after"]; - if (retry_after.isDefined()) - { - // We only support the delta-seconds type - S32 delta_seconds = retry_after.asInteger(); - if (delta_seconds > 0) - { - // ...valid delta-seconds - return now + F64(delta_seconds); - } - } - - // If no Retry-After, look for Cache-Control max-age - F64 expires = 0.0; - if (LLAvatarNameCache::expirationFromCacheControl(mHeaders, &expires)) - { - return expires; - } - - // No information in header, make a guess - const F64 DEFAULT_DELAY = 120.0; // 2 mintues - return now + DEFAULT_DELAY; - } }; +// Provide some fallback for agents that return errors +void LLAvatarNameCache::handleAgentError(const LLUUID& agent_id) +{ + std::map::iterator existing = sCache.find(agent_id); + if (existing == sCache.end()) + { + // there is no existing cache entry, so make a temporary name from legacy + LL_WARNS("AvNameCache") << "LLAvatarNameCache get legacy for agent " + << agent_id << LL_ENDL; + gCacheName->get(agent_id, false, // legacy compatibility + boost::bind(&LLAvatarNameCache::legacyNameCallback, + _1, _2, _3)); + } + else + { + // we have a chached (but probably expired) entry - since that would have + // been returned by the get method, there is no need to signal anyone + + // Clear this agent from the pending list + LLAvatarNameCache::sPendingQueue.erase(agent_id); + + const 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; + } +} + void LLAvatarNameCache::processName(const LLUUID& agent_id, const LLAvatarName& av_name, bool add_to_cache) @@ -326,6 +339,7 @@ void LLAvatarNameCache::requestNamesViaCapability() std::vector agent_ids; agent_ids.reserve(128); + U32 ids = 0; ask_queue_t::const_iterator it = sAskQueue.begin(); for ( ; it != sAskQueue.end(); ++it) { @@ -336,11 +350,13 @@ void LLAvatarNameCache::requestNamesViaCapability() // ...starting new request url += sNameLookupURL; url += "?ids="; + ids = 1; } else { // ...continuing existing request url += "&ids="; + ids++; } url += agent_id.asString(); agent_ids.push_back(agent_id); @@ -350,8 +366,10 @@ void LLAvatarNameCache::requestNamesViaCapability() if (url.size() > NAME_URL_SEND_THRESHOLD) { - //llinfos << "requestNames " << url << llendl; - LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));//, LLSD(), 10.0f); + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability first " + << ids << " ids" + << LL_ENDL; + LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids)); url.clear(); agent_ids.clear(); } @@ -359,8 +377,10 @@ void LLAvatarNameCache::requestNamesViaCapability() if (!url.empty()) { - //llinfos << "requestNames " << url << llendl; - LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));//, LLSD(), 10.0f); + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability all " + << ids << " ids" + << LL_ENDL; + LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids)); url.clear(); agent_ids.clear(); } @@ -376,6 +396,11 @@ void LLAvatarNameCache::legacyNameCallback(const LLUUID& agent_id, // Construct a dummy record for this name. By convention, SLID is blank // Never expires, but not written to disk, so lasts until end of session. LLAvatarName av_name; + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::legacyNameCallback " + << "agent " << agent_id << " " + << "full name '" << full_name << "'" + << ( is_group ? " [group]" : "" ) + << LL_ENDL; buildLegacyName(full_name, &av_name); // Don't add to cache, the data already exists in the legacy name system @@ -397,6 +422,8 @@ void LLAvatarNameCache::requestNamesViaLegacy() // invoked below. This should never happen in practice. sPendingQueue[agent_id] = now; + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaLegacy agent " << agent_id << LL_ENDL; + gCacheName->get(agent_id, false, // legacy compatibility boost::bind(&LLAvatarNameCache::legacyNameCallback, _1, _2, _3)); @@ -435,21 +462,24 @@ void LLAvatarNameCache::importFile(std::istream& istr) 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; + // Some entries may have expired since the cache was stored, + // but next time they are read that will be checked. + // Expired entries are filtered out when the cache is stored, + // or in eraseUnrefreshed + LL_INFOS("AvNameCache") << "loaded " << sCache.size() << LL_ENDL; } void LLAvatarNameCache::exportFile(std::ostream& ostr) { LLSD agents; + F64 now = LLFrameTimer::getTotalSeconds(); cache_t::const_iterator it = sCache.begin(); for ( ; it != sCache.end(); ++it) { const LLUUID& agent_id = it->first; const LLAvatarName& av_name = it->second; - if (!av_name.mIsTemporaryName) + // Do not write temporary or expired entries to the stored cache + if (!av_name.mIsTemporaryName && av_name.mExpires >= now) { // key must be a string agents[agent_id.asString()] = av_name.asLLSD(); @@ -484,56 +514,63 @@ void LLAvatarNameCache::idle() // return; //} - // Must be large relative to above - - // No longer deleting expired entries, just re-requesting in the get - // this way first synchronous get call on an expired entry won't return - // legacy name. LF - - if (sAskQueue.empty()) + if (!sAskQueue.empty()) { - return; + if (useDisplayNames()) + { + requestNamesViaCapability(); + } + else + { + // ...fall back to legacy name cache system + requestNamesViaLegacy(); + } } - if (useDisplayNames()) - { - requestNamesViaCapability(); - } - else - { - // ...fall back to legacy name cache system - requestNamesViaLegacy(); - } + // erase anything that has not been refreshed for more than MAX_UNREFRESHED_TIME + eraseUnrefreshed(); } bool LLAvatarNameCache::isRequestPending(const LLUUID& agent_id) { + bool isPending = false; const F64 PENDING_TIMEOUT_SECS = 5.0 * 60.0; - F64 now = LLFrameTimer::getTotalSeconds(); - F64 expire_time = now - PENDING_TIMEOUT_SECS; pending_queue_t::const_iterator it = sPendingQueue.find(agent_id); if (it != sPendingQueue.end()) { - bool request_expired = (it->second < expire_time); - return !request_expired; + // in the list of requests in flight, retry if too old + F64 expire_time = LLFrameTimer::getTotalSeconds() - PENDING_TIMEOUT_SECS; + isPending = (it->second > expire_time); } - return false; + return isPending; } -void LLAvatarNameCache::eraseExpired() +void LLAvatarNameCache::eraseUnrefreshed() { F64 now = LLFrameTimer::getTotalSeconds(); - cache_t::iterator it = sCache.begin(); - while (it != sCache.end()) - { - cache_t::iterator cur = it; - ++it; - const LLAvatarName& av_name = cur->second; - if (av_name.mExpires < now) - { - sCache.erase(cur); - } + F64 max_unrefreshed = now - MAX_UNREFRESHED_TIME; + + if (!sLastExpireCheck || sLastExpireCheck < max_unrefreshed) + { + sLastExpireCheck = now; + cache_t::iterator it = sCache.begin(); + while (it != sCache.end()) + { + cache_t::iterator cur = it; + ++it; + const LLAvatarName& av_name = cur->second; + if (av_name.mExpires < max_unrefreshed) + { + const LLUUID& agent_id = it->first; + LL_DEBUGS("AvNameCache") << agent_id + << " user '" << av_name.mUsername << "' " + << "expired " << now - av_name.mExpires << " secs ago" + << LL_ENDL; + sCache.erase(cur); + } + } + LL_INFOS("AvNameCache") << sCache.size() << " cached avatar names" << LL_ENDL; } } @@ -545,7 +582,10 @@ void LLAvatarNameCache::buildLegacyName(const std::string& full_name, av_name->mDisplayName = full_name; av_name->mIsDisplayNameDefault = true; av_name->mIsTemporaryName = true; - av_name->mExpires = F64_MAX; + av_name->mExpires = F64_MAX; // not used because these are not cached + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::buildLegacyName " + << full_name + << LL_ENDL; } // fills in av_name if it has it in the cache, even if expired (can check expiry time) @@ -568,6 +608,9 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) { if (!isRequestPending(agent_id)) { + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::get " + << "refresh agent " << agent_id + << LL_ENDL; sAskQueue.insert(agent_id); } } @@ -589,6 +632,9 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) if (!isRequestPending(agent_id)) { + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::get " + << "queue request for agent " << agent_id + << LL_ENDL; sAskQueue.insert(agent_id); } @@ -621,7 +667,6 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) { // ...name already exists in cache, fire callback now fireSignal(agent_id, slot, av_name); - return; } } @@ -717,6 +762,9 @@ F64 LLAvatarNameCache::nameExpirationFromHeaders(LLSD headers) bool LLAvatarNameCache::expirationFromCacheControl(LLSD headers, F64 *expires) { + bool fromCacheControl = false; + F64 now = LLFrameTimer::getTotalSeconds(); + // Allow the header to override the default LLSD cache_control_header = headers["cache-control"]; if (cache_control_header.isDefined()) @@ -725,12 +773,16 @@ bool LLAvatarNameCache::expirationFromCacheControl(LLSD headers, F64 *expires) std::string cache_control = cache_control_header.asString(); if (max_age_from_cache_control(cache_control, &max_age)) { - F64 now = LLFrameTimer::getTotalSeconds(); *expires = now + (F64)max_age; - return true; + fromCacheControl = true; } } - return false; + LL_DEBUGS("AvNameCache") + << ( fromCacheControl ? "expires based on cache control " : "default expiration " ) + << "in " << *expires - now << " seconds" + << LL_ENDL; + + return fromCacheControl; } diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 8f21ace96a..59c1329ffa 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -82,6 +82,9 @@ namespace LLAvatarNameCache void erase(const LLUUID& agent_id); + /// Provide some fallback for agents that return errors + void handleAgentError(const LLUUID& agent_id); + // Force a re-fetch of the most recent data, but keep the current // data in cache void fetch(const LLUUID& agent_id); -- cgit v1.2.3 From 8c2f2eb1f3365b661e4cc9d41ed4168bc9306314 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 18 Jan 2011 07:37:56 -0500 Subject: make storing the cache obey the same unrefreshed time as other usage --- indra/llmessage/llavatarnamecache.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index ab4785569d..579dd2782c 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -462,24 +462,24 @@ void LLAvatarNameCache::importFile(std::istream& istr) av_name.fromLLSD( it->second ); sCache[agent_id] = av_name; } + LL_INFOS("AvNameCache") << "loaded " << sCache.size() << LL_ENDL; + // Some entries may have expired since the cache was stored, - // but next time they are read that will be checked. - // Expired entries are filtered out when the cache is stored, - // or in eraseUnrefreshed - LL_INFOS("AvNameCache") << "loaded " << sCache.size() << LL_ENDL; + // but they will be flushed in the first call to eraseUnrefreshed + // from LLAvatarNameResponder::idle } void LLAvatarNameCache::exportFile(std::ostream& ostr) { LLSD agents; - F64 now = LLFrameTimer::getTotalSeconds(); + F64 max_unrefreshed = LLFrameTimer::getTotalSeconds() - MAX_UNREFRESHED_TIME; cache_t::const_iterator it = sCache.begin(); for ( ; it != sCache.end(); ++it) { 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 >= now) + if (!av_name.mIsTemporaryName && av_name.mExpires >= max_unrefreshed) { // key must be a string agents[agent_id.asString()] = av_name.asLLSD(); -- cgit v1.2.3 From 24f73fda0f9a2fa56e3141ca3f84ac76731a85c0 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 18 Jan 2011 15:59:45 -0500 Subject: remove problematic include used during debug --- indra/llmessage/llavatarnamecache.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 579dd2782c..767001b633 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -38,7 +38,6 @@ #include #include -#include namespace LLAvatarNameCache { -- cgit v1.2.3 From f91a9c87e5e758ecd32111d901ff32d282b73fa7 Mon Sep 17 00:00:00 2001 From: Dave SIMmONs Date: Wed, 19 Jan 2011 12:54:05 -0800 Subject: ER-428 / CTS-422 : [PUBLIC] movement updates are lost when walking. Changed code to detect if the circuit has stopped getting packets. Reviewed by Andrew --- indra/llmessage/llcircuit.cpp | 3 +++ indra/llmessage/llcircuit.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp index 3ba2dfb104..e0410906fb 100644 --- a/indra/llmessage/llcircuit.cpp +++ b/indra/llmessage/llcircuit.cpp @@ -87,6 +87,7 @@ LLCircuitData::LLCircuitData(const LLHost &host, TPACKETID in_id, mPingDelayAveraged((F32)INITIAL_PING_VALUE_MSEC), mUnackedPacketCount(0), mUnackedPacketBytes(0), + mLastPacketInTime(0.0), mLocalEndPointID(), mPacketsOut(0), mPacketsIn(0), @@ -667,6 +668,8 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) mHighestPacketID = llmax(mHighestPacketID, id); } + // Save packet arrival time + mLastPacketInTime = LLMessageSystem::getMessageTimeSeconds(); // Have we received anything on this circuit yet? if (0 == mPacketsIn) diff --git a/indra/llmessage/llcircuit.h b/indra/llmessage/llcircuit.h index 874c0c0bee..d1c400c6a2 100644 --- a/indra/llmessage/llcircuit.h +++ b/indra/llmessage/llcircuit.h @@ -122,7 +122,7 @@ public: U32 getPacketsLost() const; TPACKETID getPacketOutID() const; BOOL getTrusted() const; - F32 getAgeInSeconds() const; + F32 getAgeInSeconds() const; S32 getUnackedPacketCount() const { return mUnackedPacketCount; } S32 getUnackedPacketBytes() const { return mUnackedPacketBytes; } F64 getNextPingSendTime() const { return mNextPingSendTime; } @@ -130,6 +130,7 @@ public: { return mOutOfOrderRate.meanValue(scale); } U32 getLastPacketGap() const { return mLastPacketGap; } LLHost getHost() const { return mHost; } + F64 getLastPacketInTime() const { return mLastPacketInTime; } LLThrottleGroup &getThrottleGroup() { return mThrottles; } @@ -248,6 +249,7 @@ protected: S32 mUnackedPacketCount; S32 mUnackedPacketBytes; + F64 mLastPacketInTime; // Time of last packet arrival LLUUID mLocalEndPointID; -- cgit v1.2.3