about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/command.c74
-rw-r--r--src/command/commands.c90
-rw-r--r--src/config/preferences.c181
-rw-r--r--src/config/preferences.h18
-rw-r--r--src/ui/chatwin.c28
-rw-r--r--src/ui/console.c10
-rw-r--r--src/ui/mucwin.c43
-rw-r--r--src/ui/notifier.c35
-rw-r--r--src/ui/privwin.c28
-rw-r--r--src/ui/ui.h6
-rw-r--r--tests/unittests/ui/stub_ui.c2
11 files changed, 444 insertions, 71 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 3e9adc9c..547b5275 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1054,7 +1054,7 @@ static struct cmd_t command_defs[] =
     },
 
     { "/notify",
-        cmd_notify, parse_args, 2, 3, &cons_notify_setting,
+        cmd_notify, parse_args_with_freetext, 2, 4, &cons_notify_setting,
         CMD_TAGS(
             CMD_TAG_UI,
             CMD_TAG_CHAT,
@@ -1063,9 +1063,17 @@ static struct cmd_t command_defs[] =
             "/notify message on|off",
             "/notify message current on|off",
             "/notify message text on|off",
+            "/notify message trigger add <text>",
+            "/notify message trigger remove <text>",
+            "/notify message trigger list",
+            "/notify message trigger on|off",
             "/notify room on|off|mention",
             "/notify room current on|off",
             "/notify room text on|off",
+            "/notify room trigger add <text>",
+            "/notify room trigger remove <text>",
+            "/notify room trigger list",
+            "/notify room trigger on|off",
             "/notify remind <seconds>",
             "/notify typing on|off",
             "/notify typing current on|off",
@@ -1074,17 +1082,25 @@ static struct cmd_t command_defs[] =
         CMD_DESC(
             "Settings for various kinds of desktop notifications.")
         CMD_ARGS(
-            { "message on|off", "Notifications for regular chat messages." },
-            { "message current on|off", "Whether messages in the current window trigger notifications." },
-            { "message text on|off", "Show message text in regular message notifications." },
-            { "room on|off|mention", "Notifications for chat room messages, mention triggers notifications only when your nick is mentioned." },
-            { "room current on|off", "Whether chat room messages in the current window trigger notifications." },
-            { "room text on|off", "Show message text in chat room message notifications." },
-            { "remind <seconds>", "Notification reminder period for unread messages, use 0 to disable." },
-            { "typing on|off", "Notifications when contacts are typing." },
-            { "typing current on|off", "Whether typing notifications are triggered for the current window." },
-            { "invite on|off", "Notifications for chat room invites." },
-            { "sub on|off", "Notifications for subscription requests." })
+            { "message on|off",                 "Notifications for regular chat messages." },
+            { "message current on|off",         "Whether messages in the current window trigger notifications." },
+            { "message text on|off",            "Show message text in regular message notifications." },
+            { "message trigger add <text>",     "Notify when specified text included in regular chat message." },
+            { "message trigger remove <text>",  "Remove regular chat notification for specified text." },
+            { "message trigger list",           "List all regular chat custom text notifications." },
+            { "message trigger on|off",         "Enable or disable all regular chat custom text notifications." },
+            { "room on|off|mention",            "Notifications for chat room messages, mention triggers notifications only when your nick is mentioned." },
+            { "room current on|off",            "Whether chat room messages in the current window trigger notifications." },
+            { "room text on|off",               "Show message text in chat room message notifications." },
+            { "room trigger add <text>",        "Notify when specified text included in regular chat message." },
+            { "room trigger remove <text>",     "Remove regular chat notification for specified text." },
+            { "room trigger list",              "List all regular chat custom text notifications." },
+            { "room trigger on|off",            "Enable or disable all regular chat custom text notifications." },
+            { "remind <seconds>",               "Notification reminder period for unread messages, use 0 to disable." },
+            { "typing on|off",                  "Notifications when contacts are typing." },
+            { "typing current on|off",          "Whether typing notifications are triggered for the current window." },
+            { "invite on|off",                  "Notifications for chat room invites." },
+            { "sub on|off",                     "Notifications for subscription requests." })
         CMD_EXAMPLES(
             "/notify message on",
             "/notify message text on",
@@ -1791,6 +1807,7 @@ static Autocomplete notify_ac;
 static Autocomplete notify_room_ac;
 static Autocomplete notify_message_ac;
 static Autocomplete notify_typing_ac;
+static Autocomplete notify_trigger_ac;
 static Autocomplete prefs_ac;
 static Autocomplete sub_ac;
 static Autocomplete log_ac;
@@ -1929,6 +1946,7 @@ cmd_init(void)
     autocomplete_add(notify_message_ac, "off");
     autocomplete_add(notify_message_ac, "current");
     autocomplete_add(notify_message_ac, "text");
+    autocomplete_add(notify_message_ac, "trigger");
 
     notify_room_ac = autocomplete_new();
     autocomplete_add(notify_room_ac, "on");
@@ -1936,12 +1954,20 @@ cmd_init(void)
     autocomplete_add(notify_room_ac, "mention");
     autocomplete_add(notify_room_ac, "current");
     autocomplete_add(notify_room_ac, "text");
+    autocomplete_add(notify_room_ac, "trigger");
 
     notify_typing_ac = autocomplete_new();
     autocomplete_add(notify_typing_ac, "on");
     autocomplete_add(notify_typing_ac, "off");
     autocomplete_add(notify_typing_ac, "current");
 
+    notify_trigger_ac = autocomplete_new();
+    autocomplete_add(notify_trigger_ac, "add");
+    autocomplete_add(notify_trigger_ac, "remove");
+    autocomplete_add(notify_trigger_ac, "list");
+    autocomplete_add(notify_trigger_ac, "on");
+    autocomplete_add(notify_trigger_ac, "off");
+
     sub_ac = autocomplete_new();
     autocomplete_add(sub_ac, "request");
     autocomplete_add(sub_ac, "allow");
@@ -2338,6 +2364,7 @@ cmd_uninit(void)
     autocomplete_free(notify_message_ac);
     autocomplete_free(notify_room_ac);
     autocomplete_free(notify_typing_ac);
+    autocomplete_free(notify_trigger_ac);
     autocomplete_free(sub_ac);
     autocomplete_free(titlebar_ac);
     autocomplete_free(log_ac);
@@ -2524,6 +2551,7 @@ cmd_reset_autocomplete(ProfWin *window)
     autocomplete_reset(notify_message_ac);
     autocomplete_reset(notify_room_ac);
     autocomplete_reset(notify_typing_ac);
+    autocomplete_reset(notify_trigger_ac);
     autocomplete_reset(sub_ac);
 
     autocomplete_reset(who_room_ac);
@@ -2622,6 +2650,8 @@ cmd_reset_autocomplete(ProfWin *window)
     }
 
     bookmark_autocomplete_reset();
+    prefs_reset_message_trigger_ac();
+    prefs_reset_room_trigger_ac();
 }
 
 gboolean
