Mercurial > pidgin
comparison plugins/idle.c @ 11749:7da512f06185
[gaim-migrate @ 14040]
SF Patch #1335433, from sadrul ...who else? ;)
"Using the idle-maker plugin, Idle some account. Unidle
it. Idle it again. Now `Unset idle time for all
accounts'. Gaim seems to crash."
This looks good to me. It compiles.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 23 Oct 2005 13:12:08 +0000 |
parents | 78aad676fdb2 |
children | 55052a685da6 |
comparison
equal
deleted
inserted
replaced
11748:6fa0a37127fd | 11749:7da512f06185 |
---|---|
50 { | 50 { |
51 time_t t = time(NULL); /* grab the current time */ | 51 time_t t = time(NULL); /* grab the current time */ |
52 GaimConnection *gc = gaim_account_get_connection(acct); | 52 GaimConnection *gc = gaim_account_get_connection(acct); |
53 GaimPresence *presence = gaim_account_get_presence(acct); | 53 GaimPresence *presence = gaim_account_get_presence(acct); |
54 | 54 |
55 if (!gc) | |
56 return; | |
57 | |
55 gaim_debug(GAIM_DEBUG_INFO, "idle", | 58 gaim_debug(GAIM_DEBUG_INFO, "idle", |
56 "setting idle time for %s to %d\n", | 59 "setting idle time for %s to %d\n", |
57 gaim_account_get_username(acct), mins_idle); | 60 gaim_account_get_username(acct), mins_idle); |
58 | 61 |
59 t -= 60 * mins_idle; /* subtract seconds idle from current time */ | 62 t -= 60 * mins_idle; /* subtract seconds idle from current time */ |
91 GaimAccount *acct = gaim_request_fields_get_account(fields, "acct"); | 94 GaimAccount *acct = gaim_request_fields_get_account(fields, "acct"); |
92 | 95 |
93 set_idle_time(acct, 0); /* unidle the account */ | 96 set_idle_time(acct, 0); /* unidle the account */ |
94 | 97 |
95 /* once the account has been unidled it shouldn't be in the list */ | 98 /* once the account has been unidled it shouldn't be in the list */ |
96 g_list_remove(idled_accts, acct); | 99 idled_accts = g_list_remove(idled_accts, acct); |
97 } | 100 } |
98 | 101 |
99 | 102 |
100 static void | 103 static void |
101 idle_action(GaimPluginAction *action) | 104 idle_action(GaimPluginAction *action) |
160 { | 163 { |
161 GList *l; | 164 GList *l; |
162 | 165 |
163 /* freeing the list here will cause segfaults if the user idles an account | 166 /* freeing the list here will cause segfaults if the user idles an account |
164 * after the list is freed */ | 167 * after the list is freed */ |
165 for (l = idled_accts; l; l = l->next) { | 168 for (l = idled_accts; l; ) { |
166 set_idle_time((GaimAccount *)(l->data), 0); | 169 GaimAccount *account = l->data; |
167 g_list_remove(idled_accts, l->data); | 170 set_idle_time(account, 0); |
171 l = l->next; | |
172 idled_accts = g_list_remove(idled_accts, account); | |
168 } | 173 } |
169 | 174 |
170 } | 175 } |
171 | 176 |
172 static GList * | 177 static GList * |