From 18084f89394491d4a363a90354000c55af1490c8 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sat, 1 Aug 2020 09:59:21 +0200 Subject: [PATCH] base-sim: allow creating preinitialized SIM objects The default SIM creation method will attempt to initialize the SIM properties during the object creation. This new method allows creating SIM objects with already known property values, and therefore not explicitly running the asynchronous initialization process. --- src/mm-base-sim.c | 29 +++++++++++++++++++++++++++++ src/mm-base-sim.h | 9 +++++++++ 2 files changed, 38 insertions(+) diff --git a/src/mm-base-sim.c b/src/mm-base-sim.c index bb681c36..cc61a603 100644 --- a/src/mm-base-sim.c +++ b/src/mm-base-sim.c @@ -1466,6 +1466,35 @@ load_operator_name (MMBaseSim *self, /*****************************************************************************/ +MMBaseSim * +mm_base_sim_new_initialized (MMBaseModem *modem, + guint slot_number, + gboolean active, + const gchar *sim_identifier, + const gchar *imsi, + const gchar *operator_identifier, + const gchar *operator_name, + const GStrv emergency_numbers) +{ + MMBaseSim *sim; + + sim = MM_BASE_SIM (g_object_new (MM_TYPE_BASE_SIM, + MM_BASE_SIM_MODEM, modem, + MM_BASE_SIM_SLOT_NUMBER, slot_number, + "active", active, + "sim-identifier", sim_identifier, + "imsi", imsi, + "operator-identifier", operator_identifier, + "operator-name", operator_name, + "emergency-numbers", emergency_numbers, + NULL)); + + mm_base_sim_export (sim); + return sim; +} + +/*****************************************************************************/ + typedef struct _InitAsyncContext InitAsyncContext; static void interface_initialization_step (GTask *task); diff --git a/src/mm-base-sim.h b/src/mm-base-sim.h index 7a4a1faa..d9457f11 100644 --- a/src/mm-base-sim.h +++ b/src/mm-base-sim.h @@ -153,6 +153,15 @@ gboolean mm_base_sim_initialize_finish (MMBaseSim *self, GAsyncResult *result, GError **error); +MMBaseSim *mm_base_sim_new_initialized (MMBaseModem *modem, + guint slot_number, + gboolean active, + const gchar *sim_identifier, + const gchar *imsi, + const gchar *operator_identifier, + const gchar *operator_name, + const GStrv emergency_numbers); + void mm_base_sim_send_pin (MMBaseSim *self, const gchar *pin, GAsyncReadyCallback callback,