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). --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 19 ++++++++----- .../Inventory/BaseInventoryConnector.cs | 2 ++ .../Inventory/HGInventoryBroker.cs | 17 ++++++++++++ .../Inventory/LocalInventoryServiceConnector.cs | 6 +++++ .../Inventory/RemoteInventoryServiceConnector.cs | 10 +++++++ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 31 +++------------------- 6 files changed, 52 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index e2fb659..6969a3d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -7027,14 +7027,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (OnMoveInventoryItem != null) { handlerMoveInventoryItem = null; + InventoryItemBase itm = null; + List items = new List(); foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) { - handlerMoveInventoryItem = OnMoveInventoryItem; - if (handlerMoveInventoryItem != null) - { - handlerMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length, - Util.FieldToString(datablock.NewName)); - } + itm = new InventoryItemBase(datablock.ItemID, AgentId); + itm.Folder = datablock.FolderID; + itm.Name = Util.FieldToString(datablock.NewName); + // weird, comes out as empty string + //m_log.DebugFormat("[XXX] new name: {0}", itm.Name); + items.Add(itm); + } + handlerMoveInventoryItem = OnMoveInventoryItem; + if (handlerMoveInventoryItem != null) + { + handlerMoveInventoryItem(this, items); } } break; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs index d1ae3e4..d4cb616 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs @@ -181,6 +181,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// true if the item was successfully updated public abstract bool UpdateItem(InventoryItemBase item); + public abstract bool MoveItems(UUID ownerID, List items); + /// /// Delete an item from the user's inventory /// diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 6a1f2d5..787c6c8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -393,6 +393,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } + public override bool MoveItems(UUID ownerID, List items) + { + if (items == null) + return false; + if (items.Count == 0) + return true; + + if (IsLocalGridUser(ownerID)) + return m_GridService.MoveItems(ownerID, items); + else + { + UUID sessionID = GetSessionID(ownerID); + string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString(); + return m_HGService.MoveItems(uri, items, sessionID); + } + } + public override bool DeleteItems(UUID ownerID, List itemIDs) { m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index b2640af..562c5dd 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -289,6 +289,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_InventoryService.UpdateItem(item); } + + public override bool MoveItems(UUID ownerID, List items) + { + return m_InventoryService.MoveItems(ownerID, items); + } + /// /// Delete an item from the user's inventory /// diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index 081d0f7..201442c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -273,6 +273,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID); } + public override bool MoveItems(UUID ownerID, List items) + { + if (items == null) + return false; + + UUID sessionID = GetSessionID(ownerID); + return m_RemoteConnector.MoveItems(ownerID.ToString(), items, sessionID); + } + + public override bool DeleteItems(UUID ownerID, List itemIDs) { if (itemIDs == null) 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