EstateSnapshot.cs 6.2 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 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.Framework.Communications.Cache;
  32. using OpenSim.Region.DataSnapshot.Interfaces;
  33. using OpenSim.Region.Framework.Scenes;
  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.MasterAvatarAssignedUUID;
  54. if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
  55. ownerid = m_scene.RegionInfo.EstateSettings.EstateOwner;
  56. CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(ownerid);
  57. //TODO: Change to query userserver about the master avatar UUID ?
  58. String firstname;
  59. String lastname;
  60. if (userInfo != null)
  61. {
  62. UserProfileData userProfile = userInfo.UserProfile;
  63. firstname = userProfile.FirstName;
  64. lastname = userProfile.SurName;
  65. //TODO: Fix the marshalling system to have less copypasta gruntwork
  66. XmlNode user = factory.CreateNode(XmlNodeType.Element, "user", "");
  67. // XmlAttribute type = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "type", "");
  68. // type.Value = "owner";
  69. // user.Attributes.Append(type);
  70. //TODO: Create more TODOs
  71. XmlNode username = factory.CreateNode(XmlNodeType.Element, "name", "");
  72. username.InnerText = firstname + " " + lastname;
  73. user.AppendChild(username);
  74. XmlNode useruuid = factory.CreateNode(XmlNodeType.Element, "uuid", "");
  75. useruuid.InnerText = ownerid.ToString();
  76. user.AppendChild(useruuid);
  77. estatedata.AppendChild(user);
  78. }
  79. XmlNode estatename = factory.CreateNode(XmlNodeType.Element, "name", "");
  80. estatename.InnerText = m_scene.RegionInfo.EstateSettings.EstateName.ToString();
  81. estatedata.AppendChild(estatename);
  82. XmlNode estateid = factory.CreateNode(XmlNodeType.Element, "id", "");
  83. estateid.InnerText = m_scene.RegionInfo.EstateSettings.EstateID.ToString();
  84. estatedata.AppendChild(estateid);
  85. XmlNode parentid = factory.CreateNode(XmlNodeType.Element, "parentid", "");
  86. parentid.InnerText = m_scene.RegionInfo.EstateSettings.ParentEstateID.ToString();
  87. estatedata.AppendChild(parentid);
  88. XmlNode flags = factory.CreateNode(XmlNodeType.Element, "flags", "");
  89. XmlAttribute teleport = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "teleport", "");
  90. teleport.Value = m_scene.RegionInfo.EstateSettings.AllowDirectTeleport.ToString();
  91. flags.Attributes.Append(teleport);
  92. XmlAttribute publicaccess = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "public", "");
  93. publicaccess.Value = m_scene.RegionInfo.EstateSettings.PublicAccess.ToString();
  94. flags.Attributes.Append(publicaccess);
  95. estatedata.AppendChild(flags);
  96. this.Stale = false;
  97. return estatedata;
  98. }
  99. public void Initialize(Scene scene, DataSnapshotManager parent)
  100. {
  101. m_scene = scene;
  102. // m_parent = parent;
  103. }
  104. public Scene GetParentScene
  105. {
  106. get { return m_scene; }
  107. }
  108. public String Name {
  109. get { return "EstateSnapshot"; }
  110. }
  111. public bool Stale
  112. {
  113. get {
  114. return m_stale;
  115. }
  116. set {
  117. m_stale = value;
  118. if (m_stale)
  119. OnStale(this);
  120. }
  121. }
  122. public event ProviderStale OnStale;
  123. #endregion
  124. }
  125. }