aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/UserManager/LoginResponse.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/UserManager/LoginResponse.cs')
-rw-r--r--OpenSim/Framework/UserManager/LoginResponse.cs645
1 files changed, 645 insertions, 0 deletions
diff --git a/OpenSim/Framework/UserManager/LoginResponse.cs b/OpenSim/Framework/UserManager/LoginResponse.cs
new file mode 100644
index 0000000..5ca223f
--- /dev/null
+++ b/OpenSim/Framework/UserManager/LoginResponse.cs
@@ -0,0 +1,645 @@
1using System;
2using System.Text;
3using System.Text.RegularExpressions;
4using System.Threading;
5using System.Collections;
6using System.Xml;
7using libsecondlife;
8using OpenSim.Framework.Utilities;
9using OpenSim.Framework.Interfaces;
10using Nwc.XmlRpc;
11
12namespace OpenSim.Framework.UserManagement
13{
14
15 /// <summary>
16 /// A temp class to handle login response.
17 /// Should make use of UserProfileManager where possible.
18 /// </summary>
19
20 public class LoginResponse
21 {
22 private Hashtable loginFlagsHash;
23 private Hashtable globalTexturesHash;
24 private Hashtable loginError;
25 private Hashtable eventCategoriesHash;
26 private Hashtable uiConfigHash;
27 private Hashtable classifiedCategoriesHash;
28
29 private ArrayList loginFlags;
30 private ArrayList globalTextures;
31 private ArrayList eventCategories;
32 private ArrayList uiConfig;
33 private ArrayList classifiedCategories;
34 private ArrayList inventoryRoot;
35 private ArrayList initialOutfit;
36 private ArrayList agentInventory;
37
38 private UserInfo userProfile;
39
40 private LLUUID agentID;
41 private LLUUID sessionID;
42 private LLUUID secureSessionID;
43
44 // Login Flags
45 private string dst;
46 private string stipendSinceLogin;
47 private string gendered;
48 private string everLoggedIn;
49 private string login;
50 private int simPort;
51 private string simAddress;
52 private string agentAccess;
53 private Int32 circuitCode;
54 private uint regionX;
55 private uint regionY;
56
57 // Login
58 private string firstname;
59 private string lastname;
60
61 // Global Textures
62 private string sunTexture;
63 private string cloudTexture;
64 private string moonTexture;
65
66 // Error Flags
67 private string errorReason;
68 private string errorMessage;
69
70 // Response
71 private XmlRpcResponse xmlRpcResponse;
72 private XmlRpcResponse defaultXmlRpcResponse;
73
74 private string welcomeMessage;
75 private string startLocation;
76 private string allowFirstLife;
77 private string home;
78 private string seedCapability;
79 private string lookAt;
80
81 public LoginResponse()
82 {
83 this.loginFlags = new ArrayList();
84 this.globalTextures = new ArrayList();
85 this.eventCategories = new ArrayList();
86 this.uiConfig = new ArrayList();
87 this.classifiedCategories = new ArrayList();
88
89 this.loginError = new Hashtable();
90 this.eventCategoriesHash = new Hashtable();
91 this.classifiedCategoriesHash = new Hashtable();
92 this.uiConfigHash = new Hashtable();
93
94 this.defaultXmlRpcResponse = new XmlRpcResponse();
95 this.userProfile = new UserInfo();
96 this.inventoryRoot = new ArrayList();
97 this.initialOutfit = new ArrayList();
98 this.agentInventory = new ArrayList();
99
100 this.xmlRpcResponse = new XmlRpcResponse();
101 this.defaultXmlRpcResponse = new XmlRpcResponse();
102
103 this.SetDefaultValues();
104 } // LoginServer
105
106 public void SetDefaultValues()
107 {
108 this.DST = "N";
109 this.StipendSinceLogin = "N";
110 this.Gendered = "Y";
111 this.EverLoggedIn = "Y";
112 this.login = "false";
113 this.firstname = "Test";
114 this.lastname = "User";
115 this.agentAccess = "M";
116 this.startLocation = "last";
117 this.allowFirstLife = "Y";
118
119 this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
120 this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
121 this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
122
123 this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
124 this.ErrorReason = "key";
125 this.welcomeMessage = "Welcome to OpenSim!";
126 this.seedCapability = "";
127 this.home = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}";
128 this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
129 this.RegionX = (uint)255232;
130 this.RegionY = (uint)254976;
131
132 // Classifieds;
133 this.AddClassifiedCategory((Int32)1, "Shopping");
134 this.AddClassifiedCategory((Int32)2, "Land Rental");
135 this.AddClassifiedCategory((Int32)3, "Property Rental");
136 this.AddClassifiedCategory((Int32)4, "Special Attraction");
137 this.AddClassifiedCategory((Int32)5, "New Products");
138 this.AddClassifiedCategory((Int32)6, "Employment");
139 this.AddClassifiedCategory((Int32)7, "Wanted");
140 this.AddClassifiedCategory((Int32)8, "Service");
141 this.AddClassifiedCategory((Int32)9, "Personal");
142
143
144 this.SessionID = LLUUID.Random();
145 this.SecureSessionID = LLUUID.Random();
146 this.AgentID = LLUUID.Random();
147
148 Hashtable InitialOutfitHash = new Hashtable();
149 InitialOutfitHash["folder_name"] = "Nightclub Female";
150 InitialOutfitHash["gender"] = "female";
151 this.initialOutfit.Add(InitialOutfitHash);
152
153
154 } // SetDefaultValues
155
156 #region Login Failure Methods
157 public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
158 {
159 // Overwrite any default values;
160 this.xmlRpcResponse = new XmlRpcResponse();
161
162 // Ensure Login Failed message/reason;
163 this.ErrorMessage = message;
164 this.ErrorReason = reason;
165
166 this.loginError["reason"] = this.ErrorReason;
167 this.loginError["message"] = this.ErrorMessage;
168 this.loginError["login"] = login;
169 this.xmlRpcResponse.Value = this.loginError;
170 return (this.xmlRpcResponse);
171 } // GenerateResponse
172
173 public XmlRpcResponse CreateFailedResponse()
174 {
175 return (this.CreateLoginFailedResponse());
176 } // CreateErrorConnectingToGridResponse()
177
178 public XmlRpcResponse CreateLoginFailedResponse()
179 {
180 return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false"));
181 } // LoginFailedResponse
182
183 public XmlRpcResponse CreateAlreadyLoggedInResponse()
184 {
185 return (this.GenerateFailureResponse("presence", "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", "false"));
186 } // CreateAlreadyLoggedInResponse()
187
188 public XmlRpcResponse CreateDeadRegionResponse()
189 {
190 return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false"));
191 }
192
193 public XmlRpcResponse CreateGridErrorResponse()
194 {
195 return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false"));
196 }
197
198 #endregion
199
200 public XmlRpcResponse ToXmlRpcResponse()
201 {
202 try
203 {
204
205 Hashtable responseData = new Hashtable();
206
207 this.loginFlagsHash = new Hashtable();
208 this.loginFlagsHash["daylight_savings"] = this.DST;
209 this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
210 this.loginFlagsHash["gendered"] = this.Gendered;
211 this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
212 this.loginFlags.Add(this.loginFlagsHash);
213
214 responseData["first_name"] = this.Firstname;
215 responseData["last_name"] = this.Lastname;
216 responseData["agent_access"] = this.agentAccess;
217
218 this.globalTexturesHash = new Hashtable();
219 this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
220 this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
221 this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
222 this.globalTextures.Add(this.globalTexturesHash);
223 this.eventCategories.Add(this.eventCategoriesHash);
224
225 this.AddToUIConfig("allow_first_life", this.allowFirstLife);
226 this.uiConfig.Add(this.uiConfigHash);
227
228 responseData["sim_port"] =(Int32) this.SimPort;
229 responseData["sim_ip"] = this.SimAddress;
230 responseData["agent_id"] = this.AgentID.ToStringHyphenated();
231 responseData["session_id"] = this.SessionID.ToStringHyphenated();
232 responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated();
233 responseData["circuit_code"] = this.CircuitCode;
234 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
235 responseData["login-flags"] = this.loginFlags;
236 responseData["global-textures"] = this.globalTextures;
237 responseData["seed_capability"] = this.seedCapability;
238
239 responseData["event_categories"] = this.eventCategories;
240 responseData["event_notifications"] = new ArrayList(); // todo
241 responseData["classified_categories"] = this.classifiedCategories;
242 responseData["ui-config"] = this.uiConfig;
243
244 responseData["inventory-skeleton"] = this.agentInventory;
245 responseData["inventory-skel-lib"] = new ArrayList(); // todo
246 responseData["inventory-root"] = this.inventoryRoot;
247 responseData["gestures"] = new ArrayList(); // todo
248 responseData["inventory-lib-owner"] = new ArrayList(); // todo
249 responseData["initial-outfit"] = this.initialOutfit;
250 responseData["start_location"] = this.startLocation;
251 responseData["seed_capability"] = this.seedCapability;
252 responseData["home"] = this.home;
253 responseData["look_at"] = this.lookAt;
254 responseData["message"] = this.welcomeMessage;
255 responseData["region_x"] = (Int32)this.RegionX * 256;
256 responseData["region_y"] = (Int32)this.RegionY * 256;
257
258 //responseData["inventory-lib-root"] = new ArrayList(); // todo
259 //responseData["buddy-list"] = new ArrayList(); // todo
260
261 responseData["login"] = "true";
262 this.xmlRpcResponse.Value = responseData;
263
264 return (this.xmlRpcResponse);
265 }
266 catch (Exception e)
267 {
268 OpenSim.Framework.Console.MainLog.Instance.WriteLine(
269 OpenSim.Framework.Console.LogPriority.LOW,
270 "LoginResponse: Error creating XML-RPC Response: " + e.Message
271 );
272 return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
273
274 }
275
276 } // ToXmlRpcResponse
277
278 public void SetEventCategories(string category, string value)
279 {
280 this.eventCategoriesHash[category] = value;
281 } // SetEventCategories
282
283 public void AddToUIConfig(string itemName, string item)
284 {
285 this.uiConfigHash[itemName] = item;
286 } // SetUIConfig
287
288 public void AddClassifiedCategory(Int32 ID, string categoryName)
289 {
290 this.classifiedCategoriesHash["category_name"] = categoryName;
291 this.classifiedCategoriesHash["category_id"] = ID;
292 this.classifiedCategories.Add(this.classifiedCategoriesHash);
293 // this.classifiedCategoriesHash.Clear();
294 } // SetClassifiedCategory
295
296 #region Properties
297 public string Login
298 {
299 get
300 {
301 return this.login;
302 }
303 set
304 {
305 this.login = value;
306 }
307 } // Login
308
309 public string DST
310 {
311 get
312 {
313 return this.dst;
314 }
315 set
316 {
317 this.dst = value;
318 }
319 } // DST
320
321 public string StipendSinceLogin
322 {
323 get
324 {
325 return this.stipendSinceLogin;
326 }
327 set
328 {
329 this.stipendSinceLogin = value;
330 }
331 } // StipendSinceLogin
332
333 public string Gendered
334 {
335 get
336 {
337 return this.gendered;
338 }
339 set
340 {
341 this.gendered = value;
342 }
343 } // Gendered
344
345 public string EverLoggedIn
346 {
347 get
348 {
349 return this.everLoggedIn;
350 }
351 set
352 {
353 this.everLoggedIn = value;
354 }
355 } // EverLoggedIn
356
357 public int SimPort
358 {
359 get
360 {
361 return this.simPort;
362 }
363 set
364 {
365 this.simPort = value;
366 }
367 } // SimPort
368
369 public string SimAddress
370 {
371 get
372 {
373 return this.simAddress;
374 }
375 set
376 {
377 this.simAddress = value;
378 }
379 } // SimAddress
380
381 public LLUUID AgentID
382 {
383 get
384 {
385 return this.agentID;
386 }
387 set
388 {
389 this.agentID = value;
390 }
391 } // AgentID
392
393 public LLUUID SessionID
394 {
395 get
396 {
397 return this.sessionID;
398 }
399 set
400 {
401 this.sessionID = value;
402 }
403 } // SessionID
404
405 public LLUUID SecureSessionID
406 {
407 get
408 {
409 return this.secureSessionID;
410 }
411 set
412 {
413 this.secureSessionID = value;
414 }
415 } // SecureSessionID
416
417 public Int32 CircuitCode
418 {
419 get
420 {
421 return this.circuitCode;
422 }
423 set
424 {
425 this.circuitCode = value;
426 }
427 } // CircuitCode
428
429 public uint RegionX
430 {
431 get
432 {
433 return this.regionX;
434 }
435 set
436 {
437 this.regionX = value;
438 }
439 } // RegionX
440
441 public uint RegionY
442 {
443 get
444 {
445 return this.regionY;
446 }
447 set
448 {
449 this.regionY = value;
450 }
451 } // RegionY
452
453 public string SunTexture
454 {
455 get
456 {
457 return this.sunTexture;
458 }
459 set
460 {
461 this.sunTexture = value;
462 }
463 } // SunTexture
464
465 public string CloudTexture
466 {
467 get
468 {
469 return this.cloudTexture;
470 }
471 set
472 {
473 this.cloudTexture = value;
474 }
475 } // CloudTexture
476
477 public string MoonTexture
478 {
479 get
480 {
481 return this.moonTexture;
482 }
483 set
484 {
485 this.moonTexture = value;
486 }
487 } // MoonTexture
488
489 public string Firstname
490 {
491 get
492 {
493 return this.firstname;
494 }
495 set
496 {
497 this.firstname = value;
498 }
499 } // Firstname
500
501 public string Lastname
502 {
503 get
504 {
505 return this.lastname;
506 }
507 set
508 {
509 this.lastname = value;
510 }
511 } // Lastname
512
513 public string AgentAccess
514 {
515 get
516 {
517 return this.agentAccess;
518 }
519 set
520 {
521 this.agentAccess = value;
522 }
523 }
524
525 public string StartLocation
526 {
527 get
528 {
529 return this.startLocation;
530 }
531 set
532 {
533 this.startLocation = value;
534 }
535 } // StartLocation
536
537 public string LookAt
538 {
539 get
540 {
541 return this.lookAt;
542 }
543 set
544 {
545 this.lookAt = value;
546 }
547 }
548
549 public string SeedCapability
550 {
551 get
552 {
553 return this.seedCapability;
554 }
555 set
556 {
557 this.seedCapability = value;
558 }
559 } // SeedCapability
560
561 public string ErrorReason
562 {
563 get
564 {
565 return this.errorReason;
566 }
567 set
568 {
569 this.errorReason = value;
570 }
571 } // ErrorReason
572
573 public string ErrorMessage
574 {
575 get
576 {
577 return this.errorMessage;
578 }
579 set
580 {
581 this.errorMessage = value;
582 }
583 } // ErrorMessage
584
585 public ArrayList InventoryRoot
586 {
587 get
588 {
589 return this.inventoryRoot;
590 }
591 set
592 {
593 this.inventoryRoot = value;
594 }
595 }
596
597 public ArrayList InventorySkeleton
598 {
599 get
600 {
601 return this.agentInventory;
602 }
603 set
604 {
605 this.agentInventory = value;
606 }
607 }
608
609 public string Home
610 {
611 get
612 {
613 return this.home;
614 }
615 set
616 {
617 this.home = value;
618 }
619 }
620
621 public string Message
622 {
623 get
624 {
625 return this.welcomeMessage;
626 }
627 set
628 {
629 this.welcomeMessage = value;
630 }
631 }
632 #endregion
633
634
635 public class UserInfo
636 {
637 public string firstname;
638 public string lastname;
639 public ulong homeregionhandle;
640 public LLVector3 homepos;
641 public LLVector3 homelookat;
642 }
643 }
644}
645