From b3b506cba24f5c60afc2f4ed7a92e7a51e11eb4c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 12 Aug 2009 09:31:33 -0700 Subject: Better test for dropping inventory cache and writing out debug messages. --- .../Inventory/InventoryCache.cs | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index b4785f4..3afaba5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs @@ -60,8 +60,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory // If not, go get them and place them in the cache Dictionary folders = GetSystemFolders(presence.UUID); - m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent, fetched system folders for {0} {1}: count {2}", - presence.Firstname, presence.Lastname, folders.Count); + m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent in {0}, fetched system folders for {1} {2}: count {3}", + presence.Scene.RegionInfo.RegionName, presence.Firstname, presence.Lastname, folders.Count); if (folders.Count > 0) lock (m_InventoryCache) m_InventoryCache.Add(presence.UUID, folders); @@ -69,25 +69,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory void OnClientClosed(UUID clientID, Scene scene) { - ScenePresence sp = null; - foreach (Scene s in m_Scenes) + if (m_InventoryCache.ContainsKey(clientID)) // if it's still in cache { - s.TryGetAvatar(clientID, out sp); - if ((sp != null) && !sp.IsChildAgent) + ScenePresence sp = null; + foreach (Scene s in m_Scenes) { - m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache", - scene.RegionInfo.RegionName, clientID); - return; + s.TryGetAvatar(clientID, out sp); + if ((sp != null) && !sp.IsChildAgent && (s != scene)) + { + m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache", + scene.RegionInfo.RegionName, clientID); + return; + } } - } - m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders", - scene.RegionInfo.RegionName, clientID); - // Drop system folders - lock (m_InventoryCache) - if (m_InventoryCache.ContainsKey(clientID)) - m_InventoryCache.Remove(clientID); + // Drop system folders + lock (m_InventoryCache) + if (m_InventoryCache.ContainsKey(clientID)) + { + m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders", + scene.RegionInfo.RegionName, clientID); + m_InventoryCache.Remove(clientID); + } + } } public abstract Dictionary GetSystemFolders(UUID userID); -- cgit v1.1 From 41ad610f3e44d2c73451ab49b71e697259c8c965 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 12 Aug 2009 13:11:15 -0700 Subject: * Added two new packet handler implementations for inventory ops. This is starting to work! - but can't be activated incrementally, the flip needs to be global for all inventory ops. * Added a base inventory connector that does common processing of inventory among all reference connector implementations. E.g. AddItem requires additional processing before being forwarded to service. * Added if (m_Enabled) upon RemoveRegion --- .../Inventory/BaseInventoryConnector.cs | 179 +++++++++++++++++++++ .../Inventory/HGInventoryBroker.cs | 52 +++--- .../Inventory/InventoryCache.cs | 9 +- .../Inventory/LocalInventoryServiceConnector.cs | 52 +++--- .../Inventory/RemoteInventoryServiceConnector.cs | 52 +++--- 5 files changed, 270 insertions(+), 74 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs new file mode 100644 index 0000000..f2b736c --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; + +using OpenMetaverse; +using Nini.Config; +using log4net; + +using OpenSim.Framework; +using OpenSim.Services.Interfaces; + + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory +{ + public abstract class BaseInventoryConnector : IInventoryService + { + protected InventoryCache m_cache; + + protected virtual void Init(IConfigSource source) + { + m_cache = new InventoryCache(); + m_cache.Init(source, this); + } + + /// + /// Create the entire inventory for a given user + /// + /// + /// + public abstract bool CreateUserInventory(UUID user); + + /// + /// Gets the skeleton of the inventory -- folders only + /// + /// + /// + public abstract List GetInventorySkeleton(UUID userId); + + /// + /// Synchronous inventory fetch. + /// + /// + /// + public abstract InventoryCollection GetUserInventory(UUID userID); + + /// + /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the + /// inventory has been received + /// + /// + /// + public abstract void GetUserInventory(UUID userID, InventoryReceiptCallback callback); + + /// + /// Retrieve the root inventory folder for the given user. + /// + /// + /// null if no root folder was found + public abstract InventoryFolderBase GetRootFolder(UUID userID); + + public abstract Dictionary GetSystemFolders(UUID userID); + + /// + /// Gets the user folder for the given folder-type + /// + /// + /// + /// + public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) + { + return m_cache.GetFolderForType(userID, type); + } + + /// + /// Gets everything (folders and items) inside a folder + /// + /// + /// + /// + public abstract InventoryCollection GetFolderContent(UUID userID, UUID folderID); + + /// + /// Gets the items inside a folder + /// + /// + /// + /// + public abstract List GetFolderItems(UUID userID, UUID folderID); + + /// + /// Add a new folder to the user's inventory + /// + /// + /// true if the folder was successfully added + public abstract bool AddFolder(InventoryFolderBase folder); + + /// + /// Update a folder in the user's inventory + /// + /// + /// true if the folder was successfully updated + public abstract bool UpdateFolder(InventoryFolderBase folder); + + /// + /// Move an inventory folder to a new location + /// + /// A folder containing the details of the new location + /// true if the folder was successfully moved + public abstract bool MoveFolder(InventoryFolderBase folder); + + /// + /// Purge an inventory folder of all its items and subfolders. + /// + /// + /// true if the folder was successfully purged + public abstract bool PurgeFolder(InventoryFolderBase folder); + + /// + /// Add a new item to the user's inventory. + /// If the given item has to parent folder, it tries to find the most + /// suitable folder for it. + /// + /// + /// true if the item was successfully added + public bool AddItem(InventoryItemBase item) + { + if (item.Folder == UUID.Zero) + { + InventoryFolderBase f = GetFolderForType(item.Owner, (AssetType)item.AssetType); + if (f != null) + item.Folder = f.ID; + else + { + f = GetRootFolder(item.Owner); + if (f != null) + item.Folder = f.ID; + else + return false; + } + } + + return AddItemPlain(item); + } + + protected abstract bool AddItemPlain(InventoryItemBase item); + + /// + /// Update an item in the user's inventory + /// + /// + /// true if the item was successfully updated + public abstract bool UpdateItem(InventoryItemBase item); + + /// + /// Delete an item from the user's inventory + /// + /// + /// true if the item was successfully deleted + public abstract bool DeleteItem(InventoryItemBase item); + + public abstract InventoryItemBase QueryItem(InventoryItemBase item); + + public abstract InventoryFolderBase QueryFolder(InventoryFolderBase folder); + + /// + /// Does the given user have an inventory structure? + /// + /// + /// + public abstract bool HasInventoryForUser(UUID userID); + + /// + /// Get the active gestures of the agent. + /// + /// + /// + public abstract List GetActiveGestures(UUID userId); + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index d4168fe..62b9bed 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -41,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { - public class HGInventoryBroker : InventoryCache, ISharedRegionModule, IInventoryService + public class HGInventoryBroker : BaseInventoryConnector, ISharedRegionModule, IInventoryService { private static readonly ILog m_log = LogManager.GetLogger( @@ -138,7 +138,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { } - public override void AddRegion(Scene scene) + public void AddRegion(Scene scene) { if (!m_Enabled) return; @@ -156,12 +156,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } scene.RegisterModuleInterface(this); - base.AddRegion(scene); + m_cache.AddRegion(scene); } - public override void RemoveRegion(Scene scene) + public void RemoveRegion(Scene scene) { - base.RemoveRegion(scene); + if (!m_Enabled) + return; + + m_cache.RemoveRegion(scene); } public void RegionLoaded(Scene scene) @@ -175,17 +178,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory #region IInventoryService - public bool CreateUserInventory(UUID userID) + public override bool CreateUserInventory(UUID userID) { return m_GridService.CreateUserInventory(userID); } - public List GetInventorySkeleton(UUID userId) + public override List GetInventorySkeleton(UUID userId) { return m_GridService.GetInventorySkeleton(userId); } - public InventoryCollection GetUserInventory(UUID userID) + public override InventoryCollection GetUserInventory(UUID userID) { if (IsLocalGridUser(userID)) return m_GridService.GetUserInventory(userID); @@ -193,7 +196,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return null; } - public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) + public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback) { if (IsLocalGridUser(userID)) m_GridService.GetUserInventory(userID, callback); @@ -220,7 +223,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory // } //} - public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + public override InventoryCollection GetFolderContent(UUID userID, UUID folderID) { if (IsLocalGridUser(userID)) return m_GridService.GetFolderContent(userID, folderID); @@ -271,12 +274,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return new Dictionary(); } - public List GetFolderItems(UUID userID, UUID folderID) + public override List GetFolderItems(UUID userID, UUID folderID) { return new List(); } - public bool AddFolder(InventoryFolderBase folder) + public override bool AddFolder(InventoryFolderBase folder) { if (folder == null) return false; @@ -291,7 +294,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public bool UpdateFolder(InventoryFolderBase folder) + public override bool UpdateFolder(InventoryFolderBase folder) { if (folder == null) return false; @@ -306,7 +309,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public bool MoveFolder(InventoryFolderBase folder) + public override bool MoveFolder(InventoryFolderBase folder) { if (folder == null) return false; @@ -321,7 +324,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public bool PurgeFolder(InventoryFolderBase folder) + public override bool PurgeFolder(InventoryFolderBase folder) { if (folder == null) return false; @@ -336,7 +339,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public bool AddItem(InventoryItemBase item) + // public bool AddItem(InventoryItemBase item) inherited + // Uses AddItemPlain + + protected override bool AddItemPlain(InventoryItemBase item) { if (item == null) return false; @@ -351,7 +357,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public bool UpdateItem(InventoryItemBase item) + public override bool UpdateItem(InventoryItemBase item) { if (item == null) return false; @@ -366,7 +372,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public bool DeleteItem(InventoryItemBase item) + public override bool DeleteItem(InventoryItemBase item) { if (item == null) return false; @@ -381,7 +387,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public InventoryItemBase QueryItem(InventoryItemBase item) + public override InventoryItemBase QueryItem(InventoryItemBase item) { if (item == null) return null; @@ -396,7 +402,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public InventoryFolderBase QueryFolder(InventoryFolderBase folder) + public override InventoryFolderBase QueryFolder(InventoryFolderBase folder) { if (folder == null) return null; @@ -411,17 +417,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public bool HasInventoryForUser(UUID userID) + public override bool HasInventoryForUser(UUID userID) { return false; } - public InventoryFolderBase GetRootFolder(UUID userID) + public override InventoryFolderBase GetRootFolder(UUID userID) { return null; } - public List GetActiveGestures(UUID userId) + public override List GetActiveGestures(UUID userId) { return new List(); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index 3afaba5..551a7eb 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs @@ -12,21 +12,23 @@ using log4net; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { - public abstract class InventoryCache + public class InventoryCache { private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + protected BaseInventoryConnector m_Connector; protected List m_Scenes; // The cache proper protected Dictionary> m_InventoryCache; - protected virtual void Init(IConfigSource source) + public virtual void Init(IConfigSource source, BaseInventoryConnector connector) { m_Scenes = new List(); m_InventoryCache = new Dictionary>(); + m_Connector = connector; } public virtual void AddRegion(Scene scene) @@ -59,7 +61,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } // If not, go get them and place them in the cache - Dictionary folders = GetSystemFolders(presence.UUID); + Dictionary folders = m_Connector.GetSystemFolders(presence.UUID); m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent in {0}, fetched system folders for {1} {2}: count {3}", presence.Scene.RegionInfo.RegionName, presence.Firstname, presence.Lastname, folders.Count); if (folders.Count > 0) @@ -95,7 +97,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - public abstract Dictionary GetSystemFolders(UUID userID); public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 98e30ce..6efe903 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -41,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { - public class LocalInventoryServicesConnector : InventoryCache, ISharedRegionModule, IInventoryService + public class LocalInventoryServicesConnector : BaseInventoryConnector, ISharedRegionModule, IInventoryService { private static readonly ILog m_log = LogManager.GetLogger( @@ -124,7 +124,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { } - public override void AddRegion(Scene scene) + public void AddRegion(Scene scene) { if (!m_Enabled) return; @@ -141,12 +141,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory // "[INVENTORY CONNECTOR]: Registering IInventoryService to scene {0}", scene.RegionInfo.RegionName); scene.RegisterModuleInterface(this); - base.AddRegion(scene); + m_cache.AddRegion(scene); } - public override void RemoveRegion(Scene scene) + public void RemoveRegion(Scene scene) { - base.RemoveRegion(scene); + if (!m_Enabled) + return; + + m_cache.RemoveRegion(scene); } public void RegionLoaded(Scene scene) @@ -160,22 +163,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory #region IInventoryService - public bool CreateUserInventory(UUID user) + public override bool CreateUserInventory(UUID user) { return m_InventoryService.CreateUserInventory(user); } - public List GetInventorySkeleton(UUID userId) + public override List GetInventorySkeleton(UUID userId) { return m_InventoryService.GetInventorySkeleton(userId); } - public InventoryCollection GetUserInventory(UUID id) + public override InventoryCollection GetUserInventory(UUID id) { return m_InventoryService.GetUserInventory(id); } - public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) + public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback) { m_InventoryService.GetUserInventory(userID, callback); } @@ -207,13 +210,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return new Dictionary(); } - public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + public override InventoryCollection GetFolderContent(UUID userID, UUID folderID) { return m_InventoryService.GetFolderContent(userID, folderID); } - public List GetFolderItems(UUID userID, UUID folderID) + public override List GetFolderItems(UUID userID, UUID folderID) { return m_InventoryService.GetFolderItems(userID, folderID); } @@ -223,7 +226,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// /// /// true if the folder was successfully added - public bool AddFolder(InventoryFolderBase folder) + public override bool AddFolder(InventoryFolderBase folder) { return m_InventoryService.AddFolder(folder); } @@ -233,7 +236,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// /// /// true if the folder was successfully updated - public bool UpdateFolder(InventoryFolderBase folder) + public override bool UpdateFolder(InventoryFolderBase folder) { return m_InventoryService.UpdateFolder(folder); } @@ -243,7 +246,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// /// A folder containing the details of the new location /// true if the folder was successfully moved - public bool MoveFolder(InventoryFolderBase folder) + public override bool MoveFolder(InventoryFolderBase folder) { return m_InventoryService.MoveFolder(folder); } @@ -253,17 +256,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// /// /// true if the folder was successfully purged - public bool PurgeFolder(InventoryFolderBase folder) + public override bool PurgeFolder(InventoryFolderBase folder) { return m_InventoryService.PurgeFolder(folder); } /// - /// Add a new item to the user's inventory + /// Add a new item to the user's inventory, plain + /// Called by base class AddItem /// /// /// true if the item was successfully added - public bool AddItem(InventoryItemBase item) + protected override bool AddItemPlain(InventoryItemBase item) { return m_InventoryService.AddItem(item); } @@ -273,7 +277,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// /// /// true if the item was successfully updated - public bool UpdateItem(InventoryItemBase item) + public override bool UpdateItem(InventoryItemBase item) { return m_InventoryService.UpdateItem(item); } @@ -283,17 +287,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// /// /// true if the item was successfully deleted - public bool DeleteItem(InventoryItemBase item) + public override bool DeleteItem(InventoryItemBase item) { return m_InventoryService.DeleteItem(item); } - public InventoryItemBase QueryItem(InventoryItemBase item) + public override InventoryItemBase QueryItem(InventoryItemBase item) { return m_InventoryService.QueryItem(item); } - public InventoryFolderBase QueryFolder(InventoryFolderBase folder) + public override InventoryFolderBase QueryFolder(InventoryFolderBase folder) { return m_InventoryService.QueryFolder(folder); } @@ -303,7 +307,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// /// /// - public bool HasInventoryForUser(UUID userID) + public override bool HasInventoryForUser(UUID userID) { return m_InventoryService.HasInventoryForUser(userID); } @@ -313,12 +317,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// /// /// null if no root folder was found - public InventoryFolderBase GetRootFolder(UUID userID) + public override InventoryFolderBase GetRootFolder(UUID userID) { return m_InventoryService.GetRootFolder(userID); } - public List GetActiveGestures(UUID userId) + public override List GetActiveGestures(UUID userId) { return m_InventoryService.GetActiveGestures(userId); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index dceda38..f87aab9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -40,7 +40,7 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { - public class RemoteInventoryServicesConnector : InventoryCache, ISharedRegionModule, IInventoryService + public class RemoteInventoryServicesConnector : BaseInventoryConnector, ISharedRegionModule, IInventoryService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -102,7 +102,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { } - public override void AddRegion(Scene scene) + public void AddRegion(Scene scene) { if (!m_Enabled) return; @@ -117,12 +117,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } scene.RegisterModuleInterface(this); - base.AddRegion(scene); + m_cache.AddRegion(scene); } - public override void RemoveRegion(Scene scene) + public void RemoveRegion(Scene scene) { - base.RemoveRegion(scene); + if (!m_Enabled) + return; + + m_cache.RemoveRegion(scene); } public void RegionLoaded(Scene scene) @@ -138,22 +141,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory #region IInventoryService - public bool CreateUserInventory(UUID user) + public override bool CreateUserInventory(UUID user) { return false; } - public List GetInventorySkeleton(UUID userId) + public override List GetInventorySkeleton(UUID userId) { return new List(); } - public InventoryCollection GetUserInventory(UUID userID) + public override InventoryCollection GetUserInventory(UUID userID) { return null; } - public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) + public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback) { UUID sessionID = GetSessionID(userID); try @@ -180,7 +183,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.GetSystemFolders(userID.ToString(), sessionID); } - public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + public override InventoryCollection GetFolderContent(UUID userID, UUID folderID) { UUID sessionID = GetSessionID(userID); try @@ -199,12 +202,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return nullCollection; } - public List GetFolderItems(UUID userID, UUID folderID) + public override List GetFolderItems(UUID userID, UUID folderID) { return new List(); } - public bool AddFolder(InventoryFolderBase folder) + public override bool AddFolder(InventoryFolderBase folder) { if (folder == null) return false; @@ -213,7 +216,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.AddFolder(folder.Owner.ToString(), folder, sessionID); } - public bool UpdateFolder(InventoryFolderBase folder) + public override bool UpdateFolder(InventoryFolderBase folder) { if (folder == null) return false; @@ -222,7 +225,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.UpdateFolder(folder.Owner.ToString(), folder, sessionID); } - public bool MoveFolder(InventoryFolderBase folder) + public override bool MoveFolder(InventoryFolderBase folder) { if (folder == null) return false; @@ -231,7 +234,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.MoveFolder(folder.Owner.ToString(), folder, sessionID); } - public bool PurgeFolder(InventoryFolderBase folder) + public override bool PurgeFolder(InventoryFolderBase folder) { if (folder == null) return false; @@ -240,7 +243,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.PurgeFolder(folder.Owner.ToString(), folder, sessionID); } - public bool AddItem(InventoryItemBase item) + // public bool AddItem(InventoryItemBase item) inherited + // Uses AddItemPlain + + protected override bool AddItemPlain(InventoryItemBase item) { if (item == null) return false; @@ -249,7 +255,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.AddItem(item.Owner.ToString(), item, sessionID); } - public bool UpdateItem(InventoryItemBase item) + public override bool UpdateItem(InventoryItemBase item) { if (item == null) return false; @@ -258,7 +264,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID); } - public bool DeleteItem(InventoryItemBase item) + public override bool DeleteItem(InventoryItemBase item) { if (item == null) return false; @@ -267,7 +273,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.DeleteItem(item.Owner.ToString(), item, sessionID); } - public InventoryItemBase QueryItem(InventoryItemBase item) + public override InventoryItemBase QueryItem(InventoryItemBase item) { if (item == null) return null; @@ -276,7 +282,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.QueryItem(item.Owner.ToString(), item, sessionID); } - public InventoryFolderBase QueryFolder(InventoryFolderBase folder) + public override InventoryFolderBase QueryFolder(InventoryFolderBase folder) { if (folder == null) return null; @@ -285,17 +291,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return m_RemoteConnector.QueryFolder(folder.Owner.ToString(), folder, sessionID); } - public bool HasInventoryForUser(UUID userID) + public override bool HasInventoryForUser(UUID userID) { return false; } - public InventoryFolderBase GetRootFolder(UUID userID) + public override InventoryFolderBase GetRootFolder(UUID userID) { return null; } - public List GetActiveGestures(UUID userId) + public override List GetActiveGestures(UUID userId) { return new List(); } -- cgit v1.1 From 50f29752f5888ac194a5146c475720c29ae3f172 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 13 Aug 2009 11:48:39 +0900 Subject: Formatting cleanup. Add copyright headers. --- .../Inventory/BaseInventoryConnector.cs | 29 +++++++++++++++++++++- .../Inventory/InventoryCache.cs | 29 +++++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs index f2b736c..375faf5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using OpenMetaverse; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index 551a7eb..c16e92e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Reflection; -- cgit v1.1 From 0f3f2e1dc007f48dcccb27932923a8d586eedb5f Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 13 Aug 2009 13:19:12 +0100 Subject: Add reference to the profile module in the avatar profiles handler, plus an example of how to override legacy core data with data retrieved from the profile module --- .../Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs index d3324e4..a6ace63 100644 --- a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs @@ -41,6 +41,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; + private IProfileModule m_profileModule = null; public AvatarProfilesModule() { @@ -56,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles public void PostInitialise() { + m_profileModule = scene.RequestModuleInterface(); } public void Close() @@ -108,6 +110,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles charterMember = Utils.StringToBytes(profile.CustomType); } + if (m_profileModule != null) + { + Hashtable profileData = m_profileModule.GetProfileData(remoteClient.AgentId); + if (profileData["ProfileUrl"] != null) + profile.ProfileUrl = profileData["ProfileUrl"].ToString(); + } remoteClient.SendAvatarProperties(profile.ID, profile.AboutText, Util.ToDateTime(profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), charterMember, profile.FirstLifeAboutText, (uint)(profile.UserFlags & 0xff), -- cgit v1.1 From 3669115d60f4e8fbd5032836b828f6ee40901c93 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 13 Aug 2009 13:25:33 +0100 Subject: Some small fixes --- OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs index a6ace63..0f58788 100644 --- a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections; using System.Globalization; using System.Reflection; using log4net; @@ -57,7 +58,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles public void PostInitialise() { - m_profileModule = scene.RequestModuleInterface(); + m_profileModule = m_scene.RequestModuleInterface(); } public void Close() -- cgit v1.1 From 957962b48276861948267701159775c2361b235b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 14 Aug 2009 19:06:24 +0100 Subject: Remove NRE catching on TestReplicateArchivePathToUserInventory() since race failure now appears to have gone --- .../Archiver/Tests/InventoryArchiverTests.cs | 36 ++++++---------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 28b4d64..2169e36 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -395,17 +395,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); Monitor.Wait(this, 60000); } - - //userInfo.FetchInventory(); - /* - for (int i = 0 ; i < 50 ; i++) - { - if (userInfo.HasReceivedInventory == true) - break; - Thread.Sleep(200); - } - Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); - */ Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); @@ -429,22 +418,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); - try - { - new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null) - .ReplicateArchivePathToUserInventory(itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded); - - Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); - InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); - Assert.That(folder1, Is.Not.Null, "Could not find folder a"); - InventoryFolderImpl folder2 = folder1.FindFolderByPath("b"); - Assert.That(folder2, Is.Not.Null, "Could not find folder b"); - } - catch (NullReferenceException e) - { - // Non fatal for now until we resolve the race condition - Console.WriteLine("Test failed with {0}", e); - } + new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null) + .ReplicateArchivePathToUserInventory( + itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded); + + Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); + InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); + Assert.That(folder1, Is.Not.Null, "Could not find folder a"); + InventoryFolderImpl folder2 = folder1.FindFolderByPath("b"); + Assert.That(folder2, Is.Not.Null, "Could not find folder b"); } } } -- cgit v1.1 From a668a5b0d39f04497e5ea170e5af0e659a43febb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 14 Aug 2009 19:59:42 +0100 Subject: Add standard doc and standard doc formatting to IAssetService --- .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 2169e36..9784fcf 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests InventoryArchiverModule archiverModule = new InventoryArchiverModule(); - Scene scene = SceneSetupHelpers.SetupScene(""); + Scene scene = SceneSetupHelpers.SetupScene("Inventory"); SceneSetupHelpers.SetupSceneModules(scene, archiverModule); CommunicationsManager cm = scene.CommsManager; -- cgit v1.1 From ff28ecee1b35ba24ec538d8ed018c764476c62b4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 14 Aug 2009 20:07:13 +0100 Subject: Re-enable TestSaveIarV0_1() Implement more parts of TestAssetService --- .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 9784fcf..c66678f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -74,7 +74,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). /// - //[Test] + [Test] public void TestSaveIarV0_1() { TestHelper.InMethod(); -- cgit v1.1 From e17a2331a02d36a3b9f6f37630601ab4a63a4fb2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 14 Aug 2009 20:38:56 +0100 Subject: * Re-enable TestLoadIarV0_1ExistingUsers() --- .../Inventory/Archiver/Tests/InventoryArchiverTests.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index c66678f..470a386 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -222,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where /// an account exists with the creator name. /// - //[Test] + [Test] public void TestLoadIarV0_1ExistingUsers() { TestHelper.InMethod(); @@ -262,7 +262,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests InventoryArchiverModule archiverModule = new InventoryArchiverModule(); // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene - Scene scene = SceneSetupHelpers.SetupScene(); + Scene scene = SceneSetupHelpers.SetupScene("inventory"); IUserAdminService userAdminService = scene.CommsManager.UserAdminService; SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); @@ -276,16 +276,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); - //userInfo.FetchInventory(); - /* - for (int i = 0 ; i < 50 ; i++) - { - if (userInfo.HasReceivedInventory == true) - break; - Thread.Sleep(200); - } - Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); - */ + InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); Assert.That( -- cgit v1.1