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.
11 local helper = require "util.discohelper".new();
13 local jid_split = require "util.jid".split;
14 local jid_bare = require "util.jid".bare;
15 local usermanager_user_exists = require "core.usermanager".user_exists;
16 local rostermanager_is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
20 helper:addDiscoInfoHandler("*host", function(reply, to, from, node)
22 reply:tag("identity", {category="server", type="im", name="Prosody"}):up();
26 helper:addDiscoInfoHandler("*node", function(reply, to, from, node)
27 local node, host = jid_split(to);
28 if hosts[host] and rostermanager_is_contact_subscribed(node, host, jid_bare(from)) then
29 reply:tag("identity", {category="account", type="registered"}):up();
33 helper:addDiscoItemsHandler("*host", function(reply, to, from, node)
34 if hosts[to] and hosts[to].type == "local" then
42 function handle(stanza)
43 return helper:handle(stanza);
46 function addDiscoItemsHandler(jid, func)
47 return helper:addDiscoItemsHandler(jid, func);
50 function addDiscoInfoHandler(jid, func)
51 return helper:addDiscoInfoHandler(jid, func);
54 function set(plugin, var, origin)
55 -- TODO handle origin and host based on plugin.
56 local handler = function(reply, to, from, node) -- service discovery
58 reply:tag("feature", {var = var}):up();
62 addDiscoInfoHandler("*node", handler);
63 addDiscoInfoHandler("*host", handler);