summaryrefslogtreecommitdiff
path: root/indra/newview/llweb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llweb.cpp')
-rw-r--r--indra/newview/llweb.cpp84
1 files changed, 78 insertions, 6 deletions
diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp
index 3204c2d264..1a64f9d881 100644
--- a/indra/newview/llweb.cpp
+++ b/indra/newview/llweb.cpp
@@ -38,13 +38,24 @@
// Library includes
#include "llwindow.h" // spawnWebBrowser()
-#include "llviewerwindow.h"
-#include "llviewercontrol.h"
+#include "llagent.h"
+#include "llappviewer.h"
#include "llfloatermediabrowser.h"
#include "llfloaterreg.h"
-#include "llalertdialog.h"
+#include "lllogininstance.h"
+#include "llparcel.h"
+#include "llsd.h"
+#include "lltoastalertpanel.h"
+#include "llui.h"
+#include "lluri.h"
+#include "llversioninfo.h"
+#include "llviewercontrol.h"
+#include "llviewernetwork.h"
+#include "llviewerparcelmgr.h"
+#include "llviewerregion.h"
+#include "llviewerwindow.h"
-class URLLoader : public LLAlertDialog::URLLoader
+class URLLoader : public LLToastAlertPanel::URLLoader
{
virtual void load(const std::string& url , bool force_open_externally)
{
@@ -64,7 +75,7 @@ static URLLoader sAlertURLLoader;
// static
void LLWeb::initClass()
{
- LLAlertDialog::setURLLoader(&sAlertURLLoader);
+ LLToastAlertPanel::setURLLoader(&sAlertURLLoader);
}
@@ -92,8 +103,18 @@ void LLWeb::loadURLInternal(const std::string &url)
// static
void LLWeb::loadURLExternal(const std::string& url)
{
+ loadURLExternal(url, true);
+}
+
+
+// static
+void LLWeb::loadURLExternal(const std::string& url, bool async)
+{
std::string escaped_url = escapeURL(url);
- gViewerWindow->getWindow()->spawnWebBrowser(escaped_url);
+ if (gViewerWindow)
+ {
+ gViewerWindow->getWindow()->spawnWebBrowser(escaped_url, async);
+ }
}
@@ -122,3 +143,54 @@ std::string LLWeb::escapeURL(const std::string& url)
}
return escaped_url;
}
+
+//static
+std::string LLWeb::expandURLSubstitutions(const std::string &url,
+ const LLSD &default_subs)
+{
+ LLSD substitution = default_subs;
+ substitution["VERSION"] = LLVersionInfo::getVersion();
+ substitution["VERSION_MAJOR"] = LLVersionInfo::getMajor();
+ substitution["VERSION_MINOR"] = LLVersionInfo::getMinor();
+ substitution["VERSION_PATCH"] = LLVersionInfo::getPatch();
+ substitution["VERSION_BUILD"] = LLVersionInfo::getBuild();
+ substitution["CHANNEL"] = LLVersionInfo::getChannel();
+ substitution["GRID"] = LLViewerLogin::getInstance()->getGridLabel();
+ substitution["OS"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
+ substitution["SESSION_ID"] = gAgent.getSessionID();
+ substitution["FIRST_LOGIN"] = gAgent.isFirstLogin();
+
+ // work out the current language
+ std::string lang = LLUI::getLanguage();
+ if (lang == "en-us")
+ {
+ // *HACK: the correct fix is to change English.lproj/language.txt,
+ // but we're late in the release cycle and this is a less risky fix
+ lang = "en";
+ }
+ substitution["LANGUAGE"] = lang;
+
+ // find the region ID
+ LLUUID region_id;
+ LLViewerRegion *region = gAgent.getRegion();
+ if (region)
+ {
+ region_id = region->getRegionID();
+ }
+ substitution["REGION_ID"] = region_id;
+
+ // find the parcel local ID
+ S32 parcel_id = 0;
+ LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
+ if (parcel)
+ {
+ parcel_id = parcel->getLocalID();
+ }
+ substitution["PARCEL_ID"] = llformat("%d", parcel_id);
+
+ // expand all of the substitution strings and escape the url
+ std::string expanded_url = url;
+ LLStringUtil::format(expanded_url, substitution);
+
+ return LLWeb::escapeURL(expanded_url);
+}