From accd89b3f1c7729e6bb34b52e8095baf9c1f440a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 26 Apr 2008 20:31:01 +0000 Subject: * First draft implementation of copying prim inventory items back to agent inventory * Now, if you own an item in a prim, you should be able to successfully drag it back into your inventory * Temporarily, users which are not owners of the item cannot copy it, even if 'everyone can copy' is set * This is pending fixes/implementation of upstream permission implementation --- .../Region/Environment/Scenes/Scene.Inventory.cs | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'OpenSim/Region/Environment/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 40650f3..67d3dfb 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -83,6 +83,14 @@ namespace OpenSim.Region.Environment.Scenes } EventManager.TriggerOnNewInventoryItemUploadComplete(remoteClient.AgentId, item.AssetID, item.Name, userlevel); } + else + { + m_log.ErrorFormat( + "[AGENT INVENTORY]: Agent {0} {1} was not found for add of item {2} {3}", + remoteClient.Name, remoteClient.AgentId, item.Name, item.ID); + + return; + } } /// @@ -696,6 +704,79 @@ namespace OpenSim.Region.Environment.Scenes localID); } } + + /// + /// Move the given item in the given prim to a folder in the client's inventory + /// + /// + /// + /// + /// + public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId) + { + SceneObjectGroup group = GetGroupByPrim(primLocalId); + + if (null == group) + { + m_log.WarnFormat( + "[PRIM INVENTORY]: " + + "Move of inventory item {0} from prim with local id {1} failed because the prim could not be found", + itemId, primLocalId); + + return; + } + + TaskInventoryItem taskItem = group.GetInventoryItem(primLocalId, itemId); + + if (null == taskItem) + { + // Console already notified of error in GetInventoryItem + return; + } + +// bool permission; +// permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId, +// ((SceneObjectGroup) selectedEnt).UUID); + + // Pending resolving upstream problems with permissions, we just won't allow anybody who is not the owner + // to copy + if (remoteClient.AgentId != taskItem.OwnerID) + { + m_log.InfoFormat( + "[PRIM INVENTORY]: Attempt made by {0} {1} to copy inventory item {2} {3} in prim {4} {5}," + + " but temporarily not allowed pending upstream bugfixes/feature implementation", + remoteClient.Name, remoteClient.AgentId, taskItem.Name, taskItem.ItemID, group.Name, group.UUID); + + return; + } + + InventoryItemBase agentItem = new InventoryItemBase(); + + agentItem.ID = LLUUID.Random(); + agentItem.Creator = taskItem.CreatorID; + agentItem.Owner = remoteClient.AgentId; + agentItem.AssetID = taskItem.AssetID; + agentItem.Description = taskItem.Description; + agentItem.Name = taskItem.Name; + agentItem.AssetType = taskItem.Type; + agentItem.InvType = taskItem.InvType; + agentItem.Folder = folderId; + agentItem.EveryOnePermissions = taskItem.EveryoneMask; + + if (remoteClient.AgentId != taskItem.OwnerID) { + agentItem.BasePermissions = taskItem.NextOwnerMask; + agentItem.CurrentPermissions = taskItem.NextOwnerMask; + agentItem.NextPermissions = taskItem.NextOwnerMask; + } + else + { + agentItem.BasePermissions = taskItem.BaseMask; + agentItem.CurrentPermissions = taskItem.OwnerMask; + agentItem.NextPermissions = taskItem.NextOwnerMask; + } + + AddInventoryItem(remoteClient, agentItem); + } /// /// Update an item in a prim (task) inventory. -- cgit v1.1