diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-11-20 22:11:49 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-12-11 12:53:37 +0100 |
commit | 83ebc2b4a8ba80bbd291aabb4ee9c9410cac71da (patch) | |
tree | b47621a9f869c60d8d263117fbdac8f714948536 | |
parent | 8cfddef2be31556e4f11eebeed071d8d14c8337b (diff) |
base-sim: new 'SimType', 'Removability' and 'EsimStatus' properties
We implement the methods to load the properties during SIM object
initialization.
-rw-r--r-- | src/mm-base-sim.c | 66 | ||||
-rw-r--r-- | src/mm-base-sim.h | 24 |
2 files changed, 90 insertions, 0 deletions
diff --git a/src/mm-base-sim.c b/src/mm-base-sim.c index 8c26b748..22b54ba1 100644 --- a/src/mm-base-sim.c +++ b/src/mm-base-sim.c @@ -2257,6 +2257,9 @@ typedef enum { INITIALIZATION_STEP_OPERATOR_NAME, INITIALIZATION_STEP_EMERGENCY_NUMBERS, INITIALIZATION_STEP_PREFERRED_NETWORKS, + INITIALIZATION_STEP_SIM_TYPE, + INITIALIZATION_STEP_ESIM_STATUS, + INITIALIZATION_STEP_REMOVABILITY, INITIALIZATION_STEP_LAST } InitializationStep; @@ -2319,6 +2322,33 @@ initable_init_finish (GAsyncInitable *initable, interface_initialization_step (task); \ } +#undef UINT_REPLY_READY_FN +#define UINT_REPLY_READY_FN(NAME,DISPLAY) \ + static void \ + init_load_##NAME##_ready (MMBaseSim *self, \ + GAsyncResult *res, \ + GTask *task) \ + { \ + InitAsyncContext *ctx; \ + g_autoptr(GError) error = NULL; \ + guint val; \ + \ + val = (guint) MM_BASE_SIM_GET_CLASS (self)->load_##NAME##_finish (self, res, &error); \ + mm_gdbus_sim_set_##NAME (MM_GDBUS_SIM (self), val); \ + \ + if (error) \ + mm_obj_warn (self, "couldn't load %s: %s", DISPLAY, error->message); \ + \ + /* Go on to next step */ \ + ctx = g_task_get_task_data (task); \ + ctx->step++; \ + interface_initialization_step (task); \ + } + +UINT_REPLY_READY_FN (removability, "removability") +UINT_REPLY_READY_FN (esim_status, "esim status") +UINT_REPLY_READY_FN (sim_type, "sim type") + static void init_load_preferred_networks_ready (MMBaseSim *self, GAsyncResult *res, @@ -2567,6 +2597,42 @@ interface_initialization_step (GTask *task) ctx->step++; /* Fall through */ + case INITIALIZATION_STEP_SIM_TYPE: + if (MM_BASE_SIM_GET_CLASS (self)->load_sim_type && + MM_BASE_SIM_GET_CLASS (self)->load_sim_type_finish) { + MM_BASE_SIM_GET_CLASS (self)->load_sim_type ( + self, + (GAsyncReadyCallback)init_load_sim_type_ready, + task); + return; + } + ctx->step++; + /* Fall through */ + + case INITIALIZATION_STEP_ESIM_STATUS: + if (MM_BASE_SIM_GET_CLASS (self)->load_esim_status && + MM_BASE_SIM_GET_CLASS (self)->load_esim_status_finish) { + MM_BASE_SIM_GET_CLASS (self)->load_esim_status ( + self, + (GAsyncReadyCallback)init_load_esim_status_ready, + task); + return; + } + ctx->step++; + /* Fall through */ + + case INITIALIZATION_STEP_REMOVABILITY: + if (MM_BASE_SIM_GET_CLASS (self)->load_removability && + MM_BASE_SIM_GET_CLASS (self)->load_removability_finish) { + MM_BASE_SIM_GET_CLASS (self)->load_removability ( + self, + (GAsyncReadyCallback)init_load_removability_ready, + task); + return; + } + ctx->step++; + /* Fall through */ + case INITIALIZATION_STEP_LAST: /* We are done without errors! */ g_task_return_boolean (task, TRUE); diff --git a/src/mm-base-sim.h b/src/mm-base-sim.h index 6f6418c9..8eb393f7 100644 --- a/src/mm-base-sim.h +++ b/src/mm-base-sim.h @@ -116,6 +116,30 @@ struct _MMBaseSimClass { GAsyncResult *res, GError **error); + /* Load sim type (async) */ + void (* load_sim_type) (MMBaseSim *self, + GAsyncReadyCallback callback, + gpointer user_data); + MMSimType (* load_sim_type_finish) (MMBaseSim *self, + GAsyncResult *res, + GError **error); + + /* Load esim status (async) */ + void (* load_esim_status) (MMBaseSim *self, + GAsyncReadyCallback callback, + gpointer user_data); + MMSimEsimStatus (* load_esim_status_finish) (MMBaseSim *self, + GAsyncResult *res, + GError **error); + + /* Load removabilitu (async) */ + void (* load_removability) (MMBaseSim *self, + GAsyncReadyCallback callback, + gpointer user_data); + MMSimRemovability (* load_removability_finish) (MMBaseSim *self, + GAsyncResult *res, + GError **error); + /* Change PIN (async) */ void (* change_pin) (MMBaseSim *self, const gchar *old_pin, |