EstateSnapshot.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.Xml;
  29. using OpenMetaverse;
  30. using OpenSim.Framework;
  31. using OpenSim.Region.DataSnapshot.Interfaces;
  32. using OpenSim.Region.Framework.Scenes;
  33. using OpenSim.Services.Interfaces;
  34. namespace OpenSim.Region.DataSnapshot.Providers
  35. {
  36. public class EstateSnapshot : IDataSnapshotProvider
  37. {
  38. /* This module doesn't check for changes, since it's *assumed* there are none.
  39. * Nevertheless, it's possible to have changes, since all the fields are public.
  40. * There's no event to subscribe to. :/
  41. *
  42. * I don't think anything changes the fields beyond RegionModule PostInit, however.
  43. */
  44. private Scene m_scene = null;
  45. // private DataSnapshotManager m_parent = null;
  46. private bool m_stale = true;
  47. #region IDataSnapshotProvider Members
  48. public XmlNode RequestSnapshotData(XmlDocument factory)
  49. {
  50. //Estate data section - contains who owns a set of sims and the name of the set.
  51. //Now in DataSnapshotProvider module form!
  52. XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", "");
  53. UUID ownerid = m_scene.RegionInfo.EstateSettings.EstateOwner;
  54. UserAccount userInfo = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid);
  55. //TODO: Change to query userserver about the master avatar UUID ?
  56. String firstname;
  57. String lastname;
  58. if (userInfo != null)
  59. {
  60. firstname = userInfo.FirstName;
  61. lastname = userInfo.LastName;
  62. //TODO: Fix the marshalling system to have less copypasta gruntwork
  63. XmlNode user = factory.CreateNode(XmlNodeType.Element, "user", "");
  64. // XmlAttribute type = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "type", "");
  65. // type.Value = "owner";
  66. // user.Attributes.Append(type);
  67. //TODO: Create more TODOs
  68. XmlNode username = factory.CreateNode(XmlNodeType.Element, "name", "");
  69. username.InnerText = firstname + " " + lastname;
  70. user.AppendChild(username);
  71. XmlNode useruuid = factory.CreateNode(XmlNodeType.Element, "uuid", "");
  72. useruuid.InnerText = ownerid.ToString();
  73. user.AppendChild(useruuid);
  74. estatedata.AppendChild(user);
  75. }
  76. XmlNode estatename = factory.CreateNode(XmlNodeType.Element, "name", "");
  77. estatename.InnerText = m_scene.RegionInfo.EstateSettings.EstateName.ToString();
  78. estatedata.AppendChild(estatename);
  79. XmlNode estateid = factory.CreateNode(XmlNodeType.Element, "id", "");
  80. estateid.InnerText = m_scene.RegionInfo.EstateSettings.EstateID.ToString();
  81. estatedata.AppendChild(estateid);
  82. XmlNode parentid = factory.CreateNode(XmlNodeType.Element, "parentid", "");
  83. parentid.InnerText = m_scene.RegionInfo.EstateSettings.ParentEstateID.ToString();
  84. estatedata.AppendChild(parentid);
  85. XmlNode flags = factory.CreateNode(XmlNodeType.Element, "flags", "");
  86. XmlAttribute teleport = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "teleport", "");
  87. teleport.Value = m_scene.RegionInfo.EstateSettings.AllowDirectTeleport.ToString();
  88. flags.Attributes.Append(teleport);
  89. XmlAttribute publicaccess = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "public", "");
  90. publicaccess.Value = m_scene.RegionInfo.EstateSettings.PublicAccess.ToString();
  91. flags.Attributes.Append(publicaccess);
  92. estatedata.AppendChild(flags);
  93. this.Stale = false;
  94. return estatedata;
  95. }
  96. public void Initialize(Scene scene, DataSnapshotManager parent)
  97. {
  98. m_scene = scene;
  99. // m_parent = parent;
  100. }
  101. public Scene GetParentScene
  102. {
  103. get { return m_scene; }
  104. }
  105. public String Name {
  106. get { return "EstateSnapshot"; }
  107. }
  108. public bool Stale
  109. {
  110. get {
  111. return m_stale;
  112. }
  113. set {
  114. m_stale = value;
  115. if (m_stale)
  116. OnStale(this);
  117. }
  118. }
  119. public event ProviderStale OnStale;
  120. #endregion
  121. }
  122. }