OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
/// <summary>
/// Create an item using details for the given scene object.
/// </summary>
/// <param name="action"></param>
/// <param name="remoteClient"></param>
/// <param name="so"></param>
/// <param name="folderID"></param>
/// <returns></returns>
Create an item using details for the given scene object.
Create an item using details for the given scene object .
protected InventoryItemBase CreateItemForObject(
            DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID)
        {
             Get the user info of the item destination
            UUID userID = UUID.Zero;
            if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
                action == DeRezAction.SaveToExistingUserInventoryItem)
            {
                 Take or take copy require a taker
                 Saving changes requires a local user
                if (remoteClient == null)
                    return null;
                userID = remoteClient.AgentId;
                m_log.DebugFormat(
                    "[INVENTORY ACCESS MODULE]: Target of {0} in CreateItemForObject() is {1} {2}",
                    action, remoteClient.Name, userID);
            }
            else if (so.RootPart.OwnerID == so.RootPart.GroupID)
            {
                 Group owned objects go to the last owner before the object was transferred.
                userID = so.RootPart.LastOwnerID;
            }
            else
            {
                 Other returns / deletes go to the object owner
                userID = so.RootPart.OwnerID;
                m_log.DebugFormat(
                    "[INVENTORY ACCESS MODULE]: Target of {0} in CreateItemForObject() is object owner {1}",
                    action, userID);
            }
            if (userID == UUID.Zero)  Can't proceed
            {
                return null;
            }
             If we're returning someone's item, it goes back to the
             owner's Lost And Found folder.
             Delete is treated like return in this case
             Deleting your own items makes them go to trash
            InventoryFolderBase folder = null;
            InventoryItemBase item = null;
            if (DeRezAction.SaveToExistingUserInventoryItem == action)
            {
                item = new InventoryItemBase(so.RootPart.FromUserInventoryItemID, userID);
                item = m_Scene.InventoryService.GetItem(item);
                item = userInfo.RootFolder.FindItem(
                        objectGroup.RootPart.FromUserInventoryItemID);
                if (null == item)
                {
                    m_log.DebugFormat(
                        "[INVENTORY ACCESS MODULE]:  Object {0} {1} scheduled for save to inventory has already been deleted.",
                        so.Name, so.UUID);
                    return null;
                }
            }
            else
            {
                 Folder magic
                if (action == DeRezAction.Delete)
                {
                     Deleting someone else's item
                    if (remoteClient == null ||
                        so.OwnerID != remoteClient.AgentId)
                    {
                        folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
                    }
                    else
                    {
                        folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
                    }
                }
                else if (action == DeRezAction.Return)
                {
                     Dump to lost + found unconditionally
                    folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
                }
                if (folderID == UUID.Zero && folder == null)
                {
                    if (action == DeRezAction.Delete)
                    {
                         Deletes go to trash by default
                        folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
                    }
                    else
                    {
                        if (remoteClient == null || so.RootPart.OwnerID != remoteClient.AgentId)
                        {
                             Taking copy of another person's item. Take to
                             Objects folder.
                            folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
                            so.FromFolderID = UUID.Zero;
                        }
                        else
                        {
                             Catch all. Use lost & found
                            folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
                        }
                    }
                }
                 Override and put into where it came from, if it came
                 from anywhere in inventory and the owner is taking it back.
                if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
                {
                    if (so.FromFolderID != UUID.Zero && so.RootPart.OwnerID == remoteClient.AgentId)
                    {
                        InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID);
                        folder = m_Scene.InventoryService.GetFolder(f);
                        if(folder.Type == 14 || folder.Type == 16)
                        {
                             folder.Type = 6;
                            folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
                        }
                    }
                }
                if (folder == null)  None of the above
                {
                    folder = new InventoryFolderBase(folderID);
                    if (folder == null)  Nowhere to put it
                    {
                        return null;
                    }
                }
                item = new InventoryItemBase();                
                item.ID = UUID.Random();
                item.InvType = (int)InventoryType.Object;
                item.Folder = folder.ID;
                item.Owner = userID;
            }   
            return item;
        }
