diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-01-21 12:41:15 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:55 +0100 |
commit | 72afc058bffff9753cd1cc612b01adaf4143ed5b (patch) | |
tree | 6bcbe2a0a86b24643c53004a66376924b023f588 /src | |
parent | 24c28c2692c776ded60c54766a8bdbf3c298bde1 (diff) |
sim: allow subclassing the SIM object
Plugins can subclass the MMSim object and provide custom implementations of the
actions performed by the object.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-sim.c | 23 | ||||
-rw-r--r-- | src/mm-sim.h | 32 |
2 files changed, 49 insertions, 6 deletions
diff --git a/src/mm-sim.c b/src/mm-sim.c index 2a16c36a..9daa178f 100644 --- a/src/mm-sim.c +++ b/src/mm-sim.c @@ -959,8 +959,10 @@ load_sim_identifier_ready (MMSim *self, GError *error = NULL; gchar *simid; - simid = load_sim_identifier_finish (self, res, &error); + simid = MM_SIM_GET_CLASS (ctx->self)->load_sim_identifier_finish (self, res, &error); if (!simid) { + /* TODO: make the retries gobi-specific? */ + /* Try one more time... Gobi 1K cards may reply to the first * request with '+CRSM: 106,134,""' which is bogus because * subsequent requests work fine. @@ -994,7 +996,7 @@ load_sim_identifier_ready (MMSim *self, GError *error = NULL; \ gchar *val; \ \ - val = load_##NAME##_finish (self, res, &error); \ + val = MM_SIM_GET_CLASS (ctx->self)->load_##NAME##_finish (self, res, &error); \ mm_gdbus_sim_set_##NAME (MM_GDBUS_SIM (self), val); \ g_free (val); \ \ @@ -1025,7 +1027,7 @@ interface_initialization_step (InitAsyncContext *ctx) * lifetime of the modem. Therefore, if we already have them loaded, * don't try to load them again. */ if (mm_gdbus_sim_get_sim_identifier (MM_GDBUS_SIM (ctx->self)) == NULL) { - load_sim_identifier ( + MM_SIM_GET_CLASS (ctx->self)->load_sim_identifier ( ctx->self, (GAsyncReadyCallback)load_sim_identifier_ready, ctx); @@ -1039,7 +1041,7 @@ interface_initialization_step (InitAsyncContext *ctx) * lifetime of the modem. Therefore, if we already have them loaded, * don't try to load them again. */ if (mm_gdbus_sim_get_imsi (MM_GDBUS_SIM (ctx->self)) == NULL) { - load_imsi ( + MM_SIM_GET_CLASS (ctx->self)->load_imsi ( ctx->self, (GAsyncReadyCallback)load_imsi_ready, ctx); @@ -1053,7 +1055,7 @@ interface_initialization_step (InitAsyncContext *ctx) * lifetime of the modem. Therefore, if we already have them loaded, * don't try to load them again. */ if (mm_gdbus_sim_get_operator_identifier (MM_GDBUS_SIM (ctx->self)) == NULL) { - load_operator_identifier ( + MM_SIM_GET_CLASS (ctx->self)->load_operator_identifier ( ctx->self, (GAsyncReadyCallback)load_operator_identifier_ready, ctx); @@ -1067,7 +1069,7 @@ interface_initialization_step (InitAsyncContext *ctx) * lifetime of the modem. Therefore, if we already have them loaded, * don't try to load them again. */ if (mm_gdbus_sim_get_operator_name (MM_GDBUS_SIM (ctx->self)) == NULL) { - load_operator_name ( + MM_SIM_GET_CLASS (ctx->self)->load_operator_name ( ctx->self, (GAsyncReadyCallback)load_operator_name_ready, ctx); @@ -1296,6 +1298,15 @@ mm_sim_class_init (MMSimClass *klass) object_class->finalize = finalize; object_class->dispose = dispose; + klass->load_sim_identifier = load_sim_identifier; + klass->load_sim_identifier_finish = load_sim_identifier_finish; + klass->load_imsi = load_imsi; + klass->load_imsi_finish = load_imsi_finish; + klass->load_operator_identifier = load_operator_identifier; + klass->load_operator_identifier_finish = load_operator_identifier_finish; + klass->load_operator_name = load_operator_name; + klass->load_operator_name_finish = load_operator_name_finish; + properties[PROP_CONNECTION] = g_param_spec_object (MM_SIM_CONNECTION, "Connection", diff --git a/src/mm-sim.h b/src/mm-sim.h index c969c85a..98633da5 100644 --- a/src/mm-sim.h +++ b/src/mm-sim.h @@ -49,6 +49,38 @@ struct _MMSim { struct _MMSimClass { MmGdbusSimSkeletonClass parent; + + /* Load SIM identifier (async) */ + void (* load_sim_identifier) (MMSim *self, + GAsyncReadyCallback callback, + gpointer user_data); + gchar * (* load_sim_identifier_finish) (MMSim *self, + GAsyncResult *res, + GError **error); + + /* Load IMSI (async) */ + void (* load_imsi) (MMSim *self, + GAsyncReadyCallback callback, + gpointer user_data); + gchar * (* load_imsi_finish) (MMSim *self, + GAsyncResult *res, + GError **error); + + /* Load operator identifier (async) */ + void (* load_operator_identifier) (MMSim *self, + GAsyncReadyCallback callback, + gpointer user_data); + gchar * (* load_operator_identifier_finish) (MMSim *self, + GAsyncResult *res, + GError **error); + + /* Load operator name (async) */ + void (* load_operator_name) (MMSim *self, + GAsyncReadyCallback callback, + gpointer user_data); + gchar * (* load_operator_name_finish) (MMSim *self, + GAsyncResult *res, + GError **error); }; GType mm_sim_get_type (void); |