* Tweaked some of the XMPP stanzas to include a valid 'to=' parameter. The presence...
authorArt Cancro <ajc@citadel.org>
Tue, 23 Feb 2010 16:28:58 +0000 (16:28 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 23 Feb 2010 16:28:58 +0000 (16:28 +0000)
citadel/modules/xmpp/xmpp_messages.c
citadel/modules/xmpp/xmpp_presence.c

index 5ea435d4a52b543a312010d3f2911fd876cce717..2544867d409b6fbd0f8b7a065f841258cec5d33a 100644 (file)
@@ -3,21 +3,21 @@
  *
  * 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
  *
  */
 
index 9eaf88728e7eae30ed3dc4c67281d8da8fe68733..141b2d3fdc65c5c3c048a6c9e962a7e10f1c82c0 100644 (file)
 #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
  */
@@ -81,8 +95,7 @@ void xmpp_wholist_presence_dump(void)
                                && (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);
                        }
                }
        }
@@ -98,11 +111,20 @@ void xmpp_destroy_buddy(char *presence_jid) {
        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);
@@ -166,7 +188,7 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
                }
 
                /* Transmit presence information */
-               cprintf("<presence type=\"available\" from=\"%s\"></presence>", presence_jid);
+               xmpp_indicate_presence(presence_jid);
        }
 
        if (visible_sessions == 0) {