@@ -3136,16 +3166,36 @@ _notify_autocomplete(ProfWin *window, const char *const input)
     int i = 0;
     char *result = NULL;
 
+    result = autocomplete_param_with_func(input, "/notify message trigger remove", prefs_autocomplete_message_trigger);
+    if (result) {
+        return result;
+    }
+
+    result = autocomplete_param_with_func(input, "/notify room trigger remove", prefs_autocomplete_room_trigger);
+    if (result) {
+        return result;
+    }
+
     result = autocomplete_param_with_func(input, "/notify room current", prefs_autocomplete_boolean_choice);
     if (result) {
         return result;
     }
 
+    result = autocomplete_param_with_ac(input, "/notify room trigger", notify_trigger_ac, TRUE);
+    if (result) {
+        return result;
+    }
+
     result = autocomplete_param_with_func(input, "/notify message current", prefs_autocomplete_boolean_choice);
     if (result) {
         return result;
     }
 
+    result = autocomplete_param_with_ac(input, "/notify message trigger", notify_trigger_ac, TRUE);
+    if (result) {
+        return result;
+    }
+
     result = autocomplete_param_with_func(input, "/notify typing current", prefs_autocomplete_boolean_choice);
     if (result) {
         return result;
diff --git a/src/command/commands.c b/src/command/commands.c
index 1fa8cc24..9bc7bdad 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -4302,6 +4302,51 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
             } else {
                 cons_show("Usage: /notify message text on|off");
             }
