Commits

Vadim Savchuk committed ff333a9

STORM-1611 FIXED Untrusted link to server release notes.

Fetch server release notes URL suitable for external browsers from the ServerReleaseNotes capability.

  • Participants
  • Parent commits 656d988

Comments (0)

Files changed (2)

File indra/newview/llfloaterabout.cpp

 
 static std::string get_viewer_release_notes_url();
 
+///----------------------------------------------------------------------------
+/// Class LLServerReleaseNotesURLFetcher
+///----------------------------------------------------------------------------
+class LLServerReleaseNotesURLFetcher : public LLHTTPClient::Responder
+{
+	LOG_CLASS(LLServerReleaseNotesURLFetcher);
+public:
+
+	static void startFetch();
+	/*virtual*/ void completedHeader(U32 status, const std::string& reason, const LLSD& content);
+	/*virtual*/ void completedRaw(
+		U32 status,
+		const std::string& reason,
+		const LLChannelDescriptors& channels,
+		const LLIOPipe::buffer_ptr_t& buffer);
+};
 
 ///----------------------------------------------------------------------------
 /// Class LLFloaterAbout
 	/// separated so that we can programmatically access the same info.
 	static LLSD getInfo();
 	void onClickCopyToClipboard();
+
+	void updateServerReleaseNotesURL(const std::string& url);
+
+private:
+	void setSupportText(const std::string& server_release_notes_url);
 };
 
 
 	getChild<LLUICtrl>("copy_btn")->setCommitCallback(
 		boost::bind(&LLFloaterAbout::onClickCopyToClipboard, this));
 
-#if LL_WINDOWS
-	getWindow()->incBusyCount();
-	getWindow()->setCursor(UI_CURSOR_ARROW);
-#endif
-	LLSD info(getInfo());
-#if LL_WINDOWS
-	getWindow()->decBusyCount();
-	getWindow()->setCursor(UI_CURSOR_ARROW);
-#endif
-
-	std::ostringstream support;
-
-	// Render the LLSD from getInfo() as a format_map_t
-	LLStringUtil::format_map_t args;
-
-	// allow the "Release Notes" URL label to be localized
-	args["ReleaseNotes"] = LLTrans::getString("ReleaseNotes");
-
-	for (LLSD::map_const_iterator ii(info.beginMap()), iend(info.endMap());
-		 ii != iend; ++ii)
+	if (gAgent.getRegion())
 	{
-		if (! ii->second.isArray())
-		{
-			// Scalar value
-			if (ii->second.isUndefined())
-			{
-				args[ii->first] = getString("none");
-			}
-			else
-			{
-				// don't forget to render value asString()
-				args[ii->first] = ii->second.asString();
-			}
-		}
-		else
-		{
-			// array value: build KEY_0, KEY_1 etc. entries
-			for (LLSD::Integer n(0), size(ii->second.size()); n < size; ++n)
-			{
-				args[STRINGIZE(ii->first << '_' << n)] = ii->second[n].asString();
-			}
-		}
+		// start fetching server release notes URL
+		setSupportText(LLTrans::getString("RetrievingData"));
+		LLServerReleaseNotesURLFetcher::startFetch();
+	}
+	else // not logged in
+	{
+		setSupportText(LLStringUtil::null);
 	}
 
-	// Now build the various pieces
-	support << getString("AboutHeader", args);
-	if (info.has("REGION"))
-	{
-		support << "\n\n" << getString("AboutPosition", args);
-	}
-	support << "\n\n" << getString("AboutSystem", args);
-	support << "\n";
-	if (info.has("GRAPHICS_DRIVER_VERSION"))
-	{
-		support << "\n" << getString("AboutDriver", args);
-	}
-	support << "\n" << getString("AboutLibs", args);
-	if (info.has("COMPILER"))
-	{
-		support << "\n" << getString("AboutCompiler", args);
-	}
-	if (info.has("PACKETS_IN"))
-	{
-		support << '\n' << getString("AboutTraffic", args);
-	}
-
-	support_widget->appendText(support.str(), 
-								FALSE, 
-								LLStyle::Params()
-									.color(LLUIColorTable::instance().getColor("TextFgReadOnlyColor")));
 	support_widget->blockUndo();
 
 	// Fix views
 		info["HOSTNAME"] = gAgent.getRegion()->getHost().getHostName();
 		info["HOSTIP"] = gAgent.getRegion()->getHost().getString();
 		info["SERVER_VERSION"] = gLastVersionChannel;
-		info["SERVER_RELEASE_NOTES_URL"] = LLWeb::escapeURL(region->getCapability("ServerReleaseNotes"));
 	}
 
 	// CPU
 	support_widget->deselect();
 }
 
