aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-05-03 22:39:33 +0000
committerJustin Clarke Casey2008-05-03 22:39:33 +0000
commit688940e8103f2b1f55bb48ebe2566d32f872b8f5 (patch)
tree979a633643581349471e3f91bf11bfa545191549 /OpenSim
parent* Cleaned up code in Terrain, Tree and Map modules. (diff)
downloadopensim-SC_OLD-688940e8103f2b1f55bb48ebe2566d32f872b8f5.zip
opensim-SC_OLD-688940e8103f2b1f55bb48ebe2566d32f872b8f5.tar.gz
opensim-SC_OLD-688940e8103f2b1f55bb48ebe2566d32f872b8f5.tar.bz2
opensim-SC_OLD-688940e8103f2b1f55bb48ebe2566d32f872b8f5.tar.xz
* Refactor: Renaming item and folder tree search methods to have Find*() prefixes
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs12
-rw-r--r--OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs21
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs10
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs48
-rw-r--r--OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs3
6 files changed, 52 insertions, 44 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index ceca1a4..6a7b6b7 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -35,7 +35,8 @@ using log4net;
35 35
36namespace OpenSim.Framework.Communications.Cache 36namespace OpenSim.Framework.Communications.Cache
37{ 37{
38 internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); 38 //internal delegate void DeleteItemDelegate(
39 internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
39 internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); 40 internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID);
40 internal delegate void PurgeFolderDelegate(LLUUID folderID); 41 internal delegate void PurgeFolderDelegate(LLUUID folderID);
41 internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID); 42 internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID);
@@ -234,7 +235,7 @@ namespace OpenSim.Framework.Communications.Cache
234 } 235 }
235 else 236 else
236 { 237 {
237 InventoryFolderImpl folder = RootFolder.GetDescendentFolder(folderInfo.ParentID); 238 InventoryFolderImpl folder = RootFolder.FindFolder(folderInfo.ParentID);
238 lock (folder.SubFolders) 239 lock (folder.SubFolders)
239 { 240 {
240 if (folder != null) 241 if (folder != null)
@@ -275,7 +276,6 @@ namespace OpenSim.Framework.Communications.Cache
275 { 276 {
276 if (!RootFolder.Items.ContainsKey(itemInfo.ID)) 277 if (!RootFolder.Items.ContainsKey(itemInfo.ID))
277 { 278 {
278
279 RootFolder.Items.Add(itemInfo.ID, itemInfo); 279 RootFolder.Items.Add(itemInfo.ID, itemInfo);
280 } 280 }
281 else 281 else
@@ -286,7 +286,7 @@ namespace OpenSim.Framework.Communications.Cache
286 } 286 }
287 else 287 else
288 { 288 {
289 InventoryFolderImpl folder = RootFolder.GetDescendentFolder(itemInfo.Folder); 289 InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder);
290 if (folder != null) 290 if (folder != null)
291 { 291 {
292 lock (folder.Items) 292 lock (folder.Items)
@@ -346,7 +346,7 @@ namespace OpenSim.Framework.Communications.Cache
346 } 346 }
347 else 347 else
348 { 348 {
349 InventoryFolderImpl folder = RootFolder.GetDescendentFolder(parentID); 349 InventoryFolderImpl folder = RootFolder.FindFolder(parentID);
350 350
351 if (folder != null) 351 if (folder != null)
352 { 352 {
@@ -479,7 +479,7 @@ namespace OpenSim.Framework.Communications.Cache
479 479
480 if (HasInventory) 480 if (HasInventory)
481 { 481 {
482 InventoryFolderImpl purgedFolder = RootFolder.GetDescendentFolder(folderID); 482 InventoryFolderImpl purgedFolder = RootFolder.FindFolder(folderID);
483 483
484 if (purgedFolder != null) 484 if (purgedFolder != null)
485 { 485 {
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index f6accf6..39296eb 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -104,14 +104,12 @@ namespace OpenSim.Framework.Communications.Cache
104 } 104 }
105 105
106 /// <summary> 106 /// <summary>
107 /// Does this folder or any of its subfolders contain the given item? 107 /// Returns the item if it exists in this folder or any of this folder's subfolders?
108 /// </summary> 108 /// </summary>
109 /// <param name="itemID"></param> 109 /// <param name="itemID"></param>
110 /// <returns></returns> 110 /// <returns>null if the item is not found</returns>
111 public InventoryItemBase HasItem(LLUUID itemID) 111 public InventoryItemBase FindItem(LLUUID itemID)
112 { 112 {
113 InventoryItemBase base2 = null;
114
115 lock (Items) 113 lock (Items)
116 { 114 {
117 if (Items.ContainsKey(itemID)) 115 if (Items.ContainsKey(itemID))
@@ -124,15 +122,16 @@ namespace OpenSim.Framework.Communications.Cache
124 { 122 {
125 foreach (InventoryFolderImpl folder in SubFolders.Values) 123 foreach (InventoryFolderImpl folder in SubFolders.Values)
126 { 124 {
127 base2 = folder.HasItem(itemID); 125 InventoryItemBase item = folder.FindItem(itemID);
128 if (base2 != null) 126
127 if (item != null)
129 { 128 {
130 break; 129 return item;
131 } 130 }
132 } 131 }
133 } 132 }
134 133
135 return base2; 134 return null;
136 } 135 }
137 136
138 /// <summary> 137 /// <summary>
@@ -171,7 +170,7 @@ namespace OpenSim.Framework.Communications.Cache
171 /// Returns the folder requested if it exists as a descendent of this folder 170 /// Returns the folder requested if it exists as a descendent of this folder
172 /// </summary> 171 /// </summary>
173 /// <returns>The requested folder if it exists, null if it does not.</returns> 172 /// <returns>The requested folder if it exists, null if it does not.</returns>
174 public InventoryFolderImpl GetDescendentFolder(LLUUID folderID) 173 public InventoryFolderImpl FindFolder(LLUUID folderID)
175 { 174 {
176 InventoryFolderImpl returnFolder = null; 175 InventoryFolderImpl returnFolder = null;
177 176
@@ -185,7 +184,7 @@ namespace OpenSim.Framework.Communications.Cache
185 { 184 {
186 foreach (InventoryFolderImpl folder in SubFolders.Values) 185 foreach (InventoryFolderImpl folder in SubFolders.Values)
187 { 186 {
188 returnFolder = folder.GetDescendentFolder(folderID); 187 returnFolder = folder.FindFolder(folderID);
189 if (returnFolder != null) 188 if (returnFolder != null)
190 { 189 {
191 break; 190 break;
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index 0404477..92b08e5 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -259,7 +259,7 @@ namespace OpenSim.Framework.Communications.Cache
259 return; 259 return;
260 } 260 }
261 261
262 if ((fold = libraryRoot.GetDescendentFolder(folderID)) != null) 262 if ((fold = libraryRoot.FindFolder(folderID)) != null)
263 { 263 {
264 remoteClient.SendInventoryFolderDetails( 264 remoteClient.SendInventoryFolderDetails(
265 libraryRoot.Owner, folderID, fold.RequestListOfItems(), 265 libraryRoot.Owner, folderID, fold.RequestListOfItems(),
@@ -308,7 +308,7 @@ namespace OpenSim.Framework.Communications.Cache
308 } 308 }
309 else 309 else
310 { 310 {
311 if ((fold = userProfile.RootFolder.GetDescendentFolder(folderID)) != null) 311 if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null)
312 { 312 {
313// m_log.DebugFormat( 313// m_log.DebugFormat(
314// "[AGENT INVENTORY]: Found folder {0} for client {1}", 314// "[AGENT INVENTORY]: Found folder {0} for client {1}",
@@ -369,7 +369,7 @@ namespace OpenSim.Framework.Communications.Cache
369 return libraryRoot.RequestListOfItems(); 369 return libraryRoot.RequestListOfItems();
370 } 370 }
371 371
372 if ((fold = libraryRoot.GetDescendentFolder(folderID)) != null) 372 if ((fold = libraryRoot.FindFolder(folderID)) != null)
373 { 373 {
374 return fold.RequestListOfItems(); 374 return fold.RequestListOfItems();
375 } 375 }
@@ -410,7 +410,7 @@ namespace OpenSim.Framework.Communications.Cache
410 } 410 }
411 else 411 else
412 { 412 {
413 if ((fold = userProfile.RootFolder.GetDescendentFolder(folderID)) != null) 413 if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null)
414 { 414 {
415 return fold.RequestListOfItems(); 415 return fold.RequestListOfItems();
416 } 416 }
@@ -479,7 +479,7 @@ namespace OpenSim.Framework.Communications.Cache
479 { 479 {
480 if (userProfile.HasInventory) 480 if (userProfile.HasInventory)
481 { 481 {
482 InventoryItemBase item = userProfile.RootFolder.HasItem(itemID); 482 InventoryItemBase item = userProfile.RootFolder.FindItem(itemID);
483 if (item != null) 483 if (item != null)
484 { 484 {
485 remoteClient.SendInventoryItemDetails(ownerID, item); 485 remoteClient.SendInventoryItemDetails(ownerID, item);
diff --git a/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index cb94021..5df3f52 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -293,7 +293,7 @@ namespace OpenSim.Region.Environment.Modules
293 { 293 {
294 LLUUID assetId; 294 LLUUID assetId;
295 295
296 InventoryItemBase baseItem = profile.RootFolder.HasItem(wear.ItemID); 296 InventoryItemBase baseItem = profile.RootFolder.FindItem(wear.ItemID);
297 if (baseItem != null) 297 if (baseItem != null)
298 { 298 {
299 assetId = baseItem.assetID; 299 assetId = baseItem.assetID;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 0715b64..7cce216 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -127,7 +127,8 @@ namespace OpenSim.Region.Environment.Scenes
127 { 127 {
128 if (userInfo.RootFolder != null) 128 if (userInfo.RootFolder != null)
129 { 129 {
130 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 130 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
131
131 if (item != null) 132 if (item != null)
132 { 133 {
133 AssetBase asset = 134 AssetBase asset =
@@ -271,7 +272,7 @@ namespace OpenSim.Region.Environment.Scenes
271 272
272 if (userInfo != null && userInfo.RootFolder != null) 273 if (userInfo != null && userInfo.RootFolder != null)
273 { 274 {
274 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 275 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
275 276
276 if (item != null) 277 if (item != null)
277 { 278 {
@@ -340,7 +341,8 @@ namespace OpenSim.Region.Environment.Scenes
340 341
341 if (senderUserInfo.RootFolder != null) 342 if (senderUserInfo.RootFolder != null)
342 { 343 {
343 InventoryItemBase item = senderUserInfo.RootFolder.HasItem(itemId); 344 InventoryItemBase item = senderUserInfo.RootFolder.FindItem(itemId);
345
344 if (item != null) 346 if (item != null)
345 { 347 {
346 // TODO get recipient's root folder 348 // TODO get recipient's root folder
@@ -407,7 +409,8 @@ namespace OpenSim.Region.Environment.Scenes
407 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", 409 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
408 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); 410 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
409 411
410 InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID); 412 InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(oldItemID);
413
411 if (item == null) 414 if (item == null)
412 { 415 {
413 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID); 416 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID);
@@ -419,7 +422,8 @@ namespace OpenSim.Region.Environment.Scenes
419 422
420 if (userInfo.RootFolder != null) 423 if (userInfo.RootFolder != null)
421 { 424 {
422 item = userInfo.RootFolder.HasItem(oldItemID); 425 item = userInfo.RootFolder.FindItem(oldItemID);
426
423 if (item == null) 427 if (item == null)
424 { 428 {
425 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString()); 429 m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString());
@@ -478,7 +482,8 @@ namespace OpenSim.Region.Environment.Scenes
478 482
479 if (userInfo.RootFolder != null) 483 if (userInfo.RootFolder != null)
480 { 484 {
481 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 485 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
486
482 if (item != null) 487 if (item != null)
483 { 488 {
484 if (newName != String.Empty) 489 if (newName != String.Empty)
@@ -615,9 +620,13 @@ namespace OpenSim.Region.Environment.Scenes
615 { 620 {
616 CachedUserInfo userInfo 621 CachedUserInfo userInfo
617 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 622 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
623
618 if (userInfo == null) 624 if (userInfo == null)
619 { 625 {
620 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString()); 626 m_log.ErrorFormat(
627 "[AGENT INVENTORY]: Failed to find user {0} {1} to remove inventory item {2}",
628 remoteClient.Name, remoteClient.AgentId, itemID);
629
621 return; 630 return;
622 } 631 }
623 632
@@ -627,7 +636,8 @@ namespace OpenSim.Region.Environment.Scenes
627 // the trash folder directly instead of RootFolder? 636 // the trash folder directly instead of RootFolder?
628 if (userInfo.RootFolder != null) 637 if (userInfo.RootFolder != null)
629 { 638 {
630 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 639 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
640
631 if (item != null) 641 if (item != null)
632 { 642 {
633 userInfo.DeleteItem(item); 643 userInfo.DeleteItem(item);
@@ -654,7 +664,7 @@ namespace OpenSim.Region.Environment.Scenes
654 664
655 if (userInfo.RootFolder != null) 665 if (userInfo.RootFolder != null)
656 { 666 {
657 InventoryItemBase folder = userInfo.RootFolder.HasItem(folderID); 667 InventoryItemBase folder = userInfo.RootFolder.FindItem(folderID);
658 668
659 if (folder != null) 669 if (folder != null)
660 { 670 {
@@ -833,13 +843,13 @@ namespace OpenSim.Region.Environment.Scenes
833 843
834 if (userInfo != null && userInfo.RootFolder != null) 844 if (userInfo != null && userInfo.RootFolder != null)
835 { 845 {
836 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 846 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
837 847
838 // Try library 848 // Try library
839 // XXX clumsy, possibly should be one call 849 // XXX clumsy, possibly should be one call
840 if (null == item) 850 if (null == item)
841 { 851 {
842 item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(itemID); 852 item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(itemID);
843 } 853 }
844 854
845 if (item != null) 855 if (item != null)
@@ -884,13 +894,13 @@ namespace OpenSim.Region.Environment.Scenes
884 894
885 if (userInfo != null && userInfo.RootFolder != null) 895 if (userInfo != null && userInfo.RootFolder != null)
886 { 896 {
887 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 897 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
888 898
889 // Try library 899 // Try library
890 // XXX clumsy, possibly should be one call 900 // XXX clumsy, possibly should be one call
891 if (null == item) 901 if (null == item)
892 { 902 {
893 item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(itemID); 903 item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(itemID);
894 } 904 }
895 905
896 if (item != null) 906 if (item != null)
@@ -1203,14 +1213,11 @@ namespace OpenSim.Region.Environment.Scenes
1203 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, 1213 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags,
1204 bool RezSelected, bool RemoveItem, LLUUID fromTaskID) 1214 bool RezSelected, bool RemoveItem, LLUUID fromTaskID)
1205 { 1215 {
1206 SceneObjectGroup sog = RezObject(remoteClient, itemID, RayEnd, RayStart, 1216 RezObject(
1207 RayTargetID, BypassRayCast, RayEndIsIntersection, 1217 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1208 EveryoneMask, GroupMask, NextOwnerMask, ItemFlags, 1218 EveryoneMask, GroupMask, NextOwnerMask, ItemFlags, RezSelected, RemoveItem, fromTaskID, false);
1209 RezSelected, RemoveItem, fromTaskID, false);
1210 } 1219 }
1211 1220
1212
1213
1214 /// <summary> 1221 /// <summary>
1215 /// Returns SceneObjectGroup or null from asset request. 1222 /// Returns SceneObjectGroup or null from asset request.
1216 /// </summary> 1223 /// </summary>
@@ -1265,7 +1272,8 @@ namespace OpenSim.Region.Environment.Scenes
1265 { 1272 {
1266 if (userInfo.RootFolder != null) 1273 if (userInfo.RootFolder != null)
1267 { 1274 {
1268 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 1275 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
1276
1269 if (item != null) 1277 if (item != null)
1270 { 1278 {
1271 AssetBase rezAsset = AssetCache.GetAsset(item.AssetID, false); 1279 AssetBase rezAsset = AssetCache.GetAsset(item.AssetID, false);
diff --git a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
index 0ee8848..7b1211f 100644
--- a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
@@ -300,7 +300,8 @@ namespace OpenSim.Region.Modules.AvatarFactory
300 { 300 {
301 LLUUID assetId; 301 LLUUID assetId;
302 302
303 InventoryItemBase baseItem = profile.RootFolder.HasItem(wear.ItemID); 303 InventoryItemBase baseItem = profile.RootFolder.FindItem(wear.ItemID);
304
304 if (baseItem != null) 305 if (baseItem != null)
305 { 306 {
306 assetId = baseItem.AssetID; 307 assetId = baseItem.AssetID;