# HG changeset patch # User Nathan Walp # Date 1156351018 0 # Node ID 8a2b571f999096c0fb3fed38cf40679d92bde6da # Parent ef05f400817f514ba3f1ec163a1b32383cc5e953 [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 diff -r ef05f400817f -r 8a2b571f9990 libgaim/protocols/jabber/iq.c --- 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); } diff -r ef05f400817f -r 8a2b571f9990 libgaim/protocols/jabber/jabber.c --- 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 */ diff -r ef05f400817f -r 8a2b571f9990 libgaim/protocols/jabber/jabber.h --- 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;