From 33c5a3974c210af259d3572193bcdcd65137d888 Mon Sep 17 00:00:00 2001
From: Mnikolenko ProductEngine <mnikolenko@productengine.com>
Date: Mon, 13 Jul 2015 17:52:42 +0300
Subject: [PATCH] MAINT-5369 FIXED Unable to accept group invite using
 Notification floater

---
 .../newview/llfloaternotificationstabbed.cpp  |  1 +
 indra/newview/llnotificationlistitem.cpp      | 64 ++++++++++++++++++-
 indra/newview/llnotificationlistitem.h        | 10 +++
 .../xui/en/panel_notification_list_item.xml   |  9 ++-
 4 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llfloaternotificationstabbed.cpp b/indra/newview/llfloaternotificationstabbed.cpp
index 70213680f32..57109c6763c 100644
--- a/indra/newview/llfloaternotificationstabbed.cpp
+++ b/indra/newview/llfloaternotificationstabbed.cpp
@@ -385,6 +385,7 @@ void LLFloaterNotificationsTabbed::onStoreToast(LLPanel* info_panel, LLUUID id)
     LLNotificationPtr notify = mChannel->getToastByNotificationID(id)->getNotification();
     LLSD payload = notify->getPayload();
     p.notification_name = notify->getName();
+    p.transaction_id = payload["transaction_id"];
     p.group_id = payload["group_id"];
     p.fee =  payload["fee"];
     p.subject = payload["subject"].asString();
diff --git a/indra/newview/llnotificationlistitem.cpp b/indra/newview/llnotificationlistitem.cpp
index 8e7671897d8..23a2399ed34 100644
--- a/indra/newview/llnotificationlistitem.cpp
+++ b/indra/newview/llnotificationlistitem.cpp
@@ -30,13 +30,14 @@
 #include "llnotificationlistitem.h"
 
 #include "llagent.h"
+#include "llgroupactions.h"
 #include "llinventoryicon.h"
 #include "llwindow.h"
 #include "v4color.h"
 #include "lltrans.h"
 #include "lluicolortable.h"
 #include "message.h"
-
+#include "llnotificationsutil.h"
 LLNotificationListItem::LLNotificationListItem(const Params& p) : LLPanel(p),
     mParams(p),
     mTitleBox(NULL),
@@ -224,9 +225,70 @@ BOOL LLGroupInviteNotificationListItem::postBuild()
 {
     BOOL rv = LLGroupNotificationListItem::postBuild();
     setFee(mParams.fee);
+    mInviteButtonPanel = getChild<LLPanel>("button_panel");
+    mInviteButtonPanel->setVisible(TRUE);
+    mJoinBtn = getChild<LLButton>("join_btn");
+    mDeclineBtn = getChild<LLButton>("decline_btn");
+    mInfoBtn = getChild<LLButton>("info_btn");
+
+    mJoinBtn->setClickedCallback(boost::bind(&LLGroupInviteNotificationListItem::onClickJoinBtn,this));
+    mDeclineBtn->setClickedCallback(boost::bind(&LLGroupInviteNotificationListItem::onClickDeclineBtn,this));
+    mInfoBtn->setClickedCallback(boost::bind(&LLGroupInviteNotificationListItem::onClickInfoBtn,this));
+
+    std::string expanded_height_resize_str = getString("expanded_height_resize_for_attachment");
+    mExpandedHeightResize = (S32)atoi(expanded_height_resize_str.c_str());
+
     return rv;
 }
 
