aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs')
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs70
1 files changed, 22 insertions, 48 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
index e239a90..0d7766c 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System.Reflection; 28using System.Reflection;
29using System.Text;
29using OpenMetaverse; 30using OpenMetaverse;
30using OpenMetaverse.StructuredData; 31using OpenMetaverse.StructuredData;
31using OpenSim.Framework; 32using OpenSim.Framework;
@@ -59,9 +60,6 @@ namespace OpenSim.Capabilities.Handlers
59 OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); 60 OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
60 OSDArray itemsRequested = (OSDArray)requestmap["items"]; 61 OSDArray itemsRequested = (OSDArray)requestmap["items"];
61 62
62 string reply;
63 LLSDFetchInventory llsdReply = new LLSDFetchInventory();
64
65 UUID[] itemIDs = new UUID[itemsRequested.Count]; 63 UUID[] itemIDs = new UUID[itemsRequested.Count];
66 int i = 0; 64 int i = 0;
67 65
@@ -92,55 +90,31 @@ namespace OpenSim.Capabilities.Handlers
92 items[i++] = m_inventoryService.GetItem(UUID.Zero, id); 90 items[i++] = m_inventoryService.GetItem(UUID.Zero, id);
93 } 91 }
94 92
95 foreach (InventoryItemBase item in items) 93 StringBuilder lsl = LLSDxmlEncode.Start(4096);
94 LLSDxmlEncode.AddMap(lsl);
95
96 if(m_agentID == UUID.Zero && items.Length > 0)
97 LLSDxmlEncode.AddElem("agent_id", items[0].Owner, lsl);
98 else
99 LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl);
100
101 if(items == null || items.Length == 0)
102 {
103 LLSDxmlEncode.AddEmptyArray("items", lsl);
104 }
105 else
96 { 106 {
97 if (item != null) 107 LLSDxmlEncode.AddArray("items", lsl);
108 foreach (InventoryItemBase item in items)
98 { 109 {
99 // We don't know the agent that this request belongs to so we'll use the agent id of the item 110 if (item != null)
100 // which will be the same for all items. 111 item.ToLLSDxml(lsl);
101 llsdReply.agent_id = item.Owner;
102 llsdReply.items.Array.Add(ConvertInventoryItem(item));
103 } 112 }
104 } 113 LLSDxmlEncode.AddEndArray(lsl);
105 114 }
106 reply = LLSDHelpers.SerialiseLLSDReply(llsdReply);
107 115
108 return reply; 116 LLSDxmlEncode.AddEndMap(lsl);
109 } 117 return LLSDxmlEncode.End(lsl);;
110
111 /// <summary>
112 /// Convert an internal inventory item object into an LLSD object.
113 /// </summary>
114 /// <param name="invItem"></param>
115 /// <returns></returns>
116 private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem)
117 {
118 LLSDInventoryItem llsdItem = new LLSDInventoryItem();
119 llsdItem.asset_id = invItem.AssetID;
120 llsdItem.created_at = invItem.CreationDate;
121 llsdItem.desc = invItem.Description;
122 llsdItem.flags = ((int)invItem.Flags) & 0xff;
123 llsdItem.item_id = invItem.ID;
124 llsdItem.name = invItem.Name;
125 llsdItem.parent_id = invItem.Folder;
126 llsdItem.type = invItem.AssetType;
127 llsdItem.inv_type = invItem.InvType;
128
129 llsdItem.permissions = new LLSDPermissions();
130 llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
131 llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions;
132 llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions;
133 llsdItem.permissions.group_id = invItem.GroupID;
134 llsdItem.permissions.group_mask = (int)invItem.GroupPermissions;
135 llsdItem.permissions.is_owner_group = invItem.GroupOwned;
136 llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions;
137 llsdItem.permissions.owner_id = invItem.Owner;
138 llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
139 llsdItem.sale_info = new LLSDSaleInfo();
140 llsdItem.sale_info.sale_price = invItem.SalePrice;
141 llsdItem.sale_info.sale_type = invItem.SaleType;
142
143 return llsdItem;
144 } 118 }
145 } 119 }
146} 120}