diff --git a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs index 0e71c72ad6..7cc9ff4044 100644 --- a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs +++ b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs @@ -65,7 +65,7 @@ namespace OpenSim.Groups m_log.DebugFormat("[Groups.RobustHGConnector]: Starting with config name {0}", m_ConfigName); - string homeURI = Util.GetConfigVarWithDefaultSection(config, "HomeURI", m_ConfigName); //cnf.GetString("HomeURI", string.Empty); + string homeURI = Util.GetConfigVarFromSections(config, "HomeURI", new string[] { "Startup", m_ConfigName} ); //cnf.GetString("HomeURI", string.Empty); if (homeURI == string.Empty) throw new Exception(String.Format("[Groups.RobustHGConnector]: please provide the HomeURI [Startup] or in section {0}", m_ConfigName)); diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 1700d3eb97..8b8e50756d 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -904,6 +904,44 @@ namespace OpenSim.Framework return val; } + + /// + /// Gets the value of a configuration variable by looking into + /// multiple sections in order. The latter sections overwrite + /// any values previously found. + /// + /// Type of the variable + /// The configuration object + /// The configuration variable + /// Ordered sequence of sections to look at + /// + public static T GetConfigVarFromSections(IConfigSource config, string varname, string[] sections) + { + object val = default(T); + foreach (string section in sections) + { + IConfig cnf = config.Configs[section]; + if (cnf == null) + continue; + + if (typeof(T) == typeof(String)) + { + if (val == null) // no null strings, please + val = string.Empty; + val = cnf.GetString(varname, (string)val); + } + else if (typeof(T) == typeof(Boolean)) + val = cnf.GetBoolean(varname, (bool)val); + else if (typeof(T) == typeof(Int32)) + val = cnf.GetInt(varname, (int)val); + else if (typeof(T) == typeof(float)) + val = cnf.GetFloat(varname, (int)val); + else + m_log.WarnFormat("[UTIL]: Unhandled type {0}", typeof(T)); + } + return (T)val; + } + #endregion 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 784a78862f..22cdc8086f 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 { m_Enabled = true; - m_ThisGridURL = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "Messaging"); + m_ThisGridURL = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] {"Startup", "Messaging"}); // Legacy. Remove soon! m_ThisGridURL = config.Configs["Messaging"].GetString("Gatekeeper", m_ThisGridURL); 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 c439ea811f..4f6b92e288 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 IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; if (thisModuleConfig != null) { - m_HomeURI = Util.GetConfigVarWithDefaultSection(source, "HomeURI", "HGInventoryAccessModule"); - m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); - m_ThisGatekeeper = Util.GetConfigVarWithDefaultSection(source, "GatekeeperURI", "HGInventoryAccessModule"); + m_HomeURI = Util.GetConfigVarFromSections(source, "HomeURI", new string[] {"Startup", "HGInventoryAccessModule"}); + m_ThisGatekeeper = Util.GetConfigVarFromSections(source, "GatekeeperURI", new string[] {"Startup", "HGInventoryAccessModule"}); // Legacy. Renove soon! m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", m_ThisGatekeeper); + + m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); } else diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 13d9d31b35..e8bf1943ed 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -113,7 +113,7 @@ namespace OpenSim.Region.DataSnapshot try { m_enabled = config.Configs["DataSnapshot"].GetBoolean("index_sims", m_enabled); - string gatekeeper = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "GridService"); + string gatekeeper = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] {"Startup", "GridService"}); // Legacy. Remove soon! if (string.IsNullOrEmpty(gatekeeper)) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 0334169ab1..d356f8c2c9 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 m_host.AddScriptLPS(1); IConfigSource config = m_ScriptEngine.ConfigSource; - string HomeURI = Util.GetConfigVarWithDefaultSection(config, "HomeURI", string.Empty); + string HomeURI = Util.GetConfigVarFromSections(config, "HomeURI", new string[]{"Startup"}); if (!string.IsNullOrEmpty(HomeURI)) return HomeURI; @@ -2159,7 +2159,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); IConfigSource config = m_ScriptEngine.ConfigSource; - string gatekeeperURI = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", string.Empty); + string gatekeeperURI = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] {"Startup"}); if (!string.IsNullOrEmpty(gatekeeperURI)) return gatekeeperURI; diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 35f86c5acf..d85aab07fe 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -177,7 +177,7 @@ namespace OpenSim.Server.Handlers.Grid map[k] = OSD.FromString(_info[k].ToString()); } - string HomeURI = Util.GetConfigVarWithDefaultSection(m_Config, "HomeURI", string.Empty); + string HomeURI = Util.GetConfigVarFromSections(m_Config, "HomeURI", new string[] {"Startup"}); if (!String.IsNullOrEmpty(HomeURI)) map["home"] = OSD.FromString(HomeURI); diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 3e7c556f46..80575ee4b4 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -128,7 +128,7 @@ namespace OpenSim.Services.GridService m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); - m_ThisGatekeeper = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "GridService"); + m_ThisGatekeeper = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] {"Startup", "GridService"}); // Legacy. Remove soon! m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); try diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 21f363c3a8..c41d95284c 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -96,7 +96,7 @@ namespace OpenSim.Services.HypergridService UUID.TryParse(scope, out m_ScopeID); //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true); - m_ExternalName = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "GatekeeperService"); + m_ExternalName = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] {"Startup", "GatekeeperService"}); m_ExternalName = serverConfig.GetString("ExternalName", m_ExternalName); if (m_ExternalName != string.Empty && !m_ExternalName.EndsWith("/")) m_ExternalName = m_ExternalName + "/"; diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs index a9661f41a8..17e83ccd3b 100644 --- a/OpenSim/Services/HypergridService/HGInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGInventoryService.cs @@ -81,7 +81,7 @@ namespace OpenSim.Services.HypergridService if (m_UserAccountService == null) throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); - m_HomeURL = Util.GetConfigVarWithDefaultSection(config, "HomeURI", m_ConfigName); + m_HomeURL = Util.GetConfigVarFromSections(config, "HomeURI", new string[] {"Startup", m_ConfigName}); m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); } diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index dd546b8e06..776bf0c086 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -96,7 +96,7 @@ namespace OpenSim.Services.HypergridService if (m_AvatarService == null) throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); - m_HomeURL = Util.GetConfigVarWithDefaultSection(config, "HomeURI", m_ConfigName); + m_HomeURL = Util.GetConfigVarFromSections(config, "HomeURI", new string[] {"Startup", m_ConfigName}); // m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); } diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 8757a4ca59..2ab0b87b2f 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -131,7 +131,7 @@ namespace OpenSim.Services.HypergridService LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_TripsAllowedExceptions); LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_TripsDisallowedExceptions); - m_GridName = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "UserAgentService"); + m_GridName = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] {"Startup", "UserAgentService"}); if (string.IsNullOrEmpty(m_GridName)) // Legacy. Remove soon. { m_GridName = serverConfig.GetString("ExternalName", string.Empty); diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 7f32d3058d..0fbd090f49 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -110,7 +110,7 @@ namespace OpenSim.Services.LLLoginService m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true); m_AllowRemoteSetLoginLevel = m_LoginServerConfig.GetBoolean("AllowRemoteSetLoginLevel", false); m_MinLoginLevel = m_LoginServerConfig.GetInt("MinLoginLevel", 0); - m_GatekeeperURL = Util.GetConfigVarWithDefaultSection(config, "GatekeeperURI", "LoginService"); + m_GatekeeperURL = Util.GetConfigVarFromSections(config, "GatekeeperURI", new string[] {"Startup", "LoginService"}); m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty); m_ProfileURL = m_LoginServerConfig.GetString("ProfileServerURL", string.Empty); m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty);