diff options
Diffstat (limited to 'OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs')
-rw-r--r-- | OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index eecf757..0601ece 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs | |||
@@ -54,7 +54,7 @@ namespace OpenSim.Services.HypergridService | |||
54 | LogManager.GetLogger( | 54 | LogManager.GetLogger( |
55 | MethodBase.GetCurrentMethod().DeclaringType); | 55 | MethodBase.GetCurrentMethod().DeclaringType); |
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 | private IAvatarService m_AvatarService; |
60 | 60 | ||
@@ -96,8 +96,8 @@ namespace OpenSim.Services.HypergridService | |||
96 | if (m_AvatarService == null) | 96 | if (m_AvatarService == null) |
97 | throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); | 97 | throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); |
98 | 98 | ||
99 | m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI", | 99 | // m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI", |
100 | new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); | 100 | // new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); |
101 | 101 | ||
102 | // m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); | 102 | // m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); |
103 | } | 103 | } |
@@ -115,6 +115,12 @@ namespace OpenSim.Services.HypergridService | |||
115 | { | 115 | { |
116 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | 116 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
117 | 117 | ||
118 | if (suitcase == null) | ||
119 | { | ||
120 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for inventory skeleton", principalID); | ||
121 | return null; | ||
122 | } | ||
123 | |||
118 | List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID); | 124 | List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID); |
119 | if (tree == null || (tree != null && tree.Count == 0)) | 125 | if (tree == null || (tree != null && tree.Count == 0)) |
120 | return null; | 126 | return null; |
@@ -134,6 +140,7 @@ namespace OpenSim.Services.HypergridService | |||
134 | public override InventoryCollection GetUserInventory(UUID userID) | 140 | public override InventoryCollection GetUserInventory(UUID userID) |
135 | { | 141 | { |
136 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID); | 142 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID); |
143 | |||
137 | InventoryCollection userInventory = new InventoryCollection(); | 144 | InventoryCollection userInventory = new InventoryCollection(); |
138 | userInventory.UserID = userID; | 145 | userInventory.UserID = userID; |
139 | userInventory.Folders = new List<InventoryFolderBase>(); | 146 | userInventory.Folders = new List<InventoryFolderBase>(); |
@@ -141,6 +148,12 @@ namespace OpenSim.Services.HypergridService | |||
141 | 148 | ||
142 | XInventoryFolder suitcase = GetSuitcaseXFolder(userID); | 149 | XInventoryFolder suitcase = GetSuitcaseXFolder(userID); |
143 | 150 | ||
151 | if (suitcase == null) | ||
152 | { | ||
153 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for user inventory", userID); | ||
154 | return null; | ||
155 | } | ||
156 | |||
144 | List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID); | 157 | List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID); |
145 | if (tree == null || (tree != null && tree.Count == 0)) | 158 | if (tree == null || (tree != null && tree.Count == 0)) |
146 | { | 159 | { |
@@ -182,7 +195,8 @@ namespace OpenSim.Services.HypergridService | |||
182 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); | 195 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); |
183 | 196 | ||
184 | // Let's find out the local root folder | 197 | // Let's find out the local root folder |
185 | XInventoryFolder root = GetRootXFolder(principalID); ; | 198 | XInventoryFolder root = GetRootXFolder(principalID); |
199 | |||
186 | if (root == null) | 200 | if (root == null) |
187 | { | 201 | { |
188 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); | 202 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); |
@@ -255,6 +269,13 @@ namespace OpenSim.Services.HypergridService | |||
255 | { | 269 | { |
256 | //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); | 270 | //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); |
257 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | 271 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
272 | |||
273 | if (suitcase == null) | ||
274 | { | ||
275 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for child type folder {1}", principalID, type); | ||
276 | return null; | ||
277 | } | ||
278 | |||
258 | XInventoryFolder[] folders = m_Database.GetFolders( | 279 | XInventoryFolder[] folders = m_Database.GetFolders( |
259 | new string[] { "agentID", "type", "parentFolderID" }, | 280 | new string[] { "agentID", "type", "parentFolderID" }, |
260 | new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() }); | 281 | new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() }); |
@@ -472,6 +493,22 @@ namespace OpenSim.Services.HypergridService | |||
472 | return null; | 493 | return null; |
473 | } | 494 | } |
474 | 495 | ||
496 | private XInventoryFolder GetCurrentOutfitXFolder(UUID userID) | ||
497 | { | ||
498 | XInventoryFolder root = GetRootXFolder(userID); | ||
499 | if (root == null) | ||
500 | return null; | ||
501 | |||
502 | XInventoryFolder[] folders = m_Database.GetFolders( | ||
503 | new string[] { "agentID", "type", "parentFolderID" }, | ||
504 | new string[] { userID.ToString(), ((int)AssetType.CurrentOutfitFolder).ToString(), root.folderID.ToString() }); | ||
505 | |||
506 | if (folders.Length == 0) | ||
507 | return null; | ||
508 | |||
509 | return folders[0]; | ||
510 | } | ||
511 | |||
475 | private XInventoryFolder GetSuitcaseXFolder(UUID principalID) | 512 | private XInventoryFolder GetSuitcaseXFolder(UUID principalID) |
476 | { | 513 | { |
477 | // Warp! Root folder for travelers | 514 | // Warp! Root folder for travelers |
@@ -510,6 +547,7 @@ namespace OpenSim.Services.HypergridService | |||
510 | if (m_SuitcaseTrees.TryGetValue(principalID, out t)) | 547 | if (m_SuitcaseTrees.TryGetValue(principalID, out t)) |
511 | return t; | 548 | return t; |
512 | 549 | ||
550 | // Get the tree of the suitcase folder | ||
513 | t = GetFolderTreeRecursive(folder); | 551 | t = GetFolderTreeRecursive(folder); |
514 | m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes | 552 | m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes |
515 | return t; | 553 | return t; |
@@ -546,6 +584,7 @@ namespace OpenSim.Services.HypergridService | |||
546 | private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID) | 584 | private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID) |
547 | { | 585 | { |
548 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | 586 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
587 | |||
549 | if (suitcase == null) | 588 | if (suitcase == null) |
550 | { | 589 | { |
551 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID); | 590 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID); |
@@ -555,6 +594,9 @@ namespace OpenSim.Services.HypergridService | |||
555 | List<XInventoryFolder> tree = new List<XInventoryFolder>(); | 594 | List<XInventoryFolder> tree = new List<XInventoryFolder>(); |
556 | tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder | 595 | tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder |
557 | tree.AddRange(GetFolderTree(principalID, suitcase.folderID)); | 596 | tree.AddRange(GetFolderTree(principalID, suitcase.folderID)); |
597 | // Also add the Current Outfit folder to the list of available folders | ||
598 | tree.Add(GetCurrentOutfitXFolder(principalID)); | ||
599 | |||
558 | XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) | 600 | XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) |
559 | { | 601 | { |
560 | if (fl.folderID == folderID) return true; | 602 | if (fl.folderID == folderID) return true; |