-
Notifications
You must be signed in to change notification settings - Fork 96
[Draft] Nearby chat voice moderation #4943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
0a14318
219da2a
53d8310
c64c16a
21e9b38
cf048cf
c39135c
74a64d2
a4d01ed
d9ec89a
8111052
bee23b4
e740bd2
6ee41d6
ec149b5
a9e8676
1565e46
8b1e44e
88a3d95
3647e95
c4ec3d8
9f82b90
4f22c12
3fd68bc
49c73ac
cbe606d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| /** | ||
| * @file llnearbyvoicemoderation.cpp | ||
| * | ||
| * $LicenseInfo:firstyear=2008&license=viewerlgpl$ | ||
| * Second Life Viewer Source Code | ||
| * Copyright (C) 2010, Linden Research, Inc. | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; | ||
| * version 2.1 of the License only. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| * | ||
| * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA | ||
| * $/LicenseInfo$ | ||
| */ | ||
|
|
||
| #include "llviewerprecompiledheaders.h" | ||
|
|
||
| #include "llagent.h" | ||
| #include "llnotificationsutil.h" | ||
| #include "llviewerregion.h" | ||
| #include "llvoavatar.h" | ||
| #include "llvoiceclient.h" | ||
| #include "llviewerobjectlist.h" | ||
| #include "llviewerparcelmgr.h" | ||
| #include "roles_constants.h" | ||
|
|
||
| #include "llnearbyvoicemoderation.h" | ||
|
|
||
| LLNearbyVoiceModeration::LLNearbyVoiceModeration() | ||
| { | ||
| } | ||
|
|
||
| LLNearbyVoiceModeration::~LLNearbyVoiceModeration() | ||
| { | ||
| } | ||
|
|
||
| LLVOAvatar* LLNearbyVoiceModeration::getVOAvatarFromId(const LLUUID& agent_id) | ||
| { | ||
| LLViewerObject *obj = gObjectList.findObject(agent_id); | ||
| while (obj && obj->isAttachment()) | ||
| { | ||
| obj = (LLViewerObject*)obj->getParent(); | ||
| } | ||
|
|
||
| if (obj && obj->isAvatar()) | ||
| { | ||
| return (LLVOAvatar*)obj; | ||
| } | ||
| else | ||
| { | ||
| return NULL; | ||
| } | ||
| } | ||
|
|
||
| const std::string LLNearbyVoiceModeration::getCapUrlFromRegion(LLViewerRegion* region) | ||
| { | ||
| if (! region || ! region->capabilitiesReceived()) | ||
| { | ||
| return std::string(); | ||
| } | ||
|
|
||
| std::string url = region->getCapability("SpatialVoiceModerationRequest"); | ||
| if (url.empty()) | ||
| { | ||
| LL_INFOS() << "Capability URL for region " << region->getName() << " is empty" << LL_ENDL; | ||
| return std::string(); | ||
| } | ||
| LL_INFOS() << "Capability URL for region " << region->getName() << " is " << url << LL_ENDL; | ||
|
|
||
| return url; | ||
| } | ||
|
|
||
| void LLNearbyVoiceModeration::requestMuteIndividual(const LLUUID& agent_id, bool mute) | ||
| { | ||
| LLVOAvatar* avatar = getVOAvatarFromId(agent_id); | ||
| if (avatar) | ||
| { | ||
| const std::string cap_url = getCapUrlFromRegion(avatar->getRegion()); | ||
| if (cap_url.length()) | ||
| { | ||
| const std::string operand = mute ? "mute" : "unmute"; | ||
|
|
||
| LLSD body; | ||
| body["operand"] = operand; | ||
| body["agent_id"] = agent_id; | ||
| body["moderator_id"] = gAgent.getID(); | ||
|
||
|
|
||
| const std::string agent_name = avatar->getFullname(); | ||
| LL_INFOS() << "Resident " << agent_name | ||
| << " (" << agent_id << ")" << " applying " << operand << LL_ENDL; | ||
|
|
||
| std::string success_msg = | ||
| STRINGIZE("Resident " << agent_name | ||
| << " (" << agent_id << ")" << " nearby voice was set to " << operand); | ||
|
|
||
| std::string failure_msg = | ||
| STRINGIZE("Unable to change voice muting for resident " | ||
| << agent_name << " (" << agent_id << ")"); | ||
|
|
||
| LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost( | ||
| cap_url, | ||
| body, | ||
| success_msg, | ||
| failure_msg); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void LLNearbyVoiceModeration::requestMuteAll(bool mute) | ||
| { | ||
| // Use our own avatar to get the region name | ||
| LLViewerRegion* region = gAgent.getRegion(); | ||
|
|
||
| const std::string cap_url = getCapUrlFromRegion(region); | ||
| if (cap_url.length()) | ||
| { | ||
| const std::string operand = mute ? "mute_all" : "unmute_all"; | ||
|
|
||
| LLSD body; | ||
| body["operand"] = operand; | ||
| body["moderator_id"] = gAgent.getID(); | ||
|
||
|
|
||
| LL_INFOS() << "For all residents in this region, applying: " << operand << LL_ENDL; | ||
|
|
||
| std::string success_msg = | ||
| STRINGIZE("Nearby voice for all residents was set to: " << operand); | ||
|
|
||
| std::string failure_msg = | ||
| STRINGIZE("Unable to set nearby voice for all residents to: " << operand); | ||
|
|
||
| LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost( | ||
| cap_url, | ||
| body, | ||
| success_msg, | ||
| failure_msg); | ||
| } | ||
| } | ||
|
|
||
| void LLNearbyVoiceModeration::setMutedInfo(const std::string& channelID, bool mute) | ||
| { | ||
| auto it = mChannelMuteMap.find(channelID); | ||
| if (it == mChannelMuteMap.end()) | ||
| { | ||
| if (mute) | ||
| { | ||
| // Channel is new and being muted | ||
| showMutedNotification(true); | ||
| } | ||
| mChannelMuteMap[channelID] = mute; | ||
| } | ||
| else | ||
| { | ||
| if (it->second != mute) | ||
| { | ||
| // Flag changed | ||
| showMutedNotification(mute); | ||
| it->second = mute; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void LLNearbyVoiceModeration::showNotificationIfNeeded() | ||
| { | ||
| if (LLVoiceClient::getInstance()->inProximalChannel() && | ||
| LLVoiceClient::getInstance()->getIsModeratorMuted(gAgentID)) | ||
| { | ||
| showMutedNotification(true); | ||
| } | ||
| } | ||
|
|
||
| void LLNearbyVoiceModeration::showMutedNotification(bool is_muted) | ||
| { | ||
| // Check if the current voice channel is nearby chat | ||
| if (LLVoiceClient::getInstance()->inProximalChannel()) | ||
| { | ||
| LLNotificationsUtil::add(is_muted ? "NearbyVoiceMutedByModerator" : "NearbyVoiceUnmutedByModerator"); | ||
| } | ||
| } | ||
|
|
||
| bool LLNearbyVoiceModeration::isNearbyChatModerator() | ||
| { | ||
| return gAgent.getRegion() && gAgent.getRegion()->isRegionWebRTCEnabled() && | ||
| (gAgent.canManageEstate() || LLViewerParcelMgr::getInstance()->allowVoiceModeration()); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has the viewer switched yet to using
nullptr(c++-ism) instead ofNULL(c-ism)?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it was probably just copy-paste from another place. It's more common just to do
if (!selectedItem)check.Speaking of
NULLvsnullptr- there we no switch, but it makes sense to usenullptrat least in the new code.