[PATCH 3/3] libmm-glib,manager: port mm_manager_scan_devices to use GTask

Aleksander Morgado aleksander at aleksander.es
Fri Jun 23 08:33:51 UTC 2017


On 23/06/17 10:12, Ben Chan wrote:
> ---
>  libmm-glib/mm-manager.c | 25 ++++++++++---------------
>  1 file changed, 10 insertions(+), 15 deletions(-)
> 

Pushed to git master, thanks!

> diff --git a/libmm-glib/mm-manager.c b/libmm-glib/mm-manager.c
> index 9f71414b..2fc08cbb 100644
> --- a/libmm-glib/mm-manager.c
> +++ b/libmm-glib/mm-manager.c
> @@ -392,13 +392,13 @@ mm_manager_scan_devices_finish (MMManager     *manager,
>                                  GAsyncResult  *res,
>                                  GError       **error)
>  {
> -    return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
> +    return g_task_propagate_boolean (G_TASK (res), error);
>  }
>  
>  static void
>  scan_devices_ready (MmGdbusOrgFreedesktopModemManager1 *manager_iface_proxy,
>                      GAsyncResult                       *res,
> -                    GSimpleAsyncResult                 *simple)
> +                    GTask                              *task)
>  {
>      GError *error = NULL;
>  
> @@ -406,12 +406,11 @@ scan_devices_ready (MmGdbusOrgFreedesktopModemManager1 *manager_iface_proxy,
>              manager_iface_proxy,
>              res,
>              &error))
> -        g_simple_async_result_take_error (simple, error);
> +        g_task_return_error (task, error);
>      else
> -        g_simple_async_result_set_op_res_gboolean (simple, TRUE);
> +        g_task_return_boolean (task, TRUE);
>  
> -    g_simple_async_result_complete (simple);
> -    g_object_unref (simple);
> +    g_object_unref (task);
>  }
>  
>  /**
> @@ -436,20 +435,16 @@ mm_manager_scan_devices (MMManager           *manager,
>                           GAsyncReadyCallback  callback,
>                           gpointer             user_data)
>  {
> -    GSimpleAsyncResult *result;
> +    GTask *task;
>      GError *inner_error = NULL;
>  
>      g_return_if_fail (MM_IS_MANAGER (manager));
>  
> -    result = g_simple_async_result_new (G_OBJECT (manager),
> -                                        callback,
> -                                        user_data,
> -                                        mm_manager_scan_devices);
> +    task = g_task_new (manager, cancellable, callback, user_data);
>  
>      if (!ensure_modem_manager1_proxy (manager, &inner_error)) {
> -        g_simple_async_result_take_error (result, inner_error);
> -        g_simple_async_result_complete_in_idle (result);
> -        g_object_unref (result);
> +        g_task_return_error (task, inner_error);
> +        g_object_unref (task);
>          return;
>      }
>  
> @@ -457,7 +452,7 @@ mm_manager_scan_devices (MMManager           *manager,
>          manager->priv->manager_iface_proxy,
>          cancellable,
>          (GAsyncReadyCallback)scan_devices_ready,
> -        result);
> +        task);
>  }
>  
>  /**
> 


-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list