summaryrefslogtreecommitdiff
path: root/indra/newview/llchiclet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llchiclet.cpp')
-rw-r--r--indra/newview/llchiclet.cpp921
1 files changed, 43 insertions, 878 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index a661808d1f..3dbb43c657 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -27,35 +27,17 @@
#include "llviewerprecompiledheaders.h" // must be first include
#include "llchiclet.h"
-#include "llagent.h"
-#include "llavataractions.h"
#include "llchicletbar.h"
-#include "lleventtimer.h"
-#include "llgroupactions.h"
-#include "lliconctrl.h"
-#include "llimfloater.h"
-#include "llimview.h"
+#include "llfloaterimsession.h"
+#include "llfloaterimcontainer.h"
#include "llfloaterreg.h"
#include "lllocalcliprect.h"
-#include "llmenugl.h"
-#include "llnotifications.h"
-#include "llnotificationsutil.h"
-#include "lloutputmonitorctrl.h"
#include "llscriptfloater.h"
-#include "llspeakers.h"
-#include "lltextbox.h"
-#include "llvoiceclient.h"
-#include "llgroupmgr.h"
-#include "llnotificationmanager.h"
-#include "lltransientfloatermgr.h"
+#include "llsingleton.h"
#include "llsyswellwindow.h"
static LLDefaultChildRegistry::Register<LLChicletPanel> t1("chiclet_panel");
-static LLDefaultChildRegistry::Register<LLIMWellChiclet> t2_0("chiclet_im_well");
static LLDefaultChildRegistry::Register<LLNotificationChiclet> t2("chiclet_notification");
-static LLDefaultChildRegistry::Register<LLIMP2PChiclet> t3("chiclet_im_p2p");
-static LLDefaultChildRegistry::Register<LLIMGroupChiclet> t4("chiclet_im_group");
-static LLDefaultChildRegistry::Register<LLAdHocChiclet> t5("chiclet_im_adhoc");
static LLDefaultChildRegistry::Register<LLScriptChiclet> t6("chiclet_script");
static LLDefaultChildRegistry::Register<LLInvOfferChiclet> t7("chiclet_offer");
@@ -66,65 +48,10 @@ boost::signals2::signal<LLChiclet* (const LLUUID&),
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-/**
- * Updates the Well's 'Lit' state to flash it when "new messages" are come.
- *
- * It gets callback which will be called 2*N times with passed period. See EXT-3147
- */
-class LLSysWellChiclet::FlashToLitTimer : public LLEventTimer
-{
-public:
- typedef boost::function<void()> callback_t;
-
- /**
- * Constructor.
- *
- * @param count - how many times callback should be called (twice to not change original state)
- * @param period - how frequently callback should be called
- * @param cb - callback to be called each tick
- */
- FlashToLitTimer(S32 count, F32 period, callback_t cb)
- : LLEventTimer(period)
- , mCallback(cb)
- , mFlashCount(2 * count)
- , mCurrentFlashCount(0)
- {
- mEventTimer.stop();
- }
-
- BOOL tick()
- {
- mCallback();
-
- if (++mCurrentFlashCount == mFlashCount) mEventTimer.stop();
- return FALSE;
- }
-
- void flash()
- {
- mCurrentFlashCount = 0;
- mEventTimer.start();
- }
-
- void stopFlashing()
- {
- mEventTimer.stop();
- }
-
-private:
- callback_t mCallback;
-
- /**
- * How many times Well will blink.
- */
- S32 mFlashCount;
- S32 mCurrentFlashCount;
-};
-
LLSysWellChiclet::Params::Params()
-: button("button")
-, unread_notifications("unread_notifications")
-, max_displayed_count("max_displayed_count", 99)
+ : button("button")
+ , unread_notifications("unread_notifications")
+ , max_displayed_count("max_displayed_count", 99)
{
button.name = "button";
button.tab_stop = FALSE;
@@ -132,30 +59,24 @@ LLSysWellChiclet::Params::Params()
}
LLSysWellChiclet::LLSysWellChiclet(const Params& p)
-: LLChiclet(p)
-, mButton(NULL)
-, mCounter(0)
-, mMaxDisplayedCount(p.max_displayed_count)
-, mIsNewMessagesState(false)
-, mFlashToLitTimer(NULL)
-, mContextMenu(NULL)
+ : LLChiclet(p)
+ , mButton(NULL)
+ , mCounter(0)
+ , mMaxDisplayedCount(p.max_displayed_count)
+ , mIsNewMessagesState(false)
+ , mFlashToLitTimer(NULL)
+ , mContextMenu(NULL)
{
LLButton::Params button_params = p.button;
mButton = LLUICtrlFactory::create<LLButton>(button_params);
addChild(mButton);
- // use settings from settings.xml to be able change them via Debug settings. See EXT-5973.
- // Due to Timer is implemented as derived class from EventTimer it is impossible to change period
- // in runtime. So, both settings are made as required restart.
- static S32 flash_to_lit_count = gSavedSettings.getS32("WellIconFlashCount");
- static F32 flash_period = gSavedSettings.getF32("WellIconFlashPeriod");
-
- mFlashToLitTimer = new FlashToLitTimer(flash_to_lit_count, flash_period, boost::bind(&LLSysWellChiclet::changeLitState, this));
+ mFlashToLitTimer = new LLFlashTimer(boost::bind(&LLSysWellChiclet::changeLitState, this, _1));
}
LLSysWellChiclet::~LLSysWellChiclet()
{
- delete mFlashToLitTimer;
+ mFlashToLitTimer->unset();
}
void LLSysWellChiclet::setCounter(S32 counter)
@@ -190,7 +111,7 @@ void LLSysWellChiclet::setToggleState(BOOL toggled) {
mButton->setToggleState(toggled);
}
-void LLSysWellChiclet::changeLitState()
+void LLSysWellChiclet::changeLitState(bool blink)
{
setNewMessagesState(!mIsNewMessagesState);
}
@@ -235,130 +156,18 @@ BOOL LLSysWellChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask)
}
/************************************************************************/
-/* LLIMWellChiclet implementation */
-/************************************************************************/
-LLIMWellChiclet::LLIMWellChiclet(const Params& p)
-: LLSysWellChiclet(p)
-{
- LLIMModel::instance().addNewMsgCallback(boost::bind(&LLIMWellChiclet::messageCountChanged, this, _1));
- LLIMModel::instance().addNoUnreadMsgsCallback(boost::bind(&LLIMWellChiclet::messageCountChanged, this, _1));
-
- LLIMMgr::getInstance()->addSessionObserver(this);
-
- LLIMWellWindow::getInstance()->setSysWellChiclet(this);
-}
-
-LLIMWellChiclet::~LLIMWellChiclet()
-{
- LLIMWellWindow* im_well_window = LLIMWellWindow::findInstance();
- if (im_well_window)
- {
- im_well_window->setSysWellChiclet(NULL);
- }
-
- LLIMMgr::getInstance()->removeSessionObserver(this);
-}
-
-void LLIMWellChiclet::onMenuItemClicked(const LLSD& user_data)
-{
- std::string action = user_data.asString();
- if("close all" == action)
- {
- LLIMWellWindow::getInstance()->closeAll();
- }
-}
-
-bool LLIMWellChiclet::enableMenuItem(const LLSD& user_data)
-{
- std::string item = user_data.asString();
- if (item == "can close all")
- {
- return !LLIMWellWindow::getInstance()->isWindowEmpty();
- }
- return true;
-}
-
-void LLIMWellChiclet::createMenu()
-{
- if(mContextMenu)
- {
- llwarns << "Menu already exists" << llendl;
- return;
- }
-
- LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
- registrar.add("IMWellChicletMenu.Action",
- boost::bind(&LLIMWellChiclet::onMenuItemClicked, this, _2));
-
- LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
- enable_registrar.add("IMWellChicletMenu.EnableItem",
- boost::bind(&LLIMWellChiclet::enableMenuItem, this, _2));
-
- mContextMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>
- ("menu_im_well_button.xml",
- LLMenuGL::sMenuContainer,
- LLViewerMenuHolderGL::child_registry_t::instance());
-}
-
-void LLIMWellChiclet::messageCountChanged(const LLSD& session_data)
-{
- // The singleton class LLChicletBar instance might be already deleted
- // so don't create a new one.
- if (!LLChicletBar::instanceExists())
- {
- return;
- }
-
- const LLUUID& session_id = session_data["session_id"];
- const S32 counter = LLChicletBar::getInstance()->getTotalUnreadIMCount();
- const bool im_not_visible = !LLFloaterReg::instanceVisible("im_container")
- && !LLFloaterReg::instanceVisible("impanel", session_id);
-
- setNewMessagesState(counter > mCounter && im_not_visible);
-
- // we have to flash to 'Lit' state each time new unread message is coming.
- if (counter > mCounter && im_not_visible)
- {
- mFlashToLitTimer->flash();
- }
- else if (counter == 0)
- {
- // if notification is resolved while well is flashing it can leave in the 'Lit' state
- // when flashing finishes itself. Let break flashing here.
- mFlashToLitTimer->stopFlashing();
- }
-
- setCounter(counter);
-}
-
-/************************************************************************/
/* LLNotificationChiclet implementation */
/************************************************************************/
LLNotificationChiclet::LLNotificationChiclet(const Params& p)
-: LLSysWellChiclet(p)
-, mUreadSystemNotifications(0)
+: LLSysWellChiclet(p),
+ mUreadSystemNotifications(0)
{
- // connect counter handlers to the signals
- connectCounterUpdatersToSignal("notify");
- connectCounterUpdatersToSignal("groupnotify");
- connectCounterUpdatersToSignal("offer");
-
+ mNotificationChannel.reset(new ChicletNotificationChannel(this));
// ensure that notification well window exists, to synchronously
// handle toast add/delete events.
LLNotificationWellWindow::getInstance()->setSysWellChiclet(this);
}
-void LLNotificationChiclet::connectCounterUpdatersToSignal(const std::string& notification_type)
-{
- LLNotificationsUI::LLNotificationManager* manager = LLNotificationsUI::LLNotificationManager::getInstance();
- LLNotificationsUI::LLEventHandler* n_handler = manager->getHandlerForNotification(notification_type);
- if(n_handler)
- {
- n_handler->setNewNotificationCallback(boost::bind(&LLNotificationChiclet::incUreadSystemNotifications, this));
- n_handler->setDelNotification(boost::bind(&LLNotificationChiclet::decUreadSystemNotifications, this));
- }
-}
-
void LLNotificationChiclet::onMenuItemClicked(const LLSD& user_data)
{
std::string action = user_data.asString();
@@ -407,6 +216,23 @@ void LLNotificationChiclet::setCounter(S32 counter)
updateWidget(getCounter() == 0);
}
+
+bool LLNotificationChiclet::ChicletNotificationChannel::filterNotification( LLNotificationPtr notification )
+{
+ if (notification->getName() == "ScriptDialog")
+ {
+ return false;
+ }
+
+ if( !(notification->canLogToIM() && notification->hasFormElements())
+ && (!notification->getPayload().has("give_inventory_notification")
+ || notification->getPayload()["give_inventory_notification"]))
+ {
+ return true;
+ }
+ return false;
+}
+
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@@ -422,12 +248,6 @@ LLChiclet::LLChiclet(const Params& p)
, mSessionId(LLUUID::null)
, mShowCounter(p.show_counter)
{
-
-}
-
-LLChiclet::~LLChiclet()
-{
-
}
boost::signals2::connection LLChiclet::setLeftButtonClickCallback(
@@ -462,7 +282,9 @@ LLSD LLChiclet::getValue() const
void LLChiclet::setValue(const LLSD& value)
{
if(value.isUUID())
+ {
setSessionId(value.asUUID());
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -474,12 +296,9 @@ LLIMChiclet::LLIMChiclet(const LLIMChiclet::Params& p)
, mShowSpeaker(false)
, mDefaultWidth(p.rect().getWidth())
, mNewMessagesIcon(NULL)
-, mSpeakerCtrl(NULL)
-, mCounterCtrl(NULL)
, mChicletButton(NULL)
, mPopupMenu(NULL)
{
- enableCounterControl(p.enable_counter);
}
/* virtual*/
@@ -490,16 +309,6 @@ BOOL LLIMChiclet::postBuild()
mChicletButton->setDoubleClickCallback(boost::bind(&LLIMChiclet::onMouseDown, this));
return TRUE;
}
-void LLIMChiclet::setShowSpeaker(bool show)
-{
- bool needs_resize = getShowSpeaker() != show;
- if(needs_resize)
- {
- mShowSpeaker = show;
- }
-
- toggleSpeakerControl();
-}
void LLIMChiclet::enableCounterControl(bool enable)
{
@@ -510,87 +319,13 @@ void LLIMChiclet::enableCounterControl(bool enable)
}
}
-void LLIMChiclet::setShowCounter(bool show)
-{
- if(!mCounterEnabled)
- {
- return;
- }
-
- bool needs_resize = getShowCounter() != show;
- if(needs_resize)
- {
- LLChiclet::setShowCounter(show);
- toggleCounterControl();
- }
-}
-
-void LLIMChiclet::initSpeakerControl()
-{
- // virtual
-}
-
void LLIMChiclet::setRequiredWidth()
{
- bool show_speaker = getShowSpeaker();
- bool show_counter = getShowCounter();
S32 required_width = mDefaultWidth;
-
- if (show_counter)
- {
- required_width += mCounterCtrl->getRect().getWidth();
- }
- if (show_speaker)
- {
- required_width += mSpeakerCtrl->getRect().getWidth();
- }
-
reshape(required_width, getRect().getHeight());
-
onChicletSizeChanged();
}
-void LLIMChiclet::toggleSpeakerControl()
-{
- if(getShowSpeaker())
- {
- // move speaker to the right of chiclet icon
- LLRect speaker_rc = mSpeakerCtrl->getRect();
- speaker_rc.setLeftTopAndSize(mDefaultWidth, speaker_rc.mTop, speaker_rc.getWidth(), speaker_rc.getHeight());
- mSpeakerCtrl->setRect(speaker_rc);
-
- if(getShowCounter())
- {
- // move speaker to the right of counter
- mSpeakerCtrl->translate(mCounterCtrl->getRect().getWidth(), 0);
- }
-
- initSpeakerControl();
- }
-
- setRequiredWidth();
- mSpeakerCtrl->setSpeakerId(LLUUID::null);
- mSpeakerCtrl->setVisible(getShowSpeaker());
-}
-
-void LLIMChiclet::setCounter(S32 counter)
-{
- if (mCounterCtrl->getCounter() == counter)
- {
- return;
- }
-
- mCounterCtrl->setCounter(counter);
- setShowCounter(counter);
- setShowNewMessagesIcon(counter);
-}
-
-void LLIMChiclet::toggleCounterControl()
-{
- setRequiredWidth();
- mCounterCtrl->setVisible(getShowCounter());
-}
-
void LLIMChiclet::setShowNewMessagesIcon(bool show)
{
if(mNewMessagesIcon)
@@ -607,8 +342,7 @@ bool LLIMChiclet::getShowNewMessagesIcon()
void LLIMChiclet::onMouseDown()
{
- LLIMFloater::toggle(getSessionId());
- setCounter(0);
+ LLFloaterIMSession::toggle(getSessionId());
}
void LLIMChiclet::setToggleState(bool toggle)
@@ -616,52 +350,6 @@ void LLIMChiclet::setToggleState(bool toggle)
mChicletButton->setToggleState(toggle);
}
-void LLIMChiclet::draw()
-{
- LLUICtrl::draw();
-}
-
-// static
-LLIMChiclet::EType LLIMChiclet::getIMSessionType(const LLUUID& session_id)
-{
- EType type = TYPE_UNKNOWN;
-
- if(session_id.isNull())
- return type;
-
- EInstantMessage im_type = LLIMModel::getInstance()->getType(session_id);
- if (IM_COUNT == im_type)
- {
- llassert_always(0 && "IM session not found"); // should never happen
- return type;
- }
-
- switch(im_type)
- {
- case IM_NOTHING_SPECIAL:
- case IM_SESSION_P2P_INVITE:
- type = TYPE_IM;
- break;
- case IM_SESSION_GROUP_START:
- case IM_SESSION_INVITE:
- if (gAgent.isInGroup(session_id))
- {
- type = TYPE_GROUP;
- }
- else
- {
- type = TYPE_AD_HOC;
- }
- break;
- case IM_SESSION_CONFERENCE_START:
- type = TYPE_AD_HOC;
- default:
- break;
- }
-
- return type;
-}
-
BOOL LLIMChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
if(!mPopupMenu)
@@ -697,382 +385,6 @@ bool LLIMChiclet::canCreateMenu()
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-LLIMP2PChiclet::Params::Params()
-: avatar_icon("avatar_icon")
-, chiclet_button("chiclet_button")
-, unread_notifications("unread_notifications")
-, speaker("speaker")
-, new_message_icon("new_message_icon")
-, show_speaker("show_speaker")
-{
-}
-
-LLIMP2PChiclet::LLIMP2PChiclet(const Params& p)
-: LLIMChiclet(p)
-, mChicletIconCtrl(NULL)
-{
- LLButton::Params button_params = p.chiclet_button;
- mChicletButton = LLUICtrlFactory::create<LLButton>(button_params);
- addChild(mChicletButton);
-
- LLIconCtrl::Params new_msg_params = p.new_message_icon;
- mNewMessagesIcon = LLUICtrlFactory::create<LLIconCtrl>(new_msg_params);
- addChild(mNewMessagesIcon);
-
- LLChicletAvatarIconCtrl::Params avatar_params = p.avatar_icon;
- mChicletIconCtrl = LLUICtrlFactory::create<LLChicletAvatarIconCtrl>(avatar_params);
- addChild(mChicletIconCtrl);
-
- LLChicletNotificationCounterCtrl::Params unread_params = p.unread_notifications;
- mCounterCtrl = LLUICtrlFactory::create<LLChicletNotificationCounterCtrl>(unread_params);
- addChild(mCounterCtrl);
-
- setCounter(getCounter());
- setShowCounter(getShowCounter());
-
- LLChicletSpeakerCtrl::Params speaker_params = p.speaker;
- mSpeakerCtrl = LLUICtrlFactory::create<LLChicletSpeakerCtrl>(speaker_params);
- addChild(mSpeakerCtrl);
-
- sendChildToFront(mNewMessagesIcon);
- setShowSpeaker(p.show_speaker);
-}
-
-void LLIMP2PChiclet::initSpeakerControl()
-{
- mSpeakerCtrl->setSpeakerId(getOtherParticipantId());
-}
-
-void LLIMP2PChiclet::setOtherParticipantId(const LLUUID& other_participant_id)
-{
- LLIMChiclet::setOtherParticipantId(other_participant_id);
- mChicletIconCtrl->setValue(getOtherParticipantId());
-}
-
-void LLIMP2PChiclet::updateMenuItems()
-{
- if(!mPopupMenu)
- return;
- if(getSessionId().isNull())
- return;
-
- LLIMFloater* open_im_floater = LLIMFloater::findInstance(getSessionId());
- bool open_window_exists = open_im_floater && open_im_floater->getVisible();
- mPopupMenu->getChild<LLUICtrl>("Send IM")->setEnabled(!open_window_exists);
-
- bool is_friend = LLAvatarActions::isFriend(getOtherParticipantId());
- mPopupMenu->getChild<LLUICtrl>("Add Friend")->setEnabled(!is_friend);
-}
-
-void LLIMP2PChiclet::createPopupMenu()
-{
- if(!canCreateMenu())
- return;
-
- LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
- registrar.add("IMChicletMenu.Action", boost::bind(&LLIMP2PChiclet::onMenuItemClicked, this, _2));
-
- mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>
- ("menu_imchiclet_p2p.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
-}
-
-void LLIMP2PChiclet::onMenuItemClicked(const LLSD& user_data)
-{
- std::string level = user_data.asString();
- LLUUID other_participant_id = getOtherParticipantId();
-
- if("profile" == level)
- {
- LLAvatarActions::showProfile(other_participant_id);
- }
- else if("im" == level)
- {
- LLAvatarActions::startIM(other_participant_id);
- }
- else if("add" == level)
- {
- LLAvatarActions::requestFriendshipDialog(other_participant_id);
- }
- else if("end" == level)
- {
- LLAvatarActions::endIM(other_participant_id);
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-
-LLAdHocChiclet::Params::Params()
-: avatar_icon("avatar_icon")
-, chiclet_button("chiclet_button")
-, unread_notifications("unread_notifications")
-, speaker("speaker")
-, new_message_icon("new_message_icon")
-, show_speaker("show_speaker")
-, avatar_icon_color("avatar_icon_color", LLColor4::green)
-{
-}
-
-LLAdHocChiclet::LLAdHocChiclet(const Params& p)
-: LLIMChiclet(p)
-, mChicletIconCtrl(NULL)
-{
- LLButton::Params button_params = p.chiclet_button;
- mChicletButton = LLUICtrlFactory::create<LLButton>(button_params);
- addChild(mChicletButton);
-
- LLIconCtrl::Params new_msg_params = p.new_message_icon;
- mNewMessagesIcon = LLUICtrlFactory::create<LLIconCtrl>(new_msg_params);
- addChild(mNewMessagesIcon);
-
- LLChicletAvatarIconCtrl::Params avatar_params = p.avatar_icon;
- mChicletIconCtrl = LLUICtrlFactory::create<LLChicletAvatarIconCtrl>(avatar_params);
- //Make the avatar modified
- mChicletIconCtrl->setColor(p.avatar_icon_color);
- addChild(mChicletIconCtrl);
-
- LLChicletNotificationCounterCtrl::Params unread_params = p.unread_notifications;
- mCounterCtrl = LLUICtrlFactory::create<LLChicletNotificationCounterCtrl>(unread_params);
- addChild(mCounterCtrl);
-
- setCounter(getCounter());
- setShowCounter(getShowCounter());
-
- LLChicletSpeakerCtrl::Params speaker_params = p.speaker;
- mSpeakerCtrl = LLUICtrlFactory::create<LLChicletSpeakerCtrl>(speaker_params);
- addChild(mSpeakerCtrl);
-
- sendChildToFront(mNewMessagesIcon);
- setShowSpeaker(p.show_speaker);
-}
-
-void LLAdHocChiclet::setSessionId(const LLUUID& session_id)
-{
- LLChiclet::setSessionId(session_id);
- LLIMModel::LLIMSession* im_session = LLIMModel::getInstance()->findIMSession(session_id);
- mChicletIconCtrl->setValue(im_session->mOtherParticipantID);
-}
-
-void LLAdHocChiclet::draw()
-{
- switchToCurrentSpeaker();
- LLIMChiclet::draw();
-}
-
-void LLAdHocChiclet::initSpeakerControl()
-{
- switchToCurrentSpeaker();
-}
-
-void LLAdHocChiclet::switchToCurrentSpeaker()
-{
- LLUUID speaker_id;
- LLSpeakerMgr::speaker_list_t speaker_list;
-
- LLIMModel::getInstance()->findIMSession(getSessionId())->mSpeakers->getSpeakerList(&speaker_list, FALSE);
- for (LLSpeakerMgr::speaker_list_t::iterator i = speaker_list.begin(); i != speaker_list.end(); ++i)
- {
- LLPointer<LLSpeaker> s = *i;
- if (s->mSpeechVolume > 0 || s->mStatus == LLSpeaker::STATUS_SPEAKING)
- {
- speaker_id = s->mID;
- break;
- }
- }
-
- mSpeakerCtrl->setSpeakerId(speaker_id);
-}
-
-void LLAdHocChiclet::createPopupMenu()
-{
- if(!canCreateMenu())
- return;
-
- LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
- registrar.add("IMChicletMenu.Action", boost::bind(&LLAdHocChiclet::onMenuItemClicked, this, _2));
-
- mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>
- ("menu_imchiclet_adhoc.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
-}
-
-void LLAdHocChiclet::onMenuItemClicked(const LLSD& user_data)
-{
- std::string level = user_data.asString();
- LLUUID group_id = getSessionId();
-
- if("end" == level)
- {
- LLGroupActions::endIM(group_id);
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-
-LLIMGroupChiclet::Params::Params()
-: group_icon("group_icon")
-, chiclet_button("chiclet_button")
-, unread_notifications("unread_notifications")
-, speaker("speaker")
-, new_message_icon("new_message_icon")
-, show_speaker("show_speaker")
-{
-}
-
-LLIMGroupChiclet::LLIMGroupChiclet(const Params& p)
-: LLIMChiclet(p)
-, LLGroupMgrObserver(LLUUID::null)
-, mChicletIconCtrl(NULL)
-{
- LLButton::Params button_params = p.chiclet_button;
- mChicletButton = LLUICtrlFactory::create<LLButton>(button_params);
- addChild(mChicletButton);
-
- LLIconCtrl::Params new_msg_params = p.new_message_icon;
- mNewMessagesIcon = LLUICtrlFactory::create<LLIconCtrl>(new_msg_params);
- addChild(mNewMessagesIcon);
-
- LLChicletGroupIconCtrl::Params avatar_params = p.group_icon;
- mChicletIconCtrl = LLUICtrlFactory::create<LLChicletGroupIconCtrl>(avatar_params);
- addChild(mChicletIconCtrl);
-
- LLChicletNotificationCounterCtrl::Params unread_params = p.unread_notifications;
- mCounterCtrl = LLUICtrlFactory::create<LLChicletNotificationCounterCtrl>(unread_params);
- addChild(mCounterCtrl);
-
- setCounter(getCounter());
- setShowCounter(getShowCounter());
-
- LLChicletSpeakerCtrl::Params speaker_params = p.speaker;
- mSpeakerCtrl = LLUICtrlFactory::create<LLChicletSpeakerCtrl>(speaker_params);
- addChild(mSpeakerCtrl);
-
- sendChildToFront(mNewMessagesIcon);
- setShowSpeaker(p.show_speaker);
-}
-
-LLIMGroupChiclet::~LLIMGroupChiclet()
-{
- LLGroupMgr::getInstance()->removeObserver(this);
-}
-
-void LLIMGroupChiclet::draw()
-{
- if(getShowSpeaker())
- {
- switchToCurrentSpeaker();
- }
- LLIMChiclet::draw();
-}
-
-void LLIMGroupChiclet::initSpeakerControl()
-{
- switchToCurrentSpeaker();
-}
-
-void LLIMGroupChiclet::switchToCurrentSpeaker()
-{
- LLUUID speaker_id;
- LLSpeakerMgr::speaker_list_t speaker_list;
-
- LLIMModel::getInstance()->findIMSession(getSessionId())->mSpeakers->getSpeakerList(&speaker_list, FALSE);
- for (LLSpeakerMgr::speaker_list_t::iterator i = speaker_list.begin(); i != speaker_list.end(); ++i)
- {
- LLPointer<LLSpeaker> s = *i;
- if (s->mSpeechVolume > 0 || s->mStatus == LLSpeaker::STATUS_SPEAKING)
- {
- speaker_id = s->mID;
- break;
- }
- }
-
- mSpeakerCtrl->setSpeakerId(speaker_id);
-}
-
-void LLIMGroupChiclet::setSessionId(const LLUUID& session_id)
-{
- LLChiclet::setSessionId(session_id);
-
- LLGroupMgr* grp_mgr = LLGroupMgr::getInstance();
- LLGroupMgrGroupData* group_data = grp_mgr->getGroupData(session_id);
- if (group_data && group_data->mInsigniaID.notNull())
- {
- mChicletIconCtrl->setValue(group_data->mInsigniaID);
- }
- else
- {
- if(getSessionId() != mID)
- {
- grp_mgr->removeObserver(this);
- mID = getSessionId();
- grp_mgr->addObserver(this);
- }
- grp_mgr->sendGroupPropertiesRequest(session_id);
- }
-}
-
-void LLIMGroupChiclet::changed(LLGroupChange gc)
-{
- if (GC_PROPERTIES == gc)
- {
- LLGroupMgrGroupData* group_data = LLGroupMgr::getInstance()->getGroupData(getSessionId());
- if (group_data)
- {
- mChicletIconCtrl->setValue(group_data->mInsigniaID);
- }
- }
-}
-
-void LLIMGroupChiclet::updateMenuItems()
-{
- if(!mPopupMenu)
- return;
- if(getSessionId().isNull())
- return;
-
- LLIMFloater* open_im_floater = LLIMFloater::findInstance(getSessionId());
- bool open_window_exists = open_im_floater && open_im_floater->getVisible();
- mPopupMenu->getChild<LLUICtrl>("Chat")->setEnabled(!open_window_exists);
-}
-
-void LLIMGroupChiclet::createPopupMenu()
-{
- if(!canCreateMenu())
- return;
-
- LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
- registrar.add("IMChicletMenu.Action", boost::bind(&LLIMGroupChiclet::onMenuItemClicked, this, _2));
-
- mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>
- ("menu_imchiclet_group.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
-}
-
-void LLIMGroupChiclet::onMenuItemClicked(const LLSD& user_data)
-{
- std::string level = user_data.asString();
- LLUUID group_id = getSessionId();
-
- if("group chat" == level)
- {
- LLGroupActions::startIM(group_id);
- }
- else if("info" == level)
- {
- LLGroupActions::show(group_id);
- }
- else if("end" == level)
- {
- LLGroupActions::endIM(group_id);
- }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-
LLChicletPanel::Params::Params()
: chiclet_padding("chiclet_padding")
, scrolling_offset("scrolling_offset")
@@ -1118,25 +430,11 @@ void LLChicletPanel::onMessageCountChanged(const LLSD& data)
LLUUID session_id = data["session_id"].asUUID();
S32 unread = data["participant_unread"].asInteger();
- LLIMFloater* im_floater = LLIMFloater::findInstance(session_id);
+ LLFloaterIMSession* im_floater = LLFloaterIMSession::findInstance(session_id);
if (im_floater && im_floater->getVisible() && im_floater->hasFocus())
{
unread = 0;
}
-
- std::list<LLChiclet*> chiclets = LLIMChiclet::sFindChicletsSignal(session_id);
- std::list<LLChiclet *>::iterator iter;
- for (iter = chiclets.begin(); iter != chiclets.end(); iter++) {
- LLChiclet* chiclet = *iter;
- if (chiclet != NULL)
- {
- chiclet->setCounter(unread);
- }
- else
- {
- llwarns << "Unable to set counter for chiclet " << session_id << llendl;
- }
- }
}
void LLChicletPanel::objectChicletCallback(const LLSD& data)
@@ -1151,10 +449,6 @@ void LLChicletPanel::objectChicletCallback(const LLSD& data)
LLIMChiclet* chiclet = dynamic_cast<LLIMChiclet*>(*iter);
if (chiclet != NULL)
{
- if(data.has("unread"))
- {
- chiclet->setCounter(data["unread"]);
- }
chiclet->setShowNewMessagesIcon(new_message);
}
}
@@ -1196,28 +490,13 @@ void LLChicletPanel::onCurrentVoiceChannelChanged(const LLUUID& session_id)
LLIMChiclet* chiclet = dynamic_cast<LLIMChiclet*>(*it);
if(chiclet)
{
- chiclet->setShowSpeaker(true);
if (gSavedSettings.getBOOL("OpenIMOnVoice"))
{
- LLIMFloater::show(chiclet->getSessionId());
+ LLFloaterIMContainer::getInstance()->showConversation(session_id);
}
}
}
- if(!s_previous_active_voice_session_id.isNull() && s_previous_active_voice_session_id != session_id)
- {
- chiclets = LLIMChiclet::sFindChicletsSignal(s_previous_active_voice_session_id);
-
- for(std::list<LLChiclet *>::iterator it = chiclets.begin(); it != chiclets.end(); ++it)
- {
- LLIMChiclet* chiclet = dynamic_cast<LLIMChiclet*>(*it);
- if(chiclet)
- {
- chiclet->setShowSpeaker(false);
- }
- }
- }
-
s_previous_active_voice_session_id = session_id;
}
@@ -1690,7 +969,7 @@ bool LLChicletPanel::isAnyIMFloaterDoked()
for (chiclet_list_t::iterator it = mChicletList.begin(); it
!= mChicletList.end(); it++)
{
- LLIMFloater* im_floater = LLFloaterReg::findTypedInstance<LLIMFloater>(
+ LLFloaterIMSession* im_floater = LLFloaterReg::findTypedInstance<LLFloaterIMSession>(
"impanel", (*it)->getSessionId());
if (im_floater != NULL && im_floater->getVisible()
&& !im_floater->isMinimized() && im_floater->isDocked())
@@ -1703,89 +982,17 @@ bool LLChicletPanel::isAnyIMFloaterDoked()
return res;
}
-S32 LLChicletPanel::getTotalUnreadIMCount()
-{
- S32 count = 0;
- chiclet_list_t::const_iterator it = mChicletList.begin();
- for( ; mChicletList.end() != it; ++it)
- {
- LLIMChiclet* chiclet = dynamic_cast<LLIMChiclet*>(*it);
- if(chiclet)
- {
- count += chiclet->getCounter();
- }
- }
- return count;
-}
-
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
LLChicletNotificationCounterCtrl::Params::Params()
-: max_displayed_count("max_displayed_count", 99)
-{
-}
-
-LLChicletNotificationCounterCtrl::LLChicletNotificationCounterCtrl(const Params& p)
- : LLTextBox(p)
- , mCounter(0)
- , mInitialWidth(0)
- , mMaxDisplayedCount(p.max_displayed_count)
-{
- mInitialWidth = getRect().getWidth();
-}
-
-void LLChicletNotificationCounterCtrl::setCounter(S32 counter)
-{
- mCounter = counter;
-
- // note same code in LLSysWellChiclet::setCounter(S32 counter)
- std::string s_count;
- if(counter != 0)
- {
- static std::string more_messages_exist("+");
- std::string more_messages(counter > mMaxDisplayedCount ? more_messages_exist : "");
- s_count = llformat("%d%s"
- , llmin(counter, mMaxDisplayedCount)
- , more_messages.c_str()
- );
- }
-
- if(mCounter != 0)
- {
- setText(s_count);
- }
- else
- {
- setText(std::string(""));
- }
-}
-
-LLRect LLChicletNotificationCounterCtrl::getRequiredRect()
-{
- LLRect rc;
- S32 text_width = getTextPixelWidth();
-
- rc.mRight = rc.mLeft + llmax(text_width, mInitialWidth);
-
- return rc;
-}
-
-void LLChicletNotificationCounterCtrl::setValue(const LLSD& value)
+ : max_displayed_count("max_displayed_count", 99)
{
- if(value.isInteger())
- setCounter(value.asInteger());
-}
-
-LLSD LLChicletNotificationCounterCtrl::getValue() const
-{
- return LLSD(getCounter());
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-
LLChicletAvatarIconCtrl::LLChicletAvatarIconCtrl(const Params& p)
: LLAvatarIconCtrl(p)
{
@@ -1795,29 +1002,6 @@ LLChicletAvatarIconCtrl::LLChicletAvatarIconCtrl(const Params& p)
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-LLChicletGroupIconCtrl::LLChicletGroupIconCtrl(const Params& p)
-: LLIconCtrl(p)
-, mDefaultIcon(p.default_icon)
-{
- setValue(LLUUID::null);
-}
-
-void LLChicletGroupIconCtrl::setValue(const LLSD& value )
-{
- if(value.asUUID().isNull())
- {
- LLIconCtrl::setValue(mDefaultIcon);
- }
- else
- {
- LLIconCtrl::setValue(value);
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-
LLChicletInvOfferIconCtrl::LLChicletInvOfferIconCtrl(const Params& p)
: LLChicletAvatarIconCtrl(p)
, mDefaultIcon(p.default_icon)
@@ -1840,15 +1024,6 @@ void LLChicletInvOfferIconCtrl::setValue(const LLSD& value )
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-LLChicletSpeakerCtrl::LLChicletSpeakerCtrl(const Params&p)
- : LLOutputMonitorCtrl(p)
-{
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-
LLScriptChiclet::Params::Params()
: icon("icon")
, chiclet_button("chiclet_button")
@@ -1884,11 +1059,6 @@ void LLScriptChiclet::setSessionId(const LLUUID& session_id)
setToolTip(LLScriptFloaterManager::getObjectName(session_id));
}
-void LLScriptChiclet::setCounter(S32 counter)
-{
- setShowNewMessagesIcon( counter > 0 );
-}
-
void LLScriptChiclet::onMouseDown()
{
LLScriptFloaterManager::getInstance()->toggleScriptFloater(getSessionId());
@@ -1967,11 +1137,6 @@ void LLInvOfferChiclet::setSessionId(const LLUUID& session_id)
}
}
-void LLInvOfferChiclet::setCounter(S32 counter)
-{
- setShowNewMessagesIcon( counter > 0 );
-}
-
void LLInvOfferChiclet::onMouseDown()
{
LLScriptFloaterManager::instance().toggleScriptFloater(getSessionId());