Mercurial > pidgin.yaz
changeset 12825:bd80fb1e8406
[gaim-migrate @ 15173]
This fixes a problem Bleeter told me about where
1. Set yourself idle using the idle maker
2. Wait 10 minutes, for Gaim's built-in idle tracker to kick in and
do nothing
3. When you return your computer and Gaim's built-in idle tracker
detects that you are back, it will incorrectly set you to unidle
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 11 Jan 2006 06:16:33 +0000 |
parents | 7b8e885c1be3 |
children | 74eb10cead7f |
files | src/idle.c |
diffstat | 1 files changed, 29 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/idle.c Wed Jan 11 05:53:45 2006 +0000 +++ b/src/idle.c Wed Jan 11 06:16:33 2006 +0000 @@ -47,10 +47,11 @@ * This is needed for the I'dle Mak'er plugin to work correctly. We * use it to determine if we're the ones who set our accounts idle * or if someone else did it (the I'dle Mak'er plugin, for example). - * If our accounts are marked as idle and have_set_idle is FALSE and - * the user moves the mouse, then we will NOT unidle our accounts. + * Basically we just keep track of which accounts were set idle by us, + * and then we'll only set these specific accounts unidle when the + * user returns. */ -static gboolean have_set_idle = FALSE; +static GList *idled_accts = NULL; static guint idle_timer = 0; @@ -118,12 +119,10 @@ } static void -set_account_idle(GaimConnection *gc, int time_idle) +set_account_idle(GaimAccount *account, int time_idle) { - GaimAccount *account; GaimPresence *presence; - account = gaim_connection_get_account(gc); presence = gaim_account_get_presence(account); if (gaim_presence_is_idle(presence)) @@ -133,17 +132,18 @@ gaim_debug_info("idle", "Setting %s idle %d seconds\n", gaim_account_get_username(account), time_idle); gaim_presence_set_idle(presence, TRUE, time(NULL) - time_idle); + idled_accts = g_list_prepend(idled_accts, account); } static void -set_account_unidle(GaimConnection *gc) +set_account_unidle(GaimAccount *account) { - GaimAccount *account; GaimPresence *presence; - account = gaim_connection_get_account(gc); presence = gaim_account_get_presence(account); + idled_accts = g_list_remove(idled_accts, account); + if (!gaim_presence_is_idle(presence)) /* This account is already unidle! */ return; @@ -217,17 +217,18 @@ } /* Idle reporting stuff */ - if (report_idle && (time_idle >= IDLEMARK) && !have_set_idle) + if (report_idle && (time_idle >= IDLEMARK)) { for (l = gaim_connections_get_all(); l != NULL; l = l->next) - set_account_idle(l->data, time_idle); - have_set_idle = TRUE; + { + GaimConnection *gc = l->data; + set_account_idle(gaim_connection_get_account(gc), time_idle); + } } - else if ((!report_idle || time_idle < IDLEMARK) && have_set_idle) + else if (!report_idle || (time_idle < IDLEMARK)) { - for (l = gaim_connections_get_all(); l != NULL; l = l->next) - set_account_unidle(l->data); - have_set_idle = FALSE; + while (idled_accts != NULL) + set_account_unidle(idled_accts->data); } return TRUE; @@ -241,6 +242,15 @@ check_idleness(); } +static void +signing_off_cb(GaimConnection *gc, void *data) +{ + GaimAccount *account; + + account = gaim_connection_get_account(gc); + idled_accts = g_list_remove(idled_accts, account); +} + void gaim_idle_touch() { @@ -282,6 +292,9 @@ gaim_signal_connect(gaim_conversations_get_handle(), "sent-im-msg", gaim_idle_get_handle(), GAIM_CALLBACK(im_msg_sent_cb), NULL); + gaim_signal_connect(gaim_connections_get_handle(), "signing-off", + gaim_idle_get_handle(), + GAIM_CALLBACK(signing_off_cb), NULL); gaim_idle_touch(); }