aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/General/Configuration/ConfigurationMember.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/General/Configuration/ConfigurationMember.cs')
-rw-r--r--OpenSim/Framework/General/Configuration/ConfigurationMember.cs54
1 files changed, 42 insertions, 12 deletions
diff --git a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs
index 8106d5a..e93a576 100644
--- a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs
+++ b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs
@@ -12,7 +12,7 @@ namespace OpenSim.Framework.Configuration
12{ 12{
13 public class ConfigurationMember 13 public class ConfigurationMember
14 { 14 {
15 public delegate void ConfigurationOptionResult(string configuration_key, object configuration_result); 15 public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result);
16 public delegate void ConfigurationOptionsLoad(); 16 public delegate void ConfigurationOptionsLoad();
17 17
18 private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>(); 18 private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>();
@@ -44,13 +44,14 @@ namespace OpenSim.Framework.Configuration
44 resultFunction = result; 44 resultFunction = result;
45 } 45 }
46 46
47 public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default) 47 public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt)
48 { 48 {
49 ConfigurationOption configOption = new ConfigurationOption(); 49 ConfigurationOption configOption = new ConfigurationOption();
50 configOption.configurationKey = configuration_key; 50 configOption.configurationKey = configuration_key;
51 configOption.configurationQuestion = configuration_question; 51 configOption.configurationQuestion = configuration_question;
52 configOption.configurationDefault = configuration_default; 52 configOption.configurationDefault = configuration_default;
53 configOption.configurationType = configuration_type; 53 configOption.configurationType = configuration_type;
54 configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
54 55
55 if (configuration_key != "" && configuration_question != "") 56 if (configuration_key != "" && configuration_question != "")
56 { 57 {
@@ -116,7 +117,8 @@ namespace OpenSim.Framework.Configuration
116 bool ignoreNextFromConfig = false; 117 bool ignoreNextFromConfig = false;
117 while (convertSuccess == false) 118 while (convertSuccess == false)
118 { 119 {
119 120
121 string console_result = "";
120 string attribute = null; 122 string attribute = null;
121 if (useFile) 123 if (useFile)
122 { 124 {
@@ -130,17 +132,24 @@ namespace OpenSim.Framework.Configuration
130 } 132 }
131 } 133 }
132 134
133 string console_result = "";
134 if (attribute == null) 135 if (attribute == null)
135 { 136 {
136 if (configurationDescription.Trim() != "") 137 if (configOption.configurationUseDefaultNoPrompt)
137 { 138 {
138 console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); 139 console_result = configOption.configurationDefault;
139 } 140 }
140 else 141 else
141 { 142 {
142 console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault); 143
143 } 144 if (configurationDescription.Trim() != "")
145 {
146 console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault);
147 }
148 else
149 {
150 console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault);
151 }
152 }
144 } 153 }
145 else 154 else
146 { 155 {
@@ -153,6 +162,14 @@ namespace OpenSim.Framework.Configuration
153 return_result = console_result; 162 return_result = console_result;
154 convertSuccess = true; 163 convertSuccess = true;
155 break; 164 break;
165 case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY:
166 if (console_result.Length > 0)
167 {
168 return_result = console_result;
169 convertSuccess = true;
170 }
171 errorMessage = "a string that is not empty";
172 break;
156 case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN: 173 case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN:
157 bool boolResult; 174 bool boolResult;
158 if (Boolean.TryParse(console_result, out boolResult)) 175 if (Boolean.TryParse(console_result, out boolResult))
@@ -290,13 +307,26 @@ namespace OpenSim.Framework.Configuration
290 xmlConfig.SetAttribute(configOption.configurationKey, console_result); 307 xmlConfig.SetAttribute(configOption.configurationKey, console_result);
291 } 308 }
292 309
293 310
294 this.resultFunction(configOption.configurationKey, return_result); 311 if (!this.resultFunction(configOption.configurationKey, return_result))
312 {
313 Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again.");
314 convertSuccess = false;
315 ignoreNextFromConfig = true;
316 }
295 } 317 }
296 else 318 else
297 { 319 {
298 MainLog.Instance.Warn("Incorrect result given, the configuration option must be " + errorMessage + ". Prompting for same option..."); 320 if (configOption.configurationUseDefaultNoPrompt)
299 ignoreNextFromConfig = true; 321 {
322 MainLog.Instance.Error("Default given for '" + configOption.configurationKey + "' is not valid; the configuration result must be " + errorMessage + ". Will skip this option...");
323 convertSuccess = true;
324 }
325 else
326 {
327 MainLog.Instance.Warn("Incorrect result given, the configuration option must be " + errorMessage + ". Prompting for same option...");
328 ignoreNextFromConfig = true;
329 }
300 } 330 }
301 } 331 }
302 } 332 }