Index: GridClient.cs =================================================================== --- GridClient.cs (revision 2054) +++ GridClient.cs (working copy) @@ -99,7 +99,17 @@ /// Throttling total bandwidth usage, or allocating bandwidth /// for specific data stream types public AgentThrottle Throttle; + /// + /// Inventory instance that holds information and manages the local data structure + /// of the agent's inventory. + /// + /// public Inventory InventoryStore; + /// + /// Inventory instance that holds information and manages the local data structure + /// of the Linden-provided inventory library. + /// + /// public Inventory LibraryStore; /// @@ -125,21 +135,19 @@ Sound = new SoundManager(this); Throttle = new AgentThrottle(this); - if (Settings.ENABLE_INVENTORY_STORE || Settings.ENABLE_LIBRARY_STORE) - { - Inventory.OnSkeletonsReceived += - delegate(InventoryManager manager) - { - if (Settings.ENABLE_INVENTORY_STORE) - { - InventoryStore = new Inventory(Inventory, Inventory.InventorySkeleton); - } - if (Settings.ENABLE_LIBRARY_STORE) - { - LibraryStore = new Inventory(Inventory, Inventory.LibrarySkeleton); - } - }; - } + if (Settings.ENABLE_INVENTORY_STORE) + InventoryStore = new Inventory(Inventory); + if (Settings.ENABLE_LIBRARY_STORE) + LibraryStore = new Inventory(Inventory); + + Inventory.OnSkeletonsReceived += + delegate(InventoryManager manager) + { + if (Settings.ENABLE_INVENTORY_STORE) + InventoryStore.InitializeFromSkeleton(Inventory.InventorySkeleton); + if (Settings.ENABLE_LIBRARY_STORE) + LibraryStore.InitializeFromSkeleton(Inventory.LibrarySkeleton); + }; } /// 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()