Rename secret_password_remove() to secret_password_clear()

* It's clearer what happens here: we try to remove as many matching
   passwords as possible.
 * Also rename secret_service_remove() to secret_service_clear()
 * Rename secret_password_clear() which used to wipe password memory
   to secret_password_wipe().
This commit is contained in:
Stef Walter 2012-07-14 08:18:56 +02:00
parent 7efb4d5073
commit e0ba10ee09
13 changed files with 162 additions and 166 deletions

View File

@ -128,12 +128,12 @@ secret_password_lookup_sync
secret_password_lookup_nonpageable_sync secret_password_lookup_nonpageable_sync
secret_password_lookupv_sync secret_password_lookupv_sync
secret_password_lookupv_nonpageable_sync secret_password_lookupv_nonpageable_sync
secret_password_remove
secret_password_removev
secret_password_remove_finish
secret_password_remove_sync
secret_password_removev_sync
secret_password_clear secret_password_clear
secret_password_clearv
secret_password_clear_finish
secret_password_clear_sync
secret_password_clearv_sync
secret_password_wipe
secret_password_free secret_password_free
</SECTION> </SECTION>
@ -217,9 +217,9 @@ secret_service_store_sync
secret_service_lookup secret_service_lookup
secret_service_lookup_finish secret_service_lookup_finish
secret_service_lookup_sync secret_service_lookup_sync
secret_service_remove secret_service_clear
secret_service_remove_finish secret_service_clear_finish
secret_service_remove_sync secret_service_clear_sync
secret_service_prompt secret_service_prompt
secret_service_prompt_finish secret_service_prompt_finish
secret_service_prompt_sync secret_service_prompt_sync

View File

@ -361,12 +361,12 @@
<tbody> <tbody>
<row> <row>
<entry>gnome_keyring_delete_password()</entry> <entry>gnome_keyring_delete_password()</entry>
<entry>secret_password_remove(), although we now try to delete <entry>secret_password_clear(), although we now try to delete
all unlocked matching items</entry> all unlocked matching items</entry>
</row> </row>
<row> <row>
<entry>gnome_keyring_delete_password_sync()</entry> <entry>gnome_keyring_delete_password_sync()</entry>
<entry>secret_password_remove_sync(), although we now try to delete <entry>secret_password_clear_sync(), although we now try to delete
all unlocked matching items</entry> all unlocked matching items</entry>
</row> </row>
<row> <row>
@ -403,11 +403,11 @@
</row> </row>
<row> <row>
<entry>gnome_keyring_item_delete()</entry> <entry>gnome_keyring_item_delete()</entry>
<entry>secret_item_delete(), although secret_password_remove() may be simpler</entry> <entry>secret_item_delete(), although secret_password_clear() may be simpler</entry>
</row> </row>
<row> <row>
<entry>gnome_keyring_item_delete_sync()</entry> <entry>gnome_keyring_item_delete_sync()</entry>
<entry>secret_item_delete_sync(), although secret_password_remove_sync() may be simpler</entry> <entry>secret_item_delete_sync(), although secret_password_clear_sync() may be simpler</entry>
</row> </row>
<row> <row>
<entry>gnome_keyring_item_get_info()</entry> <entry>gnome_keyring_item_get_info()</entry>

View File

@ -10,10 +10,10 @@ password_lookup skip=false
password_lookup_sync skip=false throws="GLib.Error" password_lookup_sync skip=false throws="GLib.Error"
.error skip .error skip
password_lookupv finish_name="secret_password_lookup_finish" password_lookupv finish_name="secret_password_lookup_finish"
password_remove skip=false password_clear skip=false
password_remove_sync skip=false throws="GLib.Error" password_clear_sync skip=false throws="GLib.Error"
.error skip .error skip
password_removev finish_name="secret_password_remove_finish" password_clearv finish_name="secret_password_clear_finish"
password_store skip=false password_store skip=false
password_store_sync skip=false throws="GLib.Error" password_store_sync skip=false throws="GLib.Error"
.error skip .error skip

View File

