hbfloaterareasearch.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. /**
  2. * @file hbfloaterareasearch.cpp
  3. * @brief HBFloaterAreaSearch class implementation
  4. *
  5. * This class implements a floater where all surroundind objects are listed.
  6. *
  7. * $LicenseInfo:firstyear=2009&license=viewergpl$
  8. *
  9. * Original code Copyright (c) 2009 Modular Systems Ltd. All rights reserved.
  10. * Rewritten/augmented code Copyright (c) 2010-2019 Henri Beauchamp.
  11. *
  12. * Second Life Viewer Source Code
  13. * The source code in this file ("Source Code") is provided by Linden Lab
  14. * to you under the terms of the GNU General Public License, version 2.0
  15. * ("GPL"), unless you have obtained a separate licensing agreement
  16. * ("Other License"), formally executed by you and Linden Lab. Terms of
  17. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  18. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  19. *
  20. * There are special exceptions to the terms and conditions of the GPL as
  21. * it is applied to this Source Code. View the full text of the exception
  22. * in the file doc/FLOSS-exception.txt in this software distribution, or
  23. * online at
  24. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  25. *
  26. * By copying, modifying or distributing this software, you acknowledge
  27. * that you have read and understood your obligations described above,
  28. * and agree to abide by those obligations.
  29. *
  30. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  31. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  32. * COMPLETENESS OR PERFORMANCE.
  33. * $/LicenseInfo$
  34. *
  35. * Revision history:
  36. * - Initial backport from Emerald viewer, modified, debugged, optimized and
  37. * improved by Henri Beauchamp - Feb 2010.
  38. * - Speed optimization by Henri Beauchamp - Jul 2011.
  39. * - Tracked object info added by Henri Beauchamp - Nov 2011.
  40. * - Further modified and augmented with mutes, derender, report & inspect
  41. * functions. Henri Beauchamp - May 2013.
  42. * - Full rewrite by Henri Beauchamp - Aug 2014.
  43. * - Another partial rewrite by Henri Beauchamp - Nov 2016.
  44. * - Yet another large rewrite, with proper exclusion of attachments and
  45. * viewer-side only objects to avoid fake "pending" requests and to prevent
  46. * sending to the server the bogus/spammy/useless messages corresponding to
  47. * them. Fixed the bug that caused group-owned objects to stay forever in the
  48. * "pending" requests list. Added the "Show", "Mute particles", "Mute owner"
  49. * and "Copy UUID" action. Changed input lines for search input lines.
  50. * Henri Beauchamp - Jan 2019.
  51. * - On "Refresh", clear the cached objects list so that any renamed object
  52. * will be properly refreshed. Henri Beauchamp - Apr 2021.
  53. */
  54. #include "llviewerprecompiledheaders.h"
  55. #include "hbfloaterareasearch.h"
  56. #include "llcachename.h"
  57. #include "llcombobox.h"
  58. #include "lllineeditor.h"
  59. #include "llscrolllistctrl.h"
  60. #include "lltabcontainer.h"
  61. #include "lluictrlfactory.h"
  62. #include "llagent.h"
  63. #include "llappviewer.h" // For gFrameTimeSeconds
  64. #include "llfloaterinspect.h"
  65. #include "llfloatermute.h"
  66. #include "llfloaterreporter.h"
  67. #include "lltracker.h"
  68. #include "llselectmgr.h"
  69. #include "llviewercontrol.h"
  70. #include "llviewerobjectlist.h"
  71. #include "llviewerwindow.h" // For gWindowp
  72. // static variables
  73. F32 HBFloaterAreaSearch::sLastUpdateTime = 0.f;
  74. bool HBFloaterAreaSearch::sIsDirty = false;
  75. bool HBFloaterAreaSearch::sUpdateDone = false;
  76. bool HBFloaterAreaSearch::sTracking = false;
  77. LLUUID HBFloaterAreaSearch::sTrackingObjectID;
  78. LLVector3d HBFloaterAreaSearch::sTrackingLocation;
  79. std::string HBFloaterAreaSearch::sTrackingInfoLine;
  80. HBFloaterAreaSearch::object_details_map_t HBFloaterAreaSearch::sObjectDetails;
  81. // Minimum interval between idle updates (and list refreshes) in seconds:
  82. constexpr F32 MIN_REFRESH_INTERVAL = 0.25f;
  83. // Interval of time between auto-refresh of stalled objects details requests in
  84. // seconds:
  85. constexpr F32 AUTO_REFRESH_INTERVAL = 10.f;
  86. HBFloaterAreaSearch::HBFloaterAreaSearch(const LLSD&)
  87. {
  88. LLUICtrlFactory::getInstance()->buildFloater(this,
  89. "floater_area_search.xml");
  90. }
  91. //virtual
  92. bool HBFloaterAreaSearch::postBuild()
  93. {
  94. mResultsList = getChild<LLScrollListCtrl>("result_list");
  95. mResultsList->setCommitCallback(onSelectResult);
  96. mResultsList->setDoubleClickCallback(onDoubleClickResult);
  97. mResultsList->setCallbackUserData(this);
  98. mResultsList->sortByColumn("name", true);
  99. mCounterText = getChild<LLTextBox>("counter");
  100. if (sTracking)
  101. {
  102. mCounterText->setText(sTrackingInfoLine);
  103. }
  104. mMuteFlyoutBtn = getChild<LLFlyoutButton>("mute");
  105. mMuteFlyoutBtn->setCommitCallback(onClickMute);
  106. mMuteFlyoutBtn->setCallbackUserData(this);
  107. mDerenderBtn = getChild<LLButton>("derender");
  108. mDerenderBtn->setClickedCallback(onClickDerender, this);
  109. mReportBtn = getChild<LLButton>("report");
  110. mReportBtn->setClickedCallback(onClickReport, this);
  111. mShowBtn = getChild<LLButton>("show");
  112. mShowBtn->setClickedCallback(onClickShow, this);
  113. mInspectFlyoutBtn = getChild<LLFlyoutButton>("inspect");
  114. mInspectFlyoutBtn->setCommitCallback(onClickInspect);
  115. mInspectFlyoutBtn->setCallbackUserData(this);
  116. mRefreshBtn = getChild<LLButton>("refresh");
  117. mRefreshBtn->setClickedCallback(onClickRefresh, this);
  118. childSetAction("close", onClickClose, this);
  119. mNameInputLine = getChild<LLSearchEditor>("name_query");
  120. mNameInputLine->setSearchCallback(onSearchEdit, mNameInputLine);
  121. mDescInputLine = getChild<LLSearchEditor>("desc_query");
  122. mDescInputLine->setSearchCallback(onSearchEdit, mDescInputLine);
  123. mOwnerInputLine = getChild<LLSearchEditor>("owner_query");
  124. mOwnerInputLine->setSearchCallback(onSearchEdit, mOwnerInputLine);
  125. mGroupInputLine = getChild<LLSearchEditor>("group_query");
  126. mGroupInputLine->setSearchCallback(onSearchEdit, mGroupInputLine);
  127. sIsDirty = true;
  128. return true;
  129. }
  130. //virtual
  131. void HBFloaterAreaSearch::draw()
  132. {
  133. if (sTracking)
  134. {
  135. F32 dist = 3.f;
  136. if (gTracker.getTrackingStatus() == LLTracker::TRACKING_LOCATION)
  137. {
  138. dist = fabsf((F32)(gTracker.getTrackedPositionGlobal() -
  139. sTrackingLocation).length());
  140. }
  141. if (dist > 2.f)
  142. {
  143. // Tracker stopped or tracking another location
  144. sTracking = false;
  145. sIsDirty = true;
  146. sTrackingInfoLine.clear();
  147. }
  148. }
  149. if (sIsDirty && sUpdateDone && getVisible() && !isMinimized())
  150. {
  151. uuid_vec_t selected = mResultsList->getSelectedIDs();
  152. S32 scrollpos = mResultsList->getScrollPos();
  153. mResultsList->deleteAllItems();
  154. LLViewerObject* objectp;
  155. const LLViewerRegion* our_region = gAgent.getRegion();
  156. bool searching_uuid = mSearchUUID.notNull();
  157. if (searching_uuid)
  158. {
  159. objectp = gObjectList.findObject(mSearchUUID);
  160. if (objectp)
  161. {
  162. objectp = objectp->getRootEdit();
  163. }
  164. if (isObjectOfInterest(objectp) && !objectp->isDead() &&
  165. objectp->getRegion() == our_region)
  166. {
  167. const LLUUID& object_id = objectp->getID();
  168. if (checkObjectDetails(object_id))
  169. {
  170. addInResultsList(object_id, false);
  171. }
  172. }
  173. }
  174. S32 total= 0;
  175. S32 pending = 0;
  176. for (object_details_map_t::iterator it = sObjectDetails.begin();
  177. it != sObjectDetails.end(); )
  178. {
  179. object_details_map_t::iterator cur_it = it++;
  180. const LLUUID& object_id = cur_it->first;
  181. objectp = gObjectList.findObject(object_id);
  182. if (!objectp || objectp->isDead() ||
  183. objectp->getRegion() != our_region)
  184. {
  185. sObjectDetails.erase(cur_it);
  186. continue;
  187. }
  188. if (!cur_it->second.valid())
  189. {
  190. ++pending;
  191. }
  192. else if (!searching_uuid)
  193. {
  194. addInResultsList(object_id, true);
  195. }
  196. ++total;
  197. }
  198. mResultsList->sortItems();
  199. mResultsList->selectMultiple(selected);
  200. mResultsList->setScrollPos(scrollpos);
  201. if (!sTracking)
  202. {
  203. mCounterText->setText(llformat("%d listed/%d pending/%d total",
  204. mResultsList->getItemCount(), pending,
  205. total));
  206. }
  207. setButtonsStatus();
  208. sIsDirty = sUpdateDone = false;
  209. }
  210. LLFloater::draw();
  211. }
  212. void HBFloaterAreaSearch::addInResultsList(const LLUUID& object_id,
  213. bool match_filters)
  214. {
  215. HBObjectDetails* details = &sObjectDetails[object_id];
  216. if (!details->valid())
  217. {
  218. // We did not yet receive the details for this object.
  219. return;
  220. }
  221. std::string tmp;
  222. std::string object_name = details->name;
  223. if (match_filters && !mSearchedName.empty())
  224. {
  225. tmp = object_name;
  226. LLStringUtil::toLower(tmp);
  227. if (tmp.find(mSearchedName) == std::string::npos)
  228. {
  229. return; // Failed name filter match
  230. }
  231. }
  232. std::string object_desc = details->desc;
  233. if (match_filters && !mSearchedDesc.empty())
  234. {
  235. tmp = object_desc;
  236. LLStringUtil::toLower(tmp);
  237. if (tmp.find(mSearchedDesc) == std::string::npos)
  238. {
  239. return; // Failed description filter match
  240. }
  241. }
  242. std::string object_owner;
  243. if (gCacheNamep)
  244. {
  245. const LLUUID& owner_id = details->owner_id;
  246. // Note: a valid entry always got either a non-null owner or group Id
  247. if (owner_id.isNull())
  248. {
  249. gCacheNamep->getGroupName(details->group_id, object_owner);
  250. }
  251. else
  252. {
  253. gCacheNamep->getFullName(owner_id, object_owner);
  254. }
  255. }
  256. if (match_filters && !mSearchedOwner.empty())
  257. {
  258. tmp = object_owner;
  259. LLStringUtil::toLower(tmp);
  260. if (tmp.find(mSearchedOwner) == std::string::npos)
  261. {
  262. return; // Failed owner name filter match
  263. }
  264. }
  265. std::string object_group;
  266. if (gCacheNamep && details->group_id.notNull())
  267. {
  268. gCacheNamep->getGroupName(details->group_id, object_group);
  269. }
  270. if (match_filters && !mSearchedGroup.empty())
  271. {
  272. tmp = object_group;
  273. LLStringUtil::toLower(tmp);
  274. if (tmp.find(mSearchedGroup) == std::string::npos)
  275. {
  276. return; // Failed group name filter match
  277. }
  278. }
  279. std::string style;
  280. if (sTracking && object_id == sTrackingObjectID)
  281. {
  282. style = "BOLD";
  283. }
  284. else
  285. {
  286. style = "NORMAL";
  287. }
  288. LLSD element;
  289. element["id"] = object_id;
  290. LLSD& column_name = element["columns"][LIST_OBJECT_NAME];
  291. column_name["column"] = "name";
  292. column_name["type"] = "text";
  293. column_name["value"] = object_name;
  294. column_name["font-style"] = style;
  295. if (object_id == mSearchUUID)
  296. {
  297. column_name["color"] = LLColor4::red2.getValue();
  298. }
  299. LLSD& column_desc = element["columns"][LIST_OBJECT_DESC];
  300. column_desc["column"] = "description";
  301. column_desc["type"] = "text";
  302. column_desc["value"] = object_desc;
  303. column_desc["font-style"] = style;
  304. LLSD& column_owner = element["columns"][LIST_OBJECT_OWNER];
  305. column_owner["column"] = "owner";
  306. column_owner["type"] = "text";
  307. column_owner["value"] = object_owner;
  308. column_owner["font-style"] = style;
  309. LLSD& column_group = element["columns"][LIST_OBJECT_GROUP];
  310. column_group["column"] = "group";
  311. column_group["type"] = "text";
  312. column_group["value"] = object_group;
  313. column_group["font-style"] = style;
  314. mResultsList->addElement(element, ADD_BOTTOM);
  315. }
  316. void HBFloaterAreaSearch::setButtonsStatus()
  317. {
  318. LLScrollListItem* item = mResultsList->getFirstSelected();
  319. if (item)
  320. {
  321. object_details_map_t::iterator it =
  322. sObjectDetails.find(item->getUUID());
  323. bool is_ours = it != sObjectDetails.end() &&
  324. it->second.owner_id == gAgentID;
  325. mMuteFlyoutBtn->setEnabled(!is_ours);
  326. mDerenderBtn->setEnabled(true);
  327. mReportBtn->setEnabled(!is_ours);
  328. mShowBtn->setEnabled(true);
  329. mInspectFlyoutBtn->setEnabled(true);
  330. }
  331. else
  332. {
  333. mMuteFlyoutBtn->setEnabled(false);
  334. mDerenderBtn->setEnabled(false);
  335. mReportBtn->setEnabled(false);
  336. mShowBtn->setEnabled(false);
  337. mInspectFlyoutBtn->setEnabled(false);
  338. }
  339. }
  340. //static
  341. void HBFloaterAreaSearch::newRegion()
  342. {
  343. // We changed region so we can clear the object details cache.
  344. sObjectDetails.clear();
  345. sTracking = false;
  346. sIsDirty = true;
  347. HBFloaterAreaSearch* self = findInstance();
  348. if (self)
  349. {
  350. self->mResultsList->deleteAllItems();
  351. self->mCounterText->setText(self->getString("counter_text"));
  352. }
  353. }
  354. //static
  355. bool HBFloaterAreaSearch::isObjectOfInterest(LLViewerObject* objectp)
  356. {
  357. if (!objectp) return false;
  358. LLPCode pcode = objectp->getPCode();
  359. // Reject all avatars and all viewer-side only objects
  360. if (pcode != LL_PCODE_VOLUME && pcode != LL_PCODE_LEGACY_GRASS &&
  361. pcode != LL_PCODE_LEGACY_TREE)
  362. {
  363. return false;
  364. }
  365. // Reject temporary objects, attachments and child primitives
  366. return !objectp->flagTemporaryOnRez() && !objectp->isAttachment() &&
  367. objectp->isRoot();
  368. }
  369. //static
  370. void HBFloaterAreaSearch::idleUpdate()
  371. {
  372. if (gFrameTimeSeconds - sLastUpdateTime >= MIN_REFRESH_INTERVAL &&
  373. findInstance())
  374. {
  375. const LLViewerRegion* our_region = gAgent.getRegion();
  376. for (S32 i = 0, count = gObjectList.getNumObjects(); i < count; ++i)
  377. {
  378. LLViewerObject* objectp = gObjectList.getObject(i);
  379. if (isObjectOfInterest(objectp) &&
  380. objectp->getRegion() == our_region)
  381. {
  382. if (!checkObjectDetails(objectp->getID()))
  383. {
  384. sIsDirty = true;
  385. }
  386. }
  387. }
  388. sLastUpdateTime = gFrameTimeSeconds;
  389. sUpdateDone = true;
  390. }
  391. }
  392. //static
  393. bool HBFloaterAreaSearch::checkObjectDetails(const LLUUID& object_id)
  394. {
  395. HBObjectDetails* details;
  396. object_details_map_t::iterator it = sObjectDetails.find(object_id);
  397. if (it == sObjectDetails.end())
  398. {
  399. details = &sObjectDetails[object_id];
  400. }
  401. else
  402. {
  403. details = &it->second;
  404. }
  405. if (details->valid())
  406. {
  407. return true;
  408. }
  409. if (gFrameTimeSeconds - details->time_stamp > AUTO_REFRESH_INTERVAL)
  410. {
  411. details->time_stamp = gFrameTimeSeconds;
  412. LLMessageSystem* msg = gMessageSystemp;
  413. msg->newMessageFast(_PREHASH_RequestObjectPropertiesFamily);
  414. msg->nextBlockFast(_PREHASH_AgentData);
  415. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  416. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  417. msg->nextBlockFast(_PREHASH_ObjectData);
  418. msg->addU32Fast(_PREHASH_RequestFlags, 0);
  419. msg->addUUIDFast(_PREHASH_ObjectID, object_id);
  420. gAgent.sendReliableMessage();
  421. LL_DEBUGS("AreaSearch") << "Sent data request for object " << object_id
  422. << LL_ENDL;
  423. }
  424. return false;
  425. }
  426. //static
  427. void HBFloaterAreaSearch::processObjectPropertiesFamily(LLMessageSystem* msg)
  428. {
  429. if (!msg || !findInstance()) return;
  430. LLUUID object_id;
  431. msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID, object_id);
  432. bool exists = sObjectDetails.count(object_id) != 0;
  433. if (!exists)
  434. {
  435. LLViewerObject* objectp = gObjectList.findObject(object_id);
  436. if (!isObjectOfInterest(objectp) || objectp->isDead() ||
  437. objectp->getRegion() != gAgent.getRegion())
  438. {
  439. LL_DEBUGS("AreaSearch") << "Rejected info for object "
  440. << object_id << LL_ENDL;
  441. return; // Not an interesting object for us
  442. }
  443. }
  444. // Update the object's details whether they were requested or not (to avoid
  445. // having to request them later).
  446. HBObjectDetails* details = &sObjectDetails[object_id];
  447. details->time_stamp = gFrameTimeSeconds;
  448. msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_OwnerID, details->owner_id);
  449. msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_GroupID, details->group_id);
  450. msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Name, details->name);
  451. msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Description,
  452. details->desc);
  453. if (gCacheNamep)
  454. {
  455. if (details->owner_id.notNull())
  456. {
  457. gCacheNamep->get(details->owner_id, false,
  458. boost::bind(&HBFloaterAreaSearch::setDirty));
  459. }
  460. if (details->group_id.notNull())
  461. {
  462. gCacheNamep->get(details->group_id, true,
  463. boost::bind(&HBFloaterAreaSearch::setDirty));
  464. }
  465. }
  466. LL_DEBUGS("AreaSearch") << "Got info for " << (exists ? "requested" : "new")
  467. << " object " << object_id << LL_ENDL;
  468. sIsDirty = true;
  469. }
  470. //static
  471. void HBFloaterAreaSearch::onSelectResult(LLUICtrl*, void* userdata)
  472. {
  473. HBFloaterAreaSearch* self = (HBFloaterAreaSearch*)userdata;
  474. if (self)
  475. {
  476. self->setButtonsStatus();
  477. }
  478. }
  479. //static
  480. void HBFloaterAreaSearch::onDoubleClickResult(void* userdata)
  481. {
  482. HBFloaterAreaSearch* self = (HBFloaterAreaSearch*)userdata;
  483. if (!self) return;
  484. LLScrollListItem* item = self->mResultsList->getFirstSelected();
  485. if (!item) return;
  486. LLUUID object_id = item->getUUID();
  487. LLViewerObject* objectp = gObjectList.findObject(object_id);
  488. if (objectp)
  489. {
  490. sTrackingObjectID = object_id;
  491. sTrackingLocation = objectp->getPositionGlobal();
  492. LLVector3 region_pos = objectp->getPositionRegion();
  493. sTrackingInfoLine = llformat("Tracking object at position: %d, %d, %d",
  494. (S32)region_pos.mV[VX],
  495. (S32)region_pos.mV[VY],
  496. (S32)region_pos.mV[VZ]);
  497. self->mCounterText->setText(sTrackingInfoLine);
  498. gTracker.trackLocation(sTrackingLocation,
  499. sObjectDetails[object_id].name, "",
  500. LLTracker::LOCATION_ITEM);
  501. sTracking = sIsDirty = true;
  502. }
  503. }
  504. //static
  505. void HBFloaterAreaSearch::onClickDerender(void* userdata)
  506. {
  507. HBFloaterAreaSearch* self = (HBFloaterAreaSearch*)userdata;
  508. if (!self) return;
  509. LLScrollListItem* item = self->mResultsList->getFirstSelected();
  510. if (!item) return;
  511. LLUUID object_id = item->getUUID();
  512. LLViewerObject* objectp = gObjectList.findObject(object_id);
  513. if (objectp)
  514. {
  515. // Make sure the object is not selected
  516. gSelectMgr.removeObjectFromSelections(object_id);
  517. // Remove the object from the list
  518. sObjectDetails.erase(object_id);
  519. // Mark the list as dirty
  520. sIsDirty = true;
  521. // Derender by killing the object.
  522. gObjectList.killObject(objectp);
  523. }
  524. }
  525. //static
  526. void HBFloaterAreaSearch::onClickMute(LLUICtrl* ctrl, void* userdata)
  527. {
  528. HBFloaterAreaSearch* self = (HBFloaterAreaSearch*)userdata;
  529. if (!self || !ctrl) return;
  530. LLScrollListItem* item = self->mResultsList->getFirstSelected();
  531. if (!item) return;
  532. LLUUID object_id = item->getUUID();
  533. object_details_map_t::iterator it = sObjectDetails.find(object_id);
  534. if (it == sObjectDetails.end() || it->second.owner_id == gAgentID)
  535. {
  536. return; // Abort !
  537. }
  538. std::string operation = ctrl->getValue().asString();
  539. if (operation == "mute_by_name")
  540. {
  541. std::string name = it->second.name;
  542. if (!name.empty())
  543. {
  544. LLMute mute(LLUUID::null, name, LLMute::BY_NAME);
  545. if (LLMuteList::add(mute))
  546. {
  547. LLFloaterMute::selectMute(name);
  548. }
  549. }
  550. }
  551. else if (operation == "mute_particles")
  552. {
  553. if (gCacheNamep)
  554. {
  555. LLUUID owner_id = it->second.owner_id;
  556. const LLUUID& group_id = it->second.group_id;
  557. bool group_owned = owner_id.isNull() && group_id.notNull();
  558. std::string object_owner;
  559. if (group_owned)
  560. {
  561. gCacheNamep->getGroupName(group_id, object_owner);
  562. owner_id = group_id;
  563. }
  564. else
  565. {
  566. gCacheNamep->getFullName(owner_id, object_owner);
  567. }
  568. LLMute::EType type = group_owned ? LLMute::GROUP : LLMute::AGENT;
  569. LLMute mute(owner_id, object_owner, type);
  570. if (LLMuteList::add(mute, LLMute::flagParticles))
  571. {
  572. LLFloaterMute::selectMute(mute.mID);
  573. }
  574. }
  575. }
  576. else if (operation == "mute_owner")
  577. {
  578. if (gCacheNamep)
  579. {
  580. LLUUID owner_id = it->second.owner_id;
  581. const LLUUID& group_id = it->second.group_id;
  582. bool group_owned = owner_id.isNull() && group_id.notNull();
  583. std::string object_owner;
  584. if (group_owned)
  585. {
  586. gCacheNamep->getGroupName(group_id, object_owner);
  587. owner_id = group_id;
  588. }
  589. else
  590. {
  591. gCacheNamep->getFullName(owner_id, object_owner);
  592. }
  593. LLMute::EType type = group_owned ? LLMute::GROUP : LLMute::AGENT;
  594. LLMute mute(owner_id, object_owner, type);
  595. if (LLMuteList::add(mute))
  596. {
  597. LLFloaterMute::selectMute(mute.mID);
  598. }
  599. }
  600. }
  601. else
  602. {
  603. LLMute mute(object_id, it->second.name, LLMute::OBJECT);
  604. if (LLMuteList::add(mute))
  605. {
  606. LLFloaterMute::selectMute(mute.mID);
  607. }
  608. }
  609. }
  610. //static
  611. void HBFloaterAreaSearch::onClickReport(void* userdata)
  612. {
  613. HBFloaterAreaSearch* self = (HBFloaterAreaSearch*)userdata;
  614. if (!self) return;
  615. LLScrollListItem* item = self->mResultsList->getFirstSelected();
  616. if (item)
  617. {
  618. LLFloaterReporter::showFromObject(item->getUUID());
  619. }
  620. }
  621. //static
  622. void HBFloaterAreaSearch::onClickShow(void* userdata)
  623. {
  624. HBFloaterAreaSearch* self = (HBFloaterAreaSearch*)userdata;
  625. if (!self) return;
  626. LLScrollListItem* item = self->mResultsList->getFirstSelected();
  627. if (item)
  628. {
  629. gAgent.lookAtObject(item->getUUID(), CAMERA_POSITION_OBJECT);
  630. }
  631. }
  632. //static
  633. void HBFloaterAreaSearch::onClickInspect(LLUICtrl* ctrl, void* userdata)
  634. {
  635. HBFloaterAreaSearch* self = (HBFloaterAreaSearch*)userdata;
  636. if (!self || !ctrl || !gWindowp) return;
  637. LLScrollListItem* item = self->mResultsList->getFirstSelected();
  638. if (!item) return;
  639. LLUUID object_id = item->getUUID();
  640. std::string operation = ctrl->getValue().asString();
  641. if (operation == "copy_uuid")
  642. {
  643. gWindowp->copyTextToClipboard(utf8str_to_wstring(object_id.asString()));
  644. }
  645. else if (operation == "debug")
  646. {
  647. LLViewerObject* objectp = gObjectList.findObject(object_id);
  648. if (objectp)
  649. {
  650. objectp->toggleDebugUpdateMsg();
  651. }
  652. }
  653. else
  654. {
  655. LLViewerObject* objectp = gObjectList.findObject(object_id);
  656. if (objectp)
  657. {
  658. std::vector<LLViewerObject*> objects;
  659. objects.push_back(objectp);
  660. gSelectMgr.selectObjectAndFamily(objects);
  661. LLFloaterInspect::show();
  662. }
  663. }
  664. }
  665. //static
  666. void HBFloaterAreaSearch::onClickRefresh(void* userdata)
  667. {
  668. sObjectDetails.clear();
  669. sTracking = false;
  670. sIsDirty = true;
  671. }
  672. //static
  673. void HBFloaterAreaSearch::onClickClose(void* userdata)
  674. {
  675. HBFloaterAreaSearch* self = (HBFloaterAreaSearch*)userdata;
  676. if (self)
  677. {
  678. self->close();
  679. }
  680. }
  681. //static
  682. void HBFloaterAreaSearch::onSearchEdit(const std::string& search_string,
  683. void* userdata)
  684. {
  685. HBFloaterAreaSearch* self = findInstance();
  686. LLSearchEditor* search = (LLSearchEditor*)userdata;
  687. if (self && search)
  688. {
  689. std::string text = search_string;
  690. LLStringUtil::toLower(text);
  691. if (search == self->mNameInputLine)
  692. {
  693. if (LLUUID::validate(text))
  694. {
  695. self->mSearchUUID.set(text);
  696. self->mSearchedName.clear();
  697. self->mDescInputLine->clear();
  698. self->mDescInputLine->setEnabled(false);
  699. self->mOwnerInputLine->clear();
  700. self->mOwnerInputLine->setEnabled(false);
  701. self->mGroupInputLine->clear();
  702. self->mGroupInputLine->setEnabled(false);
  703. }
  704. else
  705. {
  706. self->mSearchedName = text;
  707. self->mSearchUUID.setNull();
  708. self->mDescInputLine->setText(self->mSearchedDesc);
  709. self->mDescInputLine->setEnabled(true);
  710. self->mOwnerInputLine->setEnabled(true);
  711. self->mOwnerInputLine->setText(self->mSearchedOwner);
  712. self->mGroupInputLine->setEnabled(true);
  713. self->mGroupInputLine->setText(self->mSearchedGroup);
  714. }
  715. }
  716. else if (search == self->mDescInputLine)
  717. {
  718. self->mSearchedDesc = text;
  719. }
  720. else if (search == self->mOwnerInputLine)
  721. {
  722. self->mSearchedOwner = text;
  723. }
  724. else if (search == self->mGroupInputLine)
  725. {
  726. self->mSearchedGroup = text;
  727. }
  728. if (text.length() > 2)
  729. {
  730. setDirty();
  731. }
  732. }
  733. }