aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs')
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs760
1 files changed, 760 insertions, 0 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs
new file mode 100644
index 0000000..f543451
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs
@@ -0,0 +1,760 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using System.Xml.Serialization;
35using log4net;
36using Nwc.XmlRpc;
37using OpenMetaverse;
38using OpenSim.Data;
39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Clients;
42
43namespace OpenSim.Region.Communications.OGS1
44{
45 public class OGS1UserDataPlugin : IUserDataPlugin
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 protected CommunicationsManager m_commsManager;
50
51 public OGS1UserDataPlugin(CommunicationsManager commsManager)
52 {
53 m_log.DebugFormat("[OGS1 USER SERVICES]: {0} initialized", Name);
54 m_commsManager = commsManager;
55 }
56
57 public string Version { get { return "0.1"; } }
58 public string Name { get { return "Open Grid Services 1 (OGS1) User Data Plugin"; } }
59 public void Initialise() {}
60
61 public void Initialise(string connect) {}
62
63 public void Dispose() {}
64
65 // Arguably the presence of these means that IUserDataPlugin could be fissioned
66 public UserAgentData GetUserAgent(string name) { return null; }
67 public UserAgentData GetAgentByName(string name) { return null; }
68 public UserAgentData GetAgentByName(string fname, string lname) { return null; }
69 public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {}
70 public void AddNewUserProfile(UserProfileData user) {}
71 public void AddNewUserAgent(UserAgentData agent) {}
72 public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; }
73 public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; }
74 public void ResetAttachments(UUID userID) {}
75 public void LogoutUsers(UUID regionID) {}
76
77 public UserProfileData GetUserByUri(Uri uri)
78 {
79 WebRequest request = WebRequest.Create(uri);
80
81 WebResponse webResponse = request.GetResponse();
82
83 XmlSerializer deserializer = new XmlSerializer(typeof(XmlRpcResponse));
84 XmlRpcResponse xmlRpcResponse = (XmlRpcResponse)deserializer.Deserialize(webResponse.GetResponseStream());
85
86 Hashtable respData = (Hashtable)xmlRpcResponse.Value;
87
88 return ConvertXMLRPCDataToUserProfile(respData);
89 }
90
91// public Uri GetUserUri(UserProfileData userProfile)
92// {
93// throw new NotImplementedException();
94// }
95
96 public virtual UserAgentData GetAgentByUUID(UUID userId)
97 {
98 try
99 {
100 Hashtable param = new Hashtable();
101 param["avatar_uuid"] = userId.ToString();
102 IList parameters = new ArrayList();
103 parameters.Add(param);
104 XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters);
105
106 XmlRpcResponse resp = req.Send(GetUserServerURL(userId), 6000);
107 Hashtable respData = (Hashtable)resp.Value;
108 if (respData.Contains("error_type"))
109 {
110 //m_log.Warn("[GRID]: " +
111 // "Error sent by user server when trying to get agent: (" +
112 // (string) respData["error_type"] +
113 // "): " + (string)respData["error_desc"]);
114 return null;
115 }
116 UUID sessionid = UUID.Zero;
117
118 UserAgentData userAgent = new UserAgentData();
119 userAgent.Handle = Convert.ToUInt64((string)respData["handle"]);
120 UUID.TryParse((string)respData["sessionid"], out sessionid);
121 userAgent.SessionID = sessionid;
122
123 if ((string)respData["agent_online"] == "TRUE")
124 {
125 userAgent.AgentOnline = true;
126 }
127 else
128 {
129 userAgent.AgentOnline = false;
130 }
131
132 return userAgent;
133 }
134 catch (Exception e)
135 {
136 m_log.ErrorFormat(
137 "[OGS1 USER SERVICES]: Error when trying to fetch agent data by uuid from remote user server: {0}",
138 e);
139 }
140
141 return null;
142 }
143
144 public virtual UserProfileData GetUserByName(string firstName, string lastName)
145 {
146 return GetUserProfile(firstName + " " + lastName);
147 }
148
149 public virtual List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
150 {
151 List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
152 Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]");
153 try
154 {
155 Hashtable param = new Hashtable();
156 param["queryid"] = (string)queryID.ToString();
157 param["avquery"] = objAlphaNumericPattern.Replace(query, String.Empty);
158 IList parameters = new ArrayList();
159 parameters.Add(param);
160 XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters);
161 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
162 Hashtable respData = (Hashtable)resp.Value;
163 pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData);
164 }
165 catch (WebException e)
166 {
167 m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar Picker Response: " +
168 e.Message);
169 // Return Empty picker list (no results)
170 }
171 return pickerlist;
172 }
173
174 /// <summary>
175 /// Get a user profile from the user server
176 /// </summary>
177 /// <param name="avatarID"></param>
178 /// <returns>null if the request fails</returns>
179 protected virtual UserProfileData GetUserProfile(string name)
180 {
181 try
182 {
183 Hashtable param = new Hashtable();
184 param["avatar_name"] = name;
185 IList parameters = new ArrayList();
186 parameters.Add(param);
187 XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters);
188 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
189 Hashtable respData = (Hashtable)resp.Value;
190
191 return ConvertXMLRPCDataToUserProfile(respData);
192 }
193 catch (WebException e)
194 {
195 m_log.ErrorFormat(
196 "[OGS1 USER SERVICES]: Error when trying to fetch profile data by name from remote user server: {0}",
197 e);
198 }
199
200 return null;
201 }
202
203 /// <summary>
204 /// Get a user profile from the user server
205 /// </summary>
206 /// <param name="avatarID"></param>
207 /// <returns>null if the request fails</returns>
208 public virtual UserProfileData GetUserByUUID(UUID avatarID)
209 {
210 try
211 {
212 Hashtable param = new Hashtable();
213 param["avatar_uuid"] = avatarID.ToString();
214 IList parameters = new ArrayList();
215 parameters.Add(param);
216 XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters);
217 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
218 Hashtable respData = (Hashtable)resp.Value;
219
220 return ConvertXMLRPCDataToUserProfile(respData);
221 }
222 catch (Exception e)
223 {
224 m_log.ErrorFormat(
225 "[OGS1 USER SERVICES]: Error when trying to fetch profile data by uuid from remote user server: {0}",
226 e);
227 }
228
229 return null;
230 }
231
232 public virtual bool UpdateUserProfile(UserProfileData userProfile)
233 {
234 m_log.Debug("[OGS1 USER SERVICES]: Asking UserServer to update profile.");
235
236 Hashtable param = new Hashtable();
237 param["avatar_uuid"] = userProfile.ID.ToString();
238 //param["AllowPublish"] = userProfile.ToString();
239 param["FLImageID"] = userProfile.FirstLifeImage.ToString();
240 param["ImageID"] = userProfile.Image.ToString();
241 //param["MaturePublish"] = MaturePublish.ToString();
242 param["AboutText"] = userProfile.AboutText;
243 param["FLAboutText"] = userProfile.FirstLifeAboutText;
244 //param["ProfileURL"] = userProfile.ProfileURL.ToString();
245
246 param["home_region"] = userProfile.HomeRegion.ToString();
247 param["home_region_id"] = userProfile.HomeRegionID.ToString();
248
249 param["home_pos_x"] = userProfile.HomeLocationX.ToString();
250 param["home_pos_y"] = userProfile.HomeLocationY.ToString();
251 param["home_pos_z"] = userProfile.HomeLocationZ.ToString();
252 param["home_look_x"] = userProfile.HomeLookAtX.ToString();
253 param["home_look_y"] = userProfile.HomeLookAtY.ToString();
254 param["home_look_z"] = userProfile.HomeLookAtZ.ToString();
255 param["user_flags"] = userProfile.UserFlags.ToString();
256 param["god_level"] = userProfile.GodLevel.ToString();
257 param["custom_type"] = userProfile.CustomType.ToString();
258 param["partner"] = userProfile.Partner.ToString();
259
260 IList parameters = new ArrayList();
261 parameters.Add(param);
262
263 XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters);
264 XmlRpcResponse resp = req.Send(GetUserServerURL(userProfile.ID), 3000);
265 Hashtable respData = (Hashtable)resp.Value;
266 if (respData != null)
267 {
268 if (respData.Contains("returnString"))
269 {
270 if (((string)respData["returnString"]).ToUpper() != "TRUE")
271 {
272 m_log.Warn("[GRID]: Unable to update user profile, User Server Reported an issue");
273 return false;
274 }
275 }
276 else
277 {
278 m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
279 return false;
280 }
281 }
282 else
283 {
284 m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
285 return false;
286 }
287
288 return true;
289 }
290
291 /// <summary>
292 /// Adds a new friend to the database for XUser
293 /// </summary>
294 /// <param name="friendlistowner">The agent that who's friends list is being added to</param>
295 /// <param name="friend">The agent that being added to the friends list of the friends list owner</param>
296 /// <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>
297 public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
298 {
299 try
300 {
301 Hashtable param = new Hashtable();
302 param["ownerID"] = friendlistowner.Guid.ToString();
303 param["friendID"] = friend.Guid.ToString();
304 param["friendPerms"] = perms.ToString();
305 IList parameters = new ArrayList();
306 parameters.Add(param);
307
308 XmlRpcRequest req = new XmlRpcRequest("add_new_user_friend", parameters);
309 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
310 Hashtable respData = (Hashtable)resp.Value;
311 if (respData != null)
312 {
313 if (respData.Contains("returnString"))
314 {
315 if ((string)respData["returnString"] == "TRUE")
316 {
317
318 }
319 else
320 {
321 m_log.Warn("[GRID]: Unable to add new friend, User Server Reported an issue");
322 }
323 }
324 else
325 {
326 m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!");
327 }
328 }
329 else
330 {
331 m_log.Warn("[GRID]: Unable to add new friend, UserServer didn't understand me!");
332
333 }
334 }
335 catch (WebException e)
336 {
337 m_log.Warn("[GRID]: Error when trying to AddNewUserFriend: " +
338 e.Message);
339
340 }
341 }
342
343 /// <summary>
344 /// Delete friend on friendlistowner's friendlist.
345 /// </summary>
346 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
347 /// <param name="friend">The Ex-friend agent</param>
348 public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend)
349 {
350 try
351 {
352 Hashtable param = new Hashtable();
353 param["ownerID"] = friendlistowner.Guid.ToString();
354 param["friendID"] = friend.Guid.ToString();
355
356 IList parameters = new ArrayList();
357 parameters.Add(param);
358
359 XmlRpcRequest req = new XmlRpcRequest("remove_user_friend", parameters);
360 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
361 Hashtable respData = (Hashtable)resp.Value;
362 if (respData != null)
363 {
364 if (respData.Contains("returnString"))
365 {
366 if ((string)respData["returnString"] == "TRUE")
367 {
368
369 }
370 else
371 {
372 m_log.Warn("[GRID]: Unable to remove friend, User Server Reported an issue");
373 }
374 }
375 else
376 {
377 m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!");
378 }
379 }
380 else
381 {
382 m_log.Warn("[GRID]: Unable to remove friend, UserServer didn't understand me!");
383
384 }
385 }
386 catch (WebException e)
387 {
388 m_log.Warn("[GRID]: Error when trying to RemoveUserFriend: " +
389 e.Message);
390
391 }
392 }
393
394 /// <summary>
395 /// Update permissions for friend on friendlistowner's friendlist.
396 /// </summary>
397 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
398 /// <param name="friend">The agent that is getting or loosing permissions</param>
399 /// <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>
400 public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
401 {
402 try
403 {
404 Hashtable param = new Hashtable();
405 param["ownerID"] = friendlistowner.Guid.ToString();
406 param["friendID"] = friend.Guid.ToString();
407 param["friendPerms"] = perms.ToString();
408 IList parameters = new ArrayList();
409 parameters.Add(param);
410
411 XmlRpcRequest req = new XmlRpcRequest("update_user_friend_perms", parameters);
412 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
413 Hashtable respData = (Hashtable)resp.Value;
414 if (respData != null)
415 {
416 if (respData.Contains("returnString"))
417 {
418 if ((string)respData["returnString"] == "TRUE")
419 {
420
421 }
422 else
423 {
424 m_log.Warn("[GRID]: Unable to update_user_friend_perms, User Server Reported an issue");
425 }
426 }
427 else
428 {
429 m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!");
430 }
431 }
432 else
433 {
434 m_log.Warn("[GRID]: Unable to update_user_friend_perms, UserServer didn't understand me!");
435
436 }
437 }
438 catch (WebException e)
439 {
440 m_log.Warn("[GRID]: Error when trying to update_user_friend_perms: " +
441 e.Message);
442 }
443 }
444 /// <summary>
445 /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
446 /// </summary>
447 /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
448 public virtual List<FriendListItem> GetUserFriendList(UUID friendlistowner)
449 {
450 List<FriendListItem> buddylist = new List<FriendListItem>();
451
452 try
453 {
454 Hashtable param = new Hashtable();
455 param["ownerID"] = friendlistowner.Guid.ToString();
456
457 IList parameters = new ArrayList();
458 parameters.Add(param);
459 XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters);
460 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000);
461 Hashtable respData = (Hashtable)resp.Value;
462
463 if (respData != null && respData.Contains("avcount"))
464 {
465 buddylist = ConvertXMLRPCDataToFriendListItemList(respData);
466 }
467
468 }
469 catch (WebException e)
470 {
471 m_log.Warn("[OGS1 USER SERVICES]: Error when trying to fetch Avatar's friends list: " +
472 e.Message);
473 // Return Empty list (no friends)
474 }
475 return buddylist;
476 }
477
478 public virtual Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
479 {
480 Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>();
481
482 // ask MessageServer about the current on-/offline status and regions the friends are in
483 ArrayList parameters = new ArrayList();
484 Hashtable map = new Hashtable();
485
486 ArrayList list = new ArrayList();
487 foreach (UUID uuid in uuids)
488 {
489 list.Add(uuid.ToString());
490 list.Add(uuid.ToString());
491 }
492 map["uuids"] = list;
493
494 map["recv_key"] = m_commsManager.NetworkServersInfo.UserRecvKey;
495 map["send_key"] = m_commsManager.NetworkServersInfo.UserSendKey;
496
497 parameters.Add(map);
498
499 try
500 {
501 XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters);
502 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.MessagingURL, 8000);
503 Hashtable respData = resp != null ? (Hashtable)resp.Value : null;
504
505 if (respData == null || respData.ContainsKey("faultMessage"))
506 {
507 m_log.WarnFormat("[OGS1 USER SERVICES]: Contacting MessagingServer about user-regions resulted in error: {0}",
508 respData == null ? "<unknown error>" : respData["faultMessage"]);
509 }
510 else if (!respData.ContainsKey("count"))
511 {
512 m_log.WarnFormat("[OGS1 USER SERVICES]: Wrong format in response for MessagingServer request get_presence_info_bulk: missing 'count' field");
513 }
514 else
515 {
516 int count = (int)respData["count"];
517 m_log.DebugFormat("[OGS1 USER SERVICES]: Request returned {0} results.", count);
518 for (int i = 0; i < count; ++i)
519 {
520 if (respData.ContainsKey("uuid_" + i) && respData.ContainsKey("isOnline_" + i) && respData.ContainsKey("regionHandle_" + i))
521 {
522 UUID uuid;
523 if (UUID.TryParse((string)respData["uuid_" + i], out uuid))
524 {
525 FriendRegionInfo info = new FriendRegionInfo();
526 info.isOnline = (bool)respData["isOnline_" + i];
527 if (info.isOnline)
528 {
529 // TODO remove this after the next protocol update (say, r7800?)
530 info.regionHandle = Convert.ToUInt64(respData["regionHandle_" + i]);
531
532 // accept missing id
533 if (respData.ContainsKey("regionID_" + i))
534 UUID.TryParse((string)respData["regionID_" + i], out info.regionID);
535 }
536
537 result.Add(uuid, info);
538 }
539 }
540 else
541 {
542 m_log.WarnFormat("[OGS1 USER SERVICES]: Response to get_presence_info_bulk contained an error in entry {0}", i);
543 }
544 }
545 }
546 }
547 catch (WebException e)
548 {
549 m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch friend infos: {0}", e.Message);
550 }
551
552 m_log.DebugFormat("[OGS1 USER SERVICES]: Returning {0} entries", result.Count);
553
554 return result;
555 }
556
557 public virtual AvatarAppearance GetUserAppearance(UUID user)
558 {
559 AvatarAppearance appearance = null;
560
561 try
562 {
563 Hashtable param = new Hashtable();
564 param["owner"] = user.ToString();
565
566 IList parameters = new ArrayList();
567 parameters.Add(param);
568 XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters);
569 XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000);
570 Hashtable respData = (Hashtable)resp.Value;
571
572 return ConvertXMLRPCDataToAvatarAppearance(respData);
573 }
574 catch (WebException e)
575 {
576 m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch appearance for avatar {0}, {1}", user, e.Message);
577 }
578
579 return appearance;
580 }
581
582 public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
583 {
584 try
585 {
586 Hashtable param = appearance.ToHashTable();
587 param["owner"] = user.ToString();
588
589 IList parameters = new ArrayList();
590 parameters.Add(param);
591 XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters);
592 XmlRpcResponse resp = req.Send(GetUserServerURL(user), 8000);
593 Hashtable respData = (Hashtable)resp.Value;
594
595 if (respData != null)
596 {
597 if (respData.Contains("returnString"))
598 {
599 if ((string)respData["returnString"] == "TRUE")
600 {
601
602 }
603 else
604 {
605 m_log.Warn("[GRID]: Unable to update_user_appearance, User Server Reported an issue");
606 }
607 }
608 else
609 {
610 m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!");
611 }
612 }
613 else
614 {
615 m_log.Warn("[GRID]: Unable to update_user_appearance, UserServer didn't understand me!");
616 }
617 }
618 catch (WebException e)
619 {
620 m_log.Warn("[OGS1 USER SERVICES]: Error when trying to update Avatar's appearance: " +
621 e.Message);
622 // Return Empty list (no friends)
623 }
624 }
625
626 protected virtual string GetUserServerURL(UUID userID)
627 {
628 return m_commsManager.NetworkServersInfo.UserURL;
629 }
630
631 protected UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data)
632 {
633 if (data.Contains("error_type"))
634 {
635 m_log.Warn("[GRID]: " +
636 "Error sent by user server when trying to get user profile: (" +
637 data["error_type"] +
638 "): " + data["error_desc"]);
639 return null;
640 }
641
642 UserProfileData userData = new UserProfileData();
643 userData.FirstName = (string)data["firstname"];
644 userData.SurName = (string)data["lastname"];
645 userData.ID = new UUID((string)data["uuid"]);
646 userData.Created = Convert.ToInt32(data["profile_created"]);
647 userData.UserInventoryURI = (string)data["server_inventory"];
648 userData.UserAssetURI = (string)data["server_asset"];
649 userData.FirstLifeAboutText = (string)data["profile_firstlife_about"];
650 userData.FirstLifeImage = new UUID((string)data["profile_firstlife_image"]);
651 userData.CanDoMask = Convert.ToUInt32((string)data["profile_can_do"]);
652 userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]);
653 userData.AboutText = (string)data["profile_about"];
654 userData.Image = new UUID((string)data["profile_image"]);
655 userData.LastLogin = Convert.ToInt32((string)data["profile_lastlogin"]);
656 userData.HomeRegion = Convert.ToUInt64((string)data["home_region"]);
657 if (data.Contains("home_region_id"))
658 userData.HomeRegionID = new UUID((string)data["home_region_id"]);
659 else
660 userData.HomeRegionID = UUID.Zero;
661 userData.HomeLocation =
662 new Vector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]),
663 (float)Convert.ToDecimal((string)data["home_coordinates_y"]),
664 (float)Convert.ToDecimal((string)data["home_coordinates_z"]));
665 userData.HomeLookAt =
666 new Vector3((float)Convert.ToDecimal((string)data["home_look_x"]),
667 (float)Convert.ToDecimal((string)data["home_look_y"]),
668 (float)Convert.ToDecimal((string)data["home_look_z"]));
669 if (data.Contains("user_flags"))
670 userData.UserFlags = Convert.ToInt32((string)data["user_flags"]);
671 if (data.Contains("god_level"))
672 userData.GodLevel = Convert.ToInt32((string)data["god_level"]);
673
674 if (data.Contains("custom_type"))
675 userData.CustomType = (string)data["custom_type"];
676 else
677 userData.CustomType = "";
678 if (userData.CustomType == null)
679 userData.CustomType = "";
680
681 if (data.Contains("partner"))
682 userData.Partner = new UUID((string)data["partner"]);
683 else
684 userData.Partner = UUID.Zero;
685
686 return userData;
687 }
688
689 protected AvatarAppearance ConvertXMLRPCDataToAvatarAppearance(Hashtable data)
690 {
691 if (data != null)
692 {
693 if (data.Contains("error_type"))
694 {
695 m_log.Warn("[GRID]: " +
696 "Error sent by user server when trying to get user appearance: (" +
697 data["error_type"] +
698 "): " + data["error_desc"]);
699 return null;
700 }
701 else
702 {
703 return new AvatarAppearance(data);
704 }
705 }
706 else
707 {
708 m_log.Error("[GRID]: The avatar appearance is null, something bad happenend");
709 return null;
710 }
711 }
712
713 protected List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data)
714 {
715 List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
716 int pickercount = Convert.ToInt32((string)data["avcount"]);
717 UUID respqueryID = new UUID((string)data["queryid"]);
718 if (queryID == respqueryID)
719 {
720 for (int i = 0; i < pickercount; i++)
721 {
722 AvatarPickerAvatar apicker = new AvatarPickerAvatar();
723 UUID avatarID = new UUID((string)data["avatarid" + i.ToString()]);
724 string firstname = (string)data["firstname" + i.ToString()];
725 string lastname = (string)data["lastname" + i.ToString()];
726 apicker.AvatarID = avatarID;
727 apicker.firstName = firstname;
728 apicker.lastName = lastname;
729 pickerlist.Add(apicker);
730 }
731 }
732 else
733 {
734 m_log.Warn("[OGS1 USER SERVICES]: Got invalid queryID from userServer");
735 }
736 return pickerlist;
737 }
738
739 protected List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
740 {
741 List<FriendListItem> buddylist = new List<FriendListItem>();
742 int buddycount = Convert.ToInt32((string)data["avcount"]);
743
744
745 for (int i = 0; i < buddycount; i++)
746 {
747 FriendListItem buddylistitem = new FriendListItem();
748
749 buddylistitem.FriendListOwner = new UUID((string)data["ownerID" + i.ToString()]);
750 buddylistitem.Friend = new UUID((string)data["friendID" + i.ToString()]);
751 buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]);
752 buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]);
753
754 buddylist.Add(buddylistitem);
755 }
756
757 return buddylist;
758 }
759 }
760}