aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Framework/UserProfileManager.cs
diff options
context:
space:
mode:
authorgareth2007-03-22 10:11:15 +0000
committergareth2007-03-22 10:11:15 +0000
commit7daa3955bc3a1918e40962851f9e8d38597a245e (patch)
treebee3e1372a7eed0c1b220a8a49f7bee7d29a6b91 /OpenSim.Framework/UserProfileManager.cs
parentLoad XML for neighbourinfo from grid (diff)
downloadopensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.zip
opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.gz
opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.bz2
opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.xz
brought zircon branch into trunk
Diffstat (limited to '')
-rw-r--r--OpenSim.Framework/UserProfileManager.cs223
1 files changed, 223 insertions, 0 deletions
diff --git a/OpenSim.Framework/UserProfileManager.cs b/OpenSim.Framework/UserProfileManager.cs
new file mode 100644
index 0000000..f77ca4c
--- /dev/null
+++ b/OpenSim.Framework/UserProfileManager.cs
@@ -0,0 +1,223 @@
1using System;
2using System.Collections.Generic;
3using System.Collections;
4using System.Text;
5using System.Text.RegularExpressions;
6using System.Xml;
7using libsecondlife;
8using Nwc.XmlRpc;
9using OpenSim.Framework.Sims;
10using OpenSim.Framework.Inventory;
11using OpenSim.Framework.Utilities;
12
13namespace OpenSim.Framework.User
14{
15 public class UserProfileManager : UserProfileManagerBase
16 {
17 public string GridURL;
18 public string GridSendKey;
19 public string GridRecvKey;
20 public string DefaultStartupMsg;
21
22 public UserProfileManager()
23 {
24
25 }
26
27 public void SetKeys(string sendKey, string recvKey, string url, string message)
28 {
29 GridRecvKey = recvKey;
30 GridSendKey = sendKey;
31 GridURL = url;
32 DefaultStartupMsg = message;
33 }
34
35 public virtual string ParseXMLRPC(string requestBody)
36 {
37 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
38
39 Hashtable requestData = (Hashtable)request.Params[0];
40 switch (request.MethodName)
41 {
42 case "login_to_simulator":
43 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
44 bool GoodLogin = false;
45 string firstname = "";
46 string lastname = "";
47 string passwd = "";
48
49 if (GoodXML)
50 {
51 firstname = (string)requestData["first"];
52 lastname = (string)requestData["last"];
53 passwd = (string)requestData["passwd"];
54 GoodLogin = AuthenticateUser(firstname, lastname, passwd);
55 }
56
57
58 if (!(GoodXML && GoodLogin))
59 {
60 XmlRpcResponse LoginErrorResp = new XmlRpcResponse();
61 Hashtable ErrorRespData = new Hashtable();
62 ErrorRespData["reason"] = "key";
63 ErrorRespData["message"] = "Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct";
64 ErrorRespData["login"] = "false";
65 LoginErrorResp.Value = ErrorRespData;
66 return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginErrorResp), " encoding=\"utf-16\"", ""));
67 }
68
69 UserProfile TheUser = GetProfileByName(firstname, lastname);
70
71 if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null)))
72 {
73 XmlRpcResponse PresenceErrorResp = new XmlRpcResponse();
74 Hashtable PresenceErrorRespData = new Hashtable();
75 PresenceErrorRespData["reason"] = "presence";
76 PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner";
77 PresenceErrorRespData["login"] = "false";
78 PresenceErrorResp.Value = PresenceErrorRespData;
79 return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""));
80
81 }
82
83 try
84 {
85 LLUUID AgentID = TheUser.UUID;
86 TheUser.InitSessionData();
87 // SimProfile SimInfo = new SimProfile();
88 // SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
89
90 XmlRpcResponse LoginGoodResp = new XmlRpcResponse();
91 Hashtable LoginGoodData = new Hashtable();
92
93 Hashtable GlobalT = new Hashtable();
94 GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
95 GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
96 GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
97 ArrayList GlobalTextures = new ArrayList();
98 GlobalTextures.Add(GlobalT);
99
100 Hashtable LoginFlagsHash = new Hashtable();
101 LoginFlagsHash["daylight_savings"] = "N";
102 LoginFlagsHash["stipend_since_login"] = "N";
103 LoginFlagsHash["gendered"] = "Y";
104 LoginFlagsHash["ever_logged_in"] = "Y";
105 ArrayList LoginFlags = new ArrayList();
106 LoginFlags.Add(LoginFlagsHash);
107
108 Hashtable uiconfig = new Hashtable();
109 uiconfig["allow_first_life"] = "Y";
110 ArrayList ui_config = new ArrayList();
111 ui_config.Add(uiconfig);
112
113 Hashtable ClassifiedCategoriesHash = new Hashtable();
114 ClassifiedCategoriesHash["category_name"] = "bla bla";
115 ClassifiedCategoriesHash["category_id"] = (Int32)1;
116 ArrayList ClassifiedCategories = new ArrayList();
117 ClassifiedCategories.Add(ClassifiedCategoriesHash);
118
119 ArrayList AgentInventory = new ArrayList();
120 foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values)
121 {
122 Hashtable TempHash = new Hashtable();
123 TempHash["name"] = InvFolder.FolderName;
124 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
125 TempHash["version"] = (Int32)InvFolder.Version;
126 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
127 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
128 AgentInventory.Add(TempHash);
129 }
130
131 Hashtable InventoryRootHash = new Hashtable();
132 InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated();
133 ArrayList InventoryRoot = new ArrayList();
134 InventoryRoot.Add(InventoryRootHash);
135
136 Hashtable InitialOutfitHash = new Hashtable();
137 InitialOutfitHash["folder_name"] = "Nightclub Female";
138 InitialOutfitHash["gender"] = "female";
139 ArrayList InitialOutfit = new ArrayList();
140 InitialOutfit.Add(InitialOutfitHash);
141
142 uint circode = (uint)(Util.RandomClass.Next());
143 //TheUser.AddSimCircuit(circode, SimInfo.UUID);
144
145 LoginGoodData["last_name"] = "\"" + TheUser.firstname + "\"";
146 LoginGoodData["ui-config"] = ui_config;
147 LoginGoodData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString();
148 LoginGoodData["login-flags"] = LoginFlags;
149 LoginGoodData["global-textures"] = GlobalTextures;
150 LoginGoodData["classified_categories"] = ClassifiedCategories;
151 LoginGoodData["event_categories"] = new ArrayList();
152 LoginGoodData["inventory-skeleton"] = AgentInventory;
153 LoginGoodData["inventory-skel-lib"] = new ArrayList();
154 LoginGoodData["inventory-root"] = InventoryRoot;
155 LoginGoodData["event_notifications"] = new ArrayList();
156 LoginGoodData["gestures"] = new ArrayList();
157 LoginGoodData["inventory-lib-owner"] = new ArrayList();
158 LoginGoodData["initial-outfit"] = InitialOutfit;
159 LoginGoodData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
160 LoginGoodData["start_location"] = "last";
161 LoginGoodData["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}";
162 LoginGoodData["message"] = DefaultStartupMsg;
163 LoginGoodData["first_name"] = "\"" + firstname + "\"";
164 LoginGoodData["circuit_code"] = (Int32)circode;
165 LoginGoodData["sim_port"] = 9000; //(Int32)SimInfo.sim_port;
166 LoginGoodData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated();
167 LoginGoodData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n";
168 LoginGoodData["agent_id"] = AgentID.ToStringHyphenated();
169 LoginGoodData["region_y"] = (Int32) 996 * 256; // (Int32)SimInfo.RegionLocY * 256;
170 LoginGoodData["region_x"] = (Int32) 997 * 256; //SimInfo.RegionLocX * 256;
171 LoginGoodData["seed_capability"] = null;
172 LoginGoodData["agent_access"] = "M";
173 LoginGoodData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated();
174 LoginGoodData["login"] = "true";
175
176 this.CustomiseResponse(ref LoginGoodData, TheUser);
177 LoginGoodResp.Value = LoginGoodData;
178 //TheUser.SendDataToSim(SimInfo);
179 return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginGoodResp), "utf-16", "utf-8"));
180
181 }
182 catch (Exception E)
183 {
184 Console.WriteLine(E.ToString());
185 }
186
187 break;
188 }
189
190 return "";
191 }
192
193 public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser)
194 {
195 //default method set up to act as ogs user server
196 SimProfile SimInfo = new SimProfile();
197 //get siminfo from grid server
198 SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
199 uint circode = (uint)response["circuit_code"];
200 theUser.AddSimCircuit(circode, SimInfo.UUID);
201 response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}";
202 response["sim_ip"] = SimInfo.sim_ip.ToString();
203 response["sim_port"] = (Int32)SimInfo.sim_port;
204 response["region_y"] = (Int32) SimInfo.RegionLocY * 256;
205 response["region_x"] = (Int32) SimInfo.RegionLocX * 256;
206
207 //default is ogs user server, so let the sim know about the user via a XmlRpcRequest
208 Console.WriteLine(SimInfo.caps_url);
209 Hashtable SimParams = new Hashtable();
210 SimParams["session_id"] = theUser.CurrentSessionID.ToString();
211 SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString();
212 SimParams["firstname"] = theUser.firstname;
213 SimParams["lastname"] = theUser.lastname;
214 SimParams["agent_id"] = theUser.UUID.ToString();
215 SimParams["circuit_code"] = (Int32)theUser.Circuits[SimInfo.UUID];
216 ArrayList SendParams = new ArrayList();
217 SendParams.Add(SimParams);
218
219 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
220 XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000);
221 }
222 }
223}