AgentCircuitData.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. using System;
  28. using System.Collections.Generic;
  29. using OpenMetaverse;
  30. using OpenMetaverse.StructuredData;
  31. namespace OpenSim.Framework
  32. {
  33. public class AgentCircuitData
  34. {
  35. public UUID AgentID;
  36. public AvatarAppearance Appearance;
  37. public UUID BaseFolder;
  38. public string CapsPath = String.Empty;
  39. public Dictionary<ulong, string> ChildrenCapSeeds;
  40. public bool child;
  41. public uint circuitcode;
  42. public string firstname;
  43. public UUID InventoryFolder;
  44. public string lastname;
  45. public UUID SecureSessionID;
  46. public UUID SessionID;
  47. public Vector3 startpos;
  48. public AgentCircuitData()
  49. {
  50. }
  51. public AgentCircuitData(sAgentCircuitData cAgent)
  52. {
  53. AgentID = new UUID(cAgent.AgentID);
  54. SessionID = new UUID(cAgent.SessionID);
  55. SecureSessionID = new UUID(cAgent.SecureSessionID);
  56. startpos = new Vector3(cAgent.startposx, cAgent.startposy, cAgent.startposz);
  57. firstname = cAgent.firstname;
  58. lastname = cAgent.lastname;
  59. circuitcode = cAgent.circuitcode;
  60. child = cAgent.child;
  61. InventoryFolder = new UUID(cAgent.InventoryFolder);
  62. BaseFolder = new UUID(cAgent.BaseFolder);
  63. CapsPath = cAgent.CapsPath;
  64. ChildrenCapSeeds = cAgent.ChildrenCapSeeds;
  65. }
  66. public OSDMap PackAgentCircuitData()
  67. {
  68. OSDMap args = new OSDMap();
  69. args["agent_id"] = OSD.FromUUID(AgentID);
  70. args["base_folder"] = OSD.FromUUID(BaseFolder);
  71. args["caps_path"] = OSD.FromString(CapsPath);
  72. OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
  73. foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds)
  74. {
  75. OSDMap pair = new OSDMap();
  76. pair["handle"] = OSD.FromString(kvp.Key.ToString());
  77. pair["seed"] = OSD.FromString(kvp.Value);
  78. childrenSeeds.Add(pair);
  79. }
  80. if (ChildrenCapSeeds.Count > 0)
  81. args["children_seeds"] = childrenSeeds;
  82. args["child"] = OSD.FromBoolean(child);
  83. args["circuit_code"] = OSD.FromString(circuitcode.ToString());
  84. args["first_name"] = OSD.FromString(firstname);
  85. args["last_name"] = OSD.FromString(lastname);
  86. args["inventory_folder"] = OSD.FromUUID(InventoryFolder);
  87. args["secure_session_id"] = OSD.FromUUID(SecureSessionID);
  88. args["session_id"] = OSD.FromUUID(SessionID);
  89. args["start_pos"] = OSD.FromString(startpos.ToString());
  90. return args;
  91. }
  92. public void UnpackAgentCircuitData(OSDMap args)
  93. {
  94. if (args["agent_id"] != null)
  95. AgentID = args["agent_id"].AsUUID();
  96. if (args["base_folder"] != null)
  97. BaseFolder = args["base_folder"].AsUUID();
  98. if (args["caps_path"] != null)
  99. CapsPath = args["caps_path"].AsString();
  100. if ((args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array))
  101. {
  102. OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
  103. ChildrenCapSeeds = new Dictionary<ulong, string>();
  104. foreach (OSD o in childrenSeeds)
  105. {
  106. if (o.Type == OSDType.Map)
  107. {
  108. ulong handle = 0;
  109. string seed = "";
  110. OSDMap pair = (OSDMap)o;
  111. if (pair["handle"] != null)
  112. if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
  113. continue;
  114. if (pair["seed"] != null)
  115. seed = pair["seed"].AsString();
  116. if (!ChildrenCapSeeds.ContainsKey(handle))
  117. ChildrenCapSeeds.Add(handle, seed);
  118. }
  119. }
  120. }
  121. if (args["child"] != null)
  122. child = args["child"].AsBoolean();
  123. if (args["circuit_code"] != null)
  124. UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
  125. if (args["first_name"] != null)
  126. firstname = args["first_name"].AsString();
  127. if (args["last_name"] != null)
  128. lastname = args["last_name"].AsString();
  129. if (args["inventory_folder"] != null)
  130. InventoryFolder = args["inventory_folder"].AsUUID();
  131. if (args["secure_session_id"] != null)
  132. SecureSessionID = args["secure_session_id"].AsUUID();
  133. if (args["session_id"] != null)
  134. SessionID = args["session_id"].AsUUID();
  135. if (args["start_pos"] != null)
  136. Vector3.TryParse(args["start_pos"].AsString(), out startpos);
  137. }
  138. }
  139. [Serializable]
  140. public class sAgentCircuitData
  141. {
  142. public Guid AgentID;
  143. public Guid BaseFolder;
  144. public string CapsPath = String.Empty;
  145. public Dictionary<ulong, string> ChildrenCapSeeds;
  146. public bool child;
  147. public uint circuitcode;
  148. public string firstname;
  149. public Guid InventoryFolder;
  150. public string lastname;
  151. public Guid SecureSessionID;
  152. public Guid SessionID;
  153. public float startposx;
  154. public float startposy;
  155. public float startposz;
  156. public sAgentCircuitData()
  157. {
  158. }
  159. public sAgentCircuitData(AgentCircuitData cAgent)
  160. {
  161. AgentID = cAgent.AgentID.Guid;
  162. SessionID = cAgent.SessionID.Guid;
  163. SecureSessionID = cAgent.SecureSessionID.Guid;
  164. startposx = cAgent.startpos.X;
  165. startposy = cAgent.startpos.Y;
  166. startposz = cAgent.startpos.Z;
  167. firstname = cAgent.firstname;
  168. lastname = cAgent.lastname;
  169. circuitcode = cAgent.circuitcode;
  170. child = cAgent.child;
  171. InventoryFolder = cAgent.InventoryFolder.Guid;
  172. BaseFolder = cAgent.BaseFolder.Guid;
  173. CapsPath = cAgent.CapsPath;
  174. ChildrenCapSeeds = cAgent.ChildrenCapSeeds;
  175. }
  176. }
  177. }