summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-30 13:01:20 +0200
committerThomas Haller <thaller@redhat.com>2018-06-13 15:29:41 +0200
commit0496fee063d6a3d84e5ab13b8a412d4ed9e2892a (patch)
treec873be6644ba62e613e6373308d9f93076059858
parent321ccc63fa9cd64277ea6781ce9502e0625ef0ba (diff)
downloadNetworkManager-0496fee063d6a3d84e5ab13b8a412d4ed9e2892a.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 9e3b6ef851..801f840217 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -1370,6 +1370,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);
@@ -1418,6 +1419,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_("GROUP")),
group_fld,
NULL);
@@ -1976,10 +1978,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 001be486d4..c3457f9622 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_("GROUP")),
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_("GROUP")),
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_("GROUP")),
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_("GROUP")),
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_("GROUP")),
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 4139360981..987917c245 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,
@@ -946,6 +949,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,
@@ -1032,6 +1036,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,
@@ -1064,6 +1069,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,
@@ -1312,6 +1318,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,
@@ -1329,6 +1336,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 1154fabfb6..2dd872058b 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -7888,6 +7888,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,
@@ -7914,6 +7915,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,
@@ -7924,6 +7926,7 @@ _meta_type_property_info_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,
diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h
index e7ab6e860a..01751a39ab 100644
--- a/clients/common/nm-meta-setting-desc.h
+++ b/clients/common/nm-meta-setting-desc.h
@@ -358,6 +358,7 @@ struct _NMMetaType {
const NMMetaEnvironment *environment,
gpointer environment_user_data,
gpointer target,
+ gpointer target_data,
NMMetaAccessorGetType get_type,
NMMetaAccessorGetFlags get_flags,
NMMetaAccessorGetOutFlags *out_flags,