# HG changeset patch # User Myhailo Danylenko # Date 1271233262 -10800 # Node ID 5bcdb71ef2f2d12c242b82177f15966fe1655e66 # Parent bd9f24178d67e1e599157d4b1e73275dba71ecce Fix some example scripts * Unregister LM message handlers on module unload * Fix muc room-config command diff -r bd9f24178d67 -r 5bcdb71ef2f2 examples/attention.lua --- a/examples/attention.lua Mon Apr 12 00:41:23 2010 +0300 +++ b/examples/attention.lua Wed Apr 14 11:21:02 2010 +0300 @@ -48,8 +48,7 @@ attention_handler_registered = true end end -main.hook ( 'hook-post-connect', attention_pc_handler ) -main.hook ( 'hook-pre-disconnect', +local attention_pd_handler = function ( args ) if attention_handler_registered then local connection = main.connection () @@ -58,7 +57,9 @@ end attention_handler_registered = false end - end ) + end +main.hook ( 'hook-post-connect', attention_pc_handler ) +main.hook ( 'hook-pre-disconnect', attention_pd_handler ) -- register handler, if we are already connected main.hook ( 'hook-lua-start', @@ -69,6 +70,7 @@ main.hook ('hook-lua-quit', function ( args ) main.del_feature ( 'urn:xmpp:attention:0' ) + attention_pd_handler () end ) -- vim: se ts=4 sw=4: -- diff -r bd9f24178d67 -r 5bcdb71ef2f2 examples/evil.lua --- a/examples/evil.lua Mon Apr 12 00:41:23 2010 +0300 +++ b/examples/evil.lua Wed Apr 14 11:21:02 2010 +0300 @@ -86,8 +86,7 @@ evil_handler_registered = true end end -main.hook ( 'hook-post-connect', evil_pc_handler ) -main.hook ( 'hook-pre-disconnect', +local evil_pd_handler = function ( args ) if evil_handler_registered then local connection = main.connection () @@ -98,7 +97,9 @@ end evil_handler_registered = false end - end ) + end +main.hook ( 'hook-post-connect', evil_pc_handler ) +main.hook ( 'hook-pre-disconnect', evil_pd_handler ) main.hook ( 'hook-lua-start', function ( args ) @@ -108,6 +109,7 @@ main.hook ( 'hook-lua-quit', function ( args ) main.del_feature ( 'http://jabber.org/protocol/evil' ) + evil_pd_handler () end ) local char2xmpp = { diff -r bd9f24178d67 -r 5bcdb71ef2f2 examples/lm/muc.lua --- a/examples/lm/muc.lua Mon Apr 12 00:41:23 2010 +0300 +++ b/examples/lm/muc.lua Wed Apr 14 11:21:02 2010 +0300 @@ -23,13 +23,13 @@ function ( form, success, fail ) iq.send ( conn, to, 'set', { - command = form:format ( { xmlns = 'http://jabber.org/protocol/muc#owner' }, 'submit' ), + query = form:format ( { xmlns = 'http://jabber.org/protocol/muc#owner' }, 'submit' ), }, success, fail ) end, function ( form, success, fail ) iq.send ( conn, to, 'set', { - command = form:format ( { xmlns = 'http://jabber.org/protocol/muc#owner' }, 'cancel' ), + query = form:format ( { xmlns = 'http://jabber.org/protocol/muc#owner' }, 'cancel' ), }, success, fail ) end ) end diff -r bd9f24178d67 -r 5bcdb71ef2f2 examples/muc.lua --- a/examples/muc.lua Mon Apr 12 00:41:23 2010 +0300 +++ b/examples/muc.lua Wed Apr 14 11:21:02 2010 +0300 @@ -10,7 +10,7 @@ return end local who - if args then + if args and args ~= "" then who = args else who = main.current_buddy () diff -r bd9f24178d67 -r 5bcdb71ef2f2 examples/oob.lua --- a/examples/oob.lua Mon Apr 12 00:41:23 2010 +0300 +++ b/examples/oob.lua Wed Apr 14 11:21:02 2010 +0300 @@ -44,38 +44,39 @@ local connection = main.connection () if connection then local conn = lm.connection.bless ( connection ) - conn:handler ( oob_iq_handler, 'iq', 'normal' ) - conn:handler ( oob_message_handler, 'message', 'normal' ) + conn:handler ( oob_iq_handler, 'iq', 'normal' ) + conn:handler ( oob_message_handler, 'message', 'normal' ) conn:handler ( oob_message_handler, 'presence', 'normal' ) oob_handler_registered = true end end -main.hook ( 'hook-post-connect', oob_pc_handler ) -main.hook ( 'hook-pre-disconnect', +local oob_pd_handler = function ( args ) if oob_handler_registered then local connection = main.connection () if connection then local conn = lm.connection.bless ( connection ) - conn:handler ( oob_iq_handler, 'iq' ) - conn:handler ( oob_message_handler, 'message' ) + conn:handler ( oob_iq_handler, 'iq' ) + conn:handler ( oob_message_handler, 'message' ) conn:handler ( oob_message_handler, 'presence' ) end oob_handler_registered = false end - end ) - + end +main.hook ( 'hook-post-connect', oob_pc_handler ) +main.hook ( 'hook-pre-disconnect', oob_pd_handler ) main.hook ( 'hook-lua-start', function ( args ) main.add_feature ( 'jabber:iq:oob' ) - main.add_feature ( 'jabber:x:oob' ) + main.add_feature ( 'jabber:x:oob' ) oob_pc_handler () end ) main.hook ( 'hook-lua-quit', function ( args ) main.del_feature ( 'jabber:iq:oob' ) - main.del_feature ( 'jabber:x:oob' ) + main.del_feature ( 'jabber:x:oob' ) + oob_pd_handler () end ) -- vim: se ts=4 sw=4: -- diff -r bd9f24178d67 -r 5bcdb71ef2f2 examples/privacy.lua --- a/examples/privacy.lua Mon Apr 12 00:41:23 2010 +0300 +++ b/examples/privacy.lua Wed Apr 14 11:21:02 2010 +0300 @@ -86,8 +86,7 @@ privacy_handler_registered = true end end -main.hook ( 'hook-post-connect', privacy_pc_handler ) -main.hook ( 'hook-pre-disconnect', +privacy_pd_handler = function ( args ) if privacy_handler_registered then local connection = main.connection () @@ -96,6 +95,9 @@ end privacy_handler_registered = false end - end ) + end +main.hook ( 'hook-post-connect', privacy_pc_handler ) +main.hook ( 'hook-pre-disconnect', privacy_pd_handler ) +main.hook ( 'hook-lua-quit', privacy_pd_handler ) -- vim: se ts=4 sw=4: --