a few more changes on inventory library and inv fetch

httptests
UbitUmarov 2018-01-30 01:07:24 +00:00
parent 4c65bb4196
commit 5548b66dc0
4 changed files with 50 additions and 80 deletions

View File

@ -90,7 +90,7 @@ namespace OpenSim.Capabilities.Handlers
items[i++] = m_inventoryService.GetItem(UUID.Zero, id);
}
StringBuilder lsl = LLSDxmlEncode.Start(2048);
StringBuilder lsl = LLSDxmlEncode.Start(4096);
LLSDxmlEncode.AddMap(lsl);
if(m_agentID == UUID.Zero && items.Length > 0)
@ -100,49 +100,15 @@ namespace OpenSim.Capabilities.Handlers
if(items == null || items.Length == 0)
{
LLSDxmlEncode.AddEmptyArray("items",lsl);
LLSDxmlEncode.AddEmptyArray("items", lsl);
}
else
{
LLSDxmlEncode.AddArray("items",lsl);
LLSDxmlEncode.AddArray("items", lsl);
foreach (InventoryItemBase item in items)
{
if (item != null)
{
// this is as FecthLib, possible to move to a shared location later
LLSDxmlEncode.AddMap(lsl);
LLSDxmlEncode.AddElem("parent_id", item.Folder, lsl);
LLSDxmlEncode.AddElem("asset_id", item.AssetID, lsl);
LLSDxmlEncode.AddElem("item_id", item.ID, lsl);
LLSDxmlEncode.AddMap("permissions",lsl);
LLSDxmlEncode.AddElem("creator_id", item.CreatorIdAsUuid, lsl);
LLSDxmlEncode.AddElem("owner_id", item.Owner, lsl);
LLSDxmlEncode.AddElem("group_id", item.GroupID, lsl);
LLSDxmlEncode.AddElem("base_mask", (int)item.CurrentPermissions, lsl);
LLSDxmlEncode.AddElem("owner_mask", (int)item.CurrentPermissions, lsl);
LLSDxmlEncode.AddElem("group_mask", (int)item.GroupPermissions, lsl);
LLSDxmlEncode.AddElem("everyone_mask", (int)item.EveryOnePermissions, lsl);
LLSDxmlEncode.AddElem("next_owner_mask", (int)item.NextPermissions, lsl);
LLSDxmlEncode.AddElem("is_owner_group", item.GroupOwned, lsl);
LLSDxmlEncode.AddEndMap(lsl);
LLSDxmlEncode.AddElem("type", item.AssetType, lsl);
LLSDxmlEncode.AddElem("inv_type", item.InvType, lsl);
LLSDxmlEncode.AddElem("flags", ((int)item.Flags) & 0xff, lsl);
LLSDxmlEncode.AddElem("flags", ((int)item.Flags) & 0xff, lsl);
LLSDxmlEncode.AddMap("sale_info",lsl);
LLSDxmlEncode.AddElem("sale_price", item.SalePrice, lsl);
LLSDxmlEncode.AddElem("sale_type", item.SaleType, lsl);
LLSDxmlEncode.AddEndMap(lsl);
LLSDxmlEncode.AddElem("name", item.Name, lsl);
LLSDxmlEncode.AddElem("desc", item.Description, lsl);
LLSDxmlEncode.AddElem("created_at", item.CreationDate, lsl);
LLSDxmlEncode.AddEndMap(lsl);
}
item.ToLLSDxml(lsl);
}
LLSDxmlEncode.AddEndArray(lsl);
}

View File

