Skip to content

Commit 53d8310

Browse files
committed
Improve robustness of when moderator options appear and add some initial code for muting indivudual / everyone via the capability
1 parent 219da2a commit 53d8310

File tree

3 files changed

+111
-34
lines changed

3 files changed

+111
-34
lines changed

indra/newview/llfloaterimcontainer.cpp

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,12 @@ void LLFloaterIMContainer::idleUpdate()
504504
const LLConversationItem *current_session = getCurSelectedViewModelItem();
505505
if (current_session)
506506
{
507-
bool is_nearby_chat = current_session->getType() == LLConversationItem::CONV_SESSION_NEARBY;
508-
if (current_session->getType() == LLConversationItem::CONV_SESSION_GROUP || is_nearby_chat)
507+
if (current_session->getType() == LLConversationItem::CONV_SESSION_GROUP)
509508
{
510509
// Update moderator options visibility
511510
LLFolderViewModelItemCommon::child_list_t::const_iterator current_participant_model = current_session->getChildrenBegin();
512511
LLFolderViewModelItemCommon::child_list_t::const_iterator end_participant_model = current_session->getChildrenEnd();
513-
bool is_moderator = isGroupModerator() || (is_nearby_chat && isNearbyChatModerator());
512+
bool is_moderator = isGroupModerator();
514513
bool can_ban = haveAbilityToBan();
515514
while (current_participant_model != end_participant_model)
516515
{
@@ -533,6 +532,23 @@ void LLFloaterIMContainer::idleUpdate()
533532
mGeneralTitleInUse = !needs_override;
534533
setTitle(needs_override ? conversation_floaterp->getTitle() : mGeneralTitle);
535534
}
535+
const LLConversationItem* nearby_session = getSessionModel(LLUUID());
536+
if (nearby_session)
537+
{
538+
LLFolderViewModelItemCommon::child_list_t::const_iterator current_participant_model = nearby_session->getChildrenBegin();
539+
LLFolderViewModelItemCommon::child_list_t::const_iterator end_participant_model = nearby_session->getChildrenEnd();
540+
while (current_participant_model != end_participant_model)
541+
{
542+
LLConversationItemParticipant* participant_model =
543+
dynamic_cast<LLConversationItemParticipant*>((*current_participant_model).get());
544+
if (participant_model)
545+
{
546+
participant_model->setModeratorOptionsVisible(isNearbyChatModerator());
547+
}
548+
549+
current_participant_model++;
550+
}
551+
}
536552
}
537553

538554
mParticipantRefreshTimer.setTimerExpirySec(1.0f);
@@ -2183,19 +2199,37 @@ void LLFloaterIMContainer::moderateVoice(const std::string& command, const LLUUI
21832199

21842200
// Request a mute/unmute using a capability request via the simulator
21852201
const bool mute_state = LLAvatarActions::isVoiceMuted(userID);
2186-
LLNearbyVoiceModeration::getInstance()->requestMuteChange(userID, mute_state);
2202+
LLNearbyVoiceModeration::getInstance()->requestMuteIndividual(userID, mute_state);
21872203
}
21882204
else
21892205
if ("mute_all" == command)
21902206
{
21912207
// TODO: the SpatialVoiceModerationRequest has an mute_all/unmute_all
21922208
// verb but we do not have an equivalent of LLAvatarActions::toggleMuteVoice(userID);
21932209
// to visually mute all the speaker icons in the conversation floater
2210+
2211+
// Mute visually too
2212+
conversations_widgets_map::const_iterator iter = mConversationsWidgets.begin();
2213+
conversations_widgets_map::const_iterator end = mConversationsWidgets.end();
2214+
const LLUUID * conversation_uuidp = NULL;
2215+
while(iter != end)
2216+
{
2217+
const LLUUID id = (*iter).first;
2218+
++iter;
2219+
}
2220+
2221+
// Send the mute_all request to the server
2222+
const bool mute_state = true;
2223+
LLNearbyVoiceModeration::getInstance()->requestMuteAll(mute_state);
21942224
}
21952225
else
21962226
if ("unmute_all" == command)
21972227
{
21982228
// TODO: same idea as "mute_all" above
2229+
2230+
// Send the unmute_all request to the server
2231+
const bool mute_state = false;
2232+
LLNearbyVoiceModeration::getInstance()->requestMuteAll(mute_state);
21992233
}
22002234

22012235
return;

indra/newview/llnearbyvoicemoderation.cpp

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -50,53 +50,92 @@ LLVOAvatar* LLNearbyVoiceModeration::getVOAvatarFromId(const LLUUID& agent_id)
5050
}
5151
}
5252

