* Tried to complete the dead buddy thing in xmpp, but the code I already wrote now...
authorArt Cancro <ajc@citadel.org>
Mon, 3 May 2010 04:24:29 +0000 (04:24 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 3 May 2010 04:24:29 +0000 (04:24 +0000)
citadel/modules/xmpp/serv_xmpp.c
citadel/modules/xmpp/serv_xmpp.h
citadel/modules/xmpp/xmpp_presence.c

index 1268fe302c91e3ee6190657eda6cbd597342002b..682fdb2c44a854971cfcdff633124570a859be71 100644 (file)
@@ -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();
 }
 
 
index 901ad883e3b65a7d5e7168cb8813333c884c6fcd..d8e29e9e1400839c7ff9f88b0f3abda97b929582 100644 (file)
@@ -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);
index a57c124669100438eb53233c52fca77046f3efcf..c222b086c3ef09c34ce4259e44284124ea3d8029 100644 (file)
@@ -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);
+}