about summary refs log tree commit diff stats
path: root/src/command/commands.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-01-01 19:50:13 +0000
committerJames Booth <boothj5@gmail.com>2016-01-01 19:50:13 +0000
commitf27cae68c507c6def2591ec43c130f92f485fbec (patch)
treeac028a3e6ab8a3090c32503706485b479a574665 /src/command/commands.c
parent94b0d2c6da7e36c29ee091ae6212d70e9a9294e4 (diff)
downloadprofani-tty-f27cae68c507c6def2591ec43c130f92f485fbec.tar.gz
Added autoping timeout preference
Diffstat (limited to 'src/command/commands.c')
-rw-r--r--src/command/commands.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 404db139..192f241d 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -4788,23 +4788,46 @@ cmd_reconnect(ProfWin *window, const char *const command, gchar **args)
 gboolean
 cmd_autoping(ProfWin *window, const char *const command, gchar **args)
 {
-    char *value = args[0];
+    char *cmd = args[0];
+    char *value = args[1];
 
-    int intval = 0;
-    char *err_msg = NULL;
-    gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg);
-    if (res) {
-        prefs_set_autoping(intval);
-        iq_set_autoping(intval);
-        if (intval == 0) {
-            cons_show("Autoping disabled.", intval);
+    if (g_strcmp0(cmd, "set") == 0) {
+        int intval = 0;
+        char *err_msg = NULL;
+        gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg);
+        if (res) {
+            prefs_set_autoping(intval);
+            iq_set_autoping(intval);
+            if (intval == 0) {
+                cons_show("Autoping disabled.");
+            } else {
+                cons_show("Autoping interval set to %d seconds.", intval);
+            }
         } else {
-            cons_show("Autoping interval set to %d seconds.", intval);
+            cons_show(err_msg);
+            cons_bad_cmd_usage(command);
+            free(err_msg);
         }
+
+    } else if (g_strcmp0(cmd, "timeout") == 0) {
+        int intval = 0;
+        char *err_msg = NULL;
+        gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg);
+        if (res) {
+            prefs_set_autoping_timeout(intval);
+            if (intval == 0) {
+                cons_show("Autoping timeout disabled.");
+            } else {
+                cons_show("Autoping timeout set to %d seconds.", intval);
+            }
+        } else {
+            cons_show(err_msg);
+            cons_bad_cmd_usage(command);
+            free(err_msg);
+        }
+
     } else {
-        cons_show(err_msg);
         cons_bad_cmd_usage(command);
-        free(err_msg);
     }
 
     return TRUE;