vlan: export parent device for VLANs as D-Bus property

and use the internal construct-time parent property for VLAN creation.
This commit is contained in:
Jiří Klimeš 2014-07-21 12:15:54 +02:00
parent 5b75e00d43
commit fa325dca5a
3 changed files with 33 additions and 7 deletions

View file

@ -15,6 +15,12 @@
</tp:docstring>
</property>
<property name="Parent" type="o" access="read">
<tp:docstring>
Object path of the parent device of this VLAN device.
</tp:docstring>
</property>
<property name="VlanId" type="u" access="read">
<tp:docstring>
The VLAN ID of this VLAN interface.

View file

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

View file

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