summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2014-09-20 14:51:09 +0200
committerSébastien Helleu <flashcode@flashtux.org>2014-09-20 14:51:09 +0200
commitd1b4281d204ad3c3b53d3ddd9125cac1bfc4af14 (patch)
tree7312c7e1aef5c5a526379ea29b441ba5e54ff866
parent6860aa491f3462c48c907e78ac259405b3db6d40 (diff)
downloadweechat-d1b4281d204ad3c3b53d3ddd9125cac1bfc4af14.zip
trigger: do not allow any changes on a trigger when it is currently running (closes #189)
-rw-r--r--ChangeLog.asciidoc2
-rw-r--r--po/cs.po8
-rw-r--r--po/de.po8
-rw-r--r--po/es.po8
-rw-r--r--po/fr.po12
-rw-r--r--po/hu.po8
-rw-r--r--po/it.po8
-rw-r--r--po/ja.po8
-rw-r--r--po/pl.po8
-rw-r--r--po/pt_BR.po8
-rw-r--r--po/ru.po8
-rw-r--r--po/tr.po8
-rw-r--r--po/weechat.pot8
-rw-r--r--src/plugins/trigger/trigger-command.c130
14 files changed, 196 insertions, 36 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc
index c954b7d17..c3063346f 100644
--- a/ChangeLog.asciidoc
+++ b/ChangeLog.asciidoc
@@ -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)
diff --git a/po/cs.po b/po/cs.po
index 57b6020ca..7fe051423 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -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"
diff --git a/po/de.po b/po/de.po
index 73c0c90b6..96586ba27 100644
--- a/po/de.po
+++ b/po/de.po
@@ -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"
@@ -11261,6 +11261,12 @@ 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"
diff --git a/po/es.po b/po/es.po
index 94fa54685..4bf61dc9a 100644
--- a/po/es.po
+++ b/po/es.po
@@ -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"
diff --git a/po/fr.po b/po/fr.po
index 8477b5f46..5db84b5c2 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -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"
@@ -11015,6 +11015,14 @@ 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é"
diff --git a/po/hu.po b/po/hu.po
index f86b4a085..496e99c08 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -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"
diff --git a/po/it.po b/po/it.po
index 47da275a6..8d5b4bcd2 100644
--- a/po/it.po
+++ b/po/it.po
@@ -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"
diff --git a/po/ja.po b/po/ja.po
index 5a84abc0b..29e68d353 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -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"
@@ -10607,6 +10607,12 @@ 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\" を再開しました"
diff --git a/po/pl.po b/po/pl.po
index 89995bf0a..73d0c95a5 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -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"
@@ -10803,6 +10803,12 @@ 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"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 60e373a7c..e94056231 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -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"
diff --git a/po/ru.po b/po/ru.po
index fd8df9e4b..6efaf1a17 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -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"
diff --git a/po/tr.po b/po/tr.po
index 2ee258ec3..09fabb058 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -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"
diff --git a/po/weechat.pot b/po/weechat.pot
index b2116f6a0..5fc5f567a 100644
--- a/po/weechat.pot
+++ b/po/weechat.pot
@@ -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"
@@ -8405,6 +8405,12 @@ 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 ""
diff --git a/src/plugins/trigger/trigger-command.c b/src/plugins/trigger/trigger-command.c
index ab918dbd7..a03879e54 100644
--- a/src/plugins/trigger/trigger-command.c
+++ b/src/plugins/trigger/trigger-command.c
@@ -315,6 +315,20 @@ trigger_command_list_default (int verbose)
}
/*
+ * 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.
*
* Argument "enable" can be:
@@ -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
{