summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-09-12 15:55:35 +0200
committerThomas Haller <thaller@redhat.com>2017-09-12 16:03:05 +0200
commite36ed195baea1caaba7916594782c91d189e38ba (patch)
tree19785f90e754e414ca2c85bf197b2887997b5bd8
parent6ad53975b32c895876966d5b0204462fe9b87f88 (diff)
downloadNetworkManager-e36ed195baea1caaba7916594782c91d189e38ba.tar.gz
cli: refactor ipv4.dad-timeout to use int-getter
- Reduce duplicated code and implement the property according to best-practice for integer types. - Do not translate the output - This way, the setter also supprts the nick names
-rw-r--r--clients/common/nm-meta-setting-desc.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
index c520a92652..707f293284 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -3130,28 +3130,6 @@ _get_fcn_ip_config_routes (ARGS_GET_FCN)
RETURN_STR_TO_FREE (g_string_free (printable, FALSE));
}
-static gconstpointer
-_get_fcn_ip4_config_dad_timeout (ARGS_GET_FCN)
-{
- NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting);
- gint dad_timeout;
-
- RETURN_UNSUPPORTED_GET_TYPE ();
-
- dad_timeout = nm_setting_ip_config_get_dad_timeout (s_ip);
- if (get_type != NM_META_ACCESSOR_GET_TYPE_PRETTY)
- RETURN_STR_TO_FREE (g_strdup_printf ("%d", dad_timeout));
-
- switch (dad_timeout) {
- case -1:
- RETURN_STR_TO_FREE (g_strdup_printf (_("%d (default)"), dad_timeout));
- case 0:
- RETURN_STR_TO_FREE (g_strdup_printf (_("%d (off)"), dad_timeout));
- default:
- RETURN_STR_TO_FREE (g_strdup_printf ("%d", dad_timeout));
- }
-}
-
static const char *ipv4_valid_methods[] = {
NM_SETTING_IP4_CONFIG_METHOD_AUTO,
NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL,
@@ -5452,9 +5430,18 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
.property_type = &_pt_gobject_bool,
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DAD_TIMEOUT, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DAD_TIMEOUT,
- .property_type = DEFINE_PROPERTY_TYPE (
- .get_fcn = _get_fcn_ip4_config_dad_timeout,
- .set_fcn = _set_fcn_gobject_int,
+ .property_type = &_pt_gobject_int,
+ .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_int,
+ .value_infos = INT_VALUE_INFOS (
+ {
+ .value = -1,
+ .nick = "default",
+ },
+ {
+ .value = 0,
+ .nick = "off",
+ }
+ ),
),
),
NULL