changeset 27001:a6a4b440e5ae

merge of '53630753bb021f7391e8ad30abd709f73fe47c3d' and '90901b2c41b0b1a7856d9fb15fb2eb3b67383423'
author Paul Aurich <paul@darkrain42.org>
date Wed, 20 May 2009 00:39:12 +0000
parents 65fadd6977b4 (current diff) 6b0e150f2276 (diff)
children c9ac5cc1e46c 3e83f63b16b4 2e849a9adc01
files
diffstat 3 files changed, 22 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Tue May 19 21:35:08 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Wed May 20 00:39:12 2009 +0000
@@ -483,7 +483,7 @@
 	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);
 	}
--- a/libpurple/protocols/jabber/ping.c	Tue May 19 21:35:08 2009 +0000
+++ b/libpurple/protocols/jabber/ping.c	Wed May 20 00:39:12 2009 +0000
@@ -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,16 +59,23 @@
                                   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)
--- a/libpurple/protocols/jabber/ping.h	Tue May 19 21:35:08 2009 +0000
+++ b/libpurple/protocols/jabber/ping.h	Wed May 20 00:39:12 2009 +0000
@@ -29,5 +29,6 @@
 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_ */