1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

fix /reconnect now

This fixes #1846
Issue introduced by a0aa26b6fa

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel 2023-05-10 15:07:07 +02:00
parent 08d68d329b
commit 8cd53acfd7
7 changed files with 22 additions and 3 deletions

View File

@ -6575,7 +6575,8 @@ cmd_reconnect(ProfWin* window, const char* const command, gchar** args)
int intval = 0; int intval = 0;
char* err_msg = NULL; char* err_msg = NULL;
if (g_strcmp0(value, "now") == 0) { if (g_strcmp0(value, "now") == 0) {
session_reconnect_now(); cons_show("Reconnecting now.");
cl_ev_reconnect();
} else if (strtoi_range(value, &intval, 0, INT_MAX, &err_msg)) { } else if (strtoi_range(value, &intval, 0, INT_MAX, &err_msg)) {
prefs_set_reconnect(intval); prefs_set_reconnect(intval);
if (intval == 0) { if (intval == 0) {

View File

@ -47,6 +47,7 @@
#include "plugins/plugins.h" #include "plugins/plugins.h"
#include "ui/window_list.h" #include "ui/window_list.h"
#include "xmpp/chat_session.h" #include "xmpp/chat_session.h"
#include "xmpp/session.h"
#include "xmpp/xmpp.h" #include "xmpp/xmpp.h"
#ifdef HAVE_LIBOTR #ifdef HAVE_LIBOTR
@ -94,6 +95,18 @@ cl_ev_disconnect(void)
ev_reset_connection_counter(); ev_reset_connection_counter();
} }
void
cl_ev_reconnect(void)
{
if (connection_get_status() != JABBER_DISCONNECTED) {
connection_disconnect();
ev_disconnect_cleanup();
// on intentional disconnect reset the counter
ev_reset_connection_counter();
}
session_reconnect_now();
}
void void
cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs) cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs)
{ {

View File

@ -42,6 +42,7 @@ jabber_conn_status_t cl_ev_connect_jid(const char* const jid, const char* const
jabber_conn_status_t cl_ev_connect_account(ProfAccount* account); jabber_conn_status_t cl_ev_connect_account(ProfAccount* account);
void cl_ev_disconnect(void); void cl_ev_disconnect(void);
void cl_ev_reconnect(void);
void cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs); void cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs);

View File

@ -48,7 +48,6 @@ jabber_conn_status_t connection_connect(const char* const fulljid, const char* c
const char* const tls_policy, const char* const auth_policy); const char* const tls_policy, const char* const auth_policy);
jabber_conn_status_t connection_register(const char* const altdomain, int port, const char* const tls_policy, jabber_conn_status_t connection_register(const char* const altdomain, int port, const char* const tls_policy,
const char* const username, const char* const password); const char* const username, const char* const password);
void connection_disconnect(void);
void connection_set_disconnected(void); void connection_set_disconnected(void);
void connection_set_priority(const int priority); void connection_set_priority(const int priority);

View File

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

View File

@ -186,7 +186,9 @@ void session_disconnect(void);
void session_shutdown(void); void session_shutdown(void);
void session_process_events(void); void session_process_events(void);
char* session_get_account_name(void); char* session_get_account_name(void);
void session_reconnect_now(void);
void connection_disconnect(void);
jabber_conn_status_t connection_get_status(void); jabber_conn_status_t connection_get_status(void);
char* connection_get_presence_msg(void); char* connection_get_presence_msg(void);
void connection_set_presence_msg(const char* const message); void connection_set_presence_msg(const char* const message);

View File

@ -54,6 +54,10 @@ void
session_process_events(void) session_process_events(void)
{ {
} }
void
connection_disconnect(void)
{
}
const char* const char*
connection_get_fulljid(void) connection_get_fulljid(void)
{ {