EstateSnapshot.cs 6.1 KB

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