diff options
author | Melanie | 2014-04-12 16:58:07 +0100 |
---|---|---|
committer | Melanie | 2014-04-12 16:58:07 +0100 |
commit | 5d964a6424b301a9175becd6c878e542b7d278eb (patch) | |
tree | a0ce19775822fd1d3298276dc893a061127aedbc /OpenSim/Framework | |
parent | Tweak to PrimLimits and add missing Regions.ini example (diff) | |
download | opensim-SC_OLD-5d964a6424b301a9175becd6c878e542b7d278eb.zip opensim-SC_OLD-5d964a6424b301a9175becd6c878e542b7d278eb.tar.gz opensim-SC_OLD-5d964a6424b301a9175becd6c878e542b7d278eb.tar.bz2 opensim-SC_OLD-5d964a6424b301a9175becd6c878e542b7d278eb.tar.xz |
Remove the old XML format parsing. Now additional region params can just be
added as they are already exposed through an API when using Nini. That will
remove the need to always edit RegioInfo just to add a region based setting.
Diffstat (limited to 'OpenSim/Framework')
8 files changed, 8 insertions, 1186 deletions
diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs deleted file mode 100644 index 6681c37..0000000 --- a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using log4net; | ||
34 | using OpenSim.Framework.Configuration.XML; | ||
35 | |||
36 | namespace OpenSim.Framework.Configuration.HTTP | ||
37 | { | ||
38 | public class HTTPConfiguration : IGenericConfig | ||
39 | { | ||
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | |||
42 | private RemoteConfigSettings remoteConfigSettings; | ||
43 | |||
44 | private XmlConfiguration xmlConfig; | ||
45 | |||
46 | private string configFileName = String.Empty; | ||
47 | |||
48 | public HTTPConfiguration() | ||
49 | { | ||
50 | remoteConfigSettings = new RemoteConfigSettings("remoteconfig.xml"); | ||
51 | xmlConfig = new XmlConfiguration(); | ||
52 | } | ||
53 | |||
54 | public void SetFileName(string fileName) | ||
55 | { | ||
56 | configFileName = fileName; | ||
57 | } | ||
58 | |||
59 | public void LoadData() | ||
60 | { | ||
61 | try | ||
62 | { | ||
63 | StringBuilder sb = new StringBuilder(); | ||
64 | |||
65 | byte[] buf = new byte[8192]; | ||
66 | HttpWebRequest request = | ||
67 | (HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName); | ||
68 | using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) | ||
69 | { | ||
70 | using (Stream resStream = response.GetResponseStream()) | ||
71 | { | ||
72 | string tempString = null; | ||
73 | int count = 0; | ||
74 | |||
75 | do | ||
76 | { | ||
77 | count = resStream.Read(buf, 0, buf.Length); | ||
78 | if (count != 0) | ||
79 | { | ||
80 | tempString = Util.UTF8.GetString(buf, 0, count); | ||
81 | sb.Append(tempString); | ||
82 | } | ||
83 | } | ||
84 | while (count > 0); | ||
85 | |||
86 | LoadDataFromString(sb.ToString()); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | catch (WebException) | ||
91 | { | ||
92 | m_log.Warn("Unable to connect to remote configuration file (" + | ||
93 | remoteConfigSettings.baseConfigURL + configFileName + | ||
94 | "). Creating local file instead."); | ||
95 | xmlConfig.SetFileName(configFileName); | ||
96 | xmlConfig.LoadData(); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public void LoadDataFromString(string data) | ||
101 | { | ||
102 | xmlConfig.LoadDataFromString(data); | ||
103 | } | ||
104 | |||
105 | public string GetAttribute(string attributeName) | ||
106 | { | ||
107 | return xmlConfig.GetAttribute(attributeName); | ||
108 | } | ||
109 | |||
110 | public bool SetAttribute(string attributeName, string attributeValue) | ||
111 | { | ||
112 | return true; | ||
113 | } | ||
114 | |||
115 | public void Commit() | ||
116 | { | ||
117 | } | ||
118 | |||
119 | public void Close() | ||
120 | { | ||
121 | } | ||
122 | } | ||
123 | } | ||
diff --git a/OpenSim/Framework/Configuration/HTTP/Properties/AssemblyInfo.cs b/OpenSim/Framework/Configuration/HTTP/Properties/AssemblyInfo.cs deleted file mode 100644 index 05a2e0e..0000000 --- a/OpenSim/Framework/Configuration/HTTP/Properties/AssemblyInfo.cs +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Framework.Configuration.HTTP")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator develoeprs")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("cb78b672-d000-4f93-88f9-dae151cc0061")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.8.0.*")] | ||
33 | |||
diff --git a/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs deleted file mode 100644 index 10bc88a..0000000 --- a/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | |||
30 | namespace OpenSim.Framework.Configuration.HTTP | ||
31 | { | ||
32 | public class RemoteConfigSettings | ||
33 | { | ||
34 | private ConfigurationMember configMember; | ||
35 | |||
36 | public string baseConfigURL = String.Empty; | ||
37 | |||
38 | public RemoteConfigSettings(string filename) | ||
39 | { | ||
40 | configMember = | ||
41 | new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions, | ||
42 | handleIncomingConfiguration,true); | ||
43 | configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll"); | ||
44 | configMember.performConfigurationRetrieve(); | ||
45 | } | ||
46 | |||
47 | public void loadConfigurationOptions() | ||
48 | { | ||
49 | configMember.addConfigurationOption("base_config_url", | ||
50 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
51 | "URL Containing Configuration Files", "http://localhost/", false); | ||
52 | } | ||
53 | |||
54 | public bool handleIncomingConfiguration(string configuration_key, object configuration_result) | ||
55 | { | ||
56 | if (configuration_key == "base_config_url") | ||
57 | { | ||
58 | baseConfigURL = (string) configuration_result; | ||
59 | } | ||
60 | return true; | ||
61 | } | ||
62 | } | ||
63 | } | ||
diff --git a/OpenSim/Framework/Configuration/XML/Properties/AssemblyInfo.cs b/OpenSim/Framework/Configuration/XML/Properties/AssemblyInfo.cs deleted file mode 100644 index d928a94..0000000 --- a/OpenSim/Framework/Configuration/XML/Properties/AssemblyInfo.cs +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Framework.Configuration.XML")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("eeb880df-0112-4c3d-87ed-b2108d614c55")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.8.0.*")] | ||
33 | |||
diff --git a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs deleted file mode 100644 index 3152a7d..0000000 --- a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs +++ /dev/null | |||
@@ -1,141 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Xml; | ||
31 | |||
32 | namespace OpenSim.Framework.Configuration.XML | ||
33 | { | ||
34 | public class XmlConfiguration : IGenericConfig | ||
35 | { | ||
36 | private XmlDocument doc; | ||
37 | private XmlNode rootNode; | ||
38 | private XmlNode configNode; | ||
39 | private string fileName; | ||
40 | private bool createdFile = false; | ||
41 | |||
42 | public void SetFileName(string file) | ||
43 | { | ||
44 | fileName = file; | ||
45 | } | ||
46 | |||
47 | private void LoadDataToClass() | ||
48 | { | ||
49 | rootNode = doc.SelectSingleNode("Root"); | ||
50 | if (null == rootNode) | ||
51 | throw new Exception("Error: Invalid .xml File. Missing <Root>"); | ||
52 | |||
53 | configNode = rootNode.SelectSingleNode("Config"); | ||
54 | if (null == configNode) | ||
55 | throw new Exception("Error: Invalid .xml File. <Root> should contain a <Config>"); | ||
56 | } | ||
57 | |||
58 | public void LoadData() | ||
59 | { | ||
60 | lock (this) | ||
61 | { | ||
62 | doc = new XmlDocument(); | ||
63 | if (File.Exists(fileName)) | ||
64 | { | ||
65 | XmlTextReader reader = new XmlTextReader(fileName); | ||
66 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
67 | doc.Load(reader); | ||
68 | reader.Close(); | ||
69 | } | ||
70 | else | ||
71 | { | ||
72 | createdFile = true; | ||
73 | rootNode = doc.CreateNode(XmlNodeType.Element, "Root", String.Empty); | ||
74 | doc.AppendChild(rootNode); | ||
75 | configNode = doc.CreateNode(XmlNodeType.Element, "Config", String.Empty); | ||
76 | rootNode.AppendChild(configNode); | ||
77 | } | ||
78 | |||
79 | LoadDataToClass(); | ||
80 | |||
81 | if (createdFile) | ||
82 | { | ||
83 | Commit(); | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | |||
88 | public void LoadDataFromString(string data) | ||
89 | { | ||
90 | doc = new XmlDocument(); | ||
91 | doc.LoadXml(data); | ||
92 | |||
93 | LoadDataToClass(); | ||
94 | } | ||
95 | |||
96 | public string GetAttribute(string attributeName) | ||
97 | { | ||
98 | string result = null; | ||
99 | if (configNode.Attributes[attributeName] != null) | ||
100 | { | ||
101 | result = ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value; | ||
102 | } | ||
103 | return result; | ||
104 | } | ||
105 | |||
106 | public bool SetAttribute(string attributeName, string attributeValue) | ||
107 | { | ||
108 | if (configNode.Attributes[attributeName] != null) | ||
109 | { | ||
110 | ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | XmlAttribute attri; | ||
115 | attri = doc.CreateAttribute(attributeName); | ||
116 | attri.Value = attributeValue; | ||
117 | configNode.Attributes.Append(attri); | ||
118 | } | ||
119 | return true; | ||
120 | } | ||
121 | |||
122 | public void Commit() | ||
123 | { | ||
124 | if (string.IsNullOrEmpty(fileName)) | ||
125 | return; | ||
126 | |||
127 | if (!Directory.Exists(Util.configDir())) | ||
128 | { | ||
129 | Directory.CreateDirectory(Util.configDir()); | ||
130 | } | ||
131 | doc.Save(fileName); | ||
132 | } | ||
133 | |||
134 | public void Close() | ||
135 | { | ||
136 | configNode = null; | ||
137 | rootNode = null; | ||
138 | doc = null; | ||
139 | } | ||
140 | } | ||
141 | } | ||
diff --git a/OpenSim/Framework/ConfigurationMember.cs b/OpenSim/Framework/ConfigurationMember.cs deleted file mode 100644 index 7afa68a..0000000 --- a/OpenSim/Framework/ConfigurationMember.cs +++ /dev/null | |||
@@ -1,530 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Globalization; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Xml; | ||
34 | using log4net; | ||
35 | using OpenMetaverse; | ||
36 | //using OpenSim.Framework.Console; | ||
37 | |||
38 | namespace OpenSim.Framework | ||
39 | { | ||
40 | public class ConfigurationMember | ||
41 | { | ||
42 | #region Delegates | ||
43 | |||
44 | public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result); | ||
45 | |||
46 | public delegate void ConfigurationOptionsLoad(); | ||
47 | |||
48 | #endregion | ||
49 | |||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | private int cE = 0; | ||
52 | |||
53 | private string configurationDescription = String.Empty; | ||
54 | private string configurationFilename = String.Empty; | ||
55 | private XmlNode configurationFromXMLNode = null; | ||
56 | private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>(); | ||
57 | private IGenericConfig configurationPlugin = null; | ||
58 | |||
59 | /// <summary> | ||
60 | /// This is the default configuration DLL loaded | ||
61 | /// </summary> | ||
62 | private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll"; | ||
63 | |||
64 | private ConfigurationOptionsLoad loadFunction; | ||
65 | private ConfigurationOptionResult resultFunction; | ||
66 | |||
67 | private bool useConsoleToPromptOnError = true; | ||
68 | |||
69 | public ConfigurationMember(string configuration_filename, string configuration_description, | ||
70 | ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function, bool use_console_to_prompt_on_error) | ||
71 | { | ||
72 | configurationFilename = configuration_filename; | ||
73 | configurationDescription = configuration_description; | ||
74 | loadFunction = load_function; | ||
75 | resultFunction = result_function; | ||
76 | useConsoleToPromptOnError = use_console_to_prompt_on_error; | ||
77 | } | ||
78 | |||
79 | public ConfigurationMember(XmlNode configuration_xml, string configuration_description, | ||
80 | ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function, bool use_console_to_prompt_on_error) | ||
81 | { | ||
82 | configurationFilename = String.Empty; | ||
83 | configurationFromXMLNode = configuration_xml; | ||
84 | configurationDescription = configuration_description; | ||
85 | loadFunction = load_function; | ||
86 | resultFunction = result_function; | ||
87 | useConsoleToPromptOnError = use_console_to_prompt_on_error; | ||
88 | } | ||
89 | |||
90 | public void setConfigurationFilename(string filename) | ||
91 | { | ||
92 | configurationFilename = filename; | ||
93 | } | ||
94 | |||
95 | public void setConfigurationDescription(string desc) | ||
96 | { | ||
97 | configurationDescription = desc; | ||
98 | } | ||
99 | |||
100 | public void setConfigurationResultFunction(ConfigurationOptionResult result) | ||
101 | { | ||
102 | resultFunction = result; | ||
103 | } | ||
104 | |||
105 | public void forceConfigurationPluginLibrary(string dll_filename) | ||
106 | { | ||
107 | configurationPluginFilename = dll_filename; | ||
108 | } | ||
109 | |||
110 | private void checkAndAddConfigOption(ConfigurationOption option) | ||
111 | { | ||
112 | if ((option.configurationKey != String.Empty && option.configurationQuestion != String.Empty) || | ||
113 | (option.configurationKey != String.Empty && option.configurationUseDefaultNoPrompt)) | ||
114 | { | ||
115 | if (!configurationOptions.Contains(option)) | ||
116 | { | ||
117 | configurationOptions.Add(option); | ||
118 | } | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | m_log.Info( | ||
123 | "Required fields for adding a configuration option is invalid. Will not add this option (" + | ||
124 | option.configurationKey + ")"); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | public void addConfigurationOption(string configuration_key, | ||
129 | ConfigurationOption.ConfigurationTypes configuration_type, | ||
130 | string configuration_question, string configuration_default, | ||
131 | bool use_default_no_prompt) | ||
132 | { | ||
133 | ConfigurationOption configOption = new ConfigurationOption(); | ||
134 | configOption.configurationKey = configuration_key; | ||
135 | configOption.configurationQuestion = configuration_question; | ||
136 | configOption.configurationDefault = configuration_default; | ||
137 | configOption.configurationType = configuration_type; | ||
138 | configOption.configurationUseDefaultNoPrompt = use_default_no_prompt; | ||
139 | configOption.shouldIBeAsked = null; //Assumes true, I can ask whenever | ||
140 | checkAndAddConfigOption(configOption); | ||
141 | } | ||
142 | |||
143 | public void addConfigurationOption(string configuration_key, | ||
144 | ConfigurationOption.ConfigurationTypes configuration_type, | ||
145 | string configuration_question, string configuration_default, | ||
146 | bool use_default_no_prompt, | ||
147 | ConfigurationOption.ConfigurationOptionShouldBeAsked shouldIBeAskedDelegate) | ||
148 | { | ||
149 | ConfigurationOption configOption = new ConfigurationOption(); | ||
150 | configOption.configurationKey = configuration_key; | ||
151 | configOption.configurationQuestion = configuration_question; | ||
152 | configOption.configurationDefault = configuration_default; | ||
153 | configOption.configurationType = configuration_type; | ||
154 | configOption.configurationUseDefaultNoPrompt = use_default_no_prompt; | ||
155 | configOption.shouldIBeAsked = shouldIBeAskedDelegate; | ||
156 | checkAndAddConfigOption(configOption); | ||
157 | } | ||
158 | |||
159 | // TEMP - REMOVE | ||
160 | public void performConfigurationRetrieve() | ||
161 | { | ||
162 | if (cE > 1) | ||
163 | m_log.Error("READING CONFIGURATION COUT: " + cE.ToString()); | ||
164 | |||
165 | |||
166 | configurationPlugin = LoadConfigDll(configurationPluginFilename); | ||
167 | configurationOptions.Clear(); | ||
168 | if (loadFunction == null) | ||
169 | { | ||
170 | m_log.Error("Load Function for '" + configurationDescription + | ||
171 | "' is null. Refusing to run configuration."); | ||
172 | return; | ||
173 | } | ||
174 | |||
175 | if (resultFunction == null) | ||
176 | { | ||
177 | m_log.Error("Result Function for '" + configurationDescription + | ||
178 | "' is null. Refusing to run configuration."); | ||
179 | return; | ||
180 | } | ||
181 | |||
182 | //m_log.Debug("[CONFIG]: Calling Configuration Load Function..."); | ||
183 | loadFunction(); | ||
184 | |||
185 | if (configurationOptions.Count <= 0) | ||
186 | { | ||
187 | m_log.Error("[CONFIG]: No configuration options were specified for '" + configurationOptions + | ||
188 | "'. Refusing to continue configuration."); | ||
189 | return; | ||
190 | } | ||
191 | |||
192 | bool useFile = true; | ||
193 | if (configurationPlugin == null) | ||
194 | { | ||
195 | m_log.Error("[CONFIG]: Configuration Plugin NOT LOADED!"); | ||
196 | return; | ||
197 | } | ||
198 | |||
199 | if (configurationFilename.Trim() != String.Empty) | ||
200 | { | ||
201 | configurationPlugin.SetFileName(configurationFilename); | ||
202 | try | ||
203 | { | ||
204 | configurationPlugin.LoadData(); | ||
205 | useFile = true; | ||
206 | } | ||
207 | catch (XmlException e) | ||
208 | { | ||
209 | m_log.WarnFormat("[CONFIG] Not using {0}: {1}", | ||
210 | configurationFilename, | ||
211 | e.Message.ToString()); | ||
212 | //m_log.Error("Error loading " + configurationFilename + ": " + e.ToString()); | ||
213 | useFile = false; | ||
214 | } | ||
215 | } | ||
216 | else | ||
217 | { | ||
218 | if (configurationFromXMLNode != null) | ||
219 | { | ||
220 | m_log.Info("Loading from XML Node, will not save to the file"); | ||
221 | configurationPlugin.LoadDataFromString(configurationFromXMLNode.OuterXml); | ||
222 | } | ||
223 | |||
224 | m_log.Info("XML Configuration Filename is not valid; will not save to the file."); | ||
225 | useFile = false; | ||
226 | } | ||
227 | |||
228 | foreach (ConfigurationOption configOption in configurationOptions) | ||
229 | { | ||
230 | bool convertSuccess = false; | ||
231 | object return_result = null; | ||
232 | string errorMessage = String.Empty; | ||
233 | bool ignoreNextFromConfig = false; | ||
234 | while (convertSuccess == false) | ||
235 | { | ||
236 | string console_result = String.Empty; | ||
237 | string attribute = null; | ||
238 | if (useFile || configurationFromXMLNode != null) | ||
239 | { | ||
240 | if (!ignoreNextFromConfig) | ||
241 | { | ||
242 | attribute = configurationPlugin.GetAttribute(configOption.configurationKey); | ||
243 | } | ||
244 | else | ||
245 | { | ||
246 | ignoreNextFromConfig = false; | ||
247 | } | ||
248 | } | ||
249 | |||
250 | if (attribute == null) | ||
251 | { | ||
252 | if (configOption.configurationUseDefaultNoPrompt || useConsoleToPromptOnError == false) | ||
253 | { | ||
254 | console_result = configOption.configurationDefault; | ||
255 | } | ||
256 | else | ||
257 | { | ||
258 | if ((configOption.shouldIBeAsked != null && | ||
259 | configOption.shouldIBeAsked(configOption.configurationKey)) || | ||
260 | configOption.shouldIBeAsked == null) | ||
261 | { | ||
262 | if (configurationDescription.Trim() != String.Empty) | ||
263 | { | ||
264 | console_result = | ||
265 | MainConsole.Instance.CmdPrompt( | ||
266 | configurationDescription + ": " + configOption.configurationQuestion, | ||
267 | configOption.configurationDefault); | ||
268 | } | ||
269 | else | ||
270 | { | ||
271 | console_result = | ||
272 | MainConsole.Instance.CmdPrompt(configOption.configurationQuestion, | ||
273 | configOption.configurationDefault); | ||
274 | } | ||
275 | } | ||
276 | else | ||
277 | { | ||
278 | //Dont Ask! Just use default | ||
279 | console_result = configOption.configurationDefault; | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | else | ||
284 | { | ||
285 | console_result = attribute; | ||
286 | } | ||
287 | |||
288 | // if the first character is a "$", assume it's the name | ||
289 | // of an environment variable and substitute with the value of that variable | ||
290 | if (console_result.StartsWith("$")) | ||
291 | console_result = Environment.GetEnvironmentVariable(console_result.Substring(1)); | ||
292 | |||
293 | switch (configOption.configurationType) | ||
294 | { | ||
295 | case ConfigurationOption.ConfigurationTypes.TYPE_STRING: | ||
296 | return_result = console_result; | ||
297 | convertSuccess = true; | ||
298 | break; | ||
299 | case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY: | ||
300 | if (console_result.Length > 0) | ||
301 | { | ||
302 | return_result = console_result; | ||
303 | convertSuccess = true; | ||
304 | } | ||
305 | errorMessage = "a string that is not empty"; | ||
306 | break; | ||
307 | case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN: | ||
308 | bool boolResult; | ||
309 | if (Boolean.TryParse(console_result, out boolResult)) | ||
310 | { | ||
311 | convertSuccess = true; | ||
312 | return_result = boolResult; | ||
313 | } | ||
314 | errorMessage = "'true' or 'false' (Boolean)"; | ||
315 | break; | ||
316 | case ConfigurationOption.ConfigurationTypes.TYPE_BYTE: | ||
317 | byte byteResult; | ||
318 | if (Byte.TryParse(console_result, out byteResult)) | ||
319 | { | ||
320 | convertSuccess = true; | ||
321 | return_result = byteResult; | ||
322 | } | ||
323 | errorMessage = "a byte (Byte)"; | ||
324 | break; | ||
325 | case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER: | ||
326 | char charResult; | ||
327 | if (Char.TryParse(console_result, out charResult)) | ||
328 | { | ||
329 | convertSuccess = true; | ||
330 | return_result = charResult; | ||
331 | } | ||
332 | errorMessage = "a character (Char)"; | ||
333 | break; | ||
334 | case ConfigurationOption.ConfigurationTypes.TYPE_INT16: | ||
335 | short shortResult; | ||
336 | if (Int16.TryParse(console_result, out shortResult)) | ||
337 | { | ||
338 | convertSuccess = true; | ||
339 | return_result = shortResult; | ||
340 | } | ||
341 | errorMessage = "a signed 32 bit integer (short)"; | ||
342 | break; | ||
343 | case ConfigurationOption.ConfigurationTypes.TYPE_INT32: | ||
344 | int intResult; | ||
345 | if (Int32.TryParse(console_result, out intResult)) | ||
346 | { | ||
347 | convertSuccess = true; | ||
348 | return_result = intResult; | ||
349 | } | ||
350 | errorMessage = "a signed 32 bit integer (int)"; | ||
351 | break; | ||
352 | case ConfigurationOption.ConfigurationTypes.TYPE_INT64: | ||
353 | long longResult; | ||
354 | if (Int64.TryParse(console_result, out longResult)) | ||
355 | { | ||
356 | convertSuccess = true; | ||
357 | return_result = longResult; | ||
358 | } | ||
359 | errorMessage = "a signed 32 bit integer (long)"; | ||
360 | break; | ||
361 | case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS: | ||
362 | IPAddress ipAddressResult; | ||
363 | if (IPAddress.TryParse(console_result, out ipAddressResult)) | ||
364 | { | ||
365 | convertSuccess = true; | ||
366 | return_result = ipAddressResult; | ||
367 | } | ||
368 | errorMessage = "an IP Address (IPAddress)"; | ||
369 | break; | ||
370 | case ConfigurationOption.ConfigurationTypes.TYPE_UUID: | ||
371 | UUID uuidResult; | ||
372 | if (UUID.TryParse(console_result, out uuidResult)) | ||
373 | { | ||
374 | convertSuccess = true; | ||
375 | return_result = uuidResult; | ||
376 | } | ||
377 | errorMessage = "a UUID (UUID)"; | ||
378 | break; | ||
379 | case ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE: | ||
380 | UUID uuidResult2; | ||
381 | if (UUID.TryParse(console_result, out uuidResult2)) | ||
382 | { | ||
383 | convertSuccess = true; | ||
384 | |||
385 | if (uuidResult2 == UUID.Zero) | ||
386 | uuidResult2 = UUID.Random(); | ||
387 | |||
388 | return_result = uuidResult2; | ||
389 | } | ||
390 | errorMessage = "a non-null UUID (UUID)"; | ||
391 | break; | ||
392 | case ConfigurationOption.ConfigurationTypes.TYPE_Vector3: | ||
393 | Vector3 vectorResult; | ||
394 | if (Vector3.TryParse(console_result, out vectorResult)) | ||
395 | { | ||
396 | convertSuccess = true; | ||
397 | return_result = vectorResult; | ||
398 | } | ||
399 | errorMessage = "a vector (Vector3)"; | ||
400 | break; | ||
401 | case ConfigurationOption.ConfigurationTypes.TYPE_UINT16: | ||
402 | ushort ushortResult; | ||
403 | if (UInt16.TryParse(console_result, out ushortResult)) | ||
404 | { | ||
405 | convertSuccess = true; | ||
406 | return_result = ushortResult; | ||
407 | } | ||
408 | errorMessage = "an unsigned 16 bit integer (ushort)"; | ||
409 | break; | ||
410 | case ConfigurationOption.ConfigurationTypes.TYPE_UINT32: | ||
411 | uint uintResult; | ||
412 | if (UInt32.TryParse(console_result, out uintResult)) | ||
413 | { | ||
414 | convertSuccess = true; | ||
415 | return_result = uintResult; | ||
416 | } | ||
417 | errorMessage = "an unsigned 32 bit integer (uint)"; | ||
418 | break; | ||
419 | case ConfigurationOption.ConfigurationTypes.TYPE_UINT64: | ||
420 | ulong ulongResult; | ||
421 | if (UInt64.TryParse(console_result, out ulongResult)) | ||
422 | { | ||
423 | convertSuccess = true; | ||
424 | return_result = ulongResult; | ||
425 | } | ||
426 | errorMessage = "an unsigned 64 bit integer (ulong)"; | ||
427 | break; | ||
428 | case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT: | ||
429 | float floatResult; | ||
430 | if ( | ||
431 | float.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo, | ||
432 | out floatResult)) | ||
433 | { | ||
434 | convertSuccess = true; | ||
435 | return_result = floatResult; | ||
436 | } | ||
437 | errorMessage = "a single-precision floating point number (float)"; | ||
438 | break; | ||
439 | case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE: | ||
440 | double doubleResult; | ||
441 | if ( | ||
442 | Double.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo, | ||
443 | out doubleResult)) | ||
444 | { | ||
445 | convertSuccess = true; | ||
446 | return_result = doubleResult; | ||
447 | } | ||
448 | errorMessage = "an double-precision floating point number (double)"; | ||
449 | break; | ||
450 | } | ||
451 | |||
452 | if (convertSuccess) | ||
453 | { | ||
454 | if (useFile) | ||
455 | { | ||
456 | configurationPlugin.SetAttribute(configOption.configurationKey, console_result); | ||
457 | } | ||
458 | |||
459 | if (!resultFunction(configOption.configurationKey, return_result)) | ||
460 | { | ||
461 | m_log.Info( | ||
462 | "The handler for the last configuration option denied that input, please try again."); | ||
463 | convertSuccess = false; | ||
464 | ignoreNextFromConfig = true; | ||
465 | } | ||
466 | } | ||
467 | else | ||
468 | { | ||
469 | if (configOption.configurationUseDefaultNoPrompt) | ||
470 | { | ||
471 | m_log.Error(string.Format( | ||
472 | "[CONFIG]: [{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", | ||
473 | configOption.configurationKey, console_result, errorMessage, | ||
474 | configurationFilename)); | ||
475 | convertSuccess = true; | ||
476 | } | ||
477 | else | ||
478 | { | ||
479 | m_log.Warn(string.Format( | ||
480 | "[CONFIG]: [{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", | ||
481 | configOption.configurationKey, console_result, errorMessage, | ||
482 | configurationFilename)); | ||
483 | ignoreNextFromConfig = true; | ||
484 | } | ||
485 | } | ||
486 | } | ||
487 | } | ||
488 | |||
489 | if (useFile) | ||
490 | { | ||
491 | configurationPlugin.Commit(); | ||
492 | configurationPlugin.Close(); | ||
493 | } | ||
494 | } | ||
495 | |||
496 | private static IGenericConfig LoadConfigDll(string dllName) | ||
497 | { | ||
498 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
499 | IGenericConfig plug = null; | ||
500 | |||
501 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
502 | { | ||
503 | if (pluginType.IsPublic) | ||
504 | { | ||
505 | if (!pluginType.IsAbstract) | ||
506 | { | ||
507 | Type typeInterface = pluginType.GetInterface("IGenericConfig", true); | ||
508 | |||
509 | if (typeInterface != null) | ||
510 | { | ||
511 | plug = | ||
512 | (IGenericConfig) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
513 | } | ||
514 | } | ||
515 | } | ||
516 | } | ||
517 | |||
518 | pluginAssembly = null; | ||
519 | return plug; | ||
520 | } | ||
521 | |||
522 | public void forceSetConfigurationOption(string configuration_key, string configuration_value) | ||
523 | { | ||
524 | configurationPlugin.LoadData(); | ||
525 | configurationPlugin.SetAttribute(configuration_key, configuration_value); | ||
526 | configurationPlugin.Commit(); | ||
527 | configurationPlugin.Close(); | ||
528 | } | ||
529 | } | ||
530 | } | ||
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 44d05b7..6b3adcc 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -102,7 +102,6 @@ namespace OpenSim.Framework | |||
102 | private static readonly string LogHeader = "[REGION INFO]"; | 102 | private static readonly string LogHeader = "[REGION INFO]"; |
103 | 103 | ||
104 | public bool commFailTF = false; | 104 | public bool commFailTF = false; |
105 | public ConfigurationMember configMember; | ||
106 | public string RegionFile = String.Empty; | 105 | public string RegionFile = String.Empty; |
107 | public bool isSandbox = false; | 106 | public bool isSandbox = false; |
108 | public bool Persistent = true; | 107 | public bool Persistent = true; |
@@ -204,7 +203,6 @@ namespace OpenSim.Framework | |||
204 | try | 203 | try |
205 | { | 204 | { |
206 | // This will throw if it's not legal Nini XML format | 205 | // This will throw if it's not legal Nini XML format |
207 | // and thereby toss it to the legacy loader | ||
208 | // | 206 | // |
209 | IConfigSource xmlsource = new XmlConfigSource(filename); | 207 | IConfigSource xmlsource = new XmlConfigSource(filename); |
210 | 208 | ||
@@ -217,21 +215,18 @@ namespace OpenSim.Framework | |||
217 | catch (Exception) | 215 | catch (Exception) |
218 | { | 216 | { |
219 | } | 217 | } |
220 | |||
221 | configMember = | ||
222 | new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig); | ||
223 | configMember.performConfigurationRetrieve(); | ||
224 | RegionFile = filename; | ||
225 | } | 218 | } |
226 | 219 | ||
227 | // The web loader uses this | 220 | // The web loader uses this |
228 | // | 221 | // |
229 | public RegionInfo(string description, XmlNode xmlNode, bool skipConsoleConfig, IConfigSource configSource) | 222 | public RegionInfo(string description, XmlNode xmlNode, bool skipConsoleConfig, IConfigSource configSource) |
230 | { | 223 | { |
231 | // m_configSource = configSource; | 224 | XmlElement elem = (XmlElement)xmlNode; |
232 | configMember = | 225 | string name = elem.GetAttribute("Name"); |
233 | new ConfigurationMember(xmlNode, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig); | 226 | string xmlstr = "<Nini>" + xmlNode.OuterXml + "</Nini>"; |
234 | configMember.performConfigurationRetrieve(); | 227 | XmlConfigSource source = new XmlConfigSource(XmlReader.Create(new StringReader(xmlstr))); |
228 | ReadNiniConfig(source, name); | ||
229 | |||
235 | m_serverURI = string.Empty; | 230 | m_serverURI = string.Empty; |
236 | } | 231 | } |
237 | 232 | ||
@@ -889,264 +884,14 @@ namespace OpenSim.Framework | |||
889 | 884 | ||
890 | return; | 885 | return; |
891 | } | 886 | } |
892 | else if (filename.ToLower().EndsWith(".xml")) | ||
893 | { | ||
894 | configMember = new ConfigurationMember(filename, description, loadConfigurationOptionsFromMe, | ||
895 | ignoreIncomingConfiguration, false); | ||
896 | configMember.performConfigurationRetrieve(); | ||
897 | RegionFile = filename; | ||
898 | } | ||
899 | else | 887 | else |
900 | throw new Exception("Invalid file type for region persistence."); | 888 | throw new Exception("Invalid file type for region persistence."); |
901 | } | 889 | } |
902 | 890 | ||
903 | public void loadConfigurationOptionsFromMe() | ||
904 | { | ||
905 | configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE, | ||
906 | "UUID of Region (Default is recommended, random UUID)", | ||
907 | RegionID.ToString(), true); | ||
908 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
909 | "Region Name", RegionName, true); | ||
910 | |||
911 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
912 | "Grid Location (X Axis)", RegionLocX.ToString(), true); | ||
913 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
914 | "Grid Location (Y Axis)", RegionLocY.ToString(), true); | ||
915 | configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
916 | "Size of region in X dimension", RegionSizeX.ToString(), true); | ||
917 | configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
918 | "Size of region in Y dimension", RegionSizeY.ToString(), true); | ||
919 | configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
920 | "Size of region in Z dimension", RegionSizeZ.ToString(), true); | ||
921 | |||
922 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); | ||
923 | configMember.addConfigurationOption("internal_ip_address", | ||
924 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, | ||
925 | "Internal IP Address for incoming UDP client connections", | ||
926 | m_internalEndPoint.Address.ToString(), | ||
927 | true); | ||
928 | configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
929 | "Internal IP Port for incoming UDP client connections", | ||
930 | m_internalEndPoint.Port.ToString(), true); | ||
931 | configMember.addConfigurationOption("allow_alternate_ports", | ||
932 | ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, | ||
933 | "Allow sim to find alternate UDP ports when ports are in use?", | ||
934 | m_allow_alternate_ports.ToString(), true); | ||
935 | configMember.addConfigurationOption("external_host_name", | ||
936 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
937 | "External Host Name", m_externalHostName, true); | ||
938 | configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | ||
939 | "Last Map UUID", lastMapUUID.ToString(), true); | ||
940 | configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
941 | "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); | ||
942 | |||
943 | configMember.addConfigurationOption("nonphysical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, | ||
944 | "Minimum size for nonphysical prims", m_nonphysPrimMin.ToString(), true); | ||
945 | |||
946 | configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
947 | "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true); | ||
948 | |||
949 | configMember.addConfigurationOption("physical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, | ||
950 | "Minimum size for nonphysical prims", m_physPrimMin.ToString(), true); | ||
951 | |||
952 | configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
953 | "Maximum size for physical prims", m_physPrimMax.ToString(), true); | ||
954 | |||
955 | configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, | ||
956 | "Clamp prims to max size", m_clampPrimSize.ToString(), true); | ||
957 | |||
958 | configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
959 | "Max objects this sim will hold", m_objectCapacity.ToString(), true); | ||
960 | |||
961 | configMember.addConfigurationOption("prims_per_user", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
962 | "Max objects one user may rez", m_maxPrimsPerUser.ToString(), true); | ||
963 | |||
964 | configMember.addConfigurationOption("linkset_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
965 | "Max prims an object will hold", m_linksetCapacity.ToString(), true); | ||
966 | |||
967 | configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
968 | "Max avatars this sim will hold", m_agentCapacity.ToString(), true); | ||
969 | |||
970 | configMember.addConfigurationOption("scope_id", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | ||
971 | "Scope ID for this region", ScopeID.ToString(), true); | ||
972 | |||
973 | configMember.addConfigurationOption("region_type", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | ||
974 | "Free form string describing the type of region", String.Empty, true); | ||
975 | |||
976 | configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | ||
977 | "UUID of a texture to use as the map for this region", m_maptileStaticUUID.ToString(), true); | ||
978 | |||
979 | configMember.addConfigurationOption("region_static_mapfile", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | ||
980 | "Filename of a texture to use as the map for this region", MaptileStaticFile, true); | ||
981 | } | ||
982 | |||
983 | public void loadConfigurationOptions() | ||
984 | { | ||
985 | configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | ||
986 | "UUID of Region (Default is recommended, random UUID)", | ||
987 | UUID.Random().ToString(), true); | ||
988 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
989 | "Region Name", "OpenSim Test", false); | ||
990 | |||
991 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
992 | "Grid Location (X Axis)", "1000", false); | ||
993 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
994 | "Grid Location (Y Axis)", "1000", false); | ||
995 | configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
996 | "Size of region in X dimension", Constants.RegionSize.ToString(), false); | ||
997 | configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
998 | "Size of region in Y dimension", Constants.RegionSize.ToString(), false); | ||
999 | configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
1000 | "Size of region in Z dimension", Constants.RegionHeight.ToString(), false); | ||
1001 | |||
1002 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); | ||
1003 | configMember.addConfigurationOption("internal_ip_address", | ||
1004 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, | ||
1005 | "Internal IP Address for incoming UDP client connections", "0.0.0.0", | ||
1006 | false); | ||
1007 | configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
1008 | "Internal IP Port for incoming UDP client connections", | ||
1009 | ConfigSettings.DefaultRegionHttpPort.ToString(), false); | ||
1010 | configMember.addConfigurationOption("allow_alternate_ports", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, | ||
1011 | "Allow sim to find alternate UDP ports when ports are in use?", | ||
1012 | "false", true); | ||
1013 | configMember.addConfigurationOption("external_host_name", | ||
1014 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
1015 | "External Host Name", "127.0.0.1", false); | ||
1016 | configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | ||
1017 | "Last Map UUID", lastMapUUID.ToString(), true); | ||
1018 | |||
1019 | configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
1020 | "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); | ||
1021 | |||
1022 | configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
1023 | "Maximum size for nonphysical prims", "0", true); | ||
1024 | |||
1025 | configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
1026 | "Maximum size for physical prims", "0", true); | ||
1027 | |||
1028 | configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, | ||
1029 | "Clamp prims to max size", "false", true); | ||
1030 | |||
1031 | configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
1032 | "Max objects this sim will hold", "15000", true); | ||
1033 | |||
1034 | configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
1035 | "Max avatars this sim will hold", "100", true); | ||
1036 | |||
1037 | configMember.addConfigurationOption("scope_id", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | ||
1038 | "Scope ID for this region", UUID.Zero.ToString(), true); | ||
1039 | |||
1040 | configMember.addConfigurationOption("region_type", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | ||
1041 | "Region Type", String.Empty, true); | ||
1042 | |||
1043 | configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | ||
1044 | "UUID of a texture to use as the map for this region", String.Empty, true); | ||
1045 | |||
1046 | configMember.addConfigurationOption("region_static_mapfile", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | ||
1047 | "Filename of a texture to use as the map for this region", String.Empty, true); | ||
1048 | } | ||
1049 | |||
1050 | public bool handleIncomingConfiguration(string configuration_key, object configuration_result) | ||
1051 | { | ||
1052 | switch (configuration_key) | ||
1053 | { | ||
1054 | case "sim_UUID": | ||
1055 | RegionID = (UUID) configuration_result; | ||
1056 | originRegionID = (UUID) configuration_result; | ||
1057 | break; | ||
1058 | case "sim_name": | ||
1059 | RegionName = (string) configuration_result; | ||
1060 | break; | ||
1061 | case "sim_location_x": | ||
1062 | RegionLocX = (uint) configuration_result; | ||
1063 | break; | ||
1064 | case "sim_location_y": | ||
1065 | RegionLocY = (uint) configuration_result; | ||
1066 | break; | ||
1067 | case "sim_size_x": | ||
1068 | RegionSizeX = (uint) configuration_result; | ||
1069 | break; | ||
1070 | case "sim_size_y": | ||
1071 | RegionSizeY = (uint) configuration_result; | ||
1072 | break; | ||
1073 | case "sim_size_z": | ||
1074 | RegionSizeZ = (uint) configuration_result; | ||
1075 | break; | ||
1076 | case "internal_ip_address": | ||
1077 | IPAddress address = (IPAddress) configuration_result; | ||
1078 | m_internalEndPoint = new IPEndPoint(address, 0); | ||
1079 | break; | ||
1080 | case "internal_ip_port": | ||
1081 | m_internalEndPoint.Port = (int) configuration_result; | ||
1082 | break; | ||
1083 | case "allow_alternate_ports": | ||
1084 | m_allow_alternate_ports = (bool) configuration_result; | ||
1085 | break; | ||
1086 | case "external_host_name": | ||
1087 | if ((string) configuration_result != "SYSTEMIP") | ||
1088 | { | ||
1089 | m_externalHostName = (string) configuration_result; | ||
1090 | } | ||
1091 | else | ||
1092 | { | ||
1093 | m_externalHostName = Util.GetLocalHost().ToString(); | ||
1094 | } | ||
1095 | break; | ||
1096 | case "lastmap_uuid": | ||
1097 | lastMapUUID = (UUID)configuration_result; | ||
1098 | break; | ||
1099 | case "lastmap_refresh": | ||
1100 | lastMapRefresh = (string)configuration_result; | ||
1101 | break; | ||
1102 | case "nonphysical_prim_max": | ||
1103 | m_nonphysPrimMax = (int)configuration_result; | ||
1104 | break; | ||
1105 | case "physical_prim_max": | ||
1106 | m_physPrimMax = (int)configuration_result; | ||
1107 | break; | ||
1108 | case "clamp_prim_size": | ||
1109 | m_clampPrimSize = (bool)configuration_result; | ||
1110 | break; | ||
1111 | case "object_capacity": | ||
1112 | m_objectCapacity = (int)configuration_result; | ||
1113 | break; | ||
1114 | case "prims_per_user": | ||
1115 | m_maxPrimsPerUser = (int)configuration_result; | ||
1116 | break; | ||
1117 | case "linkset_capacity": | ||
1118 | m_linksetCapacity = (int)configuration_result; | ||
1119 | break; | ||
1120 | case "agent_capacity": | ||
1121 | m_agentCapacity = (int)configuration_result; | ||
1122 | break; | ||
1123 | case "scope_id": | ||
1124 | ScopeID = (UUID)configuration_result; | ||
1125 | break; | ||
1126 | case "region_type": | ||
1127 | m_regionType = (string)configuration_result; | ||
1128 | break; | ||
1129 | case "region_static_maptile": | ||
1130 | m_maptileStaticUUID = (UUID)configuration_result; | ||
1131 | break; | ||
1132 | case "region_static_mapfile": | ||
1133 | MaptileStaticFile = (string)configuration_result; | ||
1134 | break; | ||
1135 | } | ||
1136 | |||
1137 | return true; | ||
1138 | } | ||
1139 | |||
1140 | public void SaveLastMapUUID(UUID mapUUID) | 891 | public void SaveLastMapUUID(UUID mapUUID) |
1141 | { | 892 | { |
1142 | lastMapUUID = mapUUID; | 893 | lastMapUUID = mapUUID; |
1143 | lastMapRefresh = Util.UnixTimeSinceEpoch().ToString(); | 894 | lastMapRefresh = Util.UnixTimeSinceEpoch().ToString(); |
1144 | |||
1145 | if (configMember == null) | ||
1146 | return; | ||
1147 | |||
1148 | configMember.forceSetConfigurationOption("lastmap_uuid", mapUUID.ToString()); | ||
1149 | configMember.forceSetConfigurationOption("lastmap_refresh", lastMapRefresh); | ||
1150 | } | 895 | } |
1151 | 896 | ||
1152 | public OSDMap PackRegionInfoData() | 897 | public OSDMap PackRegionInfoData() |
diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs index 05c64fa..f60bb12 100644 --- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs +++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs | |||
@@ -98,7 +98,7 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
98 | xmlSource.Length); | 98 | xmlSource.Length); |
99 | XmlDocument xmlDoc = new XmlDocument(); | 99 | XmlDocument xmlDoc = new XmlDocument(); |
100 | xmlDoc.LoadXml(xmlSource); | 100 | xmlDoc.LoadXml(xmlSource); |
101 | if (xmlDoc.FirstChild.Name == "Regions") | 101 | if (xmlDoc.FirstChild.Name == "Nini") |
102 | { | 102 | { |
103 | regionCount = xmlDoc.FirstChild.ChildNodes.Count; | 103 | regionCount = xmlDoc.FirstChild.ChildNodes.Count; |
104 | 104 | ||
@@ -144,4 +144,4 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
144 | } | 144 | } |
145 | } | 145 | } |
146 | } | 146 | } |
147 | } \ No newline at end of file | 147 | } |