From fe0da9bf7b81d24a9614f95d9f91012796eabf77 Mon Sep 17 00:00:00 2001 From: Paul Guslisty <pguslisty@productengine.com> Date: Mon, 14 Dec 2009 19:53:54 +0200 Subject: [PATCH] Fixed low bug EXT - 3255 (Call button is enabled in the People & Profile panels while voice is disabled) --HG-- branch : product-engine --- indra/newview/llavataractions.cpp | 19 ++++++++++++++ indra/newview/llavataractions.h | 5 ++++ indra/newview/llpanelavatar.cpp | 2 +- indra/newview/llpanelpeople.cpp | 25 ++++++++++++++++++- indra/newview/llpanelpeople.h | 1 + indra/newview/llpanelpeoplemenus.cpp | 18 +++++++++++++ .../default/xui/en/menu_people_nearby.xml | 3 +++ .../xui/en/menu_people_nearby_multiselect.xml | 3 +++ 8 files changed, 74 insertions(+), 2 deletions(-) diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 5f90a7627f3..33dc7ee2c8f 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -61,6 +61,7 @@ #include "llviewerregion.h" #include "llimfloater.h" #include "lltrans.h" +#include "llcallingcard.h" // static void LLAvatarActions::requestFriendshipDialog(const LLUUID& id, const std::string& name) @@ -265,6 +266,24 @@ bool LLAvatarActions::isCalling(const LLUUID &id) return (LLIMModel::getInstance()->findIMSession(session_id) != NULL); } +//static +bool LLAvatarActions::canCall(const LLUUID &id) +{ + if(isFriend(id)) + { + return LLAvatarTracker::instance().isBuddyOnline(id) && LLVoiceClient::voiceEnabled(); + } + else + { + // don't need to check online/offline status because "usual resident" (resident that is not a friend) + // can be only ONLINE. There is no way to see "usual resident" in OFFLINE status. If we see "usual + // resident" it automatically means that the resident is ONLINE. So to make a call to the "usual resident" + // we need to check only that "our" voice is enabled. + return LLVoiceClient::voiceEnabled(); + } + +} + // static void LLAvatarActions::startConference(const std::vector<LLUUID>& ids) { diff --git a/indra/newview/llavataractions.h b/indra/newview/llavataractions.h index 2dd2a4c4b12..01c18d42285 100644 --- a/indra/newview/llavataractions.h +++ b/indra/newview/llavataractions.h @@ -128,6 +128,11 @@ class LLAvatarActions */ static bool isCalling(const LLUUID &id); + /** + * @return true if call to the resident can be made (resident is online and voice is enabled) + */ + + static bool canCall(const LLUUID &id); /** * Invite avatar to a group. */ diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index b9f422ca6f6..ffe7f571676 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -396,7 +396,7 @@ void LLPanelProfileTab::updateButtons() && gAgent.isGodlike() || is_agent_mappable(getAvatarId()); childSetEnabled("show_on_map_btn", enable_map_btn); - childSetEnabled("call", LLVoiceClient::voiceEnabled()); + childSetEnabled("call", LLAvatarActions::canCall(getAvatarId())); } ////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 79a593a8c90..e1348401533 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -776,7 +776,7 @@ void LLPanelPeople::updateButtons() buttonSetEnabled("teleport_btn", friends_tab_active && item_selected && isFriendOnline(selected_uuids.front())); buttonSetEnabled("view_profile_btn", item_selected); buttonSetEnabled("im_btn", multiple_selected); // allow starting the friends conference for multiple selection - buttonSetEnabled("call_btn", multiple_selected && LLVoiceClient::voiceEnabled()); + buttonSetEnabled("call_btn", multiple_selected && canCall()); buttonSetEnabled("share_btn", item_selected); // not implemented yet bool none_group_selected = item_selected && selected_id.isNull(); @@ -784,6 +784,29 @@ void LLPanelPeople::updateButtons() buttonSetEnabled("chat_btn", !none_group_selected); } +bool LLPanelPeople::canCall() +{ + std::vector<LLUUID> selected_uuids; + getCurrentItemIDs(selected_uuids); + + bool result = false; + + std::vector<LLUUID>::const_iterator + id = selected_uuids.begin(), + uuids_end = selected_uuids.end(); + + for (;id != uuids_end; ++id) + { + if (LLAvatarActions::canCall(*id)) + { + result = true; + break; + } + } + + return result; +} + std::string LLPanelPeople::getActiveTabName() const { return mTabContainer->getCurrentPanel()->getName(); diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index 750d3b573f5..f5cdc0935c3 100644 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -73,6 +73,7 @@ class LLPanelPeople : public LLPanel bool isFriendOnline(const LLUUID& id); bool isItemsFreeOfFriends(const std::vector<LLUUID>& uuids); + bool canCall(); void updateButtons(); std::string getActiveTabName() const; diff --git a/indra/newview/llpanelpeoplemenus.cpp b/indra/newview/llpanelpeoplemenus.cpp index 573de1e51ce..0314642d9eb 100644 --- a/indra/newview/llpanelpeoplemenus.cpp +++ b/indra/newview/llpanelpeoplemenus.cpp @@ -181,7 +181,25 @@ bool NearbyMenu::enableContextMenuItem(const LLSD& userdata) const LLUUID& id = mUUIDs.front(); return LLAvatarActions::isFriend(id); } + else if (item == std::string("can_call")) + { + bool result = false; + int size = mUUIDs.size(); + std::cout << size << std::endl; + std::vector<LLUUID>::const_iterator + id = mUUIDs.begin(), + uuids_end = mUUIDs.end(); + for (;id != uuids_end; ++id) + { + if (LLAvatarActions::canCall(*id)) + { + result = true; + break; + } + } + return result; + } return false; } diff --git a/indra/newview/skins/default/xui/en/menu_people_nearby.xml b/indra/newview/skins/default/xui/en/menu_people_nearby.xml index 39469f7101c..5f2e6e0f6c6 100644 --- a/indra/newview/skins/default/xui/en/menu_people_nearby.xml +++ b/indra/newview/skins/default/xui/en/menu_people_nearby.xml @@ -32,6 +32,9 @@ name="Call"> <menu_item_call.on_click function="Avatar.Call" /> + <menu_item_call.on_enable + function="Avatar.EnableItem" + parameter="can_call" /> </menu_item_call> <menu_item_call label="Share" diff --git a/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml b/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml index df74d2dcd4b..0d3dd3366d4 100644 --- a/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml +++ b/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml @@ -27,6 +27,9 @@ name="Call"> <on_click function="Avatar.Call" /> + <on_enable + function="Avatar.EnableItem" + parameter="can_call" /> </menu_item_call> <menu_item_call enabled="false" -- GitLab