void jabber_output_incoming_messages(void);
void xmpp_queue_event(int, char *);
void xmpp_process_events(void);
-void xmpp_presence_notify(char *, char *);
+void xmpp_presence_notify(char *, int);
void jabber_roster_item(struct CitContext *);
void jabber_send_message(char *, char *);
void jabber_non_sasl_authenticate(char *, char *, char *, char *);
* 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) {
+void xmpp_presence_notify(char *presence_jid, int event_type) {
struct CitContext *cptr;
static int unsolicited_id;
int visible_sessions = 0;
lprintf(CTDL_DEBUG, "%d sessions for <%s> are now visible to session %d\n",
visible_sessions, presence_jid, CC->cs_pid);
- if (
- ( (strcasecmp(presence_type, "unavailable")) || (strcasecmp(presence_type, "unsubscribed")) )
- && (visible_sessions == 1) ) {
+ if ( (event_type == XMPP_EVT_LOGIN) && (visible_sessions == 1) ) {
lprintf(CTDL_DEBUG, "Telling session %d that <%s> logged in\n", CC->cs_pid, presence_jid);
}
/* Transmit presence information */
- cprintf("<presence type=\"%s\" from=\"%s\"></presence>", presence_type, presence_jid);
+ cprintf("<presence type=\"available\" from=\"%s\"></presence>", presence_jid);
}
- if ( (!strcasecmp(presence_type, "unavailable")) && (visible_sessions == 0) ) {
+ if (visible_sessions == 0) {
lprintf(CTDL_DEBUG, "Telling session %d that <%s> logged out\n", CC->cs_pid, presence_jid);
/* Transmit non-presence information */
- cprintf("<presence type=\"%s\" from=\"%s\"></presence>", presence_type, presence_jid);
+ cprintf("<presence type=\"unavailable\" from=\"%s\"></presence>", presence_jid);
+ cprintf("<presence type=\"unsubscribed\" from=\"%s\"></presence>", presence_jid);
/* Do an unsolicited roster update that deletes the contact. */
cprintf("<iq id=\"unsolicited_%x\" type=\"result\">", ++unsolicited_id);
switch(xptr->event_type) {
case XMPP_EVT_LOGIN:
- if (xptr->session_which_generated_this_event != CC->cs_pid) {
- xmpp_presence_notify(xptr->event_jid, "available");
- }
- break;
-
case XMPP_EVT_LOGOUT:
if (xptr->session_which_generated_this_event != CC->cs_pid) {
- xmpp_presence_notify(xptr->event_jid, "unavailable");
- xmpp_presence_notify(xptr->event_jid, "unsubscribed");
+ xmpp_presence_notify(xptr->event_jid, xptr->event_type);
}
break;
-
}
if (xptr->event_seq > highest_event) {