aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-09-20 22:26:23 -0700
committerAleksander Morgado <aleksander@aleksander.es>2017-11-03 11:55:03 +0100
commit6bf046b6fc0b0704081a8d1e7c063d422747e839 (patch)
tree188df601f95551e1c1a5d52901191a285faca917
parent71f0fc6821fd0c5fc67f99e2588bf4e9fd5bd396 (diff)
cli: port mmcli_get_manager to GTask
-rw-r--r--cli/mmcli-common.c48
-rw-r--r--cli/mmcli-common.h12
2 files changed, 29 insertions, 31 deletions
diff --git a/cli/mmcli-common.c b/cli/mmcli-common.c
index 327031c2..dcad85a3 100644
--- a/cli/mmcli-common.c
+++ b/cli/mmcli-common.c
@@ -26,14 +26,23 @@
#include "mmcli-common.h"
+/******************************************************************************/
+/* Manager */
+
+MMManager *
+mmcli_get_manager_finish (GAsyncResult *res)
+{
+ return g_task_propagate_pointer (G_TASK (res), NULL);
+}
+
static void
manager_new_ready (GDBusConnection *connection,
- GAsyncResult *res,
- GSimpleAsyncResult *simple)
+ GAsyncResult *res,
+ GTask *task)
{
MMManager *manager;
- gchar *name_owner;
- GError *error = NULL;
+ gchar *name_owner;
+ GError *error = NULL;
manager = mm_manager_new_finish (res, &error);
if (!manager) {
@@ -51,36 +60,25 @@ manager_new_ready (GDBusConnection *connection,
g_debug ("ModemManager process found at '%s'", name_owner);
g_free (name_owner);
-
-
- g_simple_async_result_set_op_res_gpointer (simple, manager, NULL);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-}
-
-MMManager *
-mmcli_get_manager_finish (GAsyncResult *res)
-{
- return g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
+ g_task_return_pointer (task, manager, g_object_unref);
+ g_object_unref (task);
}
void
-mmcli_get_manager (GDBusConnection *connection,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+mmcli_get_manager (GDBusConnection *connection,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- GSimpleAsyncResult *result;
+ GTask *task;
+
+ task = g_task_new (connection, cancellable, callback, user_data);
- result = g_simple_async_result_new (G_OBJECT (connection),
- callback,
- user_data,
- mmcli_get_manager);
mm_manager_new (connection,
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START,
cancellable,
(GAsyncReadyCallback)manager_new_ready,
- result);
+ task);
}
MMManager *
diff --git a/cli/mmcli-common.h b/cli/mmcli-common.h
index f38429b7..b7341205 100644
--- a/cli/mmcli-common.h
+++ b/cli/mmcli-common.h
@@ -26,12 +26,12 @@
#define _LIBMM_INSIDE_MMCLI
#include <libmm-glib.h>
-void mmcli_get_manager (GDBusConnection *connection,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-MMManager *mmcli_get_manager_finish (GAsyncResult *res);
-MMManager *mmcli_get_manager_sync (GDBusConnection *connection);
+void mmcli_get_manager (GDBusConnection *connection,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+MMManager *mmcli_get_manager_finish (GAsyncResult *res);
+MMManager *mmcli_get_manager_sync (GDBusConnection *connection);
void mmcli_get_modem (GDBusConnection *connection,