From ae2174d8f526b225c3cccf551f1a9f01d6569203 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 29 Jan 2010 18:11:53 +0000
Subject: Add method to get all items with the same name from a particular prim
Extend load oar test to check loading of a sound item
---
.../World/Archiver/Tests/ArchiverTests.cs | 9 ++++----
.../Framework/Interfaces/IEntityInventory.cs | 13 ++++++++++-
.../Framework/Scenes/SceneObjectPartInventory.cs | 26 +++++++++++++++++++++-
3 files changed, 41 insertions(+), 7 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 1200105..bf80a1c 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -237,6 +237,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
SceneObjectGroup object1 = new SceneObjectGroup(part1);
// Let's put some inventory items into our object
+ string soundItemName = "sound-item1";
UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
Type type = GetType();
Assembly assembly = type.Assembly;
@@ -269,7 +270,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
asset1FileName = ArchiveConstants.ASSETS_PATH + soundUuid + ".wav";
*/
- TaskInventoryItem item1 = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid };
+ TaskInventoryItem item1
+ = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
part1.Inventory.AddInventoryItem(item1, true);
}
}
@@ -305,14 +307,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
Assert.That(
object1PartLoaded.OffsetPosition, Is.EqualTo(offsetPosition), "object1 offset position not equal");
- // Need to implement a method to get the task inventory item by name (since the uuid will have changed on load)
- /*
- TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItem(soundItemUuid);
+ TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0];
Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null");
AssetBase loadedSoundAsset = scene.AssetService.Get(loadedSoundItem.AssetID.ToString());
Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null");
Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match");
- */
// Temporary
Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index eeb5102..fa9bf19 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -71,7 +71,8 @@ namespace OpenSim.Region.Framework.Interfaces
///
/// Start all the scripts contained in this entity's inventory
///
- void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
+ void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
+
ArrayList GetScriptErrors(UUID itemID);
///
@@ -143,6 +144,16 @@ namespace OpenSim.Region.Framework.Interfaces
TaskInventoryItem GetInventoryItem(UUID itemId);
///
+ /// Get inventory items by name.
+ ///
+ ///
+ ///
+ /// A list of inventory items with that name.
+ /// If no inventory item has that name then an empty list is returned.
+ ///
+ IList GetInventoryItems(string name);
+
+ ///
/// Update an existing inventory item.
///
/// The updated item. An item with the same id must already exist
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 5f13278..b37e1a2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -554,8 +554,32 @@ namespace OpenSim.Region.Framework.Scenes
m_items.TryGetValue(itemId, out item);
return item;
- }
+ }
+
+ ///
+ /// Get inventory items by name.
+ ///
+ ///
+ ///
+ /// A list of inventory items with that name.
+ /// If no inventory item has that name then an empty list is returned.
+ ///
+ public IList GetInventoryItems(string name)
+ {
+ IList items = new List();
+ lock (m_items)
+ {
+ foreach (TaskInventoryItem item in m_items.Values)
+ {
+ if (item.Name == name)
+ items.Add(item);
+ }
+ }
+
+ return items;
+ }
+
///
/// Update an existing inventory item.
///
--
cgit v1.1