Add secret_value_get_text() function to return NULL terminated secret
authorStef Walter <stefw@gnome.org>
Thu, 20 Jun 2013 10:11:27 +0000 (12:11 +0200)
committerStef Walter <stefw@gnome.org>
Fri, 21 Jun 2013 13:11:14 +0000 (15:11 +0200)
docs/reference/libsecret/libsecret-sections.txt
libsecret/secret-value.c
libsecret/secret-value.h

index f8a9c1b..34045bc 100644 (file)
@@ -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
index cbfdf6b..64130e0 100644 (file)
@@ -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
  *
index 08bd88b..baaff34 100644 (file)
@@ -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);