Software /
code /
verse
Comparison
plugins/blocking.lua @ 80:336864e83991
verse.plugins.blocking, squishy: New plugin for XEP-0191: Simple Communications Blocking
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 14 Jun 2010 14:12:44 +0100 |
child | 250:a5ac643a7fd6 |
comparison
equal
deleted
inserted
replaced
79:da06d4996992 | 80:336864e83991 |
---|---|
1 local xmlns_blocking = "urn:xmpp:blocking"; | |
2 | |
3 function verse.plugins.blocking(stream) | |
4 -- FIXME: Disco | |
5 stream.blocking = {}; | |
6 function stream.blocking:block_jid(jid, callback) | |
7 stream:send_iq(verse.iq{type="set"} | |
8 :tag("block", { xmlns = xmlns_blocking }) | |
9 :tag("item", { jid = jid }) | |
10 , function () return callback and callback(true); end | |
11 , function () return callback and callback(false); end | |
12 ); | |
13 end | |
14 function stream.blocking:unblock_jid(jid, callback) | |
15 stream:send_iq(verse.iq{type="set"} | |
16 :tag("unblock", { xmlns = xmlns_blocking }) | |
17 :tag("item", { jid = jid }) | |
18 , function () return callback and callback(true); end | |
19 , function () return callback and callback(false); end | |
20 ); | |
21 end | |
22 function stream.blocking:unblock_all_jids(callback) | |
23 stream:send_iq(verse.iq{type="set"} | |
24 :tag("unblock", { xmlns = xmlns_blocking }) | |
25 , function () return callback and callback(true); end | |
26 , function () return callback and callback(false); end | |
27 ); | |
28 end | |
29 function stream.blocking:get_blocked_jids(callback) | |
30 stream:send_iq(verse.iq{type="get"} | |
31 :tag("blocklist", { xmlns = xmlns_blocking }) | |
32 , function (result) | |
33 local list = result:get_child("blocklist", xmlns_blocking); | |
34 if not list then return callback and callback(false); end | |
35 local jids = {}; | |
36 for item in list:childtags() do | |
37 jids[#jids+1] = item.attr.jid; | |
38 end | |
39 return callback and callback(jids); | |
40 end | |
41 , function (result) return callback and callback(false); end | |
42 ); | |
43 end | |
44 end |