From d7605649af23678308544bafbe2fb23f2641e52f Mon Sep 17 00:00:00 2001
From: Cinder <cinder@sdf.org>
Date: Fri, 15 Jan 2016 12:58:49 -0700
Subject: [PATCH] ALCH-353 - Keep list of used audio streams for quick access

---
 .../newview/app_settings/settings_alchemy.xml | 11 +++++
 indra/newview/llpanellandmedia.cpp            | 43 +++++++++++++++++--
 indra/newview/llpanellandmedia.h              |  3 +-
 .../default/xui/en/floater_about_land.xml     | 15 +++++--
 4 files changed, 63 insertions(+), 9 deletions(-)

diff --git a/indra/newview/app_settings/settings_alchemy.xml b/indra/newview/app_settings/settings_alchemy.xml
index 24112a1dd8..4cffc64922 100644
--- a/indra/newview/app_settings/settings_alchemy.xml
+++ b/indra/newview/app_settings/settings_alchemy.xml
@@ -1142,6 +1142,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>StreamList</key>
+    <map>
+      <key>Comment</key>
+      <string>Saved list of parcel audio streams</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>LLSD</string>
+      <key>Value</key>
+      <string />
+    </map>
     <key>UIImgTransparentUUID</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llpanellandmedia.cpp b/indra/newview/llpanellandmedia.cpp
index 8a30a6cc08..233cb3b09e 100755
--- a/indra/newview/llpanellandmedia.cpp
+++ b/indra/newview/llpanellandmedia.cpp
@@ -35,6 +35,7 @@
 #include "llviewerregion.h"
 #include "llviewermedia.h"
 #include "llviewerparcelmedia.h"
+#include "llviewercontrol.h" // gSavedSettings
 
 // library includes
 #include "llcheckboxctrl.h"
@@ -132,8 +133,8 @@ BOOL LLPanelLandMedia::postBuild()
 	mCheckParcelVoiceLocal = getChild<LLCheckBoxCtrl>("parcel_enable_voice_channel_local");
 	mCheckParcelVoiceLocal->setCommitCallback(boost::bind(&LLPanelLandMedia::onCommitAny, this));
 	
-	mMusicURLEdit = getChild<LLLineEditor>("music_url");
-	mMusicURLEdit->setCommitCallback(boost::bind(&LLPanelLandMedia::onCommitAny, this));
+	mMusicURLEdit = getChild<LLComboBox>("music_url");
+	mMusicURLEdit->setCommitCallback(boost::bind(&LLPanelLandMedia::onCommitMusicUrl, this));
 	
 	mCheckAVSoundAny = getChild<LLCheckBoxCtrl>("all av sound check");
 	mCheckAVSoundAny->setCommitCallback(boost::bind(&LLPanelLandMedia::onCommitAny, this));
@@ -244,7 +245,17 @@ void LLPanelLandMedia::refresh()
 		mCheckParcelEnableVoice->set(allow_voice);
 		mCheckParcelVoiceLocal->set(!parcel->getParcelFlagUseEstateVoiceChannel());
 		
-		mMusicURLEdit->setText(parcel->getMusicURL());
+		const std::string& current_url = parcel->getMusicURL();
+		mMusicURLEdit->clearRows();
+		LLSD stream_list = gSavedSettings.getLLSD("StreamList");
+		const LLSD streams = stream_list["audio"];
+		for(LLSD::array_const_iterator s_itr = streams.beginArray(); s_itr != streams.endArray(); ++s_itr)
+		{
+			mMusicURLEdit->add(LLSD(*s_itr));
+		}
+		mMusicURLEdit->addSeparator(ADD_TOP);
+		mMusicURLEdit->add(LLSD(current_url), ADD_TOP);
+		mMusicURLEdit->selectByValue(current_url);
 		mMusicURLEdit->setEnabled( can_change_media );
 		
 		BOOL can_change_av_sounds = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_OPTIONS) && parcel->getHaveNewParcelLimitData();
