[Commits] [SCM] claws branch, master, updated. 3.13.2-86-ga9ead9d

ticho at claws-mail.org ticho at claws-mail.org
Thu Mar 24 20:40:37 CET 2016


The branch, master has been updated
       via  a9ead9d10f511119061dd7619aa7b050d1dc9507 (commit)
      from  0970a983844b1bb9616821383f0a4d55a59dd6bf (commit)

Summary of changes:
 src/account.c       |    5 +++++
 src/passwordstore.c |   21 +++++++++++++++++++++
 src/passwordstore.h |    3 +++
 3 files changed, 29 insertions(+)


- Log -----------------------------------------------------------------
commit a9ead9d10f511119061dd7619aa7b050d1dc9507
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Thu Mar 24 20:39:26 2016 +0100

    Empty account block in password store when deleting an account.
    
    This effectively deletes it, as empty password blocks are
    not saved to disk.

diff --git a/src/account.c b/src/account.c
index 58dfab9..e2f472f 100644
--- 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
index 4cdddd1..dcb9d52 100644
--- 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
index 373116b..20d2c6b 100644
--- 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,

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list