From 412112acbafa6e1f111b12007fd3a81728d0b2f5 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 23 Mar 2009 00:11:34 +0000 Subject: Committing partial work on passing folders across instances. This may crash. --- .../Communications/Cache/CachedUserInfo.cs | 51 ++++++++++++++++++++++ .../Framework/Communications/IInventoryServices.cs | 8 ++++ .../Communications/ISecureInventoryService.cs | 2 + .../Communications/InventoryServiceBase.cs | 14 ++++++ 4 files changed, 75 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index e590b9d..8d36623 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -37,6 +37,7 @@ namespace OpenSim.Framework.Communications.Cache internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo); internal delegate void DeleteItemDelegate(UUID itemID); internal delegate void QueryItemDelegate(UUID itemID); + internal delegate void QueryFolderDelegate(UUID folderID); internal delegate void CreateFolderDelegate(string folderName, UUID folderID, ushort folderType, UUID parentID); internal delegate void MoveFolderDelegate(UUID folderID, UUID parentID); @@ -819,6 +820,56 @@ namespace OpenSim.Framework.Communications.Cache return false; } + public bool QueryFolder(InventoryFolderBase folder) + { + if (m_hasReceivedInventory) + { + InventoryFolderBase invFolder = RootFolder.FindFolder(folder.ID); + + if (invFolder != null) + { + // Folder is in local cache, just update client + // + return true; + } + + InventoryFolderBase folderInfo = null; + + if (m_commsManager.SecureInventoryService != null) + { + folderInfo = m_commsManager.SecureInventoryService.QueryFolder(folder, m_session_id); + } + else + { + folderInfo = m_commsManager.InventoryService.QueryFolder(folder); + } + + if (folderInfo != null) + { + InventoryFolderImpl createdFolder = RootFolder.CreateChildFolder(folderInfo.ID, folderInfo.Name, (ushort)folderInfo.Type); + + createdFolder.Version = folderInfo.Version; + createdFolder.Owner = folderInfo.Owner; + createdFolder.ParentID = folderInfo.ParentID; + + return true; + } + + return false; + } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(QueryFolderDelegate), this, "QueryFolder"), + new object[] { folder.ID })); + + return true; + } + + return false; + } + } /// diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index fc9d8af..e37b188 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -113,6 +113,14 @@ namespace OpenSim.Framework.Communications InventoryItemBase QueryItem(InventoryItemBase item); /// + /// Query the server for a folder that may have been added by + /// another region + /// + /// + /// true if the folder was found in local cache + InventoryFolderBase QueryFolder(InventoryFolderBase folder); + + /// /// Does the given user have an inventory structure? /// /// diff --git a/OpenSim/Framework/Communications/ISecureInventoryService.cs b/OpenSim/Framework/Communications/ISecureInventoryService.cs index d70dd0b..a405ee5 100644 --- a/OpenSim/Framework/Communications/ISecureInventoryService.cs +++ b/OpenSim/Framework/Communications/ISecureInventoryService.cs @@ -98,6 +98,8 @@ namespace OpenSim.Framework.Communications InventoryItemBase QueryItem(InventoryItemBase item, UUID session_id); + InventoryFolderBase QueryFolder(InventoryFolderBase item, UUID session_id); + /// /// Does the given user have an inventory structure? /// diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index cad7989..ff66250 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -292,6 +292,20 @@ namespace OpenSim.Framework.Communications return null; } + public virtual InventoryFolderBase QueryFolder(InventoryFolderBase item) + { + foreach (IInventoryDataPlugin plugin in m_plugins) + { + InventoryFolderBase result = plugin.queryInventoryFolder(item.ID); + if (result != null) + { + return result; + } + } + + return null; + } + /// /// Purge a folder of all items items and subfolders. /// -- cgit v1.1