aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/ConfigurationLoader.cs
diff options
context:
space:
mode:
authorMW2008-11-05 20:14:52 +0000
committerMW2008-11-05 20:14:52 +0000
commit571b94f537cc1f431ed52e6a185863ae17357f30 (patch)
treeff5381abcf3237c7a9339a1b5e2904d88f75bfa1 /OpenSim/Region/Application/ConfigurationLoader.cs
parent* Zap the letters that accidentally crept in to the license in EventQueueThre... (diff)
downloadopensim-SC-571b94f537cc1f431ed52e6a185863ae17357f30.zip
opensim-SC-571b94f537cc1f431ed52e6a185863ae17357f30.tar.gz
opensim-SC-571b94f537cc1f431ed52e6a185863ae17357f30.tar.bz2
opensim-SC-571b94f537cc1f431ed52e6a185863ae17357f30.tar.xz
moved the initial loading/setting of the config settings to its own class, ConfigurationLoader. To make it easier to customise the loading of those settings and possible in the future move it to a plugin.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs196
1 files changed, 196 insertions, 0 deletions
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
new file mode 100644
index 0000000..6fde140
--- /dev/null
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -0,0 +1,196 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Threading;
5using System.IO;
6using OpenSim.Framework;
7using Nini;
8using Nini.Config;
9
10namespace OpenSim
11{
12 public class ConfigurationLoader
13 {
14 protected ConfigSettings m_configSettings;
15 protected OpenSimConfigSource m_config;
16 protected NetworkServersInfo m_networkServersInfo;
17
18 public ConfigurationLoader()
19 {
20
21 }
22
23 public OpenSimConfigSource LoadConfigSettings(IConfigSource configSource, out ConfigSettings configSettings, out NetworkServersInfo networkInfo)
24 {
25 m_configSettings = configSettings = new ConfigSettings();
26 m_networkServersInfo = networkInfo = new NetworkServersInfo();
27 bool iniFileExists = false;
28
29 IConfig startupConfig = configSource.Configs["Startup"];
30
31 string iniFileName = startupConfig.GetString("inifile", "OpenSim.ini");
32 Application.iniFilePath = Path.Combine(Util.configDir(), iniFileName);
33
34 string masterFileName = startupConfig.GetString("inimaster", "");
35 string masterfilePath = Path.Combine(Util.configDir(), masterFileName);
36
37 m_config = new OpenSimConfigSource();
38 m_config.Source = new IniConfigSource();
39 m_config.Source.Merge(DefaultConfig());
40
41 //check for .INI file (either default or name passed in command line)
42 if (File.Exists(masterfilePath))
43 {
44 m_config.Source.Merge(new IniConfigSource(masterfilePath));
45 }
46
47 if (File.Exists(Application.iniFilePath))
48 {
49 iniFileExists = true;
50
51 // From reading Nini's code, it seems that later merged keys replace earlier ones.
52 m_config.Source.Merge(new IniConfigSource(Application.iniFilePath));
53 }
54 else
55 {
56 // check for a xml config file
57 Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml");
58
59 if (File.Exists(Application.iniFilePath))
60 {
61 iniFileExists = true;
62
63 m_config.Source = new XmlConfigSource();
64 m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath));
65 }
66 }
67
68 m_config.Source.Merge(configSource);
69
70 if (!iniFileExists)
71 m_config.Save("OpenSim.ini");
72
73 ReadConfigSettings();
74
75 return m_config;
76 }
77
78 /// <summary>
79 /// Setup a default config values in case they aren't present in the ini file
80 /// </summary>
81 /// <returns></returns>
82 public static IConfigSource DefaultConfig()
83 {
84 IConfigSource defaultConfig = new IniConfigSource();
85
86 {
87 IConfig config = defaultConfig.Configs["Startup"];
88
89 if (null == config)
90 config = defaultConfig.AddConfig("Startup");
91
92 config.Set("gridmode", false);
93 config.Set("physics", "basicphysics");
94 config.Set("meshing", "ZeroMesher");
95 config.Set("physical_prim", true);
96 config.Set("see_into_this_sim_from_neighbor", true);
97 config.Set("serverside_object_permissions", false);
98 config.Set("storage_plugin", "OpenSim.Data.SQLite.dll");
99 config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3");
100 config.Set("storage_prim_inventories", true);
101 config.Set("startup_console_commands_file", String.Empty);
102 config.Set("shutdown_console_commands_file", String.Empty);
103 config.Set("DefaultScriptEngine", "ScriptEngine.DotNetEngine");
104 config.Set("asset_database", "sqlite");
105 config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
106 }
107
108 {
109 IConfig config = defaultConfig.Configs["StandAlone"];
110
111 if (null == config)
112 config = defaultConfig.AddConfig("StandAlone");
113
114 config.Set("accounts_authenticate", false);
115 config.Set("welcome_message", "Welcome to OpenSimulator");
116 config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll");
117 config.Set("inventory_source", "");
118 config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll");
119 config.Set("user_source", "");
120 config.Set("asset_plugin", "OpenSim.Data.SQLite.dll");
121 config.Set("asset_source", "");
122 config.Set("dump_assets_to_file", false);
123 }
124
125 {
126 IConfig config = defaultConfig.Configs["Network"];
127
128 if (null == config)
129 config = defaultConfig.AddConfig("Network");
130
131 config.Set("default_location_x", 1000);
132 config.Set("default_location_y", 1000);
133 config.Set("http_listener_port", NetworkServersInfo.DefaultHttpListenerPort);
134 config.Set("remoting_listener_port", NetworkServersInfo.RemotingListenerPort);
135 config.Set("grid_server_url", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString());
136 config.Set("grid_send_key", "null");
137 config.Set("grid_recv_key", "null");
138 config.Set("user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString());
139 config.Set("user_send_key", "null");
140 config.Set("user_recv_key", "null");
141 config.Set("asset_server_url", "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString());
142 config.Set("inventory_server_url", "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString());
143 config.Set("secure_inventory_server", "true");
144 }
145
146 return defaultConfig;
147 }
148
149 protected virtual void ReadConfigSettings()
150 {
151 IConfig startupConfig = m_config.Source.Configs["Startup"];
152
153 if (startupConfig != null)
154 {
155 m_configSettings.Standalone = !startupConfig.GetBoolean("gridmode");
156 m_configSettings.PhysicsEngine = startupConfig.GetString("physics");
157 m_configSettings.MeshEngineName = startupConfig.GetString("meshing");
158
159 m_configSettings.PhysicalPrim = startupConfig.GetBoolean("physical_prim");
160
161 m_configSettings.See_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor");
162
163 m_configSettings.StorageDll = startupConfig.GetString("storage_plugin");
164 if (m_configSettings.StorageDll == "OpenSim.DataStore.MonoSqlite.dll")
165 {
166 m_configSettings.StorageDll = "OpenSim.Data.SQLite.dll";
167 Console.WriteLine("WARNING: OpenSim.DataStore.MonoSqlite.dll is deprecated. Set storage_plugin to OpenSim.Data.SQLite.dll.");
168 Thread.Sleep(3000);
169 }
170
171 m_configSettings.StorageConnectionString = startupConfig.GetString("storage_connection_string");
172 m_configSettings.EstateConnectionString = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString);
173 m_configSettings.AssetStorage = startupConfig.GetString("asset_database");
174 m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin");
175 }
176
177 IConfig standaloneConfig = m_config.Source.Configs["StandAlone"];
178 if (standaloneConfig != null)
179 {
180 m_configSettings.StandaloneAuthenticate = standaloneConfig.GetBoolean("accounts_authenticate");
181 m_configSettings.StandaloneWelcomeMessage = standaloneConfig.GetString("welcome_message");
182
183 m_configSettings.StandaloneInventoryPlugin = standaloneConfig.GetString("inventory_plugin");
184 m_configSettings.StandaloneInventorySource = standaloneConfig.GetString("inventory_source");
185 m_configSettings.StandaloneUserPlugin = standaloneConfig.GetString("userDatabase_plugin");
186 m_configSettings.StandaloneUserSource = standaloneConfig.GetString("user_source");
187 m_configSettings.StandaloneAssetPlugin = standaloneConfig.GetString("asset_plugin");
188 m_configSettings.StandaloneAssetSource = standaloneConfig.GetString("asset_source");
189
190 m_configSettings.DumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file");
191 }
192
193 m_networkServersInfo.loadFromConfiguration(m_config.Source);
194 }
195 }
196}