Comparison

libs/xstanza.lua @ 6:f8e0ab90d84e

util.xstanza: New library to extend util.stanza with XMPP-specific helpers
author Matthew Wild <mwild1@gmail.com>
date Sat, 28 Nov 2009 22:25:04 +0000
child 15:be4154ed4e3a
comparison
equal deleted inserted replaced
5:93970910d064 6:f8e0ab90d84e
1 local stanza_mt = getmetatable(require "util.stanza".stanza());
2
3 function stanza_mt:error_from_stanza()
4 local type, condition, text;
5
6 local error_tag = self:get_child("error", "urn:ietf:params:xml:ns:xmpp-stanzas");
7 if not error_tag then
8 return nil, nil;
9 end
10 type = error.attr.type;
11
12 for child in error_tag:children() do
13 if child.attr.xmlns == xmlns_stanzas then
14 if child.name == "text" then
15 text = child:get_text();
16 else
17 condition = child.name;
18 end
19 if condition and text then
20 break;
21 end
22 end
23 end
24 return type, condition, text;
25 end