* Ok, it's not an async bug. When I changed everything over to xmpp_is_visible(...
authorArt Cancro <ajc@citadel.org>
Mon, 10 May 2010 21:06:42 +0000 (21:06 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 10 May 2010 21:06:42 +0000 (21:06 +0000)
citadel/modules/xmpp/serv_xmpp.c
citadel/modules/xmpp/serv_xmpp.h
citadel/modules/xmpp/xmpp_presence.c
citadel/modules/xmpp/xmpp_query_namespace.c

index 8c7297350b2cb976ac8f66e10c553ed23595a68f..e92d7ddc5f0ef7e2bdc96c6f629a567f1684cb19 100644 (file)
@@ -498,6 +498,7 @@ 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();
 }
index 473f9937e74d27866cc7a7c3b1f1fc1e484ca004..0292d9716f28868ef33dc929e4bd27af470f4cd3 100644 (file)
@@ -83,4 +83,4 @@ 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);
-int xmpp_is_visible(struct CitContext *cptr);
+int xmpp_is_visible(struct CitContext *from, struct CitContext *to_whom);
index e53b26cc0bb5cc1b3fd42667eb90624cc662f1c4..557361169af18a751b9d7bdf96bd50ffb6e79724 100644 (file)
@@ -75,14 +75,15 @@ void xmpp_indicate_presence(char *presence_jid)
 
 
 /*
- * Convenience function to determine whether a particular session is visible to this user
+ * Convenience function to determine whether any given session is 'visible' to any other given session,
+ * and is capable of receiving instant messages from that session.
  */
-int xmpp_is_visible(struct CitContext *cptr) {
-       int aide = (CC->user.axlevel >= AxAideU);
+int xmpp_is_visible(struct CitContext *cptr, struct CitContext *to_whom) {
+       int aide = (to_whom->user.axlevel >= AxAideU);
 
        if (    (cptr->logged_in)
                &&      (((cptr->cs_flags&CS_STEALTH)==0) || (aide))    /* aides see everyone */
-               &&      (cptr->user.usernum != CC->user.usernum)        /* don't show myself */
+               &&      (cptr->user.usernum != to_whom->user.usernum)   /* don't show myself */
                &&      (cptr->can_receive_im)                          /* IM-capable session */
        ) {
                return(1);
@@ -107,7 +108,7 @@ void xmpp_wholist_presence_dump(void)
        }
 
        for (i=0; i<nContexts; i++) {
-               if (xmpp_is_visible(&cptr[i])) {
+               if (xmpp_is_visible(&cptr[i], CC)) {
                        xmpp_indicate_presence(cptr[i].cs_inet_email);
                }
        }
@@ -154,6 +155,7 @@ void xmpp_destroy_buddy(char *presence_jid) {
 
 /*
  * When a user logs in or out of the local Citadel system, notify all XMPP sessions about it.
+ * THIS FUNCTION HAS A BUG IN IT THAT ENUMERATES THE SESSIONS WRONG.
  */
 void xmpp_presence_notify(char *presence_jid, int event_type) {
        struct CitContext *cptr;
@@ -168,10 +170,10 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
        if (!cptr) {
                return;
        }
-               
+
        /* Count the visible sessions for this user */
        for (i=0; i<nContexts; i++) {
-               if (xmpp_is_visible(&cptr[i])) {
+               if (xmpp_is_visible(CC, &cptr[i])) {
                        ++visible_sessions;
                }
        }
@@ -185,7 +187,7 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
 
                /* Do an unsolicited roster update that adds a new contact. */
                for (i=0; i<nContexts; i++) {
-                       if (xmpp_is_visible(&cptr[i])) {
+                       if (xmpp_is_visible(CC, &cptr[i])) {
                                if (!strcasecmp(cptr[i].cs_inet_email, presence_jid)) {
                                        cprintf("<iq id=\"unsolicited_%x\" type=\"result\">",
                                                ++unsolicited_id);
@@ -324,7 +326,7 @@ void xmpp_massacre_roster(void)
        cptr = CtdlGetContextArray(&nContexts);
        if (cptr) {
                for (i=0; i<nContexts; i++) {
-                       if (xmpp_is_visible(&cptr[i])) {
+                       if (xmpp_is_visible(&cptr[i], CC)) {
                                if (mortuary) {
                                        char *buddy = strdup(cptr[i].cs_inet_email);
                                        Put(mortuary, buddy, strlen(buddy), buddy, NULL);
@@ -372,7 +374,7 @@ void xmpp_delete_old_buddies_who_no_longer_exist_from_the_client_roster(void)
 
                online_now = 0;
                if (cptr) for (i=0; i<nContexts; i++) {
-                       if (xmpp_is_visible(&cptr[i])) {
+                       if (xmpp_is_visible(&cptr[i], CC)) {
                                if (!strcasecmp(cptr[i].cs_inet_email, (char *)Value)) {
                                        online_now = 1;
                                }
index 45bc9ed8ef0bf995abb94be991ee8f009d91f1ea..5f6465778a1e8d1a8c2ede551ca1bc1619838ef6 100644 (file)
@@ -89,7 +89,7 @@ void xmpp_iq_roster_query(void)
        cptr = CtdlGetContextArray(&nContexts);
        if (cptr) {
                for (i=0; i<nContexts; i++) {
-                       if (xmpp_is_visible(&cptr[i])) {
+                       if (xmpp_is_visible(&cptr[i], CC)) {
                                CtdlLogPrintf(CTDL_DEBUG, "Rosterizing %s\n", cptr[i].user.fullname);
                                xmpp_roster_item(&cptr[i]);
                        }