talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit a9ead9d10f511119061dd7619aa7b050d1dc9507
parent 0970a983844b1bb9616821383f0a4d55a59dd6bf
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Thu, 24 Mar 2016 20:39:26 +0100

Empty account block in password store when deleting an account.

This effectively deletes it, as empty password blocks are
not saved to disk.

Diffstat:
Msrc/account.c | 5+++++
Msrc/passwordstore.c | 21+++++++++++++++++++++
Msrc/passwordstore.h | 3+++
3 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/account.c b/src/account.c @@ -54,6 +54,7 @@ #include "filtering.h" #include "prefs_actions.h" #include "hooks.h" +#include "passwordstore.h" enum { ACCOUNT_IS_DEFAULT, @@ -1103,6 +1104,10 @@ static void account_delete(GtkWidget *widget, gpointer data) GINT_TO_POINTER(ac_prefs->account_id)); } + gchar *uid = g_strdup_printf("%d", ac_prefs->account_id); + passwd_store_delete_block(PWS_ACCOUNT, uid); + g_free(uid); + debug_print("Removing filter rules relative to this account...\n"); for(cur = filtering_rules ; cur != NULL ;) { FilteringProp * prop = (FilteringProp *) cur->data; diff --git a/src/passwordstore.c b/src/passwordstore.c @@ -208,6 +208,27 @@ gchar *passwd_store_get(PasswordBlockType block_type, return password; } +gboolean passwd_store_delete_block(PasswordBlockType block_type, + const gchar *block_name) +{ + PasswordBlock *block; + + g_return_val_if_fail(block_type >= 0 && block_type < NUM_PWS_TYPES, + FALSE); + g_return_val_if_fail(block_name != NULL, FALSE); + + debug_print("Deleting block (%d/%s)\n", block_type, block_name); + + // find correct block + if ((block = _get_block(block_type, block_name)) == NULL) { + debug_print("Block (%d/%s) not found.\n", block_type, block_name); + return FALSE; + } + + g_hash_table_destroy(block->entries); + return TRUE; +} + gboolean passwd_store_set_account(gint account_id, const gchar *password_id, const gchar *password, diff --git a/src/passwordstore.h b/src/passwordstore.h @@ -57,6 +57,9 @@ gchar *passwd_store_get(PasswordBlockType block_type, const gchar *block_name, const gchar *password_id); +gboolean passwd_store_delete_block(PasswordBlockType block_type, + const gchar *block_name); + /* Reencrypts all stored passwords using new_mpwd as an encryption * password. */ void passwd_store_reencrypt_all(const gchar *old_mpwd,