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