From 37d26a3d25048a08463d6230b6f8149f417ac150 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 10 May 2010 21:22:05 +0000 Subject: [PATCH] * I think this cleans up the remaining XMPP bugs. We now see the correct number of sessions for each user (and it turns out I didn't have to modify the xmpp_is_visible() API after all, but it's still a nice enhancement to have and doesn't cost extra). --- citadel/modules/xmpp/serv_xmpp.c | 1 - citadel/modules/xmpp/xmpp_presence.c | 33 ++++++++++----------- citadel/modules/xmpp/xmpp_query_namespace.c | 3 -- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/citadel/modules/xmpp/serv_xmpp.c b/citadel/modules/xmpp/serv_xmpp.c index e92d7ddc5..8c7297350 100644 --- a/citadel/modules/xmpp/serv_xmpp.c +++ b/citadel/modules/xmpp/serv_xmpp.c @@ -498,7 +498,6 @@ void xmpp_command_loop(void) { * Async loop for XMPP sessions (handles the transmission of unsolicited stanzas) */ void xmpp_async_loop(void) { - CtdlLogPrintf(CTDL_DEBUG, "\033[35m xmpp_async_loop() IS BEING CALLED!! \033[0m\n"); xmpp_process_events(); xmpp_output_incoming_messages(); } diff --git a/citadel/modules/xmpp/xmpp_presence.c b/citadel/modules/xmpp/xmpp_presence.c index 557361169..5dadfe38e 100644 --- a/citadel/modules/xmpp/xmpp_presence.c +++ b/citadel/modules/xmpp/xmpp_presence.c @@ -30,6 +30,7 @@ #include #include #include +#include #if TIME_WITH_SYS_TIME # include @@ -127,7 +128,6 @@ void xmpp_destroy_buddy(char *presence_jid) { if (!XMPP) return; if (!XMPP->client_jid) return; - CtdlLogPrintf(CTDL_DEBUG, "\033[31mdestroy_buddy(%s)\033[0m\n", presence_jid); /* Transmit non-presence information */ cprintf("", presence_jid, XMPP->client_jid @@ -162,6 +162,7 @@ void xmpp_presence_notify(char *presence_jid, int event_type) { static int unsolicited_id; int visible_sessions = 0; int nContexts, i; + int which_cptr_is_relevant = (-1); if (IsEmptyStr(presence_jid)) return; if (CC->kill_me) return; @@ -173,8 +174,11 @@ void xmpp_presence_notify(char *presence_jid, int event_type) { /* Count the visible sessions for this user */ for (i=0; i logged in\n", CC->cs_pid, presence_jid); + CtdlLogPrintf(CTDL_DEBUG, "Telling session %d that <%s> logged in\n", + CC->cs_pid, presence_jid); /* Do an unsolicited roster update that adds a new contact. */ - for (i=0; i", - ++unsolicited_id); - cprintf(""); - xmpp_roster_item(&cptr[i]); - cprintf("" - ""); - } - } - } + assert(which_cptr_is_relevant >= 0); + cprintf("", ++unsolicited_id); + cprintf(""); + xmpp_roster_item(&cptr[which_cptr_is_relevant]); + cprintf(""); /* Transmit presence information */ xmpp_indicate_presence(presence_jid); } if (visible_sessions == 0) { - CtdlLogPrintf(CTDL_DEBUG, "Telling session %d that <%s> logged out\n", CC->cs_pid, presence_jid); - + CtdlLogPrintf(CTDL_DEBUG, "Telling session %d that <%s> logged out\n", + CC->cs_pid, presence_jid); xmpp_destroy_buddy(presence_jid); } + free(cptr); } diff --git a/citadel/modules/xmpp/xmpp_query_namespace.c b/citadel/modules/xmpp/xmpp_query_namespace.c index 5f6465778..720233e03 100644 --- a/citadel/modules/xmpp/xmpp_query_namespace.c +++ b/citadel/modules/xmpp/xmpp_query_namespace.c @@ -62,7 +62,6 @@ * Output a single roster item, for roster queries or pushes */ void xmpp_roster_item(struct CitContext *cptr) { - CtdlLogPrintf(CTDL_DEBUG, "\033[32mxmpp_roster_item(%s)\033[0m\n", cptr->cs_inet_email); cprintf("", cptr->cs_inet_email, cptr->user.fullname @@ -83,8 +82,6 @@ void xmpp_iq_roster_query(void) struct CitContext *cptr; int nContexts, i; - CtdlLogPrintf(CTDL_DEBUG, "\033[36m ROSTER QUERY !! \033[0m\n"); - cprintf(""); cptr = CtdlGetContextArray(&nContexts); if (cptr) { -- 2.30.2