diff 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
line wrap: on
line diff
--- a/mcabber/src/screen.c	Tue Jul 11 22:50:48 2006 +0200
+++ b/mcabber/src/screen.c	Fri Jul 14 19:32:23 2006 +0200
@@ -1300,16 +1300,20 @@
   }
 }
 
-unsigned int scr_GetAutoAwayTimeout()
+unsigned int scr_GetAutoAwayTimeout(time_t now)
 {
+  enum imstatus cur_st;
   unsigned int autoaway_timeout = settings_opt_get_int("autoaway");
-  time_t now;
 
   if (Autoaway || !autoaway_timeout)
-    return (unsigned)INT_MAX;
+    return 86400;
 
-  time(&now);
-  if (now > LastActivity + (time_t)autoaway_timeout)
+  cur_st = jb_getstatus();
+  // Auto-away is disabled for the following states
+  if ((cur_st != available) && (cur_st != freeforchat))
+    return 86400;
+
+  if (now >= LastActivity + (time_t)autoaway_timeout)
     return 0;
   else
     return LastActivity + (time_t)autoaway_timeout - now;