diff --git a/indra/llcommon/llavatarname.cpp b/indra/llcommon/llavatarname.cpp index d50eca6792..2b9fb45e65 100755 --- a/indra/llcommon/llavatarname.cpp +++ b/indra/llcommon/llavatarname.cpp @@ -45,7 +45,7 @@ static const std::string DISPLAY_NAME_NEXT_UPDATE("display_name_next_update"); bool LLAvatarName::sUseDisplayNames = true; bool LLAvatarName::sUseLegacyNameFormat = false; // Legacy name option -bool LLAvatarName::sTrimResidentSurname = true; // Trim "Resident" from legacy name +bool LLAvatarName::sTrimResidentSurname = true; // FIRE-6659 - Trim "Resident" from legacy name // Minimum time-to-live (in seconds) for a name entry. // Avatar name should always guarantee to expire reasonably soon by default @@ -126,7 +126,10 @@ void LLAvatarName::fromString(const std::string& full_name) // The name is in 2 parts (first last) mLegacyFirstName = full_name.substr(0, index); mLegacyLastName = full_name.substr(index+1); - if (mLegacyLastName != "Resident") + // FIRE-6659 - Trim "Resident" from legacy name + //if (mLegacyLastName != "Resident") + if ((mLegacyLastName != "Resident") && sTrimResidentSurname) + // { mUsername = mLegacyFirstName + "." + mLegacyLastName; mDisplayName = full_name; @@ -172,8 +175,10 @@ std::string LLAvatarName::getCompleteName() const else if (sUseLegacyNameFormat) { // FIRE-6659 - if ((sTrimResidentSurname && mLegacyLastName == "Resident") || mLegacyLastName.empty()) + if (sTrimResidentSurname && (mLegacyLastName == "Resident" || mLegacyLastName.empty())) name = mDisplayName + " (" + mLegacyFirstName + ")"; + else if (mLegacyLastName.empty() && !sTrimResidentSurname) + name = mDisplayName + " (" + mLegacyLastName + " Resident)"; else name = mDisplayName + " (" + mLegacyFirstName + " " + mLegacyLastName + ")"; } @@ -185,7 +190,10 @@ std::string LLAvatarName::getCompleteName() const } else { - name = getUserName(); + // FIRE-6659 - Trim "Resident" from legacy name + //return getUserName(); + return getUserNameForDisplay(); + // } return name; } @@ -213,7 +221,10 @@ std::string LLAvatarName::getDisplayName() const } else { - return getUserName(); + // FIRE-6659 - Trim "Resident" from legacy name + //return getUserName(); + return getUserNameForDisplay(); + // } } @@ -240,6 +251,32 @@ std::string LLAvatarName::getUserName() const return name; } +// Returns the same as getUserName() but honors sTrimResidentSurname +std::string LLAvatarName::getUserNameForDisplay() const +{ + std::string name; + if (mLegacyFirstName.empty() && mLegacyLastName.empty()) + { + // If we cannot create a user name from the legacy strings, use the display name + name = mDisplayName; + } + else if ((mLegacyLastName.empty() || (mLegacyLastName == "Resident")) && sTrimResidentSurname) + { + // The last name might be empty if it defaulted to "Resident" + name = mLegacyFirstName; + } + else if (mLegacyLastName.empty() && !sTrimResidentSurname) + { + name = mLegacyFirstName + " Resident"; + } + else + { + name = mLegacyFirstName + " " + mLegacyLastName; + } + return name; +} +// + void LLAvatarName::dump() const { LL_DEBUGS("AvNameCache") << "LLAvatarName: " diff --git a/indra/llcommon/llavatarname.h b/indra/llcommon/llavatarname.h index 89a222bb88..3fbcc6833b 100755 --- a/indra/llcommon/llavatarname.h +++ b/indra/llcommon/llavatarname.h @@ -87,6 +87,9 @@ public: // Also used for backwards compatibility with systems like voice and muting std::string getUserName() const; + // FIRE-6659 - Returns the same as getUserName() but honors sTrimResidentSurname + std::string getUserNameForDisplay() const; + // Returns "james.linden" or the legacy name for very old names std::string getAccountName() const { return mUsername; } diff --git a/indra/newview/fschathistory.cpp b/indra/newview/fschathistory.cpp index 0352d63591..2db5c793a2 100644 --- a/indra/newview/fschathistory.cpp +++ b/indra/newview/fschathistory.cpp @@ -684,7 +684,7 @@ private: style_params_name.font.name("SansSerifSmall"); style_params_name.font.style("NORMAL"); style_params_name.readonly_color(userNameColor); - user_name->appendText(" - " + av_name.getUserName(), false, style_params_name); + user_name->appendText(" - " + av_name.getUserNameForDisplay(), false, style_params_name); } setToolTip( av_name.getUserName() ); // name might have changed, update width diff --git a/indra/newview/fsconsoleutils.cpp b/indra/newview/fsconsoleutils.cpp index 4257829b38..97cfa3232e 100644 --- a/indra/newview/fsconsoleutils.cpp +++ b/indra/newview/fsconsoleutils.cpp @@ -258,7 +258,7 @@ void FSConsoleUtils::onProccessInstantMessageNameLookup(const LLUUID& agent_id, } else { - senderName = av_name.getLegacyName(); + senderName = av_name.getUserNameForDisplay(); } if (rlv_handler_t::isEnabled() && gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) diff --git a/indra/newview/fscontactsfloater.cpp b/indra/newview/fscontactsfloater.cpp index 94340329e9..2a6e4b7047 100644 --- a/indra/newview/fscontactsfloater.cpp +++ b/indra/newview/fscontactsfloater.cpp @@ -586,7 +586,7 @@ void FSFloaterContacts::addFriend(const LLUUID& agent_id) element["id"] = agent_id; LLSD& username_column = element["columns"][LIST_FRIEND_USER_NAME]; username_column["column"] = "user_name"; - username_column["value"] = av_name.getUserName(); + username_column["value"] = av_name.getUserNameForDisplay(); LLSD& friend_column = element["columns"][LIST_FRIEND_NAME]; friend_column["column"] = "full_name"; @@ -674,7 +674,7 @@ void FSFloaterContacts::updateFriendItem(const LLUUID& agent_id, const LLRelatio itemp->getColumn(LIST_ONLINE_STATUS)->setValue(statusIcon); - itemp->getColumn(LIST_FRIEND_USER_NAME)->setValue( av_name.getUserName() ); + itemp->getColumn(LIST_FRIEND_USER_NAME)->setValue( av_name.getUserNameForDisplay() ); itemp->getColumn(LIST_FRIEND_NAME)->setValue( av_name.getCompleteName() ); // render name of online friends in bold text diff --git a/indra/newview/fsfloaterim.cpp b/indra/newview/fsfloaterim.cpp index 489535affe..2d9a6019b9 100644 --- a/indra/newview/fsfloaterim.cpp +++ b/indra/newview/fsfloaterim.cpp @@ -904,7 +904,7 @@ void FSFloaterIM::onAvatarNameCache(const LLUUID& agent_id, break; // Username case 1: - name = av_name.getUserName(); + name = av_name.getUserNameForDisplay(); break; // Display name (username) case 2: @@ -914,11 +914,11 @@ void FSFloaterIM::onAvatarNameCache(const LLUUID& agent_id, case 3: if (av_name.isDisplayNameDefault()) { - name = av_name.getUserName(); + name = av_name.getUserNameForDisplay(); } else { - name = av_name.getUserName() + " (" + av_name.getDisplayName() + ")"; + name = av_name.getUserNameForDisplay() + " (" + av_name.getDisplayName() + ")"; } break; default: diff --git a/indra/newview/fsradarentry.cpp b/indra/newview/fsradarentry.cpp index 99683951a6..33d4f6e9e2 100644 --- a/indra/newview/fsradarentry.cpp +++ b/indra/newview/fsradarentry.cpp @@ -89,7 +89,7 @@ void FSRadarEntry::onAvatarNameCache(const LLUUID& av_id, const LLAvatarName& av { if (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) { - mUserName = av_name.getUserName(); + mUserName = av_name.getUserNameForDisplay(); mDisplayName = av_name.getDisplayName(); mName = getRadarName(av_name); mIsLinden = FSCommon::isLinden(av_id); @@ -134,7 +134,7 @@ std::string FSRadarEntry::getRadarName(const LLAvatarName& av_name) } else if (fmt == FSRADAR_NAMEFORMAT_USERNAME) { - return av_name.getUserName(); + return av_name.getUserNameForDisplay(); } else if (fmt == FSRADAR_NAMEFORMAT_DISPLAYNAME_USERNAME) { @@ -144,7 +144,7 @@ std::string FSRadarEntry::getRadarName(const LLAvatarName& av_name) } else { - return llformat("%s (%s)", av_name.getDisplayName().c_str(), av_name.getUserName().c_str()); + return llformat("%s (%s)", av_name.getDisplayName().c_str(), av_name.getUserNameForDisplay().c_str()); } } else if (fmt == FSRADAR_NAMEFORMAT_USERNAME_DISPLAYNAME) @@ -155,7 +155,7 @@ std::string FSRadarEntry::getRadarName(const LLAvatarName& av_name) } else { - return llformat("%s (%s)", av_name.getUserName().c_str(), av_name.getDisplayName().c_str()); + return llformat("%s (%s)", av_name.getUserNameForDisplay().c_str(), av_name.getDisplayName().c_str()); } } } diff --git a/indra/newview/lggcontactsetsfloater.cpp b/indra/newview/lggcontactsetsfloater.cpp index 920e966a74..cc433761be 100644 --- a/indra/newview/lggcontactsetsfloater.cpp +++ b/indra/newview/lggcontactsetsfloater.cpp @@ -512,7 +512,7 @@ void lggContactSetsFloater::drawRightClick() LLAvatarName avatar_name; if (LLAvatarNameCache::get(selected[0], &avatar_name)) { - avName=avatar_name.getLegacyName(); + avName = avatar_name.getUserNameForDisplay(); } LLColor4 friendColor = LGGContactSets::getInstance()->getFriendColor(selected[0], ""); @@ -1864,10 +1864,18 @@ void lggContactSetsFloater::draw() switch (sPhoenixNameSystem()) { - case 0 : fullname = avatar_name.getLegacyName(); break; - case 1 : fullname = (avatar_name.isDisplayNameDefault() ? avatar_name.getDisplayName() : avatar_name.getCompleteName()); break; - case 2 : fullname = avatar_name.getDisplayName(); break; - default : fullname = avatar_name.getCompleteName(); break; + case 0 : + fullname = avatar_name.getUserNameForDisplay(); + break; + case 1 : + fullname = (avatar_name.isDisplayNameDefault() ? avatar_name.getDisplayName() : avatar_name.getCompleteName()); + break; + case 2 : + fullname = avatar_name.getDisplayName(); + break; + default : + fullname = avatar_name.getCompleteName(); + break; } text += fullname; @@ -2233,10 +2241,18 @@ BOOL lggContactSetsFloater::compareAv(LLUUID av1, LLUUID av2) std::string fullname; switch (sPhoenixNameSystem()) { - case 0 : fullname = avatar_name.getLegacyName(); break; - case 1 : fullname = (avatar_name.isDisplayNameDefault() ? avatar_name.getDisplayName() : avatar_name.getCompleteName()); break; - case 2 : fullname = avatar_name.getDisplayName(); break; - default : fullname = avatar_name.getCompleteName(); break; + case 0 : + fullname = avatar_name.getUserNameForDisplay(); + break; + case 1 : + fullname = (avatar_name.isDisplayNameDefault() ? avatar_name.getDisplayName() : avatar_name.getCompleteName()); + break; + case 2 : + fullname = avatar_name.getDisplayName(); + break; + default : + fullname = avatar_name.getCompleteName(); + break; } avN1 = fullname; @@ -2246,10 +2262,18 @@ BOOL lggContactSetsFloater::compareAv(LLUUID av1, LLUUID av2) std::string fullname; switch (sPhoenixNameSystem()) { - case 0 : fullname = avatar_name.getLegacyName(); break; - case 1 : fullname = (avatar_name.isDisplayNameDefault() ? avatar_name.getDisplayName() : avatar_name.getCompleteName()); break; - case 2 : fullname = avatar_name.getDisplayName(); break; - default : fullname = avatar_name.getCompleteName(); break; + case 0 : + fullname = avatar_name.getUserNameForDisplay(); + break; + case 1 : + fullname = (avatar_name.isDisplayNameDefault() ? avatar_name.getDisplayName() : avatar_name.getCompleteName()); + break; + case 2 : + fullname = avatar_name.getDisplayName(); + break; + default : + fullname = avatar_name.getCompleteName(); + break; } avN2 = fullname; @@ -2328,10 +2352,18 @@ BOOL lggContactSetsFloater::generateCurrentList() static LLCachedControl sPhoenixNameSystem(gSavedSettings, "FSContactSetsNameFormat"); switch (sPhoenixNameSystem()) { - case 0 : fullname = avatar_name.getLegacyName(); break; - case 1 : fullname = (avatar_name.isDisplayNameDefault() ? avatar_name.getDisplayName() : avatar_name.getCompleteName()); break; - case 2 : fullname = avatar_name.getDisplayName(); break; - default : fullname = avatar_name.getCompleteName(); break; + case 0 : + fullname = avatar_name.getUserNameForDisplay(); + break; + case 1 : + fullname = (avatar_name.isDisplayNameDefault() ? avatar_name.getDisplayName() : avatar_name.getCompleteName()); + break; + case 2 : + fullname = avatar_name.getDisplayName(); + break; + default : + fullname = avatar_name.getCompleteName(); + break; } avN = fullname; } diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 94ab56cdd0..feb6506b95 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -1955,7 +1955,7 @@ void LLAvatarActions::onDerenderAvatarNameLookup(const LLUUID& agent_id, const L { if (permanent) { - FSWSAssetBlacklist::getInstance()->addNewItemToBlacklist(agent_id, av_name.getLegacyName(), "", LLAssetType::AT_OBJECT); + FSWSAssetBlacklist::getInstance()->addNewItemToBlacklist(agent_id, av_name.getUserName(), "", LLAssetType::AT_OBJECT); } LLViewerObject* av_obj = gObjectList.findObject(agent_id); diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index bb985d8ef9..72aa220354 100755 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -834,7 +834,7 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id, } else { - args["NAME"] = av_name.getLegacyName(); + args["NAME"] = av_name.getUserNameForDisplay(); } args["STATUS"] = online ? LLTrans::getString("OnlineStatus") : LLTrans::getString("OfflineStatus"); diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp index 153c968040..2397d6fdc3 100755 --- a/indra/newview/llfavoritesbar.cpp +++ b/indra/newview/llfavoritesbar.cpp @@ -1580,7 +1580,7 @@ void LLFavoritesOrderStorage::saveFavoritesSLURLs() // FIRE-10122 - User@grid stored_favorites.xml //lldebugs << "Saved favorites for " << av_name.getUserName() << llendl; //fav_llsd[av_name.getUserName()] = user_llsd; - std::string name = av_name.getLegacyName() + " @ " + LLGridManager::getInstance()->getGridLabel(); + std::string name = av_name.getUserName() + " @ " + LLGridManager::getInstance()->getGridLabel(); LL_DEBUGS("Favorites") << "Saved favorites for " << name << LL_ENDL; fav_llsd[name] = user_llsd; // @@ -1610,7 +1610,7 @@ void LLFavoritesOrderStorage::removeFavoritesRecordOfUser() //{ // fav_llsd.erase(av_name.getUserName()); //} - std::string name = av_name.getLegacyName() + " @ " + LLGridManager::getInstance()->getGridLabel(); + std::string name = av_name.getUserName() + " @ " + LLGridManager::getInstance()->getGridLabel(); LL_DEBUGS("Favorites") << "Removed favorites for " << name << LL_ENDL; if (fav_llsd.has(name)) { diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp index 764e51a962..4514c84ac9 100755 --- a/indra/newview/llhudeffectlookat.cpp +++ b/indra/newview/llhudeffectlookat.cpp @@ -585,7 +585,7 @@ void LLHUDEffectLookAt::render() name = nameBuffer.getDisplayName(); break; case 3: // First Last - name = nameBuffer.getLegacyName(); + name = nameBuffer.getUserNameForDisplay(); break; default: //user.name name = nameBuffer.getAccountName(); diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index f61c86d296..44ddc48c50 100755 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -3617,7 +3617,7 @@ void LLIMMgr::noteOfflineUsers( } else { - offline.setArg("[NAME]", av_name.getLegacyName()); + offline.setArg("[NAME]", av_name.getUserNameForDisplay()); } im_model.proccessOnlineOfflineNotification(session_id, offline); } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 39c482f37d..01a36fa2f1 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2968,7 +2968,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) // // Show user name as legacy name if selected - std::string username( show_legacynames ? av_name.getLegacyName() : av_name.getAccountName() ); + std::string username( show_legacynames ? av_name.getUserNameForDisplay() : av_name.getAccountName() ); addNameTagLine(username, username_color, LLFontGL::NORMAL, LLFontGL::getFontSansSerifSmall()); }