PageRenderTime 344ms CodeModel.GetById 181ms app.highlight 14ms RepoModel.GetById 147ms app.codeStats 0ms

/indra/newview/llimfloatercontainer.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 164 lines | 95 code | 26 blank | 43 comment | 13 complexity | 6b40821bbdd625afc294e92372596b62 MD5 | raw file
  1/** 
  2 * @file llimfloatercontainer.cpp
  3 * @brief Multifloater containing active IM sessions in separate tab container tabs
  4 *
  5 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27
 28#include "llviewerprecompiledheaders.h"
 29
 30#include "llimfloatercontainer.h"
 31#include "llfloaterreg.h"
 32#include "llimview.h"
 33#include "llavatariconctrl.h"
 34#include "llgroupiconctrl.h"
 35#include "llagent.h"
 36#include "lltransientfloatermgr.h"
 37
 38//
 39// LLIMFloaterContainer
 40//
 41LLIMFloaterContainer::LLIMFloaterContainer(const LLSD& seed)
 42:	LLMultiFloater(seed)
 43{
 44	mAutoResize = FALSE;
 45	LLTransientFloaterMgr::getInstance()->addControlView(LLTransientFloaterMgr::IM, this);
 46}
 47
 48LLIMFloaterContainer::~LLIMFloaterContainer()
 49{
 50	mNewMessageConnection.disconnect();
 51	LLTransientFloaterMgr::getInstance()->removeControlView(LLTransientFloaterMgr::IM, this);
 52}
 53
 54BOOL LLIMFloaterContainer::postBuild()
 55{
 56	mNewMessageConnection = LLIMModel::instance().mNewMsgSignal.connect(boost::bind(&LLIMFloaterContainer::onNewMessageReceived, this, _1));
 57	// Do not call base postBuild to not connect to mCloseSignal to not close all floaters via Close button
 58	// mTabContainer will be initialized in LLMultiFloater::addChild()
 59	return TRUE;
 60}
 61
 62void LLIMFloaterContainer::onOpen(const LLSD& key)
 63{
 64	LLMultiFloater::onOpen(key);
 65/*
 66	if (key.isDefined())
 67	{
 68		LLIMFloater* im_floater = LLIMFloater::findInstance(key.asUUID());
 69		if (im_floater)
 70		{
 71			im_floater->openFloater();
 72		}
 73	}
 74*/
 75}
 76
 77void LLIMFloaterContainer::addFloater(LLFloater* floaterp, 
 78									BOOL select_added_floater, 
 79									LLTabContainer::eInsertionPoint insertion_point)
 80{
 81	if(!floaterp) return;
 82
 83	// already here
 84	if (floaterp->getHost() == this)
 85	{
 86		openFloater(floaterp->getKey());
 87		return;
 88	}
 89
 90	LLMultiFloater::addFloater(floaterp, select_added_floater, insertion_point);
 91
 92	LLUUID session_id = floaterp->getKey();
 93
 94	LLIconCtrl* icon = 0;
 95
 96	if(gAgent.isInGroup(session_id, TRUE))
 97	{
 98		LLGroupIconCtrl::Params icon_params;
 99		icon_params.group_id = session_id;
100		icon = LLUICtrlFactory::instance().create<LLGroupIconCtrl>(icon_params);
101
102		mSessions[session_id] = floaterp;
103		floaterp->mCloseSignal.connect(boost::bind(&LLIMFloaterContainer::onCloseFloater, this, session_id));
104	}
105	else
106	{
107		LLUUID avatar_id = LLIMModel::getInstance()->getOtherParticipantID(session_id);
108
109		LLAvatarIconCtrl::Params icon_params;
110		icon_params.avatar_id = avatar_id;
111		icon = LLUICtrlFactory::instance().create<LLAvatarIconCtrl>(icon_params);
112
113		mSessions[session_id] = floaterp;
114		floaterp->mCloseSignal.connect(boost::bind(&LLIMFloaterContainer::onCloseFloater, this, session_id));
115	}
116	mTabContainer->setTabImage(floaterp, icon);
117}
118
119void LLIMFloaterContainer::onCloseFloater(LLUUID& id)
120{
121	mSessions.erase(id);
122}
123
124void LLIMFloaterContainer::onNewMessageReceived(const LLSD& data)
125{
126	LLUUID session_id = data["session_id"].asUUID();
127	LLFloater* floaterp = get_ptr_in_map(mSessions, session_id);
128	LLFloater* current_floater = LLMultiFloater::getActiveFloater();
129
130	if(floaterp && current_floater && floaterp != current_floater)
131	{
132		if(LLMultiFloater::isFloaterFlashing(floaterp))
133			LLMultiFloater::setFloaterFlashing(floaterp, FALSE);
134		LLMultiFloater::setFloaterFlashing(floaterp, TRUE);
135	}
136}
137
138LLIMFloaterContainer* LLIMFloaterContainer::findInstance()
139{
140	return LLFloaterReg::findTypedInstance<LLIMFloaterContainer>("im_container");
141}
142
143LLIMFloaterContainer* LLIMFloaterContainer::getInstance()
144{
145	return LLFloaterReg::getTypedInstance<LLIMFloaterContainer>("im_container");
146}
147
148void LLIMFloaterContainer::setMinimized(BOOL b)
149{
150	if (isMinimized() == b) return;
151	
152	LLMultiFloater::setMinimized(b);
153	// Hide minimized floater (see EXT-5315)
154	setVisible(!b);
155
156	if (isMinimized()) return;
157
158	if (getActiveFloater())
159	{
160		getActiveFloater()->setVisible(TRUE);
161	}
162}
163
164// EOF