void temp_upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed)
{
	LLResourceData* data = (LLResourceData*)user_data;
	if(result >= 0)
	{
		LLAssetType::EType dest_loc = (data->mPreferredLocation == LLAssetType::AT_NONE) ? data->mAssetInfo.mType : data->mPreferredLocation;
		LLUUID folder_id(gInventory.findCategoryUUIDForType(dest_loc));
		LLUUID item_id;
		item_id.generate();
		LLPermissions perm;
		perm.init(gAgentID,
				  gAgentID,
				  gAgentID,
				  gAgentID);
		perm.setMaskBase(PERM_ALL);
		perm.setMaskOwner(PERM_ALL);
		perm.setMaskEveryone(PERM_ALL);
		perm.setMaskGroup(PERM_ALL);
		LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem(item_id, folder_id, perm, data->mAssetInfo.mTransactionID.makeAssetID(gAgent.getSecureSessionID()), data->mAssetInfo.mType, data->mInventoryType, data->mAssetInfo.getName(), "", LLSaleInfo::DEFAULT, LLInventoryItem::II_FLAGS_NONE, time_corrected());
		item->updateServer(TRUE);
		gInventory.updateItem(item);
		gInventory.notifyObservers();
	}else // 	if(result >= 0)
	{
		LLSD args;
		args["FILE"] = LLInventoryType::lookupHumanReadable(data->mInventoryType);
		args["REASON"] = std::string(LLAssetStorage::getErrorString(result));
		LLNotifications::instance().add("CannotUploadReason", args);
	}

	LLUploadDialog::modalUploadFinished();
	delete data;
}
LLPermissions ll_permissions_from_sd(const LLSD& sd_perm)
{
	LLPermissions rv;
	rv.init(
		sd_perm[PERM_CREATOR_ID_LABEL].asUUID(),
		sd_perm[PERM_OWNER_ID_LABEL].asUUID(),
		sd_perm[PERM_LAST_OWNER_ID_LABEL].asUUID(),
		sd_perm[PERM_GROUP_ID_LABEL].asUUID());

	// We do a cast to U32 here since LLSD does not attempt to
	// represent unsigned ints.
	PermissionMask mask;
	mask = (U32)(sd_perm[PERM_BASE_MASK_LABEL].asInteger());
	rv.setMaskBase(mask);
	mask = (U32)(sd_perm[PERM_OWNER_MASK_LABEL].asInteger());
	rv.setMaskOwner(mask);
	mask = (U32)(sd_perm[PERM_EVERYONE_MASK_LABEL].asInteger());
	rv.setMaskEveryone(mask);
	mask = (U32)(sd_perm[PERM_GROUP_MASK_LABEL].asInteger());
	rv.setMaskGroup(mask);
	mask = (U32)(sd_perm[PERM_NEXT_OWNER_MASK_LABEL].asInteger());
	rv.setMaskNext(mask);
	rv.fix();
	return rv;
}
LLUUID LLLocalInventory::addItem(std::string name, int type, LLUUID asset_id)
{
    LLUUID item_id;
    item_id.generate();
    LLPermissions* perms = new LLPermissions();
    perms->set(LLPermissions::DEFAULT);
    perms->setOwnerAndGroup(LLUUID::null, LLUUID::null, LLUUID::null, false);
    perms->setMaskBase(0);
    perms->setMaskEveryone(0);
    perms->setMaskGroup(0);
    perms->setMaskNext(0);
    perms->setMaskOwner(0);
    LLViewerInventoryItem* item = new LLViewerInventoryItem(
        item_id,
        gSystemFolderAssets,
        *perms,
        asset_id,
        (LLAssetType::EType)type,
        (LLInventoryType::EType)type,
        name,
        "",
        LLSaleInfo::DEFAULT,
        0,
        time_corrected());
    addItem(item);
    return item_id;
}
// <edit>
void temp_upload_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed)
{
	LLResourceData* data = (LLResourceData*)user_data;
	
	if(result >= 0)
	{
		LLUUID item_id;
		item_id.generate();
		LLPermissions* perms = new LLPermissions();
		perms->set(LLPermissions::DEFAULT);
		perms->setOwnerAndGroup(gAgentID, gAgentID, gAgentID, false);


		perms->setMaskBase(PERM_ALL);
		perms->setMaskOwner(PERM_ALL);
		perms->setMaskEveryone(PERM_ALL);
		perms->setMaskGroup(PERM_ALL);
		perms->setMaskNext(PERM_ALL);
		
		LLUUID destination = gInventory.findCategoryUUIDForType(LLFolderType::FT_TEXTURE);
		BOOL bUseSystemInventory = (gSavedSettings.getBOOL("AscentUseSystemFolder") && gSavedSettings.getBOOL("AscentSystemTemporary"));
		if (bUseSystemInventory)
		{
			destination = gSystemFolderAssets;
		}
		LLViewerInventoryItem* item = new LLViewerInventoryItem(
				item_id,
				destination,
				*perms,
				uuid,
				(LLAssetType::EType)data->mAssetInfo.mType,
				(LLInventoryType::EType)data->mInventoryType,
				data->mAssetInfo.getName(),
				data->mAssetInfo.getDescription(),
				LLSaleInfo::DEFAULT,
				0,
				time_corrected());
		if (bUseSystemInventory)
		{
			LLLocalInventory::addItem(item);
		}
		else
		{
			item->updateServer(TRUE);
			gInventory.updateItem(item);
			gInventory.notifyObservers();
		}
	}
	else 
	{
		LLSD args;
		args["FILE"] = LLInventoryType::lookupHumanReadable(data->mInventoryType);
		args["REASON"] = std::string(LLAssetStorage::getErrorString(result));
		LLNotificationsUtil::add("CannotUploadReason", args);
	}

	LLUploadDialog::modalUploadFinished();
	delete data;
}
	void fire(const LLUUID &inv_item)
	{
		LLPreviewGesture::show(inv_item, LLUUID::null);
		
		LLInventoryItem* item = gInventory.getItem(inv_item);
		if (item)
		{
			LLPermissions perm = item->getPermissions();
			perm.setMaskNext(LLFloaterPerms::getNextOwnerPerms("Gestures"));
			perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("Gestures"));
			perm.setMaskGroup(LLFloaterPerms::getGroupPerms("Gestures"));
			item->setPermissions(perm);
			item->updateServer(FALSE);
		}
	}
