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 discomanager_handle = require "core.discomanager".handle;
10 local componentmanager_get_children = require "core.componentmanager".get_children;
12 module:add_feature("http://jabber.org/protocol/disco#info");
13 module:add_feature("http://jabber.org/protocol/disco#items");
15 module:add_identity("server", "im", "Prosody");
16 local st = require "util.stanza"
17 module:hook("iq/host/http://jabber.org/protocol/disco#info:query", function(event)
18 local origin, stanza = event.origin, event.stanza;
19 if stanza.attr.type ~= "get" then return; end
20 local node = stanza.tags[1].attr.node;
21 if node and node ~= "" then return; end -- TODO fire event?
23 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#info");
25 for _,identity in ipairs(module:get_host_items("identity")) do
26 local identity_s = identity.category.."\0"..identity.type;
27 if not done[identity_s] then
28 reply:tag("identity", identity):up();
29 done[identity_s] = true;
32 for _,feature in ipairs(module:get_host_items("feature")) do
33 if not done[feature] then
34 reply:tag("feature", {var=feature}):up();
41 module:hook("iq/host/http://jabber.org/protocol/disco#items:query", function(event)
42 local origin, stanza = event.origin, event.stanza;
43 if stanza.attr.type ~= "get" then return; end
44 local node = stanza.tags[1].attr.node;
45 if node and node ~= "" then return; end -- TODO fire event?
47 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items");
48 for jid in pairs(componentmanager_get_children(module.host)) do
49 reply:tag("item", {jid = jid}):up();