diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2011-12-30 23:47:39 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:41 +0100 |
commit | ba5321adf153bed36a3328b6178e3746c17140ce (patch) | |
tree | 55148458d97f5ff7752eb98ad8ba56140f05c0ea /src | |
parent | 7d2626ea4495ffaac5a180ae167fe264b355c990 (diff) |
iface-modem: let different SIM object creation implementations
We let objects implementing the Modem interface to provide their own SIM
creation method. This allows plugins to subclass MMSim themselves.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-iface-modem.c | 69 | ||||
-rw-r--r-- | src/mm-iface-modem.h | 9 |
2 files changed, 47 insertions, 31 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index cd9f4fe7..97c50c24 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -2426,22 +2426,25 @@ sim_new_ready (GAsyncInitable *initable, MMSim *sim; GError *error = NULL; - sim = mm_sim_new_finish (initable, res, &error); + sim = MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim_finish (ctx->self, res, &error); if (!sim) { + /* FATAL */ mm_warn ("couldn't create SIM: '%s'", error ? error->message : "Unknown error"); - g_clear_error (&error); - } else { - g_object_bind_property (sim, MM_SIM_PATH, - ctx->skeleton, "sim", - G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); - - g_object_set (ctx->self, - MM_IFACE_MODEM_SIM, sim, - NULL); - g_object_unref (sim); + g_simple_async_result_take_error (ctx->result, error); + initialization_context_complete_and_free (ctx); + return; } + g_object_bind_property (sim, MM_SIM_PATH, + ctx->skeleton, "sim", + G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); + + g_object_set (ctx->self, + MM_IFACE_MODEM_SIM, sim, + NULL); + g_object_unref (sim); + /* Go on to next step */ ctx->step++; interface_initialization_step (ctx); @@ -2685,30 +2688,34 @@ interface_initialization_step (InitializationContext *ctx) /* Fall down to next step */ ctx->step++; - case INITIALIZATION_STEP_SIM: { - MMSim *sim = NULL; + case INITIALIZATION_STEP_SIM: + /* If the modem doesn't need any SIM, skip */ + if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim && + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim_finish) { + MMSim *sim = NULL; - g_object_get (ctx->self, - MM_IFACE_MODEM_SIM, &sim, - NULL); - if (!sim) { - mm_sim_new (MM_BASE_MODEM (ctx->self), - NULL, /* TODO: cancellable */ - (GAsyncReadyCallback)sim_new_ready, - ctx); + g_object_get (ctx->self, + MM_IFACE_MODEM_SIM, &sim, + NULL); + if (!sim) { + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim ( + MM_IFACE_MODEM (ctx->self), + (GAsyncReadyCallback)sim_new_ready, + ctx); + return; + } + + /* If already available the sim object, relaunch initialization. + * This will try to load any missing property value that couldn't be + * retrieved before due to having the SIM locked. */ + mm_sim_initialize (sim, + NULL, /* TODO: cancellable */ + (GAsyncReadyCallback)sim_reinit_ready, + ctx); + g_object_unref (sim); return; } - /* If already available the sim object, relaunch initialization. - * This will try to load any missing property value that couldn't be - * retrieved before due to having the SIM locked. */ - mm_sim_initialize (sim, - NULL, /* TODO: cancellable */ - (GAsyncReadyCallback)sim_reinit_ready, - ctx); - return; - } - case INITIALIZATION_STEP_SUPPORTED_MODES: g_assert (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_supported_modes != NULL); g_assert (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_supported_modes_finish != NULL); diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h index 4a82cbb8..e86b0da6 100644 --- a/src/mm-iface-modem.h +++ b/src/mm-iface-modem.h @@ -22,6 +22,7 @@ #include "mm-charsets.h" #include "mm-at-serial-port.h" #include "mm-bearer.h" +#include "mm-sim.h" #define MM_TYPE_IFACE_MODEM (mm_iface_modem_get_type ()) #define MM_IFACE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_MODEM, MMIfaceModem)) @@ -253,6 +254,14 @@ struct _MMIfaceModem { GAsyncResult *res, GError **error); + /* Create SIM */ + void (*create_sim) (MMIfaceModem *self, + GAsyncReadyCallback callback, + gpointer user_data); + MMSim * (*create_sim_finish) (MMIfaceModem *self, + GAsyncResult *res, + GError **error); + /* Create bearer */ void (*create_bearer) (MMIfaceModem *self, MMCommonBearerProperties *properties, |