PageRenderTime 130ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llfloaterperms.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 132 lines | 85 code | 17 blank | 30 comment | 4 complexity | f273259f5135d2b263b3230f56f7f4b5 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llfloaterperms.cpp
  3. * @brief Asset creation permission preferences.
  4. * @author Coco
  5. *
  6. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #include "llviewerprecompiledheaders.h"
  28. #include "llcheckboxctrl.h"
  29. #include "llfloaterperms.h"
  30. #include "llviewercontrol.h"
  31. #include "llviewerwindow.h"
  32. #include "lluictrlfactory.h"
  33. #include "llpermissions.h"
  34. LLFloaterPerms::LLFloaterPerms(const LLSD& seed)
  35. : LLFloater(seed)
  36. {
  37. mCommitCallbackRegistrar.add("Perms.Copy", boost::bind(&LLFloaterPerms::onCommitCopy, this));
  38. mCommitCallbackRegistrar.add("Perms.OK", boost::bind(&LLFloaterPerms::onClickOK, this));
  39. mCommitCallbackRegistrar.add("Perms.Cancel", boost::bind(&LLFloaterPerms::onClickCancel, this));
  40. }
  41. BOOL LLFloaterPerms::postBuild()
  42. {
  43. mCloseSignal.connect(boost::bind(&LLFloaterPerms::cancel, this));
  44. refresh();
  45. return TRUE;
  46. }
  47. void LLFloaterPerms::onClickOK()
  48. {
  49. ok();
  50. closeFloater();
  51. }
  52. void LLFloaterPerms::onClickCancel()
  53. {
  54. cancel();
  55. closeFloater();
  56. }
  57. void LLFloaterPerms::onCommitCopy()
  58. {
  59. // Implements fair use
  60. BOOL copyable = gSavedSettings.getBOOL("NextOwnerCopy");
  61. if(!copyable)
  62. {
  63. gSavedSettings.setBOOL("NextOwnerTransfer", TRUE);
  64. }
  65. LLCheckBoxCtrl* xfer = getChild<LLCheckBoxCtrl>("next_owner_transfer");
  66. xfer->setEnabled(copyable);
  67. }
  68. void LLFloaterPerms::ok()
  69. {
  70. refresh(); // Changes were already applied to saved settings. Refreshing internal values makes it official.
  71. }
  72. void LLFloaterPerms::cancel()
  73. {
  74. gSavedSettings.setBOOL("ShareWithGroup", mShareWithGroup);
  75. gSavedSettings.setBOOL("EveryoneCopy", mEveryoneCopy);
  76. gSavedSettings.setBOOL("NextOwnerCopy", mNextOwnerCopy);
  77. gSavedSettings.setBOOL("NextOwnerModify", mNextOwnerModify);
  78. gSavedSettings.setBOOL("NextOwnerTransfer", mNextOwnerTransfer);
  79. }
  80. void LLFloaterPerms::refresh()
  81. {
  82. mShareWithGroup = gSavedSettings.getBOOL("ShareWithGroup");
  83. mEveryoneCopy = gSavedSettings.getBOOL("EveryoneCopy");
  84. mNextOwnerCopy = gSavedSettings.getBOOL("NextOwnerCopy");
  85. mNextOwnerModify = gSavedSettings.getBOOL("NextOwnerModify");
  86. mNextOwnerTransfer = gSavedSettings.getBOOL("NextOwnerTransfer");
  87. }
  88. //static
  89. U32 LLFloaterPerms::getGroupPerms(std::string prefix)
  90. {
  91. return gSavedSettings.getBOOL(prefix+"ShareWithGroup") ? PERM_COPY : PERM_NONE;
  92. }
  93. //static
  94. U32 LLFloaterPerms::getEveryonePerms(std::string prefix)
  95. {
  96. return gSavedSettings.getBOOL(prefix+"EveryoneCopy") ? PERM_COPY : PERM_NONE;
  97. }
  98. //static
  99. U32 LLFloaterPerms::getNextOwnerPerms(std::string prefix)
  100. {
  101. U32 flags = PERM_MOVE;
  102. if ( gSavedSettings.getBOOL(prefix+"NextOwnerCopy") )
  103. {
  104. flags |= PERM_COPY;
  105. }
  106. if ( gSavedSettings.getBOOL(prefix+"NextOwnerModify") )
  107. {
  108. flags |= PERM_MODIFY;
  109. }
  110. if ( gSavedSettings.getBOOL(prefix+"NextOwnerTransfer") )
  111. {
  112. flags |= PERM_TRANSFER;
  113. }
  114. return flags;
  115. }