Thanks ... this is invaluable for anybody writing a transport from another system to Jabber :-)
- Dave Tom Waters wrote: > > with a ton of help from rob, i wrote my first jsm tonight... > > i've been wanting to get acks from my messages... ... you get a nak in > the form of a message type='error' when the user you send the message to > doesn't exist, but there's no positive acknowledge, (other than the > absence of an error!). > > this jsm works for me... > > /* > * Jabber JSM message ack module > * > * Copyright (C) 2002 Tom Waters <[EMAIL PROTECTED]> > * Released under the LGPL v2. See http://www.gnu.org/copyleft/lgpl.html > */ > > /* $Id: mod_message_ack.c,v 1.0 2002/07/10 17:20:32 waters Exp $ */ > > /* > * Installation: > * > * 1. Place mod_message_ack.c in jabber/jsm/modules > * 2. Add "mod_message_ack.o" to jsm_modules_OBJECTS in > jabber/jsm/modules/Makefile > * 3. Add "modules/mod_message_ack.o" to jsm_EXOBJECTS in > jabber/jsm/Makefile > * 5. "make all" in jabber/jsm, or (re)compile entire server > * 6. Add <mod_message_ack>./jsm/jsm.so</mod_message_ack> (or similar) > to the > * <load main="jsm"> section of jabber.xml. I add it just before > <mod_filter> > */ > > /* > * Usage: > * > * You send something like this: > * > * <message type='chat' to='[EMAIL PROTECTED]'> > * <body>hello</body> > * <ack xmlns='message:ack' id=42/> > * </message> > * > * Server will respond with something like: > * > * <message type='chat' to='[EMAIL PROTECTED]' > from='[EMAIL PROTECTED]'> > * <body>hello</body> > * <ack xmlns='message:ack' id=42/> > * </message> > * > * And [EMAIL PROTECTED] will get this: > * > * <message type='chat' to='[EMAIL PROTECTED]' > from='[EMAIL PROTECTED]'> > * <body>hello</body> > * </message> > * > * If the recipient doesn't exist, you will not get an ack, you'll get > an error. > */ > > #include <jsm.h> > > #define NS_MESSAGE_ACK "message:ack" > > mreturn mod_message_ack_handler(mapi m, void *arg) { > xmlnode ack; > jpacket ret; > > if(m->packet->type != JPACKET_MESSAGE) > return M_IGNORE; > > ack = xmlnode_get_tag(m->packet->x, "ack"); > > if (ack == NULL || !NSCHECK(ack, NS_MESSAGE_ACK)) > return M_PASS; > > if (xmlnode_get_attrib(ack, "delivered") != NULL) > return M_PASS; > > if (js_user(m->si, m->packet->to, NULL) == NULL) { > log_debug("mod_message_ack","not sending ack because %s doesn't > exist", > jid_full(m->packet->to)); > return M_PASS; > } > > log_debug("mod_message_ack","sending message ack to %s from %s", > jid_user(m->packet->from), jid_user(m->packet->to)); > > ret = jpacket_new(xmlnode_dup(m->packet->x)); > > jutil_tofrom(ret->x); > xmlnode_put_attrib(xmlnode_get_tag(ret->x, "ack"), "delivered", "yes"); > > jpacket_reset(ret); > js_deliver(m->si, ret); > > xmlnode_hide(ack); > return M_PASS; > } > > void mod_message_ack(jsmi si) { > js_mapi_register(si, e_SERVER, mod_message_ack_handler, NULL); > js_mapi_register(si, e_DELIVER, mod_message_ack_handler, NULL); > js_mapi_register(si, e_OFFLINE, mod_message_ack_handler, NULL); > } > > _______________________________________________ > jdev mailing list > [EMAIL PROTECTED] > http://mailman.jabber.org/listinfo/jdev > _______________________________________________ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
