aboutsummaryrefslogtreecommitdiffstats
path: root/core
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
parentba09a2a2b6a57e733261d98bff261f6f7718084b (diff)
parent271afa36733db02b9cace7261a16b8243505bf33 (diff)
downloadprosody-3525d3e37048d7fe2444347439d81d1484f0ad1a.tar.gz
prosody-3525d3e37048d7fe2444347439d81d1484f0ad1a.zip
Merge with 0.5
Diffstat (limited to 'core')
-rw-r--r--core/componentmanager.lua11
-rw-r--r--core/hostmanager.lua2
-rw-r--r--core/modulemanager.lua1
3 files changed, 9 insertions, 5 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
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 6bc8e285..9b5acffa 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -91,6 +91,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)