2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
9 local componentmanager_get_children = require "core.componentmanager".get_children;
10 local st = require "util.stanza"
12 module:add_identity("server", "im", "Prosody"); -- FIXME should be in the non-existing mod_router
13 module:add_feature("http://jabber.org/protocol/disco#info");
14 module:add_feature("http://jabber.org/protocol/disco#items");
16 module:hook("iq/host/http://jabber.org/protocol/disco#info:query", function(event)
17 local origin, stanza = event.origin, event.stanza;
18 if stanza.attr.type ~= "get" then return; end
19 local node = stanza.tags[1].attr.node;
20 if node and node ~= "" then return; end -- TODO fire event?
22 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#info");
24 for _,identity in ipairs(module:get_host_items("identity")) do
25 local identity_s = identity.category.."\0"..identity.type;
26 if not done[identity_s] then
27 reply:tag("identity", identity):up();
28 done[identity_s] = true;
31 for _,feature in ipairs(module:get_host_items("feature")) do
32 if not done[feature] then
33 reply:tag("feature", {var=feature}):up();
40 module:hook("iq/host/http://jabber.org/protocol/disco#items:query", function(event)
41 local origin, stanza = event.origin, event.stanza;
42 if stanza.attr.type ~= "get" then return; end
43 local node = stanza.tags[1].attr.node;
44 if node and node ~= "" then return; end -- TODO fire event?
46 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items");
47 for jid in pairs(componentmanager_get_children(module.host)) do
48 reply:tag("item", {jid = jid}):up();