From 022fba2ba48d72ec21fcb374488a25f456c04b9b Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Tue, 8 Jan 2019 11:27:51 -0500 Subject: [PATCH] Add option "Add to Conference" to Conference chats and Instant Messages Sync code from upstream for inviting people to conference via Avatar Picker --- indra/newview/llimpanel.cpp | 100 +++++++++++++++++- indra/newview/llimpanel.h | 5 + .../xui/de/floater_instant_message_ad_hoc.xml | 2 +- ..._instant_message_ad_hoc_concisebuttons.xml | 2 +- .../skins/default/xui/de/notifications.xml | 4 + .../xui/en-us/floater_instant_message.xml | 1 + .../en-us/floater_instant_message_ad_hoc.xml | 4 +- ..._instant_message_ad_hoc_concisebuttons.xml | 4 +- ...floater_instant_message_concisebuttons.xml | 1 + .../skins/default/xui/en-us/notifications.xml | 14 +++ .../xui/es/floater_instant_message_ad_hoc.xml | 2 +- ..._instant_message_ad_hoc_concisebuttons.xml | 2 +- .../skins/default/xui/es/notifications.xml | 5 +- .../skins/default/xui/fr/notifications.xml | 5 + .../skins/default/xui/it/notifications.xml | 4 + .../skins/default/xui/pt/notifications.xml | 4 + 16 files changed, 150 insertions(+), 9 deletions(-) diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index c2eb49492..9eed719b5 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -42,6 +42,7 @@ #include "llavatarnamecache.h" #include "llbutton.h" #include "llcombobox.h" +#include "llfloateravatarpicker.h" #include "llfloaterchat.h" #include "llfloaterinventory.h" #include "llfloaterwebcontent.h" // For web browser display of logs @@ -980,6 +981,96 @@ bool LLFloaterIMPanel::isInviteAllowed() const return mSessionType == ADHOC_SESSION; } +void LLFloaterIMPanel::onAddButtonClicked() +{ + LLView * button = findChild("instant_message_flyout"); + LLFloater* root_floater = gFloaterView->getParentFloater(this); + LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show(boost::bind(&LLFloaterIMPanel::addSessionParticipants, this, _1), TRUE, TRUE, FALSE, root_floater->getName(), button); + if (!picker) + { + return; + } + + // Need to disable 'ok' button when selected users are already in conversation. + picker->setOkBtnEnableCb(boost::bind(&LLFloaterIMPanel::canAddSelectedToChat, this, _1)); + + if (root_floater) + { + root_floater->addDependentFloater(picker); + } +} + +bool LLFloaterIMPanel::canAddSelectedToChat(const uuid_vec_t& uuids) const +{ + switch (mSessionType) + { + case P2P_SESSION: return true; // Don't bother blocking self or peer + case ADHOC_SESSION: + { + // For a conference session we need to check against the list from LLSpeakerMgr, + // because this list may change when participants join or leave the session. + + LLSpeakerMgr::speaker_list_t speaker_list; + LLIMSpeakerMgr* speaker_mgr = getSpeakerManager(); + if (speaker_mgr) + { + speaker_mgr->getSpeakerList(&speaker_list, true); + } + + for (const auto& id : uuids) + for (const LLPointer& speaker : speaker_list) + if (id == speaker->mID) + return false; + } + return true; + default: return false; + } +} + +void LLFloaterIMPanel::addSessionParticipants(const uuid_vec_t& uuids) +{ + if (mSessionType == P2P_SESSION) + { + LLSD payload; + LLSD args; + + LLNotificationsUtil::add("ConfirmAddingChatParticipants", args, payload, + boost::bind(&LLFloaterIMPanel::addP2PSessionParticipants, this, _1, _2, uuids)); + } + else inviteToSession(uuids); +} + +void LLFloaterIMPanel::addP2PSessionParticipants(const LLSD& notification, const LLSD& response, const uuid_vec_t& uuids) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) + { + return; + } + + LLVoiceChannel* voice_channel = LLActiveSpeakerMgr::getInstance()->getVoiceChannel(); + + // first check whether this is a voice session + bool is_voice_call = voice_channel != nullptr && voice_channel->getSessionID() == mSessionUUID && voice_channel->isActive(); + + uuid_vec_t temp_ids; + + // Add the initial participant of a P2P session + temp_ids.push_back(mOtherParticipantUUID); + temp_ids.insert(temp_ids.end(), uuids.begin(), uuids.end()); + + // Start a new ad hoc voice call if we invite new participants to a P2P call, + // or start a text chat otherwise. + if (is_voice_call) + { + LLAvatarActions::startAdhocCall(temp_ids); + } + else + { + LLAvatarActions::startConference(temp_ids); + } +} + void LLFloaterIMPanel::removeDynamics(LLComboBox* flyout) { flyout->remove(mDing ? getString("ding on") : getString("ding off")); @@ -1012,8 +1103,12 @@ void LLFloaterIMPanel::onFlyoutCommit(LLComboBox* flyout, const LLSD& value) { if (value.isUndefined() || value.asInteger() == 0) { - LLAvatarActions::showProfile(mOtherParticipantUUID); - return; + switch (mSessionType) + { + case GROUP_SESSION: LLGroupActions::show(mOtherParticipantUUID); return; + case P2P_SESSION: LLAvatarActions::showProfile(mOtherParticipantUUID); return; + default: onClickHistory(); return; // If there's no profile for this type, we should be the history button. + } } switch (int option = value.asInteger()) @@ -1026,6 +1121,7 @@ void LLFloaterIMPanel::onFlyoutCommit(LLComboBox* flyout, const LLSD& value) case -1: copy_profile_uri(mOtherParticipantUUID); break; case -2: LLAvatarActions::showOnMap(mOtherParticipantUUID); break; case -3: gAgentCamera.lookAtObject(mOtherParticipantUUID); break; + case -4: onAddButtonClicked(); break; default: // Options >= 6 use dynamic items { // First remove them all diff --git a/indra/newview/llimpanel.h b/indra/newview/llimpanel.h index e3789b4ab..6a2e54dbe 100644 --- a/indra/newview/llimpanel.h +++ b/indra/newview/llimpanel.h @@ -165,6 +165,11 @@ private: // test if local agent can add agents. bool isInviteAllowed() const; + void onAddButtonClicked(); + void addSessionParticipants(const uuid_vec_t& uuids); + void addP2PSessionParticipants(const LLSD& notification, const LLSD& response, const uuid_vec_t& uuids); + bool canAddSelectedToChat(const uuid_vec_t& uuids) const; + // Called whenever the user starts or stops typing. // Sends the typing state to the other user if necessary. void setTyping(bool typing); diff --git a/indra/newview/skins/default/xui/de/floater_instant_message_ad_hoc.xml b/indra/newview/skins/default/xui/de/floater_instant_message_ad_hoc.xml index da45b31e9..26728aafe 100644 --- a/indra/newview/skins/default/xui/de/floater_instant_message_ad_hoc.xml +++ b/indra/newview/skins/default/xui/de/floater_instant_message_ad_hoc.xml @@ -10,7 +10,7 @@ Für Instant Message hier klicken. - diff --git a/indra/newview/skins/default/xui/en-us/floater_instant_message_ad_hoc_concisebuttons.xml b/indra/newview/skins/default/xui/en-us/floater_instant_message_ad_hoc_concisebuttons.xml index 65196f003..2d0a69f5c 100644 --- a/indra/newview/skins/default/xui/en-us/floater_instant_message_ad_hoc_concisebuttons.xml +++ b/indra/newview/skins/default/xui/en-us/floater_instant_message_ad_hoc_concisebuttons.xml @@ -8,7 +8,9 @@ [NAME] is typing... Starting session with [NAME], please wait. Click here to instant message. - diff --git a/indra/newview/skins/default/xui/en-us/floater_instant_message_concisebuttons.xml b/indra/newview/skins/default/xui/en-us/floater_instant_message_concisebuttons.xml index b8c3acbb7..6bfe25215 100644 --- a/indra/newview/skins/default/xui/en-us/floater_instant_message_concisebuttons.xml +++ b/indra/newview/skins/default/xui/en-us/floater_instant_message_concisebuttons.xml @@ -19,6 +19,7 @@ + diff --git a/indra/newview/skins/default/xui/en-us/notifications.xml b/indra/newview/skins/default/xui/en-us/notifications.xml index 28d0a6b0b..b13e4c8eb 100644 --- a/indra/newview/skins/default/xui/en-us/notifications.xml +++ b/indra/newview/skins/default/xui/en-us/notifications.xml @@ -5362,6 +5362,20 @@ Visit the [SECOND_LIFE] Support Web site? type="alertmodal"> This grid has no link for support. + + + +When you add a person to an existing conversation, a new conversation will be created. All participants will receive new conversation notifications. + confirm + + -