mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-20 06:26:21 +00:00
Added settings for message notifications in current window
This commit is contained in:
@@ -469,14 +469,18 @@ static struct cmd_t command_defs[] =
|
||||
|
||||
{ "/notify",
|
||||
cmd_notify, parse_args, 2, 3, &cons_notify_setting,
|
||||
{ "/notify [type value]", "Control various desktop noficiations.",
|
||||
{ "/notify [type value]",
|
||||
"--------------------",
|
||||
{ "/notify [type value]|[type setting value]", "Control various desktop noficiations.",
|
||||
{ "/notify [type value]|[type setting value]",
|
||||
"-----------------------------------------",
|
||||
"Settings for various desktop notifications where type is one of:",
|
||||
"message : Notificaitons for regular messages.",
|
||||
" : on|off",
|
||||
"message current : Whether messages in the current window trigger notifications.",
|
||||
" : on|off",
|
||||
"room : Notificaitons for chat room messages.",
|
||||
" : on|off|mention",
|
||||
"room current : Whether chat room messages in the current window trigger notifications.",
|
||||
" : on|off",
|
||||
"remind : Notification reminders of unread messages.",
|
||||
" : where value is the reminder period in seconds,",
|
||||
" : use 0 to disable.",
|
||||
@@ -487,12 +491,13 @@ static struct cmd_t command_defs[] =
|
||||
"sub : Notifications for subscription requests.",
|
||||
" : on|off",
|
||||
"",
|
||||
"Example : /notify message on (enable message notifications)",
|
||||
"Example : /notify room mention (enable chat room notifications only on mention)",
|
||||
"Example : /notify remind 10 (remind every 10 seconds)",
|
||||
"Example : /notify remind 0 (switch off reminders)",
|
||||
"Example : /notify typing on (enable typing notifications)",
|
||||
"Example : /notify invite on (enable chat room invite notifications)",
|
||||
"Example : /notify message on (enable message notifications)",
|
||||
"Example : /notify room mention (enable chat room notifications only on mention)",
|
||||
"Example : /notify room current off (disable room message notifications when window visible)",
|
||||
"Example : /notify remind 10 (remind every 10 seconds)",
|
||||
"Example : /notify remind 0 (switch off reminders)",
|
||||
"Example : /notify typing on (enable typing notifications)",
|
||||
"Example : /notify invite on (enable chat room invite notifications)",
|
||||
NULL } } },
|
||||
|
||||
{ "/flash",
|
||||
@@ -878,6 +883,7 @@ static Autocomplete who_ac;
|
||||
static Autocomplete help_ac;
|
||||
static Autocomplete notify_ac;
|
||||
static Autocomplete notify_room_ac;
|
||||
static Autocomplete notify_message_ac;
|
||||
static Autocomplete prefs_ac;
|
||||
static Autocomplete sub_ac;
|
||||
static Autocomplete log_ac;
|
||||
@@ -974,10 +980,16 @@ cmd_init(void)
|
||||
autocomplete_add(notify_ac, "invite");
|
||||
autocomplete_add(notify_ac, "sub");
|
||||
|
||||
notify_message_ac = autocomplete_new();
|
||||
autocomplete_add(notify_message_ac, "on");
|
||||
autocomplete_add(notify_message_ac, "off");
|
||||
autocomplete_add(notify_message_ac, "current");
|
||||
|
||||
notify_room_ac = autocomplete_new();
|
||||
autocomplete_add(notify_room_ac, "on");
|
||||
autocomplete_add(notify_room_ac, "off");
|
||||
autocomplete_add(notify_room_ac, "mention");
|
||||
autocomplete_add(notify_room_ac, "current");
|
||||
|
||||
sub_ac = autocomplete_new();
|
||||
autocomplete_add(sub_ac, "request");
|
||||
@@ -1153,6 +1165,7 @@ cmd_uninit(void)
|
||||
autocomplete_free(who_ac);
|
||||
autocomplete_free(help_ac);
|
||||
autocomplete_free(notify_ac);
|
||||
autocomplete_free(notify_message_ac);
|
||||
autocomplete_free(notify_room_ac);
|
||||
autocomplete_free(sub_ac);
|
||||
autocomplete_free(titlebar_ac);
|
||||
@@ -1266,6 +1279,7 @@ cmd_reset_autocomplete()
|
||||
presence_reset_sub_request_search();
|
||||
autocomplete_reset(help_ac);
|
||||
autocomplete_reset(notify_ac);
|
||||
autocomplete_reset(notify_message_ac);
|
||||
autocomplete_reset(notify_room_ac);
|
||||
autocomplete_reset(sub_ac);
|
||||
|
||||
@@ -1782,13 +1796,27 @@ _notify_autocomplete(char *input, int *size)
|
||||
int i = 0;
|
||||
char *result = NULL;
|
||||
|
||||
result = autocomplete_param_with_func(input, size, "/notify room current", prefs_autocomplete_boolean_choice);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, size, "/notify message current", prefs_autocomplete_boolean_choice);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
||||
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" };
|
||||
result = autocomplete_param_with_ac(input, size, "/notify message", notify_message_ac);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
|
||||
gchar *boolean_choices[] = { "/notify typing", "/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);
|
||||
|
||||
@@ -2195,7 +2195,6 @@ gboolean
|
||||
cmd_notify(gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
char *kind = args[0];
|
||||
char *value = args[1];
|
||||
|
||||
// bad kind
|
||||
if ((strcmp(kind, "message") != 0) && (strcmp(kind, "typing") != 0) &&
|
||||
@@ -2205,37 +2204,57 @@ cmd_notify(gchar **args, struct cmd_help_t help)
|
||||
|
||||
// set message setting
|
||||
} else if (strcmp(kind, "message") == 0) {
|
||||
if (strcmp(value, "on") == 0) {
|
||||
if (strcmp(args[1], "on") == 0) {
|
||||
cons_show("Message notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_MESSAGE, TRUE);
|
||||
} else if (strcmp(value, "off") == 0) {
|
||||
} else if (strcmp(args[1], "off") == 0) {
|
||||
cons_show("Message notifications disabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_MESSAGE, FALSE);
|
||||
} else if (strcmp(args[1], "current") == 0) {
|
||||
if (g_strcmp0(args[2], "on") == 0) {
|
||||
cons_show("Current window messages notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_MESSAGE_CURRENT, TRUE);
|
||||
} else if (g_strcmp0(args[2], "off") == 0) {
|
||||
cons_show("Current window messages notifications disabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_MESSAGE_CURRENT, FALSE);
|
||||
} else {
|
||||
cons_show("Usage: /notify message current on|off");
|
||||
}
|
||||
} else {
|
||||
cons_show("Usage: /notify message on|off");
|
||||
}
|
||||
|
||||
// set room setting
|
||||
} else if (strcmp(kind, "room") == 0) {
|
||||
if (strcmp(value, "on") == 0) {
|
||||
if (strcmp(args[1], "on") == 0) {
|
||||
cons_show("Chat room notifications enabled.");
|
||||
prefs_set_string(PREF_NOTIFY_ROOM, "on");
|
||||
} else if (strcmp(value, "off") == 0) {
|
||||
} else if (strcmp(args[1], "off") == 0) {
|
||||
cons_show("Chat room notifications disabled.");
|
||||
prefs_set_string(PREF_NOTIFY_ROOM, "off");
|
||||
} else if (strcmp(value, "mention") == 0) {
|
||||
} else if (strcmp(args[1], "mention") == 0) {
|
||||
cons_show("Chat room notifications enable on mention.");
|
||||
prefs_set_string(PREF_NOTIFY_ROOM, "mention");
|
||||
} else if (strcmp(args[1], "current") == 0) {
|
||||
if (g_strcmp0(args[2], "on") == 0) {
|
||||
cons_show("Current window chat room messages notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_ROOM_CURRENT, TRUE);
|
||||
} else if (g_strcmp0(args[2], "off") == 0) {
|
||||
cons_show("Current window chat room messages notifications disabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_ROOM_CURRENT, FALSE);
|
||||
} else {
|
||||
cons_show("Usage: /notify room current on|off");
|
||||
}
|
||||
} else {
|
||||
cons_show("Usage: /notify room on|off|mention");
|
||||
}
|
||||
|
||||
// set typing setting
|
||||
} else if (strcmp(kind, "typing") == 0) {
|
||||
if (strcmp(value, "on") == 0) {
|
||||
if (strcmp(args[1], "on") == 0) {
|
||||
cons_show("Typing notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_TYPING, TRUE);
|
||||
} else if (strcmp(value, "off") == 0) {
|
||||
} else if (strcmp(args[1], "off") == 0) {
|
||||
cons_show("Typing notifications disabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_TYPING, FALSE);
|
||||
} else {
|
||||
@@ -2244,10 +2263,10 @@ cmd_notify(gchar **args, struct cmd_help_t help)
|
||||
|
||||
// set invite setting
|
||||
} else if (strcmp(kind, "invite") == 0) {
|
||||
if (strcmp(value, "on") == 0) {
|
||||
if (strcmp(args[1], "on") == 0) {
|
||||
cons_show("Chat room invite notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_INVITE, TRUE);
|
||||
} else if (strcmp(value, "off") == 0) {
|
||||
} else if (strcmp(args[1], "off") == 0) {
|
||||
cons_show("Chat room invite notifications disabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_INVITE, FALSE);
|
||||
} else {
|
||||
@@ -2256,10 +2275,10 @@ cmd_notify(gchar **args, struct cmd_help_t help)
|
||||
|
||||
// set subscription setting
|
||||
} else if (strcmp(kind, "sub") == 0) {
|
||||
if (strcmp(value, "on") == 0) {
|
||||
if (strcmp(args[1], "on") == 0) {
|
||||
cons_show("Subscription notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_SUB, TRUE);
|
||||
} else if (strcmp(value, "off") == 0) {
|
||||
} else if (strcmp(args[1], "off") == 0) {
|
||||
cons_show("Subscription notifications disabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_SUB, FALSE);
|
||||
} else {
|
||||
@@ -2268,7 +2287,7 @@ cmd_notify(gchar **args, struct cmd_help_t help)
|
||||
|
||||
// set remind setting
|
||||
} else if (strcmp(kind, "remind") == 0) {
|
||||
gint period = atoi(value);
|
||||
gint period = atoi(args[1]);
|
||||
prefs_set_notify_remind(period);
|
||||
if (period == 0) {
|
||||
cons_show("Message reminders disabled.");
|
||||
|
||||
Reference in New Issue
Block a user