1
0

HGUserServices.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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.Collections;
  28. using System.Collections.Generic;
  29. using OpenMetaverse;
  30. using OpenSim.Framework;
  31. using OpenSim.Framework.Communications;
  32. using OpenSim.Region.Communications.OGS1;
  33. namespace OpenSim.Region.Communications.Hypergrid
  34. {
  35. /// <summary>
  36. /// For the time being, this class is just an identity wrapper around OGS1UserServices,
  37. /// so it always fails for foreign users.
  38. /// Later it needs to talk with the foreign users' user servers.
  39. /// </summary>
  40. public class HGUserServices : IUserService, IAvatarService, IMessagingService
  41. {
  42. //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  43. //private HGCommunicationsGridMode m_parent;
  44. private OGS1UserServices m_remoteUserServices;
  45. public HGUserServices(HGCommunicationsGridMode parent)
  46. {
  47. //m_parent = parent;
  48. m_remoteUserServices = new OGS1UserServices(parent);
  49. }
  50. public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data)
  51. {
  52. return m_remoteUserServices.ConvertXMLRPCDataToUserProfile(data);
  53. }
  54. /// <summary>
  55. /// Get a user agent from the user server
  56. /// </summary>
  57. /// <param name="avatarID"></param>
  58. /// <returns>null if the request fails</returns>
  59. public UserAgentData GetAgentByUUID(UUID userId)
  60. {
  61. return m_remoteUserServices.GetAgentByUUID(userId);
  62. }
  63. public AvatarAppearance ConvertXMLRPCDataToAvatarAppearance(Hashtable data)
  64. {
  65. return m_remoteUserServices.ConvertXMLRPCDataToAvatarAppearance(data);
  66. }
  67. public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data)
  68. {
  69. return m_remoteUserServices.ConvertXMLRPCDataToAvatarPickerList(queryID, data);
  70. }
  71. public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
  72. {
  73. return m_remoteUserServices.ConvertXMLRPCDataToFriendListItemList(data);
  74. }
  75. /// <summary>
  76. /// Logs off a user on the user server
  77. /// </summary>
  78. /// <param name="UserID">UUID of the user</param>
  79. /// <param name="regionID">UUID of the Region</param>
  80. /// <param name="regionhandle">regionhandle</param>
  81. /// <param name="position">final position</param>
  82. /// <param name="lookat">final lookat</param>
  83. public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
  84. {
  85. m_remoteUserServices.LogOffUser(userid, regionid, regionhandle, position, lookat);
  86. }
  87. /// <summary>
  88. /// Logs off a user on the user server (deprecated as of 2008-08-27)
  89. /// </summary>
  90. /// <param name="UserID">UUID of the user</param>
  91. /// <param name="regionID">UUID of the Region</param>
  92. /// <param name="regionhandle">regionhandle</param>
  93. /// <param name="posx">final position x</param>
  94. /// <param name="posy">final position y</param>
  95. /// <param name="posz">final position z</param>
  96. public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
  97. {
  98. m_remoteUserServices.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
  99. }
  100. public UserProfileData GetUserProfile(string firstName, string lastName)
  101. {
  102. return GetUserProfile(firstName + " " + lastName);
  103. }
  104. public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
  105. {
  106. return m_remoteUserServices.GenerateAgentPickerRequestResponse(queryID, query);
  107. }
  108. /// <summary>
  109. /// Get a user profile from the user server
  110. /// </summary>
  111. /// <param name="avatarID"></param>
  112. /// <returns>null if the request fails</returns>
  113. public UserProfileData GetUserProfile(string name)
  114. {
  115. return m_remoteUserServices.GetUserProfile(name);
  116. }
  117. /// <summary>
  118. /// Get a user profile from the user server
  119. /// </summary>
  120. /// <param name="avatarID"></param>
  121. /// <returns>null if the request fails</returns>
  122. public UserProfileData GetUserProfile(UUID avatarID)
  123. {
  124. return m_remoteUserServices.GetUserProfile(avatarID);
  125. }
  126. public void ClearUserAgent(UUID avatarID)
  127. {
  128. m_remoteUserServices.ClearUserAgent(avatarID);
  129. }
  130. /// <summary>
  131. /// Retrieve the user information for the given master uuid.
  132. /// </summary>
  133. /// <param name="uuid"></param>
  134. /// <returns></returns>
  135. public UserProfileData SetupMasterUser(string firstName, string lastName)
  136. {
  137. return m_remoteUserServices.SetupMasterUser(firstName, lastName);
  138. }
  139. /// <summary>
  140. /// Retrieve the user information for the given master uuid.
  141. /// </summary>
  142. /// <param name="uuid"></param>
  143. /// <returns></returns>
  144. public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
  145. {
  146. return m_remoteUserServices.SetupMasterUser(firstName, lastName, password);
  147. }
  148. /// <summary>
  149. /// Retrieve the user information for the given master uuid.
  150. /// </summary>
  151. /// <param name="uuid"></param>
  152. /// <returns></returns>
  153. public UserProfileData SetupMasterUser(UUID uuid)
  154. {
  155. return m_remoteUserServices.SetupMasterUser(uuid);
  156. }
  157. public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
  158. {
  159. return m_remoteUserServices.AddUserProfile(firstName, lastName, pass, regX, regY);
  160. }
  161. public bool ResetUserPassword(string firstName, string lastName, string newPassword)
  162. {
  163. return m_remoteUserServices.ResetUserPassword(firstName, lastName, newPassword);
  164. }
  165. public bool UpdateUserProfile(UserProfileData userProfile)
  166. {
  167. return m_remoteUserServices.UpdateUserProfile(userProfile);
  168. }
  169. #region IUserServices Friend Methods
  170. /// <summary>
  171. /// Adds a new friend to the database for XUser
  172. /// </summary>
  173. /// <param name="friendlistowner">The agent that who's friends list is being added to</param>
  174. /// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
  175. /// <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>
  176. public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
  177. {
  178. m_remoteUserServices.AddNewUserFriend(friendlistowner, friend, perms);
  179. }
  180. /// <summary>
  181. /// Delete friend on friendlistowner's friendlist.
  182. /// </summary>
  183. /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
  184. /// <param name="friend">The Ex-friend agent</param>
  185. public void RemoveUserFriend(UUID friendlistowner, UUID friend)
  186. {
  187. m_remoteUserServices.RemoveUserFriend(friend, friend);
  188. }
  189. /// <summary>
  190. /// Update permissions for friend on friendlistowner's friendlist.
  191. /// </summary>
  192. /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
  193. /// <param name="friend">The agent that is getting or loosing permissions</param>
  194. /// <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>
  195. public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
  196. {
  197. m_remoteUserServices.UpdateUserFriendPerms(friendlistowner, friend, perms);
  198. }
  199. /// <summary>
  200. /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
  201. /// </summary>
  202. /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
  203. public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
  204. {
  205. return m_remoteUserServices.GetUserFriendList(friendlistowner);
  206. }
  207. #endregion
  208. /// Appearance
  209. public AvatarAppearance GetUserAppearance(UUID user)
  210. {
  211. return m_remoteUserServices.GetUserAppearance(user);
  212. }
  213. public void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
  214. {
  215. m_remoteUserServices.UpdateUserAppearance(user, appearance);
  216. }
  217. #region IMessagingService
  218. public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
  219. {
  220. return m_remoteUserServices.GetFriendRegionInfos(uuids);
  221. }
  222. #endregion
  223. }
  224. }