diff options
Diffstat (limited to 'src/devices/nm-device-generic.c')
-rw-r--r-- | src/devices/nm-device-generic.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index db5b2b6b4d..5d092b98f7 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -60,6 +60,21 @@ get_type_description (NMDevice *device) return NM_DEVICE_CLASS (nm_device_generic_parent_class)->get_type_description (device); } +static void +setup (NMDevice *device, NMPlatformLink *plink) +{ + NMDeviceGeneric *self = NM_DEVICE_GENERIC (device); + NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); + int ifindex; + + NM_DEVICE_CLASS (nm_device_generic_parent_class)->setup (device, plink); + + g_clear_pointer (&priv->type_description, g_free); + ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self)); + if (ifindex > 0) + priv->type_description = g_strdup (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex)); +} + static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { @@ -96,12 +111,12 @@ update_connection (NMDevice *device, NMConnection *connection) /**************************************************************/ NMDevice * -nm_device_generic_new (NMPlatformLink *platform_device) +nm_device_generic_new (NMPlatformLink *plink) { - g_return_val_if_fail (platform_device != NULL, NULL); + g_return_val_if_fail (plink != NULL, NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_GENERIC, - NM_DEVICE_PLATFORM_DEVICE, platform_device, + NM_DEVICE_IFACE, plink->name, NM_DEVICE_TYPE_DESC, "Generic", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, NULL); @@ -114,22 +129,6 @@ nm_device_generic_init (NMDeviceGeneric *self) } static void -constructed (GObject *object) -{ - NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); - NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); - - if (!priv->type_description) { - int ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self)); - - if (ifindex != 0) - priv->type_description = g_strdup (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex)); - } - - G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object); -} - -static void dispose (GObject *object) { NMDeviceGeneric *self = NM_DEVICE_GENERIC (object); @@ -184,11 +183,11 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass) parent_class->connection_type = NM_SETTING_GENERIC_SETTING_NAME; - object_class->constructed = constructed; object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; + parent_class->setup = setup; parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_type_description = get_type_description; parent_class->check_connection_compatible = check_connection_compatible; |