From a9b16734a1690551cc6277dc419dcb8629f4ddd1 Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Mon, 9 Nov 2009 19:28:14 +0000 Subject: DEV-41317 DEV-41318: Enabled the Call button in the Profile panel. I've added a new LLAvatarActions::startCall() method to make it easy to start a new P2P call. The Resident Profile "Call" button is now hooked up to this. I've also put back the "Call" menu in the avatar popup menu and hooked this up too. While I was there I noticed that the "IM" popup menu code could all be removed in favor of a call to LLAvatarActions::startIM(). --- indra/newview/llavataractions.cpp | 32 ++++++++++++++++++++++ indra/newview/llavataractions.h | 10 +++++++ indra/newview/llviewermenu.cpp | 32 ++++++++++------------ .../newview/skins/default/xui/en/panel_profile.xml | 1 - 4 files changed, 56 insertions(+), 19 deletions(-) (limited to 'indra') diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 3fc37aa3d5..dae4296a82 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -185,6 +185,38 @@ void LLAvatarActions::startIM(const LLUUID& id) make_ui_sound("UISndStartIM"); } +// static +void LLAvatarActions::startCall(const LLUUID& id) +{ + if (id.isNull() || isCalling(id)) + { + return; + } + + std::string name; + gCacheName->getFullName(id, name); + LLUUID session_id = gIMMgr->addSession(name, IM_NOTHING_SPECIAL, id); + if (session_id != LLUUID::null) + { + // always open IM window when connecting to voice + LLIMFloater::show(session_id); + gIMMgr->startCall(session_id); + } + make_ui_sound("UISndStartIM"); +} + +// static +bool LLAvatarActions::isCalling(const LLUUID &id) +{ + if (id.isNull()) + { + return false; + } + + LLUUID session_id = gIMMgr->computeSessionID(IM_NOTHING_SPECIAL, id); + return (LLIMModel::getInstance()->findIMSession(session_id) != NULL); +} + // static void LLAvatarActions::startConference(const std::vector& ids) { diff --git a/indra/newview/llavataractions.h b/indra/newview/llavataractions.h index 512f673b43..0ec20ae357 100644 --- a/indra/newview/llavataractions.h +++ b/indra/newview/llavataractions.h @@ -66,6 +66,11 @@ public: */ static void startIM(const LLUUID& id); + /** + * Start an avatar-to-avatar voice call with another user + */ + static void startCall(const LLUUID& id); + /** * Start conference chat with the given avatars. */ @@ -96,6 +101,11 @@ public: */ static bool isBlocked(const LLUUID& id); + /** + * Return true if the avatar is in a P2P voice call with a given user + */ + static bool isCalling(const LLUUID &id); + /** * Invite avatar to a group. */ diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 07d073c3a9..b086e6d055 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -6249,25 +6249,20 @@ class LLAvatarSendIM : public view_listener_t LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); if(avatar) { - std::string name("IM"); - LLNameValue *first = avatar->getNVPair("FirstName"); - LLNameValue *last = avatar->getNVPair("LastName"); - if (first && last) - { - name.assign( first->getString() ); - name.append(" "); - name.append( last->getString() ); - } + LLAvatarActions::startIM(avatar->getID()); + } + return true; + } +}; - //EInstantMessage type = have_agent_callingcard(gLastHitObjectID) - // ? IM_SESSION_ADD : IM_SESSION_CARDLESS_START; - LLUUID session_id = gIMMgr->addSession(name, - IM_NOTHING_SPECIAL, - avatar->getID()); - if (session_id != LLUUID::null) - { - LLIMFloater::show(session_id); - } +class LLAvatarCall : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); + if(avatar) + { + LLAvatarActions::startCall(avatar->getID()); } return true; } @@ -7938,6 +7933,7 @@ void initialize_menus() view_listener_t::addMenu(new LLAvatarGiveCard(), "Avatar.GiveCard"); commit.add("Avatar.Eject", boost::bind(&handle_avatar_eject, LLSD())); view_listener_t::addMenu(new LLAvatarSendIM(), "Avatar.SendIM"); + view_listener_t::addMenu(new LLAvatarCall(), "Avatar.Call"); view_listener_t::addMenu(new LLAvatarReportAbuse(), "Avatar.ReportAbuse"); view_listener_t::addMenu(new LLAvatarEnableAddFriend(), "Avatar.EnableAddFriend"); diff --git a/indra/newview/skins/default/xui/en/panel_profile.xml b/indra/newview/skins/default/xui/en/panel_profile.xml index a0055383b1..0f5e96416d 100644 --- a/indra/newview/skins/default/xui/en/panel_profile.xml +++ b/indra/newview/skins/default/xui/en/panel_profile.xml @@ -294,7 +294,6 @@ left_pad="5" width="45" />