diff --git a/src/command/command.c b/src/command/command.c index df0197fe..f9938b16 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -473,7 +473,9 @@ static struct cmd_t command_defs[] = { "/notify type value", "------------------", "Settings for various desktop notifications where type is one of:", - "message : Notificaitons for messages.", + "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,", @@ -486,6 +488,7 @@ static struct cmd_t command_defs[] = " : on|off", "", "Example : /notify message on (enable message notifications)", + "Example : /notify message on (enable chat room notifications)", "Example : /notify remind 10 (remind every 10 seconds)", "Example : /notify remind 0 (switch off reminders)", "Example : /notify typing on (enable typing notifications)", @@ -964,6 +967,7 @@ cmd_init(void) notify_ac = autocomplete_new(); autocomplete_add(notify_ac, "message"); + autocomplete_add(notify_ac, "room"); autocomplete_add(notify_ac, "typing"); autocomplete_add(notify_ac, "remind"); autocomplete_add(notify_ac, "invite"); @@ -1771,7 +1775,7 @@ _notify_autocomplete(char *input, int *size) char *result = NULL; gchar *boolean_choices[] = { "/notify message", "/notify typing", - "/notify invite", "/notify sub" }; + "/notify invite", "/notify sub", "/notify room" }; 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 fd50f08b..eb3ef91b 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2200,7 +2200,7 @@ cmd_notify(gchar **args, struct cmd_help_t help) // bad kind if ((strcmp(kind, "message") != 0) && (strcmp(kind, "typing") != 0) && (strcmp(kind, "remind") != 0) && (strcmp(kind, "invite") != 0) && - (strcmp(kind, "sub") != 0)) { + (strcmp(kind, "sub") != 0) && (strcmp(kind, "room") != 0)) { cons_show("Usage: %s", help.usage); // set message setting @@ -2215,6 +2215,18 @@ cmd_notify(gchar **args, struct cmd_help_t help) cons_show("Usage: /notify message on|off"); } + // set room setting + } else if (strcmp(kind, "room") == 0) { + if (strcmp(value, "on") == 0) { + cons_show("Chat room notifications enabled."); + prefs_set_boolean(PREF_NOTIFY_ROOM, TRUE); + } else if (strcmp(value, "off") == 0) { + cons_show("Chat room notifications disabled."); + prefs_set_boolean(PREF_NOTIFY_ROOM, FALSE); + } else { + cons_show("Usage: /notify room on|off"); + } + // set typing setting } else if (strcmp(kind, "typing") == 0) { if (strcmp(value, "on") == 0) { diff --git a/src/config/preferences.c b/src/config/preferences.c index 5ba7d1dc..61ae6edb 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -401,6 +401,7 @@ _get_group(preference_t pref) return PREF_GROUP_CHATSTATES; case PREF_NOTIFY_TYPING: case PREF_NOTIFY_MESSAGE: + case PREF_NOTIFY_ROOM: case PREF_NOTIFY_INVITE: case PREF_NOTIFY_SUB: return PREF_GROUP_NOTIFICATIONS; @@ -463,6 +464,8 @@ _get_key(preference_t pref) return "typing"; case PREF_NOTIFY_MESSAGE: return "message"; + case PREF_NOTIFY_ROOM: + return "room"; case PREF_NOTIFY_INVITE: return "invite"; case PREF_NOTIFY_SUB: diff --git a/src/config/preferences.h b/src/config/preferences.h index fb11d873..952b5bb7 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -53,6 +53,7 @@ typedef enum { PREF_OUTTYPE, PREF_NOTIFY_TYPING, PREF_NOTIFY_MESSAGE, + PREF_NOTIFY_ROOM, PREF_NOTIFY_INVITE, PREF_NOTIFY_SUB, PREF_CHLOG, diff --git a/src/ui/console.c b/src/ui/console.c index e29b4eb7..ea106ec8 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1163,6 +1163,11 @@ _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"); + if (prefs_get_boolean(PREF_NOTIFY_TYPING)) cons_show("Composing (/notify typing) : ON"); else diff --git a/src/ui/core.c b/src/ui/core.c index eec21351..09b12ea0 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1696,7 +1696,7 @@ _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_MESSAGE)) { + if (prefs_get_boolean(PREF_NOTIFY_ROOM)) { Jid *jidp = jid_create(room_jid); notify_room_message(nick, jidp->localpart, ui_index); jid_destroy(jidp);