summaryrefslogtreecommitdiff
path: root/indra/newview/llnotificationtiphandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llnotificationtiphandler.cpp')
-rw-r--r--indra/newview/llnotificationtiphandler.cpp106
1 files changed, 96 insertions, 10 deletions
diff --git a/indra/newview/llnotificationtiphandler.cpp b/indra/newview/llnotificationtiphandler.cpp
index 7239f49b7f..1f1afe293a 100644
--- a/indra/newview/llnotificationtiphandler.cpp
+++ b/indra/newview/llnotificationtiphandler.cpp
@@ -36,12 +36,45 @@
#include "llfloaterreg.h"
#include "llnearbychat.h"
#include "llnotificationhandler.h"
+#include "llnotifications.h"
#include "lltoastnotifypanel.h"
#include "llviewercontrol.h"
#include "llviewerwindow.h"
+#include "llnotificationmanager.h"
using namespace LLNotificationsUI;
+class LLOnlineStatusToast : public LLToastPanel
+{
+public:
+
+ struct Params
+ {
+ LLNotificationPtr notification;
+ LLUUID avatar_id;
+ std::string message;
+
+ Params() {}
+ };
+
+ LLOnlineStatusToast(Params& p) : LLToastPanel(p.notification)
+ {
+ LLUICtrlFactory::getInstance()->buildPanel(this, "panel_online_status_toast.xml");
+
+ childSetValue("avatar_icon", p.avatar_id);
+ childSetValue("message", p.message);
+
+ if (p.notification->getPayload().has("respond_on_mousedown")
+ && p.notification->getPayload()["respond_on_mousedown"] )
+ {
+ setMouseDownCallback(boost::bind(&LLNotification::respond, p.notification,
+ p.notification->getResponseTemplate()));
+ }
+
+ // set line max count to 2 in case of a very long name
+ snapToMessageHeight(getChild<LLTextBox>("message"), 2);
+ }
+};
//--------------------------------------------------------------------------
LLTipHandler::LLTipHandler(e_notification_type type, const LLSD& id)
@@ -50,6 +83,10 @@ LLTipHandler::LLTipHandler(e_notification_type type, const LLSD& id)
// Getting a Channel for our notifications
mChannel = LLChannelManager::getInstance()->createNotificationChannel();
+
+ LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel);
+ if(channel)
+ channel->setOnRejectToastCallback(boost::bind(&LLTipHandler::onRejectToast, this, _1));
}
//--------------------------------------------------------------------------
@@ -60,7 +97,7 @@ LLTipHandler::~LLTipHandler()
//--------------------------------------------------------------------------
void LLTipHandler::initChannel()
{
- S32 channel_right_bound = gViewerWindow->getWorldViewRect().mRight - gSavedSettings.getS32("NotificationChannelRightMargin");
+ S32 channel_right_bound = gViewerWindow->getWorldViewRectScaled().mRight - gSavedSettings.getS32("NotificationChannelRightMargin");
S32 channel_width = gSavedSettings.getS32("NotifyBoxWidth");
mChannel->init(channel_right_bound - channel_width, channel_right_bound);
}
@@ -86,7 +123,52 @@ bool LLTipHandler::processNotification(const LLSD& notify)
if(notify["sigtype"].asString() == "add" || notify["sigtype"].asString() == "change")
{
- LLToastNotifyPanel* notify_box = new LLToastNotifyPanel(notification);
+ // archive message in nearby chat
+ if (LLHandlerUtil::canLogToNearbyChat(notification))
+ {
+ LLHandlerUtil::logToNearbyChat(notification, CHAT_SOURCE_SYSTEM);
+
+ // don't show toast if Nearby Chat is opened
+ LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<
+ LLNearbyChat>("nearby_chat", LLSD());
+ if (nearby_chat->getVisible())
+ {
+ return true;
+ }
+ }
+
+ const std::string name = notification->getSubstitutions()["NAME"];
+ LLUUID from_id = notification->getPayload()["from_id"];
+ if (LLHandlerUtil::canLogToIM(notification))
+ {
+ LLHandlerUtil::logToIM(IM_NOTHING_SPECIAL, name, name,
+ notification->getMessage(), from_id, from_id);
+ }
+
+ if (LLHandlerUtil::canSpawnIMSession(notification))
+ {
+ LLHandlerUtil::spawnIMSession(name, from_id);
+ }
+
+ // don't spawn toast for inventory accepted/declined offers if respective IM window is open (EXT-5909)
+ if (!LLHandlerUtil::canSpawnToast(notification))
+ {
+ return true;
+ }
+
+ LLToastPanel* notify_box = NULL;
+ if("FriendOffline" == notification->getName() || "FriendOnline" == notification->getName())
+ {
+ LLOnlineStatusToast::Params p;
+ p.notification = notification;
+ p.message = notification->getMessage();
+ p.avatar_id = notification->getPayload()["FROM_ID"];
+ notify_box = new LLOnlineStatusToast(p);
+ }
+ else
+ {
+ notify_box = new LLToastNotifyPanel(notification);
+ }
LLToast::Params p;
p.notif_id = notification->getID();
@@ -96,17 +178,11 @@ bool LLTipHandler::processNotification(const LLSD& notify)
p.is_tip = true;
p.can_be_stored = false;
+ removeExclusiveNotifications(notification);
+
LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel);
if(channel)
channel->addToast(p);
-
- // archive message in nearby chat
- LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
- if(nearby_chat)
- {
- LLChat chat_msg(notification->getMessage());
- nearby_chat->addMessage(chat_msg);
- }
}
else if (notify["sigtype"].asString() == "delete")
{
@@ -122,4 +198,14 @@ void LLTipHandler::onDeleteToast(LLToast* toast)
//--------------------------------------------------------------------------
+void LLTipHandler::onRejectToast(const LLUUID& id)
+{
+ LLNotificationPtr notification = LLNotifications::instance().find(id);
+ if (notification
+ && LLNotificationManager::getInstance()->getHandlerForNotification(
+ notification->getType()) == this)
+ {
+ LLNotifications::instance().cancel(notification);
+ }
+}