From c4f59aebe00c0cd25c4d27ed9e58b690e6b4b878 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Fri, 7 Jan 2022 12:53:30 +0100 Subject: mmcli,modem: new '--get-cell-info' action --- cli/mmcli-output.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'cli/mmcli-output.c') diff --git a/cli/mmcli-output.c b/cli/mmcli-output.c index aa701d80..5483e56a 100644 --- a/cli/mmcli-output.c +++ b/cli/mmcli-output.c @@ -21,6 +21,7 @@ #include #include +#define _LIBMM_INSIDE_MMCLI #include #include "mm-common-helpers.h" #include "mmcli-output.h" @@ -41,6 +42,7 @@ static SectionInfo section_infos[] = { [MMC_S_MODEM_MODES] = { "Modes" }, [MMC_S_MODEM_BANDS] = { "Bands" }, [MMC_S_MODEM_IP] = { "IP" }, + [MMC_S_MODEM_CELL_INFO] = { "Cell info" }, [MMC_S_MODEM_3GPP] = { "3GPP" }, [MMC_S_MODEM_3GPP_EPS] = { "3GPP EPS" }, [MMC_S_MODEM_3GPP_5GNR] = { "3GPP 5GNR" }, @@ -127,6 +129,7 @@ static FieldInfo field_infos[] = { [MMC_F_BANDS_SUPPORTED] = { "modem.generic.supported-bands", "supported", MMC_S_MODEM_BANDS, }, [MMC_F_BANDS_CURRENT] = { "modem.generic.current-bands", "current", MMC_S_MODEM_BANDS, }, [MMC_F_IP_SUPPORTED] = { "modem.generic.supported-ip-families", "supported", MMC_S_MODEM_IP, }, + [MMC_F_CELL_INFO] = { "modem.generic.cell-info", "cells", MMC_S_MODEM_CELL_INFO, }, [MMC_F_3GPP_IMEI] = { "modem.3gpp.imei", "imei", MMC_S_MODEM_3GPP, }, [MMC_F_3GPP_ENABLED_LOCKS] = { "modem.3gpp.enabled-locks", "enabled locks", MMC_S_MODEM_3GPP, }, [MMC_F_3GPP_OPERATOR_ID] = { "modem.3gpp.operator-code", "operator id", MMC_S_MODEM_3GPP, }, @@ -1112,6 +1115,33 @@ mmcli_output_profile_set (MM3gppProfile *profile) g_list_free (profile_list); } +/******************************************************************************/ +/* (Custom) Cell info output */ + +void +mmcli_output_cell_info (GList *cell_info_list) +{ + gchar **cell_infos = NULL; + + if (cell_info_list) { + GPtrArray *aux; + GList *l; + + aux = g_ptr_array_new (); + for (l = cell_info_list; l; l = g_list_next (l)) + g_ptr_array_add (aux, mm_cell_info_build_string (MM_CELL_INFO (l->data))); + g_ptr_array_add (aux, NULL); + cell_infos = (gchar **) g_ptr_array_free (aux, FALSE); + } + + /* When printing human result, we want to show some result even if no networks + * are found, so we force a explicit string result. */ + if (selected_type == MMC_OUTPUT_TYPE_HUMAN && !cell_infos) + output_item_new_take_single (MMC_F_CELL_INFO, g_strdup ("n/a")); + else + output_item_new_take_multiple (MMC_F_CELL_INFO, cell_infos, TRUE); +} + /******************************************************************************/ /* Human-friendly output */ -- cgit v1.2.3-70-g09d2