diff --git a/OpenSim/Framework/ConfigSettings.cs b/OpenSim/Framework/ConfigSettings.cs
index 275ab699f6..3ff02f989c 100644
--- a/OpenSim/Framework/ConfigSettings.cs
+++ b/OpenSim/Framework/ConfigSettings.cs
@@ -148,5 +148,13 @@ namespace OpenSim.Framework
get { return m_estateConnectionString; }
set { m_estateConnectionString = value; }
}
+
+ protected bool m_dumpAssetsToFile;
+
+ public bool DumpAssetsToFile
+ {
+ get { return m_dumpAssetsToFile; }
+ set { m_dumpAssetsToFile = value; }
+ }
}
}
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
new file mode 100644
index 0000000000..6fde1402c5
--- /dev/null
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -0,0 +1,196 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using System.IO;
+using OpenSim.Framework;
+using Nini;
+using Nini.Config;
+
+namespace OpenSim
+{
+ public class ConfigurationLoader
+ {
+ protected ConfigSettings m_configSettings;
+ protected OpenSimConfigSource m_config;
+ protected NetworkServersInfo m_networkServersInfo;
+
+ public ConfigurationLoader()
+ {
+
+ }
+
+ public OpenSimConfigSource LoadConfigSettings(IConfigSource configSource, out ConfigSettings configSettings, out NetworkServersInfo networkInfo)
+ {
+ m_configSettings = configSettings = new ConfigSettings();
+ m_networkServersInfo = networkInfo = new NetworkServersInfo();
+ bool iniFileExists = false;
+
+ IConfig startupConfig = configSource.Configs["Startup"];
+
+ string iniFileName = startupConfig.GetString("inifile", "OpenSim.ini");
+ Application.iniFilePath = Path.Combine(Util.configDir(), iniFileName);
+
+ string masterFileName = startupConfig.GetString("inimaster", "");
+ string masterfilePath = Path.Combine(Util.configDir(), masterFileName);
+
+ m_config = new OpenSimConfigSource();
+ m_config.Source = new IniConfigSource();
+ m_config.Source.Merge(DefaultConfig());
+
+ //check for .INI file (either default or name passed in command line)
+ if (File.Exists(masterfilePath))
+ {
+ m_config.Source.Merge(new IniConfigSource(masterfilePath));
+ }
+
+ if (File.Exists(Application.iniFilePath))
+ {
+ iniFileExists = true;
+
+ // From reading Nini's code, it seems that later merged keys replace earlier ones.
+ m_config.Source.Merge(new IniConfigSource(Application.iniFilePath));
+ }
+ else
+ {
+ // check for a xml config file
+ Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml");
+
+ if (File.Exists(Application.iniFilePath))
+ {
+ iniFileExists = true;
+
+ m_config.Source = new XmlConfigSource();
+ m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath));
+ }
+ }
+
+ m_config.Source.Merge(configSource);
+
+ if (!iniFileExists)
+ m_config.Save("OpenSim.ini");
+
+ ReadConfigSettings();
+
+ return m_config;
+ }
+
+ ///
+ /// Setup a default config values in case they aren't present in the ini file
+ ///
+ ///
+ public static IConfigSource DefaultConfig()
+ {
+ IConfigSource defaultConfig = new IniConfigSource();
+
+ {
+ IConfig config = defaultConfig.Configs["Startup"];
+
+ if (null == config)
+ config = defaultConfig.AddConfig("Startup");
+
+ config.Set("gridmode", false);
+ config.Set("physics", "basicphysics");
+ config.Set("meshing", "ZeroMesher");
+ config.Set("physical_prim", true);
+ config.Set("see_into_this_sim_from_neighbor", true);
+ config.Set("serverside_object_permissions", false);
+ config.Set("storage_plugin", "OpenSim.Data.SQLite.dll");
+ config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3");
+ config.Set("storage_prim_inventories", true);
+ config.Set("startup_console_commands_file", String.Empty);
+ config.Set("shutdown_console_commands_file", String.Empty);
+ config.Set("DefaultScriptEngine", "ScriptEngine.DotNetEngine");
+ config.Set("asset_database", "sqlite");
+ config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
+ }
+
+ {
+ IConfig config = defaultConfig.Configs["StandAlone"];
+
+ if (null == config)
+ config = defaultConfig.AddConfig("StandAlone");
+
+ config.Set("accounts_authenticate", false);
+ config.Set("welcome_message", "Welcome to OpenSimulator");
+ config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll");
+ config.Set("inventory_source", "");
+ config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll");
+ config.Set("user_source", "");
+ config.Set("asset_plugin", "OpenSim.Data.SQLite.dll");
+ config.Set("asset_source", "");
+ config.Set("dump_assets_to_file", false);
+ }
+
+ {
+ IConfig config = defaultConfig.Configs["Network"];
+
+ if (null == config)
+ config = defaultConfig.AddConfig("Network");
+
+ config.Set("default_location_x", 1000);
+ config.Set("default_location_y", 1000);
+ config.Set("http_listener_port", NetworkServersInfo.DefaultHttpListenerPort);
+ config.Set("remoting_listener_port", NetworkServersInfo.RemotingListenerPort);
+ config.Set("grid_server_url", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString());
+ config.Set("grid_send_key", "null");
+ config.Set("grid_recv_key", "null");
+ config.Set("user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString());
+ config.Set("user_send_key", "null");
+ config.Set("user_recv_key", "null");
+ config.Set("asset_server_url", "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString());
+ config.Set("inventory_server_url", "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString());
+ config.Set("secure_inventory_server", "true");
+ }
+
+ return defaultConfig;
+ }
+
+ protected virtual void ReadConfigSettings()
+ {
+ IConfig startupConfig = m_config.Source.Configs["Startup"];
+
+ if (startupConfig != null)
+ {
+ m_configSettings.Standalone = !startupConfig.GetBoolean("gridmode");
+ m_configSettings.PhysicsEngine = startupConfig.GetString("physics");
+ m_configSettings.MeshEngineName = startupConfig.GetString("meshing");
+
+ m_configSettings.PhysicalPrim = startupConfig.GetBoolean("physical_prim");
+
+ m_configSettings.See_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor");
+
+ m_configSettings.StorageDll = startupConfig.GetString("storage_plugin");
+ if (m_configSettings.StorageDll == "OpenSim.DataStore.MonoSqlite.dll")
+ {
+ m_configSettings.StorageDll = "OpenSim.Data.SQLite.dll";
+ Console.WriteLine("WARNING: OpenSim.DataStore.MonoSqlite.dll is deprecated. Set storage_plugin to OpenSim.Data.SQLite.dll.");
+ Thread.Sleep(3000);
+ }
+
+ m_configSettings.StorageConnectionString = startupConfig.GetString("storage_connection_string");
+ m_configSettings.EstateConnectionString = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString);
+ m_configSettings.AssetStorage = startupConfig.GetString("asset_database");
+ m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin");
+ }
+
+ IConfig standaloneConfig = m_config.Source.Configs["StandAlone"];
+ if (standaloneConfig != null)
+ {
+ m_configSettings.StandaloneAuthenticate = standaloneConfig.GetBoolean("accounts_authenticate");
+ m_configSettings.StandaloneWelcomeMessage = standaloneConfig.GetString("welcome_message");
+
+ m_configSettings.StandaloneInventoryPlugin = standaloneConfig.GetString("inventory_plugin");
+ m_configSettings.StandaloneInventorySource = standaloneConfig.GetString("inventory_source");
+ m_configSettings.StandaloneUserPlugin = standaloneConfig.GetString("userDatabase_plugin");
+ m_configSettings.StandaloneUserSource = standaloneConfig.GetString("user_source");
+ m_configSettings.StandaloneAssetPlugin = standaloneConfig.GetString("asset_plugin");
+ m_configSettings.StandaloneAssetSource = standaloneConfig.GetString("asset_source");
+
+ m_configSettings.DumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file");
+ }
+
+ m_networkServersInfo.loadFromConfiguration(m_config.Source);
+ }
+ }
+}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index e710ec2f11..763aaa5900 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -67,7 +67,7 @@ namespace OpenSim
{
}
- protected override void ReadConfigSettings()
+ protected override void ReadExtraConfigSettings()
{
IConfig startupConfig = m_config.Source.Configs["Startup"];
@@ -78,7 +78,6 @@ namespace OpenSim
m_timedScript = startupConfig.GetString("timer_Script", "disabled");
}
- base.ReadConfigSettings();
}
///
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 61e6f09121..93cc0a7ae8 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -76,7 +76,7 @@ namespace OpenSim
///
protected const string DEFAULT_INV_BACKUP_FILENAME = "opensim_inv.tar.gz";
- protected ConfigSettings m_configSettings = new ConfigSettings();
+ protected ConfigSettings m_configSettings;
public ConfigSettings ConfigurationSettings
{
@@ -84,14 +84,15 @@ namespace OpenSim
set { m_configSettings = value; }
}
+ protected ConfigurationLoader m_configLoader;
+
protected GridInfoService m_gridInfoService;
protected List m_clientServers = new List();
protected List m_regionData = new List();
public ConsoleCommand CreateAccount = null;
- protected bool m_dumpAssetsToFile;
-
+
protected List m_plugins = new List();
///
@@ -138,178 +139,14 @@ namespace OpenSim
///
public OpenSimBase(IConfigSource configSource) : base()
{
- LoadConfigSettings(configSource);
+ m_configLoader = new ConfigurationLoader();
+ m_config = m_configLoader.LoadConfigSettings(configSource, out m_configSettings, out m_networkServersInfo);
+ ReadExtraConfigSettings();
}
- protected void LoadConfigSettings(IConfigSource configSource)
+ protected virtual void ReadExtraConfigSettings()
{
- bool iniFileExists = false;
- IConfig startupConfig = configSource.Configs["Startup"];
-
- string iniFileName = startupConfig.GetString("inifile", "OpenSim.ini");
- Application.iniFilePath = Path.Combine(Util.configDir(), iniFileName);
-
- string masterFileName = startupConfig.GetString("inimaster", "");
- string masterfilePath = Path.Combine(Util.configDir(), masterFileName);
-
- m_config = new OpenSimConfigSource();
- m_config.Source = new IniConfigSource();
- m_config.Source.Merge(DefaultConfig());
-
- //check for .INI file (either default or name passed in command line)
- if (File.Exists(masterfilePath))
- {
- m_config.Source.Merge(new IniConfigSource(masterfilePath));
- }
-
- if (File.Exists(Application.iniFilePath))
- {
- iniFileExists = true;
-
- // From reading Nini's code, it seems that later merged keys replace earlier ones.
- m_config.Source.Merge(new IniConfigSource(Application.iniFilePath));
- }
- else
- {
- // check for a xml config file
- Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml");
-
- if (File.Exists(Application.iniFilePath))
- {
- iniFileExists = true;
-
- m_config.Source = new XmlConfigSource();
- m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath));
- }
- }
-
- m_config.Source.Merge(configSource);
-
- if (!iniFileExists)
- m_config.Save("OpenSim.ini");
-
- ReadConfigSettings();
- }
-
- ///
- /// Setup a default config values in case they aren't present in the ini file
- ///
- ///
- public static IConfigSource DefaultConfig()
- {
- IConfigSource defaultConfig = new IniConfigSource();
-
- {
- IConfig config = defaultConfig.Configs["Startup"];
-
- if (null == config)
- config = defaultConfig.AddConfig("Startup");
-
- config.Set("gridmode", false);
- config.Set("physics", "basicphysics");
- config.Set("meshing", "ZeroMesher");
- config.Set("physical_prim", true);
- config.Set("see_into_this_sim_from_neighbor", true);
- config.Set("serverside_object_permissions", false);
- config.Set("storage_plugin", "OpenSim.Data.SQLite.dll");
- config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3");
- config.Set("storage_prim_inventories", true);
- config.Set("startup_console_commands_file", String.Empty);
- config.Set("shutdown_console_commands_file", String.Empty);
- config.Set("DefaultScriptEngine", "ScriptEngine.DotNetEngine");
- config.Set("asset_database", "sqlite");
- config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
- }
-
- {
- IConfig config = defaultConfig.Configs["StandAlone"];
-
- if (null == config)
- config = defaultConfig.AddConfig("StandAlone");
-
- config.Set("accounts_authenticate", false);
- config.Set("welcome_message", "Welcome to OpenSimulator");
- config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll");
- config.Set("inventory_source", "");
- config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll");
- config.Set("user_source", "");
- config.Set("asset_plugin", "OpenSim.Data.SQLite.dll");
- config.Set("asset_source", "");
- config.Set("dump_assets_to_file", false);
- }
-
- {
- IConfig config = defaultConfig.Configs["Network"];
-
- if (null == config)
- config = defaultConfig.AddConfig("Network");
-
- config.Set("default_location_x", 1000);
- config.Set("default_location_y", 1000);
- config.Set("http_listener_port", NetworkServersInfo.DefaultHttpListenerPort);
- config.Set("remoting_listener_port", NetworkServersInfo.RemotingListenerPort);
- config.Set("grid_server_url", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString());
- config.Set("grid_send_key", "null");
- config.Set("grid_recv_key", "null");
- config.Set("user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString());
- config.Set("user_send_key", "null");
- config.Set("user_recv_key", "null");
- config.Set("asset_server_url", "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString());
- config.Set("inventory_server_url", "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString());
- config.Set("secure_inventory_server", "true");
- }
-
- return defaultConfig;
- }
-
- protected virtual void ReadConfigSettings()
- {
- m_networkServersInfo = new NetworkServersInfo();
-
- IConfig startupConfig = m_config.Source.Configs["Startup"];
-
- if (startupConfig != null)
- {
- m_configSettings.Standalone = !startupConfig.GetBoolean("gridmode");
- m_configSettings.PhysicsEngine = startupConfig.GetString("physics");
- m_configSettings.MeshEngineName = startupConfig.GetString("meshing");
-
- m_configSettings.PhysicalPrim = startupConfig.GetBoolean("physical_prim");
-
- m_configSettings.See_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor");
-
- m_configSettings.StorageDll = startupConfig.GetString("storage_plugin");
- if (m_configSettings.StorageDll == "OpenSim.DataStore.MonoSqlite.dll")
- {
- m_configSettings.StorageDll = "OpenSim.Data.SQLite.dll";
- Console.WriteLine("WARNING: OpenSim.DataStore.MonoSqlite.dll is deprecated. Set storage_plugin to OpenSim.Data.SQLite.dll.");
- Thread.Sleep(3000);
- }
-
- m_configSettings.StorageConnectionString = startupConfig.GetString("storage_connection_string");
- m_configSettings.EstateConnectionString = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString);
- m_configSettings.AssetStorage = startupConfig.GetString("asset_database");
- m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin");
- }
-
- IConfig standaloneConfig = m_config.Source.Configs["StandAlone"];
- if (standaloneConfig != null)
- {
- m_configSettings.StandaloneAuthenticate = standaloneConfig.GetBoolean("accounts_authenticate");
- m_configSettings.StandaloneWelcomeMessage = standaloneConfig.GetString("welcome_message");
-
- m_configSettings.StandaloneInventoryPlugin = standaloneConfig.GetString("inventory_plugin");
- m_configSettings.StandaloneInventorySource = standaloneConfig.GetString("inventory_source");
- m_configSettings.StandaloneUserPlugin = standaloneConfig.GetString("userDatabase_plugin");
- m_configSettings.StandaloneUserSource = standaloneConfig.GetString("user_source");
- m_configSettings.StandaloneAssetPlugin = standaloneConfig.GetString("asset_plugin");
- m_configSettings.StandaloneAssetSource = standaloneConfig.GetString("asset_source");
-
- m_dumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file");
- }
-
- m_networkServersInfo.loadFromConfiguration(m_config.Source);
}
protected void LoadPlugins()
@@ -384,7 +221,7 @@ namespace OpenSim
= new CommunicationsLocal(
m_networkServersInfo, m_httpServer, m_assetCache, userService, userService,
inventoryService, backendService, backendService, userService,
- libraryRootFolder, m_dumpAssetsToFile);
+ libraryRootFolder, m_configSettings.DumpAssetsToFile);
// set up XMLRPC handler for client's initial login request message
m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
@@ -613,7 +450,7 @@ namespace OpenSim
return
new Scene(regionInfo, circuitManager, m_commsManager, sceneGridService, m_assetCache,
storageManager, m_httpServer,
- m_moduleLoader, m_dumpAssetsToFile, m_configSettings.PhysicalPrim, m_configSettings.See_into_region_from_neighbor, m_config.Source,
+ m_moduleLoader, m_configSettings.DumpAssetsToFile, m_configSettings.PhysicalPrim, m_configSettings.See_into_region_from_neighbor, m_config.Source,
m_version);
}
diff --git a/OpenSim/Tools/Export/OpenSimExport.cs b/OpenSim/Tools/Export/OpenSimExport.cs
index 5c0ff521d3..570a85580d 100644
--- a/OpenSim/Tools/Export/OpenSimExport.cs
+++ b/OpenSim/Tools/Export/OpenSimExport.cs
@@ -102,7 +102,7 @@ namespace OpenSimExport
{
// no default config files, so set default values, and save it
Console.WriteLine("We didn't find a config!");
- config.Merge(OpenSimBase.DefaultConfig());
+ config.Merge(ConfigurationLoader.DefaultConfig());
config.Merge(configSource);
}