diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfloaterimsession.cpp | 19 | ||||
-rw-r--r-- | indra/newview/llfloaterimsession.h | 2 | ||||
-rw-r--r-- | indra/newview/llfloaterimsessiontab.cpp | 55 | ||||
-rw-r--r-- | indra/newview/llfloaterimsessiontab.h | 7 | ||||
-rw-r--r-- | indra/newview/llvoicechannel.cpp | 10 |
5 files changed, 64 insertions, 29 deletions
diff --git a/indra/newview/llfloaterimsession.cpp b/indra/newview/llfloaterimsession.cpp index 557b3f27c5..97e0d01b52 100644 --- a/indra/newview/llfloaterimsession.cpp +++ b/indra/newview/llfloaterimsession.cpp @@ -368,8 +368,6 @@ bool LLFloaterIMSession::postBuild() add_btn->setEnabled(isInviteAllowed()); add_btn->setClickedCallback(boost::bind(&LLFloaterIMSession::onAddButtonClicked, this)); - childSetAction("voice_call_btn", boost::bind(&LLFloaterIMSession::onCallButtonClicked, this)); - LLVoiceClient::addObserver(this); //*TODO if session is not initialized yet, add some sort of a warning message like "starting session...blablabla" @@ -551,23 +549,6 @@ void LLFloaterIMSession::boundVoiceChannel() } } -void LLFloaterIMSession::onCallButtonClicked() -{ - LLVoiceChannel* voice_channel = LLIMModel::getInstance()->getVoiceChannel(mSessionID); - if (voice_channel) - { - bool is_call_active = voice_channel->getState() >= LLVoiceChannel::STATE_CALL_STARTED; - if (is_call_active) - { - gIMMgr->endCall(mSessionID); - } - else - { - gIMMgr->startCall(mSessionID); - } - } -} - void LLFloaterIMSession::onChange(EStatusType status, const LLSD& channelInfo, bool proximal) { if(status != STATUS_JOINING && status != STATUS_LEFT_CHANNEL) diff --git a/indra/newview/llfloaterimsession.h b/indra/newview/llfloaterimsession.h index 7bc54cf3da..a442099ad1 100644 --- a/indra/newview/llfloaterimsession.h +++ b/indra/newview/llfloaterimsession.h @@ -159,8 +159,6 @@ private: void sendParticipantsAddedNotification(const uuid_vec_t& uuids); bool canAddSelectedToChat(const uuid_vec_t& uuids); - void onCallButtonClicked(); - void onVoiceChannelChanged(const LLUUID &session_id); void boundVoiceChannel(); diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp index 2621ce576c..00e7dae657 100644 --- a/indra/newview/llfloaterimsessiontab.cpp +++ b/indra/newview/llfloaterimsessiontab.cpp @@ -302,6 +302,7 @@ bool LLFloaterIMSessionTab::postBuild() mGearBtn = getChild<LLButton>("gear_btn"); mAddBtn = getChild<LLButton>("add_btn"); mVoiceButton = getChild<LLButton>("voice_call_btn"); + mVoiceButton->setClickedCallback([this](LLUICtrl*, const LLSD&) { onCallButtonClicked(); }); mParticipantListPanel = getChild<LLLayoutPanel>("speakers_list_panel"); mRightPartPanel = getChild<LLLayoutPanel>("right_part_holder"); @@ -434,16 +435,34 @@ void LLFloaterIMSessionTab::draw() void LLFloaterIMSessionTab::enableDisableCallBtn() { - if (LLVoiceClient::instanceExists() && mVoiceButton) + if (!mVoiceButton) + return; + + bool enable = false; + + if (mSessionID.notNull() && mSession && mSession->mSessionInitialized && mSession->mCallBackEnabled) { - mVoiceButton->setEnabled( - mSessionID.notNull() - && mSession - && mSession->mSessionInitialized - && LLVoiceClient::getInstance()->voiceEnabled() - && LLVoiceClient::getInstance()->isVoiceWorking() - && mSession->mCallBackEnabled); + if (mVoiceButtonHangUpMode) + { + // We allow to hang up from any state + enable = true; + } + else + { + // We allow to start call from this state only + if (mSession->mVoiceChannel->getState() == LLVoiceChannel::STATE_NO_CHANNEL_INFO && + LLVoiceClient::instanceExists()) + { + LLVoiceClient* client = LLVoiceClient::getInstance(); + if (client->voiceEnabled() && client->isVoiceWorking()) + { + enable = true; + } + } + } } + + mVoiceButton->setEnabled(enable); } // virtual @@ -466,6 +485,25 @@ void LLFloaterIMSessionTab::onFocusLost() super::onFocusLost(); } +void LLFloaterIMSessionTab::onCallButtonClicked() +{ + if (mVoiceButtonHangUpMode) + { + // We allow to hang up from any state + gIMMgr->endCall(mSessionID); + } + else + { + LLVoiceChannel::EState channel_state = mSession && mSession->mVoiceChannel ? + mSession->mVoiceChannel->getState() : LLVoiceChannel::STATE_NO_CHANNEL_INFO; + // We allow to start call from this state only + if (channel_state == LLVoiceChannel::STATE_NO_CHANNEL_INFO) + { + gIMMgr->startCall(mSessionID); + } + } +} + void LLFloaterIMSessionTab::onInputEditorClicked() { LLFloaterIMContainer* im_box = LLFloaterIMContainer::findInstance(); @@ -1040,6 +1078,7 @@ void LLFloaterIMSessionTab::updateCallBtnState(bool callIsActive) { mVoiceButton->setImageOverlay(callIsActive? getString("call_btn_stop") : getString("call_btn_start")); mVoiceButton->setToolTip(callIsActive? getString("end_call_button_tooltip") : getString("start_call_button_tooltip")); + mVoiceButtonHangUpMode = callIsActive; enableDisableCallBtn(); } diff --git a/indra/newview/llfloaterimsessiontab.h b/indra/newview/llfloaterimsessiontab.h index 6dd8e62482..bee5c8c2c4 100644 --- a/indra/newview/llfloaterimsessiontab.h +++ b/indra/newview/llfloaterimsessiontab.h @@ -198,6 +198,11 @@ protected: LLButton* mAddBtn; LLButton* mVoiceButton; + // Since mVoiceButton can work in one of two modes, "Start call" or "Hang up", + // (with different images and tooltips depending on the currently chosen mode) + // we should track the mode we're currently using to react on click accordingly + bool mVoiceButtonHangUpMode { false }; + private: // Handling selection and contextual menu void doToSelected(const LLSD& userdata); @@ -216,6 +221,8 @@ private: */ void reshapeChatLayoutPanel(); + void onCallButtonClicked(); + void onInputEditorClicked(); void onEmojiRecentPanelToggleBtnClicked(); diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index eb1cd00940..55769f567b 100644 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -328,6 +328,16 @@ void LLVoiceChannel::setState(EState state) void LLVoiceChannel::doSetState(const EState& new_state) { + LL_DEBUGS("Voice") << "session '" << mSessionName << "' state " << mState << ", new_state " << new_state << ": " + << (new_state == STATE_ERROR ? "ERROR" : + new_state == STATE_HUNG_UP ? "HUNG_UP" : + new_state == STATE_READY ? "READY" : + new_state == STATE_CALL_STARTED ? "CALL_STARTED" : + new_state == STATE_RINGING ? "RINGING" : + new_state == STATE_CONNECTED ? "CONNECTED" : + "NO_INFO") + << LL_ENDL; + EState old_state = mState; mState = new_state; |