llpaneldirfind.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /**
  2. * @file llpaneldirfind.cpp
  3. * @brief The "All" panel in the Search floater.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  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. #include "llviewerprecompiledheaders.h"
  33. #include "llpaneldirfind.h"
  34. #include "llcheckboxctrl.h"
  35. #include "llclassifiedflags.h"
  36. #include "llparcel.h"
  37. #include "llqueryflags.h"
  38. #include "lluictrlfactory.h"
  39. #include "llmessage.h"
  40. #include "llagent.h"
  41. #include "hbfloatersearch.h"
  42. #include "llpaneldirbrowser.h"
  43. LLPanelDirFind::LLPanelDirFind(const std::string& name,
  44. HBFloaterSearch* floater)
  45. : LLPanelDirBrowser(name, floater)
  46. {
  47. mMinSearchChars = 3;
  48. }
  49. bool LLPanelDirFind::postBuild()
  50. {
  51. LLPanelDirBrowser::postBuild();
  52. mSearchEditor = getChild<LLSearchEditor>("search_text");
  53. mSearchEditor->setSearchCallback(LLPanelDirBrowser::onSearchEdit, this);
  54. childSetAction("search_btn", onClickSearch, this);
  55. childDisable("search_btn");
  56. setDefaultBtn("search_btn");
  57. return true;
  58. }
  59. //virtual
  60. void LLPanelDirFind::draw()
  61. {
  62. updateMaturityCheckbox();
  63. LLPanelDirBrowser::draw();
  64. }
  65. //virtual
  66. void LLPanelDirFind::search(const std::string& search_text)
  67. {
  68. LLMessageSystem* msg = gMessageSystemp;
  69. if (!msg) return;
  70. bool inc_pg = !mIncPGCheck || mIncPGCheck->getValue().asBoolean();
  71. bool inc_mature = mIncMatureCheck && mIncMatureCheck->getValue().asBoolean();
  72. bool inc_adult = mIncAdultCheck && mIncAdultCheck->getValue().asBoolean();
  73. if (!(inc_pg || inc_mature || inc_adult))
  74. {
  75. gNotifications.add("NoContentToSearch");
  76. return;
  77. }
  78. setupNewSearch();
  79. // Figure out scope
  80. U32 scope = 0x0;
  81. scope |= DFQ_PEOPLE; // people (not just online = 0x01 | 0x02)
  82. // places handled below
  83. scope |= DFQ_EVENTS; // events
  84. scope |= DFQ_GROUPS; // groups
  85. if (inc_pg)
  86. {
  87. scope |= DFQ_INC_PG;
  88. }
  89. if (inc_mature)
  90. {
  91. scope |= DFQ_INC_MATURE;
  92. }
  93. if (inc_adult)
  94. {
  95. scope |= DFQ_INC_ADULT;
  96. }
  97. // send the message
  98. S32 start_row = 0;
  99. sendDirFindQuery(msg, mSearchID, search_text, scope, start_row);
  100. // Also look up classified ads. JC 12/2005
  101. bool filter_auto_renew = false;
  102. U32 classified_flags = pack_classified_flags_request(filter_auto_renew,
  103. inc_pg, inc_mature,
  104. inc_adult);
  105. msg->newMessage("DirClassifiedQuery");
  106. msg->nextBlock("AgentData");
  107. msg->addUUID("AgentID", gAgentID);
  108. msg->addUUID("SessionID", gAgentSessionID);
  109. msg->nextBlock("QueryData");
  110. msg->addUUID("QueryID", mSearchID);
  111. msg->addString("QueryText", search_text);
  112. msg->addU32("QueryFlags", classified_flags);
  113. msg->addU32("Category", 0); // all categories
  114. msg->addS32("QueryStart", 0);
  115. gAgent.sendReliableMessage();
  116. // Need to use separate find places query because places are
  117. // sent using the more compact DirPlacesReply message.
  118. U32 query_flags = DFQ_DWELL_SORT;
  119. if (inc_pg)
  120. {
  121. query_flags |= DFQ_INC_PG;
  122. }
  123. if (inc_mature)
  124. {
  125. query_flags |= DFQ_INC_MATURE;
  126. }
  127. if (inc_adult)
  128. {
  129. query_flags |= DFQ_INC_ADULT;
  130. }
  131. msg->newMessage("DirPlacesQuery");
  132. msg->nextBlock("AgentData");
  133. msg->addUUID("AgentID", gAgentID);
  134. msg->addUUID("SessionID", gAgentSessionID);
  135. msg->nextBlock("QueryData");
  136. msg->addUUID("QueryID", mSearchID);
  137. msg->addString("QueryText", search_text);
  138. msg->addU32("QueryFlags", query_flags);
  139. msg->addS32("QueryStart", 0); // Always get the first 100 when using find ALL
  140. msg->addS8("Category", LLParcel::C_ANY);
  141. msg->addString("SimName", NULL);
  142. gAgent.sendReliableMessage();
  143. mSearchEditor->setText(search_text);
  144. }
  145. //static
  146. void LLPanelDirFind::onCommitScope(LLUICtrl* ctrl, void* userdata)
  147. {
  148. LLPanelDirFind* self = (LLPanelDirFind*)userdata;
  149. if (self)
  150. {
  151. self->setFocus(true);
  152. }
  153. }
  154. //static
  155. void LLPanelDirFind::onClickSearch(void* userdata)
  156. {
  157. LLPanelDirFind* self = (LLPanelDirFind*)userdata;
  158. if (self)
  159. {
  160. std::string search_text = self->mSearchEditor->getText();
  161. if (search_text.length() >= self->mMinSearchChars)
  162. {
  163. self->search(search_text);
  164. }
  165. }
  166. }