Completed code migration from LLViewerWearable to LLWearable.
This commit is contained in:
@@ -3,31 +3,25 @@
|
||||
* @author Phoenix
|
||||
* @brief Permissions for objects and inventory.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2002-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
@@ -578,143 +572,17 @@ void LLPermissions::unpackMessage(LLMessageSystem* msg, const char* block, S32 b
|
||||
|
||||
BOOL LLPermissions::importFile(LLFILE* fp)
|
||||
{
|
||||
init(LLUUID::null, LLUUID::null, LLUUID::null, LLUUID::null);
|
||||
const S32 BUFSIZE = 16384;
|
||||
|
||||
// *NOTE: Changing the buffer size will require changing the scanf
|
||||
// calls below.
|
||||
char buffer[BUFSIZE]; /* Flawfinder: ignore */
|
||||
char keyword[256]; /* Flawfinder: ignore */
|
||||
char valuestr[256]; /* Flawfinder: ignore */
|
||||
char uuid_str[256]; /* Flawfinder: ignore */
|
||||
U32 mask;
|
||||
|
||||
keyword[0] = '\0';
|
||||
valuestr[0] = '\0';
|
||||
|
||||
while (!feof(fp))
|
||||
{
|
||||
if (fgets(buffer, BUFSIZE, fp) == NULL)
|
||||
{
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
|
||||
sscanf( /* Flawfinder: ignore */
|
||||
buffer,
|
||||
" %255s %255s",
|
||||
keyword, valuestr);
|
||||
if (!strcmp("{", keyword))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!strcmp("}",keyword))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (!strcmp("creator_mask", keyword))
|
||||
{
|
||||
// legacy support for "creator" masks
|
||||
sscanf(valuestr, "%x", &mask);
|
||||
mMaskBase = mask;
|
||||
fixFairUse();
|
||||
}
|
||||
else if (!strcmp("base_mask", keyword))
|
||||
{
|
||||
sscanf(valuestr, "%x", &mask);
|
||||
mMaskBase = mask;
|
||||
//fixFairUse();
|
||||
}
|
||||
else if (!strcmp("owner_mask", keyword))
|
||||
{
|
||||
sscanf(valuestr, "%x", &mask);
|
||||
mMaskOwner = mask;
|
||||
}
|
||||
else if (!strcmp("group_mask", keyword))
|
||||
{
|
||||
sscanf(valuestr, "%x", &mask);
|
||||
mMaskGroup = mask;
|
||||
}
|
||||
else if (!strcmp("everyone_mask", keyword))
|
||||
{
|
||||
sscanf(valuestr, "%x", &mask);
|
||||
mMaskEveryone = mask;
|
||||
}
|
||||
else if (!strcmp("next_owner_mask", keyword))
|
||||
{
|
||||
sscanf(valuestr, "%x", &mask);
|
||||
mMaskNextOwner = mask;
|
||||
}
|
||||
else if (!strcmp("creator_id", keyword))
|
||||
{
|
||||
sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
|
||||
mCreator.set(uuid_str);
|
||||
}
|
||||
else if (!strcmp("owner_id", keyword))
|
||||
{
|
||||
sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
|
||||
mOwner.set(uuid_str);
|
||||
}
|
||||
else if (!strcmp("last_owner_id", keyword))
|
||||
{
|
||||
sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
|
||||
mLastOwner.set(uuid_str);
|
||||
}
|
||||
else if (!strcmp("group_id", keyword))
|
||||
{
|
||||
sscanf(valuestr, "%255s", uuid_str); /* Flawfinder: ignore */
|
||||
mGroup.set(uuid_str);
|
||||
}
|
||||
else if (!strcmp("group_owned", keyword))
|
||||
{
|
||||
sscanf(valuestr, "%d", &mask);
|
||||
if(mask) mIsGroupOwned = true;
|
||||
else mIsGroupOwned = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
llinfos << "unknown keyword " << keyword << " in permissions import" << llendl;
|
||||
}
|
||||
}
|
||||
fix();
|
||||
return TRUE;
|
||||
llifstream ifs(fp);
|
||||
return importStream(ifs);
|
||||
}
|
||||
|
||||
|
||||
BOOL LLPermissions::exportFile(LLFILE* fp) const
|
||||
{
|
||||
std::string uuid_str;
|
||||
|
||||
fprintf(fp, "\tpermissions 0\n");
|
||||
fprintf(fp, "\t{\n");
|
||||
|
||||
fprintf(fp, "\t\tbase_mask\t%08x\n", mMaskBase);
|
||||
fprintf(fp, "\t\towner_mask\t%08x\n", mMaskOwner);
|
||||
fprintf(fp, "\t\tgroup_mask\t%08x\n", mMaskGroup);
|
||||
fprintf(fp, "\t\teveryone_mask\t%08x\n", mMaskEveryone);
|
||||
fprintf(fp, "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner);
|
||||
|
||||
mCreator.toString(uuid_str);
|
||||
fprintf(fp, "\t\tcreator_id\t%s\n", uuid_str.c_str());
|
||||
|
||||
mOwner.toString(uuid_str);
|
||||
fprintf(fp, "\t\towner_id\t%s\n", uuid_str.c_str());
|
||||
|
||||
mLastOwner.toString(uuid_str);
|
||||
fprintf(fp, "\t\tlast_owner_id\t%s\n", uuid_str.c_str());
|
||||
|
||||
mGroup.toString(uuid_str);
|
||||
fprintf(fp, "\t\tgroup_id\t%s\n", uuid_str.c_str());
|
||||
|
||||
if(mIsGroupOwned)
|
||||
{
|
||||
fprintf(fp, "\t\tgroup_owned\t1\n");
|
||||
}
|
||||
fprintf(fp,"\t}\n");
|
||||
return TRUE;
|
||||
llofstream ofs(fp);
|
||||
return exportStream(ofs);
|
||||
}
|
||||
|
||||
|
||||
BOOL LLPermissions::importLegacyStream(std::istream& input_stream)
|
||||
BOOL LLPermissions::importStream(std::istream& input_stream)
|
||||
{
|
||||
init(LLUUID::null, LLUUID::null, LLUUID::null, LLUUID::null);
|
||||
const S32 BUFSIZE = 16384;
|
||||
@@ -733,6 +601,18 @@ BOOL LLPermissions::importLegacyStream(std::istream& input_stream)
|
||||
while (input_stream.good())
|
||||
{
|
||||
input_stream.getline(buffer, BUFSIZE);
|
||||
if (input_stream.eof())
|
||||
{
|
||||
llwarns << "Bad permissions: early end of input stream"
|
||||
<< llendl;
|
||||
return FALSE;
|
||||
}
|
||||
if (input_stream.fail())
|
||||
{
|
||||
llwarns << "Bad permissions: failed to read from input stream"
|
||||
<< llendl;
|
||||
return FALSE;
|
||||
}
|
||||
sscanf( /* Flawfinder: ignore */
|
||||
buffer,
|
||||
" %255s %255s",
|
||||
@@ -806,7 +686,8 @@ BOOL LLPermissions::importLegacyStream(std::istream& input_stream)
|
||||
}
|
||||
else
|
||||
{
|
||||
llinfos << "unknown keyword " << keyword << " in permissions import" << llendl;
|
||||
llwarns << "unknown keyword " << keyword
|
||||
<< " in permissions import" << llendl;
|
||||
}
|
||||
}
|
||||
fix();
|
||||
@@ -814,36 +695,26 @@ BOOL LLPermissions::importLegacyStream(std::istream& input_stream)
|
||||
}
|
||||
|
||||
|
||||
BOOL LLPermissions::exportLegacyStream(std::ostream& output_stream) const
|
||||
BOOL LLPermissions::exportStream(std::ostream& output_stream) const
|
||||
{
|
||||
std::string uuid_str;
|
||||
|
||||
if (!output_stream.good()) return FALSE;
|
||||
output_stream << "\tpermissions 0\n";
|
||||
output_stream << "\t{\n";
|
||||
|
||||
std::string buffer;
|
||||
buffer = llformat( "\t\tbase_mask\t%08x\n", mMaskBase);
|
||||
output_stream << buffer;
|
||||
buffer = llformat( "\t\towner_mask\t%08x\n", mMaskOwner);
|
||||
output_stream << buffer;
|
||||
buffer = llformat( "\t\tgroup_mask\t%08x\n", mMaskGroup);
|
||||
output_stream << buffer;
|
||||
buffer = llformat( "\t\teveryone_mask\t%08x\n", mMaskEveryone);
|
||||
output_stream << buffer;
|
||||
buffer = llformat( "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner);
|
||||
output_stream << buffer;
|
||||
char prev_fill = output_stream.fill('0');
|
||||
output_stream << std::hex;
|
||||
output_stream << "\t\tbase_mask\t" << std::setw(8) << mMaskBase << "\n";
|
||||
output_stream << "\t\towner_mask\t" << std::setw(8) << mMaskOwner << "\n";
|
||||
output_stream << "\t\tgroup_mask\t" << std::setw(8) << mMaskGroup << "\n";
|
||||
output_stream << "\t\teveryone_mask\t" << std::setw(8) << mMaskEveryone << "\n";
|
||||
output_stream << "\t\tnext_owner_mask\t" << std::setw(8) << mMaskNextOwner << "\n";
|
||||
output_stream << std::dec;
|
||||
output_stream.fill(prev_fill);
|
||||
|
||||
mCreator.toString(uuid_str);
|
||||
output_stream << "\t\tcreator_id\t" << uuid_str << "\n";
|
||||
|
||||
mOwner.toString(uuid_str);
|
||||
output_stream << "\t\towner_id\t" << uuid_str << "\n";
|
||||
|
||||
mLastOwner.toString(uuid_str);
|
||||
output_stream << "\t\tlast_owner_id\t" << uuid_str << "\n";
|
||||
|
||||
mGroup.toString(uuid_str);
|
||||
output_stream << "\t\tgroup_id\t" << uuid_str << "\n";
|
||||
output_stream << "\t\tcreator_id\t" << mCreator << "\n";
|
||||
output_stream << "\t\towner_id\t" << mOwner << "\n";
|
||||
output_stream << "\t\tlast_owner_id\t" << mLastOwner << "\n";
|
||||
output_stream << "\t\tgroup_id\t" << mGroup << "\n";
|
||||
|
||||
if(mIsGroupOwned)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user