[libsecret] Add secret_value_get_text() function to return NULL terminated secret
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsecret] Add secret_value_get_text() function to return NULL terminated secret
- Date: Fri, 21 Jun 2013 13:13:39 +0000 (UTC)
commit cec740fea9a7ddec75cd625f86c03827e098326c
Author: Stef Walter <stefw gnome org>
Date: Thu Jun 20 12:11:27 2013 +0200
Add secret_value_get_text() function to return NULL terminated secret
docs/reference/libsecret/libsecret-sections.txt | 1 +
libsecret/secret-value.c | 22 ++++++++++++++++++++++
libsecret/secret-value.h | 2 ++
3 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/libsecret/libsecret-sections.txt b/docs/reference/libsecret/libsecret-sections.txt
index f8a9c1b..34045bc 100644
--- a/docs/reference/libsecret/libsecret-sections.txt
+++ b/docs/reference/libsecret/libsecret-sections.txt
@@ -296,6 +296,7 @@ SecretValue
secret_value_new
secret_value_new_full
secret_value_get
+secret_value_get_text
secret_value_get_content_type
secret_value_ref
secret_value_unref
diff --git a/libsecret/secret-value.c b/libsecret/secret-value.c
index cbfdf6b..64130e0 100644
--- a/libsecret/secret-value.c
+++ b/libsecret/secret-value.c
@@ -44,6 +44,8 @@
* Stability: Unstable
*/
+static gboolean is_password_value (SecretValue *value);
+
/**
* SecretValue:
*
@@ -170,6 +172,26 @@ secret_value_get (SecretValue *value,
}
/**
+ * secret_value_get_text:
+ * @value: the value
+ *
+ * Get the secret data in the #SecretValue if it contains a textual
+ * value. The content type must be <literal>text/plain</literal>.
+ *
+ * Returns: (allow-none): the content type
+ */
+const gchar *
+secret_value_get_text (SecretValue *value)
+{
+ g_return_val_if_fail (value, NULL);
+
+ if (!is_password_value (value))
+ return NULL;
+
+ return value->secret;
+}
+
+/**
* secret_value_get_content_type:
* @value: the value
*
diff --git a/libsecret/secret-value.h b/libsecret/secret-value.h
index 08bd88b..baaff34 100644
--- a/libsecret/secret-value.h
+++ b/libsecret/secret-value.h
@@ -43,6 +43,8 @@ SecretValue * secret_value_new_full (gchar *secret,
const gchar * secret_value_get (SecretValue *value,
gsize *length);
+const gchar * secret_value_get_text (SecretValue *value);
+
const gchar * secret_value_get_content_type (SecretValue *value);
SecretValue * secret_value_ref (SecretValue *value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]