From 315c381d804ccad4039e193ebd0cdc1b8d2ddec1 Mon Sep 17 00:00:00 2001
From: Rick Pasetto <rick@lindenlab.com>
Date: Fri, 15 Jan 2010 12:01:57 -0800
Subject: [PATCH] FIX EXT-3957: add "Media Enabled" checkbox to Privacy Prefs

review http://codereview.lindenlab.com/271074
---
 indra/newview/llfloaterpreference.cpp         | 35 ++++++++++++++-----
 indra/newview/llfloaterpreference.h           |  1 +
 .../xui/en/panel_preferences_privacy.xml      | 17 +++++++--
 3 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 9af37e81749..a545190546e 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -326,6 +326,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key)
 	mCommitCallbackRegistrar.add("Pref.UpdateSliderText",       boost::bind(&LLFloaterPreference::onUpdateSliderText,this, _1,_2));	
 	mCommitCallbackRegistrar.add("Pref.AutoDetectAspect",       boost::bind(&LLFloaterPreference::onCommitAutoDetectAspect, this));	
 	mCommitCallbackRegistrar.add("Pref.ParcelMediaAutoPlayEnable",       boost::bind(&LLFloaterPreference::onCommitParcelMediaAutoPlayEnable, this));	
+	mCommitCallbackRegistrar.add("Pref.MediaEnabled",           boost::bind(&LLFloaterPreference::onCommitMediaEnabled, this));	
 	mCommitCallbackRegistrar.add("Pref.onSelectAspectRatio",    boost::bind(&LLFloaterPreference::onKeystrokeAspectRatio, this));	
 	mCommitCallbackRegistrar.add("Pref.QualityPerformance",     boost::bind(&LLFloaterPreference::onChangeQuality, this, _2));	
 	mCommitCallbackRegistrar.add("Pref.applyUIColor",			boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2));
@@ -994,16 +995,18 @@ void LLFloaterPreference::onCommitParcelMediaAutoPlayEnable()
 	gSavedSettings.setBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING, autoplay);
 
 	lldebugs << "autoplay now = " << int(autoplay) << llendl;
+}
 
-	if (autoplay)
-	{
-		// autoplay toggle has gone from FALSE to TRUE; ensure that
-		// the media system is thus actually turned on too.
-		gSavedSettings.setBOOL("AudioStreamingVideo", TRUE);
-		gSavedSettings.setBOOL("AudioStreamingMusic", TRUE);
-		gSavedSettings.setBOOL("AudioStreamingMedia", TRUE);
-		llinfos << "autoplay turned on, turned all media subsystems on" << llendl;
-	}
+void LLFloaterPreference::onCommitMediaEnabled()
+{
+	LLCheckBoxCtrl *media_enabled_ctrl = getChild<LLCheckBoxCtrl>("media_enabled");
+	bool enabled = media_enabled_ctrl->get();
+	gSavedSettings.setBOOL("AudioStreamingVideo", enabled);
+	gSavedSettings.setBOOL("AudioStreamingMusic", enabled);
+	gSavedSettings.setBOOL("AudioStreamingMedia", enabled);
+	media_enabled_ctrl->setTentative(false);
+	// Update enabled state of the "autoplay" checkbox
+	getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(enabled);
 }
 
 void LLFloaterPreference::refresh()
@@ -1419,6 +1422,20 @@ BOOL LLPanelPreference::postBuild()
 		refresh();
 	}
 	
+	//////////////////////PanelPrivacy ///////////////////
+	if(hasChild("media_enabled"))
+	{
+		bool video_enabled = gSavedSettings.getBOOL("AudioStreamingVideo");
+		bool music_enabled = gSavedSettings.getBOOL("AudioStreamingMusic");
+		bool media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia");
+		bool enabled = video_enabled || music_enabled || media_enabled;
+		
+		LLCheckBoxCtrl *media_enabled_ctrl = getChild<LLCheckBoxCtrl>("media_enabled");	
+		media_enabled_ctrl->set(enabled);
+		media_enabled_ctrl->setTentative(!(video_enabled == music_enabled == media_enabled));
+		getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(enabled);
+	}
+	
 	apply();
 	return true;
 }
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index b2bc34231d3..2591b0ff684 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -133,6 +133,7 @@ class LLFloaterPreference : public LLFloater
 
 	void onCommitAutoDetectAspect();
 	void onCommitParcelMediaAutoPlayEnable();
+	void onCommitMediaEnabled();
 	void applyResolution();
 	void applyUIColor(LLUICtrl* ctrl, const LLSD& param);
 	void getUIColor(LLUICtrl* ctrl, const LLSD& param);	
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml
index 1c1e17eb5a4..a8e24366f27 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml
@@ -77,10 +77,23 @@
      name="cookies_enabled"
      top_pad="10"
      width="350" />
-    <check_box
+	<check_box
+     control_name="MediaEnabled"
+     height="16"
+     label="Media Enabled"
+     layout="topleft"
+     left="30"
+     name="media_enabled"
+     top_pad="10"
+     width="350">
+       <check_box.commit_callback
+          function="Pref.MediaEnabled" />
+    </check_box>
+	<check_box
+	 enabled_control="MediaEnabled"
      control_name="ParcelMediaAutoPlayEnable"
      height="16"
-     label="Allow Media Autoplay"
+     label="Allow Media to auto-play"
      layout="topleft"
      left="30"
      name="autoplay_enabled"
-- 
GitLab