From b0c975724510b2685fc08cee060da670361c93c9 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 23 Oct 2025 01:28:13 +0300 Subject: #4411 WIP add Web tab to legacy Search --- indra/newview/llpaneldirweb.cpp | 149 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 indra/newview/llpaneldirweb.cpp (limited to 'indra/newview/llpaneldirweb.cpp') diff --git a/indra/newview/llpaneldirweb.cpp b/indra/newview/llpaneldirweb.cpp new file mode 100644 index 0000000000..ec0635a407 --- /dev/null +++ b/indra/newview/llpaneldirweb.cpp @@ -0,0 +1,149 @@ +/** + * @file llpaneldirweb.cpp + * @brief Web panel in the legacy Search directory. + * + * $LicenseInfo:firstyear=2025&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2025, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llpaneldirweb.h" + +#include "llagent.h" +#include "llbutton.h" +#include "llfloaterdirectory.h" +#include "lltextbox.h" +#include "llviewercontrol.h" +#include "llweb.h" + +static LLPanelInjector t_panel_dir_web("panel_dir_web"); + +LLPanelDirWeb::LLPanelDirWeb() +: LLPanel(), + mFloaterDirectory(nullptr), + mWebBrowser(nullptr) +{ +} + +bool LLPanelDirWeb::postBuild() +{ + childSetAction("home_btn", onClickHome, this); + + mBtnBack = getChild("back_btn"); + mBtnForward = getChild("forward_btn"); + mStatusBarText = getChild("statusbartext"); + + mBtnBack->setClickedCallback([this](LLUICtrl*, const LLSD&) { mWebBrowser->navigateBack(); }); + mBtnForward->setClickedCallback([this](LLUICtrl*, const LLSD&) { mWebBrowser->navigateForward(); }); + + mWebBrowser = findChild("web_search"); + navigateToDefaultPage(); + mWebBrowser->addObserver(this); + + return true; +} + +void LLPanelDirWeb::draw() +{ + // Asynchronous so we need to keep checking + mBtnBack->setEnabled(mWebBrowser->canNavigateBack()); + mBtnForward->setEnabled(mWebBrowser->canNavigateForward()); + + LLPanel::draw(); +} + +LLPanelDirWeb::~LLPanelDirWeb() +{ +} + +// When we show any browser-based view, we want to hide all +// the right-side XUI detail panels. +// virtual +void LLPanelDirWeb::onVisibilityChange(bool new_visibility) +{ + if (new_visibility && mFloaterDirectory) + { + mFloaterDirectory->hideAllDetailPanels(); + } + LLPanel::onVisibilityChange(new_visibility); +} + +void LLPanelDirWeb::navigateToDefaultPage() +{ + std::string url = gSavedSettings.getString("SearchURL"); + + LLSD subs; + subs["QUERY"] = ""; + subs["TYPE"] = "standard"; + // Default to PG + std::string maturity = "g"; + if (gAgent.prefersAdult()) + { + // PG,Mature,Adult + maturity = "gma"; + } + else if (gAgent.prefersMature()) + { + // PG,Mature + maturity = "gm"; + } + subs["MATURITY"] = maturity; + + url = LLWeb::expandURLSubstitutions(url, subs); + mWebBrowser->navigateTo(url, HTTP_CONTENT_TEXT_HTML); +} + +// static +void LLPanelDirWeb::onClickHome( void* data ) +{ + LLPanelDirWeb* self = (LLPanelDirWeb*)data; + if (!self) + return; + self->navigateToDefaultPage(); +} + +void LLPanelDirWeb::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) +{ + if (event == MEDIA_EVENT_LOCATION_CHANGED) + { + const std::string url = self->getLocation(); + if (url.length()) + mStatusBarText->setText(url); + } + else if (event == MEDIA_EVENT_NAVIGATE_COMPLETE) + { + // we populate the status bar with URLs as they change so clear it now we're done + const std::string end_str = ""; + mStatusBarText->setText(end_str); + } + else if (event == MEDIA_EVENT_STATUS_TEXT_CHANGED) + { + const std::string text = self->getStatusText(); + if (text.length()) + mStatusBarText->setText(text); + } + else if (event == MEDIA_EVENT_LINK_HOVERED) + { + const std::string link = self->getHoverLink(); + mStatusBarText->setText(link); + } +} -- cgit v1.3 From 8bcbb33cf2bfed9ab929170aeedb7f6ea391b06f Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 27 Oct 2025 18:44:24 +0200 Subject: Fix indentation and trailing-whitespace --- indra/newview/llfloaterdirectory.h | 2 +- indra/newview/llpaneldirbrowser.cpp | 20 ++++++------- indra/newview/llpaneldirbrowser.h | 8 ++--- indra/newview/llpaneldirclassified.cpp | 2 +- indra/newview/llpaneldirland.cpp | 54 +++++++++++++++------------------- indra/newview/llpaneldirland.h | 46 +++++++++++++---------------- indra/newview/llpaneldirpeople.cpp | 6 ++-- indra/newview/llpaneldirplaces.cpp | 4 +-- indra/newview/llpaneldirweb.cpp | 1 - 9 files changed, 64 insertions(+), 79 deletions(-) (limited to 'indra/newview/llpaneldirweb.cpp') diff --git a/indra/newview/llfloaterdirectory.h b/indra/newview/llfloaterdirectory.h index c7dd243007..a5f39c895d 100644 --- a/indra/newview/llfloaterdirectory.h +++ b/indra/newview/llfloaterdirectory.h @@ -57,7 +57,7 @@ class LLPanelClassifiedInfo; // Floater to find people, places, things class LLFloaterDirectory : public LLFloater { -public: +public: LLFloaterDirectory(const std::string& name); /*virtual*/ ~LLFloaterDirectory(); diff --git a/indra/newview/llpaneldirbrowser.cpp b/indra/newview/llpaneldirbrowser.cpp index ff431c6034..5431a3af98 100644 --- a/indra/newview/llpaneldirbrowser.cpp +++ b/indra/newview/llpaneldirbrowser.cpp @@ -171,13 +171,13 @@ void LLPanelDirBrowser::updateResultCount() if (!mHaveSearchResults) result_count = 0; - if (mNextPageBtn && mNextPageBtn->getVisible()) + if (mNextPageBtn && mNextPageBtn->getVisible()) { // Item count be off by a few if bogus items sent from database // Just use the number of results per page. JC result_text = llformat(">%d found", mResultsPerPage); } - else + else { result_text = llformat("%d found", result_count); } @@ -203,17 +203,17 @@ void LLPanelDirBrowser::updateResultCount() std::string LLPanelDirBrowser::filterShortWords(const std::string source_string, int shortest_word_length, bool& was_filtered) { // degenerate case - if ( source_string.length() < 1 ) + if ( source_string.length() < 1 ) return ""; std::stringstream codec( source_string ); std::string each_word; std::vector< std::string > all_words; - + while( codec >> each_word ) all_words.push_back( each_word ); - std::ostringstream dest_string( "" ); + std::ostringstream dest_string( "" ); was_filtered = false; @@ -319,7 +319,6 @@ void LLPanelDirBrowser::onCommitList(LLUICtrl* ctrl, void* data) void LLPanelDirBrowser::showDetailPanel(S32 type, LLSD id) { - switch(type) { case AVATAR_CODE: @@ -371,7 +370,6 @@ void LLPanelDirBrowser::showDetailPanel(S32 type, LLSD id) } break; } - } @@ -399,7 +397,7 @@ void LLPanelDirBrowser::processDirPeopleReply(LLMessageSystem *msg, void**) msg->getUUIDFast(_PREHASH_QueryData,_PREHASH_QueryID, query_id); LLPanelDirBrowser* self = get_if_there(gDirBrowserInstances, query_id, (LLPanelDirBrowser*)NULL); - if (!self) + if (!self) { // data from an old query return; @@ -493,7 +491,7 @@ void LLPanelDirBrowser::processDirPlacesReply(LLMessageSystem* msg, void**) } LLPanelDirBrowser* self = get_if_there(gDirBrowserInstances, query_id, (LLPanelDirBrowser*)NULL); - if (!self) + if (!self) { // data from an old query return; @@ -877,7 +875,7 @@ void LLPanelDirBrowser::processDirLandReply(LLMessageSystem *msg, void**) msg->getUUID("QueryData", "QueryID", query_id ); LLPanelDirBrowser* browser = get_if_there(gDirBrowserInstances, query_id, (LLPanelDirBrowser*)NULL); - if (!browser) + if (!browser) { // data from an old query return; @@ -1149,7 +1147,7 @@ void LLPanelDirBrowser::onVisibilityChange(bool new_visibility) S32 LLPanelDirBrowser::showNextButton(S32 rows) { - // HACK: This hack doesn't work for llpaneldirfind (ALL) + // HACK: This hack doesn't work for llpaneldirfind (ALL) // because other data is being returned as well. if ( getName() != "find_all_old_panel") { diff --git a/indra/newview/llpaneldirbrowser.h b/indra/newview/llpaneldirbrowser.h index 8954f397e7..0e82f7e423 100644 --- a/indra/newview/llpaneldirbrowser.h +++ b/indra/newview/llpaneldirbrowser.h @@ -148,10 +148,10 @@ const S32 PLACE_CODE = 1; //const S32 OFFLINE_CODE = 3; const S32 AVATAR_CODE = 3; const S32 GROUP_CODE = 4; -const S32 CLASSIFIED_CODE = 5; -const S32 FOR_SALE_CODE = 6; // for sale place -const S32 AUCTION_CODE = 7; // for auction place -const S32 POPULAR_CODE = 8; // popular by dwell +const S32 CLASSIFIED_CODE = 5; +const S32 FOR_SALE_CODE = 6; // for sale place +const S32 AUCTION_CODE = 7; // for auction place +const S32 POPULAR_CODE = 8; // popular by dwell // mask values for search flags const S32 SEARCH_NONE = 0; // should try not to send this to the search engine diff --git a/indra/newview/llpaneldirclassified.cpp b/indra/newview/llpaneldirclassified.cpp index cedd91e1bd..f055e6f05a 100644 --- a/indra/newview/llpaneldirclassified.cpp +++ b/indra/newview/llpaneldirclassified.cpp @@ -96,7 +96,7 @@ void LLPanelDirClassified::performQuery() inc_mature && gAgent.canAccessMature(), inc_adult && gAgent.canAccessAdult()); U32 category = childGetValue("Category").asInteger(); - + msg->nextBlockFast(_PREHASH_QueryData); msg->addUUIDFast(_PREHASH_QueryID, mSearchID ); msg->addStringFast(_PREHASH_QueryText, childGetValue("name").asString()); diff --git a/indra/newview/llpaneldirland.cpp b/indra/newview/llpaneldirland.cpp index ae1dfae092..c4809fc2a6 100644 --- a/indra/newview/llpaneldirland.cpp +++ b/indra/newview/llpaneldirland.cpp @@ -1,32 +1,26 @@ -/** +/** * @file llpaneldirland.cpp - * @brief Land For Sale and Auction in the Find directory. + * @brief Land panel in the legacy Search directory. * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2025&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 - * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception - * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. - * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Copyright (C) 2025, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -122,7 +116,7 @@ void LLPanelDirLand::onClickSort() performQuery(); } -// static +// static void LLPanelDirLand::onCommitPrice(LLUICtrl* ctrl, void* data) { LLPanelDirLand* self = (LLPanelDirLand*)data; @@ -132,7 +126,7 @@ void LLPanelDirLand::onCommitPrice(LLUICtrl* ctrl, void* data) self->childSetEnabled("priceedit", check->get()); } -// static +// static void LLPanelDirLand::onCommitArea(LLUICtrl* ctrl, void* data) { LLPanelDirLand* self = (LLPanelDirLand*)data; @@ -187,7 +181,7 @@ void LLPanelDirLand::performQuery() { query_flags |= DFQ_INC_ADULT; } - + // Add old flags in case we are talking to an old dataserver if (inc_pg && !inc_mature) { @@ -196,7 +190,7 @@ void LLPanelDirLand::performQuery() if (!inc_pg && inc_mature) { - query_flags |= DFQ_MATURE_SIMS_ONLY; + query_flags |= DFQ_MATURE_SIMS_ONLY; } LLScrollListCtrl* list = getChild("results"); diff --git a/indra/newview/llpaneldirland.h b/indra/newview/llpaneldirland.h index 1d3168f19f..197c4cdc3d 100644 --- a/indra/newview/llpaneldirland.h +++ b/indra/newview/llpaneldirland.h @@ -1,32 +1,26 @@ -/** +/** * @file llpaneldirland.h - * @brief Land For Sale and Auction in the Find directory. + * @brief Land panel in the legacy Search directory. * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2025&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 - * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception - * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. - * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Copyright (C) 2025, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ diff --git a/indra/newview/llpaneldirpeople.cpp b/indra/newview/llpaneldirpeople.cpp index 75226f3a09..976b179fb8 100644 --- a/indra/newview/llpaneldirpeople.cpp +++ b/indra/newview/llpaneldirpeople.cpp @@ -72,9 +72,9 @@ void LLPanelDirPeople::performQuery() // The shortest username is 2 characters long. const S32 SHORTEST_WORD_LEN = 2; bool query_was_filtered = false; - std::string query_string = LLPanelDirBrowser::filterShortWords( - childGetValue("name").asString(), - SHORTEST_WORD_LEN, + std::string query_string = LLPanelDirBrowser::filterShortWords( + childGetValue("name").asString(), + SHORTEST_WORD_LEN, query_was_filtered ); // possible we threw away all the short words in the query so check length diff --git a/indra/newview/llpaneldirplaces.cpp b/indra/newview/llpaneldirplaces.cpp index 3f1fa2ab05..57d9d556b6 100644 --- a/indra/newview/llpaneldirplaces.cpp +++ b/indra/newview/llpaneldirplaces.cpp @@ -140,9 +140,9 @@ void LLPanelDirPlaces::performQuery() if (0x0 == flags) { LLNotificationsUtil::add("NoContentToSearch"); - return; + return; } - + queryCore(query_string, category, flags); } diff --git a/indra/newview/llpaneldirweb.cpp b/indra/newview/llpaneldirweb.cpp index ec0635a407..9e76bb81a6 100644 --- a/indra/newview/llpaneldirweb.cpp +++ b/indra/newview/llpaneldirweb.cpp @@ -107,7 +107,6 @@ void LLPanelDirWeb::navigateToDefaultPage() maturity = "gm"; } subs["MATURITY"] = maturity; - url = LLWeb::expandURLSubstitutions(url, subs); mWebBrowser->navigateTo(url, HTTP_CONTENT_TEXT_HTML); } -- cgit v1.3