Software /
code /
verse
Annotate
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 |
rev | line source |
---|---|
149
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local xmlns_private = "jabber:iq:private"; |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 function verse.plugins.private(stream) |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 function stream:private_set(name, xmlns, data, callback) |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local iq = verse.iq({ type = "set" }) |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 :tag("query", { xmlns = xmlns_private }) |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 :tag(name, { xmlns = xmlns }); |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 if data then iq:add_child(data); end |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 self:send_iq(iq, function () callback(); end); |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 end |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 function stream:private_get(name, xmlns, callback) |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 self:send_iq(verse.iq({type="get"}) |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 :tag("query", { xmlns = xmlns_private }) |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 :tag(name, { xmlns = xmlns }), |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 function (reply) |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 if reply.attr.type == "result" then |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 local query = reply:get_child("query", xmlns_private); |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 local result = query:get_child(name, xmlns); |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 callback(result); |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 end |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 end); |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 end |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 end |
f5c524412939
plugins.private: Private XML storage support
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 |