From acb23fb44417d152d610cfb4f384629b56c81c1c Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 10 Mar 2013 19:36:08 +0000 Subject: Handle dependent settings /history requires /chlog /outtype and /gone require /states --- src/command/command.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'src/command') diff --git a/src/command/command.c b/src/command/command.c index f016a517..fd8747d9 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -2182,8 +2182,16 @@ _cmd_set_beep(gchar **args, struct cmd_help_t help) static gboolean _cmd_set_states(gchar **args, struct cmd_help_t help) { - return _cmd_set_boolean_preference(args[0], help, "Sending chat states", + gboolean result = _cmd_set_boolean_preference(args[0], help, "Sending chat states", PREF_STATES); + + // if disabled, disable outtype and gone + if (result == TRUE && (strcmp(args[0], "off") == 0)) { + prefs_set_boolean(PREF_OUTTYPE, FALSE); + prefs_set_gone(0); + } + + return result; } static gboolean @@ -2201,8 +2209,15 @@ _cmd_set_titlebar(gchar **args, struct cmd_help_t help) static gboolean _cmd_set_outtype(gchar **args, struct cmd_help_t help) { - return _cmd_set_boolean_preference(args[0], help, + gboolean result = _cmd_set_boolean_preference(args[0], help, "Sending typing notifications", PREF_OUTTYPE); + + // if enabled, enable states + if (result == TRUE && (strcmp(args[0], "on") == 0)) { + prefs_set_boolean(PREF_STATES, TRUE); + } + + return result; } static gboolean @@ -2220,6 +2235,11 @@ _cmd_set_gone(gchar **args, struct cmd_help_t help) cons_show("Leaving conversations after %d minutes of inactivity.", period); } + // if enabled, enable states + if (period > 0) { + prefs_set_boolean(PREF_STATES, TRUE); + } + return TRUE; } @@ -2462,8 +2482,15 @@ _cmd_set_splash(gchar **args, struct cmd_help_t help) static gboolean _cmd_set_chlog(gchar **args, struct cmd_help_t help) { - return _cmd_set_boolean_preference(args[0], help, + gboolean result = _cmd_set_boolean_preference(args[0], help, "Chat logging", PREF_CHLOG); + + // if set to off, disable history + if (result == TRUE && (strcmp(args[0], "off") == 0)) { + prefs_set_boolean(PREF_HISTORY, FALSE); + } + + return result; } static gboolean @@ -2476,8 +2503,15 @@ _cmd_set_mouse(gchar **args, struct cmd_help_t help) static gboolean _cmd_set_history(gchar **args, struct cmd_help_t help) { - return _cmd_set_boolean_preference(args[0], help, + gboolean result = _cmd_set_boolean_preference(args[0], help, "Chat history", PREF_HISTORY); + + // if set to on, set chlog + if (result == TRUE && (strcmp(args[0], "on") == 0)) { + prefs_set_boolean(PREF_CHLOG, TRUE); + } + + return result; } static gboolean -- cgit 1.4.1-2-gfad0