PageRenderTime 15ms CodeModel.GetById 1ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

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