Added settings for message notifications in current window

This commit is contained in:
James Booth
2014-05-24 20:46:03 +01:00
parent 8e14946aad
commit eb0f0dd96b
6 changed files with 107 additions and 31 deletions

View File

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