diff options
author | diva | 2009-04-14 02:58:09 +0000 |
---|---|---|
committer | diva | 2009-04-14 02:58:09 +0000 |
commit | 23c88c2f4db99c39bd5eeb4601f68ea91bc0749d (patch) | |
tree | fe0a04c3d116ff90a192e6ffa508e6334650fd96 /OpenSim/Region/Communications/OGS1/OGS1UserServices.cs | |
parent | Cleaning up old circuit upon client close. (diff) | |
download | opensim-SC-23c88c2f4db99c39bd5eeb4601f68ea91bc0749d.zip opensim-SC-23c88c2f4db99c39bd5eeb4601f68ea91bc0749d.tar.gz opensim-SC-23c88c2f4db99c39bd5eeb4601f68ea91bc0749d.tar.bz2 opensim-SC-23c88c2f4db99c39bd5eeb4601f68ea91bc0749d.tar.xz |
Making OGS1UserServices friendly to subclassing.
Diffstat (limited to 'OpenSim/Region/Communications/OGS1/OGS1UserServices.cs')
-rw-r--r-- | OpenSim/Region/Communications/OGS1/OGS1UserServices.cs | 74 |
1 files changed, 45 insertions, 29 deletions
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; | |||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Communications; | 39 | using OpenSim.Framework.Communications; |
40 | using OpenSim.Framework.Communications.Clients; | ||
40 | 41 | ||
41 | namespace OpenSim.Region.Communications.OGS1 | 42 | namespace OpenSim.Region.Communications.OGS1 |
42 | { | 43 | { |
@@ -44,13 +45,17 @@ namespace OpenSim.Region.Communications.OGS1 | |||
44 | { | 45 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 47 | ||
47 | private CommunicationsManager m_commsManager; | 48 | protected CommunicationsManager m_commsManager; |
48 | 49 | ||
49 | public OGS1UserServices(CommunicationsManager commsManager) | 50 | public OGS1UserServices(CommunicationsManager commsManager) |
50 | { | 51 | { |
51 | m_commsManager = commsManager; | 52 | m_commsManager = commsManager; |
52 | } | 53 | } |
53 | 54 | ||
55 | public OGS1UserServices() | ||
56 | { | ||
57 | } | ||
58 | |||
54 | public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data) | 59 | public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data) |
55 | { | 60 | { |
56 | if (data.Contains("error_type")) | 61 | if (data.Contains("error_type")) |
@@ -133,7 +138,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
133 | /// </summary> | 138 | /// </summary> |
134 | /// <param name="avatarID"></param> | 139 | /// <param name="avatarID"></param> |
135 | /// <returns>null if the request fails</returns> | 140 | /// <returns>null if the request fails</returns> |
136 | public UserAgentData GetAgentByUUID(UUID userId) | 141 | public virtual UserAgentData GetAgentByUUID(UUID userId) |
137 | { | 142 | { |
138 | try | 143 | try |
139 | { | 144 | { |
@@ -142,9 +147,8 @@ namespace OpenSim.Region.Communications.OGS1 | |||
142 | IList parameters = new ArrayList(); | 147 | IList parameters = new ArrayList(); |
143 | parameters.Add(param); | 148 | parameters.Add(param); |
144 | XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters); | 149 | XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters); |
145 | string url = m_commsManager.NetworkServersInfo.UserURL; | ||
146 | 150 | ||
147 | XmlRpcResponse resp = req.Send(url, 6000); | 151 | XmlRpcResponse resp = req.Send(GetUserServerURL(userId), 6000); |
148 | Hashtable respData = (Hashtable)resp.Value; | 152 | Hashtable respData = (Hashtable)resp.Value; |
149 | if (respData.Contains("error_type")) | 153 | if (respData.Contains("error_type")) |
150 | { | 154 | { |
@@ -262,7 +266,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
262 | /// <param name="regionhandle">regionhandle</param> | 266 | /// <param name="regionhandle">regionhandle</param> |
263 | /// <param name="position">final position</param> | 267 | /// <param name="position">final position</param> |
264 | /// <param name="lookat">final lookat</param> | 268 | /// <param name="lookat">final lookat</param> |
265 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) | 269 | public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) |
266 | { | 270 | { |
267 | Hashtable param = new Hashtable(); | 271 | Hashtable param = new Hashtable(); |
268 | param["avatar_uuid"] = userid.Guid.ToString(); | 272 | param["avatar_uuid"] = userid.Guid.ToString(); |
@@ -281,7 +285,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
281 | 285 | ||
282 | try | 286 | try |
283 | { | 287 | { |
284 | req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); | 288 | req.Send(GetUserServerURL(userid), 3000); |
285 | } | 289 | } |
286 | catch (WebException) | 290 | catch (WebException) |
287 | { | 291 | { |
@@ -298,17 +302,17 @@ namespace OpenSim.Region.Communications.OGS1 | |||
298 | /// <param name="posx">final position x</param> | 302 | /// <param name="posx">final position x</param> |
299 | /// <param name="posy">final position y</param> | 303 | /// <param name="posy">final position y</param> |
300 | /// <param name="posz">final position z</param> | 304 | /// <param name="posz">final position z</param> |
301 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | 305 | public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) |
302 | { | 306 | { |
303 | LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); | 307 | LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); |
304 | } | 308 | } |
305 | 309 | ||
306 | public UserProfileData GetUserProfile(string firstName, string lastName) | 310 | public virtual UserProfileData GetUserProfile(string firstName, string lastName) |
307 | { | 311 | { |
308 | return GetUserProfile(firstName + " " + lastName); | 312 | return GetUserProfile(firstName + " " + lastName); |
309 | } | 313 | } |
310 | 314 | ||
311 | public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) | 315 | public virtual List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) |
312 | { | 316 | { |
313 | List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); | 317 | List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); |
314 | Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]"); | 318 | Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]"); |
@@ -338,7 +342,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
338 | /// </summary> | 342 | /// </summary> |
339 | /// <param name="avatarID"></param> | 343 | /// <param name="avatarID"></param> |
340 | /// <returns>null if the request fails</returns> | 344 | /// <returns>null if the request fails</returns> |
341 | public UserProfileData GetUserProfile(string name) | 345 | public virtual UserProfileData GetUserProfile(string name) |
342 | { | 346 | { |
343 | try | 347 | try |
344 | { | 348 | { |
@@ -367,7 +371,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
367 | /// </summary> | 371 | /// </summary> |
368 | /// <param name="avatarID"></param> | 372 | /// <param name="avatarID"></param> |
369 | /// <returns>null if the request fails</returns> | 373 | /// <returns>null if the request fails</returns> |
370 | public UserProfileData GetUserProfile(UUID avatarID) | 374 | public virtual UserProfileData GetUserProfile(UUID avatarID) |
371 | { | 375 | { |
372 | try | 376 | try |
373 | { | 377 | { |
@@ -376,7 +380,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
376 | IList parameters = new ArrayList(); | 380 | IList parameters = new ArrayList(); |
377 | parameters.Add(param); | 381 | parameters.Add(param); |
378 | XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters); | 382 | XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters); |
379 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); | 383 | XmlRpcResponse resp = req.Send(GetUserServerURL(avatarID), 30000); |
380 | Hashtable respData = (Hashtable)resp.Value; | 384 | Hashtable respData = (Hashtable)resp.Value; |
381 | 385 | ||
382 | return ConvertXMLRPCDataToUserProfile(respData); | 386 | return ConvertXMLRPCDataToUserProfile(respData); |
@@ -392,7 +396,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
392 | } | 396 | } |
393 | 397 | ||
394 | 398 | ||
395 | public void ClearUserAgent(UUID avatarID) | 399 | public virtual void ClearUserAgent(UUID avatarID) |
396 | { | 400 | { |
397 | // TODO: implement | 401 | // TODO: implement |
398 | } | 402 | } |
@@ -402,7 +406,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
402 | /// </summary> | 406 | /// </summary> |
403 | /// <param name="uuid"></param> | 407 | /// <param name="uuid"></param> |
404 | /// <returns></returns> | 408 | /// <returns></returns> |
405 | public UserProfileData SetupMasterUser(string firstName, string lastName) | 409 | public virtual UserProfileData SetupMasterUser(string firstName, string lastName) |
406 | { | 410 | { |
407 | return SetupMasterUser(firstName, lastName, String.Empty); | 411 | return SetupMasterUser(firstName, lastName, String.Empty); |
408 | } | 412 | } |
@@ -412,7 +416,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
412 | /// </summary> | 416 | /// </summary> |
413 | /// <param name="uuid"></param> | 417 | /// <param name="uuid"></param> |
414 | /// <returns></returns> | 418 | /// <returns></returns> |
415 | public UserProfileData SetupMasterUser(string firstName, string lastName, string password) | 419 | public virtual UserProfileData SetupMasterUser(string firstName, string lastName, string password) |
416 | { | 420 | { |
417 | UserProfileData profile = GetUserProfile(firstName, lastName); | 421 | UserProfileData profile = GetUserProfile(firstName, lastName); |
418 | return profile; | 422 | return profile; |
@@ -423,7 +427,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
423 | /// </summary> | 427 | /// </summary> |
424 | /// <param name="uuid"></param> | 428 | /// <param name="uuid"></param> |
425 | /// <returns></returns> | 429 | /// <returns></returns> |
426 | public UserProfileData SetupMasterUser(UUID uuid) | 430 | public virtual UserProfileData SetupMasterUser(UUID uuid) |
427 | { | 431 | { |
428 | UserProfileData data = GetUserProfile(uuid); | 432 | UserProfileData data = GetUserProfile(uuid); |
429 | 433 | ||
@@ -436,17 +440,17 @@ namespace OpenSim.Region.Communications.OGS1 | |||
436 | return data; | 440 | return data; |
437 | } | 441 | } |
438 | 442 | ||
439 | public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) | 443 | public virtual UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) |
440 | { | 444 | { |
441 | throw new Exception("The method or operation is not implemented."); | 445 | throw new Exception("The method or operation is not implemented."); |
442 | } | 446 | } |
443 | 447 | ||
444 | public bool ResetUserPassword(string firstName, string lastName, string newPassword) | 448 | public virtual bool ResetUserPassword(string firstName, string lastName, string newPassword) |
445 | { | 449 | { |
446 | throw new Exception("The method or operation is not implemented."); | 450 | throw new Exception("The method or operation is not implemented."); |
447 | } | 451 | } |
448 | 452 | ||
449 | public bool UpdateUserProfile(UserProfileData userProfile) | 453 | public virtual bool UpdateUserProfile(UserProfileData userProfile) |
450 | { | 454 | { |
451 | m_log.Debug("[OGS1 USER SERVICES]: Asking UserServer to update profile."); | 455 | m_log.Debug("[OGS1 USER SERVICES]: Asking UserServer to update profile."); |
452 | Hashtable param = new Hashtable(); | 456 | Hashtable param = new Hashtable(); |
@@ -477,7 +481,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
477 | parameters.Add(param); | 481 | parameters.Add(param); |
478 | 482 | ||
479 | XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters); | 483 | XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters); |
480 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000); | 484 | XmlRpcResponse resp = req.Send(GetUserServerURL(userProfile.ID), 3000); |
481 | Hashtable respData = (Hashtable)resp.Value; | 485 | Hashtable respData = (Hashtable)resp.Value; |
482 | if (respData != null) | 486 | if (respData != null) |
483 | { | 487 | { |
@@ -511,7 +515,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
511 | /// <param name="friendlistowner">The agent that who's friends list is being added to</param> | 515 | /// <param name="friendlistowner">The agent that who's friends list is being added to</param> |
512 | /// <param name="friend">The agent that being added to the friends list of the friends list owner</param> | 516 | /// <param name="friend">The agent that being added to the friends list of the friends list owner</param> |
513 | /// <param name="perms">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 </param> | 517 | /// <param name="perms">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 </param> |
514 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | 518 | public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) |
515 | { | 519 | { |
516 | try | 520 | try |
517 | { | 521 | { |
@@ -563,7 +567,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
563 | /// </summary> | 567 | /// </summary> |
564 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | 568 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> |
565 | /// <param name="friend">The Ex-friend agent</param> | 569 | /// <param name="friend">The Ex-friend agent</param> |
566 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) | 570 | public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend) |
567 | { | 571 | { |
568 | try | 572 | try |
569 | { | 573 | { |
@@ -615,7 +619,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
615 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | 619 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> |
616 | /// <param name="friend">The agent that is getting or loosing permissions</param> | 620 | /// <param name="friend">The agent that is getting or loosing permissions</param> |
617 | /// <param name="perms">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 </param> | 621 | /// <param name="perms">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 </param> |
618 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | 622 | public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) |
619 | { | 623 | { |
620 | try | 624 | try |
621 | { | 625 | { |
@@ -663,7 +667,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
663 | /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner | 667 | /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner |
664 | /// </summary> | 668 | /// </summary> |
665 | /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param> | 669 | /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param> |
666 | public List<FriendListItem> GetUserFriendList(UUID friendlistowner) | 670 | public virtual List<FriendListItem> GetUserFriendList(UUID friendlistowner) |
667 | { | 671 | { |
668 | List<FriendListItem> buddylist = new List<FriendListItem>(); | 672 | List<FriendListItem> buddylist = new List<FriendListItem>(); |
669 | 673 | ||
@@ -693,7 +697,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
693 | return buddylist; | 697 | return buddylist; |
694 | } | 698 | } |
695 | 699 | ||
696 | public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) | 700 | public virtual Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) |
697 | { | 701 | { |
698 | Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>(); | 702 | Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>(); |
699 | 703 | ||
@@ -774,7 +778,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
774 | #endregion | 778 | #endregion |
775 | 779 | ||
776 | /// Appearance | 780 | /// Appearance |
777 | public AvatarAppearance GetUserAppearance(UUID user) | 781 | public virtual AvatarAppearance GetUserAppearance(UUID user) |
778 | { | 782 | { |
779 | AvatarAppearance appearance = null; | 783 | AvatarAppearance appearance = null; |
780 | 784 | ||
@@ -786,7 +790,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
786 | IList parameters = new ArrayList(); | 790 | IList parameters = new ArrayList(); |
787 | parameters.Add(param); | 791 | parameters.Add(param); |
788 | XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters); | 792 | XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters); |
789 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000); | 793 | XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000); |
790 | Hashtable respData = (Hashtable)resp.Value; | 794 | Hashtable respData = (Hashtable)resp.Value; |
791 | 795 | ||
792 | return ConvertXMLRPCDataToAvatarAppearance(respData); | 796 | return ConvertXMLRPCDataToAvatarAppearance(respData); |
@@ -799,7 +803,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
799 | return appearance; | 803 | return appearance; |
800 | } | 804 | } |
801 | 805 | ||
802 | public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) | 806 | public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance) |
803 | { | 807 | { |
804 | try | 808 | try |
805 | { | 809 | { |
@@ -809,7 +813,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
809 | IList parameters = new ArrayList(); | 813 | IList parameters = new ArrayList(); |
810 | parameters.Add(param); | 814 | parameters.Add(param); |
811 | XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters); | 815 | XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters); |
812 | XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000); | 816 | XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000); |
813 | Hashtable respData = (Hashtable)resp.Value; | 817 | Hashtable respData = (Hashtable)resp.Value; |
814 | 818 | ||
815 | if (respData != null) | 819 | if (respData != null) |
@@ -842,5 +846,17 @@ namespace OpenSim.Region.Communications.OGS1 | |||
842 | // Return Empty list (no friends) | 846 | // Return Empty list (no friends) |
843 | } | 847 | } |
844 | } | 848 | } |
849 | |||
850 | public bool VerifySession(UUID userID, UUID sessionID) | ||
851 | { | ||
852 | m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID); | ||
853 | return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID); | ||
854 | } | ||
855 | |||
856 | protected virtual string GetUserServerURL(UUID userID) | ||
857 | { | ||
858 | return m_commsManager.NetworkServersInfo.UserURL; | ||
859 | } | ||
860 | |||
845 | } | 861 | } |
846 | } | 862 | } |