Software /
code /
verse
Annotate
plugins/disco.lua @ 191:e0664081654c
plugins.presence: Fix priority setting. (Thanks Florob)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 07 Mar 2011 21:53:02 +0100 |
parent | 180:58537eb98506 |
child | 197:7e98cf2c1d8d |
rev | line source |
---|---|
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 -- Verse XMPP Library |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 -- Copyright (C) 2010 Hubert Chathi <hubert@uhoreg.ca> |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 -- Copyright (C) 2010 Matthew Wild <mwild1@gmail.com> |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 -- |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 -- This project is MIT/X11 licensed. Please see the |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 -- COPYING file in the source package for more information. |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 -- |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 local st = require "util.stanza" |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 local b64 = require("mime").b64 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 local sha1 = require("util.sha1").sha1 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 |
175
4d2a5d02fdfa
plugins.disco: Fix missing xmlns variable.
Kim Alvefur <zash@zash.se>
parents:
172
diff
changeset
|
13 local xmlns_caps = "http://jabber.org/protocol/caps"; |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 local xmlns_disco = "http://jabber.org/protocol/disco"; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 local xmlns_disco_info = xmlns_disco.."#info"; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 local xmlns_disco_items = xmlns_disco.."#items"; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 function verse.plugins.disco(stream) |
180
58537eb98506
plugins.disco: Load the presence plugin
Kim Alvefur <zash@zash.se>
parents:
179
diff
changeset
|
19 stream:add_plugin("presence"); |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 stream.disco = { cache = {}, info = {} } |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 stream.disco.info.identities = { |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 {category = 'client', type='pc', name='Verse'}, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 } |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 stream.disco.info.features = { |
176
6004486e8b6c
plugins.disco,compression: Use xmlns_* variables
Kim Alvefur <zash@zash.se>
parents:
175
diff
changeset
|
25 {var = xmlns_caps}, |
6004486e8b6c
plugins.disco,compression: Use xmlns_* variables
Kim Alvefur <zash@zash.se>
parents:
175
diff
changeset
|
26 {var = xmlns_disco_info}, |
6004486e8b6c
plugins.disco,compression: Use xmlns_* variables
Kim Alvefur <zash@zash.se>
parents:
175
diff
changeset
|
27 {var = xmlns_disco_items}, |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 } |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 stream.disco.items = {} |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 stream.disco.nodes = {} |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 stream.caps = {} |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 stream.caps.node = 'http://code.matthewwild.co.uk/verse/' |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 local function cmp_identity(item1, item2) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 if item1.category < item2.category then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 return true; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 elseif item2.category < item1.category then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 return false; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 if item1.type < item2.type then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 return true; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 elseif item2.type < item1.type then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 return false; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 if (not item1['xml:lang'] and item2['xml:lang']) or |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 (item2['xml:lang'] and item1['xml:lang'] < item2['xml:lang']) then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 return true |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 return false |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 local function cmp_feature(item1, item2) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 return item1.var < item2.var |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 local function calculate_hash() |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 table.sort(stream.disco.info.identities, cmp_identity) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 table.sort(stream.disco.info.features, cmp_feature) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 local S = '' |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 for key,identity in pairs(stream.disco.info.identities) do |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 S = S .. string.format( |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 '%s/%s/%s/%s', identity.category, identity.type, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 identity['xml:lang'] or '', identity.name or '' |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 ) .. '<' |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 for key,feature in pairs(stream.disco.info.features) do |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 S = S .. feature.var .. '<' |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 -- FIXME: make sure S is utf8-encoded |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 --stream:debug("Computed hash string: "..S); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 --stream:debug("Computed hash string (sha1): "..sha1(S, true)); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 --stream:debug("Computed hash string (sha1+b64): "..b64(sha1(S))); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 return (b64(sha1(S))) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 setmetatable(stream.caps, { |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 __call = function (...) -- vararg: allow calling as function or member |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 -- retrieve the c stanza to insert into the |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 -- presence stanza |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 local hash = calculate_hash() |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 return st.stanza('c', { |
176
6004486e8b6c
plugins.disco,compression: Use xmlns_* variables
Kim Alvefur <zash@zash.se>
parents:
175
diff
changeset
|
83 xmlns = xmlns_caps, |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 hash = 'sha-1', |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 node = stream.caps.node, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 ver = hash |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 }) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 }) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 function stream:add_disco_feature(feature) |
167
a2ae7a9d360f
plugins.disco: Automatically insert caps into outgoing presence, and re-send last global presence with new caps when features change
Matthew Wild <mwild1@gmail.com>
parents:
146
diff
changeset
|
92 table.insert(self.disco.info.features, {var=feature}); |
179
5e2ff25c1dd9
plugins.disco: Use the new presence plugin for caching and resending
Kim Alvefur <zash@zash.se>
parents:
176
diff
changeset
|
93 stream:resend_presence(); |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 end |
113
769366a8b238
verse.plugins.disco: Add stream:remove_disco_feature()
Matthew Wild <mwild1@gmail.com>
parents:
112
diff
changeset
|
95 |
769366a8b238
verse.plugins.disco: Add stream:remove_disco_feature()
Matthew Wild <mwild1@gmail.com>
parents:
112
diff
changeset
|
96 function stream:remove_disco_feature(feature) |
769366a8b238
verse.plugins.disco: Add stream:remove_disco_feature()
Matthew Wild <mwild1@gmail.com>
parents:
112
diff
changeset
|
97 for idx, disco_feature in ipairs(self.disco.info.features) do |
769366a8b238
verse.plugins.disco: Add stream:remove_disco_feature()
Matthew Wild <mwild1@gmail.com>
parents:
112
diff
changeset
|
98 if disco_feature.var == feature then |
769366a8b238
verse.plugins.disco: Add stream:remove_disco_feature()
Matthew Wild <mwild1@gmail.com>
parents:
112
diff
changeset
|
99 table.remove(self.disco.info.features, idx); |
179
5e2ff25c1dd9
plugins.disco: Use the new presence plugin for caching and resending
Kim Alvefur <zash@zash.se>
parents:
176
diff
changeset
|
100 stream:resend_presence(); |
113
769366a8b238
verse.plugins.disco: Add stream:remove_disco_feature()
Matthew Wild <mwild1@gmail.com>
parents:
112
diff
changeset
|
101 return true; |
769366a8b238
verse.plugins.disco: Add stream:remove_disco_feature()
Matthew Wild <mwild1@gmail.com>
parents:
112
diff
changeset
|
102 end |
769366a8b238
verse.plugins.disco: Add stream:remove_disco_feature()
Matthew Wild <mwild1@gmail.com>
parents:
112
diff
changeset
|
103 end |
769366a8b238
verse.plugins.disco: Add stream:remove_disco_feature()
Matthew Wild <mwild1@gmail.com>
parents:
112
diff
changeset
|
104 end |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 |
115
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
106 function stream:add_disco_item(item, node) |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
107 local disco_items = self.disco.items; |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
108 if node then |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
109 disco_items = self.disco.nodes[node]; |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
110 if not disco_items then |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
111 disco_items = { features = {}, items = {} }; |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
112 self.disco.nodes[node] = disco_items; |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
113 disco_items = disco_items.items; |
119
989cb40f8e62
plugins.disco: Fixes for storing/retrieving items from the disco cache.
Matthew Wild <mwild1@gmail.com>
parents:
115
diff
changeset
|
114 else |
989cb40f8e62
plugins.disco: Fixes for storing/retrieving items from the disco cache.
Matthew Wild <mwild1@gmail.com>
parents:
115
diff
changeset
|
115 disco_items = disco_items.items; |
115
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
116 end |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
117 end |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
118 table.insert(disco_items, item); |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
119 end |
9f8cacfca7c7
verse.plugins.disco: Add stream:add_disco_item()
Matthew Wild <mwild1@gmail.com>
parents:
113
diff
changeset
|
120 |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 function stream:jid_has_identity(jid, category, type) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 local cached_disco = self.disco.cache[jid]; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
123 if not cached_disco then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 return nil, "no-cache"; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
125 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 local identities = self.disco.cache[jid].identities; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 if type then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 return identities[category.."/"..type] or false; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 -- Check whether we have any identities with this category instead |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 for identity in pairs(identities) do |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 if identity:match("^(.*)/") == category then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 return true; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 function stream:jid_supports(jid, feature) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 local cached_disco = self.disco.cache[jid]; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 if not cached_disco or not cached_disco.features then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 return nil, "no-cache"; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 return cached_disco.features[feature] or false; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
146 function stream:get_local_services(category, type) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
147 local host_disco = self.disco.cache[self.host]; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
148 if not(host_disco) or not(host_disco.items) then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
149 return nil, "no-cache"; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
150 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
151 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
152 local results = {}; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
153 for _, service in ipairs(host_disco.items) do |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
154 if self:jid_has_identity(service.jid, category, type) then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
155 table.insert(results, service.jid); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
156 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
157 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
158 return results; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
159 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
160 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
161 function stream:disco_local_services(callback) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
162 self:disco_items(self.host, nil, function (items) |
172
1a32e9ae79d0
plugins.disco: Fix disco_local_services() to call callback with empty array in case of disco error
Matthew Wild <mwild1@gmail.com>
parents:
167
diff
changeset
|
163 if not items then |
1a32e9ae79d0
plugins.disco: Fix disco_local_services() to call callback with empty array in case of disco error
Matthew Wild <mwild1@gmail.com>
parents:
167
diff
changeset
|
164 return callback({}); |
1a32e9ae79d0
plugins.disco: Fix disco_local_services() to call callback with empty array in case of disco error
Matthew Wild <mwild1@gmail.com>
parents:
167
diff
changeset
|
165 end |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
166 local n_items = 0; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
167 local function item_callback() |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
168 n_items = n_items - 1; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
169 if n_items == 0 then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
170 return callback(items); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
171 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
172 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
173 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
174 for _, item in ipairs(items) do |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
175 if item.jid then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
176 n_items = n_items + 1; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
177 self:disco_info(item.jid, nil, item_callback); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
178 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
179 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
180 if n_items == 0 then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
181 return callback(items); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
182 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
183 end); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
184 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
185 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
186 function stream:disco_info(jid, node, callback) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
187 local disco_request = verse.iq({ to = jid, type = "get" }) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
188 :tag("query", { xmlns = xmlns_disco_info, node = node }); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
189 self:send_iq(disco_request, function (result) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
190 if result.attr.type == "error" then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
191 return callback(nil, result:get_error()); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
192 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
193 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
194 local identities, features = {}, {}; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
195 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
196 for tag in result:get_child("query", xmlns_disco_info):childtags() do |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
197 if tag.name == "identity" then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
198 identities[tag.attr.category.."/"..tag.attr.type] = tag.attr.name or true; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
199 elseif tag.name == "feature" then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
200 features[tag.attr.var] = true; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
201 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
202 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
203 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
204 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
205 if not self.disco.cache[jid] then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
206 self.disco.cache[jid] = { nodes = {} }; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
207 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
208 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
209 if node then |
119
989cb40f8e62
plugins.disco: Fixes for storing/retrieving items from the disco cache.
Matthew Wild <mwild1@gmail.com>
parents:
115
diff
changeset
|
210 if not self.disco.cache[jid].nodes[node] then |
989cb40f8e62
plugins.disco: Fixes for storing/retrieving items from the disco cache.
Matthew Wild <mwild1@gmail.com>
parents:
115
diff
changeset
|
211 self.disco.cache[jid].nodes[node] = { nodes = {} }; |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
212 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
213 self.disco.cache[jid].nodes[node].identities = identities; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
214 self.disco.cache[jid].nodes[node].features = features; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
215 else |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
216 self.disco.cache[jid].identities = identities; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
217 self.disco.cache[jid].features = features; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
218 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
219 return callback(self.disco.cache[jid]); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
220 end); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
221 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
222 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
223 function stream:disco_items(jid, node, callback) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
224 local disco_request = verse.iq({ to = jid, type = "get" }) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
225 :tag("query", { xmlns = xmlns_disco_items, node = node }); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
226 self:send_iq(disco_request, function (result) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
227 if result.attr.type == "error" then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
228 return callback(nil, result:get_error()); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
229 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
230 local disco_items = { }; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
231 for tag in result:get_child("query", xmlns_disco_items):childtags() do |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
232 if tag.name == "item" then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
233 table.insert(disco_items, { |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
234 name = tag.attr.name; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
235 jid = tag.attr.jid; |
120
47449a29d8ed
plugins.disco: Store node of disco items
Matthew Wild <mwild1@gmail.com>
parents:
119
diff
changeset
|
236 node = tag.attr.node; |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
237 }); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
238 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
239 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
240 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
241 if not self.disco.cache[jid] then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
242 self.disco.cache[jid] = { nodes = {} }; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
243 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
244 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
245 if node then |
121
9b31ac5a37ea
plugins.disco: Further fixes to storing and retrieving to/from the disco cache
Matthew Wild <mwild1@gmail.com>
parents:
120
diff
changeset
|
246 if not self.disco.cache[jid].nodes[node] then |
9b31ac5a37ea
plugins.disco: Further fixes to storing and retrieving to/from the disco cache
Matthew Wild <mwild1@gmail.com>
parents:
120
diff
changeset
|
247 self.disco.cache[jid].nodes[node] = { nodes = {} }; |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
248 end |
121
9b31ac5a37ea
plugins.disco: Further fixes to storing and retrieving to/from the disco cache
Matthew Wild <mwild1@gmail.com>
parents:
120
diff
changeset
|
249 self.disco.cache[jid].nodes[node].items = disco_items; |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
250 else |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
251 self.disco.cache[jid].items = disco_items; |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
252 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
253 return callback(disco_items); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
254 end); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
255 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
256 |
176
6004486e8b6c
plugins.disco,compression: Use xmlns_* variables
Kim Alvefur <zash@zash.se>
parents:
175
diff
changeset
|
257 stream:hook("iq/"..xmlns_disco_info, function (stanza) |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
258 if stanza.attr.type == 'get' then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
259 local query = stanza:child_with_name('query') |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
260 if not query then return; end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
261 -- figure out what identities/features to send |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
262 local identities |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
263 local features |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
264 if query.attr.node then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
265 local hash = calculate_hash() |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
266 local node = stream.disco.nodes[query.attr.node] |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
267 if node and node.info then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
268 identities = node.info.identities or {} |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
269 features = node.info.identities or {} |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
270 elseif query.attr.node == stream.caps.node..'#'..hash then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
271 -- matches caps hash, so use the main info |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
272 identities = stream.disco.info.identities |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
273 features = stream.disco.info.features |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
274 else |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
275 -- unknown node: give an error |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
276 local response = st.stanza('iq',{ |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
277 to = stanza.attr.from, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
278 from = stanza.attr.to, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
279 id = stanza.attr.id, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
280 type = 'error' |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
281 }) |
176
6004486e8b6c
plugins.disco,compression: Use xmlns_* variables
Kim Alvefur <zash@zash.se>
parents:
175
diff
changeset
|
282 response:tag('query',{xmlns = xmlns_disco_info}):reset() |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
283 response:tag('error',{type = 'cancel'}):tag( |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
284 'item-not-found',{xmlns = 'urn:ietf:params:xml:ns:xmpp-stanzas'} |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
285 ) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
286 stream:send(response) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
287 return true |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
288 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
289 else |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
290 identities = stream.disco.info.identities |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
291 features = stream.disco.info.features |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
292 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
293 -- construct the response |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
294 local result = st.stanza('query',{ |
176
6004486e8b6c
plugins.disco,compression: Use xmlns_* variables
Kim Alvefur <zash@zash.se>
parents:
175
diff
changeset
|
295 xmlns = xmlns_disco_info, |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
296 node = query.attr.node |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
297 }) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
298 for key,identity in pairs(identities) do |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
299 result:tag('identity', identity):reset() |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
300 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
301 for key,feature in pairs(features) do |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
302 result:tag('feature', feature):reset() |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
303 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
304 stream:send(st.stanza('iq',{ |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
305 to = stanza.attr.from, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
306 from = stanza.attr.to, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
307 id = stanza.attr.id, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
308 type = 'result' |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
309 }):add_child(result)) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
310 return true |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
311 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
312 end); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
313 |
176
6004486e8b6c
plugins.disco,compression: Use xmlns_* variables
Kim Alvefur <zash@zash.se>
parents:
175
diff
changeset
|
314 stream:hook("iq/"..xmlns_disco_items, function (stanza) |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
315 if stanza.attr.type == 'get' then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
316 local query = stanza:child_with_name('query') |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
317 if not query then return; end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
318 -- figure out what items to send |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
319 local items |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
320 if query.attr.node then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
321 local node = stream.disco.nodes[query.attr.node] |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
322 if node then |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
323 items = node.items or {} |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
324 else |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
325 -- unknown node: give an error |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
326 local response = st.stanza('iq',{ |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
327 to = stanza.attr.from, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
328 from = stanza.attr.to, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
329 id = stanza.attr.id, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
330 type = 'error' |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
331 }) |
176
6004486e8b6c
plugins.disco,compression: Use xmlns_* variables
Kim Alvefur <zash@zash.se>
parents:
175
diff
changeset
|
332 response:tag('query',{xmlns = xmlns_disco_items}):reset() |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
333 response:tag('error',{type = 'cancel'}):tag( |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
334 'item-not-found',{xmlns = 'urn:ietf:params:xml:ns:xmpp-stanzas'} |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
335 ) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
336 stream:send(response) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
337 return true |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
338 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
339 else |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
340 items = stream.disco.items |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
341 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
342 -- construct the response |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
343 local result = st.stanza('query',{ |
176
6004486e8b6c
plugins.disco,compression: Use xmlns_* variables
Kim Alvefur <zash@zash.se>
parents:
175
diff
changeset
|
344 xmlns = xmlns_disco_items, |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
345 node = query.attr.node |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
346 }) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
347 for key,item in pairs(items) do |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
348 result:tag('item', item):reset() |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
349 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
350 stream:send(st.stanza('iq',{ |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
351 to = stanza.attr.from, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
352 from = stanza.attr.to, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
353 id = stanza.attr.id, |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
354 type = 'result' |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
355 }):add_child(result)) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
356 return true |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
357 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
358 end); |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
359 |
109
60a03b2cabec
verse.plugins.disco: Auto-disco local services on connect, and delay 'ready' event until done
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
360 local initial_disco_started; |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
361 stream:hook("ready", function () |
109
60a03b2cabec
verse.plugins.disco: Auto-disco local services on connect, and delay 'ready' event until done
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
362 if initial_disco_started then return; end |
60a03b2cabec
verse.plugins.disco: Auto-disco local services on connect, and delay 'ready' event until done
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
363 initial_disco_started = true; |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
364 stream:disco_local_services(function (services) |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
365 for _, service in ipairs(services) do |
146
2678048e93e6
plugins.disco: Fix traceback when disco#info isn't returned for a service in disco#items
Matthew Wild <mwild1@gmail.com>
parents:
121
diff
changeset
|
366 local service_disco_info = stream.disco.cache[service.jid]; |
2678048e93e6
plugins.disco: Fix traceback when disco#info isn't returned for a service in disco#items
Matthew Wild <mwild1@gmail.com>
parents:
121
diff
changeset
|
367 if service_disco_info then |
2678048e93e6
plugins.disco: Fix traceback when disco#info isn't returned for a service in disco#items
Matthew Wild <mwild1@gmail.com>
parents:
121
diff
changeset
|
368 for identity in pairs(service_disco_info.identities) do |
2678048e93e6
plugins.disco: Fix traceback when disco#info isn't returned for a service in disco#items
Matthew Wild <mwild1@gmail.com>
parents:
121
diff
changeset
|
369 local category, type = identity:match("^(.*)/(.*)$"); |
2678048e93e6
plugins.disco: Fix traceback when disco#info isn't returned for a service in disco#items
Matthew Wild <mwild1@gmail.com>
parents:
121
diff
changeset
|
370 stream:event("disco/service-discovered/"..category, { |
2678048e93e6
plugins.disco: Fix traceback when disco#info isn't returned for a service in disco#items
Matthew Wild <mwild1@gmail.com>
parents:
121
diff
changeset
|
371 type = type, jid = service.jid; |
2678048e93e6
plugins.disco: Fix traceback when disco#info isn't returned for a service in disco#items
Matthew Wild <mwild1@gmail.com>
parents:
121
diff
changeset
|
372 }); |
2678048e93e6
plugins.disco: Fix traceback when disco#info isn't returned for a service in disco#items
Matthew Wild <mwild1@gmail.com>
parents:
121
diff
changeset
|
373 end |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
374 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
375 end |
109
60a03b2cabec
verse.plugins.disco: Auto-disco local services on connect, and delay 'ready' event until done
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
376 stream:event("ready"); |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
377 end); |
109
60a03b2cabec
verse.plugins.disco: Auto-disco local services on connect, and delay 'ready' event until done
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
378 return true; |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
379 end, 5); |
167
a2ae7a9d360f
plugins.disco: Automatically insert caps into outgoing presence, and re-send last global presence with new caps when features change
Matthew Wild <mwild1@gmail.com>
parents:
146
diff
changeset
|
380 |
a2ae7a9d360f
plugins.disco: Automatically insert caps into outgoing presence, and re-send last global presence with new caps when features change
Matthew Wild <mwild1@gmail.com>
parents:
146
diff
changeset
|
381 stream:hook("presence-out", function (presence) |
a2ae7a9d360f
plugins.disco: Automatically insert caps into outgoing presence, and re-send last global presence with new caps when features change
Matthew Wild <mwild1@gmail.com>
parents:
146
diff
changeset
|
382 if not presence:get_child("c", xmlns_caps) then |
a2ae7a9d360f
plugins.disco: Automatically insert caps into outgoing presence, and re-send last global presence with new caps when features change
Matthew Wild <mwild1@gmail.com>
parents:
146
diff
changeset
|
383 presence:reset():add_child(stream:caps()):reset(); |
a2ae7a9d360f
plugins.disco: Automatically insert caps into outgoing presence, and re-send last global presence with new caps when features change
Matthew Wild <mwild1@gmail.com>
parents:
146
diff
changeset
|
384 end |
179
5e2ff25c1dd9
plugins.disco: Use the new presence plugin for caching and resending
Kim Alvefur <zash@zash.se>
parents:
176
diff
changeset
|
385 end, 10); |
99
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
386 end |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
387 |
0f5a8d530fcd
verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
388 -- end of disco.lua |