1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Tidied output for /notify command

This commit is contained in:
James Booth 2015-11-29 00:34:53 +00:00
parent cadaf73148
commit b404663847

View File

@ -4269,52 +4269,68 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
if (!args[0]) { if (!args[0]) {
ProfWin *current = wins_get_current(); ProfWin *current = wins_get_current();
if (current->type == WIN_MUC) { if (current->type == WIN_MUC) {
win_println(current, 0, "");
ProfMucWin *mucwin = (ProfMucWin *)current; 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);
if (!has_notify && !has_notify_mention && !has_notify_trigger) { win_vprintln_ch(window, '!', "Notification settings for %s:", mucwin->roomjid);
win_vprintln_ch(window, '!', "No notification settings for %s", mucwin->roomjid); if (prefs_has_room_notify(mucwin->roomjid)) {
} else {
win_vprintln_ch(window, '!', "Notification settings for %s", mucwin->roomjid);
if (has_notify) {
if (prefs_get_room_notify(mucwin->roomjid)) { if (prefs_get_room_notify(mucwin->roomjid)) {
win_vprintln_ch(window, '!', " Message : ON"); win_vprintln_ch(window, '!', " Message : ON");
} else { } else {
win_vprintln_ch(window, '!', " Message : OFF"); win_vprintln_ch(window, '!', " Message : OFF");
} }
} else {
if (prefs_get_boolean(PREF_NOTIFY_ROOM)) {
win_vprintln_ch(window, '!', " Message : ON (global setting)");
} else {
win_vprintln_ch(window, '!', " Message : OFF (global setting)");
} }
if (has_notify_mention) { }
if (prefs_has_room_notify_mention(mucwin->roomjid)) {
if (prefs_get_room_notify_mention(mucwin->roomjid)) { if (prefs_get_room_notify_mention(mucwin->roomjid)) {
win_vprintln_ch(window, '!', " Mention : ON"); win_vprintln_ch(window, '!', " Mention : ON");
} else { } else {
win_vprintln_ch(window, '!', " Mention : OFF"); win_vprintln_ch(window, '!', " Mention : OFF");
} }
} else {
if (prefs_get_boolean(PREF_NOTIFY_ROOM_MENTION)) {
win_vprintln_ch(window, '!', " Mention : ON (global setting)");
} else {
win_vprintln_ch(window, '!', " Mention : OFF (global setting)");
} }
if (has_notify_trigger) { }
if (prefs_has_room_notify_trigger(mucwin->roomjid)) {
if (prefs_get_room_notify_trigger(mucwin->roomjid)) { if (prefs_get_room_notify_trigger(mucwin->roomjid)) {
win_vprintln_ch(window, '!', " Triggers : ON"); win_vprintln_ch(window, '!', " Triggers : ON");
} else { } else {
win_vprintln_ch(window, '!', " Triggers : OFF"); win_vprintln_ch(window, '!', " Triggers : OFF");
} }
}
}
} else { } else {
if (prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER)) {
win_vprintln_ch(window, '!', " Triggers : ON (global setting)");
} else {
win_vprintln_ch(window, '!', " Triggers : OFF (global setting)");
}
}
win_println(current, 0, "");
} else {
cons_show("");
cons_notify_setting(); cons_notify_setting();
cons_bad_cmd_usage(command);
} }
return TRUE; return TRUE;
} }
// chat settings // chat settings
if (strcmp(args[0], "chat") == 0) { if (g_strcmp0(args[0], "chat") == 0) {
if (strcmp(args[1], "on") == 0) { if (g_strcmp0(args[1], "on") == 0) {
cons_show("Chat notifications enabled."); cons_show("Chat notifications enabled.");
prefs_set_boolean(PREF_NOTIFY_CHAT, TRUE); prefs_set_boolean(PREF_NOTIFY_CHAT, TRUE);
} else if (strcmp(args[1], "off") == 0) { } else if (g_strcmp0(args[1], "off") == 0) {
cons_show("Chat notifications disabled."); cons_show("Chat notifications disabled.");
prefs_set_boolean(PREF_NOTIFY_CHAT, FALSE); prefs_set_boolean(PREF_NOTIFY_CHAT, FALSE);
} else if (strcmp(args[1], "current") == 0) { } else if (g_strcmp0(args[1], "current") == 0) {
if (g_strcmp0(args[2], "on") == 0) { if (g_strcmp0(args[2], "on") == 0) {
cons_show("Current window chat notifications enabled."); cons_show("Current window chat notifications enabled.");
prefs_set_boolean(PREF_NOTIFY_CHAT_CURRENT, TRUE); prefs_set_boolean(PREF_NOTIFY_CHAT_CURRENT, TRUE);
@ -4324,7 +4340,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
cons_show("Usage: /notify chat current on|off"); cons_show("Usage: /notify chat current on|off");
} }
} else if (strcmp(args[1], "text") == 0) { } else if (g_strcmp0(args[1], "text") == 0) {
if (g_strcmp0(args[2], "on") == 0) { if (g_strcmp0(args[2], "on") == 0) {
cons_show("Showing text in chat notifications enabled."); cons_show("Showing text in chat notifications enabled.");
prefs_set_boolean(PREF_NOTIFY_CHAT_TEXT, TRUE); prefs_set_boolean(PREF_NOTIFY_CHAT_TEXT, TRUE);
@ -4337,24 +4353,24 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} }
// chat room settings // chat room settings
} else if (strcmp(args[0], "room") == 0) { } else if (g_strcmp0(args[0], "room") == 0) {
if (strcmp(args[1], "on") == 0) { if (g_strcmp0(args[1], "on") == 0) {
cons_show("Room notifications enabled."); cons_show("Room notifications enabled.");
prefs_set_boolean(PREF_NOTIFY_ROOM, TRUE); prefs_set_boolean(PREF_NOTIFY_ROOM, TRUE);
} else if (strcmp(args[1], "off") == 0) { } else if (g_strcmp0(args[1], "off") == 0) {
cons_show("Room notifications disabled."); cons_show("Room notifications disabled.");
prefs_set_boolean(PREF_NOTIFY_ROOM, FALSE); prefs_set_boolean(PREF_NOTIFY_ROOM, FALSE);
} else if (strcmp(args[1], "mention") == 0) { } else if (g_strcmp0(args[1], "mention") == 0) {
if (strcmp(args[2], "on") == 0) { if (g_strcmp0(args[2], "on") == 0) {
cons_show("Room notifications with mention enabled."); cons_show("Room notifications with mention enabled.");
prefs_set_boolean(PREF_NOTIFY_ROOM_MENTION, TRUE); prefs_set_boolean(PREF_NOTIFY_ROOM_MENTION, TRUE);
} else if (strcmp(args[2], "off") == 0) { } else if (g_strcmp0(args[2], "off") == 0) {
cons_show("Room notifications with mention disabled."); cons_show("Room notifications with mention disabled.");
prefs_set_boolean(PREF_NOTIFY_ROOM_MENTION, FALSE); prefs_set_boolean(PREF_NOTIFY_ROOM_MENTION, FALSE);
} else { } else {
cons_show("Usage: /notify room mention on|off"); cons_show("Usage: /notify room mention on|off");
} }
} else if (strcmp(args[1], "current") == 0) { } else if (g_strcmp0(args[1], "current") == 0) {
if (g_strcmp0(args[2], "on") == 0) { if (g_strcmp0(args[2], "on") == 0) {
cons_show("Current window chat room message notifications enabled."); cons_show("Current window chat room message notifications enabled.");
prefs_set_boolean(PREF_NOTIFY_ROOM_CURRENT, TRUE); prefs_set_boolean(PREF_NOTIFY_ROOM_CURRENT, TRUE);
@ -4364,7 +4380,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
cons_show("Usage: /notify room current on|off"); cons_show("Usage: /notify room current on|off");
} }
} else if (strcmp(args[1], "text") == 0) { } else if (g_strcmp0(args[1], "text") == 0) {
if (g_strcmp0(args[2], "on") == 0) { if (g_strcmp0(args[2], "on") == 0) {
cons_show("Showing text in chat room message notifications enabled."); cons_show("Showing text in chat room message notifications enabled.");
prefs_set_boolean(PREF_NOTIFY_ROOM_TEXT, TRUE); prefs_set_boolean(PREF_NOTIFY_ROOM_TEXT, TRUE);
@ -4424,14 +4440,14 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} }
// typing settings // typing settings
} else if (strcmp(args[0], "typing") == 0) { } else if (g_strcmp0(args[0], "typing") == 0) {
if (strcmp(args[1], "on") == 0) { if (g_strcmp0(args[1], "on") == 0) {
cons_show("Typing notifications enabled."); cons_show("Typing notifications enabled.");
prefs_set_boolean(PREF_NOTIFY_TYPING, TRUE); prefs_set_boolean(PREF_NOTIFY_TYPING, TRUE);
} else if (strcmp(args[1], "off") == 0) { } else if (g_strcmp0(args[1], "off") == 0) {
cons_show("Typing notifications disabled."); cons_show("Typing notifications disabled.");
prefs_set_boolean(PREF_NOTIFY_TYPING, FALSE); prefs_set_boolean(PREF_NOTIFY_TYPING, FALSE);
} else if (strcmp(args[1], "current") == 0) { } else if (g_strcmp0(args[1], "current") == 0) {
if (g_strcmp0(args[2], "on") == 0) { if (g_strcmp0(args[2], "on") == 0) {
cons_show("Current window typing notifications enabled."); cons_show("Current window typing notifications enabled.");
prefs_set_boolean(PREF_NOTIFY_TYPING_CURRENT, TRUE); prefs_set_boolean(PREF_NOTIFY_TYPING_CURRENT, TRUE);
@ -4446,11 +4462,11 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} }
// invite settings // invite settings
} else if (strcmp(args[0], "invite") == 0) { } else if (g_strcmp0(args[0], "invite") == 0) {
if (strcmp(args[1], "on") == 0) { if (g_strcmp0(args[1], "on") == 0) {
cons_show("Chat room invite notifications enabled."); cons_show("Chat room invite notifications enabled.");
prefs_set_boolean(PREF_NOTIFY_INVITE, TRUE); prefs_set_boolean(PREF_NOTIFY_INVITE, TRUE);
} else if (strcmp(args[1], "off") == 0) { } else if (g_strcmp0(args[1], "off") == 0) {
cons_show("Chat room invite notifications disabled."); cons_show("Chat room invite notifications disabled.");
prefs_set_boolean(PREF_NOTIFY_INVITE, FALSE); prefs_set_boolean(PREF_NOTIFY_INVITE, FALSE);
} else { } else {
@ -4458,11 +4474,11 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} }
// subscription settings // subscription settings
} else if (strcmp(args[0], "sub") == 0) { } else if (g_strcmp0(args[0], "sub") == 0) {
if (strcmp(args[1], "on") == 0) { if (g_strcmp0(args[1], "on") == 0) {
cons_show("Subscription notifications enabled."); cons_show("Subscription notifications enabled.");
prefs_set_boolean(PREF_NOTIFY_SUB, TRUE); prefs_set_boolean(PREF_NOTIFY_SUB, TRUE);
} else if (strcmp(args[1], "off") == 0) { } else if (g_strcmp0(args[1], "off") == 0) {
cons_show("Subscription notifications disabled."); cons_show("Subscription notifications disabled.");
prefs_set_boolean(PREF_NOTIFY_SUB, FALSE); prefs_set_boolean(PREF_NOTIFY_SUB, FALSE);
} else { } else {
@ -4470,7 +4486,10 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} }
// remind settings // remind settings
} else if (strcmp(args[0], "remind") == 0) { } else if (g_strcmp0(args[0], "remind") == 0) {
if (!args[1]) {
cons_bad_cmd_usage(command);
} else {
gint period = atoi(args[1]); gint period = atoi(args[1]);
prefs_set_notify_remind(period); prefs_set_notify_remind(period);
if (period == 0) { if (period == 0) {
@ -4480,6 +4499,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
cons_show("Message reminder period set to %d seconds.", period); cons_show("Message reminder period set to %d seconds.", period);
} }
}
// current chat room settings // current chat room settings
} else if (g_strcmp0(args[0], "on") == 0) { } else if (g_strcmp0(args[0], "on") == 0) {