1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Split regular and chat room notify settings

This commit is contained in:
James Booth 2014-05-24 15:54:10 +01:00
parent 663a22fb7e
commit 7d90d218c0
6 changed files with 29 additions and 4 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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:

View File

@ -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,

View File

@ -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

View File

@ -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);