aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpaneldirfind.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llpaneldirfind.cpp137
1 files changed, 72 insertions, 65 deletions
diff --git a/linden/indra/newview/llpaneldirfind.cpp b/linden/indra/newview/llpaneldirfind.cpp
index 50bdc9e..24db19f 100644
--- a/linden/indra/newview/llpaneldirfind.cpp
+++ b/linden/indra/newview/llpaneldirfind.cpp
@@ -88,11 +88,14 @@ private:
88 static void onClickHome( void* data ); 88 static void onClickHome( void* data );
89 static void onClickSearch( void* data ); 89 static void onClickSearch( void* data );
90 static void onCommitSearch(LLUICtrl*, void* data); 90 static void onCommitSearch(LLUICtrl*, void* data);
91 static void onKeystrokeSearchEditor(LLLineEditor* line, void* data); 91
92 static std::string getSearchURLSuffix(bool mature);
92 93
93 /*virtual*/ void onNavigateBegin( const EventType& eventIn ); 94 /*virtual*/ void onNavigateBegin( const EventType& eventIn );
94 /*virtual*/ void onNavigateComplete( const EventType& eventIn ); 95 /*virtual*/ void onNavigateComplete( const EventType& eventIn );
95 // Used to update progress indicator 96 // Used to update progress indicator
97 /*virtual*/ void onLocationChange( const EventType& eventIn );
98 // Debugging info to console
96 99
97private: 100private:
98#if LL_LIBXUL_ENABLED 101#if LL_LIBXUL_ENABLED
@@ -123,13 +126,9 @@ BOOL LLPanelDirFindAll::postBuild()
123 if (gAgent.isTeen()) 126 if (gAgent.isTeen())
124 { 127 {
125 childSetVisible("mature_check", false); 128 childSetVisible("mature_check", false);
129 childSetValue("mature_check", false);
126 } 130 }
127 131
128 // we don't record the last search query (yet) so search text will be empty -> disable search
129 childDisable("search_btn");
130
131 childSetKeystrokeCallback("search_editor", onKeystrokeSearchEditor, this);
132
133#if LL_LIBXUL_ENABLED 132#if LL_LIBXUL_ENABLED
134 mWebBrowser = LLViewerUICtrlFactory::getWebBrowserByName(this, "find_browser"); 133 mWebBrowser = LLViewerUICtrlFactory::getWebBrowserByName(this, "find_browser");
135 if (mWebBrowser) 134 if (mWebBrowser)
@@ -190,7 +189,14 @@ void LLPanelDirFindAll::search(const std::string& search_text)
190 } 189 }
191 } 190 }
192 191
193 std::string url = gSavedSettings.getString("SearchQueryURL"); 192 // If user types "%" into search, it builds a bogus URL.
193 // Try to work around that. It's not a security problem
194 // as far as I can tell -- we MySQL escape database queries
195 // on the server. Do this after "+" substitution because
196 // "+" is an allowed character.
197 query = LLURI::escape(query);
198
199 std::string url = gSavedSettings.getString("SearchURLQuery");
194 std::string substring = "[QUERY]"; 200 std::string substring = "[QUERY]";
195 url.replace(url.find(substring), substring.length(), query); 201 url.replace(url.find(substring), substring.length(), query);
196 202
@@ -199,46 +205,9 @@ void LLPanelDirFindAll::search(const std::string& search_text)
199 substring = "[COLLECTION]"; 205 substring = "[COLLECTION]";
200 url.replace(url.find(substring), substring.length(), selected_collection); 206 url.replace(url.find(substring), substring.length(), selected_collection);
201 207
202 // if the mature checkbox is unchecked, modify query to remove 208 // Add common parameters (mature, teen, location)
203 // terms with given phrase from the result set 209 bool mature = childGetValue( "mature_check" ).asBoolean();
204 substring = "[MATURE]"; 210 url += getSearchURLSuffix(mature);
205 if ( childGetValue( "mature_check" ).asBoolean() == false )
206 {
207 url.replace(url.find(substring), substring.length(), "N");
208 }
209 else
210 {
211 url.replace(url.find(substring), substring.length(), "Y");
212 }
213
214 substring = "[TEEN]";
215 const char* teen = (gAgent.isTeen() ? "Y" : "N");
216 url.replace(url.find(substring), substring.length(), teen);
217
218 // Include region and x/y position, not for the GSA, but
219 // just to get logs on the web server for search_proxy.php
220 // showing where people were standing when they searched.
221 std::string region_name;
222 LLViewerRegion* region = gAgent.getRegion();
223 if (region)
224 {
225 region_name = region->getName();
226 }
227 // take care of spaces in names
228 region_name = LLURI::escape(region_name);
229 substring = "[REGION]";
230 url.replace(url.find(substring), substring.length(), region_name);
231
232 LLVector3 pos_region = gAgent.getPositionAgent();
233 std::string x = llformat("%.0f", pos_region.mV[VX]);
234 substring = "[X]";
235 url.replace(url.find(substring), substring.length(), x);
236 std::string y = llformat("%.0f", pos_region.mV[VY]);
237 substring = "[Y]";
238 url.replace(url.find(substring), substring.length(), y);
239 std::string z = llformat("%.0f", pos_region.mV[VZ]);
240 substring = "[Z]";
241 url.replace(url.find(substring), substring.length(), z);
242 211
243 llinfos << "url " << url << llendl; 212 llinfos << "url " << url << llendl;
244 213
@@ -265,18 +234,11 @@ void LLPanelDirFindAll::focus()
265 234
266void LLPanelDirFindAll::navigateToDefaultPage() 235void LLPanelDirFindAll::navigateToDefaultPage()
267{ 236{
268 std::string start_url = gSavedSettings.getString("SearchDefaultURL"); 237 std::string start_url = gSavedSettings.getString("SearchURLDefault");
238 bool mature = childGetValue( "mature_check" ).asBoolean();
239 start_url += getSearchURLSuffix( mature );
269 240
270 std::string substring = "[MATURE]"; 241 llinfos << "default url: " << start_url << llendl;
271 if ( childGetValue( "mature_check" ).asBoolean() == false )
272 {
273 start_url.replace( start_url.find( substring ), substring.length(), "N" );
274 }
275 else
276 {
277 start_url.replace( start_url.find( substring ), substring.length(), "Y" );
278 }
279 llinfos << "SEARCH> browsing to default url: " << start_url << llendl;
280 242
281#if LL_LIBXUL_ENABLED 243#if LL_LIBXUL_ENABLED
282 if (mWebBrowser) 244 if (mWebBrowser)
@@ -286,20 +248,60 @@ void LLPanelDirFindAll::navigateToDefaultPage()
286#endif //LL_LIBXUL_ENABLED 248#endif //LL_LIBXUL_ENABLED
287} 249}
288 250
289// static - only enable search if there is at least 1 character 251// static
290void LLPanelDirFindAll::onKeystrokeSearchEditor(LLLineEditor* line, void* data) 252std::string LLPanelDirFindAll::getSearchURLSuffix(bool mature_in)
291{ 253{
292 LLPanelDirBrowser *self = (LLPanelDirBrowser*)data; 254 bool mature = mature_in;
293 if (line->getLength() > 0 ) 255 // Teens never get mature results. Explicitly override because
256 // Lindens/testers have multiple accounts and shared settings sometimes
257 // result in teen=Y and mature=Y simultaneously. JC
258 if (gAgent.isTeen())
294 { 259 {
295 self->childEnable("search_btn"); 260 mature = false;
296 } 261 }
297 else 262
263 std::string url = gSavedSettings.getString("SearchURLSuffix");
264
265 // if the mature checkbox is unchecked, modify query to remove
266 // terms with given phrase from the result set
267 std::string substring = "[MATURE]";
268 const char* mature_flag = (mature ? "Y" : "N");
269 url.replace(url.find(substring), substring.length(), mature_flag);
270
271 substring = "[TEEN]";
272 const char* teen_flag = (gAgent.isTeen() ? "Y" : "N");
273 url.replace(url.find(substring), substring.length(), teen_flag);
274
275 // Include region and x/y position, not for the GSA, but
276 // just to get logs on the web server for search_proxy.php
277 // showing where people were standing when they searched.
278 std::string region_name;
279 LLViewerRegion* region = gAgent.getRegion();
280 if (region)
298 { 281 {
299 self->childDisable("search_btn"); 282 region_name = region->getName();
300 } 283 }
284 // take care of spaces in names
285 region_name = LLURI::escape(region_name);
286 substring = "[REGION]";
287 url.replace(url.find(substring), substring.length(), region_name);
288
289 LLVector3 pos_region = gAgent.getPositionAgent();
290
291 std::string x = llformat("%.0f", pos_region.mV[VX]);
292 substring = "[X]";
293 url.replace(url.find(substring), substring.length(), x);
294 std::string y = llformat("%.0f", pos_region.mV[VY]);
295 substring = "[Y]";
296 url.replace(url.find(substring), substring.length(), y);
297 std::string z = llformat("%.0f", pos_region.mV[VZ]);
298 substring = "[Z]";
299 url.replace(url.find(substring), substring.length(), z);
300
301 return url;
301} 302}
302 303
304
303// static 305// static
304void LLPanelDirFindAll::onClickBack( void* data ) 306void LLPanelDirFindAll::onClickBack( void* data )
305{ 307{
@@ -360,6 +362,11 @@ void LLPanelDirFindAll::onNavigateComplete( const EventType& eventIn )
360 childSetText("status_text", childGetText("done_text")); 362 childSetText("status_text", childGetText("done_text"));
361} 363}
362 364
365void LLPanelDirFindAll::onLocationChange( const EventType& eventIn )
366{
367 llinfos << eventIn.getStringValue() << llendl;
368}
369
363//--------------------------------------------------------------------------- 370//---------------------------------------------------------------------------
364// LLPanelDirFindAllInterface 371// LLPanelDirFindAllInterface
365//--------------------------------------------------------------------------- 372//---------------------------------------------------------------------------