aboutsummaryrefslogtreecommitdiffstats
path: root/core/componentmanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-04-08 20:19:55 +0100
committerMatthew Wild <mwild1@gmail.com>2009-04-08 20:19:55 +0100
commitf6a5da2375a21b7cd2429b7ba82d819683af5109 (patch)
tree7148b7e142e79cfc47dcec5f7e22f47a219946b3 /core/componentmanager.lua
parent9982558804de3976a3d5d9e12ab5215503420e0f (diff)
parentedd59b5d381bd8b0daee063a99f8678f86f6b9bb (diff)
downloadprosody-f6a5da2375a21b7cd2429b7ba82d819683af5109.tar.gz
prosody-f6a5da2375a21b7cd2429b7ba82d819683af5109.zip
Automated merge with http://waqas.ath.cx:8000/
Diffstat (limited to 'core/componentmanager.lua')
-rw-r--r--core/componentmanager.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/core/componentmanager.lua b/core/componentmanager.lua
index 0b13c5c5..5efb1f51 100644
--- a/core/componentmanager.lua
+++ b/core/componentmanager.lua
@@ -34,12 +34,18 @@ end);
module "componentmanager"
+local function default_component_handler(origin, stanza)
+ origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable"));
+end
+
+
function load_enabled_components(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) and type(host_config.core.component_module) == "string") then
hosts[host] = { type = "component", host = host, connected = false, s2sout = {} };
+ 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));
@@ -93,7 +99,13 @@ function deregister_component(host)
if components[host] then
modulemanager.unload(host, "dialback");
components[host] = nil;
- hosts[host] = nil;
+ local host_config = defined_hosts[host];
+ if ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then
+ -- Set default handler
+ else
+ -- Component not in config, or disabled, remove
+ hosts[host] = nil;
+ end
-- remove from disco_items
if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then
disco_items:remove(host:sub(host:find(".", 1, true)+1), host);
@@ -105,4 +117,8 @@ function deregister_component(host)
end
end
+function set_component_handler(host, handler)
+ components[host] = handler;
+end
+
return _M;