From e88219b5e363f9535ac1193b2041da35ba5dd702 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Fri, 27 Nov 2009 13:34:24 +0200
Subject: Work on major sub-task EXT-2790 (Complete Voice Control Panel
 (floater) started by Lynx (LLVoiceControlPanel))  -- improved logic to update
 Participant List for session. Now it uses current voice channel.

--HG--
branch : product-engine
---
 indra/newview/llcallfloater.cpp         | 57 +++++++++++++++++++++++++++------
 indra/newview/llcallfloater.h           |  4 +++
 indra/newview/llpanelimcontrolpanel.cpp |  2 +-
 3 files changed, 52 insertions(+), 11 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llcallfloater.cpp b/indra/newview/llcallfloater.cpp
index 4a24b558c9..17d59f86bb 100644
--- a/indra/newview/llcallfloater.cpp
+++ b/indra/newview/llcallfloater.cpp
@@ -73,25 +73,62 @@ BOOL LLCallFloater::postBuild()
 }
 
 // virtual
-void LLCallFloater::onOpen(const LLSD& key)
+void LLCallFloater::onOpen(const LLSD& /*key*/)
 {
-	// by default let show nearby chat participants
-	mSpeakerManager = LLLocalSpeakerMgr::getInstance();
+	updateSession();
+}
+
+//////////////////////////////////////////////////////////////////////////
+/// PRIVATE SECTION
+//////////////////////////////////////////////////////////////////////////
+void LLCallFloater::updateSession()
+{
+	LLVoiceChannel* voice_channel = LLVoiceChannel::getCurrentVoiceChannel();
+	if (voice_channel)
+	{
+		lldebugs << "Current voice channel: " << voice_channel->getSessionID() << llendl;
+
+		if (mSpeakerManager && voice_channel->getSessionID() == mSpeakerManager->getSessionID())
+		{
+			lldebugs << "Speaker manager is already set for session: " << voice_channel->getSessionID() << llendl;
+			return;
+		}
+		else
+		{
+			mSpeakerManager = NULL;
+		}
+	}
+
+	const LLUUID& session_id = voice_channel->getSessionID();
+	lldebugs << "Set speaker manager for session: " << session_id << llendl;
 
-	const LLUUID& session_id = key.asUUID();
 	LLIMModel::LLIMSession* im_session = LLIMModel::getInstance()->findIMSession(session_id);
 	if (im_session)
 	{
 		mSpeakerManager = LLIMModel::getInstance()->getSpeakerManager(session_id);
 	}
 
-	delete mPaticipants;
-	mAvatarList->clear();
-	mPaticipants = new LLParticipantList(mSpeakerManager, mAvatarList, false);
+	if (NULL == mSpeakerManager)
+	{
+		setDefaultSession();
+	}
+
+	refreshPartisipantList();
 }
 
-//////////////////////////////////////////////////////////////////////////
-/// PRIVATE SECTION
-//////////////////////////////////////////////////////////////////////////
+void LLCallFloater::setDefaultSession()
+{
+	// by default let show nearby chat participants
+	mSpeakerManager = LLLocalSpeakerMgr::getInstance();
+	lldebugs << "Set DEFAULT speaker manager" << llendl;
+}
 
+void LLCallFloater::refreshPartisipantList()
+{
+	delete mPaticipants;
+	mAvatarList->clear();
+
+	bool is_local_chat_session = LLLocalSpeakerMgr::getInstance() == mSpeakerManager;
+	mPaticipants = new LLParticipantList(mSpeakerManager, mAvatarList, is_local_chat_session);
+}
 //EOF
diff --git a/indra/newview/llcallfloater.h b/indra/newview/llcallfloater.h
index 0b86a6ee92..db33f17839 100644
--- a/indra/newview/llcallfloater.h
+++ b/indra/newview/llcallfloater.h
@@ -60,6 +60,10 @@ public:
 	/*virtual*/ BOOL postBuild();
 	/*virtual*/ void onOpen(const LLSD& key);
 
+private:
+	void updateSession();
+	void setDefaultSession();
+	void refreshPartisipantList();
 
 private:
 	LLSpeakerMgr* mSpeakerManager;
diff --git a/indra/newview/llpanelimcontrolpanel.cpp b/indra/newview/llpanelimcontrolpanel.cpp
index 741f42f9d5..405c95fc22 100644
--- a/indra/newview/llpanelimcontrolpanel.cpp
+++ b/indra/newview/llpanelimcontrolpanel.cpp
@@ -60,7 +60,7 @@ void LLPanelChatControlPanel::onEndCallButtonClicked()
 
 void LLPanelChatControlPanel::onOpenVoiceControlsClicked()
 {
-	LLFloaterReg::showInstance("voice_controls", getSessionId());
+	LLFloaterReg::showInstance("voice_controls");
 }
 
 void LLPanelChatControlPanel::onVoiceChannelStateChanged(const LLVoiceChannel::EState& old_state, const LLVoiceChannel::EState& new_state)
-- 
cgit v1.2.3