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: * @@ -169,6 +171,26 @@ secret_value_get (SecretValue *value, return value->secret; } +/** + * 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 text/plain. + * + * 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);