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