HGUserServices.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Reflection;
  32. using System.Text.RegularExpressions;
  33. using OpenMetaverse;
  34. using log4net;
  35. using Nwc.XmlRpc;
  36. using OpenSim.Framework;
  37. using OpenSim.Framework.Communications;
  38. using OpenSim.Region.Communications.OGS1;
  39. namespace OpenSim.Region.Communications.Hypergrid
  40. {
  41. /// <summary>
  42. /// For the time being, this class is just an identity wrapper around OGS1UserServices,
  43. /// so it always fails for foreign users.
  44. /// Later it needs to talk with the foreign users' user servers.
  45. /// </summary>
  46. public class HGUserServices : IUserService, IAvatarService, IMessagingService
  47. {
  48. //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  49. //private HGCommunicationsGridMode m_parent;
  50. private OGS1UserServices m_remoteUserServices;
  51. public HGUserServices(HGCommunicationsGridMode parent)
  52. {
  53. //m_parent = parent;
  54. m_remoteUserServices = new OGS1UserServices(parent);
  55. }
  56. public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data)
  57. {
  58. return m_remoteUserServices.ConvertXMLRPCDataToUserProfile(data);
  59. }
  60. /// <summary>
  61. /// Get a user agent from the user server
  62. /// </summary>
  63. /// <param name="avatarID"></param>
  64. /// <returns>null if the request fails</returns>
  65. public UserAgentData GetAgentByUUID(UUID userId)
  66. {
  67. return m_remoteUserServices.GetAgentByUUID(userId);
  68. }
  69. public AvatarAppearance ConvertXMLRPCDataToAvatarAppearance(Hashtable data)
  70. {
  71. return m_remoteUserServices.ConvertXMLRPCDataToAvatarAppearance(data);
  72. }
  73. public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data)
  74. {
  75. return m_remoteUserServices.ConvertXMLRPCDataToAvatarPickerList(queryID, data);
  76. }
  77. public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
  78. {
  79. return m_remoteUserServices.ConvertXMLRPCDataToFriendListItemList(data);
  80. }
  81. /// <summary>
  82. /// Logs off a user on the user server
  83. /// </summary>
  84. /// <param name="UserID">UUID of the user</param>
  85. /// <param name="regionID">UUID of the Region</param>
  86. /// <param name="regionhandle">regionhandle</param>
  87. /// <param name="position">final position</param>
  88. /// <param name="lookat">final lookat</param>
  89. public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
  90. {
  91. m_remoteUserServices.LogOffUser(userid, regionid, regionhandle, position, lookat);
  92. }
  93. /// <summary>
  94. /// Logs off a user on the user server (deprecated as of 2008-08-27)
  95. /// </summary>
  96. /// <param name="UserID">UUID of the user</param>
  97. /// <param name="regionID">UUID of the Region</param>
  98. /// <param name="regionhandle">regionhandle</param>
  99. /// <param name="posx">final position x</param>
  100. /// <param name="posy">final position y</param>
  101. /// <param name="posz">final position z</param>
  102. public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
  103. {
  104. m_remoteUserServices.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
  105. }
  106. public UserProfileData GetUserProfile(string firstName, string lastName)
  107. {
  108. return GetUserProfile(firstName + " " + lastName);
  109. }
  110. public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
  111. {
  112. return m_remoteUserServices.GenerateAgentPickerRequestResponse(queryID, query);
  113. }
  114. /// <summary>
  115. /// Get a user profile from the user server
  116. /// </summary>
  117. /// <param name="avatarID"></param>
  118. /// <returns>null if the request fails</returns>
  119. public UserProfileData GetUserProfile(string name)
  120. {
  121. return m_remoteUserServices.GetUserProfile(name);
  122. }
  123. /// <summary>
  124. /// Get a user profile from the user server
  125. /// </summary>
  126. /// <param name="avatarID"></param>
  127. /// <returns>null if the request fails</returns>
  128. public UserProfileData GetUserProfile(UUID avatarID)
  129. {
  130. return m_remoteUserServices.GetUserProfile(avatarID);
  131. }
  132. public void ClearUserAgent(UUID avatarID)
  133. {
  134. m_remoteUserServices.ClearUserAgent(avatarID);
  135. }
  136. /// <summary>
  137. /// Retrieve the user information for the given master uuid.
  138. /// </summary>
  139. /// <param name="uuid"></param>
  140. /// <returns></returns>
  141. public UserProfileData SetupMasterUser(string firstName, string lastName)
  142. {
  143. return m_remoteUserServices.SetupMasterUser(firstName, lastName);
  144. }
  145. /// <summary>
  146. /// Retrieve the user information for the given master uuid.
  147. /// </summary>
  148. /// <param name="uuid"></param>
  149. /// <returns></returns>
  150. public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
  151. {
  152. return m_remoteUserServices.SetupMasterUser(firstName, lastName, password);
  153. }
  154. /// <summary>
  155. /// Retrieve the user information for the given master uuid.
  156. /// </summary>
  157. /// <param name="uuid"></param>
  158. /// <returns></returns>
  159. public UserProfileData SetupMasterUser(UUID uuid)
  160. {
  161. return m_remoteUserServices.SetupMasterUser(uuid);
  162. }
  163. public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
  164. {
  165. return m_remoteUserServices.AddUserProfile(firstName, lastName, pass, regX, regY);
  166. }
  167. public bool ResetUserPassword(string firstName, string lastName, string newPassword)
  168. {
  169. return m_remoteUserServices.ResetUserPassword(firstName, lastName, newPassword);
  170. }
  171. public bool UpdateUserProfile(UserProfileData userProfile)
  172. {
  173. return m_remoteUserServices.UpdateUserProfile(userProfile);
  174. }
  175. #region IUserServices Friend Methods
  176. /// <summary>
  177. /// Adds a new friend to the database for XUser
  178. /// </summary>
  179. /// <param name="friendlistowner">The agent that who's friends list is being added to</param>
  180. /// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
  181. /// <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>
  182. public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
  183. {
  184. m_remoteUserServices.AddNewUserFriend(friendlistowner, friend, perms);
  185. }
  186. /// <summary>
  187. /// Delete friend on friendlistowner's friendlist.
  188. /// </summary>
  189. /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
  190. /// <param name="friend">The Ex-friend agent</param>
  191. public void RemoveUserFriend(UUID friendlistowner, UUID friend)
  192. {
  193. m_remoteUserServices.RemoveUserFriend(friend, friend);
  194. }
  195. /// <summary>
  196. /// Update permissions for friend on friendlistowner's friendlist.
  197. /// </summary>
  198. /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
  199. /// <param name="friend">The agent that is getting or loosing permissions</param>
  200. /// <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>
  201. public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
  202. {
  203. m_remoteUserServices.UpdateUserFriendPerms(friendlistowner, friend, perms);
  204. }
  205. /// <summary>
  206. /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
  207. /// </summary>
  208. /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
  209. public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
  210. {
  211. return m_remoteUserServices.GetUserFriendList(friendlistowner);
  212. }
  213. #endregion
  214. /// Appearance
  215. public AvatarAppearance GetUserAppearance(UUID user)
  216. {
  217. return m_remoteUserServices.GetUserAppearance(user);
  218. }
  219. public void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
  220. {
  221. m_remoteUserServices.UpdateUserAppearance(user, appearance);
  222. }
  223. #region IMessagingService
  224. public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
  225. {
  226. return m_remoteUserServices.GetFriendRegionInfos(uuids);
  227. }
  228. #endregion
  229. }
  230. }