DEV-52931 Toggling "View Display Names" doesn't take effect right away in the Friends list

meow-7.2.2
Leyla Farazha 2010-09-13 14:59:31 -07:00
parent 7ca63c963d
commit a923da7fc7
8 changed files with 68 additions and 8 deletions

View File

@ -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<char> EQUALS_SEPARATOR("=");
static const boost::char_separator<char> COMMA_SEPARATOR(",");
@ -809,4 +820,3 @@ bool max_age_from_cache_control(const std::string& cache_control, S32 *max_age)
return false;
}

View File

@ -37,6 +37,9 @@ class LLUUID;
namespace LLAvatarNameCache
{
typedef boost::signals2::signal<void (void)> 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.

View File

@ -117,6 +117,7 @@ LLAvatarList::LLAvatarList(const Params& p)
, mShowLastInteractionTime(p.show_last_interaction_time)
, mContextMenu(NULL)
, mDirty(true) // to force initial update
, mNeedUpdateNames(false)
, mLITUpdateTimer(NULL)
, mShowIcons(true)
, mShowInfoBtn(p.show_info_btn)
@ -134,8 +135,17 @@ LLAvatarList::LLAvatarList(const Params& p)
mLITUpdateTimer->setTimerExpirySec(0); // zero to force initial update
mLITUpdateTimer->start();
}
LLAvatarNameCache::addUseDisplayNamesCallback(boost::bind(&LLAvatarList::handleDisplayNamesOptionChanged, this));
}
void LLAvatarList::handleDisplayNamesOptionChanged()
{
mNeedUpdateNames = true;
}
LLAvatarList::~LLAvatarList()
{
delete mLITUpdateTimer;
@ -155,6 +165,11 @@ void LLAvatarList::draw()
LLFlatListViewEx::draw();
if (mNeedUpdateNames)
{
updateAvatarNames();
}
if (mDirty)
refresh();
@ -218,7 +233,6 @@ void LLAvatarList::addAvalineItem(const LLUUID& item_id, const LLUUID& session_i
//////////////////////////////////////////////////////////////////////////
// PROTECTED SECTION
//////////////////////////////////////////////////////////////////////////
void LLAvatarList::refresh()
{
bool have_names = TRUE;
@ -329,6 +343,20 @@ void LLAvatarList::refresh()
onCommit();
}
void LLAvatarList::updateAvatarNames()
{
std::vector<LLPanel*> items;
getItems(items);
for( std::vector<LLPanel*>::const_iterator it = items.begin(); it != items.end(); it++)
{
LLAvatarListItem* item = static_cast<LLAvatarListItem*>(*it);
item->updateAvatarName();
}
mNeedUpdateNames = false;
}
bool LLAvatarList::filterHasMatches()
{
uuid_vec_t values = getIDs();

View File

@ -93,6 +93,7 @@ public:
virtual S32 notifyParent(const LLSD& info);
void addAvalineItem(const LLUUID& item_id, const LLUUID& session_id, const std::string& item_name);
void handleDisplayNamesOptionChanged();
protected:
void refresh();
@ -102,14 +103,17 @@ protected:
const uuid_vec_t& vnew,
uuid_vec_t& vadded,
uuid_vec_t& vremoved);
void updateLastInteractionTimes();
void updateLastInteractionTimes();
void rebuildNames();
void onItemDoubleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask);
void updateAvatarNames();
private:
bool mIgnoreOnlineStatus;
bool mShowLastInteractionTime;
bool mDirty;
bool mNeedUpdateNames;
bool mShowIcons;
bool mShowInfoBtn;
bool mShowProfileBtn;

View File

@ -334,6 +334,12 @@ std::string LLAvatarListItem::getAvatarToolTip() const
return mAvatarName->getToolTip();
}
void LLAvatarListItem::updateAvatarName()
{
LLAvatarNameCache::get(getAvatarId(),
boost::bind(&LLAvatarListItem::onAvatarNameCache, this, _2));
}
//== PRIVATE SECITON ==========================================================
void LLAvatarListItem::setNameInternal(const std::string& name, const std::string& highlight)

View File

@ -86,6 +86,7 @@ public:
virtual void changed(U32 mask); // from LLFriendObserver
void setOnline(bool online);
void updateAvatarName(); // re-query the name cache
void setAvatarName(const std::string& name);
void setAvatarToolTip(const std::string& tooltip);
void setHighlight(const std::string& highlight);

View File

@ -114,6 +114,9 @@ LLCallFloater::LLCallFloater(const LLSD& key)
// force docked state since this floater doesn't save it between recreations
setDocked(true);
// update the agent's name if display name setting change
LLAvatarNameCache::addUseDisplayNamesCallback(boost::bind(&LLCallFloater::updateAgentModeratorState, this));
}
LLCallFloater::~LLCallFloater()
@ -460,15 +463,12 @@ void LLCallFloater::setModeratorMutedVoice(bool moderator_muted)
mSpeakingIndicator->setIsMuted(moderator_muted);
}
void LLCallFloater::updateAgentModeratorState()
void LLCallFloater::onModeratorNameCache(const LLAvatarName& av_name)
{
std::string name;
// Just use display name, because it's you
LLAvatarName av_name;
LLAvatarNameCache::get(gAgentID, &av_name);
name = av_name.mDisplayName;
if(gAgent.isInGroup(mSpeakerManager->getSessionID()))
if(mSpeakerManager && gAgent.isInGroup(mSpeakerManager->getSessionID()))
{
// This method can be called when LLVoiceChannel.mState == STATE_NO_CHANNEL_INFO
// in this case there are not any speakers yet.
@ -486,6 +486,11 @@ void LLCallFloater::updateAgentModeratorState()
mAgentPanel->getChild<LLUICtrl>("user_text")->setValue(name);
}
void LLCallFloater::updateAgentModeratorState()
{
LLAvatarNameCache::get(gAgentID, boost::bind(&LLCallFloater::onModeratorNameCache, this, _2));
}
static void get_voice_participants_uuids(uuid_vec_t& speakers_uuids)
{
// Get a list of participants from VoiceClient

View File

@ -126,6 +126,7 @@ private:
void initAgentData();
void setModeratorMutedVoice(bool moderator_muted);
void updateAgentModeratorState();
void onModeratorNameCache(const LLAvatarName& av_name);
/**
* Sets initial participants voice states in avatar list (Invited, Joined, Has Left).