aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserServices.cs105
1 files changed, 105 insertions, 0 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
new file mode 100644
index 0000000..2bbaf9d
--- /dev/null
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -0,0 +1,105 @@
1using System;
2using System.Collections;
3using libsecondlife;
4using Nwc.XmlRpc;
5using OpenSim.Framework.Communications;
6using OpenSim.Framework.Data;
7
8namespace OpenSim.Region.Communications.OGS1
9{
10 public class OGS1UserServices :IUserServices
11 {
12 CommunicationsOGS1 m_parent;
13 public OGS1UserServices(CommunicationsOGS1 parent)
14 {
15 m_parent = parent;
16 }
17
18 public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data)
19 {
20 if (data.Contains("error_type"))
21 {
22 Console.WriteLine("Error sent by user server when trying to get user profile: (" + data["error_type"] + "): " + data["error_desc"]);
23 return null;
24 }
25
26 UserProfileData userData = new UserProfileData();
27 userData.username = (string)data["firstname"];
28 userData.surname = (string)data["lastname"];
29 userData.UUID = new LLUUID((string)data["uuid"]);
30 userData.userInventoryURI = (string)data["server_inventory"];
31 userData.userAssetURI = (string)data["server_asset"];
32 userData.profileFirstText = (string)data["profile_firstlife_about"];
33 userData.profileFirstImage = new LLUUID((string)data["profile_firstlife_image"]);
34 userData.profileCanDoMask = Convert.ToUInt32((string)data["profile_can_do"]);
35 userData.profileWantDoMask = Convert.ToUInt32(data["profile_want_do"]);
36 userData.profileImage = new LLUUID((string)data["profile_image"]);
37 userData.lastLogin = Convert.ToInt32((string)data["profile_lastlogin"]);
38 userData.homeRegion = Convert.ToUInt64((string)data["home_region"]);
39 userData.homeLocation = new LLVector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]), (float)Convert.ToDecimal((string)data["home_coordinates_y"]), (float)Convert.ToDecimal((string)data["home_coordinates_z"]));
40 userData.homeLookAt = new LLVector3((float)Convert.ToDecimal((string)data["home_look_x"]), (float)Convert.ToDecimal((string)data["home_look_y"]), (float)Convert.ToDecimal((string)data["home_look_z"]));
41
42 return userData;
43 }
44 public UserProfileData GetUserProfile(string firstName, string lastName)
45 {
46 return GetUserProfile(firstName + " " + lastName);
47 }
48 public UserProfileData GetUserProfile(string name)
49 {
50 //try
51 //{
52 Hashtable param = new Hashtable();
53 param["avatar_name"] = name;
54 IList parameters = new ArrayList();
55 parameters.Add(param);
56 XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters);
57 XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000);
58 Hashtable respData = (Hashtable)resp.Value;
59
60 return ConvertXMLRPCDataToUserProfile(respData);
61 //}
62 //catch (Exception e)
63 //{
64 // Console.WriteLine("Error when trying to fetch profile data by name from remote user server: " + e.Message);
65 //}
66 //return null;
67 }
68 public UserProfileData GetUserProfile(LLUUID avatarID)
69 {
70 try
71 {
72
73 Hashtable param = new Hashtable();
74 param["avatar_uuid"] = avatarID.ToString();
75 IList parameters = new ArrayList();
76 parameters.Add(param);
77 XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters);
78 XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000);
79 Hashtable respData = (Hashtable)resp.Value;
80
81 return ConvertXMLRPCDataToUserProfile(respData);
82 }
83 catch (Exception e)
84 {
85 Console.WriteLine("Error when trying to fetch profile data by uuid from remote user server: " + e.Message);
86 }
87 return null;
88 }
89
90 public UserProfileData SetupMasterUser(string firstName, string lastName)
91 {
92 return SetupMasterUser(firstName, lastName, "");
93 }
94
95 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
96 {
97 UserProfileData profile = GetUserProfile(firstName, lastName);
98 if (profile == null)
99 {
100 Console.WriteLine("Unknown Master User. Grid Mode: No clue what I should do. Probably would choose the grid owner UUID when that is implemented");
101 }
102 return null;
103 }
104 }
105}