aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/DataSnapshot
diff options
context:
space:
mode:
authorJeff Ames2008-04-07 14:19:08 +0000
committerJeff Ames2008-04-07 14:19:08 +0000
commit8833a72388a07db48eb1fc135bf3919da13fb1db (patch)
treee9ba61c9b6a2eb78d664a8a5fa8d49ddfd4e1332 /OpenSim/Region/DataSnapshot
parentThank you kindly Diva & KMeisthax for adding the beginnings (diff)
downloadopensim-SC_OLD-8833a72388a07db48eb1fc135bf3919da13fb1db.zip
opensim-SC_OLD-8833a72388a07db48eb1fc135bf3919da13fb1db.tar.gz
opensim-SC_OLD-8833a72388a07db48eb1fc135bf3919da13fb1db.tar.bz2
opensim-SC_OLD-8833a72388a07db48eb1fc135bf3919da13fb1db.tar.xz
Update svn properties.
Diffstat (limited to 'OpenSim/Region/DataSnapshot')
-rw-r--r--OpenSim/Region/DataSnapshot/DataRequestHandler.cs150
-rw-r--r--OpenSim/Region/DataSnapshot/DataSnapshotManager.cs1048
-rw-r--r--OpenSim/Region/DataSnapshot/EstateSnapshot.cs136
-rw-r--r--OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs96
-rw-r--r--OpenSim/Region/DataSnapshot/LandSnapshot.cs534
-rw-r--r--OpenSim/Region/DataSnapshot/ObjectSnapshot.cs166
6 files changed, 1065 insertions, 1065 deletions
diff --git a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
index 512ad55..a59d86a 100644
--- a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
+++ b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
@@ -1,75 +1,75 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Collections; 31using System.Collections;
32using System.Text; 32using System.Text;
33using System.Xml; 33using System.Xml;
34using OpenSim.Region.Environment.Scenes; 34using OpenSim.Region.Environment.Scenes;
35using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37 37
38namespace OpenSim.Region.DataSnapshot 38namespace OpenSim.Region.DataSnapshot
39{ 39{
40 public class DataRequestHandler 40 public class DataRequestHandler
41 { 41 {
42 private Scene m_scene = null; 42 private Scene m_scene = null;
43 private DataSnapshotManager m_externalData = null; 43 private DataSnapshotManager m_externalData = null;
44 private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 44 private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 public DataRequestHandler(Scene scene, DataSnapshotManager externalData) 46 public DataRequestHandler(Scene scene, DataSnapshotManager externalData)
47 { 47 {
48 m_scene = scene; 48 m_scene = scene;
49 m_externalData = externalData; 49 m_externalData = externalData;
50 50
51 if (m_scene.AddHTTPHandler("collector", OnGetSnapshot)) 51 if (m_scene.AddHTTPHandler("collector", OnGetSnapshot))
52 { 52 {
53 m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); 53 m_log.Info("[DATASNAPSHOT]: Set up snapshot service");
54 } 54 }
55 //harbl 55 //harbl
56 } 56 }
57 57
58 public Hashtable OnGetSnapshot(Hashtable keysvals) 58 public Hashtable OnGetSnapshot(Hashtable keysvals)
59 { 59 {
60 m_log.Info("[DATASNAPSHOT] Received collection request"); 60 m_log.Info("[DATASNAPSHOT] Received collection request");
61 Hashtable reply = new Hashtable(); 61 Hashtable reply = new Hashtable();
62 int statuscode = 200; 62 int statuscode = 200;
63 63
64 string snapObj = (string)keysvals["region"]; 64 string snapObj = (string)keysvals["region"];
65 65
66 XmlDocument response = m_externalData.GetSnapshot(snapObj); 66 XmlDocument response = m_externalData.GetSnapshot(snapObj);
67 67
68 reply["str_response_string"] = response.OuterXml; 68 reply["str_response_string"] = response.OuterXml;
69 reply["int_response_code"] = statuscode; 69 reply["int_response_code"] = statuscode;
70 reply["content_type"] = "text/xml"; 70 reply["content_type"] = "text/xml";
71 71
72 return reply; 72 return reply;
73 } 73 }
74 } 74 }
75} 75}
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
index 1831f0a..cb9ce44 100644
--- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
@@ -1,524 +1,524 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Xml; 32using System.Xml;
33using System.IO; 33using System.IO;
34using System.Text; 34using System.Text;
35using System.Timers; 35using System.Timers;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
38using OpenSim.Region.Environment.Interfaces; 38using OpenSim.Region.Environment.Interfaces;
39using OpenSim.Region.Environment.Scenes; 39using OpenSim.Region.Environment.Scenes;
40using Nini.Config; 40using Nini.Config;
41using libsecondlife; 41using libsecondlife;
42using libsecondlife.Packets; 42using libsecondlife.Packets;
43 43
44namespace OpenSim.Region.DataSnapshot 44namespace OpenSim.Region.DataSnapshot
45{ 45{
46 public class DataSnapshotManager : IRegionModule 46 public class DataSnapshotManager : IRegionModule
47 { 47 {
48 #region Class members 48 #region Class members
49 private List<Scene> m_scenes = new List<Scene>(); 49 private List<Scene> m_scenes = new List<Scene>();
50 private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 50 private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
51 private bool m_enabled = false; 51 private bool m_enabled = false;
52 private bool m_configLoaded = false; 52 private bool m_configLoaded = false;
53 internal object m_syncInit = new object(); 53 internal object m_syncInit = new object();
54 private DataRequestHandler m_requests = null; 54 private DataRequestHandler m_requests = null;
55 private Dictionary<Scene, List<IDataSnapshotProvider>> m_dataproviders = new Dictionary<Scene, List<IDataSnapshotProvider>>(); 55 private Dictionary<Scene, List<IDataSnapshotProvider>> m_dataproviders = new Dictionary<Scene, List<IDataSnapshotProvider>>();
56 private Dictionary<String, String> m_gridinfo = new Dictionary<String, String>(); 56 private Dictionary<String, String> m_gridinfo = new Dictionary<String, String>();
57 //private int m_oldestSnapshot = 0; 57 //private int m_oldestSnapshot = 0;
58 private int m_maxSnapshots = 500; 58 private int m_maxSnapshots = 500;
59 private int m_lastSnapshot = 0; 59 private int m_lastSnapshot = 0;
60 private string m_snapsDir = "DataSnapshot"; 60 private string m_snapsDir = "DataSnapshot";
61 private string m_dataServices = "noservices"; 61 private string m_dataServices = "noservices";
62 private string m_listener_port = "9000"; //TODO: Set default port over 9000 62 private string m_listener_port = "9000"; //TODO: Set default port over 9000
63 private string m_hostname = "127.0.0.1"; 63 private string m_hostname = "127.0.0.1";
64 private Timer m_periodic = null; 64 private Timer m_periodic = null;
65 private int m_period = 60; // in seconds 65 private int m_period = 60; // in seconds
66 private List<String> m_disabledModules = new List<String>(); 66 private List<String> m_disabledModules = new List<String>();
67 #endregion 67 #endregion
68 68
69 #region IRegionModule 69 #region IRegionModule
70 public void Close() 70 public void Close()
71 { 71 {
72 72
73 } 73 }
74 74
75 public void Initialise(Scene scene, Nini.Config.IConfigSource config) 75 public void Initialise(Scene scene, Nini.Config.IConfigSource config)
76 { 76 {
77 if (!m_scenes.Contains(scene)) 77 if (!m_scenes.Contains(scene))
78 m_scenes.Add(scene); 78 m_scenes.Add(scene);
79 79
80 if (!m_configLoaded) { 80 if (!m_configLoaded) {
81 m_configLoaded = true; 81 m_configLoaded = true;
82 m_log.Info("[DATASNAPSHOT]: Loading configuration"); 82 m_log.Info("[DATASNAPSHOT]: Loading configuration");
83 //Read from the config for options 83 //Read from the config for options
84 lock (m_syncInit) { 84 lock (m_syncInit) {
85 try { 85 try {
86 m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); 86 m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled);
87 if (config.Configs["Startup"].GetBoolean("gridmode", true)) 87 if (config.Configs["Startup"].GetBoolean("gridmode", true))
88 { 88 {
89 m_gridinfo.Add("gridserverURL", config.Configs["Network"].GetString("grid_server_url", "harbl")); 89 m_gridinfo.Add("gridserverURL", config.Configs["Network"].GetString("grid_server_url", "harbl"));
90 m_gridinfo.Add("userserverURL", config.Configs["Network"].GetString("user_server_url", "harbl")); 90 m_gridinfo.Add("userserverURL", config.Configs["Network"].GetString("user_server_url", "harbl"));
91 m_gridinfo.Add("assetserverURL", config.Configs["Network"].GetString("asset_server_url", "harbl")); 91 m_gridinfo.Add("assetserverURL", config.Configs["Network"].GetString("asset_server_url", "harbl"));
92 } 92 }
93 else 93 else
94 { 94 {
95 //Non gridmode stuff 95 //Non gridmode stuff
96 } 96 }
97 97
98 m_gridinfo.Add("Name", config.Configs["DataSnapshot"].GetString("gridname", "harbl")); 98 m_gridinfo.Add("Name", config.Configs["DataSnapshot"].GetString("gridname", "harbl"));
99 m_maxSnapshots = config.Configs["DataSnapshot"].GetInt("max_snapshots", m_maxSnapshots); 99 m_maxSnapshots = config.Configs["DataSnapshot"].GetInt("max_snapshots", m_maxSnapshots);
100 m_period = config.Configs["DataSnapshot"].GetInt("default_snapshot_period", m_period); 100 m_period = config.Configs["DataSnapshot"].GetInt("default_snapshot_period", m_period);
101 m_snapsDir = config.Configs["DataSnapshot"].GetString("snapshot_cache_directory", m_snapsDir); 101 m_snapsDir = config.Configs["DataSnapshot"].GetString("snapshot_cache_directory", m_snapsDir);
102 m_dataServices = config.Configs["DataSnapshot"].GetString("data_services", m_dataServices); 102 m_dataServices = config.Configs["DataSnapshot"].GetString("data_services", m_dataServices);
103 m_listener_port = config.Configs["Network"].GetString("http_listener_port", m_listener_port); 103 m_listener_port = config.Configs["Network"].GetString("http_listener_port", m_listener_port);
104 //BUG: Naming a search data module "DESUDESUDESU" will cause it to not get loaded by default. 104 //BUG: Naming a search data module "DESUDESUDESU" will cause it to not get loaded by default.
105 //RESOLUTION: Wontfix, there are no Suiseiseki-loving developers 105 //RESOLUTION: Wontfix, there are no Suiseiseki-loving developers
106 String[] annoying_string_array = config.Configs["DataSnapshot"].GetString("disable_modules", "DESUDESUDESU").Split(".".ToCharArray()); 106 String[] annoying_string_array = config.Configs["DataSnapshot"].GetString("disable_modules", "DESUDESUDESU").Split(".".ToCharArray());
107 foreach (String bloody_wanker in annoying_string_array) { 107 foreach (String bloody_wanker in annoying_string_array) {
108 m_disabledModules.Add(bloody_wanker); 108 m_disabledModules.Add(bloody_wanker);
109 } 109 }
110 110
111 } catch (Exception) { 111 } catch (Exception) {
112 m_log.Info("[DATASNAPSHOT]: Could not load configuration. DataSnapshot will be disabled."); 112 m_log.Info("[DATASNAPSHOT]: Could not load configuration. DataSnapshot will be disabled.");
113 m_enabled = false; 113 m_enabled = false;
114 return; 114 return;
115 } 115 }
116 116
117 } 117 }
118 } 118 }
119 if (Directory.Exists(m_snapsDir)) 119 if (Directory.Exists(m_snapsDir))
120 { 120 {
121 m_log.Info("[DATASNAPSHOT] DataSnapshot directory already exists."); 121 m_log.Info("[DATASNAPSHOT] DataSnapshot directory already exists.");
122 } 122 }
123 else 123 else
124 { 124 {
125 // Try to create the directory. 125 // Try to create the directory.
126 m_log.Info("[DATASNAPSHOT] Creating " + m_snapsDir + " directory."); 126 m_log.Info("[DATASNAPSHOT] Creating " + m_snapsDir + " directory.");
127 try 127 try
128 { 128 {
129 Directory.CreateDirectory(m_snapsDir); 129 Directory.CreateDirectory(m_snapsDir);
130 } 130 }
131 catch (Exception) 131 catch (Exception)
132 { 132 {
133 m_log.Error("[DATASNAPSHOT] Failed to create " + m_snapsDir + " directory."); 133 m_log.Error("[DATASNAPSHOT] Failed to create " + m_snapsDir + " directory.");
134 } 134 }
135 } 135 }
136 136
137 137
138 if (m_enabled) 138 if (m_enabled)
139 { 139 {
140 m_log.Info("[DATASNAPSHOT]: Scene added to module."); 140 m_log.Info("[DATASNAPSHOT]: Scene added to module.");
141 } 141 }
142 else 142 else
143 { 143 {
144 m_log.Warn("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else)."); 144 m_log.Warn("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else).");
145 } 145 }
146 } 146 }
147 147
148 public bool IsSharedModule 148 public bool IsSharedModule
149 { 149 {
150 get { return true; } 150 get { return true; }
151 } 151 }
152 152
153 public string Name 153 public string Name
154 { 154 {
155 get { return "External Data Generator"; } 155 get { return "External Data Generator"; }
156 } 156 }
157 157
158 public void PostInitialise() 158 public void PostInitialise()
159 { 159 {
160 if (m_enabled) 160 if (m_enabled)
161 { 161 {
162 //Right now, only load ISearchData objects in the current assembly. 162 //Right now, only load ISearchData objects in the current assembly.
163 //Eventually allow it to load ISearchData objects from all assemblies. 163 //Eventually allow it to load ISearchData objects from all assemblies.
164 Assembly currentasm = Assembly.GetExecutingAssembly(); 164 Assembly currentasm = Assembly.GetExecutingAssembly();
165 165
166 //Stolen from ModuleLoader.cs 166 //Stolen from ModuleLoader.cs
167 foreach (Type pluginType in currentasm.GetTypes()) 167 foreach (Type pluginType in currentasm.GetTypes())
168 { 168 {
169 if (pluginType.IsPublic) 169 if (pluginType.IsPublic)
170 { 170 {
171 if (!pluginType.IsAbstract) 171 if (!pluginType.IsAbstract)
172 { 172 {
173 if (pluginType.GetInterface("IDataSnapshotProvider") != null) 173 if (pluginType.GetInterface("IDataSnapshotProvider") != null)
174 { 174 {
175 foreach (Scene scene in m_scenes) 175 foreach (Scene scene in m_scenes)
176 { 176 {
177 IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); 177 IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType);
178 module.Initialize(scene, this); 178 module.Initialize(scene, this);
179 //module.PrepareData(); 179 //module.PrepareData();
180 List<IDataSnapshotProvider> providerlist = null; 180 List<IDataSnapshotProvider> providerlist = null;
181 m_dataproviders.TryGetValue(scene, out providerlist); 181 m_dataproviders.TryGetValue(scene, out providerlist);
182 if (providerlist == null) 182 if (providerlist == null)
183 { 183 {
184 providerlist = new List<IDataSnapshotProvider>(); 184 providerlist = new List<IDataSnapshotProvider>();
185 m_dataproviders.Add(scene, providerlist); 185 m_dataproviders.Add(scene, providerlist);
186 } 186 }
187 providerlist.Add(module); 187 providerlist.Add(module);
188 188
189 } 189 }
190 m_log.Info("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); 190 m_log.Info("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name);
191 } 191 }
192 } 192 }
193 } 193 }
194 } 194 }
195 195
196 //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer 196 //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer
197 m_requests = new DataRequestHandler(m_scenes[0], this); 197 m_requests = new DataRequestHandler(m_scenes[0], this);
198 198
199 //Create timer 199 //Create timer
200 m_periodic = new Timer(); 200 m_periodic = new Timer();
201 m_periodic.Interval = m_period * 1000; 201 m_periodic.Interval = m_period * 1000;
202 m_periodic.Elapsed += SnapshotTimerCallback; 202 m_periodic.Elapsed += SnapshotTimerCallback;
203 m_periodic.Enabled = true; 203 m_periodic.Enabled = true;
204 204
205 m_hostname = m_scenes[0].RegionInfo.ExternalHostName; 205 m_hostname = m_scenes[0].RegionInfo.ExternalHostName;
206 206
207 MakeNewSnapshot(); //Make the initial snapshot 207 MakeNewSnapshot(); //Make the initial snapshot
208 208
209 if (m_dataServices != "noservices") 209 if (m_dataServices != "noservices")
210 NotifyDataServices(m_dataServices); 210 NotifyDataServices(m_dataServices);
211 } 211 }
212 } 212 }
213 #endregion 213 #endregion
214 214
215 #region Associated helper functions 215 #region Associated helper functions
216 216
217 string DataFileName(Scene scene) 217 string DataFileName(Scene scene)
218 { 218 {
219 return Path.Combine(m_snapsDir, Path.ChangeExtension(scene.RegionInfo.RegionName, "xml")); 219 return Path.Combine(m_snapsDir, Path.ChangeExtension(scene.RegionInfo.RegionName, "xml"));
220 //return (m_snapsDir + Path.DirectorySeparatorChar + scene.RegionInfo.RegionName + ".xml"); 220 //return (m_snapsDir + Path.DirectorySeparatorChar + scene.RegionInfo.RegionName + ".xml");
221 } 221 }
222 222
223 Scene SceneForName(string name) 223 Scene SceneForName(string name)
224 { 224 {
225 foreach (Scene scene in m_scenes) 225 foreach (Scene scene in m_scenes)
226 if (scene.RegionInfo.RegionName == name) 226 if (scene.RegionInfo.RegionName == name)
227 return scene; 227 return scene;
228 228
229 return null; 229 return null;
230 } 230 }
231 231
232 #endregion 232 #endregion
233 233
234 #region [Private] XML snapshot generator 234 #region [Private] XML snapshot generator
235 235
236 private XmlDocument Snapshot(Scene scene) 236 private XmlDocument Snapshot(Scene scene)
237 { 237 {
238 XmlDocument basedoc = new XmlDocument(); 238 XmlDocument basedoc = new XmlDocument();
239 XmlNode regionElement = MakeRegionNode(scene, basedoc); 239 XmlNode regionElement = MakeRegionNode(scene, basedoc);
240 240
241 regionElement.AppendChild(GetGridSnapshotData(basedoc)); 241 regionElement.AppendChild(GetGridSnapshotData(basedoc));
242 XmlNode regionData = basedoc.CreateNode(XmlNodeType.Element, "data", ""); 242 XmlNode regionData = basedoc.CreateNode(XmlNodeType.Element, "data", "");
243 243
244 foreach (KeyValuePair<Scene, List<IDataSnapshotProvider>> dataprovider in m_dataproviders) 244 foreach (KeyValuePair<Scene, List<IDataSnapshotProvider>> dataprovider in m_dataproviders)
245 { 245 {
246 if (dataprovider.Key == scene) 246 if (dataprovider.Key == scene)
247 { 247 {
248 foreach (IDataSnapshotProvider provider in dataprovider.Value) 248 foreach (IDataSnapshotProvider provider in dataprovider.Value)
249 { 249 {
250 XmlNode data = provider.RequestSnapshotData(basedoc); 250 XmlNode data = provider.RequestSnapshotData(basedoc);
251 regionData.AppendChild(data); 251 regionData.AppendChild(data);
252 } 252 }
253 } 253 }
254 } 254 }
255 255
256 regionElement.AppendChild(regionData); 256 regionElement.AppendChild(regionData);
257 257
258 basedoc.AppendChild(regionElement); 258 basedoc.AppendChild(regionElement);
259 259
260 return basedoc; 260 return basedoc;
261 } 261 }
262 262
263 private XmlNode MakeRegionNode(Scene scene, XmlDocument basedoc) 263 private XmlNode MakeRegionNode(Scene scene, XmlDocument basedoc)
264 { 264 {
265 XmlNode docElement = basedoc.CreateNode(XmlNodeType.Element, "region", ""); 265 XmlNode docElement = basedoc.CreateNode(XmlNodeType.Element, "region", "");
266 266
267 XmlAttribute attr = basedoc.CreateAttribute("category"); 267 XmlAttribute attr = basedoc.CreateAttribute("category");
268 attr.Value = GetRegionCategory(scene); 268 attr.Value = GetRegionCategory(scene);
269 docElement.Attributes.Append(attr); 269 docElement.Attributes.Append(attr);
270 270
271 attr = basedoc.CreateAttribute("entities"); 271 attr = basedoc.CreateAttribute("entities");
272 attr.Value = scene.Entities.Count.ToString(); 272 attr.Value = scene.Entities.Count.ToString();
273 docElement.Attributes.Append(attr); 273 docElement.Attributes.Append(attr);
274 274
275 //attr = basedoc.CreateAttribute("parcels"); 275 //attr = basedoc.CreateAttribute("parcels");
276 //attr.Value = scene.LandManager.landList.Count.ToString(); 276 //attr.Value = scene.LandManager.landList.Count.ToString();
277 //docElement.Attributes.Append(attr); 277 //docElement.Attributes.Append(attr);
278 278
279 279
280 XmlNode infoblock = basedoc.CreateNode(XmlNodeType.Element, "info", ""); 280 XmlNode infoblock = basedoc.CreateNode(XmlNodeType.Element, "info", "");
281 281
282 XmlNode infopiece = basedoc.CreateNode(XmlNodeType.Element, "uuid", ""); 282 XmlNode infopiece = basedoc.CreateNode(XmlNodeType.Element, "uuid", "");
283 infopiece.InnerText = scene.RegionInfo.RegionID.ToString(); 283 infopiece.InnerText = scene.RegionInfo.RegionID.ToString();
284 infoblock.AppendChild(infopiece); 284 infoblock.AppendChild(infopiece);
285 285
286 infopiece = basedoc.CreateNode(XmlNodeType.Element, "url", ""); 286 infopiece = basedoc.CreateNode(XmlNodeType.Element, "url", "");
287 infopiece.InnerText = "http://" + m_hostname + ":" + m_listener_port; 287 infopiece.InnerText = "http://" + m_hostname + ":" + m_listener_port;
288 infoblock.AppendChild(infopiece); 288 infoblock.AppendChild(infopiece);
289 289
290 infopiece = basedoc.CreateNode(XmlNodeType.Element, "name", ""); 290 infopiece = basedoc.CreateNode(XmlNodeType.Element, "name", "");
291 infopiece.InnerText = scene.RegionInfo.RegionName; 291 infopiece.InnerText = scene.RegionInfo.RegionName;
292 infoblock.AppendChild(infopiece); 292 infoblock.AppendChild(infopiece);
293 293
294 docElement.AppendChild(infoblock); 294 docElement.AppendChild(infoblock);
295 295
296 return docElement; 296 return docElement;
297 } 297 }
298 298
299 private XmlNode GetGridSnapshotData(XmlDocument factory) 299 private XmlNode GetGridSnapshotData(XmlDocument factory)
300 { 300 {
301 XmlNode griddata = factory.CreateNode(XmlNodeType.Element, "grid", ""); 301 XmlNode griddata = factory.CreateNode(XmlNodeType.Element, "grid", "");
302 302
303 foreach (KeyValuePair<String, String> GridData in m_gridinfo) 303 foreach (KeyValuePair<String, String> GridData in m_gridinfo)
304 { 304 {
305 //TODO: make it lowercase tag names for diva 305 //TODO: make it lowercase tag names for diva
306 XmlNode childnode = factory.CreateNode(XmlNodeType.Element, GridData.Key, ""); 306 XmlNode childnode = factory.CreateNode(XmlNodeType.Element, GridData.Key, "");
307 childnode.InnerText = GridData.Value; 307 childnode.InnerText = GridData.Value;
308 griddata.AppendChild(childnode); 308 griddata.AppendChild(childnode);
309 } 309 }
310 310
311 return griddata; 311 return griddata;
312 } 312 }
313 313
314 private String GetRegionCategory(Scene scene) 314 private String GetRegionCategory(Scene scene)
315 { 315 {
316 316
317 //Boolean choice between: 317 //Boolean choice between:
318 // "PG" - Mormontown 318 // "PG" - Mormontown
319 // "Mature" - Sodom and Gomorrah 319 // "Mature" - Sodom and Gomorrah
320 // (Depreciated) "Patriotic Nigra Testing Sandbox" - Abandon Hope All Ye Who Enter Here 320 // (Depreciated) "Patriotic Nigra Testing Sandbox" - Abandon Hope All Ye Who Enter Here
321 if ((scene.RegionInfo.EstateSettings.simAccess & Simulator.SimAccess.Mature) == Simulator.SimAccess.Mature) 321 if ((scene.RegionInfo.EstateSettings.simAccess & Simulator.SimAccess.Mature) == Simulator.SimAccess.Mature)
322 { 322 {
323 return "Mature"; 323 return "Mature";
324 } 324 }
325 else if ((scene.RegionInfo.EstateSettings.simAccess & Simulator.SimAccess.PG) == Simulator.SimAccess.PG) 325 else if ((scene.RegionInfo.EstateSettings.simAccess & Simulator.SimAccess.PG) == Simulator.SimAccess.PG)
326 { 326 {
327 return "PG"; 327 return "PG";
328 } 328 }
329 else 329 else
330 { 330 {
331 return "Unknown"; 331 return "Unknown";
332 } 332 }
333 } 333 }
334 334
335 /* Code's closed due to AIDS, See EstateSnapshot.cs for CURE 335 /* Code's closed due to AIDS, See EstateSnapshot.cs for CURE
336 private XmlNode GetEstateSnapshotData(Scene scene, XmlDocument factory) 336 private XmlNode GetEstateSnapshotData(Scene scene, XmlDocument factory)
337 { 337 {
338 //Estate data section - contains who owns a set of sims and the name of the set. 338 //Estate data section - contains who owns a set of sims and the name of the set.
339 //In Opensim all the estate names are the same as the Master Avatar (owner of the sim) 339 //In Opensim all the estate names are the same as the Master Avatar (owner of the sim)
340 XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", ""); 340 XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", "");
341 341
342 LLUUID ownerid = scene.RegionInfo.MasterAvatarAssignedUUID; 342 LLUUID ownerid = scene.RegionInfo.MasterAvatarAssignedUUID;
343 String firstname = scene.RegionInfo.MasterAvatarFirstName; 343 String firstname = scene.RegionInfo.MasterAvatarFirstName;
344 String lastname = scene.RegionInfo.MasterAvatarLastName; 344 String lastname = scene.RegionInfo.MasterAvatarLastName;
345 String hostname = scene.RegionInfo.ExternalHostName; 345 String hostname = scene.RegionInfo.ExternalHostName;
346 346
347 XmlNode user = factory.CreateNode(XmlNodeType.Element, "owner", ""); 347 XmlNode user = factory.CreateNode(XmlNodeType.Element, "owner", "");
348 348
349 XmlNode username = factory.CreateNode(XmlNodeType.Element, "name", ""); 349 XmlNode username = factory.CreateNode(XmlNodeType.Element, "name", "");
350 username.InnerText = firstname + " " + lastname; 350 username.InnerText = firstname + " " + lastname;
351 user.AppendChild(username); 351 user.AppendChild(username);
352 352
353 XmlNode useruuid = factory.CreateNode(XmlNodeType.Element, "uuid", ""); 353 XmlNode useruuid = factory.CreateNode(XmlNodeType.Element, "uuid", "");
354 useruuid.InnerText = ownerid.ToString(); 354 useruuid.InnerText = ownerid.ToString();
355 user.AppendChild(useruuid); 355 user.AppendChild(useruuid);
356 356
357 estatedata.AppendChild(user); 357 estatedata.AppendChild(user);
358 358
359 return estatedata; 359 return estatedata;
360 } */ 360 } */
361 361
362 #endregion 362 #endregion
363 363
364 #region [Public] Snapshot storage functions 364 #region [Public] Snapshot storage functions
365 365
366 public void MakeNewSnapshot() 366 public void MakeNewSnapshot()
367 { 367 {
368 foreach (Scene scene in m_scenes) 368 foreach (Scene scene in m_scenes)
369 { 369 {
370 XmlDocument snapshot = Snapshot(scene); 370 XmlDocument snapshot = Snapshot(scene);
371 371
372 string path = DataFileName(scene); 372 string path = DataFileName(scene);
373 373
374 try 374 try
375 { 375 {
376 using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) 376 using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default))
377 { 377 {
378 snapXWriter.Formatting = Formatting.Indented; 378 snapXWriter.Formatting = Formatting.Indented;
379 snapXWriter.WriteStartDocument(); 379 snapXWriter.WriteStartDocument();
380 snapshot.WriteTo(snapXWriter); 380 snapshot.WriteTo(snapXWriter);
381 snapXWriter.WriteEndDocument(); 381 snapXWriter.WriteEndDocument();
382 382
383 m_lastSnapshot++; 383 m_lastSnapshot++;
384 } 384 }
385 } 385 }
386 catch (Exception e) 386 catch (Exception e)
387 { 387 {
388 m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to save snapshot: " + path + "\n" + e.ToString()); 388 m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to save snapshot: " + path + "\n" + e.ToString());
389 } 389 }
390 m_log.Info("[DATASNAPSHOT]: Made external data snapshot " + path); 390 m_log.Info("[DATASNAPSHOT]: Made external data snapshot " + path);
391 } 391 }
392 } 392 }
393 393
394 /** 394 /**
395 * Reply to the http request 395 * Reply to the http request
396 */ 396 */
397 public XmlDocument GetSnapshot(string regionName) 397 public XmlDocument GetSnapshot(string regionName)
398 { 398 {
399 XmlDocument requestedSnap = new XmlDocument(); 399 XmlDocument requestedSnap = new XmlDocument();
400 requestedSnap.AppendChild(requestedSnap.CreateXmlDeclaration("1.0", null, null)); 400 requestedSnap.AppendChild(requestedSnap.CreateXmlDeclaration("1.0", null, null));
401 requestedSnap.AppendChild(requestedSnap.CreateWhitespace("\r\n")); 401 requestedSnap.AppendChild(requestedSnap.CreateWhitespace("\r\n"));
402 XmlNode regiondata = requestedSnap.CreateNode(XmlNodeType.Element, "regiondata", ""); 402 XmlNode regiondata = requestedSnap.CreateNode(XmlNodeType.Element, "regiondata", "");
403 try 403 try
404 { 404 {
405 if (regionName == null || regionName == "") 405 if (regionName == null || regionName == "")
406 { 406 {
407 foreach (Scene scene in m_scenes) 407 foreach (Scene scene in m_scenes)
408 { 408 {
409 string path = DataFileName(scene); 409 string path = DataFileName(scene);
410 XmlDocument regionSnap = new XmlDocument(); 410 XmlDocument regionSnap = new XmlDocument();
411 regionSnap.PreserveWhitespace = true; 411 regionSnap.PreserveWhitespace = true;
412 412
413 regionSnap.Load(path); 413 regionSnap.Load(path);
414 XmlNode nodeOrig = regionSnap["region"]; 414 XmlNode nodeOrig = regionSnap["region"];
415 XmlNode nodeDest = requestedSnap.ImportNode(nodeOrig, true); 415 XmlNode nodeDest = requestedSnap.ImportNode(nodeOrig, true);
416 //requestedSnap.AppendChild(nodeDest); 416 //requestedSnap.AppendChild(nodeDest);
417 417
418 regiondata.AppendChild(requestedSnap.CreateWhitespace("\r\n")); 418 regiondata.AppendChild(requestedSnap.CreateWhitespace("\r\n"));
419 regiondata.AppendChild(nodeDest); 419 regiondata.AppendChild(nodeDest);
420 } 420 }
421 } 421 }
422 else 422 else
423 { 423 {
424 Scene scene = SceneForName(regionName); 424 Scene scene = SceneForName(regionName);
425 requestedSnap.Load(DataFileName(scene)); 425 requestedSnap.Load(DataFileName(scene));
426 } 426 }
427 // requestedSnap.InsertBefore(requestedSnap.CreateXmlDeclaration("1.0", null, null), 427 // requestedSnap.InsertBefore(requestedSnap.CreateXmlDeclaration("1.0", null, null),
428// requestedSnap.DocumentElement); 428// requestedSnap.DocumentElement);
429 requestedSnap.AppendChild(regiondata); 429 requestedSnap.AppendChild(regiondata);
430 regiondata.AppendChild(requestedSnap.CreateWhitespace("\r\n")); 430 regiondata.AppendChild(requestedSnap.CreateWhitespace("\r\n"));
431 431
432 432
433 } 433 }
434 catch (XmlException e) 434 catch (XmlException e)
435 { 435 {
436 m_log.Warn("[DATASNAPSHOT]: XmlException while trying to load snapshot: " + e.ToString()); 436 m_log.Warn("[DATASNAPSHOT]: XmlException while trying to load snapshot: " + e.ToString());
437 requestedSnap = GetErrorMessage(regionName, e); 437 requestedSnap = GetErrorMessage(regionName, e);
438 } 438 }
439 catch (Exception e) 439 catch (Exception e)
440 { 440 {
441 m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to load snapshot: " + e.StackTrace); 441 m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to load snapshot: " + e.StackTrace);
442 requestedSnap = GetErrorMessage(regionName, e); 442 requestedSnap = GetErrorMessage(regionName, e);
443 } 443 }
444 444
445 445
446 return requestedSnap; 446 return requestedSnap;
447 } 447 }
448 448
449 private XmlDocument GetErrorMessage(string regionName, Exception e) 449 private XmlDocument GetErrorMessage(string regionName, Exception e)
450 { 450 {
451 XmlDocument errorMessage = new XmlDocument(); 451 XmlDocument errorMessage = new XmlDocument();
452 XmlNode error = errorMessage.CreateNode(XmlNodeType.Element, "error", ""); 452 XmlNode error = errorMessage.CreateNode(XmlNodeType.Element, "error", "");
453 XmlNode region = errorMessage.CreateNode(XmlNodeType.Element, "region", ""); 453 XmlNode region = errorMessage.CreateNode(XmlNodeType.Element, "region", "");
454 region.InnerText = regionName; 454 region.InnerText = regionName;
455 455
456 XmlNode exception = errorMessage.CreateNode(XmlNodeType.Element, "exception", ""); 456 XmlNode exception = errorMessage.CreateNode(XmlNodeType.Element, "exception", "");
457 exception.InnerText = e.ToString(); 457 exception.InnerText = e.ToString();
458 458
459 error.AppendChild(region); 459 error.AppendChild(region);
460 error.AppendChild(exception); 460 error.AppendChild(exception);
461 errorMessage.AppendChild(error); 461 errorMessage.AppendChild(error);
462 462
463 return errorMessage; 463 return errorMessage;
464 } 464 }
465 465
466 #endregion 466 #endregion
467 467
468 #region Event callbacks 468 #region Event callbacks
469 469
470 private void SnapshotTimerCallback(object timer, ElapsedEventArgs args) 470 private void SnapshotTimerCallback(object timer, ElapsedEventArgs args)
471 { 471 {
472 MakeNewSnapshot(); 472 MakeNewSnapshot();
473 //Add extra calls here 473 //Add extra calls here
474 } 474 }
475 475
476 #endregion 476 #endregion
477 477
478 #region External data services 478 #region External data services
479 private void NotifyDataServices(string servicesStr) 479 private void NotifyDataServices(string servicesStr)
480 { 480 {
481 Stream reply = null; 481 Stream reply = null;
482 string delimStr = ";"; 482 string delimStr = ";";
483 char [] delimiter = delimStr.ToCharArray(); 483 char [] delimiter = delimStr.ToCharArray();
484 484
485 string[] services = servicesStr.Split(delimiter); 485 string[] services = servicesStr.Split(delimiter);
486 486
487 for (int i = 0; i < services.Length; i++) 487 for (int i = 0; i < services.Length; i++)
488 { 488 {
489 string url = services[i].Trim(); 489 string url = services[i].Trim();
490 RestClient cli = new RestClient(url); 490 RestClient cli = new RestClient(url);
491 cli.AddQueryParameter("host", m_hostname); 491 cli.AddQueryParameter("host", m_hostname);
492 cli.AddQueryParameter("port", m_listener_port); 492 cli.AddQueryParameter("port", m_listener_port);
493 cli.RequestMethod = "GET"; 493 cli.RequestMethod = "GET";
494 try 494 try
495 { 495 {
496 reply = cli.Request(); 496 reply = cli.Request();
497 } 497 }
498 catch (System.Net.WebException) 498 catch (System.Net.WebException)
499 { 499 {
500 m_log.Warn("[DATASNAPSHOT] Unable to notify " + url); 500 m_log.Warn("[DATASNAPSHOT] Unable to notify " + url);
501 } 501 }
502 catch (Exception e) 502 catch (Exception e)
503 { 503 {
504 m_log.Warn("[DATASNAPSHOT] Ignoring unknown exception " + e.ToString()); 504 m_log.Warn("[DATASNAPSHOT] Ignoring unknown exception " + e.ToString());
505 } 505 }
506 byte[] response = new byte[1024]; 506 byte[] response = new byte[1024];
507 int n = 0; 507 int n = 0;
508 try 508 try
509 { 509 {
510 n = reply.Read(response, 0, 1024); 510 n = reply.Read(response, 0, 1024);
511 } 511 }
512 catch (Exception e) 512 catch (Exception e)
513 { 513 {
514 m_log.Warn("[DATASNAPSHOT] Unable to decode reply from data service. Ignoring. " + e.StackTrace); 514 m_log.Warn("[DATASNAPSHOT] Unable to decode reply from data service. Ignoring. " + e.StackTrace);
515 } 515 }
516 // This is not quite working, so... 516 // This is not quite working, so...
517 string responseStr = System.Text.ASCIIEncoding.UTF8.GetString(response); 517 string responseStr = System.Text.ASCIIEncoding.UTF8.GetString(response);
518 m_log.Info("[DATASNAPSHOT] data service notified: " + url); 518 m_log.Info("[DATASNAPSHOT] data service notified: " + url);
519 } 519 }
520 520
521 } 521 }
522 #endregion 522 #endregion
523 } 523 }
524} 524}
diff --git a/OpenSim/Region/DataSnapshot/EstateSnapshot.cs b/OpenSim/Region/DataSnapshot/EstateSnapshot.cs
index 76fed59..eeb9709 100644
--- a/OpenSim/Region/DataSnapshot/EstateSnapshot.cs
+++ b/OpenSim/Region/DataSnapshot/EstateSnapshot.cs
@@ -1,68 +1,68 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using System.Xml; 4using System.Xml;
5using OpenSim.Region.Environment.Scenes; 5using OpenSim.Region.Environment.Scenes;
6using OpenSim.Region.Environment.Modules.LandManagement; 6using OpenSim.Region.Environment.Modules.LandManagement;
7using OpenSim.Framework; 7using OpenSim.Framework;
8using OpenSim.Framework.Console; 8using OpenSim.Framework.Console;
9using OpenSim.Framework.Communications; 9using OpenSim.Framework.Communications;
10using libsecondlife; 10using libsecondlife;
11using libsecondlife.Packets; 11using libsecondlife.Packets;
12 12
13namespace OpenSim.Region.DataSnapshot 13namespace OpenSim.Region.DataSnapshot
14{ 14{
15 public class EstateSnapshot : IDataSnapshotProvider 15 public class EstateSnapshot : IDataSnapshotProvider
16 { 16 {
17 private Scene m_scene = null; 17 private Scene m_scene = null;
18 private DataSnapshotManager m_parent = null; 18 private DataSnapshotManager m_parent = null;
19 19
20 #region IDataSnapshotProvider Members 20 #region IDataSnapshotProvider Members
21 21
22 public XmlNode RequestSnapshotData(XmlDocument factory) 22 public XmlNode RequestSnapshotData(XmlDocument factory)
23 { 23 {
24 //Estate data section - contains who owns a set of sims and the name of the set. 24 //Estate data section - contains who owns a set of sims and the name of the set.
25 //In Opensim all the estate names are the same as the Master Avatar (owner of the sim) 25 //In Opensim all the estate names are the same as the Master Avatar (owner of the sim)
26 //Now in DataSnapshotProvider module form! 26 //Now in DataSnapshotProvider module form!
27 XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", ""); 27 XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", "");
28 28
29 LLUUID ownerid = m_scene.RegionInfo.MasterAvatarAssignedUUID; 29 LLUUID ownerid = m_scene.RegionInfo.MasterAvatarAssignedUUID;
30 30
31 //TODO: Change to query userserver about the master avatar UUID ? 31 //TODO: Change to query userserver about the master avatar UUID ?
32 String firstname = m_scene.RegionInfo.MasterAvatarFirstName; 32 String firstname = m_scene.RegionInfo.MasterAvatarFirstName;
33 String lastname = m_scene.RegionInfo.MasterAvatarLastName; 33 String lastname = m_scene.RegionInfo.MasterAvatarLastName;
34 34
35 //TODO: Fix the marshalling system to have less copypasta gruntwork 35 //TODO: Fix the marshalling system to have less copypasta gruntwork
36 XmlNode user = factory.CreateNode(XmlNodeType.Element, "user", ""); 36 XmlNode user = factory.CreateNode(XmlNodeType.Element, "user", "");
37 XmlAttribute type = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "type", ""); 37 XmlAttribute type = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "type", "");
38 type.Value = "owner"; 38 type.Value = "owner";
39 user.Attributes.Append(type); 39 user.Attributes.Append(type);
40 40
41 //TODO: Create more TODOs 41 //TODO: Create more TODOs
42 XmlNode username = factory.CreateNode(XmlNodeType.Element, "name", ""); 42 XmlNode username = factory.CreateNode(XmlNodeType.Element, "name", "");
43 username.InnerText = firstname + " " + lastname; 43 username.InnerText = firstname + " " + lastname;
44 user.AppendChild(username); 44 user.AppendChild(username);
45 45
46 XmlNode useruuid = factory.CreateNode(XmlNodeType.Element, "uuid", ""); 46 XmlNode useruuid = factory.CreateNode(XmlNodeType.Element, "uuid", "");
47 useruuid.InnerText = ownerid.ToString(); 47 useruuid.InnerText = ownerid.ToString();
48 user.AppendChild(useruuid); 48 user.AppendChild(useruuid);
49 49
50 estatedata.AppendChild(user); 50 estatedata.AppendChild(user);
51 51
52 return estatedata; 52 return estatedata;
53 } 53 }
54 54
55 public void Initialize(Scene scene, DataSnapshotManager parent) 55 public void Initialize(Scene scene, DataSnapshotManager parent)
56 { 56 {
57 m_scene = scene; 57 m_scene = scene;
58 m_parent = parent; 58 m_parent = parent;
59 } 59 }
60 60
61 public Scene GetParentScene 61 public Scene GetParentScene
62 { 62 {
63 get { return m_scene; } 63 get { return m_scene; }
64 } 64 }
65 65
66 #endregion 66 #endregion
67 } 67 }
68} 68}
diff --git a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs
index 42b6818..26124ce 100644
--- a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs
+++ b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs
@@ -1,48 +1,48 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.Xml; 32using System.Xml;
33using OpenSim.Region.Environment.Scenes; 33using OpenSim.Region.Environment.Scenes;
34using libsecondlife; 34using libsecondlife;
35 35
36namespace OpenSim.Region.DataSnapshot 36namespace OpenSim.Region.DataSnapshot
37{ 37{
38 public interface IDataSnapshotProvider 38 public interface IDataSnapshotProvider
39 { 39 {
40 XmlNode RequestSnapshotData(XmlDocument document); 40 XmlNode RequestSnapshotData(XmlDocument document);
41 41
42 //void PrepareData(); 42 //void PrepareData();
43 43
44 void Initialize(Scene scene, DataSnapshotManager parent); 44 void Initialize(Scene scene, DataSnapshotManager parent);
45 45
46 Scene GetParentScene { get; } 46 Scene GetParentScene { get; }
47 } 47 }
48} 48}
diff --git a/OpenSim/Region/DataSnapshot/LandSnapshot.cs b/OpenSim/Region/DataSnapshot/LandSnapshot.cs
index 47dea43..a8bbed1 100644
--- a/OpenSim/Region/DataSnapshot/LandSnapshot.cs
+++ b/OpenSim/Region/DataSnapshot/LandSnapshot.cs
@@ -1,267 +1,267 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.Xml; 32using System.Xml;
33using System.Reflection; 33using System.Reflection;
34 34
35using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
36using OpenSim.Region.Environment.Modules.LandManagement; 36using OpenSim.Region.Environment.Modules.LandManagement;
37using OpenSim.Region.Environment.Interfaces; 37using OpenSim.Region.Environment.Interfaces;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using libsecondlife; 41using libsecondlife;
42using libsecondlife.Packets; 42using libsecondlife.Packets;
43 43
44namespace OpenSim.Region.DataSnapshot 44namespace OpenSim.Region.DataSnapshot
45{ 45{
46 public class LandSnapshot : IDataSnapshotProvider 46 public class LandSnapshot : IDataSnapshotProvider
47 { 47 {
48 private Scene m_scene = null; 48 private Scene m_scene = null;
49 private DataSnapshotManager m_parent = null; 49 private DataSnapshotManager m_parent = null;
50 //private Dictionary<int, Land> m_landIndexed = new Dictionary<int, Land>(); 50 //private Dictionary<int, Land> m_landIndexed = new Dictionary<int, Land>();
51 private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 51 private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 #region Dead code 53 #region Dead code
54 54
55 /* 55 /*
56 * David, I don't think we need this at all. When we do the snapshot, we can 56 * David, I don't think we need this at all. When we do the snapshot, we can
57 * simply look into the parcels that are marked for ShowDirectory -- see 57 * simply look into the parcels that are marked for ShowDirectory -- see
58 * conditional in RequestSnapshotData 58 * conditional in RequestSnapshotData
59 * 59 *
60 //Revise this, look for more direct way of checking for change in land 60 //Revise this, look for more direct way of checking for change in land
61 #region Client hooks 61 #region Client hooks
62 62
63 public void OnNewClient(IClientAPI client) 63 public void OnNewClient(IClientAPI client)
64 { 64 {
65 //Land hooks 65 //Land hooks
66 client.OnParcelDivideRequest += ParcelSplitHook; 66 client.OnParcelDivideRequest += ParcelSplitHook;
67 client.OnParcelJoinRequest += ParcelSplitHook; 67 client.OnParcelJoinRequest += ParcelSplitHook;
68 client.OnParcelPropertiesUpdateRequest += ParcelPropsHook; 68 client.OnParcelPropertiesUpdateRequest += ParcelPropsHook;
69 } 69 }
70 70
71 public void ParcelSplitHook(int west, int south, int east, int north, IClientAPI remote_client) 71 public void ParcelSplitHook(int west, int south, int east, int north, IClientAPI remote_client)
72 { 72 {
73 PrepareData(); 73 PrepareData();
74 } 74 }
75 75
76 public void ParcelPropsHook(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) 76 public void ParcelPropsHook(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
77 { 77 {
78 PrepareData(); 78 PrepareData();
79 } 79 }
80 80
81 #endregion 81 #endregion
82 82
83 public void PrepareData() 83 public void PrepareData()
84 { 84 {
85 m_log.Info("[EXTERNALDATA]: Generating land data."); 85 m_log.Info("[EXTERNALDATA]: Generating land data.");
86 86
87 m_landIndexed.Clear(); 87 m_landIndexed.Clear();
88 88
89 //Index sim land 89 //Index sim land
90 foreach (KeyValuePair<int, Land> curLand in m_scene.LandManager.landList) 90 foreach (KeyValuePair<int, Land> curLand in m_scene.LandManager.landList)
91 { 91 {
92 //if ((curLand.Value.landData.landFlags & (uint)Parcel.ParcelFlags.ShowDirectory) == (uint)Parcel.ParcelFlags.ShowDirectory) 92 //if ((curLand.Value.landData.landFlags & (uint)Parcel.ParcelFlags.ShowDirectory) == (uint)Parcel.ParcelFlags.ShowDirectory)
93 //{ 93 //{
94 m_landIndexed.Add(curLand.Key, curLand.Value.Copy()); 94 m_landIndexed.Add(curLand.Key, curLand.Value.Copy());
95 //} 95 //}
96 } 96 }
97 } 97 }
98 98
99 public Dictionary<int,Land> IndexedLand { 99 public Dictionary<int,Land> IndexedLand {
100 get { return m_landIndexed; } 100 get { return m_landIndexed; }
101 } 101 }
102 */ 102 */
103 103
104 #endregion 104 #endregion
105 105
106 #region IDataSnapshotProvider members 106 #region IDataSnapshotProvider members
107 107
108 public void Initialize(Scene scene, DataSnapshotManager parent) 108 public void Initialize(Scene scene, DataSnapshotManager parent)
109 { 109 {
110 m_scene = scene; 110 m_scene = scene;
111 m_parent = parent; 111 m_parent = parent;
112 //m_scene.EventManager.OnNewClient += OnNewClient; 112 //m_scene.EventManager.OnNewClient += OnNewClient;
113 } 113 }
114 114
115 public Scene GetParentScene 115 public Scene GetParentScene
116 { 116 {
117 get { return m_scene; } 117 get { return m_scene; }
118 } 118 }
119 119
120 public XmlNode RequestSnapshotData(XmlDocument nodeFactory) 120 public XmlNode RequestSnapshotData(XmlDocument nodeFactory)
121 { 121 {
122 ILandChannel landChannel = (LandChannel)m_scene.LandChannel; 122 ILandChannel landChannel = (LandChannel)m_scene.LandChannel;
123 Dictionary<int, ILandObject> landList = null; 123 Dictionary<int, ILandObject> landList = null;
124 try 124 try
125 { 125 {
126 Type landChannelType = typeof(LandChannel); 126 Type landChannelType = typeof(LandChannel);
127 FieldInfo landListField = landChannelType.GetField("landList", BindingFlags.NonPublic | BindingFlags.Instance); 127 FieldInfo landListField = landChannelType.GetField("landList", BindingFlags.NonPublic | BindingFlags.Instance);
128 if (landListField != null) 128 if (landListField != null)
129 { 129 {
130 landList = (Dictionary<int, ILandObject>)landListField.GetValue(landChannel); 130 landList = (Dictionary<int, ILandObject>)landListField.GetValue(landChannel);
131 } 131 }
132 } 132 }
133 catch (Exception e) 133 catch (Exception e)
134 { 134 {
135 Console.WriteLine("[DATASNAPSHOT] couldn't access field reflectively\n" + e.ToString()); 135 Console.WriteLine("[DATASNAPSHOT] couldn't access field reflectively\n" + e.ToString());
136 } 136 }
137 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", ""); 137 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", "");
138 if (landList != null) 138 if (landList != null)
139 { 139 {
140 140
141 //foreach (KeyValuePair<int, Land> curParcel in m_landIndexed) 141 //foreach (KeyValuePair<int, Land> curParcel in m_landIndexed)
142 foreach (LandObject land in landList.Values) 142 foreach (LandObject land in landList.Values)
143 { 143 {
144 LandData parcel = land.landData; 144 LandData parcel = land.landData;
145 if ((parcel.landFlags & (uint)Parcel.ParcelFlags.ShowDirectory) == (uint)Parcel.ParcelFlags.ShowDirectory) 145 if ((parcel.landFlags & (uint)Parcel.ParcelFlags.ShowDirectory) == (uint)Parcel.ParcelFlags.ShowDirectory)
146 { 146 {
147 147
148 //TODO: make better method of marshalling data from LandData to XmlNode 148 //TODO: make better method of marshalling data from LandData to XmlNode
149 XmlNode xmlparcel = nodeFactory.CreateNode(XmlNodeType.Element, "parcel", ""); 149 XmlNode xmlparcel = nodeFactory.CreateNode(XmlNodeType.Element, "parcel", "");
150 150
151 // Attributes of the parcel node 151 // Attributes of the parcel node
152 XmlAttribute scripts_attr = nodeFactory.CreateAttribute("scripts"); 152 XmlAttribute scripts_attr = nodeFactory.CreateAttribute("scripts");
153 scripts_attr.Value = GetScriptsPermissions(parcel); 153 scripts_attr.Value = GetScriptsPermissions(parcel);
154 XmlAttribute category_attr = nodeFactory.CreateAttribute("category"); 154 XmlAttribute category_attr = nodeFactory.CreateAttribute("category");
155 category_attr.Value = parcel.category.ToString(); 155 category_attr.Value = parcel.category.ToString();
156 //XmlAttribute entities_attr = nodeFactory.CreateAttribute("entities"); 156 //XmlAttribute entities_attr = nodeFactory.CreateAttribute("entities");
157 //entities_attr.Value = land.primsOverMe.Count.ToString(); 157 //entities_attr.Value = land.primsOverMe.Count.ToString();
158 xmlparcel.Attributes.Append(scripts_attr); 158 xmlparcel.Attributes.Append(scripts_attr);
159 xmlparcel.Attributes.Append(category_attr); 159 xmlparcel.Attributes.Append(category_attr);
160 //xmlparcel.Attributes.Append(entities_attr); 160 //xmlparcel.Attributes.Append(entities_attr);
161 161
162 162
163 //name, description, area, and UUID 163 //name, description, area, and UUID
164 XmlNode name = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); 164 XmlNode name = nodeFactory.CreateNode(XmlNodeType.Element, "name", "");
165 name.InnerText = parcel.landName; 165 name.InnerText = parcel.landName;
166 xmlparcel.AppendChild(name); 166 xmlparcel.AppendChild(name);
167 167
168 XmlNode desc = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); 168 XmlNode desc = nodeFactory.CreateNode(XmlNodeType.Element, "description", "");
169 desc.InnerText = parcel.landDesc; 169 desc.InnerText = parcel.landDesc;
170 xmlparcel.AppendChild(desc); 170 xmlparcel.AppendChild(desc);
171 171
172 XmlNode uuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); 172 XmlNode uuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", "");
173 uuid.InnerText = parcel.globalID.ToString(); 173 uuid.InnerText = parcel.globalID.ToString();
174 xmlparcel.AppendChild(uuid); 174 xmlparcel.AppendChild(uuid);
175 175
176 XmlNode area = nodeFactory.CreateNode(XmlNodeType.Element, "area", ""); 176 XmlNode area = nodeFactory.CreateNode(XmlNodeType.Element, "area", "");
177 area.InnerText = parcel.area.ToString(); 177 area.InnerText = parcel.area.ToString();
178 xmlparcel.AppendChild(area); 178 xmlparcel.AppendChild(area);
179 179
180 //default location 180 //default location
181 XmlNode tpLocation = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); 181 XmlNode tpLocation = nodeFactory.CreateNode(XmlNodeType.Element, "location", "");
182 LLVector3 loc = parcel.userLocation; 182 LLVector3 loc = parcel.userLocation;
183 if (loc.Equals(LLVector3.Zero)) // This test is mute at this point: the location is wrong by default 183 if (loc.Equals(LLVector3.Zero)) // This test is mute at this point: the location is wrong by default
184 loc = new LLVector3((parcel.AABBMax.X - parcel.AABBMin.X) / 2, (parcel.AABBMax.Y - parcel.AABBMin.Y) / 2, (parcel.AABBMax.Y - parcel.AABBMin.Y) / 2); 184 loc = new LLVector3((parcel.AABBMax.X - parcel.AABBMin.X) / 2, (parcel.AABBMax.Y - parcel.AABBMin.Y) / 2, (parcel.AABBMax.Y - parcel.AABBMin.Y) / 2);
185 tpLocation.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); 185 tpLocation.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString();
186 xmlparcel.AppendChild(tpLocation); 186 xmlparcel.AppendChild(tpLocation);
187 187
188 //TODO: figure how to figure out teleport system landData.landingType 188 //TODO: figure how to figure out teleport system landData.landingType
189 189
190 //land texture snapshot uuid 190 //land texture snapshot uuid
191 if (parcel.snapshotID != LLUUID.Zero) 191 if (parcel.snapshotID != LLUUID.Zero)
192 { 192 {
193 XmlNode textureuuid = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); 193 XmlNode textureuuid = nodeFactory.CreateNode(XmlNodeType.Element, "image", "");
194 textureuuid.InnerText = parcel.snapshotID.ToString(); 194 textureuuid.InnerText = parcel.snapshotID.ToString();
195 xmlparcel.AppendChild(textureuuid); 195 xmlparcel.AppendChild(textureuuid);
196 } 196 }
197 197
198 //attached user and group 198 //attached user and group
199 if (parcel.groupID != LLUUID.Zero) 199 if (parcel.groupID != LLUUID.Zero)
200 { 200 {
201 XmlNode groupblock = nodeFactory.CreateNode(XmlNodeType.Element, "group", ""); 201 XmlNode groupblock = nodeFactory.CreateNode(XmlNodeType.Element, "group", "");
202 XmlNode groupuuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); 202 XmlNode groupuuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", "");
203 groupuuid.InnerText = parcel.groupID.ToString(); 203 groupuuid.InnerText = parcel.groupID.ToString();
204 groupblock.AppendChild(groupuuid); 204 groupblock.AppendChild(groupuuid);
205 205
206 //No name yet, there's no way to get a group name since they don't exist yet. 206 //No name yet, there's no way to get a group name since they don't exist yet.
207 //TODO: When groups are supported, add the group handling code. 207 //TODO: When groups are supported, add the group handling code.
208 208
209 xmlparcel.AppendChild(groupblock); 209 xmlparcel.AppendChild(groupblock);
210 } 210 }
211 211
212 if (!parcel.isGroupOwned) 212 if (!parcel.isGroupOwned)
213 { 213 {
214 XmlNode userblock = nodeFactory.CreateNode(XmlNodeType.Element, "owner", ""); 214 XmlNode userblock = nodeFactory.CreateNode(XmlNodeType.Element, "owner", "");
215 215
216 LLUUID userOwnerUUID = parcel.ownerID; 216 LLUUID userOwnerUUID = parcel.ownerID;
217 217
218 XmlNode useruuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); 218 XmlNode useruuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", "");
219 useruuid.InnerText = userOwnerUUID.ToString(); 219 useruuid.InnerText = userOwnerUUID.ToString();
220 userblock.AppendChild(useruuid); 220 userblock.AppendChild(useruuid);
221 221
222 try 222 try
223 { 223 {
224 XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); 224 XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", "");
225 UserProfileData userProfile = m_scene.CommsManager.UserService.GetUserProfile(userOwnerUUID); 225 UserProfileData userProfile = m_scene.CommsManager.UserService.GetUserProfile(userOwnerUUID);
226 username.InnerText = userProfile.username + " " + userProfile.surname; 226 username.InnerText = userProfile.username + " " + userProfile.surname;
227 userblock.AppendChild(username); 227 userblock.AppendChild(username);
228 } 228 }
229 catch (Exception) 229 catch (Exception)
230 { 230 {
231 m_log.Info("[DATASNAPSHOT]: Cannot find owner name; ignoring this parcel"); 231 m_log.Info("[DATASNAPSHOT]: Cannot find owner name; ignoring this parcel");
232 } 232 }
233 233
234 xmlparcel.AppendChild(userblock); 234 xmlparcel.AppendChild(userblock);
235 } 235 }
236 //else 236 //else
237 //{ 237 //{
238 // XmlAttribute type = (XmlAttribute)nodeFactory.CreateNode(XmlNodeType.Attribute, "type", ""); 238 // XmlAttribute type = (XmlAttribute)nodeFactory.CreateNode(XmlNodeType.Attribute, "type", "");
239 // type.InnerText = "owner"; 239 // type.InnerText = "owner";
240 // groupblock.Attributes.Append(type); 240 // groupblock.Attributes.Append(type);
241 //} 241 //}
242 242
243 parent.AppendChild(xmlparcel); 243 parent.AppendChild(xmlparcel);
244 } 244 }
245 } 245 }
246 //snap.AppendChild(parent); 246 //snap.AppendChild(parent);
247 } 247 }
248 248
249 return parent; 249 return parent;
250 } 250 }
251 251
252 #endregion 252 #endregion
253 253
254 #region Helper functions 254 #region Helper functions
255 255
256 private string GetScriptsPermissions(LandData parcel) 256 private string GetScriptsPermissions(LandData parcel)
257 { 257 {
258 if ((parcel.landFlags & (uint)Parcel.ParcelFlags.AllowOtherScripts) == (uint)Parcel.ParcelFlags.AllowOtherScripts) 258 if ((parcel.landFlags & (uint)Parcel.ParcelFlags.AllowOtherScripts) == (uint)Parcel.ParcelFlags.AllowOtherScripts)
259 return "yes"; 259 return "yes";
260 else 260 else
261 return "no"; 261 return "no";
262 262
263 } 263 }
264 264
265 #endregion 265 #endregion
266 } 266 }
267} 267}
diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
index 9222b48..cb74183 100644
--- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
+++ b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
@@ -1,83 +1,83 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using System.Xml; 4using System.Xml;
5using System.Reflection; 5using System.Reflection;
6using OpenSim.Region.Environment.Scenes; 6using OpenSim.Region.Environment.Scenes;
7using OpenSim.Framework; 7using OpenSim.Framework;
8using libsecondlife; 8using libsecondlife;
9 9
10namespace OpenSim.Region.DataSnapshot 10namespace OpenSim.Region.DataSnapshot
11{ 11{
12 public class ObjectSnapshot : IDataSnapshotProvider 12 public class ObjectSnapshot : IDataSnapshotProvider
13 { 13 {
14 private Scene m_scene = null; 14 private Scene m_scene = null;
15 private DataSnapshotManager m_parent = null; 15 private DataSnapshotManager m_parent = null;
16 private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 16 private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
17 17
18 public void Initialize(Scene scene, DataSnapshotManager parent) 18 public void Initialize(Scene scene, DataSnapshotManager parent)
19 { 19 {
20 m_scene = scene; 20 m_scene = scene;
21 m_parent = parent; 21 m_parent = parent;
22 } 22 }
23 23
24 public Scene GetParentScene 24 public Scene GetParentScene
25 { 25 {
26 get { return m_scene; } 26 get { return m_scene; }
27 } 27 }
28 28
29 public XmlNode RequestSnapshotData(XmlDocument nodeFactory) 29 public XmlNode RequestSnapshotData(XmlDocument nodeFactory)
30 { 30 {
31 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "objectdata", ""); 31 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "objectdata", "");
32 XmlNode node; 32 XmlNode node;
33#if LIBSL_IS_FIXED 33#if LIBSL_IS_FIXED
34 foreach (EntityBase entity in m_scene.Entities.Values) 34 foreach (EntityBase entity in m_scene.Entities.Values)
35 { 35 {
36 // only objects, not avatars 36 // only objects, not avatars
37 if (entity is SceneObjectGroup) 37 if (entity is SceneObjectGroup)
38 { 38 {
39 SceneObjectGroup obj = (SceneObjectGroup)entity; 39 SceneObjectGroup obj = (SceneObjectGroup)entity;
40 40
41 XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", ""); 41 XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", "");
42 42
43 node = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); 43 node = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", "");
44 node.InnerText = obj.UUID.ToString(); 44 node.InnerText = obj.UUID.ToString();
45 xmlobject.AppendChild(node); 45 xmlobject.AppendChild(node);
46 46
47 SceneObjectPart m_rootPart = null; 47 SceneObjectPart m_rootPart = null;
48 try 48 try
49 { 49 {
50 Type sog = typeof(SceneObjectGroup); 50 Type sog = typeof(SceneObjectGroup);
51 FieldInfo rootField = sog.GetField("m_rootPart", BindingFlags.NonPublic | BindingFlags.Instance); 51 FieldInfo rootField = sog.GetField("m_rootPart", BindingFlags.NonPublic | BindingFlags.Instance);
52 if (rootField != null) 52 if (rootField != null)
53 { 53 {
54 m_rootPart = (SceneObjectPart)rootField.GetValue(obj); 54 m_rootPart = (SceneObjectPart)rootField.GetValue(obj);
55 } 55 }
56 } 56 }
57 catch (Exception e) 57 catch (Exception e)
58 { 58 {
59 Console.WriteLine("[DATASNAPSHOT] couldn't access field reflectively\n" + e.ToString()); 59 Console.WriteLine("[DATASNAPSHOT] couldn't access field reflectively\n" + e.ToString());
60 } 60 }
61 if (m_rootPart != null) 61 if (m_rootPart != null)
62 { 62 {
63 node = nodeFactory.CreateNode(XmlNodeType.Element, "title", ""); 63 node = nodeFactory.CreateNode(XmlNodeType.Element, "title", "");
64 node.InnerText = m_rootPart.Name; 64 node.InnerText = m_rootPart.Name;
65 xmlobject.AppendChild(node); 65 xmlobject.AppendChild(node);
66 66
67 node = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); 67 node = nodeFactory.CreateNode(XmlNodeType.Element, "description", "");
68 node.InnerText = m_rootPart.Description; 68 node.InnerText = m_rootPart.Description;
69 xmlobject.AppendChild(node); 69 xmlobject.AppendChild(node);
70 70
71 node = nodeFactory.CreateNode(XmlNodeType.Element, "flags", ""); 71 node = nodeFactory.CreateNode(XmlNodeType.Element, "flags", "");
72 node.InnerText = String.Format("{0:x}", m_rootPart.ObjectFlags); 72 node.InnerText = String.Format("{0:x}", m_rootPart.ObjectFlags);
73 xmlobject.AppendChild(node); 73 xmlobject.AppendChild(node);
74 } 74 }
75 parent.AppendChild(xmlobject); 75 parent.AppendChild(xmlobject);
76 } 76 }
77 } 77 }
78#endif 78#endif
79 return parent; 79 return parent;
80 80
81 } 81 }
82 } 82 }
83} 83}