Software /
code /
prosody
Changeset
1853:5da0e3b1f847
Merge with 0.5
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 30 Sep 2009 11:06:02 +0100 |
parents | 1847:1842da566c7d (current diff) 1852:f9b58f37bc14 (diff) |
children | 1861:e9500c4994f3 |
files | core/componentmanager.lua core/modulemanager.lua |
diffstat | 3 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- 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)