From 28a1ee9da8d58955590e3596409d2f49b130e1fc Mon Sep 17 00:00:00 2001
From: Alexei Arabadji <aarabadji@productengine.com>
Date: Fri, 4 Dec 2009 18:33:13 +0200
Subject: [PATCH] =?UTF-8?q?implemented=20EXT-700=20=E2=80=9C"Offer"=20noti?=
 =?UTF-8?q?fications=20should=20be=20accessible=20via=20chiclet=E2=80=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

--HG--
branch : product-engine
---
 indra/newview/llnotificationhandler.h         |  5 +++++
 indra/newview/llnotificationhandlerutil.cpp   | 13 +++++++++++-
 indra/newview/llnotificationofferhandler.cpp  | 21 +++++++++++++++++++
 indra/newview/llviewermessage.cpp             |  8 +++++--
 .../skins/default/xui/en/notifications.xml    |  4 ++--
 5 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/indra/newview/llnotificationhandler.h b/indra/newview/llnotificationhandler.h
index da8928321ab..5c240aa54a3 100644
--- a/indra/newview/llnotificationhandler.h
+++ b/indra/newview/llnotificationhandler.h
@@ -265,6 +265,11 @@ class LLHandlerUtil
 	 */
 	static bool canLogToIM(const LLNotificationPtr& notification);
 
+	/**
+	 * Checks sufficient conditions to spawn IM session.
+	 */
+	static bool canSpawnIMSession(const LLNotificationPtr& notification);
+
 	/**
 	 * Writes notification message to IM session.
 	 */
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp
index 857b7e9796e..0fbc6575e8f 100644
--- a/indra/newview/llnotificationhandlerutil.cpp
+++ b/indra/newview/llnotificationhandlerutil.cpp
@@ -43,7 +43,10 @@ using namespace LLNotificationsUI;
 const static std::string GRANTED_MODIFY_RIGHTS("GrantedModifyRights"),
 		REVOKED_MODIFY_RIGHTS("RevokedModifyRights"), OBJECT_GIVE_ITEM(
 				"ObjectGiveItem"), OBJECT_GIVE_ITEM_UNKNOWN_USER(
-				"ObjectGiveItemUnknownUser"), PAYMENT_RECIVED("PaymentRecived");
+				"ObjectGiveItemUnknownUser"), PAYMENT_RECIVED("PaymentRecived"),
+						ADD_FRIEND_WITH_MESSAGE("AddFriendWithMessage"),
+						USER_GIVE_ITEM("UserGiveItem"), OFFER_FRIENDSHIP("OfferFriendship"),
+						FRIENDSHIP_ACCEPTED("FriendshipAccepted");
 
 // static
 bool LLHandlerUtil::canLogToIM(const LLNotificationPtr& notification)
@@ -53,6 +56,14 @@ bool LLHandlerUtil::canLogToIM(const LLNotificationPtr& notification)
 			|| PAYMENT_RECIVED == notification->getName();
 }
 
+// static
+bool LLHandlerUtil::canSpawnIMSession(const LLNotificationPtr& notification)
+{
+	return ADD_FRIEND_WITH_MESSAGE == notification->getName()
+			|| OFFER_FRIENDSHIP == notification->getName()
+			|| FRIENDSHIP_ACCEPTED == notification->getName();
+}
+
 // 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 4f353bf6a5c..b7f95ae2fa6 100644
--- a/indra/newview/llnotificationofferhandler.cpp
+++ b/indra/newview/llnotificationofferhandler.cpp
@@ -40,6 +40,7 @@
 #include "llnotificationmanager.h"
 #include "llnotifications.h"
 #include "llscriptfloater.h"
+#include "llimview.h"
 
 using namespace LLNotificationsUI;
 
@@ -101,6 +102,26 @@ bool LLOfferHandler::processNotification(const LLSD& notify)
 		}
 		else
 		{
+			if (LLHandlerUtil::canSpawnIMSession(notification))
+			{
+				const std::string name = notification->getSubstitutions().has(
+						"NAME") ? notification->getSubstitutions()["NAME"]
+						: notification->getSubstitutions()["[NAME]"];
+
+				LLUUID from_id = notification->getPayload()["from_id"];
+
+				LLUUID session_id = LLIMMgr::computeSessionID(
+						IM_NOTHING_SPECIAL, from_id);
+
+				LLIMModel::LLIMSession* session =
+						LLIMModel::instance().findIMSession(session_id);
+				if (session == NULL)
+				{
+					LLIMMgr::instance().addSession(name, IM_NOTHING_SPECIAL,
+							from_id);
+				}
+			}
+
 			LLToastNotifyPanel* notify_box = new LLToastNotifyPanel(notification);
 
 			LLToast::Params p;
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 76cc9bf3356..c44cebe8772 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -2074,13 +2074,17 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 	case IM_INVENTORY_ACCEPTED:
 	{
 		args["NAME"] = name;
-		LLNotificationsUtil::add("InventoryAccepted", args);
+		LLSD payload;
+		payload["from_id"] = from_id;
+		LLNotificationsUtil::add("InventoryAccepted", args, payload);
 		break;
 	}
 	case IM_INVENTORY_DECLINED:
 	{
 		args["NAME"] = name;
-		LLNotificationsUtil::add("InventoryDeclined", args);
+		LLSD payload;
+		payload["from_id"] = from_id;
+		LLNotificationsUtil::add("InventoryDeclined", args, payload);
 		break;
 	}
 	// TODO: _DEPRECATED suffix as part of vote removal - DEV-24856
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index f48cc6d4bf3..0d7351395ab 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -4499,14 +4499,14 @@ You don&apos;t have permission to copy this.
   <notification
    icon="notifytip.tga"
    name="InventoryAccepted"
-   type="notifytip">
+   type="offer">
 [NAME] received your inventory offer.
   </notification>
 
   <notification
    icon="notifytip.tga"
    name="InventoryDeclined"
-   type="notifytip">
+   type="offer">
 [NAME] declined your inventory offer.
   </notification>
 
-- 
GitLab