aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities
diff options
context:
space:
mode:
authorUbitUmarov2018-01-27 04:32:03 +0000
committerUbitUmarov2018-01-27 04:32:03 +0000
commit13b4ce81991736cf424f598233fc43a5103cc939 (patch)
tree51966348c41505aa88363f18712421b706288654 /OpenSim/Capabilities
parentLet MrOpenSim have simple hardcoded profile (diff)
downloadopensim-SC-13b4ce81991736cf424f598233fc43a5103cc939.zip
opensim-SC-13b4ce81991736cf424f598233fc43a5103cc939.tar.gz
opensim-SC-13b4ce81991736cf424f598233fc43a5103cc939.tar.bz2
opensim-SC-13b4ce81991736cf424f598233fc43a5103cc939.tar.xz
add Cap_FetchLib2 note that this is still local to regions, not using grid as it possible should, but this needs more work, and issue with HG older grids/regions
Diffstat (limited to 'OpenSim/Capabilities')
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory/FetchLib2Handler.cs141
1 files changed, 141 insertions, 0 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchLib2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchLib2Handler.cs
new file mode 100644
index 0000000..a43158b
--- /dev/null
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchLib2Handler.cs
@@ -0,0 +1,141 @@
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
28using System.Reflection;
29using System.Text;
30using OpenMetaverse;
31using OpenMetaverse.StructuredData;
32using OpenSim.Framework;
33using OpenSim.Framework.Capabilities;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Services.Interfaces;
36using OSDArray = OpenMetaverse.StructuredData.OSDArray;
37using OSDMap = OpenMetaverse.StructuredData.OSDMap;
38
39using log4net;
40
41namespace OpenSim.Capabilities.Handlers
42{
43 public class FetchLib2Handler
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 private IInventoryService m_inventoryService;
48 private ILibraryService m_LibraryService;
49 private UUID m_agentID;
50 private UUID libOwner;
51
52 public FetchLib2Handler(IInventoryService invService, ILibraryService libraryService, UUID agentId)
53
54 {
55 m_inventoryService = invService;
56 m_agentID = agentId;
57 m_LibraryService = libraryService;
58 if(libraryService != null)
59 libOwner = m_LibraryService.LibraryRootFolder.Owner;
60 }
61
62 public string FetchLibRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
63 {
64 //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request);
65
66 if (m_LibraryService == null)
67 return "<llsd><map><key><agent_id></key><uuid /><key>items</key><array /></map></llsd>";
68
69 OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
70 OSDArray itemsRequested = (OSDArray)requestmap["items"];
71
72 if (m_agentID == UUID.Zero)
73 return "<llsd><map><key><agent_id></key><uuid /><key>items</key><array /></map></llsd>";
74
75 UUID[] itemIDs = new UUID[itemsRequested.Count];
76 int i = 0;
77
78 foreach (OSDMap osdItemId in itemsRequested)
79 itemIDs[i++] = osdItemId["item_id"].AsUUID();
80
81 InventoryItemBase[] items = null;
82
83// items = m_inventoryService.GetMultipleItems(libOwner, itemIDs);
84 items = m_LibraryService.GetMultipleItems(itemIDs);
85
86 StringBuilder lsl = LLSDxmlEncode.Start(2048);
87 LLSDxmlEncode.AddMap(lsl);
88 LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl);
89 if(items == null || items.Length == 0)
90 {
91 LLSDxmlEncode.AddEmptyArray("items",lsl);
92 }
93 else
94 {
95 LLSDxmlEncode.AddArray("items",lsl);
96 foreach (InventoryItemBase item in items)
97 {
98 if (item != null)
99 {
100 LLSDxmlEncode.AddMap(lsl);
101 LLSDxmlEncode.AddElem("parent_id", item.Folder, lsl);
102 LLSDxmlEncode.AddElem("asset_id", item.AssetID, lsl);
103 LLSDxmlEncode.AddElem("item_id", item.ID, lsl);
104
105 LLSDxmlEncode.AddMap("permissions",lsl);
106 LLSDxmlEncode.AddElem("creator_id", item.CreatorIdAsUuid, lsl);
107 LLSDxmlEncode.AddElem("owner_id", item.Owner, lsl);
108 LLSDxmlEncode.AddElem("group_id", item.GroupID, lsl);
109 LLSDxmlEncode.AddElem("base_mask", (int)item.CurrentPermissions, lsl);
110 LLSDxmlEncode.AddElem("owner_mask", (int)item.CurrentPermissions, lsl);
111 LLSDxmlEncode.AddElem("group_mask", (int)item.GroupPermissions, lsl);
112 LLSDxmlEncode.AddElem("everyone_mask", (int)item.EveryOnePermissions, lsl);
113 LLSDxmlEncode.AddElem("next_owner_mask", (int)item.NextPermissions, lsl);
114 LLSDxmlEncode.AddElem("is_owner_group", item.GroupOwned, lsl);
115 LLSDxmlEncode.AddEndMap(lsl);
116
117 LLSDxmlEncode.AddElem("type", item.AssetType, lsl);
118 LLSDxmlEncode.AddElem("inv_type", item.InvType, lsl);
119 LLSDxmlEncode.AddElem("flags", ((int)item.Flags) & 0xff, lsl);
120 LLSDxmlEncode.AddElem("flags", ((int)item.Flags) & 0xff, lsl);
121
122 LLSDxmlEncode.AddMap("sale_info",lsl);
123 LLSDxmlEncode.AddElem("sale_price", item.SalePrice, lsl);
124 LLSDxmlEncode.AddElem("sale_type", item.SaleType, lsl);
125 LLSDxmlEncode.AddEndMap(lsl);
126
127 LLSDxmlEncode.AddElem("name", item.Name, lsl);
128 LLSDxmlEncode.AddElem("desc", item.Description, lsl);
129 LLSDxmlEncode.AddElem("created_at", item.CreationDate, lsl);
130
131 LLSDxmlEncode.AddEndMap(lsl);
132 }
133 }
134 LLSDxmlEncode.AddEndArray(lsl);
135 }
136
137 LLSDxmlEncode.AddEndMap(lsl);
138 return LLSDxmlEncode.End(lsl);;
139 }
140 }
141}