+        } else if (g_strcmp0(args[1], "trigger") == 0) {
+            if (g_strcmp0(args[2], "add") == 0) {
+                if (!args[3]) {
+                    cons_bad_cmd_usage(command);
+                } else {
+                    gboolean res = prefs_add_msg_notify_trigger(args[3]);
+                    if (res) {
+                        cons_show("Adding message notification trigger: %s", args[3]);
+                    } else {
+                        cons_show("Message notification trigger already exists: %s", args[3]);
+                    }
+                }
+            } else if (g_strcmp0(args[2], "remove") == 0) {
+                if (!args[3]) {
+                    cons_bad_cmd_usage(command);
+                } else {
+                    gboolean res = prefs_remove_msg_notify_trigger(args[3]);
+                    if (res) {
+                        cons_show("Removing message notification trigger: %s", args[3]);
+                    } else {
+                        cons_show("Message notification trigger does not exist: %s", args[3]);
+                    }
+                }
+            } else if (g_strcmp0(args[2], "list") == 0) {
+                GList *triggers = prefs_get_msg_notify_triggers();
+                GList *curr = triggers;
+                if (curr) {
+                    cons_show("Message notification triggers:");
+                } else {
+                    cons_show("No message notification triggers");
+                }
+                while (curr) {
+                    cons_show("  %s", curr->data);
+                    curr = g_list_next(curr);
+                }
+                g_list_free_full(triggers, free);
+            } else if (g_strcmp0(args[2], "on") == 0) {
+                cons_show("Enabling message notification triggers");
+                prefs_set_boolean(PREF_NOTIFY_MESSAGE_TRIGGER, TRUE);
+            } else if (g_strcmp0(args[2], "off") == 0) {
+                cons_show("Disabling message notification triggers");
+                prefs_set_boolean(PREF_NOTIFY_MESSAGE_TRIGGER, FALSE);
+            } else {
+                cons_bad_cmd_usage(command);
+            }
         } else {
             cons_show("Usage: /notify message on|off");
         }
@@ -4337,6 +4382,51 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
             } else {
                 cons_show("Usage: /notify room text on|off");
             }
+        } else if (g_strcmp0(args[1], "trigger") == 0) {
+            if (g_strcmp0(args[2], "add") == 0) {
+                if (!args[3]) {
+                    cons_bad_cmd_usage(command);
+                } else {
+                    gboolean res = prefs_add_room_notify_trigger(args[3]);
+                    if (res) {
+                        cons_show("Adding room notification trigger: %s", args[3]);
+                    } else {
+                        cons_show("Room notification trigger already exists: %s", args[3]);
+                    }
+                }
+            } else if (g_strcmp0(args[2], "remove") == 0) {
+                if (!args[3]) {
+                    cons_bad_cmd_usage(command);
+                } else {
+                    gboolean res = prefs_remove_room_notify_trigger(args[3]);
+                    if (res) {
+                        cons_show("Removing room notification trigger: %s", args[3]);
+                    } else {
+                        cons_show("Room notification trigger does not exist: %s", args[3]);
+                    }
+                }
+            } else if (g_strcmp0(args[2], "list") == 0) {
+                GList *triggers = prefs_get_room_notify_triggers();
+                GList *curr = triggers;
+                if (curr) {
+                    cons_show("Room notification triggers:");
+                } else {
+                    cons_show("No room notification triggers");
+                }
+                while (curr) {
+                    cons_show("  %s", curr->data);
+                    curr = g_list_next(curr);
+                }
+                g_list_free_full(triggers, free);
+            } else if (g_strcmp0(args[2], "on") == 0) {
+                cons_show("Enabling room notification triggers");
+                prefs_set_boolean(PREF_NOTIFY_ROOM_TRIGGER, TRUE);
+            } else if (g_strcmp0(args[2], "off") == 0) {
+                cons_show("Disabling room notification triggers");
+                prefs_set_boolean(PREF_NOTIFY_ROOM_TRIGGER, FALSE);
+            } else {
+                cons_bad_cmd_usage(command);
+            }
         } else {
             cons_show("Usage: /notify room on|off|mention");
         }
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 07985efc..205d47df 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -45,6 +45,7 @@
 #include "log.h"
 #include "preferences.h"
 #include "tools/autocomplete.h"
+#include "config/conflists.h"
 
 // preference groups refer to the sections in .profrc, for example [ui]
 #define PREF_GROUP_LOGGING "logging"
