From 98cb9251853a594a51bdc8c70a00c6ecc50bb412 Mon Sep 17 00:00:00 2001
From: Natty Linden <natty@lindenlab.com>
Date: Wed, 14 Sep 2016 15:53:58 -0700
Subject: [PATCH] MAINT-6731 Use web profile URLs from the grid configuration

---
 indra/newview/app_settings/settings.xml      | 22 --------------
 indra/newview/llpanelprofile.cpp             | 14 ++-------
 indra/newview/llviewernetwork.cpp            | 30 +++++++++++++++++++-
 indra/newview/llviewernetwork.h              |  8 ++++++
 indra/newview/tests/lllogininstance_test.cpp |  1 +
 5 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 4498798ce92..674923e88d8 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -4515,28 +4515,6 @@
       <key>Value</key>
       <string>http://search.secondlife.com/viewer/[CATEGORY]/?q=[QUERY]&amp;p=[AUTH_TOKEN]&amp;r=[MATURITY]&amp;lang=[LANGUAGE]&amp;g=[GODLIKE]&amp;sid=[SESSION_ID]&amp;rid=[REGION_ID]&amp;pid=[PARCEL_ID]&amp;channel=[CHANNEL]&amp;version=[VERSION]&amp;major=[VERSION_MAJOR]&amp;minor=[VERSION_MINOR]&amp;patch=[VERSION_PATCH]&amp;build=[VERSION_BUILD]</string>
     </map>
-    <key>WebProfileURL</key>
-    <map>
-      <key>Comment</key>
-      <string>URL for Web Profiles</string>
-      <key>Persist</key>
-      <integer>0</integer>
-      <key>Type</key>
-      <string>String</string>
-      <key>Value</key>
-      <string>https://my.secondlife.com/[AGENT_NAME]</string>
-    </map>
-	<key>WebProfileNonProductionURL</key>
-	<map>
-		<key>Comment</key>
-		<string>URL for Web Profiles on Non-Production grids</string>
-		<key>Persist</key>
-		<integer>0</integer>
-		<key>Type</key>
-		<string>String</string>
-		<key>Value</key>
-		<string>https://my-demo.secondlife.com/[AGENT_NAME]</string>
-	</map>
     <key>HighResSnapshot</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp
index 184238c40ca..8afa35efa0b 100644
--- a/indra/newview/llpanelprofile.cpp
+++ b/indra/newview/llpanelprofile.cpp
@@ -44,19 +44,11 @@ static const std::string PANEL_PICKS = "panel_picks";
 
 std::string getProfileURL(const std::string& agent_name)
 {
-	std::string url;
-
-	if (LLGridManager::getInstance()->isInProductionGrid())
-	{
-		url = gSavedSettings.getString("WebProfileURL");
-	}
-	else
-	{
-		url = gSavedSettings.getString("WebProfileNonProductionURL");
-	}
+	std::string url = "[WEB_PROFILE_URL][AGENT_NAME]";
 	LLSD subs;
+	subs["WEB_PROFILE_URL"] = LLGridManager::getInstance()->getWebProfileURL();
 	subs["AGENT_NAME"] = agent_name;
-	url = LLWeb::expandURLSubstitutions(url,subs);
+	url = LLWeb::expandURLSubstitutions(url, subs);
 	LLStringUtil::toLower(url);
 	return url;
 }
diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp
index 6666aecca20..25258862226 100644
--- a/indra/newview/llviewernetwork.cpp
+++ b/indra/newview/llviewernetwork.cpp
@@ -49,6 +49,8 @@ const std::string  GRID_UPDATE_SERVICE_URL = "update_query_url_base";
 const std::string  GRID_HELPER_URI_VALUE = "helper_uri";
 /// the splash page url
 const std::string  GRID_LOGIN_PAGE_VALUE = "login_page";
+/// url for the web profile site
+const std::string  GRID_WEB_PROFILE_VALUE = "web_profile_url";
 /// internal data on system grids
 const std::string  GRID_IS_SYSTEM_GRID_VALUE = "system_grid";
 /// whether this is single or double names
@@ -70,6 +72,8 @@ const std::string SL_UPDATE_QUERY_URL = "https://update.secondlife.com/update";
 const std::string MAIN_GRID_SLURL_BASE = "http://maps.secondlife.com/secondlife/";
 const std::string SYSTEM_GRID_APP_SLURL_BASE = "secondlife:///app";
 
+const std::string MAIN_GRID_WEB_PROFILE_URL = "https://my.secondlife.com/";
+
 const char* SYSTEM_GRID_SLURL_BASE = "secondlife://%s/secondlife/";
 const char* DEFAULT_SLURL_BASE = "https://%s/region/";
 const char* DEFAULT_APP_SLURL_BASE = "x-grid-location-info://%s/app";
@@ -125,6 +129,7 @@ void LLGridManager::initialize(const std::string& grid_file)
 				  "https://secondlife.com/helpers/",
 				  DEFAULT_LOGIN_PAGE,
 				  SL_UPDATE_QUERY_URL,