+void LLGroupInviteNotificationListItem::onClickJoinBtn()
+{
+	if (!gAgent.canJoinGroups())
+	{
+		LLNotificationsUtil::add("JoinedTooManyGroups");
+		return;
+	}
+
+	if(mParams.fee > 0)
+	{
+		LLSD args;
+		args["COST"] = llformat("%d", mParams.fee);
+		// Set the fee for next time to 0, so that we don't keep
+		// asking about a fee.
+		LLSD next_payload;
+		next_payload["group_id"]=  mParams.group_id;
+		next_payload["transaction_id"]= mParams.transaction_id;
+		next_payload["fee"] = 0;
+		LLNotificationsUtil::add("JoinGroupCanAfford", args, next_payload);
+	}
+	else
+	{
+		send_improved_im(mParams.group_id,
+						std::string("name"),
+						std::string("message"),
+						IM_ONLINE,
+						IM_GROUP_INVITATION_ACCEPT,
+						mParams.transaction_id);
+	}
+	LLNotificationListItem::onClickCloseBtn();
+}
+
+void LLGroupInviteNotificationListItem::onClickDeclineBtn()
+{
+	send_improved_im(mParams.group_id,
+					std::string("name"),
+					std::string("message"),
+					IM_ONLINE,
+					IM_GROUP_INVITATION_DECLINE,
+					mParams.transaction_id);
+	LLNotificationListItem::onClickCloseBtn();
+}
+
+void LLGroupInviteNotificationListItem::onClickInfoBtn()
+{
+	LLGroupActions::show(mParams.group_id);
+}
+
 void LLGroupInviteNotificationListItem::setFee(S32 fee)
 {
     LLStringUtil::format_map_t string_args;
diff --git a/indra/newview/llnotificationlistitem.h b/indra/newview/llnotificationlistitem.h
index f8d9fc03306..6801e773422 100644
--- a/indra/newview/llnotificationlistitem.h
+++ b/indra/newview/llnotificationlistitem.h
@@ -46,6 +46,7 @@ class LLNotificationListItem : public LLPanel
     struct Params : public LLInitParam::Block<Params, LLPanel::Params>
     {
         LLUUID          notification_id;
+        LLUUID			transaction_id;
         LLUUID          group_id;
         LLUUID          paid_from_id;
         LLUUID          paid_to_id;
@@ -160,6 +161,15 @@ class LLGroupInviteNotificationListItem
     LLGroupInviteNotificationListItem & operator=(LLGroupInviteNotificationListItem &);
 
     void setFee(S32 fee);
+
+    void onClickJoinBtn();
+    void onClickDeclineBtn();
+    void onClickInfoBtn();
+
+    LLPanel*        mInviteButtonPanel;
+    LLButton*		mJoinBtn;
+    LLButton*		mDeclineBtn;
+    LLButton*		mInfoBtn;
 };
 
 class LLGroupNoticeNotificationListItem
diff --git a/indra/newview/skins/default/xui/en/panel_notification_list_item.xml b/indra/newview/skins/default/xui/en/panel_notification_list_item.xml
index 3dbe11387a6..6af0115a07e 100644
--- a/indra/newview/skins/default/xui/en/panel_notification_list_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_notification_list_item.xml
@@ -123,10 +123,15 @@
                         Attachment goes here b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a b l a bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla. bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla .
                       </text>
                     </panel>
+                   <panel border="false" left="0" bottom="-4" height="30" bevel_style="none" follows="left|right|bottom" layout="topleft" name="button_panel" visible="false">
+                      <button top="2" left="0" width="65" height="23" layout="topleft" follows="left|top|bottom" name="join_btn" mouse_opaque="true" tab_stop="false" label = "Join"/>                 
+                      <button top="2" left_pad="12" width="65" height="23" layout="topleft" follows="left|top|bottom" name="decline_btn" mouse_opaque="true" tab_stop="false" label = "Decline"/>                  
+                      <button top="2" left_pad="12" width="65" height="23" layout="topleft" follows="left|top|bottom" name="info_btn" mouse_opaque="true" tab_stop="false" label = "Info"/>                  
+                   </panel>
                   </layout_panel>
                 </layout_stack>
-              </panel>
-            </layout_panel>
+              </panel>              
+            </layout_panel>             
             <layout_panel width="18" orientation="horizontal" follows="right|top|bottom" name="layout_panel_left_exp">
               <panel top="0" left="0" width="17" follows="left|top|right|bottom" layout="topleft" name="close_expand_panel_exp">
                 <button top="0" left="2" width="17" height="17" layout="topleft" follows="top" name="close_expanded_btn" mouse_opaque="true"
-- 
GitLab