diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs | 104 |
1 files changed, 56 insertions, 48 deletions
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 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Reflection; | 28 | using System.Reflection; |
29 | using System.Text; | ||
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenMetaverse.StructuredData; | 31 | using OpenMetaverse.StructuredData; |
31 | using OpenSim.Framework; | 32 | using 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,65 @@ 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(2048); |
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 | { |
101 | llsdReply.agent_id = item.Owner; | 112 | // this is as FecthLib, possible to move to a shared location later |
102 | llsdReply.items.Array.Add(ConvertInventoryItem(item)); | 113 | LLSDxmlEncode.AddMap(lsl); |
114 | LLSDxmlEncode.AddElem("parent_id", item.Folder, lsl); | ||
115 | LLSDxmlEncode.AddElem("asset_id", item.AssetID, lsl); | ||
116 | LLSDxmlEncode.AddElem("item_id", item.ID, lsl); | ||
117 | |||
118 | LLSDxmlEncode.AddMap("permissions",lsl); | ||
119 | LLSDxmlEncode.AddElem("creator_id", item.CreatorIdAsUuid, lsl); | ||
120 | LLSDxmlEncode.AddElem("owner_id", item.Owner, lsl); | ||
121 | LLSDxmlEncode.AddElem("group_id", item.GroupID, lsl); | ||
122 | LLSDxmlEncode.AddElem("base_mask", (int)item.CurrentPermissions, lsl); | ||
123 | LLSDxmlEncode.AddElem("owner_mask", (int)item.CurrentPermissions, lsl); | ||
124 | LLSDxmlEncode.AddElem("group_mask", (int)item.GroupPermissions, lsl); | ||
125 | LLSDxmlEncode.AddElem("everyone_mask", (int)item.EveryOnePermissions, lsl); | ||
126 | LLSDxmlEncode.AddElem("next_owner_mask", (int)item.NextPermissions, lsl); | ||
127 | LLSDxmlEncode.AddElem("is_owner_group", item.GroupOwned, lsl); | ||
128 | LLSDxmlEncode.AddEndMap(lsl); | ||
129 | |||
130 | LLSDxmlEncode.AddElem("type", item.AssetType, lsl); | ||
131 | LLSDxmlEncode.AddElem("inv_type", item.InvType, lsl); | ||
132 | LLSDxmlEncode.AddElem("flags", ((int)item.Flags) & 0xff, lsl); | ||
133 | LLSDxmlEncode.AddElem("flags", ((int)item.Flags) & 0xff, lsl); | ||
134 | |||
135 | LLSDxmlEncode.AddMap("sale_info",lsl); | ||
136 | LLSDxmlEncode.AddElem("sale_price", item.SalePrice, lsl); | ||
137 | LLSDxmlEncode.AddElem("sale_type", item.SaleType, lsl); | ||
138 | LLSDxmlEncode.AddEndMap(lsl); | ||
139 | |||
140 | LLSDxmlEncode.AddElem("name", item.Name, lsl); | ||
141 | LLSDxmlEncode.AddElem("desc", item.Description, lsl); | ||
142 | LLSDxmlEncode.AddElem("created_at", item.CreationDate, lsl); | ||
143 | |||
144 | LLSDxmlEncode.AddEndMap(lsl); | ||
145 | } | ||
103 | } | 146 | } |
104 | } | 147 | LLSDxmlEncode.AddEndArray(lsl); |
105 | 148 | } | |
106 | reply = LLSDHelpers.SerialiseLLSDReply(llsdReply); | ||
107 | 149 | ||
108 | return reply; | 150 | LLSDxmlEncode.AddEndMap(lsl); |
109 | } | 151 | 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 | } | 152 | } |
145 | } | 153 | } |
146 | } | 154 | } |