From 01a2b0b289933febc95523de02275c9bd573b10e Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 2 Jun 2012 04:57:10 +0100 Subject: [PATCH 1/6] Fix various issues with http inventory 1) The return messages were being wrongly populated with the names of asset, inventory and sale types when their corresponding integers should have been used instead. 2) Folders with links were including the linked items in the descendents figure, when only the links should be included. 3) Links and linked items in link folders were not being included in the return data, and not in the correct order. Now that these issues have been addressed, outfits and attachments appear to work consistently when HTTP inventory is enabled (as is now the default). --- .../FetchInventory2/FetchInventory2Handler.cs | 30 +---- .../WebFetchInvDescHandler.cs | 125 +++++++++++------- OpenSim/Capabilities/LLSDInventoryItem.cs | 6 +- .../InventoryService/XInventoryService.cs | 2 +- 4 files changed, 85 insertions(+), 78 deletions(-) diff --git a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs index 717a097c70..c0ca1e1896 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs @@ -101,18 +101,8 @@ namespace OpenSim.Capabilities.Handlers llsdItem.item_id = invItem.ID; llsdItem.name = invItem.Name; llsdItem.parent_id = invItem.Folder; - - try - { - llsdItem.type = Utils.AssetTypeToString((AssetType)invItem.AssetType); - llsdItem.inv_type = Utils.InventoryTypeToString((InventoryType)invItem.InvType); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[WEB FETCH INV DESC HANDLER]: Problem setting asset {0} inventory {1} types while converting inventory item {2}: {3}", - invItem.AssetType, invItem.InvType, invItem.Name, e.Message); - } + llsdItem.type = invItem.AssetType; + llsdItem.inv_type = invItem.InvType; llsdItem.permissions = new LLSDPermissions(); llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; @@ -126,21 +116,7 @@ namespace OpenSim.Capabilities.Handlers llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; llsdItem.sale_info = new LLSDSaleInfo(); llsdItem.sale_info.sale_price = invItem.SalePrice; - switch (invItem.SaleType) - { - default: - llsdItem.sale_info.sale_type = "not"; - break; - case 1: - llsdItem.sale_info.sale_type = "original"; - break; - case 2: - llsdItem.sale_info.sale_type = "copy"; - break; - case 3: - llsdItem.sale_info.sale_type = "contents"; - break; - } + llsdItem.sale_info.sale_type = invItem.SaleType; return llsdItem; } diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs index d5c062b831..b3196d99db 100644 --- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs @@ -156,11 +156,12 @@ namespace OpenSim.Capabilities.Handlers inv.Folders = new List(); inv.Items = new List(); int version = 0; + int descendents = 0; inv = Fetch( invFetch.owner_id, invFetch.folder_id, invFetch.owner_id, - invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version); + invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version, out descendents); if (inv != null && inv.Folders != null) { @@ -168,6 +169,8 @@ namespace OpenSim.Capabilities.Handlers { contents.categories.Array.Add(ConvertInventoryFolder(invFolder)); } + + descendents += inv.Folders; } if (inv != null && inv.Items != null) @@ -178,7 +181,7 @@ namespace OpenSim.Capabilities.Handlers } } - contents.descendents = contents.items.Array.Count + contents.categories.Array.Count; + contents.descendents = descendents; contents.version = version; // m_log.DebugFormat( @@ -206,7 +209,7 @@ namespace OpenSim.Capabilities.Handlers /// An empty InventoryCollection if the inventory look up failed private InventoryCollection Fetch( UUID agentID, UUID folderID, UUID ownerID, - bool fetchFolders, bool fetchItems, int sortOrder, out int version) + bool fetchFolders, bool fetchItems, int sortOrder, out int version, out int descendents) { // m_log.DebugFormat( // "[WEB FETCH INV DESC HANDLER]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", @@ -215,6 +218,8 @@ namespace OpenSim.Capabilities.Handlers // FIXME MAYBE: We're not handling sortOrder! version = 0; + descendents = 0; + InventoryFolderImpl fold; if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null && agentID == m_LibraryService.LibraryRootFolder.Owner) { @@ -223,6 +228,7 @@ namespace OpenSim.Capabilities.Handlers InventoryCollection ret = new InventoryCollection(); ret.Folders = new List(); ret.Items = fold.RequestListOfItems(); + descendents = ret.Folders.Count + ret.Items.Count; return ret; } @@ -246,24 +252,73 @@ namespace OpenSim.Capabilities.Handlers version = containingFolder.Version; -// if (fetchItems) + if (fetchItems) + { + List itemsToReturn = contents.Items; + List originalItems = new List(itemsToReturn); + + // descendents must only include the links, not the linked items we add + descendents = originalItems.Count; + + // Second, add target items for links in this folder + foreach (InventoryItemBase item in originalItems) + { + if (item.AssetType == (int)AssetType.Link) + { + InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID)); + + // Take care of genuinely broken links where the target doesn't exist + // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, + // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles + // rather than having to keep track of every folder requested in the recursion. + if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) + itemsToReturn.Insert(0, linkedItem); + } + } + + // First, scan for folder links and add target items in those folders. + foreach (InventoryItemBase item in originalItems) + { + if (item.AssetType == (int)AssetType.LinkFolder) + { + InventoryCollection linkedFolderContents = m_InventoryService.GetFolderContent(ownerID, item.AssetID); + List links = linkedFolderContents.Items; + + // Second, insert the links contained in this linked folder. + itemsToReturn.InsertRange(0, links); + + // Third, insert the real items linked by the links in this linked folder. + foreach (InventoryItemBase link in linkedFolderContents.Items) + { + // Take care of genuinely broken links where the target doesn't exist + // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, + // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles + // rather than having to keep track of every folder requested in the recursion. + if (link != null) + { +// m_log.DebugFormat( +// "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3}", +// link.Name, (AssetType)link.AssetType, item.AssetID, containingFolder.Name); + + InventoryItemBase linkedItem + = m_InventoryService.GetItem(new InventoryItemBase(link.AssetID)); + + itemsToReturn.Insert(0, linkedItem); + } + } + } + } + } + +// foreach (InventoryItemBase item in contents.Items) // { -// List linkedItemsToAdd = new List(); -// -// foreach (InventoryItemBase item in contents.Items) -// { -// if (item.AssetType == (int)AssetType.Link) -// { -// InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID)); -// -// // Take care of genuinely broken links where the target doesn't exist -// // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, -// // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles -// // rather than having to keep track of every folder requested in the recursion. -// if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) -// linkedItemsToAdd.Insert(0, linkedItem); -// } -// } +// m_log.DebugFormat( +// "[WEB FETCH INV DESC HANDLER]: Returning item {0}, type {1}, parent {2} in {3} {4}", +// item.Name, (AssetType)item.AssetType, item.Folder, containingFolder.Name, containingFolder.ID); +// } + + // ===== + // // foreach (InventoryItemBase linkedItem in linkedItemsToAdd) // { @@ -365,18 +420,8 @@ namespace OpenSim.Capabilities.Handlers llsdItem.item_id = invItem.ID; llsdItem.name = invItem.Name; llsdItem.parent_id = invItem.Folder; - - try - { - llsdItem.type = Utils.AssetTypeToString((AssetType)invItem.AssetType); - llsdItem.inv_type = Utils.InventoryTypeToString((InventoryType)invItem.InvType); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[WEB FETCH INV DESC HANDLER]: Problem setting asset {0} inventory {1} types while converting inventory item {2}: {3}", - invItem.AssetType, invItem.InvType, invItem.Name, e.Message); - } + llsdItem.type = invItem.AssetType; + llsdItem.inv_type = invItem.InvType; llsdItem.permissions = new LLSDPermissions(); llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; @@ -390,21 +435,7 @@ namespace OpenSim.Capabilities.Handlers llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; llsdItem.sale_info = new LLSDSaleInfo(); llsdItem.sale_info.sale_price = invItem.SalePrice; - switch (invItem.SaleType) - { - default: - llsdItem.sale_info.sale_type = "not"; - break; - case 1: - llsdItem.sale_info.sale_type = "original"; - break; - case 2: - llsdItem.sale_info.sale_type = "copy"; - break; - case 3: - llsdItem.sale_info.sale_type = "contents"; - break; - } + llsdItem.sale_info.sale_type = invItem.SaleType; return llsdItem; } diff --git a/OpenSim/Capabilities/LLSDInventoryItem.cs b/OpenSim/Capabilities/LLSDInventoryItem.cs index 426a6cbaf5..958e8079b4 100644 --- a/OpenSim/Capabilities/LLSDInventoryItem.cs +++ b/OpenSim/Capabilities/LLSDInventoryItem.cs @@ -37,8 +37,8 @@ namespace OpenSim.Framework.Capabilities public UUID asset_id; public UUID item_id; public LLSDPermissions permissions; - public string type; - public string inv_type; + public int type; + public int inv_type; public int flags; public LLSDSaleInfo sale_info; @@ -65,7 +65,7 @@ namespace OpenSim.Framework.Capabilities public class LLSDSaleInfo { public int sale_price; - public string sale_type; + public int sale_type; } [OSDMap] diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 3355428cf4..7518b86f0b 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -436,7 +436,7 @@ namespace OpenSim.Services.InventoryService public virtual bool AddItem(InventoryItemBase item) { // m_log.DebugFormat( -// "[XINVENTORY SERVICE]: Adding item {0} to folder {1} for {2}", item.ID, item.Folder, item.Owner); +// "[XINVENTORY SERVICE]: Adding item {0} {1} to folder {2} for {3}", item.Name, item.ID, item.Folder, item.Owner); return m_Database.StoreItem(ConvertFromOpenSim(item)); } From 2de5479c3f0df84ab76365dc3a6eb618012c3153 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 2 Jun 2012 05:01:56 +0100 Subject: [PATCH 2/6] minor: tidy up some comments --- .../WebFetchInventoryDescendents/WebFetchInvDescHandler.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs index b3196d99db..1594c55938 100644 --- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs @@ -260,7 +260,7 @@ namespace OpenSim.Capabilities.Handlers // descendents must only include the links, not the linked items we add descendents = originalItems.Count; - // Second, add target items for links in this folder + // Add target items for links in this folder before the links themselves. foreach (InventoryItemBase item in originalItems) { if (item.AssetType == (int)AssetType.Link) @@ -276,7 +276,7 @@ namespace OpenSim.Capabilities.Handlers } } - // First, scan for folder links and add target items in those folders. + // Now scan for folder links and insert the items they target and those links at the head of the return data foreach (InventoryItemBase item in originalItems) { if (item.AssetType == (int)AssetType.LinkFolder) @@ -284,10 +284,8 @@ namespace OpenSim.Capabilities.Handlers InventoryCollection linkedFolderContents = m_InventoryService.GetFolderContent(ownerID, item.AssetID); List links = linkedFolderContents.Items; - // Second, insert the links contained in this linked folder. itemsToReturn.InsertRange(0, links); - // Third, insert the real items linked by the links in this linked folder. foreach (InventoryItemBase link in linkedFolderContents.Items) { // Take care of genuinely broken links where the target doesn't exist From 729d90173f82f5ac51b8b69ee8b3362599ffd2f1 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 2 Jun 2012 05:03:56 +0100 Subject: [PATCH 3/6] Fix build break whree accidentally did inv.Folders rather than inv.Folders.Count in a minor change. --- .../WebFetchInventoryDescendents/WebFetchInvDescHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs index 1594c55938..849cad2115 100644 --- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs @@ -170,7 +170,7 @@ namespace OpenSim.Capabilities.Handlers contents.categories.Array.Add(ConvertInventoryFolder(invFolder)); } - descendents += inv.Folders; + descendents += inv.Folders.Count; } if (inv != null && inv.Items != null) From 5c646e26031400961dcfe3d7c4bd84512a1bc7cb Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jun 2012 18:22:09 +0100 Subject: [PATCH 4/6] Remove the "Profile" config as it's covered by the replaceable interface --- .../CoreModules/Avatar/Profile/BasicProfileModule.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs index 8101ca21c3..87ca3277be 100644 --- a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs @@ -57,14 +57,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile public void Initialise(IConfigSource config) { - // This can be reduced later as the loader will determine - // whether we are needed - if (config.Configs["Profile"] != null) - { - if (config.Configs["Profile"].GetString("Module", string.Empty) != "BasicProfileModule") - return; - } - m_log.DebugFormat("[PROFILE MODULE]: Basic Profile Module enabled"); m_Enabled = true; } From f94ef37b46c680e3d74b21cdb2e2a89f482bcc62 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 4 Jun 2012 10:26:39 -0700 Subject: [PATCH 5/6] Correct the delegate specification in EventManager.TriggerTerrainTainted. Looks like the wrong one was cut and pasted. --- OpenSim/Region/Framework/Scenes/EventManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index f97b0a9a19..f92ed8e599 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -923,7 +923,7 @@ namespace OpenSim.Region.Framework.Scenes OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted; if (handlerTerrainTainted != null) { - foreach (OnTerrainTickDelegate d in handlerTerrainTainted.GetInvocationList()) + foreach (OnTerrainTaintedDelegate d in handlerTerrainTainted.GetInvocationList()) { try { From 9707a2d57c4a4a8e818e0e9b0ec57c5b7abcb70c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jun 2012 18:24:02 +0100 Subject: [PATCH 6/6] Remove profile from basic configuration --- bin/config-include/Grid.ini | 3 --- bin/config-include/Standalone.ini | 3 --- 2 files changed, 6 deletions(-) diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini index 95d62649ca..cb3a5c86d6 100644 --- a/bin/config-include/Grid.ini +++ b/bin/config-include/Grid.ini @@ -29,9 +29,6 @@ SimulationServiceInConnector = true LibraryModule = true -[Profile] - Module = "BasicProfileModule" - [SimulationDataStore] LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService" diff --git a/bin/config-include/Standalone.ini b/bin/config-include/Standalone.ini index 74d9d2eb3e..ba72fe747d 100644 --- a/bin/config-include/Standalone.ini +++ b/bin/config-include/Standalone.ini @@ -25,9 +25,6 @@ GridInfoServiceInConnector = true MapImageServiceInConnector = true -[Profile] - Module = "BasicProfileModule" - [SimulationDataStore] LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService"