diff -r ab4470465a0c -r 6effa1929af7 lm.lua --- a/lm.lua Sun Apr 05 14:55:51 2009 +0300 +++ b/lm.lua Sun Apr 05 16:55:48 2009 +0300 @@ -153,83 +153,9 @@ end end ---[=[ --- recursively fills a node, see lm.message.create -function lm.message_node.fill ( n, a ) - for name, value in pairs ( a ) do - if type ( value ) == "table" then - if type ( value[1] ) == "table" then - for index, instance in ipairs ( value ) do - lm.message_node.fill ( n:child ( name, "" ), instance ) - end - else - lm.message_node.fill ( n:child ( name, "" ), value ) - end - elseif name == 1 then - n:value ( value ) - else - n:attribute ( name, value ) - end - end -end ---[[ --- recursively fills a message -lm.message.create { mtype = 'iq-result', to = 'foo@bar.xyz', - command = { xmlns = 'http://jabber.org/protocol/commands', node = 'http://jabber.org/protocol/rc#set-status', status = 'executing', sessionid = 'set-status:aaa3', - x = { xmlns = 'jabber:x:data', type = 'form', - title = { "Change Status" }, - instructions = { "Choose the status and status message" }, - field = {{ type = 'hidden', var = 'FORM_TYPE', - value = { "http://jabber.org/protocol/rc" }, - },{ type = 'list-single', label = 'Status', var = 'status', - required = { }, - value = { "online" }, - option = {{ label = 'Chat', - value = { "chat" }, - },{ label = 'Online', - value = { "online" }, - },{ label = 'Away', - value = { "away" }, - },{ label = 'Extended Away', - value = { "xa" }, - },{ label = 'Do Not Disturb', - value = { "dnd" }, - },{ label = 'Invisible', - value = { "invisible" }, - },{ label = 'Offline', - value = { "offline" }, - }}, - },{ type = 'text-single', label = 'Priority', var = 'status-priority', - value = { "5" }, - },{ type = 'text-multi', label = 'Message', var = 'status-message' }}, - }, - }, -} ---]] -function lm.message.create ( a ) - if type ( a ) ~= "table" then - error "table expected as argument" - end - if not a.mtype then - error "you must specify message type" - end - local mtype, subtype = a.mtype:match ( "(.-)%-(.+)" ) - local m - if not mtype then - m = lm.message.new ( a.to, a.mtype ) - else - m = lm.message.new ( a.to, mtype, subtype ) - end - a.to = nil - a.mtype = nil - lm.message_node.fill ( m, a ) - return m -end ---]=] - -- TODO: multiple nodes with same name function lm.message_node.parse ( node, r ) - local n = node:children () + local n = node:child () while n do local name = n:name () r[name] = { }