trigger: do not allow any changes on a trigger when it is currently running (closes #189)

v2.8-utf8proc
Sébastien Helleu 2014-09-20 14:51:09 +02:00
parent 6860aa491f
commit d1b4281d20
14 changed files with 196 additions and 36 deletions

View File

@ -44,6 +44,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* perl: fix detection of Perl >= 5.20 with autotools
* script: fix crash on "/script update" if a script detail is displayed in
buffer (closes #177)
* trigger: do not allow any changes on a trigger when it is currently running
(closes #189)
* trigger: fix regex used in default triggers to hide passwords ("\S" is not
supported on *BSD) (closes #172)

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-08-16 11:46+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -10014,6 +10014,12 @@ msgstr "Žádné rmodifikátory nejsou definovány"
msgid "List of default triggers:"
msgstr "Seznam aliasů:"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, fuzzy, c-format
msgid "Trigger \"%s\" restarted"
msgstr "Pole \"%s\" vytvořeno"

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-08-23 10:49+0100\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <weechatter@arcor.de>\n"
@ -11260,6 +11260,12 @@ msgstr "Kein Trigger definiert"
msgid "List of default triggers:"
msgstr "Liste der standardmäßigen Trigger:"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, c-format
msgid "Trigger \"%s\" restarted"
msgstr "Trigger \"%s\" neu gestartet"

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-08-16 11:46+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -10289,6 +10289,12 @@ msgstr "Ningún modificador regular definido"
msgid "List of default triggers:"
msgstr "Lista de alias:"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, fuzzy, c-format
msgid "Trigger \"%s\" restarted"
msgstr "Barra \"%s\" creada"

View File

@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"PO-Revision-Date: 2014-09-03 22:09+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-09-20 14:38+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@ -11014,6 +11014,14 @@ msgstr "Pas de trigger défini"
msgid "List of default triggers:"
msgstr "Liste des triggers par défaut :"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
"%s%s : l'action \"%s\" ne peut pas être exécutée sur le trigger \"%s\" car "
"il est actuellement en cours d'exécution"
#, c-format
msgid "Trigger \"%s\" restarted"
msgstr "Trigger \"%s\" redémarré"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-08-16 11:46+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -9384,6 +9384,12 @@ msgstr "Nincs aliasz definiálva.\n"
msgid "List of default triggers:"
msgstr "Aliaszok listája:\n"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, fuzzy, c-format
msgid "Trigger \"%s\" restarted"
msgstr "A \"%s\" => \"%s\" aliasz elkészült\n"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-08-16 11:46+0200\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -10467,6 +10467,12 @@ msgstr "Nessun rmodifier definito"
msgid "List of default triggers:"
msgstr "Elenco degli alias:"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, fuzzy, c-format
msgid "Trigger \"%s\" restarted"
msgstr "Barra \"%s\" creata"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-08-31 05:54+0900\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/weechat/tree/translation_ja>\n"
@ -10606,6 +10606,12 @@ msgstr "トリガは定義されていません"
msgid "List of default triggers:"
msgstr "デフォルトトリガのリスト:"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, c-format
msgid "Trigger \"%s\" restarted"
msgstr "トリガ \"%s\" を再開しました"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-09-14 00:18+0100\n"
"Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -10802,6 +10802,12 @@ msgstr "Nie zdefiniowano triggerów"
msgid "List of default triggers:"
msgstr "Lista domyślnych triggerów:"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, c-format
msgid "Trigger \"%s\" restarted"
msgstr "Trigger \"%s\" został zrestartowany"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-08-16 11:46+0200\n"
"Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -9659,6 +9659,12 @@ msgstr "Nenhuma rmodifier definido"
msgid "List of default triggers:"
msgstr "Lista de atalhos:"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, fuzzy, c-format
msgid "Trigger \"%s\" restarted"
msgstr "Barra \"%s\" criada"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-08-16 11:46+0200\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -9410,6 +9410,12 @@ msgstr "Сокращения не заданы.\n"
msgid "List of default triggers:"
msgstr "Список сокращений:\n"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, fuzzy, c-format
msgid "Trigger \"%s\" restarted"
msgstr "Сокращение \"%s\" => \"%s\" создано\n"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-07-25 07:50+0200\n"
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -8472,6 +8472,12 @@ msgstr ""
msgid "List of default triggers:"
msgstr "filtrelerin listesi"
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, fuzzy, c-format
msgid "Trigger \"%s\" restarted"
msgstr "Filtre \"%s\" etkin"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-09-03 22:08+0200\n"
"POT-Creation-Date: 2014-09-20 14:37+0200\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -8404,6 +8404,12 @@ msgstr ""
msgid "List of default triggers:"
msgstr ""
#, c-format
msgid ""
"%s%s: action \"%s\" can not be executed on trigger \"%s\" because it is "
"currently running"
msgstr ""
#, c-format
msgid "Trigger \"%s\" restarted"
msgstr ""

View File

@ -314,6 +314,20 @@ trigger_command_list_default (int verbose)
weechat_string_free_split (commands);
}
/*
* Displays an error if a trigger is running.
*/
void
trigger_command_error_running (struct t_trigger *trigger, const char *action)
{
weechat_printf_tags (NULL, "no_trigger",
_("%s%s: action \"%s\" can not be executed on "
"trigger \"%s\" because it is currently running"),
weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
action, trigger->name);
}
/*
* Set "enabled" value in a trigger.
*
@ -325,9 +339,16 @@ trigger_command_list_default (int verbose)
*/
void
trigger_command_set_enabled (struct t_trigger *trigger, int enable,
trigger_command_set_enabled (struct t_trigger *trigger,
int enable, const char *enable_string,
int display_error)
{
if (trigger->hook_running)
{
trigger_command_error_running (trigger, enable_string);
return;
}
if (enable == 2)
{
if (weechat_config_boolean (trigger->options[TRIGGER_OPTION_ENABLED]))
@ -539,7 +560,14 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
if (weechat_strcasecmp (argv[1], "addreplace") == 0)
{
if (ptr_trigger)
{
if (ptr_trigger->hook_running)
{
trigger_command_error_running (ptr_trigger, argv[1]);
goto end;
}
trigger_free (ptr_trigger);
}
}
else
{
@ -680,6 +708,11 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
argv[2]);
goto end;
}
if (ptr_trigger->hook_running)
{
trigger_command_error_running (ptr_trigger, argv[1]);
goto end;
}
if (weechat_strcasecmp (argv[3], "name") == 0)
{
trigger_command_rename (ptr_trigger, argv[4]);
@ -724,6 +757,11 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
argv[2]);
goto end;
}
if (ptr_trigger->hook_running)
{
trigger_command_error_running (ptr_trigger, argv[1]);
goto end;
}
trigger_command_rename (ptr_trigger, argv[3]);
goto end;
}
@ -814,7 +852,7 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
for (ptr_trigger = triggers; ptr_trigger;
ptr_trigger = ptr_trigger->next_trigger)
{
trigger_command_set_enabled (ptr_trigger, enable, 0);
trigger_command_set_enabled (ptr_trigger, enable, argv[1], 0);
}
}
else
@ -823,7 +861,8 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
{
ptr_trigger = trigger_search (argv[i]);
if (ptr_trigger)
trigger_command_set_enabled (ptr_trigger, enable, 1);
trigger_command_set_enabled (ptr_trigger, enable, argv[1],
1);
else
{
weechat_printf_tags (NULL, "no_trigger",
@ -843,7 +882,21 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
if (weechat_strcasecmp (argv[2], "-all") == 0)
{
count = triggers_count;
trigger_free_all ();
ptr_trigger = triggers;
while (ptr_trigger)
{
ptr_trigger2 = ptr_trigger->next_trigger;
if (ptr_trigger->hook_running)
{
trigger_command_error_running (ptr_trigger, argv[1]);
}
else
{
trigger_free (ptr_trigger);
}
ptr_trigger = ptr_trigger2;
}
count = count - triggers_count;
if (count > 0)
weechat_printf_tags (NULL, "no_trigger",
_("%d triggers removed"), count);
@ -855,9 +908,16 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
ptr_trigger = trigger_search (argv[i]);
if (ptr_trigger)
{
trigger_free (ptr_trigger);
weechat_printf_tags (NULL, "no_trigger",
_("Trigger \"%s\" removed"), argv[i]);
if (ptr_trigger->hook_running)
{
trigger_command_error_running (ptr_trigger, argv[1]);
}
else
{
trigger_free (ptr_trigger);
weechat_printf_tags (NULL, "no_trigger",
_("Trigger \"%s\" removed"), argv[i]);
}
}
else
{
@ -908,19 +968,27 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
if (trigger_config_default_list[j][0])
{
ptr_trigger = trigger_search (argv[i]);
if (ptr_trigger)
trigger_free (ptr_trigger);
trigger_new (
trigger_config_default_list[j][0], /* name */
trigger_config_default_list[j][1], /* enabled */
trigger_config_default_list[j][2], /* hook */
trigger_config_default_list[j][3], /* arguments */
trigger_config_default_list[j][4], /* conditions */
trigger_config_default_list[j][5], /* regex */
trigger_config_default_list[j][6], /* command */
trigger_config_default_list[j][7]); /* return code */
weechat_printf_tags (NULL, "no_trigger",
_("Trigger \"%s\" restored"), argv[i]);
if (ptr_trigger && ptr_trigger->hook_running)
{
trigger_command_error_running (ptr_trigger, argv[1]);
}
else
{
if (ptr_trigger)
trigger_free (ptr_trigger);
trigger_new (
trigger_config_default_list[j][0], /* name */
trigger_config_default_list[j][1], /* enabled */
trigger_config_default_list[j][2], /* hook */
trigger_config_default_list[j][3], /* arguments */
trigger_config_default_list[j][4], /* conditions */
trigger_config_default_list[j][5], /* regex */
trigger_config_default_list[j][6], /* command */
trigger_config_default_list[j][7]); /* return code */
weechat_printf_tags (NULL, "no_trigger",
_("Trigger \"%s\" restored"),
argv[i]);
}
}
else
{
@ -937,9 +1005,25 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
{
if ((argc >= 3) && (weechat_strcasecmp (argv[2], "-yes") == 0))
{
trigger_free_all ();
trigger_create_default ();
trigger_command_list (_("Default triggers restored:"), 0);
ptr_trigger = triggers;
while (ptr_trigger)
{
ptr_trigger2 = ptr_trigger->next_trigger;
if (ptr_trigger->hook_running)
{
trigger_command_error_running (ptr_trigger, argv[1]);
}
else
{
trigger_free (ptr_trigger);
}
ptr_trigger = ptr_trigger2;
}
if (triggers_count == 0)
{
trigger_create_default ();
trigger_command_list (_("Default triggers restored:"), 0);
}
}
else
{