* documenting and minor refactoring in UserProfileCacheService

0.6.0-stable
Justin Clarke Casey 2008-04-11 16:30:58 +00:00
parent 9a7717743b
commit 576db5b72a
1 changed files with 24 additions and 14 deletions

View File

@ -39,21 +39,26 @@ namespace OpenSim.Framework.Communications.Cache
{ {
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Fields /// <summary>
private readonly CommunicationsManager m_parent; /// The comms manager holds the reference to this service
/// </summary>
private readonly CommunicationsManager m_commsManager;
/// <summary>
/// Each user has a cached profile.
/// </summary>
private readonly Dictionary<LLUUID, CachedUserInfo> m_userProfiles = new Dictionary<LLUUID, CachedUserInfo>(); private readonly Dictionary<LLUUID, CachedUserInfo> m_userProfiles = new Dictionary<LLUUID, CachedUserInfo>();
public LibraryRootFolder libraryRoot = new LibraryRootFolder(); public readonly LibraryRootFolder libraryRoot = new LibraryRootFolder();
// Methods // Methods
public UserProfileCacheService(CommunicationsManager parent) public UserProfileCacheService(CommunicationsManager commsManager)
{ {
m_parent = parent; m_commsManager = commsManager;
} }
/// <summary> /// <summary>
/// A new user has moved into a region in this instance /// A new user has moved into a region in this instance so retrieve their profile from the user service.
/// so get info from servers
/// </summary> /// </summary>
/// <param name="userID"></param> /// <param name="userID"></param>
public void AddNewUser(LLUUID userID) public void AddNewUser(LLUUID userID)
@ -63,8 +68,8 @@ namespace OpenSim.Framework.Communications.Cache
{ {
if (!m_userProfiles.ContainsKey(userID)) if (!m_userProfiles.ContainsKey(userID))
{ {
CachedUserInfo userInfo = new CachedUserInfo(m_parent); CachedUserInfo userInfo = new CachedUserInfo(m_commsManager);
userInfo.UserProfile = m_parent.UserService.GetUserProfile(userID); userInfo.UserProfile = m_commsManager.UserService.GetUserProfile(userID);
if (userInfo.UserProfile != null) if (userInfo.UserProfile != null)
{ {
@ -73,7 +78,7 @@ namespace OpenSim.Framework.Communications.Cache
} }
else 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); CachedUserInfo userInfo = GetUserDetails(userID);
if (userInfo != null) if (userInfo != null)
{ {
m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
} }
else else
{ {
@ -97,6 +102,11 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
/// <summary>
/// Get the details of the given user.
/// </summary>
/// <param name="userID"></param>
/// <returns>null if no user details are found</returns>
public CachedUserInfo GetUserDetails(LLUUID userID) public CachedUserInfo GetUserDetails(LLUUID userID)
{ {
if (m_userProfiles.ContainsKey(userID)) if (m_userProfiles.ContainsKey(userID))
@ -128,7 +138,7 @@ namespace OpenSim.Framework.Communications.Cache
createdBaseFolder.ParentID = createdFolder.ParentID; createdBaseFolder.ParentID = createdFolder.ParentID;
createdBaseFolder.Type = createdFolder.Type; createdBaseFolder.Type = createdFolder.Type;
createdBaseFolder.Version = createdFolder.Version; createdBaseFolder.Version = createdFolder.Version;
m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder); m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder);
} }
} }
else else
@ -171,7 +181,7 @@ namespace OpenSim.Framework.Communications.Cache
baseFolder.ParentID = parentID; baseFolder.ParentID = parentID;
baseFolder.Type = (short) type; baseFolder.Type = (short) type;
baseFolder.Version = userProfile.RootFolder.Version; 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.Owner = remoteClient.AgentId;
baseFolder.ID = folderID; baseFolder.ID = folderID;
baseFolder.ParentID = parentID; baseFolder.ParentID = parentID;
m_parent.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder); m_commsManager.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder);
} }
} }
} }