From 73476cc0f861f8dc160afc4021c38032d2a2c567 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Mon, 12 Mar 2012 11:55:35 +0100 Subject: [PATCH] irc: fix redirection of message when message is queued for sending on server --- ChangeLog | 1 + doc/de/autogen/plugin_api/hdata.txt | 1 + doc/en/autogen/plugin_api/hdata.txt | 1 + doc/fr/autogen/plugin_api/hdata.txt | 1 + doc/it/autogen/plugin_api/hdata.txt | 1 + src/plugins/irc/irc-redirect.c | 8 +++++++- src/plugins/irc/irc-redirect.h | 1 + src/plugins/irc/irc-server.c | 3 +++ src/plugins/irc/irc-upgrade.c | 1 + 9 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 156fa960a..8e229a4fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ Version 0.3.8 (under dev!) (task #11316) * core: fix display of wide chars on last column of chat area (patch #7733) * api: add list "gui_buffer_last_displayed" in hdata "buffer" +* irc: fix redirection of message when message is queued for sending on server * irc: add signals and tags in messages for irc notify (task #11887) * irc: check notify immediately when adding a nick to notify list, improve first notify message for a nick (bug #35731) diff --git a/doc/de/autogen/plugin_api/hdata.txt b/doc/de/autogen/plugin_api/hdata.txt index 5dca081e5..30efe0f6a 100644 --- a/doc/de/autogen/plugin_api/hdata.txt +++ b/doc/de/autogen/plugin_api/hdata.txt @@ -78,6 +78,7 @@ 'string' (string) + 'timeout' (integer) + 'command' (string) + + 'assigned_to_command' (integer) + 'start_time' (time) + 'cmd_start' (hashtable) + 'cmd_stop' (hashtable) + diff --git a/doc/en/autogen/plugin_api/hdata.txt b/doc/en/autogen/plugin_api/hdata.txt index 2a53e02f9..113e07c5f 100644 --- a/doc/en/autogen/plugin_api/hdata.txt +++ b/doc/en/autogen/plugin_api/hdata.txt @@ -78,6 +78,7 @@ 'string' (string) + 'timeout' (integer) + 'command' (string) + + 'assigned_to_command' (integer) + 'start_time' (time) + 'cmd_start' (hashtable) + 'cmd_stop' (hashtable) + diff --git a/doc/fr/autogen/plugin_api/hdata.txt b/doc/fr/autogen/plugin_api/hdata.txt index 9b354bda4..4922cd9ae 100644 --- a/doc/fr/autogen/plugin_api/hdata.txt +++ b/doc/fr/autogen/plugin_api/hdata.txt @@ -78,6 +78,7 @@ 'string' (string) + 'timeout' (integer) + 'command' (string) + + 'assigned_to_command' (integer) + 'start_time' (time) + 'cmd_start' (hashtable) + 'cmd_stop' (hashtable) + diff --git a/doc/it/autogen/plugin_api/hdata.txt b/doc/it/autogen/plugin_api/hdata.txt index ab2afba6d..85ed25878 100644 --- a/doc/it/autogen/plugin_api/hdata.txt +++ b/doc/it/autogen/plugin_api/hdata.txt @@ -78,6 +78,7 @@ 'string' (string) + 'timeout' (integer) + 'command' (string) + + 'assigned_to_command' (integer) + 'start_time' (time) + 'cmd_start' (hashtable) + 'cmd_stop' (hashtable) + diff --git a/src/plugins/irc/irc-redirect.c b/src/plugins/irc/irc-redirect.c index 1059e4069..90a7ae1bf 100644 --- a/src/plugins/irc/irc-redirect.c +++ b/src/plugins/irc/irc-redirect.c @@ -458,6 +458,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server, new_redirect->string = (string) ? strdup (string) : NULL; new_redirect->timeout = timeout; new_redirect->command = NULL; + new_redirect->assigned_to_command = 0; new_redirect->start_time = 0; new_redirect->cmd_start = hash_cmd[0]; new_redirect->cmd_stop = hash_cmd[1]; @@ -557,7 +558,7 @@ irc_redirect_search_available (struct t_irc_server *server) for (ptr_redirect = server->redirects; ptr_redirect; ptr_redirect = ptr_redirect->next_redirect) { - if (ptr_redirect->start_time == 0) + if (!ptr_redirect->assigned_to_command) return ptr_redirect; } @@ -592,6 +593,7 @@ irc_redirect_init_command (struct t_irc_redirect *redirect, else redirect->command = NULL; + redirect->assigned_to_command = 1; redirect->start_time = time (NULL); if (weechat_irc_plugin->debug >= 2) @@ -1013,6 +1015,7 @@ irc_redirect_hdata_redirect_cb (void *data, const char *hdata_name) WEECHAT_HDATA_VAR(struct t_irc_redirect, string, STRING, NULL); WEECHAT_HDATA_VAR(struct t_irc_redirect, timeout, INTEGER, NULL); WEECHAT_HDATA_VAR(struct t_irc_redirect, command, STRING, NULL); + WEECHAT_HDATA_VAR(struct t_irc_redirect, assigned_to_command, INTEGER, NULL); WEECHAT_HDATA_VAR(struct t_irc_redirect, start_time, TIME, NULL); WEECHAT_HDATA_VAR(struct t_irc_redirect, cmd_start, HASHTABLE, NULL); WEECHAT_HDATA_VAR(struct t_irc_redirect, cmd_stop, HASHTABLE, NULL); @@ -1098,6 +1101,8 @@ irc_redirect_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_string (ptr_item, "command", redirect->command)) return 0; + if (!weechat_infolist_new_var_integer (ptr_item, "assigned_to_command", redirect->assigned_to_command)) + return 0; if (!weechat_infolist_new_var_time (ptr_item, "start_time", redirect->start_time)) return 0; if (!weechat_infolist_new_var_string (ptr_item, "cmd_start", weechat_hashtable_get_string (redirect->cmd_start, "keys_values"))) @@ -1169,6 +1174,7 @@ irc_redirect_print_log (struct t_irc_server *server) weechat_log_printf (" string. . . . . . . : '%s'", ptr_redirect->string); weechat_log_printf (" timeout . . . . . . : %d", ptr_redirect->timeout); weechat_log_printf (" command . . . . . . : '%s'", ptr_redirect->command); + weechat_log_printf (" assigned_to_command : %d", ptr_redirect->assigned_to_command); weechat_log_printf (" start_time. . . . . : %ld", ptr_redirect->start_time); weechat_log_printf (" cmd_start . . . . . : 0x%lx (hashtable: '%s')", ptr_redirect->cmd_start, diff --git a/src/plugins/irc/irc-redirect.h b/src/plugins/irc/irc-redirect.h index d2d092de7..f9fbf9f4e 100644 --- a/src/plugins/irc/irc-redirect.h +++ b/src/plugins/irc/irc-redirect.h @@ -54,6 +54,7 @@ struct t_irc_redirect int timeout; /* timeout (in seconds) */ char *command; /* command sent to server, which is */ /* redirected */ + int assigned_to_command; /* 1 if assigned to a command */ time_t start_time; /* time when command is sent to server */ /* (this is begining of this redirect) */ struct t_hashtable *cmd_start; /* command(s) starting redirection */ diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 9a22397a7..04f7b3752 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1769,6 +1769,9 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags, (new_msg) ? 1 : 0, tags_to_send, ptr_redirect); + /* mark redirect as "used" */ + if (ptr_redirect) + ptr_redirect->assigned_to_command = 1; } else { diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index 974df36a4..fe2ef7540 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -568,6 +568,7 @@ irc_upgrade_read_cb (void *data, str = weechat_infolist_string (infolist, "command"); if (str) ptr_redirect->command = strdup (str); + ptr_redirect->assigned_to_command = weechat_infolist_integer (infolist, "assigned_to_command"); ptr_redirect->start_time = weechat_infolist_time (infolist, "start_time"); ptr_redirect->cmd_start_received = weechat_infolist_integer (infolist, "cmd_start_received"); ptr_redirect->cmd_stop_received = weechat_infolist_integer (infolist, "cmd_stop_received");