From 3a49beed0e96a797a6d663bcae5e932437ca3661 Mon Sep 17 00:00:00 2001
From: Merov Linden <merov@lindenlab.com>
Date: Wed, 5 Dec 2012 20:25:46 -0800
Subject: CHUI-580 : WIP : Change the display name cache system, deprecating
 the old protocol and using the cap (People API) whenever available. Still has
 occurence of Resident as last name to clean up.

---
 indra/newview/llavataractions.cpp         | 16 ++++++----------
 indra/newview/llavatariconctrl.cpp        |  2 +-
 indra/newview/llavatarlist.cpp            |  9 +++++----
 indra/newview/llavatarlistitem.cpp        |  4 ++--
 indra/newview/llcallingcard.cpp           |  6 +++---
 indra/newview/llchathistory.cpp           | 14 +++++++-------
 indra/newview/llconversationmodel.cpp     |  4 ++--
 indra/newview/llfavoritesbar.cpp          | 10 +++++-----
 indra/newview/llfloateravatarpicker.cpp   | 12 ++++--------
 indra/newview/llfloaterdisplayname.cpp    | 10 ++++------
 indra/newview/llfloaterimnearbychat.cpp   |  2 +-
 indra/newview/llfloaterscriptlimits.cpp   | 15 ++-------------
 indra/newview/llfloatersellland.cpp       |  2 +-
 indra/newview/llfloatertopobjects.cpp     | 14 +++-----------
 indra/newview/llfloatervoicevolume.cpp    |  2 +-
 indra/newview/llfriendcard.cpp            |  2 +-
 indra/newview/llimview.cpp                | 20 ++++++--------------
 indra/newview/llinspectavatar.cpp         |  6 +++---
 indra/newview/llinventorybridge.cpp       |  5 ++---
 indra/newview/llnamelistctrl.cpp          |  4 ++--
 indra/newview/llpanelblockedlist.cpp      |  2 +-
 indra/newview/llpanelgroupinvite.cpp      |  4 ++--
 indra/newview/llpanelgroupnotices.cpp     |  5 +----
 indra/newview/llpanelgrouproles.cpp       |  4 ++--
 indra/newview/llparticipantlist.cpp       |  2 +-
 indra/newview/lltoastgroupnotifypanel.cpp |  6 ++----
 indra/newview/lltoolpie.cpp               |  3 +--
 indra/newview/llviewerdisplayname.cpp     |  6 +++---
 indra/newview/llviewermenu.cpp            |  6 +-----
 indra/newview/llviewermessage.cpp         | 15 +++------------
 indra/newview/llvoavatar.cpp              | 24 ++++++++++--------------
 indra/newview/llvoicevivox.cpp            |  4 ++--
 32 files changed, 90 insertions(+), 150 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp
index 1969a0bc5f..59b862503c 100755
--- a/indra/newview/llavataractions.cpp
+++ b/indra/newview/llavataractions.cpp
@@ -135,7 +135,7 @@ void LLAvatarActions::removeFriendsDialog(const uuid_vec_t& ids)
 		LLAvatarName av_name;
 		if(LLAvatarNameCache::get(agent_id, &av_name))
 		{
-			args["NAME"] = av_name.mDisplayName;
+			args["NAME"] = av_name.getDisplayName();
 		}
 
 		msgType = "RemoveFromFriends";
