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
master
Ansariel 2021-04-11 16:07:49 +02:00
parent d3f74c2dff
commit 4ced21b2c5
5 changed files with 81 additions and 26 deletions

View File

@ -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];

View File

@ -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<LLScrollListItem*> items = mAnimationScrollList->getAllData();
for (std::vector<LLScrollListItem*>::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<LLScrollListItem*> items = mAnimationScrollList->getAllData();
for (std::vector<LLScrollListItem*>::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;

View File

@ -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<LLUUID> mRequestedIDs; // list of object IDs we requested named for
std::map<LLUUID, std::string> mKnownIDs; // known list of names for object IDs
typedef std::map<LLUUID, boost::signals2::connection> 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

View File

@ -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
{

View File

@ -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),