mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 21:06:20 +00:00
Added room specific notify settings
This commit is contained in:
@@ -1054,7 +1054,7 @@ static struct cmd_t command_defs[] =
|
||||
},
|
||||
|
||||
{ "/notify",
|
||||
cmd_notify, parse_args_with_freetext, 2, 4, &cons_notify_setting,
|
||||
cmd_notify, parse_args_with_freetext, 0, 4, NULL,
|
||||
CMD_TAGS(
|
||||
CMD_TAG_UI,
|
||||
CMD_TAG_CHAT,
|
||||
@@ -1075,6 +1075,9 @@ static struct cmd_t command_defs[] =
|
||||
"/notify room trigger remove <text>",
|
||||
"/notify room trigger list",
|
||||
"/notify room trigger on|off",
|
||||
"/notify on|off",
|
||||
"/notify mention on|off",
|
||||
"/notify trigger on|off"
|
||||
"/notify remind <seconds>",
|
||||
"/notify typing on|off",
|
||||
"/notify typing current on|off",
|
||||
@@ -1084,20 +1087,23 @@ static struct cmd_t command_defs[] =
|
||||
"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 current on|off", "Whether to show regular chat message notifications when the window is focussed." },
|
||||
{ "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", "Notifications for chat room messages, mention triggers notifications only when your nick is mentioned." },
|
||||
{ "room mention on|off", "Notifications for chat room messages when your nick is mentioned." },
|
||||
{ "room current on|off", "Whether chat room messages in the current window trigger notifications." },
|
||||
{ "message trigger on|off", "Enable or disable all regular chat notification triggers." },
|
||||
{ "room on|off", "Notifications for all chat room messages, 'mention' only notifies when your nick is mentioned." },
|
||||
{ "room mention on|off", "Notifications for all chat room messages when your nick is mentioned." },
|
||||
{ "room current on|off", "Whether to show all chat room messages notifications when the window is focussed." },
|
||||
{ "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." },
|
||||
{ "room trigger add <text>", "Notify when specified text included in all chat room messages." },
|
||||
{ "room trigger remove <text>", "Remove chat room notification trigger." },
|
||||
{ "room trigger list", "List all chat room triggers." },
|
||||
{ "room trigger on|off", "Enable or disable all chat room notification triggers." },
|
||||
{ "on|off", "Notifications for the current chat room." },
|
||||
{ "mention on|off", "Override the global 'mention' setting for the current chat room." },
|
||||
{ "trigger on|off", "Override the global 'trigger' setting for the current chat room." },
|
||||
{ "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." },
|
||||
@@ -1942,6 +1948,10 @@ cmd_init(void)
|
||||
autocomplete_add(notify_ac, "remind");
|
||||
autocomplete_add(notify_ac, "invite");
|
||||
autocomplete_add(notify_ac, "sub");
|
||||
autocomplete_add(notify_ac, "on");
|
||||
autocomplete_add(notify_ac, "off");
|
||||
autocomplete_add(notify_ac, "mention");
|
||||
autocomplete_add(notify_ac, "trigger");
|
||||
|
||||
notify_message_ac = autocomplete_new();
|
||||
autocomplete_add(notify_message_ac, "on");
|
||||
@@ -3178,9 +3188,14 @@ _notify_autocomplete(ProfWin *window, const char *const input)
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, "/notify room current", prefs_autocomplete_boolean_choice);
|
||||
if (result) {
|
||||
return result;
|
||||
gchar *boolean_choices1[] = { "/notify room current", "/notify message current", "/notify typing current",
|
||||
"/notify room text", "/notify room mention", "/notify message text" };
|
||||
for (i = 0; i < ARRAY_SIZE(boolean_choices1); i++) {
|
||||
result = autocomplete_param_with_func(input, boolean_choices1[i],
|
||||
prefs_autocomplete_boolean_choice);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/notify room trigger", notify_trigger_ac, TRUE);
|
||||
@@ -3188,36 +3203,11 @@ _notify_autocomplete(ProfWin *window, const char *const input)
|
||||
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;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, "/notify room text", prefs_autocomplete_boolean_choice);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, "/notify room mention", prefs_autocomplete_boolean_choice);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, "/notify message text", prefs_autocomplete_boolean_choice);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/notify room", notify_room_ac, TRUE);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -3233,9 +3223,9 @@ _notify_autocomplete(ProfWin *window, const char *const input)
|
||||
return result;
|
||||
}
|
||||
|
||||
gchar *boolean_choices[] = { "/notify invite", "/notify sub" };
|
||||
for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
|
||||
result = autocomplete_param_with_func(input, boolean_choices[i],
|
||||
gchar *boolean_choices2[] = { "/notify invite", "/notify sub", "/notify mention", "/notify trigger"};
|
||||
for (i = 0; i < ARRAY_SIZE(boolean_choices2); i++) {
|
||||
result = autocomplete_param_with_func(input, boolean_choices2[i],
|
||||
prefs_autocomplete_boolean_choice);
|
||||
if (result) {
|
||||
return result;
|
||||
|
||||
@@ -4266,16 +4266,48 @@ cmd_gone(ProfWin *window, const char *const command, gchar **args)
|
||||
gboolean
|
||||
cmd_notify(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
char *kind = args[0];
|
||||
if (!args[0]) {
|
||||
ProfWin *current = wins_get_current();
|
||||
if (current->type == WIN_MUC) {
|
||||
ProfMucWin *mucwin = (ProfMucWin *)current;
|
||||
gboolean has_notify = prefs_has_room_notify(mucwin->roomjid);
|
||||
gboolean has_notify_mention = prefs_has_room_notify_mention(mucwin->roomjid);
|
||||
gboolean has_notify_trigger = prefs_has_room_notify_trigger(mucwin->roomjid);
|
||||
|
||||
// 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, "room") != 0)) {
|
||||
cons_bad_cmd_usage(command);
|
||||
if (!has_notify && !has_notify_mention && !has_notify_trigger) {
|
||||
win_vprintln_ch(window, '!', "No notification settings for %s", mucwin->roomjid);
|
||||
} else {
|
||||
win_vprintln_ch(window, '!', "Notification settings for %s", mucwin->roomjid);
|
||||
if (has_notify) {
|
||||
if (prefs_get_room_notify(mucwin->roomjid)) {
|
||||
win_vprintln_ch(window, '!', " All: ON");
|
||||
} else {
|
||||
win_vprintln_ch(window, '!', " All: OFF");
|
||||
}
|
||||
}
|
||||
if (has_notify_mention) {
|
||||
if (prefs_get_room_notify_mention(mucwin->roomjid)) {
|
||||
win_vprintln_ch(window, '!', " Mention: ON");
|
||||
} else {
|
||||
win_vprintln_ch(window, '!', " Mention: OFF");
|
||||
}
|
||||
}
|
||||
if (has_notify_trigger) {
|
||||
if (prefs_get_room_notify_trigger(mucwin->roomjid)) {
|
||||
win_vprintln_ch(window, '!', " Triggers: ON");
|
||||
} else {
|
||||
win_vprintln_ch(window, '!', " Triggers: OFF");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cons_notify_setting();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// set message setting
|
||||
} else if (strcmp(kind, "message") == 0) {
|
||||
// message settings
|
||||
if (strcmp(args[0], "message") == 0) {
|
||||
if (strcmp(args[1], "on") == 0) {
|
||||
cons_show("Message notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_MESSAGE, TRUE);
|
||||
@@ -4351,8 +4383,8 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
|
||||
cons_show("Usage: /notify message on|off");
|
||||
}
|
||||
|
||||
// set room setting
|
||||
} else if (strcmp(kind, "room") == 0) {
|
||||
// chat room settings
|
||||
} else if (strcmp(args[0], "room") == 0) {
|
||||
if (strcmp(args[1], "on") == 0) {
|
||||
cons_show("Room notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_ROOM, TRUE);
|
||||
@@ -4438,8 +4470,8 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
|
||||
cons_show("Usage: /notify room on|off|mention");
|
||||
}
|
||||
|
||||
// set typing setting
|
||||
} else if (strcmp(kind, "typing") == 0) {
|
||||
// typing settings
|
||||
} else if (strcmp(args[0], "typing") == 0) {
|
||||
if (strcmp(args[1], "on") == 0) {
|
||||
cons_show("Typing notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_TYPING, TRUE);
|
||||
@@ -4460,8 +4492,8 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
|
||||
cons_show("Usage: /notify typing on|off");
|
||||
}
|
||||
|
||||
// set invite setting
|
||||
} else if (strcmp(kind, "invite") == 0) {
|
||||
// invite settings
|
||||
} else if (strcmp(args[0], "invite") == 0) {
|
||||
if (strcmp(args[1], "on") == 0) {
|
||||
cons_show("Chat room invite notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_INVITE, TRUE);
|
||||
@@ -4472,8 +4504,8 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
|
||||
cons_show("Usage: /notify invite on|off");
|
||||
}
|
||||
|
||||
// set subscription setting
|
||||
} else if (strcmp(kind, "sub") == 0) {
|
||||
// subscription settings
|
||||
} else if (strcmp(args[0], "sub") == 0) {
|
||||
if (strcmp(args[1], "on") == 0) {
|
||||
cons_show("Subscription notifications enabled.");
|
||||
prefs_set_boolean(PREF_NOTIFY_SUB, TRUE);
|
||||
@@ -4484,8 +4516,8 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
|
||||
cons_show("Usage: /notify sub on|off");
|
||||
}
|
||||
|
||||
// set remind setting
|
||||
} else if (strcmp(kind, "remind") == 0) {
|
||||
// remind settings
|
||||
} else if (strcmp(args[0], "remind") == 0) {
|
||||
gint period = atoi(args[1]);
|
||||
prefs_set_notify_remind(period);
|
||||
if (period == 0) {
|
||||
@@ -4496,8 +4528,114 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
|
||||
cons_show("Message reminder period set to %d seconds.", period);
|
||||
}
|
||||
|
||||
// current chat room settings
|
||||
} else if (g_strcmp0(args[0], "on") == 0) {
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currenlty connected.");
|
||||
} else {
|
||||
ProfWin *window = wins_get_current();
|
||||
if (window->type != WIN_MUC) {
|
||||
cons_show("You must be in a chat room.");
|
||||
} else {
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
prefs_set_room_notify(mucwin->roomjid, TRUE);
|
||||
win_vprintln_ch(window, '!', "Notifications enabled for %s", mucwin->roomjid);
|
||||
}
|
||||
}
|
||||
} else if (g_strcmp0(args[0], "off") == 0) {
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currenlty connected.");
|
||||
} else {
|
||||
ProfWin *window = wins_get_current();
|
||||
if (window->type != WIN_MUC) {
|
||||
cons_show("You must be in a chat room.");
|
||||
} else {
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
prefs_set_room_notify(mucwin->roomjid, FALSE);
|
||||
win_vprintln_ch(window, '!', "Notifications disabled for %s", mucwin->roomjid);
|
||||
}
|
||||
}
|
||||
} else if (g_strcmp0(args[0], "mention") == 0) {
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currenlty connected.");
|
||||
} else {
|
||||
if (g_strcmp0(args[1], "on") == 0) {
|
||||
ProfWin *window = wins_get_current();
|
||||
if (window->type != WIN_MUC) {
|
||||
cons_show("You must be in a chat room.");
|
||||
} else {
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
prefs_set_room_notify_mention(mucwin->roomjid, TRUE);
|
||||
win_vprintln_ch(window, '!', "Mention notifications enabled for %s", mucwin->roomjid);
|
||||
}
|
||||
} else if (g_strcmp0(args[1], "off") == 0) {
|
||||
ProfWin *window = wins_get_current();
|
||||
if (window->type != WIN_MUC) {
|
||||
cons_show("You must be in a chat rooms.");
|
||||
} else {
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
prefs_set_room_notify_mention(mucwin->roomjid, FALSE);
|
||||
win_vprintln_ch(window, '!', "Mention notifications disabled for %s", mucwin->roomjid);
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
}
|
||||
} else if (g_strcmp0(args[0], "trigger") == 0) {
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currenlty connected.");
|
||||
} else {
|
||||
if (g_strcmp0(args[1], "on") == 0) {
|
||||
ProfWin *window = wins_get_current();
|
||||
if (window->type != WIN_MUC) {
|
||||
cons_show("You must be in a chat room.");
|
||||
} else {
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
prefs_set_room_notify_trigger(mucwin->roomjid, TRUE);
|
||||
win_vprintln_ch(window, '!', "Custom trigger notifications enabled for %s", mucwin->roomjid);
|
||||
}
|
||||
} else if (g_strcmp0(args[1], "off") == 0) {
|
||||
ProfWin *window = wins_get_current();
|
||||
if (window->type != WIN_MUC) {
|
||||
cons_show("You must be in a chat rooms.");
|
||||
} else {
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
prefs_set_room_notify_trigger(mucwin->roomjid, FALSE);
|
||||
win_vprintln_ch(window, '!', "Custom trigger notifications disabled for %s", mucwin->roomjid);
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
}
|
||||
} else if (g_strcmp0(args[0], "reset") == 0) {
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currenlty connected.");
|
||||
} else {
|
||||
ProfWin *window = wins_get_current();
|
||||
if (window->type != WIN_MUC) {
|
||||
cons_show("You must be in a chat room.");
|
||||
} else {
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
gboolean res = prefs_reset_room_notify(mucwin->roomjid);
|
||||
if (res) {
|
||||
win_vprintln_ch(window, '!', "Notification settings set to global defaults for %s", mucwin->roomjid);
|
||||
} else {
|
||||
win_vprintln_ch(window, '!', "No custom notification settings for %s", mucwin->roomjid);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cons_show("Unknown command: %s.", kind);
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user