From 54607d12837acac1b88cc3602e041362340796f8 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Wed, 11 Aug 2010 05:57:33 -0700 Subject: Re-enabled search url fetching in the grid manager and fixed up web search to support them (fetched urls are equivalent to SearchURLDefault and searches follow the SL web search formatting) --- linden/indra/newview/floatergridmanager.cpp | 81 ++++++++++++---------- linden/indra/newview/hippoGridManager.cpp | 33 +++++++-- linden/indra/newview/hippoGridManager.h | 2 + linden/indra/newview/llpaneldirfind.cpp | 40 +++++++---- .../default/xui/en-us/floater_grid_manager.xml | 21 ++++-- 5 files changed, 115 insertions(+), 62 deletions(-) (limited to 'linden') diff --git a/linden/indra/newview/floatergridmanager.cpp b/linden/indra/newview/floatergridmanager.cpp index 1ca7ae3..3d4b17f 100644 --- a/linden/indra/newview/floatergridmanager.cpp +++ b/linden/indra/newview/floatergridmanager.cpp @@ -94,7 +94,7 @@ void FloaterGridManager::clearInfo() //getChild("first_name")->clear(); //getChild("last_name")->clear(); //getChild("avatar_password")->clear(); - //getChild("search")->clear(); + getChild("search")->clear(); //getChild("btn_delete"); //getChild("btn_add") //getChild("btn_copy"); @@ -129,7 +129,7 @@ void FloaterGridManager::refresh() //getChild("first_name")->setEnabled(can_edit); //getChild("last_name")->setEnabled(can_edit); //getChild("avatar_password")->setEnabled(can_edit); - //getChild("search")->setEnabled(can_edit); + getChild("search")->setEnabled(can_edit); getChild("btn_delete")->setEnabled(can_edit); //getChild("btn_add") //getChild("btn_copy")->setEnabled(can_edit); @@ -234,52 +234,57 @@ void FloaterGridManager::refreshGrids() // else if(gridInfo->getPasswordUrl().empty()) // FloaterGridManager::getInstance()->childSetText("avatar_password", std::string("")); - // if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) { - // //childSetEnabled("search", false); - // //childSetText("search", LLStringExplicit("")); - // childSetEnabled("render_compat", false); - // childSetValue("render_compat", false); - // } else { - // //childSetEnabled("search", true); - // //childSetText("search", gridInfo->getSearchUrl()); - // childSetEnabled("render_compat", true); - // childSetValue("render_compat", gridInfo->isRenderCompat()); - // } + if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) + { + FloaterGridManager::getInstance()->childSetEnabled("search", false); + FloaterGridManager::getInstance()->childSetText("search", LLStringUtil::null); + //childSetEnabled("render_compat", false); + //childSetValue("render_compat", false); + } + else + { + FloaterGridManager::getInstance()->childSetEnabled("search", true); + FloaterGridManager::getInstance()->childSetText("search", gridInfo->getSearchUrl()); + //childSetEnabled("render_compat", true); + //childSetValue("render_compat", gridInfo->isRenderCompat()); + } } else { - std::string empty = ""; - FloaterGridManager::getInstance()->childSetText("gridnick", empty); - FloaterGridManager::getInstance()->childSetText("gridname", empty); - FloaterGridManager::getInstance()->childSetText("loginuri", empty); - FloaterGridManager::getInstance()->childSetText("loginpage", empty); - FloaterGridManager::getInstance()->childSetText("helperuri", empty); - FloaterGridManager::getInstance()->childSetText("website", empty); - // FloaterGridManager::getInstance()->childSetText("first_name", empty); - // FloaterGridManager::getInstance()->childSetText("last_name", empty); - // FloaterGridManager::getInstance()->childSetText("avatar_password", empty); + FloaterGridManager::getInstance()->childSetText("gridnick", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("gridname", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("loginuri", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("loginpage", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("helperuri", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("website", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("support", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("register", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("password", LLStringUtil::null); + // FloaterGridManager::getInstance()->childSetText("first_name", LLStringUtil::null); + // FloaterGridManager::getInstance()->childSetText("last_name", LLStringUtil::null); + // FloaterGridManager::getInstance()->childSetText("avatar_password", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("search", LLStringUtil::null); } } else if (FloaterGridManager::getInstance()->getState() == ADD_NEW) { llinfos << "mState == ADD_NEW" << llendl; std::string required = ""; - std::string empty = ""; FloaterGridManager::getInstance()->childSetText("gridnick", required); - FloaterGridManager::getInstance()->childSetText("gridname", empty); + FloaterGridManager::getInstance()->childSetText("gridname", LLStringUtil::null); FloaterGridManager::getInstance()->childSetText("loginuri", required); - FloaterGridManager::getInstance()->childSetText("loginpage", empty); - FloaterGridManager::getInstance()->childSetText("helperuri", empty); - FloaterGridManager::getInstance()->childSetText("website", empty); - FloaterGridManager::getInstance()->childSetText("support", empty); - FloaterGridManager::getInstance()->childSetText("register", empty); - FloaterGridManager::getInstance()->childSetText("password", empty); - // FloaterGridManager::getInstance()->childSetText("first_name", empty); - // FloaterGridManager::getInstance()->childSetText("last_name", empty); - // FloaterGridManager::getInstance()->childSetText("avatar_password", empty); + FloaterGridManager::getInstance()->childSetText("loginpage", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("helperuri", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("website", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("support", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("register", LLStringUtil::null); + FloaterGridManager::getInstance()->childSetText("password", LLStringUtil::null); + // FloaterGridManager::getInstance()->childSetText("first_name", LLStringUtil::null); + // FloaterGridManager::getInstance()->childSetText("last_name", LLStringUtil::null); + // FloaterGridManager::getInstance()->childSetText("avatar_password", LLStringUtil::null); //childSetEnabled("search", true); - //childSetText("search", empty); + FloaterGridManager::getInstance()->childSetText("search", LLStringUtil::null); } else if (FloaterGridManager::getInstance()->getState() == ADD_COPY) { @@ -316,7 +321,7 @@ void FloaterGridManager::applyChanges() gridInfo->setSupportUrl(childGetValue("support")); gridInfo->setRegisterUrl(childGetValue("register")); gridInfo->setPasswordUrl(childGetValue("password")); - //gridInfo->setSearchUrl(childGetValue("search")); + gridInfo->setSearchUrl(childGetValue("search")); gridInfo->setRenderCompat(childGetValue("render_compat")); // gridInfo->setFirstName(childGetValue("first_name")); @@ -387,7 +392,7 @@ bool FloaterGridManager::createNewGrid() grid->setSupportUrl(childGetValue("support")); grid->setRegisterUrl(childGetValue("register")); grid->setPasswordUrl(childGetValue("password")); - //grid->setSearchUrl(childGetValue("search")); + grid->setSearchUrl(childGetValue("search")); grid->setRenderCompat(childGetValue("render_compat")); gHippoGridManager->addGrid(grid); @@ -450,7 +455,7 @@ void FloaterGridManager::retrieveGridInfo() if (grid->getSupportUrl() != "") childSetText("support", grid->getSupportUrl()); if (grid->getRegisterUrl() != "") childSetText("register", grid->getRegisterUrl()); if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl()); - //if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl()); + if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl()); } else { diff --git a/linden/indra/newview/hippoGridManager.cpp b/linden/indra/newview/hippoGridManager.cpp index ccf63f5..5a229fd 100644 --- a/linden/indra/newview/hippoGridManager.cpp +++ b/linden/indra/newview/hippoGridManager.cpp @@ -314,6 +314,27 @@ std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const return ""; } } + else if (!mSearchUrl.empty()) + { + // Search url sent to us in the login response + if (ty == SEARCH_ALL_EMPTY) + { + return (mSearchUrl); + } + else if (ty == SEARCH_ALL_QUERY) + { + return (mSearchUrl + "q=[QUERY]&s=[COLLECTION]&"); + } + else if (ty == SEARCH_ALL_TEMPLATE) + { + return "lang=[LANG]&mat=[MATURITY]&t=[TEEN]®ion=[REGION]&x=[X]&y=[Y]&z=[Z]&session=[SESSION]"; + } + else + { + llinfos << "Illegal search URL type " << ty << llendl; + return ""; + } + } else { // OpenSim and other web search defaults @@ -349,7 +370,7 @@ std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const } else if (ty == SEARCH_ALL_TEMPLATE) { - return "lang=[LANG]&m=[MATURE]&t=[TEEN]®ion=[REGION]&x=[X]&y=[Y]&z=[Z]&session=[SESSION]"; + return "lang=[LANG]&m=[MATURITY]&t=[TEEN]®ion=[REGION]&x=[X]&y=[Y]&z=[Z]&session=[SESSION]"; } else { @@ -384,8 +405,8 @@ void HippoGridInfo::onXmlElementStart(void* userData, const XML_Char* name, cons self->mXmlState = XML_REGISTER; else if (strcasecmp(name, "password") == 0) self->mXmlState = XML_PASSWORD; - //else if (strcasecmp(name, "search") == 0) - //self->mXmlState = XML_SEARCH; + else if (strcasecmp(name, "search") == 0) + self->mXmlState = XML_SEARCH; } //static @@ -431,7 +452,7 @@ void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int le case XML_SEARCH: { - //self->mSearchUrl.assign(s, len); + self->mSearchUrl.assign(s, len); //sanitizeQueryUrl(mSearchUrl); break; } @@ -888,7 +909,7 @@ void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer) if (gridMap.has("support")) grid->setSupportUrl(gridMap["support"]); if (gridMap.has("register")) grid->setRegisterUrl(gridMap["register"]); if (gridMap.has("password")) grid->setPasswordUrl(gridMap["password"]); - //if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]); + if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]); if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]); // if (gridMap.has("firstname")) grid->setFirstName(gridMap["firstname"]); // if (gridMap.has("lastname")) grid->setLastName(gridMap["lastname"]); @@ -928,7 +949,7 @@ void HippoGridManager::saveFile() // gridInfo[i]["lastname"] = grid->getLastName(); // gridInfo[i]["avatarpassword"] = grid->getAvatarPassword(); - //gridInfo[i]["search"] = grid->getSearchUrl(); + gridInfo[i]["search"] = grid->getSearchUrl(); gridInfo[i]["render_compat"] = grid->isRenderCompat(); } diff --git a/linden/indra/newview/hippoGridManager.h b/linden/indra/newview/hippoGridManager.h index 5ad6ca2..bc19ff8 100644 --- a/linden/indra/newview/hippoGridManager.h +++ b/linden/indra/newview/hippoGridManager.h @@ -47,6 +47,7 @@ public: const std::string& getSupportUrl() const; const std::string& getRegisterUrl() const; const std::string& getPasswordUrl() const; + // Returns the url base used for the Web Search tab const std::string& getSearchUrl() const; const std::string& getFirstName() const; const std::string& getLastName() const; @@ -72,6 +73,7 @@ public: void setSupportUrl(const std::string& url); void setRegisterUrl(const std::string& url); void setPasswordUrl(const std::string& url); + // sets the url base used for the Web Search tab void setSearchUrl(const std::string& url); void setRenderCompat(bool compat); void setMaxAgentGroups(int max) { mMaxAgentGroups = max; } diff --git a/linden/indra/newview/llpaneldirfind.cpp b/linden/indra/newview/llpaneldirfind.cpp index ed22477..4ad75fa 100644 --- a/linden/indra/newview/llpaneldirfind.cpp +++ b/linden/indra/newview/llpaneldirfind.cpp @@ -262,11 +262,25 @@ void LLPanelDirFind::focus() void LLPanelDirFind::navigateToDefaultPage() { - std::string start_url; + std::string start_url = ""; // Note: we use the web panel in OpenSim as well as Second Life -- MC - if (gHippoGridManager->getConnectedGrid()->isSecondLife()) + if (gHippoGridManager->getConnectedGrid()->getSearchUrl().empty() && + !gHippoGridManager->getConnectedGrid()->isSecondLife()) { - start_url = gSavedSettings.getString("SearchURLDefault"); + // OS-based but doesn't have its own web search url -- MC + start_url = gSavedSettings.getString("SearchURLDefaultOpenSim"); + } + else + { + if (gHippoGridManager->getConnectedGrid()->isSecondLife()) + { + start_url = gSavedSettings.getString("SearchURLDefault"); + } + else + { + // OS-based but has its own web search url -- MC + start_url = gHippoGridManager->getConnectedGrid()->getSearchUrl(); + } BOOL inc_pg = childGetValue("incpg").asBoolean(); BOOL inc_mature = childGetValue("incmature").asBoolean(); @@ -279,13 +293,9 @@ void LLPanelDirFind::navigateToDefaultPage() } start_url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult, true); - } - else - { - start_url = gSavedSettings.getString("SearchURLDefaultOpenSim"); } - llinfos << "default url: " << start_url << llendl; + llinfos << "default web search url: " << start_url << llendl; if (mWebBrowser) { @@ -297,9 +307,12 @@ std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const bool inc_pg, bool inc_mature, bool inc_adult, bool is_web) { std::string url; - if (search_text.empty()) { + if (search_text.empty()) + { url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_EMPTY, is_web); - } else { + } + else + { // Replace spaces with "+" for use by Google search appliance // Yes, this actually works for double-spaces // " foo bar" becomes "+foo++bar" and works fine. JC @@ -340,7 +353,7 @@ std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const } url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult, is_web); - llinfos << "search url " << url << llendl; + llinfos << "web search url " << url << llendl; return url; } // static @@ -350,8 +363,9 @@ std::string LLPanelDirFind::getSearchURLSuffix(bool inc_pg, bool inc_mature, boo if (!url.empty()) { - // Note: opensim's template (SearchURLSuffixOpenSim) is currently empty -- MC - if (gHippoGridManager->getConnectedGrid()->isSecondLife()) + // Note: opensim's default template (SearchURLSuffixOpenSim) is currently empty -- MC + if (gHippoGridManager->getConnectedGrid()->isSecondLife() || + !gHippoGridManager->getConnectedGrid()->getSearchUrl().empty()) { // if the mature checkbox is unchecked, modify query to remove // terms with given phrase from the result set diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml b/linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml index 8d3e101..f635d59 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml @@ -129,7 +129,7 @@ bottom_delta="-30" drop_shadow_visible="true" follows="left|top" font="SansSerif" h_pad="0" halign="left" height="16" left="195" mouse_opaque="true" name="loginpage_text" v_pad="0" width="120"> - Grid Info: + Grid Info URLs: - Support URL: + Support: - Account URL: + Account: - Password URL: + Password: + + Web Search: + + +