diff options
Diffstat (limited to 'src/gui/curses')
-rw-r--r-- | src/gui/curses/gui-display.c | 24 | ||||
-rw-r--r-- | src/gui/curses/gui-input.c | 35 |
2 files changed, 55 insertions, 4 deletions
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c index 3c89eeeea..2da714033 100644 --- a/src/gui/curses/gui-display.c +++ b/src/gui/curses/gui-display.c @@ -1013,8 +1013,11 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) /* display list of other active windows (if any) with numbers */ if (hotlist) { + gui_window_set_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); + wprintw (ptr_win->win_status, "["); gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, _("[Act: ")); + wprintw (ptr_win->win_status, _("Act: ")); for (ptr_hotlist = hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist) { @@ -1045,10 +1048,27 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) wprintw (ptr_win->win_status, ","); } gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "]"); } + /* display lag */ + if (SERVER(ptr_win->buffer)) + { + if (SERVER(ptr_win->buffer)->lag / 1000 >= cfg_irc_lag_min_show) + { + gui_window_set_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); + wprintw (ptr_win->win_status, "["); + gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS); + wprintw (ptr_win->win_status, _("Lag: %.1f"), + ((float)(SERVER(ptr_win->buffer)->lag)) / 1000); + gui_window_set_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); + wprintw (ptr_win->win_status, "]"); + } + } + /* display "-MORE-" if last line is not displayed */ gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE); if (ptr_win->sub_lines > 0) diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c index eec1532ff..9001587b6 100644 --- a/src/gui/curses/gui-input.c +++ b/src/gui/curses/gui-input.c @@ -634,9 +634,10 @@ void gui_main_loop () { fd_set read_fd; - static struct timeval timeout; + static struct timeval timeout, tv; + static struct timezone tz; t_irc_server *ptr_server; - int old_min, old_sec; + int old_min, old_sec, diff; time_t new_time; struct tm *local_time; @@ -680,8 +681,38 @@ gui_main_loop () && (new_time >= (ptr_server->reconnect_start + ptr_server->autoreconnect_delay))) server_reconnect (ptr_server); else + { + if (ptr_server->is_connected) + { + /* check for lag */ + if ((ptr_server->lag_check_time.tv_sec == 0) + && (new_time >= ptr_server->lag_next_check)) + { + server_sendf (ptr_server, "PING %s\r\n", ptr_server->address); + gettimeofday (&(ptr_server->lag_check_time), &tz); + } + + /* lag timeout => disconnect */ + if ((ptr_server->lag_check_time.tv_sec != 0) + && (cfg_irc_lag_disconnect > 0)) + { + gettimeofday (&tv, &tz); + diff = (int) get_timeval_diff (&(ptr_server->lag_check_time), &tv); + if (diff / 1000 > cfg_irc_lag_disconnect * 60) + { + irc_display_prefix (ptr_server->buffer, PREFIX_ERROR); + gui_printf (ptr_server->buffer, + _("%s lag is high, disconnecting from server...\n"), + WEECHAT_WARNING); + server_disconnect (ptr_server, 1); + continue; + } + } + } + if (ptr_server->sock4 >= 0) FD_SET (ptr_server->sock4, &read_fd); + } } if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout)) { |