Annotate

core/discomanager.lua @ 388:9f520efc89ba

Added discomanager
author Waqas Hussain <waqas20@gmail.com>
date Sun, 23 Nov 2008 03:32:34 +0500
child 393:885a1864cd97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
388
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2 local helper = require "util.discohelper".new();
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3 local hosts = hosts;
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
4 local jid_split = require "util.jid".split;
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
5 local jid_bare = require "util.jid".bare;
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
6 local usermanager_user_exists = require "core.usermanager".user_exists;
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7 local rostermanager_is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
8
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
9 do
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10 helper:addDiscoInfoHandler("*host", function(reply, to, from, node)
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
11 if hosts[to] then
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
12 reply:tag("identity", {category="server", type="im", name="ejabberd"}):up();
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
13 return true;
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
14 end
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15 end);
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 helper:addDiscoInfoHandler("*node", function(reply, to, from, node)
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
17 local node, host = jid_split(to);
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18 if hosts[host] and rostermanager_is_contact_subscribed(node, host, jid_bare(from)) then
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19 reply:tag("identity", {category="account", type="registered"}):up();
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
20 return true;
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
21 end
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
22 end);
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23 end
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
24
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
25 module "discomanager"
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
26
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
27 function handle(stanza)
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
28 return helper:handle(stanza);
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
29 end
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
30
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
31 function addDiscoItemsHandler(jid, func)
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
32 return helper:addDiscoItemsHandler(jid, func);
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
33 end
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
34
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
35 function addDiscoInfoHandler(jid, func)
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
36 return helper:addDiscoInfoHandler(jid, func);
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
37 end
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
38
9f520efc89ba Added discomanager
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
39 return _M;