From 994a35407b479591ac84c14a8ce0e2521a0d4cac Mon Sep 17 00:00:00 2001 From: Cinder Date: Sun, 23 Jan 2022 14:26:13 -0600 Subject: [PATCH] Wire in AISv3 for Item and Folder removal in InventoryManager --- LibreMetaverse/InventoryAISClient.cs | 8 +++---- LibreMetaverse/InventoryManager.cs | 32 +++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/LibreMetaverse/InventoryAISClient.cs b/LibreMetaverse/InventoryAISClient.cs index 4e0e832a..a0ecdde4 100644 --- a/LibreMetaverse/InventoryAISClient.cs +++ b/LibreMetaverse/InventoryAISClient.cs @@ -166,7 +166,7 @@ public async Task SlamFolder(UUID folderUuid, OSD newInventory, Action cal } } - public async Task RemoveCategory(UUID categoryUuid, Action callback) + public async Task RemoveCategory(UUID categoryUuid, Action callback) { var cap = getInventoryCap(); if (cap == null) @@ -204,11 +204,11 @@ public async Task RemoveCategory(UUID categoryUuid, Action callback) } finally { - callback?.Invoke(success); + callback?.Invoke(success, categoryUuid); } } - public async Task RemoveItem(UUID itemUuid, Action callback) + public async Task RemoveItem(UUID itemUuid, Action callback) { var cap = getInventoryCap(); if (cap == null) @@ -247,7 +247,7 @@ public async Task RemoveItem(UUID itemUuid, Action callback) } finally { - callback?.Invoke(success); + callback?.Invoke(success, itemUuid); } } diff --git a/LibreMetaverse/InventoryManager.cs b/LibreMetaverse/InventoryManager.cs index 8a079d85..7ca7a962 100644 --- a/LibreMetaverse/InventoryManager.cs +++ b/LibreMetaverse/InventoryManager.cs @@ -1449,8 +1449,17 @@ public void RemoveDescendants(UUID folder) /// The of the inventory item to remove public void RemoveItem(UUID item) { - List items = new List(1) { item }; - Remove(items, null); + if (Client.AisClient.IsAvailable) + { + Client.AisClient.RemoveItem(item, RemoveLocalUi).ConfigureAwait(false); + } + else + { + List items = new List(1) { item }; +#pragma warning disable CS0612 // Type or member is obsolete + Remove(items, null); +#pragma warning restore CS0612 // Type or member is obsolete + } } /// @@ -1459,15 +1468,26 @@ public void RemoveItem(UUID item) /// The of the folder to remove public void RemoveFolder(UUID folder) { - List folders = new List(1) { folder }; - Remove(null, folders); + if (Client.AisClient.IsAvailable) + { + Client.AisClient.RemoveCategory(folder, RemoveLocalUi).ConfigureAwait(false); + } + else + { + List folders = new List(1) { folder }; +#pragma warning disable CS0612 // Type or member is obsolete + Remove(null, folders); +#pragma warning restore CS0612 // Type or member is obsolete + } } /// - /// Remove multiple items or folders from inventory + /// Remove multiple items or folders from inventory. Note that this uses the LLUDP method + /// which Second Life has deprecated and removed. /// /// A List containing the s of items to remove /// A List containing the s of the folders to remove + [Obsolete] public void Remove(List items, List folders) { if ((items == null || items.Count == 0) && (folders == null || folders.Count == 0)) @@ -1583,7 +1603,9 @@ private void EmptySystemFolder(FolderType folderType) } } +#pragma warning disable CS0612 // Type or member is obsolete Remove(remItems, remFolders); +#pragma warning restore CS0612 // Type or member is obsolete } } #endregion Remove