cli: port mmcli_get_manager to GTask
This commit is contained in:
@@ -26,14 +26,23 @@
|
|||||||
|
|
||||||
#include "mmcli-common.h"
|
#include "mmcli-common.h"
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* Manager */
|
||||||
|
|
||||||
|
MMManager *
|
||||||
|
mmcli_get_manager_finish (GAsyncResult *res)
|
||||||
|
{
|
||||||
|
return g_task_propagate_pointer (G_TASK (res), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
manager_new_ready (GDBusConnection *connection,
|
manager_new_ready (GDBusConnection *connection,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *simple)
|
GTask *task)
|
||||||
{
|
{
|
||||||
MMManager *manager;
|
MMManager *manager;
|
||||||
gchar *name_owner;
|
gchar *name_owner;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
manager = mm_manager_new_finish (res, &error);
|
manager = mm_manager_new_finish (res, &error);
|
||||||
if (!manager) {
|
if (!manager) {
|
||||||
@@ -51,36 +60,25 @@ manager_new_ready (GDBusConnection *connection,
|
|||||||
g_debug ("ModemManager process found at '%s'", name_owner);
|
g_debug ("ModemManager process found at '%s'", name_owner);
|
||||||
g_free (name_owner);
|
g_free (name_owner);
|
||||||
|
|
||||||
|
g_task_return_pointer (task, manager, g_object_unref);
|
||||||
|
g_object_unref (task);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mmcli_get_manager (GDBusConnection *connection,
|
mmcli_get_manager (GDBusConnection *connection,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
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,
|
mm_manager_new (connection,
|
||||||
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START,
|
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START,
|
||||||
cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback)manager_new_ready,
|
(GAsyncReadyCallback)manager_new_ready,
|
||||||
result);
|
task);
|
||||||
}
|
}
|
||||||
|
|
||||||
MMManager *
|
MMManager *
|
||||||
|
@@ -26,12 +26,12 @@
|
|||||||
#define _LIBMM_INSIDE_MMCLI
|
#define _LIBMM_INSIDE_MMCLI
|
||||||
#include <libmm-glib.h>
|
#include <libmm-glib.h>
|
||||||
|
|
||||||
void mmcli_get_manager (GDBusConnection *connection,
|
void mmcli_get_manager (GDBusConnection *connection,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
MMManager *mmcli_get_manager_finish (GAsyncResult *res);
|
MMManager *mmcli_get_manager_finish (GAsyncResult *res);
|
||||||
MMManager *mmcli_get_manager_sync (GDBusConnection *connection);
|
MMManager *mmcli_get_manager_sync (GDBusConnection *connection);
|
||||||
|
|
||||||
|
|
||||||
void mmcli_get_modem (GDBusConnection *connection,
|
void mmcli_get_modem (GDBusConnection *connection,
|
||||||
|
Reference in New Issue
Block a user