pidgin: 90901b2c: Stop trying to be clever with XMPP keepa...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Tue May 19 20:40:40 EDT 2009


-----------------------------------------------------------------
Revision: 90901b2c41b0b1a7856d9fb15fb2eb3b67383423
Ancestor: f31c237230f5ba1bbcda8aa1d4017c909484430d
Author: darkrain42 at pidgin.im
Date: 2009-05-20T00:34:59
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/90901b2c41b0b1a7856d9fb15fb2eb3b67383423

Modified files:
        libpurple/protocols/jabber/jabber.c
        libpurple/protocols/jabber/ping.c
        libpurple/protocols/jabber/ping.h

ChangeLog: 

Stop trying to be clever with XMPP keepalive pings.

djabberd is responding like this (note no 'from' on the reply. No, I haven't yet filed a bug with them):
C: <iq type='get' id='purplefc9e10a4' to='livejournal.com'><ping xmlns='urn:xmpp:ping'/></iq>
S: <iq to='Adium user' type='error' id='purplefc9e10a4'><ping xmlns='urn:xmpp:ping'/><error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='en'>This feature is not implemented yet in DJabberd.</text></error></iq>

This fixes Adium#12124.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c	f61a71df206bfcebf263458cdb67d84177e88eb0
+++ libpurple/protocols/jabber/jabber.c	60ad9561ac2d1b2e37b6c8dbdb73dd5db91d6591
@@ -483,7 +483,7 @@ void jabber_keepalive(PurpleConnection *
 	JabberStream *js = gc->proto_data;
 
 	if (js->keepalive_timeout == -1) {
-		jabber_ping_jid(js, js->user->domain);
+		jabber_keepalive_ping(js);
 		js->keepalive_timeout = purple_timeout_add_seconds(120,
 				(GSourceFunc)(jabber_keepalive_timeout), gc);
 	}
============================================================
--- libpurple/protocols/jabber/ping.c	ffdd7f6e30b2315ae6cb61d9b16599ac486493a6
+++ libpurple/protocols/jabber/ping.c	6633b410f413b9f686cab70d6e83e806d8074f98
@@ -28,7 +28,9 @@
 #include "ping.h"
 #include "iq.h"
 
-static void jabber_keepalive_pong_cb(JabberStream *js)
+static void jabber_keepalive_pong_cb(JabberStream *js, const char *from,
+                                     JabberIqType type, const char *id,
+                                     xmlnode *packet, gpointer data)
 {
 	if (js->keepalive_timeout >= 0) {
 		purple_timeout_remove(js->keepalive_timeout);
@@ -57,18 +59,25 @@ static void jabber_ping_result_cb(Jabber
                                   JabberIqType type, const char *id,
                                   xmlnode *packet, gpointer data)
 {
-	if (purple_strequal(from, js->user->domain))
-		/* If the pong is from the server, assume it's a result of the
-		 * keepalive functions */
-		jabber_keepalive_pong_cb(js);
-	else {
-		if (type == JABBER_IQ_RESULT)
-			purple_debug_info("jabber", "PONG!\n");
-		else
-			purple_debug_info("jabber", "ping not supported\n");
-	}
+	if (type == JABBER_IQ_RESULT)
+		purple_debug_info("jabber", "PONG!\n");
+	else
+		purple_debug_info("jabber", "ping not supported\n");
 }
 
+void jabber_keepalive_ping(JabberStream *js)
+{
+	JabberIq *iq;
+	xmlnode *ping;
+
+	iq = jabber_iq_new(js, JABBER_IQ_GET);
+	ping = xmlnode_new_child(iq->node, "ping");
+	xmlnode_set_namespace(ping, "urn:xmpp:ping");
+
+	jabber_iq_set_callback(iq, jabber_keepalive_pong_cb, NULL);
+	jabber_iq_send(iq);
+}
+
 gboolean jabber_ping_jid(JabberStream *js, const char *jid)
 {
 	JabberIq *iq;
============================================================
--- libpurple/protocols/jabber/ping.h	80ddcb823753bb35f3422d3bdb7a6eba937f2dd7
+++ libpurple/protocols/jabber/ping.h	11a3aba5aac7ffcdba86b64b61165c05d46d7917
@@ -29,5 +29,6 @@ gboolean jabber_ping_jid(JabberStream *j
 void jabber_ping_parse(JabberStream *js, const char *from,
                        JabberIqType, const char *id, xmlnode *child);
 gboolean jabber_ping_jid(JabberStream *js, const char *jid);
+void jabber_keepalive_ping(JabberStream *js);
 
 #endif /* PURPLE_JABBER_PING_H_ */


More information about the Commits mailing list