llfloaterperms.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:4k
源码类别:

游戏引擎

开发平台:

C++ Builder

  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-2010, 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 "llcheckboxctrl.h"
  35. #include "llfloaterperms.h"
  36. #include "llviewercontrol.h"
  37. #include "llviewerwindow.h"
  38. #include "lluictrlfactory.h"
  39. #include "llpermissions.h"
  40. LLFloaterPerms::LLFloaterPerms(const LLSD& seed)
  41. : LLFloater(seed)
  42. {
  43. //LLUICtrlFactory::getInstance()->buildFloater(this, "floater_perm_prefs.xml");
  44. mCommitCallbackRegistrar.add("Perms.Copy", boost::bind(&LLFloaterPerms::onCommitCopy, this));
  45. mCommitCallbackRegistrar.add("Perms.OK", boost::bind(&LLFloaterPerms::onClickOK, this));
  46. mCommitCallbackRegistrar.add("Perms.Cancel", boost::bind(&LLFloaterPerms::onClickCancel, this));
  47. }
  48. BOOL LLFloaterPerms::postBuild()
  49. {
  50. mCloseSignal.connect(boost::bind(&LLFloaterPerms::cancel, this));
  51. refresh();
  52. return TRUE;
  53. }
  54. void LLFloaterPerms::onClickOK()
  55. {
  56. ok();
  57. closeFloater();
  58. }
  59. void LLFloaterPerms::onClickCancel()
  60. {
  61. cancel();
  62. closeFloater();
  63. }
  64. void LLFloaterPerms::onCommitCopy()
  65. {
  66. // Implements fair use
  67. BOOL copyable = gSavedSettings.getBOOL("NextOwnerCopy");
  68. if(!copyable)
  69. {
  70. gSavedSettings.setBOOL("NextOwnerTransfer", TRUE);
  71. }
  72. LLCheckBoxCtrl* xfer = getChild<LLCheckBoxCtrl>("next_owner_transfer");
  73. xfer->setEnabled(copyable);
  74. }
  75. void LLFloaterPerms::ok()
  76. {
  77. refresh(); // Changes were already applied to saved settings. Refreshing internal values makes it official.
  78. }
  79. void LLFloaterPerms::cancel()
  80. {
  81. gSavedSettings.setBOOL("ShareWithGroup",    mShareWithGroup);
  82. gSavedSettings.setBOOL("EveryoneCopy",      mEveryoneCopy);
  83. gSavedSettings.setBOOL("NextOwnerCopy",     mNextOwnerCopy);
  84. gSavedSettings.setBOOL("NextOwnerModify",   mNextOwnerModify);
  85. gSavedSettings.setBOOL("NextOwnerTransfer", mNextOwnerTransfer);
  86. }
  87. void LLFloaterPerms::refresh()
  88. {
  89. mShareWithGroup    = gSavedSettings.getBOOL("ShareWithGroup");
  90. mEveryoneCopy      = gSavedSettings.getBOOL("EveryoneCopy");
  91. mNextOwnerCopy     = gSavedSettings.getBOOL("NextOwnerCopy");
  92. mNextOwnerModify   = gSavedSettings.getBOOL("NextOwnerModify");
  93. mNextOwnerTransfer = gSavedSettings.getBOOL("NextOwnerTransfer");
  94. }
  95. //static 
  96. U32 LLFloaterPerms::getGroupPerms(std::string prefix)
  97. {
  98. return gSavedSettings.getBOOL(prefix+"ShareWithGroup") ? PERM_COPY : PERM_NONE;
  99. }
  100. //static 
  101. U32 LLFloaterPerms::getEveryonePerms(std::string prefix)
  102. {
  103. return gSavedSettings.getBOOL(prefix+"EveryoneCopy") ? PERM_COPY : PERM_NONE;
  104. }
  105. //static 
  106. U32 LLFloaterPerms::getNextOwnerPerms(std::string prefix)
  107. {
  108. U32 flags = 0;
  109. if ( gSavedSettings.getBOOL(prefix+"NextOwnerCopy") )
  110. {
  111. flags |= PERM_COPY;
  112. }
  113. if ( gSavedSettings.getBOOL(prefix+"NextOwnerModify") )
  114. {
  115. flags |= PERM_MODIFY;
  116. }
  117. if ( gSavedSettings.getBOOL(prefix+"NextOwnerTransfer") )
  118. {
  119. flags |= PERM_TRANSFER;
  120. }
  121. return flags;
  122. }