summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterabout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterabout.cpp')
-rw-r--r--indra/newview/llfloaterabout.cpp231
1 files changed, 165 insertions, 66 deletions
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index 849826bb6b..22f500ba15 100644
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -70,6 +70,22 @@ extern U32 gPacketsIn;
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
@@ -89,6 +105,11 @@ public:
/// 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);
};
@@ -122,76 +143,17 @@ BOOL LLFloaterAbout::postBuild()
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 (! 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"))
+ if (gAgent.getRegion())
{
- support << "\n" << getString("AboutCompiler", args);
+ // start fetching server release notes URL
+ setSupportText(LLTrans::getString("RetrievingData"));
+ LLServerReleaseNotesURLFetcher::startFetch();
}
- if (info.has("PACKETS_IN"))
+ else // not logged in
{
- support << '\n' << getString("AboutTraffic", args);
+ setSupportText(LLStringUtil::null);
}
- support_widget->appendText(support.str(),
- FALSE,
- LLStyle::Params()
- .color(LLUIColorTable::instance().getColor("TextFgReadOnlyColor")));
support_widget->blockUndo();
// Fix views
@@ -294,7 +256,6 @@ LLSD LLFloaterAbout::getInfo()
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
@@ -389,6 +350,95 @@ void LLFloaterAbout::onClickCopyToClipboard()
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
///----------------------------------------------------------------------------
@@ -398,3 +448,52 @@ void LLFloaterAboutUtil::registerFloater()
&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.
+}