EstateSnapshot.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 libsecondlife;
  30. using OpenSim.Region.DataSnapshot.Interfaces;
  31. using OpenSim.Region.Environment.Scenes;
  32. namespace OpenSim.Region.DataSnapshot.Providers
  33. {
  34. public class EstateSnapshot : IDataSnapshotProvider
  35. {
  36. /* This module doesn't check for changes, since it's *assumed* there are none.
  37. * Nevertheless, it's possible to have changes, since all the fields are public.
  38. * There's no event to subscribe to. :/
  39. *
  40. * I don't think anything changes the fields beyond RegionModule PostInit, however.
  41. */
  42. private Scene m_scene = null;
  43. private DataSnapshotManager m_parent = null;
  44. private bool m_stale = true;
  45. #region IDataSnapshotProvider Members
  46. public XmlNode RequestSnapshotData(XmlDocument factory)
  47. {
  48. //Estate data section - contains who owns a set of sims and the name of the set.
  49. //In Opensim all the estate names are the same as the Master Avatar (owner of the sim)
  50. //Now in DataSnapshotProvider module form!
  51. XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", "");
  52. LLUUID ownerid = m_scene.RegionInfo.MasterAvatarAssignedUUID;
  53. //TODO: Change to query userserver about the master avatar UUID ?
  54. String firstname = m_scene.RegionInfo.MasterAvatarFirstName;
  55. String lastname = m_scene.RegionInfo.MasterAvatarLastName;
  56. //TODO: Fix the marshalling system to have less copypasta gruntwork
  57. XmlNode user = factory.CreateNode(XmlNodeType.Element, "user", "");
  58. XmlAttribute type = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "type", "");
  59. type.Value = "owner";
  60. user.Attributes.Append(type);
  61. //TODO: Create more TODOs
  62. XmlNode username = factory.CreateNode(XmlNodeType.Element, "name", "");
  63. username.InnerText = firstname + " " + lastname;
  64. user.AppendChild(username);
  65. XmlNode useruuid = factory.CreateNode(XmlNodeType.Element, "uuid", "");
  66. useruuid.InnerText = ownerid.ToString();
  67. user.AppendChild(useruuid);
  68. estatedata.AppendChild(user);
  69. this.Stale = false;
  70. return estatedata;
  71. }
  72. public void Initialize(Scene scene, DataSnapshotManager parent)
  73. {
  74. m_scene = scene;
  75. m_parent = parent;
  76. }
  77. public Scene GetParentScene
  78. {
  79. get { return m_scene; }
  80. }
  81. public String Name {
  82. get { return "EstateSnapshot"; }
  83. }
  84. public bool Stale
  85. {
  86. get {
  87. return m_stale;
  88. }
  89. set {
  90. m_stale = value;
  91. if (m_stale)
  92. OnStale(this);
  93. }
  94. }
  95. public event ProviderStale OnStale;
  96. #endregion
  97. }
  98. }