From 23c88c2f4db99c39bd5eeb4601f68ea91bc0749d Mon Sep 17 00:00:00 2001 From: diva Date: Tue, 14 Apr 2009 02:58:09 +0000 Subject: Making OGS1UserServices friendly to subclassing. --- .../Region/Communications/OGS1/OGS1UserServices.cs | 74 +++++++++++++--------- 1 file changed, 45 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region/Communications/OGS1/OGS1UserServices.cs') diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 3fe78a3..11ae6e3 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -37,6 +37,7 @@ using Nwc.XmlRpc; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Clients; namespace OpenSim.Region.Communications.OGS1 { @@ -44,13 +45,17 @@ namespace OpenSim.Region.Communications.OGS1 { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private CommunicationsManager m_commsManager; + protected CommunicationsManager m_commsManager; public OGS1UserServices(CommunicationsManager commsManager) { m_commsManager = commsManager; } + public OGS1UserServices() + { + } + public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data) { if (data.Contains("error_type")) @@ -133,7 +138,7 @@ namespace OpenSim.Region.Communications.OGS1 /// /// /// null if the request fails - public UserAgentData GetAgentByUUID(UUID userId) + public virtual UserAgentData GetAgentByUUID(UUID userId) { try { @@ -142,9 +147,8 @@ namespace OpenSim.Region.Communications.OGS1 IList parameters = new ArrayList(); parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters); - string url = m_commsManager.NetworkServersInfo.UserURL; - XmlRpcResponse resp = req.Send(url, 6000); + XmlRpcResponse resp = req.Send(GetUserServerURL(userId), 6000); Hashtable respData = (Hashtable)resp.Value; if (respData.Contains("error_type")) { @@ -262,7 +266,7 @@ namespace OpenSim.Region.Communications.OGS1 /// regionhandle /// final position /// final lookat - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) + public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) { Hashtable param = new Hashtable(); param["avatar_uuid"] = userid.Guid.ToString(); @@ -281,7 +285,7 @@ namespace OpenSim.Region.Communications.OGS1 try { - req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); + req.Send(GetUserServerURL(userid), 3000); } catch (WebException) { @@ -298,17 +302,17 @@ namespace OpenSim.Region.Communications.OGS1 /// final position x /// final position y /// final position z - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) + public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) { LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); } - public UserProfileData GetUserProfile(string firstName, string lastName) + public virtual UserProfileData GetUserProfile(string firstName, string lastName) { return GetUserProfile(firstName + " " + lastName); } - public List GenerateAgentPickerRequestResponse(UUID queryID, string query) + public virtual List GenerateAgentPickerRequestResponse(UUID queryID, string query) { List pickerlist = new List(); Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]"); @@ -338,7 +342,7 @@ namespace OpenSim.Region.Communications.OGS1 /// /// /// null if the request fails - public UserProfileData GetUserProfile(string name) + public virtual UserProfileData GetUserProfile(string name) { try { @@ -367,7 +371,7 @@ namespace OpenSim.Region.Communications.OGS1 /// /// /// null if the request fails - public UserProfileData GetUserProfile(UUID avatarID) + public virtual UserProfileData GetUserProfile(UUID avatarID) { try { @@ -376,7 +380,7 @@ namespace OpenSim.Region.Communications.OGS1 IList parameters = new ArrayList(); parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters); - XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); + XmlRpcResponse resp = req.Send(GetUserServerURL(avatarID), 30000); Hashtable respData = (Hashtable)resp.Value; return ConvertXMLRPCDataToUserProfile(respData); @@ -392,7 +396,7 @@ namespace OpenSim.Region.Communications.OGS1 } - public void ClearUserAgent(UUID avatarID) + public virtual void ClearUserAgent(UUID avatarID) { // TODO: implement } @@ -402,7 +406,7 @@ namespace OpenSim.Region.Communications.OGS1 /// /// /// - public UserProfileData SetupMasterUser(string firstName, string lastName) + public virtual UserProfileData SetupMasterUser(string firstName, string lastName) { return SetupMasterUser(firstName, lastName, String.Empty); } @@ -412,7 +416,7 @@ namespace OpenSim.Region.Communications.OGS1 /// /// /// - public UserProfileData SetupMasterUser(string firstName, string lastName, string password) + public virtual UserProfileData SetupMasterUser(string firstName, string lastName, string password) { UserProfileData profile = GetUserProfile(firstName, lastName); return profile; @@ -423,7 +427,7 @@ namespace OpenSim.Region.Communications.OGS1 /// /// /// - public UserProfileData SetupMasterUser(UUID uuid) + public virtual UserProfileData SetupMasterUser(UUID uuid) { UserProfileData data = GetUserProfile(uuid); @@ -436,17 +440,17 @@ namespace OpenSim.Region.Communications.OGS1 return data; } - public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) + public virtual UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) { throw new Exception("The method or operation is not implemented."); } - public bool ResetUserPassword(string firstName, string lastName, string newPassword) + public virtual bool ResetUserPassword(string firstName, string lastName, string newPassword) { throw new Exception("The method or operation is not implemented."); } - public bool UpdateUserProfile(UserProfileData userProfile) + public virtual bool UpdateUserProfile(UserProfileData userProfile) { m_log.Debug("[OGS1 USER SERVICES]: Asking UserServer to update profile."); Hashtable param = new Hashtable(); @@ -477,7 +481,7 @@ namespace OpenSim.Region.Communications.OGS1 parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters); - XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); + XmlRpcResponse resp = req.Send(GetUserServerURL(userProfile.ID), 3000); Hashtable respData = (Hashtable)resp.Value; if (respData != null) { @@ -511,7 +515,7 @@ namespace OpenSim.Region.Communications.OGS1 /// The agent that who's friends list is being added to /// The agent that being added to the friends list of the friends list owner /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects - public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) + public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) { try { @@ -563,7 +567,7 @@ namespace OpenSim.Region.Communications.OGS1 /// /// The agent that who's friends list is being updated /// The Ex-friend agent - public void RemoveUserFriend(UUID friendlistowner, UUID friend) + public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend) { try { @@ -615,7 +619,7 @@ namespace OpenSim.Region.Communications.OGS1 /// The agent that who's friends list is being updated /// The agent that is getting or loosing permissions /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects - public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) + public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { try { @@ -663,7 +667,7 @@ namespace OpenSim.Region.Communications.OGS1 /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner /// /// The agent that we're retreiving the friends Data. - public List GetUserFriendList(UUID friendlistowner) + public virtual List GetUserFriendList(UUID friendlistowner) { List buddylist = new List(); @@ -693,7 +697,7 @@ namespace OpenSim.Region.Communications.OGS1 return buddylist; } - public Dictionary GetFriendRegionInfos(List uuids) + public virtual Dictionary GetFriendRegionInfos(List uuids) { Dictionary result = new Dictionary(); @@ -774,7 +778,7 @@ namespace OpenSim.Region.Communications.OGS1 #endregion /// Appearance - public AvatarAppearance GetUserAppearance(UUID user) + public virtual AvatarAppearance GetUserAppearance(UUID user) { AvatarAppearance appearance = null; @@ -786,7 +790,7 @@ namespace OpenSim.Region.Communications.OGS1 IList parameters = new ArrayList(); parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters); - XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000); + XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000); Hashtable respData = (Hashtable)resp.Value; return ConvertXMLRPCDataToAvatarAppearance(respData); @@ -799,7 +803,7 @@ namespace OpenSim.Region.Communications.OGS1 return appearance; } - public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) + public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance) { try { @@ -809,7 +813,7 @@ namespace OpenSim.Region.Communications.OGS1 IList parameters = new ArrayList(); parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters); - XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000); + XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000); Hashtable respData = (Hashtable)resp.Value; if (respData != null) @@ -842,5 +846,17 @@ namespace OpenSim.Region.Communications.OGS1 // Return Empty list (no friends) } } + + public bool VerifySession(UUID userID, UUID sessionID) + { + m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID); + return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID); + } + + protected virtual string GetUserServerURL(UUID userID) + { + return m_commsManager.NetworkServersInfo.UserURL; + } + } } -- cgit v1.1