From c07f617bff0ac759263c6639d27eac26eb5283fd Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 29 Jun 2021 20:11:34 +0200 Subject: [PATCH] libnm: refactor to_dbus_fcn() for "wifi-sec.wep-key-type" property The goal is to get rid of gprop_to_dbus_fcn() uses. --- .../nm-setting-wireless-security.c | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/libnm-core-impl/nm-setting-wireless-security.c b/src/libnm-core-impl/nm-setting-wireless-security.c index ed77563295..0b806b7a0e 100644 --- a/src/libnm-core-impl/nm-setting-wireless-security.c +++ b/src/libnm-core-impl/nm-setting-wireless-security.c @@ -1290,13 +1290,24 @@ set_secret_flags(NMSetting * setting, ->set_secret_flags(setting, secret_name, flags, error); } -/* NMSettingWirelessSecurity:wep-key-type is an enum, but needs to be marshalled - * as 'u', not 'i', for backward-compatibility. - */ static GVariant * -wep_key_type_to_dbus(const GValue *from) +wep_key_type_to_dbus(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty * property_info, + NMConnection * connection, + NMSetting * setting, + NMConnectionSerializationFlags flags, + const NMConnectionSerializationOptions *options) { - return g_variant_new_uint32(g_value_get_enum(from)); + NMWepKeyType t; + + t = nm_setting_wireless_security_get_wep_key_type(NM_SETTING_WIRELESS_SECURITY(setting)); + if (t == NM_WEP_KEY_TYPE_UNKNOWN) + return NULL; + + /* NMSettingWirelessSecurity:wep-key-type is an enum, but needs to be marshalled + * as 'u', not 'i', for backward-compatibility. + */ + return g_variant_new_uint32(t); } /*****************************************************************************/ @@ -1924,10 +1935,12 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) NM_TYPE_WEP_KEY_TYPE, NM_WEP_KEY_TYPE_UNKNOWN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_WEP_KEY_TYPE], - &nm_sett_info_propert_type_plain_u, - .to_dbus_data.gprop_to_dbus_fcn = wep_key_type_to_dbus, ); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_WEP_KEY_TYPE], + NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_UINT32, + .to_dbus_fcn = wep_key_type_to_dbus, + .compare_fcn = _nm_setting_property_compare_fcn_default)); /** * NMSettingWirelessSecurity:wps-method: