mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
* #25241: gnome: dlclose and free addressbook when exiting
This commit is contained in:
@ -158,6 +158,8 @@ sflphone_quit(gboolean force_quit, SFLPhoneClient *client)
|
||||
calllist_clean(current_calls_tab);
|
||||
calllist_clean(contacts_tab);
|
||||
calllist_clean(history_tab);
|
||||
free_addressbook();
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,32,0)
|
||||
g_application_quit(G_APPLICATION(client));
|
||||
#else
|
||||
|
@ -84,21 +84,26 @@ handler_async_search(GList *hits, gpointer user_data)
|
||||
|
||||
void abook_init()
|
||||
{
|
||||
/* Clear any existing error */
|
||||
dlerror();
|
||||
|
||||
const gchar *addrbook_path = PLUGINS_DIR "/libevladdrbook.so";
|
||||
/* FIXME: handle should be unloaded with dlclose on exit */
|
||||
void *handle = dlopen(addrbook_path, RTLD_LAZY);
|
||||
|
||||
if (handle == NULL) {
|
||||
g_debug("Did not load addressbook from path %s", addrbook_path);
|
||||
g_debug("Did not load addressbook from path %s:%s", addrbook_path, dlerror());
|
||||
return;
|
||||
}
|
||||
|
||||
addrbook = g_new0(AddrBookHandle, 1);
|
||||
/* Keep the handle around to dlclose it later */
|
||||
addrbook->handle = handle;
|
||||
|
||||
#define LOAD(func) do { \
|
||||
addrbook-> func = dlsym(handle, "addressbook_" #func); \
|
||||
if (addrbook-> func == NULL) { \
|
||||
g_warning("Couldn't load " # func); \
|
||||
g_warning("Couldn't load " # func ":%s", dlerror());\
|
||||
dlclose(handle); \
|
||||
g_free(addrbook); \
|
||||
addrbook = NULL; \
|
||||
@ -118,3 +123,15 @@ void abook_init()
|
||||
|
||||
addrbook->search_cb = handler_async_search;
|
||||
}
|
||||
|
||||
void
|
||||
free_addressbook()
|
||||
{
|
||||
if (!addrbook)
|
||||
return;
|
||||
|
||||
if (addrbook->handle)
|
||||
dlclose(addrbook->handle);
|
||||
|
||||
g_free(addrbook);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "addressbook.h"
|
||||
|
||||
void abook_init();
|
||||
void free_addressbook();
|
||||
|
||||
extern AddrBookHandle *addrbook;
|
||||
|
||||
|
@ -86,6 +86,7 @@ struct AddrBookHandle {
|
||||
void (*set_current_book)(const gchar *);
|
||||
void (*set_search_type)(AddrbookSearchType);
|
||||
void (*search_cb)(GList *, gpointer);
|
||||
void *handle;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user