+				  MAIN_GRID_WEB_PROFILE_URL,
 				  "Agni");
 	addSystemGrid(LLTrans::getString("AditiGridLabel"),
 				  "util.aditi.lindenlab.com",
@@ -132,6 +137,7 @@ void LLGridManager::initialize(const std::string& grid_file)
 				  "http://aditi-secondlife.webdev.lindenlab.com/helpers/",
 				  DEFAULT_LOGIN_PAGE,
 				  SL_UPDATE_QUERY_URL,
+				  "https://my.aditi.lindenlab.com/",
 				  "Aditi");
 
 	LLSD other_grids;
@@ -288,6 +294,10 @@ bool LLGridManager::addGrid(LLSD& grid_data)
 				{
 					grid_data[GRID_HELPER_URI_VALUE] = std::string("https://") + grid + "/helpers/";
 				}
+				if (!grid_data.has(GRID_WEB_PROFILE_VALUE))
+				{
+					grid_data[GRID_WEB_PROFILE_VALUE] = std::string("https://") + grid + "/";
+				}
 
 				if (!grid_data.has(GRID_LOGIN_IDENTIFIER_TYPES))
 				{
@@ -302,7 +312,8 @@ bool LLGridManager::addGrid(LLSD& grid_data)
 										 <<"  id:          "<<grid_data[GRID_ID_VALUE].asString()<<"\n"
 										 <<"  label:       "<<grid_data[GRID_LABEL_VALUE].asString()<<"\n"
 										 <<"  login page:  "<<grid_data[GRID_LOGIN_PAGE_VALUE].asString()<<"\n"
-										 <<"  helper page: "<<grid_data[GRID_HELPER_URI_VALUE].asString()<<"\n";
+										 <<"  helper page: "<<grid_data[GRID_HELPER_URI_VALUE].asString()<<"\n"
+										 <<"  web profile: "<<grid_data[GRID_WEB_PROFILE_VALUE].asString()<<"\n";
 				/* still in LL_DEBUGS */ 
 				for (LLSD::array_const_iterator login_uris = grid_data[GRID_LOGIN_URI_VALUE].beginArray();
 					 login_uris != grid_data[GRID_LOGIN_URI_VALUE].endArray();
@@ -339,6 +350,7 @@ void LLGridManager::addSystemGrid(const std::string& label,
 								  const std::string& helper,
 								  const std::string& login_page,
 								  const std::string& update_url_base,
+								  const std::string& web_profile_url,
 								  const std::string& login_id)
 {
 	LLSD grid = LLSD::emptyMap();
@@ -349,6 +361,7 @@ void LLGridManager::addSystemGrid(const std::string& label,
 	grid[GRID_LOGIN_URI_VALUE].append(login_uri);
 	grid[GRID_LOGIN_PAGE_VALUE] = login_page;
 	grid[GRID_UPDATE_SERVICE_URL] = update_url_base;
+	grid[GRID_WEB_PROFILE_VALUE] = web_profile_url;
 	grid[GRID_IS_SYSTEM_GRID_VALUE] = true;
 	grid[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray();
 	grid[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT);
@@ -535,6 +548,21 @@ std::string LLGridManager::getLoginPage()
 	return login_page;
 }
 
+std::string LLGridManager::getWebProfileURL(const std::string& grid)
+{
+	std::string web_profile_url;
+	std::string grid_name = getGrid(grid);
+	if (!grid_name.empty())
+	{
+		web_profile_url = mGridList[grid_name][GRID_WEB_PROFILE_VALUE].asString();
+	}
+	else
+	{
+		LL_WARNS("GridManager")<<"invalid grid '"<<grid<<"'"<<LL_ENDL;
+	}
+	return web_profile_url;
+}
+
 void LLGridManager::getLoginIdentifierTypes(LLSD& idTypes)
 {
 	idTypes = mGridList[mGrid][GRID_LOGIN_IDENTIFIER_TYPES];
diff --git a/indra/newview/llviewernetwork.h b/indra/newview/llviewernetwork.h
index 8526c0ba7f3..228303d8e2d 100644
--- a/indra/newview/llviewernetwork.h
+++ b/indra/newview/llviewernetwork.h
@@ -166,6 +166,13 @@ class LLGridManager : public LLSingleton<LLGridManager>
 	/// Return the application URL prefix for the selected grid
 	std::string getAppSLURLBase() { return getAppSLURLBase(mGrid); }	
 
+	/// Return the url of the resident profile web site for the given grid
+	std::string getWebProfileURL(const std::string& grid);
+
+	/// Return the url of the resident profile web site for the selected grid
+	std::string getWebProfileURL() { return getWebProfileURL(mGrid); }
+
+
 	//@}
 
 	/* ================================================================
@@ -216,6 +223,7 @@ class LLGridManager : public LLSingleton<LLGridManager>
 					   const std::string& helper,
 					   const std::string& login_page,
 					   const std::string& update_url_base,
+					   const std::string& web_profile_url,
 					   const std::string& login_id = "");	
 	
 	
diff --git a/indra/newview/tests/lllogininstance_test.cpp b/indra/newview/tests/lllogininstance_test.cpp
index 1b0334498e2..b603157ca75 100644
--- a/indra/newview/tests/lllogininstance_test.cpp
+++ b/indra/newview/tests/lllogininstance_test.cpp
@@ -136,6 +136,7 @@ void LLGridManager::addSystemGrid(const std::string& label,
 								  const std::string& helper,
 								  const std::string& login_page,
 								  const std::string& update_url_base,
+								  const std::string& web_profile_url,
 								  const std::string& login_id)
 {
 }
-- 
GitLab