From 03e2fda50400f1e71623484d5e6f12446f2c76b7 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sun, 18 Apr 2010 16:29:29 -0700 Subject: Ported slviewer-0-v12300-ReinstateOldSearchTabs.patch from the Hippo Viewer (opensim currently uses the old search all) --- linden/indra/newview/llfloaterdirectory.cpp | 13 +- linden/indra/newview/llfloaterdirectory.h | 3 +- linden/indra/newview/llpaneldirfind.cpp | 155 ++++++++++++++++++- linden/indra/newview/llpaneldirfind.h | 18 ++- linden/indra/newview/llpaneldirgroups.cpp | 122 +++++++++++---- linden/indra/newview/llpaneldirgroups.h | 14 +- .../skins/default/xui/en-us/floater_directory.xml | 167 +++++++++++++-------- 7 files changed, 386 insertions(+), 106 deletions(-) diff --git a/linden/indra/newview/llfloaterdirectory.cpp b/linden/indra/newview/llfloaterdirectory.cpp index 76cb26b..8018c31 100644 --- a/linden/indra/newview/llfloaterdirectory.cpp +++ b/linden/indra/newview/llfloaterdirectory.cpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2002&license=viewergpl$ * - * Copyright (c) 2002-2009, Linden Research, Inc. + * Copyright (c) 2002-2010, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab @@ -93,6 +93,7 @@ LLFloaterDirectory::LLFloaterDirectory(const std::string& name) // Build the floater with our tab panel classes LLCallbackMap::map_t factory_map; + factory_map["find_all_old_panel"] = LLCallbackMap(createFindAllOld, this); factory_map["find_all_panel"] = LLCallbackMap(createFindAll, this); factory_map["classified_panel"] = LLCallbackMap(createClassified, this); factory_map["events_panel"] = LLCallbackMap(createEvents, this); @@ -119,6 +120,7 @@ LLFloaterDirectory::LLFloaterDirectory(const std::string& name) mPanelAvatarp->selectTab(0); } + childSetTabChangeCallback("Directory Tabs", "find_all_old_panel", onTabChanged, this); childSetTabChangeCallback("Directory Tabs", "find_all_panel", onTabChanged, this); childSetTabChangeCallback("Directory Tabs", "classified_panel", onTabChanged, this); childSetTabChangeCallback("Directory Tabs", "events_panel", onTabChanged, this); @@ -206,7 +208,14 @@ void* LLFloaterDirectory::createPeople(void* userdata) void* LLFloaterDirectory::createGroups(void* userdata) { LLFloaterDirectory *self = (LLFloaterDirectory*)userdata; - return new LLPanelDirGroups("people_groups", self); + return new LLPanelDirGroups("groups_panel", self); +} + +// static +void *LLFloaterDirectory::createFindAllOld(void* userdata) +{ + LLFloaterDirectory *self = (LLFloaterDirectory*)userdata; + return new LLPanelDirFindAllOld("find_all_old_panel", self); } // static diff --git a/linden/indra/newview/llfloaterdirectory.h b/linden/indra/newview/llfloaterdirectory.h index d8f8399..dd6a5e9 100644 --- a/linden/indra/newview/llfloaterdirectory.h +++ b/linden/indra/newview/llfloaterdirectory.h @@ -106,7 +106,8 @@ private: static void* createLand(void* userdata); static void* createPeople(void* userdata); static void* createGroups(void* userdata); - + static void* createFindAllOld(void* userdata); + static void* createClassifiedDetail(void* userdata); static void* createAvatarDetail(void* userdata); static void* createEventDetail(void* userdata); diff --git a/linden/indra/newview/llpaneldirfind.cpp b/linden/indra/newview/llpaneldirfind.cpp index ee9aa69..cb83ee1 100644 --- a/linden/indra/newview/llpaneldirfind.cpp +++ b/linden/indra/newview/llpaneldirfind.cpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2001&license=viewergpl$ * - * Copyright (c) 2001-2009, Linden Research, Inc. + * Copyright (c) 2001-2010, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab @@ -72,6 +72,8 @@ #include "boost/lexical_cast.hpp" #endif +#include "hippoGridManager.h" + //--------------------------------------------------------------------------- // LLPanelDirFindAll - Google search appliance based search //--------------------------------------------------------------------------- @@ -248,7 +250,15 @@ void LLPanelDirFind::focus() void LLPanelDirFind::navigateToDefaultPage() { - std::string start_url = getString("default_search_page"); + 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() + "&"; + }*/ + BOOL inc_pg = childGetValue("incpg").asBoolean(); BOOL inc_mature = childGetValue("incmature").asBoolean(); BOOL inc_adult = childGetValue("incadult").asBoolean(); @@ -272,9 +282,10 @@ void LLPanelDirFind::navigateToDefaultPage() std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const std::string& collection, bool inc_pg, bool inc_mature, bool inc_adult) { - std::string url = gSavedSettings.getString("SearchURLDefault"); - if (!search_text.empty()) - { + std::string url; + if (search_text.empty()) { + url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_EMPTY); + } 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 @@ -296,7 +307,7 @@ std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const "-._~$+!*'()"; std::string query = LLURI::escape(search_text_with_plus, allowed); - url = gSavedSettings.getString("SearchURLQuery"); + url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_QUERY); std::string substring = "[QUERY]"; std::string::size_type where = url.find(substring); if (where != std::string::npos) @@ -321,7 +332,7 @@ std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const // static std::string LLPanelDirFind::getSearchURLSuffix(bool inc_pg, bool inc_mature, bool inc_adult) { - std::string url = gSavedSettings.getString("SearchURLSuffix2"); + 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 @@ -469,3 +480,133 @@ void LLPanelDirFindAllInterface::focus(LLPanelDirFindAll* panel) panel->focus(); } +//--------------------------------------------------------------------------- +// LLPanelDirFindAllOld - deprecated if new Google search works out. JC +//--------------------------------------------------------------------------- + +LLPanelDirFindAllOld::LLPanelDirFindAllOld(const std::string& name, LLFloaterDirectory* floater) + : LLPanelDirBrowser(name, floater) +{ + mMinSearchChars = 3; +} + +BOOL LLPanelDirFindAllOld::postBuild() +{ + LLPanelDirBrowser::postBuild(); + + childSetKeystrokeCallback("name", &LLPanelDirBrowser::onKeystrokeName, this); + + childSetAction("Search", onClickSearch, this); + childDisable("Search"); + setDefaultBtn( "Search" ); + + return TRUE; +} + +LLPanelDirFindAllOld::~LLPanelDirFindAllOld() +{ + // Children all cleaned up by default view destructor. +} + +// virtual +void LLPanelDirFindAllOld::draw() +{ + updateMaturityCheckbox(); + LLPanelDirBrowser::draw(); +} + +// static +void LLPanelDirFindAllOld::onCommitScope(LLUICtrl* ctrl, void* data) +{ + LLPanelDirFindAllOld* self = (LLPanelDirFindAllOld*)data; + self->setFocus(TRUE); +} + +// static +void LLPanelDirFindAllOld::onClickSearch(void *userdata) +{ + LLPanelDirFindAllOld *self = (LLPanelDirFindAllOld *)userdata; + + if (self->childGetValue("name").asString().length() < self->mMinSearchChars) + { + return; + }; + + BOOL inc_pg = self->childGetValue("incpg").asBoolean(); + BOOL inc_mature = self->childGetValue("incmature").asBoolean(); + BOOL inc_adult = self->childGetValue("incadult").asBoolean(); + if (!(inc_pg || inc_mature || inc_adult)) + { + LLNotifications::instance().add("NoContentToSearch"); + return; + } + + self->setupNewSearch(); + + // Figure out scope + U32 scope = 0x0; + scope |= DFQ_PEOPLE; // people (not just online = 0x01 | 0x02) + // places handled below + scope |= DFQ_EVENTS; // events + scope |= DFQ_GROUPS; // groups + if (inc_pg) + { + scope |= DFQ_INC_PG; + } + if (inc_mature) + { + scope |= DFQ_INC_MATURE; + } + if (inc_adult) + { + scope |= DFQ_INC_ADULT; + } + + // send the message + LLMessageSystem *msg = gMessageSystem; + S32 start_row = 0; + sendDirFindQuery(msg, self->mSearchID, self->childGetValue("name").asString(), scope, start_row); + + // Also look up classified ads. JC 12/2005 + BOOL filter_auto_renew = FALSE; + U32 classified_flags = pack_classified_flags_request(filter_auto_renew, inc_pg, inc_mature, inc_adult); + msg->newMessage("DirClassifiedQuery"); + msg->nextBlock("AgentData"); + msg->addUUID("AgentID", gAgent.getID()); + msg->addUUID("SessionID", gAgent.getSessionID()); + msg->nextBlock("QueryData"); + msg->addUUID("QueryID", self->mSearchID); + msg->addString("QueryText", self->childGetValue("name").asString()); + msg->addU32("QueryFlags", classified_flags); + msg->addU32("Category", 0); // all categories + msg->addS32("QueryStart", 0); + gAgent.sendReliableMessage(); + + // Need to use separate find places query because places are + // sent using the more compact DirPlacesReply message. + U32 query_flags = DFQ_DWELL_SORT; + if (inc_pg) + { + query_flags |= DFQ_INC_PG; + } + if (inc_mature) + { + query_flags |= DFQ_INC_MATURE; + } + if (inc_adult) + { + query_flags |= DFQ_INC_ADULT; + } + msg->newMessage("DirPlacesQuery"); + msg->nextBlock("AgentData"); + msg->addUUID("AgentID", gAgent.getID() ); + msg->addUUID("SessionID", gAgent.getSessionID()); + msg->nextBlock("QueryData"); + msg->addUUID("QueryID", self->mSearchID ); + msg->addString("QueryText", self->childGetValue("name").asString()); + msg->addU32("QueryFlags", query_flags ); + msg->addS32("QueryStart", 0 ); // Always get the first 100 when using find ALL + msg->addS8("Category", LLParcel::C_ANY); + msg->addString("SimName", NULL); + gAgent.sendReliableMessage(); +} diff --git a/linden/indra/newview/llpaneldirfind.h b/linden/indra/newview/llpaneldirfind.h index a813d33..299060c 100644 --- a/linden/indra/newview/llpaneldirfind.h +++ b/linden/indra/newview/llpaneldirfind.h @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2001&license=viewergpl$ * - * Copyright (c) 2001-2009, Linden Research, Inc. + * Copyright (c) 2001-2010, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab @@ -93,4 +93,20 @@ public: static void focus(LLPanelDirFindAll* panel); }; + +class LLPanelDirFindAllOld : public LLPanelDirBrowser +{ +public: + LLPanelDirFindAllOld(const std::string& name, LLFloaterDirectory* floater); + /*virtual*/ ~LLPanelDirFindAllOld(); + + /*virtual*/ BOOL postBuild(); + + /*virtual*/ void draw(); + + static void onClickSearch(void *userdata); + static void onCommitScope(LLUICtrl* ctrl, void* data); + static void onKeystrokeName(LLLineEditor* line, void* data); +}; + #endif diff --git a/linden/indra/newview/llpaneldirgroups.cpp b/linden/indra/newview/llpaneldirgroups.cpp index e775952..1aa2e86 100644 --- a/linden/indra/newview/llpaneldirgroups.cpp +++ b/linden/indra/newview/llpaneldirgroups.cpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2001&license=viewergpl$ * - * Copyright (c) 2001-2009, Linden Research, Inc. + * Copyright (c) 2001-2010, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab @@ -33,47 +33,111 @@ #include "llviewerprecompiledheaders.h" #include "llpaneldirgroups.h" -#include "llnotifications.h" -#include "llwebbrowserctrl.h" +// linden library includes +#include "llagent.h" +//#include "llfontgl.h" +#include "message.h" +#include "llqueryflags.h" +#include "llviewercontrol.h" +#include "llviewerwindow.h" LLPanelDirGroups::LLPanelDirGroups(const std::string& name, LLFloaterDirectory* floater) - : LLPanelDirFind(name, floater, "groups_browser") + : LLPanelDirBrowser(name, floater) { + mMinSearchChars = 3; } -void LLPanelDirGroups::search(const std::string& search_text) +BOOL LLPanelDirGroups::postBuild() { - if (!search_text.empty()) - { - 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)) - { - LLNotifications::instance().add("NoContentToSearch"); - return; - } - - std::string selected_collection = "Groups"; - std::string url = buildSearchURL(search_text, selected_collection, inc_pg, inc_mature, inc_adult); - if (mWebBrowser) - { - mWebBrowser->navigateTo(url); - } - } - else - { - // empty search text - navigateToDefaultPage(); - } + LLPanelDirBrowser::postBuild(); + + childSetKeystrokeCallback("name", &LLPanelDirBrowser::onKeystrokeName, this); - childSetText("search_editor", search_text); + childSetAction("Search", &LLPanelDirBrowser::onClickSearchCore, this); + childDisable("Search"); + setDefaultBtn( "Search" ); + + return TRUE; +} + +LLPanelDirGroups::~LLPanelDirGroups() +{ + // Children all cleaned up by default view destructor. } +// virtual void LLPanelDirGroups::draw() { updateMaturityCheckbox(); LLPanelDirBrowser::draw(); } + + +// virtual +void LLPanelDirGroups::performQuery() +{ + std::string group_name = childGetValue("name").asString(); + if (group_name.length() < mMinSearchChars) + { + return; + } + + // "hi " is three chars but not a long-enough search + std::string query_string = group_name; + LLStringUtil::trim( query_string ); + bool query_was_filtered = (query_string != group_name); + + // possible we threw away all the short words in the query so check length + if ( query_string.length() < mMinSearchChars ) + { + LLNotifications::instance().add("SeachFilteredOnShortWordsEmpty"); + return; + }; + + 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)) + { + LLNotifications::instance().add("NoContentToSearch"); + return; + } + + // if we filtered something out, display a popup + if ( query_was_filtered ) + { + LLSD args; + args["[FINALQUERY]"] = query_string; + LLNotifications::instance().add("SeachFilteredOnShortWords", args); + }; + + setupNewSearch(); + + // groups + U32 scope = DFQ_GROUPS; + if (inc_pg) + { + scope |= DFQ_INC_PG; + } + if (inc_mature) + { + scope |= DFQ_INC_MATURE; + } + if (inc_adult) + { + scope |= DFQ_INC_ADULT; + } + + mCurrentSortColumn = "score"; + mCurrentSortAscending = FALSE; + + // send the message + sendDirFindQuery( + gMessageSystem, + mSearchID, + query_string, + scope, + mSearchStart); +} diff --git a/linden/indra/newview/llpaneldirgroups.h b/linden/indra/newview/llpaneldirgroups.h index d1248c0..5edb34d 100644 --- a/linden/indra/newview/llpaneldirgroups.h +++ b/linden/indra/newview/llpaneldirgroups.h @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2001&license=viewergpl$ * - * Copyright (c) 2001-2009, Linden Research, Inc. + * Copyright (c) 2001-2010, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab @@ -33,15 +33,21 @@ #ifndef LLPANELDIRGROUPS_H #define LLPANELDIRGROUPS_H -#include "llpaneldirfind.h" +#include "llpaneldirbrowser.h" -class LLPanelDirGroups : public LLPanelDirFind +class LLPanelDirGroups : public LLPanelDirBrowser { public: LLPanelDirGroups(const std::string& name, LLFloaterDirectory* floater); + virtual ~LLPanelDirGroups(); - /*virtual*/ void search(const std::string& search_text); /*virtual*/ void draw(); + + /*virtual*/ BOOL postBuild(); + + /*virtual*/ void performQuery(); + + static void onClickSearch(void *userdata); }; #endif 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 a600c86..039c4f8 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 @@ -1,12 +1,70 @@ + label="All" left="1" mouse_opaque="false" name="find_all_old_panel" width="778"> + + Searching... + + + None Found. + +