diff options
Diffstat (limited to 'libnm-glib')
-rw-r--r-- | libnm-glib/nm-device-generic.c | 30 | ||||
-rw-r--r-- | libnm-glib/nm-device.c | 1 |
2 files changed, 29 insertions, 2 deletions
diff --git a/libnm-glib/nm-device-generic.c b/libnm-glib/nm-device-generic.c index a17a67355..a7b2fa04d 100644 --- a/libnm-glib/nm-device-generic.c +++ b/libnm-glib/nm-device-generic.c @@ -184,15 +184,41 @@ register_properties (NMDeviceGeneric *device) property_info); } +static const char * +_device_type_to_interface (NMDeviceType type) +{ + switch (type) { + case NM_DEVICE_TYPE_GENERIC: + return NM_DBUS_INTERFACE_DEVICE_GENERIC; + case NM_DEVICE_TYPE_TUN: + return NM_DBUS_INTERFACE_DEVICE_TUN; + default: + return NULL; + } +} + static void constructed (GObject *object) { NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); + NMDeviceType type; + DBusGConnection *connection; + const char *path, *interface; G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object); - priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_GENERIC); - register_properties (NM_DEVICE_GENERIC (object)); + g_object_get (object, + NM_OBJECT_DBUS_CONNECTION, &connection, + NM_OBJECT_DBUS_PATH, &path, + NULL); + + type = _nm_device_type_for_path (connection, path); + interface = _device_type_to_interface (type); + + if (interface) { + priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, interface); + register_properties (NM_DEVICE_GENERIC (object)); + } } static void diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index 7731183e7..aac94fb1d 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -320,6 +320,7 @@ _nm_device_gtype_from_dtype (NMDeviceType dtype) case NM_DEVICE_TYPE_VLAN: return NM_TYPE_DEVICE_VLAN; case NM_DEVICE_TYPE_GENERIC: + case NM_DEVICE_TYPE_TUN: return NM_TYPE_DEVICE_GENERIC; default: g_warning ("Unknown device type %d", dtype); |