From 6941058824e418bcdc2932c35f226bbcc5cea2ad Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 1 Jan 2012 14:57:13 -0500 Subject: Profile Updates Update basic profile to use the replaceable interface, making configuration less error-prone. Add support to query avatar's home user account and profile service for regions usng the updated OpenProfileModule with Hypergrid. --- .../Avatar/Profile/BasicProfileModule.cs | 12 +-- .../UserManagement/UserManagementModule.cs | 93 ++++++++++++++++++++++ .../Region/Framework/Interfaces/IUserManagement.cs | 3 + 3 files changed, 103 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs index dee0ad4..eb1e4b5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs @@ -43,7 +43,7 @@ using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.Profile { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class BasicProfileModule : ISharedRegionModule + public class BasicProfileModule : IProfileModule, ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -57,6 +57,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile public void Initialise(IConfigSource config) { + // This can be reduced later as the loader will determine + // whether we are needed if (config.Configs["Profile"] != null) { if (config.Configs["Profile"].GetString("Module", string.Empty) != "BasicProfileModule") @@ -65,14 +67,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile m_log.DebugFormat("[PROFILE MODULE]: Basic Profile Module enabled"); m_Enabled = true; - } public void AddRegion(Scene scene) { if (!m_Enabled) return; - + lock (m_Scenes) { if (!m_Scenes.Contains(scene)) @@ -80,6 +81,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile m_Scenes.Add(scene); // Hook up events scene.EventManager.OnNewClient += OnNewClient; + scene.RegisterModuleInterface(this); } } } @@ -116,7 +118,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile public Type ReplaceableInterface { - get { return null; } + get { return typeof(IProfileModule); } } #endregion @@ -170,4 +172,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index dbe2560..37292d6 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -50,6 +50,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement public string LastName { get; set; } public string HomeURL { get; set; } public Dictionary ServerURLs { get; set; } + public string Title { get; set; } + public int Flags { get; set; } + public int Created { get; set; } } public class UserManagementModule : ISharedRegionModule, IUserManagement @@ -281,6 +284,94 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement return string.Empty; } + public int GetUserFlags(UUID userID) + { + UserData userdata; + lock (m_UserCache) + m_UserCache.TryGetValue(userID, out userdata); + + if (userdata.Flags == -1) + GetUserInfo(userID); + + if (userdata.Flags != -1) + return userdata.Flags; + + return 0; + } + + public int GetUserCreated(UUID userID) + { + UserData userdata; + lock (m_UserCache) + m_UserCache.TryGetValue(userID, out userdata); + + if (userdata.Flags == -1) + GetUserInfo(userID); + + if (userdata.Created != -1) + return userdata.Created; + + return 0; + } + + public string GetUserTitle(UUID userID) + { + UserData userdata; + lock (m_UserCache) + m_UserCache.TryGetValue(userID, out userdata); + + if (userdata.Flags == -1) + GetUserInfo(userID); + + if (userdata.Created != -1) + return userdata.Title; + + return string.Empty; + } + + // This will cache the user data + // Change this to return bool + private bool GetUserInfo(UUID userID) + { + UserData userdata; + lock (m_UserCache) + m_UserCache.TryGetValue(userID, out userdata); + + if (userdata != null) + { +// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID); + + if (userdata.Flags >= 0) + { + // This is already populated + return true; + } + + if (userdata.HomeURL != null && userdata.HomeURL != string.Empty) + { + m_log.DebugFormat( + "[USER MANAGEMENT MODULE]: Requesting user flags from '{0}' for {1}", + userdata.HomeURL, userID); + + UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL); + Dictionary info = uConn.GetUserInfo(userID); + + // Pull our data now + if (info["result"].ToString() == "success") + { + userdata.Flags = (int)info["user_flags"]; + userdata.Created = (int)info["user_created"]; + userdata.Title = (string)info["user_title"]; + + return true; + } + } + } + + return false; + } + + public string GetUserUUI(UUID userID) { UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, userID); @@ -352,6 +443,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement { UserData user = new UserData(); user.Id = id; + user.Flags = -1; + user.Created = -1; if (creatorData != null && creatorData != string.Empty) { diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs index ea0ba593..54dfaf4 100644 --- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs +++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs @@ -14,6 +14,9 @@ namespace OpenSim.Region.Framework.Interfaces string GetUserHomeURL(UUID uuid); string GetUserUUI(UUID uuid); string GetUserServerURL(UUID uuid, string serverType); + int GetUserFlags(UUID userID); + int GetUserCreated(UUID userID); + string GetUserTitle(UUID userID); /// /// Add a user. -- cgit v1.1