core: move nm_device_interface_can_assume_connections() to nm-device.c

This commit is contained in:
Dan Williams 2011-11-17 23:10:11 -06:00
parent 4f330838bd
commit 1287c8e18d
5 changed files with 13 additions and 28 deletions

View file

@ -381,16 +381,6 @@ nm_device_interface_connection_match_config (NMDeviceInterface *device,
return NULL;
}
gboolean
nm_device_interface_can_assume_connections (NMDeviceInterface *device)
{
g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), FALSE);
if (NM_DEVICE_INTERFACE_GET_INTERFACE (device)->can_assume_connections)
return NM_DEVICE_INTERFACE_GET_INTERFACE (device)->can_assume_connections (device);
return FALSE;
}
void
nm_device_interface_set_enabled (NMDeviceInterface *device, gboolean enabled)
{

View file

@ -104,8 +104,6 @@ struct _NMDeviceInterface {
NMConnection * (*connection_match_config) (NMDeviceInterface *device, const GSList *specs);
gboolean (*can_assume_connections) (NMDeviceInterface *device);
void (*set_enabled) (NMDeviceInterface *device, gboolean enabled);
gboolean (*get_enabled) (NMDeviceInterface *device);
@ -136,8 +134,6 @@ gboolean nm_device_interface_spec_match_list (NMDeviceInterface *device,
NMConnection * nm_device_interface_connection_match_config (NMDeviceInterface *device,
const GSList *connections);
gboolean nm_device_interface_can_assume_connections (NMDeviceInterface *device);
gboolean nm_device_interface_get_enabled (NMDeviceInterface *device);
void nm_device_interface_set_enabled (NMDeviceInterface *device, gboolean enabled);

View file

@ -175,7 +175,6 @@ static void nm_device_deactivate (NMDeviceInterface *device, NMDeviceStateReason
static gboolean device_disconnect (NMDeviceInterface *device, GError **error);
static gboolean spec_match_list (NMDeviceInterface *device, const GSList *specs);
static NMConnection *connection_match_config (NMDeviceInterface *device, const GSList *connections);
static gboolean can_assume_connections (NMDeviceInterface *device);
static void nm_device_take_down (NMDevice *dev, gboolean wait, NMDeviceStateReason reason);
@ -207,7 +206,6 @@ device_interface_init (NMDeviceInterface *device_interface_class)
device_interface_class->disconnect = device_disconnect;
device_interface_class->spec_match_list = spec_match_list;
device_interface_class->connection_match_config = connection_match_config;
device_interface_class->can_assume_connections = can_assume_connections;
}
@ -669,6 +667,15 @@ nm_device_check_connection_compatible (NMDevice *device,
return TRUE;
}
gboolean
nm_device_can_assume_connections (NMDevice *device)
{
g_return_val_if_fail (device != NULL, FALSE);
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
return !!NM_DEVICE_GET_CLASS (device)->connection_match_config;
}
static void
dnsmasq_state_changed_cb (NMDnsMasqManager *manager, guint32 status, gpointer user_data)
{
@ -3345,8 +3352,7 @@ dispose (GObject *object)
/* Don't down can-assume-connection capable devices that are activated with
* a connection that can be assumed.
*/
if ( nm_device_interface_can_assume_connections (NM_DEVICE_INTERFACE (self))
&& (nm_device_get_state (self) == NM_DEVICE_STATE_ACTIVATED)) {
if (nm_device_can_assume_connections (self) && (priv->state == NM_DEVICE_STATE_ACTIVATED)) {
NMConnection *connection;
NMSettingIP4Config *s_ip4 = NULL;
const char *method = NULL;
@ -4059,14 +4065,6 @@ connection_match_config (NMDeviceInterface *device, const GSList *connections)
return NULL;
}
static gboolean
can_assume_connections (NMDeviceInterface *device)
{
g_return_val_if_fail (device != NULL, FALSE);
return !!NM_DEVICE_GET_CLASS (device)->connection_match_config;
}
void
nm_device_set_dhcp_timeout (NMDevice *device, guint32 timeout)
{

View file

@ -160,6 +160,7 @@ gboolean nm_device_check_connection_compatible (NMDevice *device,
NMConnection *connection,
GError **error);
gboolean nm_device_can_assume_connections (NMDevice *device);
gboolean nm_device_is_activating (NMDevice *dev);
gboolean nm_device_can_interrupt_activation (NMDevice *self);

View file

@ -553,7 +553,7 @@ remove_one_device (NMManager *manager,
* connections get torn down and the interface is deactivated.
*/
if ( !nm_device_interface_can_assume_connections (NM_DEVICE_INTERFACE (device))
if ( !nm_device_can_assume_connections (device)
|| (nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED)
|| !quitting)
nm_device_set_managed (device, FALSE, NM_DEVICE_STATE_REASON_REMOVED);
@ -1563,7 +1563,7 @@ add_device (NMManager *self, NMDevice *device)
/* Check if we should assume the device's active connection by matching its
* config with an existing system connection.
*/
if (nm_device_interface_can_assume_connections (NM_DEVICE_INTERFACE (device))) {
if (nm_device_can_assume_connections (device)) {
GSList *connections = NULL;
connections = nm_settings_get_connections (priv->settings);