Software /
code /
verse
Comparison
plugins/private.lua @ 149:f5c524412939
plugins.private: Private XML storage support
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 28 Oct 2010 19:37:22 +0100 |
child | 155:9c9af7a196ed |
comparison
equal
deleted
inserted
replaced
148:386920f05808 | 149:f5c524412939 |
---|---|
1 local xmlns_private = "jabber:iq:private"; | |
2 | |
3 function verse.plugins.private(stream) | |
4 function stream:private_set(name, xmlns, data, callback) | |
5 local iq = verse.iq({ type = "set" }) | |
6 :tag("query", { xmlns = xmlns_private }) | |
7 :tag(name, { xmlns = xmlns }); | |
8 if data then iq:add_child(data); end | |
9 self:send_iq(iq, function () callback(); end); | |
10 end | |
11 | |
12 function stream:private_get(name, xmlns, callback) | |
13 self:send_iq(verse.iq({type="get"}) | |
14 :tag("query", { xmlns = xmlns_private }) | |
15 :tag(name, { xmlns = xmlns }), | |
16 function (reply) | |
17 if reply.attr.type == "result" then | |
18 local query = reply:get_child("query", xmlns_private); | |
19 local result = query:get_child(name, xmlns); | |
20 callback(result); | |
21 end | |
22 end); | |
23 end | |
24 end | |
25 |