iface-modem-time: let initialization and enabling sequences get cancelled
This commit is contained in:
@@ -6306,6 +6306,7 @@ enabling_step (EnablingContext *ctx)
|
|||||||
mm_dbg ("Modem has time capabilities, enabling the Time interface...");
|
mm_dbg ("Modem has time capabilities, enabling the Time interface...");
|
||||||
/* Enabling the Modem Time interface */
|
/* Enabling the Modem Time interface */
|
||||||
mm_iface_modem_time_enable (MM_IFACE_MODEM_TIME (ctx->self),
|
mm_iface_modem_time_enable (MM_IFACE_MODEM_TIME (ctx->self),
|
||||||
|
ctx->cancellable,
|
||||||
(GAsyncReadyCallback)iface_modem_time_enable_ready,
|
(GAsyncReadyCallback)iface_modem_time_enable_ready,
|
||||||
ctx);
|
ctx);
|
||||||
return;
|
return;
|
||||||
@@ -6671,6 +6672,7 @@ initialize_step (InitializeContext *ctx)
|
|||||||
case INITIALIZE_STEP_IFACE_TIME:
|
case INITIALIZE_STEP_IFACE_TIME:
|
||||||
/* Initialize the Time interface */
|
/* Initialize the Time interface */
|
||||||
mm_iface_modem_time_initialize (MM_IFACE_MODEM_TIME (ctx->self),
|
mm_iface_modem_time_initialize (MM_IFACE_MODEM_TIME (ctx->self),
|
||||||
|
ctx->cancellable,
|
||||||
(GAsyncReadyCallback)iface_modem_time_initialize_ready,
|
(GAsyncReadyCallback)iface_modem_time_initialize_ready,
|
||||||
ctx);
|
ctx);
|
||||||
return;
|
return;
|
||||||
|
@@ -569,11 +569,13 @@ struct _EnablingContext {
|
|||||||
MMIfaceModemTime *self;
|
MMIfaceModemTime *self;
|
||||||
EnablingStep step;
|
EnablingStep step;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
|
GCancellable *cancellable;
|
||||||
MmGdbusModemTime *skeleton;
|
MmGdbusModemTime *skeleton;
|
||||||
};
|
};
|
||||||
|
|
||||||
static EnablingContext *
|
static EnablingContext *
|
||||||
enabling_context_new (MMIfaceModemTime *self,
|
enabling_context_new (MMIfaceModemTime *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
@@ -581,6 +583,7 @@ enabling_context_new (MMIfaceModemTime *self,
|
|||||||
|
|
||||||
ctx = g_new0 (EnablingContext, 1);
|
ctx = g_new0 (EnablingContext, 1);
|
||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->cancellable = g_object_ref (cancellable);
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
@@ -600,10 +603,25 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
|||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
g_object_unref (ctx->cancellable);
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
enabling_context_complete_and_free_if_cancelled (EnablingContext *ctx)
|
||||||
|
{
|
||||||
|
if (!g_cancellable_is_cancelled (ctx->cancellable))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
g_simple_async_result_set_error (ctx->result,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_CANCELLED,
|
||||||
|
"Interface enabling cancelled");
|
||||||
|
enabling_context_complete_and_free (ctx);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mm_iface_modem_time_enable_finish (MMIfaceModemTime *self,
|
mm_iface_modem_time_enable_finish (MMIfaceModemTime *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
@@ -672,6 +690,10 @@ enable_unsolicited_events_ready (MMIfaceModemTime *self,
|
|||||||
static void
|
static void
|
||||||
interface_enabling_step (EnablingContext *ctx)
|
interface_enabling_step (EnablingContext *ctx)
|
||||||
{
|
{
|
||||||
|
/* Don't run new steps if we're cancelled */
|
||||||
|
if (enabling_context_complete_and_free_if_cancelled (ctx))
|
||||||
|
return;
|
||||||
|
|
||||||
switch (ctx->step) {
|
switch (ctx->step) {
|
||||||
case ENABLING_STEP_FIRST:
|
case ENABLING_STEP_FIRST:
|
||||||
/* Fall down to next step */
|
/* Fall down to next step */
|
||||||
@@ -741,10 +763,12 @@ interface_enabling_step (EnablingContext *ctx)
|
|||||||
|
|
||||||
void
|
void
|
||||||
mm_iface_modem_time_enable (MMIfaceModemTime *self,
|
mm_iface_modem_time_enable (MMIfaceModemTime *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
interface_enabling_step (enabling_context_new (self,
|
interface_enabling_step (enabling_context_new (self,
|
||||||
|
cancellable,
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
user_data));
|
||||||
}
|
}
|
||||||
@@ -765,11 +789,13 @@ struct _InitializationContext {
|
|||||||
MMIfaceModemTime *self;
|
MMIfaceModemTime *self;
|
||||||
MmGdbusModemTime *skeleton;
|
MmGdbusModemTime *skeleton;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
|
GCancellable *cancellable;
|
||||||
InitializationStep step;
|
InitializationStep step;
|
||||||
};
|
};
|
||||||
|
|
||||||
static InitializationContext *
|
static InitializationContext *
|
||||||
initialization_context_new (MMIfaceModemTime *self,
|
initialization_context_new (MMIfaceModemTime *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
@@ -777,6 +803,7 @@ initialization_context_new (MMIfaceModemTime *self,
|
|||||||
|
|
||||||
ctx = g_new0 (InitializationContext, 1);
|
ctx = g_new0 (InitializationContext, 1);
|
||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->cancellable = g_object_ref (cancellable);
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
@@ -795,10 +822,25 @@ initialization_context_complete_and_free (InitializationContext *ctx)
|
|||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
|
g_object_unref (ctx->cancellable);
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
initialization_context_complete_and_free_if_cancelled (InitializationContext *ctx)
|
||||||
|
{
|
||||||
|
if (!g_cancellable_is_cancelled (ctx->cancellable))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
g_simple_async_result_set_error (ctx->result,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_CANCELLED,
|
||||||
|
"Interface initialization cancelled");
|
||||||
|
initialization_context_complete_and_free (ctx);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_support_ready (MMIfaceModemTime *self,
|
check_support_ready (MMIfaceModemTime *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
@@ -829,6 +871,10 @@ check_support_ready (MMIfaceModemTime *self,
|
|||||||
static void
|
static void
|
||||||
interface_initialization_step (InitializationContext *ctx)
|
interface_initialization_step (InitializationContext *ctx)
|
||||||
{
|
{
|
||||||
|
/* Don't run new steps if we're cancelled */
|
||||||
|
if (initialization_context_complete_and_free_if_cancelled (ctx))
|
||||||
|
return;
|
||||||
|
|
||||||
switch (ctx->step) {
|
switch (ctx->step) {
|
||||||
case INITIALIZATION_STEP_FIRST:
|
case INITIALIZATION_STEP_FIRST:
|
||||||
/* Setup quarks if we didn't do it before */
|
/* Setup quarks if we didn't do it before */
|
||||||
@@ -916,6 +962,7 @@ mm_iface_modem_time_initialize_finish (MMIfaceModemTime *self,
|
|||||||
|
|
||||||
void
|
void
|
||||||
mm_iface_modem_time_initialize (MMIfaceModemTime *self,
|
mm_iface_modem_time_initialize (MMIfaceModemTime *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
@@ -937,6 +984,7 @@ mm_iface_modem_time_initialize (MMIfaceModemTime *self,
|
|||||||
|
|
||||||
/* Perform async initialization here */
|
/* Perform async initialization here */
|
||||||
interface_initialization_step (initialization_context_new (self,
|
interface_initialization_step (initialization_context_new (self,
|
||||||
|
cancellable,
|
||||||
callback,
|
callback,
|
||||||
user_data));
|
user_data));
|
||||||
g_object_unref (skeleton);
|
g_object_unref (skeleton);
|
||||||
|
@@ -94,6 +94,7 @@ GType mm_iface_modem_time_get_type (void);
|
|||||||
|
|
||||||
/* Initialize Time interface (async) */
|
/* Initialize Time interface (async) */
|
||||||
void mm_iface_modem_time_initialize (MMIfaceModemTime *self,
|
void mm_iface_modem_time_initialize (MMIfaceModemTime *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
gboolean mm_iface_modem_time_initialize_finish (MMIfaceModemTime *self,
|
gboolean mm_iface_modem_time_initialize_finish (MMIfaceModemTime *self,
|
||||||
@@ -102,6 +103,7 @@ gboolean mm_iface_modem_time_initialize_finish (MMIfaceModemTime *self,
|
|||||||
|
|
||||||
/* Enable Time interface (async) */
|
/* Enable Time interface (async) */
|
||||||
void mm_iface_modem_time_enable (MMIfaceModemTime *self,
|
void mm_iface_modem_time_enable (MMIfaceModemTime *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
gboolean mm_iface_modem_time_enable_finish (MMIfaceModemTime *self,
|
gboolean mm_iface_modem_time_enable_finish (MMIfaceModemTime *self,
|
||||||
|
Reference in New Issue
Block a user