[gnome-keyring/dbus-api] [secret-store] Add gck_secret_fields_take() functionality.
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-keyring/dbus-api] [secret-store] Add gck_secret_fields_take() functionality.
- Date: Fri, 14 Aug 2009 22:50:17 +0000 (UTC)
commit 25e684ce4dcfaf07dcd604a5fab364cb875ce691
Author: Stef Walter <stef memberwebs com>
Date: Fri Aug 14 21:10:30 2009 +0000
[secret-store] Add gck_secret_fields_take() functionality.
pkcs11/secret-store/gck-secret-fields.c | 12 +++++++++++-
pkcs11/secret-store/gck-secret-fields.h | 4 ++++
.../secret-store/tests/unit-test-secret-fields.c | 6 +++++-
3 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/pkcs11/secret-store/gck-secret-fields.c b/pkcs11/secret-store/gck-secret-fields.c
index 6d27ba6..b90f101 100644
--- a/pkcs11/secret-store/gck-secret-fields.c
+++ b/pkcs11/secret-store/gck-secret-fields.c
@@ -314,12 +314,22 @@ gck_secret_fields_match (GHashTable *haystack, GHashTable *needle)
}
void
+gck_secret_fields_take (GHashTable *fields, gchar *name, gchar *value)
+{
+ g_return_if_fail (fields);
+ g_return_if_fail (name);
+ if (value == NULL)
+ value = g_strdup ("");
+ g_hash_table_replace (fields, name, value);
+}
+
+void
gck_secret_fields_add (GHashTable *fields, const gchar *name,
const gchar *value)
{
g_return_if_fail (fields);
g_return_if_fail (name);
- g_hash_table_replace (fields, g_strdup (name), g_strdup (value));
+ gck_secret_fields_take (fields, g_strdup (name), g_strdup (value));
}
const gchar*
diff --git a/pkcs11/secret-store/gck-secret-fields.h b/pkcs11/secret-store/gck-secret-fields.h
index 48e23af..206976c 100644
--- a/pkcs11/secret-store/gck-secret-fields.h
+++ b/pkcs11/secret-store/gck-secret-fields.h
@@ -57,6 +57,10 @@ void gck_secret_fields_add (GHashTable *field
const gchar *name,
const gchar *value);
+void gck_secret_fields_take (GHashTable *fields,
+ gchar *name,
+ gchar *value);
+
const gchar* gck_secret_fields_get (GHashTable *fields,
const gchar *name);
diff --git a/pkcs11/secret-store/tests/unit-test-secret-fields.c b/pkcs11/secret-store/tests/unit-test-secret-fields.c
index 9952370..8090106 100644
--- a/pkcs11/secret-store/tests/unit-test-secret-fields.c
+++ b/pkcs11/secret-store/tests/unit-test-secret-fields.c
@@ -54,7 +54,8 @@ DEFINE_TEST(fields_add_get_values)
const gchar *value;
gck_secret_fields_add (fields, "one", "value1");
- gck_secret_fields_add (fields, "two", "value2");
+ gck_secret_fields_take (fields, g_strdup ("two"), g_strdup ("value2"));
+ gck_secret_fields_add (fields, "three", NULL);
value = gck_secret_fields_get (fields, "one");
g_assert_cmpstr (value, ==, "value1");
@@ -62,6 +63,9 @@ DEFINE_TEST(fields_add_get_values)
value = gck_secret_fields_get (fields, "two");
g_assert_cmpstr (value, ==, "value2");
+ value = gck_secret_fields_get (fields, "three");
+ g_assert_cmpstr (value, ==, "");
+
g_hash_table_unref (fields);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]