1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-16 21:35:24 +00:00

add now option to /reconnect command

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel 2022-12-27 22:53:18 +01:00
parent a45f05a45e
commit a0aa26b6fa
5 changed files with 22 additions and 15 deletions

View File

@ -1936,11 +1936,13 @@ static const struct cmd_t command_defs[] = {
CMD_TAGS(
CMD_TAG_CONNECTION)
CMD_SYN(
"/reconnect <seconds>")
"/reconnect <seconds>",
"/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(
{ "<seconds>", "Number of seconds before attempting to reconnect, a value of 0 disables reconnect." })
{ "<seconds>", "Number of seconds before attempting to reconnect, a value of 0 disables reconnect." },
{ "now", "Immediately trigger a reconnect." })
},
{ CMD_PREAMBLE("/autoping",

View File

@ -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);

View File

@ -96,8 +96,6 @@ static activity_state_t activity_state;
static resource_presence_t saved_presence;
static char* saved_status;
static void _session_reconnect(void);
static void _session_free_internals(void);
static void _session_free_saved_details(void);
@ -268,12 +266,12 @@ session_process_events(void)
if ((reconnect_sec != 0) && reconnect_timer) {
int elapsed_sec = g_timer_elapsed(reconnect_timer, NULL);
if (elapsed_sec > reconnect_sec) {
_session_reconnect();
session_reconnect_now();
}
}
break;
case JABBER_RECONNECT:
_session_reconnect();
session_reconnect_now();
break;
default:
break;
@ -557,8 +555,8 @@ session_reconnect(gchar* altdomain, unsigned short altport)
reconnect.altport = altport;
}
static void
_session_reconnect(void)
void
session_reconnect_now(void)
{
// reconnect with account.
ProfAccount* account = accounts_get_account(saved_account.name);

View File

@ -47,5 +47,6 @@ void session_init_activity(void);
void session_check_autoaway(void);
void session_reconnect(gchar* altdomain, unsigned short altport);
void session_reconnect_now(void);
#endif

View File

@ -38,6 +38,10 @@ session_connect_with_account(const ProfAccount* const account)
return mock_type(jabber_conn_status_t);
}
void
session_reconnect_now(void)
{
}
void
session_disconnect(void)
{