From f27cae68c507c6def2591ec43c130f92f485fbec Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 1 Jan 2016 19:50:13 +0000 Subject: Added autoping timeout preference --- src/command/commands.c | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'src/command/commands.c') 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; -- cgit 1.4.1-2-gfad0