diff options
author | Antonio Cardace <acardace@redhat.com> | 2020-03-13 10:23:13 +0100 |
---|---|---|
committer | Antonio Cardace <acardace@redhat.com> | 2020-03-13 10:23:13 +0100 |
commit | 1a76141e66c9f7b8dc265955d3f3d149bc6c95ba (patch) | |
tree | 348d436a6cf08f8bc1f43c496ddf5f5eb2f18883 | |
parent | 219ee9a9e8bcbd8f83a7736f0c68fc5376befe9b (diff) | |
parent | 067a3d6c08615eadf55941dec266c7396d823f66 (diff) | |
download | NetworkManager-1a76141e66c9f7b8dc265955d3f3d149bc6c95ba.tar.gz |
nm-device: merge branch 'ac/nm-device-hwaddr'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/430
57 files changed, 302 insertions, 685 deletions
diff --git a/introspection/org.freedesktop.NetworkManager.Device.Bluetooth.xml b/introspection/org.freedesktop.NetworkManager.Device.Bluetooth.xml index 43a3047c1e..1f5e618975 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Bluetooth.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Bluetooth.xml @@ -11,6 +11,8 @@ HwAddress: Bluetooth hardware address of the device. + + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Bond.xml b/introspection/org.freedesktop.NetworkManager.Device.Bond.xml index 30421a5450..c7ccf38998 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Bond.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Bond.xml @@ -11,6 +11,8 @@ HwAddress: Hardware address of the device. +n + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Bridge.xml b/introspection/org.freedesktop.NetworkManager.Device.Bridge.xml index 011805acb0..5a35f54dd1 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Bridge.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Bridge.xml @@ -11,6 +11,8 @@ HwAddress: Hardware address of the device. +n + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Dummy.xml b/introspection/org.freedesktop.NetworkManager.Device.Dummy.xml index ce87693fb9..2c5675e8ae 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Dummy.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Dummy.xml @@ -11,6 +11,8 @@ HwAddress: Hardware address of the device. +n + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Generic.xml b/introspection/org.freedesktop.NetworkManager.Device.Generic.xml index ecbfed6895..b847018be4 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Generic.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Generic.xml @@ -11,6 +11,8 @@ HwAddress: Hardware address of the device. +n + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Infiniband.xml b/introspection/org.freedesktop.NetworkManager.Device.Infiniband.xml index cc03b74b8d..53f71486df 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Infiniband.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Infiniband.xml @@ -11,6 +11,8 @@ HwAddress: Hardware address of the device. +n + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Lowpan.xml b/introspection/org.freedesktop.NetworkManager.Device.Lowpan.xml index c0317be6c3..3415f18510 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Lowpan.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Lowpan.xml @@ -11,6 +11,8 @@ HwAddress: The active hardware address of the device. + + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.OlpcMesh.xml b/introspection/org.freedesktop.NetworkManager.Device.OlpcMesh.xml index 0e54403d8f..3ae7ea961d 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.OlpcMesh.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.OlpcMesh.xml @@ -11,6 +11,8 @@ HwAddress: The hardware address of the device. + + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Team.xml b/introspection/org.freedesktop.NetworkManager.Device.Team.xml index a0caa3992a..0a4c72122d 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Team.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Team.xml @@ -11,6 +11,8 @@ HwAddress: Hardware address of the device. +n + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Tun.xml b/introspection/org.freedesktop.NetworkManager.Device.Tun.xml index 9dc4661a99..97bf5848cd 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Tun.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Tun.xml @@ -56,6 +56,8 @@ HwAddress: Hardware address of the device. +n + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Vlan.xml b/introspection/org.freedesktop.NetworkManager.Device.Vlan.xml index 1bc83fce78..b63194ec66 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Vlan.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Vlan.xml @@ -11,6 +11,8 @@ HwAddress: Hardware address of the device. +n + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Vxlan.xml b/introspection/org.freedesktop.NetworkManager.Device.Vxlan.xml index 52b59cc514..035ca09b94 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Vxlan.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Vxlan.xml @@ -19,6 +19,8 @@ HwAddress: Hardware address of the device. +n + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.WifiP2P.xml b/introspection/org.freedesktop.NetworkManager.Device.WifiP2P.xml index 40e6fdbb65..9e74eb6e56 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.WifiP2P.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.WifiP2P.xml @@ -14,6 +14,8 @@ The active hardware address of the device. + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. + Since: 1.16 --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Wired.xml b/introspection/org.freedesktop.NetworkManager.Device.Wired.xml index f62c3f0c3b..c501091951 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Wired.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Wired.xml @@ -12,6 +12,8 @@ HwAddress: Active hardware address of the device. + + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Wireless.xml b/introspection/org.freedesktop.NetworkManager.Device.Wireless.xml index af54408816..d9af0964ec 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Wireless.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Wireless.xml @@ -46,6 +46,8 @@ HwAddress: The active hardware address of the device. + + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.Wpan.xml b/introspection/org.freedesktop.NetworkManager.Device.Wpan.xml index 32bc6f95d4..1591ce81f6 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.Wpan.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.Wpan.xml @@ -11,6 +11,8 @@ HwAddress: The active hardware address of the device. + + DEPRECATED. Use the "HwAddress" property in "org.freedesktop.NetworkManager.Device" instead which exists since version NetworkManager 1.24.0. --> <property name="HwAddress" type="s" access="read"/> diff --git a/introspection/org.freedesktop.NetworkManager.Device.xml b/introspection/org.freedesktop.NetworkManager.Device.xml index ca9dd8d758..e82770fc64 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.xml @@ -290,6 +290,17 @@ <property name="InterfaceFlags" type="u" access="read"/> <!-- + HwAddress: + + The hardware address of the device. + + This replaces the other 'HwAddress' properties on the device-specific D-Bus interfaces. + + Since: 1.24 + --> + <property name="HwAddress" type="s" access="read"/> + + <!-- Reapply: @connection: The optional connection settings that will be reapplied on the device. If empty, the currently active settings-connection will be used. The connection cannot arbitrarly differ from the current applied-connection otherwise the call will fail. Only certain changes are supported, like adding or removing IP addresses. @version_id: If non-zero, the current version id of the applied-connection must match. The current version id can be retrieved via GetAppliedConnection. This optional argument allows to catch concurrent modifications between the GetAppliedConnection call and Reapply. diff --git a/libnm/nm-device-6lowpan.c b/libnm/nm-device-6lowpan.c index 5899df3044..5173b6ad12 100644 --- a/libnm/nm-device-6lowpan.c +++ b/libnm/nm-device-6lowpan.c @@ -13,12 +13,10 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_PARENT, - PROP_HW_ADDRESS, ); typedef struct { NMLDBusPropertyO parent; - char *hw_address; } NMDevice6LowpanPrivate; struct _NMDevice6Lowpan { @@ -62,19 +60,15 @@ nm_device_6lowpan_get_parent (NMDevice6Lowpan *device) * device, and must not be modified. * * Since: 1.14 + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_6lowpan_get_hw_address (NMDevice6Lowpan *device) { g_return_val_if_fail (NM_IS_DEVICE_6LOWPAN (device), NULL); - return NM_DEVICE_6LOWPAN_GET_PRIVATE (device)->hw_address; -} - -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_6lowpan_get_hw_address (NM_DEVICE_6LOWPAN (device)); + return nm_device_get_hw_address (NM_DEVICE (device)); } /*****************************************************************************/ @@ -85,16 +79,6 @@ nm_device_6lowpan_init (NMDevice6Lowpan *device) } static void -dispose (GObject *object) -{ - NMDevice6LowpanPrivate *priv = NM_DEVICE_6LOWPAN_GET_PRIVATE (object); - - G_OBJECT_CLASS (nm_device_6lowpan_parent_class)->dispose (object); - - nm_clear_g_free (&priv->hw_address); -} - -static void get_property (GObject *object, guint prop_id, GValue *value, @@ -106,9 +90,6 @@ get_property (GObject *object, case PROP_PARENT: g_value_set_object (value, nm_device_6lowpan_get_parent (device)); break; - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_6lowpan_get_hw_address (device)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -120,8 +101,8 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_lowpan = NML_DBUS_META_IFA nm_device_6lowpan_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDevice6Lowpan, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_O_PROP ("Parent", PROP_PARENT, NMDevice6Lowpan, _priv.parent, nm_device_get_type ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_O_PROP ("Parent", PROP_PARENT, NMDevice6Lowpan, _priv.parent, nm_device_get_type ), ), ); @@ -130,17 +111,13 @@ nm_device_6lowpan_class_init (NMDevice6LowpanClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS (klass); - NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); object_class->get_property = get_property; - object_class->dispose = dispose; _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT (nm_object_class, NMDevice6Lowpan); _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1 (nm_object_class, NMDevice6LowpanPrivate, parent); - device_class->get_hw_address = get_hw_address; - /** * NMDevice6Lowpan:parent: * @@ -154,18 +131,5 @@ nm_device_6lowpan_class_init (NMDevice6LowpanClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - /** - * NMDevice6Lowpan:hw-address: - * - * The hardware (MAC) address of the device. - * - * Since: 1.14 - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_6LOWPAN_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - _nml_dbus_meta_class_init_with_properties (object_class, &_nml_dbus_meta_iface_nm_device_lowpan); } diff --git a/libnm/nm-device-6lowpan.h b/libnm/nm-device-6lowpan.h index eba4886e39..6f400c8d97 100644 --- a/libnm/nm-device-6lowpan.h +++ b/libnm/nm-device-6lowpan.h @@ -34,8 +34,11 @@ GType nm_device_6lowpan_get_type (void); NM_AVAILABLE_IN_1_14 NMDevice * nm_device_6lowpan_get_parent (NMDevice6Lowpan *device); + NM_AVAILABLE_IN_1_14 +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char * nm_device_6lowpan_get_hw_address (NMDevice6Lowpan *device); + G_END_DECLS #endif /* __NM_DEVICE_6LOWPAN_H__ */ diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index 66c1bf8331..72203247bc 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -16,7 +16,6 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_CARRIER, PROP_SLAVES, ); @@ -50,13 +49,15 @@ G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_bond_get_hw_address (NMDeviceBond *device) { g_return_val_if_fail (NM_IS_DEVICE_BOND (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_BOND_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -116,12 +117,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_BOND; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_bond_get_hw_address (NM_DEVICE_BOND (device)); -} - /*****************************************************************************/ static void @@ -148,9 +143,6 @@ get_property (GObject *object, NMDeviceBond *device = NM_DEVICE_BOND (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_bond_get_hw_address (device)); - break; case PROP_CARRIER: g_value_set_boolean (value, nm_device_bond_get_carrier (device)); break; @@ -168,9 +160,9 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bond = NML_DBUS_META_IFACE nm_device_bond_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceBond, _priv.carrier ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceBond, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_AO_PROP ("Slaves", PROP_SLAVES, NMDeviceBond, _priv.slaves, nm_device_get_type ), + NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceBond, _priv.carrier ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_AO_PROP ("Slaves", PROP_SLAVES, NMDeviceBond, _priv.slaves, nm_device_get_type ), ), ); @@ -190,18 +182,6 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceBond:hw-address: - * - * The hardware (MAC) address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_BOND_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceBond:carrier: diff --git a/libnm/nm-device-bond.h b/libnm/nm-device-bond.h index a65f88f916..2ffe974e36 100644 --- a/libnm/nm-device-bond.h +++ b/libnm/nm-device-bond.h @@ -32,7 +32,9 @@ typedef struct _NMDeviceBondClass NMDeviceBondClass; GType nm_device_bond_get_type (void); +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char *nm_device_bond_get_hw_address (NMDeviceBond *device); + gboolean nm_device_bond_get_carrier (NMDeviceBond *device); const GPtrArray *nm_device_bond_get_slaves (NMDeviceBond *device); diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index f50054d4b2..bee8c17736 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -16,14 +16,12 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_CARRIER, PROP_SLAVES, ); typedef struct { NMLDBusPropertyAO slaves; - char *hw_address; bool carrier; } NMDeviceBridgePrivate; @@ -50,13 +48,15 @@ G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE) * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_bridge_get_hw_address (NMDeviceBridge *device) { g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_BRIDGE_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -121,12 +121,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_BRIDGE; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_bridge_get_hw_address (NM_DEVICE_BRIDGE (device)); -} - /*****************************************************************************/ static void @@ -135,16 +129,6 @@ nm_device_bridge_init (NMDeviceBridge *device) } static void -finalize (GObject *object) -{ - NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (object); - - g_free (priv->hw_address); - - G_OBJECT_CLASS (nm_device_bridge_parent_class)->finalize (object); -} - -static void get_property (GObject *object, guint prop_id, GValue *value, @@ -153,9 +137,6 @@ get_property (GObject *object, NMDeviceBridge *device = NM_DEVICE_BRIDGE (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_bridge_get_hw_address (device)); - break; case PROP_CARRIER: g_value_set_boolean (value, nm_device_bridge_get_carrier (device)); break; @@ -173,9 +154,9 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bridge = NML_DBUS_META_IFA nm_device_bridge_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceBridge, _priv.carrier ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceBridge, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_AO_PROP ("Slaves", PROP_SLAVES, NMDeviceBridge, _priv.slaves, nm_device_get_type ), + NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceBridge, _priv.carrier ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_AO_PROP ("Slaves", PROP_SLAVES, NMDeviceBridge, _priv.slaves, nm_device_get_type ), ), ); @@ -186,7 +167,6 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); - object_class->finalize = finalize; object_class->get_property = get_property; _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT (nm_object_class, NMDeviceBridge); @@ -195,18 +175,6 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceBridge:hw-address: - * - * The hardware (MAC) address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_BRIDGE_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceBridge:carrier: diff --git a/libnm/nm-device-bridge.h b/libnm/nm-device-bridge.h index 339f44dd37..c1d1e18319 100644 --- a/libnm/nm-device-bridge.h +++ b/libnm/nm-device-bridge.h @@ -32,7 +32,9 @@ typedef struct _NMDeviceBridgeClass NMDeviceBridgeClass; GType nm_device_bridge_get_type (void); +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char *nm_device_bridge_get_hw_address (NMDeviceBridge *device); + gboolean nm_device_bridge_get_carrier (NMDeviceBridge *device); const GPtrArray *nm_device_bridge_get_slaves (NMDeviceBridge *device); diff --git a/libnm/nm-device-bt.c b/libnm/nm-device-bt.c index 150b5d84cb..bf7535945c 100644 --- a/libnm/nm-device-bt.c +++ b/libnm/nm-device-bt.c @@ -17,13 +17,11 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_NAME, PROP_BT_CAPABILITIES, ); typedef struct { - char *hw_address; char *name; guint32 bt_capabilities; } NMDeviceBtPrivate; @@ -51,13 +49,15 @@ G_DEFINE_TYPE (NMDeviceBt, nm_device_bt, NM_TYPE_DEVICE) * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_bt_get_hw_address (NMDeviceBt *device) { g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_BT_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -138,7 +138,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro } /* Check BT address */ - hw_addr = nm_device_bt_get_hw_address (NM_DEVICE_BT (device)); + hw_addr = nm_device_get_hw_address (device); if (hw_addr) { if (!nm_utils_hwaddr_valid (hw_addr, ETH_ALEN)) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, @@ -170,12 +170,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_BLUETOOTH; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_bt_get_hw_address (NM_DEVICE_BT (device)); -} - /*****************************************************************************/ static void @@ -188,7 +182,6 @@ finalize (GObject *object) { NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); - g_free (priv->hw_address); g_free (priv->name); G_OBJECT_CLASS (nm_device_bt_parent_class)->finalize (object); @@ -203,9 +196,6 @@ get_property (GObject *object, NMDeviceBt *device = NM_DEVICE_BT (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_bt_get_hw_address (device)); - break; case PROP_NAME: g_value_set_string (value, nm_device_bt_get_name (device)); break; @@ -223,9 +213,9 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bluetooth = NML_DBUS_META_ nm_device_bt_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_U ("BtCapabilities", PROP_BT_CAPABILITIES, NMDeviceBt, _priv.bt_capabilities ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceBt, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_S ("Name", PROP_NAME, NMDeviceBt, _priv.name ), + NML_DBUS_META_PROPERTY_INIT_U ("BtCapabilities", PROP_BT_CAPABILITIES, NMDeviceBt, _priv.bt_capabilities ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_S ("Name", PROP_NAME, NMDeviceBt, _priv.name ), ), ); @@ -240,18 +230,6 @@ nm_device_bt_class_init (NMDeviceBtClass *bt_class) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceBt:hw-address: - * - * The hardware (MAC) address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_BT_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceBt:name: diff --git a/libnm/nm-device-bt.h b/libnm/nm-device-bt.h index 2633c2dc9e..4e38f10423 100644 --- a/libnm/nm-device-bt.h +++ b/libnm/nm-device-bt.h @@ -33,6 +33,7 @@ typedef struct _NMDeviceBtClass NMDeviceBtClass; GType nm_device_bt_get_type (void); +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char *nm_device_bt_get_hw_address (NMDeviceBt *device); const char *nm_device_bt_get_name (NMDeviceBt *device); diff --git a/libnm/nm-device-dummy.c b/libnm/nm-device-dummy.c index 4916cc7d9f..a63cbe941b 100644 --- a/libnm/nm-device-dummy.c +++ b/libnm/nm-device-dummy.c @@ -13,17 +13,8 @@ /*****************************************************************************/ -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, -); - -typedef struct { - char *hw_address; -} NMDeviceDummyPrivate; - struct _NMDeviceDummy { NMDevice parent; - NMDeviceDummyPrivate _priv; }; struct _NMDeviceDummyClass { @@ -46,13 +37,15 @@ G_DEFINE_TYPE (NMDeviceDummy, nm_device_dummy, NM_TYPE_DEVICE) * device, and must not be modified. * * Since: 1.10 + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_dummy_get_hw_address (NMDeviceDummy *device) { g_return_val_if_fail (NM_IS_DEVICE_DUMMY (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_DUMMY_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } static gboolean @@ -85,12 +78,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_DUMMY; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_dummy_get_hw_address (NM_DEVICE_DUMMY (device)); -} - /*****************************************************************************/ static void @@ -98,68 +85,20 @@ nm_device_dummy_init (NMDeviceDummy *device) { } -static void -finalize (GObject *object) -{ - NMDeviceDummyPrivate *priv = NM_DEVICE_DUMMY_GET_PRIVATE (object); - - g_free (priv->hw_address); - - G_OBJECT_CLASS (nm_device_dummy_parent_class)->finalize (object); -} - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - NMDeviceDummy *device = NM_DEVICE_DUMMY (object); - - switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_dummy_get_hw_address (device)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_dummy = NML_DBUS_META_IFACE_INIT_PROP ( +const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_dummy = NML_DBUS_META_IFACE_INIT ( NM_DBUS_INTERFACE_DEVICE_DUMMY, nm_device_dummy_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceDummy, _priv.hw_address ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), ), ); static void nm_device_dummy_class_init (NMDeviceDummyClass *dummy_class) { - GObjectClass *object_class = G_OBJECT_CLASS (dummy_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (dummy_class); - object_class->get_property = get_property; - object_class->finalize = finalize; - device_class->connection_compatible = connection_compatible; - device_class->get_hw_address = get_hw_address; device_class->get_setting_type = get_setting_type; - - /** - * NMDeviceDummy:hw-address: - * - * The active hardware (MAC) address of the device. - * - * Since: 1.10 - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_DUMMY_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - - _nml_dbus_meta_class_init_with_properties (object_class, &_nml_dbus_meta_iface_nm_device_dummy); } diff --git a/libnm/nm-device-dummy.h b/libnm/nm-device-dummy.h index 4b33490c08..0878936e3a 100644 --- a/libnm/nm-device-dummy.h +++ b/libnm/nm-device-dummy.h @@ -29,7 +29,9 @@ G_BEGIN_DECLS typedef struct _NMDeviceDummyClass NMDeviceDummyClass; GType nm_device_dummy_get_type (void); + NM_AVAILABLE_IN_1_10 +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char *nm_device_dummy_get_hw_address (NMDeviceDummy *device); G_END_DECLS diff --git a/libnm/nm-device-ethernet.c b/libnm/nm-device-ethernet.c index 7cd5b89fc1..20809ee495 100644 --- a/libnm/nm-device-ethernet.c +++ b/libnm/nm-device-ethernet.c @@ -17,7 +17,6 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_PERM_HW_ADDRESS, PROP_SPEED, PROP_CARRIER, @@ -26,7 +25,6 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( typedef struct { char **s390_subchannels; - char *hw_address; char *perm_hw_address; guint32 speed; bool carrier; @@ -55,13 +53,15 @@ G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE) * * Returns: the active hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_ethernet_get_hw_address (NMDeviceEthernet *device) { g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_ETHERNET_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -210,7 +210,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro /* Virtual devices will have empty permanent addr but they should not be excluded * from the MAC address check specified in the connection */ if (*perm_addr == 0) - perm_addr = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device)); + perm_addr = nm_device_get_hw_address (NM_DEVICE (device)); if (!nm_utils_hwaddr_valid (perm_addr, ETH_ALEN)) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, @@ -251,12 +251,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_WIRED; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device)); -} - /*****************************************************************************/ static void @@ -269,7 +263,6 @@ finalize (GObject *object) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object); - g_free (priv->hw_address); g_free (priv->perm_hw_address); g_strfreev (priv->s390_subchannels); @@ -286,9 +279,6 @@ get_property (GObject *object, NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_ethernet_get_hw_address (device)); - break; case PROP_PERM_HW_ADDRESS: g_value_set_string (value, nm_device_ethernet_get_permanent_hw_address (device)); break; @@ -319,11 +309,11 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wired = NML_DBUS_META_IFAC nm_device_ethernet_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceEthernet, _priv.carrier ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceEthernet, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_S ("PermHwAddress", PROP_PERM_HW_ADDRESS, NMDeviceEthernet, _priv.perm_hw_address ), - NML_DBUS_META_PROPERTY_INIT_AS ("S390Subchannels", PROP_S390_SUBCHANNELS, NMDeviceEthernet, _priv.s390_subchannels ), - NML_DBUS_META_PROPERTY_INIT_U ("Speed", PROP_SPEED, NMDeviceEthernet, _priv.speed ), + NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceEthernet, _priv.carrier ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_S ("PermHwAddress", PROP_PERM_HW_ADDRESS, NMDeviceEthernet, _priv.perm_hw_address ), + NML_DBUS_META_PROPERTY_INIT_AS ("S390Subchannels", PROP_S390_SUBCHANNELS, NMDeviceEthernet, _priv.s390_subchannels ), + NML_DBUS_META_PROPERTY_INIT_U ("Speed", PROP_SPEED, NMDeviceEthernet, _priv.speed ), ), ); @@ -338,18 +328,6 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *eth_class) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceEthernet:hw-address: - * - * The active hardware (MAC) address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_ETHERNET_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceEthernet:perm-hw-address: diff --git a/libnm/nm-device-ethernet.h b/libnm/nm-device-ethernet.h index 28b95dc2d2..1a430cb650 100644 --- a/libnm/nm-device-ethernet.h +++ b/libnm/nm-device-ethernet.h @@ -35,7 +35,9 @@ typedef struct _NMDeviceEthernetClass NMDeviceEthernetClass; GType nm_device_ethernet_get_type (void); +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char * nm_device_ethernet_get_hw_address (NMDeviceEthernet *device); + const char * nm_device_ethernet_get_permanent_hw_address (NMDeviceEthernet *device); guint32 nm_device_ethernet_get_speed (NMDeviceEthernet *device); gboolean nm_device_ethernet_get_carrier (NMDeviceEthernet *device); diff --git a/libnm/nm-device-generic.c b/libnm/nm-device-generic.c index b1c784757f..14d6a5d7c3 100644 --- a/libnm/nm-device-generic.c +++ b/libnm/nm-device-generic.c @@ -14,12 +14,10 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_TYPE_DESCRIPTION, ); typedef struct { - char *hw_address; char *type_description; } NMDeviceGenericPrivate; @@ -46,13 +44,15 @@ G_DEFINE_TYPE (NMDeviceGeneric, nm_device_generic, NM_TYPE_DEVICE) * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_generic_get_hw_address (NMDeviceGeneric *device) { g_return_val_if_fail (NM_IS_DEVICE_GENERIC (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_GENERIC_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /*****************************************************************************/ @@ -65,12 +65,6 @@ get_type_description (NMDevice *device) return _nml_coerce_property_str_not_empty (priv->type_description); } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_generic_get_hw_address (NM_DEVICE_GENERIC (device)); -} - static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { @@ -113,7 +107,6 @@ finalize (GObject *object) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); - g_free (priv->hw_address); g_free (priv->type_description); G_OBJECT_CLASS (nm_device_generic_parent_class)->finalize (object); @@ -126,12 +119,8 @@ get_property (GObject *object, GParamSpec *pspec) { NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); - NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, priv->hw_address); - break; case PROP_TYPE_DESCRIPTION: g_value_set_string (value, get_type_description ((NMDevice *) self)); break; @@ -146,8 +135,8 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_generic = NML_DBUS_META_IF nm_device_generic_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceGeneric, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_S ("TypeDescription", PROP_TYPE_DESCRIPTION, NMDeviceGeneric, _priv.type_description ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_S ("TypeDescription", PROP_TYPE_DESCRIPTION, NMDeviceGeneric, _priv.type_description ), ), ); @@ -161,20 +150,9 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass) object_class->finalize = finalize; device_class->get_type_description = get_type_description; - device_class->get_hw_address = get_hw_address; device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - /** - * NMDeviceGeneric:hw-address: - * - * The hardware address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_GENERIC_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceGeneric:type-description: diff --git a/libnm/nm-device-generic.h b/libnm/nm-device-generic.h index aa52023a0e..c62afcd750 100644 --- a/libnm/nm-device-generic.h +++ b/libnm/nm-device-generic.h @@ -31,6 +31,7 @@ typedef struct _NMDeviceGenericClass NMDeviceGenericClass; GType nm_device_generic_get_type (void); +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char *nm_device_generic_get_hw_address (NMDeviceGeneric *device); G_END_DECLS diff --git a/libnm/nm-device-infiniband.c b/libnm/nm-device-infiniband.c index c3e57c9596..096dc5e12f 100644 --- a/libnm/nm-device-infiniband.c +++ b/libnm/nm-device-infiniband.c @@ -15,12 +15,10 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_CARRIER, ); typedef struct { - char *hw_address; bool carrier; } NMDeviceInfinibandPrivate; @@ -47,13 +45,15 @@ G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE) * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_infiniband_get_hw_address (NMDeviceInfiniband *device) { g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_INFINIBAND_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -87,7 +87,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro return FALSE; } - hwaddr = nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device)); + hwaddr = nm_device_get_hw_address (NM_DEVICE (device)); if (hwaddr) { if (!nm_utils_hwaddr_valid (hwaddr, INFINIBAND_ALEN)) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, @@ -113,12 +113,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_INFINIBAND; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_infiniband_get_hw_address (NM_DEVICE_INFINIBAND (device)); -} - /*****************************************************************************/ static void @@ -127,16 +121,6 @@ nm_device_infiniband_init (NMDeviceInfiniband *device) } static void -finalize (GObject *object) -{ - NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (object); - - g_free (priv->hw_address); - - G_OBJECT_CLASS (nm_device_infiniband_parent_class)->finalize (object); -} - -static void get_property (GObject *object, guint prop_id, GValue *value, @@ -145,9 +129,6 @@ get_property (GObject *object, NMDeviceInfiniband *device = NM_DEVICE_INFINIBAND (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_infiniband_get_hw_address (device)); - break; case PROP_CARRIER: g_value_set_boolean (value, nm_device_infiniband_get_carrier (device)); break; @@ -162,8 +143,8 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_infiniband = NML_DBUS_META nm_device_infiniband_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceInfiniband, _priv.carrier ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceInfiniband, _priv.hw_address ), + NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceInfiniband, _priv.carrier ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), ), ); @@ -174,22 +155,9 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *ib_class) NMDeviceClass *device_class = NM_DEVICE_CLASS (ib_class); object_class->get_property = get_property; - object_class->finalize = finalize; device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceInfiniband:hw-address: - * - * The hardware (MAC) address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_INFINIBAND_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceInfiniband:carrier: diff --git a/libnm/nm-device-infiniband.h b/libnm/nm-device-infiniband.h index 06a2c25728..c6b623775b 100644 --- a/libnm/nm-device-infiniband.h +++ b/libnm/nm-device-infiniband.h @@ -31,7 +31,9 @@ typedef struct _NMDeviceInfinibandClass NMDeviceInfinibandClass; GType nm_device_infiniband_get_type (void); +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char * nm_device_infiniband_get_hw_address (NMDeviceInfiniband *device); + gboolean nm_device_infiniband_get_carrier (NMDeviceInfiniband *device); G_END_DECLS diff --git a/libnm/nm-device-macsec.c b/libnm/nm-device-macsec.c index 194261f07e..36ee110e13 100644 --- a/libnm/nm-device-macsec.c +++ b/libnm/nm-device-macsec.c @@ -15,7 +15,6 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_PARENT, - PROP_HW_ADDRESS, PROP_SCI, PROP_CIPHER_SUITE, PROP_ICV_LENGTH, @@ -32,7 +31,6 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( typedef struct { NMLDBusPropertyO parent; - char *hw_address; char *validation; guint64 sci; guint64 cipher_suite; @@ -88,13 +86,15 @@ nm_device_macsec_get_parent (NMDeviceMacsec *device) * device, and must not be modified. * * Since: 1.6 + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_macsec_get_hw_address (NMDeviceMacsec *device) { g_return_val_if_fail (NM_IS_DEVICE_MACSEC (device), NULL); - return NM_DEVICE_MACSEC_GET_PRIVATE (device)->hw_address; + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -318,12 +318,6 @@ nm_device_macsec_get_replay_protect (NMDeviceMacsec *device) return NM_DEVICE_MACSEC_GET_PRIVATE (device)->replay_protect; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_macsec_get_hw_address (NM_DEVICE_MACSEC (device)); -} - /***********************************************************/ static void @@ -337,7 +331,6 @@ finalize (GObject *object) NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (object); g_free (priv->validation); - g_free (priv->hw_address); G_OBJECT_CLASS (nm_device_macsec_parent_class)->finalize (object); } @@ -354,9 +347,6 @@ get_property (GObject *object, case PROP_PARENT: g_value_set_object (value, nm_device_macsec_get_parent (device)); break; - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_macsec_get_hw_address (device)); - break; case PROP_SCI: g_value_set_uint64 (value, nm_device_macsec_get_sci (device)); break; @@ -425,7 +415,6 @@ nm_device_macsec_class_init (NMDeviceMacsecClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); NMObjectClass *nm_object_class = NM_OBJECT_CLASS (klass); - NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); object_class->get_property = get_property; object_class->finalize = finalize; @@ -434,8 +423,6 @@ nm_device_macsec_class_init (NMDeviceMacsecClass *klass) _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1 (nm_object_class, NMDeviceMacsecPrivate, parent); - device_class->get_hw_address = get_hw_address; - /** * NMDeviceMacsec:parent: * @@ -450,19 +437,6 @@ nm_device_macsec_class_init (NMDeviceMacsecClass *klass) G_PARAM_STATIC_STRINGS); /** - * NMDeviceMacsec:hw-address: - * - * The hardware (MAC) address of the device. - * - * Since: 1.6 - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_MACSEC_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - - /** * NMDeviceMacsec:sci: * * The Secure Channel Identifier in use. diff --git a/libnm/nm-device-macsec.h b/libnm/nm-device-macsec.h index acf6269b21..3f9a40d44d 100644 --- a/libnm/nm-device-macsec.h +++ b/libnm/nm-device-macsec.h @@ -46,8 +46,11 @@ GType nm_device_macsec_get_type (void); NM_AVAILABLE_IN_1_6 NMDevice * nm_device_macsec_get_parent (NMDeviceMacsec *device); + NM_AVAILABLE_IN_1_6 +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char * nm_device_macsec_get_hw_address (NMDeviceMacsec *device); + NM_AVAILABLE_IN_1_6 guint64 nm_device_macsec_get_sci (NMDeviceMacsec *device); NM_AVAILABLE_IN_1_6 diff --git a/libnm/nm-device-macvlan.c b/libnm/nm-device-macvlan.c index e703cb5ccf..488e55f944 100644 --- a/libnm/nm-device-macvlan.c +++ b/libnm/nm-device-macvlan.c @@ -20,7 +20,6 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_MODE, PROP_NO_PROMISC, PROP_TAP, - PROP_HW_ADDRESS, ); typedef struct { @@ -128,13 +127,15 @@ nm_device_macvlan_get_tap (NMDeviceMacvlan *device) * Since: 1.2 * * This property is not implemented yet, and the function always return NULL. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_macvlan_get_hw_address (NMDeviceMacvlan *device) { g_return_val_if_fail (NM_IS_DEVICE_MACVLAN (device), NULL); - return NULL; + return nm_device_get_hw_address (NM_DEVICE (device)); } static gboolean @@ -161,12 +162,6 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro return TRUE; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_macvlan_get_hw_address (NM_DEVICE_MACVLAN (device)); -} - static GType get_setting_type (NMDevice *device) { @@ -211,9 +206,6 @@ get_property (GObject *object, case PROP_TAP: g_value_set_boolean (value, nm_device_macvlan_get_tap (device)); break; - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_macvlan_get_hw_address (device)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -248,7 +240,6 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; /** * NMDeviceMacvlan:parent: @@ -302,20 +293,5 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - /** - * NMDeviceMacvlan:hw-address: - * - * The hardware (MAC) address of the device. - * - * Since: 1.2 - * - * This property is not implemented yet, and the function always return NULL. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_MACVLAN_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - _nml_dbus_meta_class_init_with_properties (object_class, &_nml_dbus_meta_iface_nm_device_macvlan); } diff --git a/libnm/nm-device-macvlan.h b/libnm/nm-device-macvlan.h index c991f8bd81..4467cc3f1f 100644 --- a/libnm/nm-device-macvlan.h +++ b/libnm/nm-device-macvlan.h @@ -43,7 +43,9 @@ NM_AVAILABLE_IN_1_2 gboolean nm_device_macvlan_get_no_promisc (NMDeviceMacvlan *device); NM_AVAILABLE_IN_1_2 gboolean nm_device_macvlan_get_tap (NMDeviceMacvlan *device); + NM_AVAILABLE_IN_1_2 +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char * nm_device_macvlan_get_hw_address (NMDeviceMacvlan *device); G_END_DECLS diff --git a/libnm/nm-device-olpc-mesh.c b/libnm/nm-device-olpc-mesh.c index 1ad320bf86..f2d9ea67c8 100644 --- a/libnm/nm-device-olpc-mesh.c +++ b/libnm/nm-device-olpc-mesh.c @@ -15,14 +15,12 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_COMPANION, PROP_ACTIVE_CHANNEL, ); typedef struct { NMLDBusPropertyO companion; - char *hw_address; guint32 active_channel; } NMDeviceOlpcMeshPrivate; @@ -49,13 +47,15 @@ G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE) * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_olpc_mesh_get_hw_address (NMDeviceOlpcMesh *device) { g_return_val_if_fail (NM_IS_DEVICE_OLPC_MESH (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -90,12 +90,6 @@ nm_device_olpc_mesh_get_active_channel (NMDeviceOlpcMesh *device) return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->active_channel; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_olpc_mesh_get_hw_address (NM_DEVICE_OLPC_MESH (device)); -} - static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { @@ -125,16 +119,6 @@ nm_device_olpc_mesh_init (NMDeviceOlpcMesh *device) } static void -finalize (GObject *object) -{ - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (object); - - g_free (priv->hw_address); - - G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->finalize (object); -} - -static void get_property (GObject *object, guint prop_id, GValue *value, @@ -143,9 +127,6 @@ get_property (GObject *object, NMDeviceOlpcMesh *device = NM_DEVICE_OLPC_MESH (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_olpc_mesh_get_hw_address (device)); - break; case PROP_COMPANION: g_value_set_object (value, nm_device_olpc_mesh_get_companion (device)); break; @@ -163,9 +144,9 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_olpcmesh = NML_DBUS_META_I nm_device_olpc_mesh_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_U ("ActiveChannel", PROP_ACTIVE_CHANNEL, NMDeviceOlpcMesh, _priv.active_channel ), - NML_DBUS_META_PROPERTY_INIT_O_PROP ("Companion", PROP_COMPANION, NMDeviceOlpcMesh, _priv.companion, nm_device_wifi_get_type ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceOlpcMesh, _priv.hw_address ), + NML_DBUS_META_PROPERTY_INIT_U ("ActiveChannel", PROP_ACTIVE_CHANNEL, NMDeviceOlpcMesh, _priv.active_channel ), + NML_DBUS_META_PROPERTY_INIT_O_PROP ("Companion", PROP_COMPANION, NMDeviceOlpcMesh, _priv.companion, nm_device_wifi_get_type ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), ), ); @@ -177,7 +158,6 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass) NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); object_class->get_property = get_property; - object_class->finalize = finalize; _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT (nm_object_class, NMDeviceOlpcMesh); @@ -185,18 +165,6 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceOlpcMesh:hw-address: - * - * The hardware (MAC) address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_OLPC_MESH_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceOlpcMesh:companion: diff --git a/libnm/nm-device-olpc-mesh.h b/libnm/nm-device-olpc-mesh.h index 2794e6eeab..d3157a3283 100644 --- a/libnm/nm-device-olpc-mesh.h +++ b/libnm/nm-device-olpc-mesh.h @@ -32,7 +32,9 @@ typedef struct _NMDeviceOlpcMeshClass NMDeviceOlpcMeshClass; GType nm_device_olpc_mesh_get_type (void); +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char *nm_device_olpc_mesh_get_hw_address (NMDeviceOlpcMesh *device); + NMDeviceWifi *nm_device_olpc_mesh_get_companion (NMDeviceOlpcMesh *device); guint32 nm_device_olpc_mesh_get_active_channel (NMDeviceOlpcMesh *device); diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index a1c04c18f8..4c12f1e4ce 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -16,7 +16,6 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_CARRIER, PROP_SLAVES, PROP_CONFIG, @@ -24,7 +23,6 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( typedef struct { NMLDBusPropertyAO slaves; - char *hw_address; char *config; bool carrier; } NMDeviceTeamPrivate; @@ -52,13 +50,15 @@ G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_team_get_hw_address (NMDeviceTeam *device) { g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_TEAM_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -114,12 +114,6 @@ nm_device_team_get_config (NMDeviceTeam *device) return _nml_coerce_property_str_not_empty (NM_DEVICE_TEAM_GET_PRIVATE (device)->config); } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_team_get_hw_address (NM_DEVICE_TEAM (device)); -} - static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { @@ -155,7 +149,6 @@ finalize (GObject *object) { NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (object); - g_free (priv->hw_address); g_free (priv->config); G_OBJECT_CLASS (nm_device_team_parent_class)->finalize (object); @@ -170,9 +163,6 @@ get_property (GObject *object, NMDeviceTeam *device = NM_DEVICE_TEAM (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_team_get_hw_address (device)); - break; case PROP_CARRIER: g_value_set_boolean (value, nm_device_team_get_carrier (device)); break; @@ -193,10 +183,10 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_team = NML_DBUS_META_IFACE nm_device_team_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceTeam, _priv.carrier ), - NML_DBUS_META_PROPERTY_INIT_S ("Config", PROP_CONFIG, NMDeviceTeam, _priv.config ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceTeam, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_AO_PROP ("Slaves", PROP_SLAVES, NMDeviceTeam, _priv.slaves, nm_device_get_type ), + NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceTeam, _priv.carrier ), + NML_DBUS_META_PROPERTY_INIT_S ("Config", PROP_CONFIG, NMDeviceTeam, _priv.config ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_AO_PROP ("Slaves", PROP_SLAVES, NMDeviceTeam, _priv.slaves, nm_device_get_type ), ), ); @@ -216,18 +206,6 @@ nm_device_team_class_init (NMDeviceTeamClass *klass) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceTeam:hw-address: - * - * The hardware (MAC) address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_TEAM_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceTeam:carrier: diff --git a/libnm/nm-device-team.h b/libnm/nm-device-team.h index 8bc0d2cd3e..ad4ea947dc 100644 --- a/libnm/nm-device-team.h +++ b/libnm/nm-device-team.h @@ -33,7 +33,9 @@ typedef struct _NMDeviceTeamClass NMDeviceTeamClass; GType nm_device_team_get_type (void); +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char *nm_device_team_get_hw_address (NMDeviceTeam *device); + gboolean nm_device_team_get_carrier (NMDeviceTeam *device); const GPtrArray *nm_device_team_get_slaves (NMDeviceTeam *device); NM_AVAILABLE_IN_1_4 diff --git a/libnm/nm-device-tun.c b/libnm/nm-device-tun.c index cc84774bca..79b8971320 100644 --- a/libnm/nm-device-tun.c +++ b/libnm/nm-device-tun.c @@ -17,7 +17,6 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_MODE, PROP_OWNER, PROP_GROUP, @@ -27,7 +26,6 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( ); typedef struct { - char *hw_address; char *mode; gint64 owner; gint64 group; @@ -61,13 +59,15 @@ G_DEFINE_TYPE (NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE) * device, and must not be modified. * * Since: 1.2 + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_tun_get_hw_address (NMDeviceTun *device) { g_return_val_if_fail (NM_IS_DEVICE_TUN (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_TUN_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -221,12 +221,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_TUN; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_tun_get_hw_address (NM_DEVICE_TUN (device)); -} - /*****************************************************************************/ static void @@ -240,7 +234,6 @@ finalize (GObject *object) NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (object); g_free (priv->mode); - g_free (priv->hw_address); G_OBJECT_CLASS (nm_device_tun_parent_class)->finalize (object); } @@ -254,9 +247,6 @@ get_property (GObject *object, NMDeviceTun *device = NM_DEVICE_TUN (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_tun_get_hw_address (device)); - break; case PROP_MODE: g_value_set_string (value, nm_device_tun_get_mode (device)); break; @@ -287,13 +277,13 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_tun = NML_DBUS_META_IFACE_ nm_device_tun_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_X ("Group", PROP_GROUP, NMDeviceTun, _priv.group ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceTun, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_S ("Mode", PROP_MODE, NMDeviceTun, _priv.mode ), - NML_DBUS_META_PROPERTY_INIT_B ("MultiQueue", PROP_MULTI_QUEUE, NMDeviceTun, _priv.multi_queue ), - NML_DBUS_META_PROPERTY_INIT_B ("NoPi", PROP_NO_PI, NMDeviceTun, _priv.no_pi ), - NML_DBUS_META_PROPERTY_INIT_X ("Owner", PROP_OWNER, NMDeviceTun, _priv.owner ), - NML_DBUS_META_PROPERTY_INIT_B ("VnetHdr", PROP_VNET_HDR, NMDeviceTun, _priv.vnet_hdr ), + NML_DBUS_META_PROPERTY_INIT_X ("Group", PROP_GROUP, NMDeviceTun, _priv.group ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_S ("Mode", PROP_MODE, NMDeviceTun, _priv.mode ), + NML_DBUS_META_PROPERTY_INIT_B ("MultiQueue", PROP_MULTI_QUEUE, NMDeviceTun, _priv.multi_queue ), + NML_DBUS_META_PROPERTY_INIT_B ("NoPi", PROP_NO_PI, NMDeviceTun, _priv.no_pi ), + NML_DBUS_META_PROPERTY_INIT_X ("Owner", PROP_OWNER, NMDeviceTun, _priv.owner ), + NML_DBUS_META_PROPERTY_INIT_B ("VnetHdr", PROP_VNET_HDR, NMDeviceTun, _priv.vnet_hdr ), ), ); @@ -308,20 +298,6 @@ nm_device_tun_class_init (NMDeviceTunClass *gre_class) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceTun:hw-address: - * - * The hardware (MAC) address of the device. - * - * Since: 1.2 - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_TUN_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceTun:mode: diff --git a/libnm/nm-device-tun.h b/libnm/nm-device-tun.h index bcb2cbb34a..8d95342e28 100644 --- a/libnm/nm-device-tun.h +++ b/libnm/nm-device-tun.h @@ -38,7 +38,9 @@ NM_AVAILABLE_IN_1_2 GType nm_device_tun_get_type (void); NM_AVAILABLE_IN_1_2 +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char * nm_device_tun_get_hw_address (NMDeviceTun *device); + NM_AVAILABLE_IN_1_2 const char * nm_device_tun_get_mode (NMDeviceTun *device); NM_AVAILABLE_IN_1_2 diff --git a/libnm/nm-device-vlan.c b/libnm/nm-device-vlan.c index ee57d0f43f..f1ed8f195a 100644 --- a/libnm/nm-device-vlan.c +++ b/libnm/nm-device-vlan.c @@ -16,7 +16,6 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_CARRIER, PROP_PARENT, PROP_VLAN_ID, @@ -24,7 +23,6 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( typedef struct { NMLDBusPropertyO parent; - char *hw_address; guint32 vlan_id; bool carrier; } NMDeviceVlanPrivate; @@ -52,13 +50,15 @@ G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_vlan_get_hw_address (NMDeviceVlan *device) { g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -108,10 +108,10 @@ nm_device_vlan_get_vlan_id (NMDeviceVlan *device) static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { - NMDeviceVlanPrivate *priv; NMSettingVlan *s_vlan; NMSettingWired *s_wired; const char *setting_hwaddr; + const char *hw_address; if (!NM_DEVICE_CLASS (nm_device_vlan_parent_class)->connection_compatible (device, connection, error)) return FALSE; @@ -135,10 +135,11 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro else setting_hwaddr = NULL; if (setting_hwaddr) { - priv = NM_DEVICE_VLAN_GET_PRIVATE (device); - if ( !priv->hw_address + hw_address = nm_device_get_hw_address (NM_DEVICE (device)); + + if ( !hw_address || !nm_utils_hwaddr_matches (setting_hwaddr, -1, - priv->hw_address, -1)) { + hw_address, -1)) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, _("The hardware address of the device and the connection didn't match.")); } @@ -153,12 +154,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_VLAN; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_vlan_get_hw_address (NM_DEVICE_VLAN (device)); -} - /*****************************************************************************/ static void @@ -167,16 +162,6 @@ nm_device_vlan_init (NMDeviceVlan *device) } static void -finalize (GObject *object) -{ - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); - - g_free (priv->hw_address); - - G_OBJECT_CLASS (nm_device_vlan_parent_class)->finalize (object); -} - -static void get_property (GObject *object, guint prop_id, GValue *value, @@ -185,9 +170,6 @@ get_property (GObject *object, NMDeviceVlan *device = NM_DEVICE_VLAN (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_vlan_get_hw_address (device)); - break; case PROP_CARRIER: g_value_set_boolean (value, nm_device_vlan_get_carrier (device)); break; @@ -208,10 +190,10 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_vlan = NML_DBUS_META_IFACE nm_device_vlan_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceVlan, _priv.carrier ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceVlan, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_O_PROP ("Parent", PROP_PARENT, NMDeviceVlan, _priv.parent, nm_device_get_type ), - NML_DBUS_META_PROPERTY_INIT_U ("VlanId", PROP_VLAN_ID, NMDeviceVlan, _priv.vlan_id ), + NML_DBUS_META_PROPERTY_INIT_B ("Carrier", PROP_CARRIER, NMDeviceVlan, _priv.carrier ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_O_PROP ("Parent", PROP_PARENT, NMDeviceVlan, _priv.parent, nm_device_get_type ), + NML_DBUS_META_PROPERTY_INIT_U ("VlanId", PROP_VLAN_ID, NMDeviceVlan, _priv.vlan_id ), ), ); @@ -223,7 +205,6 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); object_class->get_property = get_property; - object_class->finalize = finalize; _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT (nm_object_class, NMDeviceVlan); @@ -231,18 +212,6 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceVlan:hw-address: - * - * The hardware (MAC) address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_VLAN_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceVlan:carrier: diff --git a/libnm/nm-device-vlan.h b/libnm/nm-device-vlan.h index 7a412cb028..104a1e8267 100644 --- a/libnm/nm-device-vlan.h +++ b/libnm/nm-device-vlan.h @@ -33,7 +33,9 @@ typedef struct _NMDeviceVlanClass NMDeviceVlanClass; GType nm_device_vlan_get_type (void); +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char * nm_device_vlan_get_hw_address (NMDeviceVlan *device); + gboolean nm_device_vlan_get_carrier (NMDeviceVlan *device); NMDevice * nm_device_vlan_get_parent (NMDeviceVlan *device); guint nm_device_vlan_get_vlan_id (NMDeviceVlan *device); diff --git a/libnm/nm-device-vxlan.c b/libnm/nm-device-vxlan.c index 4397977c3f..38fc23dd6c 100644 --- a/libnm/nm-device-vxlan.c +++ b/libnm/nm-device-vxlan.c @@ -15,7 +15,6 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_CARRIER, PROP_PARENT, PROP_ID, @@ -37,7 +36,6 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( typedef struct { NMLDBusPropertyO parent; - char *hw_address; char *group; char *local; guint32 id; @@ -80,13 +78,15 @@ G_DEFINE_TYPE (NMDeviceVxlan, nm_device_vxlan, NM_TYPE_DEVICE) * device, and must not be modified. * * Since: 1.2 + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_vxlan_get_hw_address (NMDeviceVxlan *device) { g_return_val_if_fail (NM_IS_DEVICE_VXLAN (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_VXLAN_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -398,12 +398,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_VXLAN; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_vxlan_get_hw_address (NM_DEVICE_VXLAN (device)); -} - /*****************************************************************************/ static void @@ -416,7 +410,6 @@ finalize (GObject *object) { NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (object); - g_free (priv->hw_address); g_free (priv->group); g_free (priv->local); @@ -432,9 +425,6 @@ get_property (GObject *object, NMDeviceVxlan *device = NM_DEVICE_VXLAN (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_vxlan_get_hw_address (device)); - break; case PROP_CARRIER: g_value_set_boolean (value, nm_device_vxlan_get_carrier (device)); break; @@ -497,23 +487,23 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_vxlan = NML_DBUS_META_IFAC nm_device_vxlan_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_U ("Ageing", PROP_AGEING, NMDeviceVxlan, _priv.ageing ), - NML_DBUS_META_PROPERTY_INIT_Q ("DstPort", PROP_DST_PORT, NMDeviceVxlan, _priv.dst_port ), - NML_DBUS_META_PROPERTY_INIT_S ("Group", PROP_GROUP, NMDeviceVxlan, _priv.group ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceVxlan, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_U ("Id", PROP_ID, NMDeviceVxlan, _priv.id ), - NML_DBUS_META_PROPERTY_INIT_B ("L2miss", PROP_L2MISS, NMDeviceVxlan, _priv.l2miss ), - NML_DBUS_META_PROPERTY_INIT_B ("L3miss", PROP_L3MISS, NMDeviceVxlan, _priv.l3miss ), - NML_DBUS_META_PROPERTY_INIT_B ("Learning", PROP_LEARNING, NMDeviceVxlan, _priv.learning ), - NML_DBUS_META_PROPERTY_INIT_U ("Limit", PROP_LIMIT, NMDeviceVxlan, _priv.limit ), - NML_DBUS_META_PROPERTY_INIT_S ("Local", PROP_LOCAL, NMDeviceVxlan, _priv.local ), - NML_DBUS_META_PROPERTY_INIT_O_PROP ("Parent", PROP_PARENT, NMDeviceVxlan, _priv.parent, nm_device_get_type ), - NML_DBUS_META_PROPERTY_INIT_B ("Proxy", PROP_PROXY, NMDeviceVxlan, _priv.proxy ), - NML_DBUS_META_PROPERTY_INIT_B ("Rsc", PROP_RSC, NMDeviceVxlan, _priv.rsc ), - NML_DBUS_META_PROPERTY_INIT_Q ("SrcPortMax", PROP_SRC_PORT_MAX, NMDeviceVxlan, _priv.src_port_max ), - NML_DBUS_META_PROPERTY_INIT_Q ("SrcPortMin", PROP_SRC_PORT_MIN, NMDeviceVxlan, _priv.src_port_min ), - NML_DBUS_META_PROPERTY_INIT_Y ("Tos", PROP_TOS, NMDeviceVxlan, _priv.tos ), - NML_DBUS_META_PROPERTY_INIT_Y ("Ttl", PROP_TTL, NMDeviceVxlan, _priv.ttl ), + NML_DBUS_META_PROPERTY_INIT_U ("Ageing", PROP_AGEING, NMDeviceVxlan, _priv.ageing ), + NML_DBUS_META_PROPERTY_INIT_Q ("DstPort", PROP_DST_PORT, NMDeviceVxlan, _priv.dst_port ), + NML_DBUS_META_PROPERTY_INIT_S ("Group", PROP_GROUP, NMDeviceVxlan, _priv.group ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_U ("Id", PROP_ID, NMDeviceVxlan, _priv.id ), + NML_DBUS_META_PROPERTY_INIT_B ("L2miss", PROP_L2MISS, NMDeviceVxlan, _priv.l2miss ), + NML_DBUS_META_PROPERTY_INIT_B ("L3miss", PROP_L3MISS, NMDeviceVxlan, _priv.l3miss ), + NML_DBUS_META_PROPERTY_INIT_B ("Learning", PROP_LEARNING, NMDeviceVxlan, _priv.learning ), + NML_DBUS_META_PROPERTY_INIT_U ("Limit", PROP_LIMIT, NMDeviceVxlan, _priv.limit ), + NML_DBUS_META_PROPERTY_INIT_S ("Local", PROP_LOCAL, NMDeviceVxlan, _priv.local ), + NML_DBUS_META_PROPERTY_INIT_O_PROP ("Parent", PROP_PARENT, NMDeviceVxlan, _priv.parent, nm_device_get_type ), + NML_DBUS_META_PROPERTY_INIT_B ("Proxy", PROP_PROXY, NMDeviceVxlan, _priv.proxy ), + NML_DBUS_META_PROPERTY_INIT_B ("Rsc", PROP_RSC, NMDeviceVxlan, _priv.rsc ), + NML_DBUS_META_PROPERTY_INIT_Q ("SrcPortMax", PROP_SRC_PORT_MAX, NMDeviceVxlan, _priv.src_port_max ), + NML_DBUS_META_PROPERTY_INIT_Q ("SrcPortMin", PROP_SRC_PORT_MIN, NMDeviceVxlan, _priv.src_port_min ), + NML_DBUS_META_PROPERTY_INIT_Y ("Tos", PROP_TOS, NMDeviceVxlan, _priv.tos ), + NML_DBUS_META_PROPERTY_INIT_Y ("Ttl", PROP_TTL, NMDeviceVxlan, _priv.ttl ), ), ); @@ -533,20 +523,6 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceVxlan:hw-address: - * - * The hardware (MAC) address of the device. - * - * Since: 1.2 - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_VXLAN_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceVxlan:carrier: diff --git a/libnm/nm-device-vxlan.h b/libnm/nm-device-vxlan.h index fef2365f2e..b285bf020d 100644 --- a/libnm/nm-device-vxlan.h +++ b/libnm/nm-device-vxlan.h @@ -47,8 +47,11 @@ typedef struct _NMDeviceVxlanClass NMDeviceVxlanClass; NM_AVAILABLE_IN_1_2 GType nm_device_vxlan_get_type (void); + NM_AVAILABLE_IN_1_2 +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char * nm_device_vxlan_get_hw_address (NMDeviceVxlan *device); + NM_AVAILABLE_IN_1_2 gboolean nm_device_vxlan_get_carrier (NMDeviceVxlan *device); NM_AVAILABLE_IN_1_2 diff --git a/libnm/nm-device-wifi-p2p.c b/libnm/nm-device-wifi-p2p.c index aa5089c7a2..a630fcb952 100644 --- a/libnm/nm-device-wifi-p2p.c +++ b/libnm/nm-device-wifi-p2p.c @@ -19,7 +19,6 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_PEERS, ); @@ -34,7 +33,6 @@ static guint signals[LAST_SIGNAL] = { 0 }; typedef struct { NMLDBusPropertyAO peers; - char *hw_address; } NMDeviceWifiP2PPrivate; struct _NMDeviceWifiP2P { @@ -62,13 +60,15 @@ G_DEFINE_TYPE (NMDeviceWifiP2P, nm_device_wifi_p2p, NM_TYPE_DEVICE) * device, and must not be modified. * * Since: 1.16 + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_wifi_p2p_get_hw_address (NMDeviceWifiP2P *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI_P2P (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_WIFI_P2P_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -279,12 +279,6 @@ get_setting_type (NMDevice *device) } static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_wifi_p2p_get_hw_address (NM_DEVICE_WIFI_P2P (device)); -} - -static const char * get_type_description (NMDevice *device) { return "wifi-p2p"; @@ -319,9 +313,6 @@ get_property (GObject *object, NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_wifi_p2p_get_hw_address (self)); - break; case PROP_PEERS: g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_wifi_p2p_get_peers (self))); break; @@ -338,23 +329,13 @@ nm_device_wifi_p2p_init (NMDeviceWifiP2P *device) { } -static void -finalize (GObject *object) -{ - NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (object); - - g_free (priv->hw_address); - - G_OBJECT_CLASS (nm_device_wifi_p2p_parent_class)->finalize (object); -} - const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wifip2p = NML_DBUS_META_IFACE_INIT_PROP ( NM_DBUS_INTERFACE_DEVICE_WIFI_P2P, nm_device_wifi_p2p_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceWifiP2P, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_AO_PROP ("Peers", PROP_PEERS, NMDeviceWifiP2P, _priv.peers, nm_wifi_p2p_peer_get_type, .notify_changed_ao = _property_ao_notify_changed_peers_cb ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_AO_PROP ("Peers", PROP_PEERS, NMDeviceWifiP2P, _priv.peers, nm_wifi_p2p_peer_get_type, .notify_changed_ao = _property_ao_notify_changed_peers_cb ), ), ); @@ -366,7 +347,6 @@ nm_device_wifi_p2p_class_init (NMDeviceWifiP2PClass *klass) NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); object_class->get_property = get_property; - object_class->finalize = finalize; _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT (nm_object_class, NMDeviceWifiP2P); @@ -374,23 +354,9 @@ nm_device_wifi_p2p_class_init (NMDeviceWifiP2PClass *klass) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; device_class->get_type_description = get_type_description; /** - * NMDeviceWifiP2P:hw-address: - * - * The hardware (MAC) address of the device. - * - * Since: 1.16 - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_WIFI_P2P_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - - /** * NMDeviceWifiP2P:peers: (type GPtrArray(NMWifiP2PPeer)) * * List of all Wi-Fi P2P peers the device can see. diff --git a/libnm/nm-device-wifi-p2p.h b/libnm/nm-device-wifi-p2p.h index 83127575af..5daa0ba1e0 100644 --- a/libnm/nm-device-wifi-p2p.h +++ b/libnm/nm-device-wifi-p2p.h @@ -36,6 +36,7 @@ NM_AVAILABLE_IN_1_16 GType nm_device_wifi_p2p_get_type (void); NM_AVAILABLE_IN_1_16 +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char * nm_device_wifi_p2p_get_hw_address (NMDeviceWifiP2P *device); NM_AVAILABLE_IN_1_16 diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index 5d8f742c5b..aef2d54661 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -21,7 +21,6 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, PROP_PERM_HW_ADDRESS, PROP_MODE, PROP_BITRATE, @@ -34,7 +33,6 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( typedef struct { NMLDBusPropertyAO access_points; NMLDBusPropertyO active_access_point; - char *hw_address; char *perm_hw_address; gint64 last_scan; guint32 mode; @@ -74,13 +72,15 @@ G_DEFINE_TYPE (NMDeviceWifi, nm_device_wifi, NM_TYPE_DEVICE) * * Returns: the actual hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_wifi_get_hw_address (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_WIFI_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } /** @@ -515,12 +515,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_WIRELESS; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device)); -} - /*****************************************************************************/ static void @@ -558,9 +552,6 @@ get_property (GObject *object, NMDeviceWifi *self = NM_DEVICE_WIFI (object); switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_wifi_get_hw_address (self)); - break; case PROP_PERM_HW_ADDRESS: g_value_set_string (value, nm_device_wifi_get_permanent_hw_address (self)); break; @@ -593,7 +584,6 @@ finalize (GObject *object) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object); - g_free (priv->hw_address); g_free (priv->perm_hw_address); G_OBJECT_CLASS (nm_device_wifi_parent_class)->finalize (object); @@ -604,14 +594,14 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wireless = NML_DBUS_META_I nm_device_wifi_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_AO_PROP ("AccessPoints", PROP_ACCESS_POINTS, NMDeviceWifi, _priv.access_points, nm_access_point_get_type, .notify_changed_ao = _property_ao_notify_changed_access_points_cb ), - NML_DBUS_META_PROPERTY_INIT_O_PROP ("ActiveAccessPoint", PROP_ACTIVE_ACCESS_POINT, NMDeviceWifi, _priv.active_access_point, nm_access_point_get_type ), - NML_DBUS_META_PROPERTY_INIT_U ("Bitrate", PROP_BITRATE, NMDeviceWifi, _priv.bitrate ), - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceWifi, _priv.hw_address ), - NML_DBUS_META_PROPERTY_INIT_X ("LastScan", PROP_LAST_SCAN, NMDeviceWifi, _priv.last_scan ), - NML_DBUS_META_PROPERTY_INIT_U ("Mode", PROP_MODE, NMDeviceWifi, _priv.mode ), - NML_DBUS_META_PROPERTY_INIT_S ("PermHwAddress", PROP_PERM_HW_ADDRESS, NMDeviceWifi, _priv.perm_hw_address ), - NML_DBUS_META_PROPERTY_INIT_U ("WirelessCapabilities", PROP_WIRELESS_CAPABILITIES, NMDeviceWifi, _priv.wireless_capabilities ), + NML_DBUS_META_PROPERTY_INIT_AO_PROP ("AccessPoints", PROP_ACCESS_POINTS, NMDeviceWifi, _priv.access_points, nm_access_point_get_type, .notify_changed_ao = _property_ao_notify_changed_access_points_cb ), + NML_DBUS_META_PROPERTY_INIT_O_PROP ("ActiveAccessPoint", PROP_ACTIVE_ACCESS_POINT, NMDeviceWifi, _priv.active_access_point, nm_access_point_get_type ), + NML_DBUS_META_PROPERTY_INIT_U ("Bitrate", PROP_BITRATE, NMDeviceWifi, _priv.bitrate ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), + NML_DBUS_META_PROPERTY_INIT_X ("LastScan", PROP_LAST_SCAN, NMDeviceWifi, _priv.last_scan ), + NML_DBUS_META_PROPERTY_INIT_U ("Mode", PROP_MODE, NMDeviceWifi, _priv.mode ), + NML_DBUS_META_PROPERTY_INIT_S ("PermHwAddress", PROP_PERM_HW_ADDRESS, NMDeviceWifi, _priv.perm_hw_address ), + NML_DBUS_META_PROPERTY_INIT_U ("WirelessCapabilities", PROP_WIRELESS_CAPABILITIES, NMDeviceWifi, _priv.wireless_capabilities ), ), ); @@ -632,18 +622,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceWifi:hw-address: - * - * The hardware (MAC) address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_WIFI_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); /** * NMDeviceWifi:perm-hw-address: diff --git a/libnm/nm-device-wifi.h b/libnm/nm-device-wifi.h index c64641d36e..e23577a47d 100644 --- a/libnm/nm-device-wifi.h +++ b/libnm/nm-device-wifi.h @@ -38,7 +38,9 @@ typedef struct _NMDeviceWifiClass NMDeviceWifiClass; GType nm_device_wifi_get_type (void); +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char * nm_device_wifi_get_hw_address (NMDeviceWifi *device); + const char * nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device); NM80211Mode nm_device_wifi_get_mode (NMDeviceWifi *device); guint32 nm_device_wifi_get_bitrate (NMDeviceWifi *device); diff --git a/libnm/nm-device-wpan.c b/libnm/nm-device-wpan.c index 5ddd8af37b..2b7f0566d7 100644 --- a/libnm/nm-device-wpan.c +++ b/libnm/nm-device-wpan.c @@ -13,17 +13,8 @@ /*****************************************************************************/ -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, -); - -typedef struct { - char *hw_address; -} NMDeviceWpanPrivate; - struct _NMDeviceWpan { NMDevice parent; - NMDeviceWpanPrivate _priv; }; struct _NMDeviceWpanClass { @@ -31,9 +22,6 @@ struct _NMDeviceWpanClass { }; G_DEFINE_TYPE (NMDeviceWpan, nm_device_wpan, NM_TYPE_DEVICE) - -#define NM_DEVICE_WPAN_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceWpan, NM_IS_DEVICE_WPAN, NMObject, NMDevice) - /*****************************************************************************/ /** @@ -44,13 +32,15 @@ G_DEFINE_TYPE (NMDeviceWpan, nm_device_wpan, NM_TYPE_DEVICE) * * Returns: the active hardware address. This is the internal string used by the * device, and must not be modified. + * + * Deprecated: 1.24 use nm_device_get_hw_address() instead. **/ const char * nm_device_wpan_get_hw_address (NMDeviceWpan *device) { g_return_val_if_fail (NM_IS_DEVICE_WPAN (device), NULL); - return _nml_coerce_property_str_not_empty (NM_DEVICE_WPAN_GET_PRIVATE (device)->hw_address); + return nm_device_get_hw_address (NM_DEVICE (device)); } static gboolean @@ -74,27 +64,6 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_WPAN; } -static const char * -get_hw_address (NMDevice *device) -{ - return nm_device_wpan_get_hw_address (NM_DEVICE_WPAN (device)); -} - -/*****************************************************************************/ - -static void -get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case PROP_HW_ADDRESS: - g_value_set_string (value, nm_device_wpan_get_hw_address (NM_DEVICE_WPAN (object))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - /*****************************************************************************/ static void @@ -102,48 +71,20 @@ nm_device_wpan_init (NMDeviceWpan *device) { } -static void -finalize (GObject *object) -{ - NMDeviceWpanPrivate *priv = NM_DEVICE_WPAN_GET_PRIVATE (object); - - g_free (priv->hw_address); - - G_OBJECT_CLASS (nm_device_wpan_parent_class)->finalize (object); -} - -const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wpan = NML_DBUS_META_IFACE_INIT_PROP ( +const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wpan = NML_DBUS_META_IFACE_INIT ( NM_DBUS_INTERFACE_DEVICE_WPAN, nm_device_wpan_get_type, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, NML_DBUS_META_IFACE_DBUS_PROPERTIES ( - NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceWpan, _priv.hw_address ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), ), ); static void nm_device_wpan_class_init (NMDeviceWpanClass *wpan_class) { - GObjectClass *object_class = G_OBJECT_CLASS (wpan_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (wpan_class); - object_class->get_property = get_property; - object_class->finalize = finalize; - device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /** - * NMDeviceWpan:hw-address: - * - * The active hardware (MAC) address of the device. - **/ - obj_properties[PROP_HW_ADDRESS] = - g_param_spec_string (NM_DEVICE_WPAN_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - - _nml_dbus_meta_class_init_with_properties (object_class, &_nml_dbus_meta_iface_nm_device_wpan); } diff --git a/libnm/nm-device-wpan.h b/libnm/nm-device-wpan.h index 43f8b7b3a9..1ff0979486 100644 --- a/libnm/nm-device-wpan.h +++ b/libnm/nm-device-wpan.h @@ -32,6 +32,7 @@ NM_AVAILABLE_IN_1_14 GType nm_device_wpan_get_type (void); NM_AVAILABLE_IN_1_14 +NM_DEPRECATED_IN_1_24_FOR (nm_device_get_hw_address) const char *nm_device_wpan_get_hw_address (NMDeviceWpan *device); G_END_DECLS diff --git a/libnm/nm-device.c b/libnm/nm-device.c index f2701cb7e5..96b288f008 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -60,6 +60,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDevice, PROP_IP4_CONNECTIVITY, PROP_IP6_CONNECTIVITY, PROP_INTERFACE_FLAGS, + PROP_HW_ADDRESS, ); enum { @@ -85,6 +86,7 @@ typedef struct _NMDevicePrivate { GPtrArray *lldp_neighbors; char *driver; char *driver_version; + char *hw_address; char *interface; char *ip_interface; char *firmware_version; @@ -105,6 +107,8 @@ typedef struct _NMDevicePrivate { bool managed; bool real; + bool hw_address_is_new:1; + guint32 old_state; struct udev *udev; @@ -340,6 +344,7 @@ finalize (GObject *object) g_free (priv->bus_name); g_free (priv->type_description); g_free (priv->physical_port_id); + g_free (priv->hw_address); nm_clear_pointer (&priv->udev, udev_unref); @@ -445,6 +450,9 @@ get_property (GObject *object, case PROP_INTERFACE_FLAGS: g_value_set_uint (value, nm_device_get_interface_flags (device)); break; + case PROP_HW_ADDRESS: + g_value_set_string (value, nm_device_get_hw_address (device)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -501,6 +509,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device = NML_DBUS_META_IFACE_INIT NML_DBUS_META_PROPERTY_INIT_S ("DriverVersion", PROP_DRIVER_VERSION, NMDevicePrivate, driver_version ), NML_DBUS_META_PROPERTY_INIT_B ("FirmwareMissing", PROP_FIRMWARE_MISSING, NMDevicePrivate, firmware_missing ), NML_DBUS_META_PROPERTY_INIT_S ("FirmwareVersion", PROP_FIRMWARE_VERSION, NMDevicePrivate, firmware_version ), + NML_DBUS_META_PROPERTY_INIT_FCN ("HwAddress", 0, "s", _nm_device_notify_update_prop_hw_address ), NML_DBUS_META_PROPERTY_INIT_S ("Interface", PROP_INTERFACE, NMDevicePrivate, interface ), NML_DBUS_META_PROPERTY_INIT_U ("InterfaceFlags", PROP_INTERFACE_FLAGS, NMDevicePrivate, interface_flags ), NML_DBUS_META_PROPERTY_INIT_IGNORE ("Ip4Address", "u" ), @@ -903,6 +912,19 @@ nm_device_class_init (NMDeviceClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + /** + * NMDevice:hw-address: + * + * The hardware address of the device. + * + * Since: 1.24 + **/ + obj_properties[PROP_HW_ADDRESS] = + g_param_spec_string (NM_DEVICE_HW_ADDRESS, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + _nml_dbus_meta_class_init_with_properties (object_class, &_nml_dbus_meta_iface_nm_device); /** @@ -1081,6 +1103,50 @@ nm_device_get_type_description (NMDevice *device) return _nml_coerce_property_str_not_empty (priv->type_description); } + NMLDBusNotifyUpdatePropFlags +_nm_device_notify_update_prop_hw_address (NMClient *client, + NMLDBusObject *dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant *value) +{ + NMDevice *self = NM_DEVICE (dbobj->nmobj); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + gboolean is_new = (meta_iface == &_nml_dbus_meta_iface_nm_device); + gboolean changed = FALSE; + + if ( !is_new + && priv->hw_address_is_new) { + /* once the instance is marked to honor the new property, the + * changed signal for the old variant gets ignored. */ + goto out; + } + + if (!value) { + if (nm_clear_g_free (&priv->hw_address)) + changed = TRUE; + goto out; + } + + priv->hw_address_is_new = is_new; + + nm_utils_strdup_reset (&priv->hw_address, + _nml_coerce_property_str_not_empty (g_variant_get_string (value, NULL))); + + /* always emit a changed signal here, even if "priv->hw_address" might be unchanged. + * We want to emit the signal because we received a PropertiesChanged signal on D-Bus, + * even if nothing actually changed. */ + changed = TRUE; + +out: + if (changed) { + _nm_client_queue_notify_object (client, + self, + obj_properties[PROP_HW_ADDRESS]); + } + return NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE; +} + /** * nm_device_get_hw_address: * @device: a #NMDevice @@ -1093,12 +1159,15 @@ nm_device_get_type_description (NMDevice *device) const char * nm_device_get_hw_address (NMDevice *device) { + NMDevicePrivate *priv; + g_return_val_if_fail (NM_IS_DEVICE (device), NULL); - if (NM_DEVICE_GET_CLASS (device)->get_hw_address) - return NM_DEVICE_GET_CLASS (device)->get_hw_address (device); + priv = NM_DEVICE_GET_PRIVATE (device); + + nm_assert (!nm_streq0 (priv->hw_address, "")); - return NULL; + return priv->hw_address; } /** diff --git a/libnm/nm-device.h b/libnm/nm-device.h index 78130c1bdf..ca359b08d0 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -55,6 +55,7 @@ _NM_DEPRECATED_SYNC_WRITABLE_PROPERTY #define NM_DEVICE_IP4_CONNECTIVITY "ip4-connectivity" #define NM_DEVICE_IP6_CONNECTIVITY "ip6-connectivity" #define NM_DEVICE_INTERFACE_FLAGS "interface-flags" +#define NM_DEVICE_HW_ADDRESS "hw-address" /** * NMDevice: diff --git a/libnm/nm-libnm-utils.h b/libnm/nm-libnm-utils.h index 28c9c1164c..e1506b0497 100644 --- a/libnm/nm-libnm-utils.h +++ b/libnm/nm-libnm-utils.h @@ -544,7 +544,7 @@ struct _NMLDBusMetaIface { #define NML_DBUS_META_IFACE_DBUS_PROPERTIES(...) \ .dbus_properties = ((const NMLDBusMetaProperty []) { __VA_ARGS__ }), \ - .n_dbus_properties = sizeof ((const NMLDBusMetaProperty []) { __VA_ARGS__ }) / sizeof (NMLDBusMetaProperty) \ + .n_dbus_properties = (sizeof ((const NMLDBusMetaProperty []) { __VA_ARGS__ }) / sizeof (NMLDBusMetaProperty)) #define NML_DBUS_META_IFACE_INIT(v_dbus_iface_name, \ v_get_type_fcn, \ @@ -557,9 +557,15 @@ struct _NMLDBusMetaIface { ##__VA_ARGS__ \ } -#define NML_DBUS_META_IFACE_INIT_PROP(...) \ - NML_DBUS_META_IFACE_INIT (__VA_ARGS__ \ - NML_DBUS_META_IFACE_OBJ_PROPERTIES ()) +#define NML_DBUS_META_IFACE_INIT_PROP(v_dbus_iface_name, \ + v_get_type_fcn, \ + v_interface_prio, \ + ...) \ + NML_DBUS_META_IFACE_INIT (v_dbus_iface_name, \ + v_get_type_fcn, \ + v_interface_prio, \ + NML_DBUS_META_IFACE_OBJ_PROPERTIES (), \ + ##__VA_ARGS__) extern const NMLDBusMetaIface *const _nml_dbus_meta_ifaces[44]; @@ -816,8 +822,6 @@ struct _NMDeviceClass { const char *(*get_type_description) (NMDevice *device); - const char *(*get_hw_address) (NMDevice *device); - GType (*get_setting_type) (NMDevice *device); }; @@ -1012,4 +1016,13 @@ void _nm_vpn_connection_state_changed_commit (NMVpnConnection *self, /*****************************************************************************/ +NMLDBusNotifyUpdatePropFlags +_nm_device_notify_update_prop_hw_address (NMClient *client, + NMLDBusObject *dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant *value); + +/*****************************************************************************/ + #endif /* __NM_LIBNM_UTILS_H__ */ diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 5d0774e917..86c3ad1ded 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -17636,6 +17636,7 @@ static const NMDBusInterfaceInfoExtended interface_info_device = { NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("Ip4Connectivity", "u", NM_DEVICE_IP4_CONNECTIVITY), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("Ip6Connectivity", "u", NM_DEVICE_IP6_CONNECTIVITY), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("InterfaceFlags", "u", NM_DEVICE_INTERFACE_FLAGS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("HwAddress", "s", NM_DEVICE_HW_ADDRESS), ), ), }; |