aboutsummaryrefslogtreecommitdiffstats
path: root/core/componentmanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-09-30 11:06:02 +0100
committerMatthew Wild <mwild1@gmail.com>2009-09-30 11:06:02 +0100
commit3525d3e37048d7fe2444347439d81d1484f0ad1a (patch)
tree611e12d618886f72c74ec6081cc4f3f236319ee4 /core/componentmanager.lua
parentba09a2a2b6a57e733261d98bff261f6f7718084b (diff)
parent271afa36733db02b9cace7261a16b8243505bf33 (diff)
downloadprosody-3525d3e37048d7fe2444347439d81d1484f0ad1a.tar.gz
prosody-3525d3e37048d7fe2444347439d81d1484f0ad1a.zip
Merge with 0.5
Diffstat (limited to 'core/componentmanager.lua')
-rw-r--r--core/componentmanager.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/componentmanager.lua b/core/componentmanager.lua
index 80b3fc58..6984ba31 100644
--- a/core/componentmanager.lua
+++ b/core/componentmanager.lua
@@ -11,6 +11,7 @@ local log = require "util.logger".init("componentmanager");
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 @@ 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
@@ -65,9 +68,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)
@@ -75,7 +78,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