diff --git a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs index 8106d5acfc..e93a57693b 100644 --- a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs +++ b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs @@ -12,7 +12,7 @@ namespace OpenSim.Framework.Configuration { public class ConfigurationMember { - public delegate void ConfigurationOptionResult(string configuration_key, object configuration_result); + public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result); public delegate void ConfigurationOptionsLoad(); private List configurationOptions = new List(); @@ -44,13 +44,14 @@ namespace OpenSim.Framework.Configuration resultFunction = result; } - public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default) + public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt) { ConfigurationOption configOption = new ConfigurationOption(); configOption.configurationKey = configuration_key; configOption.configurationQuestion = configuration_question; configOption.configurationDefault = configuration_default; configOption.configurationType = configuration_type; + configOption.configurationUseDefaultNoPrompt = use_default_no_prompt; if (configuration_key != "" && configuration_question != "") { @@ -116,7 +117,8 @@ namespace OpenSim.Framework.Configuration bool ignoreNextFromConfig = false; while (convertSuccess == false) { - + + string console_result = ""; string attribute = null; if (useFile) { @@ -130,17 +132,24 @@ namespace OpenSim.Framework.Configuration } } - string console_result = ""; if (attribute == null) { - if (configurationDescription.Trim() != "") + if (configOption.configurationUseDefaultNoPrompt) { - console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); + console_result = configOption.configurationDefault; } else { - console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault); - } + + if (configurationDescription.Trim() != "") + { + console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); + } + else + { + console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault); + } + } } else { @@ -153,6 +162,14 @@ namespace OpenSim.Framework.Configuration return_result = console_result; convertSuccess = true; break; + case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY: + if (console_result.Length > 0) + { + return_result = console_result; + convertSuccess = true; + } + errorMessage = "a string that is not empty"; + break; case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN: bool boolResult; if (Boolean.TryParse(console_result, out boolResult)) @@ -290,13 +307,26 @@ namespace OpenSim.Framework.Configuration xmlConfig.SetAttribute(configOption.configurationKey, console_result); } - - this.resultFunction(configOption.configurationKey, return_result); + + if (!this.resultFunction(configOption.configurationKey, return_result)) + { + Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again."); + convertSuccess = false; + ignoreNextFromConfig = true; + } } else { - MainLog.Instance.Warn("Incorrect result given, the configuration option must be " + errorMessage + ". Prompting for same option..."); - ignoreNextFromConfig = true; + if (configOption.configurationUseDefaultNoPrompt) + { + MainLog.Instance.Error("Default given for '" + configOption.configurationKey + "' is not valid; the configuration result must be " + errorMessage + ". Will skip this option..."); + convertSuccess = true; + } + else + { + MainLog.Instance.Warn("Incorrect result given, the configuration option must be " + errorMessage + ". Prompting for same option..."); + ignoreNextFromConfig = true; + } } } } diff --git a/OpenSim/Framework/General/Configuration/ConfigurationOption.cs b/OpenSim/Framework/General/Configuration/ConfigurationOption.cs index 15da1aa589..38f60a0fe4 100644 --- a/OpenSim/Framework/General/Configuration/ConfigurationOption.cs +++ b/OpenSim/Framework/General/Configuration/ConfigurationOption.cs @@ -9,6 +9,7 @@ namespace OpenSim.Framework.Configuration public enum ConfigurationTypes { TYPE_STRING, + TYPE_STRING_NOT_EMPTY, TYPE_UINT16, TYPE_UINT32, TYPE_UINT64, @@ -30,5 +31,6 @@ namespace OpenSim.Framework.Configuration public string configurationDefault = ""; public ConfigurationTypes configurationType = ConfigurationTypes.TYPE_STRING; + public bool configurationUseDefaultNoPrompt = false; } } diff --git a/OpenSim/Framework/General/Configuration/GridConfig.cs b/OpenSim/Framework/General/Configuration/GridConfig.cs index 97dd699288..0a7f65c5c5 100644 --- a/OpenSim/Framework/General/Configuration/GridConfig.cs +++ b/OpenSim/Framework/General/Configuration/GridConfig.cs @@ -27,21 +27,21 @@ namespace OpenSim.Framework.Configuration public void loadConfigurationOptions() { - configMember.addConfigurationOption("grid_owner",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"OGS Grid Owner","OGS development team"); - configMember.addConfigurationOption("default_asset_server",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Default Asset Server URI","http://127.0.0.1:8003/"); - configMember.addConfigurationOption("asset_send_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to send to asset server","null"); - configMember.addConfigurationOption("asset_recv_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to expect from asset server","null"); + configMember.addConfigurationOption("grid_owner", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "OGS Grid Owner", "OGS development team", false); + configMember.addConfigurationOption("default_asset_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Asset Server URI", "http://127.0.0.1:8003/", false); + configMember.addConfigurationOption("asset_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to asset server", "null", false); + configMember.addConfigurationOption("asset_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from asset server", "null", false); - configMember.addConfigurationOption("default_user_server",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Default User Server URI","http://127.0.0.1:8002/"); - configMember.addConfigurationOption("user_send_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to send to user server","null"); - configMember.addConfigurationOption("user_recv_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to expect from user server","null"); + configMember.addConfigurationOption("default_user_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default User Server URI", "http://127.0.0.1:8002/", false); + configMember.addConfigurationOption("user_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to user server", "null", false); + configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null", false); - configMember.addConfigurationOption("sim_send_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to send to a simulator","null"); - configMember.addConfigurationOption("sim_recv_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to expect from a simulator","null"); + configMember.addConfigurationOption("sim_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to a simulator", "null", false); + configMember.addConfigurationOption("sim_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from a simulator", "null", false); } - public void handleIncomingConfiguration(string configuration_key, object configuration_result) + public bool handleIncomingConfiguration(string configuration_key, object configuration_result) { switch (configuration_key) { @@ -73,6 +73,8 @@ namespace OpenSim.Framework.Configuration this.SimRecvKey = (string)configuration_result; break; } + + return true; } } } diff --git a/OpenSim/Framework/General/Configuration/UserConfig.cs b/OpenSim/Framework/General/Configuration/UserConfig.cs index 9d607b307d..a027ffc77f 100644 --- a/OpenSim/Framework/General/Configuration/UserConfig.cs +++ b/OpenSim/Framework/General/Configuration/UserConfig.cs @@ -24,16 +24,16 @@ namespace OpenSim.Framework.Configuration public void loadConfigurationOptions() { - configMember.addConfigurationOption("default_startup_message",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Default Startup Message","Welcome to OGS"); - - configMember.addConfigurationOption("default_grid_server",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Default Grid Server URI","http://127.0.0.1:8001/"); - configMember.addConfigurationOption("grid_send_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to send to grid server","null"); - configMember.addConfigurationOption("grid_recv_key",ConfigurationOption.ConfigurationTypes.TYPE_STRING,"Key to expect from grid server","null"); + configMember.addConfigurationOption("default_startup_message", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Startup Message", "Welcome to OGS",false); + + configMember.addConfigurationOption("default_grid_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Grid Server URI", "http://127.0.0.1:8001/", false); + configMember.addConfigurationOption("grid_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to grid server", "null", false); + configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from grid server", "null", false); } - public void handleIncomingConfiguration(string configuration_key, object configuration_result) + public bool handleIncomingConfiguration(string configuration_key, object configuration_result) { switch (configuration_key) { @@ -50,6 +50,8 @@ namespace OpenSim.Framework.Configuration this.GridRecvKey = (string)configuration_result; break; } + + return true; } } } diff --git a/OpenSim/Framework/General/Types/NetworkServersInfo.cs b/OpenSim/Framework/General/Types/NetworkServersInfo.cs index 40557be463..7f21d45f92 100644 --- a/OpenSim/Framework/General/Types/NetworkServersInfo.cs +++ b/OpenSim/Framework/General/Types/NetworkServersInfo.cs @@ -62,23 +62,23 @@ namespace OpenSim.Framework.Types public void loadConfigurationOptions() { - configMember.addConfigurationOption("HttpListenerPort", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "HTTP Listener Port", "9000"); - configMember.addConfigurationOption("RemotingListenerPort", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Remoting Listener Port", "8895"); - configMember.addConfigurationOption("DefaultLocationX", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Default Home Location (X Axis)", "1000"); - configMember.addConfigurationOption("DefaultLocationY", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Default Home Location (Y Axis)", "1000"); + configMember.addConfigurationOption("HttpListenerPort", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "HTTP Listener Port", "9000", false); + configMember.addConfigurationOption("RemotingListenerPort", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Remoting Listener Port", "8895", false); + configMember.addConfigurationOption("DefaultLocationX", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Default Home Location (X Axis)", "1000", false); + configMember.addConfigurationOption("DefaultLocationY", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Default Home Location (Y Axis)", "1000", false); - configMember.addConfigurationOption("GridServerURL", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Grid Server URL", "http://127.0.0.1:8001"); - configMember.addConfigurationOption("GridSendKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to grid server", "null"); - configMember.addConfigurationOption("GridRecvKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from grid server", "null"); + configMember.addConfigurationOption("GridServerURL", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Grid Server URL", "http://127.0.0.1:8001", false); + configMember.addConfigurationOption("GridSendKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to grid server", "null", false); + configMember.addConfigurationOption("GridRecvKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from grid server", "null", false); - configMember.addConfigurationOption("UserServerURL", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "User Server URL", "http://127.0.0.1:8002"); - configMember.addConfigurationOption("UserSendKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to user server", "null"); - configMember.addConfigurationOption("UserRecvKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null"); + configMember.addConfigurationOption("UserServerURL", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "User Server URL", "http://127.0.0.1:8002", false); + configMember.addConfigurationOption("UserSendKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to user server", "null", false); + configMember.addConfigurationOption("UserRecvKey", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null", false); - configMember.addConfigurationOption("AssetServerURL", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Asset Server URL", "http://127.0.0.1:8003"); + configMember.addConfigurationOption("AssetServerURL", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Asset Server URL", "http://127.0.0.1:8003", false); } - public void handleConfigurationItem(string configuration_key, object configuration_object) + public bool handleConfigurationItem(string configuration_key, object configuration_object) { switch (configuration_key) { @@ -116,6 +116,8 @@ namespace OpenSim.Framework.Types this.AssetURL = (string)configuration_object; break; } + + return true; } } } diff --git a/OpenSim/Framework/General/Types/RegionInfo.cs b/OpenSim/Framework/General/Types/RegionInfo.cs index b7c35c73a2..57bb398fe8 100644 --- a/OpenSim/Framework/General/Types/RegionInfo.cs +++ b/OpenSim/Framework/General/Types/RegionInfo.cs @@ -164,23 +164,23 @@ namespace OpenSim.Framework.Types public void loadConfigurationOptions() { - configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "UUID of Simulator (Default is recommended, random UUID)", LLUUID.Random().ToString()); - configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Simulator Name", "OpenSim Test"); - configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (X Axis)", "1000"); - configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (Y Axis)", "1000"); - configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Filename for local storage", "localworld.yap"); - configMember.addConfigurationOption("internal_ip_address", ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, "Internal IP Address for incoming UDP client connections", "0.0.0.0"); - configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Internal IP Port for incoming UDP client connections", "9000"); - configMember.addConfigurationOption("external_host_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "External Host Name", "127.0.0.1"); - configMember.addConfigurationOption("terrain_file", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Default Terrain File", "default.r32"); - configMember.addConfigurationOption("terrain_multiplier", ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE, "Terrain Height Multiplier", "60.0"); - configMember.addConfigurationOption("master_avatar_first", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "First Name of Master Avatar", "Test"); - configMember.addConfigurationOption("master_avatar_last", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Last Name of Master Avatar", "User"); - configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "(Sandbox Mode Only)Password for Master Avatar account", "test"); + configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "UUID of Simulator (Default is recommended, random UUID)", LLUUID.Random().ToString(),true); + configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Simulator Name", "OpenSim Test", false); + configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (X Axis)", "1000", false); + configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (Y Axis)", "1000", false); + configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "localworld.yap", false); + configMember.addConfigurationOption("internal_ip_address", ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, "Internal IP Address for incoming UDP client connections", "0.0.0.0", false); + configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Internal IP Port for incoming UDP client connections", "9000", false); + configMember.addConfigurationOption("external_host_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "External Host Name", "127.0.0.1", false); + configMember.addConfigurationOption("terrain_file", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Terrain File", "default.r32", false); + configMember.addConfigurationOption("terrain_multiplier", ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE, "Terrain Height Multiplier", "60.0", false); + configMember.addConfigurationOption("master_avatar_first", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "First Name of Master Avatar", "Test", false); + configMember.addConfigurationOption("master_avatar_last", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Last Name of Master Avatar", "User", false); + configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "(Sandbox Mode Only)Password for Master Avatar account", "test", false); } - public void handleIncomingConfiguration(string configuration_key, object configuration_result) + public bool handleIncomingConfiguration(string configuration_key, object configuration_result) { switch (configuration_key) { @@ -225,6 +225,8 @@ namespace OpenSim.Framework.Types this.MasterAvatarSandboxPassword = (string)configuration_result; break; } + + return true; } }