X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fmodules%2Fxmpp%2Fxmpp_presence.c;fp=citadel%2Fmodules%2Fxmpp%2Fxmpp_presence.c;h=521d257c4cb386d1e1c8a027f5b4a5331794cf16;hp=ca8a95949d8d95b10dc7e8d679787ab072a600ac;hb=62e5cd8b5bcf983f843a7e27d0ecddc4b11b13c3;hpb=99d075e91a49e16c74558b7ada9ea6aa50cc8bbd diff --git a/citadel/modules/xmpp/xmpp_presence.c b/citadel/modules/xmpp/xmpp_presence.c index ca8a95949..521d257c4 100644 --- a/citadel/modules/xmpp/xmpp_presence.c +++ b/citadel/modules/xmpp/xmpp_presence.c @@ -65,10 +65,11 @@ */ void xmpp_indicate_presence(char *presence_jid) { - char xmlbuf[256]; - - cprintf("", xmlesc(xmlbuf, XMPP->client_jid, sizeof xmlbuf)); + XPUT("client_jid, strlen(XMPP->client_jid)); + XPUT("\">"); } @@ -95,8 +96,10 @@ int xmpp_is_visible(struct CitContext *cptr, struct CitContext *to_whom) { /* * Initial dump of the entire wholist + * Respond to a update by firing back with presence information + * on the entire wholist. Check this assumption, it's probably wrong. */ -void xmpp_wholist_presence_dump(void) +void xmpp_wholist_presence_dump(void *data, const char *supplied_el, const char **attr) { struct CitContext *cptr = NULL; int nContexts, i; @@ -121,18 +124,18 @@ void xmpp_wholist_presence_dump(void) */ void xmpp_destroy_buddy(char *presence_jid, int aggressively) { static int unsolicited_id = 1; - char xmlbuf1[256]; - char xmlbuf2[256]; + struct CitContext *CCC = CC; if (!presence_jid) return; if (!XMPP) return; if (!XMPP->client_jid) return; /* Transmit non-presence information */ - cprintf("", - xmlesc(xmlbuf1, presence_jid, sizeof xmlbuf1), - xmlesc(xmlbuf2, XMPP->client_jid, sizeof xmlbuf2) - ); + XPUT("client_jid, strlen(XMPP->client_jid)); + XPUT("\">"); /* * Setting the "aggressively" flag also sends an "unsubscribed" presence update. @@ -141,26 +144,34 @@ void xmpp_destroy_buddy(char *presence_jid, int aggressively) { * it as a rejection of a subscription request. */ if (aggressively) { - cprintf("", - xmlesc(xmlbuf1, presence_jid, sizeof xmlbuf1), - xmlesc(xmlbuf2, XMPP->client_jid, sizeof xmlbuf2) - ); + XPUT("client_jid, strlen(XMPP->client_jid)); + XPUT("\">"); } // FIXME ... we should implement xmpp_indicate_nonpresence so we can use it elsewhere /* Do an unsolicited roster update that deletes the contact. */ - cprintf("", - xmlesc(xmlbuf1, CC->cs_inet_email, sizeof xmlbuf1), - xmlesc(xmlbuf2, XMPP->client_jid, sizeof xmlbuf2), - ++unsolicited_id - ); - cprintf(""); - cprintf("", xmlesc(xmlbuf1, presence_jid, sizeof xmlbuf1)); - cprintf("%s", xmlesc(xmlbuf1, config.c_humannode, sizeof xmlbuf1)); - cprintf(""); - cprintf("" - "" + XPUT("cs_inet_email, strlen(CCC->cs_inet_email)); + XPUT("\" to=\""); + XPutProp(XMPP->client_jid, strlen(XMPP->client_jid)); + XPUT("\" id=\"unbuddy_"); + XPrintf("%x", ++unsolicited_id); + XPUT("\">"); + + XPUT("" + "" + ""); + XPutBody(CFG_KEY(c_humannode)); + XPUT("" + "" + "" + "" ); } @@ -204,10 +215,12 @@ void xmpp_presence_notify(char *presence_jid, int event_type) { /* Do an unsolicited roster update that adds a new contact. */ assert(which_cptr_is_relevant >= 0); - cprintf("", ++unsolicited_id); - cprintf(""); + XPUT("" + ""); xmpp_roster_item(&cptr[which_cptr_is_relevant]); - cprintf(""); + XPUT(""); /* Transmit presence information */ xmpp_indicate_presence(presence_jid); @@ -410,3 +423,11 @@ void xmpp_delete_old_buddies_who_no_longer_exist_from_the_client_roster(void) free(cptr); } + +CTDL_MODULE_INIT(xmpp_presence) +{ + if (!threading) { + AddXMPPEndHandler(HKEY("presence"), xmpp_wholist_presence_dump, 0); + } + return "xmpp_presence"; +}