From 4ced21b2c5e34595e04f19720709d8c97c9db243 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sun, 11 Apr 2021 16:07:49 +0200 Subject: [PATCH] Avatar name stuff: * Radar, area search and sound explorer display "(Loading...)" when loading names since the UUID doesn't really help anything at all in the end anyway and might instead leak information when under RLVa @shownames restriction * Area search shows complete avatar name instead of just username * Sound explorer finally entered the age of display names and shows complete avatar name now --- indra/newview/NACLfloaterexploresounds.cpp | 3 +- indra/newview/animationexplorer.cpp | 85 ++++++++++++++++------ indra/newview/animationexplorer.h | 7 ++ indra/newview/fsareasearch.cpp | 10 ++- indra/newview/fsradarentry.cpp | 2 +- 5 files changed, 81 insertions(+), 26 deletions(-) diff --git a/indra/newview/NACLfloaterexploresounds.cpp b/indra/newview/NACLfloaterexploresounds.cpp index 737fca8e32..0bee4bd126 100644 --- a/indra/newview/NACLfloaterexploresounds.cpp +++ b/indra/newview/NACLfloaterexploresounds.cpp @@ -161,6 +161,7 @@ BOOL NACLFloaterExploreSounds::tick() static const std::string str_type_trigger_sound = getString("Type_llTriggerSound"); static const std::string str_type_loop_sound = getString("Type_llLoopSound"); static const std::string str_type_play_sound = getString("Type_llPlaySound"); + static const std::string str_unknown_name = LLTrans::getString("AvatarNameWaiting"); bool show_collision_sounds = mCollisionSounds->get(); bool show_repeated_assets = mRepeatedAssets->get(); @@ -300,7 +301,7 @@ BOOL NACLFloaterExploreSounds::tick() } else { - owner_column["value"] = item.mOwnerID.asString(); + owner_column["value"] = str_unknown_name; } LLSD& sound_column = element["columns"][3]; diff --git a/indra/newview/animationexplorer.cpp b/indra/newview/animationexplorer.cpp index 5abf5ec67d..fdde7ded88 100644 --- a/indra/newview/animationexplorer.cpp +++ b/indra/newview/animationexplorer.cpp @@ -51,8 +51,9 @@ #include "llviewerwindow.h" // for gViewerWindow #include "llvoavatar.h" #include "llvoavatarself.h" // for gAgentAvatarp +#include "llavatarnamecache.h" -const S32 MAX_ANIMATIONS=100; +constexpr S32 MAX_ANIMATIONS = 100; // -------------------------------------------------------------------------- @@ -77,7 +78,7 @@ void RecentAnimationList::addAnimation(const LLUUID& id, const LLUUID& playedBy) // only remember animation when it wasn't played by ourselves or the explorer window is open, // so the list doesn't get polluted - if (playedBy != gAgentAvatarp->getID() || explorer != NULL) + if (playedBy != gAgentAvatarp->getID() || explorer) { mAnimationList.push_back(entry); @@ -114,7 +115,7 @@ void RecentAnimationList::requestList(AnimationExplorer* explorer) AnimationExplorer::AnimationExplorer(const LLSD& key) : LLFloater(key), - mPreviewCtrl(NULL), + mPreviewCtrl(nullptr), mLastMouseX(0), mLastMouseY(0) { @@ -122,7 +123,16 @@ AnimationExplorer::AnimationExplorer(const LLSD& key) AnimationExplorer::~AnimationExplorer() { - mAnimationPreview = NULL; + mAnimationPreview = nullptr; + + for (const auto& cb : mAvatarNameCacheConnections) + { + if (cb.second.connected()) + { + cb.second.disconnect(); + } + } + mAvatarNameCacheConnections.clear(); } void AnimationExplorer::startMotion(const LLUUID& motionID) @@ -363,8 +373,21 @@ void AnimationExplorer::addAnimation(const LLUUID& id, const LLUUID& played_by, // if it was an avatar, get the name here if (vo->isAvatar()) { - playedByName = std::string(vo->getNVPair("FirstName")->getString()) + " " + - std::string(vo->getNVPair("LastName")->getString()); + LLAvatarName av_name; + if (LLAvatarNameCache::get(played_by, &av_name)) + { + playedByName = av_name.getCompleteName(); + } + else + { + if (mAvatarNameCacheConnections.find(played_by) != mAvatarNameCacheConnections.end()) + { + boost::signals2::connection cb_connection = LLAvatarNameCache::get(played_by, boost::bind(&AnimationExplorer::onAvatarNameCallback, this, _1, _2)); + mAvatarNameCacheConnections.insert(std::make_pair(played_by, cb_connection)); + } + + playedByName = LLTrans::getString("AvatarNameWaiting"); + } } // not an avatar, do a lookup by UUID else @@ -425,6 +448,21 @@ void AnimationExplorer::addAnimation(const LLUUID& id, const LLUUID& played_by, mAnimationScrollList->addElement(item, ADD_TOP); } +void AnimationExplorer::onAvatarNameCallback(const LLUUID& id, const LLAvatarName& av_name) +{ + auto iter = mAvatarNameCacheConnections.find(id); + if (iter != mAvatarNameCacheConnections.end()) + { + if (iter->second.connected()) + { + iter->second.disconnect(); + } + mAvatarNameCacheConnections.erase(iter); + } + + updateListEntry(id, av_name.getCompleteName()); +} + void AnimationExplorer::requestNameCallback(LLMessageSystem* msg) { // if we weren't looking for any IDs, ignore this callback @@ -453,22 +491,27 @@ void AnimationExplorer::requestNameCallback(LLMessageSystem* msg) mRequestedIDs.erase(iter); mKnownIDs[object_id] = object_name; - S32 object_id_column = mAnimationScrollList->getColumn("object_id")->mIndex; - S32 played_by_column = mAnimationScrollList->getColumn("played_by")->mIndex; + updateListEntry(object_id, object_name); + } + } +} - // find all scroll list entries with this object UUID and update the names there - std::vector items = mAnimationScrollList->getAllData(); - for (std::vector::iterator list_iter = items.begin(); list_iter != items.end(); ++list_iter) - { - LLScrollListItem* item = *list_iter; - LLUUID list_object_id = item->getColumn(object_id_column)->getValue().asUUID(); +void AnimationExplorer::updateListEntry(const LLUUID& id, const std::string& name) +{ + S32 object_id_column = mAnimationScrollList->getColumn("object_id")->mIndex; + S32 played_by_column = mAnimationScrollList->getColumn("played_by")->mIndex; - if (object_id == list_object_id) - { - LLScrollListText* played_by_text = (LLScrollListText*)item->getColumn(played_by_column); - played_by_text->setText(object_name); - } - } + // find all scroll list entries with this object UUID and update the names there + std::vector items = mAnimationScrollList->getAllData(); + for (std::vector::iterator list_iter = items.begin(); list_iter != items.end(); ++list_iter) + { + LLScrollListItem* item = *list_iter; + LLUUID list_object_id = item->getColumn(object_id_column)->getValue().asUUID(); + + if (id == list_object_id) + { + LLScrollListText* played_by_text = (LLScrollListText*)item->getColumn(played_by_column); + played_by_text->setText(name); } } } @@ -478,7 +521,7 @@ BOOL AnimationExplorer::handleMouseDown(S32 x, S32 y, MASK mask) { if (mPreviewCtrl && mPreviewCtrl->getRect().pointInRect(x, y)) { - bringToFront( x, y ); + bringToFront(x, y); gFocusMgr.setMouseCapture(this); gViewerWindow->hideCursor(); mLastMouseX = x; diff --git a/indra/newview/animationexplorer.h b/indra/newview/animationexplorer.h index ddda69002f..f7e9bd2db2 100644 --- a/indra/newview/animationexplorer.h +++ b/indra/newview/animationexplorer.h @@ -65,6 +65,7 @@ public: // options to preview, stop animations and revoke animation permissions // -------------------------------------------------------------------------- +class LLAvatarName; class LLButton; class LLCheckBoxCtrl; class LLMessageSystem; @@ -94,6 +95,9 @@ class AnimationExplorer void requestNameCallback(LLMessageSystem* msg); // object name query callback protected: + void onAvatarNameCallback(const LLUUID& id, const LLAvatarName& av_name); + void updateListEntry(const LLUUID& id, const std::string& name); + LLScrollListCtrl* mAnimationScrollList; LLButton* mStopButton; LLButton* mRevokeButton; @@ -112,6 +116,9 @@ class AnimationExplorer std::vector mRequestedIDs; // list of object IDs we requested named for std::map mKnownIDs; // known list of names for object IDs + typedef std::map avatar_name_cache_connection_map_t; + avatar_name_cache_connection_map_t mAvatarNameCacheConnections; + void draw(); void update(); // request list update from RecentAnimationList void updateList(F64 current_timestamp); // update times and playing status in animation list diff --git a/indra/newview/fsareasearch.cpp b/indra/newview/fsareasearch.cpp index 23a3f48890..c825ec28dc 100644 --- a/indra/newview/fsareasearch.cpp +++ b/indra/newview/fsareasearch.cpp @@ -1127,12 +1127,15 @@ void FSAreaSearch::updateObjectCosts(const LLUUID& object_id, F32 object_cost, F void FSAreaSearch::getNameFromUUID(const LLUUID& id, bool needs_rlva_check, std::string& name, bool group, bool& name_requested) { + static const std::string unknown_name = LLTrans::getString("AvatarNameWaiting"); + if (group) { BOOL is_group; if (!gCacheName->getIfThere(id, name, is_group)) { - if(std::find(mNamesRequested.begin(), mNamesRequested.end(), id) == mNamesRequested.end()) + name = unknown_name; + if (std::find(mNamesRequested.begin(), mNamesRequested.end(), id) == mNamesRequested.end()) { mNamesRequested.push_back(id); gCacheName->get(id, group, boost::bind(&FSAreaSearch::callbackLoadFullName, this, _1, _2)); @@ -1147,7 +1150,7 @@ void FSAreaSearch::getNameFromUUID(const LLUUID& id, bool needs_rlva_check, std: { if (!needs_rlva_check || !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) { - name = av_name.getUserName(); + name = av_name.getCompleteName(); } else { @@ -1156,6 +1159,7 @@ void FSAreaSearch::getNameFromUUID(const LLUUID& id, bool needs_rlva_check, std: } else { + name = unknown_name; if (std::find(mNamesRequested.begin(), mNamesRequested.end(), id) == mNamesRequested.end()) { mNamesRequested.push_back(id); @@ -1171,7 +1175,7 @@ void FSAreaSearch::avatarNameCacheCallback(const LLUUID& id, const LLAvatarName& std::string name; if (!needs_rlva_check || !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) { - name = av_name.getUserName(); + name = av_name.getCompleteName(); } else { diff --git a/indra/newview/fsradarentry.cpp b/indra/newview/fsradarentry.cpp index a8cc359108..2504b1c5c9 100644 --- a/indra/newview/fsradarentry.cpp +++ b/indra/newview/fsradarentry.cpp @@ -35,7 +35,7 @@ FSRadarEntry::FSRadarEntry(const LLUUID& avid) : mID(avid), - mName(avid.asString()), + mName(LLTrans::getString("AvatarNameWaiting")), mUserName(LLStringUtil::null), mDisplayName(LLStringUtil::null), mRange(0.f),