From 124f66bfc25984a01491b8447fa97bea2633281c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 18 Aug 2009 22:17:47 -0700 Subject: jhurliman's patch in http://opensimulator.org/mantis/view.php?id=4024 --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 35 ++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 46777e1..48c7f4e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -140,7 +140,8 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) { - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { @@ -315,7 +316,8 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID, UUID itemID, InventoryItemBase itemUpd) { - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { @@ -408,7 +410,8 @@ namespace OpenSim.Region.Framework.Scenes { Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemId)); + InventoryItemBase item = new InventoryItemBase(itemId, senderId); + item = InventoryService.GetItem(item); if ((item != null) && (item.Owner == senderId)) { @@ -558,7 +561,8 @@ namespace OpenSim.Region.Framework.Scenes if (item == null) { - item = InventoryService.GetItem(new InventoryItemBase(oldItemID)); + item = new InventoryItemBase(oldItemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item == null) { @@ -636,7 +640,8 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat( "[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId); - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { @@ -1224,7 +1229,8 @@ namespace OpenSim.Region.Framework.Scenes UUID copyID = UUID.Random(); if (itemID != UUID.Zero) { - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); // Try library if (null == item) @@ -1287,7 +1293,8 @@ namespace OpenSim.Region.Framework.Scenes if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory { - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); // Try library // XXX clumsy, possibly should be one call @@ -1672,7 +1679,7 @@ namespace OpenSim.Region.Framework.Scenes if (DeRezAction.SaveToExistingUserInventoryItem == action) { - item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID); + item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); item = InventoryService.GetItem(item); //item = userInfo.RootFolder.FindItem( @@ -1834,7 +1841,8 @@ namespace OpenSim.Region.Framework.Scenes string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { @@ -1984,7 +1992,8 @@ namespace OpenSim.Region.Framework.Scenes BypassRayCast, bRayEndIsIntersection,true,scale, false); // Rez object - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); if (item != null) { @@ -2309,7 +2318,8 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence presence; if (TryGetAvatar(remoteClient.AgentId, out presence)) { - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID, remoteClient.AgentId)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); IAvatarFactory ava = RequestModuleInterface(); @@ -2360,7 +2370,8 @@ namespace OpenSim.Region.Framework.Scenes if (TryGetAvatar(remoteClient.AgentId, out presence)) { // XXYY!! - InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID)); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = InventoryService.GetItem(item); presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); IAvatarFactory ava = RequestModuleInterface(); if (ava != null) -- cgit v1.1 From c5af39239f7f2a1725d9c08bea80522de8835e0f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 00:13:51 -0700 Subject: A better purge of trash folder. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 31 +++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 48c7f4e..5e2eb73 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -477,7 +477,11 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.BypassPermissions()) { if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) - InventoryService.DeleteItem(new InventoryItemBase(itemId)); + { + List items = new List(); + items.Add(itemId); + InventoryService.DeleteItems(senderId, items); + } } return itemCopy; @@ -652,7 +656,9 @@ namespace OpenSim.Region.Framework.Scenes item.Folder = folderID; // Diva comment: can't we just update? - InventoryService.DeleteItem(item); + List uuids = new List(); + uuids.Add(item.ID); + InventoryService.DeleteItems(item.Owner, uuids); AddInventoryItem(remoteClient, item); } @@ -799,9 +805,10 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - private void RemoveInventoryItem(IClientAPI remoteClient, UUID itemID) + private void RemoveInventoryItem(IClientAPI remoteClient, List itemIDs) { - InventoryService.DeleteItem(new InventoryItemBase(itemID)); + //m_log.Debug("[SCENE INVENTORY]: user " + remoteClient.AgentId); + InventoryService.DeleteItems(remoteClient.AgentId, itemIDs); } /// @@ -1248,7 +1255,11 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.BypassPermissions()) { if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) - RemoveInventoryItem(remoteClient, itemID); + { + List uuids = new List(); + uuids.Add(itemID); + RemoveInventoryItem(remoteClient, uuids); + } } } else @@ -2144,7 +2155,11 @@ namespace OpenSim.Region.Framework.Scenes // copy ones will be lost, so avoid it // if (!attachment) - InventoryService.DeleteItem(item); + { + List uuids = new List(); + uuids.Add(item.ID); + InventoryService.DeleteItems(item.Owner, uuids); + } } } @@ -2404,7 +2419,9 @@ namespace OpenSim.Region.Framework.Scenes } part.ParentGroup.DetachToGround(); - InventoryService.DeleteItem(new InventoryItemBase(inventoryID)); + List uuids = new List(); + uuids.Add(inventoryID); + InventoryService.DeleteItems(remoteClient.AgentId, uuids); remoteClient.SendRemoveInventoryItem(inventoryID); } SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); -- cgit v1.1 From d519f1885f587409592cf92bc0f4ba8533a1866f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 10:56:08 -0700 Subject: Added MoveItems, which is most useful upon viewer-delete inventory operation. Moving a batch of items is a 1-time operation. Made it async anyway, so that the viewer doesn't wait in case the DB layer is dumb (which is the case currently). --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 31 +++------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 5e2eb73..a119efc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -638,36 +638,13 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void MoveInventoryItem(IClientAPI remoteClient, UUID folderID, UUID itemID, int length, - string newName) + public void MoveInventoryItem(IClientAPI remoteClient, List items) { m_log.DebugFormat( - "[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId); + "[AGENT INVENTORY]: Moving {0} items for user {1}", items.Count, remoteClient.AgentId); - InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); - item = InventoryService.GetItem(item); - - if (item != null) - { - if (newName != String.Empty) - { - item.Name = newName; - } - item.Folder = folderID; - - // Diva comment: can't we just update? - List uuids = new List(); - uuids.Add(item.ID); - InventoryService.DeleteItems(item.Owner, uuids); - - AddInventoryItem(remoteClient, item); - } - else - { - m_log.Warn("[AGENT INVENTORY]: Failed to find item " + itemID.ToString()); - - return; - } + if (!InventoryService.MoveItems(remoteClient.AgentId, items)) + m_log.Warn("[AGENT INVENTORY]: Failed to move items for user " + remoteClient.AgentId); } /// -- cgit v1.1 From 6e35ddb0e9642e6719d5043da99d45f8885d13f0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 16:15:04 -0700 Subject: Fixes GetItem and GetFolder for SQLite. Turns out some methods were no-op in SQlite. Fixes most grief in http://opensimulator.org/mantis/view.php?id=4035 http://opensimulator.org/mantis/view.php?id=4027 --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a119efc..a9d361b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -179,8 +179,8 @@ namespace OpenSim.Region.Framework.Scenes else { m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not resolve user {0} for caps inventory update", - remoteClient.AgentId); + "[AGENT INVENTORY]: Could not find item {0} for caps inventory update", + itemID); } return UUID.Zero; -- cgit v1.1 From b03eeeb9f6331ed36c61f55aef847ce3b2db7ba4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 22 Aug 2009 10:24:26 -0700 Subject: * Fixes mantis http://opensimulator.org/mantis/view.php?id=4044. Turns out folders were never being removed from trash when they were singled out for purging in trash. They were being removed when Trash was purged as a whole. That behavior is now fixed for the new InventoryService set. * Removed left-overs from AssetInventoryServer. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a9d361b..3301536 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -789,23 +789,15 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Removes an inventory folder. Although there is a packet in the Linden protocol for this, it may be - /// legacy and not currently used (purge folder is used to remove folders from trash instead). + /// Removes an inventory folder. This packet is sent when the user + /// right-clicks a folder that's already in trash and chooses "purge" /// /// /// - private void RemoveInventoryFolder(IClientAPI remoteClient, UUID folderID) + private void RemoveInventoryFolder(IClientAPI remoteClient, List folderIDs) { - // Unclear is this handler is ever called by the Linden client, but it might - - InventoryFolderBase folder = new InventoryFolderBase(folderID); - folder.Owner = remoteClient.AgentId; - InventoryFolderBase trash = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder); - if (trash != null) - { - folder.ParentID = trash.ID; - InventoryService.MoveFolder(folder); - } + m_log.DebugFormat("[SCENE INVENTORY]: RemoveInventoryFolders count {0}", folderIDs.Count); + InventoryService.DeleteFolders(remoteClient.AgentId, folderIDs); } private SceneObjectGroup GetGroupByPrim(uint localID) -- cgit v1.1