From d6c105861cfb686ad539196b334394b264e5f8af Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Sun, 5 Sep 2010 08:37:04 +0000 Subject: [PATCH] Fix auto-away time strangeness when server reconnection happens. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@94 13b04d17-f746-0410-82c6-800466cd88b0 --- include/misc.h | 2 +- source/irc.c | 7 +++---- source/misc.c | 14 ++++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/misc.h b/include/misc.h index 7adedc8..92849eb 100644 --- a/include/misc.h +++ b/include/misc.h @@ -79,7 +79,7 @@ extern LastMsg last_sent_ctcp[2]; void clear_array (NickTab **, char *); char *BX_random_str (int, int); int check_serverlag (void); - void auto_away (unsigned long); + void check_auto_away (time_t); ChannelList * BX_prepare_command (int *, char *, int); int rename_file (char *, char **); void putlog (int, ...); diff --git a/source/irc.c b/source/irc.c index c674415..049e084 100644 --- a/source/irc.c +++ b/source/irc.c @@ -328,15 +328,14 @@ char *BX_update_clock(int flag) do_hook(TIMER_LIST, "%02d:%02d", hour, min); if (min == 0 || new_hour) do_hook(TIMER_HOUR_LIST, "%02d:%02d", hour, min); - idlet = (hideous - idle_time) / 60L; + idlet = hideous - idle_time; if (from_server != -1) is_away = get_server_away(from_server) ? 1 : 0; - if (do_hook(IDLE_LIST, "%lu", (unsigned long)idlet)) + if (do_hook(IDLE_LIST, "%lu", (unsigned long)idlet / 60)) { if (is_away && new_hour && get_int_var(TIMESTAMP_AWAYLOG_HOURLY_VAR)) logmsg(LOG_CRAP, NULL, 4, NULL); - if (!is_away && get_int_var(AUTO_AWAY_TIME_VAR) && (idlet >= get_int_var(AUTO_AWAY_TIME_VAR)/60)) - auto_away(idlet); + check_auto_away(idlet); } check_channel_limits(); } diff --git a/source/misc.c b/source/misc.c index ba945e0..4a82f58 100644 --- a/source/misc.c +++ b/source/misc.c @@ -1184,24 +1184,26 @@ char *BX_random_str(int min, int max) } -void auto_away(unsigned long idle_mins) +void check_auto_away(time_t idlet) { int i; char *msg = NULL; - - if (!get_int_var(AUTO_AWAY_VAR)) + int auto_away_time = get_int_var(AUTO_AWAY_TIME_VAR); + int idle_mins = auto_away_time / 60; + + if (!auto_away_time || !get_int_var(AUTO_AWAY_VAR) || idlet < auto_away_time) return; if (awaymsg) - malloc_sprintf(&msg, "%s: [%lu mins]", convert_output_format(awaymsg, NULL), idle_mins); + malloc_sprintf(&msg, "%s: [%d mins]", convert_output_format(awaymsg, NULL), idle_mins); else - malloc_sprintf(&msg, "Auto-Away after %lu mins", idle_mins); + malloc_sprintf(&msg, "Auto-Away after %d mins", idle_mins); for (i = 0; i < server_list_size(); i++) if (is_server_connected(i) && !get_server_away(i)) set_server_away(i, msg, 0); - update_all_status(current_window, NULL, 0); + update_all_status(current_window, NULL, 0); new_free(&msg); }