aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs')
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs76
1 files changed, 69 insertions, 7 deletions
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index 6e4b68c..784f136 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -56,10 +56,12 @@ namespace OpenSim.Services.HypergridService
56 56
57 private string m_HomeURL; 57 private string m_HomeURL;
58 private IUserAccountService m_UserAccountService; 58 private IUserAccountService m_UserAccountService;
59 private IAvatarService m_AvatarService;
59 60
60// private UserAccountCache m_Cache; 61// private UserAccountCache m_Cache;
61 62
62 private ExpiringCache<UUID, List<XInventoryFolder>> m_SuitcaseTrees = new ExpiringCache<UUID, List<XInventoryFolder>>(); 63 private ExpiringCache<UUID, List<XInventoryFolder>> m_SuitcaseTrees = new ExpiringCache<UUID, List<XInventoryFolder>>();
64 private ExpiringCache<UUID, AvatarAppearance> m_Appearances = new ExpiringCache<UUID, AvatarAppearance>();
63 65
64 public HGSuitcaseInventoryService(IConfigSource config, string configName) 66 public HGSuitcaseInventoryService(IConfigSource config, string configName)
65 : base(config, configName) 67 : base(config, configName)
@@ -69,7 +71,7 @@ namespace OpenSim.Services.HypergridService
69 m_ConfigName = configName; 71 m_ConfigName = configName;
70 72
71 if (m_Database == null) 73 if (m_Database == null)
72 m_log.WarnFormat("[XXX]: m_Database is null!"); 74 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: m_Database is null!");
73 75
74 // 76 //
75 // Try reading the [InventoryService] section, if it exists 77 // Try reading the [InventoryService] section, if it exists
@@ -77,7 +79,6 @@ namespace OpenSim.Services.HypergridService
77 IConfig invConfig = config.Configs[m_ConfigName]; 79 IConfig invConfig = config.Configs[m_ConfigName];
78 if (invConfig != null) 80 if (invConfig != null)
79 { 81 {
80 // realm = authConfig.GetString("Realm", realm);
81 string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty); 82 string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
82 if (userAccountsDll == string.Empty) 83 if (userAccountsDll == string.Empty)
83 throw new Exception("Please specify UserAccountsService in HGInventoryService configuration"); 84 throw new Exception("Please specify UserAccountsService in HGInventoryService configuration");
@@ -87,8 +88,14 @@ namespace OpenSim.Services.HypergridService
87 if (m_UserAccountService == null) 88 if (m_UserAccountService == null)
88 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); 89 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
89 90
90 // legacy configuration [obsolete] 91 string avatarDll = invConfig.GetString("AvatarService", string.Empty);
91 m_HomeURL = invConfig.GetString("ProfileServerURI", string.Empty); 92 if (avatarDll == string.Empty)
93 throw new Exception("Please specify AvatarService in HGInventoryService configuration");
94
95 m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarDll, args);
96 if (m_AvatarService == null)
97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll));
98
92 // Preferred 99 // Preferred
93 m_HomeURL = invConfig.GetString("HomeURI", m_HomeURL); 100 m_HomeURL = invConfig.GetString("HomeURI", m_HomeURL);
94 101
@@ -294,7 +301,7 @@ namespace OpenSim.Services.HypergridService
294 301
295 public override bool AddFolder(InventoryFolderBase folder) 302 public override bool AddFolder(InventoryFolderBase folder)
296 { 303 {
297 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID); 304 //m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID);
298 // Let's do a bit of sanity checking, more than the base service does 305 // Let's do a bit of sanity checking, more than the base service does
299 // make sure the given folder's parent folder exists under the suitcase tree of this user 306 // make sure the given folder's parent folder exists under the suitcase tree of this user
300 307
@@ -316,7 +323,7 @@ namespace OpenSim.Services.HypergridService
316 323
317 public override bool UpdateFolder(InventoryFolderBase folder) 324 public override bool UpdateFolder(InventoryFolderBase folder)
318 { 325 {
319 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); 326 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version);
320 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) 327 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
321 { 328 {
322 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); 329 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name);
@@ -394,7 +401,7 @@ namespace OpenSim.Services.HypergridService
394 return null; 401 return null;
395 } 402 }
396 403
397 if (!IsWithinSuitcaseTree(it.Owner, it.Folder)) 404 if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID))
398 { 405 {
399 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", 406 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase",
400 it.Name, it.Folder); 407 it.Name, it.Folder);
@@ -453,6 +460,15 @@ namespace OpenSim.Services.HypergridService
453 460
454 if (folders != null && folders.Length > 0) 461 if (folders != null && folders.Length > 0)
455 return folders[0]; 462 return folders[0];
463
464 // OK, so the RootFolder type didn't work. Let's look for any type with parent UUID.Zero.
465 folders = m_Database.GetFolders(
466 new string[] { "agentID", "folderName", "parentFolderID" },
467 new string[] { principalID.ToString(), "My Inventory", UUID.Zero.ToString() });
468
469 if (folders != null && folders.Length > 0)
470 return folders[0];
471
456 return null; 472 return null;
457 } 473 }
458 474
@@ -549,6 +565,52 @@ namespace OpenSim.Services.HypergridService
549 else return true; 565 else return true;
550 } 566 }
551 #endregion 567 #endregion
568
569 #region Avatar Appearance
570
571 private AvatarAppearance GetAppearance(UUID principalID)
572 {
573 AvatarAppearance a = null;
574 if (m_Appearances.TryGetValue(principalID, out a))
575 return a;
576
577 a = m_AvatarService.GetAppearance(principalID);
578 m_Appearances.AddOrUpdate(principalID, a, 5 * 60); // 5minutes
579 return a;
580 }
581
582 private bool IsPartOfAppearance(UUID principalID, UUID itemID)
583 {
584 AvatarAppearance a = GetAppearance(principalID);
585
586 if (a == null)
587 return false;
588
589 // Check wearables (body parts and clothes)
590 for (int i = 0; i < a.Wearables.Length; i++)
591 {
592 for (int j = 0; j < a.Wearables[i].Count; j++)
593 {
594 if (a.Wearables[i][j].ItemID == itemID)
595 {
596 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is a wearable", itemID);
597 return true;
598 }
599 }
600 }
601
602 // Check attachments
603 if (a.GetAttachmentForItem(itemID) != null)
604 {
605 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is an attachment", itemID);
606 return true;
607 }
608
609 return false;
610 }
611
612 #endregion
613
552 } 614 }
553 615
554} 616}