cli: adapt the code for the new flags and printing facilities
The data are added to output_data at first, and then they are printed all at once using print_data(), that takes care of proper alignment and display. The static 'width' values defined in NmcOutputField columns are not used now, but dynamically computed maximal widths override them.
This commit is contained in:
129
cli/src/common.c
129
cli/src/common.c
@@ -81,17 +81,17 @@ print_ip4_config (NMIP4Config *cfg4, NmCli *nmc, const char *group_prefix)
|
|||||||
char **domain_arr = NULL;
|
char **domain_arr = NULL;
|
||||||
char **wins_arr = NULL;
|
char **wins_arr = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
|
|
||||||
if (cfg4 == NULL)
|
if (cfg4 == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_ip4_config;
|
tmpl = nmc_fields_ip4_config;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_ip4_config);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_IP4_CONFIG_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_IP4_CONFIG_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
/* addresses */
|
/* addresses */
|
||||||
list = (GSList *) nm_ip4_config_get_addresses (cfg4);
|
list = (GSList *) nm_ip4_config_get_addresses (cfg4);
|
||||||
@@ -146,7 +146,7 @@ print_ip4_config (NMIP4Config *cfg4, NmCli *nmc, const char *group_prefix)
|
|||||||
if (ptr_array) {
|
if (ptr_array) {
|
||||||
domain_arr = g_new (char *, ptr_array->len + 1);
|
domain_arr = g_new (char *, ptr_array->len + 1);
|
||||||
for (i = 0; i < ptr_array->len; i++)
|
for (i = 0; i < ptr_array->len; i++)
|
||||||
domain_arr[i] = g_ptr_array_index (ptr_array, i);
|
domain_arr[i] = g_strdup (g_ptr_array_index (ptr_array, i));
|
||||||
|
|
||||||
domain_arr[i] = NULL;
|
domain_arr[i] = NULL;
|
||||||
}
|
}
|
||||||
@@ -161,21 +161,19 @@ print_ip4_config (NMIP4Config *cfg4, NmCli *nmc, const char *group_prefix)
|
|||||||
wins_arr[i] = NULL;
|
wins_arr[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_val_str (nmc->allowed_fields, 0, (char *) group_prefix);
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
set_val_arr (nmc->allowed_fields, 1, addr_arr);
|
set_val_strc (arr, 0, group_prefix);
|
||||||
set_val_arr (nmc->allowed_fields, 2, route_arr);
|
set_val_arr (arr, 1, addr_arr);
|
||||||
set_val_arr (nmc->allowed_fields, 3, dns_arr);
|
set_val_arr (arr, 2, route_arr);
|
||||||
set_val_arr (nmc->allowed_fields, 4, domain_arr);
|
set_val_arr (arr, 3, dns_arr);
|
||||||
set_val_arr (nmc->allowed_fields, 5, wins_arr);
|
set_val_arr (arr, 4, domain_arr);
|
||||||
|
set_val_arr (arr, 5, wins_arr);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
|
|
||||||
g_strfreev (addr_arr);
|
/* Remove any previous data */
|
||||||
g_strfreev (route_arr);
|
nmc_empty_output_fields (nmc);
|
||||||
g_strfreev (dns_arr);
|
|
||||||
g_free (domain_arr);
|
|
||||||
g_strfreev (wins_arr);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -190,17 +188,17 @@ print_ip6_config (NMIP6Config *cfg6, NmCli *nmc, const char *group_prefix)
|
|||||||
char **dns_arr = NULL;
|
char **dns_arr = NULL;
|
||||||
char **domain_arr = NULL;
|
char **domain_arr = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
|
|
||||||
if (cfg6 == NULL)
|
if (cfg6 == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_ip6_config;
|
tmpl = nmc_fields_ip6_config;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_ip6_config);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_IP6_CONFIG_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_IP6_CONFIG_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
/* addresses */
|
/* addresses */
|
||||||
list = (GSList *) nm_ip6_config_get_addresses (cfg6);
|
list = (GSList *) nm_ip6_config_get_addresses (cfg6);
|
||||||
@@ -254,24 +252,23 @@ print_ip6_config (NMIP6Config *cfg6, NmCli *nmc, const char *group_prefix)
|
|||||||
if (ptr_array) {
|
if (ptr_array) {
|
||||||
domain_arr = g_new (char *, ptr_array->len + 1);
|
domain_arr = g_new (char *, ptr_array->len + 1);
|
||||||
for (i = 0; i < ptr_array->len; i++)
|
for (i = 0; i < ptr_array->len; i++)
|
||||||
domain_arr[i] = g_ptr_array_index (ptr_array, i);
|
domain_arr[i] = g_strdup (g_ptr_array_index (ptr_array, i));
|
||||||
|
|
||||||
domain_arr[i] = NULL;
|
domain_arr[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_val_str (nmc->allowed_fields, 0, (char *) group_prefix);
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
set_val_arr (nmc->allowed_fields, 1, addr_arr);
|
set_val_strc (arr, 0, group_prefix);
|
||||||
set_val_arr (nmc->allowed_fields, 2, route_arr);
|
set_val_arr (arr, 1, addr_arr);
|
||||||
set_val_arr (nmc->allowed_fields, 3, dns_arr);
|
set_val_arr (arr, 2, route_arr);
|
||||||
set_val_arr (nmc->allowed_fields, 4, domain_arr);
|
set_val_arr (arr, 3, dns_arr);
|
||||||
|
set_val_arr (arr, 4, domain_arr);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
|
|
||||||
g_strfreev (addr_arr);
|
/* Remove any previous data */
|
||||||
g_strfreev (route_arr);
|
nmc_empty_output_fields (nmc);
|
||||||
g_strfreev (dns_arr);
|
|
||||||
g_free (domain_arr);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -280,9 +277,8 @@ gboolean
|
|||||||
print_dhcp4_config (NMDHCP4Config *dhcp4, NmCli *nmc, const char *group_prefix)
|
print_dhcp4_config (NMDHCP4Config *dhcp4, NmCli *nmc, const char *group_prefix)
|
||||||
{
|
{
|
||||||
GHashTable *table;
|
GHashTable *table;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
|
|
||||||
if (dhcp4 == NULL)
|
if (dhcp4 == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -294,10 +290,11 @@ print_dhcp4_config (NMDHCP4Config *dhcp4, NmCli *nmc, const char *group_prefix)
|
|||||||
char **options_arr = NULL;
|
char **options_arr = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dhcp4_config;
|
tmpl = nmc_fields_dhcp4_config;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dhcp4_config);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DHCP4_CONFIG_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DHCP4_CONFIG_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
options_arr = g_new (char *, g_hash_table_size (table) + 1);
|
options_arr = g_new (char *, g_hash_table_size (table) + 1);
|
||||||
g_hash_table_iter_init (&table_iter, table);
|
g_hash_table_iter_init (&table_iter, table);
|
||||||
@@ -305,13 +302,15 @@ print_dhcp4_config (NMDHCP4Config *dhcp4, NmCli *nmc, const char *group_prefix)
|
|||||||
options_arr[i++] = g_strdup_printf ("%s = %s", (char *) key, (char *) value);
|
options_arr[i++] = g_strdup_printf ("%s = %s", (char *) key, (char *) value);
|
||||||
options_arr[i] = NULL;
|
options_arr[i] = NULL;
|
||||||
|
|
||||||
set_val_str (nmc->allowed_fields, 0, (char *) group_prefix);
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
set_val_arr (nmc->allowed_fields, 1, options_arr);
|
set_val_strc (arr, 0, group_prefix);
|
||||||
|
set_val_arr (arr, 1, options_arr);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
|
|
||||||
g_strfreev (options_arr);
|
/* Remove any previous data */
|
||||||
|
nmc_empty_output_fields (nmc);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -322,9 +321,8 @@ gboolean
|
|||||||
print_dhcp6_config (NMDHCP6Config *dhcp6, NmCli *nmc, const char *group_prefix)
|
print_dhcp6_config (NMDHCP6Config *dhcp6, NmCli *nmc, const char *group_prefix)
|
||||||
{
|
{
|
||||||
GHashTable *table;
|
GHashTable *table;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
|
|
||||||
if (dhcp6 == NULL)
|
if (dhcp6 == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -336,10 +334,11 @@ print_dhcp6_config (NMDHCP6Config *dhcp6, NmCli *nmc, const char *group_prefix)
|
|||||||
char **options_arr = NULL;
|
char **options_arr = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dhcp6_config;
|
tmpl = nmc_fields_dhcp6_config;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dhcp6_config);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DHCP6_CONFIG_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DHCP6_CONFIG_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
options_arr = g_new (char *, g_hash_table_size (table) + 1);
|
options_arr = g_new (char *, g_hash_table_size (table) + 1);
|
||||||
g_hash_table_iter_init (&table_iter, table);
|
g_hash_table_iter_init (&table_iter, table);
|
||||||
@@ -347,13 +346,15 @@ print_dhcp6_config (NMDHCP6Config *dhcp6, NmCli *nmc, const char *group_prefix)
|
|||||||
options_arr[i++] = g_strdup_printf ("%s = %s", (char *) key, (char *) value);
|
options_arr[i++] = g_strdup_printf ("%s = %s", (char *) key, (char *) value);
|
||||||
options_arr[i] = NULL;
|
options_arr[i] = NULL;
|
||||||
|
|
||||||
set_val_str (nmc->allowed_fields, 0, (char *) group_prefix);
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
set_val_arr (nmc->allowed_fields, 1, options_arr);
|
set_val_strc (arr, 0, group_prefix);
|
||||||
|
set_val_arr (arr, 1, options_arr);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
|
|
||||||
g_strfreev (options_arr);
|
/* Remove any previous data */
|
||||||
|
nmc_empty_output_fields (nmc);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -307,9 +307,6 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
|
|||||||
char *fields_str;
|
char *fields_str;
|
||||||
char *fields_all = NMC_FIELDS_SETTINGS_NAMES_ALL;
|
char *fields_all = NMC_FIELDS_SETTINGS_NAMES_ALL;
|
||||||
char *fields_common = NMC_FIELDS_SETTINGS_NAMES_ALL;
|
char *fields_common = NMC_FIELDS_SETTINGS_NAMES_ALL;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
gboolean was_output = FALSE;
|
gboolean was_output = FALSE;
|
||||||
|
|
||||||
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
||||||
@@ -324,17 +321,20 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
|
|||||||
if (error->code == 0)
|
if (error->code == 0)
|
||||||
g_string_printf (nmc->return_text, _("Error: 'list configured': %s"), error->message);
|
g_string_printf (nmc->return_text, _("Error: 'list configured': %s"), error->message);
|
||||||
else
|
else
|
||||||
g_string_printf (nmc->return_text, _("Error: 'list configured': %s; allowed fields: %s"), error->message, NMC_FIELDS_SETTINGS_NAMES_ALL);
|
g_string_printf (nmc->return_text, _("Error: 'list configured': %s; allowed fields: %s"),
|
||||||
|
error->message, NMC_FIELDS_SETTINGS_NAMES_ALL);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_settings_names;
|
/* Main header */
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ONLY;
|
|
||||||
nmc->print_fields.header_name = _("Connection details");
|
nmc->print_fields.header_name = _("Connection details");
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_SETTINGS_NAMES_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_SETTINGS_NAMES_ALL,
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
nmc_fields_settings_names, NULL);
|
||||||
|
|
||||||
|
nmc_fields_settings_names[0].flags = NMC_OF_FLAG_MAIN_HEADER_ONLY;
|
||||||
|
print_required_fields (nmc, nmc_fields_settings_names);
|
||||||
|
|
||||||
/* Loop through the required settings and print them. */
|
/* Loop through the required settings and print them. */
|
||||||
for (i = 0; i < print_settings_array->len; i++) {
|
for (i = 0; i < print_settings_array->len; i++) {
|
||||||
@@ -346,6 +346,9 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
|
|||||||
|
|
||||||
was_output = FALSE;
|
was_output = FALSE;
|
||||||
|
|
||||||
|
/* Remove any previous data */
|
||||||
|
nmc_empty_output_fields (nmc);
|
||||||
|
|
||||||
setting = nm_connection_get_setting_by_name (connection, nmc_fields_settings_names[section_idx].name);
|
setting = nm_connection_get_setting_by_name (connection, nmc_fields_settings_names[section_idx].name);
|
||||||
if (setting) {
|
if (setting) {
|
||||||
setting_details (setting, nmc);
|
setting_details (setting, nmc);
|
||||||
@@ -361,7 +364,7 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_connection (NMConnection *data, gpointer user_data)
|
fill_output_connection (NMConnection *data, gpointer user_data)
|
||||||
{
|
{
|
||||||
NMConnection *connection = (NMConnection *) data;
|
NMConnection *connection = (NMConnection *) data;
|
||||||
NmCli *nmc = (NmCli *) user_data;
|
NmCli *nmc = (NmCli *) user_data;
|
||||||
@@ -369,29 +372,33 @@ show_connection (NMConnection *data, gpointer user_data)
|
|||||||
guint64 timestamp;
|
guint64 timestamp;
|
||||||
time_t timestamp_real;
|
time_t timestamp_real;
|
||||||
char *timestamp_str;
|
char *timestamp_str;
|
||||||
char timestamp_real_str[64];
|
char *timestamp_real_str;
|
||||||
|
NmcOutputField *arr;
|
||||||
|
|
||||||
s_con = nm_connection_get_setting_connection (connection);
|
s_con = nm_connection_get_setting_connection (connection);
|
||||||
if (s_con) {
|
if (s_con) {
|
||||||
/* Obtain field values */
|
/* Obtain field values */
|
||||||
timestamp = nm_setting_connection_get_timestamp (s_con);
|
timestamp = nm_setting_connection_get_timestamp (s_con);
|
||||||
timestamp_str = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp);
|
timestamp_str = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp);
|
||||||
timestamp_real = timestamp;
|
if (timestamp) {
|
||||||
strftime (timestamp_real_str, sizeof (timestamp_real_str), "%c", localtime (×tamp_real));
|
timestamp_real = timestamp;
|
||||||
|
timestamp_real_str = g_malloc0 (64);
|
||||||
|
strftime (timestamp_real_str, 64, "%c", localtime (×tamp_real));
|
||||||
|
}
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = (char *) nm_setting_connection_get_id (s_con);
|
arr = nmc_dup_fields_array (nmc_fields_con_show,
|
||||||
nmc->allowed_fields[1].value = (char *) nm_setting_connection_get_uuid (s_con);
|
sizeof (nmc_fields_con_show),
|
||||||
nmc->allowed_fields[2].value = (char *) nm_setting_connection_get_connection_type (s_con);
|
0);
|
||||||
nmc->allowed_fields[3].value = timestamp_str;
|
set_val_strc (arr, 0, nm_setting_connection_get_id (s_con));
|
||||||
nmc->allowed_fields[4].value = timestamp ? timestamp_real_str : _("never");
|
set_val_strc (arr, 1, nm_setting_connection_get_uuid (s_con));
|
||||||
nmc->allowed_fields[5].value = nm_setting_connection_get_autoconnect (s_con) ? _("yes") : _("no");
|
set_val_strc (arr, 2, nm_setting_connection_get_connection_type (s_con));
|
||||||
nmc->allowed_fields[6].value = nm_setting_connection_get_read_only (s_con) ? _("yes") : _("no");
|
set_val_str (arr, 3, timestamp_str);
|
||||||
nmc->allowed_fields[7].value = (char *) nm_connection_get_path (connection);
|
set_val_str (arr, 4, timestamp ? timestamp_real_str : g_strdup (_("never")));
|
||||||
|
set_val_strc (arr, 5, nm_setting_connection_get_autoconnect (s_con) ? _("yes") : _("no"));
|
||||||
|
set_val_strc (arr, 6, nm_setting_connection_get_read_only (s_con) ? _("yes") : _("no"));
|
||||||
|
set_val_strc (arr, 7, nm_connection_get_path (connection));
|
||||||
|
|
||||||
nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
|
||||||
|
|
||||||
g_free (timestamp_str);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,9 +447,8 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
|||||||
char *fields_str;
|
char *fields_str;
|
||||||
char *fields_all = NMC_FIELDS_CON_SHOW_ALL;
|
char *fields_all = NMC_FIELDS_CON_SHOW_ALL;
|
||||||
char *fields_common = NMC_FIELDS_CON_SHOW_COMMON;
|
char *fields_common = NMC_FIELDS_CON_SHOW_COMMON;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
gboolean printed = FALSE;
|
gboolean printed = FALSE;
|
||||||
|
|
||||||
nmc->should_wait = FALSE;
|
nmc->should_wait = FALSE;
|
||||||
@@ -454,8 +460,9 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
|||||||
else
|
else
|
||||||
fields_str = nmc->required_fields;
|
fields_str = nmc->required_fields;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_con_show;
|
tmpl = nmc_fields_con_show;
|
||||||
nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &error1);
|
tmpl_len = sizeof (nmc_fields_con_show);
|
||||||
|
nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, &error1);
|
||||||
/* error1 is checked later - it's not valid for connection details */
|
/* error1 is checked later - it's not valid for connection details */
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
@@ -464,13 +471,14 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
|||||||
if (error1)
|
if (error1)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Print headers */
|
/* Add headers */
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
|
|
||||||
nmc->print_fields.header_name = _("List of configured connections");
|
nmc->print_fields.header_name = _("List of configured connections");
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
/* Print values */
|
/* Add values */
|
||||||
g_slist_foreach (nmc->system_connections, (GFunc) show_connection, nmc);
|
g_slist_foreach (nmc->system_connections, (GFunc) fill_output_connection, nmc);
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
} else {
|
} else {
|
||||||
g_clear_error (&error1); /* the error1 is only relevant for 'show configured' without arguments */
|
g_clear_error (&error1); /* the error1 is only relevant for 'show configured' without arguments */
|
||||||
|
|
||||||
@@ -512,7 +520,8 @@ error:
|
|||||||
if (error1->code == 0)
|
if (error1->code == 0)
|
||||||
g_string_printf (nmc->return_text, _("Error: 'show configured': %s"), error1->message);
|
g_string_printf (nmc->return_text, _("Error: 'show configured': %s"), error1->message);
|
||||||
else
|
else
|
||||||
g_string_printf (nmc->return_text, _("Error: 'show configured': %s; allowed fields: %s"), error1->message, NMC_FIELDS_CON_SHOW_ALL);
|
g_string_printf (nmc->return_text, _("Error: 'show configured': %s; allowed fields: %s"),
|
||||||
|
error1->message, NMC_FIELDS_CON_SHOW_ALL);
|
||||||
g_error_free (error1);
|
g_error_free (error1);
|
||||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
}
|
}
|
||||||
@@ -584,8 +593,11 @@ get_connection_for_active (const GSList *con_list, NMActiveConnection *active)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
fill_in_fields_con_active (NMActiveConnection *active, GSList *con_list)
|
fill_output_active_connection (NMActiveConnection *active,
|
||||||
|
NmCli *nmc,
|
||||||
|
gboolean with_group,
|
||||||
|
guint32 o_flags)
|
||||||
{
|
{
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
const char *active_path;
|
const char *active_path;
|
||||||
@@ -594,7 +606,10 @@ fill_in_fields_con_active (NMActiveConnection *active, GSList *con_list)
|
|||||||
GString *dev_str;
|
GString *dev_str;
|
||||||
NMActiveConnectionState state;
|
NMActiveConnectionState state;
|
||||||
int i;
|
int i;
|
||||||
gboolean success = FALSE;
|
GSList *con_list = nmc->system_connections;
|
||||||
|
NmcOutputField *tmpl, *arr;
|
||||||
|
size_t tmpl_len;
|
||||||
|
int idx_start = with_group ? 0 : 1;
|
||||||
|
|
||||||
active_path = nm_active_connection_get_connection (active);
|
active_path = nm_active_connection_get_connection (active);
|
||||||
state = nm_active_connection_get_state (active);
|
state = nm_active_connection_get_state (active);
|
||||||
@@ -614,20 +629,29 @@ fill_in_fields_con_active (NMActiveConnection *active, GSList *con_list)
|
|||||||
if (dev_str->len > 0)
|
if (dev_str->len > 0)
|
||||||
g_string_truncate (dev_str, dev_str->len - 1); /* Cut off last ',' */
|
g_string_truncate (dev_str, dev_str->len - 1); /* Cut off last ',' */
|
||||||
|
|
||||||
|
tmpl = nmc_fields_con_show_active;
|
||||||
|
tmpl_len = sizeof (nmc_fields_con_show_active);
|
||||||
|
if (!with_group) {
|
||||||
|
tmpl++;
|
||||||
|
tmpl_len -= sizeof (NmcOutputField);
|
||||||
|
}
|
||||||
|
|
||||||
/* Fill field values */
|
/* Fill field values */
|
||||||
nmc_fields_con_show_active[0].value = (char *) nmc_fields_con_active_details_groups[0].name;
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, o_flags);
|
||||||
nmc_fields_con_show_active[1].value = _("N/A");
|
if (with_group)
|
||||||
nmc_fields_con_show_active[2].value = (char *) nm_active_connection_get_uuid (active);
|
set_val_strc (arr, 0, nmc_fields_con_active_details_groups[0].name);
|
||||||
nmc_fields_con_show_active[3].value = dev_str->str;
|
set_val_strc (arr, 1-idx_start, _("N/A"));
|
||||||
nmc_fields_con_show_active[4].value = (char *) active_connection_state_to_string (state);
|
set_val_strc (arr, 2-idx_start, nm_active_connection_get_uuid (active));
|
||||||
nmc_fields_con_show_active[5].value = nm_active_connection_get_default (active) ? _("yes") : _("no");
|
set_val_str (arr, 3-idx_start, dev_str->str);
|
||||||
nmc_fields_con_show_active[6].value = nm_active_connection_get_default6 (active) ? _("yes") : _("no");
|
set_val_strc (arr, 4-idx_start, active_connection_state_to_string (state));
|
||||||
nmc_fields_con_show_active[7].value = (char *) nm_active_connection_get_specific_object (active);
|
set_val_strc (arr, 5-idx_start, nm_active_connection_get_default (active) ? _("yes") : _("no"));
|
||||||
nmc_fields_con_show_active[8].value = NM_IS_VPN_CONNECTION (active) ? _("yes") : _("no");
|
set_val_strc (arr, 6-idx_start, nm_active_connection_get_default6 (active) ? _("yes") : _("no"));
|
||||||
nmc_fields_con_show_active[9].value = (char *) nm_object_get_path (NM_OBJECT (active));
|
set_val_strc (arr, 7-idx_start, nm_active_connection_get_specific_object (active));
|
||||||
nmc_fields_con_show_active[10].value = (char *) nm_active_connection_get_connection (active);
|
set_val_strc (arr, 8-idx_start, NM_IS_VPN_CONNECTION (active) ? _("yes") : _("no"));
|
||||||
nmc_fields_con_show_active[11].value = _("N/A");
|
set_val_strc (arr, 9-idx_start, nm_object_get_path (NM_OBJECT (active)));
|
||||||
nmc_fields_con_show_active[12].value = (char *) nm_active_connection_get_master (active);
|
set_val_strc (arr, 10-idx_start, nm_active_connection_get_connection (active));
|
||||||
|
set_val_strc (arr, 11-idx_start, _("N/A"));
|
||||||
|
set_val_strc (arr, 12-idx_start, nm_active_connection_get_master (active));
|
||||||
|
|
||||||
for (iter = con_list; iter; iter = g_slist_next (iter)) {
|
for (iter = con_list; iter; iter = g_slist_next (iter)) {
|
||||||
NMConnection *connection = (NMConnection *) iter->data;
|
NMConnection *connection = (NMConnection *) iter->data;
|
||||||
@@ -639,40 +663,15 @@ fill_in_fields_con_active (NMActiveConnection *active, GSList *con_list)
|
|||||||
g_assert (s_con != NULL);
|
g_assert (s_con != NULL);
|
||||||
|
|
||||||
/* Fill field values that depend on NMConnection */
|
/* Fill field values that depend on NMConnection */
|
||||||
nmc_fields_con_show_active[1].value = (char *) nm_setting_connection_get_id (s_con);
|
set_val_strc (arr, 1-idx_start, nm_setting_connection_get_id (s_con));
|
||||||
nmc_fields_con_show_active[11].value = (char *) nm_setting_connection_get_zone (s_con);
|
set_val_strc (arr, 11-idx_start, nm_setting_connection_get_zone (s_con));
|
||||||
|
|
||||||
success = TRUE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
/* Just free GString here, the char array has to be freed after printing
|
|
||||||
* (by free_fields_con_active()) */
|
|
||||||
g_string_free (dev_str, FALSE);
|
g_string_free (dev_str, FALSE);
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
free_fields_con_active (void)
|
|
||||||
{
|
|
||||||
/* Just DEVICES string was dynamically allocated */
|
|
||||||
g_free ((char *) nmc_fields_con_show_active[3].value);
|
|
||||||
nmc_fields_con_show_active[3].value = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
show_active_connection (gpointer data, gpointer user_data)
|
|
||||||
{
|
|
||||||
NMActiveConnection *active = NM_ACTIVE_CONNECTION (data);
|
|
||||||
NmCli *nmc = (NmCli *) user_data;
|
|
||||||
|
|
||||||
fill_in_fields_con_active (active, nmc->system_connections);
|
|
||||||
|
|
||||||
nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
|
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
|
||||||
|
|
||||||
free_fields_con_active ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMActiveConnection *
|
static NMActiveConnection *
|
||||||
@@ -810,9 +809,8 @@ nmc_active_connection_detail (NMActiveConnection *acon, NmCli *nmc)
|
|||||||
char *fields_str;
|
char *fields_str;
|
||||||
char *fields_all = NMC_FIELDS_CON_ACTIVE_DETAILS_ALL;
|
char *fields_all = NMC_FIELDS_CON_ACTIVE_DETAILS_ALL;
|
||||||
char *fields_common = NMC_FIELDS_CON_ACTIVE_DETAILS_ALL;
|
char *fields_common = NMC_FIELDS_CON_ACTIVE_DETAILS_ALL;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
gboolean was_output = FALSE;
|
gboolean was_output = FALSE;
|
||||||
|
|
||||||
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
||||||
@@ -827,17 +825,20 @@ nmc_active_connection_detail (NMActiveConnection *acon, NmCli *nmc)
|
|||||||
if (error->code == 0)
|
if (error->code == 0)
|
||||||
g_string_printf (nmc->return_text, _("Error: 'list active': %s"), error->message);
|
g_string_printf (nmc->return_text, _("Error: 'list active': %s"), error->message);
|
||||||
else
|
else
|
||||||
g_string_printf (nmc->return_text, _("Error: 'list active': %s; allowed fields: %s"), error->message, NMC_FIELDS_CON_ACTIVE_DETAILS_ALL);
|
g_string_printf (nmc->return_text, _("Error: 'list active': %s; allowed fields: %s"),
|
||||||
|
error->message, NMC_FIELDS_CON_ACTIVE_DETAILS_ALL);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_con_active_details_groups;
|
/* Main header */
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ONLY;
|
|
||||||
nmc->print_fields.header_name = _("Active connection details");
|
nmc->print_fields.header_name = _("Active connection details");
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_CON_ACTIVE_DETAILS_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_CON_ACTIVE_DETAILS_ALL,
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
nmc_fields_con_active_details_groups, NULL);
|
||||||
|
|
||||||
|
nmc_fields_con_active_details_groups[0].flags = NMC_OF_FLAG_MAIN_HEADER_ONLY;
|
||||||
|
print_required_fields (nmc, nmc_fields_con_active_details_groups);
|
||||||
|
|
||||||
/* Loop through the groups and print them. */
|
/* Loop through the groups and print them. */
|
||||||
for (i = 0; i < print_groups->len; i++) {
|
for (i = 0; i < print_groups->len; i++) {
|
||||||
@@ -848,23 +849,23 @@ nmc_active_connection_detail (NMActiveConnection *acon, NmCli *nmc)
|
|||||||
|
|
||||||
was_output = FALSE;
|
was_output = FALSE;
|
||||||
|
|
||||||
|
/* Remove any previous data */
|
||||||
|
nmc_empty_output_fields (nmc);
|
||||||
|
|
||||||
/* GENERAL */
|
/* GENERAL */
|
||||||
if (strcasecmp (nmc_fields_con_active_details_groups[group_idx].name, nmc_fields_con_active_details_groups[0].name) == 0) {
|
if (strcasecmp (nmc_fields_con_active_details_groups[group_idx].name, nmc_fields_con_active_details_groups[0].name) == 0) {
|
||||||
nmc->allowed_fields = nmc_fields_con_show_active;
|
/* Add field names */
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_CON_ACTIVE_DETAILS_GENERAL_ALL, nmc->allowed_fields, NULL);
|
tmpl = nmc_fields_con_show_active;
|
||||||
|
tmpl_len = sizeof (nmc_fields_con_show_active);
|
||||||
/* Print field names */
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_CON_ACTIVE_DETAILS_GENERAL_ALL, tmpl, NULL);
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
/* Fill in values */
|
/* Fill in values */
|
||||||
fill_in_fields_con_active (acon, nmc->system_connections);
|
fill_output_active_connection (acon, nmc, TRUE, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
|
|
||||||
/* and print them */
|
print_data (nmc); /* Print all data */
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
|
||||||
|
|
||||||
free_fields_con_active ();
|
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -907,12 +908,11 @@ nmc_active_connection_detail (NMActiveConnection *acon, NmCli *nmc)
|
|||||||
s_con = nm_connection_get_setting_connection (con);
|
s_con = nm_connection_get_setting_connection (con);
|
||||||
g_assert (s_con != NULL);
|
g_assert (s_con != NULL);
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_con_active_details_vpn;
|
tmpl = nmc_fields_con_active_details_vpn;
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_CON_ACTIVE_DETAILS_VPN_ALL, nmc->allowed_fields, NULL);
|
tmpl_len = sizeof (nmc_fields_con_active_details_vpn);
|
||||||
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_CON_ACTIVE_DETAILS_VPN_ALL, tmpl, NULL);
|
||||||
/* Print field names */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
|
||||||
|
|
||||||
s_vpn = nm_connection_get_setting_vpn (con);
|
s_vpn = nm_connection_get_setting_vpn (con);
|
||||||
if (s_vpn) {
|
if (s_vpn) {
|
||||||
@@ -934,22 +934,18 @@ nmc_active_connection_detail (NMActiveConnection *acon, NmCli *nmc)
|
|||||||
vpn_state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (acon));
|
vpn_state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (acon));
|
||||||
vpn_state_str = g_strdup_printf ("%d - %s", vpn_state, vpn_connection_state_to_string (vpn_state));
|
vpn_state_str = g_strdup_printf ("%d - %s", vpn_state, vpn_connection_state_to_string (vpn_state));
|
||||||
|
|
||||||
/* Print values */
|
/* Add values */
|
||||||
set_val_str (nmc->allowed_fields, 0, (char *) nmc_fields_con_active_details_groups[2].name);
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
set_val_str (nmc->allowed_fields, 1, type_str);
|
set_val_strc (arr, 0, nmc_fields_con_active_details_groups[2].name);
|
||||||
set_val_str (nmc->allowed_fields, 2, (char *) (username ? username : get_vpn_data_item (con, VPN_DATA_ITEM_USERNAME)));
|
set_val_str (arr, 1, type_str);
|
||||||
set_val_str (nmc->allowed_fields, 3, (char *) get_vpn_data_item (con, VPN_DATA_ITEM_GATEWAY));
|
set_val_strc (arr, 2, username ? username : get_vpn_data_item (con, VPN_DATA_ITEM_USERNAME));
|
||||||
set_val_str (nmc->allowed_fields, 4, banner_str);
|
set_val_strc (arr, 3, get_vpn_data_item (con, VPN_DATA_ITEM_GATEWAY));
|
||||||
set_val_str (nmc->allowed_fields, 5, vpn_state_str);
|
set_val_str (arr, 4, banner_str);
|
||||||
set_val_arr (nmc->allowed_fields, 6, vpn_data_array);
|
set_val_str (arr, 5, vpn_state_str);
|
||||||
|
set_val_arr (arr, 6, vpn_data_array);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
|
||||||
|
|
||||||
g_free (type_str);
|
|
||||||
g_free (banner_str);
|
|
||||||
g_free (vpn_state_str);
|
|
||||||
g_strfreev (vpn_data_array);
|
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -964,8 +960,11 @@ static NMCResultCode
|
|||||||
do_connections_show_active (NmCli *nmc, int argc, char **argv)
|
do_connections_show_active (NmCli *nmc, int argc, char **argv)
|
||||||
{
|
{
|
||||||
const GPtrArray *active_cons;
|
const GPtrArray *active_cons;
|
||||||
|
int i;
|
||||||
GError *err1 = NULL;
|
GError *err1 = NULL;
|
||||||
gboolean printed = FALSE;
|
gboolean printed = FALSE;
|
||||||
|
NmcOutputField *tmpl, *arr;
|
||||||
|
size_t tmpl_len;
|
||||||
|
|
||||||
nmc->should_wait = FALSE;
|
nmc->should_wait = FALSE;
|
||||||
|
|
||||||
@@ -984,9 +983,6 @@ do_connections_show_active (NmCli *nmc, int argc, char **argv)
|
|||||||
char *fields_str;
|
char *fields_str;
|
||||||
char *fields_all = NMC_FIELDS_CON_ACTIVE_ALL;
|
char *fields_all = NMC_FIELDS_CON_ACTIVE_ALL;
|
||||||
char *fields_common = NMC_FIELDS_CON_ACTIVE_COMMON;
|
char *fields_common = NMC_FIELDS_CON_ACTIVE_COMMON;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
|
|
||||||
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
||||||
fields_str = fields_common;
|
fields_str = fields_common;
|
||||||
@@ -995,18 +991,23 @@ do_connections_show_active (NmCli *nmc, int argc, char **argv)
|
|||||||
else
|
else
|
||||||
fields_str = nmc->required_fields;
|
fields_str = nmc->required_fields;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_con_show_active + 1 ;
|
tmpl = nmc_fields_con_show_active + 1;
|
||||||
nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &err1);
|
tmpl_len = sizeof (nmc_fields_con_show_active) - sizeof (NmcOutputField);
|
||||||
|
nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, &err1);
|
||||||
if (err1)
|
if (err1)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Print headers */
|
/* Add headers */
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
|
|
||||||
nmc->print_fields.header_name = _("List of active connections");
|
nmc->print_fields.header_name = _("List of active connections");
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
if (active_cons && active_cons->len)
|
/* Add values */
|
||||||
g_ptr_array_foreach ((GPtrArray *) active_cons, show_active_connection, (gpointer) nmc);
|
for (i = 0; active_cons && i < active_cons->len; i++) {
|
||||||
|
NMActiveConnection *ac = g_ptr_array_index (active_cons, i);
|
||||||
|
fill_output_active_connection (ac, nmc, FALSE, 0);
|
||||||
|
}
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
} else {
|
} else {
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
NMActiveConnection *acon;
|
NMActiveConnection *acon;
|
||||||
|
@@ -373,15 +373,17 @@ ap_wpa_rsn_flags_to_string (NM80211ApSecurityFlags flags)
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
NmCli *nmc;
|
NmCli *nmc;
|
||||||
int index;
|
int index;
|
||||||
|
guint32 output_flags;
|
||||||
const char* active_bssid;
|
const char* active_bssid;
|
||||||
const char* device;
|
const char* device;
|
||||||
} APInfo;
|
} APInfo;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
detail_access_point (gpointer data, gpointer user_data)
|
fill_output_access_point (gpointer data, gpointer user_data)
|
||||||
{
|
{
|
||||||
NMAccessPoint *ap = NM_ACCESS_POINT (data);
|
NMAccessPoint *ap = NM_ACCESS_POINT (data);
|
||||||
APInfo *info = (APInfo *) user_data;
|
APInfo *info = (APInfo *) user_data;
|
||||||
|
NmcOutputField *arr;
|
||||||
gboolean active = FALSE;
|
gboolean active = FALSE;
|
||||||
NM80211ApFlags flags;
|
NM80211ApFlags flags;
|
||||||
NM80211ApSecurityFlags wpa_flags, rsn_flags;
|
NM80211ApSecurityFlags wpa_flags, rsn_flags;
|
||||||
@@ -440,44 +442,41 @@ detail_access_point (gpointer data, gpointer user_data)
|
|||||||
if (security_str->len > 0)
|
if (security_str->len > 0)
|
||||||
g_string_truncate (security_str, security_str->len-1); /* Chop off last space */
|
g_string_truncate (security_str, security_str->len-1); /* Chop off last space */
|
||||||
|
|
||||||
|
arr = nmc_dup_fields_array (nmc_fields_dev_wifi_list,
|
||||||
|
sizeof (nmc_fields_dev_wifi_list),
|
||||||
|
info->output_flags);
|
||||||
|
|
||||||
ap_name = g_strdup_printf ("AP[%d]", info->index++); /* AP */
|
ap_name = g_strdup_printf ("AP[%d]", info->index++); /* AP */
|
||||||
info->nmc->allowed_fields[0].value = ap_name;
|
set_val_str (arr, 0, ap_name);
|
||||||
info->nmc->allowed_fields[1].value = ssid_str;
|
set_val_str (arr, 1, ssid_str);
|
||||||
info->nmc->allowed_fields[2].value = (char *) bssid;
|
set_val_strc (arr, 2, bssid);
|
||||||
info->nmc->allowed_fields[3].value = mode == NM_802_11_MODE_ADHOC ? _("Ad-Hoc")
|
set_val_strc (arr, 3, mode == NM_802_11_MODE_ADHOC ? _("Ad-Hoc")
|
||||||
: mode == NM_802_11_MODE_INFRA ? _("Infrastructure")
|
: mode == NM_802_11_MODE_INFRA ? _("Infrastructure")
|
||||||
: _("Unknown");
|
: _("Unknown"));
|
||||||
info->nmc->allowed_fields[4].value = freq_str;
|
set_val_str (arr, 4, freq_str);
|
||||||
info->nmc->allowed_fields[5].value = bitrate_str;
|
set_val_str (arr, 5, bitrate_str);
|
||||||
info->nmc->allowed_fields[6].value = strength_str;
|
set_val_str (arr, 6, strength_str);
|
||||||
info->nmc->allowed_fields[7].value = security_str->str;
|
set_val_str (arr, 7, security_str->str);
|
||||||
info->nmc->allowed_fields[8].value = wpa_flags_str;
|
set_val_str (arr, 8, wpa_flags_str);
|
||||||
info->nmc->allowed_fields[9].value = rsn_flags_str;
|
set_val_str (arr, 9, rsn_flags_str);
|
||||||
info->nmc->allowed_fields[10].value = (char *) info->device;
|
set_val_strc (arr, 10, info->device);
|
||||||
info->nmc->allowed_fields[11].value = active ? _("yes") : _("no");
|
set_val_strc (arr, 11, active ? _("yes") : _("no"));
|
||||||
info->nmc->allowed_fields[12].value = (char *) nm_object_get_path (NM_OBJECT (ap));
|
set_val_strc (arr, 12, nm_object_get_path (NM_OBJECT (ap)));
|
||||||
|
|
||||||
info->nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
|
g_ptr_array_add (info->nmc->output_data, arr);
|
||||||
print_fields (info->nmc->print_fields, info->nmc->allowed_fields);
|
|
||||||
|
|
||||||
g_free (ap_name);
|
g_string_free (security_str, FALSE);
|
||||||
g_free (ssid_str);
|
|
||||||
g_free (freq_str);
|
|
||||||
g_free (bitrate_str);
|
|
||||||
g_free (strength_str);
|
|
||||||
g_free (wpa_flags_str);
|
|
||||||
g_free (rsn_flags_str);
|
|
||||||
g_string_free (security_str, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WITH_WIMAX
|
#if WITH_WIMAX
|
||||||
static void
|
static void
|
||||||
detail_wimax_nsp (NMWimaxNsp *nsp, NmCli *nmc, NMDevice *dev, int idx)
|
fill_output_wimax_nsp (NMWimaxNsp *nsp, NmCli *nmc, NMDevice *dev, int idx, guint32 o_flags)
|
||||||
{
|
{
|
||||||
NMDeviceWimax *wimax = NM_DEVICE_WIMAX (dev);
|
NMDeviceWimax *wimax = NM_DEVICE_WIMAX (dev);
|
||||||
char *nsp_name, *quality_str;
|
char *nsp_name, *quality_str;
|
||||||
const char *ntype;
|
const char *ntype;
|
||||||
gboolean active = FALSE;
|
gboolean active = FALSE;
|
||||||
|
NmcOutputField *arr;
|
||||||
|
|
||||||
switch (nm_wimax_nsp_get_network_type (nsp)) {
|
switch (nm_wimax_nsp_get_network_type (nsp)) {
|
||||||
case NM_WIMAX_NSP_NETWORK_TYPE_HOME:
|
case NM_WIMAX_NSP_NETWORK_TYPE_HOME:
|
||||||
@@ -502,32 +501,40 @@ detail_wimax_nsp (NMWimaxNsp *nsp, NmCli *nmc, NMDevice *dev, int idx)
|
|||||||
quality_str = g_strdup_printf ("%u", nm_wimax_nsp_get_signal_quality (nsp));
|
quality_str = g_strdup_printf ("%u", nm_wimax_nsp_get_signal_quality (nsp));
|
||||||
nsp_name = g_strdup_printf ("NSP[%d]", idx); /* NSP */
|
nsp_name = g_strdup_printf ("NSP[%d]", idx); /* NSP */
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = nsp_name;
|
arr = nmc_dup_fields_array (nmc_fields_dev_wimax_list,
|
||||||
nmc->allowed_fields[1].value = (char *) nm_wimax_nsp_get_name (nsp);
|
sizeof (nmc_fields_dev_wimax_list),
|
||||||
nmc->allowed_fields[2].value = quality_str;
|
o_flags);
|
||||||
nmc->allowed_fields[3].value = (char *) ntype;
|
set_val_str (arr, 0, nsp_name);
|
||||||
nmc->allowed_fields[4].value = (char *) nm_device_get_iface (dev);
|
set_val_strc (arr, 1, nm_wimax_nsp_get_name (nsp));
|
||||||
nmc->allowed_fields[5].value = active ? _("yes") : _("no");
|
set_val_str (arr, 2, quality_str);
|
||||||
nmc->allowed_fields[6].value = (char *) nm_object_get_path (NM_OBJECT (nsp));
|
set_val_strc (arr, 3, ntype);
|
||||||
|
set_val_strc (arr, 4, nm_device_get_iface (dev));
|
||||||
|
set_val_strc (arr, 5, active ? _("yes") : _("no"));
|
||||||
|
set_val_strc (arr, 6, nm_object_get_path (NM_OBJECT (nsp)));
|
||||||
|
|
||||||
nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
|
||||||
|
|
||||||
g_free (nsp_name);
|
|
||||||
g_free (quality_str);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct cb_info {
|
static const char *
|
||||||
NMClient *client;
|
construct_header_name (const char *base, const char *spec)
|
||||||
const GPtrArray *active;
|
{
|
||||||
};
|
static char header_name[128];
|
||||||
|
|
||||||
|
if (spec == NULL)
|
||||||
|
return base;
|
||||||
|
|
||||||
|
g_strlcpy (header_name, base, sizeof (header_name));
|
||||||
|
g_strlcat (header_name, " (", sizeof (header_name));
|
||||||
|
g_strlcat (header_name, spec, sizeof (header_name));
|
||||||
|
g_strlcat (header_name, ")", sizeof (header_name));
|
||||||
|
|
||||||
|
return header_name;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_device_info (gpointer data, gpointer user_data)
|
show_device_info (NMDevice *device, NmCli *nmc)
|
||||||
{
|
{
|
||||||
NMDevice *device = NM_DEVICE (data);
|
|
||||||
NmCli *nmc = (NmCli *) user_data;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
APInfo *info;
|
APInfo *info;
|
||||||
const char *hwaddr = NULL;
|
const char *hwaddr = NULL;
|
||||||
@@ -544,14 +551,14 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
char *fields_str;
|
char *fields_str;
|
||||||
char *fields_all = NMC_FIELDS_DEV_SHOW_SECTIONS_ALL;
|
char *fields_all = NMC_FIELDS_DEV_SHOW_SECTIONS_ALL;
|
||||||
char *fields_common = NMC_FIELDS_DEV_SHOW_SECTIONS_COMMON;
|
char *fields_common = NMC_FIELDS_DEV_SHOW_SECTIONS_COMMON;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
gboolean was_output = FALSE;
|
gboolean was_output = FALSE;
|
||||||
NMIP4Config *cfg4;
|
NMIP4Config *cfg4;
|
||||||
NMIP6Config *cfg6;
|
NMIP6Config *cfg6;
|
||||||
NMDHCP4Config *dhcp4;
|
NMDHCP4Config *dhcp4;
|
||||||
NMDHCP6Config *dhcp6;
|
NMDHCP6Config *dhcp6;
|
||||||
|
const char *base_hdr = _("Device details");
|
||||||
|
|
||||||
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
||||||
fields_str = fields_common;
|
fields_str = fields_common;
|
||||||
@@ -565,36 +572,42 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
if (error->code == 0)
|
if (error->code == 0)
|
||||||
g_string_printf (nmc->return_text, _("Error: 'device show': %s"), error->message);
|
g_string_printf (nmc->return_text, _("Error: 'device show': %s"), error->message);
|
||||||
else
|
else
|
||||||
g_string_printf (nmc->return_text, _("Error: 'device show': %s; allowed fields: %s"), error->message, NMC_FIELDS_DEV_SHOW_SECTIONS_ALL);
|
g_string_printf (nmc->return_text, _("Error: 'device show': %s; allowed fields: %s"),
|
||||||
|
error->message, NMC_FIELDS_DEV_SHOW_SECTIONS_ALL);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main header */
|
/* Main header */
|
||||||
nmc->allowed_fields = nmc_fields_dev_show_general;
|
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr, nm_device_get_iface (device));
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ONLY;
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_GENERAL_ALL,
|
||||||
nmc->print_fields.header_name = _("Device details");
|
nmc_fields_dev_show_general, NULL);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_GENERAL_ALL, nmc->allowed_fields, NULL);
|
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
nmc_fields_dev_show_general[0].flags = NMC_OF_FLAG_MAIN_HEADER_ONLY;
|
||||||
|
print_required_fields (nmc, nmc_fields_dev_show_general);
|
||||||
|
|
||||||
/* Loop through the required sections and print them. */
|
/* Loop through the required sections and print them. */
|
||||||
for (k = 0; k < sections_array->len; k++) {
|
for (k = 0; k < sections_array->len; k++) {
|
||||||
int section_idx = g_array_index (sections_array, int, k);
|
int section_idx = g_array_index (sections_array, int, k);
|
||||||
|
|
||||||
if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output)
|
if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output)
|
||||||
printf ("\n"); /* Empty line */
|
printf ("\n"); /* Print empty line between groups in tabular mode */
|
||||||
|
|
||||||
was_output = FALSE;
|
was_output = FALSE;
|
||||||
|
|
||||||
|
/* Remove any previous data */
|
||||||
|
nmc_empty_output_fields (nmc);
|
||||||
|
|
||||||
state = nm_device_get_state_reason (device, &reason);
|
state = nm_device_get_state_reason (device, &reason);
|
||||||
|
|
||||||
/* section GENERAL */
|
/* section GENERAL */
|
||||||
if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[0].name)) {
|
if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[0].name)) {
|
||||||
nmc->allowed_fields = nmc_fields_dev_show_general;
|
tmpl = nmc_fields_dev_show_general;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dev_show_general);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_GENERAL_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_GENERAL_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
if (NM_IS_DEVICE_ETHERNET (device))
|
if (NM_IS_DEVICE_ETHERNET (device))
|
||||||
hwaddr = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device));
|
hwaddr = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device));
|
||||||
@@ -616,38 +629,38 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
state_str = g_strdup_printf ("%d (%s)", state, nmc_device_state_to_string (state));
|
state_str = g_strdup_printf ("%d (%s)", state, nmc_device_state_to_string (state));
|
||||||
reason_str = g_strdup_printf ("%d (%s)", reason, nmc_device_reason_to_string (reason));
|
reason_str = g_strdup_printf ("%d (%s)", reason, nmc_device_reason_to_string (reason));
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = (char *) nmc_fields_dev_show_sections[0].name; /* "GENERAL"*/
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
nmc->allowed_fields[1].value = (char *) nm_device_get_iface (device);
|
set_val_strc (arr, 0, nmc_fields_dev_show_sections[0].name); /* "GENERAL"*/
|
||||||
nmc->allowed_fields[2].value = (char *) nm_device_get_type_description (device);
|
set_val_strc (arr, 1, nm_device_get_iface (device));
|
||||||
nmc->allowed_fields[3].value = (char *) nm_device_get_vendor (device);
|
set_val_strc (arr, 2, nm_device_get_type_description (device));
|
||||||
nmc->allowed_fields[4].value = (char *) nm_device_get_product (device);
|
set_val_strc (arr, 3, nm_device_get_vendor (device));
|
||||||
nmc->allowed_fields[5].value = (char *) (nm_device_get_driver (device) ? nm_device_get_driver (device) : _("(unknown)"));
|
set_val_strc (arr, 4, nm_device_get_product (device));
|
||||||
nmc->allowed_fields[6].value = (char *) nm_device_get_driver_version (device);
|
set_val_strc (arr, 5, nm_device_get_driver (device) ? nm_device_get_driver (device) : _("(unknown)"));
|
||||||
nmc->allowed_fields[7].value = (char *) nm_device_get_firmware_version (device);
|
set_val_strc (arr, 6, nm_device_get_driver_version (device));
|
||||||
nmc->allowed_fields[8].value = (char *) (hwaddr ? hwaddr : _("(unknown)"));
|
set_val_strc (arr, 7, nm_device_get_firmware_version (device));
|
||||||
nmc->allowed_fields[9].value = (char *) state_str;
|
set_val_strc (arr, 8, hwaddr ? hwaddr : _("(unknown)"));
|
||||||
nmc->allowed_fields[10].value = (char *) reason_str;
|
set_val_str (arr, 9, state_str);
|
||||||
nmc->allowed_fields[11].value = (char *) nm_device_get_udi (device);
|
set_val_str (arr, 10, reason_str);
|
||||||
nmc->allowed_fields[12].value = (char *) nm_device_get_ip_iface (device);
|
set_val_strc (arr, 11, nm_device_get_udi (device));
|
||||||
nmc->allowed_fields[13].value = nm_device_get_managed (device) ? _("yes") : _("no");
|
set_val_strc (arr, 12, nm_device_get_ip_iface (device));
|
||||||
nmc->allowed_fields[14].value = nm_device_get_autoconnect (device) ? _("yes") : _("no");
|
set_val_strc (arr, 13, nm_device_get_managed (device) ? _("yes") : _("no"));
|
||||||
nmc->allowed_fields[15].value = nm_device_get_firmware_missing (device) ? _("yes") : _("no");
|
set_val_strc (arr, 14, nm_device_get_autoconnect (device) ? _("yes") : _("no"));
|
||||||
nmc->allowed_fields[16].value = (char *) ((acon = nm_device_get_active_connection (device)) ?
|
set_val_strc (arr, 15, nm_device_get_firmware_missing (device) ? _("yes") : _("no"));
|
||||||
nm_object_get_path (NM_OBJECT (acon)) : _("not connected"));
|
set_val_strc (arr, 16, ((acon = nm_device_get_active_connection (device)) ?
|
||||||
|
nm_object_get_path (NM_OBJECT (acon)) : _("not connected")));
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
g_free (state_str);
|
|
||||||
g_free (reason_str);
|
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* section CAPABILITIES */
|
/* section CAPABILITIES */
|
||||||
if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[1].name)) {
|
if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[1].name)) {
|
||||||
nmc->allowed_fields = nmc_fields_dev_show_cap;
|
tmpl = nmc_fields_dev_show_cap;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dev_show_cap);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_CAP_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_CAP_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
caps = nm_device_get_capabilities (device);
|
caps = nm_device_get_capabilities (device);
|
||||||
speed = 0;
|
speed = 0;
|
||||||
@@ -659,20 +672,18 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device));
|
speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device));
|
||||||
speed /= 1000;
|
speed /= 1000;
|
||||||
}
|
}
|
||||||
if (speed)
|
speed_str = speed ? g_strdup_printf (_("%u Mb/s"), speed) : g_strdup (_("unknown"));
|
||||||
speed_str = g_strdup_printf (_("%u Mb/s"), speed);
|
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = (char *) nmc_fields_dev_show_sections[1].name; /* "CAPABILITIES" */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
nmc->allowed_fields[1].value = (caps & NM_DEVICE_CAP_CARRIER_DETECT) ? _("yes") : _("no");
|
set_val_strc (arr, 0, nmc_fields_dev_show_sections[1].name); /* "CAPABILITIES" */
|
||||||
nmc->allowed_fields[2].value = speed_str ? speed_str : _("unknown");
|
set_val_strc (arr, 1, (caps & NM_DEVICE_CAP_CARRIER_DETECT) ? _("yes") : _("no"));
|
||||||
|
set_val_str (arr, 2, speed_str);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
g_free (speed_str);
|
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Wireless specific information */
|
/* Wireless specific information */
|
||||||
if ((NM_IS_DEVICE_WIFI (device))) {
|
if ((NM_IS_DEVICE_WIFI (device))) {
|
||||||
NMDeviceWifiCapabilities wcaps;
|
NMDeviceWifiCapabilities wcaps;
|
||||||
@@ -684,22 +695,25 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[2].name)) {
|
if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[2].name)) {
|
||||||
wcaps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (device));
|
wcaps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (device));
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dev_show_wifi_prop;
|
tmpl = nmc_fields_dev_show_wifi_prop;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dev_show_wifi_prop);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_WIFI_PROP_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_WIFI_PROP_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = (char *) nmc_fields_dev_show_sections[2].name; /* "WIFI-PROPERTIES" */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
nmc->allowed_fields[1].value = (wcaps & (NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | NM_WIFI_DEVICE_CAP_CIPHER_WEP104)) ? _("yes") : _("no");
|
set_val_strc (arr, 0, nmc_fields_dev_show_sections[2].name); /* "WIFI-PROPERTIES" */
|
||||||
nmc->allowed_fields[2].value = (wcaps & NM_WIFI_DEVICE_CAP_WPA) ? _("yes") : _("no");
|
set_val_strc (arr, 1, (wcaps & (NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | NM_WIFI_DEVICE_CAP_CIPHER_WEP104)) ?
|
||||||
nmc->allowed_fields[3].value = (wcaps & NM_WIFI_DEVICE_CAP_RSN) ? _("yes") : _("no");
|
_("yes") : _("no"));
|
||||||
nmc->allowed_fields[4].value = (wcaps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP) ? _("yes") : _("no");
|
set_val_strc (arr, 2, (wcaps & NM_WIFI_DEVICE_CAP_WPA) ? _("yes") : _("no"));
|
||||||
nmc->allowed_fields[5].value = (wcaps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP) ? _("yes") : _("no");
|
set_val_strc (arr, 3, (wcaps & NM_WIFI_DEVICE_CAP_RSN) ? _("yes") : _("no"));
|
||||||
nmc->allowed_fields[6].value = (wcaps & NM_WIFI_DEVICE_CAP_AP) ? _("yes") : _("no");
|
set_val_strc (arr, 4, (wcaps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP) ? _("yes") : _("no"));
|
||||||
nmc->allowed_fields[7].value = (wcaps & NM_WIFI_DEVICE_CAP_ADHOC) ? _("yes") : _("no");
|
set_val_strc (arr, 5, (wcaps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP) ? _("yes") : _("no"));
|
||||||
|
set_val_strc (arr, 6, (wcaps & NM_WIFI_DEVICE_CAP_AP) ? _("yes") : _("no"));
|
||||||
|
set_val_strc (arr, 7, (wcaps & NM_WIFI_DEVICE_CAP_ADHOC) ? _("yes") : _("no"));
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,36 +724,41 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
active_bssid = active_ap ? nm_access_point_get_bssid (active_ap) : NULL;
|
active_bssid = active_ap ? nm_access_point_get_bssid (active_ap) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dev_wifi_list;
|
tmpl = nmc_fields_dev_wifi_list;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dev_wifi_list);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_WIFI_LIST_FOR_DEV_LIST, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_WIFI_LIST_FOR_DEV_LIST, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
|
||||||
info = g_malloc0 (sizeof (APInfo));
|
info = g_malloc0 (sizeof (APInfo));
|
||||||
info->nmc = nmc;
|
info->nmc = nmc;
|
||||||
info->index = 1;
|
info->index = 1;
|
||||||
|
info->output_flags = NMC_OF_FLAG_SECTION_PREFIX;
|
||||||
info->active_bssid = active_bssid;
|
info->active_bssid = active_bssid;
|
||||||
info->device = nm_device_get_iface (device);
|
info->device = nm_device_get_iface (device);
|
||||||
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device));
|
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device));
|
||||||
if (aps && aps->len)
|
if (aps && aps->len)
|
||||||
g_ptr_array_foreach ((GPtrArray *) aps, detail_access_point, (gpointer) info);
|
g_ptr_array_foreach ((GPtrArray *) aps, fill_output_access_point, (gpointer) info);
|
||||||
g_free (info);
|
g_free (info);
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
} else if (NM_IS_DEVICE_ETHERNET (device)) {
|
} else if (NM_IS_DEVICE_ETHERNET (device)) {
|
||||||
/* WIRED-PROPERTIES */
|
/* WIRED-PROPERTIES */
|
||||||
if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[4].name)) {
|
if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[4].name)) {
|
||||||
nmc->allowed_fields = nmc_fields_dev_show_wired_prop;
|
tmpl = nmc_fields_dev_show_wired_prop;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dev_show_wired_prop);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_WIRED_PROP_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_WIRED_PROP_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = (char *) nmc_fields_dev_show_sections[4].name; /* "WIRED-PROPERTIES" */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
nmc->allowed_fields[1].value = (nm_device_ethernet_get_carrier (NM_DEVICE_ETHERNET (device))) ? _("on") : _("off");
|
set_val_strc (arr, 0, nmc_fields_dev_show_sections[4].name); /* "WIRED-PROPERTIES" */
|
||||||
|
set_val_strc (arr, 1, (nm_device_ethernet_get_carrier (NM_DEVICE_ETHERNET (device))) ?
|
||||||
|
_("on") : _("off"));
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -750,45 +769,44 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
char *cfreq = NULL, *rssi = NULL, *cinr = NULL, *txpow = NULL;
|
char *cfreq = NULL, *rssi = NULL, *cinr = NULL, *txpow = NULL;
|
||||||
guint tmp_uint;
|
guint tmp_uint;
|
||||||
gint tmp_int;
|
gint tmp_int;
|
||||||
char *bsid;
|
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dev_show_wimax_prop;
|
/* Field names */
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl = nmc_fields_dev_show_wimax_prop;
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_WIMAX_PROP_ALL, nmc->allowed_fields, NULL);
|
tmpl_len = sizeof (nmc_fields_dev_show_wimax_prop);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_WIMAX_PROP_ALL, tmpl, NULL);
|
||||||
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
nmc->allowed_fields[0].value = (char *) nmc_fields_dev_show_sections[5].name; /* "WIMAX-PROPERTIES" */
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
/* Center frequency */
|
/* Center frequency */
|
||||||
tmp_uint = nm_device_wimax_get_center_frequency (NM_DEVICE_WIMAX (device));
|
tmp_uint = nm_device_wimax_get_center_frequency (NM_DEVICE_WIMAX (device));
|
||||||
if (tmp_uint)
|
if (tmp_uint)
|
||||||
cfreq = g_strdup_printf ("%'.1f MHz", (double) tmp_uint / 1000.0);
|
cfreq = g_strdup_printf ("%'.1f MHz", (double) tmp_uint / 1000.0);
|
||||||
nmc->allowed_fields[1].value = cfreq ? cfreq : "";
|
|
||||||
|
|
||||||
/* RSSI */
|
/* RSSI */
|
||||||
tmp_int = nm_device_wimax_get_rssi (NM_DEVICE_WIMAX (device));
|
tmp_int = nm_device_wimax_get_rssi (NM_DEVICE_WIMAX (device));
|
||||||
if (tmp_int)
|
if (tmp_int)
|
||||||
rssi = g_strdup_printf ("%d dBm", tmp_int);
|
rssi = g_strdup_printf ("%d dBm", tmp_int);
|
||||||
nmc->allowed_fields[2].value = rssi ? rssi : "";
|
|
||||||
|
|
||||||
/* CINR */
|
/* CINR */
|
||||||
tmp_int = nm_device_wimax_get_cinr (NM_DEVICE_WIMAX (device));
|
tmp_int = nm_device_wimax_get_cinr (NM_DEVICE_WIMAX (device));
|
||||||
if (tmp_int)
|
if (tmp_int)
|
||||||
cinr = g_strdup_printf ("%d dB", tmp_int);
|
cinr = g_strdup_printf ("%d dB", tmp_int);
|
||||||
nmc->allowed_fields[3].value = cinr ? cinr : "";
|
|
||||||
|
|
||||||
/* TX Power */
|
/* TX Power */
|
||||||
tmp_int = nm_device_wimax_get_tx_power (NM_DEVICE_WIMAX (device));
|
tmp_int = nm_device_wimax_get_tx_power (NM_DEVICE_WIMAX (device));
|
||||||
if (tmp_int)
|
if (tmp_int)
|
||||||
txpow = g_strdup_printf ("%'.2f dBm", (float) tmp_int / 2.0);
|
txpow = g_strdup_printf ("%'.2f dBm", (float) tmp_int / 2.0);
|
||||||
nmc->allowed_fields[4].value = txpow ? txpow : "";
|
|
||||||
|
|
||||||
/* BSID */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
bsid = (char *) nm_device_wimax_get_bsid (NM_DEVICE_WIMAX (device));
|
set_val_strc (arr, 0, nmc_fields_dev_show_sections[5].name); /* "WIMAX-PROPERTIES" */
|
||||||
nmc->allowed_fields[5].value = bsid ? bsid : "";
|
set_val_str (arr, 1, cfreq);
|
||||||
|
set_val_str (arr, 2, rssi);
|
||||||
|
set_val_str (arr, 3, cinr);
|
||||||
|
set_val_str (arr, 4, txpow);
|
||||||
|
set_val_strc (arr, 5, nm_device_wimax_get_bsid (NM_DEVICE_WIMAX (device)));
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -797,19 +815,19 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
const GPtrArray *nsps;
|
const GPtrArray *nsps;
|
||||||
int g, idx = 1;
|
int g, idx = 1;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dev_wimax_list;
|
tmpl = nmc_fields_dev_wimax_list;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dev_wimax_list);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_WIMAX_LIST_FOR_DEV_LIST, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_WIMAX_LIST_FOR_DEV_LIST, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
|
||||||
|
|
||||||
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
|
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
|
||||||
for (g = 0; nsps && g < nsps->len; g++) {
|
for (g = 0; nsps && g < nsps->len; g++) {
|
||||||
NMWimaxNsp *nsp = g_ptr_array_index (nsps, g);
|
NMWimaxNsp *nsp = g_ptr_array_index (nsps, g);
|
||||||
|
|
||||||
detail_wimax_nsp (nsp, nmc, device, idx++);
|
fill_output_wimax_nsp (nsp, nmc, device, idx++, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
}
|
}
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -858,18 +876,20 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
if (bond_slaves_str->len > 0)
|
if (bond_slaves_str->len > 0)
|
||||||
g_string_truncate (bond_slaves_str, bond_slaves_str->len-1); /* Chop off last space */
|
g_string_truncate (bond_slaves_str, bond_slaves_str->len-1); /* Chop off last space */
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dev_show_bond_prop;
|
tmpl = nmc_fields_dev_show_bond_prop;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dev_show_bond_prop);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_BOND_PROP_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_BOND_PROP_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = (char *) nmc_fields_dev_show_sections[11].name; /* "BOND" */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
nmc->allowed_fields[1].value = bond_slaves_str->str;
|
set_val_strc (arr, 0, nmc_fields_dev_show_sections[11].name); /* "BOND" */
|
||||||
|
set_val_str (arr, 1, bond_slaves_str->str);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
|
|
||||||
g_string_free (bond_slaves_str, TRUE);
|
g_string_free (bond_slaves_str, FALSE);
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -879,18 +899,19 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[12].name)) {
|
if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[12].name)) {
|
||||||
char * vlan_id_str = g_strdup_printf ("%u", nm_device_vlan_get_vlan_id (NM_DEVICE_VLAN (device)));
|
char * vlan_id_str = g_strdup_printf ("%u", nm_device_vlan_get_vlan_id (NM_DEVICE_VLAN (device)));
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dev_show_vlan_prop;
|
tmpl = nmc_fields_dev_show_vlan_prop;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dev_show_vlan_prop);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_VLAN_PROP_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_VLAN_PROP_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = (char *) nmc_fields_dev_show_sections[12].name; /* "VLAN" */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
nmc->allowed_fields[1].value = vlan_id_str;
|
set_val_strc (arr, 0, nmc_fields_dev_show_sections[12].name); /* "VLAN" */
|
||||||
|
set_val_str (arr, 1, vlan_id_str);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
|
|
||||||
g_free (vlan_id_str);
|
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -902,10 +923,11 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
char **ac_arr = NULL;
|
char **ac_arr = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dev_show_connections;
|
tmpl = nmc_fields_dev_show_connections;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
tmpl_len = sizeof (nmc_fields_dev_show_connections);
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_CONNECTIONS_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_SHOW_CONNECTIONS_ALL, tmpl, NULL);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
/* available-connections */
|
/* available-connections */
|
||||||
avail_cons = nm_device_get_available_connections (device);
|
avail_cons = nm_device_get_available_connections (device);
|
||||||
@@ -931,15 +953,15 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
if (ac_paths_str->len > 0)
|
if (ac_paths_str->len > 0)
|
||||||
g_string_append_c (ac_paths_str, '}');
|
g_string_append_c (ac_paths_str, '}');
|
||||||
|
|
||||||
set_val_str (nmc->allowed_fields, 0, (char *) nmc_fields_dev_show_sections[13].name); /* "CONNECTIONS" */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
|
||||||
set_val_str (nmc->allowed_fields, 1, ac_paths_str->str);
|
set_val_strc (arr, 0, nmc_fields_dev_show_sections[13].name); /* "CONNECTIONS" */
|
||||||
set_val_arr (nmc->allowed_fields, 2, ac_arr);
|
set_val_str (arr, 1, ac_paths_str->str);
|
||||||
|
set_val_arr (arr, 2, (ac_arr));
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
|
|
||||||
g_string_free (ac_paths_str, TRUE);
|
g_string_free (ac_paths_str, FALSE);
|
||||||
g_strfreev (ac_arr);
|
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -949,15 +971,18 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_device_status (NMDevice *device, NmCli *nmc)
|
fill_output_device_status (NMDevice *device, NmCli *nmc)
|
||||||
{
|
{
|
||||||
nmc->allowed_fields[0].value = (char *) nm_device_get_iface (device);
|
NmcOutputField *arr = nmc_dup_fields_array (nmc_fields_dev_status,
|
||||||
nmc->allowed_fields[1].value = (char *) nm_device_get_type_description (device);
|
sizeof (nmc_fields_dev_status),
|
||||||
nmc->allowed_fields[2].value = (char *) nmc_device_state_to_string (nm_device_get_state (device));
|
0);
|
||||||
nmc->allowed_fields[3].value = (char *) nm_object_get_path (NM_OBJECT (device));
|
|
||||||
|
|
||||||
nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
|
set_val_strc (arr, 0, nm_device_get_iface (device));
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
set_val_strc (arr, 1, nm_device_get_type_description (device));
|
||||||
|
set_val_strc (arr, 2, nmc_device_state_to_string (nm_device_get_state (device)));
|
||||||
|
set_val_strc (arr, 3, nm_object_get_path (NM_OBJECT (device)));
|
||||||
|
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
@@ -969,9 +994,8 @@ do_devices_status (NmCli *nmc, int argc, char **argv)
|
|||||||
char *fields_str;
|
char *fields_str;
|
||||||
char *fields_all = NMC_FIELDS_DEV_STATUS_ALL;
|
char *fields_all = NMC_FIELDS_DEV_STATUS_ALL;
|
||||||
char *fields_common = NMC_FIELDS_DEV_STATUS_COMMON;
|
char *fields_common = NMC_FIELDS_DEV_STATUS_COMMON;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
|
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
|
fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
|
||||||
@@ -986,8 +1010,9 @@ do_devices_status (NmCli *nmc, int argc, char **argv)
|
|||||||
else
|
else
|
||||||
fields_str = nmc->required_fields;
|
fields_str = nmc->required_fields;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dev_status;
|
tmpl = nmc_fields_dev_status;
|
||||||
nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &error);
|
tmpl_len = sizeof (nmc_fields_dev_status);
|
||||||
|
nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, &error);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error->code == 0)
|
if (error->code == 0)
|
||||||
@@ -1011,14 +1036,18 @@ do_devices_status (NmCli *nmc, int argc, char **argv)
|
|||||||
if (!nmc_versions_match (nmc))
|
if (!nmc_versions_match (nmc))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Print headers */
|
/* Add headers */
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
|
|
||||||
nmc->print_fields.header_name = _("Status of devices");
|
nmc->print_fields.header_name = _("Status of devices");
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields);
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
devices = get_devices_sorted (nmc->client);
|
devices = get_devices_sorted (nmc->client);
|
||||||
for (i = 0; devices[i]; i++)
|
for (i = 0; devices[i]; i++)
|
||||||
show_device_status (devices[i], nmc);
|
fill_output_device_status (devices[i], nmc);
|
||||||
|
|
||||||
|
/* Now print all data */
|
||||||
|
print_data (nmc);
|
||||||
|
|
||||||
g_free (devices);
|
g_free (devices);
|
||||||
|
|
||||||
return NMC_RESULT_SUCCESS;
|
return NMC_RESULT_SUCCESS;
|
||||||
@@ -1074,6 +1103,7 @@ do_devices_show (NmCli *nmc, int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
/* Show details for all devices */
|
/* Show details for all devices */
|
||||||
for (i = 0; devices[i]; i++) {
|
for (i = 0; devices[i]; i++) {
|
||||||
|
nmc_empty_output_fields (nmc);
|
||||||
show_device_info (devices[i], nmc);
|
show_device_info (devices[i], nmc);
|
||||||
if (devices[i + 1])
|
if (devices[i + 1])
|
||||||
printf ("\n"); /* Empty line */
|
printf ("\n"); /* Empty line */
|
||||||
@@ -1242,20 +1272,29 @@ show_acces_point_info (NMDevice *device, NmCli *nmc)
|
|||||||
const char *active_bssid = NULL;
|
const char *active_bssid = NULL;
|
||||||
const GPtrArray *aps;
|
const GPtrArray *aps;
|
||||||
APInfo *info;
|
APInfo *info;
|
||||||
|
NmcOutputField *arr;
|
||||||
|
|
||||||
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
|
||||||
active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (device));
|
active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (device));
|
||||||
active_bssid = active_ap ? nm_access_point_get_bssid (active_ap) : NULL;
|
active_bssid = active_ap ? nm_access_point_get_bssid (active_ap) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arr = nmc_dup_fields_array (nmc_fields_dev_wifi_list, sizeof (nmc_fields_dev_wifi_list),
|
||||||
|
NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
info = g_malloc0 (sizeof (APInfo));
|
info = g_malloc0 (sizeof (APInfo));
|
||||||
info->nmc = nmc;
|
info->nmc = nmc;
|
||||||
info->index = 1;
|
info->index = 1;
|
||||||
|
info->output_flags = 0;
|
||||||
info->active_bssid = active_bssid;
|
info->active_bssid = active_bssid;
|
||||||
info->device = nm_device_get_iface (device);
|
info->device = nm_device_get_iface (device);
|
||||||
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device));
|
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device));
|
||||||
if (aps && aps->len)
|
if (aps && aps->len)
|
||||||
g_ptr_array_foreach ((GPtrArray *) aps, detail_access_point, (gpointer) info);
|
g_ptr_array_foreach ((GPtrArray *) aps, fill_output_access_point, (gpointer) info);
|
||||||
|
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
|
nmc_empty_output_fields (nmc);
|
||||||
g_free (info);
|
g_free (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1274,9 +1313,9 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
char *fields_str;
|
char *fields_str;
|
||||||
char *fields_all = NMC_FIELDS_DEV_WIFI_LIST_ALL;
|
char *fields_all = NMC_FIELDS_DEV_WIFI_LIST_ALL;
|
||||||
char *fields_common = NMC_FIELDS_DEV_WIFI_LIST_COMMON;
|
char *fields_common = NMC_FIELDS_DEV_WIFI_LIST_COMMON;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
const char *base_hdr = _("Wi-Fi scan list");
|
||||||
|
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (strcmp (*argv, "ifname") == 0) {
|
if (strcmp (*argv, "ifname") == 0) {
|
||||||
@@ -1302,7 +1341,6 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
||||||
fields_str = fields_common;
|
fields_str = fields_common;
|
||||||
else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0)
|
else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0)
|
||||||
@@ -1310,8 +1348,9 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
else
|
else
|
||||||
fields_str = nmc->required_fields;
|
fields_str = nmc->required_fields;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dev_wifi_list;
|
tmpl = nmc_fields_dev_wifi_list;
|
||||||
nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &error);
|
tmpl_len = sizeof (nmc_fields_dev_wifi_list);
|
||||||
|
nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, &error);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error->code == 0)
|
if (error->code == 0)
|
||||||
@@ -1335,10 +1374,6 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
if (!nmc_versions_match (nmc))
|
if (!nmc_versions_match (nmc))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Print headers */
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
|
|
||||||
nmc->print_fields.header_name = _("Wi-Fi scan list");
|
|
||||||
|
|
||||||
devices = get_devices_sorted (nmc->client);
|
devices = get_devices_sorted (nmc->client);
|
||||||
if (ifname) {
|
if (ifname) {
|
||||||
/* Device specified - list only APs of this interface */
|
/* Device specified - list only APs of this interface */
|
||||||
@@ -1351,13 +1386,15 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
g_string_printf (nmc->return_text, _("Error: Device '%s' not found."), ifname);
|
g_string_printf (nmc->return_text, _("Error: Device '%s' not found."), ifname);
|
||||||
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Main header name */
|
||||||
|
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr, ifname);
|
||||||
|
|
||||||
if (NM_IS_DEVICE_WIFI (device)) {
|
if (NM_IS_DEVICE_WIFI (device)) {
|
||||||
if (bssid_user) {
|
if (bssid_user) {
|
||||||
/* Specific AP requested - list only that */
|
/* Specific AP requested - list only that */
|
||||||
@@ -1373,20 +1410,27 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
g_free (bssid_up);
|
g_free (bssid_up);
|
||||||
}
|
}
|
||||||
if (!ap) {
|
if (!ap) {
|
||||||
g_string_printf (nmc->return_text, _("Error: Access point with bssid '%s' not found."), bssid_user);
|
g_string_printf (nmc->return_text, _("Error: Access point with bssid '%s' not found."),
|
||||||
|
bssid_user);
|
||||||
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
/* Add headers (field names) */
|
||||||
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
info = g_malloc0 (sizeof (APInfo));
|
info = g_malloc0 (sizeof (APInfo));
|
||||||
info->nmc = nmc;
|
info->nmc = nmc;
|
||||||
info->index = 1;
|
info->index = 1;
|
||||||
|
info->output_flags = 0;
|
||||||
info->active_bssid = NULL;
|
info->active_bssid = NULL;
|
||||||
info->device = nm_device_get_iface (device);
|
info->device = nm_device_get_iface (device);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
|
||||||
detail_access_point (ap, info);
|
fill_output_access_point (ap, info);
|
||||||
|
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
g_free (info);
|
g_free (info);
|
||||||
} else {
|
} else {
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
|
||||||
show_acces_point_info (device, nmc);
|
show_acces_point_info (device, nmc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1396,7 +1440,6 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* List APs for all devices */
|
/* List APs for all devices */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
|
||||||
if (bssid_user) {
|
if (bssid_user) {
|
||||||
/* Specific AP requested - list only that */
|
/* Specific AP requested - list only that */
|
||||||
for (i = 0; devices[i]; i++) {
|
for (i = 0; devices[i]; i++) {
|
||||||
@@ -1405,6 +1448,12 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
if (!NM_IS_DEVICE_WIFI (dev))
|
if (!NM_IS_DEVICE_WIFI (dev))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* Main header name */
|
||||||
|
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr, nm_device_get_iface (dev));
|
||||||
|
|
||||||
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (dev));
|
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (dev));
|
||||||
for (j = 0; aps && (j < aps->len); j++) {
|
for (j = 0; aps && (j < aps->len); j++) {
|
||||||
char *bssid_up;
|
char *bssid_up;
|
||||||
@@ -1418,22 +1467,30 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
info = g_malloc0 (sizeof (APInfo));
|
info = g_malloc0 (sizeof (APInfo));
|
||||||
info->nmc = nmc;
|
info->nmc = nmc;
|
||||||
info->index = 1;
|
info->index = 1;
|
||||||
|
info->output_flags = 0;
|
||||||
info->active_bssid = NULL;
|
info->active_bssid = NULL;
|
||||||
info->device = nm_device_get_iface (dev);
|
info->device = nm_device_get_iface (dev);
|
||||||
detail_access_point (ap, info);
|
fill_output_access_point (ap, info);
|
||||||
g_free (info);
|
g_free (info);
|
||||||
}
|
}
|
||||||
g_free (bssid_up);
|
g_free (bssid_up);
|
||||||
}
|
}
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
|
nmc_empty_output_fields (nmc);
|
||||||
}
|
}
|
||||||
if (!ap) {
|
if (!ap) {
|
||||||
g_string_printf (nmc->return_text, _("Error: Access point with bssid '%s' not found."), bssid_user);
|
g_string_printf (nmc->return_text, _("Error: Access point with bssid '%s' not found."),
|
||||||
|
bssid_user);
|
||||||
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; devices[i]; i++) {
|
for (i = 0; devices[i]; i++) {
|
||||||
NMDevice *dev = devices[i];
|
NMDevice *dev = devices[i];
|
||||||
|
|
||||||
|
/* Main header name */
|
||||||
|
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr,
|
||||||
|
nm_device_get_iface (dev));
|
||||||
if (NM_IS_DEVICE_WIFI (dev))
|
if (NM_IS_DEVICE_WIFI (dev))
|
||||||
show_acces_point_info (dev, nmc);
|
show_acces_point_info (dev, nmc);
|
||||||
}
|
}
|
||||||
@@ -1968,13 +2025,21 @@ show_nsp_info (NMDevice *device, NmCli *nmc)
|
|||||||
{
|
{
|
||||||
const GPtrArray *nsps;
|
const GPtrArray *nsps;
|
||||||
int i, idx = 1;
|
int i, idx = 1;
|
||||||
|
NmcOutputField *arr;
|
||||||
|
|
||||||
|
/* Add headers (field names) */
|
||||||
|
arr = nmc_dup_fields_array (nmc_fields_dev_wimax_list, sizeof (nmc_fields_dev_wimax_list),
|
||||||
|
NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
|
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
|
||||||
for (i = 0; nsps && i < nsps->len; i++) {
|
for (i = 0; nsps && i < nsps->len; i++) {
|
||||||
NMWimaxNsp *nsp = g_ptr_array_index (nsps, i);
|
NMWimaxNsp *nsp = g_ptr_array_index (nsps, i);
|
||||||
|
|
||||||
detail_wimax_nsp (nsp, nmc, device, idx++);
|
fill_output_wimax_nsp (nsp, nmc, device, idx++, 0);
|
||||||
}
|
}
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
|
nmc_empty_output_fields (nmc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
@@ -1991,9 +2056,9 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||||||
char *fields_str;
|
char *fields_str;
|
||||||
char *fields_all = NMC_FIELDS_DEV_WIMAX_LIST_ALL;
|
char *fields_all = NMC_FIELDS_DEV_WIMAX_LIST_ALL;
|
||||||
char *fields_common = NMC_FIELDS_DEV_WIMAX_LIST_COMMON;
|
char *fields_common = NMC_FIELDS_DEV_WIMAX_LIST_COMMON;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
const char *base_hdr = _("WiMAX NSP list");
|
||||||
|
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (strcmp (*argv, "ifname") == 0) {
|
if (strcmp (*argv, "ifname") == 0) {
|
||||||
@@ -2025,8 +2090,9 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||||||
else
|
else
|
||||||
fields_str = nmc->required_fields;
|
fields_str = nmc->required_fields;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_dev_wimax_list;
|
tmpl = nmc_fields_dev_wimax_list;
|
||||||
nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &error);
|
tmpl_len = sizeof (nmc_fields_dev_wimax_list);
|
||||||
|
nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, &error);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error->code == 0)
|
if (error->code == 0)
|
||||||
@@ -2050,10 +2116,6 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||||||
if (!nmc_versions_match (nmc))
|
if (!nmc_versions_match (nmc))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Print headers */
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
|
|
||||||
nmc->print_fields.header_name = _("WiMAX NSP list");
|
|
||||||
|
|
||||||
devices = nm_client_get_devices (nmc->client);
|
devices = nm_client_get_devices (nmc->client);
|
||||||
if (ifname) {
|
if (ifname) {
|
||||||
/* Device specified - list only NSPs of this interface */
|
/* Device specified - list only NSPs of this interface */
|
||||||
@@ -2073,6 +2135,9 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Main header name */
|
||||||
|
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr, ifname);
|
||||||
|
|
||||||
if (NM_IS_DEVICE_WIMAX (device)) {
|
if (NM_IS_DEVICE_WIMAX (device)) {
|
||||||
if (nsp_user) {
|
if (nsp_user) {
|
||||||
/* Specific NSP requested - list only that */
|
/* Specific NSP requested - list only that */
|
||||||
@@ -2092,10 +2157,12 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||||||
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
/* Add headers (field names) */
|
||||||
detail_wimax_nsp (nsp, nmc, device, 1);
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
fill_output_wimax_nsp (nsp, nmc, device, 1, 0);
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
} else {
|
} else {
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
|
||||||
show_nsp_info (device, nmc);
|
show_nsp_info (device, nmc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2105,7 +2172,6 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* List NSPs for all devices */
|
/* List NSPs for all devices */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
|
||||||
if (nsp_user) {
|
if (nsp_user) {
|
||||||
/* Specific NSP requested - list only that */
|
/* Specific NSP requested - list only that */
|
||||||
for (i = 0; devices && (i < devices->len); i++) {
|
for (i = 0; devices && (i < devices->len); i++) {
|
||||||
@@ -2115,6 +2181,12 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||||||
if (!NM_IS_DEVICE_WIMAX (dev))
|
if (!NM_IS_DEVICE_WIMAX (dev))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* Main header name */
|
||||||
|
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr, nm_device_get_iface (dev));
|
||||||
|
|
||||||
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (dev));
|
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (dev));
|
||||||
for (j = 0, nsp = NULL; nsps && (j < nsps->len); j++) {
|
for (j = 0, nsp = NULL; nsps && (j < nsps->len); j++) {
|
||||||
NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j);
|
NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j);
|
||||||
@@ -2124,10 +2196,12 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||||||
nsp_up = g_ascii_strup (nsp_user, -1);
|
nsp_up = g_ascii_strup (nsp_user, -1);
|
||||||
if (!strcmp (nsp_up, candidate_name)) {
|
if (!strcmp (nsp_up, candidate_name)) {
|
||||||
nsp = candidate_nsp;
|
nsp = candidate_nsp;
|
||||||
detail_wimax_nsp (nsp, nmc, dev, idx);
|
fill_output_wimax_nsp (nsp, nmc, dev, idx, 0);
|
||||||
}
|
}
|
||||||
g_free (nsp_up);
|
g_free (nsp_up);
|
||||||
}
|
}
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
|
nmc_empty_output_fields (nmc);
|
||||||
}
|
}
|
||||||
if (!nsp) {
|
if (!nsp) {
|
||||||
g_string_printf (nmc->return_text, _("Error: Access point with nsp '%s' not found."), nsp_user);
|
g_string_printf (nmc->return_text, _("Error: Access point with nsp '%s' not found."), nsp_user);
|
||||||
@@ -2137,6 +2211,11 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
for (i = 0; devices && (i < devices->len); i++) {
|
for (i = 0; devices && (i < devices->len); i++) {
|
||||||
NMDevice *dev = g_ptr_array_index (devices, i);
|
NMDevice *dev = g_ptr_array_index (devices, i);
|
||||||
|
|
||||||
|
/* Main header name */
|
||||||
|
nmc->print_fields.header_name = (char *) construct_header_name (base_hdr,
|
||||||
|
nm_device_get_iface (dev));
|
||||||
|
|
||||||
if (NM_IS_DEVICE_WIMAX (dev))
|
if (NM_IS_DEVICE_WIMAX (dev))
|
||||||
show_nsp_info (dev, nmc);
|
show_nsp_info (dev, nmc);
|
||||||
}
|
}
|
||||||
|
@@ -167,9 +167,8 @@ show_nm_status (NmCli *nmc, const char *pretty_header_name, const char *print_fl
|
|||||||
const char *fields_str;
|
const char *fields_str;
|
||||||
const char *fields_all = print_flds ? print_flds : NMC_FIELDS_NM_STATUS_ALL;
|
const char *fields_all = print_flds ? print_flds : NMC_FIELDS_NM_STATUS_ALL;
|
||||||
const char *fields_common = print_flds ? print_flds : NMC_FIELDS_NM_STATUS_COMMON;
|
const char *fields_common = print_flds ? print_flds : NMC_FIELDS_NM_STATUS_COMMON;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
|
|
||||||
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
||||||
fields_str = fields_common;
|
fields_str = fields_common;
|
||||||
@@ -178,8 +177,9 @@ show_nm_status (NmCli *nmc, const char *pretty_header_name, const char *print_fl
|
|||||||
else
|
else
|
||||||
fields_str = nmc->required_fields;
|
fields_str = nmc->required_fields;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_nm_status;
|
tmpl = nmc_fields_nm_status;
|
||||||
nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &error);
|
tmpl_len = sizeof (nmc_fields_nm_status);
|
||||||
|
nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, &error);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error->code == 0)
|
if (error->code == 0)
|
||||||
@@ -218,25 +218,26 @@ show_nm_status (NmCli *nmc, const char *pretty_header_name, const char *print_fl
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
|
|
||||||
nmc->print_fields.header_name = pretty_header_name ? (char *) pretty_header_name : _("NetworkManager status");
|
nmc->print_fields.header_name = pretty_header_name ? (char *) pretty_header_name : _("NetworkManager status");
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = nm_running ? _("running") : _("not running");
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, 0);
|
||||||
nmc->allowed_fields[1].value = nm_running ? (char *) nm_client_get_version (nmc->client) : _("unknown");
|
set_val_strc (arr, 0, nm_running ? _("running") : _("not running"));
|
||||||
nmc->allowed_fields[2].value = (char *) nm_state_to_string (state);
|
set_val_strc (arr, 1, nm_running ? nm_client_get_version (nmc->client) : _("unknown"));
|
||||||
nmc->allowed_fields[3].value = (char *) net_enabled_str;
|
set_val_strc (arr, 2, nm_state_to_string (state));
|
||||||
nmc->allowed_fields[4].value = (char *) wireless_hw_enabled_str;
|
set_val_strc (arr, 3, net_enabled_str);
|
||||||
nmc->allowed_fields[5].value = (char *) wireless_enabled_str;
|
set_val_strc (arr, 4, wireless_hw_enabled_str);
|
||||||
nmc->allowed_fields[6].value = (char *) wwan_hw_enabled_str;
|
set_val_strc (arr, 5, wireless_enabled_str);
|
||||||
nmc->allowed_fields[7].value = (char *) wwan_enabled_str;
|
set_val_strc (arr, 6, wwan_hw_enabled_str);
|
||||||
|
set_val_strc (arr, 7, wwan_enabled_str);
|
||||||
#if WITH_WIMAX
|
#if WITH_WIMAX
|
||||||
nmc->allowed_fields[8].value = (char *) wimax_hw_enabled_str;
|
set_val_strc (arr, 8, wimax_hw_enabled_str);
|
||||||
nmc->allowed_fields[9].value = (char *) wimax_enabled_str;
|
set_val_strc (arr, 9, wimax_enabled_str);
|
||||||
#endif
|
#endif
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
|
print_data (nmc); /* Print all data */
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -308,9 +309,8 @@ show_nm_permissions (NmCli *nmc)
|
|||||||
const char *fields_str;
|
const char *fields_str;
|
||||||
const char *fields_all = NMC_FIELDS_NM_PERMISSIONS_ALL;
|
const char *fields_all = NMC_FIELDS_NM_PERMISSIONS_ALL;
|
||||||
const char *fields_common = NMC_FIELDS_NM_PERMISSIONS_COMMON;
|
const char *fields_common = NMC_FIELDS_NM_PERMISSIONS_COMMON;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
|
|
||||||
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
||||||
fields_str = fields_common;
|
fields_str = fields_common;
|
||||||
@@ -319,8 +319,9 @@ show_nm_permissions (NmCli *nmc)
|
|||||||
else
|
else
|
||||||
fields_str = nmc->required_fields;
|
fields_str = nmc->required_fields;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_nm_permissions;
|
tmpl = nmc_fields_nm_permissions;
|
||||||
nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &error);
|
tmpl_len = sizeof (nmc_fields_nm_permissions);
|
||||||
|
nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, &error);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error->code == 0)
|
if (error->code == 0)
|
||||||
@@ -341,18 +342,19 @@ show_nm_permissions (NmCli *nmc)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
|
|
||||||
nmc->print_fields.header_name = _("NetworkManager permissions");
|
nmc->print_fields.header_name = _("NetworkManager permissions");
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
for (perm = NM_CLIENT_PERMISSION_NONE + 1; perm <= NM_CLIENT_PERMISSION_LAST; perm++) {
|
for (perm = NM_CLIENT_PERMISSION_NONE + 1; perm <= NM_CLIENT_PERMISSION_LAST; perm++) {
|
||||||
NMClientPermissionResult perm_result = nm_client_get_permission_result (nmc->client, perm);
|
NMClientPermissionResult perm_result = nm_client_get_permission_result (nmc->client, perm);
|
||||||
|
|
||||||
set_val_str (nmc->allowed_fields, 0, (char *) permission_to_string (perm));
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, 0);
|
||||||
set_val_str (nmc->allowed_fields, 1, (char *) permission_result_to_string (perm_result));
|
set_val_strc (arr, 0, permission_to_string (perm));
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
|
set_val_strc (arr, 1, permission_result_to_string (perm_result));
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
}
|
}
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -366,9 +368,8 @@ show_general_logging (NmCli *nmc)
|
|||||||
const char *fields_str;
|
const char *fields_str;
|
||||||
const char *fields_all = NMC_FIELDS_NM_LOGGING_ALL;
|
const char *fields_all = NMC_FIELDS_NM_LOGGING_ALL;
|
||||||
const char *fields_common = NMC_FIELDS_NM_LOGGING_COMMON;
|
const char *fields_common = NMC_FIELDS_NM_LOGGING_COMMON;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
NmcOutputField *tmpl, *arr;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
size_t tmpl_len;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
|
||||||
|
|
||||||
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
||||||
fields_str = fields_common;
|
fields_str = fields_common;
|
||||||
@@ -377,8 +378,10 @@ show_general_logging (NmCli *nmc)
|
|||||||
else
|
else
|
||||||
fields_str = nmc->required_fields;
|
fields_str = nmc->required_fields;
|
||||||
|
|
||||||
nmc->allowed_fields = nmc_fields_nm_logging;
|
tmpl = nmc_fields_nm_logging;
|
||||||
nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &error);
|
tmpl_len = sizeof (nmc_fields_nm_logging);
|
||||||
|
nmc->print_fields.indices = parse_output_fields (fields_str, tmpl, &error);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error->code == 0)
|
if (error->code == 0)
|
||||||
g_string_printf (nmc->return_text, _("Error: 'general logging': %s"), error->message);
|
g_string_printf (nmc->return_text, _("Error: 'general logging': %s"), error->message);
|
||||||
@@ -399,17 +402,17 @@ show_general_logging (NmCli *nmc)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
|
|
||||||
nmc->print_fields.header_name = _("NetworkManager logging");
|
nmc->print_fields.header_name = _("NetworkManager logging");
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_MAIN_HEADER_ADD | NMC_OF_FLAG_FIELD_NAMES);
|
||||||
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
set_val_str (nmc->allowed_fields, 0, level);
|
arr = nmc_dup_fields_array (tmpl, tmpl_len, 0);
|
||||||
set_val_str (nmc->allowed_fields, 1, domains);
|
set_val_str (arr, 0, level);
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
|
set_val_str (arr, 1, domains);
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
g_ptr_array_add (nmc->output_data, arr);
|
||||||
|
|
||||||
|
print_data (nmc); /* Print all data */
|
||||||
|
|
||||||
g_free (level);
|
|
||||||
g_free (domains);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user