Skip to content

Commit

Permalink
Wire in AISv3 for Item and Folder removal in InventoryManager
Browse files Browse the repository at this point in the history
  • Loading branch information
cinderblocks committed Jan 23, 2022
1 parent 9413585 commit 994a354
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
8 changes: 4 additions & 4 deletions LibreMetaverse/InventoryAISClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public async Task SlamFolder(UUID folderUuid, OSD newInventory, Action<bool> cal
}
}

public async Task RemoveCategory(UUID categoryUuid, Action<bool> callback)
public async Task RemoveCategory(UUID categoryUuid, Action<bool, UUID> callback)
{
var cap = getInventoryCap();
if (cap == null)
Expand Down Expand Up @@ -204,11 +204,11 @@ public async Task RemoveCategory(UUID categoryUuid, Action<bool> callback)
}
finally
{
callback?.Invoke(success);
callback?.Invoke(success, categoryUuid);
}
}

public async Task RemoveItem(UUID itemUuid, Action<bool> callback)
public async Task RemoveItem(UUID itemUuid, Action<bool, UUID> callback)
{
var cap = getInventoryCap();
if (cap == null)
Expand Down Expand Up @@ -247,7 +247,7 @@ public async Task RemoveItem(UUID itemUuid, Action<bool> callback)
}
finally
{
callback?.Invoke(success);
callback?.Invoke(success, itemUuid);
}
}

Expand Down
32 changes: 27 additions & 5 deletions LibreMetaverse/InventoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1449,8 +1449,17 @@ public void RemoveDescendants(UUID folder)
/// <param name="item">The <seealso cref="UUID"/> of the inventory item to remove</param>
public void RemoveItem(UUID item)
{
List<UUID> items = new List<UUID>(1) { item };
Remove(items, null);
if (Client.AisClient.IsAvailable)
{
Client.AisClient.RemoveItem(item, RemoveLocalUi).ConfigureAwait(false);
}
else
{
List<UUID> items = new List<UUID>(1) { item };
#pragma warning disable CS0612 // Type or member is obsolete
Remove(items, null);
#pragma warning restore CS0612 // Type or member is obsolete
}
}

/// <summary>
Expand All @@ -1459,15 +1468,26 @@ public void RemoveItem(UUID item)
/// <param name="folder">The <seealso cref="UUID"/> of the folder to remove</param>
public void RemoveFolder(UUID folder)
{
List<UUID> folders = new List<UUID>(1) { folder };
Remove(null, folders);
if (Client.AisClient.IsAvailable)
{
Client.AisClient.RemoveCategory(folder, RemoveLocalUi).ConfigureAwait(false);
}
else
{
List<UUID> folders = new List<UUID>(1) { folder };
#pragma warning disable CS0612 // Type or member is obsolete
Remove(null, folders);
#pragma warning restore CS0612 // Type or member is obsolete
}
}

/// <summary>
/// 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.
/// </summary>
/// <param name="items">A List containing the <seealso cref="UUID"/>s of items to remove</param>
/// <param name="folders">A List containing the <seealso cref="UUID"/>s of the folders to remove</param>
[Obsolete]
public void Remove(List<UUID> items, List<UUID> folders)
{
if ((items == null || items.Count == 0) && (folders == null || folders.Count == 0))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 994a354

Please sign in to comment.