LocalUserProfileManager.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 libsecondlife;
  36. namespace OpenSim.UserServer
  37. {
  38. public class LocalUserProfileManager : UserProfileManager
  39. {
  40. private IGridServer m_gridServer;
  41. private int m_port;
  42. private string m_ipAddr;
  43. public LocalUserProfileManager(IGridServer gridServer, int simPort, string ipAddr)
  44. {
  45. m_gridServer = gridServer;
  46. m_port = simPort;
  47. m_ipAddr = ipAddr;
  48. }
  49. public override void InitUserProfiles()
  50. {
  51. // TODO: need to load from database
  52. }
  53. public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser)
  54. {
  55. Int32 circode = (Int32)response["circuit_code"];
  56. theUser.AddSimCircuit((uint)circode, LLUUID.Random());
  57. 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() + "]}";
  58. response["sim_port"] = m_port;
  59. response["sim_ip"] = m_ipAddr;
  60. response["region_y"] = (Int32)996 * 256;
  61. response["region_x"] = (Int32)997* 256;
  62. string first;
  63. string last;
  64. if (response.Contains("first_name"))
  65. {
  66. first = (string)response["first_name"];
  67. }
  68. else
  69. {
  70. first = "test";
  71. }
  72. if (response.Contains("last_name"))
  73. {
  74. last = (string)response["last_name"];
  75. }
  76. else
  77. {
  78. last = "User";
  79. }
  80. ArrayList InventoryList = (ArrayList)response["inventory-skeleton"];
  81. Hashtable Inventory1 = (Hashtable)InventoryList[0];
  82. Login _login = new Login();
  83. //copy data to login object
  84. _login.First = first;
  85. _login.Last = last;
  86. _login.Agent = new LLUUID((string)response["agent_id"]) ;
  87. _login.Session = new LLUUID((string)response["session_id"]);
  88. _login.SecureSession = new LLUUID((string)response["secure_session_id"]);
  89. _login.BaseFolder = null;
  90. _login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]);
  91. //working on local computer if so lets add to the gridserver's list of sessions?
  92. if (m_gridServer.GetName() == "Local")
  93. {
  94. Console.WriteLine("adding login data to gridserver");
  95. ((LocalGridBase)this.m_gridServer).AddNewSession(_login);
  96. }
  97. }
  98. }
  99. }