libs/xstanza.lua

Sat, 28 Nov 2009 22:25:04 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 28 Nov 2009 22:25:04 +0000
changeset 6
f8e0ab90d84e
child 15
be4154ed4e3a
permissions
-rw-r--r--

util.xstanza: New library to extend util.stanza with XMPP-specific helpers

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

mercurial