changeset 14313:8a2b571f9990

[gaim-migrate @ 17005] a prpl's set_idle function can be called before the login function this is because the signing-on signal is emitted, and there's a callback to check idle and update all the prpls attached to that signal this meant that if you were idle, and got disconnected from jabber, upon attempting to reconnect, you'd segfault I've changed how jabber handles idle updates to work around this. someone may want to audit the other prpls, to make sure their set_idle callbacks (if any) don't assume the connection is up committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Wed, 23 Aug 2006 16:36:58 +0000
parents ef05f400817f
children 8b8188fa98f4
files libgaim/protocols/jabber/iq.c libgaim/protocols/jabber/jabber.c libgaim/protocols/jabber/jabber.h
diffstat 3 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/jabber/iq.c	Wed Aug 23 14:49:40 2006 +0000
+++ b/libgaim/protocols/jabber/iq.c	Wed Aug 23 16:36:58 2006 +0000
@@ -145,7 +145,7 @@
 	const char *from;
 	const char *id;
 	xmlnode *query;
-	char *idle_time;
+	GaimPresence *gpresence;
 
 	type = xmlnode_get_attrib(packet, "type");
 	from = xmlnode_get_attrib(packet, "from");
@@ -158,9 +158,18 @@
 
 		query = xmlnode_get_child(iq->node, "query");
 
-		idle_time = g_strdup_printf("%ld", js->idle ? time(NULL) - js->idle : 0);
-		xmlnode_set_attrib(query, "seconds", idle_time);
-		g_free(idle_time);
+		gpresence = gaim_account_get_presence(js->gc->account);
+
+		if(gaim_presence_is_idle(gpresence)) {
+			time_t idle_time = gaim_presence_get_idle_time(gpresence);
+			char *idle_str;
+
+			idle_str = g_strdup_printf("%ld", time(NULL) - idle_time);
+			xmlnode_set_attrib(query, "seconds", idle_str);
+			g_free(idle_str);
+		} else {
+			xmlnode_set_attrib(query, "seconds", "0");
+		}
 
 		jabber_iq_send(iq);
 	}
--- a/libgaim/protocols/jabber/jabber.c	Wed Aug 23 14:49:40 2006 +0000
+++ b/libgaim/protocols/jabber/jabber.c	Wed Aug 23 16:36:58 2006 +0000
@@ -1040,13 +1040,14 @@
 	return g_strdup_printf("gaim%x", js->next_id++);
 }
 
-
+/*
 static void jabber_idle_set(GaimConnection *gc, int idle)
 {
 	JabberStream *js = gc->proto_data;
 
 	js->idle = idle ? time(NULL) - idle : idle;
 }
+*/
 
 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b)
 {
@@ -1847,7 +1848,7 @@
 	jabber_send_typing,				/* send_typing */
 	jabber_buddy_get_info,			/* get_info */
 	jabber_presence_send,			/* set_away */
-	jabber_idle_set,				/* set_idle */
+	NULL,							/* set_idle */
 	NULL,							/* change_passwd */
 	jabber_roster_add_buddy,		/* add_buddy */
 	NULL,							/* add_buddies */
--- a/libgaim/protocols/jabber/jabber.h	Wed Aug 23 14:49:40 2006 +0000
+++ b/libgaim/protocols/jabber/jabber.h	Wed Aug 23 16:36:58 2006 +0000
@@ -111,8 +111,6 @@
 	GList *oob_file_transfers;
 	GList *file_transfers;
 
-	time_t idle;
-
 	JabberID *user;
 	GaimConnection *gc;
 	GaimSslConnection *gsc;