1
0

AgentCircuitData.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 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. args["children_seeds"] = childrenSeeds;
  81. args["child"] = OSD.FromBoolean(child);
  82. args["circuit_code"] = OSD.FromString(circuitcode.ToString());
  83. args["first_name"] = OSD.FromString(firstname);
  84. args["last_name"] = OSD.FromString(lastname);
  85. args["inventory_folder"] = OSD.FromUUID(InventoryFolder);
  86. args["secure_session_id"] = OSD.FromUUID(SecureSessionID);
  87. args["session_id"] = OSD.FromUUID(SessionID);
  88. args["start_pos"] = OSD.FromString(startpos.ToString());
  89. return args;
  90. }
  91. public void UnpackAgentCircuitData(OSDMap args)
  92. {
  93. if (args["agent_id"] != null)
  94. AgentID = args["agent_id"].AsUUID();
  95. if (args["base_folder"] != null)
  96. BaseFolder = args["base_folder"].AsUUID();
  97. if (args["caps_path"] != null)
  98. CapsPath = args["caps_path"].AsString();
  99. if ((args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array))
  100. {
  101. OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
  102. ChildrenCapSeeds = new Dictionary<ulong, string>();
  103. foreach (OSD o in childrenSeeds)
  104. {
  105. if (o.Type == OSDType.Map)
  106. {
  107. ulong handle = 0;
  108. string seed = "";
  109. OSDMap pair = (OSDMap)o;
  110. if (pair["handle"] != null)
  111. if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
  112. continue;
  113. if (pair["seed"] != null)
  114. seed = pair["seed"].AsString();
  115. if (!ChildrenCapSeeds.ContainsKey(handle))
  116. ChildrenCapSeeds.Add(handle, seed);
  117. }
  118. }
  119. }
  120. if (args["child"] != null)
  121. child = args["child"].AsBoolean();
  122. if (args["circuit_code"] != null)
  123. UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
  124. if (args["first_name"] != null)
  125. firstname = args["first_name"].AsString();
  126. if (args["last_name"] != null)
  127. lastname = args["last_name"].AsString();
  128. if (args["inventory_folder"] != null)
  129. InventoryFolder = args["inventory_folder"].AsUUID();
  130. if (args["secure_session_id"] != null)
  131. SecureSessionID = args["secure_session_id"].AsUUID();
  132. if (args["session_id"] != null)
  133. SessionID = args["session_id"].AsUUID();
  134. if (args["start_pos"] != null)
  135. Vector3.TryParse(args["start_pos"].AsString(), out startpos);
  136. }
  137. }
  138. [Serializable]
  139. public class sAgentCircuitData
  140. {
  141. public Guid AgentID;
  142. public Guid BaseFolder;
  143. public string CapsPath = String.Empty;
  144. public Dictionary<ulong, string> ChildrenCapSeeds;
  145. public bool child;
  146. public uint circuitcode;
  147. public string firstname;
  148. public Guid InventoryFolder;
  149. public string lastname;
  150. public Guid SecureSessionID;
  151. public Guid SessionID;
  152. public float startposx;
  153. public float startposy;
  154. public float startposz;
  155. public sAgentCircuitData()
  156. {
  157. }
  158. public sAgentCircuitData(AgentCircuitData cAgent)
  159. {
  160. AgentID = cAgent.AgentID.Guid;
  161. SessionID = cAgent.SessionID.Guid;
  162. SecureSessionID = cAgent.SecureSessionID.Guid;
  163. startposx = cAgent.startpos.X;
  164. startposy = cAgent.startpos.Y;
  165. startposz = cAgent.startpos.Z;
  166. firstname = cAgent.firstname;
  167. lastname = cAgent.lastname;
  168. circuitcode = cAgent.circuitcode;
  169. child = cAgent.child;
  170. InventoryFolder = cAgent.InventoryFolder.Guid;
  171. BaseFolder = cAgent.BaseFolder.Guid;
  172. CapsPath = cAgent.CapsPath;
  173. ChildrenCapSeeds = cAgent.ChildrenCapSeeds;
  174. }
  175. }
  176. }