secret-password: Mark @schema argument nullable for *v functions

Given these functions take a hash table built from valid attributes,
there is no need to re-validate.  This is also consistent with the
secret_service API.
This commit is contained in:
Daiki Ueno 2019-07-08 10:53:41 +02:00 committed by Daiki Ueno
parent a5db34dcd5
commit e3963efdee

View File

@ -104,7 +104,7 @@ secret_password_store (const SecretSchema *schema,
/**
* secret_password_storev: (rename-to secret_password_store)
* @schema: the schema for attributes
* @schema: (nullable): the schema for attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @collection: (allow-none): a collection alias, or D-Bus object path of the collection where to store the secret
* @label: label for the secret
@ -138,14 +138,13 @@ secret_password_storev (const SecretSchema *schema,
{
SecretValue *value;
g_return_if_fail (schema != NULL);
g_return_if_fail (label != NULL);
g_return_if_fail (password != NULL);
g_return_if_fail (attributes != NULL);
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, FALSE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, FALSE))
return;
value = secret_value_new (password, -1, "text/plain");
@ -210,7 +209,7 @@ secret_password_store_binary (const SecretSchema *schema,
/**
* secret_password_storev_binary: (rename-to secret_password_store_binary)
* @schema: the schema for attributes
* @schema: (nullable): the schema for attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @collection: (allow-none): a collection alias, or D-Bus object path of the collection where to store the secret
* @label: label for the secret
@ -238,14 +237,13 @@ secret_password_storev_binary (const SecretSchema *schema,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (schema != NULL);
g_return_if_fail (label != NULL);
g_return_if_fail (value != NULL);
g_return_if_fail (attributes != NULL);
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, FALSE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, FALSE))
return;
secret_service_store (NULL, schema, attributes, collection,
@ -334,7 +332,7 @@ secret_password_store_sync (const SecretSchema *schema,
/**
* secret_password_storev_sync: (rename-to secret_password_store_sync)
* @schema: the schema for attributes
* @schema: (nullable): the schema for attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @collection: (allow-none): a collection alias, or D-Bus object path of the collection where to store the secret
* @label: label for the secret
@ -370,7 +368,6 @@ secret_password_storev_sync (const SecretSchema *schema,
SecretSync *sync;
gboolean ret;
g_return_val_if_fail (schema != NULL, FALSE);
g_return_val_if_fail (label != NULL, FALSE);
g_return_val_if_fail (password != NULL, FALSE);
g_return_val_if_fail (attributes != NULL, FALSE);
@ -378,7 +375,7 @@ secret_password_storev_sync (const SecretSchema *schema,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, FALSE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, FALSE))
return FALSE;
sync = _secret_sync_new ();
@ -455,7 +452,7 @@ secret_password_store_binary_sync (const SecretSchema *schema,
/**
* secret_password_storev_binary_sync: (rename-to secret_password_store_binary_sync)
* @schema: the schema for attributes
* @schema: (nullable): the schema for attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @collection: (allow-none): a collection alias, or D-Bus object path of the collection where to store the secret
* @label: label for the secret
@ -487,7 +484,6 @@ secret_password_storev_binary_sync (const SecretSchema *schema,
SecretSync *sync;
gboolean ret;
g_return_val_if_fail (schema != NULL, FALSE);
g_return_val_if_fail (label != NULL, FALSE);
g_return_val_if_fail (value != NULL, FALSE);
g_return_val_if_fail (attributes != NULL, FALSE);
@ -495,7 +491,7 @@ secret_password_storev_binary_sync (const SecretSchema *schema,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, FALSE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, FALSE))
return FALSE;
sync = _secret_sync_new ();
@ -562,7 +558,7 @@ secret_password_lookup (const SecretSchema *schema,
/**
* secret_password_lookupv: (rename-to secret_password_lookup)
* @schema: the schema for attributes
* @schema: (nullable): the schema for attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @cancellable: optional cancellation object
* @callback: called when the operation completes
@ -583,12 +579,11 @@ secret_password_lookupv (const SecretSchema *schema,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (schema != NULL);
g_return_if_fail (attributes != NULL);
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return;
secret_service_lookup (NULL, schema, attributes,
@ -772,7 +767,7 @@ secret_password_lookup_nonpageable_sync (const SecretSchema *schema,
/**
* secret_password_lookupv_nonpageable_sync: (skip)
* @schema: the schema for attributes
* @schema: (nullable): the schema for attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @cancellable: optional cancellation object
* @error: location to place an error on failure
@ -798,13 +793,12 @@ secret_password_lookupv_nonpageable_sync (const SecretSchema *schema,
SecretSync *sync;
gchar *password;
g_return_val_if_fail (schema != NULL, NULL);
g_return_val_if_fail (attributes != NULL, NULL);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return FALSE;
sync = _secret_sync_new ();
@ -875,7 +869,7 @@ secret_password_lookup_binary_sync (const SecretSchema *schema,
/**
* secret_password_lookupv_binary_sync: (skip)
* @schema: the schema for attributes
* @schema: (nullable): the schema for attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @cancellable: optional cancellation object
* @error: location to place an error on failure
@ -902,13 +896,12 @@ secret_password_lookupv_binary_sync (const SecretSchema *schema,
SecretSync *sync;
SecretValue *value;
g_return_val_if_fail (schema != NULL, NULL);
g_return_val_if_fail (attributes != NULL, NULL);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return FALSE;
sync = _secret_sync_new ();
@ -929,7 +922,7 @@ secret_password_lookupv_binary_sync (const SecretSchema *schema,
/**
* secret_password_lookupv_sync: (rename-to secret_password_lookup_sync)
* @schema: the schema for attributes
* @schema: (nullable): the schema for attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @cancellable: optional cancellation object
* @error: location to place an error on failure
@ -955,13 +948,12 @@ secret_password_lookupv_sync (const SecretSchema *schema,
SecretSync *sync;
gchar *string;
g_return_val_if_fail (schema != NULL, NULL);
g_return_val_if_fail (attributes != NULL, NULL);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return FALSE;
sync = _secret_sync_new ();
@ -1029,7 +1021,7 @@ secret_password_clear (const SecretSchema *schema,
/**
* secret_password_clearv: (rename-to secret_password_clear)
* @schema: the schema for the attributes
* @schema: (nullable): the schema for the attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @cancellable: optional cancellation object
* @callback: called when the operation completes
@ -1050,12 +1042,11 @@ secret_password_clearv (const SecretSchema *schema,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (schema != NULL);
g_return_if_fail (attributes != NULL);
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return;
secret_service_clear (NULL, schema, attributes,
@ -1133,7 +1124,7 @@ secret_password_clear_sync (const SecretSchema* schema,
/**
* secret_password_clearv_sync: (rename-to secret_password_clear_sync)
* @schema: the schema for the attributes
* @schema: (nullable): the schema for the attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @cancellable: optional cancellation object
* @error: location to place an error on failure
@ -1158,13 +1149,12 @@ secret_password_clearv_sync (const SecretSchema *schema,
SecretSync *sync;
gboolean result;
g_return_val_if_fail (schema != NULL, FALSE);
g_return_val_if_fail (attributes != NULL, FALSE);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return FALSE;
sync = _secret_sync_new ();
@ -1233,7 +1223,7 @@ secret_password_search (const SecretSchema *schema,
/**
* secret_password_searchv: (rename-to secret_password_search)
* @schema: the schema for attributes
* @schema: (nullable): the schema for attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @flags: search option flags
* @cancellable: optional cancellation object
@ -1256,12 +1246,11 @@ secret_password_searchv (const SecretSchema *schema,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (schema != NULL);
g_return_if_fail (attributes != NULL);
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return;
secret_service_search (NULL, schema, attributes, flags,
@ -1347,7 +1336,7 @@ secret_password_search_sync (const SecretSchema *schema,
/**
* secret_password_searchv_sync: (rename-to secret_password_search_sync)
* @schema: the schema for attributes
* @schema: (nullable): the schema for attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values
* @flags: search option flags
* @cancellable: optional cancellation object
@ -1377,13 +1366,12 @@ secret_password_searchv_sync (const SecretSchema *schema,
SecretSync *sync;
GList *items;
g_return_val_if_fail (schema != NULL, NULL);
g_return_val_if_fail (attributes != NULL, NULL);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
/* Warnings raised already */
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
if (schema != NULL && !_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return NULL;
sync = _secret_sync_new ();