@@ -312,6 +323,7 @@ void LLPanelLandMedia::setMediaURL(const std::string& media_url)
 	// LLViewerParcelMedia::sendMediaNavigateMessage(media_url);
 	getChild<LLUICtrl>("current_url")->setValue(media_url);
 }
+
 std::string LLPanelLandMedia::getMediaURL()
 {
 	return mMediaURLEdit->getText();	
@@ -350,7 +362,7 @@ void LLPanelLandMedia::onCommitAny()
 	LLUUID media_id			= mMediaTextureCtrl->getImageAssetID();
 	
 	BOOL sound_local		= mCheckSoundLocal->get();
-	std::string music_url	= mMusicURLEdit->getText();
+	std::string music_url	= mMusicURLEdit->getSimple();
 	
 	BOOL voice_enabled = mCheckParcelEnableVoice->get();
 	BOOL voice_estate_chan = !mCheckParcelVoiceLocal->get();
@@ -391,6 +403,29 @@ void LLPanelLandMedia::onCommitAny()
 	// Might have changed properties, so let's redraw!
 	refresh();
 }
+
+void LLPanelLandMedia::onCommitMusicUrl()
+{
+	std::string music_url = mMusicURLEdit->getSimple();
+	LLStringUtil::trim(music_url);
+	if (!music_url.empty())
+	{
+		LLSD stream_list = gSavedSettings.getLLSD("StreamList");
+		const LLSD streams = stream_list["audio"];
+		bool found = false;
+		for(LLSD::array_const_iterator s_itr = streams.beginArray(); s_itr != streams.endArray(); ++s_itr)
+		{
+			if (LLStringUtil::compareInsensitive((LLSD(*s_itr)).asString(), music_url) == 0)
+				found = true;
+		}
+		if (!found)
+			stream_list["audio"].append(music_url);
+		gSavedSettings.setLLSD("StreamList", stream_list);
+	}
+	
+	onCommitAny();
+}
+
 // static
 void LLPanelLandMedia::onSetBtn(void *userdata)
 {
diff --git a/indra/newview/llpanellandmedia.h b/indra/newview/llpanellandmedia.h
index 5da2efbcaa..5a6ed55e1a 100755
--- a/indra/newview/llpanellandmedia.h
+++ b/indra/newview/llpanellandmedia.h
@@ -49,6 +49,7 @@ public:
 private:
 	void populateMIMECombo();
 	void onCommitAny();
+	void onCommitMusicUrl();
 	static void onCommitType(LLUICtrl* ctrl, void *userdata);
 	static void onSetBtn(void* userdata);
 	static void onResetBtn(void* userdata);
@@ -70,7 +71,7 @@ private:
 	LLCheckBoxCtrl* mCheckParcelEnableVoice;
 	LLCheckBoxCtrl* mCheckEstateDisabledVoice;
 	LLCheckBoxCtrl* mCheckParcelVoiceLocal;
-	LLLineEditor*	mMusicURLEdit;
+	LLComboBox*		mMusicURLEdit;
 	LLCheckBoxCtrl* mCheckAVSoundAny;
 	LLCheckBoxCtrl* mCheckAVSoundGroup;
 
diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml
index 2725c68a5d..3bef1082aa 100755
--- a/indra/newview/skins/default/xui/en/floater_about_land.xml
+++ b/indra/newview/skins/default/xui/en/floater_about_land.xml
@@ -1780,16 +1780,23 @@ Only large parcels can be listed in search.
              width="364">
                 Music URL:
             </text>
-            <line_editor
+            <combo_box
+             allow_text_entry="true"
+             allow_new_values="true"
              follows="left|top"
              height="23"
              layout="topleft"
-             left="100"
-             max_length_bytes="255"
+             left="110"
+             max_chars="255"
              name="music_url"
              top_delta="0"
              right="-15"
-             select_on_focus="true" />
+             select_on_focus="true">
+              <combo_box.combo_button
+               visible ="false"/>
+              <combo_box.drop_down_button
+               visible ="false"/>
+            </combo_box>
             <text
              type="string"
              length="1"
-- 
GitLab