]> code.citadel.org Git - citadel.git/commitdiff
Unsolicited presence push. Still doesn't seem to work.
authorArt Cancro <ajc@citadel.org>
Sun, 2 Dec 2007 05:46:40 +0000 (05:46 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 2 Dec 2007 05:46:40 +0000 (05:46 +0000)
citadel/modules/jabber/serv_xmpp.h
citadel/modules/jabber/xmpp_presence.c
citadel/modules/jabber/xmpp_queue.c

index 54bb87ea53dfb3a4a1ee3417c126a6251d0d593f..39030c8b714ed3c8396cc1a80cec91b3ea114028 100644 (file)
@@ -31,6 +31,7 @@ struct xmpp_event {
        time_t event_time;
        int event_type;
        char event_jid[256];
+       int session_which_generated_this_event;
 };
 
 extern struct xmpp_event *xmpp_queue;
@@ -52,3 +53,4 @@ void jabber_output_incoming_messages(void);
 void xmpp_queue_event(int, char *);
 void xmpp_process_events(void);
 void xmpp_presence_notify(char *, char *);
+void jabber_roster_item(struct CitContext *);
index 80e3e709609236bfc4caf6dd6fcbe6166944d35d..bfb9776bfca7275c54c5c41bdbf5a1b9462c379c 100644 (file)
@@ -67,9 +67,34 @@ void jabber_wholist_presence_dump(void)
 }
 
 
+
+/*
+ * When a user logs in or out of the local Citadel system, notify all Jabber sessions
+ * about it.
+ */
 void xmpp_presence_notify(char *presence_jid, char *presence_type) {
+       struct CitContext *cptr;
+       static int unsolicited_id;
+
        /* FIXME subject this to the same conditions as above */
-       cprintf("<presence type=\"%s\" from=\"%s\">", presence_type, presence_jid);
+
+       if (IsEmptyStr(presence_jid)) return;
+       lprintf(CTDL_DEBUG, "Sending presence info about <%s> to session %d\n", presence_jid, CC->cs_pid);
+
+       /* Transmit an unsolicited roster update 
+       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>");
+               }
+       } */
+
+       /* Now transmit unsolicited presence information
+       cprintf("<presence type=\"%s\" from=\"%s\"></presence>", presence_type, presence_jid);
+       */
 }
 
 
index 3191cac9dae66a63da0baab8839a2e8d9c8a721e..8a0e79554d6d60c535c63d85a962ee2823f4bff6 100644 (file)
@@ -81,6 +81,7 @@ void xmpp_queue_event(int event_type, char *email_addr) {
        new_event->event_time = time(NULL);
        new_event->event_seq = ++seq;
        new_event->event_type = event_type;
+       new_event->session_which_generated_this_event = CC->cs_pid;
        safestrncpy(new_event->event_jid, email_addr, sizeof new_event->event_jid);
 
        /* Add it to the list */
@@ -120,11 +121,15 @@ void xmpp_process_events(void) {
                        switch(xptr->event_type) {
 
                                case XMPP_EVT_LOGIN:
-                                       xmpp_presence_notify(xptr->event_jid, "available");
+                                       if (xptr->session_which_generated_this_event != CC->cs_pid) {
+                                               xmpp_presence_notify(xptr->event_jid, "available");
+                                       }
                                        break;
 
                                case XMPP_EVT_LOGOUT:
-                                       xmpp_presence_notify(xptr->event_jid, "unavailable");
+                                       if (xptr->session_which_generated_this_event != CC->cs_pid) {
+                                               xmpp_presence_notify(xptr->event_jid, "unavailable");
+                                       }
                                        break;
 
                        }