2 -- Copyright (C) 2008 Matthew Wild
3 -- Copyright (C) 2008 Waqas Hussain
5 -- This program is free software; you can redistribute it and/or
6 -- modify it under the terms of the GNU General Public License
7 -- as published by the Free Software Foundation; either version 2
8 -- of the License, or (at your option) any later version.
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 local helper = require "util.discohelper".new();
\r
23 local hosts = hosts;
\r
24 local jid_split = require "util.jid".split;
\r
25 local jid_bare = require "util.jid".bare;
\r
26 local usermanager_user_exists = require "core.usermanager".user_exists;
\r
27 local rostermanager_is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
\r
28 local print = print;
\r
31 helper:addDiscoInfoHandler("*host", function(reply, to, from, node)
\r
33 reply:tag("identity", {category="server", type="im", name="Prosody"}):up();
\r
37 helper:addDiscoInfoHandler("*node", function(reply, to, from, node)
\r
38 local node, host = jid_split(to);
\r
39 if hosts[host] and rostermanager_is_contact_subscribed(node, host, jid_bare(from)) then
\r
40 reply:tag("identity", {category="account", type="registered"}):up();
\r
46 module "discomanager"
\r
48 function handle(stanza)
\r
49 return helper:handle(stanza);
\r
52 function addDiscoItemsHandler(jid, func)
\r
53 return helper:addDiscoItemsHandler(jid, func);
\r
56 function addDiscoInfoHandler(jid, func)
\r
57 return helper:addDiscoInfoHandler(jid, func);
\r
60 function set(plugin, var, origin)
\r
61 -- TODO handle origin and host based on plugin.
\r
62 local handler = function(reply, to, from, node) -- service discovery
\r
64 reply:tag("feature", {var = var}):up();
\r
68 addDiscoInfoHandler("*node", handler);
\r
69 addDiscoInfoHandler("*host", handler);
\r