From 1251f45e6246d81658cf4fe6f2654472c772e94b Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Wed, 17 Oct 2012 00:16:18 +0300 Subject: CHUI-394 FIXED Group moderation tools missing in right click menus --- indra/llui/llmenugl.cpp | 117 +++---- indra/llui/llmenugl.h | 35 +- indra/llui/lltoggleablemenu.cpp | 5 + indra/llui/lltoggleablemenu.h | 2 + indra/newview/llconversationmodel.cpp | 13 + indra/newview/llimfloatercontainer.cpp | 344 ++++++++++++++++---- indra/newview/llimfloatercontainer.h | 13 + indra/newview/llinventorybridge.cpp | 2 +- indra/newview/llparticipantlist.cpp | 361 --------------------- indra/newview/llparticipantlist.h | 75 ----- .../skins/default/xui/en/menu_conversation.xml | 45 +++ 11 files changed, 435 insertions(+), 577 deletions(-) diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index ae4aa1e1dd..93dc13475b 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -1764,6 +1764,26 @@ bool LLMenuGL::addChild(LLView* view, S32 tab_group) return false; } +// Used in LLContextMenu and in LLTogleableMenu + +// Add an item to the context menu branch +bool LLMenuGL::addContextChild(LLView* view, S32 tab_group) +{ + LLContextMenu* context = dynamic_cast(view); + if (context) + return appendContextSubMenu(context); + + LLMenuItemSeparatorGL* separator = dynamic_cast(view); + if (separator) + return append(separator); + + LLMenuItemGL* item = dynamic_cast(view); + if (item) + return append(item); + + return false; +} + void LLMenuGL::removeChild( LLView* ctrl) { // previously a dynamic_cast with if statement to check validity @@ -2501,6 +2521,32 @@ BOOL LLMenuGL::appendMenu( LLMenuGL* menu ) return success; } +// add a context menu branch + +BOOL LLMenuGL::appendContextSubMenu(LLMenuGL *menu) + +{ + if (menu == this) + { + llerrs << "Can't attach a context menu to itself" << llendl; + } + + LLContextMenuBranch *item; + LLContextMenuBranch::Params p; + + p.name = menu->getName(); + p.label = menu->getLabel(); + p.branch = (LLContextMenu *)menu; + p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor"); + p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor"); + p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor"); + p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor"); + item = LLUICtrlFactory::create(p); + LLMenuGL::sMenuContainer->addChild(item->getBranch()); + + return append( item ); +} + void LLMenuGL::setEnabledSubMenus(BOOL enable) { setEnabled(enable); @@ -3735,39 +3781,6 @@ void LLTearOffMenu::closeTearOff() mMenu->setDropShadowed(TRUE); } - -//----------------------------------------------------------------------------- -// class LLContextMenuBranch -// A branch to another context menu -//----------------------------------------------------------------------------- -class LLContextMenuBranch : public LLMenuItemGL -{ -public: - struct Params : public LLInitParam::Block - { - Mandatory branch; - }; - - LLContextMenuBranch(const Params&); - - virtual ~LLContextMenuBranch() - {} - - // called to rebuild the draw label - virtual void buildDrawLabel( void ); - - // onCommit() - do the primary funcationality of the menu item. - virtual void onCommit( void ); - - LLContextMenu* getBranch() { return mBranch.get(); } - void setHighlight( BOOL highlight ); - -protected: - void showSubMenu(); - - LLHandle mBranch; -}; - LLContextMenuBranch::LLContextMenuBranch(const LLContextMenuBranch::Params& p) : LLMenuItemGL(p), mBranch( p.branch()->getHandle() ) @@ -4039,44 +4052,8 @@ BOOL LLContextMenu::handleRightMouseUp( S32 x, S32 y, MASK mask ) return result; } -BOOL LLContextMenu::appendContextSubMenu(LLContextMenu *menu) -{ - - if (menu == this) - { - llerrs << "Can't attach a context menu to itself" << llendl; - } - - LLContextMenuBranch *item; - LLContextMenuBranch::Params p; - p.name = menu->getName(); - p.label = menu->getLabel(); - p.branch = menu; - p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor"); - p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor"); - p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor"); - p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor"); - - item = LLUICtrlFactory::create(p); - LLMenuGL::sMenuContainer->addChild(item->getBranch()); - - return append( item ); -} - bool LLContextMenu::addChild(LLView* view, S32 tab_group) { - LLContextMenu* context = dynamic_cast(view); - if (context) - return appendContextSubMenu(context); - - LLMenuItemSeparatorGL* separator = dynamic_cast(view); - if (separator) - return append(separator); - - LLMenuItemGL* item = dynamic_cast(view); - if (item) - return append(item); - - return false; + return addContextChild(view, tab_group); } diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index a9de3ef937..3e03232e92 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -519,6 +519,9 @@ public: void resetScrollPositionOnShow(bool reset_scroll_pos) { mResetScrollPositionOnShow = reset_scroll_pos; } bool isScrollPositionOnShowReset() { return mResetScrollPositionOnShow; } + // add a context menu branch + BOOL appendContextSubMenu(LLMenuGL *menu); + protected: void createSpilloverBranch(); void cleanupSpilloverBranch(); @@ -528,6 +531,10 @@ protected: // add a menu - this will create a cascading menu virtual BOOL appendMenu( LLMenuGL* menu ); + // Used in LLContextMenu and in LLTogleableMenu + // to add an item of context menu branch + bool addContextChild(LLView* view, S32 tab_group); + // TODO: create accessor methods for these? typedef std::list< LLMenuItemGL* > item_list_t; item_list_t mItems; @@ -677,8 +684,6 @@ public: virtual bool addChild (LLView* view, S32 tab_group = 0); - BOOL appendContextSubMenu(LLContextMenu *menu); - LLHandle getHandle() { return getDerivedHandle(); } LLView* getSpawningView() const { return mSpawningViewHandle.get(); } @@ -691,7 +696,33 @@ protected: LLHandle mSpawningViewHandle; }; +//----------------------------------------------------------------------------- +// class LLContextMenuBranch +// A branch to another context menu +//----------------------------------------------------------------------------- +class LLContextMenuBranch : public LLMenuItemGL +{ +public: + struct Params : public LLInitParam::Block + { + Mandatory branch; + }; + + LLContextMenuBranch(const Params&); + + // Called to rebuild strings for this item + virtual void buildDrawLabel( void ); + // Performed when menu item clicked + virtual void onCommit( void ); + + LLContextMenu* getBranch() { return mBranch.get(); } + void setHighlight( BOOL highlight ); + +protected: + void showSubMenu(); + LLHandle mBranch; +}; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuBarGL diff --git a/indra/llui/lltoggleablemenu.cpp b/indra/llui/lltoggleablemenu.cpp index d29260750f..b4c6c6162b 100644 --- a/indra/llui/lltoggleablemenu.cpp +++ b/indra/llui/lltoggleablemenu.cpp @@ -99,3 +99,8 @@ bool LLToggleableMenu::toggleVisibility() return true; } + +bool LLToggleableMenu::addChild(LLView* view, S32 tab_group) +{ + return addContextChild(view, tab_group); +} diff --git a/indra/llui/lltoggleablemenu.h b/indra/llui/lltoggleablemenu.h index dd9ac5b8c1..57b8f62eb6 100644 --- a/indra/llui/lltoggleablemenu.h +++ b/indra/llui/lltoggleablemenu.h @@ -47,6 +47,8 @@ public: virtual void handleVisibilityChange (BOOL curVisibilityIn); + virtual bool addChild (LLView* view, S32 tab_group = 0); + const LLRect& getButtonRect() const { return mButtonRect; } // Converts the given local button rect to a screen rect diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp index e5232d730c..f0c8658cfe 100644 --- a/indra/newview/llconversationmodel.cpp +++ b/indra/newview/llconversationmodel.cpp @@ -114,6 +114,19 @@ void LLConversationItem::buildParticipantMenuOptions(menuentry_vec_t& items) items.push_back(std::string("share")); items.push_back(std::string("pay")); items.push_back(std::string("block_unblock")); + + if(this->getType() != CONV_SESSION_1_ON_1) + { + items.push_back(std::string("Moderator Options Separator")); + items.push_back(std::string("Moderator Options")); + items.push_back(std::string("AllowTextChat")); + items.push_back(std::string("moderate_voice_separator")); + items.push_back(std::string("ModerateVoiceMuteSelected")); + items.push_back(std::string("ModerateVoiceUnMuteSelected")); + items.push_back(std::string("ModerateVoiceMute")); + items.push_back(std::string("ModerateVoiceUnmute")); + } + } // diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index 5c1105531e..c9c7e94af9 100644 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -44,6 +44,7 @@ #include "llfloateravatarpicker.h" #include "llfloaterpreference.h" #include "llimview.h" +#include "llnotificationsutil.h" #include "lltransientfloatermgr.h" #include "llviewercontrol.h" #include "llconversationview.h" @@ -830,59 +831,67 @@ void LLIMFloaterContainer::getParticipantUUIDs(uuid_vec_t& selected_uuids) void LLIMFloaterContainer::doToParticipants(const std::string& command, uuid_vec_t& selectedIDS) { - if(selectedIDS.size() > 0) -{ - const LLUUID userID = selectedIDS.front(); + if(selectedIDS.size() > 0) + { + const LLUUID& userID = selectedIDS.front(); - if ("view_profile" == command) - { - LLAvatarActions::showProfile(userID); - } - else if("im" == command) - { - LLAvatarActions::startIM(userID); - } - else if("offer_teleport" == command) - { - LLAvatarActions::offerTeleport(selectedIDS); - } - else if("voice_call" == command) - { - LLAvatarActions::startCall(userID); - } - else if("chat_history" == command) - { - LLAvatarActions::viewChatHistory(userID); - } - else if("add_friend" == command) - { - LLAvatarActions::requestFriendshipDialog(userID); - } - else if("remove_friend" == command) - { - LLAvatarActions::removeFriendDialog(userID); - } - else if("invite_to_group" == command) - { - LLAvatarActions::inviteToGroup(userID); - } - else if("map" == command) - { - LLAvatarActions::showOnMap(userID); - } - else if("share" == command) - { - LLAvatarActions::share(userID); - } - else if("pay" == command) - { - LLAvatarActions::pay(userID); - } - else if("block_unblock" == command) - { - LLAvatarActions::toggleBlock(userID); - } -} + if ("view_profile" == command) + { + LLAvatarActions::showProfile(userID); + } + else if("im" == command) + { + LLAvatarActions::startIM(userID); + } + else if("offer_teleport" == command) + { + LLAvatarActions::offerTeleport(selectedIDS); + } + else if("voice_call" == command) + { + LLAvatarActions::startCall(userID); + } + else if("chat_history" == command) + { + LLAvatarActions::viewChatHistory(userID); + } + else if("add_friend" == command) + { + LLAvatarActions::requestFriendshipDialog(userID); + } + else if("remove_friend" == command) + { + LLAvatarActions::removeFriendDialog(userID); + } + else if("invite_to_group" == command) + { + LLAvatarActions::inviteToGroup(userID); + } + else if("map" == command) + { + LLAvatarActions::showOnMap(userID); + } + else if("share" == command) + { + LLAvatarActions::share(userID); + } + else if("pay" == command) + { + LLAvatarActions::pay(userID); + } + else if("block_unblock" == command) + { + LLAvatarActions::toggleBlock(userID); + } + else if("selected" == command || "mute_all" == command || "unmute_all" == command) + { + moderateVoice(command, userID); + } + else if ("toggle_allow_text_chat" == command) + { + toggleAllowTextChat(userID); + } + } } void LLIMFloaterContainer::doToSelectedConversation(const std::string& command, uuid_vec_t& selectedIDS) @@ -963,8 +972,8 @@ void LLIMFloaterContainer::doToSelectedGroup(const LLSD& userdata) bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata) { std::string item = userdata.asString(); - uuid_vec_t mUUIDs; - getParticipantUUIDs(mUUIDs); + uuid_vec_t uuids; + getParticipantUUIDs(uuids); if(item == std::string("can_activate_group")) { @@ -972,7 +981,7 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata) return gAgent.getGroupID() != selected_group_id; } - if(mUUIDs.size() <= 0) + if(uuids.size() <= 0) { return false; } @@ -982,7 +991,7 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata) if (item == std::string("can_block")) { - const LLUUID& id = mUUIDs.front(); + const LLUUID& id = uuids.front(); return LLAvatarActions::canBlock(id); } else if (item == std::string("can_add")) @@ -992,7 +1001,7 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata) // - and there are no friends among selection yet. //EXT-7389 - disable for more than 1 - if(mUUIDs.size() > 1) + if(uuids.size() > 1) { return false; } @@ -1000,8 +1009,8 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata) bool result = true; uuid_vec_t::const_iterator - id = mUUIDs.begin(), - uuids_end = mUUIDs.end(); + id = uuids.begin(), + uuids_end = uuids.end(); for (;id != uuids_end; ++id) { @@ -1020,11 +1029,11 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata) // - there are selected people // - and there are only friends among selection. - bool result = (mUUIDs.size() > 0); + bool result = (uuids.size() > 0); uuid_vec_t::const_iterator - id = mUUIDs.begin(), - uuids_end = mUUIDs.end(); + id = uuids.begin(), + uuids_end = uuids.end(); for (;id != uuids_end; ++id) { @@ -1043,15 +1052,20 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata) } else if (item == std::string("can_show_on_map")) { - const LLUUID& id = mUUIDs.front(); + const LLUUID& id = uuids.front(); return (LLAvatarTracker::instance().isBuddyOnline(id) && is_agent_mappable(id)) || gAgent.isGodlike(); } else if(item == std::string("can_offer_teleport")) { - return LLAvatarActions::canOfferTeleport(mUUIDs); + return LLAvatarActions::canOfferTeleport(uuids); } + else if("can_moderate_voice" == item || "can_allow_text_chat" == item || "can_mute" == item || "can_unmute" == item) + { + return enableModerateContextMenuItem(item); + } + return false; } @@ -1063,10 +1077,19 @@ bool LLIMFloaterContainer::checkContextMenuItem(const LLSD& userdata) if(mUUIDs.size() > 0 ) { - if (item == std::string("is_blocked")) - { - return LLAvatarActions::isBlocked(mUUIDs.front()); - } + if ("is_blocked" == item) + { + return LLAvatarActions::isBlocked(mUUIDs.front()); + } + else if ("is_allowed_text_chat" == item) + { + const LLSpeaker * speakerp = getSpeakerOfSelectedParticipant(getSpeakerMgrForSelectedParticipant()); + + if (NULL != speakerp) + { + return !speakerp->mModeratorMutedText; + } + } } return false; @@ -1284,4 +1307,189 @@ LLConversationViewParticipant* LLIMFloaterContainer::createConversationViewParti return LLUICtrlFactory::create(params); } +bool LLIMFloaterContainer::enableModerateContextMenuItem(const std::string& userdata) +{ + // only group moderators can perform actions related to this "enable callback" + if (!isGroupModerator()) + { + return false; + } + + LLSpeaker * speakerp = getSpeakerOfSelectedParticipant(getSpeakerMgrForSelectedParticipant()); + if (NULL == speakerp) + { + return false; + } + + bool voice_channel = speakerp->isInVoiceChannel(); + + if ("can_moderate_voice" == userdata) + { + return voice_channel; + } + else if ("can_mute" == userdata) + { + return voice_channel && !isMuted(getCurSelectedViewModelItem()->getUUID()); + } + else if ("can_unmute" == userdata) + { + return voice_channel && isMuted(getCurSelectedViewModelItem()->getUUID()); + } + + // The last invoke is used to check whether the "can_allow_text_chat" will enabled + return LLVoiceClient::getInstance()->isParticipantAvatar(getCurSelectedViewModelItem()->getUUID()); +} + +bool LLIMFloaterContainer::isGroupModerator() +{ + LLSpeakerMgr * speaker_manager = getSpeakerMgrForSelectedParticipant(); + if (NULL == speaker_manager) + { + llwarns << "Speaker manager is missing" << llendl; + return false; + } + + // Is session a group call/chat? + if(gAgent.isInGroup(speaker_manager->getSessionID())) + { + LLSpeaker * speaker = speaker_manager->findSpeaker(gAgentID).get(); + + // Is agent a moderator? + return speaker && speaker->mIsModerator; + } + + return false; +} + +void LLIMFloaterContainer::moderateVoice(const std::string& command, const LLUUID& userID) +{ + if (!gAgent.getRegion()) return; + + if (command.compare("selected")) + { + moderateVoiceAllParticipants(command.compare("mute_all")); + } + else + { + moderateVoiceParticipant(userID, isMuted(userID)); + } +} + +bool LLIMFloaterContainer::isMuted(const LLUUID& avatar_id) +{ + const LLSpeaker * speakerp = getSpeakerOfSelectedParticipant(getSpeakerMgrForSelectedParticipant()); + return NULL == speakerp ? true : speakerp->mStatus == LLSpeaker::STATUS_MUTED; +} + +void LLIMFloaterContainer::moderateVoiceAllParticipants(bool unmute) +{ + LLIMSpeakerMgr * speaker_managerp = dynamic_cast(getSpeakerMgrForSelectedParticipant()); + + if (NULL != speaker_managerp) + { + if (!unmute) + { + LLSD payload; + payload["session_id"] = speaker_managerp->getSessionID(); + LLNotificationsUtil::add("ConfirmMuteAll", LLSD(), payload, confirmMuteAllCallback); + return; + } + + speaker_managerp->moderateVoiceAllParticipants(unmute); + } +} + +// static +void LLIMFloaterContainer::confirmMuteAllCallback(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + // if Cancel pressed + if (option == 1) + { + return; + } + + const LLSD& payload = notification["payload"]; + const LLUUID& session_id = payload["session_id"]; + + LLIMSpeakerMgr * speaker_manager = dynamic_cast ( + LLIMModel::getInstance()->getSpeakerManager(session_id)); + if (speaker_manager) + { + speaker_manager->moderateVoiceAllParticipants(false); + } + + return; +} + +void LLIMFloaterContainer::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute) +{ + LLIMSpeakerMgr * speaker_managerp = dynamic_cast(getSpeakerMgrForSelectedParticipant()); + + if (NULL != speaker_managerp) + { + speaker_managerp->moderateVoiceParticipant(avatar_id, unmute); + } +} + +LLSpeakerMgr * LLIMFloaterContainer::getSpeakerMgrForSelectedParticipant() +{ + LLFolderViewItem * selected_folder_itemp = mConversationsRoot->getCurSelectedItem(); + if (NULL == selected_folder_itemp) + { + llwarns << "Current selected item is null" << llendl; + return NULL; + } + + LLFolderViewFolder * conversation_itemp = selected_folder_itemp->getParentFolder(); + + conversations_widgets_map::const_iterator iter = mConversationsWidgets.begin(); + conversations_widgets_map::const_iterator end = mConversationsWidgets.end(); + const LLUUID * conversation_uuidp = NULL; + while(iter != end) + { + if (iter->second == conversation_itemp) + { + conversation_uuidp = &iter->first; + break; + } + ++iter; + } + if (NULL == conversation_uuidp) + { + llwarns << "Cannot find conversation item widget" << llendl; + return NULL; + } + + return conversation_uuidp->isNull() ? (LLSpeakerMgr *)LLLocalSpeakerMgr::getInstance() + : LLIMModel::getInstance()->getSpeakerManager(*conversation_uuidp); +} + +LLSpeaker * LLIMFloaterContainer::getSpeakerOfSelectedParticipant(LLSpeakerMgr * speaker_managerp) +{ + if (NULL == speaker_managerp) + { + llwarns << "Speaker manager is missing" << llendl; + return NULL; + } + + const LLConversationItem * participant_itemp = getCurSelectedViewModelItem(); + if (NULL == participant_itemp) + { + llwarns << "Cannot evaluate current selected view model item" << llendl; + return NULL; + } + + return speaker_managerp->findSpeaker(participant_itemp->getUUID()); +} + +void LLIMFloaterContainer::toggleAllowTextChat(const LLUUID& participant_uuid) +{ + LLIMSpeakerMgr * speaker_managerp = dynamic_cast(getSpeakerMgrForSelectedParticipant()); + if (NULL != speaker_managerp) + { + speaker_managerp->toggleAllowTextChat(participant_uuid); + } +} + // EOF diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h index 579f62c688..ba2d085858 100644 --- a/indra/newview/llimfloatercontainer.h +++ b/indra/newview/llimfloatercontainer.h @@ -45,6 +45,8 @@ class LLLayoutPanel; class LLLayoutStack; class LLTabContainer; class LLIMFloaterContainer; +class LLSpeaker; +class LLSpeakerMgr; class LLIMFloaterContainer : public LLMultiFloater @@ -126,6 +128,17 @@ private: bool checkContextMenuItem(const LLSD& userdata); bool enableContextMenuItem(const LLSD& userdata); + static void confirmMuteAllCallback(const LLSD& notification, const LLSD& response); + bool enableModerateContextMenuItem(const std::string& userdata); + LLSpeaker * getSpeakerOfSelectedParticipant(LLSpeakerMgr * speaker_managerp); + LLSpeakerMgr * getSpeakerMgrForSelectedParticipant(); + bool isGroupModerator(); + bool isMuted(const LLUUID& avatar_id); + void moderateVoice(const std::string& command, const LLUUID& userID); + void moderateVoiceAllParticipants(bool unmute); + void moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute); + void toggleAllowTextChat(const LLUUID& participant_uuid); + LLButton* mExpandCollapseBtn; LLLayoutPanel* mMessagesPane; LLLayoutPanel* mConversationsPane; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 139713b96e..28c2edbe84 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -577,7 +577,7 @@ void hide_context_entries(LLMenuGL& menu, // descend into split menus: LLMenuItemBranchGL* branchp = dynamic_cast(menu_item); - if ((name == "More") && branchp) + if (NULL != branchp) { hide_context_entries(*branchp->getBranch(), entries_to_show, disabled_entries); } diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp index 90226e7fba..b263143bd1 100644 --- a/indra/newview/llparticipantlist.cpp +++ b/indra/newview/llparticipantlist.cpp @@ -213,7 +213,6 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, LLConversationItemSession(data_source->getSessionID(), root_view_model), mSpeakerMgr(data_source), mAvatarList(avatar_list), - mParticipantListMenu(NULL), mExcludeAgent(exclude_agent), mValidateSpeakerCallback(NULL) { @@ -248,8 +247,6 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, if (use_context_menu) { - //mParticipantListMenu = new LLParticipantListMenu(*this); - //mAvatarList->setContextMenu(mParticipantListMenu); mAvatarList->setContextMenu(&LLPanelPeopleMenus::gNearbyMenu); } else @@ -316,20 +313,6 @@ LLParticipantList::~LLParticipantList() mAvatarListToggleIconsConnection.disconnect(); } - // It is possible Participant List will be re-created from LLCallFloater::onCurrentChannelChanged() - // See ticket EXT-3427 - // hide menu before deleting it to stop enable and check handlers from triggering. - if(mParticipantListMenu && !LLApp::isExiting()) - { - mParticipantListMenu->hide(); - } - - if (mParticipantListMenu) - { - delete mParticipantListMenu; - mParticipantListMenu = NULL; - } - if (mAvatarList) { mAvatarList->setContextMenu(NULL); @@ -786,350 +769,6 @@ bool LLParticipantList::SpeakerMuteListener::handleEvent(LLPointersize() > 1); - main_menu->setItemVisible("SortByName", is_sort_visible); - main_menu->setItemVisible("SortByRecentSpeakers", is_sort_visible); - main_menu->setItemVisible("Moderator Options Separator", isGroupModerator()); - main_menu->setItemVisible("Moderator Options", isGroupModerator()); - main_menu->setItemVisible("View Icons Separator", mParent.mAvatarListToggleIconsConnection.connected()); - main_menu->setItemVisible("View Icons", mParent.mAvatarListToggleIconsConnection.connected()); - main_menu->arrangeAndClear(); - - return main_menu; -}*/ - -void LLParticipantList::LLParticipantListMenu::show(LLView* spawning_view, const uuid_vec_t& uuids, S32 x, S32 y) -{ - if (uuids.size() == 0) return; - - LLListContextMenu::show(spawning_view, uuids, x, y); - - const LLUUID& speaker_id = mUUIDs.front(); - BOOL is_muted = isMuted(speaker_id); - - if (is_muted) - { - LLMenuGL::sMenuContainer->getChildView("ModerateVoiceMuteSelected")->setVisible( false); - } - else - { - LLMenuGL::sMenuContainer->getChildView("ModerateVoiceUnMuteSelected")->setVisible( false); - } -} - -void LLParticipantList::LLParticipantListMenu::sortParticipantList(const LLSD& userdata) -{ - std::string param = userdata.asString(); - if ("sort_by_name" == param) - { - mParent.setSortOrder(E_SORT_BY_NAME); - } - else if ("sort_by_recent_speakers" == param) - { - mParent.setSortOrder(E_SORT_BY_RECENT_SPEAKERS); - } -} - -void LLParticipantList::LLParticipantListMenu::toggleAllowTextChat(const LLSD& userdata) -{ - - LLIMSpeakerMgr* mgr = dynamic_cast(mParent.mSpeakerMgr); - if (mgr) - { - const LLUUID speaker_id = mUUIDs.front(); - mgr->toggleAllowTextChat(speaker_id); - } -} - -void LLParticipantList::LLParticipantListMenu::toggleMute(const LLSD& userdata, U32 flags) -{ - const LLUUID speaker_id = mUUIDs.front(); - BOOL is_muted = LLMuteList::getInstance()->isMuted(speaker_id, flags); - std::string name; - - //fill in name using voice client's copy of name cache - LLPointer speakerp = mParent.mSpeakerMgr->findSpeaker(speaker_id); - if (speakerp.isNull()) - { - LL_WARNS("Speakers") << "Speaker " << speaker_id << " not found" << llendl; - return; - } - LLAvatarListItem* item = (mParent.mAvatarList ? dynamic_cast(mParent.mAvatarList->getItemByValue(speaker_id)) : NULL); - if (NULL == item) return; - - name = item->getAvatarName(); - - LLMute::EType mute_type; - switch (speakerp->mType) - { - case LLSpeaker::SPEAKER_AGENT: - mute_type = LLMute::AGENT; - break; - case LLSpeaker::SPEAKER_OBJECT: - mute_type = LLMute::OBJECT; - break; - case LLSpeaker::SPEAKER_EXTERNAL: - default: - mute_type = LLMute::EXTERNAL; - break; - } - LLMute mute(speaker_id, name, mute_type); - - if (!is_muted) - { - LLMuteList::getInstance()->add(mute, flags); - } - else - { - LLMuteList::getInstance()->remove(mute, flags); - } -} - -void LLParticipantList::LLParticipantListMenu::toggleMuteText(const LLSD& userdata) -{ - toggleMute(userdata, LLMute::flagTextChat); -} - -void LLParticipantList::LLParticipantListMenu::toggleMuteVoice(const LLSD& userdata) -{ - toggleMute(userdata, LLMute::flagVoiceChat); -} - -bool LLParticipantList::LLParticipantListMenu::isGroupModerator() -{ - if (!mParent.mSpeakerMgr) - { - llwarns << "Speaker manager is missing" << llendl; - return false; - } - - // Is session a group call/chat? - if(gAgent.isInGroup(mParent.mSpeakerMgr->getSessionID())) - { - LLSpeaker* speaker = mParent.mSpeakerMgr->findSpeaker(gAgentID).get(); - - // Is agent a moderator? - return speaker && speaker->mIsModerator; - } - return false; -} - -bool LLParticipantList::LLParticipantListMenu::isMuted(const LLUUID& avatar_id) -{ - LLPointer selected_speakerp = mParent.mSpeakerMgr->findSpeaker(avatar_id); - if (!selected_speakerp) return true; - - return selected_speakerp->mStatus == LLSpeaker::STATUS_MUTED; -} - -void LLParticipantList::LLParticipantListMenu::moderateVoice(const LLSD& userdata) -{ - if (!gAgent.getRegion()) return; - - bool moderate_selected = userdata.asString() == "selected"; - - if (moderate_selected) - { - const LLUUID& selected_avatar_id = mUUIDs.front(); - bool is_muted = isMuted(selected_avatar_id); - moderateVoiceParticipant(selected_avatar_id, is_muted); - } - else - { - bool unmute_all = userdata.asString() == "unmute_all"; - moderateVoiceAllParticipants(unmute_all); - } -} - -void LLParticipantList::LLParticipantListMenu::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute) -{ - LLIMSpeakerMgr* mgr = dynamic_cast(mParent.mSpeakerMgr); - if (mgr) - { - mgr->moderateVoiceParticipant(avatar_id, unmute); - } -} - -void LLParticipantList::LLParticipantListMenu::moderateVoiceAllParticipants(bool unmute) -{ - LLIMSpeakerMgr* mgr = dynamic_cast(mParent.mSpeakerMgr); - if (mgr) - { - if (!unmute) - { - LLSD payload; - payload["session_id"] = mgr->getSessionID(); - LLNotificationsUtil::add("ConfirmMuteAll", LLSD(), payload, confirmMuteAllCallback); - return; - } - - mgr->moderateVoiceAllParticipants(unmute); - } -} - -// static -void LLParticipantList::LLParticipantListMenu::confirmMuteAllCallback(const LLSD& notification, const LLSD& response) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - // if Cancel pressed - if (option == 1) - { - return; - } - - const LLSD& payload = notification["payload"]; - const LLUUID& session_id = payload["session_id"]; - - LLIMSpeakerMgr * speaker_manager = dynamic_cast ( - LLIMModel::getInstance()->getSpeakerManager(session_id)); - if (speaker_manager) - { - speaker_manager->moderateVoiceAllParticipants(false); - } - - return; -} - - -bool LLParticipantList::LLParticipantListMenu::enableContextMenuItem(const LLSD& userdata) -{ - std::string item = userdata.asString(); - const LLUUID& participant_id = mUUIDs.front(); - - // For now non of "can_view_profile" action and menu actions listed below except "can_block" - // can be performed for Avaline callers. - bool is_participant_avatar = LLVoiceClient::getInstance()->isParticipantAvatar(participant_id); - if (!is_participant_avatar && "can_block" != item) return false; - - if (item == "can_mute_text" || "can_block" == item || "can_share" == item || "can_im" == item - || "can_pay" == item) - { - return mUUIDs.front() != gAgentID; - } - else if (item == std::string("can_add")) - { - // We can add friends if: - // - there are selected people - // - and there are no friends among selection yet. - - bool result = (mUUIDs.size() > 0); - - uuid_vec_t::const_iterator - id = mUUIDs.begin(), - uuids_end = mUUIDs.end(); - - for (;id != uuids_end; ++id) - { - if ( *id == gAgentID || LLAvatarActions::isFriend(*id) ) - { - result = false; - break; - } - } - return result; - } - else if (item == "can_call") - { - bool not_agent = mUUIDs.front() != gAgentID; - bool can_call = not_agent && LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking(); - return can_call; - } - - return true; -} - -/* - Processed menu items with such parameters: - can_allow_text_chat - can_moderate_voice -*/ -bool LLParticipantList::LLParticipantListMenu::enableModerateContextMenuItem(const LLSD& userdata) -{ - // only group moderators can perform actions related to this "enable callback" - if (!isGroupModerator()) return false; - - const LLUUID& participant_id = mUUIDs.front(); - LLPointer speakerp = mParent.mSpeakerMgr->findSpeaker(participant_id); - - // not in voice participants can not be moderated - bool speaker_in_voice = speakerp.notNull() && speakerp->isInVoiceChannel(); - - const std::string& item = userdata.asString(); - - if ("can_moderate_voice" == item) - { - return speaker_in_voice; - } - - // For now non of menu actions except "can_moderate_voice" can be performed for Avaline callers. - bool is_participant_avatar = LLVoiceClient::getInstance()->isParticipantAvatar(participant_id); - if (!is_participant_avatar) return false; - - return true; -} - -bool LLParticipantList::LLParticipantListMenu::checkContextMenuItem(const LLSD& userdata) -{ - std::string item = userdata.asString(); - const LLUUID& id = mUUIDs.front(); - - if (item == "is_muted") - { - return LLMuteList::getInstance()->isMuted(id, LLMute::flagTextChat); - } - else if (item == "is_allowed_text_chat") - { - LLPointer selected_speakerp = mParent.mSpeakerMgr->findSpeaker(id); - - if (selected_speakerp.notNull()) - { - return !selected_speakerp->mModeratorMutedText; - } - } - else if(item == "is_blocked") - { - return LLMuteList::getInstance()->isMuted(id, LLMute::flagVoiceChat); - } - else if(item == "is_sorted_by_name") - { - return E_SORT_BY_NAME == mParent.getSortOrder(); - } - else if(item == "is_sorted_by_recent_speakers") - { - return E_SORT_BY_RECENT_SPEAKERS == mParent.getSortOrder(); - } - - return false; -} - bool LLParticipantList::LLAvatarItemRecentSpeakerComparator::doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const { if (mParent.mSpeakerMgr) diff --git a/indra/newview/llparticipantlist.h b/indra/newview/llparticipantlist.h index acee68873c..aaf1e070a5 100644 --- a/indra/newview/llparticipantlist.h +++ b/indra/newview/llparticipantlist.h @@ -159,79 +159,6 @@ protected: /*virtual*/ bool handleEvent(LLPointer event, const LLSD& userdata); }; - /** - * Menu used in the participant list. - */ - class LLParticipantListMenu : public LLListContextMenu - { - public: - LLParticipantListMenu(LLParticipantList& parent):mParent(parent){}; - /*virtual*/ LLContextMenu* createMenu(); - /*virtual*/ void show(LLView* spawning_view, const uuid_vec_t& uuids, S32 x, S32 y); - protected: - LLParticipantList& mParent; - private: - bool enableContextMenuItem(const LLSD& userdata); - bool enableModerateContextMenuItem(const LLSD& userdata); - bool checkContextMenuItem(const LLSD& userdata); - - void sortParticipantList(const LLSD& userdata); - void toggleAllowTextChat(const LLSD& userdata); - void toggleMute(const LLSD& userdata, U32 flags); - void toggleMuteText(const LLSD& userdata); - void toggleMuteVoice(const LLSD& userdata); - - /** - * Return true if Agent is group moderator(and moderator of group call). - */ - bool isGroupModerator(); - - // Voice moderation support - /** - * Check whether specified by argument avatar is muted for group chat or not. - */ - bool isMuted(const LLUUID& avatar_id); - - /** - * Processes Voice moderation menu items. - * - * It calls either moderateVoiceParticipant() or moderateVoiceParticipant() depend on - * passed parameter. - * - * @param userdata can be "selected" or "others". - * - * @see moderateVoiceParticipant() - * @see moderateVoiceAllParticipants() - */ - void moderateVoice(const LLSD& userdata); - - /** - * Mutes/Unmutes avatar for current group voice chat. - * - * It only marks avatar as muted for session and does not use local Agent's Block list. - * It does not mute Agent itself. - * - * @param[in] avatar_id UUID of avatar to be processed - * @param[in] unmute if true - specified avatar will be muted, otherwise - unmuted. - * - * @see moderateVoiceAllParticipants() - */ - void moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute); - - /** - * Mutes/Unmutes all avatars for current group voice chat. - * - * It only marks avatars as muted for session and does not use local Agent's Block list. - * - * @param[in] unmute if true - avatars will be muted, otherwise - unmuted. - * - * @see moderateVoiceParticipant() - */ - void moderateVoiceAllParticipants(bool unmute); - - static void confirmMuteAllCallback(const LLSD& notification, const LLSD& response); - }; - /** * Comparator for comparing avatar items by last spoken time */ @@ -276,8 +203,6 @@ private: LLPointer mSpeakerModeratorListener; LLPointer mSpeakerMuteListener; - LLParticipantListMenu* mParticipantListMenu; - /** * This field manages an adding a new avatar_id in the mAvatarList * If true, then agent_id wont be added into mAvatarList diff --git a/indra/newview/skins/default/xui/en/menu_conversation.xml b/indra/newview/skins/default/xui/en/menu_conversation.xml index 682d70e4f0..2e9bda5804 100644 --- a/indra/newview/skins/default/xui/en/menu_conversation.xml +++ b/indra/newview/skins/default/xui/en/menu_conversation.xml @@ -125,4 +125,49 @@ name="leave_group"> + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3