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 ++++++++++++++--------
.../Framework/Scenes/Scene.PacketHandlers.cs | 3 +-
2 files changed, 25 insertions(+), 13 deletions(-)
(limited to 'OpenSim/Region/Framework')
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)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index fde922f..1bbca49 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -404,7 +404,8 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
- InventoryItemBase item = InventoryService.GetItem(new InventoryItemBase(itemID));
+ InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
+ item = InventoryService.GetItem(item);
if (item != 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 +++++++++++++++++-----
.../Framework/Scenes/Scene.PacketHandlers.cs | 2 +-
2 files changed, 25 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/Framework')
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);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 1bbca49..a2414e5 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -560,7 +560,7 @@ namespace OpenSim.Region.Framework.Scenes
public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID)
{
- InventoryFolderBase folder = new InventoryFolderBase(folderID);
+ InventoryFolderBase folder = new InventoryFolderBase(folderID, remoteClient.AgentId);
if (InventoryService.PurgeFolder(folder))
m_log.DebugFormat("[AGENT INVENTORY]: folder {0} purged successfully", folderID);
--
cgit v1.1
From 4382f28efc6ffe70e3c6f6e8cd7e7c729d1f12af Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Wed, 19 Aug 2009 00:33:02 -0700
Subject: Async purge so that the client thread doesn't wait.
---
.../Framework/Scenes/Scene.PacketHandlers.cs | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index a2414e5..77b980c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
using System.Collections.Generic;
using System.Threading;
using OpenMetaverse;
@@ -558,15 +559,34 @@ namespace OpenSim.Region.Framework.Scenes
///
///
+ delegate void PurgeFolderDelegate(UUID userID, UUID folder);
+
public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID)
{
- InventoryFolderBase folder = new InventoryFolderBase(folderID, remoteClient.AgentId);
+ PurgeFolderDelegate d = PurgeFolderAsync;
+ try
+ {
+ d.BeginInvoke(remoteClient.AgentId, folderID, PurgeFolderCompleted, d);
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("[AGENT INVENTORY]: Exception on purge folder for user {0}: {1}", remoteClient.AgentId, e.Message);
+ }
+ }
+
+
+ private void PurgeFolderAsync(UUID userID, UUID folderID)
+ {
+ InventoryFolderBase folder = new InventoryFolderBase(folderID, userID);
if (InventoryService.PurgeFolder(folder))
m_log.DebugFormat("[AGENT INVENTORY]: folder {0} purged successfully", folderID);
else
m_log.WarnFormat("[AGENT INVENTORY]: could not purge folder {0}", folderID);
- }
+ }
+ private void PurgeFolderCompleted(IAsyncResult iar)
+ {
+ }
}
}
--
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')
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