util/xmppstream.lua

Mon, 03 Jan 2011 16:46:45 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 03 Jan 2011 16:46:45 +0000
changeset 3989
692d221ef9bd
parent 3987
8fbf57722368
child 3995
7214dc7a5642
permissions
-rw-r--r--

util.xmppstream: Prepare for using xmllex

1523
841d61be198f Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents: 1414
diff changeset
1 -- Prosody IM
2923
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 2261
diff changeset
2 -- Copyright (C) 2008-2010 Matthew Wild
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 2261
diff changeset
3 -- Copyright (C) 2008-2010 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
2921
f0ddfd7739ea util.xmppstream: new() now returns a parser object
Matthew Wild <mwild1@gmail.com>
parents: 2920
diff changeset
10 local lxp = require "lxp";
3989
692d221ef9bd util.xmppstream: Prepare for using xmllex
Matthew Wild <mwild1@gmail.com>
parents: 3987
diff changeset
11 local lex = require "util.xmllex";
2921
f0ddfd7739ea util.xmppstream: new() now returns a parser object
Matthew Wild <mwild1@gmail.com>
parents: 2920
diff changeset
12 local st = require "util.stanza";
3987
8fbf57722368 util.xmppstream: Optimized stanza building by bypassing the stanza API.
Waqas Hussain <waqas20@gmail.com>
parents: 3927
diff changeset
13 local stanza_mt = st.stanza_mt;
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
14
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
15 local tostring = tostring;
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
16 local t_insert = table.insert;
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
17 local t_concat = table.concat;
3987
8fbf57722368 util.xmppstream: Optimized stanza building by bypassing the stanza API.
Waqas Hussain <waqas20@gmail.com>
parents: 3927
diff changeset
18 local t_remove = table.remove;
8fbf57722368 util.xmppstream: Optimized stanza building by bypassing the stanza API.
Waqas Hussain <waqas20@gmail.com>
parents: 3927
diff changeset
19 local setmetatable = setmetatable;
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
20
3696
a96f275c42b5 util.xmppstream: Fix logger name.
Waqas Hussain <waqas20@gmail.com>
parents: 3638
diff changeset
21 local default_log = require "util.logger".init("xmppstream");
145
fbb3a4ff9cf1 dialback keys now verified
Matthew Wild <mwild1@gmail.com>
parents: 99
diff changeset
22
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
23 local error = error;
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
24
2920
f3335285b20d util.xmppstream: Initial commit
Matthew Wild <mwild1@gmail.com>
parents: 2506
diff changeset
25 module "xmppstream"
1
b8787e859fd2 Switched to new connection framework, courtesy of the luadch project
matthew
parents:
diff changeset
26
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
27 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
28
3989
692d221ef9bd util.xmppstream: Prepare for using xmllex
Matthew Wild <mwild1@gmail.com>
parents: 3987
diff changeset
29 function new(session, stream_callbacks)
692d221ef9bd util.xmppstream: Prepare for using xmllex
Matthew Wild <mwild1@gmail.com>
parents: 3987
diff changeset
30 local partial;
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
31
3989
692d221ef9bd util.xmppstream: Prepare for using xmllex
Matthew Wild <mwild1@gmail.com>
parents: 3987
diff changeset
32 local function feed(stream, data)
692d221ef9bd util.xmppstream: Prepare for using xmllex
Matthew Wild <mwild1@gmail.com>
parents: 3987
diff changeset
33 index(data,
2492
b5e2d1919ec3 xmlhandlers: Fixed indentation and added some semicolons.
Waqas Hussain <waqas20@gmail.com>
parents: 2468
diff changeset
34 end
3032
38459cffaf67 util.xmppstream: Stream objects now just have feed/reset methods
Matthew Wild <mwild1@gmail.com>
parents: 2926
diff changeset
35
38459cffaf67 util.xmppstream: Stream objects now just have feed/reset methods
Matthew Wild <mwild1@gmail.com>
parents: 2926
diff changeset
36 return {
38459cffaf67 util.xmppstream: Stream objects now just have feed/reset methods
Matthew Wild <mwild1@gmail.com>
parents: 2926
diff changeset
37 reset = function ()
38459cffaf67 util.xmppstream: Stream objects now just have feed/reset methods
Matthew Wild <mwild1@gmail.com>
parents: 2926
diff changeset
38 parser = new_parser(handlers, ns_separator);
38459cffaf67 util.xmppstream: Stream objects now just have feed/reset methods
Matthew Wild <mwild1@gmail.com>
parents: 2926
diff changeset
39 parse = parser.parse;
38459cffaf67 util.xmppstream: Stream objects now just have feed/reset methods
Matthew Wild <mwild1@gmail.com>
parents: 2926
diff changeset
40 meta.reset();
38459cffaf67 util.xmppstream: Stream objects now just have feed/reset methods
Matthew Wild <mwild1@gmail.com>
parents: 2926
diff changeset
41 end,
38459cffaf67 util.xmppstream: Stream objects now just have feed/reset methods
Matthew Wild <mwild1@gmail.com>
parents: 2926
diff changeset
42 feed = function (self, data)
38459cffaf67 util.xmppstream: Stream objects now just have feed/reset methods
Matthew Wild <mwild1@gmail.com>
parents: 2926
diff changeset
43 return parse(parser, data);
3424
9e0df614e5d0 util.xmppstream: Add set_session() method to change the session that a stream is associated with
Matthew Wild <mwild1@gmail.com>
parents: 3032
diff changeset
44 end,
9e0df614e5d0 util.xmppstream: Add set_session() method to change the session that a stream is associated with
Matthew Wild <mwild1@gmail.com>
parents: 3032
diff changeset
45 set_session = meta.set_session;
3032
38459cffaf67 util.xmppstream: Stream objects now just have feed/reset methods
Matthew Wild <mwild1@gmail.com>
parents: 2926
diff changeset
46 };
2921
f0ddfd7739ea util.xmppstream: new() now returns a parser object
Matthew Wild <mwild1@gmail.com>
parents: 2920
diff changeset
47 end
f0ddfd7739ea util.xmppstream: new() now returns a parser object
Matthew Wild <mwild1@gmail.com>
parents: 2920
diff changeset
48
2920
f3335285b20d util.xmppstream: Initial commit
Matthew Wild <mwild1@gmail.com>
parents: 2506
diff changeset
49 return _M;

mercurial