Example #6
0
	void permission_object_t::test<3>()
	{
		LLPermissions permissions;
		U32 base = PERM_ALL;
		U32 owner = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
		U32 group = PERM_TRANSFER | PERM_MOVE | PERM_COPY|PERM_MODIFY;
		U32 everyone = PERM_TRANSFER | PERM_MOVE | PERM_MODIFY;
		U32 next = PERM_NONE;

		U32 fixedbase = base;
		U32 fixedowner = PERM_ITEM_UNRESTRICTED; //owner & fixedbase
		U32 fixedgroup = PERM_ITEM_UNRESTRICTED; // no PERM_MOVE as owner does not have that perm either
		U32 fixedeveryone = PERM_TRANSFER; // no PERM_MOVE. Everyone can never modify.
		U32 fixednext = PERM_NONE;

		permissions.initMasks(base, owner, everyone, group, next); // will fix perms if not allowed.
		ensure_equals("initMasks/getMaskBase():failed to return the MaskBase ", fixedbase, permissions.getMaskBase());	
		ensure_equals("initMasks/getMaskOwner():failed to return the MaskOwner ", fixedowner, permissions.getMaskOwner());	
		ensure_equals("initMasks/getMaskEveryone():failed to return the MaskGroup ", fixedgroup, permissions.getMaskGroup());	
		ensure_equals("initMasks/getMaskEveryone():failed to return the MaskEveryone ", fixedeveryone, permissions.getMaskEveryone());	
		ensure_equals("initMasks/getMaskNextOwner():failed to return the MaskNext ", fixednext, permissions.getMaskNextOwner());	

		// explictly set should maintain the values
		permissions.setMaskBase(base); //no fixing
		ensure_equals("setMaskBase/getMaskBase():failed to return the MaskBase ", base, permissions.getMaskBase());	

		permissions.setMaskOwner(owner);
		ensure_equals("setMaskOwner/getMaskOwner():failed to return the MaskOwner ", owner, permissions.getMaskOwner());	
		
		permissions.setMaskEveryone(everyone);
		ensure_equals("setMaskEveryone/getMaskEveryone():failed to return the MaskEveryone ", everyone, permissions.getMaskEveryone());	

		permissions.setMaskGroup(group);
		ensure_equals("setMaskGroup/getMaskEveryone():failed to return the MaskGroup ", group, permissions.getMaskGroup());	

		permissions.setMaskNext(next);
		ensure_equals("setMaskNext/getMaskNextOwner():failed to return the MaskNext ", next, permissions.getMaskNextOwner());	

		// further tests can be added to ensure perms for owner/group/everyone etc. get properly fixed. 
		// code however suggests that there is no explict check if the perms are correct and the user of this 
		// class is expected to know how to use them correctly. skipping further test cases for now for various
		// perm combinations.
	}
