automated merge viewer2.0->viewer2.0
commit
e85cf743e5
|
|
@ -196,6 +196,31 @@ std::string LLUrlEntryHTTPLabel::getUrl(const std::string &string)
|
|||
return getUrlFromWikiLink(string);
|
||||
}
|
||||
|
||||
//
|
||||
// LLUrlEntryHTTPNoProtocol Describes generic Urls like www.google.com
|
||||
//
|
||||
LLUrlEntryHTTPNoProtocol::LLUrlEntryHTTPNoProtocol()
|
||||
{
|
||||
mPattern = boost::regex("(\\bwww\\.\\S+\\.\\S+|\\S+.com\\S*|\\S+.net\\S*|\\S+.edu\\S*|\\S+.org\\S*)",
|
||||
boost::regex::perl|boost::regex::icase);
|
||||
mMenuName = "menu_url_http.xml";
|
||||
mTooltip = LLTrans::getString("TooltipHttpUrl");
|
||||
}
|
||||
|
||||
std::string LLUrlEntryHTTPNoProtocol::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
|
||||
{
|
||||
return unescapeUrl(url);
|
||||
}
|
||||
|
||||
std::string LLUrlEntryHTTPNoProtocol::getUrl(const std::string &string)
|
||||
{
|
||||
if (string.find("://") == std::string::npos)
|
||||
{
|
||||
return "http://" + escapeUrl(string);
|
||||
}
|
||||
return escapeUrl(string);
|
||||
}
|
||||
|
||||
//
|
||||
// LLUrlEntrySLURL Describes generic http: and https: Urls
|
||||
//
|
||||
|
|
|
|||
|
|
@ -134,6 +134,17 @@ public:
|
|||
/*virtual*/ std::string getUrl(const std::string &string);
|
||||
};
|
||||
|
||||
///
|
||||
/// LLUrlEntryHTTPNoProtocol Describes generic Urls like www.google.com
|
||||
///
|
||||
class LLUrlEntryHTTPNoProtocol : public LLUrlEntryBase
|
||||
{
|
||||
public:
|
||||
LLUrlEntryHTTPNoProtocol();
|
||||
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
|
||||
/*virtual*/ std::string getUrl(const std::string &string);
|
||||
};
|
||||
|
||||
///
|
||||
/// LLUrlEntrySLURL Describes http://slurl.com/... Urls
|
||||
///
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ LLUrlRegistry::LLUrlRegistry()
|
|||
//so it should be registered in the end of list
|
||||
registerUrl(new LLUrlEntrySL());
|
||||
registerUrl(new LLUrlEntrySLLabel());
|
||||
// most common pattern is a URL without any protocol,
|
||||
// e.g., "secondlife.com"
|
||||
registerUrl(new LLUrlEntryHTTPNoProtocol());
|
||||
}
|
||||
|
||||
LLUrlRegistry::~LLUrlRegistry()
|
||||
|
|
@ -118,10 +121,23 @@ static bool matchRegex(const char *text, boost::regex regex, U32 &start, U32 &en
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool stringHasUrl(const std::string &text)
|
||||
{
|
||||
// fast heuristic test for a URL in a string. This is used
|
||||
// to avoid lots of costly regex calls, BUT it needs to be
|
||||
// kept in sync with the LLUrlEntry regexes we support.
|
||||
return (text.find("://") != std::string::npos ||
|
||||
text.find("www.") != std::string::npos ||
|
||||
text.find(".com") != std::string::npos ||
|
||||
text.find(".net") != std::string::npos ||
|
||||
text.find(".edu") != std::string::npos ||
|
||||
text.find(".org") != std::string::npos);
|
||||
}
|
||||
|
||||
bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LLUrlLabelCallback &cb)
|
||||
{
|
||||
// avoid costly regexes if there is clearly no URL in the text
|
||||
if (text.find("://") == std::string::npos)
|
||||
if (! stringHasUrl(text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@
|
|||
LLFloaterSearch::LLFloaterSearch(const LLSD& key) :
|
||||
LLFloater(key),
|
||||
LLViewerMediaObserver(),
|
||||
mBrowser(NULL)
|
||||
mBrowser(NULL),
|
||||
mSearchGodLevel(0)
|
||||
{
|
||||
// declare a map that transforms a category name into
|
||||
// the URL suffix that is used to search that category
|
||||
|
|
@ -86,12 +87,21 @@ void LLFloaterSearch::handleMediaEvent(LLPluginClassMedia *self, EMediaEvent eve
|
|||
case MEDIA_EVENT_NAVIGATE_COMPLETE:
|
||||
childSetText("status_text", getString("done_text"));
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LLFloaterSearch::godLevelChanged(U8 godlevel)
|
||||
{
|
||||
// search results can change based upon god level - if the user
|
||||
// changes god level, then give them a warning (we don't refresh
|
||||
// the search as this might undo any page navigation or
|
||||
// AJAX-driven changes since the last search).
|
||||
childSetVisible("refresh_search", (godlevel != mSearchGodLevel));
|
||||
}
|
||||
|
||||
void LLFloaterSearch::search(const LLSD &key)
|
||||
{
|
||||
if (! mBrowser)
|
||||
|
|
@ -99,6 +109,10 @@ void LLFloaterSearch::search(const LLSD &key)
|
|||
return;
|
||||
}
|
||||
|
||||
// reset the god level warning as we're sending the latest state
|
||||
childHide("refresh_search");
|
||||
mSearchGodLevel = gAgent.getGodLevel();
|
||||
|
||||
// get the URL for the search page
|
||||
std::string url = getString("search_url");
|
||||
if (! LLStringUtil::endsWith(url, "/"))
|
||||
|
|
|
|||
|
|
@ -66,14 +66,20 @@ public:
|
|||
/// "events", "groups", "wiki", "destinations", "classifieds"
|
||||
void search(const LLSD &key);
|
||||
|
||||
/// changing godmode can affect the search results that are
|
||||
/// returned by the search website - use this method to tell the
|
||||
/// search floater that the user has changed god level.
|
||||
void godLevelChanged(U8 godlevel);
|
||||
|
||||
private:
|
||||
/*virtual*/ BOOL postBuild();
|
||||
|
||||
// inherited from LLViewerMediaObserver
|
||||
/*virtual*/ void handleMediaEvent(LLPluginClassMedia *self, EMediaEvent event);
|
||||
|
||||
|
||||
LLMediaCtrl *mBrowser;
|
||||
LLSD mCategoryPaths;
|
||||
U8 mSearchGodLevel;
|
||||
};
|
||||
|
||||
#endif // LL_LLFLOATERSEARCH_H
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
#include "llfloaterland.h"
|
||||
#include "llfloaterpay.h"
|
||||
#include "llfloaterreporter.h"
|
||||
#include "llfloatersearch.h"
|
||||
#include "llfloaterscriptdebug.h"
|
||||
#include "llfloatertools.h"
|
||||
#include "llfloaterworldmap.h"
|
||||
|
|
@ -3408,6 +3409,13 @@ void set_god_level(U8 god_level)
|
|||
|
||||
// changing god-level can affect which menus we see
|
||||
show_debug_menus();
|
||||
|
||||
// changing god-level can invalidate search results
|
||||
LLFloaterSearch *search = dynamic_cast<LLFloaterSearch*>(LLFloaterReg::getInstance("search"));
|
||||
if (search)
|
||||
{
|
||||
search->godLevelChanged(god_level);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TOGGLE_HACKED_GODLIKE_VIEWER
|
||||
|
|
|
|||
|
|
@ -55,8 +55,20 @@
|
|||
layout="topleft"
|
||||
left_delta="0"
|
||||
name="status_text"
|
||||
top_pad="5"
|
||||
top_pad="7"
|
||||
width="150" />
|
||||
<text
|
||||
visible="false"
|
||||
follows="bottom|right"
|
||||
height="16"
|
||||
left_delta="0"
|
||||
name="refresh_search"
|
||||
left_pad="0"
|
||||
right="-10"
|
||||
halign="right"
|
||||
width="450">
|
||||
Redo search to reflect current God level
|
||||
</text>
|
||||
</layout_panel>
|
||||
</layout_stack>
|
||||
</floater>
|
||||
|
|
|
|||
Loading…
Reference in New Issue