Annotate

core/xmlhandlers.lua @ 2493:ec09d16a51e1

xmlhandlers: Rearranged a little code.
author Waqas Hussain <waqas20@gmail.com>
date Sat, 23 Jan 2010 18:41:20 +0500
parent 2492:b5e2d1919ec3
child 2505:0849e349992d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1523
841d61be198f Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents: 1414
diff changeset
1 -- Prosody IM
760
90ce865eebd8 Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents: 759
diff changeset
2 -- Copyright (C) 2008-2009 Matthew Wild
90ce865eebd8 Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents: 759
diff changeset
3 -- Copyright (C) 2008-2009 Waqas Hussain
519
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 355
diff changeset
4 --
758
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 625
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 625
diff changeset
6 -- COPYING file in the source package for more information.
519
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 355
diff changeset
7 --
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 355
diff changeset
8
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 355
diff changeset
9
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
10
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
11 require "util.stanza"
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
12
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
13 local st = stanza;
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
14 local tostring = tostring;
148
4c0dcd245d34 s2s works! \o/ \o/
Matthew Wild <mwild1@gmail.com>
parents: 146
diff changeset
15 local pairs = pairs;
4c0dcd245d34 s2s works! \o/ \o/
Matthew Wild <mwild1@gmail.com>
parents: 146
diff changeset
16 local ipairs = ipairs;
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
17 local t_insert = table.insert;
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
18 local t_concat = table.concat;
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
19
145
fbb3a4ff9cf1 dialback keys now verified
Matthew Wild <mwild1@gmail.com>
parents: 99
diff changeset
20 local default_log = require "util.logger".init("xmlhandlers");
fbb3a4ff9cf1 dialback keys now verified
Matthew Wild <mwild1@gmail.com>
parents: 99
diff changeset
21
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
22 local error = error;
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
23
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
24 module "xmlhandlers"
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
25
148
4c0dcd245d34 s2s works! \o/ \o/
Matthew Wild <mwild1@gmail.com>
parents: 146
diff changeset
26 local ns_prefixes = {
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
27 ["http://www.w3.org/XML/1998/namespace"] = "xml";
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
28 };
2464
0b5f0ae7a6b1 xmlhandlers: More refactoring, split up stream_ns and stream_tag, add stream_error_tag so that callers don't need to be so worried about the separator we use
Matthew Wild <mwild1@gmail.com>
parents: 2463
diff changeset
29
0b5f0ae7a6b1 xmlhandlers: More refactoring, split up stream_ns and stream_tag, add stream_error_tag so that callers don't need to be so worried about the separator we use
Matthew Wild <mwild1@gmail.com>
parents: 2463
diff changeset
30 local xmlns_streams = "http://etherx.jabber.org/streams";
0b5f0ae7a6b1 xmlhandlers: More refactoring, split up stream_ns and stream_tag, add stream_error_tag so that callers don't need to be so worried about the separator we use
Matthew Wild <mwild1@gmail.com>
parents: 2463
diff changeset
31
2463
d9ff0190eb4a xmlhandlers: Define ns_separator and ns_pattern to save repeating it in literal form throughout the file
Matthew Wild <mwild1@gmail.com>
parents: 2261
diff changeset
32 local ns_separator = "\1";
d9ff0190eb4a xmlhandlers: Define ns_separator and ns_pattern to save repeating it in literal form throughout the file
Matthew Wild <mwild1@gmail.com>
parents: 2261
diff changeset
33 local ns_pattern = "^([^"..ns_separator.."]*)"..ns_separator.."?(.*)$";
148
4c0dcd245d34 s2s works! \o/ \o/
Matthew Wild <mwild1@gmail.com>
parents: 146
diff changeset
34
331
830fd67f9378 Quite some changes, to:
Matthew Wild <mwild1@gmail.com>
parents: 166
diff changeset
35 function init_xmlhandlers(session, stream_callbacks)
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
36 local ns_stack = { "" };
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
37 local curr_tag;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
38 local chardata = {};
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
39 local xml_handlers = {};
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
40 local log = session.log or default_log;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
41
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
42 local cb_streamopened = stream_callbacks.streamopened;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
43 local cb_streamclosed = stream_callbacks.streamclosed;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
44 local cb_error = stream_callbacks.error or function(session, e) error("XML stream error: "..tostring(e)); end;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
45 local cb_handlestanza = stream_callbacks.handlestanza;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
46
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
47 local stream_ns = stream_callbacks.stream_ns or xmlns_streams;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
48 local stream_tag = stream_ns..ns_separator..(stream_callbacks.stream_tag or "stream");
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
49 local stream_error_tag = stream_ns..ns_separator..(stream_callbacks.error_tag or "error");
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
50
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
51 local stream_default_ns = stream_callbacks.default_ns;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
52
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
53 local stanza;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
54 function xml_handlers:StartElement(tagname, attr)
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
55 if stanza and #chardata > 0 then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
56 -- We have some character data in the buffer
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
57 stanza:text(t_concat(chardata));
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
58 chardata = {};
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
59 end
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
60 local curr_ns,name = tagname:match(ns_pattern);
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
61 if name == "" then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
62 curr_ns, name = "", curr_ns;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
63 end
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
64
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
65 if curr_ns ~= stream_default_ns then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
66 attr.xmlns = curr_ns;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
67 end
2464
0b5f0ae7a6b1 xmlhandlers: More refactoring, split up stream_ns and stream_tag, add stream_error_tag so that callers don't need to be so worried about the separator we use
Matthew Wild <mwild1@gmail.com>
parents: 2463
diff changeset
68
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
69 -- FIXME !!!!!
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
70 for i=1,#attr do
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
71 local k = attr[i];
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
72 attr[i] = nil;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
73 local ns, nm = k:match(ns_pattern);
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
74 if nm ~= "" then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
75 ns = ns_prefixes[ns];
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
76 if ns then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
77 attr[ns..":"..nm] = attr[k];
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
78 attr[k] = nil;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
79 end
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
80 end
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
81 end
557
c9b3ffb08fe3 Disconnect with stream errors on bad XML, or invalid stream namespace
Matthew Wild <mwild1@gmail.com>
parents: 545
diff changeset
82
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
83 if not stanza then --if we are not currently inside a stanza
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
84 if session.notopen then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
85 if tagname == stream_tag then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
86 if cb_streamopened then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
87 cb_streamopened(session, attr);
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
88 end
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
89 else
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
90 -- Garbage before stream?
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
91 cb_error(session, "no-stream");
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
92 end
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
93 return;
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
94 end
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
95 if curr_ns == "jabber:client" and name ~= "iq" and name ~= "presence" and name ~= "message" then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
96 cb_error(session, "invalid-top-level-element");
1051
0327c569eb1a xmlhandlers: Fix tag pattern again for the default namespace
Matthew Wild <mwild1@gmail.com>
parents: 1003
diff changeset
97 end
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
98
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
99 stanza = st.stanza(name, attr);
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
100 curr_tag = stanza;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
101 else -- we are inside a stanza, so add a tag
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
102 attr.xmlns = nil;
899
b95368f199a1 core.xmlhandlers: Filter out default stream namespace from stanzas
Matthew Wild <mwild1@gmail.com>
parents: 896
diff changeset
103 if curr_ns ~= stream_default_ns then
148
4c0dcd245d34 s2s works! \o/ \o/
Matthew Wild <mwild1@gmail.com>
parents: 146
diff changeset
104 attr.xmlns = curr_ns;
4c0dcd245d34 s2s works! \o/ \o/
Matthew Wild <mwild1@gmail.com>
parents: 146
diff changeset
105 end
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
106 stanza:tag(name, attr);
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
107 end
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
108 end
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
109 function xml_handlers:CharacterData(data)
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
110 if stanza then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
111 t_insert(chardata, data);
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
112 end
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
113 end
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
114 function xml_handlers:EndElement(tagname)
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
115 local curr_ns,name = tagname:match(ns_pattern);
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
116 if name == "" then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
117 curr_ns, name = "", curr_ns;
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
118 end
2493
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
119 if stanza then
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
120 if #chardata > 0 then
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
121 -- We have some character data in the buffer
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
122 stanza:text(t_concat(chardata));
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
123 chardata = {};
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
124 end
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
125 -- Complete stanza
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
126 if #stanza.last_add == 0 then
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
127 if tagname ~= stream_error_tag then
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
128 cb_handlestanza(session, stanza);
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
129 else
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
130 cb_error(session, "stream-error", stanza);
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
131 end
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
132 stanza = nil;
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
133 else
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
134 stanza:up();
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
135 end
ec09d16a51e1 xmlhandlers: Rearranged a little code.
Waqas Hussain <waqas20@gmail.com>
parents: 2492
diff changeset
136 else
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
137 if tagname == stream_tag then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
138 if cb_streamclosed then
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
139 cb_streamclosed(session);
148
4c0dcd245d34 s2s works! \o/ \o/
Matthew Wild <mwild1@gmail.com>
parents: 146
diff changeset
140 end
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
141 else
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
142 cb_error(session, "parse-error", "unexpected-element-close", name);
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
143 end
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
144 stanza, chardata = nil, {};
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
145 end
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
146 end
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
147 return xml_handlers;
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
148 end
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
149
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
150 return init_xmlhandlers;