about summary refs log tree commit diff stats
path: root/src/event
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2023-05-11 08:45:46 +0200
committerGitHub <noreply@github.com>2023-05-11 08:45:46 +0200
commitea35a4ceb03a975b4c1dabc5eb71510162dbe25f (patch)
tree15c2735f04b414a1a8426499302f90fb9408a6f3 /src/event
parent7f3fca2bd081a729d425184f7a0484025862257e (diff)
parent209a8f4bf5b2db2ca54f727d29e625228bccd170 (diff)
downloadprofani-tty-ea35a4ceb03a975b4c1dabc5eb71510162dbe25f.tar.gz
Merge branch 'master' into cleanup/gchar-char
Diffstat (limited to 'src/event')
-rw-r--r--src/event/client_events.c16
-rw-r--r--src/event/client_events.h1
-rw-r--r--src/event/server_events.c2
3 files changed, 16 insertions, 3 deletions
diff --git a/src/event/client_events.c b/src/event/client_events.c
index 67ffec20..c393ccd4 100644
--- a/src/event/client_events.c
+++ b/src/event/client_events.c
@@ -47,6 +47,7 @@
 #include "plugins/plugins.h"
 #include "ui/window_list.h"
 #include "xmpp/chat_session.h"
+#include "xmpp/session.h"
 #include "xmpp/xmpp.h"
 
 #ifdef HAVE_LIBOTR
@@ -85,9 +86,8 @@ cl_ev_connect_account(ProfAccount* account)
 void
 cl_ev_disconnect(void)
 {
-    char* mybarejid = connection_get_barejid();
+    auto_char char* mybarejid = connection_get_barejid();
     cons_show("%s logged out successfully.", mybarejid);
-    free(mybarejid);
 
     ui_close_all_wins();
     ev_disconnect_cleanup();
@@ -96,6 +96,18 @@ cl_ev_disconnect(void)
 }
 
 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
 cl_ev_presence_send(const resource_presence_t presence_type, const int idle_secs)
 {
     char* signed_status = NULL;
diff --git a/src/event/client_events.h b/src/event/client_events.h
index fed2bb37..a35e97b5 100644
--- a/src/event/client_events.h
+++ b/src/event/client_events.h
@@ -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);
 
 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);
 
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 01002a1e..c10f69c3 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -1332,8 +1332,8 @@ sv_ev_bookmark_autojoin(Bookmark* bookmark)
 
     log_debug("Autojoin %s with nick=%s", bookmark->barejid, nick);
     if (!muc_active(bookmark->barejid)) {
-        presence_join_room(bookmark->barejid, nick, bookmark->password);
         muc_join(bookmark->barejid, nick, bookmark->password, TRUE);
+        presence_join_room(bookmark->barejid, nick, bookmark->password);
         iq_room_affiliation_list(bookmark->barejid, "member", false);
         iq_room_affiliation_list(bookmark->barejid, "admin", false);
         iq_room_affiliation_list(bookmark->barejid, "owner", false);