From e2655d4c4b38ad2336ad136a057d315e31195080 Mon Sep 17 00:00:00 2001
From: Palmer Truelson <palmer@lindenlab.com>
Date: Fri, 26 Jun 2009 12:17:35 +0000
Subject: [PATCH] DEV-34569

new --nonotifications command line option for automated testing

Reviewed by Q
---
 indra/llui/llnotifications.cpp          | 19 +++++++++++++++++--
 indra/llui/llnotifications.h            |  5 +++++
 indra/newview/app_settings/cmd_line.xml |  8 ++++++++
 indra/newview/app_settings/settings.xml | 11 +++++++++++
 indra/newview/llappviewer.cpp           | 10 ++++++++++
 indra/newview/llviewerwindow.cpp        |  2 ++
 6 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index 452f18b40ba..50fee410294 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -160,6 +160,12 @@ class LLNotificationHistoryChannel : public LLNotificationChannel
 
 bool filterIgnoredNotifications(LLNotificationPtr notification)
 {
+	// filter everything if we are to ignore ALL
+	if(LLNotifications::instance().getIgnoreAllNotifications())
+	{
+		return false;
+	}
+
 	LLNotificationFormPtr form = notification->getForm();
 	// Check to see if the user wants to ignore this alert
 	if (form->getIgnoreType() != LLNotificationForm::IGNORE_NO)
@@ -231,7 +237,7 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLXMLNodeP
 		LLSD item_entry;
 		std::string element_name = child->getName()->mString;
 
-		if (element_name == "ignore")
+		if (element_name == "ignore" )
 		{
 			bool save_option = false;
 			child->getAttribute_bool("save_option", save_option);
@@ -925,7 +931,8 @@ std::string LLNotificationChannel::summarize()
 // LLNotifications implementation
 // ---
 LLNotifications::LLNotifications() : LLNotificationChannelBase(LLNotificationFilters::includeEverything,
-															   LLNotificationComparators::orderByUUID())
+															   LLNotificationComparators::orderByUUID()),
+									mIgnoreAllNotifications(false)
 {
 	LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Notification.Show", boost::bind(&LLNotifications::addFromCallback, this, _2));
 }
@@ -1473,6 +1480,14 @@ std::string LLNotifications::getGlobalString(const std::string& key) const
 	}
 }
 
+void LLNotifications::setIgnoreAllNotifications(bool setting)
+{
+	mIgnoreAllNotifications = setting; 
+}
+bool LLNotifications::getIgnoreAllNotifications()
+{
+	return mIgnoreAllNotifications; 
+}
 													
 // ---
 // END OF LLNotifications implementation
diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h
index b749724b4e9..512886790ca 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -870,6 +870,9 @@ class LLNotifications :
 	
 	std::string getGlobalString(const std::string& key) const;
 
+	void setIgnoreAllNotifications(bool ignore);
+	bool getIgnoreAllNotifications();
+
 private:
 	// we're a singleton, so we don't have a public constructor
 	LLNotifications();
@@ -898,6 +901,8 @@ class LLNotifications :
 	
 	typedef std::map<std::string, std::string> GlobalStringMap;
 	GlobalStringMap mGlobalStrings;
+
+	bool mIgnoreAllNotifications;
 };
 
 
diff --git a/indra/newview/app_settings/cmd_line.xml b/indra/newview/app_settings/cmd_line.xml
index 783a886fdd3..5f143431deb 100644
--- a/indra/newview/app_settings/cmd_line.xml
+++ b/indra/newview/app_settings/cmd_line.xml
@@ -146,6 +146,14 @@
       <string>ReplaySession</string>
     </map>
 
+    <key>nonotifications</key>
+    <map>
+      <key>desc</key>
+      <string>User will not get any notifications. NOTE: All notifications that occur will get added to ignore file for future runs.</string>
+      <key>map-to</key>
+      <string>IgnoreAllNotifications</string>      
+    </map>    
+
     <key>rotate</key>
     <map>
       <key>map-to</key>
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 5ad49774a9e..afa7f707f17 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -3560,6 +3560,17 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
+    <key>IgnoreAllNotifications</key>
+    <map>
+      <key>Comment</key>
+      <string>Ignore all notifications so we never need user input on them.</string>
+      <key>Persist</key>
+      <integer>0</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>0</integer>
+    </map>  
     <key>IgnorePixelDepth</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index d0d6a118b39..2c570de697a 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -641,6 +641,11 @@ bool LLAppViewer::init()
 	// Get the single value from the crash settings file, if it exists
 	std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
 	gCrashSettings.loadFromFile(crash_settings_filename);
+	if(gSavedSettings.getBOOL("IgnoreAllNotifications"))
+	{
+		gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, CRASH_BEHAVIOR_ALWAYS_SEND);
+		gCrashSettings.saveToFile(crash_settings_filename, FALSE);
+	}
 
 	/////////////////////////////////////////////////
 	// OS-specific login dialogs
@@ -1971,6 +1976,11 @@ bool LLAppViewer::initConfiguration()
 	{
 		LLAgentPilot::sReplaySession = TRUE;
 	}
+
+	if (clp.hasOption("nonotifications"))
+	{
+		gSavedSettings.setBOOL("IgnoreAllNotifications", TRUE);
+	}
 	
 	if (clp.hasOption("debugsession"))
 	{
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index fb501b023f6..5c9f8af2169 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1269,6 +1269,8 @@ LLViewerWindow::LLViewerWindow(
 
 	LLNotifications::instance().getChannel("VW_alerts")->connectChanged(&LLViewerWindow::onAlert);
 	LLNotifications::instance().getChannel("VW_alertmodal")->connectChanged(&LLViewerWindow::onAlert);
+	LLNotifications::instance().setIgnoreAllNotifications(gSavedSettings.getBOOL("IgnoreAllNotifications"));
+	llinfos << "NOTE: ALL NOTIFICATIONS THAT OCCUR WILL GET ADDED TO IGNORE LIST FOR LATER RUNS." << llendl;
 
 	// Default to application directory.
 	LLViewerWindow::sSnapshotBaseName = "Snapshot";
-- 
GitLab