llfloaterperms.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /**
  2. * @file llfloaterperms.cpp
  3. * @brief Asset creation permission preferences.
  4. * @author Coco
  5. *
  6. * $LicenseInfo:firstyear=2001&license=viewergpl$
  7. *
  8. * Copyright (c) 2001-2009, Linden Research, Inc.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #include "llviewerprecompiledheaders.h"
  34. #include "llfloaterperms.h"
  35. #include "llpermissions.h"
  36. #include "lluictrlfactory.h"
  37. #include "llviewercontrol.h"
  38. LLFloaterPerms::LLFloaterPerms(const LLSD& seed)
  39. {
  40. LLUICtrlFactory::getInstance()->buildFloater(this,
  41. "floater_perm_prefs.xml");
  42. }
  43. //virtual
  44. bool LLFloaterPerms::postBuild()
  45. {
  46. childSetEnabled("next_owner_transfer",
  47. gSavedSettings.getBool("NextOwnerCopy"));
  48. childSetAction("ok", onClickOK, this);
  49. childSetAction("cancel", onClickCancel, this);
  50. childSetCommitCallback("next_owner_copy", &onCommitCopy, this);
  51. refresh();
  52. return true;
  53. }
  54. //virtual
  55. void LLFloaterPerms::refresh()
  56. {
  57. mShareWithGroup = gSavedSettings.getBool("ShareWithGroup");
  58. mEveryoneCopy = gSavedSettings.getBool("EveryoneCopy");
  59. mNextOwnerCopy = gSavedSettings.getBool("NextOwnerCopy");
  60. mNextOwnerModify = gSavedSettings.getBool("NextOwnerModify");
  61. mNextOwnerTransfer = gSavedSettings.getBool("NextOwnerTransfer");
  62. mFullPermNotecards = gSavedSettings.getBool("FullPermNotecards");
  63. mFullPermSnapshots = gSavedSettings.getBool("FullPermSnapshots");
  64. mNoModScripts = gSavedSettings.getBool("NoModScripts");
  65. }
  66. void LLFloaterPerms::cancel()
  67. {
  68. gSavedSettings.setBool("ShareWithGroup", mShareWithGroup);
  69. gSavedSettings.setBool("EveryoneCopy", mEveryoneCopy);
  70. gSavedSettings.setBool("NextOwnerCopy", mNextOwnerCopy);
  71. gSavedSettings.setBool("NextOwnerModify", mNextOwnerModify);
  72. gSavedSettings.setBool("NextOwnerTransfer", mNextOwnerTransfer);
  73. gSavedSettings.setBool("FullPermNotecards", mFullPermNotecards);
  74. gSavedSettings.setBool("FullPermSnapshots", mFullPermSnapshots);
  75. gSavedSettings.setBool("NoModScripts", mNoModScripts);
  76. }
  77. void LLFloaterPerms::onClose(bool app_quitting)
  78. {
  79. // Cancel any unsaved changes before closing.
  80. // Note: when closed due to the OK button this amounts to a no-op.
  81. cancel();
  82. LLFloater::onClose(app_quitting);
  83. }
  84. //static
  85. void LLFloaterPerms::onClickOK(void* data)
  86. {
  87. LLFloaterPerms* self = (LLFloaterPerms*)data;
  88. if (self)
  89. {
  90. // Store changed flags so that cancel() in onClose() doesn't revert
  91. // them...
  92. self->refresh();
  93. self->close();
  94. }
  95. }
  96. //static
  97. void LLFloaterPerms::onClickCancel(void* data)
  98. {
  99. LLFloaterPerms* self = (LLFloaterPerms*)data;
  100. if (self)
  101. {
  102. self->cancel();
  103. self->close();
  104. }
  105. }
  106. //static
  107. void LLFloaterPerms::onCommitCopy(LLUICtrl* ctrl, void* data)
  108. {
  109. LLFloaterPerms* self = (LLFloaterPerms*)data;
  110. if (!self) return;
  111. // Implements fair use
  112. bool copyable = gSavedSettings.getBool("NextOwnerCopy");
  113. if (!copyable)
  114. {
  115. gSavedSettings.setBool("NextOwnerTransfer", true);
  116. }
  117. self->childSetEnabled("next_owner_transfer", copyable);
  118. }
  119. //static
  120. U32 LLFloaterPerms::getGroupPerms(const std::string& prefix)
  121. {
  122. std::string cname = prefix + "ShareWithGroup";
  123. return gSavedSettings.getBool(cname.c_str()) ? PERM_COPY
  124. : PERM_NONE;
  125. }
  126. //static
  127. U32 LLFloaterPerms::getEveryonePerms(const std::string& prefix)
  128. {
  129. std::string cname = prefix + "EveryoneCopy";
  130. return gSavedSettings.getBool(cname.c_str()) ? PERM_COPY
  131. : PERM_NONE;
  132. }
  133. //static
  134. U32 LLFloaterPerms::getNextOwnerPerms(const std::string& prefix)
  135. {
  136. U32 flags = PERM_MOVE;
  137. std::string cname = prefix + "NextOwnerCopy";
  138. if (gSavedSettings.getBool(cname.c_str()))
  139. {
  140. flags |= PERM_COPY;
  141. }
  142. cname = prefix + "NextOwnerModify";
  143. if (gSavedSettings.getBool(cname.c_str()))
  144. {
  145. flags |= PERM_MODIFY;
  146. }
  147. cname = prefix + "NextOwnerTransfer";
  148. if (gSavedSettings.getBool(cname.c_str()))
  149. {
  150. flags |= PERM_TRANSFER;
  151. }
  152. return flags;
  153. }