aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/General/Configuration
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/General/Configuration')
-rw-r--r--OpenSim/Framework/General/Configuration/AssetConfig.cs83
-rw-r--r--OpenSim/Framework/General/Configuration/ConfigurationMember.cs415
-rw-r--r--OpenSim/Framework/General/Configuration/ConfigurationOption.cs64
-rw-r--r--OpenSim/Framework/General/Configuration/GridConfig.cs121
-rw-r--r--OpenSim/Framework/General/Configuration/Interfaces/IGenericConfig.cs40
-rw-r--r--OpenSim/Framework/General/Configuration/UserConfig.cs98
6 files changed, 0 insertions, 821 deletions
diff --git a/OpenSim/Framework/General/Configuration/AssetConfig.cs b/OpenSim/Framework/General/Configuration/AssetConfig.cs
deleted file mode 100644
index c4e1cc4..0000000
--- a/OpenSim/Framework/General/Configuration/AssetConfig.cs
+++ /dev/null
@@ -1,83 +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 OpenSim 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
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace OpenSim.Framework.Configuration
34{
35 /// <summary>
36 /// UserConfig -- For User Server Configuration
37 /// </summary>
38 public class AssetConfig
39 {
40 public string DefaultStartupMsg = "";
41
42 public string DatabaseProvider = "";
43
44 public static uint DefaultHttpPort = 8003;
45 public uint HttpPort = DefaultHttpPort;
46
47 private ConfigurationMember configMember;
48
49 public AssetConfig(string description, string filename)
50 {
51 configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
52 configMember.performConfigurationRetrieve();
53 }
54
55 public void loadConfigurationOptions()
56 {
57 configMember.addConfigurationOption("default_startup_message", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Startup Message", "Welcome to OGS", false);
58
59 configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
60
61 configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", DefaultHttpPort.ToString(), false);
62
63 }
64
65 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
66 {
67 switch (configuration_key)
68 {
69 case "default_startup_message":
70 this.DefaultStartupMsg = (string)configuration_result;
71 break;
72 case "database_provider":
73 this.DatabaseProvider = (string)configuration_result;
74 break;
75 case "http_port":
76 HttpPort = (uint)configuration_result;
77 break;
78 }
79
80 return true;
81 }
82 }
83}
diff --git a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs
deleted file mode 100644
index af9a0f6..0000000
--- a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs
+++ /dev/null
@@ -1,415 +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 OpenSim 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
29using System;
30using System.Reflection;
31using System.Collections;
32using System.Collections.Generic;
33using System.Text;
34using System.Net;
35
36using libsecondlife;
37
38using OpenSim.Framework.Console;
39using OpenSim.Framework.Configuration.Interfaces;
40using System.Globalization;
41
42namespace OpenSim.Framework.Configuration
43{
44 public class ConfigurationMember
45 {
46 public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result);
47 public delegate void ConfigurationOptionsLoad();
48
49 private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>();
50 private string configurationFilename = "";
51 private string configurationDescription = "";
52
53 private ConfigurationOptionsLoad loadFunction;
54 private ConfigurationOptionResult resultFunction;
55
56 private IGenericConfig configurationPlugin = null;
57 /// <summary>
58 /// This is the default configuration DLL loaded
59 /// </summary>
60 private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll";
61 public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function)
62 {
63 this.configurationFilename = configuration_filename;
64 this.configurationDescription = configuration_description;
65 this.loadFunction = load_function;
66 this.resultFunction = result_function;
67 }
68
69 public void setConfigurationFilename(string filename)
70 {
71 configurationFilename = filename;
72 }
73 public void setConfigurationDescription(string desc)
74 {
75 configurationDescription = desc;
76 }
77
78 public void setConfigurationResultFunction(ConfigurationOptionResult result)
79 {
80 resultFunction = result;
81 }
82
83 public void forceConfigurationPluginLibrary(string dll_filename)
84 {
85 configurationPluginFilename = dll_filename;
86 }
87 public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt)
88 {
89 ConfigurationOption configOption = new ConfigurationOption();
90 configOption.configurationKey = configuration_key;
91 configOption.configurationQuestion = configuration_question;
92 configOption.configurationDefault = configuration_default;
93 configOption.configurationType = configuration_type;
94 configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
95
96 if ((configuration_key != "" && configuration_question != "") || (configuration_key != "" && use_default_no_prompt))
97 {
98 if (!configurationOptions.Contains(configOption))
99 {
100 configurationOptions.Add(configOption);
101 }
102 }
103 else
104 {
105 MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + configuration_key + ")");
106 }
107 }
108
109 public void performConfigurationRetrieve()
110 {
111 configurationPlugin = this.LoadConfigDll(configurationPluginFilename);
112 configurationOptions.Clear();
113 if(loadFunction == null)
114 {
115 MainLog.Instance.Error("Load Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
116 return;
117 }
118
119 if(resultFunction == null)
120 {
121 MainLog.Instance.Error("Result Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
122 return;
123 }
124
125 MainLog.Instance.Verbose("Calling Configuration Load Function...");
126 this.loadFunction();
127
128 if(configurationOptions.Count <= 0)
129 {
130 MainLog.Instance.Error("No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration.");
131 return;
132 }
133
134 bool useFile = true;
135 if (configurationPlugin == null)
136 {
137 MainLog.Instance.Error("Configuration Plugin NOT LOADED!");
138 return;
139 }
140
141 if (configurationFilename.Trim() != "")
142 {
143 configurationPlugin.SetFileName(configurationFilename);
144 configurationPlugin.LoadData();
145 useFile = true;
146 }
147 else
148 {
149 MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file.");
150 useFile = false;
151 }
152
153 foreach (ConfigurationOption configOption in configurationOptions)
154 {
155 bool convertSuccess = false;
156 object return_result = null;
157 string errorMessage = "";
158 bool ignoreNextFromConfig = false;
159 while (convertSuccess == false)
160 {
161
162 string console_result = "";
163 string attribute = null;
164 if (useFile)
165 {
166 if (!ignoreNextFromConfig)
167 {
168 attribute = configurationPlugin.GetAttribute(configOption.configurationKey);
169 }
170 else
171 {
172 ignoreNextFromConfig = false;
173 }
174 }
175
176 if (attribute == null)
177 {
178 if (configOption.configurationUseDefaultNoPrompt)
179 {
180 console_result = configOption.configurationDefault;
181 }
182 else
183 {
184
185 if (configurationDescription.Trim() != "")
186 {
187 console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault);
188 }
189 else
190 {
191 console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault);
192 }
193 }
194 }
195 else
196 {
197 console_result = attribute;
198 }
199
200 switch (configOption.configurationType)
201 {
202 case ConfigurationOption.ConfigurationTypes.TYPE_STRING:
203 return_result = console_result;
204 convertSuccess = true;
205 break;
206 case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY:
207 if (console_result.Length > 0)
208 {
209 return_result = console_result;
210 convertSuccess = true;
211 }
212 errorMessage = "a string that is not empty";
213 break;
214 case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN:
215 bool boolResult;
216 if (Boolean.TryParse(console_result, out boolResult))
217 {
218 convertSuccess = true;
219 return_result = boolResult;
220 }
221 errorMessage = "'true' or 'false' (Boolean)";
222 break;
223 case ConfigurationOption.ConfigurationTypes.TYPE_BYTE:
224 byte byteResult;
225 if (Byte.TryParse(console_result, out byteResult))
226 {
227 convertSuccess = true;
228 return_result = byteResult;
229 }
230 errorMessage = "a byte (Byte)";
231 break;
232 case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER:
233 char charResult;
234 if (Char.TryParse(console_result, out charResult))
235 {
236 convertSuccess = true;
237 return_result = charResult;
238 }
239 errorMessage = "a character (Char)";
240 break;
241 case ConfigurationOption.ConfigurationTypes.TYPE_INT16:
242 short shortResult;
243 if (Int16.TryParse(console_result, out shortResult))
244 {
245 convertSuccess = true;
246 return_result = shortResult;
247 }
248 errorMessage = "a signed 32 bit integer (short)";
249 break;
250 case ConfigurationOption.ConfigurationTypes.TYPE_INT32:
251 int intResult;
252 if (Int32.TryParse(console_result, out intResult))
253 {
254 convertSuccess = true;
255 return_result = intResult;
256
257 }
258 errorMessage = "a signed 32 bit integer (int)";
259 break;
260 case ConfigurationOption.ConfigurationTypes.TYPE_INT64:
261 long longResult;
262 if (Int64.TryParse(console_result, out longResult))
263 {
264 convertSuccess = true;
265 return_result = longResult;
266 }
267 errorMessage = "a signed 32 bit integer (long)";
268 break;
269 case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS:
270 IPAddress ipAddressResult;
271 if (IPAddress.TryParse(console_result, out ipAddressResult))
272 {
273 convertSuccess = true;
274 return_result = ipAddressResult;
275 }
276 errorMessage = "an IP Address (IPAddress)";
277 break;
278 case ConfigurationOption.ConfigurationTypes.TYPE_LLUUID:
279 LLUUID uuidResult;
280 if (LLUUID.TryParse(console_result, out uuidResult))
281 {
282 convertSuccess = true;
283 return_result = uuidResult;
284 }
285 errorMessage = "a UUID (LLUUID)";
286 break;
287 case ConfigurationOption.ConfigurationTypes.TYPE_LLVECTOR3:
288 LLVector3 vectorResult;
289 if (LLVector3.TryParse(console_result, out vectorResult))
290 {
291 convertSuccess = true;
292 return_result = vectorResult;
293 }
294 errorMessage = "a vector (LLVector3)";
295 break;
296 case ConfigurationOption.ConfigurationTypes.TYPE_UINT16:
297 ushort ushortResult;
298 if (UInt16.TryParse(console_result, out ushortResult))
299 {
300 convertSuccess = true;
301 return_result = ushortResult;
302 }
303 errorMessage = "an unsigned 16 bit integer (ushort)";
304 break;
305 case ConfigurationOption.ConfigurationTypes.TYPE_UINT32:
306 uint uintResult;
307 if (UInt32.TryParse(console_result, out uintResult))
308 {
309 convertSuccess = true;
310 return_result = uintResult;
311
312 }
313 errorMessage = "an unsigned 32 bit integer (uint)";
314 break;
315 case ConfigurationOption.ConfigurationTypes.TYPE_UINT64:
316 ulong ulongResult;
317 if (UInt64.TryParse(console_result, out ulongResult))
318 {
319 convertSuccess = true;
320 return_result = ulongResult;
321 }
322 errorMessage = "an unsigned 64 bit integer (ulong)";
323 break;
324 case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT:
325 float floatResult;
326 if (float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out floatResult))
327 {
328 convertSuccess = true;
329 return_result = floatResult;
330 }
331 errorMessage = "a single-precision floating point number (float)";
332 break;
333 case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE:
334 double doubleResult;
335 if (Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out doubleResult))
336 {
337 convertSuccess = true;
338 return_result = doubleResult;
339 }
340 errorMessage = "an double-precision floating point number (double)";
341 break;
342 }
343
344 if (convertSuccess)
345 {
346 if (useFile)
347 {
348 configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
349 }
350
351
352 if (!this.resultFunction(configOption.configurationKey, return_result))
353 {
354 Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again.");
355 convertSuccess = false;
356 ignoreNextFromConfig = true;
357 }
358 }
359 else
360 {
361 if (configOption.configurationUseDefaultNoPrompt)
362 {
363 MainLog.Instance.Error("CONFIG", string.Format("[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename));
364 convertSuccess = true;
365 }
366 else
367 {
368 MainLog.Instance.Warn("CONFIG", string.Format("[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename));
369 ignoreNextFromConfig = true;
370 }
371 }
372 }
373 }
374
375 if(useFile)
376 {
377 configurationPlugin.Commit();
378 configurationPlugin.Close();
379 }
380 }
381
382 private IGenericConfig LoadConfigDll(string dllName)
383 {
384 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
385 IGenericConfig plug = null;
386
387 foreach (Type pluginType in pluginAssembly.GetTypes())
388 {
389 if (pluginType.IsPublic)
390 {
391 if (!pluginType.IsAbstract)
392 {
393 Type typeInterface = pluginType.GetInterface("IGenericConfig", true);
394
395 if (typeInterface != null)
396 {
397 plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
398 }
399 }
400 }
401 }
402
403 pluginAssembly = null;
404 return plug;
405 }
406
407 public void forceSetConfigurationOption(string configuration_key, string configuration_value)
408 {
409 this.configurationPlugin.LoadData();
410 this.configurationPlugin.SetAttribute(configuration_key, configuration_value);
411 this.configurationPlugin.Commit();
412 this.configurationPlugin.Close();
413 }
414 }
415}
diff --git a/OpenSim/Framework/General/Configuration/ConfigurationOption.cs b/OpenSim/Framework/General/Configuration/ConfigurationOption.cs
deleted file mode 100644
index fcba35e..0000000
--- a/OpenSim/Framework/General/Configuration/ConfigurationOption.cs
+++ /dev/null
@@ -1,64 +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 OpenSim 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
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace OpenSim.Framework.Configuration
34{
35 public class ConfigurationOption
36 {
37 public enum ConfigurationTypes
38 {
39 TYPE_STRING,
40 TYPE_STRING_NOT_EMPTY,
41 TYPE_UINT16,
42 TYPE_UINT32,
43 TYPE_UINT64,
44 TYPE_INT16,
45 TYPE_INT32,
46 TYPE_INT64,
47 TYPE_IP_ADDRESS,
48 TYPE_CHARACTER,
49 TYPE_BOOLEAN,
50 TYPE_BYTE,
51 TYPE_LLUUID,
52 TYPE_LLVECTOR3,
53 TYPE_FLOAT,
54 TYPE_DOUBLE
55 };
56
57 public string configurationKey = "";
58 public string configurationQuestion = "";
59 public string configurationDefault = "";
60
61 public ConfigurationTypes configurationType = ConfigurationTypes.TYPE_STRING;
62 public bool configurationUseDefaultNoPrompt = false;
63 }
64}
diff --git a/OpenSim/Framework/General/Configuration/GridConfig.cs b/OpenSim/Framework/General/Configuration/GridConfig.cs
deleted file mode 100644
index 9020404..0000000
--- a/OpenSim/Framework/General/Configuration/GridConfig.cs
+++ /dev/null
@@ -1,121 +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 OpenSim 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
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace OpenSim.Framework.Configuration
34{
35 public class GridConfig
36 {
37 public string GridOwner = "";
38 public string DefaultAssetServer = "";
39 public string AssetSendKey = "";
40 public string AssetRecvKey = "";
41
42 public string DefaultUserServer = "";
43 public string UserSendKey = "";
44 public string UserRecvKey = "";
45
46 public string SimSendKey = "";
47 public string SimRecvKey = "";
48
49 public string DatabaseProvider = "";
50
51 public static uint DefaultHttpPort = 8001;
52 public uint HttpPort = DefaultHttpPort;
53
54 private ConfigurationMember configMember;
55 public GridConfig(string description, string filename)
56 {
57 configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
58 configMember.performConfigurationRetrieve();
59 }
60
61 public void loadConfigurationOptions()
62 {
63 configMember.addConfigurationOption("grid_owner", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "OGS Grid Owner", "OGS development team", false);
64 configMember.addConfigurationOption("default_asset_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Asset Server URI", "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString() + "/", false);
65 configMember.addConfigurationOption("asset_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to asset server", "null", false);
66 configMember.addConfigurationOption("asset_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from asset server", "null", false);
67
68 configMember.addConfigurationOption("default_user_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default User Server URI", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString() + "/", false);
69 configMember.addConfigurationOption("user_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to user server", "null", false);
70 configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null", false);
71
72 configMember.addConfigurationOption("sim_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to a simulator", "null", false);
73 configMember.addConfigurationOption("sim_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from a simulator", "null", false);
74 configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
75
76 configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", DefaultHttpPort.ToString(), false);
77 }
78
79 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
80 {
81 switch (configuration_key)
82 {
83 case "grid_owner":
84 this.GridOwner = (string)configuration_result;
85 break;
86 case "default_asset_server":
87 this.DefaultAssetServer = (string)configuration_result;
88 break;
89 case "asset_send_key":
90 this.AssetSendKey = (string)configuration_result;
91 break;
92 case "asset_recv_key":
93 this.AssetRecvKey = (string)configuration_result;
94 break;
95 case "default_user_server":
96 this.DefaultUserServer = (string)configuration_result;
97 break;
98 case "user_send_key":
99 this.UserSendKey = (string)configuration_result;
100 break;
101 case "user_recv_key":
102 this.UserRecvKey = (string)configuration_result;
103 break;
104 case "sim_send_key":
105 this.SimSendKey = (string)configuration_result;
106 break;
107 case "sim_recv_key":
108 this.SimRecvKey = (string)configuration_result;
109 break;
110 case "database_provider":
111 this.DatabaseProvider = (string)configuration_result;
112 break;
113 case "http_port":
114 HttpPort = (uint)configuration_result;
115 break;
116 }
117
118 return true;
119 }
120 }
121}
diff --git a/OpenSim/Framework/General/Configuration/Interfaces/IGenericConfig.cs b/OpenSim/Framework/General/Configuration/Interfaces/IGenericConfig.cs
deleted file mode 100644
index 82e1856..0000000
--- a/OpenSim/Framework/General/Configuration/Interfaces/IGenericConfig.cs
+++ /dev/null
@@ -1,40 +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 OpenSim 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*/
28namespace OpenSim.Framework.Configuration.Interfaces
29{
30 public interface IGenericConfig
31 {
32 void SetFileName(string fileName);
33 void LoadData();
34 void LoadDataFromString(string data);
35 string GetAttribute(string attributeName);
36 bool SetAttribute(string attributeName, string attributeValue);
37 void Commit();
38 void Close();
39 }
40}
diff --git a/OpenSim/Framework/General/Configuration/UserConfig.cs b/OpenSim/Framework/General/Configuration/UserConfig.cs
deleted file mode 100644
index d664e94..0000000
--- a/OpenSim/Framework/General/Configuration/UserConfig.cs
+++ /dev/null
@@ -1,98 +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 OpenSim 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
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace OpenSim.Framework.Configuration
34{
35 /// <summary>
36 /// UserConfig -- For User Server Configuration
37 /// </summary>
38 public class UserConfig
39 {
40 public string DefaultStartupMsg = "";
41 public string GridServerURL = "";
42 public string GridSendKey = "";
43 public string GridRecvKey = "";
44
45 public string DatabaseProvider = "";
46
47 public static uint DefaultHttpPort = 8002;
48 public uint HttpPort = DefaultHttpPort;
49
50 private ConfigurationMember configMember;
51
52 public UserConfig(string description, string filename)
53 {
54 configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
55 configMember.performConfigurationRetrieve();
56 }
57
58 public void loadConfigurationOptions()
59 {
60 configMember.addConfigurationOption("default_startup_message", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Startup Message", "Welcome to OGS", false);
61
62 configMember.addConfigurationOption("default_grid_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Grid Server URI", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString() + "/", false);
63 configMember.addConfigurationOption("grid_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to grid server", "null", false);
64 configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from grid server", "null", false);
65 configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
66
67 configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", DefaultHttpPort.ToString(), false);
68
69 }
70
71 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
72 {
73 switch (configuration_key)
74 {
75 case "default_startup_message":
76 this.DefaultStartupMsg = (string)configuration_result;
77 break;
78 case "default_grid_server":
79 this.GridServerURL = (string)configuration_result;
80 break;
81 case "grid_send_key":
82 this.GridSendKey = (string)configuration_result;
83 break;
84 case "grid_recv_key":
85 this.GridRecvKey = (string)configuration_result;
86 break;
87 case "database_provider":
88 this.DatabaseProvider = (string)configuration_result;
89 break;
90 case "http_port":
91 HttpPort = (uint)configuration_result;
92 break;
93 }
94
95 return true;
96 }
97 }
98}