From 0a9be086ecd4fae7b9d390d00501b642c70357a5 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 19 Apr 2010 02:39:31 -0700 Subject: Use metaverseink.com for non-SL web searches --- linden/indra/newview/app_settings/settings.xml | 45 +++++- linden/indra/newview/hippoGridManager.cpp | 53 +++++-- linden/indra/newview/hippoGridManager.h | 2 +- linden/indra/newview/llpaneldirfind.cpp | 169 ++++++++++++--------- linden/indra/newview/llpaneldirfind.h | 4 +- linden/indra/newview/llpanelweb.cpp | 29 +++- .../skins/default/xui/en-us/floater_directory.xml | 2 +- 7 files changed, 203 insertions(+), 101 deletions(-) diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 6643e43..0fee2e0 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -8828,7 +8828,7 @@ SearchURLDefault Comment - URL to load for empty searches + URL to load for empty Second Life searches Persist 1 HideFromEditor @@ -8838,10 +8838,23 @@ Value http://search.secondlife.com/client_search.php? + SearchURLDefaultOpenSim + + Comment + URL to load for empty OpenSim searches + Persist + 1 + HideFromEditor + 0 + Type + String + Value + http://webi.metaverseink.com/opensim/results.jsp? + SearchURLQuery Comment - URL to use for searches + URL to use for Second Life searches Persist 1 HideFromEditor @@ -8851,10 +8864,23 @@ Value http://search.secondlife.com/client_search.php?q=[QUERY]&s=[COLLECTION]& + SearchURLQueryOpenSim + + Comment + URL to use for OpenSim searches + Persist + 1 + HideFromEditor + 0 + Type + String + Value + http://webi.metaverseink.com/opensim/results.jsp?query=[QUERY]&vw=os + SearchURLSuffix2 Comment - Parameters added to end of search queries + Parameters added to end of Second Life search queries Persist 1 HideFromEditor @@ -8864,6 +8890,19 @@ Value lang=[LANG]&mat=[MATURITY]&t=[TEEN]&region=[REGION]&x=[X]&y=[Y]&z=[Z]&session=[SESSION] + SearchURLSuffixOpenSim + + Comment + Parameters added to end of OpenSim search queries + Persist + 1 + HideFromEditor + 0 + Type + String + Value + + SelectMovableOnly Comment diff --git a/linden/indra/newview/hippoGridManager.cpp b/linden/indra/newview/hippoGridManager.cpp index f96e3ec..9acdd69 100644 --- a/linden/indra/newview/hippoGridManager.cpp +++ b/linden/indra/newview/hippoGridManager.cpp @@ -263,22 +263,43 @@ void HippoGridInfo::setDirectoryFee(int fee) // ******************************************************************** // Grid Info -std::string HippoGridInfo::getSearchUrl(SearchType ty) const -{ - if ((mPlatform == PLATFORM_SECONDLIFE) || mSearchUrl.empty()) { - // Second Life defaults - if (ty == SEARCH_ALL_EMPTY) { - return gSavedSettings.getString("SearchURLDefault"); - } else if (ty == SEARCH_ALL_QUERY) { - return gSavedSettings.getString("SearchURLQuery"); - } else if (ty == SEARCH_ALL_TEMPLATE) { - return gSavedSettings.getString("SearchURLSuffix2"); - } else { - llinfos << "Illegal search URL type " << ty << llendl; - return ""; - } - } else { - // OpenSim and other +std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const +{ + // Don't worry about whether or not mSearchUrl is empty here anymore -- MC + if (is_web) + { + if (mPlatform == PLATFORM_SECONDLIFE) + { + // Second Life defaults + if (ty == SEARCH_ALL_EMPTY) { + return gSavedSettings.getString("SearchURLDefault"); + } else if (ty == SEARCH_ALL_QUERY) { + return gSavedSettings.getString("SearchURLQuery"); + } else if (ty == SEARCH_ALL_TEMPLATE) { + return gSavedSettings.getString("SearchURLSuffix2"); + } else { + llinfos << "Illegal search URL type " << ty << llendl; + return ""; + } + } + else + { + // OpenSim and other web search defaults + if (ty == SEARCH_ALL_EMPTY) { + return gSavedSettings.getString("SearchURLDefaultOpenSim"); + } else if (ty == SEARCH_ALL_QUERY) { + return gSavedSettings.getString("SearchURLQueryOpenSim"); + } else if (ty == SEARCH_ALL_TEMPLATE) { + return gSavedSettings.getString("SearchURLSuffixOpenSim"); + } else { + llinfos << "Illegal search URL type " << ty << llendl; + return ""; + } + } + } + else + { + // Use the old search all if (ty == SEARCH_ALL_EMPTY) { return (mSearchUrl + "panel=All&"); } else if (ty == SEARCH_ALL_QUERY) { diff --git a/linden/indra/newview/hippoGridManager.h b/linden/indra/newview/hippoGridManager.h index ef351d9..d99918b 100644 --- a/linden/indra/newview/hippoGridManager.h +++ b/linden/indra/newview/hippoGridManager.h @@ -51,7 +51,7 @@ public: const std::string& getFirstName() const; const std::string& getLastName() const; const std::string& getAvatarPassword() const; - std::string getSearchUrl(SearchType ty) const; + std::string getSearchUrl(SearchType ty, bool is_web) const; bool isRenderCompat() const; const std::string& getCurrencySymbol() const; diff --git a/linden/indra/newview/llpaneldirfind.cpp b/linden/indra/newview/llpaneldirfind.cpp index cb83ee1..ed22477 100644 --- a/linden/indra/newview/llpaneldirfind.cpp +++ b/linden/indra/newview/llpaneldirfind.cpp @@ -227,8 +227,20 @@ void LLPanelDirFindAll::search(const std::string& search_text) if (!search_text.empty()) { + // Check whether or not we're on the old or web search All -- MC + bool is_web = false; + LLPanel* tabs_panel = mFloaterDirectory->getChild("Directory Tabs")->getCurrentPanel(); + if (tabs_panel) + { + is_web = tabs_panel->getName() == "find_all_panel"; + } + else + { + llwarns << "search panel not found! How can this be?!" << llendl; + } + std::string selected_collection = childGetValue( "Category" ).asString(); - std::string url = buildSearchURL(search_text, selected_collection, inc_pg, inc_mature, inc_adult); + std::string url = buildSearchURL(search_text, selected_collection, inc_pg, inc_mature, inc_adult, is_web); if (mWebBrowser) { mWebBrowser->navigateTo(url); @@ -250,26 +262,28 @@ void LLPanelDirFind::focus() void LLPanelDirFind::navigateToDefaultPage() { - std::string start_url = gSavedSettings.getString("SearchURLDefault"); - // Note: beware porting stuff like below. We use the web panel in OpenSim as well as Second Life -- MC - /*if (gHippoGridManager->getConnectedGrid()->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) { - start_url = getString("default_search_page"); - } else { - start_url = gHippoGridManager->getConnectedGrid()->getSearchUrl(); - start_url += "panel=" + getLabel() + "&"; - }*/ + std::string start_url; + // Note: we use the web panel in OpenSim as well as Second Life -- MC + if (gHippoGridManager->getConnectedGrid()->isSecondLife()) + { + start_url = gSavedSettings.getString("SearchURLDefault"); - BOOL inc_pg = childGetValue("incpg").asBoolean(); - BOOL inc_mature = childGetValue("incmature").asBoolean(); - BOOL inc_adult = childGetValue("incadult").asBoolean(); - if (!(inc_pg || inc_mature || inc_adult)) + BOOL inc_pg = childGetValue("incpg").asBoolean(); + BOOL inc_mature = childGetValue("incmature").asBoolean(); + BOOL inc_adult = childGetValue("incadult").asBoolean(); + if (!(inc_pg || inc_mature || inc_adult)) + { + // if nothing's checked, just go for pg; we don't notify in + // this case because it's a default page. + inc_pg = true; + } + + start_url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult, true); + } + else { - // if nothing's checked, just go for pg; we don't notify in - // this case because it's a default page. - inc_pg = true; + start_url = gSavedSettings.getString("SearchURLDefaultOpenSim"); } - - start_url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult); llinfos << "default url: " << start_url << llendl; @@ -280,11 +294,11 @@ void LLPanelDirFind::navigateToDefaultPage() } // static std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const std::string& collection, - bool inc_pg, bool inc_mature, bool inc_adult) + bool inc_pg, bool inc_mature, bool inc_adult, bool is_web) { std::string url; if (search_text.empty()) { - url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_EMPTY); + url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_EMPTY, is_web); } else { // Replace spaces with "+" for use by Google search appliance // Yes, this actually works for double-spaces @@ -307,7 +321,7 @@ std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const "-._~$+!*'()"; std::string query = LLURI::escape(search_text_with_plus, allowed); - url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_QUERY); + url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_QUERY, is_web); std::string substring = "[QUERY]"; std::string::size_type where = url.find(substring); if (where != std::string::npos) @@ -325,66 +339,73 @@ std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const } } - url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult); + url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult, is_web); llinfos << "search url " << url << llendl; return url; } // static -std::string LLPanelDirFind::getSearchURLSuffix(bool inc_pg, bool inc_mature, bool inc_adult) +std::string LLPanelDirFind::getSearchURLSuffix(bool inc_pg, bool inc_mature, bool inc_adult, bool is_web) { - std::string url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_TEMPLATE); - - // if the mature checkbox is unchecked, modify query to remove - // terms with given phrase from the result set - // This builds a value from 1-7 by or-ing together the flags, and then converts - // it to a string. - std::string substring="[MATURITY]"; - S32 maturityFlag = - (inc_pg ? SEARCH_PG : SEARCH_NONE) | - (inc_mature ? SEARCH_MATURE : SEARCH_NONE) | - (inc_adult ? SEARCH_ADULT : SEARCH_NONE); - url.replace(url.find(substring), substring.length(), boost::lexical_cast(maturityFlag)); - - // Include region and x/y position, not for the GSA, but - // just to get logs on the web server for search_proxy.php - // showing where people were standing when they searched. - std::string region_name; - LLViewerRegion* region = gAgent.getRegion(); - if (region) + std::string url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_TEMPLATE, is_web); + + if (!url.empty()) { - region_name = region->getName(); + // Note: opensim's template (SearchURLSuffixOpenSim) is currently empty -- MC + if (gHippoGridManager->getConnectedGrid()->isSecondLife()) + { + // if the mature checkbox is unchecked, modify query to remove + // terms with given phrase from the result set + // This builds a value from 1-7 by or-ing together the flags, and then converts + // it to a string. + std::string substring="[MATURITY]"; + S32 maturityFlag = + (inc_pg ? SEARCH_PG : SEARCH_NONE) | + (inc_mature ? SEARCH_MATURE : SEARCH_NONE) | + (inc_adult ? SEARCH_ADULT : SEARCH_NONE); + url.replace(url.find(substring), substring.length(), boost::lexical_cast(maturityFlag)); + + // Include region and x/y position, not for the GSA, but + // just to get logs on the web server for search_proxy.php + // showing where people were standing when they searched. + std::string region_name; + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + region_name = region->getName(); + } + // take care of spaces in names + region_name = LLURI::escape(region_name); + substring = "[REGION]"; + url.replace(url.find(substring), substring.length(), region_name); + + LLVector3 pos_region = gAgent.getPositionAgent(); + + std::string x = llformat("%.0f", pos_region.mV[VX]); + substring = "[X]"; + url.replace(url.find(substring), substring.length(), x); + std::string y = llformat("%.0f", pos_region.mV[VY]); + substring = "[Y]"; + url.replace(url.find(substring), substring.length(), y); + std::string z = llformat("%.0f", pos_region.mV[VZ]); + substring = "[Z]"; + url.replace(url.find(substring), substring.length(), z); + + LLUUID session_id = gAgent.getSessionID(); + std::string session_string = session_id.getString(); + substring = "[SESSION]"; + url.replace(url.find(substring), substring.length(), session_string); + + // set the currently selected language by asking the pref setting + std::string language_string = LLUI::getLanguage(); + std::string language_tag = "[LANG]"; + url.replace( url.find( language_tag ), language_tag.length(), language_string ); + + // and set the flag for the teen grid + std::string teen_string = gAgent.isTeen() ? "y" : "n"; + std::string teen_tag = "[TEEN]"; + url.replace( url.find( teen_tag ), teen_tag.length(), teen_string ); + } } - // take care of spaces in names - region_name = LLURI::escape(region_name); - substring = "[REGION]"; - url.replace(url.find(substring), substring.length(), region_name); - - LLVector3 pos_region = gAgent.getPositionAgent(); - - std::string x = llformat("%.0f", pos_region.mV[VX]); - substring = "[X]"; - url.replace(url.find(substring), substring.length(), x); - std::string y = llformat("%.0f", pos_region.mV[VY]); - substring = "[Y]"; - url.replace(url.find(substring), substring.length(), y); - std::string z = llformat("%.0f", pos_region.mV[VZ]); - substring = "[Z]"; - url.replace(url.find(substring), substring.length(), z); - - LLUUID session_id = gAgent.getSessionID(); - std::string session_string = session_id.getString(); - substring = "[SESSION]"; - url.replace(url.find(substring), substring.length(), session_string); - - // set the currently selected language by asking the pref setting - std::string language_string = LLUI::getLanguage(); - std::string language_tag = "[LANG]"; - url.replace( url.find( language_tag ), language_tag.length(), language_string ); - - // and set the flag for the teen grid - std::string teen_string = gAgent.isTeen() ? "y" : "n"; - std::string teen_tag = "[TEEN]"; - url.replace( url.find( teen_tag ), teen_tag.length(), teen_string ); return url; } diff --git a/linden/indra/newview/llpaneldirfind.h b/linden/indra/newview/llpaneldirfind.h index 299060c..1a97f4b 100644 --- a/linden/indra/newview/llpaneldirfind.h +++ b/linden/indra/newview/llpaneldirfind.h @@ -62,8 +62,8 @@ public: virtual void navigateToDefaultPage(); void focus(); - static std::string buildSearchURL(const std::string& search_text, const std::string& collection, bool inc_pg, bool inc_mature, bool inc_adult); - static std::string getSearchURLSuffix(bool inc_pg, bool inc_mature, bool inc_adult); + static std::string buildSearchURL(const std::string& search_text, const std::string& collection, bool inc_pg, bool inc_mature, bool inc_adult, bool is_web); + static std::string getSearchURLSuffix(bool inc_pg, bool inc_mature, bool inc_adult, bool is_web); private: static void onClickBack( void* data ); diff --git a/linden/indra/newview/llpanelweb.cpp b/linden/indra/newview/llpanelweb.cpp index 32ec567..38bb2d7 100644 --- a/linden/indra/newview/llpanelweb.cpp +++ b/linden/indra/newview/llpanelweb.cpp @@ -37,6 +37,7 @@ // project includes #include "llcheckboxctrl.h" +#include "hippoGridManager.h" #include "llmediamanager.h" #include "lluictrlfactory.h" #include "llviewercontrol.h" @@ -100,7 +101,14 @@ BOOL LLPanelWeb::postBuild() childSetValue("web_proxy_editor", gSavedSettings.getString("BrowserProxyAddress")); childSetValue("web_proxy_port", gSavedSettings.getS32("BrowserProxyPort")); - childSetValue("world_search_editor", gSavedSettings.getString("SearchURLQuery")) ; + if (gHippoGridManager->getConnectedGrid()->isSecondLife()) + { + childSetValue("world_search_editor", gSavedSettings.getString("SearchURLQuery")) ; + } + else + { + childSetValue("world_search_editor", gSavedSettings.getString("SearchURLQueryOpenSim")) ; + } childSetAction("world_search_reset_default", onClickDefault, this); childSetAction("world_search_clear", onClickClear, this); @@ -124,7 +132,14 @@ void LLPanelWeb::apply() gSavedSettings.setBOOL("BrowserProxyEnabled", childGetValue("web_proxy_enabled")); gSavedSettings.setString("BrowserProxyAddress", childGetValue("web_proxy_editor")); gSavedSettings.setS32("BrowserProxyPort", childGetValue("web_proxy_port")); - gSavedSettings.setString("SearchURLQuery", childGetValue("world_search_editor")); + if (gHippoGridManager->getConnectedGrid()->isSecondLife()) + { + gSavedSettings.setString("SearchURLQuery", childGetValue("world_search_editor")); + } + else + { + gSavedSettings.setString("SearchURLQueryOpenSim", childGetValue("world_search_editor")); + } bool value = childGetValue("use_external_browser").asString() == "external" ? true : false; gSavedSettings.setBOOL("UseExternalBrowser", value); @@ -217,14 +232,20 @@ void LLPanelWeb::onCommitWebProxyEnabled(LLUICtrl* ctrl, void* data) void LLPanelWeb::onClickDefault(void* user_data) { LLPanelWeb* self = (LLPanelWeb*)user_data; - LLControlVariable* controlp = gSavedSettings.getControl("SearchURLQuery"); + LLControlVariable* controlp = + (gHippoGridManager->getConnectedGrid()->isSecondLife()) + ? + gSavedSettings.getControl("SearchURLQuery") + : + gSavedSettings.getControl("SearchURLQueryOpenSim"); + if (controlp) { self->childSetValue("world_search_editor",controlp->getDefault().asString()) ; } else { - llwarns << "SearchURLQuery missing from settings.xml - thats bad!" << llendl; + llwarns << "SearchURLQuery or SearchURLQueryOpenSim missing from settings.xml - thats bad!" << llendl; } } diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_directory.xml b/linden/indra/newview/skins/default/xui/en-us/floater_directory.xml index 039c4f8..ebadde3 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_directory.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_directory.xml @@ -82,7 +82,7 @@ font="SansSerif" handle_edit_keys_directly="false" height="18" label="Search" left_delta="56" max_length="254" mouse_opaque="true" name="search_editor" select_all_on_focus_received="false" - select_on_focus="false" tab_group="1" tool_tip="Search Second Life" + select_on_focus="false" tab_group="1" tool_tip="Search the web" width="160" />