From: Art Cancro Date: Mon, 3 May 2010 04:24:29 +0000 (+0000) Subject: * Tried to complete the dead buddy thing in xmpp, but the code I already wrote now... X-Git-Tag: v7.86~232 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=b5317e7fe25279508049b334a23d28a9e2c9a094 * Tried to complete the dead buddy thing in xmpp, but the code I already wrote now seems to be broken? --- diff --git a/citadel/modules/xmpp/serv_xmpp.c b/citadel/modules/xmpp/serv_xmpp.c index 1268fe302..682fdb2c4 100644 --- a/citadel/modules/xmpp/serv_xmpp.c +++ b/citadel/modules/xmpp/serv_xmpp.c @@ -510,6 +510,7 @@ void xmpp_async_loop(void) { */ void xmpp_login_hook(void) { xmpp_queue_event(XMPP_EVT_LOGIN, CC->cs_inet_email); + xmpp_delete_old_buddies_who_no_longer_exist_from_the_client_roster(); } diff --git a/citadel/modules/xmpp/serv_xmpp.h b/citadel/modules/xmpp/serv_xmpp.h index 901ad883e..d8e29e9e1 100644 --- a/citadel/modules/xmpp/serv_xmpp.h +++ b/citadel/modules/xmpp/serv_xmpp.h @@ -82,3 +82,4 @@ void xmpp_roster_item(struct CitContext *); void xmpp_send_message(char *, char *); void xmpp_non_sasl_authenticate(char *, char *, char *, char *); void xmpp_massacre_roster(void); +void xmpp_delete_old_buddies_who_no_longer_exist_from_the_client_roster(void); diff --git a/citadel/modules/xmpp/xmpp_presence.c b/citadel/modules/xmpp/xmpp_presence.c index a57c12466..c222b086c 100644 --- a/citadel/modules/xmpp/xmpp_presence.c +++ b/citadel/modules/xmpp/xmpp_presence.c @@ -219,6 +219,7 @@ void xmpp_fetch_mortuary_backend(long msgnum, void *userdata) { ptr = msg->cm_fields['M']; endptr = ptr + strlen(ptr); // only do strlen once :) + CtdlLogPrintf(CTDL_DEBUG, "\033[33m%s\033[0m\n", ptr); while (ptr = memreadlinelen(ptr, buf, (sizeof buf - 2), &len), ((ptr < endptr) && (*ptr != 0)) ) { if (in_body) { char *pch; @@ -333,3 +334,25 @@ void xmpp_massacre_roster(void) +/* + * Stupidly, XMPP does not specify a way to tell the client to flush its client-side roster + * and prepare to receive a new one. So instead we remember every buddy we've ever told the + * client about, and push delete operations out at the beginning of a session. + */ +void xmpp_delete_old_buddies_who_no_longer_exist_from_the_client_roster(void) +{ + long len; + void *Value; + const char *Key; + HashList *mortuary = xmpp_fetch_mortuary(); + HashPos *HashPos = GetNewHashPos(mortuary, 0); + + CtdlLogPrintf(CTDL_DEBUG, "\033[32mHAHA\033[0m\n"); + while (GetNextHashPos(mortuary, HashPos, &len, &Key, &Value) != 0) + { + CtdlLogPrintf(CTDL_DEBUG, "\033[31mDELETE: %s\033[0m\n", (char *)Value); + } + CtdlLogPrintf(CTDL_DEBUG, "\033[32mHOHO\033[0m\n"); + DeleteHashPos(&HashPos); + DeleteHash(&mortuary); +}