Wed, 05 Jan 2011 03:03:01 +0000
mod_presence: Use get_text() instead of table.concat
-- Prosody IM -- Copyright (C) 2008-2010 Matthew Wild -- Copyright (C) 2008-2010 Waqas Hussain -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. -- local tblinsert = table.insert local lex = require "util.xmllex"; local index = lex.index local tagindex_to_tree = lex.tagindex_to_tree local process_starttag = lex.process_starttag local default_log = require "util.logger".init("xmppstream"); local xmlns_streams = "http://etherx.jabber.org/streams"; local function new(session, stream_callbacks) local partial local openindexes = { } local lastindex = 0 return { reset = function ( ) partial = nil openindexes = { } end ; feed = function ( stream , data ) while true do partial = index ( data , partial ) for i = lastindex + 1 , #partial - 1 do local v = partial [ i ] if v.finish then if v.type == "open" then tblinsert ( openindexes , i ) if #openindexes == 1 then local name , attr = process_starttag ( v ) stream_callbacks.streamopened ( session , attr ) end elseif v.type == "close" then if #openindexes == 2 then -- If closing level 2... local stanza = tagindex_to_tree ( partial , openindexes [ #openindexes ] , i ) stream_callbacks.handlestanza ( session , stanza ) elseif #openindexes == 1 then stream_callbacks.streamclosed ( session ) end --print ( "Closed level " .. #openindexes ) openindexes [ #openindexes ] = nil end end end lastindex = #partial - 1 break end end ; set_session = function ( newsession ) session = newsession end }; end return { new = new ; }