From 3a70cdac4976bc5ee4cbac96800f8eae18621be1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 30 Sep 2009 11:01:21 +0100 Subject: hostmanager: Only load vhosts, not components --- core/hostmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/hostmanager.lua b/core/hostmanager.lua index ba363273..4934e7b2 100644 --- a/core/hostmanager.lua +++ b/core/hostmanager.lua @@ -24,7 +24,7 @@ local function load_enabled_hosts(config) local defined_hosts = config or configmanager.getconfig(); for host, host_config in pairs(defined_hosts) do - if host ~= "*" and (host_config.core.enabled == nil or host_config.core.enabled) then + if host ~= "*" and (host_config.core.enabled == nil or host_config.core.enabled) and not host_config.core.component_module then activate(host, host_config); end end -- cgit v1.2.3 From 955ff89a519865808714c89025645c225df1637c Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 30 Sep 2009 11:02:31 +0100 Subject: componentmanager: Use create_component for, er, creating components --- core/componentmanager.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/componentmanager.lua b/core/componentmanager.lua index 08868236..a17d4091 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -51,7 +51,8 @@ function load_enabled_components(config) for host, host_config in pairs(defined_hosts) do if host ~= "*" and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then - hosts[host] = { type = "component", host = host, connected = false, s2sout = {}, events = events_new() }; + hosts[host] = create_component(host); + hosts[host].connected = false; components[host] = default_component_handler; local ok, err = modulemanager.load(host, host_config.core.component_module); if not ok then -- cgit v1.2.3 From afe32590a124663f31b680cce0dd3bfc14f34c4b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 30 Sep 2009 11:03:11 +0100 Subject: componentmanager: Fire event on component activation --- core/componentmanager.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core') diff --git a/core/componentmanager.lua b/core/componentmanager.lua index a17d4091..208f42e4 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -14,6 +14,7 @@ local configmanager = require "core.configmanager"; local modulemanager = require "core.modulemanager"; local core_route_stanza = core_route_stanza; local jid_split = require "util.jid".split; +local fire_event = require "core.eventmanager".fire_event; local events_new = require "util.events".new; local st = require "util.stanza"; local hosts = hosts; @@ -58,6 +59,7 @@ function load_enabled_components(config) if not ok then log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err)); else + fire_event("component-activated", host, host_config); log("debug", "Activated %s component: %s", host_config.core.component_module, host); end end -- cgit v1.2.3 From f9a8d01543ed2a8ed49ffcf4e9c3f24565a26bdd Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 30 Sep 2009 11:05:01 +0100 Subject: componentmanager: Preserve existing events table (if any) when registering a component --- core/componentmanager.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/componentmanager.lua b/core/componentmanager.lua index 208f42e4..34f97c25 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -83,9 +83,9 @@ function handle_stanza(origin, stanza) end end -function create_component(host, component) +function create_component(host, component, events) -- TODO check for host well-formedness - return { type = "component", host = host, connected = true, s2sout = {}, events = events_new() }; + return { type = "component", host = host, connected = true, s2sout = {}, events = events or events_new() }; end function register_component(host, component, session) @@ -93,7 +93,7 @@ function register_component(host, component, session) local old_events = hosts[host] and hosts[host].events; components[host] = component; - hosts[host] = session or create_component(host, component); + hosts[host] = session or create_component(host, component, old_events); -- Add events object if not already one if not hosts[host].events then -- cgit v1.2.3 From 271afa36733db02b9cace7261a16b8243505bf33 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 30 Sep 2009 11:05:26 +0100 Subject: modulemanager: Load modules for components, too --- core/modulemanager.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'core') diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 250551ed..a1ed8981 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -96,6 +96,7 @@ function load_modules_for_host(host) end end eventmanager.add_event_hook("host-activated", load_modules_for_host); +eventmanager.add_event_hook("component-activated", load_modules_for_host); -- function load(host, module_name, config) -- cgit v1.2.3