summary refs log tree commit diff
path: root/libnm-glib/nm-device-generic.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2016-01-20 16:26:51 +0100
committerMichael Biebl <biebl@debian.org>2016-01-20 16:26:51 +0100
commit494f296a3baab08522617b24b1f126d8f9a17502 (patch)
treec8ef32fb0dd1c4ff35a0b38e787abb58692de0cd /libnm-glib/nm-device-generic.c
parent54f6333410ffd570e62717d9e77c5c987175e397 (diff)
Imported Upstream version 1.1.90 upstream/1.1.90
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