summaryrefslogtreecommitdiff
path: root/libnm/nm-device.c
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-11-12 14:09:08 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2016-11-14 13:38:26 +0100
commit5dfc571971f749a35b5c6c22d73b38a99d10b840 (patch)
treee286266962cba6a64abbb192c6d490a5de1eb9b3 /libnm/nm-device.c
parentce28e6ab3080cacdb1138057ac8442e42e0b20b7 (diff)
downloadNetworkManager-5dfc571971f749a35b5c6c22d73b38a99d10b840.tar.gz
libnm: initialize @device_type of device objects
Before switching to the ObjectManager, the D-Bus property was used to decide the actual type of the device and the property set manually by each subclass in its _init() function. Now we determine objects type based on their D-Bus interface and therefore we can handle the property like all others, ensuring that we return a known value in get_property() to avoid warnings in GLib. This fixes the missing initialization of the property which causes regressions on clients as nm-applet. Fixes: 1f5b48a59eb46c40cb10bf4381b2b21a19a9f471
Diffstat (limited to 'libnm/nm-device.c')
-rw-r--r--libnm/nm-device.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/libnm/nm-device.c b/libnm/nm-device.c
index 25788d92b1..e55549df48 100644
--- a/libnm/nm-device.c
+++ b/libnm/nm-device.c
@@ -199,6 +199,7 @@ init_dbus (NMObject *object)
const NMPropertiesInfo property_info[] = {
{ NM_DEVICE_UDI, &priv->udi },
{ NM_DEVICE_INTERFACE, &priv->iface },
+ { NM_DEVICE_DEVICE_TYPE, &priv->device_type },
{ NM_DEVICE_IP_INTERFACE, &priv->ip_iface },
{ NM_DEVICE_DRIVER, &priv->driver },
{ NM_DEVICE_DRIVER_VERSION, &priv->driver_version },
@@ -224,7 +225,6 @@ init_dbus (NMObject *object)
/* Properties that exist in D-Bus but that we don't track */
{ "ip4-address", NULL },
- { "device-type", NULL },
{ NULL },
};
@@ -251,6 +251,36 @@ device_state_reason_changed (GObject *object, GParamSpec *pspec, gpointer user_d
priv->last_seen_state = priv->state;
}
+static NMDeviceType
+coerce_type (NMDeviceType type)
+{
+ switch (type) {
+ case NM_DEVICE_TYPE_ETHERNET:
+ case NM_DEVICE_TYPE_WIFI:
+ case NM_DEVICE_TYPE_BT:
+ case NM_DEVICE_TYPE_OLPC_MESH:
+ case NM_DEVICE_TYPE_WIMAX:
+ case NM_DEVICE_TYPE_MODEM:
+ case NM_DEVICE_TYPE_INFINIBAND:
+ case NM_DEVICE_TYPE_BOND:
+ case NM_DEVICE_TYPE_TEAM:
+ case NM_DEVICE_TYPE_BRIDGE:
+ case NM_DEVICE_TYPE_VLAN:
+ case NM_DEVICE_TYPE_ADSL:
+ case NM_DEVICE_TYPE_MACVLAN:
+ case NM_DEVICE_TYPE_VXLAN:
+ case NM_DEVICE_TYPE_IP_TUNNEL:
+ case NM_DEVICE_TYPE_TUN:
+ case NM_DEVICE_TYPE_VETH:
+ case NM_DEVICE_TYPE_GENERIC:
+ case NM_DEVICE_TYPE_UNUSED1:
+ case NM_DEVICE_TYPE_UNUSED2:
+ case NM_DEVICE_TYPE_UNKNOWN:
+ return type;
+ }
+ return NM_DEVICE_TYPE_UNKNOWN;
+}
+
static void
dispose (GObject *object)
{
@@ -302,7 +332,7 @@ get_property (GObject *object,
switch (prop_id) {
case PROP_DEVICE_TYPE:
- g_value_set_enum (value, nm_device_get_device_type (device));
+ g_value_set_enum (value, coerce_type (nm_device_get_device_type (device)));
break;
case PROP_UDI:
g_value_set_string (value, nm_device_get_udi (device));
@@ -399,10 +429,6 @@ set_property (GObject *object,
gboolean b;
switch (prop_id) {
- case PROP_DEVICE_TYPE:
- /* Construct only */
- priv->device_type = g_value_get_enum (value);
- break;
case PROP_MANAGED:
b = g_value_get_boolean (value);
if (priv->managed != b)