core: rearrange some VLAN code and clean up dispose()
Move parent-related stuff before its callers and clean up dispose so that we no longer need priv->disposed.
This commit is contained in:
@@ -52,12 +52,10 @@ G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE)
|
|||||||
#define NM_DEVICE_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VLAN, NMDeviceVlanPrivate))
|
#define NM_DEVICE_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VLAN, NMDeviceVlanPrivate))
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gboolean disposed;
|
|
||||||
gboolean invalid;
|
gboolean invalid;
|
||||||
|
|
||||||
NMDevice *parent;
|
NMDevice *parent;
|
||||||
guint parent_state_id;
|
guint parent_state_id;
|
||||||
|
|
||||||
int vlan_id;
|
int vlan_id;
|
||||||
} NMDeviceVlanPrivate;
|
} NMDeviceVlanPrivate;
|
||||||
|
|
||||||
@@ -73,38 +71,6 @@ enum {
|
|||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
static NMDeviceCapabilities
|
|
||||||
get_generic_capabilities (NMDevice *dev)
|
|
||||||
{
|
|
||||||
/* We assume VLAN interfaces always support carrier detect */
|
|
||||||
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
bring_up (NMDevice *dev, gboolean *no_firmware)
|
|
||||||
{
|
|
||||||
gboolean success = FALSE;
|
|
||||||
guint i = 20;
|
|
||||||
|
|
||||||
while (i-- > 0 && !success) {
|
|
||||||
success = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->bring_up (dev, no_firmware);
|
|
||||||
g_usleep (50);
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************/
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
|
|
||||||
{
|
|
||||||
if (!NM_DEVICE_VLAN_GET_PRIVATE (device)->parent)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->is_available (device, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parent_state_changed (NMDevice *parent,
|
parent_state_changed (NMDevice *parent,
|
||||||
NMDeviceState new_state,
|
NMDeviceState new_state,
|
||||||
@@ -163,6 +129,38 @@ nm_device_vlan_set_parent (NMDeviceVlan *self, NMDevice *parent, gboolean constr
|
|||||||
g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_PARENT);
|
g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_PARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NMDeviceCapabilities
|
||||||
|
get_generic_capabilities (NMDevice *dev)
|
||||||
|
{
|
||||||
|
/* We assume VLAN interfaces always support carrier detect */
|
||||||
|
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
bring_up (NMDevice *dev, gboolean *no_firmware)
|
||||||
|
{
|
||||||
|
gboolean success = FALSE;
|
||||||
|
guint i = 20;
|
||||||
|
|
||||||
|
while (i-- > 0 && !success) {
|
||||||
|
success = NM_DEVICE_CLASS (nm_device_vlan_parent_class)->bring_up (dev, no_firmware);
|
||||||
|
g_usleep (50);
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
|
||||||
|
{
|
||||||
|
if (!NM_DEVICE_VLAN_GET_PRIVATE (device)->parent)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->is_available (device, flags);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
component_added (NMDevice *device, GObject *component)
|
component_added (NMDevice *device, GObject *component)
|
||||||
{
|
{
|
||||||
@@ -553,16 +551,7 @@ set_property (GObject *object, guint prop_id,
|
|||||||
static void
|
static void
|
||||||
dispose (GObject *object)
|
dispose (GObject *object)
|
||||||
{
|
{
|
||||||
NMDeviceVlan *self = NM_DEVICE_VLAN (object);
|
nm_device_vlan_set_parent (NM_DEVICE_VLAN (object), NULL, FALSE);
|
||||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
|
|
||||||
|
|
||||||
if (priv->disposed) {
|
|
||||||
G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
priv->disposed = TRUE;
|
|
||||||
|
|
||||||
nm_device_vlan_set_parent (self, NULL, FALSE);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object);
|
G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user