53-
void LLNearbyVoiceModeration::requestMuteChange(const LLUUID& agent_id, bool mute)
53+
const std::string LLNearbyVoiceModeration::getCapUrlFromRegion(LLViewerRegion* region)
54+
{
55+
if (! region || ! region->capabilitiesReceived())
56+
{
57+
// TODO: Retry if fails since the capabilities may not have been received
58+
// if this is called early into a region entry
59+
LL_INFOS() << "Region or region capabilities unavailable." << LL_ENDL;
60+
return std::string();
61+
}
62+
LL_INFOS() << "Capabilities for region " << region->getName() << " received." << LL_ENDL;
63+
64+
std::string url = region->getCapability("SpatialVoiceModerationRequest");
65+
if (url.empty())
66+
{
67+
// TODO: Retry if fails since URL may not have not be available
68+
// if this is called early into a region entry
69+
LL_INFOS() << "Capability URL for region " << region->getName() << " is empty" << LL_ENDL;
70+
return std::string();
71+
}
72+
LL_INFOS() << "Capability URL for region " << region->getName() << " is " << url << LL_ENDL;
73+
74+
return url;
75+
}
76+
77+
void LLNearbyVoiceModeration::requestMuteIndividual(const LLUUID& agent_id, bool mute)
5478
{
5579
LLVOAvatar* avatar = getVOAvatarFromId(agent_id);
5680
if (avatar)
5781
{
58-
LLViewerRegion* region = avatar->getRegion();
59-
if (! region || ! region->capabilitiesReceived())
82+
const std::string cap_url = getCapUrlFromRegion(avatar->getRegion());
83+
if (cap_url.length())
6084
{
61-
// TODO: Retry if fails since the capabilities may not have been received
62-
// if this is called early into a region entry
63-
LL_INFOS() << "Region or region capabilities unavailable" << LL_ENDL;
64-
return;
65-
}
66-
LL_INFOS() << "Region name is " << region->getName() << LL_ENDL;
85+
const std::string operand = mute ? "mute" : "unmute";
6786

68-
std::string url = region->getCapability("SpatialVoiceModerationRequest");
69-
if (url.empty())
70-
{
71-
// TODO: Retry if fails since URL may not have not be available
72-
// if this is called early into a region entry
73-
LL_INFOS() << "Capability URL is empty" << LL_ENDL;
74-
return;
87+
LLSD body;
88+
body["operand"] = operand;
89+
body["agent_id"] = agent_id;
90+
body["moderator_id"] = gAgent.getID();
91+
92+
const std::string agent_name = avatar->getFullname();
93+
LL_INFOS() << "Resident " << agent_name
94+
<< " (" << agent_id << ")" << " applying " << operand << LL_ENDL;
95+
96+
std::string success_msg =
97+
STRINGIZE("Resident " << agent_name
98+
<< " (" << agent_id << ")" << " nearby voice was set to " << operand);
99+
100+
std::string failure_msg =
101+
STRINGIZE("Unable to change voice muting for resident "
102+
<< agent_name << " (" << agent_id << ")");
103+
104+
LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(
105+
cap_url,
106+
body,
107+
success_msg,
108+
failure_msg);
75109
}
76-
LL_INFOS() << "Capability URL is " << url << LL_ENDL;
110+
}
111+
}
77112

78-
const std::string agent_name = avatar->getFullname();
113+
void LLNearbyVoiceModeration::requestMuteAll(bool mute)
114+
{
115+
// Use our own avatar to get the region name
116+
LLViewerRegion* region = gAgent.getRegion();
79117

80-
const std::string operand = mute ? "mute" : "unmute";
118+
const std::string cap_url = getCapUrlFromRegion(region);
119+
if (cap_url.length())
120+
{
121+
const std::string operand = mute ? "mute_all" : "unmute_all";
81122

82123
LLSD body;
83124
body["operand"] = operand;
84-
body["agent_id"] = agent_id;
85125
body["moderator_id"] = gAgent.getID();
86126

87-
LL_INFOS() << "Resident " << agent_name
88-
<< " (" << agent_id << ")" << " applying " << operand << LL_ENDL;
127+
LL_INFOS() << "For all residents in this region, applying: " << operand << LL_ENDL;
89128

90129
std::string success_msg =
91-
STRINGIZE("Resident " << agent_name
92-
<< " (" << agent_id << ")" << " nearby voice was set to " << operand);
130+
STRINGIZE("Nearby voice for all residents was set to: " << operand);
93131

94132
std::string failure_msg =
95-
STRINGIZE("Unable to change voice muting for resident "
96-
<< agent_name << " (" << agent_id << ")");
133+
STRINGIZE("Unable to set nearby voice for all residents to: " << operand);
97134

98-
LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, body,
99-
success_msg,
100-
failure_msg);
135+
LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(
136+
cap_url,
137+
body,
138+
success_msg,
139+
failure_msg);
101140
}
102141
}

indra/newview/llnearbyvoicemoderation.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@ class LLNearbyVoiceModeration :
3737

3838
public:
3939
LLVOAvatar* getVOAvatarFromId(const LLUUID& id);
40-
void requestMuteChange(const LLUUID& userID, bool mute);
40+
void requestMuteIndividual(const LLUUID& userID, bool mute);
41+
void requestMuteAll(bool mute);
42+
43+
private:
44+
const std::string getCapUrlFromRegion(LLViewerRegion* region);
4145
};

0 commit comments

Comments
 (0)