clockwerk-opensim-stable – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 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 OpenSimulator 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.Net;
32 using System.Reflection;
33  
34 using OpenSim.Framework;
35 using OpenSim.Services.Interfaces;
36 using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37 using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38  
39 using log4net;
40 using OpenMetaverse;
41 using OpenMetaverse.StructuredData;
42 using OSDArray = OpenMetaverse.StructuredData.OSDArray;
43 using OSDMap = OpenMetaverse.StructuredData.OSDMap;
44  
45 namespace OpenSim.Services.LLLoginService
46 {
47 public class LLFailedLoginResponse : OpenSim.Services.Interfaces.FailedLoginResponse
48 {
49 protected string m_key;
50 protected string m_value;
51 protected string m_login;
52  
53 public static LLFailedLoginResponse UserProblem;
54 public static LLFailedLoginResponse GridProblem;
55 public static LLFailedLoginResponse InventoryProblem;
56 public static LLFailedLoginResponse DeadRegionProblem;
57 public static LLFailedLoginResponse LoginBlockedProblem;
58 public static LLFailedLoginResponse AlreadyLoggedInProblem;
59 public static LLFailedLoginResponse InternalError;
60  
61 static LLFailedLoginResponse()
62 {
63 UserProblem = new LLFailedLoginResponse("key",
64 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
65 "false");
66 GridProblem = new LLFailedLoginResponse("key",
67 "Error connecting to the desired location. Try connecting to another region.",
68 "false");
69 InventoryProblem = new LLFailedLoginResponse("key",
70 "The inventory service is not responding. Please notify your login region operator.",
71 "false");
72 DeadRegionProblem = new LLFailedLoginResponse("key",
73 "The region you are attempting to log into is not responding. Please select another region and try again.",
74 "false");
75 LoginBlockedProblem = new LLFailedLoginResponse("presence",
76 "Logins are currently restricted. Please try again later.",
77 "false");
78 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence",
79 "You appear to be already logged in. " +
80 "If this is not the case please wait for your session to timeout. " +
81 "If this takes longer than a few minutes please contact the grid owner. " +
82 "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.",
83 "false");
84 InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false");
85 }
86  
87 public LLFailedLoginResponse(string key, string value, string login)
88 {
89 m_key = key;
90 m_value = value;
91 m_login = login;
92 }
93  
94 public override Hashtable ToHashtable()
95 {
96 Hashtable loginError = new Hashtable();
97 loginError["reason"] = m_key;
98 loginError["message"] = m_value;
99 loginError["login"] = m_login;
100 return loginError;
101 }
102  
103 public override OSD ToOSDMap()
104 {
105 OSDMap map = new OSDMap();
106  
107 map["reason"] = OSD.FromString(m_key);
108 map["message"] = OSD.FromString(m_value);
109 map["login"] = OSD.FromString(m_login);
110  
111 return map;
112 }
113 }
114  
115 /// <summary>
116 /// A class to handle LL login response.
117 /// </summary>
118 public class LLLoginResponse : OpenSim.Services.Interfaces.LoginResponse
119 {
120 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
121 private static Hashtable globalTexturesHash;
122 // Global Textures
123 private static string sunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
124 private static string cloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621";
125 private static string moonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621";
126  
127 private Hashtable loginFlagsHash;
128 private Hashtable uiConfigHash;
129  
130 private ArrayList loginFlags;
131 private ArrayList globalTextures;
132 private ArrayList eventCategories;
133 private ArrayList uiConfig;
134 private ArrayList classifiedCategories;
135 private ArrayList inventoryRoot;
136 private ArrayList initialOutfit;
137 private ArrayList agentInventory;
138 private ArrayList inventoryLibraryOwner;
139 private ArrayList inventoryLibRoot;
140 private ArrayList inventoryLibrary;
141 private ArrayList activeGestures;
142  
143 private UserInfo userProfile;
144  
145 private UUID agentID;
146 private UUID sessionID;
147 private UUID secureSessionID;
148  
149 // Login Flags
150 private string dst;
151 private string stipendSinceLogin;
152 private string gendered;
153 private string everLoggedIn;
154 private string login;
155 private uint simPort;
156 private uint simHttpPort;
157 private string simAddress;
158 private string agentAccess;
159 private string agentAccessMax;
160 private Int32 circuitCode;
161 private uint regionX;
162 private uint regionY;
163  
164 // Login
165 private string firstname;
166 private string lastname;
167  
168 // Web map
169 private string mapTileURL;
170  
171 // Web Profiles
172 private string profileURL;
173  
174 // OpenID
175 private string openIDURL;
176  
177 private string searchURL;
178  
179 // Error Flags
180 private string errorReason;
181 private string errorMessage;
182  
183 private string welcomeMessage;
184 private string startLocation;
185 private string allowFirstLife;
186 private string home;
187 private string seedCapability;
188 private string lookAt;
189  
190 private BuddyList m_buddyList = null;
191  
192 private string currency;
193 private string classifiedFee;
194  
195 static LLLoginResponse()
196 {
197 // This is being set, but it's not used
198 // not sure why.
199 globalTexturesHash = new Hashtable();
200 globalTexturesHash["sun_texture_id"] = sunTexture;
201 globalTexturesHash["cloud_texture_id"] = cloudTexture;
202 globalTexturesHash["moon_texture_id"] = moonTexture;
203 }
204  
205 public LLLoginResponse()
206 {
207 loginFlags = new ArrayList();
208 globalTextures = new ArrayList();
209 eventCategories = new ArrayList();
210 uiConfig = new ArrayList();
211 classifiedCategories = new ArrayList();
212  
213 uiConfigHash = new Hashtable();
214  
215 // defaultXmlRpcResponse = new XmlRpcResponse();
216 userProfile = new UserInfo();
217 inventoryRoot = new ArrayList();
218 initialOutfit = new ArrayList();
219 agentInventory = new ArrayList();
220 inventoryLibrary = new ArrayList();
221 inventoryLibraryOwner = new ArrayList();
222 activeGestures = new ArrayList();
223  
224 SetDefaultValues();
225 }
226  
227 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo,
228 GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService,
229 string where, string startlocation, Vector3 position, Vector3 lookAt, List<InventoryItemBase> gestures, string message,
230 GridRegion home, IPEndPoint clientIP, string mapTileURL, string profileURL, string openIDURL, string searchURL, string currency,
231 string DSTZone, string destinationsURL, string avatarsURL, string classifiedFee)
232 : this()
233 {
234 FillOutInventoryData(invSkel, libService);
235  
236 FillOutActiveGestures(gestures);
237  
238 CircuitCode = (int)aCircuit.circuitcode;
239 Lastname = account.LastName;
240 Firstname = account.FirstName;
241 AgentID = account.PrincipalID;
242 SessionID = aCircuit.SessionID;
243 SecureSessionID = aCircuit.SecureSessionID;
244 Message = message;
245 BuddList = ConvertFriendListItem(friendsList);
246 StartLocation = where;
247 MapTileURL = mapTileURL;
248 ProfileURL = profileURL;
249 OpenIDURL = openIDURL;
250 DestinationsURL = destinationsURL;
251 AvatarsURL = avatarsURL;
252  
253 SearchURL = searchURL;
254 Currency = currency;
255 ClassifiedFee = classifiedFee;
256  
257  
258 FillOutHomeData(pinfo, home);
259 LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z);
260  
261 FillOutRegionData(destination);
262  
263 FillOutSeedCap(aCircuit, destination, clientIP);
264  
265 switch (DSTZone)
266 {
267 case "none":
268 DST = "N";
269 break;
270 case "local":
271 DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
272 break;
273 default:
274 TimeZoneInfo dstTimeZone = null;
275 string[] tzList = DSTZone.Split(';');
276  
277 foreach (string tzName in tzList)
278 {
279 try
280 {
281 dstTimeZone = TimeZoneInfo.FindSystemTimeZoneById(tzName);
282 }
283 catch
284 {
285 continue;
286 }
287 break;
288 }
289  
290 if (dstTimeZone == null)
291 {
292 m_log.WarnFormat(
293 "[LLOGIN RESPONSE]: No valid timezone found for DST in {0}, falling back to system time.", tzList);
294 DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
295 }
296 else
297 {
298 DST = dstTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
299 }
300  
301 break;
302 }
303 }
304  
305 private void FillOutInventoryData(List<InventoryFolderBase> invSkel, ILibraryService libService)
306 {
307 InventoryData inventData = null;
308  
309 try
310 {
311 inventData = GetInventorySkeleton(invSkel);
312 }
313 catch (Exception e)
314 {
315 m_log.WarnFormat(
316 "[LLLOGIN SERVICE]: Error processing inventory skeleton of agent {0} - {1}",
317 agentID, e);
318  
319 // ignore and continue
320 }
321  
322 if (inventData != null)
323 {
324 ArrayList AgentInventoryArray = inventData.InventoryArray;
325  
326 Hashtable InventoryRootHash = new Hashtable();
327 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString();
328 InventoryRoot = new ArrayList();
329 InventoryRoot.Add(InventoryRootHash);
330 InventorySkeleton = AgentInventoryArray;
331 }
332  
333 // Inventory Library Section
334 if (libService != null && libService.LibraryRootFolder != null)
335 {
336 Hashtable InventoryLibRootHash = new Hashtable();
337 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
338 InventoryLibRoot = new ArrayList();
339 InventoryLibRoot.Add(InventoryLibRootHash);
340  
341 InventoryLibraryOwner = GetLibraryOwner(libService.LibraryRootFolder);
342 InventoryLibrary = GetInventoryLibrary(libService);
343 }
344 }
345  
346 private void FillOutActiveGestures(List<InventoryItemBase> gestures)
347 {
348 ArrayList list = new ArrayList();
349 if (gestures != null)
350 {
351 foreach (InventoryItemBase gesture in gestures)
352 {
353 Hashtable item = new Hashtable();
354 item["item_id"] = gesture.ID.ToString();
355 item["asset_id"] = gesture.AssetID.ToString();
356 list.Add(item);
357 }
358 }
359 ActiveGestures = list;
360 }
361  
362 private void FillOutHomeData(GridUserInfo pinfo, GridRegion home)
363 {
364 int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize;
365 if (home != null)
366 {
367 x = home.RegionLocX;
368 y = home.RegionLocY;
369 }
370  
371 Home = string.Format(
372 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
373 x,
374 y,
375 pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z,
376 pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z);
377  
378 }
379  
380 private void FillOutRegionData(GridRegion destination)
381 {
382 IPEndPoint endPoint = destination.ExternalEndPoint;
383 SimAddress = endPoint.Address.ToString();
384 SimPort = (uint)endPoint.Port;
385 RegionX = (uint)destination.RegionLocX;
386 RegionY = (uint)destination.RegionLocY;
387 }
388  
389 private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient)
390 {
391 SeedCapability = destination.ServerURI + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath);
392 }
393  
394 private void SetDefaultValues()
395 {
396 TimeZoneInfo gridTimeZone;
397  
398 // Disabled for now pending making timezone a config value, which can at some point have a default of
399 // a ; separated list of possible timezones.
400 // The problem here is that US/Pacific (or even the Olsen America/Los_Angeles) is not universal across
401 // windows, mac and various distributions of linux, introducing another element of consistency.
402 // The server operator needs to be able to control this setting
403 // try
404 // {
405 // // First try to fetch DST from Pacific Standard Time, because this is
406 // // the one expected by the viewer. "US/Pacific" is the string to search
407 // // on linux and mac, and should work also on Windows (to confirm)
408 // gridTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US/Pacific");
409 // }
410 // catch (Exception e)
411 // {
412 // m_log.WarnFormat(
413 // "[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time",
414 // e.Message);
415  
416 gridTimeZone = TimeZoneInfo.Local;
417 // }
418  
419 DST = gridTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
420  
421 StipendSinceLogin = "N";
422 Gendered = "Y";
423 EverLoggedIn = "Y";
424 login = "false";
425 firstname = "Test";
426 lastname = "User";
427 agentAccess = "M";
428 agentAccessMax = "A";
429 startLocation = "last";
430 allowFirstLife = "Y";
431  
432 ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
433 ErrorReason = "key";
434 welcomeMessage = "Welcome to OpenSim!";
435 seedCapability = String.Empty;
436 home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" +
437 userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" +
438 userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" +
439 userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}";
440 lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
441 RegionX = (uint) 255232;
442 RegionY = (uint) 254976;
443  
444 // Classifieds;
445 AddClassifiedCategory((Int32) 1, "Shopping");
446 AddClassifiedCategory((Int32) 2, "Land Rental");
447 AddClassifiedCategory((Int32) 3, "Property Rental");
448 AddClassifiedCategory((Int32) 4, "Special Attraction");
449 AddClassifiedCategory((Int32) 5, "New Products");
450 AddClassifiedCategory((Int32) 6, "Employment");
451 AddClassifiedCategory((Int32) 7, "Wanted");
452 AddClassifiedCategory((Int32) 8, "Service");
453 AddClassifiedCategory((Int32) 9, "Personal");
454  
455 SessionID = UUID.Random();
456 SecureSessionID = UUID.Random();
457 AgentID = UUID.Random();
458  
459 Hashtable InitialOutfitHash = new Hashtable();
460 InitialOutfitHash["folder_name"] = "Nightclub Female";
461 InitialOutfitHash["gender"] = "female";
462 initialOutfit.Add(InitialOutfitHash);
463 mapTileURL = String.Empty;
464 profileURL = String.Empty;
465 openIDURL = String.Empty;
466 searchURL = String.Empty;
467  
468 currency = String.Empty;
469 ClassifiedFee = "0";
470 }
471  
472  
473 public override Hashtable ToHashtable()
474 {
475 try
476 {
477 Hashtable responseData = new Hashtable();
478  
479 loginFlagsHash = new Hashtable();
480 loginFlagsHash["daylight_savings"] = DST;
481 loginFlagsHash["stipend_since_login"] = StipendSinceLogin;
482 loginFlagsHash["gendered"] = Gendered;
483 loginFlagsHash["ever_logged_in"] = EverLoggedIn;
484 loginFlags.Add(loginFlagsHash);
485  
486 responseData["first_name"] = Firstname;
487 responseData["last_name"] = Lastname;
488 responseData["agent_access"] = agentAccess;
489 responseData["agent_access_max"] = agentAccessMax;
490  
491 globalTextures.Add(globalTexturesHash);
492 // this.eventCategories.Add(this.eventCategoriesHash);
493  
494 AddToUIConfig("allow_first_life", allowFirstLife);
495 uiConfig.Add(uiConfigHash);
496  
497 responseData["sim_port"] = (Int32) SimPort;
498 responseData["sim_ip"] = SimAddress;
499 responseData["http_port"] = (Int32)SimHttpPort;
500  
501 responseData["agent_id"] = AgentID.ToString();
502 responseData["session_id"] = SessionID.ToString();
503 responseData["secure_session_id"] = SecureSessionID.ToString();
504 responseData["circuit_code"] = CircuitCode;
505 responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
506 responseData["login-flags"] = loginFlags;
507 responseData["global-textures"] = globalTextures;
508 responseData["seed_capability"] = seedCapability;
509  
510 responseData["event_categories"] = eventCategories;
511 responseData["event_notifications"] = new ArrayList(); // todo
512 responseData["classified_categories"] = classifiedCategories;
513 responseData["ui-config"] = uiConfig;
514  
515 if (agentInventory != null)
516 {
517 responseData["inventory-skeleton"] = agentInventory;
518 responseData["inventory-root"] = inventoryRoot;
519 }
520 responseData["inventory-skel-lib"] = inventoryLibrary;
521 responseData["inventory-lib-root"] = inventoryLibRoot;
522 responseData["gestures"] = activeGestures;
523 responseData["inventory-lib-owner"] = inventoryLibraryOwner;
524 responseData["initial-outfit"] = initialOutfit;
525 responseData["start_location"] = startLocation;
526 responseData["seed_capability"] = seedCapability;
527 responseData["home"] = home;
528 responseData["look_at"] = lookAt;
529 responseData["message"] = welcomeMessage;
530 responseData["region_x"] = (Int32)(RegionX);
531 responseData["region_y"] = (Int32)(RegionY);
532  
533 if (searchURL != String.Empty)
534 responseData["search"] = searchURL;
535  
536 if (mapTileURL != String.Empty)
537 responseData["map-server-url"] = mapTileURL;
538  
539 if (profileURL != String.Empty)
540 responseData["profile-server-url"] = profileURL;
541  
542 if (DestinationsURL != String.Empty)
543 responseData["destination_guide_url"] = DestinationsURL;
544  
545 if (AvatarsURL != String.Empty)
546 responseData["avatar_picker_url"] = AvatarsURL;
547  
548 // We need to send an openid_token back in the response too
549 if (openIDURL != String.Empty)
550 responseData["openid_url"] = openIDURL;
551  
552 if (m_buddyList != null)
553 {
554 responseData["buddy-list"] = m_buddyList.ToArray();
555 }
556  
557 if (currency != String.Empty)
558 {
559 // responseData["real_currency"] = currency;
560 responseData["currency"] = currency;
561 }
562  
563 if (ClassifiedFee != String.Empty)
564 responseData["classified_fee"] = ClassifiedFee;
565  
566 responseData["login"] = "true";
567  
568 return responseData;
569 }
570 catch (Exception e)
571 {
572 m_log.Warn("[CLIENT]: LoginResponse: Error creating Hashtable Response: " + e.Message);
573  
574 return LLFailedLoginResponse.InternalError.ToHashtable();
575 }
576 }
577  
578 public override OSD ToOSDMap()
579 {
580 try
581 {
582 OSDMap map = new OSDMap();
583  
584 map["first_name"] = OSD.FromString(Firstname);
585 map["last_name"] = OSD.FromString(Lastname);
586 map["agent_access"] = OSD.FromString(agentAccess);
587 map["agent_access_max"] = OSD.FromString(agentAccessMax);
588  
589 map["sim_port"] = OSD.FromInteger(SimPort);
590 map["sim_ip"] = OSD.FromString(SimAddress);
591  
592 map["agent_id"] = OSD.FromUUID(AgentID);
593 map["session_id"] = OSD.FromUUID(SessionID);
594 map["secure_session_id"] = OSD.FromUUID(SecureSessionID);
595 map["circuit_code"] = OSD.FromInteger(CircuitCode);
596 map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);
597  
598 #region Login Flags
599  
600 OSDMap loginFlagsLLSD = new OSDMap();
601 loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST);
602 loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin);
603 loginFlagsLLSD["gendered"] = OSD.FromString(Gendered);
604 loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn);
605 map["login-flags"] = WrapOSDMap(loginFlagsLLSD);
606  
607 #endregion Login Flags
608  
609 #region Global Textures
610  
611 OSDMap globalTexturesLLSD = new OSDMap();
612 globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture);
613 globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture);
614 globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture);
615  
616 map["global-textures"] = WrapOSDMap(globalTexturesLLSD);
617  
618 #endregion Global Textures
619  
620 map["seed_capability"] = OSD.FromString(seedCapability);
621  
622 map["event_categories"] = ArrayListToOSDArray(eventCategories);
623 //map["event_notifications"] = new OSDArray(); // todo
624 map["classified_categories"] = ArrayListToOSDArray(classifiedCategories);
625  
626 #region UI Config
627  
628 OSDMap uiConfigLLSD = new OSDMap();
629 uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife);
630 map["ui-config"] = WrapOSDMap(uiConfigLLSD);
631  
632 #endregion UI Config
633  
634 #region Inventory
635  
636 map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory);
637  
638 map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary);
639 map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ;
640 map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot);
641 map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner);
642  
643 #endregion Inventory
644  
645 map["gestures"] = ArrayListToOSDArray(activeGestures);
646  
647 map["initial-outfit"] = ArrayListToOSDArray(initialOutfit);
648 map["start_location"] = OSD.FromString(startLocation);
649  
650 map["seed_capability"] = OSD.FromString(seedCapability);
651 map["home"] = OSD.FromString(home);
652 map["look_at"] = OSD.FromString(lookAt);
653 map["message"] = OSD.FromString(welcomeMessage);
654 map["region_x"] = OSD.FromInteger(RegionX);
655 map["region_y"] = OSD.FromInteger(RegionY);
656  
657 if (mapTileURL != String.Empty)
658 map["map-server-url"] = OSD.FromString(mapTileURL);
659  
660 if (profileURL != String.Empty)
661 map["profile-server-url"] = OSD.FromString(profileURL);
662  
663 if (openIDURL != String.Empty)
664 map["openid_url"] = OSD.FromString(openIDURL);
665  
666 if (searchURL != String.Empty)
667 map["search"] = OSD.FromString(searchURL);
668  
669 if (ClassifiedFee != String.Empty)
670 map["classified_fee"] = OSD.FromString(ClassifiedFee);
671  
672 if (m_buddyList != null)
673 {
674 map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray());
675 }
676  
677 map["login"] = OSD.FromString("true");
678  
679 return map;
680 }
681 catch (Exception e)
682 {
683 m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message);
684  
685 return LLFailedLoginResponse.InternalError.ToOSDMap();
686 }
687 }
688  
689 public OSDArray ArrayListToOSDArray(ArrayList arrlst)
690 {
691 OSDArray llsdBack = new OSDArray();
692 foreach (Hashtable ht in arrlst)
693 {
694 OSDMap mp = new OSDMap();
695 foreach (DictionaryEntry deHt in ht)
696 {
697 mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value));
698 }
699 llsdBack.Add(mp);
700 }
701 return llsdBack;
702 }
703  
704 private static OSDArray WrapOSDMap(OSDMap wrapMe)
705 {
706 OSDArray array = new OSDArray();
707 array.Add(wrapMe);
708 return array;
709 }
710  
711 public void SetEventCategories(string category, string value)
712 {
713 // this.eventCategoriesHash[category] = value;
714 //TODO
715 }
716  
717 public void AddToUIConfig(string itemName, string item)
718 {
719 uiConfigHash[itemName] = item;
720 }
721  
722 public void AddClassifiedCategory(Int32 ID, string categoryName)
723 {
724 Hashtable hash = new Hashtable();
725 hash["category_name"] = categoryName;
726 hash["category_id"] = ID;
727 classifiedCategories.Add(hash);
728 // this.classifiedCategoriesHash.Clear();
729 }
730  
731  
732 private static LLLoginResponse.BuddyList ConvertFriendListItem(FriendInfo[] friendsList)
733 {
734 LLLoginResponse.BuddyList buddylistreturn = new LLLoginResponse.BuddyList();
735 foreach (FriendInfo finfo in friendsList)
736 {
737 if (finfo.TheirFlags == -1)
738 continue;
739 LLLoginResponse.BuddyList.BuddyInfo buddyitem = new LLLoginResponse.BuddyList.BuddyInfo(finfo.Friend);
740 // finfo.Friend may not be a simple uuid
741 UUID friendID = UUID.Zero;
742 if (UUID.TryParse(finfo.Friend, out friendID))
743 buddyitem.BuddyID = finfo.Friend;
744 else
745 {
746 string tmp;
747 if (Util.ParseUniversalUserIdentifier(finfo.Friend, out friendID, out tmp, out tmp, out tmp, out tmp))
748 buddyitem.BuddyID = friendID.ToString();
749 else
750 // junk entry
751 continue;
752 }
753 buddyitem.BuddyRightsHave = (int)finfo.TheirFlags;
754 buddyitem.BuddyRightsGiven = (int)finfo.MyFlags;
755 buddylistreturn.AddNewBuddy(buddyitem);
756 }
757 return buddylistreturn;
758 }
759  
760 private InventoryData GetInventorySkeleton(List<InventoryFolderBase> folders)
761 {
762 UUID rootID = UUID.Zero;
763 ArrayList AgentInventoryArray = new ArrayList();
764 Hashtable TempHash;
765 foreach (InventoryFolderBase InvFolder in folders)
766 {
767 if (InvFolder.ParentID == UUID.Zero && InvFolder.Name == "My Inventory")
768 {
769 rootID = InvFolder.ID;
770 }
771 TempHash = new Hashtable();
772 TempHash["name"] = InvFolder.Name;
773 TempHash["parent_id"] = InvFolder.ParentID.ToString();
774 TempHash["version"] = (Int32)InvFolder.Version;
775 TempHash["type_default"] = (Int32)InvFolder.Type;
776 TempHash["folder_id"] = InvFolder.ID.ToString();
777 AgentInventoryArray.Add(TempHash);
778 }
779  
780 return new InventoryData(AgentInventoryArray, rootID);
781  
782 }
783  
784 /// <summary>
785 /// Converts the inventory library skeleton into the form required by the rpc request.
786 /// </summary>
787 /// <returns></returns>
788 protected virtual ArrayList GetInventoryLibrary(ILibraryService library)
789 {
790 Dictionary<UUID, InventoryFolderImpl> rootFolders = library.GetAllFolders();
791 // m_log.DebugFormat("[LLOGIN]: Library has {0} folders", rootFolders.Count);
792 //Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>();
793 ArrayList folderHashes = new ArrayList();
794  
795 foreach (InventoryFolderBase folder in rootFolders.Values)
796 {
797 Hashtable TempHash = new Hashtable();
798 TempHash["name"] = folder.Name;
799 TempHash["parent_id"] = folder.ParentID.ToString();
800 TempHash["version"] = (Int32)folder.Version;
801 TempHash["type_default"] = (Int32)folder.Type;
802 TempHash["folder_id"] = folder.ID.ToString();
803 folderHashes.Add(TempHash);
804 }
805  
806 return folderHashes;
807 }
808  
809 /// <summary>
810 ///
811 /// </summary>
812 /// <returns></returns>
813 protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder)
814 {
815 //for now create random inventory library owner
816 Hashtable TempHash = new Hashtable();
817 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; // libFolder.Owner
818 ArrayList inventoryLibOwner = new ArrayList();
819 inventoryLibOwner.Add(TempHash);
820 return inventoryLibOwner;
821 }
822  
823 public class InventoryData
824 {
825 public ArrayList InventoryArray = null;
826 public UUID RootFolderID = UUID.Zero;
827  
828 public InventoryData(ArrayList invList, UUID rootID)
829 {
830 InventoryArray = invList;
831 RootFolderID = rootID;
832 }
833 }
834  
835 #region Properties
836  
837 public string Login
838 {
839 get { return login; }
840 set { login = value; }
841 }
842  
843 public string DST
844 {
845 get { return dst; }
846 set { dst = value; }
847 }
848  
849 public string StipendSinceLogin
850 {
851 get { return stipendSinceLogin; }
852 set { stipendSinceLogin = value; }
853 }
854  
855 public string Gendered
856 {
857 get { return gendered; }
858 set { gendered = value; }
859 }
860  
861 public string EverLoggedIn
862 {
863 get { return everLoggedIn; }
864 set { everLoggedIn = value; }
865 }
866  
867 public uint SimPort
868 {
869 get { return simPort; }
870 set { simPort = value; }
871 }
872  
873 public uint SimHttpPort
874 {
875 get { return simHttpPort; }
876 set { simHttpPort = value; }
877 }
878  
879 public string SimAddress
880 {
881 get { return simAddress; }
882 set { simAddress = value; }
883 }
884  
885 public UUID AgentID
886 {
887 get { return agentID; }
888 set { agentID = value; }
889 }
890  
891 public UUID SessionID
892 {
893 get { return sessionID; }
894 set { sessionID = value; }
895 }
896  
897 public UUID SecureSessionID
898 {
899 get { return secureSessionID; }
900 set { secureSessionID = value; }
901 }
902  
903 public Int32 CircuitCode
904 {
905 get { return circuitCode; }
906 set { circuitCode = value; }
907 }
908  
909 public uint RegionX
910 {
911 get { return regionX; }
912 set { regionX = value; }
913 }
914  
915 public uint RegionY
916 {
917 get { return regionY; }
918 set { regionY = value; }
919 }
920  
921 public string SunTexture
922 {
923 get { return sunTexture; }
924 set { sunTexture = value; }
925 }
926  
927 public string CloudTexture
928 {
929 get { return cloudTexture; }
930 set { cloudTexture = value; }
931 }
932  
933 public string MoonTexture
934 {
935 get { return moonTexture; }
936 set { moonTexture = value; }
937 }
938  
939 public string Firstname
940 {
941 get { return firstname; }
942 set { firstname = value; }
943 }
944  
945 public string Lastname
946 {
947 get { return lastname; }
948 set { lastname = value; }
949 }
950  
951 public string AgentAccess
952 {
953 get { return agentAccess; }
954 set { agentAccess = value; }
955 }
956  
957 public string AgentAccessMax
958 {
959 get { return agentAccessMax; }
960 set { agentAccessMax = value; }
961 }
962  
963 public string StartLocation
964 {
965 get { return startLocation; }
966 set { startLocation = value; }
967 }
968  
969 public string LookAt
970 {
971 get { return lookAt; }
972 set { lookAt = value; }
973 }
974  
975 public string SeedCapability
976 {
977 get { return seedCapability; }
978 set { seedCapability = value; }
979 }
980  
981 public string ErrorReason
982 {
983 get { return errorReason; }
984 set { errorReason = value; }
985 }
986  
987 public string ErrorMessage
988 {
989 get { return errorMessage; }
990 set { errorMessage = value; }
991 }
992  
993 public ArrayList InventoryRoot
994 {
995 get { return inventoryRoot; }
996 set { inventoryRoot = value; }
997 }
998  
999 public ArrayList InventorySkeleton
1000 {
1001 get { return agentInventory; }
1002 set { agentInventory = value; }
1003 }
1004  
1005 public ArrayList InventoryLibrary
1006 {
1007 get { return inventoryLibrary; }
1008 set { inventoryLibrary = value; }
1009 }
1010  
1011 public ArrayList InventoryLibraryOwner
1012 {
1013 get { return inventoryLibraryOwner; }
1014 set { inventoryLibraryOwner = value; }
1015 }
1016  
1017 public ArrayList InventoryLibRoot
1018 {
1019 get { return inventoryLibRoot; }
1020 set { inventoryLibRoot = value; }
1021 }
1022  
1023 public ArrayList ActiveGestures
1024 {
1025 get { return activeGestures; }
1026 set { activeGestures = value; }
1027 }
1028  
1029 public string Home
1030 {
1031 get { return home; }
1032 set { home = value; }
1033 }
1034  
1035 public string MapTileURL
1036 {
1037 get { return mapTileURL; }
1038 set { mapTileURL = value; }
1039 }
1040  
1041 public string ProfileURL
1042 {
1043 get { return profileURL; }
1044 set { profileURL = value; }
1045 }
1046  
1047 public string OpenIDURL
1048 {
1049 get { return openIDURL; }
1050 set { openIDURL = value; }
1051 }
1052  
1053 public string SearchURL
1054 {
1055 get { return searchURL; }
1056 set { searchURL = value; }
1057 }
1058  
1059 public string Message
1060 {
1061 get { return welcomeMessage; }
1062 set { welcomeMessage = value; }
1063 }
1064  
1065 public BuddyList BuddList
1066 {
1067 get { return m_buddyList; }
1068 set { m_buddyList = value; }
1069 }
1070  
1071 public string Currency
1072 {
1073 get { return currency; }
1074 set { currency = value; }
1075 }
1076  
1077 public string ClassifiedFee
1078 {
1079 get { return classifiedFee; }
1080 set { classifiedFee = value; }
1081 }
1082  
1083 public string DestinationsURL
1084 {
1085 get; set;
1086 }
1087  
1088 public string AvatarsURL
1089 {
1090 get; set;
1091 }
1092  
1093 #endregion
1094  
1095 public class UserInfo
1096 {
1097 public string firstname;
1098 public string lastname;
1099 public ulong homeregionhandle;
1100 public Vector3 homepos;
1101 public Vector3 homelookat;
1102 }
1103  
1104 public class BuddyList
1105 {
1106 public List<BuddyInfo> Buddies = new List<BuddyInfo>();
1107  
1108 public void AddNewBuddy(BuddyInfo buddy)
1109 {
1110 if (!Buddies.Contains(buddy))
1111 {
1112 Buddies.Add(buddy);
1113 }
1114 }
1115  
1116 public ArrayList ToArray()
1117 {
1118 ArrayList buddyArray = new ArrayList();
1119 foreach (BuddyInfo buddy in Buddies)
1120 {
1121 buddyArray.Add(buddy.ToHashTable());
1122 }
1123 return buddyArray;
1124 }
1125  
1126 public class BuddyInfo
1127 {
1128 public int BuddyRightsHave = 1;
1129 public int BuddyRightsGiven = 1;
1130 public string BuddyID;
1131  
1132 public BuddyInfo(string buddyID)
1133 {
1134 BuddyID = buddyID;
1135 }
1136  
1137 public BuddyInfo(UUID buddyID)
1138 {
1139 BuddyID = buddyID.ToString();
1140 }
1141  
1142 public Hashtable ToHashTable()
1143 {
1144 Hashtable hTable = new Hashtable();
1145 hTable["buddy_rights_has"] = BuddyRightsHave;
1146 hTable["buddy_rights_given"] = BuddyRightsGiven;
1147 hTable["buddy_id"] = BuddyID;
1148 return hTable;
1149 }
1150 }
1151 }
1152 }
1153 }