1
0

AgentCircuitData.cs 7.9 KB

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