plugins/disco.lua

Sat, 21 Aug 2010 14:51:36 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 21 Aug 2010 14:51:36 +0100
changeset 99
0f5a8d530fcd
child 109
60a03b2cabec
permissions
-rw-r--r--

verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities

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 -- NOTE: The b64 routine in LuaSocket 2.0.2 and below
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 -- contains a bug regarding handling \0, it's advisable
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 -- that you use another base64 routine, or a patched
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 -- version of LuaSocket.
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 -- You can borrow Prosody's (binary) util.encodings lib:
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 b64 = require("util.encodings").base64.encode
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
19
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
21 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
22 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
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 function verse.plugins.disco(stream)
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 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
26 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
27 {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
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.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
30 {var = 'http://jabber.org/protocol/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
31 {var = 'http://jabber.org/protocol/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
32 {var = 'http://jabber.org/protocol/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
33 }
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
35 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
36
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
38 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
39
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
41 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
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.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
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 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
47 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
48 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
49 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
50 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
51 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
52 (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
53 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
54 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
55 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
56 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
57
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
59 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
60 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
61
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
63 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
64 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
65 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
66 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
67 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
68 '%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
69 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
70 ) .. '<'
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
72 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
73 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
74 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
75 -- 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
76 --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
77 --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
78 --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
79 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
80 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
81
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
83 __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
84 -- 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
85 -- 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
86 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
87 return st.stanza('c', {
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 xmlns = 'http://jabber.org/protocol/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
89 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
90 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
91 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
92 })
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 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
94 })
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 function stream:add_disco_feature(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
97 table.insert(self.disco.info.features, {var=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
98 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
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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 -- 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
110 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
111 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
112 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
113 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
114 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
115 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
116
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 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
118 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
119 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
120 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
121 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
122 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
123 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
124
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
126 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
127 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
128 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
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
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
132 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
133 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
134 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
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 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
138 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
139
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
141 self:disco_items(self.host, nil, function (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
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
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 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
161
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
163 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
164 :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
165 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
166 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
167 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
168 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
169
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
171
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
173 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
174 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
175 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
176 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
177 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
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
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
182 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
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
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
186 if not self.disco.cache.nodes[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
187 self.disco.cache.nodes[node] = { 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
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195 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
196 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
197 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
198
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
200 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
201 :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
202 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
203 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
204 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
205 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
206 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
207 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
208 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
209 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
210 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
211 jid = tag.attr.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
212 });
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
214 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
215
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
217 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
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
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
221 if not self.disco.cache.nodes[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
222 self.disco.cache.nodes[node] = { 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
223 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
224 self.disco.cache.nodes[node].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
225 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
226 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
227 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
228 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
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 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
231
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 stream:hook("iq/http://jabber.org/protocol/disco#info", function (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
233 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
234 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
235 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
236 -- 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245 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
246 -- 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
247 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
248 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
249 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
250 -- 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
251 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
252 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
253 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
254 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
255 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
256 })
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
257 response:tag('query',{xmlns = 'http://jabber.org/protocol/disco#info'}):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
258 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
259 '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
260 )
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
262 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
263 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
264 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
265 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
266 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
267 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
268 -- 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
269 local result = st.stanza('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
270 xmlns = 'http://jabber.org/protocol/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
271 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
272 })
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
274 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
275 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
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284 }):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
285 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
286 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
287 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
288
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 stream:hook("iq/http://jabber.org/protocol/disco#items", function (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
290 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
291 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
292 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
293 -- 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
294 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
295 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
296 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
297 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
298 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
299 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
300 -- 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
301 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
302 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
303 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
304 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
305 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
306 })
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 response:tag('query',{xmlns = 'http://jabber.org/protocol/disco#items'}):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
308 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
309 '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
310 )
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
312 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
313 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
314 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
315 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
316 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
317 -- 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
318 local result = st.stanza('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
319 xmlns = 'http://jabber.org/protocol/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
320 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
321 })
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
323 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
324 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
325 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
326 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
327 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
328 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
329 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
330 }):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
331 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
332 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
333 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
334
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 stream:hook("ready", function ()
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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: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
337 for _, service in ipairs(services) 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
338 for identity in pairs(stream.disco.cache[service.jid].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
339 local category, type = identity:match("^(.*)/(.*)$");
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 stream:event("disco/service-discovered/"..category, {
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 type = type, jid = 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
342 });
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
344 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
345 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
346 end, 5);
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 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
348
0f5a8d530fcd verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted 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 of disco.lua

mercurial