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