summaryrefslogtreecommitdiff
path: root/indra/newview/llnearbychathandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llnearbychathandler.cpp')
-rw-r--r--indra/newview/llnearbychathandler.cpp207
1 files changed, 121 insertions, 86 deletions
diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp
index d2ad78f140..600fd395fb 100644
--- a/indra/newview/llnearbychathandler.cpp
+++ b/indra/newview/llnearbychathandler.cpp
@@ -29,7 +29,6 @@
#include "llagentdata.h" // for gAgentID
#include "llnearbychathandler.h"
-#include "llbottomtray.h"
#include "llchatitemscontainerctrl.h"
#include "llfirstuse.h"
#include "llfloaterscriptdebug.h"
@@ -41,6 +40,9 @@
#include "llfloaterreg.h"//for LLFloaterReg::getTypedInstance
#include "llviewerwindow.h"//for screen channel position
+#include "llnearbychatbar.h"
+#include "llrootview.h"
+#include "lllayoutstack.h"
//add LLNearbyChatHandler to LLNotificationsUI namespace
using namespace LLNotificationsUI;
@@ -61,7 +63,8 @@ public:
typedef std::vector<LLHandle<LLToast> > toast_vec_t;
typedef std::list<LLHandle<LLToast> > toast_list_t;
- LLNearbyChatScreenChannel(const LLUUID& id):LLScreenChannelBase(id)
+ LLNearbyChatScreenChannel(const Params& p)
+ : LLScreenChannelBase(p)
{
mStopProcessing = false;
@@ -80,7 +83,6 @@ public:
void addNotification (LLSD& notification);
void arrangeToasts ();
- void showToastsBottom ();
typedef boost::function<LLToastPanelBase* (void )> create_toast_panel_callback_t;
void setCreatePanelCallback(create_toast_panel_callback_t value) { m_create_toast_panel_callback_t = value;}
@@ -88,8 +90,6 @@ public:
void onToastDestroyed (LLToast* toast, bool app_quitting);
void onToastFade (LLToast* toast);
- void reshape (S32 width, S32 height, BOOL called_from_parent);
-
void redrawToasts()
{
arrangeToasts();
@@ -121,7 +121,7 @@ protected:
if (!toast) return;
LL_DEBUGS("NearbyChat") << "Pooling toast" << llendl;
toast->setVisible(FALSE);
- toast->stopFading();
+ toast->stopTimer();
toast->setIsHidden(true);
// Nearby chat toasts that are hidden, not destroyed. They are collected to the toast pool, so that
@@ -149,6 +149,7 @@ protected:
toast_list_t m_toast_pool;
bool mStopProcessing;
+ bool mChannelRect;
};
//-----------------------------------------------------------------------------------------------
@@ -268,6 +269,9 @@ bool LLNearbyChatScreenChannel::createPoolToast()
toast->setOnFadeCallback(boost::bind(&LLNearbyChatScreenChannel::onToastFade, this, _1));
+ // If the toast gets somehow prematurely destroyed, deactivate it to prevent crash (STORM-1352).
+ toast->setOnToastDestroyedCallback(boost::bind(&LLNearbyChatScreenChannel::onToastDestroyed, this, _1, false));
+
LL_DEBUGS("NearbyChat") << "Creating and pooling toast" << llendl;
m_toast_pool.push_back(toast->getHandle());
return true;
@@ -296,7 +300,7 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification)
{
panel->addMessage(notification);
toast->reshapeToPanel();
- toast->startFading();
+ toast->startTimer();
arrangeToasts();
return;
@@ -341,48 +345,50 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification)
panel->init(notification);
toast->reshapeToPanel();
- toast->startFading();
+ toast->startTimer();
m_active_toasts.push_back(toast->getHandle());
arrangeToasts();
}
-void LLNearbyChatScreenChannel::arrangeToasts()
+static bool sort_toasts_predicate(LLHandle<LLToast> first, LLHandle<LLToast> second)
{
- if(!isHovering())
- {
- showToastsBottom();
- }
-
- if (m_active_toasts.empty())
- {
- LLHints::registerHintTarget("incoming_chat", LLHandle<LLView>());
- }
- else
- {
- LLToast* toast = m_active_toasts.front().get();
- if (toast)
- {
- LLHints::registerHintTarget("incoming_chat", m_active_toasts.front().get()->LLView::getHandle());
- }
- }
-}
+ if (!first.get() || !second.get()) return false; // STORM-1352
-int sort_toasts_predicate(LLHandle<LLToast> first, LLHandle<LLToast> second)
-{
F32 v1 = first.get()->getTimeLeftToLive();
F32 v2 = second.get()->getTimeLeftToLive();
return v1 > v2;
}
-void LLNearbyChatScreenChannel::showToastsBottom()
+void LLNearbyChatScreenChannel::arrangeToasts()
{
- if(mStopProcessing)
+ if(mStopProcessing || isHovering())
return;
+ if (mFloaterSnapRegion == NULL)
+ {
+ mFloaterSnapRegion = gViewerWindow->getRootView()->getChildView("floater_snap_region");
+ }
+
+ if (!getParent())
+ {
+ // connect to floater snap region just to get resize events, we don't care about being a proper widget
+ mFloaterSnapRegion->addChild(this);
+ setFollows(FOLLOWS_ALL);
+ }
+
LLRect toast_rect;
- S32 bottom = getRect().mBottom;
+ updateRect();
+
+ LLRect channel_rect;
+ mFloaterSnapRegion->localRectToOtherView(mFloaterSnapRegion->getLocalRect(), &channel_rect, gFloaterView);
+ channel_rect.mLeft += 10;
+ channel_rect.mRight = channel_rect.mLeft + 300;
+
+ S32 channel_bottom = channel_rect.mBottom;
+
+ S32 bottom = channel_bottom + 80;
S32 margin = gSavedSettings.getS32("ToastGap");
//sort active toasts
@@ -393,11 +399,15 @@ void LLNearbyChatScreenChannel::showToastsBottom()
for(toast_vec_t::iterator it = m_active_toasts.begin(); it != m_active_toasts.end(); ++it)
{
LLToast* toast = it->get();
- if (!toast) continue;
+ if (!toast)
+ {
+ llwarns << "NULL found in the active chat toasts list!" << llendl;
+ continue;
+ }
S32 toast_top = bottom + toast->getRect().getHeight() + margin;
- if(toast_top > gFloaterView->getRect().getHeight())
+ if(toast_top > channel_rect.getHeight())
{
while(it!=m_active_toasts.end())
{
@@ -408,7 +418,7 @@ void LLNearbyChatScreenChannel::showToastsBottom()
}
toast_rect = toast->getRect();
- toast_rect.setLeftTopAndSize(getRect().mLeft , bottom + toast_rect.getHeight(), toast_rect.getWidth() ,toast_rect.getHeight());
+ toast_rect.setLeftTopAndSize(channel_rect.mLeft , bottom + toast_rect.getHeight(), toast_rect.getWidth() ,toast_rect.getHeight());
toast->setRect(toast_rect);
bottom += toast_rect.getHeight() - toast->getTopPad() + margin;
@@ -426,30 +436,31 @@ void LLNearbyChatScreenChannel::showToastsBottom()
}
}
- }
-
-void LLNearbyChatScreenChannel::reshape (S32 width, S32 height, BOOL called_from_parent)
-{
- LLScreenChannelBase::reshape(width, height, called_from_parent);
- arrangeToasts();
}
+
//-----------------------------------------------------------------------------------------------
//LLNearbyChatHandler
//-----------------------------------------------------------------------------------------------
+boost::scoped_ptr<LLEventPump> LLNearbyChatHandler::sChatWatcher(new LLEventStream("LLChat"));
+
LLNearbyChatHandler::LLNearbyChatHandler(e_notification_type type, const LLSD& id)
{
mType = type;
// Getting a Channel for our notifications
- LLNearbyChatScreenChannel* channel = new LLNearbyChatScreenChannel(LLUUID(gSavedSettings.getString("NearByChatChannelUUID")));
+ LLNearbyChatScreenChannel::Params p;
+ p.id = LLUUID(gSavedSettings.getString("NearByChatChannelUUID"));
+ LLNearbyChatScreenChannel* channel = new LLNearbyChatScreenChannel(p);
LLNearbyChatScreenChannel::create_toast_panel_callback_t callback = createToastPanel;
channel->setCreatePanelCallback(callback);
- mChannel = LLChannelManager::getInstance()->addChannel(channel);
+ LLChannelManager::getInstance()->addChannel(channel);
+
+ mChannel = channel->getHandle();
}
LLNearbyChatHandler::~LLNearbyChatHandler()
@@ -459,15 +470,14 @@ LLNearbyChatHandler::~LLNearbyChatHandler()
void LLNearbyChatHandler::initChannel()
{
- LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
- LLView* chat_box = LLBottomTray::getInstance()->getChildView("chat_box");
- S32 channel_right_bound = nearby_chat->getRect().mRight;
- mChannel->init(chat_box->getRect().mLeft, channel_right_bound);
+ //LLRect snap_rect = gFloaterView->getSnapRect();
+ //mChannel->init(snap_rect.mLeft, snap_rect.mLeft + 200);
}
-void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args)
+void LLNearbyChatHandler::processChat(const LLChat& chat_msg,
+ const LLSD &args)
{
if(chat_msg.mMuted == TRUE)
return;
@@ -475,13 +485,29 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args)
if(chat_msg.mText.empty())
return;//don't process empty messages
- LLChat& tmp_chat = const_cast<LLChat&>(chat_msg);
-
- LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
+ LLFloater* chat_bar = LLFloaterReg::getInstance("chat_bar");
+
+ LLNearbyChat* nearby_chat = chat_bar->findChild<LLNearbyChat>("nearby_chat");
+
+ // Build notification data
+ LLSD notification;
+ notification["message"] = chat_msg.mText;
+ notification["from"] = chat_msg.mFromName;
+ notification["from_id"] = chat_msg.mFromID;
+ notification["time"] = chat_msg.mTime;
+ notification["source"] = (S32)chat_msg.mSourceType;
+ notification["chat_type"] = (S32)chat_msg.mChatType;
+ notification["chat_style"] = (S32)chat_msg.mChatStyle;
+ // Pass sender info so that it can be rendered properly (STORM-1021).
+ notification["sender_slurl"] = LLViewerChat::getSenderSLURL(chat_msg, args);
+
+ if (chat_msg.mChatType == CHAT_TYPE_DIRECT &&
+ chat_msg.mText.length() > 0 &&
+ chat_msg.mText[0] == '@')
{
- //sometimes its usefull to have no name at all...
- //if(tmp_chat.mFromName.empty() && tmp_chat.mFromID!= LLUUID::null)
- // tmp_chat.mFromName = tmp_chat.mFromID.asString();
+ // Send event on to LLEventStream and exit
+ sChatWatcher->post(notification);
+ return;
}
// don't show toast and add message to chat history on receive debug message
@@ -514,22 +540,32 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args)
}
nearby_chat->addMessage(chat_msg, true, args);
- if( nearby_chat->getVisible()
- || ( chat_msg.mSourceType == CHAT_SOURCE_AGENT
- && gSavedSettings.getBOOL("UseChatBubbles") ) )
- return;//no need in toast if chat is visible or if bubble chat is enabled
- // Handle irc styled messages for toast panel
- if (tmp_chat.mChatStyle == CHAT_STYLE_IRC)
+ if(chat_msg.mSourceType == CHAT_SOURCE_AGENT
+ && chat_msg.mFromID.notNull()
+ && chat_msg.mFromID != gAgentID)
{
- if(!tmp_chat.mFromName.empty())
- tmp_chat.mText = tmp_chat.mFromName + tmp_chat.mText.substr(3);
- else
- tmp_chat.mText = tmp_chat.mText.substr(3);
+ LLFirstUse::otherAvatarChatFirst();
+
+ // Add sender to the recent people list.
+ LLRecentPeople::instance().add(chat_msg.mFromID);
+
}
+ // Send event on to LLEventStream
+ sChatWatcher->post(notification);
+
+
+ if( !chat_bar->isMinimized()
+ && nearby_chat->isInVisibleChain()
+ || ( chat_msg.mSourceType == CHAT_SOURCE_AGENT
+ && gSavedSettings.getBOOL("UseChatBubbles") )
+ || mChannel.isDead()
+ || !mChannel.get()->getShowToasts() ) // to prevent toasts in Busy mode
+ return;//no need in toast if chat is visible or if bubble chat is enabled
+
// arrange a channel on a screen
- if(!mChannel->getVisible())
+ if(!mChannel.get()->getVisible())
{
initChannel();
}
@@ -546,24 +582,29 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args)
}
*/
- LLUUID id;
- id.generate();
-
- LLNearbyChatScreenChannel* channel = dynamic_cast<LLNearbyChatScreenChannel*>(mChannel);
-
+ LLNearbyChatScreenChannel* channel = dynamic_cast<LLNearbyChatScreenChannel*>(mChannel.get());
if(channel)
{
- LLSD notification;
+ // Handle IRC styled messages.
+ std::string toast_msg;
+ if (chat_msg.mChatStyle == CHAT_STYLE_IRC)
+ {
+ if (!chat_msg.mFromName.empty())
+ {
+ toast_msg += chat_msg.mFromName;
+ }
+ toast_msg += chat_msg.mText.substr(3);
+ }
+ else
+ {
+ toast_msg = chat_msg.mText;
+ }
+
+ // Add a nearby chat toast.
+ LLUUID id;
+ id.generate();
notification["id"] = id;
- notification["message"] = chat_msg.mText;
- notification["from"] = chat_msg.mFromName;
- notification["from_id"] = chat_msg.mFromID;
- notification["time"] = chat_msg.mTime;
- notification["source"] = (S32)chat_msg.mSourceType;
- notification["chat_type"] = (S32)chat_msg.mChatType;
- notification["chat_style"] = (S32)chat_msg.mChatStyle;
-
std::string r_color_name = "White";
F32 r_color_alpha = 1.0f;
LLViewerChat::getChatColor( chat_msg, r_color_name, r_color_alpha);
@@ -571,15 +612,9 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args)
notification["text_color"] = r_color_name;
notification["color_alpha"] = r_color_alpha;
notification["font_size"] = (S32)LLViewerChat::getChatFontSize() ;
+ notification["message"] = toast_msg;
channel->addNotification(notification);
}
-
- if(chat_msg.mSourceType == CHAT_SOURCE_AGENT
- && chat_msg.mFromID.notNull()
- && chat_msg.mFromID != gAgentID)
- {
- LLFirstUse::otherAvatarChatFirst();
- }
}
void LLNearbyChatHandler::onDeleteToast(LLToast* toast)