@ -50,7 +50,6 @@ namespace OpenSim.Capabilities.Handlers
private UUID libOwner;
public FetchLib2Handler(IInventoryService invService, ILibraryService libraryService, UUID agentId)
{
m_inventoryService = invService;
m_agentID = agentId;
@ -63,15 +62,12 @@ namespace OpenSim.Capabilities.Handlers
{
//m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request);
if (m_LibraryService == null)
if (m_LibraryService == null || m_agentID == UUID.Zero)
return "<llsd><map><key><agent_id></key><uuid /><key>items</key><array /></map></llsd>";
OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
OSDArray itemsRequested = (OSDArray)requestmap["items"];
if (m_agentID == UUID.Zero)
return "<llsd><map><key><agent_id></key><uuid /><key>items</key><array /></map></llsd>";
UUID[] itemIDs = new UUID[itemsRequested.Count];
int i = 0;
@ -88,48 +84,15 @@ namespace OpenSim.Capabilities.Handlers
LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl);
if(items == null || items.Length == 0)
{
LLSDxmlEncode.AddEmptyArray("items",lsl);
LLSDxmlEncode.AddEmptyArray("items", lsl);
}
else
{
LLSDxmlEncode.AddArray("items",lsl);
LLSDxmlEncode.AddArray("items", lsl);
foreach (InventoryItemBase item in items)
{
if (item != null)
{
LLSDxmlEncode.AddMap(lsl);
LLSDxmlEncode.AddElem("parent_id", item.Folder, lsl);
LLSDxmlEncode.AddElem("asset_id", item.AssetID, lsl);
LLSDxmlEncode.AddElem("item_id", item.ID, lsl);
LLSDxmlEncode.AddMap("permissions",lsl);
LLSDxmlEncode.AddElem("creator_id", item.CreatorIdAsUuid, lsl);
LLSDxmlEncode.AddElem("owner_id", item.Owner, lsl);
LLSDxmlEncode.AddElem("group_id", item.GroupID, lsl);
LLSDxmlEncode.AddElem("base_mask", (int)item.CurrentPermissions, lsl);
LLSDxmlEncode.AddElem("owner_mask", (int)item.CurrentPermissions, lsl);
LLSDxmlEncode.AddElem("group_mask", (int)item.GroupPermissions, lsl);
LLSDxmlEncode.AddElem("everyone_mask", (int)item.EveryOnePermissions, lsl);
LLSDxmlEncode.AddElem("next_owner_mask", (int)item.NextPermissions, lsl);
LLSDxmlEncode.AddElem("is_owner_group", item.GroupOwned, lsl);
LLSDxmlEncode.AddEndMap(lsl);
LLSDxmlEncode.AddElem("type", item.AssetType, lsl);
LLSDxmlEncode.AddElem("inv_type", item.InvType, lsl);
LLSDxmlEncode.AddElem("flags", ((int)item.Flags) & 0xff, lsl);
LLSDxmlEncode.AddElem("flags", ((int)item.Flags) & 0xff, lsl);
LLSDxmlEncode.AddMap("sale_info",lsl);
LLSDxmlEncode.AddElem("sale_price", item.SalePrice, lsl);
LLSDxmlEncode.AddElem("sale_type", item.SaleType, lsl);
LLSDxmlEncode.AddEndMap(lsl);
LLSDxmlEncode.AddElem("name", item.Name, lsl);
LLSDxmlEncode.AddElem("desc", item.Description, lsl);
LLSDxmlEncode.AddElem("created_at", item.CreationDate, lsl);
LLSDxmlEncode.AddEndMap(lsl);
}
item.ToLLSDxml(lsl);
}
LLSDxmlEncode.AddEndArray(lsl);
}

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Text;
using OpenMetaverse;
namespace OpenSim.Framework
@ -415,5 +416,41 @@ namespace OpenSim.Framework
{
return MemberwiseClone();
}
public void ToLLSDxml(StringBuilder lsl)
{
LLSDxmlEncode.AddMap(lsl);
LLSDxmlEncode.AddElem("parent_id", Folder, lsl);
LLSDxmlEncode.AddElem("asset_id", AssetID, lsl);
LLSDxmlEncode.AddElem("item_id", ID, lsl);
LLSDxmlEncode.AddMap("permissions",lsl);
LLSDxmlEncode.AddElem("creator_id", CreatorIdAsUuid, lsl);
LLSDxmlEncode.AddElem("owner_id", Owner, lsl);
LLSDxmlEncode.AddElem("group_id", GroupID, lsl);
LLSDxmlEncode.AddElem("base_mask", (int)CurrentPermissions, lsl);
LLSDxmlEncode.AddElem("owner_mask", (int)CurrentPermissions, lsl);
LLSDxmlEncode.AddElem("group_mask", (int)GroupPermissions, lsl);
LLSDxmlEncode.AddElem("everyone_mask", (int)EveryOnePermissions, lsl);
LLSDxmlEncode.AddElem("next_owner_mask", (int)NextPermissions, lsl);
LLSDxmlEncode.AddElem("is_owner_group", GroupOwned, lsl);
LLSDxmlEncode.AddEndMap(lsl);
LLSDxmlEncode.AddElem("type", AssetType, lsl);
LLSDxmlEncode.AddElem("inv_type", InvType, lsl);
LLSDxmlEncode.AddElem("flags", ((int)Flags) & 0xff, lsl);
LLSDxmlEncode.AddElem("flags", ((int)Flags) & 0xff, lsl);
LLSDxmlEncode.AddMap("sale_info",lsl);
LLSDxmlEncode.AddElem("sale_price", SalePrice, lsl);
LLSDxmlEncode.AddElem("sale_type", SaleType, lsl);
LLSDxmlEncode.AddEndMap(lsl);
LLSDxmlEncode.AddElem("name", Name, lsl);
LLSDxmlEncode.AddElem("desc", Description, lsl);
LLSDxmlEncode.AddElem("created_at", CreationDate, lsl);
LLSDxmlEncode.AddEndMap(lsl);
}
}
}

View File

@ -47,6 +47,7 @@ namespace OpenSim.Region.ClientStack.Linden
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public bool Enabled { get; private set; }
private bool m_enabledLib;
private Scene m_scene;
@ -68,6 +69,8 @@ namespace OpenSim.Region.ClientStack.Linden
if (m_fetchInventory2Url != string.Empty)
Enabled = true;
if (m_fetchInventory2Url != string.Empty)
m_enabledLib = true;
}
public void AddRegion(Scene s)
@ -113,6 +116,7 @@ namespace OpenSim.Region.ClientStack.Linden
private void RegisterCaps(UUID agentID, Caps caps)
{
RegisterFetchCap(agentID, caps, "FetchInventory2", m_fetchInventory2Url);
if(m_enabledLib)
RegisterFetchLibCap(agentID, caps, "FetchLib2", m_fetchLib2Url);
}