void LLViewerInventoryCategory::createBasicHair()
{
	LLUUID item_id = LLUUID("30d1d71b-38a6-4956-b27e-3bbcc17da0e2"); //lolhack, it's my UUID?
	
	//Make some hair just in case, using the library item so we're not hacking.
	LLUUID folder_id(gInventory.findCategoryUUIDForType(LLAssetType::AT_BODYPART));
	LLPermissions* perms = new LLPermissions();
	perms->set(LLPermissions::DEFAULT);
	perms->setOwnerAndGroup(LLUUID::null, LLUUID::null, LLUUID::null, false);
	perms->setMaskBase(0);
	perms->setMaskEveryone(0);
	perms->setMaskGroup(0);
	perms->setMaskNext(0);
	perms->setMaskOwner(0);
	LLViewerInventoryItem* item = new LLViewerInventoryItem(
			item_id,
			folder_id,
			*perms,
			LLUUID("f0581d0d-d7c4-2573-b2ce-7a5d6ded3851"),
			LLAssetType::AT_BODYPART,
			LLInventoryType::IT_WEARABLE,
			"RuthHairFix",
			"",
			LLSaleInfo::DEFAULT,
			0,
			0);

	//Update some stuff I guess
	LLInventoryModel::update_map_t update;
	++update[item->getParentUUID()];
	gInventory.accountForUpdate(update);
	gInventory.updateItem(item);
	gInventory.notifyObservers();
	

	wear_inventory_item_on_avatar(item);
}
// Allow calling cards to be dropped onto text fields.  Append the name and
// a carriage return.
// virtual
BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask,
					  BOOL drop, EDragAndDropType cargo_type, void *cargo_data,
					  EAcceptance *accept,
					  std::string& tooltip_msg)
{
	BOOL handled = FALSE;
	
	LLToolDragAndDrop::ESource source = LLToolDragAndDrop::getInstance()->getSource();
	if (LLToolDragAndDrop::SOURCE_NOTECARD == source)
	{
		// We currently do not handle dragging items from one notecard to another
		// since items in a notecard must be in Inventory to be verified. See DEV-2891.
		return FALSE;
	}
	
	if (mTakesNonScrollClicks)
	{
		if (getEnabled() && acceptsTextInput())
		{
			switch( cargo_type )
			{
			// <edit>
			// This does not even appear to be used maybe
			// Throwing it out so I can embed calling cards
			/*
			case DAD_CALLINGCARD:
				if(acceptsCallingCardNames())
				{
					if (drop)
					{
						LLInventoryItem *item = (LLInventoryItem *)cargo_data;
						std::string name = item->getName();
						appendText(name, true, true);
					}
					*accept = ACCEPT_YES_COPY_SINGLE;
				}
				else
				{
					*accept = ACCEPT_NO;
				}
				break;
			*/
			case DAD_CALLINGCARD:
			// </edit>
			case DAD_TEXTURE:
			case DAD_SOUND:
			case DAD_LANDMARK:
			case DAD_SCRIPT:
			case DAD_CLOTHING:
			case DAD_OBJECT:
			case DAD_NOTECARD:
			case DAD_BODYPART:
			case DAD_ANIMATION:
			case DAD_GESTURE:
				{
					LLInventoryItem *item = (LLInventoryItem *)cargo_data;
					// <edit>
					if((item->getPermissions().getMaskOwner() & PERM_ITEM_UNRESTRICTED) != PERM_ITEM_UNRESTRICTED)
					{
						if(gSavedSettings.getBOOL("ForceNotecardDragCargoPermissive"))
						{
							item = new LLInventoryItem((LLInventoryItem *)cargo_data);
							LLPermissions old = item->getPermissions();
							LLPermissions perm;
							perm.init(old.getCreator(), old.getOwner(), old.getLastOwner(), old.getGroup());
							perm.setMaskBase(PERM_ITEM_UNRESTRICTED);
							perm.setMaskEveryone(PERM_ITEM_UNRESTRICTED);
							perm.setMaskGroup(PERM_ITEM_UNRESTRICTED);
							perm.setMaskNext(PERM_ITEM_UNRESTRICTED);
							perm.setMaskOwner(PERM_ITEM_UNRESTRICTED);
							item->setPermissions(perm);
						}
					}
					// </edit>
					if( item && allowsEmbeddedItems() )
					{
						U32 mask_next = item->getPermissions().getMaskNextOwner();
						// <edit>
						//if((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
						if(((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) || gSavedSettings.getBOOL("ForceNotecardDragCargoAcceptance"))
						{
							if( drop )
							{
								deselect();
								S32 old_cursor = mCursorPos;
								setCursorAtLocalPos( x, y, TRUE );
								S32 insert_pos = mCursorPos;
								setCursorPos(old_cursor);
								BOOL inserted = insertEmbeddedItem( insert_pos, item );
								if( inserted && (old_cursor > mCursorPos) )
								{
									setCursorPos(mCursorPos + 1);
								}

								updateLineStartList();
							}
							*accept = ACCEPT_YES_COPY_MULTI;
						}
						else
						{
							*accept = ACCEPT_NO;
							if (tooltip_msg.empty())
							{
								tooltip_msg.assign("Only items with unrestricted\n"
													"'next owner' permissions \n"
													"can be attached to notecards.");
							}
						}
					}
					else
					{
						*accept = ACCEPT_NO;
					}
					break;
				}

			default:
				*accept = ACCEPT_NO;
				break;
			}
		}
		else
		{
			// Not enabled
			*accept = ACCEPT_NO;
		}

		handled = TRUE;
		LL_DEBUGS("UserInput") << "dragAndDrop handled by LLViewerTextEditor " << getName() << LL_ENDL;
	}

	return handled;
}