aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGUserServices.cs221
1 files changed, 149 insertions, 72 deletions
diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs
index ef08421..05ae5a9 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs
@@ -31,7 +31,10 @@ using System.Collections.Generic;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Framework.Communications.Clients;
34using OpenSim.Region.Communications.OGS1; 36using OpenSim.Region.Communications.OGS1;
37using OpenSim.Region.Communications.Local;
35 38
36namespace OpenSim.Region.Communications.Hypergrid 39namespace OpenSim.Region.Communications.Hypergrid
37{ 40{
@@ -40,32 +43,30 @@ namespace OpenSim.Region.Communications.Hypergrid
40 /// so it always fails for foreign users. 43 /// so it always fails for foreign users.
41 /// Later it needs to talk with the foreign users' user servers. 44 /// Later it needs to talk with the foreign users' user servers.
42 /// </summary> 45 /// </summary>
43 public class HGUserServices : IUserService, IAvatarService, IMessagingService 46 public class HGUserServices : OGS1UserServices
44 { 47 {
45 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 49
47 //private HGCommunicationsGridMode m_parent; 50 //private CommunicationsManager m_parent;
48 private OGS1UserServices m_remoteUserServices; 51 //private OGS1UserServices m_remoteUserServices;
52 private LocalUserServices m_localUserServices;
49 53
50 public HGUserServices(HGCommunicationsGridMode parent) 54 // Constructor called when running in grid mode
55 public HGUserServices(CommunicationsManager parent)
56 : base(parent)
51 { 57 {
52 //m_parent = parent;
53 m_remoteUserServices = new OGS1UserServices(parent);
54 } 58 }
55 59
56 public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data) 60 // Constructor called when running in standalone
61 public HGUserServices(LocalUserServices local)
57 { 62 {
58 return m_remoteUserServices.ConvertXMLRPCDataToUserProfile(data); 63 m_localUserServices = local;
59 } 64 }
60 65
61 public UserProfileData GetUserProfile(Uri uri) 66 // Called for standalone mode only, to set up the communications manager
67 public void SetCommunicationsManager(CommunicationsManager parent)
62 { 68 {
63 throw new System.NotImplementedException(); 69 m_commsManager = parent;
64 }
65
66 public Uri GetUserUri(UserProfileData userProfile)
67 {
68 throw new NotImplementedException();
69 } 70 }
70 71
71 /// <summary> 72 /// <summary>
@@ -73,25 +74,15 @@ namespace OpenSim.Region.Communications.Hypergrid
73 /// </summary> 74 /// </summary>
74 /// <param name="avatarID"></param> 75 /// <param name="avatarID"></param>
75 /// <returns>null if the request fails</returns> 76 /// <returns>null if the request fails</returns>
76 public UserAgentData GetAgentByUUID(UUID userId) 77 public override UserAgentData GetAgentByUUID(UUID userId)
77 { 78 {
78 return m_remoteUserServices.GetAgentByUUID(userId); 79 string url = string.Empty;
79 } 80 if ((m_localUserServices != null) && !IsForeignUser(userId, out url))
80 81 return m_localUserServices.GetAgentByUUID(userId);
81 public AvatarAppearance ConvertXMLRPCDataToAvatarAppearance(Hashtable data)
82 {
83 return m_remoteUserServices.ConvertXMLRPCDataToAvatarAppearance(data);
84 }
85 82
86 public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data) 83 return base.GetAgentByUUID(userId);
87 {
88 return m_remoteUserServices.ConvertXMLRPCDataToAvatarPickerList(queryID, data);
89 } 84 }
90 85
91 public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
92 {
93 return m_remoteUserServices.ConvertXMLRPCDataToFriendListItemList(data);
94 }
95 86
96 /// <summary> 87 /// <summary>
97 /// Logs off a user on the user server 88 /// Logs off a user on the user server
@@ -101,9 +92,13 @@ namespace OpenSim.Region.Communications.Hypergrid
101 /// <param name="regionhandle">regionhandle</param> 92 /// <param name="regionhandle">regionhandle</param>
102 /// <param name="position">final position</param> 93 /// <param name="position">final position</param>
103 /// <param name="lookat">final lookat</param> 94 /// <param name="lookat">final lookat</param>
104 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) 95 public override void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
105 { 96 {
106 m_remoteUserServices.LogOffUser(userid, regionid, regionhandle, position, lookat); 97 string url = string.Empty;
98 if ((m_localUserServices != null) && !IsForeignUser(userid, out url))
99 m_localUserServices.LogOffUser(userid, regionid, regionhandle, position, lookat);
100 else
101 base.LogOffUser(userid, regionid, regionhandle, position, lookat);
107 } 102 }
108 103
109 /// <summary> 104 /// <summary>
@@ -115,19 +110,29 @@ namespace OpenSim.Region.Communications.Hypergrid
115 /// <param name="posx">final position x</param> 110 /// <param name="posx">final position x</param>
116 /// <param name="posy">final position y</param> 111 /// <param name="posy">final position y</param>
117 /// <param name="posz">final position z</param> 112 /// <param name="posz">final position z</param>
118 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) 113 public override void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
119 { 114 {
120 m_remoteUserServices.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); 115 string url = string.Empty;
116 if ((m_localUserServices != null) && !IsForeignUser(userid, out url))
117 m_localUserServices.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
118 else
119 base.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
121 } 120 }
122 121
123 public UserProfileData GetUserProfile(string firstName, string lastName) 122 public override UserProfileData GetUserProfile(string firstName, string lastName)
124 { 123 {
124 if (m_localUserServices != null)
125 return m_localUserServices.GetUserProfile(firstName, lastName);
126
125 return GetUserProfile(firstName + " " + lastName); 127 return GetUserProfile(firstName + " " + lastName);
126 } 128 }
127 129
128 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) 130 public override List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
129 { 131 {
130 return m_remoteUserServices.GenerateAgentPickerRequestResponse(queryID, query); 132 if (m_localUserServices != null)
133 return m_localUserServices.GenerateAgentPickerRequestResponse(queryID, query);
134
135 return base.GenerateAgentPickerRequestResponse(queryID, query);
131 } 136 }
132 137
133 /// <summary> 138 /// <summary>
@@ -135,9 +140,11 @@ namespace OpenSim.Region.Communications.Hypergrid
135 /// </summary> 140 /// </summary>
136 /// <param name="avatarID"></param> 141 /// <param name="avatarID"></param>
137 /// <returns>null if the request fails</returns> 142 /// <returns>null if the request fails</returns>
138 public UserProfileData GetUserProfile(string name) 143 public override UserProfileData GetUserProfile(string name)
139 { 144 {
140 return m_remoteUserServices.GetUserProfile(name); 145 // This doesn't exist in LocalUserServices
146
147 return base.GetUserProfile(name);
141 } 148 }
142 149
143 /// <summary> 150 /// <summary>
@@ -145,14 +152,24 @@ namespace OpenSim.Region.Communications.Hypergrid
145 /// </summary> 152 /// </summary>
146 /// <param name="avatarID"></param> 153 /// <param name="avatarID"></param>
147 /// <returns>null if the request fails</returns> 154 /// <returns>null if the request fails</returns>
148 public UserProfileData GetUserProfile(UUID avatarID) 155 public override UserProfileData GetUserProfile(UUID avatarID)
149 { 156 {
150 return m_remoteUserServices.GetUserProfile(avatarID); 157 string url = string.Empty;
158 // Unfortunately we can't query for foreigners here,
159 // because we'll end up in an infinite loop...
160 //if ((m_localUserServices != null) && (!IsForeignUser(avatarID, out url)))
161 if (m_localUserServices != null)
162 return m_localUserServices.GetUserProfile(avatarID);
163
164 return base.GetUserProfile(avatarID);
151 } 165 }
152 166
153 public void ClearUserAgent(UUID avatarID) 167 public override void ClearUserAgent(UUID avatarID)
154 { 168 {
155 m_remoteUserServices.ClearUserAgent(avatarID); 169 if (m_localUserServices != null)
170 m_localUserServices.ClearUserAgent(avatarID);
171 else
172 base.ClearUserAgent(avatarID);
156 } 173 }
157 174
158 /// <summary> 175 /// <summary>
@@ -160,9 +177,12 @@ namespace OpenSim.Region.Communications.Hypergrid
160 /// </summary> 177 /// </summary>
161 /// <param name="uuid"></param> 178 /// <param name="uuid"></param>
162 /// <returns></returns> 179 /// <returns></returns>
163 public UserProfileData SetupMasterUser(string firstName, string lastName) 180 public override UserProfileData SetupMasterUser(string firstName, string lastName)
164 { 181 {
165 return m_remoteUserServices.SetupMasterUser(firstName, lastName); 182 if (m_localUserServices != null)
183 return m_localUserServices.SetupMasterUser(firstName, lastName);
184
185 return base.SetupMasterUser(firstName, lastName);
166 } 186 }
167 187
168 /// <summary> 188 /// <summary>
@@ -170,9 +190,12 @@ namespace OpenSim.Region.Communications.Hypergrid
170 /// </summary> 190 /// </summary>
171 /// <param name="uuid"></param> 191 /// <param name="uuid"></param>
172 /// <returns></returns> 192 /// <returns></returns>
173 public UserProfileData SetupMasterUser(string firstName, string lastName, string password) 193 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
174 { 194 {
175 return m_remoteUserServices.SetupMasterUser(firstName, lastName, password); 195 if (m_localUserServices != null)
196 return m_localUserServices.SetupMasterUser(firstName, lastName, password);
197
198 return base.SetupMasterUser(firstName, lastName, password);
176 } 199 }
177 200
178 /// <summary> 201 /// <summary>
@@ -180,36 +203,47 @@ namespace OpenSim.Region.Communications.Hypergrid
180 /// </summary> 203 /// </summary>
181 /// <param name="uuid"></param> 204 /// <param name="uuid"></param>
182 /// <returns></returns> 205 /// <returns></returns>
183 public UserProfileData SetupMasterUser(UUID uuid) 206 public override UserProfileData SetupMasterUser(UUID uuid)
184 { 207 {
185 return m_remoteUserServices.SetupMasterUser(uuid); 208 if (m_localUserServices != null)
209 return m_localUserServices.SetupMasterUser(uuid);
210
211 return base.SetupMasterUser(uuid);
186 } 212 }
187 213
188 public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) 214 public override bool ResetUserPassword(string firstName, string lastName, string newPassword)
189 { 215 {
190 return m_remoteUserServices.AddUserProfile(firstName, lastName, pass, regX, regY); 216 if (m_localUserServices != null)
217 return m_localUserServices.ResetUserPassword(firstName, lastName, newPassword);
218 else
219 return base.ResetUserPassword(firstName, lastName, newPassword);
191 } 220 }
192
193 public bool ResetUserPassword(string firstName, string lastName, string newPassword)
194 {
195 return m_remoteUserServices.ResetUserPassword(firstName, lastName, newPassword);
196 }
197 221
198 public bool UpdateUserProfile(UserProfileData userProfile) 222 public override bool UpdateUserProfile(UserProfileData userProfile)
199 { 223 {
200 return m_remoteUserServices.UpdateUserProfile(userProfile); 224 string url = string.Empty;
225 if ((m_localUserServices != null) && (!IsForeignUser(userProfile.ID, out url)))
226 return m_localUserServices.UpdateUserProfile(userProfile);
227
228 return base.UpdateUserProfile(userProfile);
201 } 229 }
202 230
203 #region IUserServices Friend Methods 231 #region IUserServices Friend Methods
232
233 // NOTE: We're still not dealing with foreign user friends
234
204 /// <summary> 235 /// <summary>
205 /// Adds a new friend to the database for XUser 236 /// Adds a new friend to the database for XUser
206 /// </summary> 237 /// </summary>
207 /// <param name="friendlistowner">The agent that who's friends list is being added to</param> 238 /// <param name="friendlistowner">The agent that who's friends list is being added to</param>
208 /// <param name="friend">The agent that being added to the friends list of the friends list owner</param> 239 /// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
209 /// <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> 240 /// <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>
210 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) 241 public override void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
211 { 242 {
212 m_remoteUserServices.AddNewUserFriend(friendlistowner, friend, perms); 243 if (m_localUserServices != null)
244 m_localUserServices.AddNewUserFriend(friendlistowner, friend, perms);
245 else
246 base.AddNewUserFriend(friendlistowner, friend, perms);
213 } 247 }
214 248
215 /// <summary> 249 /// <summary>
@@ -217,9 +251,12 @@ namespace OpenSim.Region.Communications.Hypergrid
217 /// </summary> 251 /// </summary>
218 /// <param name="friendlistowner">The agent that who's friends list is being updated</param> 252 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
219 /// <param name="friend">The Ex-friend agent</param> 253 /// <param name="friend">The Ex-friend agent</param>
220 public void RemoveUserFriend(UUID friendlistowner, UUID friend) 254 public override void RemoveUserFriend(UUID friendlistowner, UUID friend)
221 { 255 {
222 m_remoteUserServices.RemoveUserFriend(friend, friend); 256 if (m_localUserServices != null)
257 m_localUserServices.RemoveUserFriend(friendlistowner, friend);
258 else
259 base.RemoveUserFriend(friend, friend);
223 } 260 }
224 261
225 /// <summary> 262 /// <summary>
@@ -228,39 +265,79 @@ namespace OpenSim.Region.Communications.Hypergrid
228 /// <param name="friendlistowner">The agent that who's friends list is being updated</param> 265 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
229 /// <param name="friend">The agent that is getting or loosing permissions</param> 266 /// <param name="friend">The agent that is getting or loosing permissions</param>
230 /// <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> 267 /// <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>
231 public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) 268 public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
232 { 269 {
233 m_remoteUserServices.UpdateUserFriendPerms(friendlistowner, friend, perms); 270 if (m_localUserServices != null)
271 m_localUserServices.UpdateUserFriendPerms(friendlistowner, friend, perms);
272 else
273 base.UpdateUserFriendPerms(friendlistowner, friend, perms);
234 } 274 }
235 /// <summary> 275 /// <summary>
236 /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner 276 /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
237 /// </summary> 277 /// </summary>
238 /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param> 278 /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
239 public List<FriendListItem> GetUserFriendList(UUID friendlistowner) 279 public override List<FriendListItem> GetUserFriendList(UUID friendlistowner)
240 { 280 {
241 return m_remoteUserServices.GetUserFriendList(friendlistowner); 281 if (m_localUserServices != null)
282 return m_localUserServices.GetUserFriendList(friendlistowner);
283
284 return base.GetUserFriendList(friendlistowner);
242 } 285 }
243 286
244 #endregion 287 #endregion
245 288
246 /// Appearance 289 /// Appearance
247 public AvatarAppearance GetUserAppearance(UUID user) 290 public override AvatarAppearance GetUserAppearance(UUID user)
248 { 291 {
249 return m_remoteUserServices.GetUserAppearance(user); 292 string url = string.Empty;
293 if ((m_localUserServices != null) && (!IsForeignUser(user, out url)))
294 return m_localUserServices.GetUserAppearance(user);
295 else
296 return base.GetUserAppearance(user);
250 } 297 }
251 298
252 public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) 299 public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
253 { 300 {
254 m_remoteUserServices.UpdateUserAppearance(user, appearance); 301 string url = string.Empty;
302 if ((m_localUserServices != null) && (!IsForeignUser(user, out url)))
303 m_localUserServices.UpdateUserAppearance(user, appearance);
304 else
305 base.UpdateUserAppearance(user, appearance);
255 } 306 }
256 307
257 #region IMessagingService 308 #region IMessagingService
258 309
259 public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) 310 public override Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
260 { 311 {
261 return m_remoteUserServices.GetFriendRegionInfos(uuids); 312 if (m_localUserServices != null)
313 return m_localUserServices.GetFriendRegionInfos(uuids);
314
315 return base.GetFriendRegionInfos(uuids);
262 } 316 }
263 #endregion 317 #endregion
264 318
319 protected override string GetUserServerURL(UUID userID)
320 {
321 string serverURL = string.Empty;
322 if (IsForeignUser(userID, out serverURL))
323 return serverURL;
324
325 return m_commsManager.NetworkServersInfo.UserURL;
326 }
327
328 private bool IsForeignUser(UUID userID, out string userServerURL)
329 {
330 userServerURL = string.Empty;
331 CachedUserInfo uinfo = m_commsManager.UserProfileCacheService.GetUserDetails(userID);
332 if (uinfo != null)
333 {
334 if (!HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile))
335 {
336 userServerURL = ((ForeignUserProfileData)(uinfo.UserProfile)).UserServerURI;
337 return true;
338 }
339 }
340 return false;
341 }
265 } 342 }
266} 343}