aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-04-22 18:15:43 +0000
committerJustin Clarke Casey2009-04-22 18:15:43 +0000
commit2c81e41c8a884ece643f3079349b033d03b6b774 (patch)
treebea7956ef00378f47fa420e82ffb665a137a9630 /OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
parentFrom: Alan Webb <alan_webb@us.ibm.com> (diff)
downloadopensim-SC_OLD-2c81e41c8a884ece643f3079349b033d03b6b774.zip
opensim-SC_OLD-2c81e41c8a884ece643f3079349b033d03b6b774.tar.gz
opensim-SC_OLD-2c81e41c8a884ece643f3079349b033d03b6b774.tar.bz2
opensim-SC_OLD-2c81e41c8a884ece643f3079349b033d03b6b774.tar.xz
* Fission OGS1UserServices into user service and OGS1 user data plugin components
* Make OGS1UserServices inherit from UserManagerBase * This allows grid mode regions to use the same user data plugin infrastructure as grid servers and standalone OpenSims
Diffstat (limited to 'OpenSim/Region/Communications/OGS1/OGS1UserServices.cs')
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserServices.cs762
1 files changed, 24 insertions, 738 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index 1836328..5f77107 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -35,229 +35,36 @@ using System.Xml.Serialization;
35using log4net; 35using log4net;
36using Nwc.XmlRpc; 36using Nwc.XmlRpc;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Data;
38using OpenSim.Framework; 39using OpenSim.Framework;
39using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Clients; 41using OpenSim.Framework.Communications.Clients;
41 42
42namespace OpenSim.Region.Communications.OGS1 43namespace OpenSim.Region.Communications.OGS1
43{ 44{
44 public class OGS1UserServices : IUserService, IAvatarService, IMessagingService 45 public class OGS1UserServices : UserManagerBase
45 { 46 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 48
48 protected CommunicationsManager m_commsManager; 49 protected CommunicationsManager m_commsManager;
49 50
50 public OGS1UserServices(CommunicationsManager commsManager) 51 public OGS1UserServices(CommunicationsManager commsManager)
52 : base(commsManager.InterServiceInventoryService)
51 { 53 {
52 m_commsManager = commsManager; 54 m_commsManager = commsManager;
53 } 55 }
54 56
55 public OGS1UserServices() 57 public override void ClearUserAgent(UUID avatarID)
56 {
57 }
58
59 public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data)
60 {
61 if (data.Contains("error_type"))
62 {
63 m_log.Warn("[GRID]: " +
64 "Error sent by user server when trying to get user profile: (" +
65 data["error_type"] +
66 "): " + data["error_desc"]);
67 return null;
68 }
69
70 UserProfileData userData = new UserProfileData();
71 userData.FirstName = (string)data["firstname"];
72 userData.SurName = (string)data["lastname"];
73 userData.ID = new UUID((string)data["uuid"]);
74 userData.Created = Convert.ToInt32(data["profile_created"]);
75 userData.UserInventoryURI = (string)data["server_inventory"];
76 userData.UserAssetURI = (string)data["server_asset"];
77 userData.FirstLifeAboutText = (string)data["profile_firstlife_about"];
78 userData.FirstLifeImage = new UUID((string)data["profile_firstlife_image"]);
79 userData.CanDoMask = Convert.ToUInt32((string)data["profile_can_do"]);
80 userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]);
81 userData.AboutText = (string)data["profile_about"];
82 userData.Image = new UUID((string)data["profile_image"]);
83 userData.LastLogin = Convert.ToInt32((string)data["profile_lastlogin"]);
84 userData.HomeRegion = Convert.ToUInt64((string)data["home_region"]);
85 if (data.Contains("home_region_id"))
86 userData.HomeRegionID = new UUID((string)data["home_region_id"]);
87 else
88 userData.HomeRegionID = UUID.Zero;
89 userData.HomeLocation =
90 new Vector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]),
91 (float)Convert.ToDecimal((string)data["home_coordinates_y"]),
92 (float)Convert.ToDecimal((string)data["home_coordinates_z"]));
93 userData.HomeLookAt =
94 new Vector3((float)Convert.ToDecimal((string)data["home_look_x"]),
95 (float)Convert.ToDecimal((string)data["home_look_y"]),
96 (float)Convert.ToDecimal((string)data["home_look_z"]));
97 if (data.Contains("user_flags"))
98 userData.UserFlags = Convert.ToInt32((string)data["user_flags"]);
99 if (data.Contains("god_level"))
100 userData.GodLevel = Convert.ToInt32((string)data["god_level"]);
101
102 if (data.Contains("custom_type"))
103 userData.CustomType = (string)data["custom_type"];
104 else
105 userData.CustomType = "";
106 if (userData.CustomType == null)
107 userData.CustomType = "";
108
109 if (data.Contains("partner"))
110 userData.Partner = new UUID((string)data["partner"]);
111 else
112 userData.Partner = UUID.Zero;
113
114 return userData;
115 }
116
117 public UserProfileData GetUserProfile(Uri uri)
118 { 58 {
119 WebRequest request = WebRequest.Create(uri); 59 // TODO: implement
120 60 // It may be possible to use the UserManagerBase implementation.
121 WebResponse webResponse = request.GetResponse();
122
123 XmlSerializer deserializer = new XmlSerializer(typeof(XmlRpcResponse));
124 XmlRpcResponse xmlRpcResponse = (XmlRpcResponse)deserializer.Deserialize(webResponse.GetResponseStream());
125
126 Hashtable respData = (Hashtable)xmlRpcResponse.Value;
127
128 return ConvertXMLRPCDataToUserProfile(respData);
129 }
130
131 public Uri GetUserUri(UserProfileData userProfile)
132 {
133 throw new NotImplementedException();
134 }
135
136 /// <summary>
137 /// Get a user agent from the user server
138 /// </summary>
139 /// <param name="avatarID"></param>
140 /// <returns>null if the request fails</returns>
141 public virtual UserAgentData GetAgentByUUID(UUID userId)
142 {
143 try
144 {
145 Hashtable param = new Hashtable();
146 param["avatar_uuid"] = userId.ToString();
147 IList parameters = new ArrayList();
148 parameters.Add(param);
149 XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters);
150
151 XmlRpcResponse resp = req.Send(GetUserServerURL(userId), 6000);
152 Hashtable respData = (Hashtable)resp.Value;
153 if (respData.Contains("error_type"))
154 {
155 //m_log.Warn("[GRID]: " +
156 // "Error sent by user server when trying to get agent: (" +
157 // (string) respData["error_type"] +
158 // "): " + (string)respData["error_desc"]);
159 return null;
160 }
161 UUID sessionid = UUID.Zero;
162
163 UserAgentData userAgent = new UserAgentData();
164 userAgent.Handle = Convert.ToUInt64((string)respData["handle"]);
165 UUID.TryParse((string)respData["sessionid"], out sessionid);
166 userAgent.SessionID = sessionid;
167
168 if ((string)respData["agent_online"] == "TRUE")
169 {
170 userAgent.AgentOnline = true;
171 }
172 else
173 {
174 userAgent.AgentOnline = false;
175 }
176
177 return userAgent;
178 }
179 catch (Exception e)
180 {
181 m_log.ErrorFormat(
182 "[OGS1 USER SERVICES]: Error when trying to fetch agent data by uuid from remote user server: {0}",
183 e);
184 }
185
186 return null;
187 }
188
189 public AvatarAppearance ConvertXMLRPCDataToAvatarAppearance(Hashtable data)
190 {
191 if (data != null)
192 {
193 if (data.Contains("error_type"))
194 {
195 m_log.Warn("[GRID]: " +
196 "Error sent by user server when trying to get user appearance: (" +
197 data["error_type"] +
198 "): " + data["error_desc"]);
199 return null;
200 }
201 else
202 {
203 return new AvatarAppearance(data);
204 }
205 }
206 else
207 {
208 m_log.Error("[GRID]: The avatar appearance is null, something bad happenend");
209 return null;
210 }
211 }
212
213 public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data)
214 {
215 List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
216 int pickercount = Convert.ToInt32((string)data["avcount"]);
217 UUID respqueryID = new UUID((string)data["queryid"]);
218 if (queryID == respqueryID)
219 {
220 for (int i = 0; i < pickercount; i++)
221 {
222 AvatarPickerAvatar apicker = new AvatarPickerAvatar();
223 UUID avatarID = new UUID((string)data["avatarid" + i.ToString()]);
224 string firstname = (string)data["firstname" + i.ToString()];
225 string lastname = (string)data["lastname" + i.ToString()];
226 apicker.AvatarID = avatarID;
227 apicker.firstName = firstname;
228 apicker.lastName = lastname;
229 pickerlist.Add(apicker);
230 }
231 }
232 else
233 {
234 m_log.Warn("[OGS1 USER SERVICES]: Got invalid queryID from userServer");
235 }
236 return pickerlist;
237 } 61 }
238 62
239 public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data) 63 protected virtual string GetUserServerURL(UUID userID)
240 { 64 {
241 List<FriendListItem> buddylist = new List<FriendListItem>(); 65 return m_commsManager.NetworkServersInfo.UserURL;
242 int buddycount = Convert.ToInt32((string)data["avcount"]);
243
244
245 for (int i = 0; i < buddycount; i++)
246 {
247 FriendListItem buddylistitem = new FriendListItem();
248
249 buddylistitem.FriendListOwner = new UUID((string)data["ownerID" + i.ToString()]);
250 buddylistitem.Friend = new UUID((string)data["friendID" + i.ToString()]);
251 buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]);
252 buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]);
253
254 buddylist.Add(buddylistitem);
255 }
256
257
258 return buddylist;
259 } 66 }
260 67
261 /// <summary> 68 /// <summary>
262 /// Logs off a user on the user server 69 /// Logs off a user on the user server
263 /// </summary> 70 /// </summary>
@@ -266,7 +73,7 @@ namespace OpenSim.Region.Communications.OGS1
266 /// <param name="regionhandle">regionhandle</param> 73 /// <param name="regionhandle">regionhandle</param>
267 /// <param name="position">final position</param> 74 /// <param name="position">final position</param>
268 /// <param name="lookat">final lookat</param> 75 /// <param name="lookat">final lookat</param>
269 public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) 76 public override void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
270 { 77 {
271 Hashtable param = new Hashtable(); 78 Hashtable param = new Hashtable();
272 param["avatar_uuid"] = userid.Guid.ToString(); 79 param["avatar_uuid"] = userid.Guid.ToString();
@@ -290,123 +97,15 @@ namespace OpenSim.Region.Communications.OGS1
290 catch (WebException) 97 catch (WebException)
291 { 98 {
292 m_log.Warn("[LOGOFF]: Unable to notify grid server of user logoff"); 99 m_log.Warn("[LOGOFF]: Unable to notify grid server of user logoff");
293 } 100 }
294 }
295
296 /// <summary>
297 /// Logs off a user on the user server (deprecated as of 2008-08-27)
298 /// </summary>
299 /// <param name="UserID">UUID of the user</param>
300 /// <param name="regionID">UUID of the Region</param>
301 /// <param name="regionhandle">regionhandle</param>
302 /// <param name="posx">final position x</param>
303 /// <param name="posy">final position y</param>
304 /// <param name="posz">final position z</param>
305 public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
306 {
307 LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3());
308 }
309
310 public virtual UserProfileData GetUserProfile(string firstName, string lastName)
311 {
312 return GetUserProfile(firstName + " " + lastName);
313 }
314
315 public virtual List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
316 {
317 List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
318 Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]");
319 try
320 {
321 Hashtable param = new Hashtable();
322 param["queryid"] = (string)queryID.ToString();
323 param["avquery"] = objAlphaNumericPattern.Replace(query, String.Empty);
324 IList parameters = new ArrayList();
325 parameters.Add(param);
326 XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters);
327 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
328 Hashtable respData = (Hashtable)resp.Value;
329 pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData);
330 }
331 catch (WebException e)
332 {
333 m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar Picker Response: " +
334 e.Message);
335 // Return Empty picker list (no results)
336 }
337 return pickerlist;
338 }
339
340 /// <summary>
341 /// Get a user profile from the user server
342 /// </summary>
343 /// <param name="avatarID"></param>
344 /// <returns>null if the request fails</returns>
345 public virtual UserProfileData GetUserProfile(string name)
346 {
347 try
348 {
349 Hashtable param = new Hashtable();
350 param["avatar_name"] = name;
351 IList parameters = new ArrayList();
352 parameters.Add(param);
353 XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters);
354 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
355 Hashtable respData = (Hashtable)resp.Value;
356
357 return ConvertXMLRPCDataToUserProfile(respData);
358 }
359 catch (WebException e)
360 {
361 m_log.ErrorFormat(
362 "[OGS1 USER SERVICES]: Error when trying to fetch profile data by name from remote user server: {0}",
363 e);
364 }
365
366 return null;
367 }
368
369 /// <summary>
370 /// Get a user profile from the user server
371 /// </summary>
372 /// <param name="avatarID"></param>
373 /// <returns>null if the request fails</returns>
374 public virtual UserProfileData GetUserProfile(UUID avatarID)
375 {
376 try
377 {
378 Hashtable param = new Hashtable();
379 param["avatar_uuid"] = avatarID.ToString();
380 IList parameters = new ArrayList();
381 parameters.Add(param);
382 XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters);
383 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
384 Hashtable respData = (Hashtable)resp.Value;
385
386 return ConvertXMLRPCDataToUserProfile(respData);
387 }
388 catch (Exception e)
389 {
390 m_log.ErrorFormat(
391 "[OGS1 USER SERVICES]: Error when trying to fetch profile data by uuid from remote user server: {0}",
392 e);
393 }
394
395 return null;
396 }
397
398
399 public virtual void ClearUserAgent(UUID avatarID)
400 {
401 // TODO: implement
402 } 101 }
403 102
404 /// <summary> 103 /// <summary>
405 /// Retrieve the user information for the given master uuid. 104 /// Retrieve the user information for the given master uuid.
406 /// </summary> 105 /// </summary>
407 /// <param name="uuid"></param> 106 /// <param name="uuid"></param>
408 /// <returns></returns> 107 /// <returns></returns>
409 public virtual UserProfileData SetupMasterUser(string firstName, string lastName) 108 public override UserProfileData SetupMasterUser(string firstName, string lastName)
410 { 109 {
411 return SetupMasterUser(firstName, lastName, String.Empty); 110 return SetupMasterUser(firstName, lastName, String.Empty);
412 } 111 }
@@ -416,7 +115,7 @@ namespace OpenSim.Region.Communications.OGS1
416 /// </summary> 115 /// </summary>
417 /// <param name="uuid"></param> 116 /// <param name="uuid"></param>
418 /// <returns></returns> 117 /// <returns></returns>
419 public virtual UserProfileData SetupMasterUser(string firstName, string lastName, string password) 118 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
420 { 119 {
421 UserProfileData profile = GetUserProfile(firstName, lastName); 120 UserProfileData profile = GetUserProfile(firstName, lastName);
422 return profile; 121 return profile;
@@ -427,7 +126,7 @@ namespace OpenSim.Region.Communications.OGS1
427 /// </summary> 126 /// </summary>
428 /// <param name="uuid"></param> 127 /// <param name="uuid"></param>
429 /// <returns></returns> 128 /// <returns></returns>
430 public virtual UserProfileData SetupMasterUser(UUID uuid) 129 public override UserProfileData SetupMasterUser(UUID uuid)
431 { 130 {
432 UserProfileData data = GetUserProfile(uuid); 131 UserProfileData data = GetUserProfile(uuid);
433 132
@@ -439,424 +138,11 @@ namespace OpenSim.Region.Communications.OGS1
439 138
440 return data; 139 return data;
441 } 140 }
442 141
443 public virtual UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) 142 public override bool VerifySession(UUID userID, UUID sessionID)
444 {
445 throw new Exception("The method or operation is not implemented.");
446 }
447
448 public virtual bool ResetUserPassword(string firstName, string lastName, string newPassword)
449 {
450 throw new Exception("The method or operation is not implemented.");
451 }
452
453 public virtual bool UpdateUserProfile(UserProfileData userProfile)
454 {
455 m_log.Debug("[OGS1 USER SERVICES]: Asking UserServer to update profile.");
456 Hashtable param = new Hashtable();
457 param["avatar_uuid"] = userProfile.ID.ToString();
458 //param["AllowPublish"] = userProfile.ToString();
459 param["FLImageID"] = userProfile.FirstLifeImage.ToString();
460 param["ImageID"] = userProfile.Image.ToString();
461 //param["MaturePublish"] = MaturePublish.ToString();
462 param["AboutText"] = userProfile.AboutText;
463 param["FLAboutText"] = userProfile.FirstLifeAboutText;
464 //param["ProfileURL"] = userProfile.ProfileURL.ToString();
465
466 param["home_region"] = userProfile.HomeRegion.ToString();
467 param["home_region_id"] = userProfile.HomeRegionID.ToString();
468
469 param["home_pos_x"] = userProfile.HomeLocationX.ToString();
470 param["home_pos_y"] = userProfile.HomeLocationY.ToString();
471 param["home_pos_z"] = userProfile.HomeLocationZ.ToString();
472 param["home_look_x"] = userProfile.HomeLookAtX.ToString();
473 param["home_look_y"] = userProfile.HomeLookAtY.ToString();
474 param["home_look_z"] = userProfile.HomeLookAtZ.ToString();
475 param["user_flags"] = userProfile.UserFlags.ToString();
476 param["god_level"] = userProfile.GodLevel.ToString();
477 param["custom_type"] = userProfile.CustomType.ToString();
478 param["partner"] = userProfile.Partner.ToString();
479
480 IList parameters = new ArrayList();
481 parameters.Add(param);
482
483 XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters);
484 XmlRpcResponse resp = req.Send(GetUserServerURL(userProfile.ID), 3000);
485 Hashtable respData = (Hashtable)resp.Value;
486 if (respData != null)
487 {
488 if (respData.Contains("returnString"))
489 {
490 if (((string)respData["returnString"]).ToUpper() != "TRUE")
491 {
492 m_log.Warn("[GRID]: Unable to update user profile, User Server Reported an issue");
493 return false;
494 }
495 }
496 else
497 {
498 m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
499 return false;
500 }
501 }
502 else
503 {
504 m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
505 return false;
506 }
507
508 return true;
509 }
510
511 #region IUserServices Friend Methods
512 /// <summary>
513 /// Adds a new friend to the database for XUser
514 /// </summary>
515 /// <param name="friendlistowner">The agent that who's friends list is being added to</param>
516 /// <param name="friend">The agent that being added to the friends list of the friends list owner</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>
518 public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
519 {
520 try
521 {
522 Hashtable param = new Hashtable();
523 param["ownerID"] = friendlistowner.Guid.ToString();
524 param["friendID"] = friend.Guid.ToString();
525 param["friendPerms"] = perms.ToString();
526 IList parameters = new ArrayList();
527 parameters.Add(param);
528
529 XmlRpcRequest req = new XmlRpcRequest("add_new_user_friend", parameters);
530 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
531 Hashtable respData = (Hashtable)resp.Value;
532 if (respData != null)
533 {
534 if (respData.Contains("returnString"))
535 {
536 if ((string)respData["returnString"] == "TRUE")
537 {
538
539 }
540 else
541 {
542 m_log.Warn("[GRID]: Unable to add new friend, User Server Reported an issue");
543 }
544 }
545 else
546 {
547 m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!");
548 }
549 }
550 else
551 {
552 m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!");
553
554 }
555 }
556 catch (WebException e)
557 {
558 m_log.Warn("[GRID]: Error when trying to AddNewUserFriend: " +
559 e.Message);
560
561 }
562
563 }
564
565 /// <summary>
566 /// Delete friend on friendlistowner's friendlist.
567 /// </summary>
568 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
569 /// <param name="friend">The Ex-friend agent</param>
570 public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend)
571 {
572 try
573 {
574 Hashtable param = new Hashtable();
575 param["ownerID"] = friendlistowner.Guid.ToString();
576 param["friendID"] = friend.Guid.ToString();
577
578 IList parameters = new ArrayList();
579 parameters.Add(param);
580
581 XmlRpcRequest req = new XmlRpcRequest("remove_user_friend", parameters);
582 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
583 Hashtable respData = (Hashtable)resp.Value;
584 if (respData != null)
585 {
586 if (respData.Contains("returnString"))
587 {
588 if ((string)respData["returnString"] == "TRUE")
589 {
590
591 }
592 else
593 {
594 m_log.Warn("[GRID]: Unable to remove friend, User Server Reported an issue");
595 }
596 }
597 else
598 {
599 m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!");
600 }
601 }
602 else
603 {
604 m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!");
605
606 }
607 }
608 catch (WebException e)
609 {
610 m_log.Warn("[GRID]: Error when trying to RemoveUserFriend: " +
611 e.Message);
612
613 }
614 }
615
616 /// <summary>
617 /// Update permissions for friend on friendlistowner's friendlist.
618 /// </summary>
619 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
620 /// <param name="friend">The agent that is getting or loosing permissions</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>
622 public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
623 {
624 try
625 {
626 Hashtable param = new Hashtable();
627 param["ownerID"] = friendlistowner.Guid.ToString();
628 param["friendID"] = friend.Guid.ToString();
629 param["friendPerms"] = perms.ToString();
630 IList parameters = new ArrayList();
631 parameters.Add(param);
632
633 XmlRpcRequest req = new XmlRpcRequest("update_user_friend_perms", parameters);
634 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
635 Hashtable respData = (Hashtable)resp.Value;
636 if (respData != null)
637 {
638 if (respData.Contains("returnString"))
639 {
640 if ((string)respData["returnString"] == "TRUE")
641 {
642
643 }
644 else
645 {
646 m_log.Warn("[GRID]: Unable to update_user_friend_perms, User Server Reported an issue");
647 }
648 }
649 else
650 {
651 m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!");
652 }
653 }
654 else
655 {
656 m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!");
657
658 }
659 }
660 catch (WebException e)
661 {
662 m_log.Warn("[GRID]: Error when trying to update_user_friend_perms: " +
663 e.Message);
664 }
665 }
666 /// <summary>
667 /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
668 /// </summary>
669 /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
670 public virtual List<FriendListItem> GetUserFriendList(UUID friendlistowner)
671 {
672 List<FriendListItem> buddylist = new List<FriendListItem>();
673
674 try
675 {
676 Hashtable param = new Hashtable();
677 param["ownerID"] = friendlistowner.Guid.ToString();
678
679 IList parameters = new ArrayList();
680 parameters.Add(param);
681 XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters);
682 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000);
683 Hashtable respData = (Hashtable)resp.Value;
684
685 if (respData != null && respData.Contains("avcount"))
686 {
687 buddylist = ConvertXMLRPCDataToFriendListItemList(respData);
688 }
689
690 }
691 catch (WebException e)
692 {
693 m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar's friends list: " +
694 e.Message);
695 // Return Empty list (no friends)
696 }
697 return buddylist;
698 }
699
700 public virtual Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
701 {
702 Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>();
703
704 // ask MessageServer about the current on-/offline status and regions the friends are in
705 ArrayList parameters = new ArrayList();
706 Hashtable map = new Hashtable();
707
708 ArrayList list = new ArrayList();
709 foreach (UUID uuid in uuids)
710 {
711 list.Add(uuid.ToString());
712 list.Add(uuid.ToString());
713 }
714 map["uuids"] = list;
715
716 map["recv_key"] = m_commsManager.NetworkServersInfo.UserRecvKey;
717 map["send_key"] = m_commsManager.NetworkServersInfo.UserSendKey;
718
719 parameters.Add(map);
720
721 try
722 {
723 XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters);
724 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.MessagingURL, 8000);
725 Hashtable respData = resp != null ? (Hashtable)resp.Value : null;
726
727 if (respData == null || respData.ContainsKey("faultMessage"))
728 {
729 m_log.WarnFormat("[OGS1 USER SERVICES]: Contacting MessagingServer about user-regions resulted in error: {0}",
730 respData == null ? "<unknown error>" : respData["faultMessage"]);
731 }
732 else if (!respData.ContainsKey("count"))
733 {
734 m_log.WarnFormat("[OGS1 USER SERVICES]: Wrong format in response for MessagingServer request get_presence_info_bulk: missing 'count' field");
735 }
736 else
737 {
738 int count = (int)respData["count"];
739 m_log.DebugFormat("[OGS1 USER SERVICES]: Request returned {0} results.", count);
740 for (int i = 0; i < count; ++i)
741 {
742 if (respData.ContainsKey("uuid_" + i) && respData.ContainsKey("isOnline_" + i) && respData.ContainsKey("regionHandle_" + i))
743 {
744 UUID uuid;
745 if (UUID.TryParse((string)respData["uuid_" + i], out uuid))
746 {
747 FriendRegionInfo info = new FriendRegionInfo();
748 info.isOnline = (bool)respData["isOnline_" + i];
749 if (info.isOnline)
750 {
751 // TODO remove this after the next protocol update (say, r7800?)
752 info.regionHandle = Convert.ToUInt64(respData["regionHandle_" + i]);
753
754 // accept missing id
755 if (respData.ContainsKey("regionID_" + i))
756 UUID.TryParse((string)respData["regionID_" + i], out info.regionID);
757 }
758
759 result.Add(uuid, info);
760 }
761 }
762 else
763 {
764 m_log.WarnFormat("[OGS1 USER SERVICES]: Response to get_presence_info_bulk contained an error in entry {0}", i);
765 }
766 }
767 }
768 }
769 catch (WebException e)
770 {
771 m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch friend infos: {0}", e.Message);
772 }
773
774 m_log.DebugFormat("[OGS1 USER SERVICES]: Returning {0} entries", result.Count);
775 return result;
776 }
777
778 #endregion
779
780 /// Appearance
781 public virtual AvatarAppearance GetUserAppearance(UUID user)
782 {
783 AvatarAppearance appearance = null;
784
785 try
786 {
787 Hashtable param = new Hashtable();
788 param["owner"] = user.ToString();
789
790 IList parameters = new ArrayList();
791 parameters.Add(param);
792 XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters);
793 XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000);
794 Hashtable respData = (Hashtable)resp.Value;
795
796 return ConvertXMLRPCDataToAvatarAppearance(respData);
797 }
798 catch (WebException e)
799 {
800 m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch appearance for avatar {0}, {1}", user, e.Message);
801 }
802
803 return appearance;
804 }
805
806 public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
807 {
808 try
809 {
810 Hashtable param = appearance.ToHashTable();
811 param["owner"] = user.ToString();
812
813 IList parameters = new ArrayList();
814 parameters.Add(param);
815 XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters);
816 XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000);
817 Hashtable respData = (Hashtable)resp.Value;
818
819 if (respData != null)
820 {
821 if (respData.Contains("returnString"))
822 {
823 if ((string)respData["returnString"] == "TRUE")
824 {
825
826 }
827 else
828 {
829 m_log.Warn("[GRID]: Unable to update_user_appearance, User Server Reported an issue");
830 }
831 }
832 else
833 {
834 m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!");
835 }
836 }
837 else
838 {
839 m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!");
840 }
841 }
842 catch (WebException e)
843 {
844 m_log.Warn("[OGS1 USER SERVICES]: Error when trying to update Avatar's appearance: " +
845 e.Message);
846 // Return Empty list (no friends)
847 }
848 }
849
850 public virtual bool VerifySession(UUID userID, UUID sessionID)
851 { 143 {
852 m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID); 144 m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID);
853 return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID); 145 return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID);
854 } 146 }
855
856 protected virtual string GetUserServerURL(UUID userID)
857 {
858 return m_commsManager.NetworkServersInfo.UserURL;
859 }
860
861 } 147 }
862} 148} \ No newline at end of file