2012-02-01 12:34:08 +00:00
|
|
|
/* libsecret - GLib wrapper for Secret Service
|
2012-01-11 06:44:32 +00:00
|
|
|
*
|
|
|
|
* Copyright 2011 Collabora Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published
|
2012-03-31 13:32:43 +00:00
|
|
|
* by the Free Software Foundation; either version 2.1 of the licence or (at
|
2012-01-11 06:44:32 +00:00
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* See the included COPYING file for more information.
|
2012-03-31 13:32:43 +00:00
|
|
|
*
|
|
|
|
* Author: Stef Walter <stefw@gnome.org>
|
2012-01-11 06:44:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-06-28 11:15:06 +00:00
|
|
|
#include "secret-attributes.h"
|
2012-02-01 12:34:08 +00:00
|
|
|
#include "secret-password.h"
|
|
|
|
#include "secret-private.h"
|
|
|
|
#include "secret-value.h"
|
2012-01-11 06:44:32 +00:00
|
|
|
|
|
|
|
#include <egg/egg-secure-memory.h>
|
|
|
|
|
2012-02-02 13:59:59 +00:00
|
|
|
/**
|
|
|
|
* SECTION:secret-password
|
|
|
|
* @title: Password storage
|
|
|
|
* @short_description: Simple password storage and lookup
|
|
|
|
*
|
|
|
|
* This is a simple API for storing passwords and retrieving passwords in the
|
|
|
|
* Secret Service.
|
|
|
|
*
|
|
|
|
* Each password is associated with a set of attributes. Attribute values can
|
|
|
|
* be either strings, integers or booleans.
|
|
|
|
*
|
|
|
|
* The names and types of allowed attributes for a given password are defined
|
|
|
|
* with a schema. Certain schemas are predefined. Additional schemas can be
|
|
|
|
* defined via the %SecretSchema structure.
|
|
|
|
*
|
|
|
|
* Each of the functions accept a variable list of attributes names and their
|
|
|
|
* values. Include a %NULL to terminate the list of attributes.
|
2012-03-24 06:52:12 +00:00
|
|
|
*
|
2012-04-27 14:57:36 +00:00
|
|
|
* Stability: Stable
|
2012-02-02 13:59:59 +00:00
|
|
|
*/
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
2012-06-28 08:36:38 +00:00
|
|
|
* secret_password_store: (skip)
|
2012-02-02 12:40:47 +00:00
|
|
|
* @schema: the schema for attributes
|
2012-07-06 07:42:08 +00:00
|
|
|
* @collection: (allow-none): a collection alias, or D-Bus object path of the collection where to store the secret
|
2012-02-02 12:40:47 +00:00
|
|
|
* @label: label for the secret
|
|
|
|
* @password: the null-terminated password to store
|
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @callback: called when the operation completes
|
|
|
|
* @user_data: data to be passed to the callback
|
|
|
|
* @...: the attribute keys and values, terminated with %NULL
|
|
|
|
*
|
|
|
|
* Store a password in the secret service.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* string, an int number, or a gboolean value, as defined in the @schema.
|
|
|
|
* The list of attribtues should be terminated with a %NULL.
|
|
|
|
*
|
|
|
|
* If the attributes match a secret item already stored in the collection, then
|
|
|
|
* the item will be updated with these new values.
|
|
|
|
*
|
2012-07-06 07:42:08 +00:00
|
|
|
* If @collection is %NULL, then the default collection will be
|
2012-03-11 12:35:43 +00:00
|
|
|
* used. Use #SECRET_COLLECTION_SESSION to store the password in the session
|
|
|
|
* collection, which doesn't get stored across login sessions.
|
|
|
|
*
|
2012-02-02 12:40:47 +00:00
|
|
|
* This method will return immediately and complete asynchronously.
|
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
void
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_store (const SecretSchema *schema,
|
2012-07-06 07:42:08 +00:00
|
|
|
const gchar *collection,
|
2012-02-02 12:40:47 +00:00
|
|
|
const gchar *label,
|
|
|
|
const gchar *password,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data,
|
|
|
|
...)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
2012-01-16 14:08:29 +00:00
|
|
|
GHashTable *attributes;
|
2012-01-11 06:44:32 +00:00
|
|
|
va_list va;
|
|
|
|
|
|
|
|
g_return_if_fail (schema != NULL);
|
|
|
|
g_return_if_fail (label != NULL);
|
|
|
|
g_return_if_fail (password != NULL);
|
|
|
|
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
|
|
|
|
|
|
|
va_start (va, user_data);
|
2012-06-28 11:15:06 +00:00
|
|
|
attributes = secret_attributes_buildv (schema, va);
|
2012-01-11 06:44:32 +00:00
|
|
|
va_end (va);
|
|
|
|
|
2012-07-06 07:42:08 +00:00
|
|
|
secret_password_storev (schema, attributes, collection, label, password,
|
2012-02-02 12:40:47 +00:00
|
|
|
cancellable, callback, user_data);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
|
|
|
g_hash_table_unref (attributes);
|
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* secret_password_storev:
|
|
|
|
* @schema: the schema for attributes
|
2012-03-11 08:06:40 +00:00
|
|
|
* @attributes: (element-type utf8 utf8): the attribute keys and values
|
2012-07-06 07:42:08 +00:00
|
|
|
* @collection: (allow-none): a collection alias, or D-Bus object path of the collection where to store the secret
|
2012-02-02 12:40:47 +00:00
|
|
|
* @label: label for the secret
|
|
|
|
* @password: the null-terminated password to store
|
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @callback: called when the operation completes
|
|
|
|
* @user_data: data to be passed to the callback
|
|
|
|
*
|
|
|
|
* Store a password in the secret service.
|
|
|
|
*
|
|
|
|
* The @attributes should be a set of key and value string pairs.
|
|
|
|
*
|
|
|
|
* If the attributes match a secret item already stored in the collection, then
|
|
|
|
* the item will be updated with these new values.
|
|
|
|
*
|
2012-07-06 07:42:08 +00:00
|
|
|
* If @collection is %NULL, then the default collection will be
|
2012-03-11 12:35:43 +00:00
|
|
|
* used. Use #SECRET_COLLECTION_SESSION to store the password in the session
|
|
|
|
* collection, which doesn't get stored across login sessions.
|
|
|
|
*
|
2012-02-02 12:40:47 +00:00
|
|
|
* This method will return immediately and complete asynchronously.
|
2012-03-11 08:06:40 +00:00
|
|
|
*
|
|
|
|
* Rename to: secret_password_store
|
2012-02-02 12:40:47 +00:00
|
|
|
*/
|
2012-01-16 14:08:29 +00:00
|
|
|
void
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_storev (const SecretSchema *schema,
|
2012-02-02 12:40:47 +00:00
|
|
|
GHashTable *attributes,
|
2012-07-06 07:42:08 +00:00
|
|
|
const gchar *collection,
|
2012-02-02 12:40:47 +00:00
|
|
|
const gchar *label,
|
|
|
|
const gchar *password,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data)
|
2012-01-16 14:08:29 +00:00
|
|
|
{
|
2012-07-05 21:14:50 +00:00
|
|
|
SecretValue *value;
|
2012-01-16 14:08:29 +00:00
|
|
|
|
|
|
|
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));
|
2012-01-11 06:44:32 +00:00
|
|
|
|
2012-03-11 08:06:40 +00:00
|
|
|
/* Warnings raised already */
|
2012-06-28 11:15:06 +00:00
|
|
|
if (!_secret_attributes_validate (schema, attributes))
|
2012-03-11 08:06:40 +00:00
|
|
|
return;
|
|
|
|
|
2012-07-05 21:14:50 +00:00
|
|
|
value = secret_value_new (password, -1, "text/plain");
|
|
|
|
|
2012-07-06 07:42:08 +00:00
|
|
|
secret_service_store (NULL, schema, attributes, collection,
|
2012-07-05 21:14:50 +00:00
|
|
|
label, value, cancellable, callback, user_data);
|
|
|
|
|
|
|
|
secret_value_unref (value);
|
2012-01-11 06:44:32 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
2012-04-27 14:57:36 +00:00
|
|
|
* secret_password_store_finish:
|
2012-02-02 12:40:47 +00:00
|
|
|
* @result: the asynchronous result passed to the callback
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
*
|
|
|
|
* Finish asynchronous operation to store a password in the secret service.
|
|
|
|
*
|
|
|
|
* Returns: whether the storage was successful or not
|
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
gboolean
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_store_finish (GAsyncResult *result,
|
2012-02-02 12:40:47 +00:00
|
|
|
GError **error)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2012-07-05 21:14:50 +00:00
|
|
|
return secret_service_store_finish (NULL, result, error);
|
2012-01-11 06:44:32 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* secret_password_store_sync:
|
|
|
|
* @schema: the schema for attributes
|
2012-07-06 07:42:08 +00:00
|
|
|
* @collection: (allow-none): a collection alias, or D-Bus object path of the collection where to store the secret
|
2012-02-02 12:40:47 +00:00
|
|
|
* @label: label for the secret
|
|
|
|
* @password: the null-terminated password to store
|
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
* @...: the attribute keys and values, terminated with %NULL
|
|
|
|
*
|
|
|
|
* Store a password in the secret service.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* string, an int number, or a gboolean value, as defined in the @schema.
|
|
|
|
* The list of attribtues should be terminated with a %NULL.
|
|
|
|
*
|
|
|
|
* If the attributes match a secret item already stored in the collection, then
|
|
|
|
* the item will be updated with these new values.
|
|
|
|
*
|
2012-07-06 07:42:08 +00:00
|
|
|
* If @collection is %NULL, then the default collection will be
|
2012-03-11 12:35:43 +00:00
|
|
|
* used. Use #SECRET_COLLECTION_SESSION to store the password in the session
|
|
|
|
* collection, which doesn't get stored across login sessions.
|
|
|
|
*
|
2012-02-02 12:40:47 +00:00
|
|
|
* This method may block indefinitely and should not be used in user interface
|
|
|
|
* threads.
|
|
|
|
*
|
|
|
|
* Returns: whether the storage was successful or not
|
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
gboolean
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_store_sync (const SecretSchema *schema,
|
2012-07-06 07:42:08 +00:00
|
|
|
const gchar *collection,
|
2012-02-02 12:40:47 +00:00
|
|
|
const gchar *label,
|
|
|
|
const gchar *password,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error,
|
|
|
|
...)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
2012-01-16 14:08:29 +00:00
|
|
|
GHashTable *attributes;
|
|
|
|
va_list va;
|
|
|
|
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 (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
|
|
|
va_start (va, error);
|
2012-06-28 11:15:06 +00:00
|
|
|
attributes = secret_attributes_buildv (schema, va);
|
2012-01-16 14:08:29 +00:00
|
|
|
va_end (va);
|
|
|
|
|
2012-07-06 07:42:08 +00:00
|
|
|
ret = secret_password_storev_sync (schema, attributes, collection,
|
2012-02-02 12:40:47 +00:00
|
|
|
label, password, cancellable, error);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
|
|
|
g_hash_table_unref (attributes);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* secret_password_storev_sync:
|
|
|
|
* @schema: the schema for attributes
|
2012-03-11 08:06:40 +00:00
|
|
|
* @attributes: (element-type utf8 utf8): the attribute keys and values
|
2012-07-06 07:42:08 +00:00
|
|
|
* @collection: (allow-none): a collection alias, or D-Bus object path of the collection where to store the secret
|
2012-02-02 12:40:47 +00:00
|
|
|
* @label: label for the secret
|
|
|
|
* @password: the null-terminated password to store
|
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
*
|
|
|
|
* Store a password in the secret service.
|
|
|
|
*
|
|
|
|
* The @attributes should be a set of key and value string pairs.
|
|
|
|
*
|
|
|
|
* If the attributes match a secret item already stored in the collection, then
|
|
|
|
* the item will be updated with these new values.
|
|
|
|
*
|
2012-07-06 07:42:08 +00:00
|
|
|
* If @collection is %NULL, then the default collection will be
|
2012-03-11 12:35:43 +00:00
|
|
|
* used. Use #SECRET_COLLECTION_SESSION to store the password in the session
|
|
|
|
* collection, which doesn't get stored across login sessions.
|
|
|
|
*
|
2012-02-02 12:40:47 +00:00
|
|
|
* This method may block indefinitely and should not be used in user interface
|
|
|
|
* threads.
|
|
|
|
*
|
|
|
|
* Returns: whether the storage was successful or not
|
2012-03-11 08:06:40 +00:00
|
|
|
*
|
|
|
|
* Rename to: secret_password_store_sync
|
2012-02-02 12:40:47 +00:00
|
|
|
*/
|
2012-01-16 14:08:29 +00:00
|
|
|
gboolean
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_storev_sync (const SecretSchema *schema,
|
2012-02-02 12:40:47 +00:00
|
|
|
GHashTable *attributes,
|
2012-07-06 07:42:08 +00:00
|
|
|
const gchar *collection,
|
2012-02-02 12:40:47 +00:00
|
|
|
const gchar *label,
|
|
|
|
const gchar *password,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error)
|
2012-01-16 14:08:29 +00:00
|
|
|
{
|
2012-02-01 12:34:08 +00:00
|
|
|
SecretSync *sync;
|
2012-01-16 14:08:29 +00:00
|
|
|
gboolean ret;
|
|
|
|
|
2012-01-11 06:44:32 +00:00
|
|
|
g_return_val_if_fail (schema != NULL, FALSE);
|
2012-01-16 14:08:29 +00:00
|
|
|
g_return_val_if_fail (label != NULL, FALSE);
|
2012-01-11 06:44:32 +00:00
|
|
|
g_return_val_if_fail (password != NULL, FALSE);
|
2012-01-16 14:08:29 +00:00
|
|
|
g_return_val_if_fail (attributes != NULL, FALSE);
|
2012-01-11 06:44:32 +00:00
|
|
|
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
2012-03-11 08:06:40 +00:00
|
|
|
/* Warnings raised already */
|
2012-06-28 11:15:06 +00:00
|
|
|
if (!_secret_attributes_validate (schema, attributes))
|
2012-03-11 08:06:40 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2012-02-01 12:34:08 +00:00
|
|
|
sync = _secret_sync_new ();
|
2012-01-20 14:10:35 +00:00
|
|
|
g_main_context_push_thread_default (sync->context);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-07-06 07:42:08 +00:00
|
|
|
secret_password_storev (schema, attributes, collection, label, password,
|
2012-02-02 12:40:47 +00:00
|
|
|
cancellable, _secret_sync_on_result, sync);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-01-20 14:10:35 +00:00
|
|
|
g_main_loop_run (sync->loop);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-02-01 12:34:08 +00:00
|
|
|
ret = secret_password_store_finish (sync->result, error);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-01-20 14:10:35 +00:00
|
|
|
g_main_context_pop_thread_default (sync->context);
|
2012-02-01 12:34:08 +00:00
|
|
|
_secret_sync_free (sync);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
2012-03-11 08:06:40 +00:00
|
|
|
* secret_password_lookup: (skip)
|
2012-03-24 12:31:14 +00:00
|
|
|
* @schema: the schema for the attributes
|
2012-02-02 12:40:47 +00:00
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @callback: called when the operation completes
|
|
|
|
* @user_data: data to be passed to the callback
|
|
|
|
* @...: the attribute keys and values, terminated with %NULL
|
|
|
|
*
|
|
|
|
* Lookup a password in the secret service.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* string, an int number, or a gboolean value, as defined in the password
|
|
|
|
* @schema. The list of attribtues should be terminated with a %NULL.
|
|
|
|
*
|
|
|
|
* If no secret is found then %NULL is returned.
|
|
|
|
*
|
|
|
|
* This method will return immediately and complete asynchronously.
|
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
void
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_lookup (const SecretSchema *schema,
|
2012-02-02 12:40:47 +00:00
|
|
|
GCancellable *cancellable,
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data,
|
|
|
|
...)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
2012-01-16 14:08:29 +00:00
|
|
|
GHashTable *attributes;
|
|
|
|
va_list va;
|
|
|
|
|
2012-01-11 06:44:32 +00:00
|
|
|
g_return_if_fail (schema != NULL);
|
|
|
|
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
|
|
|
|
2012-01-16 14:08:29 +00:00
|
|
|
va_start (va, user_data);
|
2012-06-28 11:15:06 +00:00
|
|
|
attributes = secret_attributes_buildv (schema, va);
|
2012-01-16 14:08:29 +00:00
|
|
|
va_end (va);
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
secret_password_lookupv (schema, attributes, cancellable,
|
|
|
|
callback, user_data);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
|
|
|
g_hash_table_unref (attributes);
|
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* secret_password_lookupv:
|
2012-03-18 18:04:44 +00:00
|
|
|
* @schema: the schema for attributes
|
2012-03-11 08:06:40 +00:00
|
|
|
* @attributes: (element-type utf8 utf8): the attribute keys and values
|
2012-02-02 12:40:47 +00:00
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @callback: called when the operation completes
|
|
|
|
* @user_data: data to be passed to the callback
|
|
|
|
*
|
|
|
|
* Lookup a password in the secret service.
|
|
|
|
*
|
|
|
|
* The @attributes should be a set of key and value string pairs.
|
|
|
|
*
|
|
|
|
* If no secret is found then %NULL is returned.
|
|
|
|
*
|
|
|
|
* This method will return immediately and complete asynchronously.
|
2012-03-11 08:06:40 +00:00
|
|
|
*
|
|
|
|
* Rename to: secret_password_lookup
|
2012-02-02 12:40:47 +00:00
|
|
|
*/
|
2012-01-16 14:08:29 +00:00
|
|
|
void
|
2012-02-02 12:40:47 +00:00
|
|
|
secret_password_lookupv (const SecretSchema *schema,
|
|
|
|
GHashTable *attributes,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data)
|
2012-01-16 14:08:29 +00:00
|
|
|
{
|
2012-03-18 18:04:44 +00:00
|
|
|
g_return_if_fail (schema != NULL);
|
2012-01-16 14:08:29 +00:00
|
|
|
g_return_if_fail (attributes != NULL);
|
|
|
|
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
|
|
|
|
2012-03-11 08:06:40 +00:00
|
|
|
/* Warnings raised already */
|
2012-06-28 11:15:06 +00:00
|
|
|
if (!_secret_attributes_validate (schema, attributes))
|
2012-03-11 08:06:40 +00:00
|
|
|
return;
|
|
|
|
|
2012-07-05 21:14:50 +00:00
|
|
|
secret_service_lookup (NULL, schema, attributes,
|
|
|
|
cancellable, callback, user_data);
|
2012-01-11 06:44:32 +00:00
|
|
|
}
|
|
|
|
|
2012-03-11 08:06:40 +00:00
|
|
|
/**
|
|
|
|
* secret_password_lookup_nonpageable_finish: (skip)
|
|
|
|
* @result: the asynchronous result passed to the callback
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
*
|
|
|
|
* Finish an asynchronous operation to lookup a password in the secret service.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a new password string stored in nonpageable memory
|
|
|
|
* which must be freed with secret_password_free() when done
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
secret_password_lookup_nonpageable_finish (GAsyncResult *result,
|
|
|
|
GError **error)
|
|
|
|
{
|
2012-07-05 21:14:50 +00:00
|
|
|
SecretValue *value;
|
2012-03-11 08:06:40 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
2012-07-05 21:14:50 +00:00
|
|
|
value = secret_service_lookup_finish (NULL, result, error);
|
|
|
|
if (value == NULL)
|
2012-03-11 11:40:52 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-07-05 21:14:50 +00:00
|
|
|
return _secret_value_unref_to_password (value);
|
2012-03-11 08:06:40 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* secret_password_lookup_finish:
|
|
|
|
* @result: the asynchronous result passed to the callback
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
*
|
|
|
|
* Finish an asynchronous operation to lookup a password in the secret service.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a new password string which should be freed with
|
2012-03-11 08:06:40 +00:00
|
|
|
* secret_password_free() or may be freed with g_free() when done
|
2012-02-02 12:40:47 +00:00
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
gchar *
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_lookup_finish (GAsyncResult *result,
|
2012-02-02 12:40:47 +00:00
|
|
|
GError **error)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
2012-07-05 21:14:50 +00:00
|
|
|
SecretValue *value;
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-01-11 06:44:32 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-07-05 21:14:50 +00:00
|
|
|
value = secret_service_lookup_finish (NULL, result, error);
|
|
|
|
if (value == NULL)
|
2012-03-11 11:40:52 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-07-05 21:14:50 +00:00
|
|
|
return _secret_value_unref_to_string (value);
|
2012-01-11 06:44:32 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
2012-03-11 08:06:40 +00:00
|
|
|
* secret_password_lookup_sync: (skip)
|
2012-03-24 12:31:14 +00:00
|
|
|
* @schema: the schema for the attributes
|
2012-02-02 12:40:47 +00:00
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
* @...: the attribute keys and values, terminated with %NULL
|
|
|
|
*
|
|
|
|
* Lookup a password in the secret service.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* string, an int number, or a gboolean value, as defined in the password
|
|
|
|
* @schema. The list of attribtues should be terminated with a %NULL.
|
|
|
|
*
|
|
|
|
* If no secret is found then %NULL is returned.
|
|
|
|
*
|
|
|
|
* This method may block indefinitely and should not be used in user interface
|
|
|
|
* threads.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a new password string which should be freed with
|
2012-03-11 08:06:40 +00:00
|
|
|
* secret_password_free() or may be freed with g_free() when done
|
2012-02-02 12:40:47 +00:00
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
gchar *
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_lookup_sync (const SecretSchema *schema,
|
2012-02-02 12:40:47 +00:00
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error,
|
|
|
|
...)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
2012-01-16 14:08:29 +00:00
|
|
|
GHashTable *attributes;
|
|
|
|
gchar *password;
|
|
|
|
va_list va;
|
|
|
|
|
2012-01-11 06:44:32 +00:00
|
|
|
g_return_val_if_fail (schema != NULL, NULL);
|
|
|
|
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
2012-01-16 14:08:29 +00:00
|
|
|
va_start (va, error);
|
2012-06-28 11:15:06 +00:00
|
|
|
attributes = secret_attributes_buildv (schema, va);
|
2012-01-16 14:08:29 +00:00
|
|
|
va_end (va);
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
password = secret_password_lookupv_sync (schema, attributes,
|
|
|
|
cancellable, error);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
|
|
|
g_hash_table_unref (attributes);
|
|
|
|
|
|
|
|
return password;
|
2012-01-11 06:44:32 +00:00
|
|
|
}
|
|
|
|
|
2012-03-11 08:06:40 +00:00
|
|
|
/**
|
|
|
|
* secret_password_lookup_nonpageable_sync: (skip)
|
2012-03-24 12:31:14 +00:00
|
|
|
* @schema: the schema for the attributes
|
2012-03-11 08:06:40 +00:00
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
* @...: the attribute keys and values, terminated with %NULL
|
|
|
|
*
|
|
|
|
* Lookup a password in the secret service.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* string, an int number, or a gboolean value, as defined in the password
|
|
|
|
* @schema. The list of attribtues should be terminated with a %NULL.
|
|
|
|
*
|
|
|
|
* If no secret is found then %NULL is returned.
|
|
|
|
*
|
|
|
|
* This method may block indefinitely and should not be used in user interface
|
|
|
|
* threads.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a new password string stored in nonpageable memory
|
|
|
|
* which must be freed with secret_password_free() when done
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
secret_password_lookup_nonpageable_sync (const SecretSchema *schema,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error,
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
GHashTable *attributes;
|
|
|
|
gchar *password;
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
g_return_val_if_fail (schema != NULL, NULL);
|
|
|
|
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
|
|
|
|
|
|
|
va_start (va, error);
|
2012-06-28 11:15:06 +00:00
|
|
|
attributes = secret_attributes_buildv (schema, va);
|
2012-03-11 08:06:40 +00:00
|
|
|
va_end (va);
|
|
|
|
|
|
|
|
password = secret_password_lookupv_nonpageable_sync (schema, attributes,
|
|
|
|
cancellable, error);
|
|
|
|
|
|
|
|
g_hash_table_unref (attributes);
|
|
|
|
|
|
|
|
return password;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* secret_password_lookupv_nonpageable_sync: (skip)
|
2012-03-18 18:04:44 +00:00
|
|
|
* @schema: the schema for attributes
|
2012-03-11 08:06:40 +00:00
|
|
|
* @attributes: (element-type utf8 utf8): the attribute keys and values
|
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
*
|
|
|
|
* Lookup a password in the secret service.
|
|
|
|
*
|
|
|
|
* The @attributes should be a set of key and value string pairs.
|
|
|
|
*
|
|
|
|
* If no secret is found then %NULL is returned.
|
|
|
|
*
|
|
|
|
* This method may block indefinitely and should not be used in user interface
|
|
|
|
* threads.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a new password string stored in non pageable memory
|
|
|
|
* which should be freed with secret_password_free() when done
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
secret_password_lookupv_nonpageable_sync (const SecretSchema *schema,
|
|
|
|
GHashTable *attributes,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
SecretSync *sync;
|
|
|
|
gchar *password;
|
|
|
|
|
2012-03-18 18:04:44 +00:00
|
|
|
g_return_val_if_fail (schema != NULL, NULL);
|
2012-03-11 08:06:40 +00:00
|
|
|
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 */
|
2012-06-28 11:15:06 +00:00
|
|
|
if (!_secret_attributes_validate (schema, attributes))
|
2012-03-11 08:06:40 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
sync = _secret_sync_new ();
|
|
|
|
g_main_context_push_thread_default (sync->context);
|
|
|
|
|
|
|
|
secret_password_lookupv (schema, attributes, cancellable,
|
|
|
|
_secret_sync_on_result, sync);
|
|
|
|
|
|
|
|
g_main_loop_run (sync->loop);
|
|
|
|
|
|
|
|
password = secret_password_lookup_nonpageable_finish (sync->result, error);
|
|
|
|
|
|
|
|
g_main_context_pop_thread_default (sync->context);
|
|
|
|
_secret_sync_free (sync);
|
|
|
|
|
|
|
|
return password;
|
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* secret_password_lookupv_sync:
|
2012-03-18 18:04:44 +00:00
|
|
|
* @schema: the schema for attributes
|
2012-03-11 08:06:40 +00:00
|
|
|
* @attributes: (element-type utf8 utf8): the attribute keys and values
|
2012-02-02 12:40:47 +00:00
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
*
|
|
|
|
* Lookup a password in the secret service.
|
|
|
|
*
|
|
|
|
* The @attributes should be a set of key and value string pairs.
|
|
|
|
*
|
|
|
|
* If no secret is found then %NULL is returned.
|
|
|
|
*
|
|
|
|
* This method may block indefinitely and should not be used in user interface
|
|
|
|
* threads.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a new password string which should be freed with
|
2012-03-11 08:06:40 +00:00
|
|
|
* secret_password_free() or may be freed with g_free() when done
|
|
|
|
*
|
|
|
|
* Rename to: secret_password_lookup_sync
|
2012-02-02 12:40:47 +00:00
|
|
|
*/
|
2012-01-16 14:08:29 +00:00
|
|
|
gchar *
|
2012-02-02 12:40:47 +00:00
|
|
|
secret_password_lookupv_sync (const SecretSchema *schema,
|
|
|
|
GHashTable *attributes,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error)
|
2012-01-16 14:08:29 +00:00
|
|
|
{
|
2012-02-01 12:34:08 +00:00
|
|
|
SecretSync *sync;
|
2012-03-11 08:06:40 +00:00
|
|
|
gchar *string;
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-03-18 18:04:44 +00:00
|
|
|
g_return_val_if_fail (schema != NULL, NULL);
|
2012-01-16 14:08:29 +00:00
|
|
|
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);
|
|
|
|
|
2012-03-11 08:06:40 +00:00
|
|
|
/* Warnings raised already */
|
2012-06-28 11:15:06 +00:00
|
|
|
if (!_secret_attributes_validate (schema, attributes))
|
2012-03-11 08:06:40 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2012-02-01 12:34:08 +00:00
|
|
|
sync = _secret_sync_new ();
|
2012-01-20 14:10:35 +00:00
|
|
|
g_main_context_push_thread_default (sync->context);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
secret_password_lookupv (schema, attributes, cancellable,
|
|
|
|
_secret_sync_on_result, sync);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-01-20 14:10:35 +00:00
|
|
|
g_main_loop_run (sync->loop);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-03-11 08:06:40 +00:00
|
|
|
string = secret_password_lookup_finish (sync->result, error);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-01-20 14:10:35 +00:00
|
|
|
g_main_context_pop_thread_default (sync->context);
|
2012-02-01 12:34:08 +00:00
|
|
|
_secret_sync_free (sync);
|
2012-01-16 14:08:29 +00:00
|
|
|
|
2012-03-11 08:06:40 +00:00
|
|
|
return string;
|
2012-01-16 14:08:29 +00:00
|
|
|
}
|
2012-01-11 06:44:32 +00:00
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* secret_password_remove:
|
2012-03-24 12:31:14 +00:00
|
|
|
* @schema: the schema for the attributes
|
2012-02-02 12:40:47 +00:00
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @callback: called when the operation completes
|
|
|
|
* @user_data: data to be passed to the callback
|
|
|
|
* @...: the attribute keys and values, terminated with %NULL
|
|
|
|
*
|
|
|
|
* Remove a password from the secret service.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* string, an int number, or a gboolean value, as defined in the password
|
|
|
|
* @schema. The list of attribtues should be terminated with a %NULL.
|
|
|
|
*
|
|
|
|
* If multiple items match the attributes, then only one will be deleted.
|
|
|
|
*
|
|
|
|
* This method will return immediately and complete asynchronously.
|
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
void
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_remove (const SecretSchema *schema,
|
2012-02-02 12:40:47 +00:00
|
|
|
GCancellable *cancellable,
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data,
|
|
|
|
...)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
|
|
|
GHashTable *attributes;
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
g_return_if_fail (schema != NULL);
|
|
|
|
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
|
|
|
|
|
|
|
va_start (va, user_data);
|
2012-06-28 11:15:06 +00:00
|
|
|
attributes = secret_attributes_buildv (schema, va);
|
2012-01-11 06:44:32 +00:00
|
|
|
va_end (va);
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
secret_password_removev (schema, attributes, cancellable,
|
|
|
|
callback, user_data);
|
2012-01-11 06:44:32 +00:00
|
|
|
|
|
|
|
g_hash_table_unref (attributes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* secret_password_removev:
|
2012-03-24 12:31:14 +00:00
|
|
|
* @schema: the schema for the attributes
|
2012-03-11 08:06:40 +00:00
|
|
|
* @attributes: (element-type utf8 utf8): the attribute keys and values
|
2012-02-02 12:40:47 +00:00
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @callback: called when the operation completes
|
|
|
|
* @user_data: data to be passed to the callback
|
|
|
|
*
|
|
|
|
* Remove a password from the secret service.
|
|
|
|
*
|
|
|
|
* The @attributes should be a set of key and value string pairs.
|
|
|
|
*
|
|
|
|
* If multiple items match the attributes, then only one will be deleted.
|
|
|
|
*
|
|
|
|
* This method will return immediately and complete asynchronously.
|
2012-03-11 08:06:40 +00:00
|
|
|
*
|
|
|
|
* Rename to: secret_password_remove
|
2012-02-02 12:40:47 +00:00
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
void
|
2012-02-02 12:40:47 +00:00
|
|
|
secret_password_removev (const SecretSchema *schema,
|
|
|
|
GHashTable *attributes,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
2012-03-18 18:04:44 +00:00
|
|
|
g_return_if_fail (schema != NULL);
|
2012-01-11 06:44:32 +00:00
|
|
|
g_return_if_fail (attributes != NULL);
|
|
|
|
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
|
|
|
|
2012-03-11 08:06:40 +00:00
|
|
|
/* Warnings raised already */
|
2012-06-28 11:15:06 +00:00
|
|
|
if (!_secret_attributes_validate (schema, attributes))
|
2012-03-11 08:06:40 +00:00
|
|
|
return;
|
|
|
|
|
2012-07-05 21:14:50 +00:00
|
|
|
secret_service_remove (NULL, schema, attributes,
|
|
|
|
cancellable, callback, user_data);
|
2012-01-11 06:44:32 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
2012-04-27 14:57:36 +00:00
|
|
|
* secret_password_remove_finish:
|
2012-02-02 12:40:47 +00:00
|
|
|
* @result: the asynchronous result passed to the callback
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
*
|
|
|
|
* Finish an asynchronous operation to remove a password from the secret
|
|
|
|
* service.
|
|
|
|
*
|
|
|
|
* Returns: whether the removal was successful or not
|
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
gboolean
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_remove_finish (GAsyncResult *result,
|
2012-02-02 12:40:47 +00:00
|
|
|
GError **error)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2012-07-05 21:14:50 +00:00
|
|
|
return secret_service_remove_finish (NULL, result, error);
|
2012-01-11 06:44:32 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* secret_password_remove_sync:
|
2012-03-24 12:31:14 +00:00
|
|
|
* @schema: the schema for the attributes
|
2012-02-02 12:40:47 +00:00
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
* @...: the attribute keys and values, terminated with %NULL
|
|
|
|
*
|
|
|
|
* Remove a password from the secret service.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* string, an int number, or a gboolean value, as defined in the password
|
|
|
|
* @schema. The list of attribtues should be terminated with a %NULL.
|
|
|
|
*
|
|
|
|
* If multiple items match the attributes, then only one will be deleted.
|
|
|
|
*
|
|
|
|
* This method may block indefinitely and should not be used in user interface
|
|
|
|
* threads.
|
|
|
|
*
|
|
|
|
* Returns: whether the removal was successful or not
|
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
gboolean
|
2012-02-01 12:34:08 +00:00
|
|
|
secret_password_remove_sync (const SecretSchema* schema,
|
2012-02-02 12:40:47 +00:00
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error,
|
|
|
|
...)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
|
|
|
GHashTable *attributes;
|
|
|
|
gboolean result;
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
g_return_val_if_fail (schema != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
|
|
|
va_start (va, error);
|
2012-06-28 11:15:06 +00:00
|
|
|
attributes = secret_attributes_buildv (schema, va);
|
2012-01-11 06:44:32 +00:00
|
|
|
va_end (va);
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
result = secret_password_removev_sync (schema, attributes,
|
|
|
|
cancellable, error);
|
2012-01-11 06:44:32 +00:00
|
|
|
|
|
|
|
g_hash_table_unref (attributes);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* secret_password_removev_sync:
|
2012-03-24 12:31:14 +00:00
|
|
|
* @schema: the schema for the attributes
|
2012-03-11 08:06:40 +00:00
|
|
|
* @attributes: (element-type utf8 utf8): the attribute keys and values
|
2012-02-02 12:40:47 +00:00
|
|
|
* @cancellable: optional cancellation object
|
|
|
|
* @error: location to place an error on failure
|
|
|
|
*
|
|
|
|
* Remove a password from the secret service.
|
|
|
|
*
|
|
|
|
* The @attributes should be a set of key and value string pairs.
|
|
|
|
*
|
|
|
|
* If multiple items match the attributes, then only one will be deleted.
|
|
|
|
*
|
|
|
|
* This method may block indefinitely and should not be used in user interface
|
|
|
|
* threads.
|
|
|
|
*
|
|
|
|
* Returns: whether the removal was successful or not
|
2012-03-11 08:06:40 +00:00
|
|
|
*
|
|
|
|
* Rename to: secret_password_remove_sync
|
2012-02-02 12:40:47 +00:00
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
gboolean
|
2012-02-02 12:40:47 +00:00
|
|
|
secret_password_removev_sync (const SecretSchema *schema,
|
|
|
|
GHashTable *attributes,
|
|
|
|
GCancellable *cancellable,
|
|
|
|
GError **error)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
2012-02-01 12:34:08 +00:00
|
|
|
SecretSync *sync;
|
2012-01-11 06:44:32 +00:00
|
|
|
gboolean result;
|
|
|
|
|
2012-03-18 18:04:44 +00:00
|
|
|
g_return_val_if_fail (schema != NULL, FALSE);
|
2012-01-11 06:44:32 +00:00
|
|
|
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);
|
|
|
|
|
2012-03-11 08:06:40 +00:00
|
|
|
/* Warnings raised already */
|
2012-06-28 11:15:06 +00:00
|
|
|
if (!_secret_attributes_validate (schema, attributes))
|
2012-03-11 08:06:40 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2012-02-01 12:34:08 +00:00
|
|
|
sync = _secret_sync_new ();
|
2012-01-20 14:10:35 +00:00
|
|
|
g_main_context_push_thread_default (sync->context);
|
2012-01-11 06:44:32 +00:00
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
secret_password_removev (schema, attributes, cancellable,
|
|
|
|
_secret_sync_on_result, sync);
|
2012-01-11 06:44:32 +00:00
|
|
|
|
2012-01-20 14:10:35 +00:00
|
|
|
g_main_loop_run (sync->loop);
|
2012-01-11 06:44:32 +00:00
|
|
|
|
2012-02-01 12:34:08 +00:00
|
|
|
result = secret_password_remove_finish (sync->result, error);
|
2012-01-11 06:44:32 +00:00
|
|
|
|
2012-01-20 14:10:35 +00:00
|
|
|
g_main_context_pop_thread_default (sync->context);
|
2012-02-01 12:34:08 +00:00
|
|
|
_secret_sync_free (sync);
|
2012-01-11 06:44:32 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-02-02 12:40:47 +00:00
|
|
|
/**
|
2012-03-11 08:06:40 +00:00
|
|
|
* secret_password_free: (skip)
|
2012-03-01 09:54:47 +00:00
|
|
|
* @password: (allow-none): password to free
|
2012-02-02 12:40:47 +00:00
|
|
|
*
|
2012-03-11 08:06:40 +00:00
|
|
|
* Clear the memory used by a password, and then free it.
|
|
|
|
*
|
|
|
|
* This function must be used to free nonpageable memory returned by
|
|
|
|
* secret_password_lookup_nonpageable_finish(),
|
|
|
|
* secret_password_lookup_nonpageable_sync() or
|
|
|
|
* secret_password_lookupv_nonpageable_sync().
|
2012-02-02 12:40:47 +00:00
|
|
|
*/
|
2012-01-11 06:44:32 +00:00
|
|
|
void
|
2012-03-01 09:54:47 +00:00
|
|
|
secret_password_free (gchar *password)
|
2012-01-11 06:44:32 +00:00
|
|
|
{
|
|
|
|
if (password == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
egg_secure_strfree (password);
|
|
|
|
}
|
2012-03-25 10:18:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* secret_password_clear:
|
|
|
|
* @password: (allow-none): password to clear
|
|
|
|
*
|
|
|
|
* Clear the memory used by a password.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
secret_password_clear (gchar *password)
|
|
|
|
{
|
|
|
|
if (password == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
egg_secure_strclear (password);
|
|
|
|
}
|