aboutsummaryrefslogtreecommitdiff
path: root/cli/mmcli-output.c
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/mmcli-output.c
parent816beeffcb748cde1682e470620c8b26d304b13f (diff)
mmcli,sim: add preferred networks list to SIM properties
Diffstat (limited to 'cli/mmcli-output.c')
-rw-r--r--cli/mmcli-output.c39
1 files changed, 39 insertions, 0 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