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