summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Zaporozhan <dzaporozhan@productengine.com>2010-03-23 10:10:15 +0200
committerDmitry Zaporozhan <dzaporozhan@productengine.com>2010-03-23 10:10:15 +0200
commitc5c72899f3f9e203474d8635aa05e154ee14add9 (patch)
treea9d03d739a54599449165a269a71c4996513063b
parent9ff6b6ecd123d3fcd71e189094cc9cb99eca9724 (diff)
Fixed normal subtask EXT-6441 - Do not show "friendship accepted" toast if respective IM window is open and in focus.
Minor changes to supress toast for FriendshipAccepted notification. --HG-- branch : product-engine
-rw-r--r--indra/newview/llnotificationhandler.h17
-rw-r--r--indra/newview/llnotificationhandlerutil.cpp54
-rw-r--r--indra/newview/llnotificationofferhandler.cpp6
3 files changed, 60 insertions, 17 deletions
diff --git a/indra/newview/llnotificationhandler.h b/indra/newview/llnotificationhandler.h
index 1dc0e414a2..99a1fedcf3 100644
--- a/indra/newview/llnotificationhandler.h
+++ b/indra/newview/llnotificationhandler.h
@@ -42,6 +42,8 @@
#include "llinstantmessage.h"
#include "llnotificationptr.h"
+class LLIMFloater;
+
namespace LLNotificationsUI
{
// ENotificationType enumerates all possible types of notifications that could be met
@@ -304,8 +306,6 @@ public:
/**
* Checks if passed notification can create toast.
- *
- * It returns false only for inventory accepted/declined notifications if respective IM window is open (EXT-5909)
*/
static bool canSpawnToast(const LLNotificationPtr& notification);
@@ -315,6 +315,11 @@ public:
static bool isIMFloaterOpened(const LLNotificationPtr& notification);
/**
+ * Determines whether IM floater is focused.
+ */
+ static bool isIMFloaterFocused(const LLNotificationPtr& notification);
+
+ /**
* Writes notification message to IM session.
*/
static void logToIM(const EInstantMessage& session_type,
@@ -375,6 +380,14 @@ public:
* Decrements counter of IM messages.
*/
static void decIMMesageCounter(const LLNotificationPtr& notification);
+
+private:
+
+ /**
+ * Find IM floater based on "from_id"
+ */
+ static LLIMFloater* findIMFloater(const LLNotificationPtr& notification);
+
};
}
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp
index d3ad61128d..24cffd222b 100644
--- a/indra/newview/llnotificationhandlerutil.cpp
+++ b/indra/newview/llnotificationhandlerutil.cpp
@@ -193,10 +193,36 @@ bool LLHandlerUtil::canSpawnSessionAndLogToIM(const LLNotificationPtr& notificat
// static
bool LLHandlerUtil::canSpawnToast(const LLNotificationPtr& notification)
{
- bool cannot_spawn = isIMFloaterOpened(notification) && (INVENTORY_DECLINED == notification->getName()
- || INVENTORY_ACCEPTED == notification->getName());
-
- return !cannot_spawn;
+ if(INVENTORY_DECLINED == notification->getName()
+ || INVENTORY_ACCEPTED == notification->getName())
+ {
+ // return false for inventory accepted/declined notifications if respective IM window is open (EXT-5909)
+ return ! isIMFloaterOpened(notification);
+ }
+
+ if(FRIENDSHIP_ACCEPTED == notification->getName())
+ {
+ // don't show FRIENDSHIP_ACCEPTED if IM window is opened and focused - EXT-6441
+ return ! isIMFloaterFocused(notification);
+ }
+
+ if(OFFER_FRIENDSHIP == notification->getName()
+ || USER_GIVE_ITEM == notification->getName()
+ || TELEPORT_OFFERED == notification->getName())
+ {
+ // When ANY offer arrives, show toast, unless IM window is already open - EXT-5904
+ return ! isIMFloaterOpened(notification);
+ }
+
+ return true;
+}
+
+// static
+LLIMFloater* LLHandlerUtil::findIMFloater(const LLNotificationPtr& notification)
+{
+ LLUUID from_id = notification->getPayload()["from_id"];
+ LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, from_id);
+ return LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", session_id);
}
// static
@@ -204,12 +230,7 @@ bool LLHandlerUtil::isIMFloaterOpened(const LLNotificationPtr& notification)
{
bool res = false;
- LLUUID from_id = notification->getPayload()["from_id"];
- LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL,
- from_id);
-
- LLIMFloater* im_floater = LLFloaterReg::findTypedInstance<LLIMFloater>(
- "impanel", session_id);
+ LLIMFloater* im_floater = findIMFloater(notification);
if (im_floater != NULL)
{
res = im_floater->getVisible() == TRUE;
@@ -218,6 +239,19 @@ bool LLHandlerUtil::isIMFloaterOpened(const LLNotificationPtr& notification)
return res;
}
+bool LLHandlerUtil::isIMFloaterFocused(const LLNotificationPtr& notification)
+{
+ bool res = false;
+
+ LLIMFloater* im_floater = findIMFloater(notification);
+ if (im_floater != NULL)
+ {
+ res = im_floater->hasFocus() == TRUE;
+ }
+
+ return res;
+}
+
// static
void LLHandlerUtil::logToIM(const EInstantMessage& session_type,
const std::string& session_name, const std::string& from_name,
diff --git a/indra/newview/llnotificationofferhandler.cpp b/indra/newview/llnotificationofferhandler.cpp
index e93aec9d01..c5960a9040 100644
--- a/indra/newview/llnotificationofferhandler.cpp
+++ b/indra/newview/llnotificationofferhandler.cpp
@@ -115,15 +115,11 @@ bool LLOfferHandler::processNotification(const LLSD& notify)
session_id = LLHandlerUtil::spawnIMSession(name, from_id);
}
- bool show_toast = true;
+ bool show_toast = LLHandlerUtil::canSpawnToast(notification);
bool add_notid_to_im = LLHandlerUtil::canAddNotifPanelToIM(notification);
if (add_notid_to_im)
{
LLHandlerUtil::addNotifPanelToIM(notification);
- if (LLHandlerUtil::isIMFloaterOpened(notification))
- {
- show_toast = false;
- }
}
if (notification->getPayload().has("SUPPRESS_TOAST")