diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/lluriparser.cpp | 24 | ||||
-rw-r--r-- | indra/llcommon/lluriparser.h | 2 | ||||
-rwxr-xr-x | indra/llui/lltextbase.cpp | 11 | ||||
-rwxr-xr-x | indra/llui/llurlentry.cpp | 97 | ||||
-rwxr-xr-x | indra/llui/llurlentry.h | 27 | ||||
-rwxr-xr-x | indra/llui/llurlmatch.cpp | 5 | ||||
-rwxr-xr-x | indra/llui/llurlmatch.h | 8 | ||||
-rwxr-xr-x | indra/llui/llurlregistry.cpp | 6 | ||||
-rwxr-xr-x | indra/newview/app_settings/settings.xml | 15 |
9 files changed, 171 insertions, 24 deletions
diff --git a/indra/llcommon/lluriparser.cpp b/indra/llcommon/lluriparser.cpp index 0fb004ef7e..d07288f123 100644 --- a/indra/llcommon/lluriparser.cpp +++ b/indra/llcommon/lluriparser.cpp @@ -192,19 +192,41 @@ S32 LLUriParser::normalize() void LLUriParser::glue(std::string& uri) const { + std::string first_part; + glueFirst(first_part); + + std::string second_part; + glueSecond(second_part); + + uri = first_part + second_part; +} + +void LLUriParser::glueFirst(std::string& uri) const +{ if (mScheme.size()) { uri = mScheme; uri += "://"; } + else + { + uri.clear(); + } uri += mHost; +} +void LLUriParser::glueSecond(std::string& uri) const +{ if (mPort.size()) { - uri += ':'; + uri = ':'; uri += mPort; } + else + { + uri.clear(); + } uri += mPath; diff --git a/indra/llcommon/lluriparser.h b/indra/llcommon/lluriparser.h index 719f916837..e987bae924 100644 --- a/indra/llcommon/lluriparser.h +++ b/indra/llcommon/lluriparser.h @@ -60,6 +60,8 @@ public: void extractParts(); void glue(std::string& uri) const; + void glueFirst(std::string& uri) const; + void glueSecond(std::string& uri) const; bool test() const; S32 normalize(); diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 09f923e74f..310323445b 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2063,8 +2063,17 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para LLTextUtil::processUrlMatch(&match, this, isContentTrusted() || match.isTrusted()); // output the styled Url - //appendAndHighlightTextImpl(label, part, link_params, match.underlineOnHoverOnly()); appendAndHighlightTextImpl(match.getLabel(), part, link_params, match.underlineOnHoverOnly()); + + // show query part of url with gray color if enabled in global settings in "HTTPNoProtocolShowGreyQuery" + // and only for LLUrlEntryHTTP and LLUrlEntryHTTPNoProtocol url entries + std::string label = match.getQuery(); + if (label.size()) + { + link_params.color = LLColor4::grey; + link_params.readonly_color = LLColor4::grey; + appendAndHighlightTextImpl(label, part, link_params, match.underlineOnHoverOnly()); + } // set the tooltip for the Url label if (! match.getTooltip().empty()) diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index cc7956078d..daed158fe9 100755 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -43,12 +43,16 @@ #define APP_HEADER_REGEX "((x-grid-location-info://[-\\w\\.]+/app)|(secondlife:///app))" +extern LLControlGroup gSavedSettings; + // Utility functions std::string localize_slapp_label(const std::string& url, const std::string& full_name); LLUrlEntryBase::LLUrlEntryBase() -{} +{ + mGreyQuery = gSavedSettings.getBOOL("HTTPNoProtocolShowGreyQuery"); +} LLUrlEntryBase::~LLUrlEntryBase() { @@ -187,6 +191,33 @@ bool LLUrlEntryBase::isWikiLinkCorrect(std::string url) return (LLUrlRegistry::instance().hasUrl(label)) ? false : true; } +std::string LLUrlEntryBase::urlToLabelWithGreyQuery(const std::string &url) const +{ + LLUriParser up(unescapeUrl(url)); + up.normalize(); + + std::string label; + up.extractParts(); + up.glueFirst(label); + + return label; +} + +std::string LLUrlEntryBase::urlToGreyQuery(const std::string &url) const +{ + LLUriParser up(unescapeUrl(url)); + + std::string query; + if (mGreyQuery) + { + up.extractParts(); + up.glueSecond(query); + } + + return query; +} + + static std::string getStringAfterToken(const std::string str, const std::string token) { size_t pos = str.find(token); @@ -203,6 +234,7 @@ static std::string getStringAfterToken(const std::string str, const std::string // LLUrlEntryHTTP Describes generic http: and https: Urls // LLUrlEntryHTTP::LLUrlEntryHTTP() + : LLUrlEntryBase() { mPattern = boost::regex("https?://([-\\w\\.]+)+(:\\d+)?(:\\w+)?(@\\d+)?(@\\w+)?/?\\S*", boost::regex::perl|boost::regex::icase); @@ -212,6 +244,25 @@ LLUrlEntryHTTP::LLUrlEntryHTTP() std::string LLUrlEntryHTTP::getLabel(const std::string &url, const LLUrlLabelCallback &cb) { + return urlToLabelWithGreyQuery(url); +} + +std::string LLUrlEntryHTTP::getQuery(const std::string &url) const +{ + return urlToGreyQuery(url); +} + +std::string LLUrlEntryHTTP::getUrl(const std::string &string) const +{ + if (string.find("://") == std::string::npos) + { + return "http://" + escapeUrl(string); + } + return escapeUrl(string); +} + +std::string LLUrlEntryHTTP::getTooltip(const std::string &url) const +{ return unescapeUrl(url); } @@ -247,6 +298,7 @@ std::string LLUrlEntryHTTPLabel::getUrl(const std::string &string) const // LLUrlEntryHTTPNoProtocol Describes generic Urls like www.google.com // LLUrlEntryHTTPNoProtocol::LLUrlEntryHTTPNoProtocol() + : LLUrlEntryBase() { mPattern = boost::regex("(" "\\bwww\\.\\S+\\.\\S+" // i.e. www.FOO.BAR @@ -260,7 +312,12 @@ LLUrlEntryHTTPNoProtocol::LLUrlEntryHTTPNoProtocol() std::string LLUrlEntryHTTPNoProtocol::getLabel(const std::string &url, const LLUrlLabelCallback &cb) { - return unescapeUrl(url); + return urlToLabelWithGreyQuery(url); +} + +std::string LLUrlEntryHTTPNoProtocol::getQuery(const std::string &url) const +{ + return urlToGreyQuery(url); } std::string LLUrlEntryHTTPNoProtocol::getUrl(const std::string &string) const @@ -272,6 +329,11 @@ std::string LLUrlEntryHTTPNoProtocol::getUrl(const std::string &string) const return escapeUrl(string); } +std::string LLUrlEntryHTTPNoProtocol::getTooltip(const std::string &url) const +{ + return unescapeUrl(url); +} + // // LLUrlEntrySLURL Describes generic http: and https: Urls // @@ -345,30 +407,33 @@ std::string LLUrlEntrySLURL::getLocation(const std::string &url) const } // -// LLUrlEntrySeconlifeURLs Describes *secondlife.com and *lindenlab.com urls to substitute icon 'hand.png' before link +// LLUrlEntrySeconlifeURL Describes *secondlife.com/ and *lindenlab.com/ urls to substitute icon 'hand.png' before link // -LLUrlEntrySeconlifeURL::LLUrlEntrySeconlifeURL() -{ - mPattern = boost::regex("\\b(https?://)?([-\\w\\.]*\\.)?(secondlife|lindenlab)\\.com(:\\d{1,5})?(/\\S*)?\\b", +LLUrlEntrySecondlifeURL::LLUrlEntrySecondlifeURL() +{ + mPattern = boost::regex("(https?://)?([-\\w\\.]*\\.)?(secondlife|lindenlab)\\.com(:\\d{1,5})?\\/\\S*", boost::regex::perl|boost::regex::icase); mIcon = "Hand"; mMenuName = "menu_url_http.xml"; } -std::string LLUrlEntrySeconlifeURL::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +std::string LLUrlEntrySecondlifeURL::getLabel(const std::string &url, const LLUrlLabelCallback &cb) { LLUriParser up(url); up.extractParts(); - return up.host(); + + std::string label; + up.glueFirst(label); + return label; } -std::string LLUrlEntrySeconlifeURL::getTooltip(const std::string &url) const +std::string LLUrlEntrySecondlifeURL::getTooltip(const std::string &url) const { return url; } -std::string LLUrlEntrySeconlifeURL::getUrl(const std::string &string) const +std::string LLUrlEntrySecondlifeURL::getUrl(const std::string &string) const { if (string.find("://") == std::string::npos) { @@ -378,6 +443,18 @@ std::string LLUrlEntrySeconlifeURL::getUrl(const std::string &string) const } // +// LLUrlEntrySimpleSecondlifeURL Describes *secondlife.com and *lindenlab.com urls to substitute icon 'hand.png' before link +// +LLUrlEntrySimpleSecondlifeURL::LLUrlEntrySimpleSecondlifeURL() + { + mPattern = boost::regex("(https?://)?([-\\w\\.]*\\.)?(secondlife|lindenlab)\\.com(?!\\S)", + boost::regex::perl|boost::regex::icase); + + mIcon = "Hand"; + mMenuName = "menu_url_http.xml"; +} + +// // LLUrlEntryAgent Describes a Second Life agent Url, e.g., // secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about // x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index 055a8b1515..fd18389303 100755 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -78,6 +78,9 @@ public: /// Given a matched Url, return a label for the Url virtual std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb) { return url; } + /// Return port, query and fragment parts for the Url + virtual std::string getQuery(const std::string &url) const { return ""; } + /// Return an icon that can be displayed next to Urls of this type virtual std::string getIcon(const std::string &url); @@ -111,6 +114,8 @@ protected: std::string getLabelFromWikiLink(const std::string &url) const; std::string getUrlFromWikiLink(const std::string &string) const; void addObserver(const std::string &id, const std::string &url, const LLUrlLabelCallback &cb); + std::string urlToLabelWithGreyQuery(const std::string &url) const; + std::string urlToGreyQuery(const std::string &url) const; virtual void callObservers(const std::string &id, const std::string &label, const std::string& icon); typedef struct { @@ -123,6 +128,7 @@ protected: std::string mMenuName; std::string mTooltip; std::multimap<std::string, LLUrlEntryObserver> mObservers; + bool mGreyQuery; }; /// @@ -133,6 +139,9 @@ class LLUrlEntryHTTP : public LLUrlEntryBase public: LLUrlEntryHTTP(); /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); + /*virtual*/ std::string getQuery(const std::string &url) const; + /*virtual*/ std::string getUrl(const std::string &string) const; + /*virtual*/ std::string getTooltip(const std::string &url) const; }; /// @@ -155,7 +164,9 @@ class LLUrlEntryHTTPNoProtocol : public LLUrlEntryBase public: LLUrlEntryHTTPNoProtocol(); /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); + /*virtual*/ std::string getQuery(const std::string &url) const; /*virtual*/ std::string getUrl(const std::string &string) const; + /*virtual*/ std::string getTooltip(const std::string &url) const; }; /// @@ -172,17 +183,23 @@ public: /// /// LLUrlEntrySeconlifeURLs Describes *secondlife.com and *lindenlab.com Urls /// -class LLUrlEntrySeconlifeURL : public LLUrlEntryBase +class LLUrlEntrySecondlifeURL : public LLUrlEntryBase { public: - LLUrlEntrySeconlifeURL(); + LLUrlEntrySecondlifeURL(); bool isTrusted() const { return true; } /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); /*virtual*/ std::string getTooltip(const std::string &url) const; - /*virtual*/ std::string getUrl(const std::string &string) const; + /*virtual*/ std::string getUrl(const std::string &string) const; +}; -private: - std::string mLabel; +/// +/// LLUrlEntrySeconlifeURLs Describes *secondlife.com and *lindenlab.com Urls +/// +class LLUrlEntrySimpleSecondlifeURL : public LLUrlEntrySecondlifeURL +{ +public: + LLUrlEntrySimpleSecondlifeURL(); }; /// diff --git a/indra/llui/llurlmatch.cpp b/indra/llui/llurlmatch.cpp index 016d1ca92d..2f2ac969e1 100755 --- a/indra/llui/llurlmatch.cpp +++ b/indra/llui/llurlmatch.cpp @@ -42,8 +42,8 @@ LLUrlMatch::LLUrlMatch() : { } -void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, - const std::string &label, const std::string &tooltip, +void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, const std::string &label, + const std::string& query, const std::string &tooltip, const std::string &icon, const LLStyle::Params& style, const std::string &menu, const std::string &location, const LLUUID& id, bool underline_on_hover_only, bool trusted) @@ -52,6 +52,7 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, mEnd = end; mUrl = url; mLabel = label; + mQuery = query; mTooltip = tooltip; mIcon = icon; mStyle = style; diff --git a/indra/llui/llurlmatch.h b/indra/llui/llurlmatch.h index 9f8960b32f..ff699902ca 100755 --- a/indra/llui/llurlmatch.h +++ b/indra/llui/llurlmatch.h @@ -62,6 +62,9 @@ public: /// return a label that can be used for the display of this Url std::string getLabel() const { return mLabel; } + /// return a right part of url which should be drawn in grey + std::string getQuery() const { return mQuery; } + /// return a message that could be displayed in a tooltip or status bar std::string getTooltip() const { return mTooltip; } @@ -85,10 +88,10 @@ public: /// Change the contents of this match object (used by LLUrlRegistry) void setValues(U32 start, U32 end, const std::string &url, const std::string &label, - const std::string &tooltip, const std::string &icon, + const std::string& query, const std::string &tooltip, const std::string &icon, const LLStyle::Params& style, const std::string &menu, const std::string &location, const LLUUID& id, - bool underline_on_hover_only = false, bool trusted = false ); + bool underline_on_hover_only = false, bool trusted = false); const LLUUID& getID() const { return mID; } private: @@ -96,6 +99,7 @@ private: U32 mEnd; std::string mUrl; std::string mLabel; + std::string mQuery; std::string mTooltip; std::string mIcon; std::string mMenuName; diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index 9e8d8d01f1..280d066087 100755 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -47,7 +47,8 @@ LLUrlRegistry::LLUrlRegistry() registerUrl(new LLUrlEntrySLURL()); // decorated links for host names like: secondlife.com and lindenlab.com - registerUrl(new LLUrlEntrySeconlifeURL()); + registerUrl(new LLUrlEntrySecondlifeURL()); + registerUrl(new LLUrlEntrySimpleSecondlifeURL()); registerUrl(new LLUrlEntryHTTP()); mUrlEntryHTTPLabel = new LLUrlEntryHTTPLabel(); @@ -199,6 +200,7 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL match_start = start; match_end = end; match_entry = url_entry; + break; } } } @@ -216,6 +218,7 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL match.setValues(match_start, match_end, match_entry->getUrl(url), match_entry->getLabel(url, cb), + match_entry->getQuery(url), match_entry->getTooltip(url), match_entry->getIcon(url), match_entry->getStyle(), @@ -252,6 +255,7 @@ bool LLUrlRegistry::findUrl(const LLWString &text, LLUrlMatch &match, const LLUr match.setValues(start, end, match.getUrl(), match.getLabel(), + match.getQuery(), match.getTooltip(), match.getIcon(), match.getStyle(), diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index d9161b0a10..16705e1913 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4982,6 +4982,7 @@ <key>Type</key> <string>LLSD</string> <key>Value</key> + <array /> </map> <key>LSLFindCaseInsensitivity</key> <map> @@ -11737,7 +11738,7 @@ <key>Type</key> <string>F32</string> <key>Value</key> - <integer>0.0</integer> + <real>0.0</real> </map> <key>TextureFetchSource</key> <map> @@ -15584,7 +15585,17 @@ <key>Value</key> <integer>0</integer> </map> - + <key>HTTPNoProtocolShowGreyQuery</key> + <map> + <key>Comment</key> + <string>Enable(disable) appearance of port, query and fragment parts of url for HTTP and HTTPNoProtocol entries in grey.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> </map> </llsd> |