Annotation of /trunk/indra/newview/llpaneldirfind.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llpaneldirfind.cpp | ||
| 3 : | * @brief The "All" panel in the Search directory. | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 137 | * Copyright (c) 2001-2010, Linden Research, Inc. |
| 8 : | mjm | 135 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | #include "llviewerprecompiledheaders.h" | ||
| 34 : | |||
| 35 : | #include "llpaneldirfind.h" | ||
| 36 : | |||
| 37 : | // linden library includes | ||
| 38 : | #include "llclassifiedflags.h" | ||
| 39 : | #include "llfontgl.h" | ||
| 40 : | #include "llparcel.h" | ||
| 41 : | #include "llqueryflags.h" | ||
| 42 : | #include "message.h" | ||
| 43 : | |||
| 44 : | // viewer project includes | ||
| 45 : | #include "llagent.h" | ||
| 46 : | #include "llbutton.h" | ||
| 47 : | #include "llcheckboxctrl.h" | ||
| 48 : | #include "lllineeditor.h" | ||
| 49 : | #include "llcombobox.h" | ||
| 50 : | #include "llviewercontrol.h" | ||
| 51 : | #include "llmenucommands.h" | ||
| 52 : | #include "llmenugl.h" | ||
| 53 : | #include "lltextbox.h" | ||
| 54 : | #include "lluiconstants.h" | ||
| 55 : | #include "llviewerimagelist.h" | ||
| 56 : | #include "llviewermessage.h" | ||
| 57 : | #include "llfloateravatarinfo.h" | ||
| 58 : | #include "lldir.h" | ||
| 59 : | #include "llviewercontrol.h" | ||
| 60 : | #include "llviewerregion.h" | ||
| 61 : | #include "lluictrlfactory.h" | ||
| 62 : | #include "llfloaterdirectory.h" | ||
| 63 : | #include "llpaneldirbrowser.h" | ||
| 64 : | |||
| 65 : | #include <boost/tokenizer.hpp> | ||
| 66 : | #include <boost/lexical_cast.hpp> | ||
| 67 : | |||
| 68 : | #include <hippoGridManager.h> | ||
| 69 : | |||
| 70 : | //--------------------------------------------------------------------------- | ||
| 71 : | // LLPanelDirFindAll - Google search appliance based search | ||
| 72 : | //--------------------------------------------------------------------------- | ||
| 73 : | |||
| 74 : | class LLPanelDirFindAll | ||
| 75 : | : public LLPanelDirFind | ||
| 76 : | { | ||
| 77 : | public: | ||
| 78 : | LLPanelDirFindAll(const std::string& name, LLFloaterDirectory* floater); | ||
| 79 : | |||
| 80 : | /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent); | ||
| 81 : | /*virtual*/ void search(const std::string& search_text); | ||
| 82 : | }; | ||
| 83 : | |||
| 84 : | LLPanelDirFindAll::LLPanelDirFindAll(const std::string& name, LLFloaterDirectory* floater) | ||
| 85 : | : LLPanelDirFind(name, floater, "find_browser") | ||
| 86 : | { | ||
| 87 : | } | ||
| 88 : | |||
| 89 : | //--------------------------------------------------------------------------- | ||
| 90 : | // LLPanelDirFind - Base class for all browser-based search tabs | ||
| 91 : | //--------------------------------------------------------------------------- | ||
| 92 : | |||
| 93 : | LLPanelDirFind::LLPanelDirFind(const std::string& name, LLFloaterDirectory* floater, const std::string& browser_name) | ||
| 94 : | : LLPanelDirBrowser(name, floater), | ||
| 95 : | mWebBrowser(NULL), | ||
| 96 : | mBrowserName(browser_name) | ||
| 97 : | { | ||
| 98 : | } | ||
| 99 : | |||
| 100 : | BOOL LLPanelDirFind::postBuild() | ||
| 101 : | { | ||
| 102 : | LLPanelDirBrowser::postBuild(); | ||
| 103 : | |||
| 104 : | childSetAction("back_btn", onClickBack, this); | ||
| 105 : | childSetAction("home_btn", onClickHome, this); | ||
| 106 : | childSetAction("forward_btn", onClickForward, this); | ||
| 107 : | childSetCommitCallback("search_editor", onCommitSearch, this); | ||
| 108 : | childSetAction("search_btn", onClickSearch, this); | ||
| 109 : | childSetAction("?", onClickHelp, this); | ||
| 110 : | |||
| 111 : | // showcase doesn't have maturity flags -- it's all PG | ||
| 112 : | if (hasChild("incmature")) | ||
| 113 : | { | ||
| 114 : | // Teens don't get mature checkbox | ||
| 115 : | if (gAgent.wantsPGOnly()) | ||
| 116 : | { | ||
| 117 : | childSetValue("incmature", FALSE); | ||
| 118 : | childSetValue("incadult", FALSE); | ||
| 119 : | childHide("incmature"); | ||
| 120 : | childHide("incadult"); | ||
| 121 : | childSetValue("incpg", TRUE); | ||
| 122 : | childDisable("incpg"); | ||
| 123 : | } | ||
| 124 : | |||
| 125 : | if (!gAgent.canAccessMature()) | ||
| 126 : | { | ||
| 127 : | childSetValue("incmature", FALSE); | ||
| 128 : | childDisable("incmature"); | ||
| 129 : | } | ||
| 130 : | |||
| 131 : | if (!gAgent.canAccessAdult()) | ||
| 132 : | { | ||
| 133 : | childSetValue("incadult", FALSE); | ||
| 134 : | childDisable("incadult"); | ||
| 135 : | } | ||
| 136 : | } | ||
| 137 : | |||
| 138 : | |||
| 139 : | mWebBrowser = getChild<LLWebBrowserCtrl>(mBrowserName); | ||
| 140 : | if (mWebBrowser) | ||
| 141 : | { | ||
| 142 : | // new pages appear in same window as the results page now | ||
| 143 : | mWebBrowser->setOpenInInternalBrowser( false ); | ||
| 144 : | mWebBrowser->setOpenInExternalBrowser( false ); | ||
| 145 : | |||
| 146 : | // need to handle secondlife:///app/ URLs for direct teleports | ||
| 147 : | mWebBrowser->setTrusted( true ); | ||
| 148 : | |||
| 149 : | // redirect 404 pages from S3 somewhere else | ||
| 150 : | mWebBrowser->set404RedirectUrl( getString("redirect_404_url") ); | ||
| 151 : | |||
| 152 : | // Track updates for progress display. | ||
| 153 : | mWebBrowser->addObserver(this); | ||
| 154 : | |||
| 155 : | navigateToDefaultPage(); | ||
| 156 : | } | ||
| 157 : | |||
| 158 : | return TRUE; | ||
| 159 : | } | ||
| 160 : | |||
| 161 : | LLPanelDirFind::~LLPanelDirFind() | ||
| 162 : | { | ||
| 163 : | if (mWebBrowser) | ||
| 164 : | mWebBrowser->remObserver(this); | ||
| 165 : | } | ||
| 166 : | |||
| 167 : | // virtual | ||
| 168 : | void LLPanelDirFind::draw() | ||
| 169 : | { | ||
| 170 : | // enable/disable buttons depending on state | ||
| 171 : | if ( mWebBrowser ) | ||
| 172 : | { | ||
| 173 : | bool enable_back = mWebBrowser->canNavigateBack(); | ||
| 174 : | childSetEnabled( "back_btn", enable_back ); | ||
| 175 : | |||
| 176 : | bool enable_forward = mWebBrowser->canNavigateForward(); | ||
| 177 : | childSetEnabled( "forward_btn", enable_forward ); | ||
| 178 : | } | ||
| 179 : | |||
| 180 : | // showcase doesn't have maturity flags -- it's all PG | ||
| 181 : | if (hasChild("incmature")) | ||
| 182 : | { | ||
| 183 : | updateMaturityCheckbox(); | ||
| 184 : | } | ||
| 185 : | |||
| 186 : | LLPanelDirBrowser::draw(); | ||
| 187 : | } | ||
| 188 : | |||
| 189 : | // When we show any browser-based view, we want to hide all | ||
| 190 : | // the right-side XUI detail panels. | ||
| 191 : | // virtual | ||
| 192 : | void LLPanelDirFind::onVisibilityChange(BOOL new_visibility) | ||
| 193 : | { | ||
| 194 : | if (new_visibility) | ||
| 195 : | { | ||
| 196 : | mFloaterDirectory->hideAllDetailPanels(); | ||
| 197 : | } | ||
| 198 : | LLPanel::onVisibilityChange(new_visibility); | ||
| 199 : | } | ||
| 200 : | |||
| 201 : | // virtual | ||
| 202 : | void LLPanelDirFindAll::reshape(S32 width, S32 height, BOOL called_from_parent = TRUE) | ||
| 203 : | { | ||
| 204 : | if ( mWebBrowser ) | ||
| 205 : | mWebBrowser->navigateTo( mWebBrowser->getCurrentNavUrl() ); | ||
| 206 : | |||
| 207 : | LLUICtrl::reshape( width, height, called_from_parent ); | ||
| 208 : | } | ||
| 209 : | |||
| 210 : | void LLPanelDirFindAll::search(const std::string& search_text) | ||
| 211 : | { | ||
| 212 : | BOOL inc_pg = childGetValue("incpg").asBoolean(); | ||
| 213 : | BOOL inc_mature = childGetValue("incmature").asBoolean(); | ||
| 214 : | BOOL inc_adult = childGetValue("incadult").asBoolean(); | ||
| 215 : | if (!(inc_pg || inc_mature || inc_adult)) | ||
| 216 : | { | ||
| 217 : | LLNotifications::instance().add("NoContentToSearch"); | ||
| 218 : | return; | ||
| 219 : | } | ||
| 220 : | |||
| 221 : | if (!search_text.empty()) | ||
| 222 : | { | ||
| 223 : | std::string selected_collection = childGetValue( "Category" ).asString(); | ||
| 224 : | std::string url = buildSearchURL(search_text, selected_collection, inc_pg, inc_mature, inc_adult); | ||
| 225 : | if (mWebBrowser) | ||
| 226 : | { | ||
| 227 : | mWebBrowser->navigateTo(url); | ||
| 228 : | } | ||
| 229 : | } | ||
| 230 : | else | ||
| 231 : | { | ||
| 232 : | // empty search text | ||
| 233 : | navigateToDefaultPage(); | ||
| 234 : | } | ||
| 235 : | |||
| 236 : | childSetText("search_editor", search_text); | ||
| 237 : | } | ||
| 238 : | |||
| 239 : | void LLPanelDirFind::focus() | ||
| 240 : | { | ||
| 241 : | childSetFocus("search_editor"); | ||
| 242 : | } | ||
| 243 : | |||
| 244 : | void LLPanelDirFind::navigateToDefaultPage() | ||
| 245 : | { | ||
| 246 : | std::string start_url; | ||
| 247 : | if (gHippoGridManager->getConnectedGrid()->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) { | ||
| 248 : | start_url = getString("default_search_page"); | ||
| 249 : | } else { | ||
| 250 : | start_url = gHippoGridManager->getConnectedGrid()->getSearchUrl(); | ||
| 251 : | start_url += "panel=" + getLabel() + "&"; | ||
| 252 : | } | ||
| 253 : | |||
| 254 : | BOOL inc_pg = childGetValue("incpg").asBoolean(); | ||
| 255 : | BOOL inc_mature = childGetValue("incmature").asBoolean(); | ||
| 256 : | BOOL inc_adult = childGetValue("incadult").asBoolean(); | ||
| 257 : | if (!(inc_pg || inc_mature || inc_adult)) | ||
| 258 : | { | ||
| 259 : | // if nothing's checked, just go for pg; we don't notify in | ||
| 260 : | // this case because it's a default page. | ||
| 261 : | inc_pg = true; | ||
| 262 : | } | ||
| 263 : | |||
| 264 : | start_url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult); | ||
| 265 : | //MK | ||
| 266 : | if (!gRRenabled || !gAgent.mRRInterface.mContainsShowloc) | ||
| 267 : | { | ||
| 268 : | llinfos << "default url: " << start_url << llendl; | ||
| 269 : | } | ||
| 270 : | //mk | ||
| 271 : | if (mWebBrowser) | ||
| 272 : | { | ||
| 273 : | mWebBrowser->navigateTo( start_url ); | ||
| 274 : | } | ||
| 275 : | } | ||
| 276 : | // static | ||
| 277 : | std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const std::string& collection, | ||
| 278 : | bool inc_pg, bool inc_mature, bool inc_adult) | ||
| 279 : | { | ||
| 280 : | std::string url; | ||
| 281 : | if (search_text.empty()) { | ||
| 282 : | url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_EMPTY); | ||
| 283 : | } else { | ||
| 284 : | // Replace spaces with "+" for use by Google search appliance | ||
| 285 : | // Yes, this actually works for double-spaces | ||
| 286 : | // " foo bar" becomes "+foo++bar" and works fine. JC | ||
| 287 : | std::string search_text_with_plus = search_text; | ||
| 288 : | std::string::iterator it = search_text_with_plus.begin(); | ||
| 289 : | for ( ; it != search_text_with_plus.end(); ++it ) | ||
| 290 : | { | ||
| 291 : | if ( std::isspace( *it ) ) | ||
| 292 : | { | ||
| 293 : | *it = '+'; | ||
| 294 : | } | ||
| 295 : | } | ||
| 296 : | |||
| 297 : | // Our own special set of allowed chars (RFC1738 http://www.ietf.org/rfc/rfc1738.txt) | ||
| 298 : | // Note that "+" is one of them, so we can do "+" addition first. | ||
| 299 : | const char* allowed = | ||
| 300 : | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | ||
| 301 : | "0123456789" | ||
| 302 : | "-._~$+!*'()"; | ||
| 303 : | std::string query = LLURI::escape(search_text_with_plus, allowed); | ||
| 304 : | |||
| 305 : | url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_QUERY); | ||
| 306 : | std::string substring = "[QUERY]"; | ||
| 307 : | std::string::size_type where = url.find(substring); | ||
| 308 : | if (where != std::string::npos) | ||
| 309 : | { | ||
| 310 : | url.replace(where, substring.length(), query); | ||
| 311 : | } | ||
| 312 : | |||
| 313 : | // replace the collection name with the one selected from the combo box | ||
| 314 : | // std::string selected_collection = childGetValue( "Category" ).asString(); | ||
| 315 : | substring = "[COLLECTION]"; | ||
| 316 : | where = url.find(substring); | ||
| 317 : | if (where != std::string::npos) | ||
| 318 : | { | ||
| 319 : | url.replace(where, substring.length(), collection); | ||
| 320 : | } | ||
| 321 : | |||
| 322 : | } | ||
| 323 : | url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult); | ||
| 324 : | //MK | ||
| 325 : | if (!gRRenabled || !gAgent.mRRInterface.mContainsShowloc) | ||
| 326 : | { | ||
| 327 : | llinfos << "search url " << url << llendl; | ||
| 328 : | } | ||
| 329 : | //mk | ||
| 330 : | return url; | ||
| 331 : | } | ||
| 332 : | // static | ||
| 333 : | std::string LLPanelDirFind::getSearchURLSuffix(bool inc_pg, bool inc_mature, bool inc_adult) | ||
| 334 : | { | ||
| 335 : | std::string url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_TEMPLATE); | ||
| 336 : | |||
| 337 : | // if the mature checkbox is unchecked, modify query to remove | ||
| 338 : | // terms with given phrase from the result set | ||
| 339 : | // This builds a value from 1-7 by or-ing together the flags, and then converts | ||
| 340 : | // it to a string. | ||
| 341 : | std::string substring="[MATURITY]"; | ||
| 342 : | S32 maturityFlag = | ||
| 343 : | (inc_pg ? SEARCH_PG : SEARCH_NONE) | | ||
| 344 : | (inc_mature ? SEARCH_MATURE : SEARCH_NONE) | | ||
| 345 : | (inc_adult ? SEARCH_ADULT : SEARCH_NONE); | ||
| 346 : | url.replace(url.find(substring), substring.length(), boost::lexical_cast<std::string>(maturityFlag)); | ||
| 347 : | |||
| 348 : | // Include region and x/y position, not for the GSA, but | ||
| 349 : | // just to get logs on the web server for search_proxy.php | ||
| 350 : | // showing where people were standing when they searched. | ||
| 351 : | std::string region_name; | ||
| 352 : | LLViewerRegion* region = gAgent.getRegion(); | ||
| 353 : | if (region) | ||
| 354 : | { | ||
| 355 : | region_name = region->getName(); | ||
| 356 : | } | ||
| 357 : | // take care of spaces in names | ||
| 358 : | region_name = LLURI::escape(region_name); | ||
| 359 : | substring = "[REGION]"; | ||
| 360 : | url.replace(url.find(substring), substring.length(), region_name); | ||
| 361 : | |||
| 362 : | LLVector3 pos_region = gAgent.getPositionAgent(); | ||
| 363 : | |||
| 364 : | std::string x = llformat("%.0f", pos_region.mV[VX]); | ||
| 365 : | substring = "[X]"; | ||
| 366 : | url.replace(url.find(substring), substring.length(), x); | ||
| 367 : | std::string y = llformat("%.0f", pos_region.mV[VY]); | ||
| 368 : | substring = "[Y]"; | ||
| 369 : | url.replace(url.find(substring), substring.length(), y); | ||
| 370 : | std::string z = llformat("%.0f", pos_region.mV[VZ]); | ||
| 371 : | substring = "[Z]"; | ||
| 372 : | url.replace(url.find(substring), substring.length(), z); | ||
| 373 : | |||
| 374 : | LLUUID session_id = gAgent.getSessionID(); | ||
| 375 : | std::string session_string = session_id.getString(); | ||
| 376 : | substring = "[SESSION]"; | ||
| 377 : | url.replace(url.find(substring), substring.length(), session_string); | ||
| 378 : | |||
| 379 : | // set the currently selected language by asking the pref setting | ||
| 380 : | std::string language_string = LLUI::getLanguage(); | ||
| 381 : | std::string language_tag = "[LANG]"; | ||
| 382 : | url.replace( url.find( language_tag ), language_tag.length(), language_string ); | ||
| 383 : | |||
| 384 : | // and set the flag for the teen grid | ||
| 385 : | std::string teen_string = gAgent.isTeen() ? "y" : "n"; | ||
| 386 : | std::string teen_tag = "[TEEN]"; | ||
| 387 : | url.replace( url.find( teen_tag ), teen_tag.length(), teen_string ); | ||
| 388 : | |||
| 389 : | return url; | ||
| 390 : | } | ||
| 391 : | |||
| 392 : | |||
| 393 : | // static | ||
| 394 : | void LLPanelDirFind::onClickBack( void* data ) | ||
| 395 : | { | ||
| 396 : | LLPanelDirFind* self = ( LLPanelDirFind* )data; | ||
| 397 : | if ( self->mWebBrowser ) | ||
| 398 : | { | ||
| 399 : | self->mWebBrowser->navigateBack(); | ||
| 400 : | } | ||
| 401 : | } | ||
| 402 : | |||
| 403 : | // static | ||
| 404 : | void LLPanelDirFind::onClickHelp( void* data ) | ||
| 405 : | { | ||
| 406 : | LLNotifications::instance().add("ClickSearchHelpAll"); | ||
| 407 : | } | ||
| 408 : | |||
| 409 : | // static | ||
| 410 : | void LLPanelDirFind::onClickForward( void* data ) | ||
| 411 : | { | ||
| 412 : | LLPanelDirFind* self = ( LLPanelDirFind* )data; | ||
| 413 : | if ( self->mWebBrowser ) | ||
| 414 : | { | ||
| 415 : | self->mWebBrowser->navigateForward(); | ||
| 416 : | } | ||
| 417 : | } | ||
| 418 : | |||
| 419 : | // static | ||
| 420 : | void LLPanelDirFind::onClickHome( void* data ) | ||
| 421 : | { | ||
| 422 : | LLPanelDirFind* self = ( LLPanelDirFind* )data; | ||
| 423 : | if ( self->mWebBrowser ) | ||
| 424 : | { | ||
| 425 : | self->mWebBrowser->navigateHome(); | ||
| 426 : | } | ||
| 427 : | } | ||
| 428 : | |||
| 429 : | // static | ||
| 430 : | void LLPanelDirFind::onCommitSearch(LLUICtrl*, void* data) | ||
| 431 : | { | ||
| 432 : | onClickSearch(data); | ||
| 433 : | } | ||
| 434 : | |||
| 435 : | // static | ||
| 436 : | void LLPanelDirFind::onClickSearch(void* data) | ||
| 437 : | { | ||
| 438 : | LLPanelDirFind* self = ( LLPanelDirFind* )data; | ||
| 439 : | std::string search_text = self->childGetText("search_editor"); | ||
| 440 : | self->search(search_text); | ||
| 441 : | |||
| 442 : | LLFloaterDirectory::sNewSearchCount++; | ||
| 443 : | } | ||
| 444 : | |||
| 445 : | void LLPanelDirFind::onNavigateBegin( const EventType& eventIn ) | ||
| 446 : | { | ||
| 447 : | childSetText("status_text", getString("loading_text")); | ||
| 448 : | } | ||
| 449 : | |||
| 450 : | void LLPanelDirFind::onNavigateComplete( const EventType& eventIn ) | ||
| 451 : | { | ||
| 452 : | childSetText("status_text", getString("done_text")); | ||
| 453 : | } | ||
| 454 : | |||
| 455 : | void LLPanelDirFind::onLocationChange( const EventType& eventIn ) | ||
| 456 : | { | ||
| 457 : | if (!gRRenabled || !gAgent.mRRInterface.mContainsShowloc) | ||
| 458 : | { | ||
| 459 : | llinfos << eventIn.getStringValue() << llendl; | ||
| 460 : | } | ||
| 461 : | } | ||
| 462 : | |||
| 463 : | //--------------------------------------------------------------------------- | ||
| 464 : | // LLPanelDirFindAllInterface | ||
| 465 : | //--------------------------------------------------------------------------- | ||
| 466 : | |||
| 467 : | // static | ||
| 468 : | LLPanelDirFindAll* LLPanelDirFindAllInterface::create(LLFloaterDirectory* floater) | ||
| 469 : | { | ||
| 470 : | return new LLPanelDirFindAll("find_all_panel", floater); | ||
| 471 : | } | ||
| 472 : | |||
| 473 : | // static | ||
| 474 : | void LLPanelDirFindAllInterface::search(LLPanelDirFindAll* panel, | ||
| 475 : | const std::string& search_text) | ||
| 476 : | { | ||
| 477 : | panel->search(search_text); | ||
| 478 : | } | ||
| 479 : | |||
| 480 : | // static | ||
| 481 : | void LLPanelDirFindAllInterface::focus(LLPanelDirFindAll* panel) | ||
| 482 : | { | ||
| 483 : | panel->focus(); | ||
| 484 : | } | ||
| 485 : | |||
| 486 : | //--------------------------------------------------------------------------- | ||
| 487 : | // LLPanelDirFindAllOld - deprecated if new Google search works out. JC | ||
| 488 : | //--------------------------------------------------------------------------- | ||
| 489 : | |||
| 490 : | LLPanelDirFindAllOld::LLPanelDirFindAllOld(const std::string& name, LLFloaterDirectory* floater) | ||
| 491 : | : LLPanelDirBrowser(name, floater) | ||
| 492 : | { | ||
| 493 : | mMinSearchChars = 3; | ||
| 494 : | } | ||
| 495 : | |||
| 496 : | BOOL LLPanelDirFindAllOld::postBuild() | ||
| 497 : | { | ||
| 498 : | LLPanelDirBrowser::postBuild(); | ||
| 499 : | |||
| 500 : | childSetKeystrokeCallback("name", &LLPanelDirBrowser::onKeystrokeName, this); | ||
| 501 : | |||
| 502 : | childSetAction("Search", onClickSearch, this); | ||
| 503 : | childDisable("Search"); | ||
| 504 : | setDefaultBtn( "Search" ); | ||
| 505 : | |||
| 506 : | return TRUE; | ||
| 507 : | } | ||
| 508 : | |||
| 509 : | LLPanelDirFindAllOld::~LLPanelDirFindAllOld() | ||
| 510 : | { | ||
| 511 : | // Children all cleaned up by default view destructor. | ||
| 512 : | } | ||
| 513 : | |||
| 514 : | // virtual | ||
| 515 : | void LLPanelDirFindAllOld::draw() | ||
| 516 : | { | ||
| 517 : | updateMaturityCheckbox(); | ||
| 518 : | LLPanelDirBrowser::draw(); | ||
| 519 : | } | ||
| 520 : | |||
| 521 : | // static | ||
| 522 : | void LLPanelDirFindAllOld::onCommitScope(LLUICtrl* ctrl, void* data) | ||
| 523 : | { | ||
| 524 : | LLPanelDirFindAllOld* self = (LLPanelDirFindAllOld*)data; | ||
| 525 : | self->setFocus(TRUE); | ||
| 526 : | } | ||
| 527 : | |||
| 528 : | // static | ||
| 529 : | void LLPanelDirFindAllOld::onClickSearch(void *userdata) | ||
| 530 : | { | ||
| 531 : | LLPanelDirFindAllOld *self = (LLPanelDirFindAllOld *)userdata; | ||
| 532 : | |||
| 533 : | if (self->childGetValue("name").asString().length() < self->mMinSearchChars) | ||
| 534 : | { | ||
| 535 : | return; | ||
| 536 : | }; | ||
| 537 : | |||
| 538 : | BOOL inc_pg = self->childGetValue("incpg").asBoolean(); | ||
| 539 : | BOOL inc_mature = self->childGetValue("incmature").asBoolean(); | ||
| 540 : | BOOL inc_adult = self->childGetValue("incadult").asBoolean(); | ||
| 541 : | if (!(inc_pg || inc_mature || inc_adult)) | ||
| 542 : | { | ||
| 543 : | LLNotifications::instance().add("NoContentToSearch"); | ||
| 544 : | return; | ||
| 545 : | } | ||
| 546 : | |||
| 547 : | self->setupNewSearch(); | ||
| 548 : | |||
| 549 : | // Figure out scope | ||
| 550 : | U32 scope = 0x0; | ||
| 551 : | scope |= DFQ_PEOPLE; // people (not just online = 0x01 | 0x02) | ||
| 552 : | // places handled below | ||
| 553 : | scope |= DFQ_EVENTS; // events | ||
| 554 : | scope |= DFQ_GROUPS; // groups | ||
| 555 : | if (inc_pg) | ||
| 556 : | { | ||
| 557 : | scope |= DFQ_INC_PG; | ||
| 558 : | } | ||
| 559 : | if (inc_mature) | ||
| 560 : | { | ||
| 561 : | scope |= DFQ_INC_MATURE; | ||
| 562 : | } | ||
| 563 : | if (inc_adult) | ||
| 564 : | { | ||
| 565 : | scope |= DFQ_INC_ADULT; | ||
| 566 : | } | ||
| 567 : | |||
| 568 : | // send the message | ||
| 569 : | LLMessageSystem *msg = gMessageSystem; | ||
| 570 : | S32 start_row = 0; | ||
| 571 : | sendDirFindQuery(msg, self->mSearchID, self->childGetValue("name").asString(), scope, start_row); | ||
| 572 : | |||
| 573 : | // Also look up classified ads. JC 12/2005 | ||
| 574 : | BOOL filter_auto_renew = FALSE; | ||
| 575 : | U32 classified_flags = pack_classified_flags_request(filter_auto_renew, inc_pg, inc_mature, inc_adult); | ||
| 576 : | msg->newMessage("DirClassifiedQuery"); | ||
| 577 : | msg->nextBlock("AgentData"); | ||
| 578 : | msg->addUUID("AgentID", gAgent.getID()); | ||
| 579 : | msg->addUUID("SessionID", gAgent.getSessionID()); | ||
| 580 : | msg->nextBlock("QueryData"); | ||
| 581 : | msg->addUUID("QueryID", self->mSearchID); | ||
| 582 : | msg->addString("QueryText", self->childGetValue("name").asString()); | ||
| 583 : | msg->addU32("QueryFlags", classified_flags); | ||
| 584 : | msg->addU32("Category", 0); // all categories | ||
| 585 : | msg->addS32("QueryStart", 0); | ||
| 586 : | gAgent.sendReliableMessage(); | ||
| 587 : | |||
| 588 : | // Need to use separate find places query because places are | ||
| 589 : | // sent using the more compact DirPlacesReply message. | ||
| 590 : | U32 query_flags = DFQ_DWELL_SORT; | ||
| 591 : | if (inc_pg) | ||
| 592 : | { | ||
| 593 : | query_flags |= DFQ_INC_PG; | ||
| 594 : | } | ||
| 595 : | if (inc_mature) | ||
| 596 : | { | ||
| 597 : | query_flags |= DFQ_INC_MATURE; | ||
| 598 : | } | ||
| 599 : | if (inc_adult) | ||
| 600 : | { | ||
| 601 : | query_flags |= DFQ_INC_ADULT; | ||
| 602 : | } | ||
| 603 : | msg->newMessage("DirPlacesQuery"); | ||
| 604 : | msg->nextBlock("AgentData"); | ||
| 605 : | msg->addUUID("AgentID", gAgent.getID() ); | ||
| 606 : | msg->addUUID("SessionID", gAgent.getSessionID()); | ||
| 607 : | msg->nextBlock("QueryData"); | ||
| 608 : | msg->addUUID("QueryID", self->mSearchID ); | ||
| 609 : | msg->addString("QueryText", self->childGetValue("name").asString()); | ||
| 610 : | msg->addU32("QueryFlags", query_flags ); | ||
| 611 : | msg->addS32("QueryStart", 0 ); // Always get the first 100 when using find ALL | ||
| 612 : | msg->addS8("Category", LLParcel::C_ANY); | ||
| 613 : | msg->addString("SimName", NULL); | ||
| 614 : | gAgent.sendReliableMessage(); | ||
| 615 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

