Skip to content

Commit af112c2

Browse files
committed
#2303 An error occured while trying to connect to voice
1 parent fc1c563 commit af112c2

7 files changed

+51
-17
lines changed

indra/newview/llavataractions.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,21 @@ bool LLAvatarActions::isCalling(const LLUUID &id)
303303
//static
304304
bool LLAvatarActions::canCall()
305305
{
306-
return LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking();
306+
if (LLVoiceClient* voice_client = LLVoiceClient::getInstance())
307+
{
308+
return voice_client->voiceEnabled() && voice_client->isVoiceWorking();
309+
}
310+
return false;
311+
}
312+
313+
//static
314+
bool LLAvatarActions::canCallTo(const LLUUID& id)
315+
{
316+
if (LLVoiceClient* voice_client = LLVoiceClient::getInstance())
317+
{
318+
return voice_client->voiceEnabled() && voice_client->isVoiceWorking() && voice_client->getVoiceEnabled(id);
319+
}
320+
return false;
307321
}
308322

309323
// static

indra/newview/llavataractions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ class LLAvatarActions
184184
*/
185185

186186
static bool canCall();
187+
static bool canCallTo(const LLUUID& id);
188+
187189
/**
188190
* Invite avatar to a group.
189191
*/

indra/newview/llfloaterbump.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ LLFloaterBump::LLFloaterBump(const LLSD& key)
5656
mCommitCallbackRegistrar.add("ShowAgentProfile", { boost::bind(&LLFloaterBump::showProfile, this), cb_info::UNTRUSTED_THROTTLE });
5757
mCommitCallbackRegistrar.add("Avatar.InviteToGroup", { boost::bind(&LLFloaterBump::inviteToGroup, this), cb_info::UNTRUSTED_THROTTLE });
5858
mCommitCallbackRegistrar.add("Avatar.Call", { boost::bind(&LLFloaterBump::startCall, this), cb_info::UNTRUSTED_BLOCK });
59-
mEnableCallbackRegistrar.add("Avatar.EnableCall", boost::bind(&LLAvatarActions::canCall));
59+
mEnableCallbackRegistrar.add("Avatar.EnableCall", { boost::bind(&LLFloaterBump::canCall, this), cb_info::UNTRUSTED_BLOCK });
6060
mCommitCallbackRegistrar.add("Avatar.AddFriend", { boost::bind(&LLFloaterBump::addFriend, this), cb_info::UNTRUSTED_THROTTLE });
6161
mEnableCallbackRegistrar.add("Avatar.EnableAddFriend", boost::bind(&LLFloaterBump::enableAddFriend, this));
6262
mCommitCallbackRegistrar.add("Avatar.Mute", { boost::bind(&LLFloaterBump::muteAvatar, this), cb_info::UNTRUSTED_BLOCK });
@@ -214,6 +214,11 @@ void LLFloaterBump::startCall()
214214
LLAvatarActions::startCall(mItemUUID);
215215
}
216216

