# HG changeset patch # User Myhailo Danylenko # Date 1248610520 -10800 # Node ID 8a7f7829f4df857f1d94178c554d3541543be8dd # Parent 11bd9d10ee3bca6990a43012e38ee495b6b6e17c Muc room configuration by owner diff -r 11bd9d10ee3b -r 8a7f7829f4df examples/lm/muc.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/lm/muc.lua Sun Jul 26 15:15:20 2009 +0300 @@ -0,0 +1,41 @@ + +-- MULTI-USER CHAT (XEP-0045) +-- only owner room configuration + +-- library + +local iq = require 'lm.iq' +local x_data = require 'lm.x_data' + +-- + +local F = { } + +function F.owner_config ( conn, to, success, fail ) + iq.send ( conn, to, 'get', + { + query = { xmlns = 'http://jabber.org/protocol/muc#owner' }, + }, + function ( mess ) + local x = mess:path ( 'query', 'x' ) + if x then + success ( x_data.parse ( x ), + function ( form, success, fail ) + iq.send ( conn, to, 'set', + { + command = 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' ), + }, success, fail ) + end ) + end + end, fail ) +end + +return F + +-- vim: se ts=4: -- diff -r 11bd9d10ee3b -r 8a7f7829f4df examples/mcabberrc.lua --- a/examples/mcabberrc.lua Sun Jul 26 12:23:13 2009 +0300 +++ b/examples/mcabberrc.lua Sun Jul 26 15:15:20 2009 +0300 @@ -278,6 +278,10 @@ require 'disco' +-- MULTI-USER CHAT (XEP-0045) + +require 'muc' + -- IN-BAND BYTESTREAMS (XEP-0047) require 'ibb' diff -r 11bd9d10ee3b -r 8a7f7829f4df examples/muc.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/muc.lua Sun Jul 26 15:15:20 2009 +0300 @@ -0,0 +1,43 @@ + +local lm = require 'lm' +local muc = require 'lm.muc' + +main.command ( 'room-config', + function ( args ) + local who + if args then + who = args + else + who = main.current_buddy () + end + local conn = lm.connection.bless ( main.connection () ) + muc.owner_config ( conn, who, + function ( form, submit, reject ) + insert_form ( form, + function ( form ) + submit ( form, + function () + main.print_info ( who, 'Room configuratino accepted' ) + end, + function ( mesg ) + main.print_info ( who, ('Room configuration failed: %s'):format ( mesg ) ) + end ) + end, + function ( form ) + reject ( form, + function () + main.print_info ( who, 'Room configuration cancelled' ) + end, + function ( mesg ) + main.print_info ( who, ('Room configuration cancellation failed: %s'):format ( mesg ) ) + end ) + end ) + end, + function ( mesg ) + main.print_info ( who, ('Room configutarion request failed: %s'):format ( mesg ) ) + end ) + end, false, 'jid' ) + +commands_help['room-config'] = "[room_jid]\n\nRequests room configuration form from server. You must be owner of this room." + +-- vim: se ts=4: --