@@ -64,6 +65,8 @@ static GKeyFile *prefs;
 gint log_maxsize = 0;
 
 static Autocomplete boolean_choice_ac;
+static Autocomplete message_trigger_ac;
+static Autocomplete room_trigger_ac;
 
 static void _save_prefs(void);
 static gchar* _get_preferences_file(void);
@@ -132,12 +135,33 @@ prefs_load(void)
     boolean_choice_ac = autocomplete_new();
     autocomplete_add(boolean_choice_ac, "on");
     autocomplete_add(boolean_choice_ac, "off");
+
+    message_trigger_ac = autocomplete_new();
+    gsize len = 0;
+    gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", &len, NULL);
+
+    int i;
+    for (i = 0; i < len; i++) {
+        autocomplete_add(message_trigger_ac, triggers[i]);
+    }
+    g_strfreev(triggers);
+
+    room_trigger_ac = autocomplete_new();
+    len = 0;
+    triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
+
+    for (i = 0; i < len; i++) {
+        autocomplete_add(room_trigger_ac, triggers[i]);
+    }
+    g_strfreev(triggers);
 }
 
 void
 prefs_close(void)
 {
     autocomplete_free(boolean_choice_ac);
+    autocomplete_free(message_trigger_ac);
+    autocomplete_free(room_trigger_ac);
     g_key_file_free(prefs);
     prefs = NULL;
 }
@@ -154,6 +178,71 @@ prefs_reset_boolean_choice(void)
     autocomplete_reset(boolean_choice_ac);
 }
 
+char*
+prefs_autocomplete_message_trigger(const char *const prefix)
+{
+    return autocomplete_complete(message_trigger_ac, prefix, TRUE);
+}
+
+void
+prefs_reset_message_trigger_ac(void)
+{
+    autocomplete_reset(message_trigger_ac);
+}
+
+char*
+prefs_autocomplete_room_trigger(const char *const prefix)
+{
+    return autocomplete_complete(room_trigger_ac, prefix, TRUE);
+}
+
+void
+prefs_reset_room_trigger_ac(void)
+{
+    autocomplete_reset(room_trigger_ac);
+}
+
+gboolean
+prefs_get_notify_chat(gboolean current_win)
+{
+    gboolean notify_message = prefs_get_boolean(PREF_NOTIFY_MESSAGE);
+    gboolean notify_window = FALSE;
+
+    if (!current_win || (current_win && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
+        notify_window = TRUE;
+    }
+
+    return (notify_message && notify_window);
+}
+
+gboolean
+prefs_get_notify_room(gboolean current_win, const char *const nick, const char *const message)
+{
+    gboolean notify_message = FALSE;
+    gboolean notify_window = FALSE;
+
+    char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM);
+    if (g_strcmp0(room_setting, "on") == 0) {
+        notify_message = TRUE;
+    }
+    if (g_strcmp0(room_setting, "mention") == 0) {
+        char *message_lower = g_utf8_strdown(message, -1);
+        char *nick_lower = g_utf8_strdown(nick, -1);
+        if (g_strrstr(message_lower, nick_lower)) {
+            notify_message = TRUE;
+        }
+        g_free(message_lower);
+        g_free(nick_lower);
+    }
+    prefs_free_string(room_setting);
+
+    if (!current_win || (current_win && prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT)) ) {
+        notify_window = TRUE;
+    }
+
+    return (notify_message && notify_window);
+}
+
 gboolean
 prefs_get_boolean(preference_t pref)
 {
@@ -607,6 +696,92 @@ prefs_set_roster_presence_indent(gint value)
 }
 
 gboolean
