diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-10-02 17:14:54 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-10-02 17:14:54 +0500 |
commit | 727cc275bba229332912af42fe0e55524d73efdb (patch) | |
tree | 1698593f49c403ff2d25ee9c6bc7a78be9de44c2 /core | |
parent | 498421b3bac3f259cc2a7b65cea6f7601a974d88 (diff) | |
parent | 271afa36733db02b9cace7261a16b8243505bf33 (diff) | |
download | prosody-727cc275bba229332912af42fe0e55524d73efdb.tar.gz prosody-727cc275bba229332912af42fe0e55524d73efdb.zip |
Merge
Diffstat (limited to 'core')
-rw-r--r-- | core/componentmanager.lua | 11 | ||||
-rw-r--r-- | core/hostmanager.lua | 2 | ||||
-rw-r--r-- | core/modulemanager.lua | 1 |
3 files changed, 9 insertions, 5 deletions
diff --git a/core/componentmanager.lua b/core/componentmanager.lua index 08868236..34f97c25 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; @@ -51,12 +52,14 @@ 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 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 @@ -80,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) @@ -90,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 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 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) |