From a0aa26b6fa65ba625f4a6d3495a345c7120ff16d Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 27 Dec 2022 22:53:18 +0100 Subject: add `now` option to `/reconnect` command Signed-off-by: Steffen Jaeckel --- src/command/cmd_defs.c | 8 +++++--- src/command/cmd_funcs.c | 14 ++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/command') diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 6b494e1a..fb37341d 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1936,11 +1936,13 @@ static const struct cmd_t command_defs[] = { CMD_TAGS( CMD_TAG_CONNECTION) CMD_SYN( - "/reconnect ") + "/reconnect ", + "/reconnect now") CMD_DESC( - "Set the reconnect attempt interval for when the connection is lost.") + "Set the reconnect attempt interval for when the connection is lost or immediately trigger a reconnect.") CMD_ARGS( - { "", "Number of seconds before attempting to reconnect, a value of 0 disables reconnect." }) + { "", "Number of seconds before attempting to reconnect, a value of 0 disables reconnect." }, + { "now", "Immediately trigger a reconnect." }) }, { CMD_PREAMBLE("/autoping", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index a97240ff..bbfb3cb8 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -82,16 +82,17 @@ #include "plugins/plugins.h" #include "ui/ui.h" #include "ui/window_list.h" -#include "xmpp/xmpp.h" +#include "xmpp/avatar.h" +#include "xmpp/chat_session.h" #include "xmpp/connection.h" #include "xmpp/contact.h" -#include "xmpp/roster_list.h" #include "xmpp/jid.h" #include "xmpp/muc.h" -#include "xmpp/chat_session.h" -#include "xmpp/avatar.h" +#include "xmpp/roster_list.h" +#include "xmpp/session.h" #include "xmpp/stanza.h" #include "xmpp/vcard_funcs.h" +#include "xmpp/xmpp.h" #ifdef HAVE_LIBOTR #include "otr/otr.h" @@ -6539,8 +6540,9 @@ cmd_reconnect(ProfWin* window, const char* const command, gchar** args) int intval = 0; char* err_msg = NULL; - gboolean res = strtoi_range(value, &intval, 0, INT_MAX, &err_msg); - if (res) { + if (g_strcmp0(value, "now") == 0) { + session_reconnect_now(); + } else if (strtoi_range(value, &intval, 0, INT_MAX, &err_msg)) { prefs_set_reconnect(intval); if (intval == 0) { cons_show("Reconnect disabled.", intval); -- cgit