+prefs_add_msg_notify_trigger(const char * const text)
+{
+    gboolean res = conf_string_list_add(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", text);
+    _save_prefs();
+
+    if (res) {
+        autocomplete_add(message_trigger_ac, text);
+    }
+
+    return res;
+}
+
+gboolean
+prefs_remove_msg_notify_trigger(const char * const text)
+{
+    gboolean res = conf_string_list_remove(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", text);
+    _save_prefs();
+
+    if (res) {
+        autocomplete_remove(message_trigger_ac, text);
+    }
+
+    return res;
+}
+
+GList*
+prefs_get_msg_notify_triggers(void)
+{
+    GList *result = NULL;
+    gsize len = 0;
+    gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", &len, NULL);
+
+    int i;
+    for (i = 0; i < len; i++) {
+        result = g_list_append(result, strdup(triggers[i]));
+    }
+
+    g_strfreev(triggers);
+
+    return result;
+}
+
+gboolean
+prefs_add_room_notify_trigger(const char * const text)
+{
+    gboolean res = conf_string_list_add(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text);
+    _save_prefs();
+
+    if (res) {
+        autocomplete_add(room_trigger_ac, text);
+    }
+
+    return res;
+}
+
+gboolean
+prefs_remove_room_notify_trigger(const char * const text)
+{
+    gboolean res = conf_string_list_remove(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text);
+    _save_prefs();
+
+    if (res) {
+        autocomplete_remove(room_trigger_ac, text);
+    }
+
+    return res;
+}
+
+GList*
+prefs_get_room_notify_triggers(void)
+{
+    GList *result = NULL;
+    gsize len = 0;
+    gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
+
+    int i;
+    for (i = 0; i < len; i++) {
+        result = g_list_append(result, strdup(triggers[i]));
+    }
+
+    g_strfreev(triggers);
+
+    return result;
+}
+
+gboolean
 prefs_add_alias(const char *const name, const char *const value)
 {
     if (g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) {
@@ -782,9 +957,11 @@ _get_group(preference_t pref)
         case PREF_NOTIFY_MESSAGE:
         case PREF_NOTIFY_MESSAGE_CURRENT:
         case PREF_NOTIFY_MESSAGE_TEXT:
+        case PREF_NOTIFY_MESSAGE_TRIGGER:
         case PREF_NOTIFY_ROOM:
         case PREF_NOTIFY_ROOM_CURRENT:
         case PREF_NOTIFY_ROOM_TEXT:
+        case PREF_NOTIFY_ROOM_TRIGGER:
         case PREF_NOTIFY_INVITE:
         case PREF_NOTIFY_SUB:
             return PREF_GROUP_NOTIFICATIONS;
@@ -875,12 +1052,16 @@ _get_key(preference_t pref)
             return "message.current";
         case PREF_NOTIFY_MESSAGE_TEXT:
             return "message.text";
+        case PREF_NOTIFY_MESSAGE_TRIGGER:
+            return "message.trigger";
         case PREF_NOTIFY_ROOM:
             return "room";
         case PREF_NOTIFY_ROOM_CURRENT:
             return "room.current";
         case PREF_NOTIFY_ROOM_TEXT:
             return "room.text";
+        case PREF_NOTIFY_ROOM_TRIGGER:
+            return "room.trigger";
         case PREF_NOTIFY_INVITE:
             return "invite";
         case PREF_NOTIFY_SUB:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 607a1abe..face1811 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -96,9 +96,11 @@ typedef enum {
     PREF_NOTIFY_MESSAGE,
     PREF_NOTIFY_MESSAGE_CURRENT,
     PREF_NOTIFY_MESSAGE_TEXT,
+    PREF_NOTIFY_MESSAGE_TRIGGER,
     PREF_NOTIFY_ROOM,
     PREF_NOTIFY_ROOM_CURRENT,
     PREF_NOTIFY_ROOM_TEXT,
+    PREF_NOTIFY_ROOM_TRIGGER,
     PREF_NOTIFY_INVITE,
     PREF_NOTIFY_SUB,
     PREF_CHLOG,
@@ -133,9 +135,15 @@ void prefs_close(void);
 
 char* prefs_find_login(char *prefix);
 void prefs_reset_login_search(void);
+
 char* prefs_autocomplete_boolean_choice(const char *const prefix);
 void prefs_reset_boolean_choice(void);
 
+char* prefs_autocomplete_message_trigger(const char *const prefix);
+void prefs_reset_message_trigger_ac(void);
+char* prefs_autocomplete_room_trigger(const char *const prefix);
+void prefs_reset_room_trigger_ac(void);
+
 gint prefs_get_gone(void);
 void prefs_set_gone(gint value);
 
@@ -192,10 +200,20 @@ char* prefs_get_alias(const char *const name);
 GList* prefs_get_aliases(void);
 void prefs_free_aliases(GList *aliases);
 
+gboolean prefs_add_msg_notify_trigger(const char * const text);
+gboolean prefs_add_room_notify_trigger(const char * const text);
+gboolean prefs_remove_msg_notify_trigger(const char * const text);
+gboolean prefs_remove_room_notify_trigger(const char * const text);
+GList* prefs_get_msg_notify_triggers(void);
+GList* prefs_get_room_notify_triggers(void);
+
 gboolean prefs_get_boolean(preference_t pref);
 void prefs_set_boolean(preference_t pref, gboolean value);
 char* prefs_get_string(preference_t pref);
 void prefs_free_string(char *pref);
 void prefs_set_string(preference_t pref, char *value);
 
+gboolean prefs_get_notify_chat(gboolean current_win);
+gboolean prefs_get_notify_room(gboolean current_win, const char *const nick, const char *const message);
+
 #endif
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index c34cc1fc..2efe82e1 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -274,8 +274,32 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
         beep();
     }
 
-    if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
-        notify_message(window, display_name, message);
+    if (!prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
+        free(display_name);
+        return;
+    }
+
+    gboolean notify = FALSE;
+
+    gboolean is_current = wins_is_current(window);
+    if (!is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
+        notify = TRUE;
+    }
+
+    if (!notify) {
+        free(display_name);
+        return;
+    }
+
+    int ui_index = num;
+    if (ui_index == 10) {
+        ui_index = 0;
+    }
+
+    if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT)) {
+        notify_message(display_name, ui_index, message);
+    } else {
+        notify_message(display_name, ui_index, NULL);
     }
 
     free(display_name);
diff --git a/src/ui/console.c b/src/ui/console.c
index 6aa706c5..066ea32c 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1339,6 +1339,11 @@ cons_notify_setting(void)
         else
             cons_show("Messages text (/notify message)     : OFF");
 
+        if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TRIGGER))
+            cons_show("Messages trigger (/notify message)  : ON");
+        else
+            cons_show("Messages trigger (/notify message)  : OFF");
+
         char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM);
         if (g_strcmp0(room_setting, "on") == 0) {
         cons_show    ("Room messages (/notify room)        : ON");
@@ -1359,6 +1364,11 @@ cons_notify_setting(void)
         else
             cons_show("Room text (/notify room)            : OFF");
 
+        if (prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER))
+            cons_show("Room trigger (/notify room)         : ON");
+        else
+            cons_show("Room trigger (/notify room)         : OFF");
+
         if (prefs_get_boolean(PREF_NOTIFY_TYPING))
             cons_show("Composing (/notify typing)          : ON");
         else
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 58fef4d1..aa825d16 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -390,11 +390,6 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
         mucwin->unread++;
     }
 
