aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs324
-rw-r--r--OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs48
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs29
3 files changed, 400 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
new file mode 100644
index 0000000..fb353c2
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
@@ -0,0 +1,324 @@
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 log4net;
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32using Nini.Config;
33using OpenSim.Framework;
34using OpenSim.Framework.Statistics;
35
36using OpenSim.Services.Connectors;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces;
40using OpenMetaverse;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
43{
44 public class RemoteXInventoryServicesConnector : BaseInventoryConnector, ISharedRegionModule, IInventoryService
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 private bool m_Enabled = false;
50 private bool m_Initialized = false;
51 private Scene m_Scene;
52 private XInventoryServicesConnector m_RemoteConnector;
53
54 public Type ReplaceableInterface
55 {
56 get { return null; }
57 }
58
59 public string Name
60 {
61 get { return "RemoteXInventoryServicesConnector"; }
62 }
63
64 public RemoteXInventoryServicesConnector()
65 {
66 }
67
68 public RemoteXInventoryServicesConnector(IConfigSource source)
69 {
70 Init(source);
71 }
72
73 protected override void Init(IConfigSource source)
74 {
75 m_RemoteConnector = new XInventoryServicesConnector(source);
76 base.Init(source);
77 }
78
79
80 #region ISharedRegionModule
81
82 public void Initialise(IConfigSource source)
83 {
84 IConfig moduleConfig = source.Configs["Modules"];
85 if (moduleConfig != null)
86 {
87 string name = moduleConfig.GetString("InventoryServices", "");
88 if (name == Name)
89 {
90 Init(source);
91 m_Enabled = true;
92
93 m_log.Info("[XINVENTORY CONNECTOR]: Remote XInventory enabled");
94 }
95 }
96 }
97
98 public void PostInitialise()
99 {
100 }
101
102 public void Close()
103 {
104 }
105
106 public void AddRegion(Scene scene)
107 {
108 m_Scene = scene;
109 //m_log.Debug("[XXXX] Adding scene " + m_Scene.RegionInfo.RegionName);
110
111 if (!m_Enabled)
112 return;
113
114 if (!m_Initialized)
115 {
116 m_Initialized = true;
117 }
118
119 scene.RegisterModuleInterface<IInventoryService>(this);
120 m_cache.AddRegion(scene);
121 }
122
123 public void RemoveRegion(Scene scene)
124 {
125 if (!m_Enabled)
126 return;
127
128 m_cache.RemoveRegion(scene);
129 }
130
131 public void RegionLoaded(Scene scene)
132 {
133 if (!m_Enabled)
134 return;
135
136 m_log.InfoFormat("[XINVENTORY CONNECTOR]: Enabled remote XInventory for region {0}", scene.RegionInfo.RegionName);
137
138 }
139
140 #endregion ISharedRegionModule
141
142 #region IInventoryService
143
144 public override bool CreateUserInventory(UUID user)
145 {
146 return false;
147 }
148
149 public override List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
150 {
151 return new List<InventoryFolderBase>();
152 }
153
154 public override InventoryCollection GetUserInventory(UUID userID)
155 {
156 return null;
157 }
158
159 public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
160 {
161 try
162 {
163 m_RemoteConnector.GetUserInventory(userID, callback);
164 }
165 catch (Exception e)
166 {
167 if (StatsManager.SimExtraStats != null)
168 StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure();
169
170 m_log.ErrorFormat("[XINVENTORY CONNECTOR]: Request inventory operation failed, {0} {1}",
171 e.Source, e.Message);
172 }
173
174 }
175
176 // inherited. See base class
177 // public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
178
179 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
180 {
181 return m_RemoteConnector.GetSystemFolders(userID);
182 }
183
184 public override InventoryCollection GetFolderContent(UUID userID, UUID folderID)
185 {
186 try
187 {
188 return m_RemoteConnector.GetFolderContent(userID, folderID);
189 }
190 catch (Exception e)
191 {
192 m_log.ErrorFormat("[XINVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1}",
193 e.Source, e.Message);
194 }
195 InventoryCollection nullCollection = new InventoryCollection();
196 nullCollection.Folders = new List<InventoryFolderBase>();
197 nullCollection.Items = new List<InventoryItemBase>();
198 nullCollection.UserID = userID;
199 return nullCollection;
200 }
201
202 public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
203 {
204 return m_RemoteConnector.GetFolderItems(userID, folderID);
205 }
206
207 public override bool AddFolder(InventoryFolderBase folder)
208 {
209 if (folder == null)
210 return false;
211
212 return m_RemoteConnector.AddFolder(folder);
213 }
214
215 public override bool UpdateFolder(InventoryFolderBase folder)
216 {
217 if (folder == null)
218 return false;
219
220 return m_RemoteConnector.UpdateFolder(folder);
221 }
222
223 public override bool MoveFolder(InventoryFolderBase folder)
224 {
225 if (folder == null)
226 return false;
227
228 return m_RemoteConnector.MoveFolder(folder);
229 }
230
231 public override bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
232 {
233 if (folderIDs == null)
234 return false;
235 if (folderIDs.Count == 0)
236 return false;
237
238 return m_RemoteConnector.DeleteFolders(ownerID, folderIDs);
239 }
240
241
242 public override bool PurgeFolder(InventoryFolderBase folder)
243 {
244 if (folder == null)
245 return false;
246
247 return m_RemoteConnector.PurgeFolder(folder);
248 }
249
250 // public bool AddItem(InventoryItemBase item) inherited
251 // Uses AddItemPlain
252
253 protected override bool AddItemPlain(InventoryItemBase item)
254 {
255 if (item == null)
256 return false;
257
258 return m_RemoteConnector.AddItem(item);
259 }
260
261 public override bool UpdateItem(InventoryItemBase item)
262 {
263 if (item == null)
264 return false;
265
266 return m_RemoteConnector.UpdateItem(item);
267 }
268
269 public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
270 {
271 if (items == null)
272 return false;
273
274 return m_RemoteConnector.MoveItems(ownerID, items);
275 }
276
277
278 public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
279 {
280 if (itemIDs == null)
281 return false;
282 if (itemIDs.Count == 0)
283 return true;
284
285 return m_RemoteConnector.DeleteItems(ownerID, itemIDs);
286 }
287
288 public override InventoryItemBase GetItem(InventoryItemBase item)
289 {
290 if (item == null)
291 return null;
292
293 return m_RemoteConnector.GetItem(item);
294 }
295
296 public override InventoryFolderBase GetFolder(InventoryFolderBase folder)
297 {
298 if (folder == null)
299 return null;
300
301 return m_RemoteConnector.GetFolder(folder);
302 }
303
304 public override bool HasInventoryForUser(UUID userID)
305 {
306 return false;
307 }
308
309 public override List<InventoryItemBase> GetActiveGestures(UUID userId)
310 {
311 return new List<InventoryItemBase>();
312 }
313
314 public override int GetAssetPermissions(UUID userID, UUID assetID)
315 {
316 return m_RemoteConnector.GetAssetPermissions(userID, assetID);
317 }
318
319
320 #endregion
321
322
323 }
324}
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
index 34f7dcc..7164520 100644
--- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
@@ -144,6 +144,8 @@ namespace OpenSim.Server.Handlers.Asset
144 return HandleGetActiveGestures(request); 144 return HandleGetActiveGestures(request);
145 case "GETASSETPERMISSIONS": 145 case "GETASSETPERMISSIONS":
146 return HandleGetAssetPermissions(request); 146 return HandleGetAssetPermissions(request);
147 case "GETSYSTEMFOLDERS":
148 return HandleGetSystemFolders(request);
147 } 149 }
148 m_log.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method); 150 m_log.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method);
149 } 151 }
@@ -197,7 +199,7 @@ namespace OpenSim.Server.Handlers.Asset
197 199
198 return ms.ToArray(); 200 return ms.ToArray();
199 } 201 }
200 202
201 byte[] HandleCreateUserInventory(Dictionary<string,object> request) 203 byte[] HandleCreateUserInventory(Dictionary<string,object> request)
202 { 204 {
203 Dictionary<string,object> result = new Dictionary<string,object>(); 205 Dictionary<string,object> result = new Dictionary<string,object>();
@@ -540,6 +542,24 @@ namespace OpenSim.Server.Handlers.Asset
540 return encoding.GetBytes(xmlString); 542 return encoding.GetBytes(xmlString);
541 } 543 }
542 544
545 byte[] HandleGetSystemFolders(Dictionary<string, object> request)
546 {
547 Dictionary<string, object> result = new Dictionary<string, object>();
548 UUID principal = UUID.Zero;
549 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
550
551 Dictionary<AssetType, InventoryFolderBase> sfolders = GetSystemFolders(principal);
552
553 if (sfolders != null)
554 foreach (KeyValuePair<AssetType, InventoryFolderBase> kvp in sfolders)
555 result[kvp.Key.ToString()] = EncodeFolder(kvp.Value);
556
557 string xmlString = ServerUtils.BuildXmlResponse(result);
558 m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
559 UTF8Encoding encoding = new UTF8Encoding();
560 return encoding.GetBytes(xmlString);
561 }
562
543 private Dictionary<string, object> EncodeFolder(InventoryFolderBase f) 563 private Dictionary<string, object> EncodeFolder(InventoryFolderBase f)
544 { 564 {
545 Dictionary<string, object> ret = new Dictionary<string, object>(); 565 Dictionary<string, object> ret = new Dictionary<string, object>();
@@ -623,5 +643,31 @@ namespace OpenSim.Server.Handlers.Asset
623 643
624 return item; 644 return item;
625 } 645 }
646
647 #region Extra
648 private Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
649 {
650 InventoryFolderBase root = m_InventoryService.GetRootFolder(userID);
651 if (root != null)
652 {
653 InventoryCollection content = m_InventoryService.GetFolderContent(userID, root.ID);
654 if (content != null)
655 {
656 Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
657 foreach (InventoryFolderBase folder in content.Folders)
658 {
659 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
660 folders[(AssetType)folder.Type] = folder;
661 }
662 // Put the root folder there, as type Folder
663 folders[AssetType.Folder] = root;
664 return folders;
665 }
666 }
667 m_log.WarnFormat("[INVENTORY SERVICE]: System folders for {0} not found", userID);
668 return new Dictionary<AssetType, InventoryFolderBase>();
669 }
670 #endregion
671
626 } 672 }
627} 673}
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
index 0cc1978..edf224f 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
@@ -455,6 +455,35 @@ namespace OpenSim.Services.Connectors
455 return int.Parse(ret["RESULT"].ToString()); 455 return int.Parse(ret["RESULT"].ToString());
456 } 456 }
457 457
458 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
459 {
460 Dictionary<string, object> ret = MakeRequest("GETSYSTEMFOLDERS",
461 new Dictionary<string, object> {
462 { "PRINCIPAL", userID.ToString() },
463 });
464
465 if (ret == null)
466 return new Dictionary<AssetType,InventoryFolderBase>();
467
468 Dictionary<AssetType, InventoryFolderBase> sfolders = new Dictionary<AssetType, InventoryFolderBase>();
469
470 try
471 {
472 foreach (KeyValuePair<string, object> kvp in ret)
473 {
474 InventoryFolderBase folder = BuildFolder((Dictionary<string, object>)(kvp.Value));
475 short type = 0;
476 if (Int16.TryParse(kvp.Key, out type))
477 sfolders.Add((AssetType)type, folder);
478 }
479 }
480 catch (Exception e)
481 {
482 m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: exception {0}", e.Message);
483 }
484
485 return sfolders;
486 }
458 487
459 // These are either obsolete or unused 488 // These are either obsolete or unused
460 // 489 //