aboutsummaryrefslogtreecommitdiffstats
path: root/core/componentmanager.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-10-02 17:14:54 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-10-02 17:14:54 +0500
commit727cc275bba229332912af42fe0e55524d73efdb (patch)
tree1698593f49c403ff2d25ee9c6bc7a78be9de44c2 /core/componentmanager.lua
parent498421b3bac3f259cc2a7b65cea6f7601a974d88 (diff)
parent271afa36733db02b9cace7261a16b8243505bf33 (diff)
downloadprosody-727cc275bba229332912af42fe0e55524d73efdb.tar.gz
prosody-727cc275bba229332912af42fe0e55524d73efdb.zip
Merge
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 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