diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-base-sim.c | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/src/mm-base-sim.c b/src/mm-base-sim.c index 59af3a88..8c26b748 100644 --- a/src/mm-base-sim.c +++ b/src/mm-base-sim.c @@ -2293,38 +2293,53 @@ initable_init_finish (GAsyncInitable *initable, return g_task_propagate_boolean (G_TASK (result), error); } +#undef STR_REPLY_READY_FN +#define STR_REPLY_READY_FN(NAME,DISPLAY) \ + static void \ + init_load_##NAME##_ready (MMBaseSim *self, \ + GAsyncResult *res, \ + GTask *task) \ + { \ + InitAsyncContext *ctx; \ + GError *error = NULL; \ + gchar *val; \ + \ + val = MM_BASE_SIM_GET_CLASS (self)->load_##NAME##_finish (self, res, &error); \ + mm_gdbus_sim_set_##NAME (MM_GDBUS_SIM (self), val); \ + g_free (val); \ + \ + if (error) { \ + mm_obj_warn (self, "couldn't load %s: %s", DISPLAY, error->message); \ + g_error_free (error); \ + } \ + \ + /* Go on to next step */ \ + ctx = g_task_get_task_data (task); \ + ctx->step++; \ + interface_initialization_step (task); \ + } + static void -init_load_sim_identifier_ready (MMBaseSim *self, - GAsyncResult *res, - GTask *task) +init_load_preferred_networks_ready (MMBaseSim *self, + GAsyncResult *res, + GTask *task) { InitAsyncContext *ctx; - GError *error = NULL; - gchar *simid; - - ctx = g_task_get_task_data (task); - simid = MM_BASE_SIM_GET_CLASS (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. - */ - if (++ctx->sim_identifier_tries < 2) { - g_clear_error (&error); - interface_initialization_step (task); - return; - } + GError *error = NULL; + GList *preferred_nets_list; - mm_obj_warn (self, "couldn't load SIM identifier: %s", error ? error->message : "unknown error"); - g_clear_error (&error); + preferred_nets_list = MM_BASE_SIM_GET_CLASS (self)->load_preferred_networks_finish (self, res, &error); + if (error) { + mm_obj_warn (self, "couldn't load list of preferred networks: %s", error->message); + g_error_free (error); } - mm_gdbus_sim_set_sim_identifier (MM_GDBUS_SIM (self), simid); - g_free (simid); + mm_gdbus_sim_set_preferred_networks (MM_GDBUS_SIM (self), + mm_sim_preferred_network_list_get_variant (preferred_nets_list)); + g_list_free_full (preferred_nets_list, (GDestroyNotify) mm_sim_preferred_network_free); /* Go on to next step */ + ctx = g_task_get_task_data (task); ctx->step++; interface_initialization_step (task); } @@ -2355,62 +2370,47 @@ init_load_emergency_numbers_ready (MMBaseSim *self, interface_initialization_step (task); } +STR_REPLY_READY_FN (operator_name, "operator name") +STR_REPLY_READY_FN (operator_identifier, "operator identifier") +STR_REPLY_READY_FN (eid, "EID") +STR_REPLY_READY_FN (imsi, "IMSI") + static void -init_load_preferred_networks_ready (MMBaseSim *self, - GAsyncResult *res, - GTask *task) +init_load_sim_identifier_ready (MMBaseSim *self, + GAsyncResult *res, + GTask *task) { InitAsyncContext *ctx; - GError *error = NULL; - GList *preferred_nets_list; + GError *error = NULL; + gchar *simid; - preferred_nets_list = MM_BASE_SIM_GET_CLASS (self)->load_preferred_networks_finish (self, res, &error); - if (error) { - mm_obj_warn (self, "couldn't load list of preferred networks: %s", error->message); - g_error_free (error); + ctx = g_task_get_task_data (task); + simid = MM_BASE_SIM_GET_CLASS (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. + */ + if (++ctx->sim_identifier_tries < 2) { + g_clear_error (&error); + interface_initialization_step (task); + return; + } + + mm_obj_warn (self, "couldn't load SIM identifier: %s", error ? error->message : "unknown error"); + g_clear_error (&error); } - mm_gdbus_sim_set_preferred_networks (MM_GDBUS_SIM (self), - mm_sim_preferred_network_list_get_variant (preferred_nets_list)); - g_list_free_full (preferred_nets_list, (GDestroyNotify) mm_sim_preferred_network_free); + mm_gdbus_sim_set_sim_identifier (MM_GDBUS_SIM (self), simid); + g_free (simid); /* Go on to next step */ - ctx = g_task_get_task_data (task); ctx->step++; interface_initialization_step (task); } -#undef STR_REPLY_READY_FN -#define STR_REPLY_READY_FN(NAME,DISPLAY) \ - static void \ - init_load_##NAME##_ready (MMBaseSim *self, \ - GAsyncResult *res, \ - GTask *task) \ - { \ - InitAsyncContext *ctx; \ - GError *error = NULL; \ - gchar *val; \ - \ - val = MM_BASE_SIM_GET_CLASS (self)->load_##NAME##_finish (self, res, &error); \ - mm_gdbus_sim_set_##NAME (MM_GDBUS_SIM (self), val); \ - g_free (val); \ - \ - if (error) { \ - mm_obj_warn (self, "couldn't load %s: %s", DISPLAY, error->message); \ - g_error_free (error); \ - } \ - \ - /* Go on to next step */ \ - ctx = g_task_get_task_data (task); \ - ctx->step++; \ - interface_initialization_step (task); \ - } - -STR_REPLY_READY_FN (imsi, "IMSI") -STR_REPLY_READY_FN (eid, "EID") -STR_REPLY_READY_FN (operator_identifier, "operator identifier") -STR_REPLY_READY_FN (operator_name, "operator name") - static void init_wait_sim_ready (MMBaseSim *self, GAsyncResult *res, |