Software /
code /
clix
File
clix/export.lua @ 60:1537dabc5df8
clix.export: Don't add empty iq:private nodes.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 05 May 2011 01:30:06 +0200 |
parent | 55:a3f86df6f359 |
child | 164:fafdcde2e2eb |
line wrap: on
line source
short_opts.i = "interactive"; local split_jid = require "util.jid".split; local timer = require "util.timer"; local xmlns_pie = "urn:xmpp:pie:0"; local xmlns_nodes = { { "query", "jabber:iq:roster" }, { "query", "jabber:iq:privacy" }, { "vCard", "vcard-temp" }, } local xmlns_private = "jabber:iq:private"; local xmlns_private_nodes = { { "storage", "storage:bookmarks" }, } local function on_connect(conn) local export = verse.stanza("server-data", { xmlns = xmlns_pie }) :tag("host", { jid = conn.host }) :tag("user", { name = conn.username, password = conn.password }); local out = 0; for i = 1,#xmlns_nodes do out = out + 1; local node = xmlns_nodes[i]; conn:debug("requesting %s*%s", node[2], node[1]); conn:send_iq(verse.iq{type="get"} :tag(node[1], { xmlns = node[2] }) , function(stanza) conn:debug("got %s*%s", node[2], node[1]); local query = stanza:get_child(node[1], node[2]); if query then export:add_child(query); end out = out - 1; end); end for i = 1,#xmlns_private_nodes do out = out + 1; local node = xmlns_private_nodes[i]; conn:debug("requesting private node %s*%s", node[2], node[1]); conn:send_iq(verse.iq{type="get"} :tag("query", { xmlns = xmlns_private }) :tag(node[1], { xmlns = node[2] }) , function(stanza) conn:debug("got private %s*%s", node[2], node[1]); local query = stanza:get_child("query", xmlns_private); if query and #query > 0 then export:add_child(query); end out = out - 1; end); end timer.add_task(1, function () if out > 0 then return 1 end print("<?xml version='1.0' encoding='UTF-8'?>"); print(export); conn:close(); end) end return function (opts, arg) if opts.short_help then print("Export your account"); return; end if opts.help then return 0; end clix_connect(opts, on_connect); end