When dumping or scanning the wholist in the Jabber
authorArt Cancro <ajc@citadel.org>
Mon, 17 Mar 2008 15:11:49 +0000 (15:11 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 17 Mar 2008 15:11:49 +0000 (15:11 +0000)
service, only pay attention to sessions that have users logged
in.  Doing otherwise exposes empty JID's that cause clients to
malfunction.

citadel/modules/jabber/xmpp_messages.c
citadel/modules/jabber/xmpp_presence.c
citadel/modules/jabber/xmpp_query_namespace.c
citadel/modules/jabber/xmpp_queue.c

index bdb09a5a22e32ad4ca65357a3a722456437c2e02..e579c7cfe602b35853208d78d02931ffd7337790 100644 (file)
@@ -91,8 +91,10 @@ void jabber_send_message(char *message_to, char *message_body) {
        if (!CC->logged_in) return;
 
        for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
-               if (!strcasecmp(cptr->cs_inet_email, message_to)) {
-                       recp = cptr->user.fullname;
+               if (cptr->logged_in) {
+                       if (!strcasecmp(cptr->cs_inet_email, message_to)) {
+                               recp = cptr->user.fullname;
+                       }
                }
        }
 
index b5f088b48f749d7204e86d528328b46db9035f8e..84b5662ed8606f9c46b6f3de8342040426428c0e 100644 (file)
@@ -57,11 +57,14 @@ void jabber_wholist_presence_dump(void)
        int aide = (CC->user.axlevel >= 6);
 
        for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
-               if (
-                  (((cptr->cs_flags&CS_STEALTH)==0) || (aide))         /* aides can see everyone */
-                  && (cptr->user.usernum != CC->user.usernum)          /* don't tell me about myself */
-                  ) {
-                       cprintf("<presence type=\"available\" from=\"%s\"></presence>", cptr->cs_inet_email);
+               if (cptr->logged_in) {
+                       if (
+                          (((cptr->cs_flags&CS_STEALTH)==0) || (aide))         /* aides see everyone */
+                          && (cptr->user.usernum != CC->user.usernum)          /* don't show myself */
+                          ) {
+                               cprintf("<presence type=\"available\" from=\"%s\"></presence>",
+                                       cptr->cs_inet_email);
+                       }
                }
        }
 }
@@ -82,10 +85,12 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
 
        /* Count the visible sessions for this user */
        for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
-               if (  (!strcasecmp(cptr->cs_inet_email, presence_jid)) 
-                  && (((cptr->cs_flags&CS_STEALTH)==0) || (aide))
-                  ) {
-                       ++visible_sessions;
+               if (cptr->logged_in) {
+                       if (  (!strcasecmp(cptr->cs_inet_email, presence_jid)) 
+                          && (((cptr->cs_flags&CS_STEALTH)==0) || (aide))
+                          ) {
+                               ++visible_sessions;
+                       }
                }
        }
 
@@ -98,12 +103,15 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
 
                /* Do an unsolicited roster update that adds a new contact. */
                for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
-                       if (!strcasecmp(cptr->cs_inet_email, presence_jid)) {
-                               cprintf("<iq id=\"unsolicited_%x\" type=\"result\">", ++unsolicited_id);
-                               cprintf("<query xmlns=\"jabber:iq:roster\">");
-                               jabber_roster_item(cptr);
-                               cprintf("</query>"
-                                       "</iq>");
+                       if (cptr->logged_in) {
+                               if (!strcasecmp(cptr->cs_inet_email, presence_jid)) {
+                                       cprintf("<iq id=\"unsolicited_%x\" type=\"result\">",
+                                               ++unsolicited_id);
+                                       cprintf("<query xmlns=\"jabber:iq:roster\">");
+                                       jabber_roster_item(cptr);
+                                       cprintf("</query>"
+                                               "</iq>");
+                               }
                        }
                }
 
index e89fb8cfef118f83c94a216cc1914776eaf4d47a..fdec3135fe639a19703ae8dfbd3bab2aa9c7ee16 100644 (file)
@@ -75,12 +75,13 @@ void jabber_iq_roster_query(void)
        cprintf("<query xmlns=\"jabber:iq:roster\">");
 
        for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
-
-               if (
-                  (((cptr->cs_flags&CS_STEALTH)==0) || (aide))
-                  && (cptr->user.usernum != CC->user.usernum)
-                  ) {
-                       jabber_roster_item(cptr);
+               if (cptr->logged_in) {
+                       if (
+                          (((cptr->cs_flags&CS_STEALTH)==0) || (aide))
+                          && (cptr->user.usernum != CC->user.usernum)
+                          ) {
+                               jabber_roster_item(cptr);
+                       }
                }
        }
 
index 866083393d136d69ff27a0b64c900a121bb57f54..44540496bfc5f5d34903fcea00583d5b1cfe1186 100644 (file)
@@ -100,7 +100,7 @@ void xmpp_queue_event(int event_type, char *email_addr) {
 
        /* Tell the sessions that something is happening */
        for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
-               if (cptr->h_async_function == xmpp_async_loop) {
+               if ((cptr->logged_in) && (cptr->h_async_function == xmpp_async_loop)) {
                        cptr->async_waiting = 1;
                }
        }