From 222becc8795d8abd8263c8abf8212de91faa4748 Mon Sep 17 00:00:00 2001 From: mingchen Date: Wed, 18 Jul 2007 23:15:08 +0000 Subject: *New Configuration System, much easier and less buggy compared to the original system in place *View RegionInfo.cs for an example on how it works! *This hopefully copies all the files over, but who knows :) --- OpenSim/Framework/General/AgentCircuitManager.cs | 2 +- .../General/Configuration/ConfigurationMember.cs | 311 +++++++++++++++++++++ .../General/Configuration/ConfigurationOption.cs | 34 +++ .../Framework/General/Configuration/GridConfig.cs | 78 ++++++ .../Configuration/Interfaces/IGenericConfig.cs | 38 +++ .../Framework/General/Configuration/UserConfig.cs | 55 ++++ .../General/Configuration/XmlConfiguration.cs | 123 ++++++++ .../Framework/General/Types/NetworkServersInfo.cs | 216 ++++---------- OpenSim/Framework/General/Types/RegionInfo.cs | 244 +++++----------- .../GenericConfig/Xml/Properties/AssemblyInfo.cs | 33 --- OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs | 122 -------- OpenSim/Framework/UserManager/UserManagerBase.cs | 2 + OpenSim/Grid/GridServer/GridManager.cs | 2 + OpenSim/Grid/GridServer/Main.cs | 42 +-- OpenSim/Grid/UserServer/Main.cs | 40 +-- OpenSim/Region/Application/OpenSimMain.cs | 38 +-- OpenSim/Region/ClientStack/PacketServer.cs | 1 + .../Region/ClientStack/RegionApplicationBase.cs | 4 +- OpenSim/Region/ClientStack/UDPServer.cs | 1 + OpenSim/Region/Environment/RegionManager.cs | 1 + prebuild.xml | 79 +----- 21 files changed, 792 insertions(+), 674 deletions(-) create mode 100644 OpenSim/Framework/General/Configuration/ConfigurationMember.cs create mode 100644 OpenSim/Framework/General/Configuration/ConfigurationOption.cs create mode 100644 OpenSim/Framework/General/Configuration/GridConfig.cs create mode 100644 OpenSim/Framework/General/Configuration/Interfaces/IGenericConfig.cs create mode 100644 OpenSim/Framework/General/Configuration/UserConfig.cs create mode 100644 OpenSim/Framework/General/Configuration/XmlConfiguration.cs delete mode 100644 OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs delete mode 100644 OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs diff --git a/OpenSim/Framework/General/AgentCircuitManager.cs b/OpenSim/Framework/General/AgentCircuitManager.cs index c19d6b1..10b0430 100644 --- a/OpenSim/Framework/General/AgentCircuitManager.cs +++ b/OpenSim/Framework/General/AgentCircuitManager.cs @@ -30,7 +30,7 @@ using libsecondlife; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; -namespace OpenSim.Framework +namespace OpenSim.Framework.Types { public class AgentCircuitManager { diff --git a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs new file mode 100644 index 0000000..2d945b5 --- /dev/null +++ b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs @@ -0,0 +1,311 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Net; + +using libsecondlife; + +using OpenSim.Framework.Console; + +namespace OpenSim.Framework.Configuration +{ + public class ConfigurationMember + { + public delegate void ConfigurationOptionResult(string configuration_key, object configuration_result); + public delegate void ConfigurationOptionsLoad(); + + private List configurationOptions = new List(); + private string configurationFilename = ""; + private string configurationDescription = ""; + + private ConfigurationOptionsLoad loadFunction; + private ConfigurationOptionResult resultFunction; + + public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) + { + this.configurationFilename = configuration_filename; + this.configurationDescription = configuration_description; + this.loadFunction = load_function; + this.resultFunction = result_function; + } + + public void setConfigurationFilename(string filename) + { + configurationFilename = filename; + } + public void setConfigurationDescription(string desc) + { + configurationDescription = desc; + } + + public void setConfigurationResultFunction(ConfigurationOptionResult result) + { + resultFunction = result; + } + + public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default) + { + ConfigurationOption configOption = new ConfigurationOption(); + configOption.configurationKey = configuration_key; + configOption.configurationQuestion = configuration_question; + configOption.configurationDefault = configuration_default; + configOption.configurationType = configuration_type; + + if (configuration_key != "" && configuration_question != "" && configuration_type != null) + { + if (!configurationOptions.Contains(configOption)) + { + configurationOptions.Add(configOption); + } + } + else + { + MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + configuration_key + ")"); + } + } + + public void performConfigurationRetrieve() + { + configurationOptions.Clear(); + if(loadFunction == null) + { + MainLog.Instance.Error("Load Function for '" + this.configurationDescription + "' is null. Refusing to run configuration."); + return; + } + + if(resultFunction == null) + { + MainLog.Instance.Error("Result Function for '" + this.configurationDescription + "' is null. Refusing to run configuration."); + return; + } + + MainLog.Instance.Verbose("Calling Configuration Load Function..."); + this.loadFunction(); + + if(configurationOptions.Count <= 0) + { + MainLog.Instance.Error("No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration."); + return; + } + + bool useFile = true; + XmlConfiguration xmlConfig = null; + if (configurationFilename.Trim() != "") + { + xmlConfig = new XmlConfiguration(configurationFilename); + + } + + if(xmlConfig != null) + { + xmlConfig.LoadData(); + useFile = true; + } + else + { + MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file."); + useFile = false; + } + + foreach (ConfigurationOption configOption in configurationOptions) + { + bool convertSuccess = false; + object return_result = null; + string errorMessage = ""; + bool ignoreNextFromConfig = false; + while (convertSuccess == false) + { + + string attribute = null; + if (useFile) + { + if (!ignoreNextFromConfig) + { + attribute = xmlConfig.GetAttribute(configOption.configurationKey); + } + else + { + ignoreNextFromConfig = false; + } + } + + string console_result = ""; + if (attribute == null) + { + if (configurationDescription.Trim() != "") + { + console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); + } + else + { + console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault); + } + } + else + { + console_result = attribute; + } + + switch (configOption.configurationType) + { + case ConfigurationOption.ConfigurationTypes.TYPE_STRING: + return_result = console_result; + convertSuccess = true; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN: + bool boolResult; + if (Boolean.TryParse(console_result, out boolResult)) + { + convertSuccess = true; + return_result = boolResult; + } + errorMessage = "'true' or 'false' (Boolean)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_BYTE: + byte byteResult; + if (Byte.TryParse(console_result, out byteResult)) + { + convertSuccess = true; + return_result = byteResult; + } + errorMessage = "a byte (Byte)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER: + char charResult; + if (Char.TryParse(console_result, out charResult)) + { + convertSuccess = true; + return_result = charResult; + } + errorMessage = "a character (Char)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_INT16: + short shortResult; + if (Int16.TryParse(console_result, out shortResult)) + { + convertSuccess = true; + return_result = shortResult; + } + errorMessage = "a signed 32 bit integer (short)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_INT32: + int intResult; + if (Int32.TryParse(console_result, out intResult)) + { + convertSuccess = true; + return_result = intResult; + + } + errorMessage = "a signed 32 bit integer (int)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_INT64: + long longResult; + if (Int64.TryParse(console_result, out longResult)) + { + convertSuccess = true; + return_result = longResult; + } + errorMessage = "a signed 32 bit integer (long)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS: + IPAddress ipAddressResult; + if (IPAddress.TryParse(console_result, out ipAddressResult)) + { + convertSuccess = true; + return_result = ipAddressResult; + } + errorMessage = "an IP Address (IPAddress)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_LLUUID: + LLUUID uuidResult; + if (LLUUID.TryParse(console_result, out uuidResult)) + { + convertSuccess = true; + return_result = uuidResult; + } + errorMessage = "a UUID (LLUUID)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_LLVECTOR3: + LLVector3 vectorResult; + if (LLVector3.TryParse(console_result, out vectorResult)) + { + convertSuccess = true; + return_result = vectorResult; + } + errorMessage = "a vector (LLVector3)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_UINT16: + ushort ushortResult; + if (UInt16.TryParse(console_result, out ushortResult)) + { + convertSuccess = true; + return_result = ushortResult; + } + errorMessage = "an unsigned 16 bit integer (ushort)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_UINT32: + uint uintResult; + if (UInt32.TryParse(console_result, out uintResult)) + { + convertSuccess = true; + return_result = uintResult; + + } + errorMessage = "an unsigned 32 bit integer (uint)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_UINT64: + ulong ulongResult; + if (UInt64.TryParse(console_result, out ulongResult)) + { + convertSuccess = true; + return_result = ulongResult; + } + errorMessage = "an unsigned 64 bit integer (ulong)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT: + float floatResult; + if (float.TryParse(console_result, out floatResult)) + { + convertSuccess = true; + return_result = floatResult; + } + errorMessage = "a single-precision floating point number (float)"; + break; + case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE: + double doubleResult; + if (Double.TryParse(console_result, out doubleResult)) + { + convertSuccess = true; + return_result = doubleResult; + } + errorMessage = "an double-precision floating point number (double)"; + break; + } + + if (convertSuccess) + { + if (useFile) + { + xmlConfig.SetAttribute(configOption.configurationKey, console_result); + } + + + this.resultFunction(configOption.configurationKey, return_result); + } + else + { + MainLog.Instance.Warn("Incorrect result given, the configuration option must be " + errorMessage + ". Prompting for same option..."); + ignoreNextFromConfig = true; + } + } + } + + if(useFile) + { + xmlConfig.Commit(); + xmlConfig.Close(); + } + } + } +} diff --git a/OpenSim/Framework/General/Configuration/ConfigurationOption.cs b/OpenSim/Framework/General/Configuration/ConfigurationOption.cs new file mode 100644 index 0000000..15da1aa --- /dev/null +++ b/OpenSim/Framework/General/Configuration/ConfigurationOption.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Configuration +{ + public class ConfigurationOption + { + public enum ConfigurationTypes + { + TYPE_STRING, + TYPE_UINT16, + TYPE_UINT32, + TYPE_UINT64, + TYPE_INT16, + TYPE_INT32, + TYPE_INT64, + TYPE_IP_ADDRESS, + TYPE_CHARACTER, + TYPE_BOOLEAN, + TYPE_BYTE, + TYPE_LLUUID, + TYPE_LLVECTOR3, + TYPE_FLOAT, + TYPE_DOUBLE + }; + + public string configurationKey = ""; + public string configurationQuestion = ""; + public string configurationDefault = ""; + + public ConfigurationTypes configurationType = ConfigurationTypes.TYPE_STRING; + } +} diff --git a/OpenSim/Framework/General/Configuration/GridConfig.cs b/OpenSim/Framework/General/Configuration/GridConfig.cs new file mode 100644 index 0000000..97dd699 --- /dev/null +++ b/OpenSim/Framework/General/Configuration/GridConfig.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Configuration +{ + public class GridConfig + { + public string GridOwner = ""; + public string DefaultAssetServer = ""; + public string AssetSendKey = ""; + public string AssetRecvKey = ""; + + public string DefaultUserServer = ""; + public string UserSendKey = ""; + public string UserRecvKey = ""; + + public string SimSendKey = ""; + public string SimRecvKey = ""; + + private ConfigurationMember configMember; + public GridConfig(string description, string filename) + { + configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration); + configMember.performConfigurationRetrieve(); + } + + public void loadConfigurationOptions() + { + configMember.addConfigurationOption("grid_owner",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"OGS Grid Owner","OGS development team"); + configMember.addConfigurationOption("default_asset_server",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Default Asset Server URI","http://127.0.0.1:8003/"); + configMember.addConfigurationOption("asset_send_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to send to asset server","null"); + configMember.addConfigurationOption("asset_recv_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to expect from asset server","null"); + + configMember.addConfigurationOption("default_user_server",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Default User Server URI","http://127.0.0.1:8002/"); + configMember.addConfigurationOption("user_send_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to send to user server","null"); + configMember.addConfigurationOption("user_recv_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to expect from user server","null"); + + configMember.addConfigurationOption("sim_send_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to send to a simulator","null"); + configMember.addConfigurationOption("sim_recv_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to expect from a simulator","null"); + + } + + public void handleIncomingConfiguration(string configuration_key, object configuration_result) + { + switch (configuration_key) + { + case "grid_owner": + this.GridOwner = (string)configuration_result; + break; + case "default_asset_server": + this.DefaultAssetServer = (string)configuration_result; + break; + case "asset_send_key": + this.AssetSendKey = (string)configuration_result; + break; + case "asset_recv_key": + this.AssetRecvKey = (string)configuration_result; + break; + case "default_user_server": + this.DefaultUserServer = (string)configuration_result; + break; + case "user_send_key": + this.UserSendKey = (string)configuration_result; + break; + case "user_recv_key": + this.UserRecvKey = (string)configuration_result; + break; + case "sim_send_key": + this.SimSendKey = (string)configuration_result; + break; + case "sim_recv_key": + this.SimRecvKey = (string)configuration_result; + break; + } + } + } +} diff --git a/OpenSim/Framework/General/Configuration/Interfaces/IGenericConfig.cs b/OpenSim/Framework/General/Configuration/Interfaces/IGenericConfig.cs new file mode 100644 index 0000000..2c379dd --- /dev/null +++ b/OpenSim/Framework/General/Configuration/Interfaces/IGenericConfig.cs @@ -0,0 +1,38 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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. +* +*/ +namespace OpenSim.Framework.Interfaces +{ + public interface IGenericConfig + { + void LoadData(); + string GetAttribute(string attributeName); + bool SetAttribute(string attributeName, string attributeValue); + void Commit(); + void Close(); + } +} diff --git a/OpenSim/Framework/General/Configuration/UserConfig.cs b/OpenSim/Framework/General/Configuration/UserConfig.cs new file mode 100644 index 0000000..9d607b3 --- /dev/null +++ b/OpenSim/Framework/General/Configuration/UserConfig.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Configuration +{ + /// + /// UserConfig -- For User Server Configuration + /// + public class UserConfig + { + public string DefaultStartupMsg = ""; + public string GridServerURL = ""; + public string GridSendKey = ""; + public string GridRecvKey = ""; + + private ConfigurationMember configMember; + + public UserConfig(string description, string filename) + { + configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration); + configMember.performConfigurationRetrieve(); + } + + public void loadConfigurationOptions() + { + configMember.addConfigurationOption("default_startup_message",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Default Startup Message","Welcome to OGS"); + + configMember.addConfigurationOption("default_grid_server",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Default Grid Server URI","http://127.0.0.1:8001/"); + configMember.addConfigurationOption("grid_send_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to send to grid server","null"); + configMember.addConfigurationOption("grid_recv_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to expect from grid server","null"); + + + } + + public void handleIncomingConfiguration(string configuration_key, object configuration_result) + { + switch (configuration_key) + { + case "default_startup_message": + this.DefaultStartupMsg = (string)configuration_result; + break; + case "default_grid_server": + this.GridServerURL = (string)configuration_result; + break; + case "grid_send_key": + this.GridSendKey = (string)configuration_result; + break; + case "grid_recv_key": + this.GridRecvKey = (string)configuration_result; + break; + } + } + } +} diff --git a/OpenSim/Framework/General/Configuration/XmlConfiguration.cs b/OpenSim/Framework/General/Configuration/XmlConfiguration.cs new file mode 100644 index 0000000..e1f3816 --- /dev/null +++ b/OpenSim/Framework/General/Configuration/XmlConfiguration.cs @@ -0,0 +1,123 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO; +using System.Xml; + +using OpenSim.Framework.Interfaces; + +namespace OpenSim.Framework.Configuration +{ + public class XmlConfiguration : IGenericConfig + { + private XmlDocument doc; + private XmlNode rootNode; + private XmlNode configNode; + private string fileName; + private bool createdFile = false; + + public XmlConfiguration(string filename) + { + fileName = filename; + } + + public void LoadData() + { + doc = new XmlDocument(); + + if (File.Exists(fileName)) + { + XmlTextReader reader = new XmlTextReader(fileName); + reader.WhitespaceHandling = WhitespaceHandling.None; + doc.Load(reader); + reader.Close(); + } + else + { + createdFile = true; + rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); + doc.AppendChild(rootNode); + configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); + rootNode.AppendChild(configNode); + } + + + rootNode = doc.FirstChild; + if (rootNode.Name != "Root") + throw new Exception("Error: Invalid .xml File. Missing "); + + configNode = rootNode.FirstChild; + if (configNode.Name != "Config") + throw new Exception("Error: Invalid .xml File. first child should be "); + + if (createdFile) + { + this.Commit(); + } + } + + public string GetAttribute(string attributeName) + { + string result = null; + if (configNode.Attributes[attributeName] != null) + { + result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; + } + return result; + } + + public bool SetAttribute(string attributeName, string attributeValue) + { + if (configNode.Attributes[attributeName] != null) + { + ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; + } + else + { + XmlAttribute attri; + attri = doc.CreateAttribute(attributeName); + attri.Value = attributeValue; + configNode.Attributes.Append(attri); + } + return true; + } + + public void Commit() + { + doc.Save(fileName); + } + + public void Close() + { + configNode = null; + rootNode = null; + doc = null; + } + + } +} diff --git a/OpenSim/Framework/General/Types/NetworkServersInfo.cs b/OpenSim/Framework/General/Types/NetworkServersInfo.cs index 6259d7b..40557be 100644 --- a/OpenSim/Framework/General/Types/NetworkServersInfo.cs +++ b/OpenSim/Framework/General/Types/NetworkServersInfo.cs @@ -28,6 +28,7 @@ using System; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Configuration; namespace OpenSim.Framework.Types { @@ -44,175 +45,76 @@ namespace OpenSim.Framework.Types public string UserRecvKey = ""; public bool isSandbox; - public uint DefaultHomeLocX = 1000; - public uint DefaultHomeLocY = 1000; + public uint DefaultHomeLocX = 0; + public uint DefaultHomeLocY = 0; public int HttpListenerPort = 9000; public int RemotingListenerPort = 8895; - public void InitConfig(bool sandboxMode, IGenericConfig configData) - { - this.isSandbox = sandboxMode; - - try - { - string attri = ""; - - attri = ""; - attri = configData.GetAttribute("HttpListenerPort"); - if (attri == "") - { - string location = MainLog.Instance.CmdPrompt("Http Listener Port", "9000"); - configData.SetAttribute("HttpListenerPort", location); - this.HttpListenerPort = Convert.ToInt32(location); - } - else - { - this.HttpListenerPort = Convert.ToInt32(attri); - } - - attri = ""; - attri = configData.GetAttribute("RemotingListenerPort"); - if (attri == "") - { - string location = MainLog.Instance.CmdPrompt("Remoting Listener Port", "8895"); - configData.SetAttribute("RemotingListenerPort", location); - this.RemotingListenerPort = Convert.ToInt32(location); - } - else - { - this.RemotingListenerPort = Convert.ToInt32(attri); - } - - if (sandboxMode) - { - // default home location X - attri = ""; - attri = configData.GetAttribute("DefaultLocationX"); - if (attri == "") - { - string location = MainLog.Instance.CmdPrompt("Default Home Location X", "1000"); - configData.SetAttribute("DefaultLocationX", location); - this.DefaultHomeLocX = (uint)Convert.ToUInt32(location); - } - else - { - this.DefaultHomeLocX = (uint)Convert.ToUInt32(attri); - } - - // default home location Y - attri = ""; - attri = configData.GetAttribute("DefaultLocationY"); - if (attri == "") - { - string location = MainLog.Instance.CmdPrompt("Default Home Location Y", "1000"); - configData.SetAttribute("DefaultLocationY", location); - this.DefaultHomeLocY = (uint)Convert.ToUInt32(location); - } - else - { - this.DefaultHomeLocY = (uint)Convert.ToUInt32(attri); - } - } - if (!isSandbox) - { - //Grid Server - attri = ""; - attri = configData.GetAttribute("GridServerURL"); - if (attri == "") - { - this.GridURL = MainLog.Instance.CmdPrompt("Grid server URL", "http://127.0.0.1:8001/"); - configData.SetAttribute("GridServerURL", this.GridURL); - } - else - { - this.GridURL = attri; - } + private ConfigurationMember configMember; - //Grid Send Key - attri = ""; - attri = configData.GetAttribute("GridSendKey"); - if (attri == "") - { - this.GridSendKey = MainLog.Instance.CmdPrompt("Key to send to grid server", "null"); - configData.SetAttribute("GridSendKey", this.GridSendKey); - } - else - { - this.GridSendKey = attri; - } + public NetworkServersInfo(string description, string filename) + { + configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleConfigurationItem); + configMember.performConfigurationRetrieve(); + } - //Grid Receive Key - attri = ""; - attri = configData.GetAttribute("GridRecvKey"); - if (attri == "") - { - this.GridRecvKey = MainLog.Instance.CmdPrompt("Key to expect from grid server", "null"); - configData.SetAttribute("GridRecvKey", this.GridRecvKey); - } - else - { - this.GridRecvKey = attri; - } + public void loadConfigurationOptions() + { - //Grid Server - attri = ""; - attri = configData.GetAttribute("UserServerURL"); - if (attri == "") - { - this.UserURL= MainLog.Instance.CmdPrompt("User server URL", "http://127.0.0.1:8002/"); - configData.SetAttribute("UserServerURL", this.UserURL); - } - else - { - this.UserURL = attri; - } + configMember.addConfigurationOption("HttpListenerPort", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "HTTP Listener Port", "9000"); + configMember.addConfigurationOption("RemotingListenerPort", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Remoting Listener Port", "8895"); + configMember.addConfigurationOption("DefaultLocationX", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Default Home Location (X Axis)", "1000"); + configMember.addConfigurationOption("DefaultLocationY", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Default Home Location (Y Axis)", "1000"); - //Grid Send Key - attri = ""; - attri = configData.GetAttribute("UserSendKey"); - if (attri == "") - { - this.UserSendKey = MainLog.Instance.CmdPrompt("Key to send to user server", "null"); - configData.SetAttribute("UserSendKey", this.UserSendKey); - } - else - { - this.UserSendKey = attri; - } + configMember.addConfigurationOption("GridServerURL", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Grid Server URL", "http://127.0.0.1:8001"); + configMember.addConfigurationOption("GridSendKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to grid server", "null"); + configMember.addConfigurationOption("GridRecvKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from grid server", "null"); - //Grid Receive Key - attri = ""; - attri = configData.GetAttribute("UserRecvKey"); - if (attri == "") - { - this.UserRecvKey = MainLog.Instance.CmdPrompt("Key to expect from user server", "null"); - configData.SetAttribute("UserRecvKey", this.UserRecvKey); - } - else - { - this.UserRecvKey = attri; - } + configMember.addConfigurationOption("UserServerURL", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "User Server URL", "http://127.0.0.1:8002"); + configMember.addConfigurationOption("UserSendKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to user server", "null"); + configMember.addConfigurationOption("UserRecvKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null"); - attri = ""; - attri = configData.GetAttribute("AssetServerURL"); - if (attri == "") - { - this.AssetURL = MainLog.Instance.CmdPrompt("Asset server URL", "http://127.0.0.1:8003/"); - configData.SetAttribute("AssetServerURL", this.GridURL); - } - else - { - this.AssetURL = attri; - } + configMember.addConfigurationOption("AssetServerURL", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Asset Server URL", "http://127.0.0.1:8003"); + } - } - configData.Commit(); - } - catch (Exception e) + public void handleConfigurationItem(string configuration_key, object configuration_object) + { + switch (configuration_key) { - MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured"); - MainLog.Instance.Warn(e.ToString()); + case "HttpListenerPort": + this.HttpListenerPort = (int)configuration_object; + break; + case "RemotingListenerPort": + this.RemotingListenerPort = (int)configuration_object; + break; + case "DefaultLocationX": + this.DefaultHomeLocX = (uint)configuration_object; + break; + case "DefaultLocationY": + this.DefaultHomeLocY = (uint)configuration_object; + break; + case "GridServerURL": + this.GridURL = (string)configuration_object; + break; + case "GridSendKey": + this.GridSendKey = (string)configuration_object; + break; + case "GridRecvKey": + this.GridRecvKey = (string)configuration_object; + break; + case "UserServerURL": + this.UserURL = (string)configuration_object; + break; + case "UserSendKey": + this.UserSendKey = (string)configuration_object; + break; + case "UserRecvKey": + this.UserRecvKey = (string)configuration_object; + break; + case "AssetServerURL": + this.AssetURL = (string)configuration_object; + break; } } } diff --git a/OpenSim/Framework/General/Types/RegionInfo.cs b/OpenSim/Framework/General/Types/RegionInfo.cs index 251d7f8..b7c35c7 100644 --- a/OpenSim/Framework/General/Types/RegionInfo.cs +++ b/OpenSim/Framework/General/Types/RegionInfo.cs @@ -34,6 +34,8 @@ using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Utilities; +using OpenSim.Framework.Configuration; + namespace OpenSim.Framework.Types { public class RegionInfo @@ -71,11 +73,11 @@ namespace OpenSim.Framework.Types } } - + return new IPEndPoint(ia, m_internalEndPoint.Port); } } - + private string m_externalHostName; public string ExternalHostName { @@ -117,7 +119,6 @@ namespace OpenSim.Framework.Types } } - // Only used for remote regions , ie ones not in the current instance private uint m_remotingPort; public uint RemotingPort { @@ -142,14 +143,18 @@ namespace OpenSim.Framework.Types public EstateSettings estateSettings; - public RegionInfo() + public ConfigurationMember configMember; + public RegionInfo(string description, string filename) { estateSettings = new EstateSettings(); + configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); + configMember.performConfigurationRetrieve(); } public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) - : this() { + + estateSettings = new EstateSettings(); m_regionLocX = regionLocX; m_regionLocY = regionLocY; @@ -157,187 +162,70 @@ namespace OpenSim.Framework.Types m_externalHostName = externalUri; } - public void InitConfig(bool sandboxMode, IGenericConfig configData) - { - this.isSandbox = sandboxMode; - try - { - string attri = ""; - - // Sim UUID - string simId = configData.GetAttribute("SimUUID"); - if (String.IsNullOrEmpty( simId )) - { - this.SimUUID = LLUUID.Random(); - } - else - { - this.SimUUID = new LLUUID(simId); - } - configData.SetAttribute("SimUUID", this.SimUUID.ToString()); - - this.RegionName = GetString(configData, "SimName", "OpenSim test", "Region Name"); - - //m_regionLocX = (uint) GetInt(configData, "SimLocationX", 1000, "Grid Location X"); - - attri = ""; - attri = configData.GetAttribute("SimLocationX"); - if (attri == "") - { - string location = MainLog.Instance.CmdPrompt("Grid Location X", "1000"); - configData.SetAttribute("SimLocationX", location); - m_regionLocX = (uint)Convert.ToUInt32(location); - } - else - { - m_regionLocX = (uint)Convert.ToUInt32(attri); - } - // Sim/Grid location Y - attri = ""; - attri = configData.GetAttribute("SimLocationY"); - if (attri == "") - { - string location = MainLog.Instance.CmdPrompt("Grid Location Y", "1000"); - configData.SetAttribute("SimLocationY", location); - m_regionLocY = (uint)Convert.ToUInt32(location); - } - else - { - m_regionLocY = (uint)Convert.ToUInt32(attri); - } - - m_regionHandle = null; - - this.DataStore = GetString(configData, "Datastore", "localworld.yap", "Filename for local storage"); - - string internalAddress = GetString(configData, "InternalIPAddress", "0.0.0.0", "Internal IP Address for UDP client connections").ToString(); - int internalPort = GetIPPort(configData, "InternalIPPort", "9000", "Internal IP Port for UDP client connections"); - IPAddress internalIPAddress = Util.GetHostFromDNS(internalAddress); - m_internalEndPoint = new IPEndPoint(internalIPAddress, internalPort); - - m_externalHostName = GetString(configData, "ExternalHostName", "127.0.0.1", "External Host Name"); - - estateSettings.terrainFile = - GetString(configData, "TerrainFile", "default.r32", "GENERAL SETTING: Default Terrain File"); - - attri = ""; - attri = configData.GetAttribute("TerrainMultiplier"); - if (attri == "") - { - string re = MainLog.Instance.CmdPrompt("GENERAL SETTING: Terrain Height Multiplier", "60.0"); - this.estateSettings.terrainMultiplier = Convert.ToDouble(re, CultureInfo.InvariantCulture); - configData.SetAttribute("TerrainMultiplier", this.estateSettings.terrainMultiplier.ToString()); - } - else - { - this.estateSettings.terrainMultiplier = Convert.ToDouble(attri); - } - - attri = ""; - attri = configData.GetAttribute("MasterAvatarFirstName"); - if (attri == "") - { - this.MasterAvatarFirstName = MainLog.Instance.CmdPrompt("First name of Master Avatar (Land and Region Owner)", "Test"); - - configData.SetAttribute("MasterAvatarFirstName", this.MasterAvatarFirstName); - } - else - { - this.MasterAvatarFirstName = attri; - } - - attri = ""; - attri = configData.GetAttribute("MasterAvatarLastName"); - if (attri == "") - { - this.MasterAvatarLastName = MainLog.Instance.CmdPrompt("Last name of Master Avatar (Land and Region Owner)", "User"); - - configData.SetAttribute("MasterAvatarLastName", this.MasterAvatarLastName); - } - else - { - this.MasterAvatarLastName = attri; - } - - if (isSandbox) //Sandbox Mode Specific Settings - { - attri = ""; - attri = configData.GetAttribute("MasterAvatarSandboxPassword"); - if (attri == "") - { - this.MasterAvatarSandboxPassword = MainLog.Instance.CmdPrompt("Password of Master Avatar (Needed for sandbox mode account creation only)", "test"); - - //Should I store this? - configData.SetAttribute("MasterAvatarSandboxPassword", this.MasterAvatarSandboxPassword); - } - else - { - this.MasterAvatarSandboxPassword = attri; - } - } - - configData.Commit(); - } - catch (Exception e) - { - MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured"); - MainLog.Instance.Warn(e.ToString()); - } - - MainLog.Instance.Verbose("Sim settings loaded:"); - MainLog.Instance.Verbose("UUID: " + this.SimUUID.ToStringHyphenated()); - MainLog.Instance.Verbose("Name: " + this.RegionName); - MainLog.Instance.Verbose("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); - MainLog.Instance.Verbose("Region Handle: " + this.RegionHandle.ToString()); - MainLog.Instance.Verbose("Listening on IP end point: " + m_internalEndPoint.ToString() ); - MainLog.Instance.Verbose("Sandbox Mode? " + isSandbox.ToString()); - - } - - private uint GetInt(IGenericConfig configData, string p, int p_3, string p_4) + public void loadConfigurationOptions() { - throw new Exception("The method or operation is not implemented."); - } - - private string GetString(IGenericConfig configData, string attrName, string defaultvalue, string prompt) - { - string s = configData.GetAttribute(attrName); + configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "UUID of Simulator (Default is recommended, random UUID)", LLUUID.Random().ToString()); + configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Simulator Name", "OpenSim Test"); + configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (X Axis)", "1000"); + configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (Y Axis)", "1000"); + configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Filename for local storage", "localworld.yap"); + configMember.addConfigurationOption("internal_ip_address", ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, "Internal IP Address for incoming UDP client connections", "0.0.0.0"); + configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Internal IP Port for incoming UDP client connections", "9000"); + configMember.addConfigurationOption("external_host_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "External Host Name", "127.0.0.1"); + configMember.addConfigurationOption("terrain_file", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Default Terrain File", "default.r32"); + configMember.addConfigurationOption("terrain_multiplier", ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE, "Terrain Height Multiplier", "60.0"); + configMember.addConfigurationOption("master_avatar_first", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "First Name of Master Avatar", "Test"); + configMember.addConfigurationOption("master_avatar_last", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Last Name of Master Avatar", "User"); + configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "(Sandbox Mode Only)Password for Master Avatar account", "test"); - if (String.IsNullOrEmpty( s )) - { - s = MainLog.Instance.CmdPrompt(prompt, defaultvalue); - configData.SetAttribute(attrName, s ); - } - return s; } - private IPAddress GetIPAddress(IGenericConfig configData, string attrName, string defaultvalue, string prompt) + public void handleIncomingConfiguration(string configuration_key, object configuration_result) { - string addressStr = configData.GetAttribute(attrName); - - IPAddress address; - - if (!IPAddress.TryParse(addressStr, out address)) + switch (configuration_key) { - address = MainLog.Instance.CmdPromptIPAddress(prompt, defaultvalue); - configData.SetAttribute(attrName, address.ToString()); + case "sim_UUID": + this.SimUUID = (LLUUID)configuration_result; + break; + case "sim_name": + this.RegionName = (string)configuration_result; + break; + case "sim_location_x": + this.m_regionLocX = (uint)configuration_result; + break; + case "sim_location_y": + this.m_regionLocY = (uint)configuration_result; + break; + case "datastore": + this.DataStore = (string)configuration_result; + break; + case "internal_ip_address": + IPAddress address = (IPAddress)configuration_result; + this.m_internalEndPoint = new IPEndPoint(address, 0); + break; + case "internal_ip_port": + this.m_internalEndPoint.Port = (int)configuration_result; + break; + case "external_host_name": + this.m_externalHostName = (string)configuration_result; + break; + case "terrain_file": + this.estateSettings.terrainFile = (string)configuration_result; + break; + case "terrain_multiplier": + this.estateSettings.terrainMultiplier = (double)configuration_result; + break; + case "master_avatar_first": + this.MasterAvatarFirstName = (string)configuration_result; + break; + case "master_avatar_last": + this.MasterAvatarLastName = (string)configuration_result; + break; + case "master_avatar_pass": + this.MasterAvatarSandboxPassword = (string)configuration_result; + break; } - return address; } - - private int GetIPPort(IGenericConfig configData, string attrName, string defaultvalue, string prompt) - { - string portStr = configData.GetAttribute(attrName); - int port; - - if (!int.TryParse(portStr, out port)) - { - port = MainLog.Instance.CmdPromptIPPort(prompt, defaultvalue); - configData.SetAttribute(attrName, port.ToString()); - } - - return port; - } } } diff --git a/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs b/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs deleted file mode 100644 index 28779ee..0000000 --- a/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -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.GenericConfig")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.GenericConfig")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[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("285a3047-f165-46c8-8767-b51428738a09")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs b/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs deleted file mode 100644 index 2ed8d28..0000000 --- a/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs +++ /dev/null @@ -1,122 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO; -using System.Xml; -using OpenSim.Framework.Interfaces; - -namespace OpenSim.GenericConfig -{ - public class XmlConfig : IGenericConfig - { - private XmlDocument doc; - private XmlNode rootNode; - private XmlNode configNode; - private string fileName; - private bool createdFile = false; - - public XmlConfig(string filename) - { - fileName = filename; - } - - public void LoadData() - { - doc = new XmlDocument(); - - if (File.Exists(fileName)) - { - XmlTextReader reader = new XmlTextReader(fileName); - reader.WhitespaceHandling = WhitespaceHandling.None; - doc.Load(reader); - reader.Close(); - } - else - { - createdFile = true; - rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); - doc.AppendChild(rootNode); - configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); - rootNode.AppendChild(configNode); - } - - - rootNode = doc.FirstChild; - if (rootNode.Name != "Root") - throw new Exception("Error: Invalid .xml File. Missing "); - - configNode = rootNode.FirstChild; - if (configNode.Name != "Config") - throw new Exception("Error: Invalid .xml File. first child should be "); - - if (createdFile) - { - this.Commit(); - } - } - - public string GetAttribute(string attributeName) - { - string result = ""; - if (configNode.Attributes[attributeName] != null) - { - result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; - } - return result; - } - - public bool SetAttribute(string attributeName, string attributeValue) - { - if (configNode.Attributes[attributeName] != null) - { - ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; - } - else - { - XmlAttribute attri; - attri = doc.CreateAttribute(attributeName); - attri.Value = attributeValue; - configNode.Attributes.Append(attri); - } - return true; - } - - public void Commit() - { - doc.Save(fileName); - } - - public void Close() - { - configNode = null; - rootNode = null; - doc = null; - } - - } -} diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index fe45d1b..865adbe 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -38,6 +38,8 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Inventory; using OpenSim.Framework.Utilities; +using OpenSim.Framework.Configuration; + namespace OpenSim.Framework.UserManagement { public abstract class UserManagerBase diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index b3ba4e5..2e7f9f7 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs @@ -38,6 +38,8 @@ using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Utilities; +using OpenSim.Framework.Configuration; + namespace OpenSim.Grid.GridServer { class GridManager diff --git a/OpenSim/Grid/GridServer/Main.cs b/OpenSim/Grid/GridServer/Main.cs index 09aeab5..85bd918 100644 --- a/OpenSim/Grid/GridServer/Main.cs +++ b/OpenSim/Grid/GridServer/Main.cs @@ -33,7 +33,8 @@ using System.Timers; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.GenericConfig; +using OpenSim.Framework.Configuration; + using Timer=System.Timers.Timer; namespace OpenSim.Grid.GridServer @@ -47,7 +48,6 @@ namespace OpenSim.Grid.GridServer public GridConfig Cfg; public static OpenGrid_Main thegrid; - protected IGenericConfig localXMLConfig; public static bool setuponly; @@ -105,14 +105,8 @@ namespace OpenSim.Grid.GridServer public void Startup() { - this.localXMLConfig = new XmlConfig("GridServerConfig.xml"); - this.localXMLConfig.LoadData(); - this.ConfigDB(this.localXMLConfig); - this.localXMLConfig.Close(); - - m_console.Verbose( "Main.cs:Startup() - Loading configuration"); - Cfg = this.LoadConfigDll(this.ConfigDll); - Cfg.InitConfig(); + + this.Cfg = new GridConfig("GRID SERVER","GridServer_Config.xml"); //Yeah srsly, that's it. if (setuponly) Environment.Exit(0); m_console.Verbose( "Main.cs:Startup() - Connecting to Storage Server"); @@ -148,34 +142,6 @@ namespace OpenSim.Grid.GridServer simCheckTimer.Enabled = true; } - private GridConfig LoadConfigDll(string dllName) - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - GridConfig config = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IGridConfig", true); - - if (typeInterface != null) - { - IGridConfig plug = (IGridConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - config = plug.GetConfigObject(); - break; - } - - typeInterface = null; - } - } - } - pluginAssembly = null; - return config; - } - public void CheckSims(object sender, ElapsedEventArgs e) { /* diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 9bdf8d7..b702beb 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -35,7 +35,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.User; using OpenSim.Framework.Utilities; -using OpenSim.GenericConfig; +using OpenSim.Framework.Configuration; namespace OpenSim.Grid.UserServer { @@ -46,7 +46,6 @@ namespace OpenSim.Grid.UserServer private string ConfigDll = "OpenSim.Grid.UserServer.Config.dll"; private string StorageDll = "OpenSim.Framework.Data.MySQL.dll"; private UserConfig Cfg; - protected IGenericConfig localXMLConfig; public UserManager m_userManager; @@ -83,14 +82,7 @@ namespace OpenSim.Grid.UserServer public void Startup() { - this.localXMLConfig = new XmlConfig("UserServerConfig.xml"); - this.localXMLConfig.LoadData(); - this.ConfigDB(this.localXMLConfig); - this.localXMLConfig.Close(); - - MainLog.Instance.Verbose("Main.cs:Startup() - Loading configuration"); - Cfg = this.LoadConfigDll(this.ConfigDll); - Cfg.InitConfig(); + this.Cfg = new UserConfig("USER SERVER", "UserServer_Config.xml"); MainLog.Instance.Verbose("Main.cs:Startup() - Establishing data connection"); m_userManager = new UserManager(); @@ -179,34 +171,6 @@ namespace OpenSim.Grid.UserServer } } - private UserConfig LoadConfigDll(string dllName) - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - UserConfig config = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IUserConfig", true); - - if (typeInterface != null) - { - IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - config = plug.GetConfigObject(); - break; - } - - typeInterface = null; - } - } - } - pluginAssembly = null; - return config; - } - public void Show(string ShowWhat) { } diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index c333e0e..81523e0 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -37,7 +37,7 @@ using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; -using OpenSim.GenericConfig; +using OpenSim.Framework.Configuration; using OpenSim.Physics.Manager; using OpenSim.Region.Caches; using OpenSim.Region.ClientStack; @@ -85,6 +85,9 @@ namespace OpenSim /// public override void StartUp() { + m_log = new LogBase(m_logFilename, "Region", this, m_silent); + MainLog.Instance = m_log; + base.StartUp(); if (!m_sandbox) @@ -108,27 +111,16 @@ namespace OpenSim { string path2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions"); string path3 = Path.Combine(path2, "default.xml"); - Console.WriteLine("Creating default region config file"); - //TODO create default region - IGenericConfig defaultConfig = new XmlConfig(path3); - defaultConfig.LoadData(); - defaultConfig.Commit(); - defaultConfig.Close(); - defaultConfig = null; + + RegionInfo regionInfo = new RegionInfo("DEFAULT REGION CONFIG", path3); configFiles = Directory.GetFiles(path, "*.xml"); } for (int i = 0; i < configFiles.Length; i++) { Console.WriteLine("Loading region config file"); - - IGenericConfig regionConfig = new XmlConfig(configFiles[i]); - RegionInfo regionInfo = new RegionInfo(); - regionConfig.LoadData(); - regionInfo.InitConfig(this.m_sandbox, regionConfig); - regionConfig.Close(); - - + RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]); + UDPServer udpServer; Scene scene = SetupScene(regionInfo, out udpServer); @@ -159,21 +151,7 @@ namespace OpenSim protected override void Initialize() { - IGenericConfig localConfig = new XmlConfig(m_configFileName); - localConfig.LoadData(); - - if (m_useConfigFile) - { - SetupFromConfigFile(localConfig); - } - - StartLog(); - - m_networkServersInfo.InitConfig(m_sandbox, localConfig); m_httpServerPort = m_networkServersInfo.HttpListenerPort; - - localConfig.Close(); - m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); } diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index 41aaf3a..7b15ab4 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs @@ -31,6 +31,7 @@ using System.Net.Sockets; using libsecondlife.Packets; using OpenSim.Assets; using OpenSim.Framework; +using OpenSim.Framework.Types; using OpenSim.Framework.Interfaces; using OpenSim.Region.Caches; diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 1bb383f..375306d 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -65,9 +65,9 @@ namespace OpenSim.Region.ClientStack virtual public void StartUp() { + ClientView.TerrainManager = new TerrainManager(new SecondLife()); - m_networkServersInfo = new NetworkServersInfo(); - RegionInfo m_regionInfo = new RegionInfo(); + m_networkServersInfo = new NetworkServersInfo("NETWORK SERVERS INFO", "network_servers_information.xml"); Initialize(); diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index ac17720..f90a213 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -32,6 +32,7 @@ using System.Net.Sockets; using libsecondlife.Packets; using OpenSim.Assets; using OpenSim.Framework; +using OpenSim.Framework.Types; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Region.Caches; diff --git a/OpenSim/Region/Environment/RegionManager.cs b/OpenSim/Region/Environment/RegionManager.cs index e75ee60..255aa45 100644 --- a/OpenSim/Region/Environment/RegionManager.cs +++ b/OpenSim/Region/Environment/RegionManager.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using OpenSim.Framework; +using OpenSim.Framework.Types; using OpenSim.Framework.Communications; using OpenSim.Framework.Servers; using OpenSim.Region.Capabilities; diff --git a/prebuild.xml b/prebuild.xml index 778271d..f302d85 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -53,6 +53,7 @@ + @@ -102,6 +103,8 @@ + + @@ -392,29 +395,7 @@ - - - - - ../../../../bin/ - - - - - ../../../../bin/ - - - - ../../../../bin/ - - - - - - - - - + @@ -487,7 +468,6 @@ - @@ -602,7 +582,6 @@ - @@ -705,7 +684,6 @@ - @@ -881,7 +859,6 @@ - @@ -939,7 +916,6 @@ - @@ -951,55 +927,8 @@ - - - - ../../../bin/ - - - - - ../../../bin/ - - - - ../../../bin/ - - - - - - - - - - - - - - - ../../../bin/ - - - - - ../../../bin/ - - - ../../../bin/ - - - - - - - - - - - -- cgit v1.1