diff options
author | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
commit | 2a4dea528f670b9bb1f77ef27a8a1dd16603d114 (patch) | |
tree | 95c68e362703c9099d571ecbdc6142b1cda1e005 /linden/indra/newview/llpaneldirfind.cpp | |
parent | Second Life viewer sources 1.20.6 (diff) | |
download | meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.zip meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.gz meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.bz2 meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.xz |
Second Life viewer sources 1.20.7
Diffstat (limited to 'linden/indra/newview/llpaneldirfind.cpp')
-rw-r--r-- | linden/indra/newview/llpaneldirfind.cpp | 300 |
1 files changed, 94 insertions, 206 deletions
diff --git a/linden/indra/newview/llpaneldirfind.cpp b/linden/indra/newview/llpaneldirfind.cpp index dcda770..9bf71d9 100644 --- a/linden/indra/newview/llpaneldirfind.cpp +++ b/linden/indra/newview/llpaneldirfind.cpp | |||
@@ -68,48 +68,31 @@ | |||
68 | //--------------------------------------------------------------------------- | 68 | //--------------------------------------------------------------------------- |
69 | 69 | ||
70 | class LLPanelDirFindAll | 70 | class LLPanelDirFindAll |
71 | : public LLPanelDirBrowser, | 71 | : public LLPanelDirFind |
72 | public LLWebBrowserCtrlObserver | ||
73 | { | 72 | { |
74 | public: | 73 | public: |
75 | LLPanelDirFindAll(const std::string& name, LLFloaterDirectory* floater); | 74 | LLPanelDirFindAll(const std::string& name, LLFloaterDirectory* floater); |
76 | /*virtual*/ ~LLPanelDirFindAll(); | ||
77 | 75 | ||
78 | /*virtual*/ BOOL postBuild(); | 76 | /*Virtual*/ void search(const std::string& search_text); |
79 | /*virtual*/ void draw(); | ||
80 | |||
81 | void search(const std::string& search_text); | ||
82 | void focus(); | ||
83 | void navigateToDefaultPage(); | ||
84 | |||
85 | private: | ||
86 | static void onClickBack( void* data ); | ||
87 | static void onClickForward( void* data ); | ||
88 | static void onClickHome( void* data ); | ||
89 | static void onClickSearch( void* data ); | ||
90 | static void onCommitSearch(LLUICtrl*, void* data); | ||
91 | |||
92 | static std::string getSearchURLSuffix(bool mature); | ||
93 | |||
94 | /*virtual*/ void onNavigateBegin( const EventType& eventIn ); | ||
95 | /*virtual*/ void onNavigateComplete( const EventType& eventIn ); | ||
96 | // Used to update progress indicator | ||
97 | /*virtual*/ void onLocationChange( const EventType& eventIn ); | ||
98 | // Debugging info to console | ||
99 | |||
100 | private: | ||
101 | LLWebBrowserCtrl* mWebBrowser; | ||
102 | }; | 77 | }; |
103 | 78 | ||
104 | |||
105 | LLPanelDirFindAll::LLPanelDirFindAll(const std::string& name, LLFloaterDirectory* floater) | 79 | LLPanelDirFindAll::LLPanelDirFindAll(const std::string& name, LLFloaterDirectory* floater) |
106 | : LLPanelDirBrowser(name, floater) | 80 | : LLPanelDirFind(name, floater, "find_browser") |
107 | ,mWebBrowser(NULL) | 81 | { |
82 | } | ||
83 | |||
84 | //--------------------------------------------------------------------------- | ||
85 | // LLPanelDirFind - Base class for all browser-based search tabs | ||
86 | //--------------------------------------------------------------------------- | ||
87 | |||
88 | LLPanelDirFind::LLPanelDirFind(const std::string& name, LLFloaterDirectory* floater, const std::string& browser_name) | ||
89 | : LLPanelDirBrowser(name, floater), | ||
90 | mWebBrowser(NULL), | ||
91 | mBrowserName(browser_name) | ||
108 | { | 92 | { |
109 | mMinSearchChars = 3; | ||
110 | } | 93 | } |
111 | 94 | ||
112 | BOOL LLPanelDirFindAll::postBuild() | 95 | BOOL LLPanelDirFind::postBuild() |
113 | { | 96 | { |
114 | LLPanelDirBrowser::postBuild(); | 97 | LLPanelDirBrowser::postBuild(); |
115 | 98 | ||
@@ -121,11 +104,15 @@ BOOL LLPanelDirFindAll::postBuild() | |||
121 | 104 | ||
122 | if (gAgent.isTeen()) | 105 | if (gAgent.isTeen()) |
123 | { | 106 | { |
124 | childSetVisible("mature_check", false); | 107 | // Showcase tab does not have mature checkbox |
125 | childSetValue("mature_check", false); | 108 | if (hasChild("mature_check")) |
109 | { | ||
110 | childSetVisible("mature_check", false); | ||
111 | childSetValue("mature_check", false); | ||
112 | } | ||
126 | } | 113 | } |
127 | 114 | ||
128 | mWebBrowser = getChild<LLWebBrowserCtrl>("find_browser"); | 115 | mWebBrowser = getChild<LLWebBrowserCtrl>(mBrowserName); |
129 | if (mWebBrowser) | 116 | if (mWebBrowser) |
130 | { | 117 | { |
131 | // new pages appear in same window as the results page now | 118 | // new pages appear in same window as the results page now |
@@ -147,14 +134,14 @@ BOOL LLPanelDirFindAll::postBuild() | |||
147 | return TRUE; | 134 | return TRUE; |
148 | } | 135 | } |
149 | 136 | ||
150 | LLPanelDirFindAll::~LLPanelDirFindAll() | 137 | LLPanelDirFind::~LLPanelDirFind() |
151 | { | 138 | { |
152 | if (mWebBrowser) | 139 | if (mWebBrowser) |
153 | mWebBrowser->remObserver(this); | 140 | mWebBrowser->remObserver(this); |
154 | } | 141 | } |
155 | 142 | ||
156 | // virtual | 143 | // virtual |
157 | void LLPanelDirFindAll::draw() | 144 | void LLPanelDirFind::draw() |
158 | { | 145 | { |
159 | // enable/disable buttons depending on state | 146 | // enable/disable buttons depending on state |
160 | if ( mWebBrowser ) | 147 | if ( mWebBrowser ) |
@@ -169,46 +156,25 @@ void LLPanelDirFindAll::draw() | |||
169 | LLPanelDirBrowser::draw(); | 156 | LLPanelDirBrowser::draw(); |
170 | } | 157 | } |
171 | 158 | ||
159 | // When we show any browser-based view, we want to hide all | ||
160 | // the right-side XUI detail panels. | ||
161 | // virtual | ||
162 | void LLPanelDirFind::onVisibilityChange(BOOL new_visibility) | ||
163 | { | ||
164 | if (new_visibility) | ||
165 | { | ||
166 | mFloaterDirectory->hideAllDetailPanels(); | ||
167 | } | ||
168 | LLPanel::onVisibilityChange(new_visibility); | ||
169 | } | ||
170 | |||
172 | void LLPanelDirFindAll::search(const std::string& search_text) | 171 | void LLPanelDirFindAll::search(const std::string& search_text) |
173 | { | 172 | { |
174 | if (!search_text.empty()) | 173 | if (!search_text.empty()) |
175 | { | 174 | { |
176 | // Replace spaces with "+" for use by Google search appliance | ||
177 | // Yes, this actually works for double-spaces | ||
178 | // " foo bar" becomes "+foo++bar" and works fine. JC | ||
179 | std::string search_text_with_plus = search_text; | ||
180 | std::string::iterator it = search_text_with_plus.begin(); | ||
181 | for ( ; it != search_text_with_plus.end(); ++it ) | ||
182 | { | ||
183 | if ( std::isspace( *it ) ) | ||
184 | { | ||
185 | *it = '+'; | ||
186 | } | ||
187 | } | ||
188 | |||
189 | // Our own special set of allowed chars (RFC1738 http://www.ietf.org/rfc/rfc1738.txt) | ||
190 | // Note that "+" is one of them, so we can do "+" addition first. | ||
191 | const char* allowed = | ||
192 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | ||
193 | "0123456789" | ||
194 | "-._~$+!*'()"; | ||
195 | std::string query = LLURI::escape(search_text_with_plus, allowed); | ||
196 | |||
197 | std::string url = gSavedSettings.getString("SearchURLQuery"); | ||
198 | std::string substring = "[QUERY]"; | ||
199 | url.replace(url.find(substring), substring.length(), query); | ||
200 | |||
201 | // replace the collection name with the one selected from the combo box | ||
202 | std::string selected_collection = childGetValue( "Category" ).asString(); | ||
203 | substring = "[COLLECTION]"; | ||
204 | url.replace(url.find(substring), substring.length(), selected_collection); | ||
205 | |||
206 | // Add common parameters (mature, teen, location) | ||
207 | bool mature = childGetValue( "mature_check" ).asBoolean(); | 175 | bool mature = childGetValue( "mature_check" ).asBoolean(); |
208 | url += getSearchURLSuffix(mature); | 176 | std::string selected_collection = childGetValue( "Category" ).asString(); |
209 | 177 | std::string url = buildSearchURL(search_text, selected_collection, mature); | |
210 | llinfos << "url " << url << llendl; | ||
211 | |||
212 | if (mWebBrowser) | 178 | if (mWebBrowser) |
213 | { | 179 | { |
214 | mWebBrowser->navigateTo(url); | 180 | mWebBrowser->navigateTo(url); |
@@ -223,14 +189,14 @@ void LLPanelDirFindAll::search(const std::string& search_text) | |||
223 | childSetText("search_editor", search_text); | 189 | childSetText("search_editor", search_text); |
224 | } | 190 | } |
225 | 191 | ||
226 | void LLPanelDirFindAll::focus() | 192 | void LLPanelDirFind::focus() |
227 | { | 193 | { |
228 | childSetFocus("search_editor"); | 194 | childSetFocus("search_editor"); |
229 | } | 195 | } |
230 | 196 | ||
231 | void LLPanelDirFindAll::navigateToDefaultPage() | 197 | void LLPanelDirFind::navigateToDefaultPage() |
232 | { | 198 | { |
233 | std::string start_url = gSavedSettings.getString("SearchURLDefault"); | 199 | std::string start_url = getString("default_search_page"); |
234 | bool mature = childGetValue( "mature_check" ).asBoolean(); | 200 | bool mature = childGetValue( "mature_check" ).asBoolean(); |
235 | start_url += getSearchURLSuffix( mature ); | 201 | start_url += getSearchURLSuffix( mature ); |
236 | 202 | ||
@@ -241,9 +207,49 @@ void LLPanelDirFindAll::navigateToDefaultPage() | |||
241 | mWebBrowser->navigateTo( start_url ); | 207 | mWebBrowser->navigateTo( start_url ); |
242 | } | 208 | } |
243 | } | 209 | } |
210 | // static | ||
211 | std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const std::string& collection, bool mature_in) | ||
212 | { | ||
213 | std::string url = gSavedSettings.getString("SearchURLDefault"); | ||
214 | if (!search_text.empty()) | ||
215 | { | ||
216 | // Replace spaces with "+" for use by Google search appliance | ||
217 | // Yes, this actually works for double-spaces | ||
218 | // " foo bar" becomes "+foo++bar" and works fine. JC | ||
219 | std::string search_text_with_plus = search_text; | ||
220 | std::string::iterator it = search_text_with_plus.begin(); | ||
221 | for ( ; it != search_text_with_plus.end(); ++it ) | ||
222 | { | ||
223 | if ( std::isspace( *it ) ) | ||
224 | { | ||
225 | *it = '+'; | ||
226 | } | ||
227 | } | ||
228 | |||
229 | // Our own special set of allowed chars (RFC1738 http://www.ietf.org/rfc/rfc1738.txt) | ||
230 | // Note that "+" is one of them, so we can do "+" addition first. | ||
231 | const char* allowed = | ||
232 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | ||
233 | "0123456789" | ||
234 | "-._~$+!*'()"; | ||
235 | std::string query = LLURI::escape(search_text_with_plus, allowed); | ||
236 | |||
237 | url = gSavedSettings.getString("SearchURLQuery"); | ||
238 | std::string substring = "[QUERY]"; | ||
239 | url.replace(url.find(substring), substring.length(), query); | ||
240 | |||
241 | // replace the collection name with the one selected from the combo box | ||
242 | // std::string selected_collection = childGetValue( "Category" ).asString(); | ||
243 | substring = "[COLLECTION]"; | ||
244 | url.replace(url.find(substring), substring.length(), collection); | ||
244 | 245 | ||
246 | llinfos << "url " << url << llendl; | ||
247 | } | ||
248 | url += getSearchURLSuffix( mature_in ); | ||
249 | return url; | ||
250 | } | ||
245 | // static | 251 | // static |
246 | std::string LLPanelDirFindAll::getSearchURLSuffix(bool mature_in) | 252 | std::string LLPanelDirFind::getSearchURLSuffix(bool mature_in) |
247 | { | 253 | { |
248 | bool mature = mature_in; | 254 | bool mature = mature_in; |
249 | // Teens never get mature results. Explicitly override because | 255 | // Teens never get mature results. Explicitly override because |
@@ -314,9 +320,9 @@ std::string LLPanelDirFindAll::getSearchURLSuffix(bool mature_in) | |||
314 | 320 | ||
315 | 321 | ||
316 | // static | 322 | // static |
317 | void LLPanelDirFindAll::onClickBack( void* data ) | 323 | void LLPanelDirFind::onClickBack( void* data ) |
318 | { | 324 | { |
319 | LLPanelDirFindAll* self = ( LLPanelDirFindAll* )data; | 325 | LLPanelDirFind* self = ( LLPanelDirFind* )data; |
320 | if ( self->mWebBrowser ) | 326 | if ( self->mWebBrowser ) |
321 | { | 327 | { |
322 | self->mWebBrowser->navigateBack(); | 328 | self->mWebBrowser->navigateBack(); |
@@ -324,9 +330,9 @@ void LLPanelDirFindAll::onClickBack( void* data ) | |||
324 | } | 330 | } |
325 | 331 | ||
326 | // static | 332 | // static |
327 | void LLPanelDirFindAll::onClickForward( void* data ) | 333 | void LLPanelDirFind::onClickForward( void* data ) |
328 | { | 334 | { |
329 | LLPanelDirFindAll* self = ( LLPanelDirFindAll* )data; | 335 | LLPanelDirFind* self = ( LLPanelDirFind* )data; |
330 | if ( self->mWebBrowser ) | 336 | if ( self->mWebBrowser ) |
331 | { | 337 | { |
332 | self->mWebBrowser->navigateForward(); | 338 | self->mWebBrowser->navigateForward(); |
@@ -334,9 +340,9 @@ void LLPanelDirFindAll::onClickForward( void* data ) | |||
334 | } | 340 | } |
335 | 341 | ||
336 | // static | 342 | // static |
337 | void LLPanelDirFindAll::onClickHome( void* data ) | 343 | void LLPanelDirFind::onClickHome( void* data ) |
338 | { | 344 | { |
339 | LLPanelDirFindAll* self = ( LLPanelDirFindAll* )data; | 345 | LLPanelDirFind* self = ( LLPanelDirFind* )data; |
340 | if ( self->mWebBrowser ) | 346 | if ( self->mWebBrowser ) |
341 | { | 347 | { |
342 | self->mWebBrowser->navigateHome(); | 348 | self->mWebBrowser->navigateHome(); |
@@ -344,32 +350,32 @@ void LLPanelDirFindAll::onClickHome( void* data ) | |||
344 | } | 350 | } |
345 | 351 | ||
346 | // static | 352 | // static |
347 | void LLPanelDirFindAll::onCommitSearch(LLUICtrl*, void* data) | 353 | void LLPanelDirFind::onCommitSearch(LLUICtrl*, void* data) |
348 | { | 354 | { |
349 | onClickSearch(data); | 355 | onClickSearch(data); |
350 | } | 356 | } |
351 | 357 | ||
352 | // static | 358 | // static |
353 | void LLPanelDirFindAll::onClickSearch(void* data) | 359 | void LLPanelDirFind::onClickSearch(void* data) |
354 | { | 360 | { |
355 | LLPanelDirFindAll* self = ( LLPanelDirFindAll* )data; | 361 | LLPanelDirFind* self = ( LLPanelDirFind* )data; |
356 | LLString search_text = self->childGetText("search_editor"); | 362 | LLString search_text = self->childGetText("search_editor"); |
357 | self->search(search_text); | 363 | self->search(search_text); |
358 | 364 | ||
359 | LLFloaterDirectory::sNewSearchCount++; | 365 | LLFloaterDirectory::sNewSearchCount++; |
360 | } | 366 | } |
361 | 367 | ||
362 | void LLPanelDirFindAll::onNavigateBegin( const EventType& eventIn ) | 368 | void LLPanelDirFind::onNavigateBegin( const EventType& eventIn ) |
363 | { | 369 | { |
364 | childSetText("status_text", getString("loading_text")); | 370 | childSetText("status_text", getString("loading_text")); |
365 | } | 371 | } |
366 | 372 | ||
367 | void LLPanelDirFindAll::onNavigateComplete( const EventType& eventIn ) | 373 | void LLPanelDirFind::onNavigateComplete( const EventType& eventIn ) |
368 | { | 374 | { |
369 | childSetText("status_text", getString("done_text")); | 375 | childSetText("status_text", getString("done_text")); |
370 | } | 376 | } |
371 | 377 | ||
372 | void LLPanelDirFindAll::onLocationChange( const EventType& eventIn ) | 378 | void LLPanelDirFind::onLocationChange( const EventType& eventIn ) |
373 | { | 379 | { |
374 | llinfos << eventIn.getStringValue() << llendl; | 380 | llinfos << eventIn.getStringValue() << llendl; |
375 | } | 381 | } |
@@ -397,121 +403,3 @@ void LLPanelDirFindAllInterface::focus(LLPanelDirFindAll* panel) | |||
397 | panel->focus(); | 403 | panel->focus(); |
398 | } | 404 | } |
399 | 405 | ||
400 | //--------------------------------------------------------------------------- | ||
401 | // LLPanelDirFindAllOld - deprecated if new Google search works out. JC | ||
402 | //--------------------------------------------------------------------------- | ||
403 | |||
404 | LLPanelDirFindAllOld::LLPanelDirFindAllOld(const std::string& name, LLFloaterDirectory* floater) | ||
405 | : LLPanelDirBrowser(name, floater) | ||
406 | { | ||
407 | mMinSearchChars = 3; | ||
408 | } | ||
409 | |||
410 | BOOL LLPanelDirFindAllOld::postBuild() | ||
411 | { | ||
412 | LLPanelDirBrowser::postBuild(); | ||
413 | |||
414 | childSetKeystrokeCallback("name", &LLPanelDirBrowser::onKeystrokeName, this); | ||
415 | |||
416 | childSetAction("Search", onClickSearch, this); | ||
417 | childDisable("Search"); | ||
418 | setDefaultBtn( "Search" ); | ||
419 | |||
420 | return TRUE; | ||
421 | } | ||
422 | |||
423 | LLPanelDirFindAllOld::~LLPanelDirFindAllOld() | ||
424 | { | ||
425 | // Children all cleaned up by default view destructor. | ||
426 | } | ||
427 | |||
428 | // virtual | ||
429 | void LLPanelDirFindAllOld::draw() | ||
430 | { | ||
431 | // You only have a choice if you are mature | ||
432 | childSetVisible("incmature", !gAgent.isTeen()); | ||
433 | childSetValue("incmature", gSavedSettings.getBOOL("ShowMatureFindAll")); | ||
434 | |||
435 | LLPanelDirBrowser::draw(); | ||
436 | } | ||
437 | |||
438 | // static | ||
439 | void LLPanelDirFindAllOld::onCommitScope(LLUICtrl* ctrl, void* data) | ||
440 | { | ||
441 | LLPanelDirFindAllOld* self = (LLPanelDirFindAllOld*)data; | ||
442 | self->setFocus(TRUE); | ||
443 | } | ||
444 | |||
445 | // static | ||
446 | void LLPanelDirFindAllOld::onClickSearch(void *userdata) | ||
447 | { | ||
448 | LLPanelDirFindAllOld *self = (LLPanelDirFindAllOld *)userdata; | ||
449 | |||
450 | if (self->childGetValue("name").asString().length() < self->mMinSearchChars) | ||
451 | { | ||
452 | return; | ||
453 | }; | ||
454 | |||
455 | self->setupNewSearch(); | ||
456 | |||
457 | // Figure out scope | ||
458 | U32 scope = 0x0; | ||
459 | scope |= DFQ_PEOPLE; // people (not just online = 0x01 | 0x02) | ||
460 | // places handled below | ||
461 | scope |= DFQ_EVENTS; // events | ||
462 | scope |= DFQ_GROUPS; // groups | ||
463 | |||
464 | BOOL filter_mature = (!gSavedSettings.getBOOL("ShowMatureFindAll") || | ||
465 | gAgent.isTeen() || | ||
466 | !self->childGetValue("incmature").asBoolean() ); | ||
467 | |||
468 | if ( filter_mature ) | ||
469 | { | ||
470 | scope |= DFQ_PG_SIMS_ONLY; | ||
471 | scope |= DFQ_PG_EVENTS_ONLY; | ||
472 | scope |= DFQ_FILTER_MATURE; | ||
473 | scope |= DFQ_PG_PARCELS_ONLY; | ||
474 | } | ||
475 | |||
476 | // send the message | ||
477 | LLMessageSystem *msg = gMessageSystem; | ||
478 | S32 start_row = 0; | ||
479 | sendDirFindQuery(msg, self->mSearchID, self->childGetValue("name").asString(), scope, start_row); | ||
480 | |||
481 | // Also look up classified ads. JC 12/2005 | ||
482 | BOOL filter_auto_renew = FALSE; | ||
483 | U32 classified_flags = pack_classified_flags(filter_mature, filter_auto_renew); | ||
484 | msg->newMessage("DirClassifiedQuery"); | ||
485 | msg->nextBlock("AgentData"); | ||
486 | msg->addUUID("AgentID", gAgent.getID()); | ||
487 | msg->addUUID("SessionID", gAgent.getSessionID()); | ||
488 | msg->nextBlock("QueryData"); | ||
489 | msg->addUUID("QueryID", self->mSearchID); | ||
490 | msg->addString("QueryText", self->childGetValue("name").asString()); | ||
491 | msg->addU32("QueryFlags", classified_flags); | ||
492 | msg->addU32("Category", 0); // all categories | ||
493 | msg->addS32("QueryStart", 0); | ||
494 | gAgent.sendReliableMessage(); | ||
495 | |||
496 | // Need to use separate find places query because places are | ||
497 | // sent using the more compact DirPlacesReply message. | ||
498 | U32 query_flags = DFQ_DWELL_SORT; | ||
499 | if ( filter_mature ) | ||
500 | { | ||
501 | query_flags |= DFQ_PG_SIMS_ONLY; | ||
502 | query_flags |= DFQ_PG_PARCELS_ONLY; // FWIW, currently DFQ_PG_PARCELS_ONLY is only supported | ||
503 | query_flags |= DFQ_FILTER_MATURE; | ||
504 | } | ||
505 | msg->newMessage("DirPlacesQuery"); | ||
506 | msg->nextBlock("AgentData"); | ||
507 | msg->addUUID("AgentID", gAgent.getID() ); | ||
508 | msg->addUUID("SessionID", gAgent.getSessionID()); | ||
509 | msg->nextBlock("QueryData"); | ||
510 | msg->addUUID("QueryID", self->mSearchID ); | ||
511 | msg->addString("QueryText", self->childGetValue("name").asString()); | ||
512 | msg->addU32("QueryFlags", query_flags ); | ||
513 | msg->addS32("QueryStart", 0 ); // Always get the first 100 when using find ALL | ||
514 | msg->addS8("Category", LLParcel::C_ANY); | ||
515 | msg->addString("SimName", NULL); | ||
516 | gAgent.sendReliableMessage(); | ||
517 | } | ||