# HG changeset patch # User Matthew Wild # Date 1254305162 -3600 # Node ID 5da0e3b1f8479aaff60b66742dfe0b36c9cea271 # Parent 1842da566c7d6dd16f1cc824d6d56c65a90efc1b# Parent f9b58f37bc143084c58b321418ee6e8a1ce14321 Merge with 0.5 diff -r 1842da566c7d -r 5da0e3b1f847 core/componentmanager.lua --- a/core/componentmanager.lua Tue Sep 29 19:56:23 2009 +0100 +++ b/core/componentmanager.lua Wed Sep 30 11:06:02 2009 +0100 @@ -11,6 +11,7 @@ local configmanager = require "core.configmanager"; local modulemanager = require "core.modulemanager"; 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; @@ -36,12 +37,14 @@ 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 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 @@ -65,9 +68,9 @@ 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) @@ -75,7 +78,7 @@ 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 diff -r 1842da566c7d -r 5da0e3b1f847 core/hostmanager.lua --- a/core/hostmanager.lua Tue Sep 29 19:56:23 2009 +0100 +++ b/core/hostmanager.lua Wed Sep 30 11:06:02 2009 +0100 @@ -24,7 +24,7 @@ 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 diff -r 1842da566c7d -r 5da0e3b1f847 core/modulemanager.lua --- a/core/modulemanager.lua Tue Sep 29 19:56:23 2009 +0100 +++ b/core/modulemanager.lua Wed Sep 30 11:06:02 2009 +0100 @@ -91,6 +91,7 @@ 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)