diff options
author | Diva Canto | 2013-02-22 15:57:33 -0800 |
---|---|---|
committer | Diva Canto | 2013-02-22 15:57:33 -0800 |
commit | 0e8289cd002b1947e172d1bfc77fdd0b16d92ffb (patch) | |
tree | 5eadc5f0bb6bc6d69c574aeaf46bd4482bab4f0b /OpenSim | |
parent | Err.. wrong dll name for groups in Robust.HG.ini.example (diff) | |
download | opensim-SC-0e8289cd002b1947e172d1bfc77fdd0b16d92ffb.zip opensim-SC-0e8289cd002b1947e172d1bfc77fdd0b16d92ffb.tar.gz opensim-SC-0e8289cd002b1947e172d1bfc77fdd0b16d92ffb.tar.bz2 opensim-SC-0e8289cd002b1947e172d1bfc77fdd0b16d92ffb.tar.xz |
Added new Util function for reading config vars that's more generic than the one I added yesterday -- this is for helping move config vars out of [Startup]
Diffstat (limited to 'OpenSim')
13 files changed, 54 insertions, 15 deletions
diff --git a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs index 0e71c72..7cc9ff4 100644 --- a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs +++ b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Groups | |||
65 | 65 | ||
66 | m_log.DebugFormat("[Groups.RobustHGConnector]: Starting with config name {0}", m_ConfigName); | 66 | m_log.DebugFormat("[Groups.RobustHGConnector]: Starting with config name {0}", m_ConfigName); |
67 | 67 | ||
68 | string homeURI = Util.GetConfigVarWithDefaultSection(config, "HomeURI", m_ConfigName); //cnf.GetString("HomeURI", string.Empty); | 68 | string homeURI = Util.GetConfigVarFromSections<string>(config, "HomeURI", new string[] { "Startup", m_ConfigName} ); //cnf.GetString("HomeURI", string.Empty); |
69 | if (homeURI == string.Empty) | 69 | if (homeURI == string.Empty) |
70 | throw new Exception(String.Format("[Groups.RobustHGConnector]: please provide the HomeURI [Startup] or in section {0}", m_ConfigName)); | 70 | throw new Exception(String.Format("[Groups.RobustHGConnector]: please provide the HomeURI [Startup] or in section {0}", m_ConfigName)); |
71 | 71 | ||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 1700d3e..8b8e507 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -904,6 +904,44 @@ namespace OpenSim.Framework | |||
904 | 904 | ||
905 | return val; | 905 | return val; |
906 | } | 906 | } |
907 | |||
908 | /// <summary> | ||
909 | /// Gets the value of a configuration variable by looking into | ||
910 | /// multiple sections in order. The latter sections overwrite | ||
911 | /// any values previously found. | ||
912 | /// </summary> | ||
913 | /// <typeparam name="T">Type of the variable</typeparam> | ||
914 | /// <param name="config">The configuration object</param> | ||
915 | /// <param name="varname">The configuration variable</param> | ||
916 | /// <param name="sections">Ordered sequence of sections to look at</param> | ||
917 | /// <returns></returns> | ||
918 | public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections) | ||
919 | { | ||
920 | object val = default(T); | ||
921 | foreach (string section in sections) | ||
922 | { | ||
923 | IConfig cnf = config.Configs[section]; | ||
924 | if (cnf == null) | ||
925 | continue; | ||
926 | |||
927 | if (typeof(T) == typeof(String)) | ||
928 | { | ||
929 | if (val == null) // no null strings, please | ||
930 | val = string.Empty; | ||
931 | val = cnf.GetString(varname, (string)val); | ||
932 | } | ||
933 | else if (typeof(T) == typeof(Boolean)) | ||
934 | val = cnf.GetBoolean(varname, (bool)val); | ||
935 | else if (typeof(T) == typeof(Int32)) | ||
936 | val = cnf.GetInt(varname, (int)val); | ||
937 | else if (typeof(T) == typeof(float)) | ||
938 | val = cnf.GetFloat(varname, (int)val); | ||
939 | else | ||
940 | m_log.WarnFormat("[UTIL]: Unhandled type {0}", typeof(T)); | ||
941 | } | ||
942 | return (T)val; | ||
943 | } | ||
944 | |||
907 | #endregion | 945 | #endregion |
908 | 946 | ||
909 | public static float Clip(float x, float min, float max) | 947 | public static float Clip(float x, float min, float max) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs index 784a788..22cdc80 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
65 | { | 65 | { |
66 | m_Enabled = true; | 66 | m_Enabled = true; |
67 | 67 | ||
68 | m_ThisGridURL = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "Messaging"); | 68 | m_ThisGridURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", new string[] {"Startup", "Messaging"}); |
69 | // Legacy. Remove soon! | 69 | // Legacy. Remove soon! |
70 | m_ThisGridURL = config.Configs["Messaging"].GetString("Gatekeeper", m_ThisGridURL); | 70 | m_ThisGridURL = config.Configs["Messaging"].GetString("Gatekeeper", m_ThisGridURL); |
71 | m_log.DebugFormat("[LURE MODULE]: {0} enabled", Name); | 71 | m_log.DebugFormat("[LURE MODULE]: {0} enabled", Name); |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index c439ea8..4f6b92e 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -88,11 +88,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
88 | IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; | 88 | IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; |
89 | if (thisModuleConfig != null) | 89 | if (thisModuleConfig != null) |
90 | { | 90 | { |
91 | m_HomeURI = Util.GetConfigVarWithDefaultSection(source, "HomeURI", "HGInventoryAccessModule"); | 91 | m_HomeURI = Util.GetConfigVarFromSections<string>(source, "HomeURI", new string[] {"Startup", "HGInventoryAccessModule"}); |
92 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); | 92 | m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(source, "GatekeeperURI", new string[] {"Startup", "HGInventoryAccessModule"}); |
93 | m_ThisGatekeeper = Util.GetConfigVarWithDefaultSection(source, "GatekeeperURI", "HGInventoryAccessModule"); | ||
94 | // Legacy. Renove soon! | 93 | // Legacy. Renove soon! |
95 | m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", m_ThisGatekeeper); | 94 | m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", m_ThisGatekeeper); |
95 | |||
96 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); | ||
96 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); | 97 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); |
97 | } | 98 | } |
98 | else | 99 | else |
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 13d9d31..e8bf194 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | |||
@@ -113,7 +113,7 @@ namespace OpenSim.Region.DataSnapshot | |||
113 | try | 113 | try |
114 | { | 114 | { |
115 | m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); | 115 | m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); |
116 | string gatekeeper = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "GridService"); | 116 | string gatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", new string[] {"Startup", "GridService"}); |
117 | // Legacy. Remove soon! | 117 | // Legacy. Remove soon! |
118 | if (string.IsNullOrEmpty(gatekeeper)) | 118 | if (string.IsNullOrEmpty(gatekeeper)) |
119 | { | 119 | { |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 0334169..d356f8c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2138,7 +2138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2138 | m_host.AddScriptLPS(1); | 2138 | m_host.AddScriptLPS(1); |
2139 | 2139 | ||
2140 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2140 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2141 | string HomeURI = Util.GetConfigVarWithDefaultSection(config, "HomeURI", string.Empty); | 2141 | string HomeURI = Util.GetConfigVarFromSections<string>(config, "HomeURI", new string[]{"Startup"}); |
2142 | 2142 | ||
2143 | if (!string.IsNullOrEmpty(HomeURI)) | 2143 | if (!string.IsNullOrEmpty(HomeURI)) |
2144 | return HomeURI; | 2144 | return HomeURI; |
@@ -2159,7 +2159,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2159 | m_host.AddScriptLPS(1); | 2159 | m_host.AddScriptLPS(1); |
2160 | 2160 | ||
2161 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2161 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2162 | string gatekeeperURI = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", string.Empty); | 2162 | string gatekeeperURI = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", new string[] {"Startup"}); |
2163 | 2163 | ||
2164 | if (!string.IsNullOrEmpty(gatekeeperURI)) | 2164 | if (!string.IsNullOrEmpty(gatekeeperURI)) |
2165 | return gatekeeperURI; | 2165 | return gatekeeperURI; |
diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 35f86c5..d85aab0 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | |||
@@ -177,7 +177,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
177 | map[k] = OSD.FromString(_info[k].ToString()); | 177 | map[k] = OSD.FromString(_info[k].ToString()); |
178 | } | 178 | } |
179 | 179 | ||
180 | string HomeURI = Util.GetConfigVarWithDefaultSection(m_Config, "HomeURI", string.Empty); | 180 | string HomeURI = Util.GetConfigVarFromSections<string>(m_Config, "HomeURI", new string[] {"Startup"}); |
181 | 181 | ||
182 | if (!String.IsNullOrEmpty(HomeURI)) | 182 | if (!String.IsNullOrEmpty(HomeURI)) |
183 | map["home"] = OSD.FromString(HomeURI); | 183 | map["home"] = OSD.FromString(HomeURI); |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 3e7c556..80575ee 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -128,7 +128,7 @@ namespace OpenSim.Services.GridService | |||
128 | 128 | ||
129 | m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); | 129 | m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); |
130 | 130 | ||
131 | m_ThisGatekeeper = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "GridService"); | 131 | m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", new string[] {"Startup", "GridService"}); |
132 | // Legacy. Remove soon! | 132 | // Legacy. Remove soon! |
133 | m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); | 133 | m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); |
134 | try | 134 | try |
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 21f363c..c41d952 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs | |||
@@ -96,7 +96,7 @@ namespace OpenSim.Services.HypergridService | |||
96 | UUID.TryParse(scope, out m_ScopeID); | 96 | UUID.TryParse(scope, out m_ScopeID); |
97 | //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); | 97 | //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); |
98 | m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true); | 98 | m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true); |
99 | m_ExternalName = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "GatekeeperService"); | 99 | m_ExternalName = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", new string[] {"Startup", "GatekeeperService"}); |
100 | m_ExternalName = serverConfig.GetString("ExternalName", m_ExternalName); | 100 | m_ExternalName = serverConfig.GetString("ExternalName", m_ExternalName); |
101 | if (m_ExternalName != string.Empty && !m_ExternalName.EndsWith("/")) | 101 | if (m_ExternalName != string.Empty && !m_ExternalName.EndsWith("/")) |
102 | m_ExternalName = m_ExternalName + "/"; | 102 | m_ExternalName = m_ExternalName + "/"; |
diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs index a9661f4..17e83cc 100644 --- a/OpenSim/Services/HypergridService/HGInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGInventoryService.cs | |||
@@ -81,7 +81,7 @@ namespace OpenSim.Services.HypergridService | |||
81 | if (m_UserAccountService == null) | 81 | if (m_UserAccountService == null) |
82 | throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); | 82 | throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); |
83 | 83 | ||
84 | m_HomeURL = Util.GetConfigVarWithDefaultSection(config, "HomeURI", m_ConfigName); | 84 | m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI", new string[] {"Startup", m_ConfigName}); |
85 | 85 | ||
86 | m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); | 86 | m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); |
87 | } | 87 | } |
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index dd546b8..776bf0c 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs | |||
@@ -96,7 +96,7 @@ namespace OpenSim.Services.HypergridService | |||
96 | if (m_AvatarService == null) | 96 | if (m_AvatarService == null) |
97 | throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); | 97 | throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); |
98 | 98 | ||
99 | m_HomeURL = Util.GetConfigVarWithDefaultSection(config, "HomeURI", m_ConfigName); | 99 | m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI", new string[] {"Startup", m_ConfigName}); |
100 | 100 | ||
101 | // m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); | 101 | // m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); |
102 | } | 102 | } |
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 8757a4c..2ab0b87 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs | |||
@@ -131,7 +131,7 @@ namespace OpenSim.Services.HypergridService | |||
131 | LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_TripsAllowedExceptions); | 131 | LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_TripsAllowedExceptions); |
132 | LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_TripsDisallowedExceptions); | 132 | LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_TripsDisallowedExceptions); |
133 | 133 | ||
134 | m_GridName = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "UserAgentService"); | 134 | m_GridName = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", new string[] {"Startup", "UserAgentService"}); |
135 | if (string.IsNullOrEmpty(m_GridName)) // Legacy. Remove soon. | 135 | if (string.IsNullOrEmpty(m_GridName)) // Legacy. Remove soon. |
136 | { | 136 | { |
137 | m_GridName = serverConfig.GetString("ExternalName", string.Empty); | 137 | m_GridName = serverConfig.GetString("ExternalName", string.Empty); |
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 7f32d30..0fbd090 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -110,7 +110,7 @@ namespace OpenSim.Services.LLLoginService | |||
110 | m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true); | 110 | m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true); |
111 | m_AllowRemoteSetLoginLevel = m_LoginServerConfig.GetBoolean("AllowRemoteSetLoginLevel", false); | 111 | m_AllowRemoteSetLoginLevel = m_LoginServerConfig.GetBoolean("AllowRemoteSetLoginLevel", false); |
112 | m_MinLoginLevel = m_LoginServerConfig.GetInt("MinLoginLevel", 0); | 112 | m_MinLoginLevel = m_LoginServerConfig.GetInt("MinLoginLevel", 0); |
113 | m_GatekeeperURL = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "LoginService"); | 113 | m_GatekeeperURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", new string[] {"Startup", "LoginService"}); |
114 | m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty); | 114 | m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty); |
115 | m_ProfileURL = m_LoginServerConfig.GetString("ProfileServerURL", string.Empty); | 115 | m_ProfileURL = m_LoginServerConfig.GetString("ProfileServerURL", string.Empty); |
116 | m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty); | 116 | m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty); |