217+
bool LLFloaterBump::canCall()
218+
{
219+
return LLAvatarActions::canCallTo(mItemUUID);
220+
}
221+
217222
void LLFloaterBump::reportAbuse()
218223
{
219224
LLFloaterReporter::showFromAvatar(mItemUUID, "av_name");

indra/newview/llfloaterbump.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class LLFloaterBump
5252

5353
void startIM();
5454
void startCall();
55+
bool canCall();
5556
void reportAbuse();
5657
void showProfile();
5758
void addFriend();

indra/newview/llfloaterimcontainer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,15 +1592,15 @@ bool LLFloaterIMContainer::enableContextMenuItem(const std::string& item, uuid_v
15921592
}
15931593
else if ("can_call" == item)
15941594
{
1595+
if (is_single_select)
1596+
{
1597+
return LLAvatarActions::canCallTo(single_id);
1598+
}
15951599
return LLAvatarActions::canCall();
15961600
}
15971601
else if ("can_open_voice_conversation" == item)
15981602
{
1599-
return is_single_select && LLAvatarActions::canCall();
1600-
}
1601-
else if ("can_open_voice_conversation" == item)
1602-
{
1603-
return is_single_select && LLAvatarActions::canCall();
1603+
return is_single_select && LLAvatarActions::canCallTo(single_id);
16041604
}
16051605
else if ("can_zoom_in" == item)
16061606
{

indra/newview/llpanelprofile.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,6 @@ void LLPanelProfileSecondLife::onOpen(const LLSD& key)
754754

755755
resetData();
756756

757-
LLUUID avatar_id = getAvatarId();
758-
759757
bool own_profile = getSelfProfile();
760758

761759
mGroupList->setShowNone(!own_profile);
@@ -793,7 +791,8 @@ void LLPanelProfileSecondLife::onOpen(const LLSD& key)
793791

794792
if (!own_profile)
795793
{
796-
mVoiceStatus = LLAvatarActions::canCall() && (LLAvatarActions::isFriend(avatar_id) ? LLAvatarTracker::instance().isBuddyOnline(avatar_id) : true);
794+
LLUUID avatar_id = getAvatarId();
795+
mVoiceStatus = LLAvatarActions::canCallTo(avatar_id);
797796
updateOnlineStatus();
798797
fillRightsData();
799798
}
@@ -1217,12 +1216,11 @@ void LLPanelProfileSecondLife::changed(U32 mask)
12171216
// virtual, called by LLVoiceClient
12181217
void LLPanelProfileSecondLife::onChange(EStatusType status, const LLSD& channelInfo, bool proximal)
12191218
{
1220-
if(status == STATUS_JOINING || status == STATUS_LEFT_CHANNEL)
1219+
if (status != STATUS_JOINING && status != STATUS_LEFT_CHANNEL)
12211220
{
1222-
return;
1221+
LLUUID avatar_id = getAvatarId();
1222+
mVoiceStatus = LLAvatarActions::canCallTo(avatar_id);
12231223
}
1224-
1225-
mVoiceStatus = LLAvatarActions::canCall() && (LLAvatarActions::isFriend(getAvatarId()) ? LLAvatarTracker::instance().isBuddyOnline(getAvatarId()) : true);
12261224
}
12271225

12281226
void LLPanelProfileSecondLife::setAvatarId(const LLUUID& avatar_id)

indra/newview/llviewermenu.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7808,15 +7808,29 @@ class LLAvatarSendIM : public view_listener_t
78087808

78097809
class LLAvatarCall : public view_listener_t
78107810
{
7811+
static LLVOAvatar* findAvatar()
7812+
{
7813+
return find_avatar_from_object(LLSelectMgr::getInstance()->getSelection()->getPrimaryObject());
7814+
}
7815+
78117816
bool handleEvent(const LLSD& userdata)
78127817
{
7813-
LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() );
7814-
if(avatar)
7818+
if (LLVOAvatar* avatar = findAvatar())
78157819
{
78167820
LLAvatarActions::startCall(avatar->getID());
78177821
}
78187822
return true;
78197823
}
7824+
7825+
public:
7826+
static bool isAvailable()
7827+
{
7828+
if (LLVOAvatar* avatar = findAvatar())
7829+
{
7830+
return LLAvatarActions::canCallTo(avatar->getID());
7831+
}
7832+
return LLAvatarActions::canCall();
7833+
}
78207834
};
78217835

78227836
namespace
@@ -10075,7 +10089,7 @@ void initialize_menus()
1007510089
registrar.add("Avatar.ShowInspector", boost::bind(&handle_avatar_show_inspector));
1007610090
view_listener_t::addMenu(new LLAvatarSendIM(), "Avatar.SendIM");
1007710091
view_listener_t::addMenu(new LLAvatarCall(), "Avatar.Call", cb_info::UNTRUSTED_BLOCK);
10078-
enable.add("Avatar.EnableCall", boost::bind(&LLAvatarActions::canCall));
10092+
enable.add("Avatar.EnableCall", boost::bind(&LLAvatarCall::isAvailable));
1007910093
view_listener_t::addMenu(new LLAvatarReportAbuse(), "Avatar.ReportAbuse", cb_info::UNTRUSTED_THROTTLE);
1008010094
view_listener_t::addMenu(new LLAvatarToggleMyProfile(), "Avatar.ToggleMyProfile");
1008110095
view_listener_t::addMenu(new LLAvatarTogglePicks(), "Avatar.TogglePicks");

0 commit comments

Comments
 (0)