From fa325dca5a32557857695954fded74e7d57e11ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 21 Jul 2014 12:15:54 +0200 Subject: [PATCH] vlan: export parent device for VLANs as D-Bus property and use the internal construct-time parent property for VLAN creation. --- introspection/nm-device-vlan.xml | 6 ++++++ src/devices/nm-device-vlan.c | 30 +++++++++++++++++++++++------- src/devices/nm-device-vlan.h | 4 ++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/introspection/nm-device-vlan.xml b/introspection/nm-device-vlan.xml index 54b7bbe482..992340e009 100644 --- a/introspection/nm-device-vlan.xml +++ b/introspection/nm-device-vlan.xml @@ -15,6 +15,12 @@ + + + Object path of the parent device of this VLAN device. + + + The VLAN ID of this VLAN interface. diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 555180f4e7..d5f123c48a 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -67,6 +67,8 @@ enum { PROP_PARENT, PROP_VLAN_ID, + PROP_INT_PARENT_DEVICE, + LAST_PROP }; @@ -477,6 +479,12 @@ get_property (GObject *object, guint prop_id, NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); switch (prop_id) { + case PROP_PARENT: + g_value_set_boxed (value, priv->parent ? nm_device_get_path (priv->parent) : "/"); + break; + case PROP_INT_PARENT_DEVICE: + g_value_set_object (value, priv->parent); + break; case PROP_VLAN_ID: g_value_set_uint (value, priv->vlan_id); break; @@ -493,7 +501,7 @@ set_property (GObject *object, guint prop_id, NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); switch (prop_id) { - case PROP_PARENT: + case PROP_INT_PARENT_DEVICE: nm_device_vlan_set_parent (NM_DEVICE_VLAN (object), g_value_get_object (value)); break; case PROP_VLAN_ID: @@ -564,10 +572,10 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) /* properties */ g_object_class_install_property (object_class, PROP_PARENT, - g_param_spec_object (NM_DEVICE_VLAN_PARENT, "", "", - NM_TYPE_DEVICE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + g_param_spec_boxed (NM_DEVICE_VLAN_PARENT, "", "", + DBUS_TYPE_G_OBJECT_PATH, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_VLAN_ID, g_param_spec_uint (NM_DEVICE_VLAN_ID, "", "", @@ -575,6 +583,14 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + /* Internal properties */ + g_object_class_install_property + (object_class, PROP_INT_PARENT_DEVICE, + g_param_spec_object (NM_DEVICE_VLAN_INT_PARENT_DEVICE, "", "", + NM_TYPE_DEVICE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_vlan_object_info); @@ -613,7 +629,7 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error) device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_VLAN, NM_DEVICE_PLATFORM_DEVICE, plink, - NM_DEVICE_VLAN_PARENT, parent, + NM_DEVICE_VLAN_INT_PARENT_DEVICE, parent, NM_DEVICE_DRIVER, "8021q", NM_DEVICE_TYPE_DESC, "VLAN", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_VLAN, @@ -663,7 +679,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_VLAN, NM_DEVICE_IFACE, iface, - NM_DEVICE_VLAN_PARENT, parent, + NM_DEVICE_VLAN_INT_PARENT_DEVICE, parent, NM_DEVICE_DRIVER, "8021q", NM_DEVICE_TYPE_DESC, "VLAN", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_VLAN, diff --git a/src/devices/nm-device-vlan.h b/src/devices/nm-device-vlan.h index e1618db440..20fc345379 100644 --- a/src/devices/nm-device-vlan.h +++ b/src/devices/nm-device-vlan.h @@ -40,9 +40,13 @@ typedef enum { NM_VLAN_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ } NMVlanError; +/* D-Bus exported properties */ #define NM_DEVICE_VLAN_PARENT "parent" #define NM_DEVICE_VLAN_ID "vlan-id" +/* Internal non-exported properties */ +#define NM_DEVICE_VLAN_INT_PARENT_DEVICE "int-parent-device" + typedef NMDevice NMDeviceVlan; typedef NMDeviceClass NMDeviceVlanClass;