protected InventoryItemBase CreateItemForObject ( DeRezAction action , IClientAPI remoteClient , SceneObjectGroup so , UUID folderID ) { UUID userID = UUID . Zero ; if ( action == DeRezAction . Take || action == DeRezAction . TakeCopy || action == DeRezAction . SaveToExistingUserInventoryItem ) { if ( remoteClient == null ) return null ; userID = remoteClient . AgentId ; } else if ( so . RootPart . OwnerID == so . RootPart . GroupID ) { userID = so . RootPart . LastOwnerID ; } else { userID = so . RootPart . OwnerID ; } if ( userID == UUID . Zero ) { return null ; } InventoryFolderBase folder = null ; InventoryItemBase item = null ; if ( DeRezAction . SaveToExistingUserInventoryItem == action ) { item = new InventoryItemBase ( so . RootPart . FromUserInventoryItemID , userID ) ; item = m_Scene . InventoryService . GetItem ( item ) ; if ( null == item ) { m_log . DebugFormat ( " " , so . Name , so . UUID ) ; return null ; } } else { if ( action == DeRezAction . Delete ) { if ( remoteClient == null || so . OwnerID != remoteClient . AgentId ) { folder = m_Scene . InventoryService . GetFolderForType ( userID , AssetType . LostAndFoundFolder ) ; } else { folder = m_Scene . InventoryService . GetFolderForType ( userID , AssetType . TrashFolder ) ; } } else if ( action == DeRezAction . Return ) { folder = m_Scene . InventoryService . GetFolderForType ( userID , AssetType . LostAndFoundFolder ) ; } if ( folderID == UUID . Zero && folder == null ) { if ( action == DeRezAction . Delete ) { folder = m_Scene . InventoryService . GetFolderForType ( userID , AssetType . TrashFolder ) ; } else { if ( remoteClient == null || so . RootPart . OwnerID != remoteClient . AgentId ) { folder = m_Scene . InventoryService . GetFolderForType ( userID , AssetType . Object ) ; so . FromFolderID = UUID . Zero ; } else { folder = m_Scene . InventoryService . GetFolderForType ( userID , AssetType . LostAndFoundFolder ) ; } } } if ( action == DeRezAction . Take || action == DeRezAction . TakeCopy ) { if ( so . FromFolderID != UUID . Zero && so . RootPart . OwnerID == remoteClient . AgentId ) { InventoryFolderBase f = new InventoryFolderBase ( so . FromFolderID , userID ) ; folder = m_Scene . InventoryService . GetFolder ( f ) ; if ( folder . Type == 14 || folder . Type == 16 ) { folder = m_Scene . InventoryService . GetFolderForType ( userID , AssetType . Object ) ; } } } if ( folder == null ) { folder = new InventoryFolderBase ( folderID ) ; if ( folder == null ) { return null ; } } item = new InventoryItemBase ( ) ; item . ID = UUID . Random ( ) ; item . InvType = ( int ) InventoryType . Object ; item . Folder = folder . ID ; item . Owner = userID ; } return item ; }
Create an item using details for the given scene object.
Create an item using details for the given scene object .
//            m_log.DebugFormat( //                "[BASIC INVENTORY ACCESS MODULE]: Creating item for object {0} {1} for folder {2}, action {3}",  //                so.Name, so.UUID, folderID, action); // // Get the user info of the item destination // // Take or take copy require a taker // Saving changes requires a local user // //                m_log.DebugFormat( //                    "[INVENTORY ACCESS MODULE]: Target of {0} in CreateItemForObject() is {1} {2}", //                    action, remoteClient.Name, userID); // Group owned objects go to the last owner before the object was transferred. // Other returns / deletes go to the object owner // //                m_log.DebugFormat( //                    "[INVENTORY ACCESS MODULE]: Target of {0} in CreateItemForObject() is object owner {1}", //                    action, userID); // Can't proceed // If we're returning someone's item, it goes back to the // owner's Lost And Found folder. // Delete is treated like return in this case // Deleting your own items makes them go to trash // //item = userInfo.RootFolder.FindItem( //        objectGroup.RootPart.FromUserInventoryItemID); // Folder magic // // Deleting someone else's item // // Dump to lost + found unconditionally // // Deletes go to trash by default // // Taking copy of another person's item. Take to // Objects folder. // Catch all. Use lost & found // // Override and put into where it came from, if it came // from anywhere in inventory and the owner is taking it back. // // folder.Type = 6; // None of the above // Nowhere to put it
None
action
DeRezAction
None
remoteClient
IClientAPI
None
so
SceneObjectGroup
None
folderID
UUID
None