From 45a44225f5be261bf42d69c0c7ac01b1235c836c Mon Sep 17 00:00:00 2001
From: Kelly Washington <kelly@lindenlab.com>
Date: Fri, 3 May 2013 00:58:55 +0000
Subject: [PATCH] MAINT-2646 Viewer should neither grant nor display prompts
 for unimplemented LSL permissions * Change text of dialog * Add callback for
 mute button reviewed with Richard and Widely.

---
 indra/newview/llviewermessage.cpp             | 66 ++++++++++++-------
 .../skins/default/xui/en/notifications.xml    |  9 +--
 .../newview/skins/default/xui/en/strings.xml  |  1 +
 3 files changed, 50 insertions(+), 26 deletions(-)

diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 4efe345141e..8cd06122260 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -6290,6 +6290,19 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp
 	}
 }
 
+void script_question_mute(const LLUUID& item_id, const std::string& object_name);
+
+bool unknown_script_question_cb(const LLSD& notification, const LLSD& response)
+{
+	// Only care if they muted the object here.
+	if ( response["Mute"] ) // mute
+	{
+		LLUUID item_id = notification["payload"]["item_id"].asUUID();
+		script_question_mute(item_id,notification["payload"]["object_name"].asString());
+	}
+	return false;
+}
+
 bool script_question_cb(const LLSD& notification, const LLSD& response)
 {
 	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
@@ -6340,34 +6353,42 @@ bool script_question_cb(const LLSD& notification, const LLSD& response)
 
 	if ( response["Mute"] ) // mute
 	{
-		LLMuteList::getInstance()->add(LLMute(item_id, notification["payload"]["object_name"].asString(), LLMute::OBJECT));
-
-		// purge the message queue of any previously queued requests from the same source. DEV-4879
-		class OfferMatcher : public LLNotificationsUI::LLScreenChannel::Matcher
-		{
-		public:
-			OfferMatcher(const LLUUID& to_block) : blocked_id(to_block) {}
-			bool matches(const LLNotificationPtr notification) const
-			{
-				if (notification->getName() == "ScriptQuestionCaution"
-					|| notification->getName() == "ScriptQuestion")
-				{
-					return (notification->getPayload()["item_id"].asUUID() == blocked_id);
-				}
-				return false;
-			}
-		private:
-			const LLUUID& blocked_id;
-		};
-
-		LLNotificationsUI::LLChannelManager::getInstance()->killToastsFromChannel(LLUUID(
-				gSavedSettings.getString("NotificationChannelUUID")), OfferMatcher(item_id));
+		script_question_mute(item_id,notification["payload"]["object_name"].asString());
 	}
 
 	return false;
 }
+
+void script_question_mute(const LLUUID& item_id, const std::string& object_name)
+{
+	LLMuteList::getInstance()->add(LLMute(item_id, object_name, LLMute::OBJECT));
+
+    // purge the message queue of any previously queued requests from the same source. DEV-4879
+    class OfferMatcher : public LLNotificationsUI::LLScreenChannel::Matcher
+    {
+    public:
+    	OfferMatcher(const LLUUID& to_block) : blocked_id(to_block) {}
+      	bool matches(const LLNotificationPtr notification) const
+        {
+            if (notification->getName() == "ScriptQuestionCaution"
+                || notification->getName() == "ScriptQuestion"
+				|| notification->getName() == "UnknownScriptQuestion")
+            {
+                return (notification->getPayload()["item_id"].asUUID() == blocked_id);
+            }
+            return false;
+        }
+    private:
+        const LLUUID& blocked_id;
+    };
+
+    LLNotificationsUI::LLChannelManager::getInstance()->killToastsFromChannel(LLUUID(
+            gSavedSettings.getString("NotificationChannelUUID")), OfferMatcher(item_id));
+}
+
 static LLNotificationFunctorRegistration script_question_cb_reg_1("ScriptQuestion", script_question_cb);
 static LLNotificationFunctorRegistration script_question_cb_reg_2("ScriptQuestionCaution", script_question_cb);
+static LLNotificationFunctorRegistration unknown_script_question_cb_reg("UnknownScriptQuestion", unknown_script_question_cb);
 
 void process_script_question(LLMessageSystem *msg, void **user_data)
 {
@@ -6455,6 +6476,7 @@ void process_script_question(LLMessageSystem *msg, void **user_data)
 
 		if (known_questions != questions)
 		{	// This is in addition to the normal dialog.
+			args["DOWNLOADURL"] = LLTrans::getString("ViewerDownloadURL");
 			LLNotificationsUtil::add("UnknownScriptQuestion",args);
 		}
 		
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 1f39ec041ec..1a7ebaccbd9 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -6869,14 +6869,15 @@ Do not allow access if you do not fully understand why it wants access to your a
 	 name="UnknownScriptQuestion"
 	 persist="false"
 	 type="notify">
-		&apos;&lt;nolink&gt;[OBJECTNAME]&lt;/nolink&gt;&apos;, an object owned by &apos;[NAME]&apos;, requested an unknown script runtime permission. 
+The runtime script permission requested by &apos;&lt;nolink&gt;[OBJECTNAME]&lt;/nolink&gt;&apos;, an object owned by &apos;[NAME]&apos;, isn&apos;t recognized by the viewer and can&apos;t be granted.
 
-Please update your viewer to grant this permission.
+To grant this permission please update your viewer to the latest version from [DOWNLOADURL].
 		<tag>confirm</tag>
 		<form name="form">
 			<button
-			 index="0"
-			 name="Ok"
+			 default="true"
+			 index="1"
+			 name="Deny"
 			 text="Ok"/>
 			<button
 			 index="2"
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index e52e941c285..3b57ff5fd67 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -61,6 +61,7 @@
 	<string name="Quit">Quit</string>
 	<string name="create_account_url">http://join.secondlife.com/?sourceid=[sourceid]</string>
 
+	<string name="ViewerDownloadURL">http://secondlife.com/download</string>
 	<string name="LoginFailedViewerNotPermitted">
 The viewer you are using can no longer access Second Life. Please visit the following page to download a new viewer:
 http://secondlife.com/download
-- 
GitLab