libnm: refactor to_dbus_fcn() for "wifi-sec.wep-key-type" property

The goal is to get rid of gprop_to_dbus_fcn() uses.
This commit is contained in:
Thomas Haller 2021-06-29 20:11:34 +02:00
parent a0cf869daa
commit c07f617bff
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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: