diff options
author | Wen Liang <liangwen12year@gmail.com> | 2023-01-17 10:22:04 -0500 |
---|---|---|
committer | Wen Liang <liangwen12year@gmail.com> | 2023-02-16 11:04:14 -0500 |
commit | af677542b59ae69a3925eb4c6bf37d3cc06e1dc1 (patch) | |
tree | e5999b7a325d9ac9de247e1fc6b89f3403c5ece3 /src | |
parent | b4e96ec0673e4499d75a340203d63d5087960271 (diff) | |
download | NetworkManager-af677542b59ae69a3925eb4c6bf37d3cc06e1dc1.tar.gz |
dbus: deprecate the NMActiveConnection Master property
To embrace the inclusive language, deprecate the NMActiveConnection
Master property and in favor of the NMActiveConnection Controller
property.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/nm-active-connection.c | 16 | ||||
-rw-r--r-- | src/core/nm-active-connection.h | 1 | ||||
-rw-r--r-- | src/core/vpn/nm-vpn-connection.c | 5 | ||||
-rw-r--r-- | src/libnm-client-impl/libnm.ver | 5 | ||||
-rw-r--r-- | src/libnm-client-impl/nm-active-connection.c | 115 | ||||
-rw-r--r-- | src/libnm-client-public/nm-active-connection.h | 4 |
6 files changed, 133 insertions, 13 deletions
diff --git a/src/core/nm-active-connection.c b/src/core/nm-active-connection.c index 4488d909e3..6f62a601c2 100644 --- a/src/core/nm-active-connection.c +++ b/src/core/nm-active-connection.c @@ -81,6 +81,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMActiveConnection, PROP_DHCP6_CONFIG, PROP_VPN, PROP_MASTER, + PROP_CONTROLLER, PROP_INT_SETTINGS_CONNECTION, PROP_INT_APPLIED_CONNECTION, @@ -803,7 +804,7 @@ check_master_ready(NMActiveConnection *self) * ensure that if the master connection was created without a device * that we notify clients when the master device is known. */ - _notify(self, PROP_MASTER); + nm_gobject_notify_together(self, PROP_MASTER, PROP_CONTROLLER); } } @@ -1343,6 +1344,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_VPN: g_value_set_boolean(value, priv->vpn); break; + case PROP_CONTROLLER: case PROP_MASTER: if (priv->master) master_device = nm_active_connection_get_device(priv->master); @@ -1440,8 +1442,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps /* construct-only */ priv->vpn = g_value_get_boolean(value); break; - case PROP_MASTER: - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -1601,6 +1601,9 @@ static const NMDBusInterfaceInfoExtended interface_info_active_connection = { "o", NM_ACTIVE_CONNECTION_DHCP6_CONFIG), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Vpn", "b", NM_ACTIVE_CONNECTION_VPN), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Controller", + "o", + NM_ACTIVE_CONNECTION_CONTROLLER), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Master", "o", NM_ACTIVE_CONNECTION_MASTER), ), ), @@ -1732,6 +1735,13 @@ nm_active_connection_class_init(NMActiveConnectionClass *ac_class) NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_CONTROLLER] = + g_param_spec_string(NM_ACTIVE_CONNECTION_CONTROLLER, + "", + "", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + /* Internal properties */ obj_properties[PROP_INT_SETTINGS_CONNECTION] = g_param_spec_object(NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION, diff --git a/src/core/nm-active-connection.h b/src/core/nm-active-connection.h index a2353a6558..15db68c369 100644 --- a/src/core/nm-active-connection.h +++ b/src/core/nm-active-connection.h @@ -38,6 +38,7 @@ #define NM_ACTIVE_CONNECTION_DHCP6_CONFIG "dhcp6-config" #define NM_ACTIVE_CONNECTION_VPN "vpn" #define NM_ACTIVE_CONNECTION_MASTER "master" +#define NM_ACTIVE_CONNECTION_CONTROLLER "controller" /* Internal non-exported properties */ #define NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION "int-settings-connection" diff --git a/src/core/vpn/nm-vpn-connection.c b/src/core/vpn/nm-vpn-connection.c index 4fb926a595..d7102a12ef 100644 --- a/src/core/vpn/nm-vpn-connection.c +++ b/src/core/vpn/nm-vpn-connection.c @@ -99,6 +99,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMVpnConnection, PROP_VPN_STATE, PROP_BANNER, #define PROP_IP4_CONFIG 2000 #define PROP_IP6_CONFIG 2001 #define PROP_MASTER 2002 +#define PROP_CONTROLLER 2003 ); typedef struct { @@ -2899,6 +2900,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_IP6_CONFIG: nm_dbus_utils_g_value_set_object_path(value, priv->ip_data_6.ip_config); break; + case PROP_CONTROLLER: case PROP_MASTER: nm_dbus_utils_g_value_set_object_path( value, @@ -3065,6 +3067,9 @@ nm_vpn_connection_class_init(NMVpnConnectionClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); + g_object_class_override_property(object_class, + PROP_CONTROLLER, + NM_ACTIVE_CONNECTION_CONTROLLER); g_object_class_override_property(object_class, PROP_MASTER, NM_ACTIVE_CONNECTION_MASTER); g_object_class_override_property(object_class, PROP_IP4_CONFIG, diff --git a/src/libnm-client-impl/libnm.ver b/src/libnm-client-impl/libnm.ver index c373c82322..732c933e57 100644 --- a/src/libnm-client-impl/libnm.ver +++ b/src/libnm-client-impl/libnm.ver @@ -1919,3 +1919,8 @@ global: nm_utils_ensure_gtypes; nm_version_info_capability_get_type; } libnm_1_40_0; + +libnm_1_44_0 { +global: + nm_active_connection_get_controller; +} libnm_1_42_0; diff --git a/src/libnm-client-impl/nm-active-connection.c b/src/libnm-client-impl/nm-active-connection.c index 52e82b9f08..e4948b9b56 100644 --- a/src/libnm-client-impl/nm-active-connection.c +++ b/src/libnm-client-impl/nm-active-connection.c @@ -12,6 +12,7 @@ #include "nm-object-private.h" #include "libnm-core-intern/nm-core-internal.h" #include "nm-device.h" +#include "nm-client.h" #include "nm-connection.h" #include "nm-vpn-connection.h" #include "nm-dbus-helpers.h" @@ -39,7 +40,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMActiveConnection, PROP_IP6_CONFIG, PROP_DHCP6_CONFIG, PROP_VPN, - PROP_MASTER, ); + PROP_MASTER, + PROP_CONTROLLER, ); enum { STATE_CHANGED, @@ -51,7 +53,7 @@ static guint signals[LAST_SIGNAL]; enum { PROPERTY_O_IDX_CONNECTION, - PROPERTY_O_IDX_MASTER, + PROPERTY_O_IDX_CONTROLLER, PROPERTY_O_IDX_IP4_CONFIG, PROPERTY_O_IDX_IP6_CONFIG, PROPERTY_O_IDX_DHCP4_CONFIG, @@ -73,6 +75,7 @@ typedef struct _NMActiveConnectionPrivate { bool is_default; bool is_default6; bool is_vpn; + bool controller_is_new : 1; guint32 reason; } NMActiveConnectionPrivate; @@ -381,14 +384,33 @@ nm_active_connection_get_vpn(NMActiveConnection *connection) * Gets the master #NMDevice of the connection. * * Returns: (transfer none): the master #NMDevice of the #NMActiveConnection. + * + * Deprecated: 1.44. Use nm_active_connection_get_controller() instead. **/ NMDevice * nm_active_connection_get_master(NMActiveConnection *connection) { + return nm_active_connection_get_controller(connection); +} + +/** + * nm_active_connection_get_controller: + * @connection: a #NMActiveConnection + * + * Gets the controller #NMDevice of the connection. This replaces the + * deprecated nm_active_connection_get_master() method. + * + * Returns: (transfer none): the controller #NMDevice of the #NMActiveConnection. + * + * Since: 1.44 + **/ +NMDevice * +nm_active_connection_get_controller(NMActiveConnection *connection) +{ g_return_val_if_fail(NM_IS_ACTIVE_CONNECTION(connection), NULL); return nml_dbus_property_o_get_obj( - &NM_ACTIVE_CONNECTION_GET_PRIVATE(connection)->property_o[PROPERTY_O_IDX_MASTER]); + &NM_ACTIVE_CONNECTION_GET_PRIVATE(connection)->property_o[PROPERTY_O_IDX_CONTROLLER]); } /*****************************************************************************/ @@ -455,6 +477,54 @@ is_ready(NMObject *nmobj) /*****************************************************************************/ +static NMLDBusNotifyUpdatePropFlags +active_connection_update_prop_controller(NMClient *client, + NMLDBusObject *dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant *value) +{ + NMActiveConnection *self = NM_ACTIVE_CONNECTION(dbobj->nmobj); + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); + const NMLDBusMetaProperty *meta_property = &meta_iface->dbus_properties[dbus_property_idx]; + gboolean is_new = (meta_property->obj_properties_idx == PROP_CONTROLLER); + NMLDBusNotifyUpdatePropFlags notify_update_prop_flags; + guint controller_dbus_property_idx; + + nm_assert(NM_IN_STRSET(meta_property->dbus_property_name, "Controller", "Master")); + nm_assert(NM_IN_SET(meta_property->obj_properties_idx, PROP_CONTROLLER, PROP_MASTER)); + + if (!is_new && priv->controller_is_new) { + /* once the instance is marked to honor the new property, the + * changed signal for the old variant gets ignored. */ + goto out; + } + + priv->controller_is_new = is_new; + controller_dbus_property_idx = meta_iface->obj_properties_reverse_idx[PROP_CONTROLLER]; + nm_assert(nm_streq(meta_iface->dbus_properties[controller_dbus_property_idx].dbus_property_name, + "Controller")); + + notify_update_prop_flags = + nml_dbus_property_o_notify(client, + &priv->property_o[PROPERTY_O_IDX_CONTROLLER], + dbobj, + meta_iface, + controller_dbus_property_idx, + value); + if (notify_update_prop_flags == NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE) + goto out; + nm_assert(notify_update_prop_flags == NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NOTIFY); + + _nm_client_queue_notify_object(client, self, obj_properties[PROP_MASTER]); + _nm_client_queue_notify_object(client, self, obj_properties[PROP_CONTROLLER]); + +out: + return NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE; +} + +/*****************************************************************************/ + static void nm_active_connection_init(NMActiveConnection *self) { @@ -531,7 +601,8 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) g_value_set_boolean(value, nm_active_connection_get_vpn(self)); break; case PROP_MASTER: - g_value_set_object(value, nm_active_connection_get_master(self)); + case PROP_CONTROLLER: + g_value_set_object(value, nm_active_connection_get_controller(self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -549,6 +620,12 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_connection_active = NML_DBUS_META NMActiveConnectionPrivate, property_o[PROPERTY_O_IDX_CONNECTION], nm_remote_connection_get_type), + NML_DBUS_META_PROPERTY_INIT_FCN("Controller", + PROP_CONTROLLER, + "o", + active_connection_update_prop_controller, + .extra.property_vtable_o = &((const NMLDBusPropertVTableO){ + .get_o_type_fcn = (nm_device_get_type)})), NML_DBUS_META_PROPERTY_INIT_B("Default", PROP_DEFAULT, NMActiveConnectionPrivate, @@ -583,11 +660,12 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_connection_active = NML_DBUS_META NMActiveConnectionPrivate, property_o[PROPERTY_O_IDX_IP6_CONFIG], nm_ip6_config_get_type), - NML_DBUS_META_PROPERTY_INIT_O_PROP("Master", - PROP_MASTER, - NMActiveConnectionPrivate, - property_o[PROPERTY_O_IDX_MASTER], - nm_device_get_type), + NML_DBUS_META_PROPERTY_INIT_FCN("Master", + PROP_MASTER, + "o", + active_connection_update_prop_controller, + .extra.property_vtable_o = &((const NMLDBusPropertVTableO){ + .get_o_type_fcn = (nm_device_get_type)})), NML_DBUS_META_PROPERTY_INIT_O("SpecificObject", PROP_SPECIFIC_OBJECT_PATH, NMActiveConnectionPrivate, @@ -802,7 +880,9 @@ nm_active_connection_class_init(NMActiveConnectionClass *klass) /** * NMActiveConnection:master: * - * The master device if one exists. + * The master device if one exists. Replaced by the "controller" property. + * + * Deprecated: 1.44 **/ obj_properties[PROP_MASTER] = g_param_spec_object(NM_ACTIVE_CONNECTION_MASTER, "", @@ -810,6 +890,21 @@ nm_active_connection_class_init(NMActiveConnectionClass *klass) NM_TYPE_DEVICE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + /** + * NMActiveConnection:controller: + * + * The controller device if one exists. This replaces the deprecated + * "master" property. + * + * Since: 1.44 + **/ + obj_properties[PROP_CONTROLLER] = + g_param_spec_object(NM_ACTIVE_CONNECTION_CONTROLLER, + "", + "", + NM_TYPE_DEVICE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_connection_active); diff --git a/src/libnm-client-public/nm-active-connection.h b/src/libnm-client-public/nm-active-connection.h index 5c3148269a..b4391d0fcc 100644 --- a/src/libnm-client-public/nm-active-connection.h +++ b/src/libnm-client-public/nm-active-connection.h @@ -42,6 +42,7 @@ G_BEGIN_DECLS #define NM_ACTIVE_CONNECTION_DHCP6_CONFIG "dhcp6-config" #define NM_ACTIVE_CONNECTION_VPN "vpn" #define NM_ACTIVE_CONNECTION_MASTER "master" +#define NM_ACTIVE_CONNECTION_CONTROLLER "controller" /** * NMActiveConnection: @@ -65,7 +66,10 @@ NMActiveConnectionStateReason nm_active_connection_get_state_reason(NMActiveConn struct _NMDevice; +_NM_DEPRECATED_INCLUSIVE_LANGUAGE_1_44 struct _NMDevice *nm_active_connection_get_master(NMActiveConnection *connection); +NM_AVAILABLE_IN_1_44 +struct _NMDevice *nm_active_connection_get_controller(NMActiveConnection *connection); gboolean nm_active_connection_get_default(NMActiveConnection *connection); NMIPConfig *nm_active_connection_get_ip4_config(NMActiveConnection *connection); |