[Commits] [SCM] claws branch, master, updated. 3.16.0-227-gfa7bec8
ticho at claws-mail.org
ticho at claws-mail.org
Sun Jul 1 22:15:43 CEST 2018
The branch, master has been updated
via fa7bec8685ac1b2dfda2c113ed5a876f33c506a7 (commit)
from babfcbc9c9822157da38bbfe946a8dd781ca2ab9 (commit)
Summary of changes:
src/passwordstore.c | 36 ++++++++++++++++++++++++++++++++++++
src/passwordstore.h | 11 ++++++++++-
2 files changed, 46 insertions(+), 1 deletion(-)
- Log -----------------------------------------------------------------
commit fa7bec8685ac1b2dfda2c113ed5a876f33c506a7
Author: Andrej Kacian <ticho at claws-mail.org>
Date: Sun Jul 1 21:56:16 2018 +0200
Added a password store function to check if a password exists.
diff --git a/src/passwordstore.c b/src/passwordstore.c
index 5709f15..97f44d3 100644
--- a/src/passwordstore.c
+++ b/src/passwordstore.c
@@ -208,6 +208,33 @@ gchar *passwd_store_get(PasswordBlockType block_type,
return password;
}
+/* Checks if a password exists in the password store.
+ * No decryption happens. */
+gboolean passwd_store_has_password(PasswordBlockType block_type,
+ const gchar *block_name,
+ const gchar *password_id)
+{
+ PasswordBlock *block;
+
+ g_return_val_if_fail(block_type < NUM_PWS_TYPES, FALSE);
+ g_return_val_if_fail(block_name != NULL, FALSE);
+ g_return_val_if_fail(password_id != NULL, FALSE);
+
+ /* 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;
+ }
+
+ /* do we have specified password in this block? */
+ if (g_hash_table_lookup(block->entries, password_id) != NULL) {
+ return TRUE; /* yes */
+ }
+
+ return FALSE; /* no */
+}
+
+
gboolean passwd_store_delete_block(PasswordBlockType block_type,
const gchar *block_name)
{
@@ -250,6 +277,15 @@ gchar *passwd_store_get_account(gint account_id,
return ret;
}
+gboolean passwd_store_has_password_account(gint account_id,
+ const gchar *password_id)
+{
+ gchar *uid = g_strdup_printf("%d", account_id);
+ gboolean ret = passwd_store_has_password(PWS_ACCOUNT, uid, password_id);
+ g_free(uid);
+ return ret;
+}
+
/* Reencrypts all stored passwords. */
void passwd_store_reencrypt_all(const gchar *old_mpwd,
const gchar *new_mpwd)
diff --git a/src/passwordstore.h b/src/passwordstore.h
index aeaa40d..b919820 100644
--- a/src/passwordstore.h
+++ b/src/passwordstore.h
@@ -57,6 +57,12 @@ gchar *passwd_store_get(PasswordBlockType block_type,
const gchar *block_name,
const gchar *password_id);
+/* Returns TRUE if such password exists in the password store,
+ * false otherwise. No decryption happens. */
+gboolean passwd_store_has_password(PasswordBlockType block_type,
+ const gchar *block_name,
+ const gchar *password_id);
+
gboolean passwd_store_delete_block(PasswordBlockType block_type,
const gchar *block_name);
@@ -76,7 +82,10 @@ gboolean passwd_store_set_account(gint account_id,
const gchar *password_id,
const gchar *password,
gboolean encrypted);
-gchar *passwd_store_get_account(gint account_id, const gchar *block_name);
+gchar *passwd_store_get_account(gint account_id,
+ const gchar *password_id);
+gboolean passwd_store_has_password_account(gint account_id,
+ const gchar *password_id);
/* Macros for standard, predefined password IDs. */
#define PWS_ACCOUNT_RECV "recv"
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list