mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-01 20:00:12 +01:00
libnm: implement NMSettInfoProperty.direct_also_notify for notifying two properties
We will deprecate "connection.master" for "connection.controller". The old property will become an alias for the new one. That means, when setting the property we must emit notifications for both the old and the new property. Add "NMSettInfoProperty.direct_also_notify" for that. This is not fully flexible, as it only works for direct properties (duh) and only allows to specify one addtitional GParamSpec (of the same NMSetting). It is however sufficient for our use.
This commit is contained in:
parent
64ffa1bf40
commit
d6d30ace22
3 changed files with 32 additions and 2 deletions
|
|
@ -993,6 +993,10 @@ out_notify:
|
|||
*
|
||||
* Currently we never set that, also because we still support glib 2.40. */
|
||||
nm_assert(!NM_FLAGS_HAS(pspec->flags, 1 << 30 /* G_PARAM_EXPLICIT_NOTIFY */));
|
||||
|
||||
/* We only notify "direct_also_notify". The other property is automatically notified. */
|
||||
nm_gobject_notify_together_by_pspec(object, property_info->direct_also_notify);
|
||||
|
||||
return;
|
||||
|
||||
out_fail:
|
||||
|
|
@ -1388,7 +1392,9 @@ _nm_setting_property_from_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_FROM_DB
|
|||
|
||||
if (nm_strdup_reset_take(_nm_setting_get_private_field(setting, sett_info, property_info),
|
||||
length > 0 ? nm_utils_hwaddr_ntoa(array, length) : NULL)) {
|
||||
g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec);
|
||||
nm_gobject_notify_together_by_pspec(setting,
|
||||
property_info->param_spec,
|
||||
property_info->direct_also_notify);
|
||||
} else
|
||||
*out_is_modified = FALSE;
|
||||
|
||||
|
|
@ -1692,7 +1698,9 @@ out_unchanged:
|
|||
|
||||
out_notify:
|
||||
*out_is_modified = TRUE;
|
||||
g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec);
|
||||
nm_gobject_notify_together_by_pspec(setting,
|
||||
property_info->param_spec,
|
||||
property_info->direct_also_notify);
|
||||
return TRUE;
|
||||
|
||||
out_error_wrong_dbus_type:
|
||||
|
|
|
|||
|
|
@ -4749,6 +4749,24 @@ test_setting_metadata(void)
|
|||
if (!can_have_direct_set_fcn)
|
||||
g_assert(!sip->direct_set_fcn.set_string);
|
||||
|
||||
if (sip->property_type->direct_type == NM_VALUE_TYPE_NONE)
|
||||
g_assert(!sip->direct_also_notify);
|
||||
else {
|
||||
if (sip->direct_also_notify) {
|
||||
guint prop_idx2;
|
||||
guint cnt = 0;
|
||||
|
||||
for (prop_idx2 = 0; prop_idx2 < sis->property_infos_len; prop_idx2++) {
|
||||
const NMSettInfoProperty *sip2 = &sis->property_infos[prop_idx2];
|
||||
|
||||
if (sip2->param_spec == sip->direct_also_notify)
|
||||
cnt++;
|
||||
}
|
||||
g_assert_cmpint(cnt, ==, 1u);
|
||||
g_assert(sip->param_spec != sip->direct_also_notify);
|
||||
}
|
||||
}
|
||||
|
||||
n_special_options = (sip->direct_set_string_mac_address_len != 0)
|
||||
+ (!!sip->direct_set_string_strip)
|
||||
+ (!!sip->direct_set_string_ascii_strdown)
|
||||
|
|
|
|||
|
|
@ -784,6 +784,10 @@ struct _NMSettInfoProperty {
|
|||
const char *src);
|
||||
} direct_set_fcn;
|
||||
|
||||
/* For direct properties, this is the param_spec that also should be
|
||||
* notified on changes. */
|
||||
GParamSpec *direct_also_notify;
|
||||
|
||||
/* This only has meaning for direct properties (property_type->direct_type != NM_VALUE_TYPE_UNSPEC).
|
||||
* In that case, this is the offset where _nm_setting_get_private() can find
|
||||
* the direct location. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue