diff options
Diffstat (limited to 'OpenSim/Framework/Communications/Services/LoginResponse.cs')
-rw-r--r-- | OpenSim/Framework/Communications/Services/LoginResponse.cs | 812 |
1 files changed, 812 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs new file mode 100644 index 0000000..82515e0 --- /dev/null +++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs | |||
@@ -0,0 +1,812 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using Nwc.XmlRpc; | ||
34 | using OpenMetaverse; | ||
35 | using OpenMetaverse.StructuredData; | ||
36 | |||
37 | namespace OpenSim.Framework.Communications.Services | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// A temp class to handle login response. | ||
41 | /// Should make use of UserProfileManager where possible. | ||
42 | /// </summary> | ||
43 | public class LoginResponse | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | private Hashtable loginFlagsHash; | ||
48 | private Hashtable globalTexturesHash; | ||
49 | private Hashtable loginError; | ||
50 | private Hashtable uiConfigHash; | ||
51 | |||
52 | private ArrayList loginFlags; | ||
53 | private ArrayList globalTextures; | ||
54 | private ArrayList eventCategories; | ||
55 | private ArrayList uiConfig; | ||
56 | private ArrayList classifiedCategories; | ||
57 | private ArrayList inventoryRoot; | ||
58 | private ArrayList initialOutfit; | ||
59 | private ArrayList agentInventory; | ||
60 | private ArrayList inventoryLibraryOwner; | ||
61 | private ArrayList inventoryLibRoot; | ||
62 | private ArrayList inventoryLibrary; | ||
63 | private ArrayList activeGestures; | ||
64 | |||
65 | private UserInfo userProfile; | ||
66 | |||
67 | private UUID agentID; | ||
68 | private UUID sessionID; | ||
69 | private UUID secureSessionID; | ||
70 | |||
71 | // Login Flags | ||
72 | private string dst; | ||
73 | private string stipendSinceLogin; | ||
74 | private string gendered; | ||
75 | private string everLoggedIn; | ||
76 | private string login; | ||
77 | private uint simPort; | ||
78 | private uint simHttpPort; | ||
79 | private string simAddress; | ||
80 | private string agentAccess; | ||
81 | private Int32 circuitCode; | ||
82 | private uint regionX; | ||
83 | private uint regionY; | ||
84 | |||
85 | // Login | ||
86 | private string firstname; | ||
87 | private string lastname; | ||
88 | |||
89 | // Global Textures | ||
90 | private string sunTexture; | ||
91 | private string cloudTexture; | ||
92 | private string moonTexture; | ||
93 | |||
94 | // Error Flags | ||
95 | private string errorReason; | ||
96 | private string errorMessage; | ||
97 | |||
98 | // Response | ||
99 | private XmlRpcResponse xmlRpcResponse; | ||
100 | // private XmlRpcResponse defaultXmlRpcResponse; | ||
101 | |||
102 | private string welcomeMessage; | ||
103 | private string startLocation; | ||
104 | private string allowFirstLife; | ||
105 | private string home; | ||
106 | private string seedCapability; | ||
107 | private string lookAt; | ||
108 | |||
109 | private BuddyList m_buddyList = null; | ||
110 | |||
111 | public LoginResponse() | ||
112 | { | ||
113 | loginFlags = new ArrayList(); | ||
114 | globalTextures = new ArrayList(); | ||
115 | eventCategories = new ArrayList(); | ||
116 | uiConfig = new ArrayList(); | ||
117 | classifiedCategories = new ArrayList(); | ||
118 | |||
119 | loginError = new Hashtable(); | ||
120 | uiConfigHash = new Hashtable(); | ||
121 | |||
122 | // defaultXmlRpcResponse = new XmlRpcResponse(); | ||
123 | userProfile = new UserInfo(); | ||
124 | inventoryRoot = new ArrayList(); | ||
125 | initialOutfit = new ArrayList(); | ||
126 | agentInventory = new ArrayList(); | ||
127 | inventoryLibrary = new ArrayList(); | ||
128 | inventoryLibraryOwner = new ArrayList(); | ||
129 | activeGestures = new ArrayList(); | ||
130 | |||
131 | xmlRpcResponse = new XmlRpcResponse(); | ||
132 | // defaultXmlRpcResponse = new XmlRpcResponse(); | ||
133 | |||
134 | SetDefaultValues(); | ||
135 | } | ||
136 | |||
137 | private void SetDefaultValues() | ||
138 | { | ||
139 | DST = "N"; | ||
140 | StipendSinceLogin = "N"; | ||
141 | Gendered = "Y"; | ||
142 | EverLoggedIn = "Y"; | ||
143 | login = "false"; | ||
144 | firstname = "Test"; | ||
145 | lastname = "User"; | ||
146 | agentAccess = "M"; | ||
147 | startLocation = "last"; | ||
148 | allowFirstLife = "Y"; | ||
149 | |||
150 | SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
151 | CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
152 | MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
153 | |||
154 | ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; | ||
155 | ErrorReason = "key"; | ||
156 | welcomeMessage = "Welcome to OpenSim!"; | ||
157 | seedCapability = String.Empty; | ||
158 | home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + | ||
159 | userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + | ||
160 | userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + | ||
161 | userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; | ||
162 | lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; | ||
163 | RegionX = (uint) 255232; | ||
164 | RegionY = (uint) 254976; | ||
165 | |||
166 | // Classifieds; | ||
167 | AddClassifiedCategory((Int32) 1, "Shopping"); | ||
168 | AddClassifiedCategory((Int32) 2, "Land Rental"); | ||
169 | AddClassifiedCategory((Int32) 3, "Property Rental"); | ||
170 | AddClassifiedCategory((Int32) 4, "Special Attraction"); | ||
171 | AddClassifiedCategory((Int32) 5, "New Products"); | ||
172 | AddClassifiedCategory((Int32) 6, "Employment"); | ||
173 | AddClassifiedCategory((Int32) 7, "Wanted"); | ||
174 | AddClassifiedCategory((Int32) 8, "Service"); | ||
175 | AddClassifiedCategory((Int32) 9, "Personal"); | ||
176 | |||
177 | SessionID = UUID.Random(); | ||
178 | SecureSessionID = UUID.Random(); | ||
179 | AgentID = UUID.Random(); | ||
180 | |||
181 | Hashtable InitialOutfitHash = new Hashtable(); | ||
182 | InitialOutfitHash["folder_name"] = "Nightclub Female"; | ||
183 | InitialOutfitHash["gender"] = "female"; | ||
184 | initialOutfit.Add(InitialOutfitHash); | ||
185 | } | ||
186 | |||
187 | #region Login Failure Methods | ||
188 | |||
189 | public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) | ||
190 | { | ||
191 | // Overwrite any default values; | ||
192 | xmlRpcResponse = new XmlRpcResponse(); | ||
193 | |||
194 | // Ensure Login Failed message/reason; | ||
195 | ErrorMessage = message; | ||
196 | ErrorReason = reason; | ||
197 | |||
198 | loginError["reason"] = ErrorReason; | ||
199 | loginError["message"] = ErrorMessage; | ||
200 | loginError["login"] = login; | ||
201 | xmlRpcResponse.Value = loginError; | ||
202 | return (xmlRpcResponse); | ||
203 | } | ||
204 | |||
205 | public OSD GenerateFailureResponseLLSD(string reason, string message, string login) | ||
206 | { | ||
207 | OSDMap map = new OSDMap(); | ||
208 | |||
209 | // Ensure Login Failed message/reason; | ||
210 | ErrorMessage = message; | ||
211 | ErrorReason = reason; | ||
212 | |||
213 | map["reason"] = OSD.FromString(ErrorReason); | ||
214 | map["message"] = OSD.FromString(ErrorMessage); | ||
215 | map["login"] = OSD.FromString(login); | ||
216 | |||
217 | return map; | ||
218 | } | ||
219 | |||
220 | public XmlRpcResponse CreateFailedResponse() | ||
221 | { | ||
222 | return (CreateLoginFailedResponse()); | ||
223 | } | ||
224 | |||
225 | public OSD CreateFailedResponseLLSD() | ||
226 | { | ||
227 | return CreateLoginFailedResponseLLSD(); | ||
228 | } | ||
229 | |||
230 | public XmlRpcResponse CreateLoginFailedResponse() | ||
231 | { | ||
232 | return | ||
233 | (GenerateFailureResponse("key", | ||
234 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | ||
235 | "false")); | ||
236 | } | ||
237 | |||
238 | public OSD CreateLoginFailedResponseLLSD() | ||
239 | { | ||
240 | return GenerateFailureResponseLLSD( | ||
241 | "key", | ||
242 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | ||
243 | "false"); | ||
244 | } | ||
245 | |||
246 | /// <summary> | ||
247 | /// Response to indicate that login failed because the agent's inventory was not available. | ||
248 | /// </summary> | ||
249 | /// <returns></returns> | ||
250 | public XmlRpcResponse CreateLoginInventoryFailedResponse() | ||
251 | { | ||
252 | return GenerateFailureResponse( | ||
253 | "key", | ||
254 | "The avatar inventory service is not responding. Please notify your login region operator.", | ||
255 | "false"); | ||
256 | } | ||
257 | |||
258 | public XmlRpcResponse CreateAlreadyLoggedInResponse() | ||
259 | { | ||
260 | return | ||
261 | (GenerateFailureResponse("presence", | ||
262 | "You appear to be already logged in. " + | ||
263 | "If this is not the case please wait for your session to timeout. " + | ||
264 | "If this takes longer than a few minutes please contact the grid owner. " + | ||
265 | "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", | ||
266 | "false")); | ||
267 | } | ||
268 | |||
269 | public OSD CreateAlreadyLoggedInResponseLLSD() | ||
270 | { | ||
271 | return GenerateFailureResponseLLSD( | ||
272 | "presence", | ||
273 | "You appear to be already logged in. " + | ||
274 | "If this is not the case please wait for your session to timeout. " + | ||
275 | "If this takes longer than a few minutes please contact the grid owner", | ||
276 | "false"); | ||
277 | } | ||
278 | |||
279 | public XmlRpcResponse CreateLoginBlockedResponse() | ||
280 | { | ||
281 | return | ||
282 | (GenerateFailureResponse("presence", | ||
283 | "Logins are currently restricted. Please try again later", | ||
284 | "false")); | ||
285 | } | ||
286 | |||
287 | public OSD CreateLoginBlockedResponseLLSD() | ||
288 | { | ||
289 | return GenerateFailureResponseLLSD( | ||
290 | "presence", | ||
291 | "Logins are currently restricted. Please try again later", | ||
292 | "false"); | ||
293 | } | ||
294 | |||
295 | public XmlRpcResponse CreateDeadRegionResponse() | ||
296 | { | ||
297 | return | ||
298 | (GenerateFailureResponse("key", | ||
299 | "The region you are attempting to log into is not responding. Please select another region and try again.", | ||
300 | "false")); | ||
301 | } | ||
302 | |||
303 | public OSD CreateDeadRegionResponseLLSD() | ||
304 | { | ||
305 | return GenerateFailureResponseLLSD( | ||
306 | "key", | ||
307 | "The region you are attempting to log into is not responding. Please select another region and try again.", | ||
308 | "false"); | ||
309 | } | ||
310 | |||
311 | public XmlRpcResponse CreateGridErrorResponse() | ||
312 | { | ||
313 | return | ||
314 | (GenerateFailureResponse("key", | ||
315 | "Error connecting to grid. Could not percieve credentials from login XML.", | ||
316 | "false")); | ||
317 | } | ||
318 | |||
319 | public OSD CreateGridErrorResponseLLSD() | ||
320 | { | ||
321 | return GenerateFailureResponseLLSD( | ||
322 | "key", | ||
323 | "Error connecting to grid. Could not percieve credentials from login XML.", | ||
324 | "false"); | ||
325 | } | ||
326 | |||
327 | #endregion | ||
328 | |||
329 | public virtual XmlRpcResponse ToXmlRpcResponse() | ||
330 | { | ||
331 | try | ||
332 | { | ||
333 | Hashtable responseData = new Hashtable(); | ||
334 | |||
335 | loginFlagsHash = new Hashtable(); | ||
336 | loginFlagsHash["daylight_savings"] = DST; | ||
337 | loginFlagsHash["stipend_since_login"] = StipendSinceLogin; | ||
338 | loginFlagsHash["gendered"] = Gendered; | ||
339 | loginFlagsHash["ever_logged_in"] = EverLoggedIn; | ||
340 | loginFlags.Add(loginFlagsHash); | ||
341 | |||
342 | responseData["first_name"] = Firstname; | ||
343 | responseData["last_name"] = Lastname; | ||
344 | responseData["agent_access"] = agentAccess; | ||
345 | |||
346 | globalTexturesHash = new Hashtable(); | ||
347 | globalTexturesHash["sun_texture_id"] = SunTexture; | ||
348 | globalTexturesHash["cloud_texture_id"] = CloudTexture; | ||
349 | globalTexturesHash["moon_texture_id"] = MoonTexture; | ||
350 | globalTextures.Add(globalTexturesHash); | ||
351 | // this.eventCategories.Add(this.eventCategoriesHash); | ||
352 | |||
353 | AddToUIConfig("allow_first_life", allowFirstLife); | ||
354 | uiConfig.Add(uiConfigHash); | ||
355 | |||
356 | responseData["sim_port"] = (Int32) SimPort; | ||
357 | responseData["sim_ip"] = SimAddress; | ||
358 | responseData["http_port"] = (Int32)SimHttpPort; | ||
359 | |||
360 | responseData["agent_id"] = AgentID.ToString(); | ||
361 | responseData["session_id"] = SessionID.ToString(); | ||
362 | responseData["secure_session_id"] = SecureSessionID.ToString(); | ||
363 | responseData["circuit_code"] = CircuitCode; | ||
364 | responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
365 | responseData["login-flags"] = loginFlags; | ||
366 | responseData["global-textures"] = globalTextures; | ||
367 | responseData["seed_capability"] = seedCapability; | ||
368 | |||
369 | responseData["event_categories"] = eventCategories; | ||
370 | responseData["event_notifications"] = new ArrayList(); // todo | ||
371 | responseData["classified_categories"] = classifiedCategories; | ||
372 | responseData["ui-config"] = uiConfig; | ||
373 | |||
374 | responseData["inventory-skeleton"] = agentInventory; | ||
375 | responseData["inventory-skel-lib"] = inventoryLibrary; | ||
376 | responseData["inventory-root"] = inventoryRoot; | ||
377 | responseData["inventory-lib-root"] = inventoryLibRoot; | ||
378 | responseData["gestures"] = activeGestures; | ||
379 | responseData["inventory-lib-owner"] = inventoryLibraryOwner; | ||
380 | responseData["initial-outfit"] = initialOutfit; | ||
381 | responseData["start_location"] = startLocation; | ||
382 | responseData["seed_capability"] = seedCapability; | ||
383 | responseData["home"] = home; | ||
384 | responseData["look_at"] = lookAt; | ||
385 | responseData["message"] = welcomeMessage; | ||
386 | responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); | ||
387 | responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); | ||
388 | |||
389 | //responseData["inventory-lib-root"] = new ArrayList(); // todo | ||
390 | |||
391 | if (m_buddyList != null) | ||
392 | { | ||
393 | responseData["buddy-list"] = m_buddyList.ToArray(); | ||
394 | } | ||
395 | |||
396 | responseData["login"] = "true"; | ||
397 | xmlRpcResponse.Value = responseData; | ||
398 | |||
399 | return (xmlRpcResponse); | ||
400 | } | ||
401 | catch (Exception e) | ||
402 | { | ||
403 | m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); | ||
404 | |||
405 | return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); | ||
406 | } | ||
407 | } | ||
408 | |||
409 | public OSD ToLLSDResponse() | ||
410 | { | ||
411 | try | ||
412 | { | ||
413 | OSDMap map = new OSDMap(); | ||
414 | |||
415 | map["first_name"] = OSD.FromString(Firstname); | ||
416 | map["last_name"] = OSD.FromString(Lastname); | ||
417 | map["agent_access"] = OSD.FromString(agentAccess); | ||
418 | |||
419 | map["sim_port"] = OSD.FromInteger(SimPort); | ||
420 | map["sim_ip"] = OSD.FromString(SimAddress); | ||
421 | |||
422 | map["agent_id"] = OSD.FromUUID(AgentID); | ||
423 | map["session_id"] = OSD.FromUUID(SessionID); | ||
424 | map["secure_session_id"] = OSD.FromUUID(SecureSessionID); | ||
425 | map["circuit_code"] = OSD.FromInteger(CircuitCode); | ||
426 | map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); | ||
427 | |||
428 | #region Login Flags | ||
429 | |||
430 | OSDMap loginFlagsLLSD = new OSDMap(); | ||
431 | loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); | ||
432 | loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); | ||
433 | loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); | ||
434 | loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); | ||
435 | map["login-flags"] = WrapOSDMap(loginFlagsLLSD); | ||
436 | |||
437 | #endregion Login Flags | ||
438 | |||
439 | #region Global Textures | ||
440 | |||
441 | OSDMap globalTexturesLLSD = new OSDMap(); | ||
442 | globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); | ||
443 | globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); | ||
444 | globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); | ||
445 | |||
446 | map["global-textures"] = WrapOSDMap(globalTexturesLLSD); | ||
447 | |||
448 | #endregion Global Textures | ||
449 | |||
450 | map["seed_capability"] = OSD.FromString(seedCapability); | ||
451 | |||
452 | map["event_categories"] = ArrayListToOSDArray(eventCategories); | ||
453 | //map["event_notifications"] = new OSDArray(); // todo | ||
454 | map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); | ||
455 | |||
456 | #region UI Config | ||
457 | |||
458 | OSDMap uiConfigLLSD = new OSDMap(); | ||
459 | uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); | ||
460 | map["ui-config"] = WrapOSDMap(uiConfigLLSD); | ||
461 | |||
462 | #endregion UI Config | ||
463 | |||
464 | #region Inventory | ||
465 | |||
466 | map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); | ||
467 | |||
468 | map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); | ||
469 | map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; | ||
470 | map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); | ||
471 | map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); | ||
472 | |||
473 | #endregion Inventory | ||
474 | |||
475 | map["gestures"] = ArrayListToOSDArray(activeGestures); | ||
476 | |||
477 | map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); | ||
478 | map["start_location"] = OSD.FromString(startLocation); | ||
479 | |||
480 | map["seed_capability"] = OSD.FromString(seedCapability); | ||
481 | map["home"] = OSD.FromString(home); | ||
482 | map["look_at"] = OSD.FromString(lookAt); | ||
483 | map["message"] = OSD.FromString(welcomeMessage); | ||
484 | map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); | ||
485 | map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); | ||
486 | |||
487 | if (m_buddyList != null) | ||
488 | { | ||
489 | map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); | ||
490 | } | ||
491 | |||
492 | map["login"] = OSD.FromString("true"); | ||
493 | |||
494 | return map; | ||
495 | } | ||
496 | catch (Exception e) | ||
497 | { | ||
498 | m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); | ||
499 | |||
500 | return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); | ||
501 | } | ||
502 | } | ||
503 | |||
504 | public OSDArray ArrayListToOSDArray(ArrayList arrlst) | ||
505 | { | ||
506 | OSDArray llsdBack = new OSDArray(); | ||
507 | foreach (Hashtable ht in arrlst) | ||
508 | { | ||
509 | OSDMap mp = new OSDMap(); | ||
510 | foreach (DictionaryEntry deHt in ht) | ||
511 | { | ||
512 | mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); | ||
513 | } | ||
514 | llsdBack.Add(mp); | ||
515 | } | ||
516 | return llsdBack; | ||
517 | } | ||
518 | |||
519 | private static OSDArray WrapOSDMap(OSDMap wrapMe) | ||
520 | { | ||
521 | OSDArray array = new OSDArray(); | ||
522 | array.Add(wrapMe); | ||
523 | return array; | ||
524 | } | ||
525 | |||
526 | public void SetEventCategories(string category, string value) | ||
527 | { | ||
528 | // this.eventCategoriesHash[category] = value; | ||
529 | //TODO | ||
530 | } | ||
531 | |||
532 | public void AddToUIConfig(string itemName, string item) | ||
533 | { | ||
534 | uiConfigHash[itemName] = item; | ||
535 | } | ||
536 | |||
537 | public void AddClassifiedCategory(Int32 ID, string categoryName) | ||
538 | { | ||
539 | Hashtable hash = new Hashtable(); | ||
540 | hash["category_name"] = categoryName; | ||
541 | hash["category_id"] = ID; | ||
542 | classifiedCategories.Add(hash); | ||
543 | // this.classifiedCategoriesHash.Clear(); | ||
544 | } | ||
545 | |||
546 | #region Properties | ||
547 | |||
548 | public string Login | ||
549 | { | ||
550 | get { return login; } | ||
551 | set { login = value; } | ||
552 | } | ||
553 | |||
554 | public string DST | ||
555 | { | ||
556 | get { return dst; } | ||
557 | set { dst = value; } | ||
558 | } | ||
559 | |||
560 | public string StipendSinceLogin | ||
561 | { | ||
562 | get { return stipendSinceLogin; } | ||
563 | set { stipendSinceLogin = value; } | ||
564 | } | ||
565 | |||
566 | public string Gendered | ||
567 | { | ||
568 | get { return gendered; } | ||
569 | set { gendered = value; } | ||
570 | } | ||
571 | |||
572 | public string EverLoggedIn | ||
573 | { | ||
574 | get { return everLoggedIn; } | ||
575 | set { everLoggedIn = value; } | ||
576 | } | ||
577 | |||
578 | public uint SimPort | ||
579 | { | ||
580 | get { return simPort; } | ||
581 | set { simPort = value; } | ||
582 | } | ||
583 | |||
584 | public uint SimHttpPort | ||
585 | { | ||
586 | get { return simHttpPort; } | ||
587 | set { simHttpPort = value; } | ||
588 | } | ||
589 | |||
590 | public string SimAddress | ||
591 | { | ||
592 | get { return simAddress; } | ||
593 | set { simAddress = value; } | ||
594 | } | ||
595 | |||
596 | public UUID AgentID | ||
597 | { | ||
598 | get { return agentID; } | ||
599 | set { agentID = value; } | ||
600 | } | ||
601 | |||
602 | public UUID SessionID | ||
603 | { | ||
604 | get { return sessionID; } | ||
605 | set { sessionID = value; } | ||
606 | } | ||
607 | |||
608 | public UUID SecureSessionID | ||
609 | { | ||
610 | get { return secureSessionID; } | ||
611 | set { secureSessionID = value; } | ||
612 | } | ||
613 | |||
614 | public Int32 CircuitCode | ||
615 | { | ||
616 | get { return circuitCode; } | ||
617 | set { circuitCode = value; } | ||
618 | } | ||
619 | |||
620 | public uint RegionX | ||
621 | { | ||
622 | get { return regionX; } | ||
623 | set { regionX = value; } | ||
624 | } | ||
625 | |||
626 | public uint RegionY | ||
627 | { | ||
628 | get { return regionY; } | ||
629 | set { regionY = value; } | ||
630 | } | ||
631 | |||
632 | public string SunTexture | ||
633 | { | ||
634 | get { return sunTexture; } | ||
635 | set { sunTexture = value; } | ||
636 | } | ||
637 | |||
638 | public string CloudTexture | ||
639 | { | ||
640 | get { return cloudTexture; } | ||
641 | set { cloudTexture = value; } | ||
642 | } | ||
643 | |||
644 | public string MoonTexture | ||
645 | { | ||
646 | get { return moonTexture; } | ||
647 | set { moonTexture = value; } | ||
648 | } | ||
649 | |||
650 | public string Firstname | ||
651 | { | ||
652 | get { return firstname; } | ||
653 | set { firstname = value; } | ||
654 | } | ||
655 | |||
656 | public string Lastname | ||
657 | { | ||
658 | get { return lastname; } | ||
659 | set { lastname = value; } | ||
660 | } | ||
661 | |||
662 | public string AgentAccess | ||
663 | { | ||
664 | get { return agentAccess; } | ||
665 | set { agentAccess = value; } | ||
666 | } | ||
667 | |||
668 | public string StartLocation | ||
669 | { | ||
670 | get { return startLocation; } | ||
671 | set { startLocation = value; } | ||
672 | } | ||
673 | |||
674 | public string LookAt | ||
675 | { | ||
676 | get { return lookAt; } | ||
677 | set { lookAt = value; } | ||
678 | } | ||
679 | |||
680 | public string SeedCapability | ||
681 | { | ||
682 | get { return seedCapability; } | ||
683 | set { seedCapability = value; } | ||
684 | } | ||
685 | |||
686 | public string ErrorReason | ||
687 | { | ||
688 | get { return errorReason; } | ||
689 | set { errorReason = value; } | ||
690 | } | ||
691 | |||
692 | public string ErrorMessage | ||
693 | { | ||
694 | get { return errorMessage; } | ||
695 | set { errorMessage = value; } | ||
696 | } | ||
697 | |||
698 | public ArrayList InventoryRoot | ||
699 | { | ||
700 | get { return inventoryRoot; } | ||
701 | set { inventoryRoot = value; } | ||
702 | } | ||
703 | |||
704 | public ArrayList InventorySkeleton | ||
705 | { | ||
706 | get { return agentInventory; } | ||
707 | set { agentInventory = value; } | ||
708 | } | ||
709 | |||
710 | public ArrayList InventoryLibrary | ||
711 | { | ||
712 | get { return inventoryLibrary; } | ||
713 | set { inventoryLibrary = value; } | ||
714 | } | ||
715 | |||
716 | public ArrayList InventoryLibraryOwner | ||
717 | { | ||
718 | get { return inventoryLibraryOwner; } | ||
719 | set { inventoryLibraryOwner = value; } | ||
720 | } | ||
721 | |||
722 | public ArrayList InventoryLibRoot | ||
723 | { | ||
724 | get { return inventoryLibRoot; } | ||
725 | set { inventoryLibRoot = value; } | ||
726 | } | ||
727 | |||
728 | public ArrayList ActiveGestures | ||
729 | { | ||
730 | get { return activeGestures; } | ||
731 | set { activeGestures = value; } | ||
732 | } | ||
733 | |||
734 | public string Home | ||
735 | { | ||
736 | get { return home; } | ||
737 | set { home = value; } | ||
738 | } | ||
739 | |||
740 | public string Message | ||
741 | { | ||
742 | get { return welcomeMessage; } | ||
743 | set { welcomeMessage = value; } | ||
744 | } | ||
745 | |||
746 | public BuddyList BuddList | ||
747 | { | ||
748 | get { return m_buddyList; } | ||
749 | set { m_buddyList = value; } | ||
750 | } | ||
751 | |||
752 | #endregion | ||
753 | |||
754 | public class UserInfo | ||
755 | { | ||
756 | public string firstname; | ||
757 | public string lastname; | ||
758 | public ulong homeregionhandle; | ||
759 | public Vector3 homepos; | ||
760 | public Vector3 homelookat; | ||
761 | } | ||
762 | |||
763 | public class BuddyList | ||
764 | { | ||
765 | public List<BuddyInfo> Buddies = new List<BuddyInfo>(); | ||
766 | |||
767 | public void AddNewBuddy(BuddyInfo buddy) | ||
768 | { | ||
769 | if (!Buddies.Contains(buddy)) | ||
770 | { | ||
771 | Buddies.Add(buddy); | ||
772 | } | ||
773 | } | ||
774 | |||
775 | public ArrayList ToArray() | ||
776 | { | ||
777 | ArrayList buddyArray = new ArrayList(); | ||
778 | foreach (BuddyInfo buddy in Buddies) | ||
779 | { | ||
780 | buddyArray.Add(buddy.ToHashTable()); | ||
781 | } | ||
782 | return buddyArray; | ||
783 | } | ||
784 | |||
785 | public class BuddyInfo | ||
786 | { | ||
787 | public int BuddyRightsHave = 1; | ||
788 | public int BuddyRightsGiven = 1; | ||
789 | public UUID BuddyID; | ||
790 | |||
791 | public BuddyInfo(string buddyID) | ||
792 | { | ||
793 | BuddyID = new UUID(buddyID); | ||
794 | } | ||
795 | |||
796 | public BuddyInfo(UUID buddyID) | ||
797 | { | ||
798 | BuddyID = buddyID; | ||
799 | } | ||
800 | |||
801 | public Hashtable ToHashTable() | ||
802 | { | ||
803 | Hashtable hTable = new Hashtable(); | ||
804 | hTable["buddy_rights_has"] = BuddyRightsHave; | ||
805 | hTable["buddy_rights_given"] = BuddyRightsGiven; | ||
806 | hTable["buddy_id"] = BuddyID.ToString(); | ||
807 | return hTable; | ||
808 | } | ||
809 | } | ||
810 | } | ||
811 | } | ||
812 | } | ||