time_t event_time;
int event_type;
char event_jid[256];
+ int session_which_generated_this_event;
};
extern struct xmpp_event *xmpp_queue;
void xmpp_queue_event(int, char *);
void xmpp_process_events(void);
void xmpp_presence_notify(char *, char *);
+void jabber_roster_item(struct CitContext *);
}
+
+/*
+ * 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);
+ */
}
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 */
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;
}