mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 20:05:33 +08:00
a few more changes on inventory library and inv fetch
This commit is contained in:
@@ -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)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
LLSDxmlEncode.AddEmptyArray("items",lsl);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
|
||||
reply = LLSDHelpers.SerialiseLLSDReply(llsdReply);
|
||||
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);
|
||||
|
||||
return reply;
|
||||
}
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Convert an internal inventory item object into an LLSD object.
|
||||
/// </summary>
|
||||
/// <param name="invItem"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
LLSDxmlEncode.AddMap("sale_info",lsl);
|
||||
LLSDxmlEncode.AddElem("sale_price", item.SalePrice, lsl);
|
||||
LLSDxmlEncode.AddElem("sale_type", item.SaleType, lsl);
|
||||
LLSDxmlEncode.AddEndMap(lsl);
|
||||
|
||||
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;
|
||||
LLSDxmlEncode.AddElem("name", item.Name, lsl);
|
||||
LLSDxmlEncode.AddElem("desc", item.Description, lsl);
|
||||
LLSDxmlEncode.AddElem("created_at", item.CreationDate, lsl);
|
||||
|
||||
return llsdItem;
|
||||
LLSDxmlEncode.AddEndMap(lsl);
|
||||
}
|
||||
}
|
||||
LLSDxmlEncode.AddEndArray(lsl);
|
||||
}
|
||||
|
||||
LLSDxmlEncode.AddEndMap(lsl);
|
||||
return LLSDxmlEncode.End(lsl);;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user