From 49d19e36507a01c657e9e9efb3edbfb5b15ddfa8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 4 Sep 2015 15:17:53 -0700 Subject: Moved DataSnapshot feature to OptionalModules too. --- OpenSim/Region/DataSnapshot/DataRequestHandler.cs | 99 ----- OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 490 --------------------- OpenSim/Region/DataSnapshot/EstateSnapshot.cs | 149 ------- .../DataSnapshot/Interfaces/IDataSnapshot.cs | 36 -- .../Interfaces/IDataSnapshotProvider.cs | 46 -- OpenSim/Region/DataSnapshot/LLSDDiscovery.cs | 44 -- OpenSim/Region/DataSnapshot/LandSnapshot.cs | 433 ------------------ OpenSim/Region/DataSnapshot/ObjectSnapshot.cs | 264 ----------- .../Region/DataSnapshot/Properties/AssemblyInfo.cs | 33 -- OpenSim/Region/DataSnapshot/SnapshotStore.cs | 337 -------------- .../DataSnapshot/DataRequestHandler.cs | 99 +++++ .../DataSnapshot/DataSnapshotManager.cs | 487 ++++++++++++++++++++ .../OptionalModules/DataSnapshot/EstateSnapshot.cs | 149 +++++++ .../DataSnapshot/Interfaces/IDataSnapshot.cs | 36 ++ .../Interfaces/IDataSnapshotProvider.cs | 46 ++ .../OptionalModules/DataSnapshot/LLSDDiscovery.cs | 44 ++ .../OptionalModules/DataSnapshot/LandSnapshot.cs | 433 ++++++++++++++++++ .../OptionalModules/DataSnapshot/ObjectSnapshot.cs | 264 +++++++++++ .../OptionalModules/DataSnapshot/SnapshotStore.cs | 337 ++++++++++++++ prebuild.xml | 35 -- 20 files changed, 1895 insertions(+), 1966 deletions(-) delete mode 100644 OpenSim/Region/DataSnapshot/DataRequestHandler.cs delete mode 100644 OpenSim/Region/DataSnapshot/DataSnapshotManager.cs delete mode 100644 OpenSim/Region/DataSnapshot/EstateSnapshot.cs delete mode 100644 OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs delete mode 100644 OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs delete mode 100644 OpenSim/Region/DataSnapshot/LLSDDiscovery.cs delete mode 100644 OpenSim/Region/DataSnapshot/LandSnapshot.cs delete mode 100644 OpenSim/Region/DataSnapshot/ObjectSnapshot.cs delete mode 100644 OpenSim/Region/DataSnapshot/Properties/AssemblyInfo.cs delete mode 100644 OpenSim/Region/DataSnapshot/SnapshotStore.cs create mode 100644 OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs create mode 100644 OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs create mode 100644 OpenSim/Region/OptionalModules/DataSnapshot/EstateSnapshot.cs create mode 100644 OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshot.cs create mode 100644 OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshotProvider.cs create mode 100644 OpenSim/Region/OptionalModules/DataSnapshot/LLSDDiscovery.cs create mode 100644 OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs create mode 100644 OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs create mode 100644 OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs diff --git a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs deleted file mode 100644 index 50276ae..0000000 --- a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs +++ /dev/null @@ -1,99 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSimulator Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System.Collections; -using System.Reflection; -using System.Xml; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Capabilities; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Framework.Scenes; -using Caps = OpenSim.Framework.Capabilities.Caps; - -namespace OpenSim.Region.DataSnapshot -{ - public class DataRequestHandler - { -// private Scene m_scene = null; - private DataSnapshotManager m_externalData = null; - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public DataRequestHandler(Scene scene, DataSnapshotManager externalData) - { -// m_scene = scene; - m_externalData = externalData; - - //Register HTTP handler - if (MainServer.Instance.AddHTTPHandler("collector", OnGetSnapshot)) - { - m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); - } - // Register validation callback handler - MainServer.Instance.AddHTTPHandler("validate", OnValidate); - - } - - public Hashtable OnGetSnapshot(Hashtable keysvals) - { - m_log.Debug("[DATASNAPSHOT] Received collection request"); - Hashtable reply = new Hashtable(); - int statuscode = 200; - - string snapObj = (string)keysvals["region"]; - - XmlDocument response = m_externalData.GetSnapshot(snapObj); - - reply["str_response_string"] = response.OuterXml; - reply["int_response_code"] = statuscode; - reply["content_type"] = "text/xml"; - - return reply; - } - - public Hashtable OnValidate(Hashtable keysvals) - { - m_log.Debug("[DATASNAPSHOT] Received validation request"); - Hashtable reply = new Hashtable(); - int statuscode = 200; - - string secret = (string)keysvals["secret"]; - if (secret == m_externalData.Secret.ToString()) - statuscode = 403; - - reply["str_response_string"] = string.Empty; - reply["int_response_code"] = statuscode; - reply["content_type"] = "text/plain"; - - return reply; - } - - } -} diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs deleted file mode 100644 index d5ae83e..0000000 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ /dev/null @@ -1,490 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSimulator Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Text; -using System.Xml; -using log4net; -using Nini.Config; -using OpenMetaverse; -using Mono.Addins; -using OpenSim.Framework; -using OpenSim.Region.DataSnapshot.Interfaces; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -[assembly: Addin("DataSnapshot", OpenSim.VersionInfo.VersionNumber)] -[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)] - -namespace OpenSim.Region.DataSnapshot -{ - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DataSnapshotManager")] - public class DataSnapshotManager : ISharedRegionModule, IDataSnapshot - { - #region Class members - //Information from config - private bool m_enabled = false; - private bool m_configLoaded = false; - private List m_disabledModules = new List(); - private Dictionary m_gridinfo = new Dictionary(); - private string m_snapsDir = "DataSnapshot"; - private string m_exposure_level = "minimum"; - - //Lists of stuff we need - private List m_scenes = new List(); - private List m_dataproviders = new List(); - - //Various internal objects - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - internal object m_syncInit = new object(); - - //DataServices and networking - private string m_dataServices = "noservices"; - public string m_listener_port = ConfigSettings.DefaultRegionHttpPort.ToString(); - public string m_hostname = "127.0.0.1"; - private UUID m_Secret = UUID.Random(); - private bool m_servicesNotified = false; - - //Update timers - private int m_period = 20; // in seconds - private int m_maxStales = 500; - private int m_stales = 0; - private int m_lastUpdate = 0; - - //Program objects - private SnapshotStore m_snapStore = null; - - #endregion - - #region Properties - - public string ExposureLevel - { - get { return m_exposure_level; } - } - - public UUID Secret - { - get { return m_Secret; } - } - - #endregion - - #region Region Module interface - - public void Initialise(IConfigSource config) - { - if (!m_configLoaded) - { - m_configLoaded = true; - //m_log.Debug("[DATASNAPSHOT]: Loading configuration"); - //Read from the config for options - lock (m_syncInit) - { - try - { - m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); - string gatekeeper = Util.GetConfigVarFromSections(config, "GatekeeperURI", - new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); - // Legacy. Remove soon! - if (string.IsNullOrEmpty(gatekeeper)) - { - IConfig conf = config.Configs["GridService"]; - if (conf != null) - gatekeeper = conf.GetString("Gatekeeper", gatekeeper); - } - if (!string.IsNullOrEmpty(gatekeeper)) - m_gridinfo.Add("gatekeeperURL", gatekeeper); - - m_gridinfo.Add( - "name", config.Configs["DataSnapshot"].GetString("gridname", "the lost continent of hippo")); - m_exposure_level = config.Configs["DataSnapshot"].GetString("data_exposure", m_exposure_level); - m_period = config.Configs["DataSnapshot"].GetInt("default_snapshot_period", m_period); - m_maxStales = config.Configs["DataSnapshot"].GetInt("max_changes_before_update", m_maxStales); - m_snapsDir = config.Configs["DataSnapshot"].GetString("snapshot_cache_directory", m_snapsDir); - m_listener_port = config.Configs["Network"].GetString("http_listener_port", m_listener_port); - - m_dataServices = config.Configs["DataSnapshot"].GetString("data_services", m_dataServices); - // New way of spec'ing data services, one per line - AddDataServicesVars(config.Configs["DataSnapshot"]); - - String[] annoying_string_array = config.Configs["DataSnapshot"].GetString("disable_modules", "").Split(".".ToCharArray()); - foreach (String bloody_wanker in annoying_string_array) - { - m_disabledModules.Add(bloody_wanker); - } - m_lastUpdate = Environment.TickCount; - } - catch (Exception) - { - m_log.Warn("[DATASNAPSHOT]: Could not load configuration. DataSnapshot will be disabled."); - m_enabled = false; - return; - } - - } - - } - - } - - public void AddRegion(Scene scene) - { - if (!m_enabled) - return; - - m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); - - if (!m_servicesNotified) - { - m_hostname = scene.RegionInfo.ExternalHostName; - m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); - - //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer - new DataRequestHandler(scene, this); - - if (m_dataServices != "" && m_dataServices != "noservices") - NotifyDataServices(m_dataServices, "online"); - - m_servicesNotified = true; - } - - m_scenes.Add(scene); - m_snapStore.AddScene(scene); - - Assembly currentasm = Assembly.GetExecutingAssembly(); - - foreach (Type pluginType in currentasm.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - if (pluginType.GetInterface("IDataSnapshotProvider") != null) - { - IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); - module.Initialize(scene, this); - module.OnStale += MarkDataStale; - - m_dataproviders.Add(module); - m_snapStore.AddProvider(module); - - m_log.Debug("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); - } - } - } - } - - } - - public void RemoveRegion(Scene scene) - { - if (!m_enabled) - return; - - m_log.Info("[DATASNAPSHOT]: Region " + scene.RegionInfo.RegionName + " is being removed, removing from indexing"); - Scene restartedScene = SceneForUUID(scene.RegionInfo.RegionID); - - m_scenes.Remove(restartedScene); - m_snapStore.RemoveScene(restartedScene); - - //Getting around the fact that we can't remove objects from a collection we are enumerating over - List providersToRemove = new List(); - - foreach (IDataSnapshotProvider provider in m_dataproviders) - { - if (provider.GetParentScene == restartedScene) - { - providersToRemove.Add(provider); - } - } - - foreach (IDataSnapshotProvider provider in providersToRemove) - { - m_dataproviders.Remove(provider); - m_snapStore.RemoveProvider(provider); - } - - m_snapStore.RemoveScene(restartedScene); - } - - public void PostInitialise() - { - } - - public void RegionLoaded(Scene scene) - { - if (!m_enabled) - return; - - m_log.DebugFormat("[DATASNAPSHOT]: Marking scene {0} as stale.", scene.RegionInfo.RegionName); - m_snapStore.ForceSceneStale(scene); - } - - public void Close() - { - if (!m_enabled) - return; - - if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") - NotifyDataServices(m_dataServices, "offline"); - } - - - public string Name - { - get { return "External Data Generator"; } - } - - public Type ReplaceableInterface - { - get { return null; } - } - - #endregion - - #region Associated helper functions - - public Scene SceneForName(string name) - { - foreach (Scene scene in m_scenes) - if (scene.RegionInfo.RegionName == name) - return scene; - - return null; - } - - public Scene SceneForUUID(UUID id) - { - foreach (Scene scene in m_scenes) - if (scene.RegionInfo.RegionID == id) - return scene; - - return null; - } - - private void AddDataServicesVars(IConfig config) - { - // Make sure the services given this way aren't in m_dataServices already - List servs = new List(m_dataServices.Split(new char[] { ';' })); - - StringBuilder sb = new StringBuilder(); - string[] keys = config.GetKeys(); - - if (keys.Length > 0) - { - IEnumerable serviceKeys = keys.Where(value => value.StartsWith("DATA_SRV_")); - foreach (string serviceKey in serviceKeys) - { - string keyValue = config.GetString(serviceKey, string.Empty).Trim(); - if (!servs.Contains(keyValue)) - sb.Append(keyValue).Append(";"); - } - } - - m_dataServices = (m_dataServices == "noservices") ? sb.ToString() : sb.Append(m_dataServices).ToString(); - } - - #endregion - - #region [Public] Snapshot storage functions - - /** - * Reply to the http request - */ - public XmlDocument GetSnapshot(string regionName) - { - CheckStale(); - - XmlDocument requestedSnap = new XmlDocument(); - requestedSnap.AppendChild(requestedSnap.CreateXmlDeclaration("1.0", null, null)); - requestedSnap.AppendChild(requestedSnap.CreateWhitespace("\r\n")); - - XmlNode regiondata = requestedSnap.CreateNode(XmlNodeType.Element, "regiondata", ""); - try - { - if (string.IsNullOrEmpty(regionName)) - { - XmlNode timerblock = requestedSnap.CreateNode(XmlNodeType.Element, "expire", ""); - timerblock.InnerText = m_period.ToString(); - regiondata.AppendChild(timerblock); - - regiondata.AppendChild(requestedSnap.CreateWhitespace("\r\n")); - foreach (Scene scene in m_scenes) - { - regiondata.AppendChild(m_snapStore.GetScene(scene, requestedSnap)); - } - } - else - { - Scene scene = SceneForName(regionName); - regiondata.AppendChild(m_snapStore.GetScene(scene, requestedSnap)); - } - requestedSnap.AppendChild(regiondata); - regiondata.AppendChild(requestedSnap.CreateWhitespace("\r\n")); - } - catch (XmlException e) - { - m_log.Warn("[DATASNAPSHOT]: XmlException while trying to load snapshot: " + e.ToString()); - requestedSnap = GetErrorMessage(regionName, e); - } - catch (Exception e) - { - m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to load snapshot: " + e.StackTrace); - requestedSnap = GetErrorMessage(regionName, e); - } - - - return requestedSnap; - } - - private XmlDocument GetErrorMessage(string regionName, Exception e) - { - XmlDocument errorMessage = new XmlDocument(); - XmlNode error = errorMessage.CreateNode(XmlNodeType.Element, "error", ""); - XmlNode region = errorMessage.CreateNode(XmlNodeType.Element, "region", ""); - region.InnerText = regionName; - - XmlNode exception = errorMessage.CreateNode(XmlNodeType.Element, "exception", ""); - exception.InnerText = e.ToString(); - - error.AppendChild(region); - error.AppendChild(exception); - errorMessage.AppendChild(error); - - return errorMessage; - } - - #endregion - - #region External data services - private void NotifyDataServices(string servicesStr, string serviceName) - { - Stream reply = null; - string delimStr = ";"; - char [] delimiter = delimStr.ToCharArray(); - - string[] services = servicesStr.Split(delimiter, StringSplitOptions.RemoveEmptyEntries); - - for (int i = 0; i < services.Length; i++) - { - string url = services[i].Trim(); - using (RestClient cli = new RestClient(url)) - { - cli.AddQueryParameter("service", serviceName); - cli.AddQueryParameter("host", m_hostname); - cli.AddQueryParameter("port", m_listener_port); - cli.AddQueryParameter("secret", m_Secret.ToString()); - cli.RequestMethod = "GET"; - try - { - reply = cli.Request(null); - } - catch (WebException) - { - m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url); - } - catch (Exception e) - { - m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString()); - } - - byte[] response = new byte[1024]; - // int n = 0; - try - { - // n = reply.Read(response, 0, 1024); - reply.Read(response, 0, 1024); - } - catch (Exception e) - { - m_log.WarnFormat("[DATASNAPSHOT]: Unable to decode reply from data service. Ignoring. {0}", e.StackTrace); - } - // This is not quite working, so... - // string responseStr = Util.UTF8.GetString(response); - m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret); - } - } - - } - #endregion - - #region Latency-based update functions - - public void MarkDataStale(IDataSnapshotProvider provider) - { - //Behavior here: Wait m_period seconds, then update if there has not been a request in m_period seconds - //or m_maxStales has been exceeded - m_stales++; - } - - private void CheckStale() - { - // Wrap check - if (Environment.TickCount < m_lastUpdate) - { - m_lastUpdate = Environment.TickCount; - } - - if (m_stales >= m_maxStales) - { - if (Environment.TickCount - m_lastUpdate >= 20000) - { - m_stales = 0; - m_lastUpdate = Environment.TickCount; - MakeEverythingStale(); - } - } - else - { - if (m_lastUpdate + 1000 * m_period < Environment.TickCount) - { - m_stales = 0; - m_lastUpdate = Environment.TickCount; - MakeEverythingStale(); - } - } - } - - public void MakeEverythingStale() - { - m_log.Debug("[DATASNAPSHOT]: Marking all scenes as stale."); - foreach (Scene scene in m_scenes) - { - m_snapStore.ForceSceneStale(scene); - } - } - #endregion - - } -} diff --git a/OpenSim/Region/DataSnapshot/EstateSnapshot.cs b/OpenSim/Region/DataSnapshot/EstateSnapshot.cs deleted file mode 100644 index 8da9e8c..0000000 --- a/OpenSim/Region/DataSnapshot/EstateSnapshot.cs +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Xml; -using OpenMetaverse; -using OpenSim.Framework; - -using OpenSim.Region.DataSnapshot.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Region.DataSnapshot.Providers -{ - public class EstateSnapshot : IDataSnapshotProvider - { - /* This module doesn't check for changes, since it's *assumed* there are none. - * Nevertheless, it's possible to have changes, since all the fields are public. - * There's no event to subscribe to. :/ - * - * I don't think anything changes the fields beyond RegionModule PostInit, however. - */ - private Scene m_scene = null; - // private DataSnapshotManager m_parent = null; - private bool m_stale = true; - - #region IDataSnapshotProvider Members - - public XmlNode RequestSnapshotData(XmlDocument factory) - { - //Estate data section - contains who owns a set of sims and the name of the set. - //Now in DataSnapshotProvider module form! - XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", ""); - - UUID ownerid = m_scene.RegionInfo.EstateSettings.EstateOwner; - - UserAccount userInfo = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid); - //TODO: Change to query userserver about the master avatar UUID ? - String firstname; - String lastname; - - if (userInfo != null) - { - firstname = userInfo.FirstName; - lastname = userInfo.LastName; - - //TODO: Fix the marshalling system to have less copypasta gruntwork - XmlNode user = factory.CreateNode(XmlNodeType.Element, "user", ""); -// XmlAttribute type = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "type", ""); -// type.Value = "owner"; -// user.Attributes.Append(type); - - //TODO: Create more TODOs - XmlNode username = factory.CreateNode(XmlNodeType.Element, "name", ""); - username.InnerText = firstname + " " + lastname; - user.AppendChild(username); - - XmlNode useruuid = factory.CreateNode(XmlNodeType.Element, "uuid", ""); - useruuid.InnerText = ownerid.ToString(); - user.AppendChild(useruuid); - - estatedata.AppendChild(user); - } - - XmlNode estatename = factory.CreateNode(XmlNodeType.Element, "name", ""); - estatename.InnerText = m_scene.RegionInfo.EstateSettings.EstateName.ToString(); - estatedata.AppendChild(estatename); - - XmlNode estateid = factory.CreateNode(XmlNodeType.Element, "id", ""); - estateid.InnerText = m_scene.RegionInfo.EstateSettings.EstateID.ToString(); - estatedata.AppendChild(estateid); - - XmlNode parentid = factory.CreateNode(XmlNodeType.Element, "parentid", ""); - parentid.InnerText = m_scene.RegionInfo.EstateSettings.ParentEstateID.ToString(); - estatedata.AppendChild(parentid); - - XmlNode flags = factory.CreateNode(XmlNodeType.Element, "flags", ""); - - XmlAttribute teleport = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "teleport", ""); - teleport.Value = m_scene.RegionInfo.EstateSettings.AllowDirectTeleport.ToString(); - flags.Attributes.Append(teleport); - - XmlAttribute publicaccess = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "public", ""); - publicaccess.Value = m_scene.RegionInfo.EstateSettings.PublicAccess.ToString(); - flags.Attributes.Append(publicaccess); - - estatedata.AppendChild(flags); - - this.Stale = false; - return estatedata; - } - - public void Initialize(Scene scene, DataSnapshotManager parent) - { - m_scene = scene; - // m_parent = parent; - } - - public Scene GetParentScene - { - get { return m_scene; } - } - - public String Name { - get { return "EstateSnapshot"; } - } - - public bool Stale - { - get { - return m_stale; - } - set { - m_stale = value; - - if (m_stale) - OnStale(this); - } - } - - public event ProviderStale OnStale; - - #endregion - } -} diff --git a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs deleted file mode 100644 index 3b3db65..0000000 --- a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Xml; - -namespace OpenSim.Region.DataSnapshot.Interfaces -{ - public interface IDataSnapshot - { - XmlDocument GetSnapshot(string regionName); - } -} diff --git a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs deleted file mode 100644 index daea373..0000000 --- a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshotProvider.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSimulator Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.Xml; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.DataSnapshot.Interfaces -{ - public delegate void ProviderStale(IDataSnapshotProvider provider); - - public interface IDataSnapshotProvider - { - XmlNode RequestSnapshotData(XmlDocument document); - void Initialize(Scene scene, DataSnapshotManager parent); - Scene GetParentScene { get; } - String Name { get; } - bool Stale { get; set; } - event ProviderStale OnStale; - } -} diff --git a/OpenSim/Region/DataSnapshot/LLSDDiscovery.cs b/OpenSim/Region/DataSnapshot/LLSDDiscovery.cs deleted file mode 100644 index 54a87f9..0000000 --- a/OpenSim/Region/DataSnapshot/LLSDDiscovery.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSimulator Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using OpenSim.Framework.Capabilities; - -namespace OpenSim.Region.DataSnapshot -{ - [OSDMap] - public class LLSDDiscoveryResponse - { - public OSDArray snapshot_resources; - } - - [OSDMap] - public class LLSDDiscoveryDataURL - { - public string snapshot_format; - public string snapshot_url; - } -} diff --git a/OpenSim/Region/DataSnapshot/LandSnapshot.cs b/OpenSim/Region/DataSnapshot/LandSnapshot.cs deleted file mode 100644 index b8c90cd..0000000 --- a/OpenSim/Region/DataSnapshot/LandSnapshot.cs +++ /dev/null @@ -1,433 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSimulator Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Xml; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; - -using OpenSim.Region.CoreModules.World.Land; -using OpenSim.Region.DataSnapshot.Interfaces; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Region.DataSnapshot.Providers -{ - public class LandSnapshot : IDataSnapshotProvider - { - private Scene m_scene = null; - private DataSnapshotManager m_parent = null; - //private Dictionary m_landIndexed = new Dictionary(); - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private bool m_stale = true; - - #region Dead code - - /* - * David, I don't think we need this at all. When we do the snapshot, we can - * simply look into the parcels that are marked for ShowDirectory -- see - * conditional in RequestSnapshotData - * - //Revise this, look for more direct way of checking for change in land - #region Client hooks - - public void OnNewClient(IClientAPI client) - { - //Land hooks - client.OnParcelDivideRequest += ParcelSplitHook; - client.OnParcelJoinRequest += ParcelSplitHook; - client.OnParcelPropertiesUpdateRequest += ParcelPropsHook; - } - - public void ParcelSplitHook(int west, int south, int east, int north, IClientAPI remote_client) - { - PrepareData(); - } - - public void ParcelPropsHook(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) - { - PrepareData(); - } - - #endregion - - public void PrepareData() - { - m_log.Info("[EXTERNALDATA]: Generating land data."); - - m_landIndexed.Clear(); - - //Index sim land - foreach (KeyValuePair curLand in m_scene.LandManager.landList) - { - //if ((curLand.Value.LandData.landFlags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory) - //{ - m_landIndexed.Add(curLand.Key, curLand.Value.Copy()); - //} - } - } - - public Dictionary IndexedLand { - get { return m_landIndexed; } - } - */ - - #endregion - - #region IDataSnapshotProvider members - - public void Initialize(Scene scene, DataSnapshotManager parent) - { - m_scene = scene; - m_parent = parent; - - //Brought back from the dead for staleness checks. - m_scene.EventManager.OnNewClient += OnNewClient; - } - - public Scene GetParentScene - { - get { return m_scene; } - } - - public XmlNode RequestSnapshotData(XmlDocument nodeFactory) - { - ILandChannel landChannel = m_scene.LandChannel; - List parcels = landChannel.AllParcels(); - - IDwellModule dwellModule = m_scene.RequestModuleInterface(); - - XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", ""); - if (parcels != null) - { - - //foreach (KeyValuePair curParcel in m_landIndexed) - foreach (ILandObject parcel_interface in parcels) - { - // Play it safe - if (!(parcel_interface is LandObject)) - continue; - - LandObject land = (LandObject)parcel_interface; - - LandData parcel = land.LandData; - if (m_parent.ExposureLevel.Equals("all") || - (m_parent.ExposureLevel.Equals("minimum") && - (parcel.Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory)) - { - - //TODO: make better method of marshalling data from LandData to XmlNode - XmlNode xmlparcel = nodeFactory.CreateNode(XmlNodeType.Element, "parcel", ""); - - // Attributes of the parcel node - XmlAttribute scripts_attr = nodeFactory.CreateAttribute("scripts"); - scripts_attr.Value = GetScriptsPermissions(parcel); - XmlAttribute build_attr = nodeFactory.CreateAttribute("build"); - build_attr.Value = GetBuildPermissions(parcel); - XmlAttribute public_attr = nodeFactory.CreateAttribute("public"); - public_attr.Value = GetPublicPermissions(parcel); - // Check the category of the Parcel - XmlAttribute category_attr = nodeFactory.CreateAttribute("category"); - category_attr.Value = ((int)parcel.Category).ToString(); - // Check if the parcel is for sale - XmlAttribute forsale_attr = nodeFactory.CreateAttribute("forsale"); - forsale_attr.Value = CheckForSale(parcel); - XmlAttribute sales_attr = nodeFactory.CreateAttribute("salesprice"); - sales_attr.Value = parcel.SalePrice.ToString(); - - XmlAttribute directory_attr = nodeFactory.CreateAttribute("showinsearch"); - directory_attr.Value = GetShowInSearch(parcel); - //XmlAttribute entities_attr = nodeFactory.CreateAttribute("entities"); - //entities_attr.Value = land.primsOverMe.Count.ToString(); - xmlparcel.Attributes.Append(directory_attr); - xmlparcel.Attributes.Append(scripts_attr); - xmlparcel.Attributes.Append(build_attr); - xmlparcel.Attributes.Append(public_attr); - xmlparcel.Attributes.Append(category_attr); - xmlparcel.Attributes.Append(forsale_attr); - xmlparcel.Attributes.Append(sales_attr); - //xmlparcel.Attributes.Append(entities_attr); - - - //name, description, area, and UUID - XmlNode name = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); - name.InnerText = parcel.Name; - xmlparcel.AppendChild(name); - - XmlNode desc = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); - desc.InnerText = parcel.Description; - xmlparcel.AppendChild(desc); - - XmlNode uuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); - uuid.InnerText = parcel.GlobalID.ToString(); - xmlparcel.AppendChild(uuid); - - XmlNode area = nodeFactory.CreateNode(XmlNodeType.Element, "area", ""); - area.InnerText = parcel.Area.ToString(); - xmlparcel.AppendChild(area); - - //default location - XmlNode tpLocation = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); - Vector3 loc = parcel.UserLocation; - if (loc.Equals(Vector3.Zero)) // This test is moot at this point: the location is wrong by default - loc = new Vector3((parcel.AABBMax.X + parcel.AABBMin.X) / 2, (parcel.AABBMax.Y + parcel.AABBMin.Y) / 2, (parcel.AABBMax.Z + parcel.AABBMin.Z) / 2); - tpLocation.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); - xmlparcel.AppendChild(tpLocation); - - XmlNode infouuid = nodeFactory.CreateNode(XmlNodeType.Element, "infouuid", ""); - uint x = (uint)loc.X, y = (uint)loc.Y; - findPointInParcel(land, ref x, ref y); // find a suitable spot - infouuid.InnerText = Util.BuildFakeParcelID( - m_scene.RegionInfo.RegionHandle, x, y).ToString(); - xmlparcel.AppendChild(infouuid); - - XmlNode dwell = nodeFactory.CreateNode(XmlNodeType.Element, "dwell", ""); - if (dwellModule != null) - dwell.InnerText = dwellModule.GetDwell(parcel.GlobalID).ToString(); - else - dwell.InnerText = "0"; - xmlparcel.AppendChild(dwell); - - //TODO: figure how to figure out teleport system landData.landingType - - //land texture snapshot uuid - if (parcel.SnapshotID != UUID.Zero) - { - XmlNode textureuuid = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); - textureuuid.InnerText = parcel.SnapshotID.ToString(); - xmlparcel.AppendChild(textureuuid); - } - - string groupName = String.Empty; - - //attached user and group - if (parcel.GroupID != UUID.Zero) - { - XmlNode groupblock = nodeFactory.CreateNode(XmlNodeType.Element, "group", ""); - XmlNode groupuuid = nodeFactory.CreateNode(XmlNodeType.Element, "groupuuid", ""); - groupuuid.InnerText = parcel.GroupID.ToString(); - groupblock.AppendChild(groupuuid); - - IGroupsModule gm = m_scene.RequestModuleInterface(); - if (gm != null) - { - GroupRecord g = gm.GetGroupRecord(parcel.GroupID); - if (g != null) - groupName = g.GroupName; - } - - XmlNode groupname = nodeFactory.CreateNode(XmlNodeType.Element, "groupname", ""); - groupname.InnerText = groupName; - groupblock.AppendChild(groupname); - - xmlparcel.AppendChild(groupblock); - } - - XmlNode userblock = nodeFactory.CreateNode(XmlNodeType.Element, "owner", ""); - - UUID userOwnerUUID = parcel.OwnerID; - - XmlNode useruuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); - useruuid.InnerText = userOwnerUUID.ToString(); - userblock.AppendChild(useruuid); - - if (!parcel.IsGroupOwned) - { - try - { - XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); - UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, userOwnerUUID); - username.InnerText = account.FirstName + " " + account.LastName; - userblock.AppendChild(username); - } - catch (Exception) - { - //m_log.Info("[DATASNAPSHOT]: Cannot find owner name; ignoring this parcel"); - } - - } - else - { - XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); - username.InnerText = groupName; - userblock.AppendChild(username); - } - - xmlparcel.AppendChild(userblock); - - parent.AppendChild(xmlparcel); - } - } - //snap.AppendChild(parent); - } - - this.Stale = false; - return parent; - } - - public String Name - { - get { return "LandSnapshot"; } - } - - public bool Stale - { - get - { - return m_stale; - } - set - { - m_stale = value; - - if (m_stale) - OnStale(this); - } - } - - public event ProviderStale OnStale; - - #endregion - - #region Helper functions - - private string GetScriptsPermissions(LandData parcel) - { - if ((parcel.Flags & (uint)ParcelFlags.AllowOtherScripts) == (uint)ParcelFlags.AllowOtherScripts) - return "true"; - else - return "false"; - - } - - private string GetPublicPermissions(LandData parcel) - { - if ((parcel.Flags & (uint)ParcelFlags.UseAccessList) == (uint)ParcelFlags.UseAccessList) - return "false"; - else - return "true"; - - } - - private string GetBuildPermissions(LandData parcel) - { - if ((parcel.Flags & (uint)ParcelFlags.CreateObjects) == (uint)ParcelFlags.CreateObjects) - return "true"; - else - return "false"; - - } - - private string CheckForSale(LandData parcel) - { - if ((parcel.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale) - return "true"; - else - return "false"; - } - - private string GetShowInSearch(LandData parcel) - { - if ((parcel.Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory) - return "true"; - else - return "false"; - - } - - #endregion - - #region Change detection hooks - - public void OnNewClient(IClientAPI client) - { - //Land hooks - client.OnParcelDivideRequest += delegate(int west, int south, int east, int north, - IClientAPI remote_client) { this.Stale = true; }; - client.OnParcelJoinRequest += delegate(int west, int south, int east, int north, - IClientAPI remote_client) { this.Stale = true; }; - client.OnParcelPropertiesUpdateRequest += delegate(LandUpdateArgs args, int local_id, - IClientAPI remote_client) { this.Stale = true; }; - client.OnParcelBuy += delegate(UUID agentId, UUID groupId, bool final, bool groupOwned, - bool removeContribution, int parcelLocalID, int parcelArea, int parcelPrice, bool authenticated) - { this.Stale = true; }; - } - - public void ParcelSplitHook(int west, int south, int east, int north, IClientAPI remote_client) - { - this.Stale = true; - } - - public void ParcelPropsHook(LandUpdateArgs args, int local_id, IClientAPI remote_client) - { - this.Stale = true; - } - - #endregion - - // this is needed for non-convex parcels (example: rectangular parcel, and in the exact center - // another, smaller rectangular parcel). Both will have the same initial coordinates. - private void findPointInParcel(ILandObject land, ref uint refX, ref uint refY) - { - m_log.DebugFormat("[DATASNAPSHOT] trying {0}, {1}", refX, refY); - // the point we started with already is in the parcel - if (land.ContainsPoint((int)refX, (int)refY)) return; - - // ... otherwise, we have to search for a point within the parcel - uint startX = (uint)land.LandData.AABBMin.X; - uint startY = (uint)land.LandData.AABBMin.Y; - uint endX = (uint)land.LandData.AABBMax.X; - uint endY = (uint)land.LandData.AABBMax.Y; - - // default: center of the parcel - refX = (startX + endX) / 2; - refY = (startY + endY) / 2; - // If the center point is within the parcel, take that one - if (land.ContainsPoint((int)refX, (int)refY)) return; - - // otherwise, go the long way. - for (uint y = startY; y <= endY; ++y) - { - for (uint x = startX; x <= endX; ++x) - { - if (land.ContainsPoint((int)x, (int)y)) - { - // found a point - refX = x; - refY = y; - return; - } - } - } - } - } -} - diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs deleted file mode 100644 index 0bb4044..0000000 --- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Xml; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.DataSnapshot.Interfaces; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.DataSnapshot.Providers -{ - public class ObjectSnapshot : IDataSnapshotProvider - { - private Scene m_scene = null; - // private DataSnapshotManager m_parent = null; - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private bool m_stale = true; - - private static UUID m_DefaultImage = new UUID("89556747-24cb-43ed-920b-47caed15465f"); - private static UUID m_BlankImage = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); - - - public void Initialize(Scene scene, DataSnapshotManager parent) - { - m_scene = scene; - // m_parent = parent; - - //To check for staleness, we must catch all incoming client packets. - m_scene.EventManager.OnNewClient += OnNewClient; - m_scene.EventManager.OnParcelPrimCountAdd += delegate(SceneObjectGroup obj) { this.Stale = true; }; - } - - public void OnNewClient(IClientAPI client) - { - //Detect object data changes by hooking into the IClientAPI. - //Very dirty, and breaks whenever someone changes the client API. - - client.OnAddPrim += delegate (UUID ownerID, UUID groupID, Vector3 RayEnd, Quaternion rot, - PrimitiveBaseShape shape, byte bypassRaycast, Vector3 RayStart, UUID RayTargetID, - byte RayEndIsIntersection) { this.Stale = true; }; - client.OnLinkObjects += delegate (IClientAPI remoteClient, uint parent, List children) - { this.Stale = true; }; - client.OnDelinkObjects += delegate(List primIds, IClientAPI clientApi) { this.Stale = true; }; - client.OnGrabUpdate += delegate(UUID objectID, Vector3 offset, Vector3 grapPos, - IClientAPI remoteClient, List surfaceArgs) { this.Stale = true; }; - client.OnObjectAttach += delegate(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, - bool silent) { this.Stale = true; }; - client.OnObjectDuplicate += delegate(uint localID, Vector3 offset, uint dupeFlags, UUID AgentID, - UUID GroupID) { this.Stale = true; }; - client.OnObjectDuplicateOnRay += delegate(uint localID, uint dupeFlags, UUID AgentID, UUID GroupID, - UUID RayTargetObj, Vector3 RayEnd, Vector3 RayStart, bool BypassRaycast, - bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates) { this.Stale = true; }; - client.OnObjectIncludeInSearch += delegate(IClientAPI remoteClient, bool IncludeInSearch, uint localID) - { this.Stale = true; }; - client.OnObjectPermissions += delegate(IClientAPI controller, UUID agentID, UUID sessionID, - byte field, uint localId, uint mask, byte set) { this.Stale = true; }; - client.OnRezObject += delegate(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, - Vector3 RayStart, UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, - bool RezSelected, - bool RemoveItem, UUID fromTaskID) { this.Stale = true; }; - } - - public Scene GetParentScene - { - get { return m_scene; } - } - - public XmlNode RequestSnapshotData(XmlDocument nodeFactory) - { - m_log.Debug("[DATASNAPSHOT]: Generating object data for scene " + m_scene.RegionInfo.RegionName); - - XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "objectdata", ""); - XmlNode node; - - EntityBase[] entities = m_scene.Entities.GetEntities(); - foreach (EntityBase entity in entities) - { - // only objects, not avatars - if (entity is SceneObjectGroup) - { - SceneObjectGroup obj = (SceneObjectGroup)entity; - -// m_log.Debug("[DATASNAPSHOT]: Found object " + obj.Name + " in scene"); - - // libomv will complain about PrimFlags.JointWheel - // being obsolete, so we... - #pragma warning disable 0612 - if ((obj.RootPart.Flags & PrimFlags.JointWheel) == PrimFlags.JointWheel) - { - SceneObjectPart m_rootPart = obj.RootPart; - - ILandObject land = m_scene.LandChannel.GetLandObject(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y); - - XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", ""); - node = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); - node.InnerText = obj.UUID.ToString(); - xmlobject.AppendChild(node); - - node = nodeFactory.CreateNode(XmlNodeType.Element, "title", ""); - node.InnerText = m_rootPart.Name; - xmlobject.AppendChild(node); - - node = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); - node.InnerText = m_rootPart.Description; - xmlobject.AppendChild(node); - - node = nodeFactory.CreateNode(XmlNodeType.Element, "flags", ""); - node.InnerText = String.Format("{0:x}", (uint)m_rootPart.Flags); - xmlobject.AppendChild(node); - - node = nodeFactory.CreateNode(XmlNodeType.Element, "regionuuid", ""); - node.InnerText = m_scene.RegionInfo.RegionSettings.RegionUUID.ToString(); - xmlobject.AppendChild(node); - - if (land != null && land.LandData != null) - { - node = nodeFactory.CreateNode(XmlNodeType.Element, "parceluuid", ""); - node.InnerText = land.LandData.GlobalID.ToString(); - xmlobject.AppendChild(node); - } - else - { - // Something is wrong with this object. Let's not list it. - m_log.WarnFormat("[DATASNAPSHOT]: Bad data for object {0} ({1}) in region {2}", obj.Name, obj.UUID, m_scene.RegionInfo.RegionName); - continue; - } - - node = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); - Vector3 loc = obj.AbsolutePosition; - node.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); - xmlobject.AppendChild(node); - - string bestImage = GuessImage(obj); - if (bestImage != string.Empty) - { - node = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); - node.InnerText = bestImage; - xmlobject.AppendChild(node); - } - - parent.AppendChild(xmlobject); - } - #pragma warning disable 0612 - } - } - this.Stale = false; - return parent; - } - - public String Name - { - get { return "ObjectSnapshot"; } - } - - public bool Stale - { - get - { - return m_stale; - } - set - { - m_stale = value; - - if (m_stale) - OnStale(this); - } - } - - public event ProviderStale OnStale; - - /// - /// Guesses the best image, based on a simple heuristic. It guesses only for boxes. - /// We're optimizing for boxes, because those are the most common objects - /// marked "Show in search" -- boxes with content inside.For other shapes, - /// it's really hard to tell which texture should be grabbed. - /// - /// - /// - private string GuessImage(SceneObjectGroup sog) - { - string bestguess = string.Empty; - Dictionary counts = new Dictionary(); - - PrimitiveBaseShape shape = sog.RootPart.Shape; - if (shape != null && shape.ProfileShape == ProfileShape.Square) - { - Primitive.TextureEntry textures = shape.Textures; - if (textures != null) - { - if (textures.DefaultTexture != null && - textures.DefaultTexture.TextureID != UUID.Zero && - textures.DefaultTexture.TextureID != m_DefaultImage && - textures.DefaultTexture.TextureID != m_BlankImage && - textures.DefaultTexture.RGBA.A < 50f) - { - counts[textures.DefaultTexture.TextureID] = 8; - } - - if (textures.FaceTextures != null) - { - foreach (Primitive.TextureEntryFace tentry in textures.FaceTextures) - { - if (tentry != null) - { - if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50) - { - int c = 0; - counts.TryGetValue(tentry.TextureID, out c); - counts[tentry.TextureID] = c + 1; - // decrease the default texture count - if (counts.ContainsKey(textures.DefaultTexture.TextureID)) - counts[textures.DefaultTexture.TextureID] = counts[textures.DefaultTexture.TextureID] - 1; - } - } - } - } - - // Let's pick the most unique texture - int min = 9999; - foreach (KeyValuePair kv in counts) - { - if (kv.Value < min && kv.Value >= 1) - { - bestguess = kv.Key.ToString(); - min = kv.Value; - } - } - } - } - - return bestguess; - } - } -} diff --git a/OpenSim/Region/DataSnapshot/Properties/AssemblyInfo.cs b/OpenSim/Region/DataSnapshot/Properties/AssemblyInfo.cs deleted file mode 100644 index e60d3ae..0000000 --- a/OpenSim/Region/DataSnapshot/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OpenSim.Region.DataSnapshot")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("http://opensimulator.org")] -[assembly: AssemblyProduct("OpenSim")] -[assembly: AssemblyCopyright("OpenSimulator developers")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("06c36944-a28d-470e-912c-654c3edaba6b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("0.8.2.*")] - diff --git a/OpenSim/Region/DataSnapshot/SnapshotStore.cs b/OpenSim/Region/DataSnapshot/SnapshotStore.cs deleted file mode 100644 index 480aaaf..0000000 --- a/OpenSim/Region/DataSnapshot/SnapshotStore.cs +++ /dev/null @@ -1,337 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSimulator Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using System.Xml; -using log4net; -using OpenSim.Region.DataSnapshot.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.DataSnapshot -{ - public class SnapshotStore - { - #region Class Members - private String m_directory = "unyuu"; //not an attempt at adding RM references to core SVN, honest - private Dictionary m_scenes = null; - private List m_providers = null; - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Dictionary m_gridinfo = null; - private bool m_cacheEnabled = true; - private string m_listener_port = "9000"; //TODO: Set default port over 9000 - private string m_hostname = "127.0.0.1"; - #endregion - - public SnapshotStore(string directory, Dictionary gridinfo, string port, string hostname) { - m_directory = directory; - m_scenes = new Dictionary(); - m_providers = new List(); - m_gridinfo = gridinfo; - m_listener_port = port; - m_hostname = hostname; - - if (Directory.Exists(m_directory)) - { - m_log.Info("[DATASNAPSHOT]: Response and fragment cache directory already exists."); - } - else - { - // Try to create the directory. - m_log.Info("[DATASNAPSHOT]: Creating directory " + m_directory); - try - { - Directory.CreateDirectory(m_directory); - } - catch (Exception e) - { - m_log.Error("[DATASNAPSHOT]: Failed to create directory " + m_directory, e); - - //This isn't a horrible problem, just disable cacheing. - m_cacheEnabled = false; - m_log.Error("[DATASNAPSHOT]: Could not create directory, response cache has been disabled."); - } - } - } - - public void ForceSceneStale(Scene scene) { - m_scenes[scene] = true; - } - - #region Fragment storage - public XmlNode GetFragment(IDataSnapshotProvider provider, XmlDocument factory) - { - XmlNode data = null; - - if (provider.Stale || !m_cacheEnabled) - { - data = provider.RequestSnapshotData(factory); - - if (m_cacheEnabled) - { - String path = DataFileNameFragment(provider.GetParentScene, provider.Name); - - try - { - using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) - { - snapXWriter.Formatting = Formatting.Indented; - snapXWriter.WriteStartDocument(); - data.WriteTo(snapXWriter); - snapXWriter.WriteEndDocument(); - } - } - catch (Exception e) - { - m_log.WarnFormat("[DATASNAPSHOT]: Exception on writing to file {0}: {1}", path, e.Message); - } - - } - - //mark provider as not stale, parent scene as stale - provider.Stale = false; - m_scenes[provider.GetParentScene] = true; - - m_log.Debug("[DATASNAPSHOT]: Generated fragment response for provider type " + provider.Name); - } - else - { - String path = DataFileNameFragment(provider.GetParentScene, provider.Name); - - XmlDocument fragDocument = new XmlDocument(); - fragDocument.PreserveWhitespace = true; - fragDocument.Load(path); - foreach (XmlNode node in fragDocument) - { - data = factory.ImportNode(node, true); - } - - m_log.Debug("[DATASNAPSHOT]: Retrieved fragment response for provider type " + provider.Name); - } - - return data; - } - #endregion - - #region Response storage - public XmlNode GetScene(Scene scene, XmlDocument factory) - { - m_log.Debug("[DATASNAPSHOT]: Data requested for scene " + scene.RegionInfo.RegionName); - - if (!m_scenes.ContainsKey(scene)) { - m_scenes.Add(scene, true); //stale by default - } - - XmlNode regionElement = null; - - if (!m_scenes[scene]) - { - m_log.Debug("[DATASNAPSHOT]: Attempting to retrieve snapshot from cache."); - //get snapshot from cache - String path = DataFileNameScene(scene); - - XmlDocument fragDocument = new XmlDocument(); - fragDocument.PreserveWhitespace = true; - - fragDocument.Load(path); - - foreach (XmlNode node in fragDocument) - { - regionElement = factory.ImportNode(node, true); - } - - m_log.Debug("[DATASNAPSHOT]: Obtained snapshot from cache for " + scene.RegionInfo.RegionName); - } - else - { - m_log.Debug("[DATASNAPSHOT]: Attempting to generate snapshot."); - //make snapshot - regionElement = MakeRegionNode(scene, factory); - - regionElement.AppendChild(GetGridSnapshotData(factory)); - XmlNode regionData = factory.CreateNode(XmlNodeType.Element, "data", ""); - - foreach (IDataSnapshotProvider dataprovider in m_providers) - { - if (dataprovider.GetParentScene == scene) - { - regionData.AppendChild(GetFragment(dataprovider, factory)); - } - } - - regionElement.AppendChild(regionData); - - factory.AppendChild(regionElement); - - //save snapshot - String path = DataFileNameScene(scene); - - try - { - using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) - { - snapXWriter.Formatting = Formatting.Indented; - snapXWriter.WriteStartDocument(); - regionElement.WriteTo(snapXWriter); - snapXWriter.WriteEndDocument(); - } - } - catch (Exception e) - { - m_log.WarnFormat("[DATASNAPSHOT]: Exception on writing to file {0}: {1}", path, e.Message); - } - - m_scenes[scene] = false; - - m_log.Debug("[DATASNAPSHOT]: Generated new snapshot for " + scene.RegionInfo.RegionName); - } - - return regionElement; - } - - #endregion - - #region Helpers - private string DataFileNameFragment(Scene scene, String fragmentName) - { - return Path.Combine(m_directory, Path.ChangeExtension(Sanitize(scene.RegionInfo.RegionName + "_" + fragmentName), "xml")); - } - - private string DataFileNameScene(Scene scene) - { - return Path.Combine(m_directory, Path.ChangeExtension(Sanitize(scene.RegionInfo.RegionName), "xml")); - //return (m_snapsDir + Path.DirectorySeparatorChar + scene.RegionInfo.RegionName + ".xml"); - } - - private static string Sanitize(string name) - { - string invalidChars = Regex.Escape(new string(Path.GetInvalidFileNameChars())); - string invalidReStr = string.Format(@"[{0}]", invalidChars); - string newname = Regex.Replace(name, invalidReStr, "_"); - return newname.Replace('.', '_'); - } - - private XmlNode MakeRegionNode(Scene scene, XmlDocument basedoc) - { - XmlNode docElement = basedoc.CreateNode(XmlNodeType.Element, "region", ""); - - XmlAttribute attr = basedoc.CreateAttribute("category"); - attr.Value = GetRegionCategory(scene); - docElement.Attributes.Append(attr); - - attr = basedoc.CreateAttribute("entities"); - attr.Value = scene.Entities.Count.ToString(); - docElement.Attributes.Append(attr); - - //attr = basedoc.CreateAttribute("parcels"); - //attr.Value = scene.LandManager.landList.Count.ToString(); - //docElement.Attributes.Append(attr); - - - XmlNode infoblock = basedoc.CreateNode(XmlNodeType.Element, "info", ""); - - XmlNode infopiece = basedoc.CreateNode(XmlNodeType.Element, "uuid", ""); - infopiece.InnerText = scene.RegionInfo.RegionID.ToString(); - infoblock.AppendChild(infopiece); - - infopiece = basedoc.CreateNode(XmlNodeType.Element, "url", ""); - infopiece.InnerText = "http://" + m_hostname + ":" + m_listener_port; - infoblock.AppendChild(infopiece); - - infopiece = basedoc.CreateNode(XmlNodeType.Element, "name", ""); - infopiece.InnerText = scene.RegionInfo.RegionName; - infoblock.AppendChild(infopiece); - - infopiece = basedoc.CreateNode(XmlNodeType.Element, "handle", ""); - infopiece.InnerText = scene.RegionInfo.RegionHandle.ToString(); - infoblock.AppendChild(infopiece); - - docElement.AppendChild(infoblock); - - m_log.Debug("[DATASNAPSHOT]: Generated region node"); - return docElement; - } - - private String GetRegionCategory(Scene scene) - { - if (scene.RegionInfo.RegionSettings.Maturity == 0) - return "PG"; - - if (scene.RegionInfo.RegionSettings.Maturity == 1) - return "Mature"; - - if (scene.RegionInfo.RegionSettings.Maturity == 2) - return "Adult"; - - return "Unknown"; - } - - private XmlNode GetGridSnapshotData(XmlDocument factory) - { - XmlNode griddata = factory.CreateNode(XmlNodeType.Element, "grid", ""); - - foreach (KeyValuePair GridData in m_gridinfo) - { - //TODO: make it lowercase tag names for diva - XmlNode childnode = factory.CreateNode(XmlNodeType.Element, GridData.Key, ""); - childnode.InnerText = GridData.Value; - griddata.AppendChild(childnode); - } - - m_log.Debug("[DATASNAPSHOT]: Got grid snapshot data"); - - return griddata; - } - #endregion - - #region Manage internal collections - public void AddScene(Scene newScene) - { - m_scenes.Add(newScene, true); - } - - public void RemoveScene(Scene deadScene) - { - m_scenes.Remove(deadScene); - } - - public void AddProvider(IDataSnapshotProvider newProvider) - { - m_providers.Add(newProvider); - } - - public void RemoveProvider(IDataSnapshotProvider deadProvider) - { - m_providers.Remove(deadProvider); - } - #endregion - } -} diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs new file mode 100644 index 0000000..50276ae --- /dev/null +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs @@ -0,0 +1,99 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSimulator Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System.Collections; +using System.Reflection; +using System.Xml; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Capabilities; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Scenes; +using Caps = OpenSim.Framework.Capabilities.Caps; + +namespace OpenSim.Region.DataSnapshot +{ + public class DataRequestHandler + { +// private Scene m_scene = null; + private DataSnapshotManager m_externalData = null; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public DataRequestHandler(Scene scene, DataSnapshotManager externalData) + { +// m_scene = scene; + m_externalData = externalData; + + //Register HTTP handler + if (MainServer.Instance.AddHTTPHandler("collector", OnGetSnapshot)) + { + m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); + } + // Register validation callback handler + MainServer.Instance.AddHTTPHandler("validate", OnValidate); + + } + + public Hashtable OnGetSnapshot(Hashtable keysvals) + { + m_log.Debug("[DATASNAPSHOT] Received collection request"); + Hashtable reply = new Hashtable(); + int statuscode = 200; + + string snapObj = (string)keysvals["region"]; + + XmlDocument response = m_externalData.GetSnapshot(snapObj); + + reply["str_response_string"] = response.OuterXml; + reply["int_response_code"] = statuscode; + reply["content_type"] = "text/xml"; + + return reply; + } + + public Hashtable OnValidate(Hashtable keysvals) + { + m_log.Debug("[DATASNAPSHOT] Received validation request"); + Hashtable reply = new Hashtable(); + int statuscode = 200; + + string secret = (string)keysvals["secret"]; + if (secret == m_externalData.Secret.ToString()) + statuscode = 403; + + reply["str_response_string"] = string.Empty; + reply["int_response_code"] = statuscode; + reply["content_type"] = "text/plain"; + + return reply; + } + + } +} diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs new file mode 100644 index 0000000..0c3446d --- /dev/null +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs @@ -0,0 +1,487 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSimulator Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Reflection; +using System.Text; +using System.Xml; +using log4net; +using Nini.Config; +using OpenMetaverse; +using Mono.Addins; +using OpenSim.Framework; +using OpenSim.Region.DataSnapshot.Interfaces; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.DataSnapshot +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DataSnapshotManager")] + public class DataSnapshotManager : ISharedRegionModule, IDataSnapshot + { + #region Class members + //Information from config + private bool m_enabled = false; + private bool m_configLoaded = false; + private List m_disabledModules = new List(); + private Dictionary m_gridinfo = new Dictionary(); + private string m_snapsDir = "DataSnapshot"; + private string m_exposure_level = "minimum"; + + //Lists of stuff we need + private List m_scenes = new List(); + private List m_dataproviders = new List(); + + //Various internal objects + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + internal object m_syncInit = new object(); + + //DataServices and networking + private string m_dataServices = "noservices"; + public string m_listener_port = ConfigSettings.DefaultRegionHttpPort.ToString(); + public string m_hostname = "127.0.0.1"; + private UUID m_Secret = UUID.Random(); + private bool m_servicesNotified = false; + + //Update timers + private int m_period = 20; // in seconds + private int m_maxStales = 500; + private int m_stales = 0; + private int m_lastUpdate = 0; + + //Program objects + private SnapshotStore m_snapStore = null; + + #endregion + + #region Properties + + public string ExposureLevel + { + get { return m_exposure_level; } + } + + public UUID Secret + { + get { return m_Secret; } + } + + #endregion + + #region Region Module interface + + public void Initialise(IConfigSource config) + { + if (!m_configLoaded) + { + m_configLoaded = true; + //m_log.Debug("[DATASNAPSHOT]: Loading configuration"); + //Read from the config for options + lock (m_syncInit) + { + try + { + m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); + string gatekeeper = Util.GetConfigVarFromSections(config, "GatekeeperURI", + new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); + // Legacy. Remove soon! + if (string.IsNullOrEmpty(gatekeeper)) + { + IConfig conf = config.Configs["GridService"]; + if (conf != null) + gatekeeper = conf.GetString("Gatekeeper", gatekeeper); + } + if (!string.IsNullOrEmpty(gatekeeper)) + m_gridinfo.Add("gatekeeperURL", gatekeeper); + + m_gridinfo.Add( + "name", config.Configs["DataSnapshot"].GetString("gridname", "the lost continent of hippo")); + m_exposure_level = config.Configs["DataSnapshot"].GetString("data_exposure", m_exposure_level); + m_period = config.Configs["DataSnapshot"].GetInt("default_snapshot_period", m_period); + m_maxStales = config.Configs["DataSnapshot"].GetInt("max_changes_before_update", m_maxStales); + m_snapsDir = config.Configs["DataSnapshot"].GetString("snapshot_cache_directory", m_snapsDir); + m_listener_port = config.Configs["Network"].GetString("http_listener_port", m_listener_port); + + m_dataServices = config.Configs["DataSnapshot"].GetString("data_services", m_dataServices); + // New way of spec'ing data services, one per line + AddDataServicesVars(config.Configs["DataSnapshot"]); + + String[] annoying_string_array = config.Configs["DataSnapshot"].GetString("disable_modules", "").Split(".".ToCharArray()); + foreach (String bloody_wanker in annoying_string_array) + { + m_disabledModules.Add(bloody_wanker); + } + m_lastUpdate = Environment.TickCount; + } + catch (Exception) + { + m_log.Warn("[DATASNAPSHOT]: Could not load configuration. DataSnapshot will be disabled."); + m_enabled = false; + return; + } + + } + + } + + } + + public void AddRegion(Scene scene) + { + if (!m_enabled) + return; + + m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); + + if (!m_servicesNotified) + { + m_hostname = scene.RegionInfo.ExternalHostName; + m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); + + //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer + new DataRequestHandler(scene, this); + + if (m_dataServices != "" && m_dataServices != "noservices") + NotifyDataServices(m_dataServices, "online"); + + m_servicesNotified = true; + } + + m_scenes.Add(scene); + m_snapStore.AddScene(scene); + + Assembly currentasm = Assembly.GetExecutingAssembly(); + + foreach (Type pluginType in currentasm.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + if (pluginType.GetInterface("IDataSnapshotProvider") != null) + { + IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); + module.Initialize(scene, this); + module.OnStale += MarkDataStale; + + m_dataproviders.Add(module); + m_snapStore.AddProvider(module); + + m_log.Debug("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); + } + } + } + } + + } + + public void RemoveRegion(Scene scene) + { + if (!m_enabled) + return; + + m_log.Info("[DATASNAPSHOT]: Region " + scene.RegionInfo.RegionName + " is being removed, removing from indexing"); + Scene restartedScene = SceneForUUID(scene.RegionInfo.RegionID); + + m_scenes.Remove(restartedScene); + m_snapStore.RemoveScene(restartedScene); + + //Getting around the fact that we can't remove objects from a collection we are enumerating over + List providersToRemove = new List(); + + foreach (IDataSnapshotProvider provider in m_dataproviders) + { + if (provider.GetParentScene == restartedScene) + { + providersToRemove.Add(provider); + } + } + + foreach (IDataSnapshotProvider provider in providersToRemove) + { + m_dataproviders.Remove(provider); + m_snapStore.RemoveProvider(provider); + } + + m_snapStore.RemoveScene(restartedScene); + } + + public void PostInitialise() + { + } + + public void RegionLoaded(Scene scene) + { + if (!m_enabled) + return; + + m_log.DebugFormat("[DATASNAPSHOT]: Marking scene {0} as stale.", scene.RegionInfo.RegionName); + m_snapStore.ForceSceneStale(scene); + } + + public void Close() + { + if (!m_enabled) + return; + + if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") + NotifyDataServices(m_dataServices, "offline"); + } + + + public string Name + { + get { return "External Data Generator"; } + } + + public Type ReplaceableInterface + { + get { return null; } + } + + #endregion + + #region Associated helper functions + + public Scene SceneForName(string name) + { + foreach (Scene scene in m_scenes) + if (scene.RegionInfo.RegionName == name) + return scene; + + return null; + } + + public Scene SceneForUUID(UUID id) + { + foreach (Scene scene in m_scenes) + if (scene.RegionInfo.RegionID == id) + return scene; + + return null; + } + + private void AddDataServicesVars(IConfig config) + { + // Make sure the services given this way aren't in m_dataServices already + List servs = new List(m_dataServices.Split(new char[] { ';' })); + + StringBuilder sb = new StringBuilder(); + string[] keys = config.GetKeys(); + + if (keys.Length > 0) + { + IEnumerable serviceKeys = keys.Where(value => value.StartsWith("DATA_SRV_")); + foreach (string serviceKey in serviceKeys) + { + string keyValue = config.GetString(serviceKey, string.Empty).Trim(); + if (!servs.Contains(keyValue)) + sb.Append(keyValue).Append(";"); + } + } + + m_dataServices = (m_dataServices == "noservices") ? sb.ToString() : sb.Append(m_dataServices).ToString(); + } + + #endregion + + #region [Public] Snapshot storage functions + + /** + * Reply to the http request + */ + public XmlDocument GetSnapshot(string regionName) + { + CheckStale(); + + XmlDocument requestedSnap = new XmlDocument(); + requestedSnap.AppendChild(requestedSnap.CreateXmlDeclaration("1.0", null, null)); + requestedSnap.AppendChild(requestedSnap.CreateWhitespace("\r\n")); + + XmlNode regiondata = requestedSnap.CreateNode(XmlNodeType.Element, "regiondata", ""); + try + { + if (string.IsNullOrEmpty(regionName)) + { + XmlNode timerblock = requestedSnap.CreateNode(XmlNodeType.Element, "expire", ""); + timerblock.InnerText = m_period.ToString(); + regiondata.AppendChild(timerblock); + + regiondata.AppendChild(requestedSnap.CreateWhitespace("\r\n")); + foreach (Scene scene in m_scenes) + { + regiondata.AppendChild(m_snapStore.GetScene(scene, requestedSnap)); + } + } + else + { + Scene scene = SceneForName(regionName); + regiondata.AppendChild(m_snapStore.GetScene(scene, requestedSnap)); + } + requestedSnap.AppendChild(regiondata); + regiondata.AppendChild(requestedSnap.CreateWhitespace("\r\n")); + } + catch (XmlException e) + { + m_log.Warn("[DATASNAPSHOT]: XmlException while trying to load snapshot: " + e.ToString()); + requestedSnap = GetErrorMessage(regionName, e); + } + catch (Exception e) + { + m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to load snapshot: " + e.StackTrace); + requestedSnap = GetErrorMessage(regionName, e); + } + + + return requestedSnap; + } + + private XmlDocument GetErrorMessage(string regionName, Exception e) + { + XmlDocument errorMessage = new XmlDocument(); + XmlNode error = errorMessage.CreateNode(XmlNodeType.Element, "error", ""); + XmlNode region = errorMessage.CreateNode(XmlNodeType.Element, "region", ""); + region.InnerText = regionName; + + XmlNode exception = errorMessage.CreateNode(XmlNodeType.Element, "exception", ""); + exception.InnerText = e.ToString(); + + error.AppendChild(region); + error.AppendChild(exception); + errorMessage.AppendChild(error); + + return errorMessage; + } + + #endregion + + #region External data services + private void NotifyDataServices(string servicesStr, string serviceName) + { + Stream reply = null; + string delimStr = ";"; + char [] delimiter = delimStr.ToCharArray(); + + string[] services = servicesStr.Split(delimiter, StringSplitOptions.RemoveEmptyEntries); + + for (int i = 0; i < services.Length; i++) + { + string url = services[i].Trim(); + using (RestClient cli = new RestClient(url)) + { + cli.AddQueryParameter("service", serviceName); + cli.AddQueryParameter("host", m_hostname); + cli.AddQueryParameter("port", m_listener_port); + cli.AddQueryParameter("secret", m_Secret.ToString()); + cli.RequestMethod = "GET"; + try + { + reply = cli.Request(null); + } + catch (WebException) + { + m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url); + } + catch (Exception e) + { + m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString()); + } + + byte[] response = new byte[1024]; + // int n = 0; + try + { + // n = reply.Read(response, 0, 1024); + reply.Read(response, 0, 1024); + } + catch (Exception e) + { + m_log.WarnFormat("[DATASNAPSHOT]: Unable to decode reply from data service. Ignoring. {0}", e.StackTrace); + } + // This is not quite working, so... + // string responseStr = Util.UTF8.GetString(response); + m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret); + } + } + + } + #endregion + + #region Latency-based update functions + + public void MarkDataStale(IDataSnapshotProvider provider) + { + //Behavior here: Wait m_period seconds, then update if there has not been a request in m_period seconds + //or m_maxStales has been exceeded + m_stales++; + } + + private void CheckStale() + { + // Wrap check + if (Environment.TickCount < m_lastUpdate) + { + m_lastUpdate = Environment.TickCount; + } + + if (m_stales >= m_maxStales) + { + if (Environment.TickCount - m_lastUpdate >= 20000) + { + m_stales = 0; + m_lastUpdate = Environment.TickCount; + MakeEverythingStale(); + } + } + else + { + if (m_lastUpdate + 1000 * m_period < Environment.TickCount) + { + m_stales = 0; + m_lastUpdate = Environment.TickCount; + MakeEverythingStale(); + } + } + } + + public void MakeEverythingStale() + { + m_log.Debug("[DATASNAPSHOT]: Marking all scenes as stale."); + foreach (Scene scene in m_scenes) + { + m_snapStore.ForceSceneStale(scene); + } + } + #endregion + + } +} 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 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Xml; +using OpenMetaverse; +using OpenSim.Framework; + +using OpenSim.Region.DataSnapshot.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.DataSnapshot.Providers +{ + public class EstateSnapshot : IDataSnapshotProvider + { + /* This module doesn't check for changes, since it's *assumed* there are none. + * Nevertheless, it's possible to have changes, since all the fields are public. + * There's no event to subscribe to. :/ + * + * I don't think anything changes the fields beyond RegionModule PostInit, however. + */ + private Scene m_scene = null; + // private DataSnapshotManager m_parent = null; + private bool m_stale = true; + + #region IDataSnapshotProvider Members + + public XmlNode RequestSnapshotData(XmlDocument factory) + { + //Estate data section - contains who owns a set of sims and the name of the set. + //Now in DataSnapshotProvider module form! + XmlNode estatedata = factory.CreateNode(XmlNodeType.Element, "estate", ""); + + UUID ownerid = m_scene.RegionInfo.EstateSettings.EstateOwner; + + UserAccount userInfo = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid); + //TODO: Change to query userserver about the master avatar UUID ? + String firstname; + String lastname; + + if (userInfo != null) + { + firstname = userInfo.FirstName; + lastname = userInfo.LastName; + + //TODO: Fix the marshalling system to have less copypasta gruntwork + XmlNode user = factory.CreateNode(XmlNodeType.Element, "user", ""); +// XmlAttribute type = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "type", ""); +// type.Value = "owner"; +// user.Attributes.Append(type); + + //TODO: Create more TODOs + XmlNode username = factory.CreateNode(XmlNodeType.Element, "name", ""); + username.InnerText = firstname + " " + lastname; + user.AppendChild(username); + + XmlNode useruuid = factory.CreateNode(XmlNodeType.Element, "uuid", ""); + useruuid.InnerText = ownerid.ToString(); + user.AppendChild(useruuid); + + estatedata.AppendChild(user); + } + + XmlNode estatename = factory.CreateNode(XmlNodeType.Element, "name", ""); + estatename.InnerText = m_scene.RegionInfo.EstateSettings.EstateName.ToString(); + estatedata.AppendChild(estatename); + + XmlNode estateid = factory.CreateNode(XmlNodeType.Element, "id", ""); + estateid.InnerText = m_scene.RegionInfo.EstateSettings.EstateID.ToString(); + estatedata.AppendChild(estateid); + + XmlNode parentid = factory.CreateNode(XmlNodeType.Element, "parentid", ""); + parentid.InnerText = m_scene.RegionInfo.EstateSettings.ParentEstateID.ToString(); + estatedata.AppendChild(parentid); + + XmlNode flags = factory.CreateNode(XmlNodeType.Element, "flags", ""); + + XmlAttribute teleport = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "teleport", ""); + teleport.Value = m_scene.RegionInfo.EstateSettings.AllowDirectTeleport.ToString(); + flags.Attributes.Append(teleport); + + XmlAttribute publicaccess = (XmlAttribute)factory.CreateNode(XmlNodeType.Attribute, "public", ""); + publicaccess.Value = m_scene.RegionInfo.EstateSettings.PublicAccess.ToString(); + flags.Attributes.Append(publicaccess); + + estatedata.AppendChild(flags); + + this.Stale = false; + return estatedata; + } + + public void Initialize(Scene scene, DataSnapshotManager parent) + { + m_scene = scene; + // m_parent = parent; + } + + public Scene GetParentScene + { + get { return m_scene; } + } + + public String Name { + get { return "EstateSnapshot"; } + } + + public bool Stale + { + get { + return m_stale; + } + set { + m_stale = value; + + if (m_stale) + OnStale(this); + } + } + + public event ProviderStale OnStale; + + #endregion + } +} diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshot.cs b/OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshot.cs new file mode 100644 index 0000000..3b3db65 --- /dev/null +++ b/OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshot.cs @@ -0,0 +1,36 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Xml; + +namespace OpenSim.Region.DataSnapshot.Interfaces +{ + public interface IDataSnapshot + { + XmlDocument GetSnapshot(string regionName); + } +} diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshotProvider.cs b/OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshotProvider.cs new file mode 100644 index 0000000..daea373 --- /dev/null +++ b/OpenSim/Region/OptionalModules/DataSnapshot/Interfaces/IDataSnapshotProvider.cs @@ -0,0 +1,46 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSimulator Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Xml; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.DataSnapshot.Interfaces +{ + public delegate void ProviderStale(IDataSnapshotProvider provider); + + public interface IDataSnapshotProvider + { + XmlNode RequestSnapshotData(XmlDocument document); + void Initialize(Scene scene, DataSnapshotManager parent); + Scene GetParentScene { get; } + String Name { get; } + bool Stale { get; set; } + event ProviderStale OnStale; + } +} diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/LLSDDiscovery.cs b/OpenSim/Region/OptionalModules/DataSnapshot/LLSDDiscovery.cs new file mode 100644 index 0000000..54a87f9 --- /dev/null +++ b/OpenSim/Region/OptionalModules/DataSnapshot/LLSDDiscovery.cs @@ -0,0 +1,44 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSimulator Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using OpenSim.Framework.Capabilities; + +namespace OpenSim.Region.DataSnapshot +{ + [OSDMap] + public class LLSDDiscoveryResponse + { + public OSDArray snapshot_resources; + } + + [OSDMap] + public class LLSDDiscoveryDataURL + { + public string snapshot_format; + public string snapshot_url; + } +} diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs b/OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs new file mode 100644 index 0000000..b8c90cd --- /dev/null +++ b/OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs @@ -0,0 +1,433 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSimulator Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Xml; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; + +using OpenSim.Region.CoreModules.World.Land; +using OpenSim.Region.DataSnapshot.Interfaces; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.DataSnapshot.Providers +{ + public class LandSnapshot : IDataSnapshotProvider + { + private Scene m_scene = null; + private DataSnapshotManager m_parent = null; + //private Dictionary m_landIndexed = new Dictionary(); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private bool m_stale = true; + + #region Dead code + + /* + * David, I don't think we need this at all. When we do the snapshot, we can + * simply look into the parcels that are marked for ShowDirectory -- see + * conditional in RequestSnapshotData + * + //Revise this, look for more direct way of checking for change in land + #region Client hooks + + public void OnNewClient(IClientAPI client) + { + //Land hooks + client.OnParcelDivideRequest += ParcelSplitHook; + client.OnParcelJoinRequest += ParcelSplitHook; + client.OnParcelPropertiesUpdateRequest += ParcelPropsHook; + } + + public void ParcelSplitHook(int west, int south, int east, int north, IClientAPI remote_client) + { + PrepareData(); + } + + public void ParcelPropsHook(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) + { + PrepareData(); + } + + #endregion + + public void PrepareData() + { + m_log.Info("[EXTERNALDATA]: Generating land data."); + + m_landIndexed.Clear(); + + //Index sim land + foreach (KeyValuePair curLand in m_scene.LandManager.landList) + { + //if ((curLand.Value.LandData.landFlags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory) + //{ + m_landIndexed.Add(curLand.Key, curLand.Value.Copy()); + //} + } + } + + public Dictionary IndexedLand { + get { return m_landIndexed; } + } + */ + + #endregion + + #region IDataSnapshotProvider members + + public void Initialize(Scene scene, DataSnapshotManager parent) + { + m_scene = scene; + m_parent = parent; + + //Brought back from the dead for staleness checks. + m_scene.EventManager.OnNewClient += OnNewClient; + } + + public Scene GetParentScene + { + get { return m_scene; } + } + + public XmlNode RequestSnapshotData(XmlDocument nodeFactory) + { + ILandChannel landChannel = m_scene.LandChannel; + List parcels = landChannel.AllParcels(); + + IDwellModule dwellModule = m_scene.RequestModuleInterface(); + + XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", ""); + if (parcels != null) + { + + //foreach (KeyValuePair curParcel in m_landIndexed) + foreach (ILandObject parcel_interface in parcels) + { + // Play it safe + if (!(parcel_interface is LandObject)) + continue; + + LandObject land = (LandObject)parcel_interface; + + LandData parcel = land.LandData; + if (m_parent.ExposureLevel.Equals("all") || + (m_parent.ExposureLevel.Equals("minimum") && + (parcel.Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory)) + { + + //TODO: make better method of marshalling data from LandData to XmlNode + XmlNode xmlparcel = nodeFactory.CreateNode(XmlNodeType.Element, "parcel", ""); + + // Attributes of the parcel node + XmlAttribute scripts_attr = nodeFactory.CreateAttribute("scripts"); + scripts_attr.Value = GetScriptsPermissions(parcel); + XmlAttribute build_attr = nodeFactory.CreateAttribute("build"); + build_attr.Value = GetBuildPermissions(parcel); + XmlAttribute public_attr = nodeFactory.CreateAttribute("public"); + public_attr.Value = GetPublicPermissions(parcel); + // Check the category of the Parcel + XmlAttribute category_attr = nodeFactory.CreateAttribute("category"); + category_attr.Value = ((int)parcel.Category).ToString(); + // Check if the parcel is for sale + XmlAttribute forsale_attr = nodeFactory.CreateAttribute("forsale"); + forsale_attr.Value = CheckForSale(parcel); + XmlAttribute sales_attr = nodeFactory.CreateAttribute("salesprice"); + sales_attr.Value = parcel.SalePrice.ToString(); + + XmlAttribute directory_attr = nodeFactory.CreateAttribute("showinsearch"); + directory_attr.Value = GetShowInSearch(parcel); + //XmlAttribute entities_attr = nodeFactory.CreateAttribute("entities"); + //entities_attr.Value = land.primsOverMe.Count.ToString(); + xmlparcel.Attributes.Append(directory_attr); + xmlparcel.Attributes.Append(scripts_attr); + xmlparcel.Attributes.Append(build_attr); + xmlparcel.Attributes.Append(public_attr); + xmlparcel.Attributes.Append(category_attr); + xmlparcel.Attributes.Append(forsale_attr); + xmlparcel.Attributes.Append(sales_attr); + //xmlparcel.Attributes.Append(entities_attr); + + + //name, description, area, and UUID + XmlNode name = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); + name.InnerText = parcel.Name; + xmlparcel.AppendChild(name); + + XmlNode desc = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); + desc.InnerText = parcel.Description; + xmlparcel.AppendChild(desc); + + XmlNode uuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); + uuid.InnerText = parcel.GlobalID.ToString(); + xmlparcel.AppendChild(uuid); + + XmlNode area = nodeFactory.CreateNode(XmlNodeType.Element, "area", ""); + area.InnerText = parcel.Area.ToString(); + xmlparcel.AppendChild(area); + + //default location + XmlNode tpLocation = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); + Vector3 loc = parcel.UserLocation; + if (loc.Equals(Vector3.Zero)) // This test is moot at this point: the location is wrong by default + loc = new Vector3((parcel.AABBMax.X + parcel.AABBMin.X) / 2, (parcel.AABBMax.Y + parcel.AABBMin.Y) / 2, (parcel.AABBMax.Z + parcel.AABBMin.Z) / 2); + tpLocation.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); + xmlparcel.AppendChild(tpLocation); + + XmlNode infouuid = nodeFactory.CreateNode(XmlNodeType.Element, "infouuid", ""); + uint x = (uint)loc.X, y = (uint)loc.Y; + findPointInParcel(land, ref x, ref y); // find a suitable spot + infouuid.InnerText = Util.BuildFakeParcelID( + m_scene.RegionInfo.RegionHandle, x, y).ToString(); + xmlparcel.AppendChild(infouuid); + + XmlNode dwell = nodeFactory.CreateNode(XmlNodeType.Element, "dwell", ""); + if (dwellModule != null) + dwell.InnerText = dwellModule.GetDwell(parcel.GlobalID).ToString(); + else + dwell.InnerText = "0"; + xmlparcel.AppendChild(dwell); + + //TODO: figure how to figure out teleport system landData.landingType + + //land texture snapshot uuid + if (parcel.SnapshotID != UUID.Zero) + { + XmlNode textureuuid = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); + textureuuid.InnerText = parcel.SnapshotID.ToString(); + xmlparcel.AppendChild(textureuuid); + } + + string groupName = String.Empty; + + //attached user and group + if (parcel.GroupID != UUID.Zero) + { + XmlNode groupblock = nodeFactory.CreateNode(XmlNodeType.Element, "group", ""); + XmlNode groupuuid = nodeFactory.CreateNode(XmlNodeType.Element, "groupuuid", ""); + groupuuid.InnerText = parcel.GroupID.ToString(); + groupblock.AppendChild(groupuuid); + + IGroupsModule gm = m_scene.RequestModuleInterface(); + if (gm != null) + { + GroupRecord g = gm.GetGroupRecord(parcel.GroupID); + if (g != null) + groupName = g.GroupName; + } + + XmlNode groupname = nodeFactory.CreateNode(XmlNodeType.Element, "groupname", ""); + groupname.InnerText = groupName; + groupblock.AppendChild(groupname); + + xmlparcel.AppendChild(groupblock); + } + + XmlNode userblock = nodeFactory.CreateNode(XmlNodeType.Element, "owner", ""); + + UUID userOwnerUUID = parcel.OwnerID; + + XmlNode useruuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); + useruuid.InnerText = userOwnerUUID.ToString(); + userblock.AppendChild(useruuid); + + if (!parcel.IsGroupOwned) + { + try + { + XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); + UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, userOwnerUUID); + username.InnerText = account.FirstName + " " + account.LastName; + userblock.AppendChild(username); + } + catch (Exception) + { + //m_log.Info("[DATASNAPSHOT]: Cannot find owner name; ignoring this parcel"); + } + + } + else + { + XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); + username.InnerText = groupName; + userblock.AppendChild(username); + } + + xmlparcel.AppendChild(userblock); + + parent.AppendChild(xmlparcel); + } + } + //snap.AppendChild(parent); + } + + this.Stale = false; + return parent; + } + + public String Name + { + get { return "LandSnapshot"; } + } + + public bool Stale + { + get + { + return m_stale; + } + set + { + m_stale = value; + + if (m_stale) + OnStale(this); + } + } + + public event ProviderStale OnStale; + + #endregion + + #region Helper functions + + private string GetScriptsPermissions(LandData parcel) + { + if ((parcel.Flags & (uint)ParcelFlags.AllowOtherScripts) == (uint)ParcelFlags.AllowOtherScripts) + return "true"; + else + return "false"; + + } + + private string GetPublicPermissions(LandData parcel) + { + if ((parcel.Flags & (uint)ParcelFlags.UseAccessList) == (uint)ParcelFlags.UseAccessList) + return "false"; + else + return "true"; + + } + + private string GetBuildPermissions(LandData parcel) + { + if ((parcel.Flags & (uint)ParcelFlags.CreateObjects) == (uint)ParcelFlags.CreateObjects) + return "true"; + else + return "false"; + + } + + private string CheckForSale(LandData parcel) + { + if ((parcel.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale) + return "true"; + else + return "false"; + } + + private string GetShowInSearch(LandData parcel) + { + if ((parcel.Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory) + return "true"; + else + return "false"; + + } + + #endregion + + #region Change detection hooks + + public void OnNewClient(IClientAPI client) + { + //Land hooks + client.OnParcelDivideRequest += delegate(int west, int south, int east, int north, + IClientAPI remote_client) { this.Stale = true; }; + client.OnParcelJoinRequest += delegate(int west, int south, int east, int north, + IClientAPI remote_client) { this.Stale = true; }; + client.OnParcelPropertiesUpdateRequest += delegate(LandUpdateArgs args, int local_id, + IClientAPI remote_client) { this.Stale = true; }; + client.OnParcelBuy += delegate(UUID agentId, UUID groupId, bool final, bool groupOwned, + bool removeContribution, int parcelLocalID, int parcelArea, int parcelPrice, bool authenticated) + { this.Stale = true; }; + } + + public void ParcelSplitHook(int west, int south, int east, int north, IClientAPI remote_client) + { + this.Stale = true; + } + + public void ParcelPropsHook(LandUpdateArgs args, int local_id, IClientAPI remote_client) + { + this.Stale = true; + } + + #endregion + + // this is needed for non-convex parcels (example: rectangular parcel, and in the exact center + // another, smaller rectangular parcel). Both will have the same initial coordinates. + private void findPointInParcel(ILandObject land, ref uint refX, ref uint refY) + { + m_log.DebugFormat("[DATASNAPSHOT] trying {0}, {1}", refX, refY); + // the point we started with already is in the parcel + if (land.ContainsPoint((int)refX, (int)refY)) return; + + // ... otherwise, we have to search for a point within the parcel + uint startX = (uint)land.LandData.AABBMin.X; + uint startY = (uint)land.LandData.AABBMin.Y; + uint endX = (uint)land.LandData.AABBMax.X; + uint endY = (uint)land.LandData.AABBMax.Y; + + // default: center of the parcel + refX = (startX + endX) / 2; + refY = (startY + endY) / 2; + // If the center point is within the parcel, take that one + if (land.ContainsPoint((int)refX, (int)refY)) return; + + // otherwise, go the long way. + for (uint y = startY; y <= endY; ++y) + { + for (uint x = startX; x <= endX; ++x) + { + if (land.ContainsPoint((int)x, (int)y)) + { + // found a point + refX = x; + refY = y; + return; + } + } + } + } + } +} + diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs new file mode 100644 index 0000000..0bb4044 --- /dev/null +++ b/OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs @@ -0,0 +1,264 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Xml; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.DataSnapshot.Interfaces; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.DataSnapshot.Providers +{ + public class ObjectSnapshot : IDataSnapshotProvider + { + private Scene m_scene = null; + // private DataSnapshotManager m_parent = null; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private bool m_stale = true; + + private static UUID m_DefaultImage = new UUID("89556747-24cb-43ed-920b-47caed15465f"); + private static UUID m_BlankImage = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); + + + public void Initialize(Scene scene, DataSnapshotManager parent) + { + m_scene = scene; + // m_parent = parent; + + //To check for staleness, we must catch all incoming client packets. + m_scene.EventManager.OnNewClient += OnNewClient; + m_scene.EventManager.OnParcelPrimCountAdd += delegate(SceneObjectGroup obj) { this.Stale = true; }; + } + + public void OnNewClient(IClientAPI client) + { + //Detect object data changes by hooking into the IClientAPI. + //Very dirty, and breaks whenever someone changes the client API. + + client.OnAddPrim += delegate (UUID ownerID, UUID groupID, Vector3 RayEnd, Quaternion rot, + PrimitiveBaseShape shape, byte bypassRaycast, Vector3 RayStart, UUID RayTargetID, + byte RayEndIsIntersection) { this.Stale = true; }; + client.OnLinkObjects += delegate (IClientAPI remoteClient, uint parent, List children) + { this.Stale = true; }; + client.OnDelinkObjects += delegate(List primIds, IClientAPI clientApi) { this.Stale = true; }; + client.OnGrabUpdate += delegate(UUID objectID, Vector3 offset, Vector3 grapPos, + IClientAPI remoteClient, List surfaceArgs) { this.Stale = true; }; + client.OnObjectAttach += delegate(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, + bool silent) { this.Stale = true; }; + client.OnObjectDuplicate += delegate(uint localID, Vector3 offset, uint dupeFlags, UUID AgentID, + UUID GroupID) { this.Stale = true; }; + client.OnObjectDuplicateOnRay += delegate(uint localID, uint dupeFlags, UUID AgentID, UUID GroupID, + UUID RayTargetObj, Vector3 RayEnd, Vector3 RayStart, bool BypassRaycast, + bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates) { this.Stale = true; }; + client.OnObjectIncludeInSearch += delegate(IClientAPI remoteClient, bool IncludeInSearch, uint localID) + { this.Stale = true; }; + client.OnObjectPermissions += delegate(IClientAPI controller, UUID agentID, UUID sessionID, + byte field, uint localId, uint mask, byte set) { this.Stale = true; }; + client.OnRezObject += delegate(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, + Vector3 RayStart, UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, + bool RezSelected, + bool RemoveItem, UUID fromTaskID) { this.Stale = true; }; + } + + public Scene GetParentScene + { + get { return m_scene; } + } + + public XmlNode RequestSnapshotData(XmlDocument nodeFactory) + { + m_log.Debug("[DATASNAPSHOT]: Generating object data for scene " + m_scene.RegionInfo.RegionName); + + XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "objectdata", ""); + XmlNode node; + + EntityBase[] entities = m_scene.Entities.GetEntities(); + foreach (EntityBase entity in entities) + { + // only objects, not avatars + if (entity is SceneObjectGroup) + { + SceneObjectGroup obj = (SceneObjectGroup)entity; + +// m_log.Debug("[DATASNAPSHOT]: Found object " + obj.Name + " in scene"); + + // libomv will complain about PrimFlags.JointWheel + // being obsolete, so we... + #pragma warning disable 0612 + if ((obj.RootPart.Flags & PrimFlags.JointWheel) == PrimFlags.JointWheel) + { + SceneObjectPart m_rootPart = obj.RootPart; + + ILandObject land = m_scene.LandChannel.GetLandObject(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y); + + XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", ""); + node = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); + node.InnerText = obj.UUID.ToString(); + xmlobject.AppendChild(node); + + node = nodeFactory.CreateNode(XmlNodeType.Element, "title", ""); + node.InnerText = m_rootPart.Name; + xmlobject.AppendChild(node); + + node = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); + node.InnerText = m_rootPart.Description; + xmlobject.AppendChild(node); + + node = nodeFactory.CreateNode(XmlNodeType.Element, "flags", ""); + node.InnerText = String.Format("{0:x}", (uint)m_rootPart.Flags); + xmlobject.AppendChild(node); + + node = nodeFactory.CreateNode(XmlNodeType.Element, "regionuuid", ""); + node.InnerText = m_scene.RegionInfo.RegionSettings.RegionUUID.ToString(); + xmlobject.AppendChild(node); + + if (land != null && land.LandData != null) + { + node = nodeFactory.CreateNode(XmlNodeType.Element, "parceluuid", ""); + node.InnerText = land.LandData.GlobalID.ToString(); + xmlobject.AppendChild(node); + } + else + { + // Something is wrong with this object. Let's not list it. + m_log.WarnFormat("[DATASNAPSHOT]: Bad data for object {0} ({1}) in region {2}", obj.Name, obj.UUID, m_scene.RegionInfo.RegionName); + continue; + } + + node = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); + Vector3 loc = obj.AbsolutePosition; + node.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); + xmlobject.AppendChild(node); + + string bestImage = GuessImage(obj); + if (bestImage != string.Empty) + { + node = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); + node.InnerText = bestImage; + xmlobject.AppendChild(node); + } + + parent.AppendChild(xmlobject); + } + #pragma warning disable 0612 + } + } + this.Stale = false; + return parent; + } + + public String Name + { + get { return "ObjectSnapshot"; } + } + + public bool Stale + { + get + { + return m_stale; + } + set + { + m_stale = value; + + if (m_stale) + OnStale(this); + } + } + + public event ProviderStale OnStale; + + /// + /// Guesses the best image, based on a simple heuristic. It guesses only for boxes. + /// We're optimizing for boxes, because those are the most common objects + /// marked "Show in search" -- boxes with content inside.For other shapes, + /// it's really hard to tell which texture should be grabbed. + /// + /// + /// + private string GuessImage(SceneObjectGroup sog) + { + string bestguess = string.Empty; + Dictionary counts = new Dictionary(); + + PrimitiveBaseShape shape = sog.RootPart.Shape; + if (shape != null && shape.ProfileShape == ProfileShape.Square) + { + Primitive.TextureEntry textures = shape.Textures; + if (textures != null) + { + if (textures.DefaultTexture != null && + textures.DefaultTexture.TextureID != UUID.Zero && + textures.DefaultTexture.TextureID != m_DefaultImage && + textures.DefaultTexture.TextureID != m_BlankImage && + textures.DefaultTexture.RGBA.A < 50f) + { + counts[textures.DefaultTexture.TextureID] = 8; + } + + if (textures.FaceTextures != null) + { + foreach (Primitive.TextureEntryFace tentry in textures.FaceTextures) + { + if (tentry != null) + { + if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50) + { + int c = 0; + counts.TryGetValue(tentry.TextureID, out c); + counts[tentry.TextureID] = c + 1; + // decrease the default texture count + if (counts.ContainsKey(textures.DefaultTexture.TextureID)) + counts[textures.DefaultTexture.TextureID] = counts[textures.DefaultTexture.TextureID] - 1; + } + } + } + } + + // Let's pick the most unique texture + int min = 9999; + foreach (KeyValuePair kv in counts) + { + if (kv.Value < min && kv.Value >= 1) + { + bestguess = kv.Key.ToString(); + min = kv.Value; + } + } + } + } + + return bestguess; + } + } +} diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs b/OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs new file mode 100644 index 0000000..480aaaf --- /dev/null +++ b/OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs @@ -0,0 +1,337 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSimulator Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using log4net; +using OpenSim.Region.DataSnapshot.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.DataSnapshot +{ + public class SnapshotStore + { + #region Class Members + private String m_directory = "unyuu"; //not an attempt at adding RM references to core SVN, honest + private Dictionary m_scenes = null; + private List m_providers = null; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Dictionary m_gridinfo = null; + private bool m_cacheEnabled = true; + private string m_listener_port = "9000"; //TODO: Set default port over 9000 + private string m_hostname = "127.0.0.1"; + #endregion + + public SnapshotStore(string directory, Dictionary gridinfo, string port, string hostname) { + m_directory = directory; + m_scenes = new Dictionary(); + m_providers = new List(); + m_gridinfo = gridinfo; + m_listener_port = port; + m_hostname = hostname; + + if (Directory.Exists(m_directory)) + { + m_log.Info("[DATASNAPSHOT]: Response and fragment cache directory already exists."); + } + else + { + // Try to create the directory. + m_log.Info("[DATASNAPSHOT]: Creating directory " + m_directory); + try + { + Directory.CreateDirectory(m_directory); + } + catch (Exception e) + { + m_log.Error("[DATASNAPSHOT]: Failed to create directory " + m_directory, e); + + //This isn't a horrible problem, just disable cacheing. + m_cacheEnabled = false; + m_log.Error("[DATASNAPSHOT]: Could not create directory, response cache has been disabled."); + } + } + } + + public void ForceSceneStale(Scene scene) { + m_scenes[scene] = true; + } + + #region Fragment storage + public XmlNode GetFragment(IDataSnapshotProvider provider, XmlDocument factory) + { + XmlNode data = null; + + if (provider.Stale || !m_cacheEnabled) + { + data = provider.RequestSnapshotData(factory); + + if (m_cacheEnabled) + { + String path = DataFileNameFragment(provider.GetParentScene, provider.Name); + + try + { + using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) + { + snapXWriter.Formatting = Formatting.Indented; + snapXWriter.WriteStartDocument(); + data.WriteTo(snapXWriter); + snapXWriter.WriteEndDocument(); + } + } + catch (Exception e) + { + m_log.WarnFormat("[DATASNAPSHOT]: Exception on writing to file {0}: {1}", path, e.Message); + } + + } + + //mark provider as not stale, parent scene as stale + provider.Stale = false; + m_scenes[provider.GetParentScene] = true; + + m_log.Debug("[DATASNAPSHOT]: Generated fragment response for provider type " + provider.Name); + } + else + { + String path = DataFileNameFragment(provider.GetParentScene, provider.Name); + + XmlDocument fragDocument = new XmlDocument(); + fragDocument.PreserveWhitespace = true; + fragDocument.Load(path); + foreach (XmlNode node in fragDocument) + { + data = factory.ImportNode(node, true); + } + + m_log.Debug("[DATASNAPSHOT]: Retrieved fragment response for provider type " + provider.Name); + } + + return data; + } + #endregion + + #region Response storage + public XmlNode GetScene(Scene scene, XmlDocument factory) + { + m_log.Debug("[DATASNAPSHOT]: Data requested for scene " + scene.RegionInfo.RegionName); + + if (!m_scenes.ContainsKey(scene)) { + m_scenes.Add(scene, true); //stale by default + } + + XmlNode regionElement = null; + + if (!m_scenes[scene]) + { + m_log.Debug("[DATASNAPSHOT]: Attempting to retrieve snapshot from cache."); + //get snapshot from cache + String path = DataFileNameScene(scene); + + XmlDocument fragDocument = new XmlDocument(); + fragDocument.PreserveWhitespace = true; + + fragDocument.Load(path); + + foreach (XmlNode node in fragDocument) + { + regionElement = factory.ImportNode(node, true); + } + + m_log.Debug("[DATASNAPSHOT]: Obtained snapshot from cache for " + scene.RegionInfo.RegionName); + } + else + { + m_log.Debug("[DATASNAPSHOT]: Attempting to generate snapshot."); + //make snapshot + regionElement = MakeRegionNode(scene, factory); + + regionElement.AppendChild(GetGridSnapshotData(factory)); + XmlNode regionData = factory.CreateNode(XmlNodeType.Element, "data", ""); + + foreach (IDataSnapshotProvider dataprovider in m_providers) + { + if (dataprovider.GetParentScene == scene) + { + regionData.AppendChild(GetFragment(dataprovider, factory)); + } + } + + regionElement.AppendChild(regionData); + + factory.AppendChild(regionElement); + + //save snapshot + String path = DataFileNameScene(scene); + + try + { + using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) + { + snapXWriter.Formatting = Formatting.Indented; + snapXWriter.WriteStartDocument(); + regionElement.WriteTo(snapXWriter); + snapXWriter.WriteEndDocument(); + } + } + catch (Exception e) + { + m_log.WarnFormat("[DATASNAPSHOT]: Exception on writing to file {0}: {1}", path, e.Message); + } + + m_scenes[scene] = false; + + m_log.Debug("[DATASNAPSHOT]: Generated new snapshot for " + scene.RegionInfo.RegionName); + } + + return regionElement; + } + + #endregion + + #region Helpers + private string DataFileNameFragment(Scene scene, String fragmentName) + { + return Path.Combine(m_directory, Path.ChangeExtension(Sanitize(scene.RegionInfo.RegionName + "_" + fragmentName), "xml")); + } + + private string DataFileNameScene(Scene scene) + { + return Path.Combine(m_directory, Path.ChangeExtension(Sanitize(scene.RegionInfo.RegionName), "xml")); + //return (m_snapsDir + Path.DirectorySeparatorChar + scene.RegionInfo.RegionName + ".xml"); + } + + private static string Sanitize(string name) + { + string invalidChars = Regex.Escape(new string(Path.GetInvalidFileNameChars())); + string invalidReStr = string.Format(@"[{0}]", invalidChars); + string newname = Regex.Replace(name, invalidReStr, "_"); + return newname.Replace('.', '_'); + } + + private XmlNode MakeRegionNode(Scene scene, XmlDocument basedoc) + { + XmlNode docElement = basedoc.CreateNode(XmlNodeType.Element, "region", ""); + + XmlAttribute attr = basedoc.CreateAttribute("category"); + attr.Value = GetRegionCategory(scene); + docElement.Attributes.Append(attr); + + attr = basedoc.CreateAttribute("entities"); + attr.Value = scene.Entities.Count.ToString(); + docElement.Attributes.Append(attr); + + //attr = basedoc.CreateAttribute("parcels"); + //attr.Value = scene.LandManager.landList.Count.ToString(); + //docElement.Attributes.Append(attr); + + + XmlNode infoblock = basedoc.CreateNode(XmlNodeType.Element, "info", ""); + + XmlNode infopiece = basedoc.CreateNode(XmlNodeType.Element, "uuid", ""); + infopiece.InnerText = scene.RegionInfo.RegionID.ToString(); + infoblock.AppendChild(infopiece); + + infopiece = basedoc.CreateNode(XmlNodeType.Element, "url", ""); + infopiece.InnerText = "http://" + m_hostname + ":" + m_listener_port; + infoblock.AppendChild(infopiece); + + infopiece = basedoc.CreateNode(XmlNodeType.Element, "name", ""); + infopiece.InnerText = scene.RegionInfo.RegionName; + infoblock.AppendChild(infopiece); + + infopiece = basedoc.CreateNode(XmlNodeType.Element, "handle", ""); + infopiece.InnerText = scene.RegionInfo.RegionHandle.ToString(); + infoblock.AppendChild(infopiece); + + docElement.AppendChild(infoblock); + + m_log.Debug("[DATASNAPSHOT]: Generated region node"); + return docElement; + } + + private String GetRegionCategory(Scene scene) + { + if (scene.RegionInfo.RegionSettings.Maturity == 0) + return "PG"; + + if (scene.RegionInfo.RegionSettings.Maturity == 1) + return "Mature"; + + if (scene.RegionInfo.RegionSettings.Maturity == 2) + return "Adult"; + + return "Unknown"; + } + + private XmlNode GetGridSnapshotData(XmlDocument factory) + { + XmlNode griddata = factory.CreateNode(XmlNodeType.Element, "grid", ""); + + foreach (KeyValuePair GridData in m_gridinfo) + { + //TODO: make it lowercase tag names for diva + XmlNode childnode = factory.CreateNode(XmlNodeType.Element, GridData.Key, ""); + childnode.InnerText = GridData.Value; + griddata.AppendChild(childnode); + } + + m_log.Debug("[DATASNAPSHOT]: Got grid snapshot data"); + + return griddata; + } + #endregion + + #region Manage internal collections + public void AddScene(Scene newScene) + { + m_scenes.Add(newScene, true); + } + + public void RemoveScene(Scene deadScene) + { + m_scenes.Remove(deadScene); + } + + public void AddProvider(IDataSnapshotProvider newProvider) + { + m_providers.Add(newProvider); + } + + public void RemoveProvider(IDataSnapshotProvider deadProvider) + { + m_providers.Remove(deadProvider); + } + #endregion + } +} diff --git a/prebuild.xml b/prebuild.xml index d46d178..f47e237 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1895,41 +1895,6 @@ - - - - ../../../bin/ - - - - - ../../../bin/ - - - - ../../../bin/ - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.1