diff libgaim/protocols/jabber/iq.c @ 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 8a6154a52b84
children 6e89bfd2b33f
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);
 	}