@ -1582,7 +1582,7 @@ on_delete_service (GObject *source,
} }
/** /**
* secret_service_remove: * secret_service_clear:
* @service: (allow-none): the secret service * @service: (allow-none): the secret service
* @schema: (allow-none): the schema for the attributes * @schema: (allow-none): the schema for the attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values * @attributes: (element-type utf8 utf8): the attribute keys and values
@ -1590,24 +1590,22 @@ on_delete_service (GObject *source,
* @callback: called when the operation completes * @callback: called when the operation completes
* @user_data: data to be passed to the callback * @user_data: data to be passed to the callback
* *
* Remove a secret value from the secret service. * Remove unlocked items which match the attributes from the secret service.
* *
* The @attributes should be a set of key and value string pairs. * The @attributes should be a set of key and value string pairs.
* *
* If multiple items match the attributes, then only one will be deleted.
*
* If @service is NULL, then secret_service_get() will be called to get * If @service is NULL, then secret_service_get() will be called to get
* the default #SecretService proxy. * the default #SecretService proxy.
* *
* This method will return immediately and complete asynchronously. * This method will return immediately and complete asynchronously.
*/ */
void void
secret_service_remove (SecretService *service, secret_service_clear (SecretService *service,
const SecretSchema *schema, const SecretSchema *schema,
GHashTable *attributes, GHashTable *attributes,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
const gchar *schema_name = NULL; const gchar *schema_name = NULL;
GSimpleAsyncResult *res; GSimpleAsyncResult *res;
@ -1625,7 +1623,7 @@ secret_service_remove (SecretService *service,
schema_name = schema->name; schema_name = schema->name;
res = g_simple_async_result_new (G_OBJECT (service), callback, user_data, res = g_simple_async_result_new (G_OBJECT (service), callback, user_data,
secret_service_remove); secret_service_clear);
closure = g_slice_new0 (DeleteClosure); closure = g_slice_new0 (DeleteClosure);
closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL; closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
closure->attributes = _secret_attributes_to_variant (attributes, schema_name); closure->attributes = _secret_attributes_to_variant (attributes, schema_name);
@ -1649,20 +1647,20 @@ secret_service_remove (SecretService *service,
} }
/** /**
* secret_service_remove_finish: * secret_service_clear_finish:
* @service: (allow-none): the secret service * @service: (allow-none): the secret service
* @result: the asynchronous result passed to the callback * @result: the asynchronous result passed to the callback
* @error: location to place an error on failure * @error: location to place an error on failure
* *
* Finish asynchronous operation to remove a secret value from the secret * Finish asynchronous operation to remove items from the secret
* service. * service.
* *
* Returns: whether the removal was successful or not * Returns: whether the removal was successful or not
*/ */
gboolean gboolean
secret_service_remove_finish (SecretService *service, secret_service_clear_finish (SecretService *service,
GAsyncResult *result, GAsyncResult *result,
GError **error) GError **error)
{ {
GSimpleAsyncResult *res; GSimpleAsyncResult *res;
DeleteClosure *closure; DeleteClosure *closure;
@ -1670,7 +1668,7 @@ secret_service_remove_finish (SecretService *service,
g_return_val_if_fail (service == NULL || SECRET_IS_SERVICE (service), FALSE); g_return_val_if_fail (service == NULL || SECRET_IS_SERVICE (service), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (service), g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (service),
secret_service_remove), FALSE); secret_service_clear), FALSE);
res = G_SIMPLE_ASYNC_RESULT (result); res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error)) if (g_simple_async_result_propagate_error (res, error))
@ -1681,19 +1679,17 @@ secret_service_remove_finish (SecretService *service,
} }
/** /**
* secret_service_remove_sync: * secret_service_clear_sync:
* @service: (allow-none): the secret service * @service: (allow-none): the secret service
* @schema: (allow-none): the schema for the attributes * @schema: (allow-none): the schema for the attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values * @attributes: (element-type utf8 utf8): the attribute keys and values
* @cancellable: optional cancellation object * @cancellable: optional cancellation object
* @error: location to place an error on failure * @error: location to place an error on failure
* *
* Remove a secret value from the secret service. * Remove unlocked items which match the attributes from the secret service.
* *
* The @attributes should be a set of key and value string pairs. * The @attributes should be a set of key and value string pairs.
* *
* If multiple items match the attributes, then only one will be deleted.
*
* If @service is NULL, then secret_service_get_sync() will be called to get * If @service is NULL, then secret_service_get_sync() will be called to get
* the default #SecretService proxy. * the default #SecretService proxy.
* *
@ -1703,11 +1699,11 @@ secret_service_remove_finish (SecretService *service,
* Returns: whether the removal was successful or not * Returns: whether the removal was successful or not
*/ */
gboolean gboolean
secret_service_remove_sync (SecretService *service, secret_service_clear_sync (SecretService *service,
const SecretSchema *schema, const SecretSchema *schema,
GHashTable *attributes, GHashTable *attributes,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
SecretSync *sync; SecretSync *sync;
gboolean result; gboolean result;
@ -1723,12 +1719,12 @@ secret_service_remove_sync (SecretService *service,
sync = _secret_sync_new (); sync = _secret_sync_new ();
g_main_context_push_thread_default (sync->context); g_main_context_push_thread_default (sync->context);
secret_service_remove (service, schema, attributes, cancellable, secret_service_clear (service, schema, attributes, cancellable,
_secret_sync_on_result, sync); _secret_sync_on_result, sync);
g_main_loop_run (sync->loop); g_main_loop_run (sync->loop);
result = secret_service_remove_finish (service, sync->result, error); result = secret_service_clear_finish (service, sync->result, error);
g_main_context_pop_thread_default (sync->context); g_main_context_pop_thread_default (sync->context);
_secret_sync_free (sync); _secret_sync_free (sync);

View File

@ -633,30 +633,30 @@ secret_password_lookupv_sync (const SecretSchema *schema,
} }
/** /**
* secret_password_remove: * secret_password_clear:
* @schema: the schema for the attributes * @schema: the schema for the attributes
* @cancellable: optional cancellation object * @cancellable: optional cancellation object
* @callback: called when the operation completes * @callback: called when the operation completes
* @user_data: data to be passed to the callback * @user_data: data to be passed to the callback
* @...: the attribute keys and values, terminated with %NULL * @...: the attribute keys and values, terminated with %NULL
* *
* Remove passwords from the secret service. * Clear unlocked matching passwords from the secret service.
* *
* The variable argument list should contain pairs of a) The attribute name as * The variable argument list should contain pairs of a) The attribute name as
* a null-terminated string, followed by b) attribute value, either a character * a null-terminated string, followed by b) attribute value, either a character
* string, an int number, or a gboolean value, as defined in the password * string, an int number, or a gboolean value, as defined in the password
* @schema. The list of attribtues should be terminated with a %NULL. * @schema. The list of attribtues should be terminated with a %NULL.
* *
* If multiple items match the attributes, then only one will be deleted. * All unlocked items that match the attributes will be deleted.
* *
* This method will return immediately and complete asynchronously. * This method will return immediately and complete asynchronously.
*/ */
void void
secret_password_remove (const SecretSchema *schema, secret_password_clear (const SecretSchema *schema,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data, gpointer user_data,
...) ...)
{ {
GHashTable *attributes; GHashTable *attributes;
va_list va; va_list va;
@ -668,22 +668,22 @@ secret_password_remove (const SecretSchema *schema,
attributes = secret_attributes_buildv (schema, va); attributes = secret_attributes_buildv (schema, va);
va_end (va); va_end (va);
secret_password_removev (schema, attributes, cancellable, secret_password_clearv (schema, attributes, cancellable,
callback, user_data); callback, user_data);
g_hash_table_unref (attributes); g_hash_table_unref (attributes);
} }
/** /**
* secret_password_removev: * secret_password_clearv:
* @schema: the schema for the attributes * @schema: the schema for the attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values * @attributes: (element-type utf8 utf8): the attribute keys and values
* @cancellable: optional cancellation object * @cancellable: optional cancellation object
* @callback: called when the operation completes * @callback: called when the operation completes
* @user_data: data to be passed to the callback * @user_data: data to be passed to the callback
* *
* Remove passwords from the secret service. * Remove unlocked matching passwords from the secret service.
* *
* The @attributes should be a set of key and value string pairs. * The @attributes should be a set of key and value string pairs.
* *
@ -691,14 +691,14 @@ secret_password_remove (const SecretSchema *schema,
* *
* This method will return immediately and complete asynchronously. * This method will return immediately and complete asynchronously.
* *
* Rename to: secret_password_remove * Rename to: secret_password_clear
*/ */
void void
secret_password_removev (const SecretSchema *schema, secret_password_clearv (const SecretSchema *schema,
GHashTable *attributes, GHashTable *attributes,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
g_return_if_fail (schema != NULL); g_return_if_fail (schema != NULL);
g_return_if_fail (attributes != NULL); g_return_if_fail (attributes != NULL);
@ -708,12 +708,12 @@ secret_password_removev (const SecretSchema *schema,
if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE)) if (!_secret_attributes_validate (schema, attributes, G_STRFUNC, TRUE))
return; return;
secret_service_remove (NULL, schema, attributes, secret_service_clear (NULL, schema, attributes,
cancellable, callback, user_data); cancellable, callback, user_data);
} }
/** /**
* secret_password_remove_finish: * secret_password_clear_finish:
* @result: the asynchronous result passed to the callback * @result: the asynchronous result passed to the callback
* @error: location to place an error on failure * @error: location to place an error on failure
* *
@ -723,21 +723,21 @@ secret_password_removev (const SecretSchema *schema,
* Returns: whether any passwords were removed * Returns: whether any passwords were removed
*/ */
gboolean gboolean
secret_password_remove_finish (GAsyncResult *result, secret_password_clear_finish (GAsyncResult *result,
GError **error) GError **error)
{ {
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
return secret_service_remove_finish (NULL, result, error); return secret_service_clear_finish (NULL, result, error);
} }
/** /**
* secret_password_remove_sync: * secret_password_clear_sync:
* @schema: the schema for the attributes * @schema: the schema for the attributes
* @cancellable: optional cancellation object * @cancellable: optional cancellation object
* @error: location to place an error on failure * @error: location to place an error on failure
* @...: the attribute keys and values, terminated with %NULL * @...: the attribute keys and values, terminated with %NULL
* *
* Remove passwords from the secret service. * Remove unlocked matching passwords from the secret service.
* *
* The variable argument list should contain pairs of a) The attribute name as * The variable argument list should contain pairs of a) The attribute name as
* a null-terminated string, followed by b) attribute value, either a character * a null-terminated string, followed by b) attribute value, either a character
@ -752,10 +752,10 @@ secret_password_remove_finish (GAsyncResult *result,
* Returns: whether the any passwords were removed * Returns: whether the any passwords were removed
*/ */
gboolean gboolean
secret_password_remove_sync (const SecretSchema* schema, secret_password_clear_sync (const SecretSchema* schema,
GCancellable *cancellable, GCancellable *cancellable,
GError **error, GError **error,
...) ...)
{ {
GHashTable *attributes; GHashTable *attributes;
gboolean result; gboolean result;
@ -769,8 +769,8 @@ secret_password_remove_sync (const SecretSchema* schema,
attributes = secret_attributes_buildv (schema, va); attributes = secret_attributes_buildv (schema, va);
va_end (va); va_end (va);
result = secret_password_removev_sync (schema, attributes, result = secret_password_clearv_sync (schema, attributes,
cancellable, error); cancellable, error);
g_hash_table_unref (attributes); g_hash_table_unref (attributes);
@ -778,13 +778,13 @@ secret_password_remove_sync (const SecretSchema* schema,
} }
/** /**
* secret_password_removev_sync: * secret_password_clearv_sync:
* @schema: the schema for the attributes * @schema: the schema for the attributes
* @attributes: (element-type utf8 utf8): the attribute keys and values * @attributes: (element-type utf8 utf8): the attribute keys and values
* @cancellable: optional cancellation object * @cancellable: optional cancellation object
* @error: location to place an error on failure * @error: location to place an error on failure
* *
* Remove passwords from the secret service. * Remove unlocked matching passwords from the secret service.
* *
* The @attributes should be a set of key and value string pairs. * The @attributes should be a set of key and value string pairs.
* *
@ -795,13 +795,13 @@ secret_password_remove_sync (const SecretSchema* schema,
* *
* Returns: whether any passwords were removed * Returns: whether any passwords were removed
* *
* Rename to: secret_password_remove_sync * Rename to: secret_password_clear_sync
*/ */
gboolean gboolean
secret_password_removev_sync (const SecretSchema *schema, secret_password_clearv_sync (const SecretSchema *schema,
GHashTable *attributes, GHashTable *attributes,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
SecretSync *sync; SecretSync *sync;
gboolean result; gboolean result;
@ -818,12 +818,12 @@ secret_password_removev_sync (const SecretSchema *schema,
sync = _secret_sync_new (); sync = _secret_sync_new ();
g_main_context_push_thread_default (sync->context); g_main_context_push_thread_default (sync->context);
secret_password_removev (schema, attributes, cancellable, secret_password_clearv (schema, attributes, cancellable,
_secret_sync_on_result, sync); _secret_sync_on_result, sync);
g_main_loop_run (sync->loop); g_main_loop_run (sync->loop);
result = secret_password_remove_finish (sync->result, error); result = secret_password_clear_finish (sync->result, error);
g_main_context_pop_thread_default (sync->context); g_main_context_pop_thread_default (sync->context);
_secret_sync_free (sync); _secret_sync_free (sync);
@ -852,13 +852,13 @@ secret_password_free (gchar *password)
} }
/** /**
* secret_password_clear: * secret_password_wipe:
* @password: (allow-none): password to clear * @password: (allow-none): password to clear
* *
* Clear the memory used by a password. * Clear the memory used by a password.
*/ */
void void
secret_password_clear (gchar *password) secret_password_wipe (gchar *password)
{ {
if (password == NULL) if (password == NULL)
return; return;

View File

@ -101,34 +101,34 @@ gchar * secret_password_lookupv_nonpageable_sync (const SecretSchema *sche
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
void secret_password_remove (const SecretSchema *schema, void secret_password_clear (const SecretSchema *schema,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data, gpointer user_data,
...) G_GNUC_NULL_TERMINATED; ...) G_GNUC_NULL_TERMINATED;
void secret_password_removev (const SecretSchema *schema, void secret_password_clearv (const SecretSchema *schema,
GHashTable *attributes, GHashTable *attributes,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
gboolean secret_password_remove_finish (GAsyncResult *result, gboolean secret_password_clear_finish (GAsyncResult *result,
GError **error); GError **error);
gboolean secret_password_remove_sync (const SecretSchema* schema, gboolean secret_password_clear_sync (const SecretSchema* schema,
GCancellable *cancellable, GCancellable *cancellable,
GError **error, GError **error,
...) G_GNUC_NULL_TERMINATED; ...) G_GNUC_NULL_TERMINATED;
gboolean secret_password_removev_sync (const SecretSchema *schema, gboolean secret_password_clearv_sync (const SecretSchema *schema,
GHashTable *attributes, GHashTable *attributes,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
void secret_password_free (gchar *password); void secret_password_free (gchar *password);
void secret_password_clear (gchar *password); void secret_password_wipe (gchar *password);
G_END_DECLS G_END_DECLS

View File

@ -262,18 +262,18 @@ SecretValue * secret_service_lookup_sync (SecretService
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
void secret_service_remove (SecretService *service, void secret_service_clear (SecretService *service,
const SecretSchema *schema, const SecretSchema *schema,
GHashTable *attributes, GHashTable *attributes,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
gboolean secret_service_remove_finish (SecretService *service, gboolean secret_service_clear_finish (SecretService *service,
GAsyncResult *result, GAsyncResult *result,
GError **error); GError **error);
gboolean secret_service_remove_sync (SecretService *service, gboolean secret_service_clear_sync (SecretService *service,
const SecretSchema *schema, const SecretSchema *schema,
GHashTable *attributes, GHashTable *attributes,
GCancellable *cancellable, GCancellable *cancellable,

View File

@ -59,7 +59,7 @@ noinst_PROGRAMS = \
JS_TESTS = \ JS_TESTS = \
test-lookup-password.js \ test-lookup-password.js \
test-remove-password.js \ test-clear-password.js \
test-store-password.js \ test-store-password.js \
test-unstable.js test-unstable.js
@ -69,7 +69,7 @@ JS_ENV = \
PY_TESTS = \ PY_TESTS = \
test-lookup-password.py \ test-lookup-password.py \
test-remove-password.py \ test-clear-password.py \
test-store-password.py \ test-store-password.py \
test-unstable.py test-unstable.py

View File

@ -448,8 +448,8 @@ test_unlock_sync (Test *test,
} }
static void static void
test_remove_sync (Test *test, test_clear_sync (Test *test,
gconstpointer used) gconstpointer used)
{ {
GError *error = NULL; GError *error = NULL;
GHashTable *attributes; GHashTable *attributes;
@ -461,7 +461,7 @@ test_remove_sync (Test *test,
"number", 1, "number", 1,
NULL); NULL);
ret = secret_service_remove_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error); ret = secret_service_clear_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (ret == TRUE); g_assert (ret == TRUE);
@ -470,8 +470,8 @@ test_remove_sync (Test *test,
} }
static void static void
test_remove_async (Test *test, test_clear_async (Test *test,
gconstpointer used) gconstpointer used)
{ {
GError *error = NULL; GError *error = NULL;
GAsyncResult *result = NULL; GAsyncResult *result = NULL;
@ -484,15 +484,15 @@ test_remove_async (Test *test,
"number", 1, "number", 1,
NULL); NULL);
secret_service_remove (test->service, &MOCK_SCHEMA, attributes, NULL, secret_service_clear (test->service, &MOCK_SCHEMA, attributes, NULL,
on_complete_get_result, &result); on_complete_get_result, &result);
g_hash_table_unref (attributes); g_hash_table_unref (attributes);
g_assert (result == NULL); g_assert (result == NULL);
egg_test_wait (); egg_test_wait ();
ret = secret_service_remove_finish (test->service, result, &error); ret = secret_service_clear_finish (test->service, result, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (ret == TRUE); g_assert (ret == TRUE);
@ -500,8 +500,8 @@ test_remove_async (Test *test,
} }
static void static void
test_remove_locked (Test *test, test_clear_locked (Test *test,
gconstpointer used) gconstpointer used)
{ {
GError *error = NULL; GError *error = NULL;
GHashTable *attributes; GHashTable *attributes;
@ -514,7 +514,7 @@ test_remove_locked (Test *test,
NULL); NULL);
/* Locked items can't be removed via this API */ /* Locked items can't be removed via this API */
ret = secret_service_remove_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error); ret = secret_service_clear_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
g_hash_table_unref (attributes); g_hash_table_unref (attributes);
g_assert_no_error (error); g_assert_no_error (error);
@ -522,8 +522,8 @@ test_remove_locked (Test *test,
} }
static void static void
test_remove_no_match (Test *test, test_clear_no_match (Test *test,
gconstpointer used) gconstpointer used)
{ {
GError *error = NULL; GError *error = NULL;
GHashTable *attributes; GHashTable *attributes;
@ -535,7 +535,7 @@ test_remove_no_match (Test *test,
NULL); NULL);
/* Won't match anything */ /* Won't match anything */
ret = secret_service_remove_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error); ret = secret_service_clear_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
g_hash_table_unref (attributes); g_hash_table_unref (attributes);
g_assert_no_error (error); g_assert_no_error (error);
@ -543,8 +543,8 @@ test_remove_no_match (Test *test,
} }
static void static void
test_remove_no_name (Test *test, test_clear_no_name (Test *test,
gconstpointer used) gconstpointer used)
{ {
const gchar *paths[] = { "/org/freedesktop/secrets/collection/german", NULL }; const gchar *paths[] = { "/org/freedesktop/secrets/collection/german", NULL };
GError *error = NULL; GError *error = NULL;
@ -556,7 +556,7 @@ test_remove_no_name (Test *test,
NULL); NULL);
/* Shouldn't match anything, because no item with 5 in mock schema */ /* Shouldn't match anything, because no item with 5 in mock schema */
ret = secret_service_remove_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error); ret = secret_service_clear_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (ret == FALSE); g_assert (ret == FALSE);
@ -565,7 +565,7 @@ test_remove_no_name (Test *test,
g_assert_no_error (error); g_assert_no_error (error);
/* We have an item with 5 in prime schema, but should match anyway becase of flags */ /* We have an item with 5 in prime schema, but should match anyway becase of flags */
ret = secret_service_remove_sync (test->service, &NO_NAME_SCHEMA, attributes, NULL, &error); ret = secret_service_clear_sync (test->service, &NO_NAME_SCHEMA, attributes, NULL, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (ret == TRUE); g_assert (ret == TRUE);
@ -929,11 +929,11 @@ main (int argc, char **argv)
g_test_add ("/service/lookup-no-match", Test, "mock-service-normal.py", setup, test_lookup_no_match, teardown); g_test_add ("/service/lookup-no-match", Test, "mock-service-normal.py", setup, test_lookup_no_match, teardown);
g_test_add ("/service/lookup-no-name", Test, "mock-service-normal.py", setup, test_lookup_no_name, teardown); g_test_add ("/service/lookup-no-name", Test, "mock-service-normal.py", setup, test_lookup_no_name, teardown);
g_test_add ("/service/remove-sync", Test, "mock-service-delete.py", setup, test_remove_sync, teardown); g_test_add ("/service/clear-sync", Test, "mock-service-delete.py", setup, test_clear_sync, teardown);
g_test_add ("/service/remove-async", Test, "mock-service-delete.py", setup, test_remove_async, teardown); g_test_add ("/service/clear-async", Test, "mock-service-delete.py", setup, test_clear_async, teardown);
g_test_add ("/service/remove-locked", Test, "mock-service-delete.py", setup, test_remove_locked, teardown); g_test_add ("/service/clear-locked", Test, "mock-service-delete.py", setup, test_clear_locked, teardown);
g_test_add ("/service/remove-no-match", Test, "mock-service-delete.py", setup, test_remove_no_match, teardown); g_test_add ("/service/clear-no-match", Test, "mock-service-delete.py", setup, test_clear_no_match, teardown);
g_test_add ("/service/remove-no-name", Test, "mock-service-delete.py", setup, test_remove_no_name, teardown); g_test_add ("/service/clear-no-name", Test, "mock-service-delete.py", setup, test_clear_no_name, teardown);
g_test_add ("/service/store-sync", Test, "mock-service-normal.py", setup, test_store_sync, teardown); g_test_add ("/service/store-sync", Test, "mock-service-normal.py", setup, test_store_sync, teardown);
g_test_add ("/service/store-async", Test, "mock-service-normal.py", setup, test_store_async, teardown); g_test_add ("/service/store-async", Test, "mock-service-normal.py", setup, test_store_async, teardown);

View File

@ -230,11 +230,11 @@ test_delete_sync (Test *test,
GError *error = NULL; GError *error = NULL;
gboolean ret; gboolean ret;
ret = secret_password_remove_sync (&MOCK_SCHEMA, NULL, &error, ret = secret_password_clear_sync (&MOCK_SCHEMA, NULL, &error,
"even", FALSE, "even", FALSE,
"string", "one", "string", "one",
"number", 1, "number", 1,
NULL); NULL);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (ret == TRUE); g_assert (ret == TRUE);
@ -248,18 +248,18 @@ test_delete_async (Test *test,
GAsyncResult *result = NULL; GAsyncResult *result = NULL;
gboolean ret; gboolean ret;
secret_password_remove (&MOCK_SCHEMA, NULL, secret_password_clear (&MOCK_SCHEMA, NULL,
on_complete_get_result, &result, on_complete_get_result, &result,
"even", FALSE, "even", FALSE,
"string", "one", "string", "one",
"number", 1, "number", 1,
NULL); NULL);
g_assert (result == NULL); g_assert (result == NULL);
egg_test_wait (); egg_test_wait ();
ret = secret_password_remove_finish (result, &error); ret = secret_password_clear_finish (result, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (ret == TRUE); g_assert (ret == TRUE);
@ -267,8 +267,8 @@ test_delete_async (Test *test,
} }
static void static void
test_remove_no_name (Test *test, test_clear_no_name (Test *test,
gconstpointer used) gconstpointer used)
{ {
const gchar *paths[] = { "/org/freedesktop/secrets/collection/german", NULL }; const gchar *paths[] = { "/org/freedesktop/secrets/collection/german", NULL };
SecretService *service; SecretService *service;
@ -276,9 +276,9 @@ test_remove_no_name (Test *test,
gboolean ret; gboolean ret;
/* Shouldn't match anything, because no item with 5 in mock schema */ /* Shouldn't match anything, because no item with 5 in mock schema */
ret = secret_password_remove_sync (&MOCK_SCHEMA, NULL, &error, ret = secret_password_clear_sync (&MOCK_SCHEMA, NULL, &error,
"number", 5, "number", 5,
NULL); NULL);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (ret == FALSE); g_assert (ret == FALSE);
@ -290,7 +290,7 @@ test_remove_no_name (Test *test,
g_object_unref (service); g_object_unref (service);
/* We have an item with 5 in prime schema, but should match anyway becase of flags */ /* We have an item with 5 in prime schema, but should match anyway becase of flags */
ret = secret_password_remove_sync (&NO_NAME_SCHEMA, NULL, &error, ret = secret_password_clear_sync (&NO_NAME_SCHEMA, NULL, &error,
"number", 5, "number", 5,
NULL); NULL);
@ -320,7 +320,7 @@ main (int argc, char **argv)
g_test_add ("/password/delete-sync", Test, "mock-service-delete.py", setup, test_delete_sync, teardown); g_test_add ("/password/delete-sync", Test, "mock-service-delete.py", setup, test_delete_sync, teardown);
g_test_add ("/password/delete-async", Test, "mock-service-delete.py", setup, test_delete_async, teardown); g_test_add ("/password/delete-async", Test, "mock-service-delete.py", setup, test_delete_async, teardown);
g_test_add ("/password/remove-no-name", Test, "mock-service-delete.py", setup, test_remove_no_name, teardown); g_test_add ("/password/clear-no-name", Test, "mock-service-delete.py", setup, test_clear_no_name, teardown);
g_test_add_func ("/password/free-null", test_password_free_null); g_test_add_func ("/password/free-null", test_password_free_null);

View File

@ -26,13 +26,13 @@ var attributes = { "number": "1", "string": "one", "even": "false" };
var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null); var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
assertEquals("111", password); assertEquals("111", password);
var deleted = Secret.password_remove_sync (STORE_SCHEMA, attributes, null); var deleted = Secret.password_clear_sync (STORE_SCHEMA, attributes, null);
assertEquals(true, deleted); assertEquals(true, deleted);
var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null); var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
assertEquals(null, password); assertEquals(null, password);
var deleted = Secret.password_remove_sync (STORE_SCHEMA, attributes, null); var deleted = Secret.password_clear_sync (STORE_SCHEMA, attributes, null);
assertEquals(false, deleted); assertEquals(false, deleted);
/* Asynchronous */ /* Asynchronous */
@ -44,10 +44,10 @@ assertEquals("222", password);
var loop = new GLib.MainLoop.new(null, false); var loop = new GLib.MainLoop.new(null, false);
Secret.password_remove (STORE_SCHEMA, attributes, Secret.password_clear (STORE_SCHEMA, attributes,
null, function(source, result) { null, function(source, result) {
loop.quit(); loop.quit();
var deleted = Secret.password_remove_finish(result); var deleted = Secret.password_clear_finish(result);
assertEquals(true, deleted); assertEquals(true, deleted);
}); });
@ -56,10 +56,10 @@ loop.run();
var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null); var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
assertEquals(null, password); assertEquals(null, password);
Secret.password_remove (STORE_SCHEMA, attributes, Secret.password_clear (STORE_SCHEMA, attributes,
null, function(source, result) { null, function(source, result) {
loop.quit(); loop.quit();
var deleted = Secret.password_remove_finish(result); var deleted = Secret.password_clear_finish(result);
assertEquals(false, deleted); assertEquals(false, deleted);
}); });

View File

@ -87,7 +87,7 @@ private void test_store_async () {
loop.run (); loop.run ();
} }
private void test_remove_sync () { private void test_clear_sync () {
try { try {
var attributes = new GLib.HashTable<string,string> (GLib.str_hash, GLib.str_equal); var attributes = new GLib.HashTable<string,string> (GLib.str_hash, GLib.str_equal);
attributes["even"] = "false"; attributes["even"] = "false";
@ -97,7 +97,7 @@ private void test_remove_sync () {
string? password = Secret.password_lookupv_sync (schema, attributes); string? password = Secret.password_lookupv_sync (schema, attributes);
GLib.assert (password == "999"); GLib.assert (password == "999");
bool removed = Secret.password_removev_sync (schema, attributes, null); bool removed = Secret.password_clearv_sync (schema, attributes, null);
GLib.assert (removed); GLib.assert (removed);
password = Secret.password_lookupv_sync (schema, attributes); password = Secret.password_lookupv_sync (schema, attributes);
@ -107,7 +107,7 @@ private void test_remove_sync () {
} }
} }
private async void test_remove_async_ex () { private async void test_clear_async_ex () {
var attributes = new GLib.HashTable<string,string> (GLib.str_hash, GLib.str_equal); var attributes = new GLib.HashTable<string,string> (GLib.str_hash, GLib.str_equal);
attributes["even"] = "true"; attributes["even"] = "true";
attributes["string"] = "eight"; attributes["string"] = "eight";
@ -117,7 +117,7 @@ private async void test_remove_async_ex () {
string? password = yield Secret.password_lookupv (schema, attributes, null); string? password = yield Secret.password_lookupv (schema, attributes, null);
GLib.assert (password == "999"); GLib.assert (password == "999");
bool removed = yield Secret.password_removev (schema, attributes, null); bool removed = yield Secret.password_clearv (schema, attributes, null);
GLib.assert (removed); GLib.assert (removed);
password = yield Secret.password_lookupv (schema, attributes, null); password = yield Secret.password_lookupv (schema, attributes, null);
@ -127,9 +127,9 @@ private async void test_remove_async_ex () {
} }
} }
private void test_remove_async () { private void test_clear_async () {
var loop = new GLib.MainLoop (); var loop = new GLib.MainLoop ();
test_remove_async_ex.begin ((obj, async_res) => { test_clear_async_ex.begin ((obj, async_res) => {
loop.quit (); loop.quit ();
}); });
loop.run (); loop.run ();
@ -160,8 +160,8 @@ private static int main (string[] args) {
GLib.Test.add_data_func ("/vala/lookup/no-name", test_lookup_no_name); GLib.Test.add_data_func ("/vala/lookup/no-name", test_lookup_no_name);
GLib.Test.add_data_func ("/vala/store/sync", test_store_sync); GLib.Test.add_data_func ("/vala/store/sync", test_store_sync);
GLib.Test.add_data_func ("/vala/store/async", test_store_async); GLib.Test.add_data_func ("/vala/store/async", test_store_async);
GLib.Test.add_data_func ("/vala/remove/sync", test_remove_sync); GLib.Test.add_data_func ("/vala/clear/sync", test_clear_sync);
GLib.Test.add_data_func ("/vala/remove/async", test_remove_async); GLib.Test.add_data_func ("/vala/clear/async", test_clear_async);
var res = GLib.Test.run (); var res = GLib.Test.run ();

View File

@ -48,10 +48,10 @@ static const GOptionEntry LOOKUP_OPTIONS[] = {
{ NULL } { NULL }
}; };
/* secret-tool remove name:xxxx yyyy:zzzz */ /* secret-tool clear name:xxxx yyyy:zzzz */
static const GOptionEntry REMOVE_OPTIONS[] = { static const GOptionEntry CLEAR_OPTIONS[] = {
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &attribute_args, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &attribute_args,
N_("attribute value pairs which match item to remove"), NULL }, N_("attribute value pairs which match items to clear"), NULL },
{ NULL } { NULL }
}; };
@ -64,7 +64,7 @@ usage (void)
{ {
g_printerr ("usage: secret-tool store --label='label' attribute value ...\n"); g_printerr ("usage: secret-tool store --label='label' attribute value ...\n");
g_printerr (" secret-tool lookup attribute value ...\n"); g_printerr (" secret-tool lookup attribute value ...\n");
g_printerr (" secret-tool remove attribute value ...\n"); g_printerr (" secret-tool clear attribute value ...\n");
exit (2); exit (2);
} }
@ -113,8 +113,8 @@ attributes_from_arguments (gchar **args)
} }
static int static int
secret_tool_action_remove (int argc, secret_tool_action_clear (int argc,
char *argv[]) char *argv[])
{ {
GError *error = NULL; GError *error = NULL;
GOptionContext *context; GOptionContext *context;
@ -122,7 +122,7 @@ secret_tool_action_remove (int argc,
GHashTable *attributes; GHashTable *attributes;
context = g_option_context_new ("attribute value ..."); context = g_option_context_new ("attribute value ...");
g_option_context_add_main_entries (context, REMOVE_OPTIONS, GETTEXT_PACKAGE); g_option_context_add_main_entries (context, CLEAR_OPTIONS, GETTEXT_PACKAGE);
if (!g_option_context_parse (context, &argc, &argv, &error)) { if (!g_option_context_parse (context, &argc, &argv, &error)) {
g_printerr ("%s\n", error->message); g_printerr ("%s\n", error->message);
usage(); usage();
@ -135,7 +135,7 @@ secret_tool_action_remove (int argc,
service = secret_service_get_sync (SECRET_SERVICE_NONE, NULL, &error); service = secret_service_get_sync (SECRET_SERVICE_NONE, NULL, &error);
if (error == NULL) if (error == NULL)
secret_service_remove_sync (service, NULL, attributes, NULL, &error); secret_service_clear_sync (service, NULL, attributes, NULL, &error);
g_object_unref (service); g_object_unref (service);
g_hash_table_unref (attributes); g_hash_table_unref (attributes);
@ -345,8 +345,8 @@ main (int argc,
action = secret_tool_action_store; action = secret_tool_action_store;
} else if (g_str_equal (argv[1], "lookup")) { } else if (g_str_equal (argv[1], "lookup")) {
action = secret_tool_action_lookup; action = secret_tool_action_lookup;
} else if (g_str_equal (argv[1], "remove")) { } else if (g_str_equal (argv[1], "clear")) {
action = secret_tool_action_remove; action = secret_tool_action_clear;
} else { } else {
usage (); usage ();
} }