summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-30 13:01:20 +0200
committerThomas Haller <thaller@redhat.com>2018-07-09 15:43:55 +0200
commitba350a3495f8e8c3b5bd50d96d5818fe8e5c5136 (patch)
tree3b95fda5093d842b17c0f9490631e5b29341eaa8
parent918be83493f8f5d73092b43afcfeef94d4dc113e (diff)
downloadNetworkManager-ba350a3495f8e8c3b5bd50d96d5818fe8e5c5136.tar.gz
cli: add additional user-data argument to get_fcn()
The function nmc_print() receives a list of "targets". These are essentially the rows that should be printed (while the "fields" list represents the columns). When filling the cells with values, it calles repeatedly get_fcn() on the column descriptors (fields), by passing each row (target). The caller must be well aware that the fields and targets are compatible. For example, in some cases the targets are NMDevice instances and the target type must correspond to what get_fcn() expects. Add another user-data pointer that is passed on along with the targets. That is useful, if we have a list of targets/rows, but pass in additional data that applies to all rows alike. It is still unused.
-rw-r--r--clients/cli/common.c2
-rw-r--r--clients/cli/connections.c5
-rw-r--r--clients/cli/devices.c6
-rw-r--r--clients/cli/general.c3
-rw-r--r--clients/cli/settings.c1
-rw-r--r--clients/cli/utils.c10
-rw-r--r--clients/cli/utils.h2
-rw-r--r--clients/common/nm-meta-setting-access.c2
-rw-r--r--clients/common/nm-meta-setting-access.h1
-rw-r--r--clients/common/nm-meta-setting-desc.c3
-rw-r--r--clients/common/nm-meta-setting-desc.h1
11 files changed, 34 insertions, 2 deletions
diff --git a/clients/cli/common.c b/clients/cli/common.c
index de55a49141..ede447bad0 100644
--- a/clients/cli/common.c
+++ b/clients/cli/common.c
@@ -356,6 +356,7 @@ print_ip_config (NMIPConfig *cfg,
if (!nmc_print (nmc_config,
(gpointer[]) { cfg, NULL },
NULL,
+ NULL,
addr_family == AF_INET
? NMC_META_GENERIC_GROUP ("IP4", metagen_ip4_config, N_("GROUP"))
: NMC_META_GENERIC_GROUP ("IP6", metagen_ip6_config, N_("GROUP")),
@@ -387,6 +388,7 @@ print_dhcp_config (NMDhcpConfig *dhcp,
if (!nmc_print (nmc_config,
(gpointer[]) { dhcp, NULL },
NULL,
+ NULL,
addr_family == AF_INET
? NMC_META_GENERIC_GROUP ("DHCP4", metagen_dhcp_config, N_("GROUP"))
: NMC_META_GENERIC_GROUP ("DHCP6", metagen_dhcp_config, N_("GROUP")),
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index f947a45e34..0e286d7c05 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -1380,6 +1380,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
nmc_print (&nmc->nmc_config,
(gpointer[]) { acon, NULL },
NULL,
+ NULL,
NMC_META_GENERIC_GROUP ("GENERAL", metagen_con_active_general, N_("GROUP")),
f,
NULL);
@@ -1428,6 +1429,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
nmc_print (&nmc->nmc_config,
(gpointer[]) { acon, NULL },
NULL,
+ NULL,
NMC_META_GENERIC_GROUP ("VPN", metagen_con_active_vpn, N_("NAME")),
group_fld,
NULL);
@@ -1985,10 +1987,11 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
g_ptr_array_add (items, NULL);
if (!nmc_print (&nmc->nmc_config,
items->pdata,
+ NULL,
active_only
? _("NetworkManager active profiles")
: _("NetworkManager connection profiles"),
- (const NMMetaAbstractInfo *const*) metagen_con_show,
+ (const NMMetaAbstractInfo *const*) metagen_con_show,
fields_str,
&err))
goto finish;
diff --git a/clients/cli/devices.c b/clients/cli/devices.c
index 4b2438b2bd..05b7c6defd 100644
--- a/clients/cli/devices.c
+++ b/clients/cli/devices.c
@@ -1475,6 +1475,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
nmc_print (&nmc->nmc_config,
(gpointer[]) { device, NULL },
NULL,
+ NULL,
NMC_META_GENERIC_GROUP ("GENERAL", metagen_device_detail_general, N_("NAME")),
f,
NULL);
@@ -1488,6 +1489,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
nmc_print (&nmc->nmc_config,
(gpointer[]) { device, NULL },
NULL,
+ NULL,
NMC_META_GENERIC_GROUP ("CAPABILITIES", metagen_device_detail_capabilities, N_("NAME")),
f,
NULL);
@@ -1502,6 +1504,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
nmc_print (&nmc->nmc_config,
(gpointer[]) { device, NULL },
NULL,
+ NULL,
NMC_META_GENERIC_GROUP ("WIFI-PROPERTIES", metagen_device_detail_wifi_properties, N_("NAME")),
f,
NULL);
@@ -1559,6 +1562,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
nmc_print (&nmc->nmc_config,
(gpointer[]) { device, NULL },
NULL,
+ NULL,
NMC_META_GENERIC_GROUP ("WIRED-PROPERTIES", metagen_device_detail_wired_properties, N_("NAME")),
f,
NULL);
@@ -1660,6 +1664,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
nmc_print (&nmc->nmc_config,
(gpointer[]) { device, NULL },
NULL,
+ NULL,
NMC_META_GENERIC_GROUP ("CONNECTIONS", metagen_device_detail_connections, N_("NAME")),
f,
NULL);
@@ -1718,6 +1723,7 @@ do_devices_status (NmCli *nmc, int argc, char **argv)
if (!nmc_print (&nmc->nmc_config,
(gpointer *) devices,
+ NULL,
N_("Status of devices"),
(const NMMetaAbstractInfo *const*) metagen_device_status,
fields_str,
diff --git a/clients/cli/general.c b/clients/cli/general.c
index 2e030ec78a..cb87c11054 100644
--- a/clients/cli/general.c
+++ b/clients/cli/general.c
@@ -508,6 +508,7 @@ show_nm_status (NmCli *nmc, const char *pretty_header_name, const char *print_fl
if (!nmc_print (&nmc->nmc_config,
(gpointer[]) { nmc, NULL },
+ NULL,
pretty_header_name ?: N_("NetworkManager status"),
(const NMMetaAbstractInfo *const*) metagen_general_status,
fields_str,
@@ -565,6 +566,7 @@ print_permissions (void *user_data)
if (!nmc_print (&nmc->nmc_config,
permissions,
+ NULL,
_("NetworkManager permissions"),
(const NMMetaAbstractInfo *const*) metagen_general_permissions,
fields_str,
@@ -657,6 +659,7 @@ show_general_logging (NmCli *nmc)
if (!nmc_print (&nmc->nmc_config,
(gpointer const []) { &d, NULL },
+ NULL,
_("NetworkManager logging"),
(const NMMetaAbstractInfo *const*) metagen_general_logging,
fields_str,
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index 01142ba262..b39713f901 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -814,6 +814,7 @@ setting_details (const NmcConfig *nmc_config, NMSetting *setting, const char *on
if (!nmc_print (nmc_config,
(gpointer[]) { setting, NULL },
NULL,
+ NULL,
(const NMMetaAbstractInfo *const[]) { (const NMMetaAbstractInfo *) setting_info, NULL },
fields_str,
&error))
diff --git a/clients/cli/utils.c b/clients/cli/utils.c
index 365a03030e..064343a151 100644
--- a/clients/cli/utils.c
+++ b/clients/cli/utils.c
@@ -72,6 +72,7 @@ _meta_type_nmc_generic_info_get_fcn (const NMMetaAbstractInfo *abstract_info,
const NMMetaEnvironment *environment,
gpointer environment_user_data,
gpointer target,
+ gpointer target_data,
NMMetaAccessorGetType get_type,
NMMetaAccessorGetFlags get_flags,
NMMetaAccessorGetOutFlags *out_flags,
@@ -95,7 +96,9 @@ _meta_type_nmc_generic_info_get_fcn (const NMMetaAbstractInfo *abstract_info,
if (info->get_fcn) {
return info->get_fcn (environment,
environment_user_data,
- info, target,
+ info,
+ target,
+ target_data,
get_type,
get_flags,
out_flags,
@@ -954,6 +957,7 @@ _print_data_cell_clear (gpointer cell_p)
static void
_print_fill (const NmcConfig *nmc_config,
gpointer const *targets,
+ gpointer targets_data,
const PrintDataCol *cols,
guint cols_len,
GArray **out_header_row,
@@ -1040,6 +1044,7 @@ _print_fill (const NmcConfig *nmc_config,
nmc_meta_environment,
nmc_meta_environment_arg,
target,
+ targets_data,
text_get_type,
text_get_flags,
&text_out_flags,
@@ -1072,6 +1077,7 @@ _print_fill (const NmcConfig *nmc_config,
nmc_meta_environment,
nmc_meta_environment_arg,
target,
+ targets_data,
NM_META_ACCESSOR_GET_TYPE_COLOR,
NM_META_ACCESSOR_GET_FLAGS_NONE,
&color_out_flags,
@@ -1320,6 +1326,7 @@ _print_do (const NmcConfig *nmc_config,
gboolean
nmc_print (const NmcConfig *nmc_config,
gpointer const *targets,
+ gpointer targets_data,
const char *header_name_no_l10n,
const NMMetaAbstractInfo *const*fields,
const char *fields_str,
@@ -1337,6 +1344,7 @@ nmc_print (const NmcConfig *nmc_config,
_print_fill (nmc_config,
targets,
+ targets_data,
&g_array_index (cols, PrintDataCol, 0),
cols->len,
&header_row,
diff --git a/clients/cli/utils.h b/clients/cli/utils.h
index 980c1234da..b2a3e5ebbb 100644
--- a/clients/cli/utils.h
+++ b/clients/cli/utils.h
@@ -246,6 +246,7 @@ struct _NmcMetaGenericInfo {
gpointer environment_user_data, \
const NmcMetaGenericInfo *info, \
gpointer target, \
+ gpointer target_data, \
NMMetaAccessorGetType get_type, \
NMMetaAccessorGetFlags get_flags, \
NMMetaAccessorGetOutFlags *out_flags, \
@@ -337,6 +338,7 @@ nmc_meta_generic_get_enum_with_detail (NmcMetaGenericGetEnumType get_enum_type,
gboolean nmc_print (const NmcConfig *nmc_config,
gpointer const *targets,
+ gpointer targets_data,
const char *header_name_no_l10n,
const NMMetaAbstractInfo *const*fields,
const char *fields_str,
diff --git a/clients/common/nm-meta-setting-access.c b/clients/common/nm-meta-setting-access.c
index a1bfed47b7..26cc7a57e0 100644
--- a/clients/common/nm-meta-setting-access.c
+++ b/clients/common/nm-meta-setting-access.c
@@ -229,6 +229,7 @@ nm_meta_abstract_info_get (const NMMetaAbstractInfo *abstract_info,
const NMMetaEnvironment *environment,
gpointer environment_user_data,
gpointer target,
+ gpointer target_data,
NMMetaAccessorGetType get_type,
NMMetaAccessorGetFlags get_flags,
NMMetaAccessorGetOutFlags *out_flags,
@@ -250,6 +251,7 @@ nm_meta_abstract_info_get (const NMMetaAbstractInfo *abstract_info,
environment,
environment_user_data,
target,
+ target_data,
get_type,
get_flags,
out_flags,
diff --git a/clients/common/nm-meta-setting-access.h b/clients/common/nm-meta-setting-access.h
index 577cad787a..591d65de0b 100644
--- a/clients/common/nm-meta-setting-access.h
+++ b/clients/common/nm-meta-setting-access.h
@@ -55,6 +55,7 @@ gconstpointer nm_meta_abstract_info_get (const NMMetaAbstractInfo *abstract_info
const NMMetaEnvironment *environment,
gpointer environment_user_data,
gpointer target,
+ gpointer target_data,
NMMetaAccessorGetType get_type,
NMMetaAccessorGetFlags get_flags,
NMMetaAccessorGetOutFlags *out_flags,
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
index 34c9d8e59f..37cefc2c5f 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -8007,6 +8007,7 @@ _meta_type_setting_info_editor_get_fcn (const NMMetaAbstractInfo *abstract_info,
const NMMetaEnvironment *environment,
gpointer environment_user_data,
gpointer target,
+ gpointer target_data,
NMMetaAccessorGetType get_type,
NMMetaAccessorGetFlags get_flags,
NMMetaAccessorGetOutFlags *out_flags,
@@ -8017,6 +8018,7 @@ _meta_type_setting_info_editor_get_fcn (const NMMetaAbstractInfo *abstract_info,
nm_assert (!out_to_free || !*out_to_free);
nm_assert (out_flags && !*out_flags);
+ nm_assert (!target_data);
if (!NM_IN_SET (get_type,
NM_META_ACCESSOR_GET_TYPE_PARSABLE,
@@ -8033,6 +8035,7 @@ _meta_type_property_info_get_fcn (const NMMetaAbstractInfo *abstract_info,
const NMMetaEnvironment *environment,
gpointer environment_user_data,
gpointer target,
+ gpointer target_data,
NMMetaAccessorGetType get_type,
NMMetaAccessorGetFlags get_flags,
NMMetaAccessorGetOutFlags *out_flags,
diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h
index 01a823cce2..2aa27f1b73 100644
--- a/clients/common/nm-meta-setting-desc.h
+++ b/clients/common/nm-meta-setting-desc.h
@@ -359,6 +359,7 @@ struct _NMMetaType {
const NMMetaEnvironment *environment,
gpointer environment_user_data,
gpointer target,
+ gpointer target_data,
NMMetaAccessorGetType get_type,
NMMetaAccessorGetFlags get_flags,
NMMetaAccessorGetOutFlags *out_flags,