AddInventoryItem() public method

Add the given inventory item to a user's inventory.
public AddInventoryItem ( InventoryItemBase item ) : bool
item InventoryItemBase
return bool
Esempio n. 1
0
 public static InventoryItemBase CreateInventoryItem(
     Scene scene, string itemName, UUID itemId, string folderPath, UUID userId)
 {
     InventoryItemBase item = new InventoryItemBase();
     item.Name = itemName;
     item.AssetID = AssetHelpers.CreateAsset(scene, userId).FullID;
     item.ID = itemId;
     
     // Really quite bad since the objs folder could be moved in the future and confuse the tests
     InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object);
     
     item.Folder = objsFolder.ID;
     scene.AddInventoryItem(item);
     
     return item;
 }
        /// <summary>
        /// Creates a notecard in the objects folder and specify an item id.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="itemName"></param>
        /// <param name="itemId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static InventoryItemBase CreateInventoryItem(Scene scene, string itemName, UUID itemId, UUID userId)
        {
            AssetBase asset = AssetHelpers.CreateAsset(scene, userId);
            InventoryItemBase item = new InventoryItemBase();
            item.Name = itemName;
            item.AssetID = asset.FullID;
            item.ID = itemId;
            item.Owner = userId;
            item.AssetType = asset.Type;
            item.InvType = (int)InventoryType.Notecard;

            InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, AssetType.Notecard);
            
            item.Folder = folder.ID;
            scene.AddInventoryItem(item);
            
            return item;
        }
