Index: Inventory.cs
===================================================================
--- Inventory.cs (revision 2054)
+++ Inventory.cs (working copy)
@@ -100,6 +100,15 @@
}
///
+ /// Initializes an empty, rootless, ownerless inventory.
+ /// This is used so that we can have an Inventory instance before
+ /// the owner and root data is known.
+ ///
+ /// Manager for remote updates.
+ internal Inventory(InventoryManager manager)
+ : this(manager, UUID.Zero, UUID.Zero) { }
+
+ ///
/// Creates a new Inventory. Remote updates are sent via the manager
/// passed to this constructor. All folders contained within the InventorySkeleton
/// are automatically managed. The inventory takes on the owner of the skeleton.
@@ -109,11 +118,7 @@
public Inventory(InventoryManager manager, InventorySkeleton skeleton)
: this (manager, skeleton.Owner, skeleton.RootUUID)
{
- Items = new Dictionary(skeleton.Folders.Length);
- foreach (FolderData folder in skeleton.Folders)
- {
- Manage(folder);
- }
+ ManageSkeleton(skeleton);
}
///
@@ -133,7 +138,32 @@
RegisterInventoryCallbacks();
}
+ protected internal void InitializeFromSkeleton(InventorySkeleton skeleton)
+ {
+ Owner = skeleton.Owner;
+ RootUUID = skeleton.RootUUID;
+ Items = new Dictionary(skeleton.Folders.Length);
+ ManageSkeleton(skeleton);
+ }
+
///
+ /// Manages all the folders in the skeleton, if the skeleton is owned
+ /// by the same agent.
+ ///
+ /// The skeleton with folders to manage.
+ /// true if Inventory's owner is skeleton's owner and management succeeded, false otherwise.
+ protected bool ManageSkeleton(InventorySkeleton skeleton)
+ {
+ if (skeleton.Owner != Owner)
+ return false;
+ foreach (FolderData folder in skeleton.Folders)
+ {
+ Manage(folder);
+ }
+ return true;
+ }
+
+ ///
/// Registers InventoryManager callbacks for inventory updates.
///
protected virtual void RegisterInventoryCallbacks()
@@ -952,15 +982,25 @@
}
///
+ /// Override for RequestContents that retrieves results
+ /// in order by name.
+ ///
+ public void RequestContents()
+ {
+ RequestContents(InventorySortOrder.ByName);
+ }
+
+ ///
/// Asynchronously requests the folder's contents from the remote inventory.
/// The InventoryFolder.OnContentsRetrieved event
- /// is raised when he new contents are written to the
+ /// is raised when the new contents are written to the
/// InventoryFolder.Contents Dictionary.
/// The contents retrieved are automatically managed.
///
- public void RequestContents()
+ /// The order in which results are returned.
+ public void RequestContents(InventorySortOrder sortOrder)
{
- InventoryManager.FolderContentsCallback callback =
+ InventoryManager.FolderContentsCallback callback =
delegate(UUID folder, List items, List folders)
{
if (folder != UUID)
@@ -975,7 +1015,7 @@
}
};
- Manager.RequestFolderContents(UUID, Data.OwnerID, true, true, InventorySortOrder.ByName,
+ Manager.RequestFolderContents(UUID, Data.OwnerID, true, true, sortOrder,
callback);
}