From 4c65bb4196408bfb213496c2e52064d578ed0240 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 27 Jan 2018 18:09:44 +0000
Subject: a few more changes on inventory library and inv fetch
---
.../FetchInventory/FetchInventory2Handler.cs | 104 +++++++++++----------
1 file changed, 56 insertions(+), 48 deletions(-)
(limited to 'OpenSim/Capabilities/Handlers/FetchInventory')
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
index e239a90..66b46a6 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
@@ -26,6 +26,7 @@
*/
using System.Reflection;
+using System.Text;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
@@ -59,9 +60,6 @@ namespace OpenSim.Capabilities.Handlers
OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
OSDArray itemsRequested = (OSDArray)requestmap["items"];
- string reply;
- LLSDFetchInventory llsdReply = new LLSDFetchInventory();
-
UUID[] itemIDs = new UUID[itemsRequested.Count];
int i = 0;
@@ -92,55 +90,65 @@ namespace OpenSim.Capabilities.Handlers
items[i++] = m_inventoryService.GetItem(UUID.Zero, id);
}
- foreach (InventoryItemBase item in items)
+ StringBuilder lsl = LLSDxmlEncode.Start(2048);
+ LLSDxmlEncode.AddMap(lsl);
+
+ if(m_agentID == UUID.Zero && items.Length > 0)
+ LLSDxmlEncode.AddElem("agent_id", items[0].Owner, lsl);
+ else
+ LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl);
+
+ if(items == null || items.Length == 0)
+ {
+ LLSDxmlEncode.AddEmptyArray("items",lsl);
+ }
+ else
{
- if (item != null)
+ LLSDxmlEncode.AddArray("items",lsl);
+ foreach (InventoryItemBase item in items)
{
- // We don't know the agent that this request belongs to so we'll use the agent id of the item
- // which will be the same for all items.
- llsdReply.agent_id = item.Owner;
- llsdReply.items.Array.Add(ConvertInventoryItem(item));
+ 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);
+ }
}
- }
-
- reply = LLSDHelpers.SerialiseLLSDReply(llsdReply);
+ LLSDxmlEncode.AddEndArray(lsl);
+ }
- return reply;
- }
-
- ///
- /// Convert an internal inventory item object into an LLSD object.
- ///
- ///
- ///
- private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem)
- {
- LLSDInventoryItem llsdItem = new LLSDInventoryItem();
- llsdItem.asset_id = invItem.AssetID;
- llsdItem.created_at = invItem.CreationDate;
- llsdItem.desc = invItem.Description;
- llsdItem.flags = ((int)invItem.Flags) & 0xff;
- llsdItem.item_id = invItem.ID;
- llsdItem.name = invItem.Name;
- llsdItem.parent_id = invItem.Folder;
- llsdItem.type = invItem.AssetType;
- llsdItem.inv_type = invItem.InvType;
-
- llsdItem.permissions = new LLSDPermissions();
- llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
- llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions;
- llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions;
- llsdItem.permissions.group_id = invItem.GroupID;
- llsdItem.permissions.group_mask = (int)invItem.GroupPermissions;
- llsdItem.permissions.is_owner_group = invItem.GroupOwned;
- llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions;
- llsdItem.permissions.owner_id = invItem.Owner;
- llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
- llsdItem.sale_info = new LLSDSaleInfo();
- llsdItem.sale_info.sale_price = invItem.SalePrice;
- llsdItem.sale_info.sale_type = invItem.SaleType;
-
- return llsdItem;
+ LLSDxmlEncode.AddEndMap(lsl);
+ return LLSDxmlEncode.End(lsl);;
}
}
}
--
cgit v1.1