summary refs log tree commit diff
path: root/libnm-glib/nm-device-generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-glib/nm-device-generic.c')
-rw-r--r--libnm-glib/nm-device-generic.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/libnm-glib/nm-device-generic.c b/libnm-glib/nm-device-generic.c
index a17a6735..a7b2fa04 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