Changeset

1504:9d8c35e98ca2

configmanager, modulemanager: Allow components to have modules specified in the config (but don't load the global set of modules for them)
author Matthew Wild <mwild1@gmail.com>
date Thu, 09 Jul 2009 14:34:49 +0100
parents 1503:5970e06d9335
children 1505:e19cb945c25b
files core/configmanager.lua core/modulemanager.lua
diffstat 2 files changed, 21 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/core/configmanager.lua	Thu Jul 09 04:37:08 2009 +0100
+++ b/core/configmanager.lua	Thu Jul 09 14:34:49 2009 +0100
@@ -123,7 +123,7 @@
 		function env.Component(name)
 			set(name, "core", "component_module", "component");
 			-- Don't load the global modules by default
-			set(name, "core", "modules_enable", false);
+			set(name, "core", "load_global_modules", false);
 			rawset(env, "__currenthost", name);
 	
 			return function (module)
--- a/core/modulemanager.lua	Thu Jul 09 04:37:08 2009 +0100
+++ b/core/modulemanager.lua	Thu Jul 09 14:34:49 2009 +0100
@@ -59,35 +59,33 @@
 
 -- Load modules when a host is activated
 function load_modules_for_host(host)
-	if config.get(host, "core", "modules_enable") == false then
-		return; -- Only load for hosts, not components, etc.
-	end
-
-	-- Load modules from global section
-	local modules_enabled = config.get("*", "core", "modules_enabled");
-	local modules_disabled = config.get(host, "core", "modules_disabled");
-	local disabled_set = {};
-	if modules_enabled then
-		if modules_disabled then
-			for _, module in ipairs(modules_disabled) do
-				disabled_set[module] = true;
+	if config.get(host, "core", "load_global_modules") ~= false then
+		-- Load modules from global section
+		local modules_enabled = config.get("*", "core", "modules_enabled");
+		local modules_disabled = config.get(host, "core", "modules_disabled");
+		local disabled_set = {};
+		if modules_enabled then
+			if modules_disabled then
+				for _, module in ipairs(modules_disabled) do
+					disabled_set[module] = true;
+				end
 			end
-		end
-		for _, module in ipairs({"presence", "message", "iq"}) do
-			if not disabled_set[module] then
-				load(host, module);
+			for _, module in ipairs({"presence", "message", "iq"}) do
+				if not disabled_set[module] then
+					load(host, module);
+				end
 			end
-		end
-		for _, module in ipairs(modules_enabled) do
-			if not disabled_set[module] and not is_loaded(host, module) then
-				load(host, module);
+			for _, module in ipairs(modules_enabled) do
+				if not disabled_set[module] and not is_loaded(host, module) then
+					load(host, module);
+				end
 			end
 		end
 	end
-
+	
 	-- Load modules from just this host
 	local modules_enabled = config.get(host, "core", "modules_enabled");
-	if modules_enabled then
+	if modules_enabled and modules_enabled ~= config.get("*", "core", "modules_enabled") then
 		for _, module in pairs(modules_enabled) do
 			if not is_loaded(host, module) then
 				load(host, module);