opensim-development – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ |
||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
||
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions are met: |
||
7 | * * Redistributions of source code must retain the above copyright |
||
8 | * notice, this list of conditions and the following disclaimer. |
||
9 | * * Redistributions in binary form must reproduce the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer in the |
||
11 | * documentation and/or other materials provided with the distribution. |
||
12 | * * Neither the name of the OpenSimulator Project nor the |
||
13 | * names of its contributors may be used to endorse or promote products |
||
14 | * derived from this software without specific prior written permission. |
||
15 | * |
||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
26 | */ |
||
27 | |||
28 | using System; |
||
29 | using System.Collections; |
||
30 | using System.Collections.Generic; |
||
31 | using System.Reflection; |
||
32 | using log4net; |
||
33 | using Nini.Config; |
||
34 | using OpenMetaverse; |
||
35 | using OpenMetaverse.StructuredData; |
||
36 | using OpenSim.Framework; |
||
37 | using OpenSim.Framework.Capabilities; |
||
38 | using OpenSim.Region.Framework.Interfaces; |
||
39 | using OpenSim.Framework.Servers.HttpServer; |
||
40 | using OpenSim.Services.Interfaces; |
||
41 | using Caps = OpenSim.Framework.Capabilities.Caps; |
||
42 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; |
||
43 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; |
||
44 | |||
45 | namespace OpenSim.Capabilities.Handlers |
||
46 | { |
||
47 | public class FetchInventory2Handler |
||
48 | { |
||
49 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
||
50 | |||
51 | private IInventoryService m_inventoryService; |
||
52 | |||
53 | public FetchInventory2Handler(IInventoryService invService) |
||
54 | { |
||
55 | m_inventoryService = invService; |
||
56 | } |
||
57 | |||
58 | public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
||
59 | { |
||
60 | // m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capabilty request"); |
||
61 | |||
62 | OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); |
||
63 | OSDArray itemsRequested = (OSDArray)requestmap["items"]; |
||
64 | |||
65 | string reply; |
||
66 | LLSDFetchInventory llsdReply = new LLSDFetchInventory(); |
||
67 | |||
68 | foreach (OSDMap osdItemId in itemsRequested) |
||
69 | { |
||
70 | UUID itemId = osdItemId["item_id"].AsUUID(); |
||
71 | |||
72 | InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(itemId)); |
||
73 | |||
74 | if (item != null) |
||
75 | { |
||
76 | // We don't know the agent that this request belongs to so we'll use the agent id of the item |
||
77 | // which will be the same for all items. |
||
78 | llsdReply.agent_id = item.Owner; |
||
79 | |||
80 | llsdReply.items.Array.Add(ConvertInventoryItem(item)); |
||
81 | } |
||
82 | } |
||
83 | |||
84 | reply = LLSDHelpers.SerialiseLLSDReply(llsdReply); |
||
85 | |||
86 | return reply; |
||
87 | } |
||
88 | |||
89 | /// <summary> |
||
90 | /// Convert an internal inventory item object into an LLSD object. |
||
91 | /// </summary> |
||
92 | /// <param name="invItem"></param> |
||
93 | /// <returns></returns> |
||
94 | private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem) |
||
95 | { |
||
96 | LLSDInventoryItem llsdItem = new LLSDInventoryItem(); |
||
97 | llsdItem.asset_id = invItem.AssetID; |
||
98 | llsdItem.created_at = invItem.CreationDate; |
||
99 | llsdItem.desc = invItem.Description; |
||
100 | llsdItem.flags = (int)invItem.Flags; |
||
101 | llsdItem.item_id = invItem.ID; |
||
102 | llsdItem.name = invItem.Name; |
||
103 | llsdItem.parent_id = invItem.Folder; |
||
104 | llsdItem.type = invItem.AssetType; |
||
105 | llsdItem.inv_type = invItem.InvType; |
||
106 | |||
107 | llsdItem.permissions = new LLSDPermissions(); |
||
108 | llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; |
||
109 | llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; |
||
110 | llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions; |
||
111 | llsdItem.permissions.group_id = invItem.GroupID; |
||
112 | llsdItem.permissions.group_mask = (int)invItem.GroupPermissions; |
||
113 | llsdItem.permissions.is_owner_group = invItem.GroupOwned; |
||
114 | llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions; |
||
115 | llsdItem.permissions.owner_id = invItem.Owner; |
||
116 | llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; |
||
117 | llsdItem.sale_info = new LLSDSaleInfo(); |
||
118 | llsdItem.sale_info.sale_price = invItem.SalePrice; |
||
119 | llsdItem.sale_info.sale_type = invItem.SaleType; |
||
120 | |||
121 | return llsdItem; |
||
122 | } |
||
123 | } |
||
124 | } |