aboutsummaryrefslogtreecommitdiffstats
path: root/core/xmlhandlers.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-11-18 17:52:33 +0000
committerMatthew Wild <mwild1@gmail.com>2008-11-18 17:52:33 +0000
commit01c770997f61259d6e5b8ae5018aab1ef6ac0ef8 (patch)
treee58078b7e8fe4e6d58e6fdfb0be12fcea875ee29 /core/xmlhandlers.lua
parentf4e09200420e410c608ef9b841a0669b5c0d88a9 (diff)
downloadprosody-01c770997f61259d6e5b8ae5018aab1ef6ac0ef8.tar.gz
prosody-01c770997f61259d6e5b8ae5018aab1ef6ac0ef8.zip
Quite some changes, to:
- Small logging fix for s2smanager - Send a stream error if an incoming s2s connection is to an unrecognised hostname (fixes #11) - init_xmlhandlers now takes a table of callbacks (includes changes to net/xmpp*_listener for this) - Move sending of unavailable presence to where it should be, sessionmanager.destroy_session - Fix sending of stream errors to wrong connection
Diffstat (limited to 'core/xmlhandlers.lua')
-rw-r--r--core/xmlhandlers.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua
index 3037a848..09139904 100644
--- a/core/xmlhandlers.lua
+++ b/core/xmlhandlers.lua
@@ -25,7 +25,7 @@ local ns_prefixes = {
["http://www.w3.org/XML/1998/namespace"] = "xml";
}
-function init_xmlhandlers(session, streamopened)
+function init_xmlhandlers(session, stream_callbacks)
local ns_stack = { "" };
local curr_ns = "";
local curr_tag;
@@ -36,6 +36,9 @@ function init_xmlhandlers(session, streamopened)
local send = session.send;
+ local cb_streamopened = stream_callbacks.streamopened;
+ local cb_streamclosed = stream_callbacks.streamclosed;
+
local stanza
function xml_handlers:StartElement(name, attr)
if stanza and #chardata > 0 then
@@ -65,8 +68,9 @@ function init_xmlhandlers(session, streamopened)
if not stanza then --if we are not currently inside a stanza
if session.notopen then
- if name == "stream" then
- streamopened(session, attr);
+ print("client opening with "..tostring(name));
+ if name == "stream" and cb_streamopened then
+ cb_streamopened(session, attr);
return;
end
error("Client failed to open stream successfully");
@@ -75,7 +79,7 @@ function init_xmlhandlers(session, streamopened)
error("Client sent invalid top-level stanza");
end
- stanza = st.stanza(name, attr); --{ to = attr.to, type = attr.type, id = attr.id, xmlns = curr_ns });
+ stanza = st.stanza(name, attr);
curr_tag = stanza;
else -- we are inside a stanza, so add a tag
attr.xmlns = nil;
@@ -93,9 +97,9 @@ function init_xmlhandlers(session, streamopened)
function xml_handlers:EndElement(name)
curr_ns,name = name:match("^(.+)|([%w%-]+)$");
if (not stanza) or #stanza.last_add < 0 or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then
- if name == "stream" then
+ if name == "stream" and cb_streamclosed then
log("debug", "Stream closed");
- sm_destroy_session(session);
+ cb_streamclosed(session);
return;
elseif name == "error" then
error("Stream error: "..tostring(name)..": "..tostring(stanza));