-    int ui_index = num;
-    if (ui_index == 10) {
-        ui_index = 0;
-    }
-
     // don't notify self messages
     if (strcmp(nick, my_nick) == 0) {
         return;
@@ -404,34 +399,24 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
         beep();
     }
 
-    gboolean notify = FALSE;
-    char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM);
-    if (g_strcmp0(room_setting, "on") == 0) {
-        notify = TRUE;
+    gboolean is_current = wins_is_current(window);
+    gboolean notify = prefs_get_notify_room(is_current, my_nick, message);
+    if (!notify) {
+        return;
     }
-    if (g_strcmp0(room_setting, "mention") == 0) {
-        char *message_lower = g_utf8_strdown(message, -1);
-        char *nick_lower = g_utf8_strdown(nick, -1);
-        if (g_strrstr(message_lower, nick_lower)) {
-            notify = TRUE;
-        }
-        g_free(message_lower);
-        g_free(nick_lower);
+
+    Jid *jidp = jid_create(mucwin->roomjid);
+    int ui_index = num;
+    if (ui_index == 10) {
+        ui_index = 0;
     }
-    prefs_free_string(room_setting);
 
-    if (notify) {
-        gboolean is_current = wins_is_current(window);
-        if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT)) ) {
-            Jid *jidp = jid_create(mucwin->roomjid);
-            if (prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) {
-                notify_room_message(nick, jidp->localpart, ui_index, message);
-            } else {
-                notify_room_message(nick, jidp->localpart, ui_index, NULL);
-            }
-            jid_destroy(jidp);
-        }
+    if (prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) {
+        notify_room_message(nick, jidp->localpart, ui_index, message);
+    } else {
+        notify_room_message(nick, jidp->localpart, ui_index, NULL);
     }
