collection: remove deprecated GSimpleAsyncResult

It was deprecated in favor of `GTask` some time ago in GLib.
This commit is contained in:
Niels De Graef 2019-01-18 08:56:40 +01:00
parent 5f24b4521b
commit 4d0a29ce3d

View File

@ -571,18 +571,6 @@ secret_collection_initable_iface (GInitableIface *iface)
iface->init = secret_collection_initable_init; iface->init = secret_collection_initable_init;
} }
typedef struct {
GCancellable *cancellable;
} InitClosure;
static void
init_closure_free (gpointer data)
{
InitClosure *closure = data;
g_clear_object (&closure->cancellable);
g_slice_free (InitClosure, closure);
}
static void static void
on_ensure_items (GObject *source, on_ensure_items (GObject *source,
GAsyncResult *result, GAsyncResult *result,
@ -625,7 +613,7 @@ on_init_service (GObject *source,
{ {
GSimpleAsyncResult *async = G_SIMPLE_ASYNC_RESULT (user_data); GSimpleAsyncResult *async = G_SIMPLE_ASYNC_RESULT (user_data);
SecretCollection *self = SECRET_COLLECTION (g_async_result_get_source_object (user_data)); SecretCollection *self = SECRET_COLLECTION (g_async_result_get_source_object (user_data));
InitClosure *init = g_simple_async_result_get_op_res_gpointer (async); /* InitClosure *init = g_simple_async_result_get_op_res_gpointer (async); */
SecretService *service; SecretService *service;
GError *error = NULL; GError *error = NULL;
@ -651,7 +639,7 @@ on_init_base (GObject *source,
{ {
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data); GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
SecretCollection *self = SECRET_COLLECTION (source); SecretCollection *self = SECRET_COLLECTION (source);
InitClosure *init = 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); GDBusProxy *proxy = G_DBUS_PROXY (self);
GError *error = NULL; GError *error = NULL;
@ -685,21 +673,15 @@ secret_collection_async_initable_init_async (GAsyncInitable *initable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *res; g_autoptr(GTask) res = NULL;
InitClosure *closure;
res = g_simple_async_result_new (G_OBJECT (initable), callback, user_data, res = g_task_new (G_OBJECT (initable), cancellable, callback, user_data);
secret_collection_async_initable_init_async);
closure = g_slice_new0 (InitClosure);
closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
g_simple_async_result_set_op_res_gpointer (res, closure, init_closure_free);
secret_collection_async_initable_parent_iface->init_async (initable, io_priority, secret_collection_async_initable_parent_iface->init_async (initable,
io_priority,
cancellable, cancellable,
on_init_base, on_init_base,
g_object_ref (res)); g_steal_pointer (&res));
g_object_unref (res);
} }
static gboolean static gboolean
@ -709,11 +691,13 @@ secret_collection_async_initable_init_finish (GAsyncInitable *initable,
{ {
SecretCollection *self = SECRET_COLLECTION (initable); SecretCollection *self = SECRET_COLLECTION (initable);
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (initable), g_return_val_if_fail (g_task_is_valid (result, G_OBJECT (initable)), FALSE);
secret_collection_async_initable_init_async), FALSE);
if (_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error)) if (error && *error) {
_secret_util_strip_remote_error (error);
g_task_return_error (G_TASK (result), g_steal_pointer (&error));
return FALSE; return FALSE;
}
self->pv->constructing = FALSE; self->pv->constructing = FALSE;
return TRUE; return TRUE;