aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorTeijo Kinnunen <teijo.kinnunen@uros.com>2021-02-25 16:57:16 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-02-26 12:28:01 +0100
commita4aba0a6b210b213dd631cb2f7d507b5ad187bc5 (patch)
treecae25ae0d333ce1d8400a0a84d35f1dfad3f4511 /cli
parent816beeffcb748cde1682e470620c8b26d304b13f (diff)
mmcli,sim: add preferred networks list to SIM properties
Diffstat (limited to 'cli')
-rw-r--r--cli/mmcli-output.c39
-rw-r--r--cli/mmcli-output.h22
-rw-r--r--cli/mmcli-sim.c5
3 files changed, 56 insertions, 10 deletions
diff --git a/cli/mmcli-output.c b/cli/mmcli-output.c
index 275e7066..3ef7fd12 100644
--- a/cli/mmcli-output.c
+++ b/cli/mmcli-output.c
@@ -273,6 +273,7 @@ static FieldInfo field_infos[] = {
[MMC_F_SIM_PROPERTIES_OPERATOR_ID] = { "sim.properties.operator-code", "operator id", MMC_S_SIM_PROPERTIES, },
[MMC_F_SIM_PROPERTIES_OPERATOR_NAME] = { "sim.properties.operator-name", "operator name", MMC_S_SIM_PROPERTIES, },
[MMC_F_SIM_PROPERTIES_EMERGENCY_NUMBERS] = { "sim.properties.emergency-numbers", "emergency numbers", MMC_S_SIM_PROPERTIES, },
+ [MMC_F_SIM_PROPERTIES_PREFERRED_NETWORKS] = { "sim.properties.preferred-networks", "preferred networks", MMC_S_SIM_PROPERTIES, },
[MMC_F_MODEM_LIST_DBUS_PATH] = { "modem-list", "modems", MMC_S_UNKNOWN, },
[MMC_F_SMS_LIST_DBUS_PATH] = { "modem.messaging.sms", "sms messages", MMC_S_UNKNOWN, },
[MMC_F_CALL_LIST_DBUS_PATH] = { "modem.voice.call", "calls", MMC_S_UNKNOWN, },
@@ -798,6 +799,44 @@ mmcli_output_pco_list (GList *pco_list)
}
/******************************************************************************/
+/* (Custom) Preferred networks output */
+
+void
+mmcli_output_preferred_networks (GList *preferred_nets_list)
+{
+ if (preferred_nets_list) {
+ GPtrArray *aux;
+
+ aux = g_ptr_array_new ();
+ for (;preferred_nets_list; preferred_nets_list = g_list_next (preferred_nets_list)) {
+ const MMSimPreferredNetwork *preferred_net;
+ gchar *access_technologies;
+ gchar *out;
+ const gchar *operator_code;
+
+ preferred_net = (const MMSimPreferredNetwork *)preferred_nets_list->data;
+ operator_code = mm_sim_preferred_network_get_operator_code (preferred_net);
+ access_technologies = mm_modem_access_technology_build_string_from_mask (mm_sim_preferred_network_get_access_technology (preferred_net));
+
+ if (selected_type == MMC_OUTPUT_TYPE_HUMAN)
+ out = g_strdup_printf ("%s (%s)",
+ operator_code,
+ access_technologies);
+ else
+ out = g_strdup_printf ("operator-code: %s, access-technologies: %s",
+ operator_code,
+ access_technologies);
+
+ g_ptr_array_add (aux, out);
+ g_free (access_technologies);
+ }
+ g_ptr_array_add (aux, NULL);
+
+ mmcli_output_string_array_take (MMC_F_SIM_PROPERTIES_PREFERRED_NETWORKS, (gchar **) g_ptr_array_free (aux, FALSE), TRUE);
+ }
+}
+
+/******************************************************************************/
/* Human-friendly output */
#define HUMAN_MAX_VALUE_LENGTH 60
diff --git a/cli/mmcli-output.h b/cli/mmcli-output.h
index 928bcd38..dea575b0 100644
--- a/cli/mmcli-output.h
+++ b/cli/mmcli-output.h
@@ -290,6 +290,7 @@ typedef enum {
MMC_F_SIM_PROPERTIES_OPERATOR_ID,
MMC_F_SIM_PROPERTIES_OPERATOR_NAME,
MMC_F_SIM_PROPERTIES_EMERGENCY_NUMBERS,
+ MMC_F_SIM_PROPERTIES_PREFERRED_NETWORKS,
/* Lists */
MMC_F_MODEM_LIST_DBUS_PATH,
MMC_F_SMS_LIST_DBUS_PATH,
@@ -341,16 +342,17 @@ 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_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);
+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);
+void mmcli_output_preferred_networks (GList *preferred_nets_list);
/******************************************************************************/
/* Dump output */
diff --git a/cli/mmcli-sim.c b/cli/mmcli-sim.c
index 2a1fed3a..68ae7f5d 100644
--- a/cli/mmcli-sim.c
+++ b/cli/mmcli-sim.c
@@ -158,6 +158,8 @@ mmcli_sim_shutdown (void)
static void
print_sim_info (MMSim *sim)
{
+ GList *preferred_nets_list;
+
mmcli_output_string (MMC_F_SIM_GENERAL_DBUS_PATH, mm_sim_get_path (sim));
mmcli_output_string (MMC_F_SIM_PROPERTIES_ACTIVE, mm_sim_get_active (sim) ? "yes" : "no");
mmcli_output_string (MMC_F_SIM_PROPERTIES_IMSI, mm_sim_get_imsi (sim));
@@ -166,6 +168,9 @@ print_sim_info (MMSim *sim)
mmcli_output_string (MMC_F_SIM_PROPERTIES_OPERATOR_ID, mm_sim_get_operator_identifier (sim));
mmcli_output_string (MMC_F_SIM_PROPERTIES_OPERATOR_NAME, mm_sim_get_operator_name (sim));
mmcli_output_string_array (MMC_F_SIM_PROPERTIES_EMERGENCY_NUMBERS, (const gchar **) mm_sim_get_emergency_numbers (sim), FALSE);
+ preferred_nets_list = mm_sim_get_preferred_networks (sim);
+ mmcli_output_preferred_networks (preferred_nets_list);
+ g_list_free_full (preferred_nets_list, (GDestroyNotify) mm_sim_preferred_network_free);
mmcli_output_dump ();
}