summaryrefslogtreecommitdiff
path: root/indra/newview/llsyswellwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llsyswellwindow.cpp')
-rw-r--r--indra/newview/llsyswellwindow.cpp418
1 files changed, 217 insertions, 201 deletions
diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp
index a64c200b92..c288301923 100644
--- a/indra/newview/llsyswellwindow.cpp
+++ b/indra/newview/llsyswellwindow.cpp
@@ -54,9 +54,6 @@ LLSysWellWindow::LLSysWellWindow(const LLSD& key) : LLDockableFloater(NULL, key)
mMessageList(NULL),
mSeparator(NULL)
{
- LLIMMgr::getInstance()->addSessionObserver(this);
- LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLSysWellWindow::findIMChiclet, this, _1));
-
mTypedItemsCount[IT_NOTIFICATION] = 0;
mTypedItemsCount[IT_INSTANT_MESSAGE] = 0;
}
@@ -66,11 +63,6 @@ BOOL LLSysWellWindow::postBuild()
{
mMessageList = getChild<LLFlatListView>("notification_list");
- // init connections to the list's update events
- connectListUpdaterToSignal("notify");
- connectListUpdaterToSignal("groupnotify");
- connectListUpdaterToSignal("offer");
-
// get a corresponding channel
initChannel();
@@ -96,21 +88,6 @@ void LLSysWellWindow::setMinimized(BOOL minimize)
}
//---------------------------------------------------------------------------------
-void LLSysWellWindow::connectListUpdaterToSignal(std::string notification_type)
-{
- LLNotificationsUI::LLNotificationManager* manager = LLNotificationsUI::LLNotificationManager::getInstance();
- LLNotificationsUI::LLEventHandler* n_handler = manager->getHandlerForNotification(notification_type);
- if(n_handler)
- {
- n_handler->setNotificationIDCallback(boost::bind(&LLSysWellWindow::removeItemByID, this, _1));
- }
- else
- {
- llwarns << "LLSysWellWindow::connectListUpdaterToSignal() - could not get a handler for '" << notification_type <<"' type of notifications" << llendl;
- }
-}
-
-//---------------------------------------------------------------------------------
void LLSysWellWindow::onStartUpToastClick(S32 x, S32 y, MASK mask)
{
// just set floater visible. Screen channels will be cleared.
@@ -118,53 +95,8 @@ void LLSysWellWindow::onStartUpToastClick(S32 x, S32 y, MASK mask)
}
//---------------------------------------------------------------------------------
-void LLSysWellWindow::clearScreenChannels()
-{
- // 1 - remove StartUp toast and channel if present
- if(!LLNotificationsUI::LLScreenChannel::getStartUpToastShown())
- {
- LLNotificationsUI::LLChannelManager::getInstance()->onStartUpToastClose();
- }
-
- // 2 - remove toasts in Notification channel
- if(mChannel)
- {
- mChannel->removeAndStoreAllStorableToasts();
- }
-}
-
-//---------------------------------------------------------------------------------
LLSysWellWindow::~LLSysWellWindow()
{
- LLIMMgr::getInstance()->removeSessionObserver(this);
-}
-
-//---------------------------------------------------------------------------------
-void LLSysWellWindow::addItem(LLSysWellItem::Params p)
-{
- LLSD value = p.notification_id;
- // do not add clones
- if( mMessageList->getItemByValue(value))
- return;
-
- LLSysWellItem* new_item = new LLSysWellItem(p);
- if (mMessageList->addItem(new_item, value, ADD_TOP))
- {
- handleItemAdded(IT_NOTIFICATION);
-
- reshapeWindow();
-
- new_item->setOnItemCloseCallback(boost::bind(&LLSysWellWindow::onItemClose, this, _1));
- new_item->setOnItemClickCallback(boost::bind(&LLSysWellWindow::onItemClick, this, _1));
- }
- else
- {
- llwarns << "Unable to add Notification into the list, notification ID: " << p.notification_id
- << ", title: " << p.title
- << llendl;
-
- new_item->die();
- }
}
//---------------------------------------------------------------------------------
@@ -195,42 +127,13 @@ void LLSysWellWindow::removeItemByID(const LLUUID& id)
}
//---------------------------------------------------------------------------------
-void LLSysWellWindow::onItemClick(LLSysWellItem* item)
-{
- LLUUID id = item->getID();
- if(mChannel)
- mChannel->loadStoredToastByNotificationIDToChannel(id);
-}
-
-//---------------------------------------------------------------------------------
-void LLSysWellWindow::onItemClose(LLSysWellItem* item)
-{
- LLUUID id = item->getID();
- removeItemByID(id);
- if(mChannel)
- mChannel->killToastByNotificationID(id);
-}
-
-//--------------------------------------------------------------------------
-void LLSysWellWindow::onStoreToast(LLPanel* info_panel, LLUUID id)
-{
- LLSysWellItem::Params p;
- p.notification_id = id;
- p.title = static_cast<LLToastPanel*>(info_panel)->getTitle();
- addItem(p);
-}
-
//---------------------------------------------------------------------------------
void LLSysWellWindow::initChannel()
{
LLNotificationsUI::LLScreenChannelBase* channel = LLNotificationsUI::LLChannelManager::getInstance()->findChannelByID(
LLUUID(gSavedSettings.getString("NotificationChannelUUID")));
mChannel = dynamic_cast<LLNotificationsUI::LLScreenChannel*>(channel);
- if(mChannel)
- {
- mChannel->setOnStoreToastCallback(boost::bind(&LLSysWellWindow::onStoreToast, this, _1, _2));
- }
- else
+ if(NULL == mChannel)
{
llwarns << "LLSysWellWindow::initChannel() - could not get a requested screen channel" << llendl;
}
@@ -256,9 +159,6 @@ void LLSysWellWindow::setVisible(BOOL visible)
LLBottomTray::getInstance()->getChild<LLView>(NOTIFICATION_WELL_ANCHOR_NAME), this,
getDockTongue(), LLDockControl::TOP, boost::bind(&LLSysWellWindow::getAllowedRect, this, _1)));
}
-
- // when Notification channel is cleared, storable toasts will be added into the list.
- clearScreenChannels();
}
// do not show empty window
@@ -318,104 +218,13 @@ void LLSysWellWindow::reshapeWindow()
}
//---------------------------------------------------------------------------------
-LLChiclet* LLSysWellWindow::findIMChiclet(const LLUUID& sessionId)
-{
- LLChiclet* res = NULL;
- RowPanel* panel = mMessageList->getTypedItemByValue<RowPanel>(sessionId);
- if (panel != NULL)
- {
- res = panel->mChiclet;
- }
-
- return res;
-}
-
-//---------------------------------------------------------------------------------
-void LLSysWellWindow::addIMRow(const LLUUID& sessionId, S32 chicletCounter,
- const std::string& name, const LLUUID& otherParticipantId)
-{
- RowPanel* item = new RowPanel(this, sessionId, chicletCounter, name, otherParticipantId);
- if (mMessageList->insertItemAfter(mSeparator, item, sessionId))
- {
- handleItemAdded(IT_INSTANT_MESSAGE);
- }
- else
- {
- llwarns << "Unable to add IM Row into the list, sessionID: " << sessionId
- << ", name: " << name
- << ", other participant ID: " << otherParticipantId
- << llendl;
-
- item->die();
- }
-}
-
-//---------------------------------------------------------------------------------
-void LLSysWellWindow::delIMRow(const LLUUID& sessionId)
-{
- if (mMessageList->removeItemByValue(sessionId))
- {
- handleItemRemoved(IT_INSTANT_MESSAGE);
- }
- else
- {
- llwarns << "Unable to remove IM Row from the list, sessionID: " << sessionId
- << llendl;
- }
-
- // remove all toasts that belong to this session from a screen
- if(mChannel)
- mChannel->removeToastsBySessionID(sessionId);
-
- // hide chiclet window if there are no items left
- if(isWindowEmpty())
- {
- setVisible(FALSE);
- }
-}
-
-//---------------------------------------------------------------------------------
bool LLSysWellWindow::isWindowEmpty()
{
// keep in mind, mSeparator is always in the list
return mMessageList->size() == 1;
}
-//---------------------------------------------------------------------------------
-//virtual
-void LLSysWellWindow::sessionAdded(const LLUUID& session_id,
- const std::string& name, const LLUUID& other_participant_id)
-{
- if (mMessageList->getItemByValue(session_id) == NULL)
- {
- S32 chicletCounter = LLIMModel::getInstance()->getNumUnread(session_id);
- if (chicletCounter > -1)
- {
- addIMRow(session_id, chicletCounter, name, other_participant_id);
- reshapeWindow();
- }
- }
-}
-
-//---------------------------------------------------------------------------------
-//virtual
-void LLSysWellWindow::sessionRemoved(const LLUUID& sessionId)
-{
- delIMRow(sessionId);
- reshapeWindow();
-}
-
-void LLSysWellWindow::sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id)
-{
- //for outgoing ad-hoc and group im sessions only
- LLChiclet* chiclet = findIMChiclet(old_session_id);
- if (chiclet)
- {
- chiclet->setSessionId(new_session_id);
- mMessageList->updateValue(old_session_id, new_session_id);
- }
-}
-
+// *TODO: mantipov: probably is deprecated
void LLSysWellWindow::handleItemAdded(EItemType added_item_type)
{
bool should_be_shown = ++mTypedItemsCount[added_item_type] == 1 && anotherTypeExists(added_item_type);
@@ -463,8 +272,12 @@ bool LLSysWellWindow::anotherTypeExists(EItemType item_type)
return exists;
}
+/************************************************************************/
+/* RowPanel implementation */
+/************************************************************************/
+
//---------------------------------------------------------------------------------
-LLSysWellWindow::RowPanel::RowPanel(const LLSysWellWindow* parent, const LLUUID& sessionId,
+LLIMWellWindow::RowPanel::RowPanel(const LLSysWellWindow* parent, const LLUUID& sessionId,
S32 chicletCounter, const std::string& name, const LLUUID& otherParticipantId) :
LLPanel(LLPanel::Params()), mChiclet(NULL), mParent(parent)
{
@@ -499,36 +312,36 @@ LLSysWellWindow::RowPanel::RowPanel(const LLSysWellWindow* parent, const LLUUID&
contactName->setValue(name);
mCloseBtn = getChild<LLButton>("hide_btn");
- mCloseBtn->setCommitCallback(boost::bind(&LLSysWellWindow::RowPanel::onClosePanel, this));
+ mCloseBtn->setCommitCallback(boost::bind(&LLIMWellWindow::RowPanel::onClosePanel, this));
}
//---------------------------------------------------------------------------------
-LLSysWellWindow::RowPanel::~RowPanel()
+LLIMWellWindow::RowPanel::~RowPanel()
{
}
//---------------------------------------------------------------------------------
-void LLSysWellWindow::RowPanel::onClosePanel()
+void LLIMWellWindow::RowPanel::onClosePanel()
{
gIMMgr->leaveSession(mChiclet->getSessionId());
// This row panel will be removed from the list in LLSysWellWindow::sessionRemoved().
}
//---------------------------------------------------------------------------------
-void LLSysWellWindow::RowPanel::onMouseEnter(S32 x, S32 y, MASK mask)
+void LLIMWellWindow::RowPanel::onMouseEnter(S32 x, S32 y, MASK mask)
{
setTransparentColor(LLUIColorTable::instance().getColor("SysWellItemSelected"));
}
//---------------------------------------------------------------------------------
-void LLSysWellWindow::RowPanel::onMouseLeave(S32 x, S32 y, MASK mask)
+void LLIMWellWindow::RowPanel::onMouseLeave(S32 x, S32 y, MASK mask)
{
setTransparentColor(LLUIColorTable::instance().getColor("SysWellItemUnselected"));
}
//---------------------------------------------------------------------------------
// virtual
-BOOL LLSysWellWindow::RowPanel::handleMouseDown(S32 x, S32 y, MASK mask)
+BOOL LLIMWellWindow::RowPanel::handleMouseDown(S32 x, S32 y, MASK mask)
{
// Pass the mouse down event to the chiclet (EXT-596).
if (!mChiclet->pointInView(x, y) && !mCloseBtn->getRect().pointInRect(x, y)) // prevent double call of LLIMChiclet::onMouseDown()
@@ -548,7 +361,10 @@ BOOL LLSysWellWindow::RowPanel::handleMouseDown(S32 x, S32 y, MASK mask)
LLNotificationWellWindow::LLNotificationWellWindow(const LLSD& key)
: LLSysWellWindow(key)
{
-
+ // init connections to the list's update events
+ connectListUpdaterToSignal("notify");
+ connectListUpdaterToSignal("groupnotify");
+ connectListUpdaterToSignal("offer");
}
// static
@@ -557,6 +373,108 @@ LLNotificationWellWindow* LLNotificationWellWindow::getInstance(const LLSD& key
return LLFloaterReg::getTypedInstance<LLNotificationWellWindow>("notification_well_window", key);
}
+void LLNotificationWellWindow::setVisible(BOOL visible)
+{
+ if (visible)
+ {
+ // when Notification channel is cleared, storable toasts will be added into the list.
+ clearScreenChannels();
+ }
+
+ LLSysWellWindow::setVisible(visible);
+}
+
+//---------------------------------------------------------------------------------
+void LLNotificationWellWindow::addItem(LLSysWellItem::Params p)
+{
+ LLSD value = p.notification_id;
+ // do not add clones
+ if( mMessageList->getItemByValue(value))
+ return;
+
+ LLSysWellItem* new_item = new LLSysWellItem(p);
+ if (mMessageList->addItem(new_item, value, ADD_TOP))
+ {
+ handleItemAdded(IT_NOTIFICATION);
+
+ reshapeWindow();
+
+ new_item->setOnItemCloseCallback(boost::bind(&LLNotificationWellWindow::onItemClose, this, _1));
+ new_item->setOnItemClickCallback(boost::bind(&LLNotificationWellWindow::onItemClick, this, _1));
+ }
+ else
+ {
+ llwarns << "Unable to add Notification into the list, notification ID: " << p.notification_id
+ << ", title: " << p.title
+ << llendl;
+
+ new_item->die();
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+// PRIVATE METHODS
+void LLNotificationWellWindow::initChannel()
+{
+ LLSysWellWindow::initChannel();
+ if(mChannel)
+ {
+ mChannel->setOnStoreToastCallback(boost::bind(&LLNotificationWellWindow::onStoreToast, this, _1, _2));
+ }
+}
+
+void LLNotificationWellWindow::clearScreenChannels()
+{
+ // 1 - remove StartUp toast and channel if present
+ if(!LLNotificationsUI::LLScreenChannel::getStartUpToastShown())
+ {
+ LLNotificationsUI::LLChannelManager::getInstance()->onStartUpToastClose();
+ }
+
+ // 2 - remove toasts in Notification channel
+ if(mChannel)
+ {
+ mChannel->removeAndStoreAllStorableToasts();
+ }
+}
+
+void LLNotificationWellWindow::onStoreToast(LLPanel* info_panel, LLUUID id)
+{
+ LLSysWellItem::Params p;
+ p.notification_id = id;
+ p.title = static_cast<LLToastPanel*>(info_panel)->getTitle();
+ addItem(p);
+}
+
+void LLNotificationWellWindow::connectListUpdaterToSignal(std::string notification_type)
+{
+ LLNotificationsUI::LLNotificationManager* manager = LLNotificationsUI::LLNotificationManager::getInstance();
+ LLNotificationsUI::LLEventHandler* n_handler = manager->getHandlerForNotification(notification_type);
+ if(n_handler)
+ {
+ n_handler->setNotificationIDCallback(boost::bind(&LLNotificationWellWindow::removeItemByID, this, _1));
+ }
+ else
+ {
+ llwarns << "LLSysWellWindow::connectListUpdaterToSignal() - could not get a handler for '" << notification_type <<"' type of notifications" << llendl;
+ }
+}
+
+void LLNotificationWellWindow::onItemClick(LLSysWellItem* item)
+{
+ LLUUID id = item->getID();
+ if(mChannel)
+ mChannel->loadStoredToastByNotificationIDToChannel(id);
+}
+
+void LLNotificationWellWindow::onItemClose(LLSysWellItem* item)
+{
+ LLUUID id = item->getID();
+ removeItemByID(id);
+ if(mChannel)
+ mChannel->killToastByNotificationID(id);
+}
+
/************************************************************************/
@@ -568,7 +486,13 @@ LLNotificationWellWindow* LLNotificationWellWindow::getInstance(const LLSD& key
LLIMWellWindow::LLIMWellWindow(const LLSD& key)
: LLSysWellWindow(key)
{
+ LLIMMgr::getInstance()->addSessionObserver(this);
+ LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLIMWellWindow::findIMChiclet, this, _1));
+}
+LLIMWellWindow::~LLIMWellWindow()
+{
+ LLIMMgr::getInstance()->removeSessionObserver(this);
}
// static
@@ -577,4 +501,96 @@ LLIMWellWindow* LLIMWellWindow::getInstance(const LLSD& key /*= LLSD()*/)
return LLFloaterReg::getTypedInstance<LLIMWellWindow>("im_well_window", key);
}
+//virtual
+void LLIMWellWindow::sessionAdded(const LLUUID& session_id,
+ const std::string& name, const LLUUID& other_participant_id)
+{
+ if (mMessageList->getItemByValue(session_id) == NULL)
+ {
+ S32 chicletCounter = LLIMModel::getInstance()->getNumUnread(session_id);
+ if (chicletCounter > -1)
+ {
+ addIMRow(session_id, chicletCounter, name, other_participant_id);
+ reshapeWindow();
+ }
+ }
+}
+
+//virtual
+void LLIMWellWindow::sessionRemoved(const LLUUID& sessionId)
+{
+ delIMRow(sessionId);
+ reshapeWindow();
+}
+
+//virtual
+void LLIMWellWindow::sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id)
+{
+ //for outgoing ad-hoc and group im sessions only
+ LLChiclet* chiclet = findIMChiclet(old_session_id);
+ if (chiclet)
+ {
+ chiclet->setSessionId(new_session_id);
+ mMessageList->updateValue(old_session_id, new_session_id);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+// PRIVATE METHODS
+LLChiclet* LLIMWellWindow::findIMChiclet(const LLUUID& sessionId)
+{
+ LLChiclet* res = NULL;
+ RowPanel* panel = mMessageList->getTypedItemByValue<RowPanel>(sessionId);
+ if (panel != NULL)
+ {
+ res = panel->mChiclet;
+ }
+
+ return res;
+}
+
+//---------------------------------------------------------------------------------
+void LLIMWellWindow::addIMRow(const LLUUID& sessionId, S32 chicletCounter,
+ const std::string& name, const LLUUID& otherParticipantId)
+{
+ RowPanel* item = new RowPanel(this, sessionId, chicletCounter, name, otherParticipantId);
+ if (mMessageList->insertItemAfter(mSeparator, item, sessionId))
+ {
+ handleItemAdded(IT_INSTANT_MESSAGE);
+ }
+ else
+ {
+ llwarns << "Unable to add IM Row into the list, sessionID: " << sessionId
+ << ", name: " << name
+ << ", other participant ID: " << otherParticipantId
+ << llendl;
+
+ item->die();
+ }
+}
+
+//---------------------------------------------------------------------------------
+void LLIMWellWindow::delIMRow(const LLUUID& sessionId)
+{
+ if (mMessageList->removeItemByValue(sessionId))
+ {
+ handleItemRemoved(IT_INSTANT_MESSAGE);
+ }
+ else
+ {
+ llwarns << "Unable to remove IM Row from the list, sessionID: " << sessionId
+ << llendl;
+ }
+
+ // remove all toasts that belong to this session from a screen
+ if(mChannel)
+ mChannel->removeToastsBySessionID(sessionId);
+
+ // hide chiclet window if there are no items left
+ if(isWindowEmpty())
+ {
+ setVisible(FALSE);
+ }
+}
+
// EOF