From 6fddbeb3973c3cd2135ba101afc13329a8c9fe49 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 4 Jun 2020 22:43:55 +0300 Subject: SL-12748 Blocked username displays old name after name change --- indra/newview/llmutelist.cpp | 78 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 4 deletions(-) (limited to 'indra/newview/llmutelist.cpp') diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp index 64df449c26..8a10a38b37 100644 --- a/indra/newview/llmutelist.cpp +++ b/indra/newview/llmutelist.cpp @@ -169,6 +169,14 @@ LLMuteList::LLMuteList() : gMessageSystem.callWhenReady(boost::bind(&LLMessageSystem::setHandlerFuncFast, _1, _PREHASH_UseCachedMuteList, processUseCachedMuteList, static_cast(NULL))); + + // make sure mute list's instance gets initialized before we start any name requests + LLAvatarNameCache::getInstance()->setAccountNameChangedCallback([this](const LLUUID& id, const LLAvatarName& av_name) + { + // it would be better to just pass LLAvatarName instead of doing unnesssesary copies + // but this way is just more convinient + onAccountNameChanged(id, av_name.getUserName()); + }); } //----------------------------------------------------------------------------- @@ -179,6 +187,11 @@ LLMuteList::~LLMuteList() } +void LLMuteList::cleanupSingleton() +{ + LLAvatarNameCache::getInstance()->setAccountNameChangedCallback(NULL); +} + BOOL LLMuteList::isLinden(const std::string& name) const { std::string username = boost::replace_all_copy(name, ".", " "); @@ -232,8 +245,8 @@ BOOL LLMuteList::add(const LLMute& mute, U32 flags) LL_WARNS() << "Trying to self; ignored" << LL_ENDL; return FALSE; } - - S32 mute_list_limit = gSavedSettings.getS32("MuteListLimit"); + + static LLCachedControl mute_list_limit(gSavedSettings, "MuteListLimit", 1000); if (getMutes().size() >= mute_list_limit) { LL_WARNS() << "Mute limit is reached; ignored" << LL_ENDL; @@ -358,6 +371,10 @@ void LLMuteList::updateAdd(const LLMute& mute) msg->addU32("MuteFlags", mute.mFlags); gAgent.sendReliableMessage(); + if (!mIsLoaded) + { + LL_WARNS() << "Added elements to non-initialized block list" << LL_ENDL; + } mIsLoaded = TRUE; // why is this here? -MG } @@ -412,7 +429,6 @@ BOOL LLMuteList::remove(const LLMute& mute, U32 flags) // Must be after erase. notifyObserversDetailed(localmute); - setLoaded(); // why is this here? -MG } else { @@ -426,7 +442,6 @@ BOOL LLMuteList::remove(const LLMute& mute, U32 flags) mLegacyMutes.erase(legacy_it); // Must be after erase. notifyObserversDetailed(mute); - setLoaded(); // why is this here? -MG } } @@ -584,6 +599,19 @@ BOOL LLMuteList::loadFromFile(const std::string& filename) } fclose(fp); setLoaded(); + + // server does not maintain up-to date account names (not display names!) + // in this list, so it falls to viewer. + pending_names_t::iterator iter = mPendingAgentNameUpdates.begin(); + pending_names_t::iterator end = mPendingAgentNameUpdates.end(); + while (iter != end) + { + // this will send updates to server, make sure mIsLoaded is set + onAccountNameChanged(iter->first, iter->second); + iter++; + } + mPendingAgentNameUpdates.clear(); + return TRUE; } @@ -767,6 +795,48 @@ void LLMuteList::onFileMuteList(void** user_data, S32 error_code, LLExtStat ext_ delete local_filename_and_path; } +void LLMuteList::onAccountNameChanged(const LLUUID& id, const std::string& username) +{ + if (mIsLoaded) + { + LLMute mute(id, username, LLMute::AGENT); + mute_set_t::iterator mute_it = mMutes.find(mute); + if (mute_it != mMutes.end() + && mute_it->mName != mute.mName + && mute_it->mType == LLMute::AGENT) // just in case, it is std::set, not map + { + // existing mute, but name changed, copy data + mute.mFlags = mute_it->mFlags; + + // erase old variant + mMutes.erase(mute_it); + + // (re)add the mute entry. + { + std::pair result = mMutes.insert(mute); + if (result.second) + { + LL_INFOS() << "Muting " << mute.mName << " id " << mute.mID << " flags " << mute.mFlags << LL_ENDL; + updateAdd(mute); + // Do not notify observers here, observers do not know or need to handle name changes + // Example: block list considers notifyObserversDetailed as a selection update; + // Various chat/voice statuses care only about id and flags + // Since apropriate update time for account names is considered to be in 'hours' it is + // fine not to update UI (will be fine after restart or couple other changes) + + } + } + } + } + else + { + // Delay update until we load file + // Ex: Buddies list can arrive too early since we prerequest + // names from Buddies list before we load blocklist + mPendingAgentNameUpdates[id] = username; + } +} + void LLMuteList::addObserver(LLMuteListObserver* observer) { mObservers.insert(observer); -- cgit v1.3 From d561756d58613f51f1fc17237225b7a412c51f64 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 8 Dec 2020 22:09:59 +0200 Subject: SL-14497 Unblocking does not remove voice block --- indra/newview/llagent.cpp | 2 +- indra/newview/llenvironment.cpp | 2 +- indra/newview/llmutelist.cpp | 2 ++ indra/newview/lloutputmonitorctrl.cpp | 10 +++++++--- indra/newview/lloutputmonitorctrl.h | 3 ++- indra/newview/llwlhandlers.cpp | 2 +- 6 files changed, 14 insertions(+), 7 deletions(-) (limited to 'indra/newview/llmutelist.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 6e45cfad8e..c65bc0fa50 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -965,7 +965,7 @@ void LLAgent::setRegion(LLViewerRegion *regionp) } else { - regionp->setCapabilitiesReceivedCallback([](LLUUID region_id) {LLAppViewer::instance()->updateNameLookupUrl(); }); + regionp->setCapabilitiesReceivedCallback([](const LLUUID ®ion_id) {LLAppViewer::instance()->updateNameLookupUrl(); }); } } diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index a8780d6365..74c1b99e4d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1029,7 +1029,7 @@ void LLEnvironment::onRegionChange() } if (!cur_region->capabilitiesReceived()) { - cur_region->setCapabilitiesReceivedCallback([](LLUUID region_id) { LLEnvironment::instance().requestRegion(); }); + cur_region->setCapabilitiesReceivedCallback([](const LLUUID ®ion_id) { LLEnvironment::instance().requestRegion(); }); return; } requestRegion(); diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp index 8a10a38b37..f7ad28f9cd 100644 --- a/indra/newview/llmutelist.cpp +++ b/indra/newview/llmutelist.cpp @@ -428,6 +428,7 @@ BOOL LLMuteList::remove(const LLMute& mute, U32 flags) } // Must be after erase. + notifyObservers(); notifyObserversDetailed(localmute); } else @@ -441,6 +442,7 @@ BOOL LLMuteList::remove(const LLMute& mute, U32 flags) updateRemove(mute); mLegacyMutes.erase(legacy_it); // Must be after erase. + notifyObservers(); notifyObserversDetailed(mute); } } diff --git a/indra/newview/lloutputmonitorctrl.cpp b/indra/newview/lloutputmonitorctrl.cpp index e9fe493d7e..7129641c20 100644 --- a/indra/newview/lloutputmonitorctrl.cpp +++ b/indra/newview/lloutputmonitorctrl.cpp @@ -312,10 +312,14 @@ void LLOutputMonitorCtrl::setSpeakerId(const LLUUID& speaker_id, const LLUUID& s } } -void LLOutputMonitorCtrl::onChange() +void LLOutputMonitorCtrl::onChangeDetailed(const LLMute& mute) { - // check only blocking on voice. EXT-3542 - mIsMuted = LLMuteList::getInstance()->isMuted(mSpeakerId, LLMute::flagVoiceChat); + if (mute.mID == mSpeakerId) + { + // Check only blocking on voice. + // Logic goes in reverse, if flag is set, action is allowed + mIsMuted = !(LLMute::flagVoiceChat & mute.mFlags); + } } // virtual diff --git a/indra/newview/lloutputmonitorctrl.h b/indra/newview/lloutputmonitorctrl.h index 98966d39ee..e80745e1df 100644 --- a/indra/newview/lloutputmonitorctrl.h +++ b/indra/newview/lloutputmonitorctrl.h @@ -105,7 +105,8 @@ public: void setSpeakerId(const LLUUID& speaker_id, const LLUUID& session_id = LLUUID::null, bool show_other_participants_speaking = false); //called by mute list - virtual void onChange(); + virtual void onChange() {}; + virtual void onChangeDetailed(const LLMute& mute); /** * Implementation of LLSpeakingIndicator interface. diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index 6b8374fd48..730aa3774f 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -51,7 +51,7 @@ bool LLEnvironmentRequest::initiate(LLEnvironment::environment_apply_fn cb) if (!cur_region->capabilitiesReceived()) { LL_INFOS("WindlightCaps") << "Deferring windlight settings request until we've got region caps" << LL_ENDL; - cur_region->setCapabilitiesReceivedCallback([cb](LLUUID region_id) { LLEnvironmentRequest::onRegionCapsReceived(region_id, cb); }); + cur_region->setCapabilitiesReceivedCallback([cb](const LLUUID ®ion_id) { LLEnvironmentRequest::onRegionCapsReceived(region_id, cb); }); return false; } -- cgit v1.3 From e538aaabc77deb48b2a724029ccf21ca1eec6694 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 9 Dec 2020 21:33:11 +0200 Subject: SL-14497 Observers sometimes were notified with wrong flags --- indra/newview/llmutelist.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llmutelist.cpp') diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp index f7ad28f9cd..663a6071f7 100644 --- a/indra/newview/llmutelist.cpp +++ b/indra/newview/llmutelist.cpp @@ -408,6 +408,8 @@ BOOL LLMuteList::remove(const LLMute& mute, U32 flags) else { // The caller didn't pass any flags -- just remove the mute entry entirely. + // set flags to notify observers with (flag being present means that something is allowed) + localmute.mFlags = LLMute::flagAll; } // Always remove the entry from the set -- it will be re-added with new flags if necessary. -- cgit v1.3