mirror of
https://gitlab.gnome.org/GNOME/libsecret.git
synced 2024-12-22 12:48:51 +00:00
Accept NULL as a SecretService parameter for many methods
* We use secret_service_get() to lookup the default SecretService in these cases. * Use this functionality in the secret_password_xxx() functions to greatly simplify them.
This commit is contained in:
parent
153dfcec5f
commit
600021a30b
@ -138,6 +138,23 @@ on_set_label (GObject *source,
|
||||
g_object_unref (self);
|
||||
}
|
||||
|
||||
static void
|
||||
collection_take_service (SecretCollection *self,
|
||||
SecretService *service)
|
||||
{
|
||||
if (service == NULL)
|
||||
return;
|
||||
|
||||
g_return_if_fail (self->pv->service == NULL);
|
||||
|
||||
self->pv->service = service;
|
||||
g_object_add_weak_pointer (G_OBJECT (self->pv->service),
|
||||
(gpointer *)&self->pv->service);
|
||||
|
||||
/* Yes, we expect that the service will stay around */
|
||||
g_object_unref (service);
|
||||
}
|
||||
|
||||
static void
|
||||
secret_collection_set_property (GObject *obj,
|
||||
guint prop_id,
|
||||
@ -148,11 +165,7 @@ secret_collection_set_property (GObject *obj,
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SERVICE:
|
||||
g_return_if_fail (self->pv->service == NULL);
|
||||
self->pv->service = g_value_get_object (value);
|
||||
if (self->pv->service)
|
||||
g_object_add_weak_pointer (G_OBJECT (self->pv->service),
|
||||
(gpointer *)&self->pv->service);
|
||||
collection_take_service (self, g_value_dup_object (value));
|
||||
break;
|
||||
case PROP_FLAGS:
|
||||
self->pv->init_flags = g_value_get_flags (value);
|
||||
@ -494,6 +507,7 @@ secret_collection_initable_init (GInitable *initable,
|
||||
GError **error)
|
||||
{
|
||||
SecretCollection *self;
|
||||
SecretService *service;
|
||||
GDBusProxy *proxy;
|
||||
|
||||
if (!secret_collection_initable_parent_iface->init (initable, cancellable, error))
|
||||
@ -510,6 +524,14 @@ secret_collection_initable_init (GInitable *initable,
|
||||
|
||||
self = SECRET_COLLECTION (initable);
|
||||
|
||||
if (self->pv->service == NULL) {
|
||||
service = secret_service_get_sync (SECRET_SERVICE_NONE, cancellable, error);
|
||||
if (service == NULL)
|
||||
return FALSE;
|
||||
else
|
||||
collection_take_service (self, service);
|
||||
}
|
||||
|
||||
if (self->pv->init_flags & SECRET_COLLECTION_LOAD_ITEMS) {
|
||||
if (!secret_collection_load_items_sync (self, cancellable, error))
|
||||
return FALSE;
|
||||
@ -555,6 +577,45 @@ on_init_items (GObject *source,
|
||||
g_object_unref (res);
|
||||
}
|
||||
|
||||
static void
|
||||
collection_ensure_for_flags_async (SecretCollection *self,
|
||||
SecretCollectionFlags flags,
|
||||
GSimpleAsyncResult *async)
|
||||
{
|
||||
InitClosure *init = g_simple_async_result_get_op_res_gpointer (async);
|
||||
|
||||
if (flags & SECRET_COLLECTION_LOAD_ITEMS)
|
||||
secret_collection_load_items (self, init->cancellable,
|
||||
on_init_items, g_object_ref (async));
|
||||
|
||||
else
|
||||
g_simple_async_result_complete (async);
|
||||
}
|
||||
|
||||
static void
|
||||
on_init_service (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *async = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
SecretCollection *self = SECRET_COLLECTION (g_async_result_get_source_object (user_data));
|
||||
SecretService *service;
|
||||
GError *error = NULL;
|
||||
|
||||
service = secret_service_get_finish (result, &error);
|
||||
if (error == NULL) {
|
||||
collection_take_service (self, service);
|
||||
collection_ensure_for_flags_async (self, self->pv->init_flags, async);
|
||||
|
||||
} else {
|
||||
g_simple_async_result_take_error (async, error);
|
||||
g_simple_async_result_complete (async);
|
||||
}
|
||||
|
||||
g_object_unref (self);
|
||||
g_object_unref (async);
|
||||
}
|
||||
|
||||
static void
|
||||
on_init_base (GObject *source,
|
||||
GAsyncResult *result,
|
||||
@ -562,7 +623,7 @@ on_init_base (GObject *source,
|
||||
{
|
||||
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
SecretCollection *self = SECRET_COLLECTION (source);
|
||||
InitClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
InitClosure *init = g_simple_async_result_get_op_res_gpointer (res);
|
||||
GDBusProxy *proxy = G_DBUS_PROXY (self);
|
||||
GError *error = NULL;
|
||||
|
||||
@ -577,12 +638,12 @@ on_init_base (GObject *source,
|
||||
g_dbus_proxy_get_object_path (proxy));
|
||||
g_simple_async_result_complete (res);
|
||||
|
||||
} else if (self->pv->init_flags & SECRET_COLLECTION_LOAD_ITEMS) {
|
||||
secret_collection_load_items (self, closure->cancellable,
|
||||
on_init_items, g_object_ref (res));
|
||||
} else if (self->pv->service == NULL) {
|
||||
secret_service_get (SECRET_SERVICE_NONE, init->cancellable,
|
||||
on_init_service, g_object_ref (res));
|
||||
|
||||
} else {
|
||||
g_simple_async_result_complete (res);
|
||||
collection_ensure_for_flags_async (self, self->pv->init_flags, res);
|
||||
}
|
||||
|
||||
g_object_unref (res);
|
||||
@ -640,7 +701,7 @@ secret_collection_async_initable_iface (GAsyncInitableIface *iface)
|
||||
|
||||
/**
|
||||
* secret_collection_new:
|
||||
* @service: a secret service object
|
||||
* @service: (allow-none): a secret service object
|
||||
* @collection_path: the D-Bus path of the collection
|
||||
* @flags: options for the collection initialization
|
||||
* @cancellable: optional cancellation object
|
||||
@ -649,6 +710,9 @@ secret_collection_async_initable_iface (GAsyncInitableIface *iface)
|
||||
*
|
||||
* Get a new collection proxy for a collection in the secret service.
|
||||
*
|
||||
* If @service is NULL, then secret_service_get() will be called to get
|
||||
* the default #SecretService proxy.
|
||||
*
|
||||
* This method will return immediately and complete asynchronously.
|
||||
*/
|
||||
void
|
||||
@ -661,7 +725,7 @@ secret_collection_new (SecretService *service,
|
||||
{
|
||||
GDBusProxy *proxy;
|
||||
|
||||
g_return_if_fail (SECRET_IS_SERVICE (service));
|
||||
g_return_if_fail (service == NULL || SECRET_IS_SERVICE (service));
|
||||
g_return_if_fail (collection_path != NULL);
|
||||
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
||||
|
||||
@ -714,7 +778,7 @@ secret_collection_new_finish (GAsyncResult *result,
|
||||
|
||||
/**
|
||||
* secret_collection_new_sync:
|
||||
* @service: a secret service object
|
||||
* @service: (allow-none): a secret service object
|
||||
* @collection_path: the D-Bus path of the collection
|
||||
* @flags: options for the collection initialization
|
||||
* @cancellable: optional cancellation object
|
||||
@ -722,6 +786,9 @@ secret_collection_new_finish (GAsyncResult *result,
|
||||
*
|
||||
* Get a new collection proxy for a collection in the secret service.
|
||||
*
|
||||
* If @service is NULL, then secret_service_get_sync() will be called to get
|
||||
* the default #SecretService proxy.
|
||||
*
|
||||
* This method may block indefinitely and should not be used in user interface
|
||||
* threads.
|
||||
*
|
||||
@ -737,7 +804,7 @@ secret_collection_new_sync (SecretService *service,
|
||||
{
|
||||
GDBusProxy *proxy;
|
||||
|
||||
g_return_val_if_fail (SECRET_IS_SERVICE (service), NULL);
|
||||
g_return_val_if_fail (service == NULL || SECRET_IS_SERVICE (service), NULL);
|
||||
g_return_val_if_fail (collection_path != NULL, NULL);
|
||||
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
@ -988,6 +1055,8 @@ secret_collection_refresh (SecretCollection *self)
|
||||
typedef struct {
|
||||
GCancellable *cancellable;
|
||||
SecretCollection *collection;
|
||||
GHashTable *properties;
|
||||
gchar *alias;
|
||||
} CreateClosure;
|
||||
|
||||
static void
|
||||
@ -996,6 +1065,8 @@ create_closure_free (gpointer data)
|
||||
CreateClosure *closure = data;
|
||||
g_clear_object (&closure->cancellable);
|
||||
g_clear_object (&closure->collection);
|
||||
g_hash_table_unref (closure->properties);
|
||||
g_free (closure->alias);
|
||||
g_slice_free (CreateClosure, closure);
|
||||
}
|
||||
|
||||
@ -1040,6 +1111,31 @@ on_create_path (GObject *source,
|
||||
g_object_unref (res);
|
||||
}
|
||||
|
||||
static void
|
||||
on_create_service (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *async = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
CreateClosure *create = g_simple_async_result_get_op_res_gpointer (async);
|
||||
GError *error = NULL;
|
||||
SecretService *service;
|
||||
|
||||
service = secret_service_get_finish (result, &error);
|
||||
if (error == NULL) {
|
||||
secret_service_create_collection_path (service, create->properties,
|
||||
create->alias, create->cancellable,
|
||||
on_create_path, g_object_ref (async));
|
||||
g_object_unref (service);
|
||||
|
||||
} else {
|
||||
g_simple_async_result_take_error (async, error);
|
||||
g_simple_async_result_complete (async);
|
||||
}
|
||||
|
||||
g_object_unref (async);
|
||||
}
|
||||
|
||||
static GHashTable *
|
||||
collection_properties_new (const gchar *label)
|
||||
{
|
||||
@ -1058,7 +1154,7 @@ collection_properties_new (const gchar *label)
|
||||
|
||||
/**
|
||||
* secret_collection_create:
|
||||
* @service: a secret service object
|
||||
* @service: (allow-none): a secret service object
|
||||
* @label: label for the new collection
|
||||
* @alias: (allow-none): alias to assign to the collection
|
||||
* @cancellable: optional cancellation object
|
||||
@ -1076,6 +1172,10 @@ collection_properties_new (const gchar *label)
|
||||
* easily identify and share a collection. If you specify an @alias, and a
|
||||
* collection with that alias already exists, then a new collection will not
|
||||
* be created. The previous one will be returned instead.
|
||||
*
|
||||
* If @service is NULL, then secret_service_get() will be called to get
|
||||
* the default #SecretService proxy.
|
||||
*
|
||||
*/
|
||||
void
|
||||
secret_collection_create (SecretService *service,
|
||||
@ -1087,9 +1187,8 @@ secret_collection_create (SecretService *service,
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
CreateClosure *closure;
|
||||
GHashTable *properties;
|
||||
|
||||
g_return_if_fail (SECRET_IS_SERVICE (service));
|
||||
g_return_if_fail (service == NULL || SECRET_IS_SERVICE (service));
|
||||
g_return_if_fail (label != NULL);
|
||||
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
||||
|
||||
@ -1097,14 +1196,20 @@ secret_collection_create (SecretService *service,
|
||||
secret_collection_create);
|
||||
closure = g_slice_new0 (CreateClosure);
|
||||
closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
|
||||
closure->properties = collection_properties_new (label);
|
||||
closure->alias = g_strdup (alias);
|
||||
g_simple_async_result_set_op_res_gpointer (res, closure, create_closure_free);
|
||||
|
||||
properties = collection_properties_new (label);
|
||||
if (service == NULL) {
|
||||
secret_service_get (SECRET_SERVICE_NONE, cancellable,
|
||||
on_create_service, g_object_ref (res));
|
||||
|
||||
secret_service_create_collection_path (service, properties, alias, cancellable,
|
||||
on_create_path, g_object_ref (res));
|
||||
} else {
|
||||
secret_service_create_collection_path (service, closure->properties,
|
||||
closure->alias, closure->cancellable,
|
||||
on_create_path, g_object_ref (res));
|
||||
}
|
||||
|
||||
g_hash_table_unref (properties);
|
||||
g_object_unref (res);
|
||||
}
|
||||
|
||||
@ -1143,7 +1248,7 @@ secret_collection_create_finish (GAsyncResult *result,
|
||||
|
||||
/**
|
||||
* secret_collection_create_sync:
|
||||
* @service: a secret service object
|
||||
* @service: (allow-none): a secret service object
|
||||
* @label: label for the new collection
|
||||
* @alias: (allow-none): alias to assign to the collection
|
||||
* @cancellable: optional cancellation object
|
||||
@ -1161,6 +1266,9 @@ secret_collection_create_finish (GAsyncResult *result,
|
||||
* collection with that alias already exists, then a new collection will not
|
||||
* be created. The previous one will be returned instead.
|
||||
*
|
||||
* If @service is NULL, then secret_service_get_sync() will be called to get
|
||||
* the default #SecretService proxy.
|
||||
*
|
||||
* Returns: (transfer full): the new collection, which should be unreferenced
|
||||
* with g_object_unref()
|
||||
*/
|
||||
@ -1175,11 +1283,19 @@ secret_collection_create_sync (SecretService *service,
|
||||
GHashTable *properties;
|
||||
gchar *path;
|
||||
|
||||
g_return_val_if_fail (SECRET_IS_SERVICE (service), NULL);
|
||||
g_return_val_if_fail (service == NULL || SECRET_IS_SERVICE (service), NULL);
|
||||
g_return_val_if_fail (label != NULL, NULL);
|
||||
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (service == NULL) {
|
||||
service = secret_service_get_sync (SECRET_SERVICE_NONE, cancellable, error);
|
||||
if (service == NULL)
|
||||
return NULL;
|
||||
} else {
|
||||
g_object_ref (service);
|
||||
}
|
||||
|
||||
properties = collection_properties_new (label);
|
||||
|
||||
path = secret_service_create_collection_path_sync (service, properties, alias,
|
||||
@ -1187,12 +1303,16 @@ secret_collection_create_sync (SecretService *service,
|
||||
|
||||
g_hash_table_unref (properties);
|
||||
|
||||
if (path == NULL)
|
||||
if (path == NULL) {
|
||||
g_object_unref (service);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
collection = secret_collection_new_sync (service, path,
|
||||
SECRET_COLLECTION_LOAD_ITEMS,
|
||||
cancellable, error);
|
||||
|
||||
g_object_unref (service);
|
||||
g_free (path);
|
||||
|
||||
return collection;
|
||||
|
@ -152,6 +152,24 @@ on_set_label (GObject *source,
|
||||
g_object_unref (self);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
item_take_service (SecretItem *self,
|
||||
SecretService *service)
|
||||
{
|
||||
if (service == NULL)
|
||||
return;
|
||||
|
||||
g_return_if_fail (self->pv->service == NULL);
|
||||
|
||||
self->pv->service = service;
|
||||
g_object_add_weak_pointer (G_OBJECT (self->pv->service),
|
||||
(gpointer *)&self->pv->service);
|
||||
|
||||
/* Yes, we expect that the service will stay around */
|
||||
g_object_unref (service);
|
||||
}
|
||||
|
||||
static void
|
||||
secret_item_set_property (GObject *obj,
|
||||
guint prop_id,
|
||||
@ -162,11 +180,7 @@ secret_item_set_property (GObject *obj,
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SERVICE:
|
||||
g_return_if_fail (self->pv->service == NULL);
|
||||
self->pv->service = g_value_get_object (value);
|
||||
if (self->pv->service)
|
||||
g_object_add_weak_pointer (G_OBJECT (self->pv->service),
|
||||
(gpointer *)&self->pv->service);
|
||||
item_take_service (self, g_value_dup_object (value));
|
||||
break;
|
||||
case PROP_FLAGS:
|
||||
self->pv->init_flags = g_value_get_flags (value);
|
||||
@ -444,6 +458,7 @@ secret_item_initable_init (GInitable *initable,
|
||||
GError **error)
|
||||
{
|
||||
SecretItem *self;
|
||||
SecretService *service;
|
||||
GDBusProxy *proxy;
|
||||
|
||||
if (!secret_item_initable_parent_iface->init (initable, cancellable, error))
|
||||
@ -459,6 +474,14 @@ secret_item_initable_init (GInitable *initable,
|
||||
}
|
||||
|
||||
self = SECRET_ITEM (initable);
|
||||
if (!self->pv->service) {
|
||||
service = secret_service_get_sync (SECRET_SERVICE_NONE, cancellable, error);
|
||||
if (service == NULL)
|
||||
return FALSE;
|
||||
else
|
||||
item_take_service (self, service);
|
||||
}
|
||||
|
||||
return item_ensure_for_flags_sync (self, self->pv->init_flags, cancellable, error);
|
||||
}
|
||||
|
||||
@ -470,12 +493,37 @@ secret_item_initable_iface (GInitableIface *iface)
|
||||
iface->init = secret_item_initable_init;
|
||||
}
|
||||
|
||||
static void
|
||||
on_init_service (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *async = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
SecretItem *self = SECRET_ITEM (g_async_result_get_source_object (user_data));
|
||||
SecretService *service;
|
||||
GError *error = NULL;
|
||||
|
||||
service = secret_service_get_finish (result, &error);
|
||||
if (error == NULL) {
|
||||
item_take_service (self, service);
|
||||
item_ensure_for_flags_async (self, self->pv->init_flags, async);
|
||||
|
||||
} else {
|
||||
g_simple_async_result_take_error (async, error);
|
||||
g_simple_async_result_complete (async);
|
||||
}
|
||||
|
||||
g_object_unref (self);
|
||||
g_object_unref (async);
|
||||
}
|
||||
|
||||
static void
|
||||
on_init_base (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
InitClosure *init = g_simple_async_result_get_op_res_gpointer (res);
|
||||
SecretItem *self = SECRET_ITEM (source);
|
||||
GDBusProxy *proxy = G_DBUS_PROXY (self);
|
||||
GError *error = NULL;
|
||||
@ -491,6 +539,10 @@ on_init_base (GObject *source,
|
||||
g_dbus_proxy_get_object_path (proxy));
|
||||
g_simple_async_result_complete (res);
|
||||
|
||||
} else if (self->pv->service == NULL) {
|
||||
secret_service_get (SECRET_SERVICE_NONE, init->cancellable,
|
||||
on_init_service, g_object_ref (res));
|
||||
|
||||
} else {
|
||||
item_ensure_for_flags_async (self, self->pv->init_flags, res);
|
||||
}
|
||||
@ -547,7 +599,7 @@ secret_item_async_initable_iface (GAsyncInitableIface *iface)
|
||||
|
||||
/**
|
||||
* secret_item_new:
|
||||
* @service: a secret service object
|
||||
* @service: (allow-none): a secret service object
|
||||
* @item_path: the D-Bus path of the collection
|
||||
* @flags: initialization flags for the new item
|
||||
* @cancellable: optional cancellation object
|
||||
@ -556,6 +608,9 @@ secret_item_async_initable_iface (GAsyncInitableIface *iface)
|
||||
*
|
||||
* Get a new item proxy for a secret item in the secret service.
|
||||
*
|
||||
* If @service is NULL, then secret_service_get() will be called to get
|
||||
* the default #SecretService proxy.
|
||||
*
|
||||
* This method will return immediately and complete asynchronously.
|
||||
*/
|
||||
void
|
||||
@ -568,7 +623,7 @@ secret_item_new (SecretService *service,
|
||||
{
|
||||
GDBusProxy *proxy;
|
||||
|
||||
g_return_if_fail (SECRET_IS_SERVICE (service));
|
||||
g_return_if_fail (service == NULL || SECRET_IS_SERVICE (service));
|
||||
g_return_if_fail (item_path != NULL);
|
||||
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
||||
|
||||
@ -618,7 +673,7 @@ secret_item_new_finish (GAsyncResult *result,
|
||||
|
||||
/**
|
||||
* secret_item_new_sync:
|
||||
* @service: a secret service object
|
||||
* @service: (allow-none): a secret service object
|
||||
* @item_path: the D-Bus path of the item
|
||||
* @flags: initialization flags for the new item
|
||||
* @cancellable: optional cancellation object
|
||||
@ -626,6 +681,9 @@ secret_item_new_finish (GAsyncResult *result,
|
||||
*
|
||||
* Get a new item proxy for a secret item in the secret service.
|
||||
*
|
||||
* If @service is NULL, then secret_service_get_sync() will be called to get
|
||||
* the default #SecretService proxy.
|
||||
*
|
||||
* This method may block indefinitely and should not be used in user interface
|
||||
* threads.
|
||||
*
|
||||
@ -641,7 +699,7 @@ secret_item_new_sync (SecretService *service,
|
||||
{
|
||||
GDBusProxy *proxy;
|
||||
|
||||
g_return_val_if_fail (SECRET_IS_SERVICE (service), NULL);
|
||||
g_return_val_if_fail (service == NULL || SECRET_IS_SERVICE (service), NULL);
|
||||
g_return_val_if_fail (item_path != NULL, NULL);
|
||||
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -42,76 +42,6 @@
|
||||
* Stability: Stable
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
const SecretSchema *schema;
|
||||
GHashTable *attributes;
|
||||
gchar *collection_path;
|
||||
gchar *label;
|
||||
SecretValue *value;
|
||||
GCancellable *cancellable;
|
||||
gboolean created;
|
||||
} StoreClosure;
|
||||
|
||||
static void
|
||||
store_closure_free (gpointer data)
|
||||
{
|
||||
StoreClosure *closure = data;
|
||||
_secret_schema_unref_if_nonstatic (closure->schema);
|
||||
g_hash_table_unref (closure->attributes);
|
||||
g_free (closure->collection_path);
|
||||
g_free (closure->label);
|
||||
secret_value_unref (closure->value);
|
||||
g_clear_object (&closure->cancellable);
|
||||
g_slice_free (StoreClosure, closure);
|
||||
}
|
||||
|
||||
static void
|
||||
on_store_complete (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
StoreClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
GError *error = NULL;
|
||||
|
||||
closure->created = secret_service_store_finish (SECRET_SERVICE (source),
|
||||
result, &error);
|
||||
if (error != NULL)
|
||||
g_simple_async_result_take_error (res, error);
|
||||
|
||||
g_simple_async_result_complete (res);
|
||||
g_object_unref (res);
|
||||
}
|
||||
|
||||
static void
|
||||
on_store_connected (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
StoreClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
SecretService *service;
|
||||
GError *error = NULL;
|
||||
|
||||
service = secret_service_get_finish (result, &error);
|
||||
if (error == NULL) {
|
||||
secret_service_store (service, closure->schema,
|
||||
closure->attributes,
|
||||
closure->collection_path,
|
||||
closure->label, closure->value,
|
||||
closure->cancellable,
|
||||
on_store_complete,
|
||||
g_object_ref (res));
|
||||
g_object_unref (service);
|
||||
|
||||
} else {
|
||||
g_simple_async_result_take_error (res, error);
|
||||
g_simple_async_result_complete (res);
|
||||
}
|
||||
|
||||
g_object_unref (res);
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_password_store: (skip)
|
||||
* @schema: the schema for attributes
|
||||
@ -203,8 +133,7 @@ secret_password_storev (const SecretSchema *schema,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
StoreClosure *closure;
|
||||
SecretValue *value;
|
||||
|
||||
g_return_if_fail (schema != NULL);
|
||||
g_return_if_fail (label != NULL);
|
||||
@ -216,21 +145,12 @@ secret_password_storev (const SecretSchema *schema,
|
||||
if (!_secret_attributes_validate (schema, attributes))
|
||||
return;
|
||||
|
||||
res = g_simple_async_result_new (NULL, callback, user_data,
|
||||
secret_password_storev);
|
||||
closure = g_slice_new0 (StoreClosure);
|
||||
closure->schema = _secret_schema_ref_if_nonstatic (schema);
|
||||
closure->collection_path = g_strdup (collection_path);
|
||||
closure->label = g_strdup (label);
|
||||
closure->value = secret_value_new (password, -1, "text/plain");
|
||||
closure->attributes = _secret_attributes_copy (attributes);
|
||||
closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
|
||||
g_simple_async_result_set_op_res_gpointer (res, closure, store_closure_free);
|
||||
value = secret_value_new (password, -1, "text/plain");
|
||||
|
||||
secret_service_get (SECRET_SERVICE_OPEN_SESSION, cancellable,
|
||||
on_store_connected, g_object_ref (res));
|
||||
secret_service_store (NULL, schema, attributes, collection_path,
|
||||
label, value, cancellable, callback, user_data);
|
||||
|
||||
g_object_unref (res);
|
||||
secret_value_unref (value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -246,19 +166,8 @@ gboolean
|
||||
secret_password_store_finish (GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
StoreClosure *closure;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL,
|
||||
secret_password_storev), FALSE);
|
||||
|
||||
res = G_SIMPLE_ASYNC_RESULT (result);
|
||||
if (g_simple_async_result_propagate_error (res, error))
|
||||
return FALSE;
|
||||
|
||||
closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
return closure->created;
|
||||
return secret_service_store_finish (NULL, result, error);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -387,25 +296,6 @@ secret_password_storev_sync (const SecretSchema *schema,
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GCancellable *cancellable;
|
||||
GHashTable *attributes;
|
||||
SecretValue *value;
|
||||
const SecretSchema *schema;
|
||||
} LookupClosure;
|
||||
|
||||
static void
|
||||
lookup_closure_free (gpointer data)
|
||||
{
|
||||
LookupClosure *closure = data;
|
||||
_secret_schema_unref_if_nonstatic (closure->schema);
|
||||
g_clear_object (&closure->cancellable);
|
||||
g_hash_table_unref (closure->attributes);
|
||||
if (closure->value)
|
||||
secret_value_unref (closure->value);
|
||||
g_slice_free (LookupClosure, closure);
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_password_lookup: (skip)
|
||||
* @schema: the schema for the attributes
|
||||
@ -448,50 +338,6 @@ secret_password_lookup (const SecretSchema *schema,
|
||||
g_hash_table_unref (attributes);
|
||||
}
|
||||
|
||||
static void
|
||||
on_lookup_complete (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
LookupClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
GError *error = NULL;
|
||||
|
||||
closure->value = secret_service_lookup_finish (SECRET_SERVICE (source),
|
||||
result, &error);
|
||||
|
||||
if (error != NULL)
|
||||
g_simple_async_result_take_error (res, error);
|
||||
|
||||
g_simple_async_result_complete (res);
|
||||
g_object_unref (res);
|
||||
}
|
||||
|
||||
static void
|
||||
on_lookup_connected (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
LookupClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
SecretService *service;
|
||||
GError *error = NULL;
|
||||
|
||||
service = secret_service_get_finish (result, &error);
|
||||
if (error != NULL) {
|
||||
g_simple_async_result_take_error (res, error);
|
||||
g_simple_async_result_complete (res);
|
||||
|
||||
} else {
|
||||
secret_service_lookup (service, closure->schema, closure->attributes,
|
||||
closure->cancellable, on_lookup_complete,
|
||||
g_object_ref (res));
|
||||
g_object_unref (service);
|
||||
}
|
||||
|
||||
g_object_unref (res);
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_password_lookupv:
|
||||
* @schema: the schema for attributes
|
||||
@ -517,9 +363,6 @@ secret_password_lookupv (const SecretSchema *schema,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
LookupClosure *closure;
|
||||
|
||||
g_return_if_fail (schema != NULL);
|
||||
g_return_if_fail (attributes != NULL);
|
||||
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
||||
@ -528,18 +371,8 @@ secret_password_lookupv (const SecretSchema *schema,
|
||||
if (!_secret_attributes_validate (schema, attributes))
|
||||
return;
|
||||
|
||||
res = g_simple_async_result_new (NULL, callback, user_data,
|
||||
secret_password_lookupv);
|
||||
closure = g_slice_new0 (LookupClosure);
|
||||
closure->schema = _secret_schema_ref_if_nonstatic (schema);
|
||||
closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
|
||||
closure->attributes = _secret_attributes_copy (attributes);
|
||||
g_simple_async_result_set_op_res_gpointer (res, closure, lookup_closure_free);
|
||||
|
||||
secret_service_get (SECRET_SERVICE_OPEN_SESSION, cancellable,
|
||||
on_lookup_connected, g_object_ref (res));
|
||||
|
||||
g_object_unref (res);
|
||||
secret_service_lookup (NULL, schema, attributes,
|
||||
cancellable, callback, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -556,25 +389,15 @@ gchar *
|
||||
secret_password_lookup_nonpageable_finish (GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
LookupClosure *closure;
|
||||
gchar *password = NULL;
|
||||
SecretValue *value;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL,
|
||||
secret_password_lookupv), NULL);
|
||||
|
||||
res = G_SIMPLE_ASYNC_RESULT (result);
|
||||
if (g_simple_async_result_propagate_error (res, error))
|
||||
value = secret_service_lookup_finish (NULL, result, error);
|
||||
if (value == NULL)
|
||||
return NULL;
|
||||
|
||||
closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
if (closure->value == NULL)
|
||||
return NULL;
|
||||
|
||||
password = _secret_value_unref_to_password (closure->value);
|
||||
closure->value = NULL;
|
||||
return password;
|
||||
return _secret_value_unref_to_password (value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -591,25 +414,15 @@ gchar *
|
||||
secret_password_lookup_finish (GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
LookupClosure *closure;
|
||||
gchar *string = NULL;
|
||||
SecretValue *value;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL,
|
||||
secret_password_lookupv), NULL);
|
||||
|
||||
res = G_SIMPLE_ASYNC_RESULT (result);
|
||||
if (g_simple_async_result_propagate_error (res, error))
|
||||
value = secret_service_lookup_finish (NULL, result, error);
|
||||
if (value == NULL)
|
||||
return NULL;
|
||||
|
||||
closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
if (closure->value == NULL)
|
||||
return NULL;
|
||||
|
||||
string = _secret_value_unref_to_string (closure->value);
|
||||
closure->value = NULL;
|
||||
return string;
|
||||
return _secret_value_unref_to_string (value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -816,23 +629,6 @@ secret_password_lookupv_sync (const SecretSchema *schema,
|
||||
return string;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GCancellable *cancellable;
|
||||
GHashTable *attributes;
|
||||
gboolean deleted;
|
||||
const SecretSchema *schema;
|
||||
} DeleteClosure;
|
||||
|
||||
static void
|
||||
delete_closure_free (gpointer data)
|
||||
{
|
||||
DeleteClosure *closure = data;
|
||||
g_clear_object (&closure->cancellable);
|
||||
g_hash_table_unref (closure->attributes);
|
||||
_secret_schema_unref_if_nonstatic (closure->schema);
|
||||
g_slice_free (DeleteClosure, closure);
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_password_remove:
|
||||
* @schema: the schema for the attributes
|
||||
@ -875,48 +671,6 @@ secret_password_remove (const SecretSchema *schema,
|
||||
g_hash_table_unref (attributes);
|
||||
}
|
||||
|
||||
static void
|
||||
on_delete_complete (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
DeleteClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
GError *error = NULL;
|
||||
|
||||
closure->deleted = secret_service_remove_finish (SECRET_SERVICE (source),
|
||||
result, &error);
|
||||
if (error != NULL)
|
||||
g_simple_async_result_take_error (res, error);
|
||||
g_simple_async_result_complete (res);
|
||||
|
||||
g_object_unref (res);
|
||||
}
|
||||
|
||||
static void
|
||||
on_delete_connect (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
|
||||
DeleteClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
SecretService *service;
|
||||
GError *error = NULL;
|
||||
|
||||
service = secret_service_get_finish (result, &error);
|
||||
if (error == NULL) {
|
||||
secret_service_remove (service, closure->schema, closure->attributes,
|
||||
closure->cancellable, on_delete_complete,
|
||||
g_object_ref (res));
|
||||
g_object_unref (service);
|
||||
|
||||
} else {
|
||||
g_simple_async_result_take_error (res, error);
|
||||
g_simple_async_result_complete (res);
|
||||
}
|
||||
|
||||
g_object_unref (res);
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_password_removev:
|
||||
@ -943,9 +697,6 @@ secret_password_removev (const SecretSchema *schema,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *res;
|
||||
DeleteClosure *closure;
|
||||
|
||||
g_return_if_fail (schema != NULL);
|
||||
g_return_if_fail (attributes != NULL);
|
||||
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
||||
@ -954,18 +705,8 @@ secret_password_removev (const SecretSchema *schema,
|
||||
if (!_secret_attributes_validate (schema, attributes))
|
||||
return;
|
||||
|
||||
res = g_simple_async_result_new (NULL, callback, user_data,
|
||||
secret_password_removev);
|
||||
closure = g_slice_new0 (DeleteClosure);
|
||||
closure->schema = _secret_schema_ref_if_nonstatic (schema);
|
||||
closure->attributes = _secret_attributes_copy (attributes);
|
||||
closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
|
||||
g_simple_async_result_set_op_res_gpointer (res, closure, delete_closure_free);
|
||||
|
||||
secret_service_get (SECRET_SERVICE_NONE, cancellable,
|
||||
on_delete_connect, g_object_ref (res));
|
||||
|
||||
g_object_unref (res);
|
||||
secret_service_remove (NULL, schema, attributes,
|
||||
cancellable, callback, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -982,19 +723,8 @@ gboolean
|
||||
secret_password_remove_finish (GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
DeleteClosure *closure;
|
||||
GSimpleAsyncResult *res;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL,
|
||||
secret_password_removev), FALSE);
|
||||
|
||||
res = G_SIMPLE_ASYNC_RESULT (result);
|
||||
if (g_simple_async_result_propagate_error (res, error))
|
||||
return FALSE;
|
||||
|
||||
closure = g_simple_async_result_get_op_res_gpointer (res);
|
||||
return closure->deleted;
|
||||
return secret_service_remove_finish (NULL, result, error);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -653,18 +653,6 @@ _secret_service_set_default_bus_name (const gchar *bus_name)
|
||||
default_bus_name = bus_name;
|
||||
}
|
||||
|
||||
static void
|
||||
on_service_instance_gone (gpointer user_data,
|
||||
GObject *where_the_object_was)
|
||||
{
|
||||
G_LOCK (service_instance);
|
||||
|
||||
g_assert (service_instance == where_the_object_was);
|
||||
service_instance = NULL;
|
||||
|
||||
G_UNLOCK (service_instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_service_get:
|
||||
* @flags: flags for which service functionality to ensure is initialized
|
||||
@ -758,10 +746,8 @@ secret_service_get_finish (GAsyncResult *result,
|
||||
|
||||
if (service) {
|
||||
G_LOCK (service_instance);
|
||||
if (service_instance == NULL) {
|
||||
service_instance = service;
|
||||
g_object_weak_ref (G_OBJECT (service), on_service_instance_gone, NULL);
|
||||
}
|
||||
if (service_instance == NULL)
|
||||
service_instance = g_object_ref (service);
|
||||
G_UNLOCK (service_instance);
|
||||
}
|
||||
}
|
||||
@ -818,10 +804,8 @@ secret_service_get_sync (SecretServiceFlags flags,
|
||||
|
||||
if (service != NULL) {
|
||||
G_LOCK (service_instance);
|
||||
if (service_instance == NULL) {
|
||||
service_instance = service;
|
||||
g_object_weak_ref (G_OBJECT (service), on_service_instance_gone, NULL);
|
||||
}
|
||||
if (service_instance == NULL)
|
||||
service_instance = g_object_ref (service);
|
||||
G_UNLOCK (service_instance);
|
||||
}
|
||||
|
||||
@ -835,6 +819,33 @@ secret_service_get_sync (SecretServiceFlags flags,
|
||||
return service;
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_service_disconnect:
|
||||
*
|
||||
* Disconnect the default #SecretService proxy returned by secret_service_get()
|
||||
* and secret_service_get_sync().
|
||||
*
|
||||
* It is not necessary to call this function, but you may choose to do so at
|
||||
* program exit. It is useful for testing that memory is not leaked.
|
||||
*
|
||||
* This function is safe to call at any time. But if other objects in this
|
||||
* library are still referenced, then this will not result in all memory
|
||||
* being freed.
|
||||
*/
|
||||
void
|
||||
secret_service_disconnect (void)
|
||||
{
|
||||
SecretService *instance;
|
||||
|
||||
G_LOCK (service_instance);
|
||||
instance = service_instance;
|
||||
service_instance = NULL;
|
||||
G_UNLOCK (service_instance);
|
||||
|
||||
if (instance != NULL)
|
||||
g_object_unref (instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* secret_service_new:
|
||||
* @service_gtype: the GType of the new secret service
|
||||
|
@ -100,6 +100,8 @@ SecretService * secret_service_get_sync (SecretService
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_service_disconnect (void);
|
||||
|
||||
void secret_service_new (GType service_gtype,
|
||||
const gchar *service_bus_name,
|
||||
SecretServiceFlags flags,
|
||||
@ -150,59 +152,6 @@ gboolean secret_service_load_collections_sync (SecretService
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_service_search (SecretService *self,
|
||||
const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
SecretSearchFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GList * secret_service_search_finish (SecretService *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GList * secret_service_search_sync (SecretService *self,
|
||||
const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
SecretSearchFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_service_lock (SecretService *self,
|
||||
GList *objects,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gint secret_service_lock_finish (SecretService *self,
|
||||
GAsyncResult *result,
|
||||
GList **locked,
|
||||
GError **error);
|
||||
|
||||
gint secret_service_lock_sync (SecretService *self,
|
||||
GList *objects,
|
||||
GCancellable *cancellable,
|
||||
GList **locked,
|
||||
GError **error);
|
||||
|
||||
void secret_service_unlock (SecretService *self,
|
||||
GList *objects,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gint secret_service_unlock_finish (SecretService *self,
|
||||
GAsyncResult *result,
|
||||
GList **unlocked,
|
||||
GError **error);
|
||||
|
||||
gint secret_service_unlock_sync (SecretService *self,
|
||||
GList *objects,
|
||||
GCancellable *cancellable,
|
||||
GList **unlocked,
|
||||
GError **error);
|
||||
|
||||
GVariant * secret_service_prompt_sync (SecretService *self,
|
||||
SecretPrompt *prompt,
|
||||
GCancellable *cancellable,
|
||||
@ -220,7 +169,60 @@ GVariant * secret_service_prompt_finish (SecretService
|
||||
const GVariantType *return_type,
|
||||
GError **error);
|
||||
|
||||
void secret_service_store (SecretService *self,
|
||||
void secret_service_search (SecretService *service,
|
||||
const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
SecretSearchFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GList * secret_service_search_finish (SecretService *service,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GList * secret_service_search_sync (SecretService *service,
|
||||
const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
SecretSearchFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_service_lock (SecretService *service,
|
||||
GList *objects,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gint secret_service_lock_finish (SecretService *service,
|
||||
GAsyncResult *result,
|
||||
GList **locked,
|
||||
GError **error);
|
||||
|
||||
gint secret_service_lock_sync (SecretService *service,
|
||||
GList *objects,
|
||||
GCancellable *cancellable,
|
||||
GList **locked,
|
||||
GError **error);
|
||||
|
||||
void secret_service_unlock (SecretService *service,
|
||||
GList *objects,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gint secret_service_unlock_finish (SecretService *service,
|
||||
GAsyncResult *result,
|
||||
GList **unlocked,
|
||||
GError **error);
|
||||
|
||||
gint secret_service_unlock_sync (SecretService *service,
|
||||
GList *objects,
|
||||
GCancellable *cancellable,
|
||||
GList **unlocked,
|
||||
GError **error);
|
||||
|
||||
void secret_service_store (SecretService *service,
|
||||
const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
const gchar *collection_path,
|
||||
@ -230,11 +232,11 @@ void secret_service_store (SecretService
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean secret_service_store_finish (SecretService *self,
|
||||
gboolean secret_service_store_finish (SecretService *service,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean secret_service_store_sync (SecretService *self,
|
||||
gboolean secret_service_store_sync (SecretService *service,
|
||||
const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
const gchar *collection_path,
|
||||
@ -243,67 +245,67 @@ gboolean secret_service_store_sync (SecretService
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_service_lookup (SecretService *self,
|
||||
void secret_service_lookup (SecretService *service,
|
||||
const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
SecretValue * secret_service_lookup_finish (SecretService *self,
|
||||
SecretValue * secret_service_lookup_finish (SecretService *service,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
SecretValue * secret_service_lookup_sync (SecretService *self,
|
||||
SecretValue * secret_service_lookup_sync (SecretService *service,
|
||||
const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_service_remove (SecretService *self,
|
||||
void secret_service_remove (SecretService *service,
|
||||
const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean secret_service_remove_finish (SecretService *self,
|
||||
gboolean secret_service_remove_finish (SecretService *service,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean secret_service_remove_sync (SecretService *self,
|
||||
gboolean secret_service_remove_sync (SecretService *service,
|
||||
const SecretSchema *schema,
|
||||
GHashTable *attributes,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_service_read_alias (SecretService *self,
|
||||
void secret_service_read_alias (SecretService *service,
|
||||
const gchar *alias,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
SecretCollection * secret_service_read_alias_finish (SecretService *self,
|
||||
SecretCollection * secret_service_read_alias_finish (SecretService *service,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
SecretCollection * secret_service_read_alias_sync (SecretService *self,
|
||||
SecretCollection * secret_service_read_alias_sync (SecretService *service,
|
||||
const gchar *alias,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void secret_service_set_alias (SecretService *self,
|
||||
void secret_service_set_alias (SecretService *service,
|
||||
const gchar *alias,
|
||||
SecretCollection *collection,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean secret_service_set_alias_finish (SecretService *self,
|
||||
gboolean secret_service_set_alias_finish (SecretService *service,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean secret_service_set_alias_sync (SecretService *self,
|
||||
gboolean secret_service_set_alias_sync (SecretService *service,
|
||||
const gchar *alias,
|
||||
SecretCollection *collection,
|
||||
GCancellable *cancellable,
|
||||
|
@ -51,6 +51,7 @@ teardown (Test *test,
|
||||
gconstpointer unused)
|
||||
{
|
||||
g_object_unref (test->service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (test->service);
|
||||
|
||||
mock_service_stop ();
|
||||
|
@ -52,6 +52,7 @@ teardown (Test *test,
|
||||
gconstpointer unused)
|
||||
{
|
||||
g_object_unref (test->service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (test->service);
|
||||
|
||||
mock_service_stop ();
|
||||
|
@ -99,6 +99,7 @@ teardown (Test *test,
|
||||
egg_test_wait_idle ();
|
||||
|
||||
g_object_unref (test->service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (test->service);
|
||||
|
||||
teardown_mock (test, unused);
|
||||
|
@ -74,6 +74,7 @@ static void
|
||||
teardown (Test *test,
|
||||
gconstpointer unused)
|
||||
{
|
||||
secret_service_disconnect ();
|
||||
mock_service_stop ();
|
||||
}
|
||||
|
||||
|
@ -99,6 +99,7 @@ teardown (Test *test,
|
||||
egg_test_wait_idle ();
|
||||
|
||||
g_object_unref (test->service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (test->service);
|
||||
|
||||
teardown_mock (test, unused);
|
||||
|
@ -52,6 +52,7 @@ teardown (Test *test,
|
||||
gconstpointer unused)
|
||||
{
|
||||
g_object_unref (test->service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (test->service);
|
||||
|
||||
mock_service_stop ();
|
||||
|
@ -84,14 +84,16 @@ test_get_sync (void)
|
||||
g_assert (G_IS_OBJECT (service1));
|
||||
|
||||
g_object_unref (service2);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (service2);
|
||||
|
||||
/* Services were unreffed, so this should create a new one */
|
||||
/* Services were disconnected, so this should create a new one */
|
||||
service3 = secret_service_get_sync (SECRET_SERVICE_NONE, NULL, &error);
|
||||
g_assert (SECRET_IS_SERVICE (service3));
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_object_unref (service3);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (service3);
|
||||
}
|
||||
|
||||
@ -127,6 +129,7 @@ test_get_async (void)
|
||||
g_assert (G_IS_OBJECT (service1));
|
||||
|
||||
g_object_unref (service2);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (service2);
|
||||
|
||||
/* Services were unreffed, so this should create a new one */
|
||||
@ -138,6 +141,7 @@ test_get_async (void)
|
||||
g_clear_object (&result);
|
||||
|
||||
g_object_unref (service3);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (service3);
|
||||
}
|
||||
|
||||
@ -179,6 +183,7 @@ test_get_more_sync (Test *test,
|
||||
g_object_unref (service2);
|
||||
|
||||
g_object_unref (service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (service);
|
||||
}
|
||||
|
||||
@ -211,6 +216,7 @@ test_get_more_async (Test *test,
|
||||
g_list_free_full (collections, g_object_unref);
|
||||
|
||||
g_object_unref (service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (service);
|
||||
|
||||
/* Now get a session with just collections */
|
||||
@ -233,6 +239,7 @@ test_get_more_async (Test *test,
|
||||
g_list_free_full (collections, g_object_unref);
|
||||
|
||||
g_object_unref (service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (service);
|
||||
}
|
||||
|
||||
@ -430,6 +437,7 @@ test_connect_async (Test *test,
|
||||
g_assert (path == NULL);
|
||||
|
||||
g_object_unref (service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (service);
|
||||
}
|
||||
|
||||
@ -457,6 +465,7 @@ test_connect_ensure_async (Test *test,
|
||||
g_assert (path != NULL);
|
||||
|
||||
g_object_unref (service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (service);
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ teardown (Test *test,
|
||||
gconstpointer unused)
|
||||
{
|
||||
g_object_unref (test->service);
|
||||
secret_service_disconnect ();
|
||||
egg_assert_not_object (test->service);
|
||||
|
||||
mock_service_stop ();
|
||||
|
Loading…
Reference in New Issue
Block a user