about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-03-10 19:36:08 +0000
committerJames Booth <boothj5@gmail.com>2013-03-10 19:36:08 +0000
commitacb23fb44417d152d610cfb4f384629b56c81c1c (patch)
treeb5eb160efba5ae7692044854cb87fae2fb3142aa
parent177168a20f283a14aeba92d0b2e25478e3febf5c (diff)
downloadprofani-tty-acb23fb44417d152d610cfb4f384629b56c81c1c.tar.gz
Handle dependent settings
/history requires /chlog
/outtype and /gone require /states
-rw-r--r--src/command/command.c42
1 files changed, 38 insertions, 4 deletions
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