Add secret_value_get_text() function to return NULL terminated secret

This commit is contained in:
Stef Walter 2013-06-20 12:11:27 +02:00
parent 227a5b2904
commit cec740fea9
3 changed files with 25 additions and 0 deletions

View File

@ -296,6 +296,7 @@ SecretValue
secret_value_new secret_value_new
secret_value_new_full secret_value_new_full
secret_value_get secret_value_get
secret_value_get_text
secret_value_get_content_type secret_value_get_content_type
secret_value_ref secret_value_ref
secret_value_unref secret_value_unref

View File

@ -44,6 +44,8 @@
* Stability: Unstable * Stability: Unstable
*/ */
static gboolean is_password_value (SecretValue *value);
/** /**
* SecretValue: * SecretValue:
* *
@ -169,6 +171,26 @@ secret_value_get (SecretValue *value,
return value->secret; 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 <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: * secret_value_get_content_type:
* @value: the value * @value: the value

View File

@ -43,6 +43,8 @@ SecretValue * secret_value_new_full (gchar *secret,
const gchar * secret_value_get (SecretValue *value, const gchar * secret_value_get (SecretValue *value,
gsize *length); gsize *length);
const gchar * secret_value_get_text (SecretValue *value);
const gchar * secret_value_get_content_type (SecretValue *value); const gchar * secret_value_get_content_type (SecretValue *value);
SecretValue * secret_value_ref (SecretValue *value); SecretValue * secret_value_ref (SecretValue *value);