+void LLFloaterAbout::updateServerReleaseNotesURL(const std::string& url)
+{
+	setSupportText(url);
+}
+
+void LLFloaterAbout::setSupportText(const std::string& server_release_notes_url)
+{
+#if LL_WINDOWS
+	getWindow()->incBusyCount();
+	getWindow()->setCursor(UI_CURSOR_ARROW);
+#endif
+	LLSD info(getInfo());
+#if LL_WINDOWS
+	getWindow()->decBusyCount();
+	getWindow()->setCursor(UI_CURSOR_ARROW);
+#endif
+
+	if (LLStringUtil::startsWith(server_release_notes_url, "http")) // it's an URL
+	{
+		info["SERVER_RELEASE_NOTES_URL"] = "[" + LLWeb::escapeURL(server_release_notes_url) + " " + LLTrans::getString("ReleaseNotes") + "]";
+	}
+	else
+	{
+		info["SERVER_RELEASE_NOTES_URL"] = server_release_notes_url;
+	}
+
+	LLViewerTextEditor *support_widget =
+		getChild<LLViewerTextEditor>("support_editor", true);
+
+	std::ostringstream support;
+
+	// Render the LLSD from getInfo() as a format_map_t
+	LLStringUtil::format_map_t args;
+
+	for (LLSD::map_const_iterator ii(info.beginMap()), iend(info.endMap());
+		 ii != iend; ++ii)
+	{
+		if (! ii->second.isArray())
+		{
+			// Scalar value
+			if (ii->second.isUndefined())
+			{
+				args[ii->first] = getString("none");
+			}
+			else
+			{
+				// don't forget to render value asString()
+				args[ii->first] = ii->second.asString();
+			}
+		}
+		else
+		{
+			// array value: build KEY_0, KEY_1 etc. entries
+			for (LLSD::Integer n(0), size(ii->second.size()); n < size; ++n)
+			{
+				args[STRINGIZE(ii->first << '_' << n)] = ii->second[n].asString();
+			}
+		}
+	}
+
+	// Now build the various pieces
+	support << getString("AboutHeader", args);
+	if (info.has("REGION"))
+	{
+		support << "\n\n" << getString("AboutPosition", args);
+	}
+	support << "\n\n" << getString("AboutSystem", args);
+	support << "\n";
+	if (info.has("GRAPHICS_DRIVER_VERSION"))
+	{
+		support << "\n" << getString("AboutDriver", args);
+	}
+	support << "\n" << getString("AboutLibs", args);
+	if (info.has("COMPILER"))
+	{
+		support << "\n" << getString("AboutCompiler", args);
+	}
+	if (info.has("PACKETS_IN"))
+	{
+		support << '\n' << getString("AboutTraffic", args);
+	}
+
+	support_widget->clear();
+	support_widget->appendText(support.str(),
+								FALSE,
+								LLStyle::Params()
+									.color(LLUIColorTable::instance().getColor("TextFgReadOnlyColor")));
+}
+
 ///----------------------------------------------------------------------------
 /// LLFloaterAboutUtil
 ///----------------------------------------------------------------------------
 		&LLFloaterReg::build<LLFloaterAbout>);
 
 }
+
+///----------------------------------------------------------------------------
+/// Class LLServerReleaseNotesURLFetcher implementation
+///----------------------------------------------------------------------------
+// static
+void LLServerReleaseNotesURLFetcher::startFetch()
+{
+	LLViewerRegion* region = gAgent.getRegion();
+	if (!region) return;
+
+	// We cannot display the URL returned by the ServerReleaseNotes capability
+	// because opening it in an external browser will trigger a warning about untrusted
+	// SSL certificate.
+	// So we query the URL ourselves, expecting to find
+	// an URL suitable for external browsers in the "Location:" HTTP header.
+	std::string cap_url = region->getCapability("ServerReleaseNotes");
+	LLHTTPClient::get(cap_url, new LLServerReleaseNotesURLFetcher);
+}
+
+// virtual
+void LLServerReleaseNotesURLFetcher::completedHeader(U32 status, const std::string& reason, const LLSD& content)
+{
+	lldebugs << "Status: " << status << llendl;
+	lldebugs << "Reason: " << reason << llendl;
+	lldebugs << "Headers: " << content << llendl;
+
+	LLFloaterAbout* floater_about = LLFloaterReg::getTypedInstance<LLFloaterAbout>("sl_about");
+	if (floater_about)
+	{
+		std::string location = content["location"].asString();
+		if (location.empty())
+		{
+			location = floater_about->getString("ErrorFetchingServerReleaseNotesURL");
+		}
+		floater_about->updateServerReleaseNotesURL(location);
+	}
+}
+
+// virtual
+void LLServerReleaseNotesURLFetcher::completedRaw(
+	U32 status,
+	const std::string& reason,
+	const LLChannelDescriptors& channels,
+	const LLIOPipe::buffer_ptr_t& buffer)
+{
+	// Do nothing.
+	// We're overriding just because the base implementation tries to
+	// deserialize LLSD which triggers warnings.
+}

File indra/newview/skins/default/xui/en/floater_about.xml

      name="AboutPosition">
 You are at [POSITION_0,number,1], [POSITION_1,number,1], [POSITION_2,number,1] in [REGION] located at &lt;nolink&gt;[HOSTNAME]&lt;/nolink&gt; ([HOSTIP])
 [SERVER_VERSION]
-[[SERVER_RELEASE_NOTES_URL] [ReleaseNotes]]
+[SERVER_RELEASE_NOTES_URL]
 
 </floater.string>
   <!-- *NOTE: Do not translate text like GPU, Graphics Card, etc -
      name="AboutTraffic">
 Packets Lost: [PACKETS_LOST,number,0]/[PACKETS_IN,number,0] ([PACKETS_PCT,number,1]%)
 </floater.string>
+<floater.string
+     name="ErrorFetchingServerReleaseNotesURL">
+Error fetching server release notes URL.
+</floater.string>
   <tab_container
     follows="all" 
     top="25"