*
* Handle messages sent and received using XMPP (Jabber) protocol
*
- * Copyright (c) 2007-2009 by Art Cancro
+ * Copyright (c) 2007-2010 by Art Cancro
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "serv_xmpp.h"
+
+/*
+ * Indicate the presence of another user to the client
+ * (used in several places)
+ */
+void xmpp_indicate_presence(char *presence_jid)
+{
+ cprintf("<presence from=\"%s\" to=\"%s\"></presence>",
+ presence_jid,
+ XMPP->client_jid
+ );
+}
+
+
/*
* Initial dump of the entire wholist
*/
&& (cptr[i].user.usernum != CC->user.usernum) /* don't show myself */
&& (cptr[i].can_receive_im) /* IM-capable session */
) {
- cprintf("<presence type=\"available\" from=\"%s\"></presence>",
- cptr[i].cs_inet_email);
+ xmpp_indicate_presence(cptr[i].cs_inet_email);
}
}
}
static int unsolicited_id = 1;
/* Transmit non-presence information */
- cprintf("<presence type=\"unavailable\" from=\"%s\"></presence>", presence_jid);
- cprintf("<presence type=\"unsubscribed\" from=\"%s\"></presence>", presence_jid);
+ cprintf("<presence type=\"unavailable\" from=\"%s\" to=\"%s\"></presence>",
+ presence_jid, XMPP->client_jid
+ );
+ cprintf("<presence type=\"unsubscribed\" from=\"%s\" to=\"%s\"></presence>",
+ presence_jid, XMPP->client_jid
+ );
+ // FIXME ... we should implement xmpp_indicate_nonpresence so we can use it elsewhere
/* Do an unsolicited roster update that deletes the contact. */
- cprintf("<iq id=\"unbuddy_%x\" type=\"result\">", ++unsolicited_id);
+ cprintf("<iq from=\"%s\" to=\"%s\" id=\"unbuddy_%x\" type=\"result\">",
+ CC->cs_inet_email,
+ XMPP->client_jid,
+ ++unsolicited_id
+ );
cprintf("<query xmlns=\"jabber:iq:roster\">");
cprintf("<item jid=\"%s\" subscription=\"remove\">", presence_jid);
cprintf("<group>%s</group>", config.c_humannode);
}
/* Transmit presence information */
- cprintf("<presence type=\"available\" from=\"%s\"></presence>", presence_jid);
+ xmpp_indicate_presence(presence_jid);
}
if (visible_sessions == 0) {