Introduce our own shutdown callback mechanism.

Instead of adding stuff to `_shutdown()`, we can now register a shutdown
routine from the respective `init()` function of our modules.

This also has the advantage, that we're sure they're called in reverse
order from how the initialization happened.

I didn't simply use `atexit()` because POSIX says that the number of
possible callbacks is limited (min 32) and I was not sure whether
we will maybe extend this number at one point.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2025-03-07 11:44:31 +01:00
parent 662a0be633
commit c5a131ee46
39 changed files with 321 additions and 327 deletions

View File

@@ -27,7 +27,7 @@
#include <xmpp/xmpp.h>
void
chat_log_init(void)
chatlog_init(void)
{
}
@@ -65,11 +65,6 @@ chat_log_omemo_msg_in(ProfMessage* message)
{
}
void
chat_log_close(void)
{
}
void
groupchat_log_init(void)
{

View File

@@ -10,10 +10,6 @@ void
accounts_load(void)
{
}
void
accounts_close(void)
{
}
char*
accounts_find_all(const char* const prefix, gboolean previous, void* context)

View File

@@ -78,10 +78,6 @@ log_stderr_init(log_level_t level)
{
}
void
log_stderr_close(void)
{
}
void
log_stderr_handler(void)
{
}

View File

@@ -7,10 +7,6 @@ void
omemo_init(void)
{
}
void
omemo_close(void)
{
}
char*
omemo_fingerprint_autocomplete(const char* const search_str, gboolean previous)

View File

@@ -33,10 +33,6 @@ void
otr_init(void)
{
}
void
otr_shutdown(void)
{
}
char*
otr_libotr_version(void)

View File

@@ -6,10 +6,6 @@ void
p_gpg_init(void)
{
}
void
p_gpg_close(void)
{
}
GHashTable*
p_gpg_list_keys(void)

View File

@@ -17,6 +17,9 @@
#include "plugins/plugins.h"
#include "ui/window_list.h"
void prof_shutdown(void);
void
console_shows_online_presence_when_set_online(void** state)
{
@@ -35,7 +38,7 @@ console_shows_online_presence_when_set_online(void** state)
sv_ev_contact_online(barejid, resource, NULL, NULL);
roster_destroy();
plugins_shutdown();
prof_shutdown();
}
void
@@ -56,7 +59,7 @@ console_shows_online_presence_when_set_all(void** state)
sv_ev_contact_online(barejid, resource, NULL, NULL);
roster_destroy();
plugins_shutdown();
prof_shutdown();
}
void
@@ -77,7 +80,7 @@ console_shows_dnd_presence_when_set_all(void** state)
sv_ev_contact_online(barejid, resource, NULL, NULL);
roster_destroy();
plugins_shutdown();
prof_shutdown();
}
void
@@ -103,7 +106,7 @@ handle_offline_removes_chat_session(void** state)
roster_destroy();
chat_sessions_clear();
plugins_shutdown();
prof_shutdown();
}
void

View File

@@ -63,10 +63,6 @@ ui_update(void)
{
}
void
ui_close(void)
{
}
void
ui_redraw(void)
{
}

View File

@@ -47,10 +47,6 @@ session_disconnect(void)
{
}
void
session_shutdown(void)
{
}
void
session_process_events(void)
{
}
@@ -477,11 +473,6 @@ caps_lookup(const char* const jid)
return NULL;
}
void
caps_close(void)
{
}
void
caps_destroy(EntityCapabilities* caps)
{