From 576db5b72a2fcd08598a435054f8455966b263fd Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Apr 2008 16:30:58 +0000 Subject: [PATCH] * documenting and minor refactoring in UserProfileCacheService --- .../Cache/UserProfileCacheService.cs | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 873070acff..7178d2ca0a 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -39,21 +39,26 @@ namespace OpenSim.Framework.Communications.Cache { private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - // Fields - private readonly CommunicationsManager m_parent; + /// + /// The comms manager holds the reference to this service + /// + private readonly CommunicationsManager m_commsManager; + + /// + /// Each user has a cached profile. + /// private readonly Dictionary m_userProfiles = new Dictionary(); - public LibraryRootFolder libraryRoot = new LibraryRootFolder(); + public readonly LibraryRootFolder libraryRoot = new LibraryRootFolder(); // Methods - public UserProfileCacheService(CommunicationsManager parent) + public UserProfileCacheService(CommunicationsManager commsManager) { - m_parent = parent; + m_commsManager = commsManager; } /// - /// A new user has moved into a region in this instance - /// so get info from servers + /// A new user has moved into a region in this instance so retrieve their profile from the user service. /// /// public void AddNewUser(LLUUID userID) @@ -63,8 +68,8 @@ namespace OpenSim.Framework.Communications.Cache { if (!m_userProfiles.ContainsKey(userID)) { - CachedUserInfo userInfo = new CachedUserInfo(m_parent); - userInfo.UserProfile = m_parent.UserService.GetUserProfile(userID); + CachedUserInfo userInfo = new CachedUserInfo(m_commsManager); + userInfo.UserProfile = m_commsManager.UserService.GetUserProfile(userID); if (userInfo.UserProfile != null) { @@ -73,7 +78,7 @@ namespace OpenSim.Framework.Communications.Cache } else { - m_log.ErrorFormat("[USER CACHE]: User profile for user {0} not found", userID); + m_log.ErrorFormat("[USER CACHE]: User profile for user {0} not found.", userID); } } } @@ -89,7 +94,7 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo userInfo = GetUserDetails(userID); if (userInfo != null) { - m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } else { @@ -97,6 +102,11 @@ namespace OpenSim.Framework.Communications.Cache } } + /// + /// Get the details of the given user. + /// + /// + /// null if no user details are found public CachedUserInfo GetUserDetails(LLUUID userID) { if (m_userProfiles.ContainsKey(userID)) @@ -128,7 +138,7 @@ namespace OpenSim.Framework.Communications.Cache createdBaseFolder.ParentID = createdFolder.ParentID; createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Version = createdFolder.Version; - m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); + m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); } } else @@ -171,7 +181,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.ParentID = parentID; baseFolder.Type = (short) type; baseFolder.Version = userProfile.RootFolder.Version; - m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); + m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); } } } @@ -188,7 +198,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.Owner = remoteClient.AgentId; baseFolder.ID = folderID; baseFolder.ParentID = parentID; - m_parent.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); + m_commsManager.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); } } }