mmcli: new '--3gpp-profile-manager-status' operation

In order to show the properties of the profile management interface, e.g.:

  $ sudo mmcli -m a --3gpp-profile-manager-status
    -----------------------------------
    3GPP profile manager | index field: apn-type
This commit is contained in:
Aleksander Morgado
2021-12-16 11:40:18 +01:00
parent 80c4f49940
commit 2bfa6863c4
3 changed files with 32 additions and 1 deletions

View File

@@ -46,11 +46,16 @@ typedef struct {
static Context *ctx;
/* Options */
static gboolean status_flag;
static gboolean list_flag;
static gchar *set_str;
static gchar *delete_str;
static GOptionEntry entries[] = {
{ "3gpp-profile-manager-status", 0, 0, G_OPTION_ARG_NONE, &status_flag,
"Show status of the profile management features.",
NULL
},
{ "3gpp-profile-manager-list", 0, 0, G_OPTION_ARG_NONE, &list_flag,
"List available profiles",
NULL
@@ -90,7 +95,8 @@ mmcli_modem_3gpp_profile_manager_options_enabled (void)
if (checked)
return !!n_actions;
n_actions = (list_flag +
n_actions = (status_flag +
list_flag +
!!set_str +
!!delete_str);
@@ -99,6 +105,9 @@ mmcli_modem_3gpp_profile_manager_options_enabled (void)
exit (EXIT_FAILURE);
}
if (status_flag)
mmcli_force_sync_operation ();
checked = TRUE;
return !!n_actions;
}
@@ -142,6 +151,16 @@ mmcli_modem_3gpp_profile_manager_shutdown (void)
context_free ();
}
static void
print_status (void)
{
const gchar *index_field;
index_field = mm_modem_3gpp_profile_manager_get_index_field (ctx->modem_3gpp_profile_manager);
mmcli_output_string (MMC_F_3GPP_PROFILE_MANAGER_INDEX_FIELD, index_field);
mmcli_output_dump ();
}
static void
delete_process_reply (gboolean result,
const GError *error)
@@ -261,6 +280,9 @@ get_modem_ready (GObject *source,
ensure_modem_3gpp_profile_manager ();
if (status_flag)
g_assert_not_reached ();
/* Request to list? */
if (list_flag) {
g_debug ("Asynchronously listing profiles...");
@@ -350,6 +372,13 @@ mmcli_modem_3gpp_profile_manager_run_synchronous (GDBusConnection *connection)
ensure_modem_3gpp_profile_manager ();
/* Request to get location status? */
if (status_flag) {
g_debug ("Printing profile management status...");
print_status ();
return;
}
/* Request to list? */
if (list_flag) {
GList *profiles;

View File

@@ -146,6 +146,7 @@ static FieldInfo field_infos[] = {
[MMC_F_3GPP_USSD_STATUS] = { "modem.3gpp.ussd.status", "status", MMC_S_MODEM_3GPP_USSD, },
[MMC_F_3GPP_USSD_NETWORK_REQUEST] = { "modem.3gpp.ussd.network-request", "network request", MMC_S_MODEM_3GPP_USSD, },
[MMC_F_3GPP_USSD_NETWORK_NOTIFICATION] = { "modem.3gpp.ussd.network-notification", "network notification", MMC_S_MODEM_3GPP_USSD, },
[MMC_F_3GPP_PROFILE_MANAGER_INDEX_FIELD] = { "modem.3gpp.profile-manager.index-field", "index field", MMC_S_MODEM_3GPP_PROFILE_MANAGER, },
[MMC_F_3GPP_PROFILE_MANAGER_LIST] = { "modem.3gpp.profile-manager.list", "list", MMC_S_MODEM_3GPP_PROFILE_MANAGER, },
[MMC_F_3GPP_PROFILE_MANAGER_SET] = { "modem.3gpp.profile-manager.set", "set", MMC_S_MODEM_3GPP_PROFILE_MANAGER, },
[MMC_F_CDMA_MEID] = { "modem.cdma.meid", "meid", MMC_S_MODEM_CDMA, },

View File

@@ -147,6 +147,7 @@ typedef enum {
/* 3GPP scan section */
MMC_F_3GPP_SCAN_NETWORKS,
/* 3GPP profile management section */
MMC_F_3GPP_PROFILE_MANAGER_INDEX_FIELD,
MMC_F_3GPP_PROFILE_MANAGER_LIST,
MMC_F_3GPP_PROFILE_MANAGER_SET,
/* USSD section */