From 357f6d04edb354f12ae052f35c65cfd87ba4cb2d Mon Sep 17 00:00:00 2001
From: AndreyL ProductEngine <alihatskiy@productengine.com>
Date: Fri, 20 May 2016 01:45:12 +0300
Subject: [PATCH] MAINT-6419 Show the release notes when first starting a new
 viewer

---
 indra/newview/app_settings/settings.xml       | 11 +++++++
 indra/newview/llappviewer.cpp                 | 33 +++++++++++++++++++
 .../xui/en/panel_preferences_setup.xml        | 12 +++++++
 3 files changed, 56 insertions(+)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 4912f27e701..7bcbf819e4f 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -13276,6 +13276,17 @@
       <key>Value</key>
       <string>1</string>
     </map>
+    <key>UpdaterShowReleaseNotes</key>
+    <map>
+        <key>Comment</key>
+        <string>Enables displaying of the Release notes in a web floater after update.</string>
+        <key>Persist</key>
+        <integer>1</integer>
+        <key>Type</key>
+        <string>Boolean</string>
+        <key>Value</key>
+        <string>1</string>
+    </map>
     <key>UploadBakedTexOld</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 6bc1f67e32b..29680093f91 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1220,6 +1220,8 @@ bool LLAppViewer::init()
         boost::bind(&LLControlGroup::getU32, boost::ref(gSavedSettings), _1),
         boost::bind(&LLControlGroup::declareU32, boost::ref(gSavedSettings), _1, _2, _3, LLControlVariable::PERSIST_ALWAYS));
 
+	showReleaseNotesIfRequired();
+
 	return true;
 }
 
@@ -5799,6 +5801,37 @@ void LLAppViewer::launchUpdater()
 	// LLAppViewer::instance()->forceQuit();
 }
 
+/**
+* Check if user is running a new version of the viewer.
+* Display the Release Notes if it's not overriden by the "UpdaterShowReleaseNotes" setting.
+*/
+void LLAppViewer::showReleaseNotesIfRequired()
+{
+	if (!gLastRunVersion.empty() && gSavedSettings.getBOOL("UpdaterShowReleaseNotes"))
+	{
+		try
+		{
+			boost::regex expr("(?<chan>[\\w\\s]+)\\s(?<maj>\\d+)\\.(?<min>\\d+)\\.(?<patch>\\d+)\\.(?<build>\\d+)", boost::regex::perl | boost::regex::icase);
+			boost::smatch matches;
+			if (boost::regex_search(gLastRunVersion, matches, expr))
+			{
+				if (LLVersionInfo::getChannel() == matches["chan"] &&  // don't show Release Notes when changing a channel
+					(LLVersionInfo::getBuild() > std::stoi(matches["build"])
+					|| LLVersionInfo::getPatch() > std::stoi(matches["patch"])
+					|| LLVersionInfo::getMinor() > std::stoi(matches["min"])
+					|| LLVersionInfo::getMajor() > std::stoi(matches["maj"])))
+				{
+					LLSD info(getViewerInfo());
+					LLWeb::loadURLInternal(info["VIEWER_RELEASE_NOTES_URL"]);
+				}
+			}
+		}
+		catch (boost::regex_error& e)
+		{
+			LL_WARNS() << "Can't parse previous run version, regex errpr: " << e.what() << LL_ENDL;
+		}
+	}
+}
 
 //virtual
 void LLAppViewer::setMasterSystemAudioMute(bool mute)
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_setup.xml b/indra/newview/skins/default/xui/en/panel_preferences_setup.xml
index 0b605cf6f7e..c20f9b2c510 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_setup.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_setup.xml
@@ -273,6 +273,18 @@
     name="update_willing_to_test"
     width="400"           
     top_pad="5"/>
+  <check_box
+    top_delta="4"
+    enabled="true"
+    follows="left|top"
+    height="14"
+    control_name="UpdaterShowReleaseNotes"
+    label="Show Release Notes after update"
+    left_delta="0"
+    mouse_opaque="true"
+    name="update_show_release_notes"
+    width="400"
+    top_pad="5"/>
   <text
      type="string"
      length="1"
-- 
GitLab