summaryrefslogtreecommitdiff
path: root/src/plugins/relay
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-08-07 10:04:47 +0200
committerSébastien Helleu <flashcode@flashtux.org>2022-08-07 10:04:47 +0200
commit441d532f1507b5849d0d96f3bb5bcfd5a30d9d28 (patch)
tree5cb84b61b761ee31b7592a521ab4b10b5e54e031 /src/plugins/relay
parent57c9f371bc42e35e87e1e9c18b3c6fb09cf41672 (diff)
downloadweechat-441d532f1507b5849d0d96f3bb5bcfd5a30d9d28.zip
relay: fix refresh of relay buffer after /upgrade
Diffstat (limited to 'src/plugins/relay')
-rw-r--r--src/plugins/relay/relay-buffer.c166
-rw-r--r--src/plugins/relay/relay-upgrade.c2
2 files changed, 85 insertions, 83 deletions
diff --git a/src/plugins/relay/relay-buffer.c b/src/plugins/relay/relay-buffer.c
index e89d1477e..e693025ae 100644
--- a/src/plugins/relay/relay-buffer.c
+++ b/src/plugins/relay/relay-buffer.c
@@ -49,104 +49,104 @@ relay_buffer_refresh (const char *hotlist)
int i, length, line;
struct tm *date_tmp;
- if (relay_buffer)
+ if (!relay_buffer)
+ return;
+
+ weechat_buffer_clear (relay_buffer);
+ line = 0;
+ client_selected = relay_client_search_by_number (relay_buffer_selected_line);
+ weechat_printf_y (relay_buffer, 0,
+ "%s%s%s%s%s%s%s",
+ weechat_color ("green"),
+ _("Actions (letter+enter):"),
+ weechat_color ("lightgreen"),
+ /* disconnect */
+ (client_selected
+ && !RELAY_CLIENT_HAS_ENDED(client_selected)) ?
+ _(" [D] Disconnect") : "",
+ /* remove */
+ (client_selected
+ && RELAY_CLIENT_HAS_ENDED(client_selected)) ?
+ _(" [R] Remove") : "",
+ /* purge old */
+ _(" [P] Purge finished"),
+ /* quit */
+ _(" [Q] Close this buffer"));
+ for (ptr_client = relay_clients; ptr_client;
+ ptr_client = ptr_client->next_client)
{
- weechat_buffer_clear (relay_buffer);
- line = 0;
- client_selected = relay_client_search_by_number (relay_buffer_selected_line);
- weechat_printf_y (relay_buffer, 0,
- "%s%s%s%s%s%s%s",
- weechat_color ("green"),
- _("Actions (letter+enter):"),
- weechat_color ("lightgreen"),
- /* disconnect */
- (client_selected
- && !RELAY_CLIENT_HAS_ENDED(client_selected)) ?
- _(" [D] Disconnect") : "",
- /* remove */
- (client_selected
- && RELAY_CLIENT_HAS_ENDED(client_selected)) ?
- _(" [R] Remove") : "",
- /* purge old */
- _(" [P] Purge finished"),
- /* quit */
- _(" [Q] Close this buffer"));
- for (ptr_client = relay_clients; ptr_client;
- ptr_client = ptr_client->next_client)
- {
- snprintf (str_color, sizeof (str_color),
- "%s,%s",
- (line == relay_buffer_selected_line) ?
- weechat_config_string (relay_config_color_text_selected) :
- weechat_config_string (relay_config_color_text),
- weechat_config_string (relay_config_color_text_bg));
+ snprintf (str_color, sizeof (str_color),
+ "%s,%s",
+ (line == relay_buffer_selected_line) ?
+ weechat_config_string (relay_config_color_text_selected) :
+ weechat_config_string (relay_config_color_text),
+ weechat_config_string (relay_config_color_text_bg));
- snprintf (str_status, sizeof (str_status),
- "%s", _(relay_client_status_string[ptr_client->status]));
- length = weechat_utf8_strlen_screen (str_status);
- if (length < 20)
+ snprintf (str_status, sizeof (str_status),
+ "%s", _(relay_client_status_string[ptr_client->status]));
+ length = weechat_utf8_strlen_screen (str_status);
+ if (length < 20)
+ {
+ for (i = 0; i < 20 - length; i++)
{
- for (i = 0; i < 20 - length; i++)
- {
- strcat (str_status, " ");
- }
+ strcat (str_status, " ");
}
+ }
- str_date_start[0] = '\0';
- date_tmp = localtime (&(ptr_client->start_time));
+ str_date_start[0] = '\0';
+ date_tmp = localtime (&(ptr_client->start_time));
+ if (date_tmp)
+ {
+ if (strftime (str_date_start, sizeof (str_date_start),
+ "%a, %d %b %Y %H:%M:%S", date_tmp) == 0)
+ str_date_start[0] = '\0';
+ }
+ str_date_end[0] = '-';
+ str_date_end[1] = '\0';
+ if (ptr_client->end_time > 0)
+ {
+ date_tmp = localtime (&(ptr_client->end_time));
if (date_tmp)
{
- if (strftime (str_date_start, sizeof (str_date_start),
+ if (strftime (str_date_end, sizeof (str_date_end),
"%a, %d %b %Y %H:%M:%S", date_tmp) == 0)
- str_date_start[0] = '\0';
- }
- str_date_end[0] = '-';
- str_date_end[1] = '\0';
- if (ptr_client->end_time > 0)
- {
- date_tmp = localtime (&(ptr_client->end_time));
- if (date_tmp)
- {
- if (strftime (str_date_end, sizeof (str_date_end),
- "%a, %d %b %Y %H:%M:%S", date_tmp) == 0)
- str_date_end[0] = '\0';
- }
+ str_date_end[0] = '\0';
}
+ }
- str_recv = weechat_string_format_size (ptr_client->bytes_recv);
- str_sent = weechat_string_format_size (ptr_client->bytes_sent);
+ str_recv = weechat_string_format_size (ptr_client->bytes_recv);
+ str_sent = weechat_string_format_size (ptr_client->bytes_sent);
- /* first line with status, description and bytes recv/sent */
- weechat_printf_y (relay_buffer, (line * 2) + 2,
- _("%s%s[%s%s%s%s] %s, received: %s, sent: %s"),
- weechat_color (str_color),
- (line == relay_buffer_selected_line) ? "*** " : " ",
- weechat_color (weechat_config_string (relay_config_color_status[ptr_client->status])),
- str_status,
- weechat_color ("reset"),
- weechat_color (str_color),
- ptr_client->desc,
- (str_recv) ? str_recv : "?",
- (str_sent) ? str_sent : "?");
+ /* first line with status, description and bytes recv/sent */
+ weechat_printf_y (relay_buffer, (line * 2) + 2,
+ _("%s%s[%s%s%s%s] %s, received: %s, sent: %s"),
+ weechat_color (str_color),
+ (line == relay_buffer_selected_line) ? "*** " : " ",
+ weechat_color (weechat_config_string (relay_config_color_status[ptr_client->status])),
+ str_status,
+ weechat_color ("reset"),
+ weechat_color (str_color),
+ ptr_client->desc,
+ (str_recv) ? str_recv : "?",
+ (str_sent) ? str_sent : "?");
- /* second line with start/end time */
- weechat_printf_y (relay_buffer, (line * 2) + 3,
- _("%s%-26s started on: %s, ended on: %s"),
- weechat_color (str_color),
- " ",
- str_date_start,
- str_date_end);
+ /* second line with start/end time */
+ weechat_printf_y (relay_buffer, (line * 2) + 3,
+ _("%s%-26s started on: %s, ended on: %s"),
+ weechat_color (str_color),
+ " ",
+ str_date_start,
+ str_date_end);
- if (str_recv)
- free (str_recv);
- if (str_sent)
- free (str_sent);
+ if (str_recv)
+ free (str_recv);
+ if (str_sent)
+ free (str_sent);
- line++;
- }
- if (hotlist)
- weechat_buffer_set (relay_buffer, "hotlist", hotlist);
+ line++;
}
+ if (hotlist)
+ weechat_buffer_set (relay_buffer, "hotlist", hotlist);
}
/*
diff --git a/src/plugins/relay/relay-upgrade.c b/src/plugins/relay/relay-upgrade.c
index ba7b7408b..f3711590f 100644
--- a/src/plugins/relay/relay-upgrade.c
+++ b/src/plugins/relay/relay-upgrade.c
@@ -250,5 +250,7 @@ relay_upgrade_load ()
weechat_upgrade_close (upgrade_file);
+ relay_buffer_refresh (NULL);
+
return rc;
}