aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-08-01 09:59:27 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-08-28 14:59:06 +0000
commite7409b689876488594409e945687486adb1d9514 (patch)
tree0b10be5c3d08fa5e21b22565e51b4fdfc071dcc2 /cli
parentb2979c63eb2d724512c7a96c071f3d4b422e79cb (diff)
api,modem: new 'SimSlots' and 'PrimarySimSlot' properties
The 'SimSlots' property exposes an array of SIM object paths, with one array item for each available SIM slot in the system. If a valid SIM card is found in a given slot, the path of the SIM object will be exposed in the array item; if no valid SIM card is found, the empty object path ("/") will be exposed instead. The 'PrimarySimSlot' property exposes which of the SIM slots available in the system is the one configured as being primary. In a Multi-SIM Single-Standby setup, the primary slot will be the one corresponding to the single active SIM in the system. In a Multi-SIM Multi-Standby setup, the primary slot will be the one configured to act as primary (e.g. the one that will be used for the data connection) among all the active SIM cards found.
Diffstat (limited to 'cli')
-rw-r--r--cli/mmcli-modem.c2
-rw-r--r--cli/mmcli-output.c35
-rw-r--r--cli/mmcli-output.h20
3 files changed, 48 insertions, 9 deletions
diff --git a/cli/mmcli-modem.c b/cli/mmcli-modem.c
index a25de316..2ca24495 100644
--- a/cli/mmcli-modem.c
+++ b/cli/mmcli-modem.c
@@ -475,6 +475,8 @@ print_modem_info (void)
sim_path = mm_modem_get_sim_path (ctx->modem);
mmcli_output_string (MMC_F_SIM_PATH, g_strcmp0 (sim_path, "/") != 0 ? sim_path : NULL);
+ mmcli_output_sim_slots (mm_modem_dup_sim_slot_paths (ctx->modem),
+ mm_modem_get_primary_sim_slot (ctx->modem));
bearer_paths = (const gchar **) mm_modem_get_bearer_paths (ctx->modem);
mmcli_output_string_array (MMC_F_BEARER_PATHS, (bearer_paths && bearer_paths[0]) ? bearer_paths : NULL, TRUE);
diff --git a/cli/mmcli-output.c b/cli/mmcli-output.c
index 7f68e812..ec540545 100644
--- a/cli/mmcli-output.c
+++ b/cli/mmcli-output.c
@@ -147,7 +147,9 @@ static FieldInfo field_infos[] = {
[MMC_F_CDMA_REGISTRATION_CDMA1X] = { "modem.cdma.cdma1x-registration-state", "registration cdma1x", MMC_S_MODEM_CDMA, },
[MMC_F_CDMA_REGISTRATION_EVDO] = { "modem.cdma.evdo-registration-state", "registration evdo", MMC_S_MODEM_CDMA, },
[MMC_F_CDMA_ACTIVATION] = { "modem.cdma.activation-state", "activation", MMC_S_MODEM_CDMA, },
- [MMC_F_SIM_PATH] = { "modem.generic.sim", "path", MMC_S_MODEM_SIM, },
+ [MMC_F_SIM_PATH] = { "modem.generic.sim", "primary sim path", MMC_S_MODEM_SIM, },
+ [MMC_F_SIM_PRIMARY_SLOT] = { "modem.generic.primary-sim-slot", NULL, MMC_S_MODEM_SIM, },
+ [MMC_F_SIM_SLOT_PATHS] = { "modem.generic.sim-slots", "sim slot paths", MMC_S_MODEM_SIM, },
[MMC_F_BEARER_PATHS] = { "modem.generic.bearers", "paths", MMC_S_MODEM_BEARER, },
[MMC_F_TIME_CURRENT] = { "modem.time.current", "current", MMC_S_MODEM_TIME, },
[MMC_F_TIMEZONE_CURRENT] = { "modem.timezone.current", "current", MMC_S_MODEM_TIMEZONE, },
@@ -570,6 +572,37 @@ mmcli_output_state (MMModemState state,
}
/******************************************************************************/
+/* (Custom) SIM slots output */
+
+void
+mmcli_output_sim_slots (gchar **sim_slot_paths,
+ guint primary_sim_slot)
+{
+ guint i;
+
+ if (selected_type != MMC_OUTPUT_TYPE_HUMAN || !sim_slot_paths) {
+ mmcli_output_string_take (MMC_F_SIM_PRIMARY_SLOT, primary_sim_slot ? g_strdup_printf ("%u", primary_sim_slot) : NULL);
+ mmcli_output_string_array_take (MMC_F_SIM_SLOT_PATHS, sim_slot_paths ? sim_slot_paths : NULL, TRUE);
+ return;
+ }
+
+ /* Include SIM slot number in each item */
+ for (i = 0; sim_slot_paths[i]; i++) {
+ gchar *aux;
+ guint slot_number = i + 1;
+
+ aux = g_strdup_printf ("slot %u: %s%s",
+ slot_number,
+ g_str_equal (sim_slot_paths[i], "/") ? "none" : sim_slot_paths[i],
+ (primary_sim_slot == slot_number) ? " (active)" : "");
+ g_free (sim_slot_paths[i]);
+ sim_slot_paths[i] = aux;
+ }
+
+ mmcli_output_string_array_take (MMC_F_SIM_SLOT_PATHS, sim_slot_paths, TRUE);
+}
+
+/******************************************************************************/
/* (Custom) Network scan output */
static gchar *
diff --git a/cli/mmcli-output.h b/cli/mmcli-output.h
index 0bf40a41..98702d3a 100644
--- a/cli/mmcli-output.h
+++ b/cli/mmcli-output.h
@@ -154,6 +154,8 @@ typedef enum {
MMC_F_CDMA_ACTIVATION,
/* SIM section */
MMC_F_SIM_PATH,
+ MMC_F_SIM_PRIMARY_SLOT,
+ MMC_F_SIM_SLOT_PATHS,
/* Bearer section */
MMC_F_BEARER_PATHS,
/* Time section */
@@ -338,14 +340,16 @@ void mmcli_output_listitem (MmcF field,
/******************************************************************************/
/* Custom output management */
-void mmcli_output_signal_quality (guint value,
- gboolean recent);
-void mmcli_output_state (MMModemState state,
- MMModemStateFailedReason reason);
-void mmcli_output_scan_networks (GList *network_list);
-void mmcli_output_firmware_list (GList *firmware_list,
- MMFirmwareProperties *selected);
-void mmcli_output_pco_list (GList *pco_list);
+void mmcli_output_signal_quality (guint value,
+ gboolean recent);
+void mmcli_output_state (MMModemState state,
+ MMModemStateFailedReason reason);
+void mmcli_output_sim_slots (gchar **sim_slot_paths,
+ guint primary_sim_slot);
+void mmcli_output_scan_networks (GList *network_list);
+void mmcli_output_firmware_list (GList *firmware_list,
+ MMFirmwareProperties *selected);
+void mmcli_output_pco_list (GList *pco_list);
/******************************************************************************/
/* Dump output */