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).0.7.3-extended
parent
771539a4e0
commit
41d98916df
|
@ -101,18 +101,8 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
llsdItem.item_id = invItem.ID;
|
llsdItem.item_id = invItem.ID;
|
||||||
llsdItem.name = invItem.Name;
|
llsdItem.name = invItem.Name;
|
||||||
llsdItem.parent_id = invItem.Folder;
|
llsdItem.parent_id = invItem.Folder;
|
||||||
|
llsdItem.type = invItem.AssetType;
|
||||||
try
|
llsdItem.inv_type = invItem.InvType;
|
||||||
{
|
|
||||||
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.permissions = new LLSDPermissions();
|
llsdItem.permissions = new LLSDPermissions();
|
||||||
llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
|
llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
|
||||||
|
@ -126,21 +116,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
|
llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
|
||||||
llsdItem.sale_info = new LLSDSaleInfo();
|
llsdItem.sale_info = new LLSDSaleInfo();
|
||||||
llsdItem.sale_info.sale_price = invItem.SalePrice;
|
llsdItem.sale_info.sale_price = invItem.SalePrice;
|
||||||
switch (invItem.SaleType)
|
llsdItem.sale_info.sale_type = 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return llsdItem;
|
return llsdItem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,11 +156,12 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
inv.Folders = new List<InventoryFolderBase>();
|
inv.Folders = new List<InventoryFolderBase>();
|
||||||
inv.Items = new List<InventoryItemBase>();
|
inv.Items = new List<InventoryItemBase>();
|
||||||
int version = 0;
|
int version = 0;
|
||||||
|
int descendents = 0;
|
||||||
|
|
||||||
inv
|
inv
|
||||||
= Fetch(
|
= Fetch(
|
||||||
invFetch.owner_id, invFetch.folder_id, invFetch.owner_id,
|
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.Folders != null)
|
if (inv.Folders != null)
|
||||||
{
|
{
|
||||||
|
@ -168,6 +169,8 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
{
|
{
|
||||||
contents.categories.Array.Add(ConvertInventoryFolder(invFolder));
|
contents.categories.Array.Add(ConvertInventoryFolder(invFolder));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
descendents += inv.Folders;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inv.Items != null)
|
if (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;
|
contents.version = version;
|
||||||
|
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
|
@ -206,7 +209,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
/// <returns>An empty InventoryCollection if the inventory look up failed</returns>
|
/// <returns>An empty InventoryCollection if the inventory look up failed</returns>
|
||||||
private InventoryCollection Fetch(
|
private InventoryCollection Fetch(
|
||||||
UUID agentID, UUID folderID, UUID ownerID,
|
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(
|
// m_log.DebugFormat(
|
||||||
// "[WEB FETCH INV DESC HANDLER]: Fetching folders ({0}), items ({1}) from {2} for agent {3}",
|
// "[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!
|
// FIXME MAYBE: We're not handling sortOrder!
|
||||||
|
|
||||||
version = 0;
|
version = 0;
|
||||||
|
descendents = 0;
|
||||||
|
|
||||||
InventoryFolderImpl fold;
|
InventoryFolderImpl fold;
|
||||||
if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null && agentID == m_LibraryService.LibraryRootFolder.Owner)
|
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();
|
InventoryCollection ret = new InventoryCollection();
|
||||||
ret.Folders = new List<InventoryFolderBase>();
|
ret.Folders = new List<InventoryFolderBase>();
|
||||||
ret.Items = fold.RequestListOfItems();
|
ret.Items = fold.RequestListOfItems();
|
||||||
|
descendents = ret.Folders.Count + ret.Items.Count;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -246,24 +252,73 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
|
|
||||||
version = containingFolder.Version;
|
version = containingFolder.Version;
|
||||||
|
|
||||||
// if (fetchItems)
|
if (fetchItems)
|
||||||
|
{
|
||||||
|
List<InventoryItemBase> itemsToReturn = contents.Items;
|
||||||
|
List<InventoryItemBase> originalItems = new List<InventoryItemBase>(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<InventoryItemBase> 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<InventoryItemBase> linkedItemsToAdd = new List<InventoryItemBase>();
|
// m_log.DebugFormat(
|
||||||
//
|
// "[WEB FETCH INV DESC HANDLER]: Returning item {0}, type {1}, parent {2} in {3} {4}",
|
||||||
// foreach (InventoryItemBase item in contents.Items)
|
// item.Name, (AssetType)item.AssetType, item.Folder, containingFolder.Name, containingFolder.ID);
|
||||||
// {
|
// }
|
||||||
// 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);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// foreach (InventoryItemBase linkedItem in linkedItemsToAdd)
|
// foreach (InventoryItemBase linkedItem in linkedItemsToAdd)
|
||||||
// {
|
// {
|
||||||
|
@ -365,18 +420,8 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
llsdItem.item_id = invItem.ID;
|
llsdItem.item_id = invItem.ID;
|
||||||
llsdItem.name = invItem.Name;
|
llsdItem.name = invItem.Name;
|
||||||
llsdItem.parent_id = invItem.Folder;
|
llsdItem.parent_id = invItem.Folder;
|
||||||
|
llsdItem.type = invItem.AssetType;
|
||||||
try
|
llsdItem.inv_type = invItem.InvType;
|
||||||
{
|
|
||||||
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.permissions = new LLSDPermissions();
|
llsdItem.permissions = new LLSDPermissions();
|
||||||
llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
|
llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
|
||||||
|
@ -390,21 +435,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
|
llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
|
||||||
llsdItem.sale_info = new LLSDSaleInfo();
|
llsdItem.sale_info = new LLSDSaleInfo();
|
||||||
llsdItem.sale_info.sale_price = invItem.SalePrice;
|
llsdItem.sale_info.sale_price = invItem.SalePrice;
|
||||||
switch (invItem.SaleType)
|
llsdItem.sale_info.sale_type = 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return llsdItem;
|
return llsdItem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ namespace OpenSim.Framework.Capabilities
|
||||||
public UUID asset_id;
|
public UUID asset_id;
|
||||||
public UUID item_id;
|
public UUID item_id;
|
||||||
public LLSDPermissions permissions;
|
public LLSDPermissions permissions;
|
||||||
public string type;
|
public int type;
|
||||||
public string inv_type;
|
public int inv_type;
|
||||||
public int flags;
|
public int flags;
|
||||||
|
|
||||||
public LLSDSaleInfo sale_info;
|
public LLSDSaleInfo sale_info;
|
||||||
|
@ -65,7 +65,7 @@ namespace OpenSim.Framework.Capabilities
|
||||||
public class LLSDSaleInfo
|
public class LLSDSaleInfo
|
||||||
{
|
{
|
||||||
public int sale_price;
|
public int sale_price;
|
||||||
public string sale_type;
|
public int sale_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
[OSDMap]
|
[OSDMap]
|
||||||
|
|
|
@ -416,7 +416,7 @@ namespace OpenSim.Services.InventoryService
|
||||||
public virtual bool AddItem(InventoryItemBase item)
|
public virtual bool AddItem(InventoryItemBase item)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat(
|
// 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));
|
return m_Database.StoreItem(ConvertFromOpenSim(item));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue