PageRenderTime 56ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llpanelpermissions.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 1094 lines | 838 code | 138 blank | 118 comment | 172 complexity | da356b4a2dc214506d0aa540e922b761 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llpanelpermissions.cpp
  3. * @brief LLPanelPermissions class implementation
  4. * This class represents the panel in the build view for
  5. * viewing/editing object names, owners, permissions, etc.
  6. *
  7. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #include "llviewerprecompiledheaders.h"
  29. #include "llpanelpermissions.h"
  30. // library includes
  31. #include "lluuid.h"
  32. #include "llpermissions.h"
  33. #include "llcategory.h"
  34. #include "llclickaction.h"
  35. #include "llfocusmgr.h"
  36. #include "llnotificationsutil.h"
  37. #include "llstring.h"
  38. // project includes
  39. #include "llviewerwindow.h"
  40. #include "llresmgr.h"
  41. #include "lltextbox.h"
  42. #include "llbutton.h"
  43. #include "llcheckboxctrl.h"
  44. #include "llviewerobject.h"
  45. #include "llselectmgr.h"
  46. #include "llagent.h"
  47. #include "llstatusbar.h" // for getBalance()
  48. #include "lllineeditor.h"
  49. #include "llcombobox.h"
  50. #include "lluiconstants.h"
  51. #include "lldbstrings.h"
  52. #include "llfloatergroups.h"
  53. #include "llfloaterreg.h"
  54. #include "llavataractions.h"
  55. #include "llnamebox.h"
  56. #include "llviewercontrol.h"
  57. #include "lluictrlfactory.h"
  58. #include "llspinctrl.h"
  59. #include "roles_constants.h"
  60. #include "llgroupactions.h"
  61. U8 string_value_to_click_action(std::string p_value);
  62. std::string click_action_to_string_value( U8 action);
  63. U8 string_value_to_click_action(std::string p_value)
  64. {
  65. if(p_value == "Touch")
  66. {
  67. return CLICK_ACTION_TOUCH;
  68. }
  69. if(p_value == "Sit")
  70. {
  71. return CLICK_ACTION_SIT;
  72. }
  73. if(p_value == "Buy")
  74. {
  75. return CLICK_ACTION_BUY;
  76. }
  77. if(p_value == "Pay")
  78. {
  79. return CLICK_ACTION_PAY;
  80. }
  81. if(p_value == "Open")
  82. {
  83. return CLICK_ACTION_OPEN;
  84. }
  85. if(p_value == "Zoom")
  86. {
  87. return CLICK_ACTION_ZOOM;
  88. }
  89. return CLICK_ACTION_TOUCH;
  90. }
  91. std::string click_action_to_string_value( U8 action)
  92. {
  93. switch (action)
  94. {
  95. case CLICK_ACTION_TOUCH:
  96. default:
  97. return "Touch";
  98. break;
  99. case CLICK_ACTION_SIT:
  100. return "Sit";
  101. break;
  102. case CLICK_ACTION_BUY:
  103. return "Buy";
  104. break;
  105. case CLICK_ACTION_PAY:
  106. return "Pay";
  107. break;
  108. case CLICK_ACTION_OPEN:
  109. return "Open";
  110. break;
  111. case CLICK_ACTION_ZOOM:
  112. return "Zoom";
  113. break;
  114. }
  115. }
  116. ///----------------------------------------------------------------------------
  117. /// Class llpanelpermissions
  118. ///----------------------------------------------------------------------------
  119. // Default constructor
  120. LLPanelPermissions::LLPanelPermissions() :
  121. LLPanel()
  122. {
  123. setMouseOpaque(FALSE);
  124. }
  125. BOOL LLPanelPermissions::postBuild()
  126. {
  127. childSetCommitCallback("Object Name",LLPanelPermissions::onCommitName,this);
  128. getChild<LLLineEditor>("Object Name")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
  129. childSetCommitCallback("Object Description",LLPanelPermissions::onCommitDesc,this);
  130. getChild<LLLineEditor>("Object Description")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
  131. getChild<LLUICtrl>("button set group")->setCommitCallback(boost::bind(&LLPanelPermissions::onClickGroup,this));
  132. childSetCommitCallback("checkbox share with group",LLPanelPermissions::onCommitGroupShare,this);
  133. childSetAction("button deed",LLPanelPermissions::onClickDeedToGroup,this);
  134. childSetCommitCallback("checkbox allow everyone move",LLPanelPermissions::onCommitEveryoneMove,this);
  135. childSetCommitCallback("checkbox allow everyone copy",LLPanelPermissions::onCommitEveryoneCopy,this);
  136. childSetCommitCallback("checkbox for sale",LLPanelPermissions::onCommitSaleInfo,this);
  137. childSetCommitCallback("sale type",LLPanelPermissions::onCommitSaleType,this);
  138. childSetCommitCallback("Edit Cost", LLPanelPermissions::onCommitSaleInfo, this);
  139. childSetCommitCallback("checkbox next owner can modify",LLPanelPermissions::onCommitNextOwnerModify,this);
  140. childSetCommitCallback("checkbox next owner can copy",LLPanelPermissions::onCommitNextOwnerCopy,this);
  141. childSetCommitCallback("checkbox next owner can transfer",LLPanelPermissions::onCommitNextOwnerTransfer,this);
  142. childSetCommitCallback("clickaction",LLPanelPermissions::onCommitClickAction,this);
  143. childSetCommitCallback("search_check",LLPanelPermissions::onCommitIncludeInSearch,this);
  144. mLabelGroupName = getChild<LLNameBox>("Group Name Proxy");
  145. return TRUE;
  146. }
  147. LLPanelPermissions::~LLPanelPermissions()
  148. {
  149. // base class will take care of everything
  150. }
  151. void LLPanelPermissions::disableAll()
  152. {
  153. getChildView("perm_modify")->setEnabled(FALSE);
  154. getChild<LLUICtrl>("perm_modify")->setValue(LLStringUtil::null);
  155. getChildView("Creator:")->setEnabled(FALSE);
  156. getChild<LLUICtrl>("Creator Name")->setValue(LLStringUtil::null);
  157. getChildView("Creator Name")->setEnabled(FALSE);
  158. getChildView("Owner:")->setEnabled(FALSE);
  159. getChild<LLUICtrl>("Owner Name")->setValue(LLStringUtil::null);
  160. getChildView("Owner Name")->setEnabled(FALSE);
  161. getChildView("Group:")->setEnabled(FALSE);
  162. getChild<LLUICtrl>("Group Name Proxy")->setValue(LLStringUtil::null);
  163. getChildView("Group Name Proxy")->setEnabled(FALSE);
  164. getChildView("button set group")->setEnabled(FALSE);
  165. getChild<LLUICtrl>("Object Name")->setValue(LLStringUtil::null);
  166. getChildView("Object Name")->setEnabled(FALSE);
  167. getChildView("Name:")->setEnabled(FALSE);
  168. getChild<LLUICtrl>("Group Name")->setValue(LLStringUtil::null);
  169. getChildView("Group Name")->setEnabled(FALSE);
  170. getChildView("Description:")->setEnabled(FALSE);
  171. getChild<LLUICtrl>("Object Description")->setValue(LLStringUtil::null);
  172. getChildView("Object Description")->setEnabled(FALSE);
  173. getChildView("Permissions:")->setEnabled(FALSE);
  174. getChild<LLUICtrl>("checkbox share with group")->setValue(FALSE);
  175. getChildView("checkbox share with group")->setEnabled(FALSE);
  176. getChildView("button deed")->setEnabled(FALSE);
  177. getChild<LLUICtrl>("checkbox allow everyone move")->setValue(FALSE);
  178. getChildView("checkbox allow everyone move")->setEnabled(FALSE);
  179. getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(FALSE);
  180. getChildView("checkbox allow everyone copy")->setEnabled(FALSE);
  181. //Next owner can:
  182. getChildView("Next owner can:")->setEnabled(FALSE);
  183. getChild<LLUICtrl>("checkbox next owner can modify")->setValue(FALSE);
  184. getChildView("checkbox next owner can modify")->setEnabled(FALSE);
  185. getChild<LLUICtrl>("checkbox next owner can copy")->setValue(FALSE);
  186. getChildView("checkbox next owner can copy")->setEnabled(FALSE);
  187. getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(FALSE);
  188. getChildView("checkbox next owner can transfer")->setEnabled(FALSE);
  189. //checkbox for sale
  190. getChild<LLUICtrl>("checkbox for sale")->setValue(FALSE);
  191. getChildView("checkbox for sale")->setEnabled(FALSE);
  192. //checkbox include in search
  193. getChild<LLUICtrl>("search_check")->setValue(FALSE);
  194. getChildView("search_check")->setEnabled(FALSE);
  195. LLComboBox* combo_sale_type = getChild<LLComboBox>("sale type");
  196. combo_sale_type->setValue(LLSaleInfo::FS_COPY);
  197. combo_sale_type->setEnabled(FALSE);
  198. getChildView("Cost")->setEnabled(FALSE);
  199. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
  200. getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
  201. getChildView("Edit Cost")->setEnabled(FALSE);
  202. getChildView("label click action")->setEnabled(FALSE);
  203. LLComboBox* combo_click_action = getChild<LLComboBox>("clickaction");
  204. if (combo_click_action)
  205. {
  206. combo_click_action->setEnabled(FALSE);
  207. combo_click_action->clear();
  208. }
  209. getChildView("B:")->setVisible( FALSE);
  210. getChildView("O:")->setVisible( FALSE);
  211. getChildView("G:")->setVisible( FALSE);
  212. getChildView("E:")->setVisible( FALSE);
  213. getChildView("N:")->setVisible( FALSE);
  214. getChildView("F:")->setVisible( FALSE);
  215. }
  216. void LLPanelPermissions::refresh()
  217. {
  218. LLButton* BtnDeedToGroup = getChild<LLButton>("button deed");
  219. if(BtnDeedToGroup)
  220. {
  221. std::string deedText;
  222. if (gWarningSettings.getBOOL("DeedObject"))
  223. {
  224. deedText = getString("text deed continued");
  225. }
  226. else
  227. {
  228. deedText = getString("text deed");
  229. }
  230. BtnDeedToGroup->setLabelSelected(deedText);
  231. BtnDeedToGroup->setLabelUnselected(deedText);
  232. }
  233. BOOL root_selected = TRUE;
  234. LLSelectNode* nodep = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
  235. S32 object_count = LLSelectMgr::getInstance()->getSelection()->getRootObjectCount();
  236. if(!nodep || 0 == object_count)
  237. {
  238. nodep = LLSelectMgr::getInstance()->getSelection()->getFirstNode();
  239. object_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount();
  240. root_selected = FALSE;
  241. }
  242. //BOOL attachment_selected = LLSelectMgr::getInstance()->getSelection()->isAttachment();
  243. //attachment_selected = false;
  244. LLViewerObject* objectp = NULL;
  245. if(nodep) objectp = nodep->getObject();
  246. if(!nodep || !objectp)// || attachment_selected)
  247. {
  248. // ...nothing selected
  249. disableAll();
  250. return;
  251. }
  252. // figure out a few variables
  253. const BOOL is_one_object = (object_count == 1);
  254. // BUG: fails if a root and non-root are both single-selected.
  255. BOOL is_perm_modify = (LLSelectMgr::getInstance()->getSelection()->getFirstRootNode()
  256. && LLSelectMgr::getInstance()->selectGetRootsModify())
  257. || LLSelectMgr::getInstance()->selectGetModify();
  258. const LLFocusableElement* keyboard_focus_view = gFocusMgr.getKeyboardFocus();
  259. S32 string_index = 0;
  260. std::string MODIFY_INFO_STRINGS[] =
  261. {
  262. getString("text modify info 1"),
  263. getString("text modify info 2"),
  264. getString("text modify info 3"),
  265. getString("text modify info 4")
  266. };
  267. if (!is_perm_modify)
  268. {
  269. string_index += 2;
  270. }
  271. if (!is_one_object)
  272. {
  273. ++string_index;
  274. }
  275. getChildView("perm_modify")->setEnabled(TRUE);
  276. getChild<LLUICtrl>("perm_modify")->setValue(MODIFY_INFO_STRINGS[string_index]);
  277. getChildView("Permissions:")->setEnabled(TRUE);
  278. // Update creator text field
  279. getChildView("Creator:")->setEnabled(TRUE);
  280. BOOL creators_identical;
  281. std::string creator_name;
  282. creators_identical = LLSelectMgr::getInstance()->selectGetCreator(mCreatorID,
  283. creator_name);
  284. getChild<LLUICtrl>("Creator Name")->setValue(creator_name);
  285. getChildView("Creator Name")->setEnabled(TRUE);
  286. // Update owner text field
  287. getChildView("Owner:")->setEnabled(TRUE);
  288. std::string owner_name;
  289. const BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(mOwnerID, owner_name);
  290. if (mOwnerID.isNull())
  291. {
  292. if (LLSelectMgr::getInstance()->selectIsGroupOwned())
  293. {
  294. // Group owned already displayed by selectGetOwner
  295. }
  296. else
  297. {
  298. // Display last owner if public
  299. std::string last_owner_name;
  300. LLSelectMgr::getInstance()->selectGetLastOwner(mLastOwnerID, last_owner_name);
  301. // It should never happen that the last owner is null and the owner
  302. // is null, but it seems to be a bug in the simulator right now. JC
  303. if (!mLastOwnerID.isNull() && !last_owner_name.empty())
  304. {
  305. owner_name.append(", last ");
  306. owner_name.append(last_owner_name);
  307. }
  308. }
  309. }
  310. getChild<LLUICtrl>("Owner Name")->setValue(owner_name);
  311. getChildView("Owner Name")->setEnabled(TRUE);
  312. // update group text field
  313. getChildView("Group:")->setEnabled(TRUE);
  314. getChild<LLUICtrl>("Group Name")->setValue(LLStringUtil::null);
  315. LLUUID group_id;
  316. BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
  317. if (groups_identical)
  318. {
  319. if (mLabelGroupName)
  320. {
  321. mLabelGroupName->setNameID(group_id,TRUE);
  322. mLabelGroupName->setEnabled(TRUE);
  323. }
  324. }
  325. else
  326. {
  327. if (mLabelGroupName)
  328. {
  329. mLabelGroupName->setNameID(LLUUID::null, TRUE);
  330. mLabelGroupName->refresh(LLUUID::null, std::string(), true);
  331. mLabelGroupName->setEnabled(FALSE);
  332. }
  333. }
  334. getChildView("button set group")->setEnabled(owners_identical && (mOwnerID == gAgent.getID()));
  335. getChildView("Name:")->setEnabled(TRUE);
  336. LLLineEditor* LineEditorObjectName = getChild<LLLineEditor>("Object Name");
  337. getChildView("Description:")->setEnabled(TRUE);
  338. LLLineEditor* LineEditorObjectDesc = getChild<LLLineEditor>("Object Description");
  339. if (is_one_object)
  340. {
  341. if (keyboard_focus_view != LineEditorObjectName)
  342. {
  343. getChild<LLUICtrl>("Object Name")->setValue(nodep->mName);
  344. }
  345. if (LineEditorObjectDesc)
  346. {
  347. if (keyboard_focus_view != LineEditorObjectDesc)
  348. {
  349. LineEditorObjectDesc->setText(nodep->mDescription);
  350. }
  351. }
  352. }
  353. else
  354. {
  355. getChild<LLUICtrl>("Object Name")->setValue(LLStringUtil::null);
  356. LineEditorObjectDesc->setText(LLStringUtil::null);
  357. }
  358. // figure out the contents of the name, description, & category
  359. BOOL edit_name_desc = FALSE;
  360. if (is_one_object && objectp->permModify())
  361. {
  362. edit_name_desc = TRUE;
  363. }
  364. if (edit_name_desc)
  365. {
  366. getChildView("Object Name")->setEnabled(TRUE);
  367. getChildView("Object Description")->setEnabled(TRUE);
  368. }
  369. else
  370. {
  371. getChildView("Object Name")->setEnabled(FALSE);
  372. getChildView("Object Description")->setEnabled(FALSE);
  373. }
  374. S32 total_sale_price = 0;
  375. S32 individual_sale_price = 0;
  376. BOOL is_for_sale_mixed = FALSE;
  377. BOOL is_sale_price_mixed = FALSE;
  378. U32 num_for_sale = FALSE;
  379. LLSelectMgr::getInstance()->selectGetAggregateSaleInfo(num_for_sale,
  380. is_for_sale_mixed,
  381. is_sale_price_mixed,
  382. total_sale_price,
  383. individual_sale_price);
  384. const BOOL self_owned = (gAgent.getID() == mOwnerID);
  385. const BOOL group_owned = LLSelectMgr::getInstance()->selectIsGroupOwned() ;
  386. const BOOL public_owned = (mOwnerID.isNull() && !LLSelectMgr::getInstance()->selectIsGroupOwned());
  387. const BOOL can_transfer = LLSelectMgr::getInstance()->selectGetRootsTransfer();
  388. const BOOL can_copy = LLSelectMgr::getInstance()->selectGetRootsCopy();
  389. if (!owners_identical)
  390. {
  391. getChildView("Cost")->setEnabled(FALSE);
  392. getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
  393. getChildView("Edit Cost")->setEnabled(FALSE);
  394. }
  395. // You own these objects.
  396. else if (self_owned || (group_owned && gAgent.hasPowerInGroup(group_id,GP_OBJECT_SET_SALE)))
  397. {
  398. // If there are multiple items for sale then set text to PRICE PER UNIT.
  399. if (num_for_sale > 1)
  400. {
  401. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Per Unit"));
  402. }
  403. else
  404. {
  405. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
  406. }
  407. LLSpinCtrl *edit_price = getChild<LLSpinCtrl>("Edit Cost");
  408. if (!edit_price->hasFocus())
  409. {
  410. // If the sale price is mixed then set the cost to MIXED, otherwise
  411. // set to the actual cost.
  412. if ((num_for_sale > 0) && is_for_sale_mixed)
  413. {
  414. edit_price->setTentative(TRUE);
  415. }
  416. else if ((num_for_sale > 0) && is_sale_price_mixed)
  417. {
  418. edit_price->setTentative(TRUE);
  419. }
  420. else
  421. {
  422. edit_price->setValue(individual_sale_price);
  423. }
  424. }
  425. // The edit fields are only enabled if you can sell this object
  426. // and the sale price is not mixed.
  427. BOOL enable_edit = (num_for_sale && can_transfer) ? !is_for_sale_mixed : FALSE;
  428. getChildView("Cost")->setEnabled(enable_edit);
  429. getChildView("Edit Cost")->setEnabled(enable_edit);
  430. }
  431. // Someone, not you, owns these objects.
  432. else if (!public_owned)
  433. {
  434. getChildView("Cost")->setEnabled(FALSE);
  435. getChildView("Edit Cost")->setEnabled(FALSE);
  436. // Don't show a price if none of the items are for sale.
  437. if (num_for_sale)
  438. getChild<LLUICtrl>("Edit Cost")->setValue(llformat("%d",total_sale_price));
  439. else
  440. getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
  441. // If multiple items are for sale, set text to TOTAL PRICE.
  442. if (num_for_sale > 1)
  443. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Total"));
  444. else
  445. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
  446. }
  447. // This is a public object.
  448. else
  449. {
  450. getChildView("Cost")->setEnabled(FALSE);
  451. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
  452. getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
  453. getChildView("Edit Cost")->setEnabled(FALSE);
  454. }
  455. // Enable and disable the permissions checkboxes
  456. // based on who owns the object.
  457. // TODO: Creator permissions
  458. U32 base_mask_on = 0;
  459. U32 base_mask_off = 0;
  460. U32 owner_mask_off = 0;
  461. U32 owner_mask_on = 0;
  462. U32 group_mask_on = 0;
  463. U32 group_mask_off = 0;
  464. U32 everyone_mask_on = 0;
  465. U32 everyone_mask_off = 0;
  466. U32 next_owner_mask_on = 0;
  467. U32 next_owner_mask_off = 0;
  468. BOOL valid_base_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_BASE,
  469. &base_mask_on,
  470. &base_mask_off);
  471. //BOOL valid_owner_perms =//
  472. LLSelectMgr::getInstance()->selectGetPerm(PERM_OWNER,
  473. &owner_mask_on,
  474. &owner_mask_off);
  475. BOOL valid_group_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_GROUP,
  476. &group_mask_on,
  477. &group_mask_off);
  478. BOOL valid_everyone_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_EVERYONE,
  479. &everyone_mask_on,
  480. &everyone_mask_off);
  481. BOOL valid_next_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_NEXT_OWNER,
  482. &next_owner_mask_on,
  483. &next_owner_mask_off);
  484. if (gSavedSettings.getBOOL("DebugPermissions") )
  485. {
  486. if (valid_base_perms)
  487. {
  488. getChild<LLUICtrl>("B:")->setValue("B: " + mask_to_string(base_mask_on));
  489. getChildView("B:")->setVisible( TRUE);
  490. getChild<LLUICtrl>("O:")->setValue("O: " + mask_to_string(owner_mask_on));
  491. getChildView("O:")->setVisible( TRUE);
  492. getChild<LLUICtrl>("G:")->setValue("G: " + mask_to_string(group_mask_on));
  493. getChildView("G:")->setVisible( TRUE);
  494. getChild<LLUICtrl>("E:")->setValue("E: " + mask_to_string(everyone_mask_on));
  495. getChildView("E:")->setVisible( TRUE);
  496. getChild<LLUICtrl>("N:")->setValue("N: " + mask_to_string(next_owner_mask_on));
  497. getChildView("N:")->setVisible( TRUE);
  498. }
  499. U32 flag_mask = 0x0;
  500. if (objectp->permMove()) flag_mask |= PERM_MOVE;
  501. if (objectp->permModify()) flag_mask |= PERM_MODIFY;
  502. if (objectp->permCopy()) flag_mask |= PERM_COPY;
  503. if (objectp->permTransfer()) flag_mask |= PERM_TRANSFER;
  504. getChild<LLUICtrl>("F:")->setValue("F:" + mask_to_string(flag_mask));
  505. getChildView("F:")->setVisible( TRUE);
  506. }
  507. else
  508. {
  509. getChildView("B:")->setVisible( FALSE);
  510. getChildView("O:")->setVisible( FALSE);
  511. getChildView("G:")->setVisible( FALSE);
  512. getChildView("E:")->setVisible( FALSE);
  513. getChildView("N:")->setVisible( FALSE);
  514. getChildView("F:")->setVisible( FALSE);
  515. }
  516. BOOL has_change_perm_ability = FALSE;
  517. BOOL has_change_sale_ability = FALSE;
  518. if (valid_base_perms &&
  519. (self_owned || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_MANIPULATE))))
  520. {
  521. has_change_perm_ability = TRUE;
  522. }
  523. if (valid_base_perms &&
  524. (self_owned || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_SET_SALE))))
  525. {
  526. has_change_sale_ability = TRUE;
  527. }
  528. if (!has_change_perm_ability && !has_change_sale_ability && !root_selected)
  529. {
  530. // ...must select root to choose permissions
  531. getChild<LLUICtrl>("perm_modify")->setValue(getString("text modify warning"));
  532. }
  533. if (has_change_perm_ability)
  534. {
  535. getChildView("checkbox share with group")->setEnabled(TRUE);
  536. getChildView("checkbox allow everyone move")->setEnabled(owner_mask_on & PERM_MOVE);
  537. getChildView("checkbox allow everyone copy")->setEnabled(owner_mask_on & PERM_COPY && owner_mask_on & PERM_TRANSFER);
  538. }
  539. else
  540. {
  541. getChildView("checkbox share with group")->setEnabled(FALSE);
  542. getChildView("checkbox allow everyone move")->setEnabled(FALSE);
  543. getChildView("checkbox allow everyone copy")->setEnabled(FALSE);
  544. }
  545. if (has_change_sale_ability && (owner_mask_on & PERM_TRANSFER))
  546. {
  547. getChildView("checkbox for sale")->setEnabled(can_transfer || (!can_transfer && num_for_sale));
  548. // Set the checkbox to tentative if the prices of each object selected
  549. // are not the same.
  550. getChild<LLUICtrl>("checkbox for sale")->setTentative( is_for_sale_mixed);
  551. getChildView("sale type")->setEnabled(num_for_sale && can_transfer && !is_sale_price_mixed);
  552. getChildView("Next owner can:")->setEnabled(TRUE);
  553. getChildView("checkbox next owner can modify")->setEnabled(base_mask_on & PERM_MODIFY);
  554. getChildView("checkbox next owner can copy")->setEnabled(base_mask_on & PERM_COPY);
  555. getChildView("checkbox next owner can transfer")->setEnabled(next_owner_mask_on & PERM_COPY);
  556. }
  557. else
  558. {
  559. getChildView("checkbox for sale")->setEnabled(FALSE);
  560. getChildView("sale type")->setEnabled(FALSE);
  561. getChildView("Next owner can:")->setEnabled(FALSE);
  562. getChildView("checkbox next owner can modify")->setEnabled(FALSE);
  563. getChildView("checkbox next owner can copy")->setEnabled(FALSE);
  564. getChildView("checkbox next owner can transfer")->setEnabled(FALSE);
  565. }
  566. if (valid_group_perms)
  567. {
  568. if ((group_mask_on & PERM_COPY) && (group_mask_on & PERM_MODIFY) && (group_mask_on & PERM_MOVE))
  569. {
  570. getChild<LLUICtrl>("checkbox share with group")->setValue(TRUE);
  571. getChild<LLUICtrl>("checkbox share with group")->setTentative( FALSE);
  572. getChildView("button deed")->setEnabled(gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
  573. }
  574. else if ((group_mask_off & PERM_COPY) && (group_mask_off & PERM_MODIFY) && (group_mask_off & PERM_MOVE))
  575. {
  576. getChild<LLUICtrl>("checkbox share with group")->setValue(FALSE);
  577. getChild<LLUICtrl>("checkbox share with group")->setTentative( FALSE);
  578. getChildView("button deed")->setEnabled(FALSE);
  579. }
  580. else
  581. {
  582. getChild<LLUICtrl>("checkbox share with group")->setValue(TRUE);
  583. getChild<LLUICtrl>("checkbox share with group")->setTentative( TRUE);
  584. getChildView("button deed")->setEnabled(gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (group_mask_on & PERM_MOVE) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
  585. }
  586. }
  587. if (valid_everyone_perms)
  588. {
  589. // Move
  590. if (everyone_mask_on & PERM_MOVE)
  591. {
  592. getChild<LLUICtrl>("checkbox allow everyone move")->setValue(TRUE);
  593. getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( FALSE);
  594. }
  595. else if (everyone_mask_off & PERM_MOVE)
  596. {
  597. getChild<LLUICtrl>("checkbox allow everyone move")->setValue(FALSE);
  598. getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( FALSE);
  599. }
  600. else
  601. {
  602. getChild<LLUICtrl>("checkbox allow everyone move")->setValue(TRUE);
  603. getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( TRUE);
  604. }
  605. // Copy == everyone can't copy
  606. if (everyone_mask_on & PERM_COPY)
  607. {
  608. getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(TRUE);
  609. getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative( !can_copy || !can_transfer);
  610. }
  611. else if (everyone_mask_off & PERM_COPY)
  612. {
  613. getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(FALSE);
  614. getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative( FALSE);
  615. }
  616. else
  617. {
  618. getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(TRUE);
  619. getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative( TRUE);
  620. }
  621. }
  622. if (valid_next_perms)
  623. {
  624. // Modify == next owner canot modify
  625. if (next_owner_mask_on & PERM_MODIFY)
  626. {
  627. getChild<LLUICtrl>("checkbox next owner can modify")->setValue(TRUE);
  628. getChild<LLUICtrl>("checkbox next owner can modify")->setTentative( FALSE);
  629. }
  630. else if (next_owner_mask_off & PERM_MODIFY)
  631. {
  632. getChild<LLUICtrl>("checkbox next owner can modify")->setValue(FALSE);
  633. getChild<LLUICtrl>("checkbox next owner can modify")->setTentative( FALSE);
  634. }
  635. else
  636. {
  637. getChild<LLUICtrl>("checkbox next owner can modify")->setValue(TRUE);
  638. getChild<LLUICtrl>("checkbox next owner can modify")->setTentative( TRUE);
  639. }
  640. // Copy == next owner cannot copy
  641. if (next_owner_mask_on & PERM_COPY)
  642. {
  643. getChild<LLUICtrl>("checkbox next owner can copy")->setValue(TRUE);
  644. getChild<LLUICtrl>("checkbox next owner can copy")->setTentative( !can_copy);
  645. }
  646. else if (next_owner_mask_off & PERM_COPY)
  647. {
  648. getChild<LLUICtrl>("checkbox next owner can copy")->setValue(FALSE);
  649. getChild<LLUICtrl>("checkbox next owner can copy")->setTentative( FALSE);
  650. }
  651. else
  652. {
  653. getChild<LLUICtrl>("checkbox next owner can copy")->setValue(TRUE);
  654. getChild<LLUICtrl>("checkbox next owner can copy")->setTentative( TRUE);
  655. }
  656. // Transfer == next owner cannot transfer
  657. if (next_owner_mask_on & PERM_TRANSFER)
  658. {
  659. getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(TRUE);
  660. getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( !can_transfer);
  661. }
  662. else if (next_owner_mask_off & PERM_TRANSFER)
  663. {
  664. getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(FALSE);
  665. getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( FALSE);
  666. }
  667. else
  668. {
  669. getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(TRUE);
  670. getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( TRUE);
  671. }
  672. }
  673. // reflect sale information
  674. LLSaleInfo sale_info;
  675. BOOL valid_sale_info = LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info);
  676. LLSaleInfo::EForSale sale_type = sale_info.getSaleType();
  677. LLComboBox* combo_sale_type = getChild<LLComboBox>("sale type");
  678. if (valid_sale_info)
  679. {
  680. combo_sale_type->setValue( sale_type == LLSaleInfo::FS_NOT ? LLSaleInfo::FS_COPY : sale_type);
  681. combo_sale_type->setTentative( FALSE); // unfortunately this doesn't do anything at the moment.
  682. }
  683. else
  684. {
  685. // default option is sell copy, determined to be safest
  686. combo_sale_type->setValue( LLSaleInfo::FS_COPY);
  687. combo_sale_type->setTentative( TRUE); // unfortunately this doesn't do anything at the moment.
  688. }
  689. getChild<LLUICtrl>("checkbox for sale")->setValue((num_for_sale != 0));
  690. // HACK: There are some old objects in world that are set for sale,
  691. // but are no-transfer. We need to let users turn for-sale off, but only
  692. // if for-sale is set.
  693. bool cannot_actually_sell = !can_transfer || (!can_copy && sale_type == LLSaleInfo::FS_COPY);
  694. if (cannot_actually_sell)
  695. {
  696. if (num_for_sale && has_change_sale_ability)
  697. {
  698. getChildView("checkbox for sale")->setEnabled(true);
  699. }
  700. }
  701. // Check search status of objects
  702. const BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME );
  703. bool include_in_search;
  704. const BOOL all_include_in_search = LLSelectMgr::getInstance()->selectionGetIncludeInSearch(&include_in_search);
  705. getChildView("search_check")->setEnabled(has_change_sale_ability && all_volume);
  706. getChild<LLUICtrl>("search_check")->setValue(include_in_search);
  707. getChild<LLUICtrl>("search_check")->setTentative( !all_include_in_search);
  708. // Click action (touch, sit, buy)
  709. U8 click_action = 0;
  710. if (LLSelectMgr::getInstance()->selectionGetClickAction(&click_action))
  711. {
  712. LLComboBox* combo_click_action = getChild<LLComboBox>("clickaction");
  713. if(combo_click_action)
  714. {
  715. const std::string combo_value = click_action_to_string_value(click_action);
  716. combo_click_action->setValue(LLSD(combo_value));
  717. }
  718. }
  719. getChildView("label click action")->setEnabled(is_perm_modify && all_volume);
  720. getChildView("clickaction")->setEnabled(is_perm_modify && all_volume);
  721. }
  722. // static
  723. void LLPanelPermissions::onClickClaim(void*)
  724. {
  725. // try to claim ownership
  726. LLSelectMgr::getInstance()->sendOwner(gAgent.getID(), gAgent.getGroupID());
  727. }
  728. // static
  729. void LLPanelPermissions::onClickRelease(void*)
  730. {
  731. // try to release ownership
  732. LLSelectMgr::getInstance()->sendOwner(LLUUID::null, LLUUID::null);
  733. }
  734. void LLPanelPermissions::onClickGroup()
  735. {
  736. LLUUID owner_id;
  737. std::string name;
  738. BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, name);
  739. LLFloater* parent_floater = gFloaterView->getParentFloater(this);
  740. if(owners_identical && (owner_id == gAgent.getID()))
  741. {
  742. LLFloaterGroupPicker* fg = LLFloaterReg::showTypedInstance<LLFloaterGroupPicker>("group_picker", LLSD(gAgent.getID()));
  743. if (fg)
  744. {
  745. fg->setSelectGroupCallback( boost::bind(&LLPanelPermissions::cbGroupID, this, _1) );
  746. if (parent_floater)
  747. {
  748. LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, fg);
  749. fg->setOrigin(new_rect.mLeft, new_rect.mBottom);
  750. parent_floater->addDependentFloater(fg);
  751. }
  752. }
  753. }
  754. }
  755. void LLPanelPermissions::cbGroupID(LLUUID group_id)
  756. {
  757. if(mLabelGroupName)
  758. {
  759. mLabelGroupName->setNameID(group_id, TRUE);
  760. }
  761. LLSelectMgr::getInstance()->sendGroup(group_id);
  762. }
  763. bool callback_deed_to_group(const LLSD& notification, const LLSD& response)
  764. {
  765. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  766. if (0 == option)
  767. {
  768. LLUUID group_id;
  769. BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
  770. if(group_id.notNull() && groups_identical && (gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED)))
  771. {
  772. LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE);
  773. // LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT);
  774. }
  775. }
  776. return false;
  777. }
  778. void LLPanelPermissions::onClickDeedToGroup(void* data)
  779. {
  780. LLNotificationsUtil::add( "DeedObjectToGroup", LLSD(), LLSD(), callback_deed_to_group);
  781. }
  782. ///----------------------------------------------------------------------------
  783. /// Permissions checkboxes
  784. ///----------------------------------------------------------------------------
  785. // static
  786. void LLPanelPermissions::onCommitPerm(LLUICtrl *ctrl, void *data, U8 field, U32 perm)
  787. {
  788. LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject();
  789. if(!object) return;
  790. // Checkbox will have toggled itself
  791. // LLPanelPermissions* self = (LLPanelPermissions*)data;
  792. LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl;
  793. BOOL new_state = check->get();
  794. LLSelectMgr::getInstance()->selectionSetObjectPermissions(field, new_state, perm);
  795. }
  796. // static
  797. void LLPanelPermissions::onCommitGroupShare(LLUICtrl *ctrl, void *data)
  798. {
  799. onCommitPerm(ctrl, data, PERM_GROUP, PERM_MODIFY | PERM_MOVE | PERM_COPY);
  800. }
  801. // static
  802. void LLPanelPermissions::onCommitEveryoneMove(LLUICtrl *ctrl, void *data)
  803. {
  804. onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_MOVE);
  805. }
  806. // static
  807. void LLPanelPermissions::onCommitEveryoneCopy(LLUICtrl *ctrl, void *data)
  808. {
  809. onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_COPY);
  810. }
  811. // static
  812. void LLPanelPermissions::onCommitNextOwnerModify(LLUICtrl* ctrl, void* data)
  813. {
  814. //llinfos << "LLPanelPermissions::onCommitNextOwnerModify" << llendl;
  815. onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_MODIFY);
  816. }
  817. // static
  818. void LLPanelPermissions::onCommitNextOwnerCopy(LLUICtrl* ctrl, void* data)
  819. {
  820. //llinfos << "LLPanelPermissions::onCommitNextOwnerCopy" << llendl;
  821. onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_COPY);
  822. }
  823. // static
  824. void LLPanelPermissions::onCommitNextOwnerTransfer(LLUICtrl* ctrl, void* data)
  825. {
  826. //llinfos << "LLPanelPermissions::onCommitNextOwnerTransfer" << llendl;
  827. onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_TRANSFER);
  828. }
  829. // static
  830. void LLPanelPermissions::onCommitName(LLUICtrl*, void* data)
  831. {
  832. //llinfos << "LLPanelPermissions::onCommitName()" << llendl;
  833. LLPanelPermissions* self = (LLPanelPermissions*)data;
  834. LLLineEditor* tb = self->getChild<LLLineEditor>("Object Name");
  835. if(tb)
  836. {
  837. LLSelectMgr::getInstance()->selectionSetObjectName(tb->getText());
  838. // LLSelectMgr::getInstance()->selectionSetObjectName(self->mLabelObjectName->getText());
  839. }
  840. }
  841. // static
  842. void LLPanelPermissions::onCommitDesc(LLUICtrl*, void* data)
  843. {
  844. //llinfos << "LLPanelPermissions::onCommitDesc()" << llendl;
  845. LLPanelPermissions* self = (LLPanelPermissions*)data;
  846. LLLineEditor* le = self->getChild<LLLineEditor>("Object Description");
  847. if(le)
  848. {
  849. LLSelectMgr::getInstance()->selectionSetObjectDescription(le->getText());
  850. }
  851. }
  852. // static
  853. void LLPanelPermissions::onCommitSaleInfo(LLUICtrl*, void* data)
  854. {
  855. LLPanelPermissions* self = (LLPanelPermissions*)data;
  856. self->setAllSaleInfo();
  857. }
  858. // static
  859. void LLPanelPermissions::onCommitSaleType(LLUICtrl*, void* data)
  860. {
  861. LLPanelPermissions* self = (LLPanelPermissions*)data;
  862. self->setAllSaleInfo();
  863. }
  864. void LLPanelPermissions::setAllSaleInfo()
  865. {
  866. llinfos << "LLPanelPermissions::setAllSaleInfo()" << llendl;
  867. LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_NOT;
  868. LLCheckBoxCtrl *checkPurchase = getChild<LLCheckBoxCtrl>("checkbox for sale");
  869. // Set the sale type if the object(s) are for sale.
  870. if(checkPurchase && checkPurchase->get())
  871. {
  872. sale_type = static_cast<LLSaleInfo::EForSale>(getChild<LLComboBox>("sale type")->getValue().asInteger());
  873. }
  874. S32 price = -1;
  875. LLSpinCtrl *edit_price = getChild<LLSpinCtrl>("Edit Cost");
  876. price = (edit_price->getTentative()) ? DEFAULT_PRICE : edit_price->getValue().asInteger();
  877. // If somehow an invalid price, turn the sale off.
  878. if (price < 0)
  879. sale_type = LLSaleInfo::FS_NOT;
  880. LLSaleInfo old_sale_info;
  881. LLSelectMgr::getInstance()->selectGetSaleInfo(old_sale_info);
  882. LLSaleInfo new_sale_info(sale_type, price);
  883. LLSelectMgr::getInstance()->selectionSetObjectSaleInfo(new_sale_info);
  884. U8 old_click_action = 0;
  885. LLSelectMgr::getInstance()->selectionGetClickAction(&old_click_action);
  886. if (old_sale_info.isForSale()
  887. && !new_sale_info.isForSale()
  888. && old_click_action == CLICK_ACTION_BUY)
  889. {
  890. // If turned off for-sale, make sure click-action buy is turned
  891. // off as well
  892. LLSelectMgr::getInstance()->
  893. selectionSetClickAction(CLICK_ACTION_TOUCH);
  894. }
  895. else if (new_sale_info.isForSale()
  896. && !old_sale_info.isForSale()
  897. && old_click_action == CLICK_ACTION_TOUCH)
  898. {
  899. // If just turning on for-sale, preemptively turn on one-click buy
  900. // unless user have a different click action set
  901. LLSelectMgr::getInstance()->
  902. selectionSetClickAction(CLICK_ACTION_BUY);
  903. }
  904. }
  905. struct LLSelectionPayable : public LLSelectedObjectFunctor
  906. {
  907. virtual bool apply(LLViewerObject* obj)
  908. {
  909. // can pay if you or your parent has money() event in script
  910. LLViewerObject* parent = (LLViewerObject*)obj->getParent();
  911. return (obj->flagTakesMoney()
  912. || (parent && parent->flagTakesMoney()));
  913. }
  914. };
  915. // static
  916. void LLPanelPermissions::onCommitClickAction(LLUICtrl* ctrl, void*)
  917. {
  918. LLComboBox* box = (LLComboBox*)ctrl;
  919. if (!box) return;
  920. std::string value = box->getValue().asString();
  921. U8 click_action = string_value_to_click_action(value);
  922. if (click_action == CLICK_ACTION_BUY)
  923. {
  924. LLSaleInfo sale_info;
  925. LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info);
  926. if (!sale_info.isForSale())
  927. {
  928. LLNotificationsUtil::add("CantSetBuyObject");
  929. // Set click action back to its old value
  930. U8 click_action = 0;
  931. LLSelectMgr::getInstance()->selectionGetClickAction(&click_action);
  932. std::string item_value = click_action_to_string_value(click_action);
  933. box->setValue(LLSD(item_value));
  934. return;
  935. }
  936. }
  937. else if (click_action == CLICK_ACTION_PAY)
  938. {
  939. // Verify object has script with money() handler
  940. LLSelectionPayable payable;
  941. bool can_pay = LLSelectMgr::getInstance()->getSelection()->applyToObjects(&payable);
  942. if (!can_pay)
  943. {
  944. // Warn, but do it anyway.
  945. LLNotificationsUtil::add("ClickActionNotPayable");
  946. }
  947. }
  948. LLSelectMgr::getInstance()->selectionSetClickAction(click_action);
  949. }
  950. // static
  951. void LLPanelPermissions::onCommitIncludeInSearch(LLUICtrl* ctrl, void*)
  952. {
  953. LLCheckBoxCtrl* box = (LLCheckBoxCtrl*)ctrl;
  954. llassert(box);
  955. LLSelectMgr::getInstance()->selectionSetIncludeInSearch(box->get());
  956. }