From 46ab59723d62ecd22ebe8c797e1d510514ef35da Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 7 Jan 2015 11:04:23 -0800 Subject: Added a different/better way of specifying data services in DataSnapshot -- using DATA_SRV_ keys, one per service. This allows 3rd party modules to add data services automatically. --- OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/DataSnapshot/DataSnapshotManager.cs') diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index ddaf8de..f7b2338 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -29,8 +29,10 @@ 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; @@ -131,9 +133,12 @@ namespace OpenSim.Region.DataSnapshot 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_dataServices = config.Configs["DataSnapshot"].GetString("data_services", m_dataServices); 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) { @@ -289,6 +294,28 @@ namespace OpenSim.Region.DataSnapshot 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 -- cgit v1.1