To send an IQ request, use jabber-send-iq
. It will generate an
id, and create a mapping for it for use when the response comes. The
syntax is:
(jabber-send-iq to type query success-callback success-closure failure-callback failure-closure)
Both callbacks take two arguments, the IQ stanza returned and the closure item mentioned here.
Two standard callbacks are provided. jabber-report-success
takes a string as closure item, and reports success or failure in the
echo area. jabber-process-data
prepares a browse buffer. If
its closure argument is a function, it calls that function with point
in this browse buffer. If it's a string, it prints that string along
with the error message in the IQ response. If it's anything else
(e.g. nil
), it just dumps the XML in the browse buffer.
Examples follow. This is the hypothetical Jabber protocol “frob”, for which only success report is needed:
(jabber-send-iq "someone@somewhere.org" "set" '(query ((xmlns . "frob"))) 'jabber-report-success "Frobbing" 'jabber-report-success "Frobbing")
This will print “Frobbing succeeded” or “Frobbing failed: reason”, respectively, in the echo area.
The protocol “investigate” needs to parse results and show them in a browse buffer:
(jabber-send-iq "someone@somewhere.org" "get" '(query ((xmlns . "investigate"))) 'jabber-process-data 'jabber-process-investigate 'jabber-process-data "Investigation failed")
Of course, the previous example could have used
jabber-report-success
for the error message. It's a matter of
UI taste.