@@ -180,7 +180,7 @@ void LLAvatarActions::offerTeleport(const uuid_vec_t& ids)
 static void on_avatar_name_cache_start_im(const LLUUID& agent_id,
 										  const LLAvatarName& av_name)
 {
-	std::string name = av_name.mDisplayName;
+	std::string name = av_name.getDisplayName();
 	LLUUID session_id = gIMMgr->addSession(name, IM_NOTHING_SPECIAL, agent_id);
 	if (session_id != LLUUID::null)
 	{
@@ -215,7 +215,7 @@ void LLAvatarActions::endIM(const LLUUID& id)
 static void on_avatar_name_cache_start_call(const LLUUID& agent_id,
 											const LLAvatarName& av_name)
 {
-	std::string name = av_name.mDisplayName;
+	std::string name = av_name.getDisplayName();
 	LLUUID session_id = gIMMgr->addSession(name, IM_NOTHING_SPECIAL, agent_id, true);
 	if (session_id != LLUUID::null)
 	{
@@ -315,11 +315,7 @@ static const char* get_profile_floater_name(const LLUUID& avatar_id)
 
 static void on_avatar_name_show_profile(const LLUUID& agent_id, const LLAvatarName& av_name)
 {
-	std::string username = av_name.mUsername;
-	if (username.empty())
-	{
-		username = LLCacheName::buildUsername(av_name.mDisplayName);
-	}
+	std::string username = av_name.getUserName();
 	
 	llinfos << "opening web profile for " << username << llendl;		
 	std::string url = getProfileURL(username);
@@ -379,7 +375,7 @@ void LLAvatarActions::showOnMap(const LLUUID& id)
 		return;
 	}
 
-	gFloaterWorldMap->trackAvatar(id, av_name.mDisplayName);
+	gFloaterWorldMap->trackAvatar(id, av_name.getDisplayName());
 	LLFloaterReg::showInstance("world_map");
 }
 
@@ -709,7 +705,7 @@ void LLAvatarActions::buildResidentsString(std::vector<LLAvatarName> avatar_name
 	const std::string& separator = LLTrans::getString("words_separator");
 	for (std::vector<LLAvatarName>::const_iterator it = avatar_names.begin(); ; )
 	{
-		residents_string.append((*it).mDisplayName);
+		residents_string.append((*it).getDisplayName());
 		if	(++it == avatar_names.end())
 		{
 			break;
diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp
index b7278d4a3a..0db38c947c 100755
--- a/indra/newview/llavatariconctrl.cpp
+++ b/indra/newview/llavatariconctrl.cpp
@@ -318,7 +318,7 @@ void LLAvatarIconCtrl::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarN
 	{
 		// Most avatar icon controls are next to a UI element that shows
 		// a display name, so only show username.
-		mFullName = av_name.mUsername;
+		mFullName = av_name.getUserName();
 
 		if (mDrawTooltip)
 		{
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 771419f60a..e54e47180f 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -278,7 +278,7 @@ void LLAvatarList::refresh()
 		LLAvatarName av_name;
 		have_names &= LLAvatarNameCache::get(buddy_id, &av_name);
 
-		if (!have_filter || findInsensitive(av_name.mDisplayName, mNameFilter))
+		if (!have_filter || findInsensitive(av_name.getDisplayName(), mNameFilter))
 		{
 			if (nadded >= ADD_LIMIT)
 			{
@@ -296,8 +296,9 @@ void LLAvatarList::refresh()
 				}
 				else
 				{
+					std::string display_name = av_name.getDisplayName();
 					addNewItem(buddy_id, 
-						av_name.mDisplayName.empty() ? waiting_str : av_name.mDisplayName, 
+						display_name.empty() ? waiting_str : display_name, 
 						LLAvatarTracker::instance().isBuddyOnline(buddy_id));
 				}
 				
@@ -325,7 +326,7 @@ void LLAvatarList::refresh()
 			const LLUUID& buddy_id = it->asUUID();
 			LLAvatarName av_name;
 			have_names &= LLAvatarNameCache::get(buddy_id, &av_name);
-			if (!findInsensitive(av_name.mDisplayName, mNameFilter))
+			if (!findInsensitive(av_name.getDisplayName(), mNameFilter))
 			{
 				removeItemByUUID(buddy_id);
 				modified = true;
@@ -398,7 +399,7 @@ bool LLAvatarList::filterHasMatches()
 		// If name has not been loaded yet we consider it as a match.
 		// When the name will be loaded the filter will be applied again(in refresh()).
 
-		if (have_name && !findInsensitive(av_name.mDisplayName, mNameFilter))
+		if (have_name && !findInsensitive(av_name.getDisplayName(), mNameFilter))
 		{
 			continue;
 		}
diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp
index 7ff1b39573..84e177d4a4 100644
--- a/indra/newview/llavatarlistitem.cpp
+++ b/indra/newview/llavatarlistitem.cpp
@@ -449,8 +449,8 @@ void LLAvatarListItem::setNameInternal(const std::string& name, const std::strin
 
 void LLAvatarListItem::onAvatarNameCache(const LLAvatarName& av_name)
 {
-	setAvatarName(av_name.mDisplayName);
-	setAvatarToolTip(av_name.mUsername);
+	setAvatarName(av_name.getDisplayName());
+	setAvatarToolTip(av_name.getUserName());
 
 	//requesting the list to resort
 	notifyParent(LLSD().with("sort", LLSD()));
diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp
index 60d60abd45..9a295faa73 100644
--- a/indra/newview/llcallingcard.cpp
+++ b/indra/newview/llcallingcard.cpp
@@ -723,7 +723,7 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id,
 	// Popup a notify box with online status of this agent
 	// Use display name only because this user is your friend
 	LLSD args;
-	args["NAME"] = av_name.mDisplayName;
+	args["NAME"] = av_name.getDisplayName();
 	args["STATUS"] = online ? LLTrans::getString("OnlineStatus") : LLTrans::getString("OfflineStatus");
 
 	LLNotificationPtr notification;
@@ -869,7 +869,7 @@ bool LLCollectMappableBuddies::operator()(const LLUUID& buddy_id, LLRelationship
 {
 	LLAvatarName av_name;
 	LLAvatarNameCache::get( buddy_id, &av_name);
-	buddy_map_t::value_type value(av_name.mDisplayName, buddy_id);
+	buddy_map_t::value_type value(av_name.getDisplayName(), buddy_id);
 	if(buddy->isOnline() && buddy->isRightGrantedFrom(LLRelationship::GRANT_MAP_LOCATION))
 	{
 		mMappable.insert(value);
@@ -892,7 +892,7 @@ bool LLCollectAllBuddies::operator()(const LLUUID& buddy_id, LLRelationship* bud
 {
 	LLAvatarName av_name;
 	LLAvatarNameCache::get(buddy_id, &av_name);
-	mFullName = av_name.mDisplayName;
+	mFullName = av_name.getDisplayName();
 	buddy_map_t::value_type value(mFullName, buddy_id);
 	if(buddy->isOnline())
 	{
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index a33bd88273..3e25d9c457 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -553,15 +553,15 @@ private:
 
 	void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name)
 	{
-		mFrom = av_name.mDisplayName;
+		mFrom = av_name.getDisplayName();
 
 		LLTextBox* user_name = getChild<LLTextBox>("user_name");
-		user_name->setValue( LLSD(av_name.mDisplayName ) );
-		user_name->setToolTip( av_name.mUsername );
+		user_name->setValue( LLSD(av_name.getDisplayName() ) );
+		user_name->setToolTip( av_name.getUserName() );
 
 		if (gSavedSettings.getBOOL("NameTagShowUsernames") && 
-			LLAvatarNameCache::useDisplayNames() &&
-			!av_name.mIsDisplayNameDefault)
+			av_name.useDisplayNames() &&
+			!av_name.isDisplayNameDefault())
 		{
 			LLStyle::Params style_params_name;
 			LLColor4 userNameColor = LLUIColorTable::instance().getColor("EmphasisColor");
@@ -569,9 +569,9 @@ private:
 			style_params_name.font.name("SansSerifSmall");
 			style_params_name.font.style("NORMAL");
 			style_params_name.readonly_color(userNameColor);
-			user_name->appendText("  - " + av_name.mUsername, FALSE, style_params_name);
+			user_name->appendText("  - " + av_name.getUserName(), FALSE, style_params_name);
 		}
-		setToolTip( av_name.mUsername );
+		setToolTip( av_name.getUserName() );
 		// name might have changed, update width
 		updateMinUserNameWidth();
 	}
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp
index 728b1a3f4c..76c422f34d 100644
--- a/indra/newview/llconversationmodel.cpp
+++ b/indra/newview/llconversationmodel.cpp
@@ -443,8 +443,8 @@ void LLConversationItemParticipant::buildContextMenu(LLMenuGL& menu, U32 flags)
 
 void LLConversationItemParticipant::onAvatarNameCache(const LLAvatarName& av_name)
 {
-	mName = (av_name.mUsername.empty() ? av_name.mDisplayName : av_name.mUsername);
-	mDisplayName = (av_name.mDisplayName.empty() ? av_name.mUsername : av_name.mDisplayName);
+	mName = av_name.getUserName();
+	mDisplayName = av_name.getDisplayName();
 	mNeedsRefresh = true;
 	if(mParent != NULL)
 	{
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index c68577db75..ff0e01a200 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -1520,8 +1520,8 @@ void LLFavoritesOrderStorage::saveFavoritesSLURLs()
 
 	LLAvatarName av_name;
 	LLAvatarNameCache::get( gAgentID, &av_name );
-	lldebugs << "Saved favorites for " << av_name.getLegacyName() << llendl;
-	fav_llsd[av_name.getLegacyName()] = user_llsd;
+	lldebugs << "Saved favorites for " << av_name.getUserName() << llendl;
+	fav_llsd[av_name.getUserName()] = user_llsd;
 
 	llofstream file;
 	file.open(filename);
@@ -1539,10 +1539,10 @@ void LLFavoritesOrderStorage::removeFavoritesRecordOfUser()
 
 	LLAvatarName av_name;
 	LLAvatarNameCache::get( gAgentID, &av_name );
-	lldebugs << "Removed favorites for " << av_name.getLegacyName() << llendl;
-	if (fav_llsd.has(av_name.getLegacyName()))
+	lldebugs << "Removed favorites for " << av_name.getUserName() << llendl;
+	if (fav_llsd.has(av_name.getUserName()))
 	{
-		fav_llsd.erase(av_name.getLegacyName());
+		fav_llsd.erase(av_name.getUserName());
 	}
 
 	llofstream out_file;
diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp
index 6ada809cdb..f7dd4a4a6b 100644
--- a/indra/newview/llfloateravatarpicker.cpp
+++ b/indra/newview/llfloateravatarpicker.cpp
@@ -307,9 +307,9 @@ void LLFloaterAvatarPicker::populateNearMe()
 		else
 		{
 			element["columns"][0]["column"] = "name";
-			element["columns"][0]["value"] = av_name.mDisplayName;
+			element["columns"][0]["value"] = av_name.getDisplayName();
 			element["columns"][1]["column"] = "username";
-			element["columns"][1]["value"] = av_name.mUsername;
+			element["columns"][1]["value"] = av_name.getUserName();
 
 			sAvatarNameMap[av] = av_name;
 		}
@@ -505,9 +505,7 @@ void LLFloaterAvatarPicker::find()
 	LLViewerRegion* region = gAgent.getRegion();
 	url = region->getCapability("AvatarPickerSearch");
 	// Prefer use of capabilities to search on both SLID and display name
-	// but allow display name search to be manually turned off for test
-	if (!url.empty()
-		&& LLAvatarNameCache::useDisplayNames())
+	if (!url.empty())
 	{
 		// capability urls don't end in '/', but we need one to parse
 		// query parameters correctly
@@ -679,9 +677,7 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void*
 				found_one = TRUE;
 
 				LLAvatarName av_name;
-				av_name.mLegacyFirstName = first_name;
-				av_name.mLegacyLastName = last_name;
-				av_name.mDisplayName = avatar_name;
+				av_name.fromString(avatar_name);
 				const LLUUID& agent_id = avatar_id;
 				sAvatarNameMap[agent_id] = av_name;
 
diff --git a/indra/newview/llfloaterdisplayname.cpp b/indra/newview/llfloaterdisplayname.cpp
index ac8f107928..be1ee77152 100644
--- a/indra/newview/llfloaterdisplayname.cpp
+++ b/indra/newview/llfloaterdisplayname.cpp
@@ -164,10 +164,9 @@ void LLFloaterDisplayName::onCancel()
 
 void LLFloaterDisplayName::onReset()
 {
-	if (LLAvatarNameCache::useDisplayNames())
+	if (LLAvatarNameCache::hasNameLookupURL())
 	{
-		LLViewerDisplayName::set("",
-			boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3));
+		LLViewerDisplayName::set("",boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3));
 	}	
 	else
 	{
@@ -199,10 +198,9 @@ void LLFloaterDisplayName::onSave()
 		return;
 	}
 	
-	if (LLAvatarNameCache::useDisplayNames())
+	if (LLAvatarNameCache::hasNameLookupURL())
 	{
-		LLViewerDisplayName::set(display_name_utf8,
-			boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3));	
+		LLViewerDisplayName::set(display_name_utf8,boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3));	
 	}
 	else
 	{
diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index a20fce876c..24b0355fca 100644
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -545,7 +545,7 @@ void	LLFloaterIMNearbyChat::addMessage(const LLChat& chat,bool archive,const LLS
 			LLAvatarName av_name;
 			LLAvatarNameCache::get(chat.mFromID, &av_name);
 
-			if (!av_name.mIsDisplayNameDefault)
+			if (!av_name.isDisplayNameDefault())
 			{
 				from_name = av_name.getCompleteName();
 			}
diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp
index a50907601c..8d8bba7b17 100644
--- a/indra/newview/llfloaterscriptlimits.cpp
+++ b/indra/newview/llfloaterscriptlimits.cpp
@@ -602,15 +602,7 @@ void LLPanelScriptLimitsRegionMemory::onNameCache(
 		return;
 	}
 	
-	std::string name;
-	if (LLAvatarNameCache::useDisplayNames())
-	{
-		name = LLCacheName::buildUsername(full_name);
-	}
-	else
-	{
-		name = full_name;
-	}
+	std::string name = LLCacheName::buildUsername(full_name);
 
 	std::vector<LLSD>::iterator id_itor;
 	for (id_itor = mObjectListItems.begin(); id_itor != mObjectListItems.end(); ++id_itor)
@@ -713,10 +705,7 @@ void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content)
 				else
 				{
 					name_is_cached = gCacheName->getFullName(owner_id, owner_buf);  // username
-					if (LLAvatarNameCache::useDisplayNames())
-					{
-						owner_buf = LLCacheName::buildUsername(owner_buf);
-					}
+					owner_buf = LLCacheName::buildUsername(owner_buf);
 				}
 				if(!name_is_cached)
 				{
diff --git a/indra/newview/llfloatersellland.cpp b/indra/newview/llfloatersellland.cpp
index 484ecbcd04..c97a6792f3 100644
--- a/indra/newview/llfloatersellland.cpp
+++ b/indra/newview/llfloatersellland.cpp
@@ -238,7 +238,7 @@ void LLFloaterSellLandUI::updateParcelInfo()
 void LLFloaterSellLandUI::onBuyerNameCache(const LLAvatarName& av_name)
 {
 	getChild<LLUICtrl>("sell_to_agent")->setValue(av_name.getCompleteName());
-	getChild<LLUICtrl>("sell_to_agent")->setToolTip(av_name.mUsername);
+	getChild<LLUICtrl>("sell_to_agent")->setToolTip(av_name.getUserName());
 }
 
 void LLFloaterSellLandUI::setBadge(const char* id, Badge badge)
diff --git a/indra/newview/llfloatertopobjects.cpp b/indra/newview/llfloatertopobjects.cpp
index 2d91a61b54..7530c72dd2 100644
--- a/indra/newview/llfloatertopobjects.cpp
+++ b/indra/newview/llfloatertopobjects.cpp
@@ -199,17 +199,9 @@ void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data)
 		// Owner names can have trailing spaces sent from server
 		LLStringUtil::trim(owner_buf);
 		
-		if (LLAvatarNameCache::useDisplayNames())
-		{
-			// ...convert hard-coded name from server to a username
-			// *TODO: Send owner_id from server and look up display name
-			owner_buf = LLCacheName::buildUsername(owner_buf);
-		}
-		else
-		{
-			// ...just strip out legacy "Resident" name
-			owner_buf = LLCacheName::cleanFullName(owner_buf);
-		}
+		// *TODO: Send owner_id from server and look up display name
+		owner_buf = LLCacheName::buildUsername(owner_buf);
+
 		columns[column_num]["column"] = "owner";
 		columns[column_num]["value"] = owner_buf;
 		columns[column_num++]["font"] = "SANSSERIF";
diff --git a/indra/newview/llfloatervoicevolume.cpp b/indra/newview/llfloatervoicevolume.cpp
index 87b388b30a..a1df73a065 100644
--- a/indra/newview/llfloatervoicevolume.cpp
+++ b/indra/newview/llfloatervoicevolume.cpp
@@ -151,7 +151,7 @@ void LLFloaterVoiceVolume::updateVolumeControls()
 
 		// By convention, we only display and toggle voice mutes, not all mutes
 		bool is_muted = LLAvatarActions::isVoiceMuted(mAvatarID);
-		bool is_linden = LLStringUtil::endsWith(mAvatarName.getLegacyName(), " Linden");
+		bool is_linden = LLStringUtil::endsWith(mAvatarName.getUserName(), " Linden");
 
 		mute_btn->setEnabled(!is_linden);
 		mute_btn->setValue(is_muted);
diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp
index a64ddd185d..0e72fab32c 100644
--- a/indra/newview/llfriendcard.cpp
+++ b/indra/newview/llfriendcard.cpp
@@ -533,7 +533,7 @@ void LLFriendCardsManager::addFriendCardToInventory(const LLUUID& avatarID)
 	bool shouldBeAdded = true;
 	LLAvatarName av_name;
 	LLAvatarNameCache::get(avatarID, &av_name);
-	const std::string& name = av_name.mUsername;
+	const std::string& name = av_name.getUserName();
 
 	lldebugs << "Processing buddy name: " << name 
 		<< ", id: " << avatarID
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index e5dda7e8d8..0de8f124ee 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -306,7 +306,7 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string&
 
 void LLIMModel::LLIMSession::onAdHocNameCache(const LLAvatarName& av_name)
 {
-	if (av_name.mIsTemporaryName)
+	if (!av_name.isValidName())
 	{
 		S32 separator_index = mName.rfind(" ");
 		std::string name = mName.substr(0, separator_index);
@@ -626,15 +626,7 @@ void LLIMModel::LLIMSession::buildHistoryFileName()
 		// so no need for a callback in LLAvatarNameCache::get()
 		if (LLAvatarNameCache::get(mOtherParticipantID, &av_name))
 		{
-			if (av_name.mUsername.empty())
-			{
-				// Display names are off, use mDisplayName which will be the legacy name
-				mHistoryFileName = LLCacheName::buildUsername(av_name.mDisplayName);
-			}
-			else
-			{
-				mHistoryFileName =  av_name.mUsername;
-			}
+			mHistoryFileName = LLCacheName::buildUsername(av_name.getUserName());
 		}
 		else
 		{
@@ -836,7 +828,7 @@ bool LLIMModel::logToFile(const std::string& file_name, const std::string& from,
 		LLAvatarName av_name;
 		if (!from_id.isNull() && 
 			LLAvatarNameCache::get(from_id, &av_name) &&
-			!av_name.mIsDisplayNameDefault)
+			!av_name.isDisplayNameDefault())
 		{	
 			from_name = av_name.getCompleteName();
 		}
@@ -1926,7 +1918,7 @@ void LLOutgoingCallDialog::show(const LLSD& key)
 		LLAvatarName av_name;
 		if (LLAvatarNameCache::get(callee_id, &av_name))
 		{
-			final_callee_name = av_name.mDisplayName;
+			final_callee_name = av_name.getDisplayName();
 			title = av_name.getCompleteName();
 		}
 	}
@@ -2464,7 +2456,7 @@ void LLIMMgr::addMessage(
 		LLAvatarName av_name;
 		if (LLAvatarNameCache::get(other_participant_id, &av_name) && !name_is_setted)
 		{
-			fixed_session_name = (av_name.mDisplayName.empty() ? av_name.mUsername : av_name.mDisplayName);
+			fixed_session_name = av_name.getDisplayName();
 		}
 		LLIMModel::getInstance()->newSession(new_session_id, fixed_session_name, dialog, other_participant_id, false, is_offline_msg);
 
@@ -3110,7 +3102,7 @@ void LLIMMgr::noteOfflineUsers(
 			{
 				LLUIString offline = LLTrans::getString("offline_message");
 				// Use display name only because this user is your friend
-				offline.setArg("[NAME]", av_name.mDisplayName);
+				offline.setArg("[NAME]", av_name.getDisplayName());
 				im_model.proccessOnlineOfflineNotification(session_id, offline);
 			}
 		}
diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp
index 8a15cd279f..3507b729be 100644
--- a/indra/newview/llinspectavatar.cpp
+++ b/indra/newview/llinspectavatar.cpp
@@ -263,9 +263,9 @@ void LLInspectAvatar::onAvatarNameCache(
 {
 	if (agent_id == mAvatarID)
 	{
-		getChild<LLUICtrl>("user_name")->setValue(av_name.mDisplayName);
-		getChild<LLUICtrl>("user_name_small")->setValue(av_name.mDisplayName);
-		getChild<LLUICtrl>("user_slid")->setValue(av_name.mUsername);
+		getChild<LLUICtrl>("user_name")->setValue(av_name.getDisplayName());
+		getChild<LLUICtrl>("user_name_small")->setValue(av_name.getDisplayName());
+		getChild<LLUICtrl>("user_slid")->setValue(av_name.getUserName());
 		mAvatarName = av_name;
 		
 		// show smaller display name if too long to display in regular size
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 73631f4ba8..bad4e8c231 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -4712,10 +4712,9 @@ void LLCallingCardBridge::performAction(LLInventoryModel* model, std::string act
 			gCacheName->getFullName(item->getCreatorUUID(), callingcard_name);
 			// IDEVO
 			LLAvatarName av_name;
-			if (LLAvatarNameCache::useDisplayNames()
-				&& LLAvatarNameCache::get(item->getCreatorUUID(), &av_name))
+			if (LLAvatarNameCache::get(item->getCreatorUUID(), &av_name))
 			{
-				callingcard_name = av_name.mDisplayName + " (" + av_name.mUsername + ")";
+				callingcard_name = av_name.getCompleteName();
 			}
 			LLUUID session_id = gIMMgr->addSession(callingcard_name, IM_NOTHING_SPECIAL, item->getCreatorUUID());
 			if (session_id != LLUUID::null)
diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp
index b0fbad33b0..855007e403 100644
--- a/indra/newview/llnamelistctrl.cpp
+++ b/indra/newview/llnamelistctrl.cpp
@@ -320,7 +320,7 @@ LLScrollListItem* LLNameListCtrl::addNameItemRow(
 			else if (LLAvatarNameCache::get(id, &av_name))
 			{
 				if (mShortNames)
-					fullname = av_name.mDisplayName;
+					fullname = av_name.getDisplayName();
 				else
 					fullname = av_name.getCompleteName();
 			}
@@ -390,7 +390,7 @@ void LLNameListCtrl::onAvatarNameCache(const LLUUID& agent_id,
 {
 	std::string name;
 	if (mShortNames)
-		name = av_name.mDisplayName;
+		name = av_name.getDisplayName();
 	else
 		name = av_name.getCompleteName();
 
diff --git a/indra/newview/llpanelblockedlist.cpp b/indra/newview/llpanelblockedlist.cpp
index 7612af8f5e..b4deb7a920 100644
--- a/indra/newview/llpanelblockedlist.cpp
+++ b/indra/newview/llpanelblockedlist.cpp
@@ -224,7 +224,7 @@ void LLPanelBlockedList::onFilterEdit(const std::string& search_string)
 void LLPanelBlockedList::callbackBlockPicked(const uuid_vec_t& ids, const std::vector<LLAvatarName> names)
 {
 	if (names.empty() || ids.empty()) return;
-	LLMute mute(ids[0], names[0].getLegacyName(), LLMute::AGENT);
+	LLMute mute(ids[0], names[0].getUserName(), LLMute::AGENT);
 	LLMuteList::getInstance()->add(mute);
 	showPanelAndSelect(mute.mID);
 }
diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp
index 7efeb77e23..a2bbc5400c 100644
--- a/indra/newview/llpanelgroupinvite.cpp
+++ b/indra/newview/llpanelgroupinvite.cpp
@@ -482,7 +482,7 @@ void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids)
 				}
 				else
 				{
-					names.push_back(av_name.getLegacyName());
+					names.push_back(av_name.getUserName());
 				}
 			}
 		}
@@ -495,7 +495,7 @@ void LLPanelGroupInvite::addUserCallback(const LLUUID& id, const LLAvatarName& a
 	std::vector<std::string> names;
 	uuid_vec_t agent_ids;
 	agent_ids.push_back(id);
-	names.push_back(av_name.getLegacyName());
+	names.push_back(av_name.getUserName());
 
 	mImplementation->addUsers(names, agent_ids);
 }
diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp
index 31c0e3d01a..93b108efcc 100644
--- a/indra/newview/llpanelgroupnotices.cpp
+++ b/indra/newview/llpanelgroupnotices.cpp
@@ -543,10 +543,7 @@ void LLPanelGroupNotices::processNotices(LLMessageSystem* msg)
 		msg->getU32("Data","Timestamp",timestamp,i);
 
 		// we only have the legacy name here, convert it to a username
-		if (LLAvatarNameCache::useDisplayNames())
-		{
-			name = LLCacheName::buildUsername(name);
-		}
+		name = LLCacheName::buildUsername(name);
 
 		LLSD row;
 		row["id"] = id;
diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp
index 5720168f81..7ad7e7149b 100644
--- a/indra/newview/llpanelgrouproles.cpp
+++ b/indra/newview/llpanelgrouproles.cpp
@@ -1616,7 +1616,7 @@ void LLPanelGroupMembersSubTab::onNameCache(const LLUUID& update_id, LLGroupMemb
 	}
 	
 	// trying to avoid unnecessary hash lookups
-	if (matchesSearchFilter(av_name.getLegacyName()))
+	if (matchesSearchFilter(av_name.getUserName()))
 	{
 		addMemberToList(id, member);
 		if(!mMembersList->getEnabled())
@@ -1670,7 +1670,7 @@ void LLPanelGroupMembersSubTab::updateMembers()
 		LLAvatarName av_name;
 		if (LLAvatarNameCache::get(mMemberProgress->first, &av_name))
 		{
-			if (matchesSearchFilter(av_name.getLegacyName()))
+			if (matchesSearchFilter(av_name.getUserName()))
 			{
 				addMemberToList(mMemberProgress->first, mMemberProgress->second);
 			}
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp
index 6c838f8a45..c53760bca1 100644
--- a/indra/newview/llparticipantlist.cpp
+++ b/indra/newview/llparticipantlist.cpp
@@ -381,7 +381,7 @@ void LLParticipantList::addAvatarIDExceptAgent(const LLUUID& avatar_id)
 		// Create a participant view model instance
 		LLAvatarName avatar_name;
 		bool has_name = LLAvatarNameCache::get(avatar_id, &avatar_name);
-		participant = new LLConversationItemParticipant(!has_name ? LLTrans::getString("AvatarNameWaiting") : avatar_name.mDisplayName , avatar_id, mRootViewModel);
+		participant = new LLConversationItemParticipant(!has_name ? LLTrans::getString("AvatarNameWaiting") : avatar_name.getDisplayName() , avatar_id, mRootViewModel);
 		participant->fetchAvatarName();
 	}
 	else
diff --git a/indra/newview/lltoastgroupnotifypanel.cpp b/indra/newview/lltoastgroupnotifypanel.cpp
index ed350ea144..4dc0d424ac 100644
--- a/indra/newview/lltoastgroupnotifypanel.cpp
+++ b/indra/newview/lltoastgroupnotifypanel.cpp
@@ -69,10 +69,8 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(const LLNotificationPtr& notifi
 
 	//header title
 	std::string from_name = payload["sender_name"].asString();
-	if (LLAvatarNameCache::useDisplayNames())
-	{
-		from_name = LLCacheName::buildUsername(from_name);
-	}
+	from_name = LLCacheName::buildUsername(from_name);
+
 	std::stringstream from;
 	from << from_name << "/" << groupData.mName;
 	LLTextBox* pTitleText = getChild<LLTextBox>("title");
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index 3cd761b73b..c81f6ace70 100644
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -991,8 +991,7 @@ BOOL LLToolPie::handleTooltipObject( LLViewerObject* hover_object, std::string l
 			}
 
 			LLAvatarName av_name;
-			if (LLAvatarNameCache::useDisplayNames() && 
-				LLAvatarNameCache::get(hover_object->getID(), &av_name))
+			if (LLAvatarNameCache::get(hover_object->getID(), &av_name))
 			{
 				final_name = av_name.getCompleteName();
 			}
diff --git a/indra/newview/llviewerdisplayname.cpp b/indra/newview/llviewerdisplayname.cpp
index 5741fab29a..4bd38562bc 100644
--- a/indra/newview/llviewerdisplayname.cpp
+++ b/indra/newview/llviewerdisplayname.cpp
@@ -97,7 +97,7 @@ void LLViewerDisplayName::set(const std::string& display_name, const set_name_sl
 
 	// People API expects array of [ "old value", "new value" ]
 	LLSD change_array = LLSD::emptyArray();
-	change_array.append(av_name.mDisplayName);
+	change_array.append(av_name.getDisplayName());
 	change_array.append(display_name);
 	
 	llinfos << "Set name POST to " << cap_url << llendl;
@@ -189,8 +189,8 @@ class LLDisplayNameUpdate : public LLHTTPNode
 
 		LLSD args;
 		args["OLD_NAME"] = old_display_name;
-		args["SLID"] = av_name.mUsername;
-		args["NEW_NAME"] = av_name.mDisplayName;
+		args["SLID"] = av_name.getUserName();
+		args["NEW_NAME"] = av_name.getDisplayName();
 		LLNotificationsUtil::add("DisplayNameUpdate", args);
 		if (agent_id == gAgent.getID())
 		{
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 511807ec2f..5284d2650e 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -8080,11 +8080,7 @@ class LLWorldPostProcess : public view_listener_t
 
 void handle_flush_name_caches()
 {
-	// Toggle display names on and off to flush
-	bool use_display_names = LLAvatarNameCache::useDisplayNames();
-	LLAvatarNameCache::setUseDisplayNames(!use_display_names);
-	LLAvatarNameCache::setUseDisplayNames(use_display_names);
-
+	LLAvatarNameCache::flushCache();
 	if (gCacheName) gCacheName->clear();
 }
 
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index dc8192105f..6397ef7961 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -2245,16 +2245,7 @@ static std::string clean_name_from_task_im(const std::string& msg,
 		// Don't try to clean up group names
 		if (!from_group)
 		{
-			if (LLAvatarNameCache::useDisplayNames())
-			{
-				// ...just convert to username
-				final += LLCacheName::buildUsername(name);
-			}
-			else
-			{
-				// ...strip out legacy "Resident" name
-				final += LLCacheName::cleanFullName(name);
-			}
+			final += LLCacheName::buildUsername(name);
 		}
 		final += match[3].str();
 		return final;
@@ -2268,7 +2259,7 @@ void notification_display_name_callback(const LLUUID& id,
 					  LLSD& substitutions, 
 					  const LLSD& payload)
 {
-	substitutions["NAME"] = av_name.mDisplayName;
+	substitutions["NAME"] = av_name.getDisplayName();
 	LLNotificationsUtil::add(name, substitutions, payload);
 }
 
@@ -3452,7 +3443,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
 		LLAvatarName av_name;
 		if (LLAvatarNameCache::get(from_id, &av_name))
 		{
-			chat.mFromName = av_name.mDisplayName;
+			chat.mFromName = av_name.getDisplayName();
 		}
 		else
 		{
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 220c4ef59a..7cc4e3ed04 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3188,29 +3188,27 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name)
 		static LLUICachedControl<bool> show_display_names("NameTagShowDisplayNames");
 		static LLUICachedControl<bool> show_usernames("NameTagShowUsernames");
 
-		if (LLAvatarNameCache::useDisplayNames())
+		if (LLAvatarName::useDisplayNames())
 		{
 			LLAvatarName av_name;
 			if (!LLAvatarNameCache::get(getID(), &av_name))
 			{
-				// ...call this function back when the name arrives
-				// and force a rebuild
-				LLAvatarNameCache::get(getID(),
-					boost::bind(&LLVOAvatar::clearNameTag, this));
+				// ...call this function back when the name arrives and force a rebuild
+				LLAvatarNameCache::get(getID(),boost::bind(&LLVOAvatar::clearNameTag, this));
 			}
 
 			// Might be blank if name not available yet, that's OK
 			if (show_display_names)
 			{
-				addNameTagLine(av_name.mDisplayName, name_tag_color, LLFontGL::NORMAL,
+				addNameTagLine(av_name.getDisplayName(), name_tag_color, LLFontGL::NORMAL,
 					LLFontGL::getFontSansSerif());
 			}
 			// Suppress SLID display if display name matches exactly (ugh)
-			if (show_usernames && !av_name.mIsDisplayNameDefault)
+			if (show_usernames && !av_name.isDisplayNameDefault())
 			{
 				// *HACK: Desaturate the color
 				LLColor4 username_color = name_tag_color * 0.83f;
-				addNameTagLine(av_name.mUsername, username_color, LLFontGL::NORMAL,
+				addNameTagLine(av_name.getUserName(), username_color, LLFontGL::NORMAL,
 					LLFontGL::getFontSansSerifSmall());
 			}
 		}
@@ -3421,20 +3419,18 @@ LLColor4 LLVOAvatar::getNameTagColor(bool is_friend)
 	{
 		color_name = "NameTagFriend";
 	}
-	else if (LLAvatarNameCache::useDisplayNames())
+	else if (LLAvatarName::useDisplayNames())
 	{
-		// ...color based on whether username "matches" a computed display
-		// name
+		// ...color based on whether username "matches" a computed display name
 		LLAvatarName av_name;
-		if (LLAvatarNameCache::get(getID(), &av_name)
-			&& av_name.mIsDisplayNameDefault)
+		if (LLAvatarNameCache::get(getID(), &av_name) && av_name.isDisplayNameDefault())
 		{
 			color_name = "NameTagMatch";
 		}
 		else
 		{
 			color_name = "NameTagMismatch";
-	}
+		}
 	}
 	else
 	{
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index 37491e5b58..6fdda12a1c 100644
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -2668,7 +2668,7 @@ void LLVivoxVoiceClient::checkFriend(const LLUUID& id)
 		// *NOTE: For now, we feed legacy names to Vivox because I don't know
 		// if their service can support a mix of new and old clients with
 		// different sorts of names.
-		std::string name = av_name.getLegacyName();
+		std::string name = av_name.getUserName();
 
 		const LLRelationship* relationInfo = LLAvatarTracker::instance().getBuddyInfo(id);
 		bool canSeeMeOnline = false;
@@ -6200,7 +6200,7 @@ void LLVivoxVoiceClient::lookupName(const LLUUID &id)
 void LLVivoxVoiceClient::onAvatarNameCache(const LLUUID& agent_id,
 										   const LLAvatarName& av_name)
 {
-	std::string display_name = av_name.mDisplayName;
+	std::string display_name = av_name.getDisplayName();
 	avatarNameResolved(agent_id, display_name);
 }
 
-- 
cgit v1.2.3