Esempio n. 3
0
        /// <summary>
        /// Adds the given item to an inventory folder
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="itemName"></param>
        /// <param name="itemId"></param>
        /// <param name="itemType"></param>
        /// <param name="asset">The serialized asset for this item</param>
        /// <param name="userId"></param>
        /// <param name="path">Existing inventory path at which to add.</param>
        /// <returns></returns>
        private static InventoryItemBase AddInventoryItem(
            Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId, string path)
        {
            scene.AssetService.Store(asset);

            InventoryItemBase item = new InventoryItemBase();
            item.Name = itemName;
            item.AssetID = asset.FullID;
            item.ID = itemId;
            item.Owner = userId;
            item.AssetType = asset.Type;
            item.InvType = (int)itemType;

            InventoryFolderBase folder = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, path)[0];

            item.Folder = folder.ID;
            scene.AddInventoryItem(item);

            return item;
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a notecard in the objects folder and specify an item id.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="itemName"></param>
        /// <param name="itemId"></param>
        /// <param name="assetId"></param>
        /// <param name="userId"></param>
        /// <param name="type">Type of item to create</param>
        /// <returns></returns>
        public static InventoryItemBase CreateInventoryItem(
            Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType type)
        {
            AssetBase asset = null;

            if (type == InventoryType.Notecard)
                asset = AssetHelpers.CreateAsset(scene, userId);
            else if (type == InventoryType.Object)
                asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
            else
                throw new Exception(string.Format("Inventory type {0} not supported", type));

            scene.AssetService.Store(asset);

            InventoryItemBase item = new InventoryItemBase();
            item.Name = itemName;
            item.AssetID = asset.FullID;
            item.ID = itemId;
            item.Owner = userId;
            item.AssetType = asset.Type;
            item.InvType = (int)type;

            InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, AssetType.Notecard);
            
            item.Folder = folder.ID;
            scene.AddInventoryItem(item);
            
            return item;
        }
        /// <summary>
        /// Adds the given item to an inventory folder
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="itemName"></param>
        /// <param name="itemId"></param>
        /// <param name="itemType"></param>
        /// <param name="asset">The serialized asset for this item</param>
        /// <param name="userId"></param>
        /// <param name="path">Existing inventory path at which to add.</param>
        /// <returns></returns>
        private static InventoryItemBase AddInventoryItem(
            Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId, string path)
        {
            scene.AssetService.Store(asset);

            InventoryItemBase item = new InventoryItemBase();
            item.Name = itemName;
            item.AssetID = asset.FullID;
            item.ID = itemId;
            item.Owner = userId;
            item.AssetType = asset.Type;
            item.InvType = (int)itemType;
            item.BasePermissions = (uint)OpenMetaverse.PermissionMask.All | 
                (uint)(Framework.PermissionMask.foldedMask | Framework.PermissionMask.foldedCopy | Framework.PermissionMask.foldedModify | Framework.PermissionMask.foldedTransfer);
            item.CurrentPermissions = (uint)OpenMetaverse.PermissionMask.All |
                (uint)(Framework.PermissionMask.foldedMask | Framework.PermissionMask.foldedCopy | Framework.PermissionMask.foldedModify | Framework.PermissionMask.foldedTransfer);

            InventoryFolderBase folder = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, path)[0];

            item.Folder = folder.ID;
            scene.AddInventoryItem(item);

            return item;
        }
        private void TaskInventoryOfferDecline(IClientAPI client, Scene scene, GridInstantMessage im)
        {
            // The inventory item/folder, back from it's trip
            UUID inventoryEntityID = new UUID(im.imSessionID);

            // Here, the recipient is local and we can assume that the inventory is loaded.
            // Courtesy of the above bulk update, it will have been pushed to the client, too.
            CachedUserInfo userInfo = scene.CommsManager.UserService.GetUserDetails(client.AgentId);
            if (userInfo != null)
            {
                InventoryFolderBase trashFolder = userInfo.FindFolderForType((int)FolderType.Trash);
                if (null == trashFolder)
                {
                    client.SendAgentAlertMessage("Unable to decline received inventory: Trash folder not found.", false);
                    return;
                }

                // Is it a folder or an item?
                if (userInfo.QueryItem(inventoryEntityID))
                {   // It's an item.
                    InventoryItemBase item = userInfo.FindItem(inventoryEntityID);
                    if (item == null)
                    {
                        client.SendAgentAlertMessage("Unable to decline received inventory: item/folder not found.", false);
                        return;
                    }
                    userInfo.MoveItemToTrash(item, trashFolder);
                    scene.AddInventoryItem(client, item);
                    client.SendInventoryItemCreateUpdate(item, 0);
                }
                else
                {   // It's a folder.
                    InventoryFolderBase folder = userInfo.GetFolderAttributes(inventoryEntityID);
                    userInfo.MoveFolder(inventoryEntityID, trashFolder.ID);
                    folder = userInfo.GetFolder(inventoryEntityID);
                    if (folder != null)
                    {
                        client.SendBulkUpdateInventory(folder);
                        // If we don't send the descendents, viewer shows "Loading..." on the trash item.
                        userInfo.SendInventoryDecendents(client, folder.ID, false, true);
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a notecard in the objects folder and specify an item id.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="itemName"></param>
        /// <param name="itemId"></param>
        /// <param name="itemType"></param>
        /// <param name="asset">The serialized asset for this item</param>
        /// <param name="userId"></param>
        /// <returns></returns>
        private static InventoryItemBase AddInventoryItem(
            Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId)
        {
            scene.AssetService.Store(asset);

            InventoryItemBase item = new InventoryItemBase();
            item.Name = itemName;
            item.AssetID = asset.FullID;
            item.ID = itemId;
            item.Owner = userId;
            item.AssetType = asset.Type;
            item.InvType = (int)itemType;

            InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type);

            item.Folder = folder.ID;
            scene.AddInventoryItem(item);

            return item;
        }
        public UUID MoveInventory(Scene scene,UUID destID, string category, SceneObjectPart host, List<UUID> items)
        {
            InventoryFolderBase StoreFolder = new InventoryFolderBase();
            List<InventoryFolderBase> m_invbase = new List<InventoryFolderBase> ();
            m_invbase = inventoryService.GetInventorySkeleton (destID);
            foreach (InventoryFolderBase current in m_invbase) {
                if (current.Name.ToString () == "Web Store Items") {
                    StoreFolder = current;
                }
            }

            UUID newFolderID = UUID.Random();

            InventoryFolderBase newFolder = new InventoryFolderBase(newFolderID, category, destID, -1, StoreFolder.ID, StoreFolder.Version);
            inventoryService.AddFolder(newFolder);

            foreach (UUID itemID in items)
            {
                InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(scene,destID, host, itemID);

                if (agentItem != null)
                {
                    agentItem.Folder = newFolderID;

                    scene.AddInventoryItem(agentItem);
                }
            }

            ScenePresence avatar = null;
            if (scene.TryGetScenePresence(destID, out avatar))
            {
                scene.SendInventoryUpdate(avatar.ControllingClient, StoreFolder, true, false);
                scene.SendInventoryUpdate(avatar.ControllingClient, newFolder, false, true);
            }

            return newFolderID;
        }