+    jid_destroy(jidp);
 }
 
 void
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index 9127b1e7..c0861009 100644
--- a/src/ui/notifier.c
+++ b/src/ui/notifier.c
@@ -73,17 +73,16 @@ notifier_uninit(void)
 }
 
 void
-notify_typing(const char *const handle)
+notify_typing(const char *const name)
 {
-    char message[strlen(handle) + 1 + 11];
-    sprintf(message, "%s: typing...", handle);
+    char message[strlen(name) + 1 + 11];
+    sprintf(message, "%s: typing...", name);
 
     _notify(message, 10000, "Incoming message");
 }
 
 void
-notify_invite(const char *const from, const char *const room,
-    const char *const reason)
+notify_invite(const char *const from, const char *const room, const char *const reason)
 {
     GString *message = g_string_new("Room invite\nfrom: ");
     g_string_append(message, from);
@@ -99,32 +98,24 @@ notify_invite(const char *const from, const char *const room,
 }
 
 void
-notify_message(ProfWin *window, const char *const name, const char *const text)
+notify_message(const char *const name, int win, const char *const text)
 {
-    int num = wins_get_num(window);
-    if (num == 10) {
-        num = 0;
+    GString *message = g_string_new("");
+    g_string_append_printf(message, "%s (win %d)", name, win);
+    if (text) {
+        g_string_append_printf(message, "\n%s", text);
     }
 
-    gboolean is_current = wins_is_current(window);
-    if (!is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
-        GString *message = g_string_new("");
-        g_string_append_printf(message, "%s (win %d)", name, num);
-
-        if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT) && text) {
-            g_string_append_printf(message, "\n%s", text);
-        }
+    _notify(message->str, 10000, "incoming message");
 
-        _notify(message->str, 10000, "incoming message");
-        g_string_free(message, TRUE);
-    }
+    g_string_free(message, TRUE);
 }
 
 void
-notify_room_message(const char *const handle, const char *const room, int win, const char *const text)
+notify_room_message(const char *const nick, const char *const room, int win, const char *const text)
 {
     GString *message = g_string_new("");
-    g_string_append_printf(message, "%s in %s (win %d)", handle, room, win);
+    g_string_append_printf(message, "%s in %s (win %d)", nick, room, win);
     if (text) {
         g_string_append_printf(message, "\n%s", text);
     }
diff --git a/src/ui/privwin.c b/src/ui/privwin.c
index 6031a2c0..10ce1dbe 100644
--- a/src/ui/privwin.c
+++ b/src/ui/privwin.c
@@ -75,8 +75,32 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
         beep();
     }
 
-    if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
-        notify_message(window, display_from, message);
+    if (!prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
+        free(display_from);
+        return;
+    }
+
+    gboolean notify = FALSE;
+
+    gboolean is_current = wins_is_current(window);
+    if (!is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
+        notify = TRUE;
+    }
+
+    if (!notify) {
+        free(display_from);
+        return;
+    }
+
+    int ui_index = num;
+    if (ui_index == 10) {
+        ui_index = 0;
+    }
+
+    if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT)) {
+        notify_message(display_from, ui_index, message);
+    } else {
+        notify_message(display_from, ui_index, NULL);
     }
 
     free(display_from);
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 032a1161..3cc40001 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -339,9 +339,9 @@ void win_clear(ProfWin *window);
 // desktop notifications
 void notifier_initialise(void);
 void notifier_uninit(void);
-void notify_typing(const char *const handle);
-void notify_message(ProfWin *window, const char *const name, const char *const text);
-void notify_room_message(const char *const handle, const char *const room, int win, const char *const text);
+void notify_typing(const char *const name);
+void notify_message(const char *const name, int win, const char *const text);
+void notify_room_message(const char *const nick, const char *const room, int win, const char *const text);
 void notify_remind(void);
 void notify_invite(const char *const from, const char *const room, const char *const reason);
 void notify_subscription(const char *const from);
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index 084b36be..4cab2ea9 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -514,7 +514,7 @@ void win_clear(ProfWin *window) {}
 void notifier_uninit(void) {}
 
 void notify_typing(const char * const handle) {}
-void notify_message(ProfWin *window, const char * const name, const char * const text) {}
+void notify_message(const char *const name, int win, const char *const text) {}
 void notify_room_message(const char * const handle, const char * const room,
     int win, const char * const text) {}
 void notify_remind(void) {}