//static
bool LLObjectBackup::validateNode(LLSelectNode* node)
{
	LLPermissions* perms = node->mPermissions;
	if (!perms || !validatePerms(perms))
	{
		return false;
	}

	// Additionally check if this is a sculpt or a mesh object and if yes, if
	// we have export permission on the sclupt texture or the mesh object.
	LLViewerObject* obj = node->getObject();
	if (!obj)	// Paranoia
	{
		return false;
	}
	else if (obj->isSculpted())
	{
		if (obj->isMesh())
		{
			return false; // We can't export mesh from here, anyway.
		}
		else
		{
			LLSculptParams* params;
			params = (LLSculptParams*)obj->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
			LLUUID sculpt_id = params->getSculptTexture();
			return validateTexturePerms(sculpt_id);
		}
	}
	else
	{
		return true;
	}
}
// So far, only Second Life forces TPVs to verify the creator for textures...
// which sucks, because there is no other way to check for the texture
// permissions or creator than to try and find the asset(s) corresponding to
// the texture in the inventory and check the permissions/creator on the said
// asset(s), meaning that if you created the texture and subsequently deleted
// it from your inventory, you will not be able to export it any more !!!
// The "must be creator" stuff also goes against the usage in Linden Lab's own
// official viewers, since those allow you to save full perm textures (such as
// the textures in the Library), whoever is the actual creator... Go figure !
LLUUID LLObjectBackup::validateTextureID(LLUUID asset_id)
{
	if (!gHippoGridManager->getConnectedGrid()->isSecondLife())
	{
		// If we are not in Second Life, don't bother.
		return asset_id;
	}
	LLUUID texture = LL_TEXTURE_PLYWOOD;
	if (asset_id == texture ||
		asset_id == LL_TEXTURE_BLANK ||
		asset_id == LL_TEXTURE_INVISIBLE ||
		asset_id == LL_TEXTURE_TRANSPARENT ||
		asset_id == LL_TEXTURE_MEDIA)
	{
		// Allow to export a few default SL textures.
		return asset_id;
	}
	LLViewerInventoryCategory::cat_array_t cats;
	LLViewerInventoryItem::item_array_t items;
	LLAssetIDMatches asset_id_matches(asset_id);
	gInventory.collectDescendentsIf(LLUUID::null,
							cats,
							items,
							LLInventoryModel::INCLUDE_TRASH,
							asset_id_matches);

	if (items.count())
	{
		for (S32 i = 0; i < items.count(); i++)
		{
			const LLPermissions item_permissions = items[i]->getPermissions();
			if (validatePerms(&item_permissions))
			{
				texture = asset_id;
			}
		}
	}

	if (texture != asset_id)
	{
		mNonExportedTextures |= TEXTURE_BAD_PERM;
	}

	return texture;
}
//static
bool LLObjectBackup::validateTexturePerms(const LLUUID& asset_id)
{
	if (LFSimFeatureHandler::instance().exportPolicy() == ep_full_perm)
	{
		// If we are not in Second Life and we don't have export-permission
		// support, don't bother and unconditionally accept the texture export
		// (legacy behaviour).
		return true;
	}

	if (asset_id == LL_TEXTURE_PLYWOOD ||
		asset_id == LL_TEXTURE_BLANK ||
		asset_id == LL_TEXTURE_INVISIBLE ||
		asset_id == LL_TEXTURE_TRANSPARENT ||
		asset_id == LL_TEXTURE_MEDIA)
	{
		// Allow to export a few default SL textures.
		return true;
	}

	LLViewerInventoryCategory::cat_array_t cats;
	LLViewerInventoryItem::item_array_t items;
	LLAssetIDMatches asset_id_matches(asset_id);
	gInventory.collectDescendentsIf(LLUUID::null, cats, items,
							LLInventoryModel::INCLUDE_TRASH,
							asset_id_matches);
	S32 count = items.size();
	if (count > 0)
	{
		for (S32 i = 0; i < count; ++i)
		{
			const LLPermissions item_permissions = items[i]->getPermissions();
			if (validatePerms(&item_permissions))
			{
				return true;
			}
		}
	}

	return false;
}
Exemplo n.º 4
0
// So far, only Second Life forces TPVs to verify the creator for textures...
// which sucks, because there is no other way to check for the texture
// permissions or creator than to try and find the asset(s) corresponding to
// the texture in the inventory and check the permissions/creator on the said
// asset(s), meaning that if you created the texture and subsequently deleted
// it from your inventory, you will not be able to export it any more !!!
// The "must be creator" stuff also goes against the usage in Linden Lab's own
// official viewers, since those allow you to save full perm textures (such as
// the textures in the Library), whoever is the actual creator... Go figure !
LLUUID LLObjectBackup::validateTextureID(LLUUID asset_id)
{
	if (gHippoGridManager->getConnectedGrid()->getPlatform() != HippoGridInfo::PLATFORM_SECONDLIFE)
	{
		// If we are not in Second Life, don't bother.
		return asset_id;
	}
	LLUUID texture = LLUUID(gSavedSettings.getString("DefaultObjectTexture"));
	LLViewerInventoryCategory::cat_array_t cats;
	LLViewerInventoryItem::item_array_t items;
	LLAssetIDMatches asset_id_matches(asset_id);
	gInventory.collectDescendentsIf(LLUUID::null,
							cats,
							items,
							LLInventoryModel::INCLUDE_TRASH,
							asset_id_matches);

	if (items.count())
	{
		for (S32 i = 0; i < items.count(); i++)
		{
			const LLPermissions item_permissions = items[i]->getPermissions();
			if (validatePerms(&item_permissions))
			{
				texture = asset_id;
			}
		}
	}

	if (texture != asset_id)
	{
		mNonExportedTextures |= TEXTURE_BAD_PERM;
	}

	return texture;
}