Mercurial > hg
comparison mcabber/src/screen.c @ 940:fc30221b952d
Fix an autoaway problem
This patch fixes an autoaway related issue introduced in the previous
changeset.
scr_GetAutoAwayTimeout() should not return a null timeout when the user
status do not need auto-away (i.e. status != online,free).
This patch also tries to save a few time() calls.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 14 Jul 2006 19:32:23 +0200 |
parents | 12fa2ae6445d |
children | aec71ebf98fa |
comparison
equal
deleted
inserted
replaced
939:12fa2ae6445d | 940:fc30221b952d |
---|---|
1298 oldmsg = NULL; | 1298 oldmsg = NULL; |
1299 } | 1299 } |
1300 } | 1300 } |
1301 } | 1301 } |
1302 | 1302 |
1303 unsigned int scr_GetAutoAwayTimeout() | 1303 unsigned int scr_GetAutoAwayTimeout(time_t now) |
1304 { | 1304 { |
1305 enum imstatus cur_st; | |
1305 unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); | 1306 unsigned int autoaway_timeout = settings_opt_get_int("autoaway"); |
1306 time_t now; | |
1307 | 1307 |
1308 if (Autoaway || !autoaway_timeout) | 1308 if (Autoaway || !autoaway_timeout) |
1309 return (unsigned)INT_MAX; | 1309 return 86400; |
1310 | 1310 |
1311 time(&now); | 1311 cur_st = jb_getstatus(); |
1312 if (now > LastActivity + (time_t)autoaway_timeout) | 1312 // Auto-away is disabled for the following states |
1313 if ((cur_st != available) && (cur_st != freeforchat)) | |
1314 return 86400; | |
1315 | |
1316 if (now >= LastActivity + (time_t)autoaway_timeout) | |
1313 return 0; | 1317 return 0; |
1314 else | 1318 else |
1315 return LastActivity + (time_t)autoaway_timeout - now; | 1319 return LastActivity + (time_t)autoaway_timeout - now; |
1316 } | 1320 } |
1317 | 1321 |