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