hso: port modem_create_bearer to use GTask
This commit is contained in:

committed by
Aleksander Morgado

parent
d23dd2343a
commit
0131f9b006
@@ -62,52 +62,41 @@ modem_create_bearer_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
MMBaseBearer *bearer;
|
||||
|
||||
bearer = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
|
||||
mm_dbg ("New %s bearer created at DBus path '%s'",
|
||||
MM_IS_BROADBAND_BEARER_HSO (bearer) ? "HSO" : "Generic",
|
||||
mm_base_bearer_get_path (bearer));
|
||||
|
||||
return g_object_ref (bearer);
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
broadband_bearer_new_ready (GObject *source,
|
||||
GAsyncResult *res,
|
||||
GSimpleAsyncResult *simple)
|
||||
GTask *task)
|
||||
{
|
||||
MMBaseBearer *bearer = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
bearer = mm_broadband_bearer_new_finish (res, &error);
|
||||
if (!bearer)
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_simple_async_result_set_op_res_gpointer (simple,
|
||||
bearer,
|
||||
g_object_unref);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
g_task_return_pointer (task, bearer, g_object_unref);
|
||||
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
broadband_bearer_hso_new_ready (GObject *source,
|
||||
GAsyncResult *res,
|
||||
GSimpleAsyncResult *simple)
|
||||
GTask *task)
|
||||
{
|
||||
MMBaseBearer *bearer = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
bearer = mm_broadband_bearer_hso_new_finish (res, &error);
|
||||
if (!bearer)
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_simple_async_result_set_op_res_gpointer (simple,
|
||||
bearer,
|
||||
g_object_unref);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
g_task_return_pointer (task, bearer, g_object_unref);
|
||||
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -116,12 +105,9 @@ modem_create_bearer (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *result;
|
||||
GTask *task;
|
||||
|
||||
result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
modem_create_bearer);
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
if (mm_bearer_properties_get_ip_type (properties) &
|
||||
(MM_BEARER_IP_FAMILY_IPV6 | MM_BEARER_IP_FAMILY_IPV4V6)) {
|
||||
@@ -130,7 +116,7 @@ modem_create_bearer (MMIfaceModem *self,
|
||||
properties,
|
||||
NULL, /* cancellable */
|
||||
(GAsyncReadyCallback)broadband_bearer_new_ready,
|
||||
result);
|
||||
task);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,7 +125,7 @@ modem_create_bearer (MMIfaceModem *self,
|
||||
properties,
|
||||
NULL, /* cancellable */
|
||||
(GAsyncReadyCallback)broadband_bearer_hso_new_ready,
|
||||
result);
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
Reference in New Issue
Block a user