summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterimsessiontab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterimsessiontab.cpp')
-rw-r--r--indra/newview/llfloaterimsessiontab.cpp67
1 files changed, 59 insertions, 8 deletions
diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp
index bdc7fdeadc..7b1c0ba5d4 100644
--- a/indra/newview/llfloaterimsessiontab.cpp
+++ b/indra/newview/llfloaterimsessiontab.cpp
@@ -80,6 +80,7 @@ LLFloaterIMSessionTab::LLFloaterIMSessionTab(const LLSD& session_id)
{
setAutoFocus(false);
mSession = LLIMModel::getInstance()->findIMSession(mSessionID);
+ LLIMMgr::instance().addSessionObserver(this);
mCommitCallbackRegistrar.add("IMSession.Menu.Action",
boost::bind(&LLFloaterIMSessionTab::onIMSessionMenuItemClicked, this, _2));
@@ -102,6 +103,7 @@ LLFloaterIMSessionTab::LLFloaterIMSessionTab(const LLSD& session_id)
LLFloaterIMSessionTab::~LLFloaterIMSessionTab()
{
delete mRefreshTimer;
+ LLIMMgr::instance().removeSessionObserver(this);
LLFloaterIMContainer* im_container = LLFloaterIMContainer::findInstance();
if (im_container)
@@ -302,6 +304,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 +437,39 @@ 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 (LLVoiceClient::instanceExists() &&
+ mSession->mVoiceChannel &&
+ !mSession->mVoiceChannel->callStarted()
+ )
+ {
+ LLVoiceClient* client = LLVoiceClient::getInstance();
+ if (client->voiceEnabled() && client->isVoiceWorking())
+ {
+ enable = true;
+ }
+ }
+ }
}
+
+ mVoiceButton->setEnabled(enable);
}
// virtual
@@ -466,6 +492,22 @@ void LLFloaterIMSessionTab::onFocusLost()
super::onFocusLost();
}
+void LLFloaterIMSessionTab::onCallButtonClicked()
+{
+ if (mVoiceButtonHangUpMode)
+ {
+ // We allow to hang up from any state
+ gIMMgr->endCall(mSessionID);
+ }
+ else
+ {
+ if (mSession->mVoiceChannel && !mSession->mVoiceChannel->callStarted())
+ {
+ gIMMgr->startCall(mSessionID);
+ }
+ }
+}
+
void LLFloaterIMSessionTab::onInputEditorClicked()
{
LLFloaterIMContainer* im_box = LLFloaterIMContainer::findInstance();
@@ -1041,6 +1083,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();
}
@@ -1330,6 +1373,14 @@ LLView* LLFloaterIMSessionTab::getChatHistory()
return mChatHistory;
}
+void LLFloaterIMSessionTab::sessionRemoved(const LLUUID& session_id)
+{
+ if (session_id == mSessionID)
+ {
+ mSession = nullptr;
+ }
+}
+
bool LLFloaterIMSessionTab::handleKeyHere(KEY key, MASK mask )
{
bool handled = false;