From e26d4fc08556252c09e46bfa6aa2b59119f702dc Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 17:02:20 +0000 Subject: * minor: replace test of CachedUserInfo.RootFolder != null with something more readable, and make RootFolder get only --- .../Framework/Communications/Cache/CachedUserInfo.cs | 16 +++++++++++----- .../Communications/Cache/UserProfileCacheService.cs | 18 +++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 9ece581..1208605 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -49,7 +49,8 @@ namespace OpenSim.Framework.Communications.Cache public UserProfileData UserProfile { get { return m_userProfile; } } // FIXME: These need to be hidden behind accessors - public InventoryFolderImpl RootFolder = null; + private InventoryFolderImpl m_rootFolder; + public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } /// /// Stores received folders for which we have not yet received the parents. @@ -67,6 +68,11 @@ namespace OpenSim.Framework.Communications.Cache m_commsManager = commsManager; m_userProfile = userProfile; } + + /// + /// Has this user info object yet received its inventory information from the invetnroy service? + /// + public bool HasInventory { get { return RootFolder != null; } } /// /// Store a folder pending categorization when its parent is received. @@ -134,7 +140,7 @@ namespace OpenSim.Framework.Communications.Cache { if (folderInfo.ParentID == LLUUID.Zero) { - RootFolder = folderInfo; + m_rootFolder = folderInfo; } } else if (RootFolder.ID == folderInfo.ParentID) @@ -208,7 +214,7 @@ namespace OpenSim.Framework.Communications.Cache public void AddItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.ID) && (RootFolder != null)) + if ((userID == UserProfile.ID) && HasInventory) { ItemReceive(userID, itemInfo); m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); @@ -217,7 +223,7 @@ namespace OpenSim.Framework.Communications.Cache public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.ID) && (RootFolder != null)) + if ((userID == UserProfile.ID) && HasInventory) { m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } @@ -226,7 +232,7 @@ namespace OpenSim.Framework.Communications.Cache public bool DeleteItem(LLUUID userID, InventoryItemBase item) { bool result = false; - if ((userID == UserProfile.ID) && (RootFolder != null)) + if ((userID == UserProfile.ID) && HasInventory) { result = RootFolder.DeleteItem(item.ID); if (result) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 586c24e..b924d5c 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -125,7 +125,7 @@ namespace OpenSim.Framework.Communications.Cache if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { if (userProfile.RootFolder.ID == parentID) { @@ -175,7 +175,7 @@ namespace OpenSim.Framework.Communications.Cache if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { InventoryFolderBase baseFolder = new InventoryFolderBase(); baseFolder.Owner = remoteClient.AgentId; @@ -195,7 +195,7 @@ namespace OpenSim.Framework.Communications.Cache if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { InventoryFolderBase baseFolder = new InventoryFolderBase(); baseFolder.Owner = remoteClient.AgentId; @@ -248,21 +248,21 @@ namespace OpenSim.Framework.Communications.Cache // inventory failure. // // This is a crude way of dealing with that by retrying the lookup. - if (userProfile.RootFolder == null) + if (!userProfile.HasInventory) { int attempts = 5; while (attempts-- > 0) { Thread.Sleep(3000); - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { break; } } } - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { if (userProfile.RootFolder.ID == folderID) { @@ -346,7 +346,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(agentID, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { if (userProfile.RootFolder.ID == folderID) { @@ -393,7 +393,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { InventoryFolderImpl subFolder = userProfile.RootFolder.HasSubFolder(folderID); if (subFolder != null) @@ -420,7 +420,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.RootFolder != null) + if (userProfile.HasInventory) { InventoryItemBase item = userProfile.RootFolder.HasItem(itemID); if (item != null) -- cgit v1.1