void LLInventoryItem::asLLSD( LLSD& sd ) const
{
	sd[INV_ITEM_ID_LABEL] = mUUID;
	sd[INV_PARENT_ID_LABEL] = mParentUUID;
	sd[INV_PERMISSIONS_LABEL] = ll_create_sd_from_permissions(mPermissions);

	U32 mask = mPermissions.getMaskBase();
	if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
		|| (mAssetUUID.isNull()))
	{
		sd[INV_ASSET_ID_LABEL] = mAssetUUID;
	}
	else
	{
		// *TODO: get rid of this. Phoenix 2008-01-30
		LLUUID shadow_id(mAssetUUID);
		LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
		cipher.encrypt(shadow_id.mData, UUID_BYTES);
		sd[INV_SHADOW_ID_LABEL] = shadow_id;
	}
	sd[INV_ASSET_TYPE_LABEL] = LLAssetType::lookup(mType);
	sd[INV_INVENTORY_TYPE_LABEL] = mInventoryType;
	const std::string inv_type_str = LLInventoryType::lookup(mInventoryType);
	if(!inv_type_str.empty())
	{
		sd[INV_INVENTORY_TYPE_LABEL] = inv_type_str;
	}
	//sd[INV_FLAGS_LABEL] = (S32)mFlags;
	sd[INV_FLAGS_LABEL] = ll_sd_from_U32(mFlags);
	sd[INV_SALE_INFO_LABEL] = mSaleInfo;
	sd[INV_NAME_LABEL] = mName;
	sd[INV_DESC_LABEL] = mDescription;
	sd[INV_CREATION_DATE_LABEL] = (S32) mCreationDate;
}
Exemple #2
0
LLSD LLInventoryItem::asLLSD() const
{
	LLSD sd = LLSD();
	sd["item_id"] = mUUID;
	sd["parent_id"] = mParentUUID;
	sd["permissions"] = ll_create_sd_from_permissions(mPermissions);

	U32 mask = mPermissions.getMaskBase();
	if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
		|| (mAssetUUID.isNull()))
	{
		sd["asset_id"] = mAssetUUID;
	}
	else
	{
		LLUUID shadow_id(mAssetUUID);
		LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
		cipher.encrypt(shadow_id.mData, UUID_BYTES);
		sd["shadow_id"] = shadow_id;
	}
	sd["type"] = LLAssetType::lookup(mType);
	const char* inv_type_str = LLInventoryType::lookup(mInventoryType);
	if(inv_type_str)
	{
		sd["inv_type"] = inv_type_str;
	}
	sd["flags"] = ll_sd_from_U32(mFlags);
	sd["sale_info"] = mSaleInfo;
	sd["name"] = mName;
	sd["desc"] = mDescription;
	sd["creation_date"] = mCreationDate;

	return sd;
}
LLXMLNode *LLInventoryItem::exportFileXML(BOOL include_asset_key) const
{
	LLMemType m1(LLMemType::MTYPE_INVENTORY);
	LLXMLNode *ret = new LLXMLNode("item", FALSE);

	ret->createChild("uuid", TRUE)->setUUIDValue(1, &mUUID);
	ret->createChild("parent_uuid", TRUE)->setUUIDValue(1, &mParentUUID);

	mPermissions.exportFileXML()->setParent(ret);

	// Check for permissions to see the asset id, and if so write it
	// out as an asset id. Otherwise, apply our cheesy encryption.
	if(include_asset_key)
	{
		U32 mask = mPermissions.getMaskBase();
		if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
		   || (mAssetUUID.isNull()))
		{
			ret->createChild("asset_id", FALSE)->setUUIDValue(1, &mAssetUUID);
		}
		else
		{
			LLUUID shadow_id(mAssetUUID);
			LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
			cipher.encrypt(shadow_id.mData, UUID_BYTES);

			ret->createChild("shadow_id", FALSE)->setUUIDValue(1, &shadow_id);
		}
	}

	std::string type_str = LLAssetType::lookup(mType);
	std::string inv_type_str = LLInventoryType::lookup(mInventoryType);

	ret->createChild("asset_type", FALSE)->setStringValue(type_str);
	ret->createChild("inventory_type", FALSE)->setStringValue(inv_type_str);
	S32 tmp_flags = (S32) mFlags;
	ret->createChild("flags", FALSE)->setByteValue(4, (U8*)(&tmp_flags), LLXMLNode::ENCODING_HEX);

	mSaleInfo.exportFileXML()->setParent(ret);

	std::string temp;
	temp.assign(mName);
	ret->createChild("name", FALSE)->setStringValue(temp);
	temp.assign(mDescription);
	ret->createChild("description", FALSE)->setStringValue(temp);
	S32 date = mCreationDate;
	ret->createChild("creation_date", FALSE)->setIntValue(1, &date);

	return ret;
}
BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL include_asset_key) const
{
	std::string uuid_str;
	output_stream << "\tinv_item\t0\n\t{\n";
	mUUID.toString(uuid_str);
	output_stream << "\t\titem_id\t" << uuid_str << "\n";
	mParentUUID.toString(uuid_str);
	output_stream << "\t\tparent_id\t" << uuid_str << "\n";
	mPermissions.exportLegacyStream(output_stream);

	// Check for permissions to see the asset id, and if so write it
	// out as an asset id. Otherwise, apply our cheesy encryption.
	if(include_asset_key)
	{
		U32 mask = mPermissions.getMaskBase();
		if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
		   || (mAssetUUID.isNull()))
		{
			mAssetUUID.toString(uuid_str);
			output_stream << "\t\tasset_id\t" << uuid_str << "\n";
		}
		else
		{
			LLUUID shadow_id(mAssetUUID);
			LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
			cipher.encrypt(shadow_id.mData, UUID_BYTES);
			shadow_id.toString(uuid_str);
			output_stream << "\t\tshadow_id\t" << uuid_str << "\n";
		}
	}
	else
	{
		LLUUID::null.toString(uuid_str);
		output_stream << "\t\tasset_id\t" << uuid_str << "\n";
	}
	output_stream << "\t\ttype\t" << LLAssetType::lookup(mType) << "\n";
	const char* inv_type_str = LLInventoryType::lookup(mInventoryType);
	if(inv_type_str) 
		output_stream << "\t\tinv_type\t" << inv_type_str << "\n";
	std::string buffer;
	buffer = llformat( "\t\tflags\t%08x\n", mFlags);
	output_stream << buffer;
	mSaleInfo.exportLegacyStream(output_stream);
	output_stream << "\t\tname\t" << mName.c_str() << "|\n";
	output_stream << "\t\tdesc\t" << mDescription.c_str() << "|\n";
	output_stream << "\t\tcreation_date\t" << mCreationDate << "\n";
	output_stream << "\t}\n";
	return TRUE;
}
BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const
{
	std::string uuid_str;
	fprintf(fp, "\tinv_item\t0\n\t{\n");
	mUUID.toString(uuid_str);
	fprintf(fp, "\t\titem_id\t%s\n", uuid_str.c_str());
	mParentUUID.toString(uuid_str);
	fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str());
	mPermissions.exportFile(fp);

	// Check for permissions to see the asset id, and if so write it
	// out as an asset id. Otherwise, apply our cheesy encryption.
	if(include_asset_key)
	{
		U32 mask = mPermissions.getMaskBase();
		if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
		   || (mAssetUUID.isNull()))
		{
			mAssetUUID.toString(uuid_str);
			fprintf(fp, "\t\tasset_id\t%s\n", uuid_str.c_str());
		}
		else
		{
			LLUUID shadow_id(mAssetUUID);
			LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
			cipher.encrypt(shadow_id.mData, UUID_BYTES);
			shadow_id.toString(uuid_str);
			fprintf(fp, "\t\tshadow_id\t%s\n", uuid_str.c_str());
		}
	}
	else
	{
		LLUUID::null.toString(uuid_str);
		fprintf(fp, "\t\tasset_id\t%s\n", uuid_str.c_str());
	}
	fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
	const char* inv_type_str = LLInventoryType::lookup(mInventoryType);
	if(inv_type_str) fprintf(fp, "\t\tinv_type\t%s\n", inv_type_str);
	fprintf(fp, "\t\tflags\t%08x\n", mFlags);
	mSaleInfo.exportFile(fp);
	fprintf(fp, "\t\tname\t%s|\n", mName.c_str());
	fprintf(fp, "\t\tdesc\t%s|\n", mDescription.c_str());
	fprintf(fp, "\t\tcreation_date\t%d\n", (S32) mCreationDate);
	fprintf(fp,"\t}\n");
	return TRUE;
}
void FSWSAssetBlacklist::saveBlacklist()
{
	llofstream save_file(mBlacklistFileName);
	LLSD savedata;

	for (blacklist_data_t::const_iterator itr = mBlacklistData.begin(); itr != mBlacklistData.end(); ++itr)
	{
		// <FS:CR> Apply "cheesy encryption" to obfuscate these to the user.
		LLUUID shadow_id(itr->first);
		LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
		cipher.encrypt(shadow_id.mData, UUID_BYTES);
		savedata[shadow_id.asString()] = itr->second;
	}

	LLSDSerialize::toPrettyXML(savedata, save_file);	
	save_file.close();
}
LLSD LLInventoryItem::exportLLSD(bool include_asset_key)
{
	// Cache items
	LLSD inv_item = LLSD::emptyArray();

	LLSD item = LLSD::emptyMap();
	item["item_id"] = mUUID;
	item["parent_id"] = mParentUUID;

	item["permissions"] = ll_create_sd_from_permissions(mPermissions);

	// Check for permissions to see the asset id, and if so write it
	// out as an asset id. Otherwise, apply our cheesy encryption.
	if (include_asset_key)
	{
		U32 mask = mPermissions.getMaskBase();
		if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
		   || (mAssetUUID.isNull()))
		{
			item["asset_id"] = mAssetUUID;
		}
		else
		{
			LLUUID shadow_id(mAssetUUID);
			LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
			cipher.encrypt(shadow_id.mData, UUID_BYTES);
			item["shadow_id"] = shadow_id;
		}
	}
	else
	{
		item["asset_id"] = LLUUID::null;
	}
	item["type"] = LLAssetType::lookup(mType);
	item["inv_type"] = LLInventoryType::lookup(mInventoryType);
	item["flags"] = llformat("%08x", mFlags);
	item["name"] = mName;
	item["desc"] = mDescription;
	item["creation_date"] = (S32)mCreationDate;

	inv_item["inv_item"] = item;

	return inv_item;
}