changeset 21969:27d665278485

merge of '7e8103bd3c5298a43a4e18bb59037980f5c213c9' and 'dc6923294f5f33ff7a52a998e1b9e9ad47be0211'
author Evan Schoenberg <evan.s@dreskin.net>
date Wed, 02 Jan 2008 06:42:29 +0000
parents a463f05b4566 (current diff) eaaac273d80c (diff)
children a83a70314f8a
files
diffstat 3 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Mon Dec 31 03:06:42 2007 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Wed Jan 02 06:42:29 2008 +0000
@@ -391,25 +391,27 @@
 static void jabber_pong_cb(JabberStream *js, xmlnode *packet, gpointer timeout) 
 {
 	purple_timeout_remove(GPOINTER_TO_INT(timeout));
+	js->keepalive_timeout = -1;
 }
 
 static gboolean jabber_pong_timeout(PurpleConnection *gc)
 {
 	purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 					_("Ping timeout"));
+	js->keepalive_timeout = -1;
 	return FALSE;
 }
 
 void jabber_keepalive(PurpleConnection *gc)
 {
-	JabberIq *iq = jabber_iq_new(gc->proto_data, JABBER_IQ_GET);
-	guint timeout;
+	JabberStream *js = gc->proto_data;
+	JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET);
 
-        xmlnode *ping = xmlnode_new_child(iq->node, "ping");
-        xmlnode_set_namespace(ping, "urn:xmpp:ping");
+	xmlnode *ping = xmlnode_new_child(iq->node, "ping");
+	xmlnode_set_namespace(ping, "urn:xmpp:ping");
 
-	timeout = purple_timeout_add_seconds(20, (GSourceFunc)(jabber_pong_timeout), gc);
-        jabber_iq_set_callback(iq, jabber_pong_cb, GINT_TO_POINTER(timeout));
+	js->keepalive_timeout = purple_timeout_add_seconds(20, (GSourceFunc)(jabber_pong_timeout), gc);
+	jabber_iq_set_callback(iq, jabber_pong_cb, GINT_TO_POINTER(js->keepalive_timeout));
 	jabber_iq_send(iq);
 }
 
@@ -612,6 +614,7 @@
 	js->next_id = g_random_int();
 	js->write_buffer = purple_circ_buffer_new(512);
 	js->old_length = -1;
+	js->keepalive_timeout = -1;
 
 	if(!js->user) {
 		purple_connection_error_reason (gc,
@@ -1311,6 +1314,9 @@
 	g_free(js->old_uri);
 	g_free(js->old_track);
 
+	if (js->keepalive_timeout != -1)
+		purple_timeout_remove(js->keepalive_timeout);
+	
 	g_free(js);
 
 	gc->proto_data = NULL;
--- a/libpurple/protocols/jabber/jabber.h	Mon Dec 31 03:06:42 2007 +0000
+++ b/libpurple/protocols/jabber/jabber.h	Wed Jan 02 06:42:29 2008 +0000
@@ -193,6 +193,9 @@
 	char *old_track;
 	
 	char *host;
+	
+	/* A purple timeout tag for the keepalive */
+	int keepalive_timeout;
 };
 
 typedef gboolean (JabberFeatureEnabled)(JabberStream *js, const gchar *shortname, const gchar *namespace);
--- a/libpurple/protocols/myspace/myspace.c	Mon Dec 31 03:06:42 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Wed Jan 02 06:42:29 2008 +0000
@@ -2912,8 +2912,7 @@
 	menu = g_list_append(menu, act);
 #endif
 
-	act = purple_plugin_action_new(g_strdup_printf("%s",
-				_("Add friends from MySpace.com")), msim_import_friends);
+	act = purple_plugin_action_new(_("Add friends from MySpace.com"), msim_import_friends);
 	menu = g_list_append(menu, act);
 
 	return menu;