119 { |
122 { |
120 pubsub = { xmlns = 'http://jabber.org/protocol/pubsub#owner', |
123 pubsub = { xmlns = 'http://jabber.org/protocol/pubsub#owner', |
121 configure = { node = node }, |
124 configure = { node = node }, |
122 }, |
125 }, |
123 }, |
126 }, |
124 function ( mess ) -- FIXME |
127 function ( mess ) |
125 local x = mess:path ( 'pubsub', 'configure', 'x' ) |
128 local x = mess:path ( 'pubsub', 'configure', 'x' ) |
126 if x then |
129 if x then |
127 local fid = parse_form ( x ) |
130 success ( x_data.parse ( x ), |
128 forms[fid].send = |
131 function ( form, success, fail ) |
129 function ( form ) |
132 iq.send ( conn, to, 'set', |
|
133 { |
|
134 pubsub = { xmlns = 'http://jabber.org/protocol/pubsub#owner', |
|
135 configure = form.format ( form, { node = node } ), |
|
136 }, |
|
137 }, success, fail ) |
|
138 end, |
|
139 function ( form, success, fail ) |
130 iq.send ( conn, to, 'set', |
140 iq.send ( conn, to, 'set', |
131 { |
141 { |
132 pubsub = { xmlns = 'http://jabber.org/protocol/pubsub#owner', |
142 pubsub = { xmlns = 'http://jabber.org/protocol/pubsub#owner', |
133 configure = { node = node, |
143 configure = { node = node, |
134 x = { xmlns = 'jabber:x:data', type = 'submit', |
144 x = { xmlns = 'jabber:x:data', type = 'cancel' }, -- FIXME |
135 field = form.val, |
|
136 }, |
|
137 }, |
145 }, |
138 }, |
146 }, |
139 }, |
147 }, success, fail ) |
140 function ( mess ) |
148 end ) |
141 success () |
149 else |
142 main.print_info ( to, 'Now you can run /form del ' .. fid .. ' to delete form from list' ) |
150 fail ( mess:xml () ) -- XXX |
143 form.status = 'acquired' |
|
144 end, |
|
145 function ( mesg ) |
|
146 if mesg then |
|
147 form.status = 'rejected' |
|
148 else |
|
149 form.status = 'unknown' |
|
150 end |
|
151 fail ( mesg ) |
|
152 end ) |
|
153 form.status = 'sent' |
|
154 end |
|
155 forms[fid].status = 'filling' |
|
156 main.print_info ( to, 'You have new form. To fill it, use /form ' .. fid .. ' fieldname value' ) |
|
157 else |
|
158 main.print_info ( to, 'Weird, no error and no node configuration form: ' .. mess:xml () ) |
|
159 end |
151 end |
160 end, fail ) |
152 end, fail ) |
161 end |
153 end |
162 |
154 |
163 function pubsub.list_subscriptions ( conn, to, node, success, fail ) |
155 function pubsub.list_subscriptions ( conn, to, node, success, fail ) |
259 function ( mesg ) |
251 function ( mesg ) |
260 main.print_info ( who, 'Node purge failed: ' .. mesg ) |
252 main.print_info ( who, 'Node purge failed: ' .. mesg ) |
261 end ) |
253 end ) |
262 elseif action:sub ( 1, 4 ) == 'conf' then |
254 elseif action:sub ( 1, 4 ) == 'conf' then |
263 pubsub.configure_node ( conn, who, node, |
255 pubsub.configure_node ( conn, who, node, |
264 function () |
256 function ( form, submit, reject ) |
265 main.print_info ( who, 'Node configuration accepted' ) |
257 local id = #forms + 1 |
|
258 forms[id] = { |
|
259 form = form, |
|
260 submit = |
|
261 function ( form ) |
|
262 submit ( form, |
|
263 function () |
|
264 main.print_info ( who, 'Node configuration completed' ) |
|
265 end, |
|
266 function ( mesg ) |
|
267 main.print_info ( who, 'Node configuration failed: ' .. mesg ) |
|
268 end ) |
|
269 end, |
|
270 reject = |
|
271 function ( form ) |
|
272 reject ( form, |
|
273 function () |
|
274 main.print_info ( who, 'Node configuration cancelled' ) |
|
275 end, |
|
276 function ( mesg ) |
|
277 main.print_info ( who, 'Node configuration cancellation failed: ' .. mesg ) |
|
278 end ) |
|
279 end, |
|
280 } |
|
281 print ( 'You have new form ' .. id ) |
266 end, |
282 end, |
267 function ( mesg ) |
283 function ( mesg ) |
268 main.print_info ( who, 'Node configuration failed: ' .. mesg ) |
284 main.print_info ( who, 'Node configuration failed: ' .. mesg ) |
269 end ) |
285 end ) |
270 elseif action == 'subscriptions' or action == 'subscribers' then |
286 elseif action == 'subscriptions' or action == 'subscribers' then |