aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDiva Canto2010-05-02 10:32:47 -0700
committerDiva Canto2010-05-02 10:32:47 -0700
commit052580ef44e733138cd4dbf6cfe30acc476d90fc (patch)
tree8da64b8df6ed76522fc5dfba9ef9e25e544fef45 /OpenSim
parentSwitched everything to XInventory by default. The old Inventory is still ther... (diff)
downloadopensim-SC_OLD-052580ef44e733138cd4dbf6cfe30acc476d90fc.zip
opensim-SC_OLD-052580ef44e733138cd4dbf6cfe30acc476d90fc.tar.gz
opensim-SC_OLD-052580ef44e733138cd4dbf6cfe30acc476d90fc.tar.bz2
opensim-SC_OLD-052580ef44e733138cd4dbf6cfe30acc476d90fc.tar.xz
Deleted HGInventoryBroker, so that the new one can take its name.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs540
1 files changed, 0 insertions, 540 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
deleted file mode 100644
index 54508cc..0000000
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ /dev/null
@@ -1,540 +0,0 @@
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 Nini.Config;
30using System;
31using System.Collections.Generic;
32using System.Reflection;
33using OpenSim.Framework;
34
35using OpenSim.Server.Base;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces;
39using OpenSim.Services.Connectors;
40using OpenMetaverse;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
43{
44 public class HGInventoryBroker : BaseInventoryConnector, INonSharedRegionModule, IInventoryService
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 private static bool m_Initialized = false;
51 private static bool m_Enabled = false;
52
53 private static IInventoryService m_GridService;
54 private static ISessionAuthInventoryService m_HGService;
55
56 private Scene m_Scene;
57 private IUserAccountService m_UserAccountService;
58
59 public Type ReplaceableInterface
60 {
61 get { return null; }
62 }
63
64 public string Name
65 {
66 get { return "HGInventoryBroker"; }
67 }
68
69 public void Initialise(IConfigSource source)
70 {
71 if (!m_Initialized)
72 {
73 IConfig moduleConfig = source.Configs["Modules"];
74 if (moduleConfig != null)
75 {
76 string name = moduleConfig.GetString("InventoryServices", "");
77 if (name == Name)
78 {
79 IConfig inventoryConfig = source.Configs["InventoryService"];
80 if (inventoryConfig == null)
81 {
82 m_log.Error("[HG INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini");
83 return;
84 }
85
86 string localDll = inventoryConfig.GetString("LocalGridInventoryService",
87 String.Empty);
88 string HGDll = inventoryConfig.GetString("HypergridInventoryService",
89 String.Empty);
90
91 if (localDll == String.Empty)
92 {
93 m_log.Error("[HG INVENTORY CONNECTOR]: No LocalGridInventoryService named in section InventoryService");
94 //return;
95 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
96 }
97
98 if (HGDll == String.Empty)
99 {
100 m_log.Error("[HG INVENTORY CONNECTOR]: No HypergridInventoryService named in section InventoryService");
101 //return;
102 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
103 }
104
105 Object[] args = new Object[] { source };
106 m_GridService =
107 ServerUtils.LoadPlugin<IInventoryService>(localDll,
108 args);
109
110 m_HGService =
111 ServerUtils.LoadPlugin<ISessionAuthInventoryService>(HGDll,
112 args);
113
114 if (m_GridService == null)
115 {
116 m_log.Error("[HG INVENTORY CONNECTOR]: Can't load local inventory service");
117 return;
118 }
119 if (m_HGService == null)
120 {
121 m_log.Error("[HG INVENTORY CONNECTOR]: Can't load hypergrid inventory service");
122 return;
123 }
124
125 Init(source);
126
127 m_Enabled = true;
128 m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled");
129 }
130 }
131 m_Initialized = true;
132 }
133 }
134
135 public void PostInitialise()
136 {
137 }
138
139 public void Close()
140 {
141 }
142
143 public void AddRegion(Scene scene)
144 {
145 if (!m_Enabled)
146 return;
147
148 m_Scene = scene;
149 m_UserAccountService = m_Scene.UserAccountService;
150
151 scene.RegisterModuleInterface<IInventoryService>(this);
152 m_cache.AddRegion(scene);
153 }
154
155 public void RemoveRegion(Scene scene)
156 {
157 if (!m_Enabled)
158 return;
159
160 m_cache.RemoveRegion(scene);
161 }
162
163 public void RegionLoaded(Scene scene)
164 {
165 if (!m_Enabled)
166 return;
167
168 m_log.InfoFormat("[HG INVENTORY CONNECTOR]: Enabled HG inventory for region {0}", scene.RegionInfo.RegionName);
169
170 }
171
172 #region IInventoryService
173
174 public override bool CreateUserInventory(UUID userID)
175 {
176 return m_GridService.CreateUserInventory(userID);
177 }
178
179 public override List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
180 {
181 return m_GridService.GetInventorySkeleton(userId);
182 }
183
184 public override InventoryCollection GetUserInventory(UUID userID)
185 {
186 return null;
187 }
188
189 public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
190 {
191 }
192
193 // Inherited. See base
194 //public override InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
195 //{
196 // if (IsLocalGridUser(userID))
197 // return m_GridService.GetFolderForType(userID, type);
198 // else
199 // {
200 // UUID sessionID = GetSessionID(userID);
201 // string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
202 // // !!!!!!
203 // return null;
204 // //return m_HGService.GetFolderForType(uri, sessionID, type);
205 // }
206 //}
207
208 public override InventoryCollection GetFolderContent(UUID userID, UUID folderID)
209 {
210 string uri = string.Empty;
211 if (!IsForeignUser(userID, out uri))
212 return m_GridService.GetFolderContent(userID, folderID);
213 else
214 {
215 UUID sessionID = GetSessionID(userID);
216 uri = uri + "/" + userID.ToString();
217 return m_HGService.GetFolderContent(uri, folderID, sessionID);
218 }
219 }
220
221 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
222 {
223 string uri = string.Empty;
224 if (!IsForeignUser(userID, out uri))
225 {
226 // This is not pretty, but it will have to do for now
227 if (m_GridService is BaseInventoryConnector)
228 {
229 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetSystemsFolders redirected to RemoteInventoryServiceConnector module");
230 return ((BaseInventoryConnector)m_GridService).GetSystemFolders(userID);
231 }
232 else
233 {
234 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetSystemsFolders redirected to GetSystemFoldersLocal");
235 return GetSystemFoldersLocal(userID);
236 }
237 }
238 else
239 {
240 UUID sessionID = GetSessionID(userID);
241 uri = uri + "/" + userID.ToString();
242 return m_HGService.GetSystemFolders(uri, sessionID);
243 }
244 }
245
246 private Dictionary<AssetType, InventoryFolderBase> GetSystemFoldersLocal(UUID userID)
247 {
248 InventoryFolderBase root = m_GridService.GetRootFolder(userID);
249 if (root != null)
250 {
251 InventoryCollection content = m_GridService.GetFolderContent(userID, root.ID);
252 if (content != null)
253 {
254 Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
255 foreach (InventoryFolderBase folder in content.Folders)
256 {
257 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: scanning folder type {0}", (AssetType)folder.Type);
258 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
259 folders[(AssetType)folder.Type] = folder;
260 }
261 // Put the root folder there, as type Folder
262 folders[AssetType.Folder] = root;
263 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: System folders count for {0}: {1}", userID, folders.Count);
264 return folders;
265 }
266 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder content not found for {0}", userID);
267
268 }
269
270 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder not found for {0}", userID);
271
272 return new Dictionary<AssetType, InventoryFolderBase>();
273 }
274
275 public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
276 {
277 string uri = string.Empty;
278 if (!IsForeignUser(userID, out uri))
279 return m_GridService.GetFolderItems(userID, folderID);
280 else
281 {
282 UUID sessionID = GetSessionID(userID);
283 uri = uri + "/" + userID.ToString();
284 return m_HGService.GetFolderItems(uri, folderID, sessionID);
285 }
286 }
287
288 public override bool AddFolder(InventoryFolderBase folder)
289 {
290 if (folder == null)
291 return false;
292
293 string uri = string.Empty;
294 if (!IsForeignUser(folder.Owner, out uri))
295 return m_GridService.AddFolder(folder);
296 else
297 {
298 UUID sessionID = GetSessionID(folder.Owner);
299 uri = uri + "/" + folder.Owner.ToString();
300 return m_HGService.AddFolder(uri, folder, sessionID);
301 }
302 }
303
304 public override bool UpdateFolder(InventoryFolderBase folder)
305 {
306 if (folder == null)
307 return false;
308
309 string uri = string.Empty;
310 if (!IsForeignUser(folder.Owner, out uri))
311 return m_GridService.UpdateFolder(folder);
312 else
313 {
314 UUID sessionID = GetSessionID(folder.Owner);
315 uri = uri + "/" + folder.Owner.ToString();
316 return m_HGService.UpdateFolder(uri, folder, sessionID);
317 }
318 }
319
320 public override bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
321 {
322 if (folderIDs == null)
323 return false;
324 if (folderIDs.Count == 0)
325 return false;
326
327 string uri = string.Empty;
328 if (!IsForeignUser(ownerID, out uri))
329 return m_GridService.DeleteFolders(ownerID, folderIDs);
330 else
331 {
332 UUID sessionID = GetSessionID(ownerID);
333 uri = uri + "/" + ownerID.ToString();
334 return m_HGService.DeleteFolders(uri, folderIDs, sessionID);
335 }
336 }
337
338 public override bool MoveFolder(InventoryFolderBase folder)
339 {
340 if (folder == null)
341 return false;
342
343 string uri = string.Empty;
344 if (!IsForeignUser(folder.Owner, out uri))
345 return m_GridService.MoveFolder(folder);
346 else
347 {
348 UUID sessionID = GetSessionID(folder.Owner);
349 uri = uri + "/" + folder.Owner.ToString();
350 return m_HGService.MoveFolder(uri, folder, sessionID);
351 }
352 }
353
354 public override bool PurgeFolder(InventoryFolderBase folder)
355 {
356 if (folder == null)
357 return false;
358
359 string uri = string.Empty;
360 if (!IsForeignUser(folder.Owner, out uri))
361 return m_GridService.PurgeFolder(folder);
362 else
363 {
364 UUID sessionID = GetSessionID(folder.Owner);
365 uri = uri + "/" + folder.Owner.ToString();
366 return m_HGService.PurgeFolder(uri, folder, sessionID);
367 }
368 }
369
370 // public bool AddItem(InventoryItemBase item) inherited
371 // Uses AddItemPlain
372
373 protected override bool AddItemPlain(InventoryItemBase item)
374 {
375 if (item == null)
376 return false;
377
378 string uri = string.Empty;
379 if (!IsForeignUser(item.Owner, out uri))
380 {
381 return m_GridService.AddItem(item);
382 }
383 else
384 {
385 UUID sessionID = GetSessionID(item.Owner);
386 uri = uri + "/" + item.Owner.ToString();
387 return m_HGService.AddItem(uri, item, sessionID);
388 }
389 }
390
391 public override bool UpdateItem(InventoryItemBase item)
392 {
393 if (item == null)
394 return false;
395
396 string uri = string.Empty;
397 if (!IsForeignUser(item.Owner, out uri))
398 return m_GridService.UpdateItem(item);
399 else
400 {
401 UUID sessionID = GetSessionID(item.Owner);
402 uri = uri + "/" + item.Owner.ToString();
403 return m_HGService.UpdateItem(uri, item, sessionID);
404 }
405 }
406
407 public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
408 {
409 if (items == null)
410 return false;
411 if (items.Count == 0)
412 return true;
413
414 string uri = string.Empty;
415 if (!IsForeignUser(ownerID, out uri))
416 return m_GridService.MoveItems(ownerID, items);
417 else
418 {
419 UUID sessionID = GetSessionID(ownerID);
420 uri = uri + "/" + ownerID.ToString();
421 return m_HGService.MoveItems(uri, items, sessionID);
422 }
423 }
424
425 public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
426 {
427 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID);
428
429 if (itemIDs == null)
430 return false;
431 if (itemIDs.Count == 0)
432 return true;
433
434 string uri = string.Empty;
435 if (!IsForeignUser(ownerID, out uri))
436 return m_GridService.DeleteItems(ownerID, itemIDs);
437 else
438 {
439 UUID sessionID = GetSessionID(ownerID);
440 uri = uri + "/" + ownerID.ToString();
441 return m_HGService.DeleteItems(uri, itemIDs, sessionID);
442 }
443 }
444
445 public override InventoryItemBase GetItem(InventoryItemBase item)
446 {
447 if (item == null)
448 return null;
449 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetItem {0} for user {1}", item.ID, item.Owner);
450 string uri = string.Empty;
451 if (!IsForeignUser(item.Owner, out uri))
452 return m_GridService.GetItem(item);
453 else
454 {
455 UUID sessionID = GetSessionID(item.Owner);
456 uri = uri + "/" + item.Owner.ToString();
457 return m_HGService.QueryItem(uri, item, sessionID);
458 }
459 }
460
461 public override InventoryFolderBase GetFolder(InventoryFolderBase folder)
462 {
463 if (folder == null)
464 return null;
465
466 string uri = string.Empty;
467 if (!IsForeignUser(folder.Owner, out uri))
468 return m_GridService.GetFolder(folder);
469 else
470 {
471 UUID sessionID = GetSessionID(folder.Owner);
472 uri = uri + "/" + folder.Owner.ToString();
473 return m_HGService.QueryFolder(uri, folder, sessionID);
474 }
475 }
476
477 public override bool HasInventoryForUser(UUID userID)
478 {
479 return false;
480 }
481
482 public override List<InventoryItemBase> GetActiveGestures(UUID userId)
483 {
484 return new List<InventoryItemBase>();
485 }
486
487 public override int GetAssetPermissions(UUID userID, UUID assetID)
488 {
489 string uri = string.Empty;
490 if (!IsForeignUser(userID, out uri))
491 return m_GridService.GetAssetPermissions(userID, assetID);
492 else
493 {
494 UUID sessionID = GetSessionID(userID);
495 uri = uri + "/" + userID.ToString();
496 return m_HGService.GetAssetPermissions(uri, assetID, sessionID);
497 }
498 }
499
500 #endregion
501
502 private UUID GetSessionID(UUID userID)
503 {
504 ScenePresence sp = null;
505 if (m_Scene.TryGetScenePresence(userID, out sp))
506 {
507 return sp.ControllingClient.SessionId;
508 }
509
510 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: scene presence for {0} not found", userID);
511 return UUID.Zero;
512 }
513
514 private bool IsForeignUser(UUID userID, out string inventoryURL)
515 {
516 inventoryURL = string.Empty;
517 UserAccount account = null;
518 if (m_Scene.UserAccountService != null)
519 account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID);
520
521 if (account == null) // foreign user
522 {
523 ScenePresence sp = null;
524 m_Scene.TryGetScenePresence(userID, out sp);
525 if (sp != null)
526 {
527 AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
528 if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI"))
529 {
530 inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString();
531 inventoryURL = inventoryURL.Trim(new char[] { '/' });
532 return true;
533 }
534 }
535 }
536 return false;
537 }
538
539 }
540}