about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/command.c49
-rw-r--r--src/command/commands.c9
-rw-r--r--src/config/preferences.c1
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/ui/console.c6
-rw-r--r--src/ui/core.c10
6 files changed, 50 insertions, 26 deletions
diff --git a/src/command/command.c b/src/command/command.c
index f9938b16..78818c6d 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -468,24 +468,24 @@ static struct cmd_t command_defs[] =
           NULL } } },
 
     { "/notify",
-        cmd_notify, parse_args, 2, 2, &cons_notify_setting,
-        { "/notify type value", "Control various desktop noficiations.",
-        { "/notify type value",
-          "------------------",
+        cmd_notify, parse_args, 2, 3, &cons_notify_setting,
+        { "/notify [type value]", "Control various desktop noficiations.",
+        { "/notify [type value]",
+          "--------------------",
           "Settings for various desktop notifications where type is one of:",
-          "message : Notificaitons for regular messages.",
-          "        : on|off",
-          "room    : Notificaitons for chat room messages.",
-          "        : on|off",
-          "remind  : Notification reminders of unread messages.",
-          "        : where value is the reminder period in seconds,",
-          "        : use 0 to disable.",
-          "typing  : Notifications when contacts are typing.",
-          "        : on|off",
-          "invite  : Notifications for chat room invites.",
-          "        : on|off",
-          "sub     : Notifications for subscription requests.",
-          "        : on|off",
+          "message         : Notificaitons for regular messages.",
+          "                : on|off",
+          "room            : Notificaitons for chat room messages.",
+          "                : on|off|mention",
+          "remind          : Notification reminders of unread messages.",
+          "                : where value is the reminder period in seconds,",
+          "                : use 0 to disable.",
+          "typing          : Notifications when contacts are typing.",
+          "                : on|off",
+          "invite          : Notifications for chat room invites.",
+          "                : on|off",
+          "sub             : Notifications for subscription requests.",
+          "                : on|off",
           "",
           "Example : /notify message on (enable message notifications)",
           "Example : /notify message on (enable chat room notifications)",
@@ -877,6 +877,7 @@ static Autocomplete commands_ac;
 static Autocomplete who_ac;
 static Autocomplete help_ac;
 static Autocomplete notify_ac;
+static Autocomplete notify_room_ac;
 static Autocomplete prefs_ac;
 static Autocomplete sub_ac;
 static Autocomplete log_ac;
@@ -973,6 +974,11 @@ cmd_init(void)
     autocomplete_add(notify_ac, "invite");
     autocomplete_add(notify_ac, "sub");
 
+    notify_room_ac = autocomplete_new();
+    autocomplete_add(notify_room_ac, "on");
+    autocomplete_add(notify_room_ac, "off");
+    autocomplete_add(notify_room_ac, "mention");
+
     sub_ac = autocomplete_new();
     autocomplete_add(sub_ac, "request");
     autocomplete_add(sub_ac, "allow");
@@ -1147,6 +1153,7 @@ cmd_uninit(void)
     autocomplete_free(who_ac);
     autocomplete_free(help_ac);
     autocomplete_free(notify_ac);
+    autocomplete_free(notify_room_ac);
     autocomplete_free(sub_ac);
     autocomplete_free(titlebar_ac);
     autocomplete_free(log_ac);
@@ -1259,6 +1266,7 @@ cmd_reset_autocomplete()
     presence_reset_sub_request_search();
     autocomplete_reset(help_ac);
     autocomplete_reset(notify_ac);
+    autocomplete_reset(notify_room_ac);
     autocomplete_reset(sub_ac);
 
     if (ui_current_win_type() == WIN_MUC) {
@@ -1774,8 +1782,13 @@ _notify_autocomplete(char *input, int *size)
     int i = 0;
     char *result = NULL;
 
+    result = autocomplete_param_with_ac(input, size, "/notify room", notify_room_ac);
+    if (result != NULL) {
+        return result;
+    }
+
     gchar *boolean_choices[] = { "/notify message", "/notify typing",
-        "/notify invite", "/notify sub", "/notify room" };
+        "/notify invite", "/notify sub" };
     for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
         result = autocomplete_param_with_func(input, size, boolean_choices[i],
             prefs_autocomplete_boolean_choice);
diff --git a/src/command/commands.c b/src/command/commands.c
index eb3ef91b..dcfc8a1e 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2219,12 +2219,15 @@ cmd_notify(gchar **args, struct cmd_help_t help)
     } else if (strcmp(kind, "room") == 0) {
         if (strcmp(value, "on") == 0) {
             cons_show("Chat room notifications enabled.");
-            prefs_set_boolean(PREF_NOTIFY_ROOM, TRUE);
+            prefs_set_string(PREF_NOTIFY_ROOM, "on");
         } else if (strcmp(value, "off") == 0) {
             cons_show("Chat room notifications disabled.");
-            prefs_set_boolean(PREF_NOTIFY_ROOM, FALSE);
+            prefs_set_string(PREF_NOTIFY_ROOM, "off");
+        } else if (strcmp(value, "mention") == 0) {
+            cons_show("Chat room notifications enable on mention.");
+            prefs_set_string(PREF_NOTIFY_ROOM, "mention");
         } else {
-            cons_show("Usage: /notify room on|off");
+            cons_show("Usage: /notify room on|off|mention");
         }
 
     // set typing setting
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 61ae6edb..900a68af 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -519,6 +519,7 @@ _get_default_string(preference_t pref)
     switch (pref)
     {
         case PREF_AUTOAWAY_MODE:
+        case PREF_NOTIFY_ROOM:
             return "off";
         case PREF_OTR_LOG:
             return "redact";
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 952b5bb7..e5d54d8a 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -87,6 +87,7 @@ void prefs_set_gone(gint value);
 
 void prefs_set_notify_remind(gint period);
 gint prefs_get_notify_remind(void);
+
 void prefs_set_max_log_size(gint value);
 gint prefs_get_max_log_size(void);
 gint prefs_get_priority(void);
diff --git a/src/ui/console.c b/src/ui/console.c
index ea106ec8..16a12e35 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1163,10 +1163,8 @@ _cons_notify_setting(void)
     else
         cons_show("Messages (/notify message)          : OFF");
 
-    if (prefs_get_boolean(PREF_NOTIFY_ROOM))
-        cons_show("Messages (/notify room)             : ON");
-    else
-        cons_show("Messages (/notify room)             : OFF");
+    char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM);
+    cons_show    ("Chat room messages (/notify room)   : %s", room_setting);
 
     if (prefs_get_boolean(PREF_NOTIFY_TYPING))
         cons_show("Composing (/notify typing)          : ON");
diff --git a/src/ui/core.c b/src/ui/core.c
index 09b12ea0..67fa618f 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -1696,7 +1696,15 @@ _ui_room_message(const char * const room_jid, const char * const nick,
         if (prefs_get_boolean(PREF_BEEP)) {
             beep();
         }
-        if (prefs_get_boolean(PREF_NOTIFY_ROOM)) {
+        char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM);
+        gboolean notify = FALSE;
+        if (g_strcmp0(room_setting, "on") == 0) {
+            notify = TRUE;
+        }
+        if ( (g_strcmp0(room_setting, "mention") == 0) && (g_strrstr(message, nick) != NULL) ) {
+            notify = TRUE;
+        }
+        if (notify) {
             Jid *jidp = jid_create(room_jid);
             notify_room_message(nick, jidp->localpart, ui_index);
             jid_destroy(jidp);