sim: allow re-launching initialization
It may happen that we cannot load property values when the SIM is locked, so we need to enable re-launching initialization in the object API.
This commit is contained in:
53
src/mm-sim.c
53
src/mm-sim.c
@@ -746,28 +746,22 @@ interface_initialization_step (InitAsyncContext *ctx)
|
||||
interface_initialization_step (ctx);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
initable_init_async (GAsyncInitable *initable,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
common_init_async (GAsyncInitable *initable,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
|
||||
{
|
||||
InitAsyncContext *ctx;
|
||||
GError *error = NULL;
|
||||
|
||||
mm_gdbus_sim_set_sim_identifier (MM_GDBUS_SIM (initable), NULL);
|
||||
mm_gdbus_sim_set_imsi (MM_GDBUS_SIM (initable), NULL);
|
||||
mm_gdbus_sim_set_operator_identifier (MM_GDBUS_SIM (initable), NULL);
|
||||
mm_gdbus_sim_set_operator_name (MM_GDBUS_SIM (initable), NULL);
|
||||
|
||||
ctx = g_new (InitAsyncContext, 1);
|
||||
ctx->self = g_object_ref (initable);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (initable),
|
||||
callback,
|
||||
user_data,
|
||||
initable_init_async);
|
||||
common_init_async);
|
||||
ctx->cancellable = (cancellable ?
|
||||
g_object_ref (cancellable) :
|
||||
NULL);
|
||||
@@ -785,6 +779,21 @@ initable_init_async (GAsyncInitable *initable,
|
||||
interface_initialization_step (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
initable_init_async (GAsyncInitable *initable,
|
||||
int io_priority,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_gdbus_sim_set_sim_identifier (MM_GDBUS_SIM (initable), NULL);
|
||||
mm_gdbus_sim_set_imsi (MM_GDBUS_SIM (initable), NULL);
|
||||
mm_gdbus_sim_set_operator_identifier (MM_GDBUS_SIM (initable), NULL);
|
||||
mm_gdbus_sim_set_operator_name (MM_GDBUS_SIM (initable), NULL);
|
||||
|
||||
common_init_async (initable, cancellable, callback, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
mm_sim_new (MMBaseModem *modem,
|
||||
GCancellable *cancellable,
|
||||
@@ -807,6 +816,26 @@ mm_sim_new (MMBaseModem *modem,
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_sim_initialize_finish (MMSim *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
return initable_init_finish (G_ASYNC_INITABLE (self), result, error);
|
||||
}
|
||||
|
||||
void
|
||||
mm_sim_initialize (MMSim *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
common_init_async (G_ASYNC_INITABLE (self),
|
||||
cancellable,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint prop_id,
|
||||
|
@@ -58,6 +58,13 @@ MMSim *mm_sim_new_finish (GAsyncInitable *initable,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
void mm_sim_initialize (MMSim *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_sim_initialize_finish (MMSim *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
#endif /* MM_SIM_H */
|
||||
|
||||
|
Reference in New Issue
Block a user