mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-02 21:40:13 +01:00
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: 1f5b48a59e
This commit is contained in:
parent
ce28e6ab30
commit
5dfc571971
1 changed files with 32 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue