Annotate

libs/xstanza.lua @ 99:0f5a8d530fcd

verse.plugins.disco: Add disco plugin originally developed by Hubert Chathi for Riddim, but here adapted for Verse with new APIs added to allow disco'ing the local server and remote entities
author Matthew Wild <mwild1@gmail.com>
date Sat, 21 Aug 2010 14:51:36 +0100
parent 15:be4154ed4e3a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
15
be4154ed4e3a util.xstanza: Fix and rename error_from_stanza() -> get_error()
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
3 local xmlns_stanzas = "urn:ietf:params:xml:ns:xmpp-stanzas";
be4154ed4e3a util.xstanza: Fix and rename error_from_stanza() -> get_error()
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
4
be4154ed4e3a util.xstanza: Fix and rename error_from_stanza() -> get_error()
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
5 function stanza_mt:get_error()
6
f8e0ab90d84e util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 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
7
15
be4154ed4e3a util.xstanza: Fix and rename error_from_stanza() -> get_error()
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
8 local error_tag = self:get_child("error");
6
f8e0ab90d84e util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 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
10 return nil, nil;
f8e0ab90d84e util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 end
15
be4154ed4e3a util.xstanza: Fix and rename error_from_stanza() -> get_error()
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
12 type = error_tag.attr.type;
6
f8e0ab90d84e util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13
f8e0ab90d84e util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 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
15 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
16 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
17 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
18 else
f8e0ab90d84e util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 condition = child.name;
f8e0ab90d84e util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 end
f8e0ab90d84e util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 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
22 break;
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 end
f8e0ab90d84e util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 end
f8e0ab90d84e util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 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
27 end