aboutsummaryrefslogtreecommitdiffstats
path: root/core/componentmanager.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-03-30 06:07:21 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-03-30 06:07:21 +0500
commit1dce551e58db0d49857d6ace87793259fc0aaeec (patch)
treedcc29bc3d92aac166927cddd8f7ea2603915291d /core/componentmanager.lua
parent2365831f7dfc9f7b3d3ce66ce38c19ad0f2a93e4 (diff)
downloadprosody-1dce551e58db0d49857d6ace87793259fc0aaeec.tar.gz
prosody-1dce551e58db0d49857d6ace87793259fc0aaeec.zip
Added: componentmanager: Automatically add component.host.name to the disco items list of host.name
Diffstat (limited to 'core/componentmanager.lua')
-rw-r--r--core/componentmanager.lua21
1 files changed, 20 insertions, 1 deletions
diff --git a/core/componentmanager.lua b/core/componentmanager.lua
index da079e83..e7b5e4dc 100644
--- a/core/componentmanager.lua
+++ b/core/componentmanager.lua
@@ -20,6 +20,18 @@ local pairs, type, tostring = pairs, type, tostring;
local components = {};
+local disco_items = require "util.multitable".new();
+local NULL = {};
+require "core.discomanager".addDiscoItemsHandler("*host", function(reply, to, from, node)
+ if #node == 0 and hosts[to] then
+ for jid in pairs(disco_items:get(to) or NULL) do
+ reply:tag("item", {jid = jid}):up();
+ end
+ return true;
+ end
+end);
+
+
module "componentmanager"
function load_enabled_components(config)
@@ -64,7 +76,10 @@ function register_component(host, component, session)
if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then
components[host] = component;
hosts[host] = session or create_component(host, component);
-
+ -- add to disco_items
+ if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then
+ disco_items:set(host:sub(host:find(".", 1, true)+1), host, true);
+ end
-- FIXME only load for a.b.c if b.c has dialback, and/or check in config
modulemanager.load(host, "dialback");
log("debug", "component added: "..host);
@@ -79,6 +94,10 @@ function deregister_component(host)
modulemanager.unload(host, "dialback");
components[host] = nil;
hosts[host] = nil;
+ -- 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);
+ end
log("debug", "component removed: "..host);
return true;
else