aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-08-01 09:59:21 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-08-28 14:59:06 +0000
commit18084f89394491d4a363a90354000c55af1490c8 (patch)
treec9493a2956c979faf9a438f34bbca263146aee48
parentc999c8e9cf54a6ef34b16325c32a03aa1e31db2d (diff)
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.
-rw-r--r--src/mm-base-sim.c29
-rw-r--r--src/mm-base-sim.h9
2 files changed, 38 insertions, 0 deletions
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,