LocalUserProfileManager.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (c) OpenSim project, http://sim.opensecondlife.org/
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above copyright
  9. * notice, this list of conditions and the following disclaimer in the
  10. * documentation and/or other materials provided with the distribution.
  11. * * Neither the name of the <organization> nor the
  12. * names of its contributors may be used to endorse or promote products
  13. * derived from this software without specific prior written permission.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
  16. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  19. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Collections;
  30. using System.Text;
  31. using OpenSim.Framework.User;
  32. using OpenSim.Framework.Grid;
  33. using OpenSim.Framework.Inventory;
  34. using OpenSim.Framework.Interfaces;
  35. using OpenSim.Framework.Types;
  36. using libsecondlife;
  37. namespace OpenSim.UserServer
  38. {
  39. public class LocalUserProfileManager : UserProfileManager
  40. {
  41. private IGridServer m_gridServer;
  42. private int m_port;
  43. private string m_ipAddr;
  44. public LocalUserProfileManager(IGridServer gridServer, int simPort, string ipAddr)
  45. {
  46. m_gridServer = gridServer;
  47. m_port = simPort;
  48. m_ipAddr = ipAddr;
  49. }
  50. public override void InitUserProfiles()
  51. {
  52. // TODO: need to load from database
  53. }
  54. public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser)
  55. {
  56. Int32 circode = (Int32)response["circuit_code"];
  57. theUser.AddSimCircuit((uint)circode, LLUUID.Random());
  58. response["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}";
  59. response["sim_port"] = m_port;
  60. response["sim_ip"] = m_ipAddr;
  61. response["region_y"] = (Int32)996 * 256;
  62. response["region_x"] = (Int32)997* 256;
  63. string first;
  64. string last;
  65. if (response.Contains("first_name"))
  66. {
  67. first = (string)response["first_name"];
  68. }
  69. else
  70. {
  71. first = "test";
  72. }
  73. if (response.Contains("last_name"))
  74. {
  75. last = (string)response["last_name"];
  76. }
  77. else
  78. {
  79. last = "User";
  80. }
  81. ArrayList InventoryList = (ArrayList)response["inventory-skeleton"];
  82. Hashtable Inventory1 = (Hashtable)InventoryList[0];
  83. Login _login = new Login();
  84. //copy data to login object
  85. _login.First = first;
  86. _login.Last = last;
  87. _login.Agent = new LLUUID((string)response["agent_id"]) ;
  88. _login.Session = new LLUUID((string)response["session_id"]);
  89. _login.SecureSession = new LLUUID((string)response["secure_session_id"]);
  90. _login.BaseFolder = null;
  91. _login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]);
  92. //working on local computer if so lets add to the gridserver's list of sessions?
  93. if (m_gridServer.GetName() == "Local")
  94. {
  95. Console.WriteLine("adding login data to gridserver");
  96. ((LocalGridBase)this.m_gridServer).AddNewSession(_login);
  97. }
  98. }
  99. }
  100. }