From 438552c14cd5fc32adcc39f5a88fd2c0a17242b2 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 25 May 2020 13:49:24 +0200 Subject: [PATCH] Save bookmark ignore list --- src/command/cmd_funcs.c | 2 +- src/tools/bookmark_ignore.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 83a050ed..7d9f92f2 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4780,7 +4780,7 @@ cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args) // `/bookmark ignore` lists them if (args[1] == NULL) { - gsize len; + gsize len = 0; gchar **list = bookmark_ignore_list(&len); cons_show_bookmarks_ignore(list, len); g_strfreev(list); diff --git a/src/tools/bookmark_ignore.c b/src/tools/bookmark_ignore.c index 2be65d5f..5e6a43c5 100644 --- a/src/tools/bookmark_ignore.c +++ b/src/tools/bookmark_ignore.c @@ -63,6 +63,22 @@ _bookmark_ignore_load() free(bi_loc); } +static void +_bookmark_save() +{ + gsize g_data_size; + gchar *g_bookmark_ignore_data = g_key_file_to_data(bookmark_ignore_keyfile, &g_data_size, NULL); + + char *bi_loc; + bi_loc = files_get_data_path(FILE_BOOKMARK_AUTOJOIN_IGNORE); + + g_file_set_contents(bi_loc, g_bookmark_ignore_data, g_data_size, NULL); + g_chmod(bi_loc, S_IRUSR | S_IWUSR); + + free(bi_loc); + g_free(g_bookmark_ignore_data); +} + void bookmark_ignore_on_connect(const char *const barejid) { @@ -96,10 +112,12 @@ void bookmark_ignore_add(const char *const barejid) { g_key_file_set_boolean(bookmark_ignore_keyfile, account_jid, barejid, TRUE); + _bookmark_save(); } void bookmark_ignore_remove(const char *const barejid) { g_key_file_remove_key(bookmark_ignore_keyfile, account_jid, barejid, NULL); + _bookmark_save(); }