diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 1d539ea388..cad7916064 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -290,36 +290,6 @@ nm_device_ethernet_init (NMDeviceEthernet * self) { } -static gboolean -is_up (NMDevice *device) -{ - if (!NM_DEVICE_ETHERNET_GET_PRIVATE (device)->supplicant.mgr) - return FALSE; - - return TRUE; -} - -static gboolean -bring_up (NMDevice *dev) -{ - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (dev); - - priv->supplicant.mgr = nm_supplicant_manager_get (); - - return priv->supplicant.mgr ? TRUE : FALSE; -} - -static void -take_down (NMDevice *dev) -{ - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (dev); - - if (priv->supplicant.mgr) { - g_object_unref (priv->supplicant.mgr); - priv->supplicant.mgr = NULL; - } -} - NMDevice * nm_device_ethernet_new (NMPlatformLink *platform_device) { @@ -994,6 +964,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) static NMActStageReturn nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason) { + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMConnection *connection; NMSetting8021x *security; const char *setting_name; @@ -1009,6 +980,9 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason) return ret; } + if (!priv->supplicant.mgr) + priv->supplicant.mgr = nm_supplicant_manager_get (); + iface = nm_device_get_iface (NM_DEVICE (self)); /* If we need secrets, get them */ @@ -1365,6 +1339,7 @@ dispose (GObject *object) NMDeviceEthernet *self = NM_DEVICE_ETHERNET (object); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); + g_clear_object (&priv->supplicant.mgr); g_free (priv->subchan1); g_free (priv->subchan2); g_free (priv->subchan3); @@ -1419,9 +1394,6 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) object_class->set_property = set_property; parent_class->get_generic_capabilities = get_generic_capabilities; - parent_class->is_up = is_up; - parent_class->bring_up = bring_up; - parent_class->take_down = take_down; parent_class->update_permanent_hw_address = update_permanent_hw_address; parent_class->update_initial_hw_address = update_initial_hw_address; parent_class->check_connection_compatible = check_connection_compatible; diff --git a/src/devices/nm-device-olpc-mesh.c b/src/devices/nm-device-olpc-mesh.c index 2599cce5bc..691b629506 100644 --- a/src/devices/nm-device-olpc-mesh.c +++ b/src/devices/nm-device-olpc-mesh.c @@ -81,16 +81,11 @@ enum { #define NM_OLPC_MESH_ERROR (nm_olpc_mesh_error_quark ()) -struct _NMDeviceOlpcMeshPrivate -{ +struct _NMDeviceOlpcMeshPrivate { gboolean dispose_has_run; - GByteArray * ssid; - WifiData * wifi_data; - gboolean up; - NMDevice * companion; gboolean stage1_waiting; guint device_added_id; @@ -167,43 +162,6 @@ constructor (GType type, return object; } -static gboolean -is_up (NMDevice *device) -{ - NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); - - return priv->up; -} - -static gboolean -bring_up (NMDevice *dev) -{ - NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (dev); - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); - - priv->up = TRUE; - return TRUE; -} - -static void -device_cleanup (NMDeviceOlpcMesh *self) -{ - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); - - if (priv->ssid) { - g_byte_array_free (priv->ssid, TRUE); - priv->ssid = NULL; - } - priv->up = FALSE; -} - -static void -take_down (NMDevice *dev) -{ - device_cleanup (NM_DEVICE_OLPC_MESH (dev)); -} - static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection, @@ -411,7 +369,6 @@ dispose (GObject *object) if (priv->wifi_data) wifi_utils_deinit (priv->wifi_data); - device_cleanup (self); companion_cleanup (self); manager = nm_manager_get (); @@ -471,9 +428,6 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass) object_class->set_property = set_property; object_class->dispose = dispose; - parent_class->is_up = is_up; - parent_class->bring_up = bring_up; - parent_class->take_down = take_down; parent_class->check_connection_compatible = check_connection_compatible; parent_class->can_auto_connect = can_auto_connect; parent_class->complete_connection = complete_connection; diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c index 35667599ad..a6a7d3e947 100644 --- a/src/devices/nm-device-wifi.c +++ b/src/devices/nm-device-wifi.c @@ -802,25 +802,6 @@ hw_bring_up (NMDevice *device, gboolean *no_firmware) return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->hw_bring_up (device, no_firmware); } -static gboolean -is_up (NMDevice *device) -{ - if (!NM_DEVICE_WIFI_GET_PRIVATE (device)->periodic_source_id) - return FALSE; - - return TRUE; -} - -static gboolean -bring_up (NMDevice *dev) -{ - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - - priv->periodic_source_id = g_timeout_add_seconds (6, periodic_update, self); - return TRUE; -} - static gboolean _set_hw_addr (NMDeviceWifi *self, const guint8 *addr, const char *detail) { @@ -894,22 +875,6 @@ remove_all_aps (NMDeviceWifi *self) nm_device_recheck_available_connections (NM_DEVICE (self)); } -static void -take_down (NMDevice *dev) -{ - NMDeviceWifi *self = NM_DEVICE_WIFI (dev); - NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - - if (priv->periodic_source_id) { - g_source_remove (priv->periodic_source_id); - priv->periodic_source_id = 0; - } - - cleanup_association_attempt (self, TRUE); - set_active_ap (self, NULL); - remove_all_aps (self); -} - static void deactivate (NMDevice *dev) { @@ -927,6 +892,11 @@ deactivate (NMDevice *dev) g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL); } + if (priv->periodic_source_id) { + g_source_remove (priv->periodic_source_id); + priv->periodic_source_id = 0; + } + cleanup_association_attempt (self, TRUE); set_active_ap (self, NULL); @@ -3083,6 +3053,9 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason) goto out; } + if (!priv->periodic_source_id) + priv->periodic_source_id = g_timeout_add_seconds (6, periodic_update, self); + /* We'll get stage3 started when the supplicant connects */ ret = NM_ACT_STAGE_RETURN_POSTPONE; @@ -3372,6 +3345,15 @@ device_state_changed (NMDevice *device, */ if (priv->supplicant.iface) supplicant_interface_release (self); + + if (priv->periodic_source_id) { + g_source_remove (priv->periodic_source_id); + priv->periodic_source_id = 0; + } + + cleanup_association_attempt (self, TRUE); + set_active_ap (self, NULL); + remove_all_aps (self); } /* Start or stop the rfkill poll worker for ipw cards */ @@ -3633,9 +3615,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) object_class->dispose = dispose; parent_class->hw_bring_up = hw_bring_up; - parent_class->is_up = is_up; - parent_class->bring_up = bring_up; - parent_class->take_down = take_down; parent_class->update_permanent_hw_address = update_permanent_hw_address; parent_class->update_initial_hw_address = update_initial_hw_address; parent_class->can_auto_connect = can_auto_connect; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index f337a9775e..b6514a0e40 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -288,11 +288,6 @@ typedef struct { } NMDevicePrivate; -static void nm_device_take_down (NMDevice *dev, gboolean wait, NMDeviceStateReason reason); - -static gboolean nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware); -static gboolean nm_device_is_up (NMDevice *self); - static gboolean nm_device_set_ip4_config (NMDevice *dev, NMIP4Config *config, gboolean assumed, @@ -1802,7 +1797,7 @@ nm_device_activate_stage2_device_config (gpointer user_data) nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) starting...", iface); nm_device_state_changed (self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE); - if (!nm_device_bring_up (self, FALSE, &no_firmware)) { + if (!nm_device_hw_bring_up (self, FALSE, &no_firmware)) { if (no_firmware) nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_FIRMWARE_MISSING); else @@ -4431,17 +4426,6 @@ nm_device_get_ip6_config (NMDevice *self) return NM_DEVICE_GET_PRIVATE (self)->ip6_config; } -static gboolean -nm_device_is_up (NMDevice *self) -{ - g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); - - if (NM_DEVICE_GET_CLASS (self)->is_up) - return NM_DEVICE_GET_CLASS (self)->is_up (self); - - return TRUE; -} - gboolean nm_device_hw_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) { @@ -4527,45 +4511,6 @@ hw_take_down (NMDevice *device) nm_platform_link_set_down (ifindex); } -static gboolean -nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) -{ - gboolean success = FALSE; - - g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); - - if (!nm_device_hw_bring_up (self, block, no_firmware)) - return FALSE; - - if (nm_device_is_up (self)) - return TRUE; - - nm_log_info (LOGD_HW, "(%s): preparing device.", nm_device_get_iface (self)); - - if (NM_DEVICE_GET_CLASS (self)->bring_up) - success = NM_DEVICE_GET_CLASS (self)->bring_up (self); - - return success; -} - -static void -nm_device_take_down (NMDevice *self, gboolean block, NMDeviceStateReason reason) -{ - g_return_if_fail (NM_IS_DEVICE (self)); - - if (nm_device_get_act_request (self)) - nm_device_deactivate (self, reason); - - if (nm_device_is_up (self)) { - nm_log_info (LOGD_HW, "(%s): cleaning up...", nm_device_get_iface (self)); - - if (NM_DEVICE_GET_CLASS (self)->take_down) - NM_DEVICE_GET_CLASS (self)->take_down (self); - } - - nm_device_hw_take_down (self, block); -} - static void dispose (GObject *object) { @@ -4620,8 +4565,11 @@ dispose (GObject *object) if (nm_device_get_managed (self) && take_down) { NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE; - nm_device_take_down (self, FALSE, NM_DEVICE_STATE_REASON_REMOVED); + if (nm_device_get_act_request (self)) + nm_device_deactivate (self, NM_DEVICE_STATE_REASON_REMOVED); nm_device_set_ip4_config (self, NULL, FALSE, &ignored); + + nm_device_hw_take_down (self, FALSE); } /* reset the saved RA value */ @@ -5485,12 +5433,16 @@ nm_device_state_changed (NMDevice *device, switch (state) { case NM_DEVICE_STATE_UNMANAGED: nm_device_set_firmware_missing (device, FALSE); - if (old_state > NM_DEVICE_STATE_UNMANAGED) - nm_device_take_down (device, TRUE, reason); + if (old_state > NM_DEVICE_STATE_UNMANAGED) { + /* Clean up if the device is now unmanaged but was activated */ + if (nm_device_get_act_request (device)) + nm_device_deactivate (device, reason); + nm_device_hw_take_down (device, TRUE); + } break; case NM_DEVICE_STATE_UNAVAILABLE: if (old_state == NM_DEVICE_STATE_UNMANAGED || priv->firmware_missing) { - if (!nm_device_bring_up (device, TRUE, &no_firmware) && no_firmware) + if (!nm_device_hw_bring_up (device, TRUE, &no_firmware) && no_firmware) nm_log_warn (LOGD_HW, "(%s): firmware may be missing.", nm_device_get_iface (device)); nm_device_set_firmware_missing (device, no_firmware ? TRUE : FALSE); } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 71dc06a4d8..85b1f419d0 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -109,13 +109,6 @@ typedef struct { /* Carrier state (IFF_LOWER_UP) */ void (*carrier_changed) (NMDevice *, gboolean carrier); - /* Additional stuff required to operate the device, like a - * connection to the supplicant, Bluez, etc - */ - gboolean (*is_up) (NMDevice *self); - gboolean (*bring_up) (NMDevice *self); - void (*take_down) (NMDevice *self); - void (* update_hw_address) (NMDevice *self); void (* update_permanent_hw_address) (NMDevice *self); void (* update_initial_hw_address) (NMDevice *self); diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c index 3e0d3eead9..8c0a8b1375 100644 --- a/src/devices/wimax/nm-device-wimax.c +++ b/src/devices/wimax/nm-device-wimax.c @@ -332,15 +332,6 @@ set_enabled (NMDevice *device, gboolean enabled) /* NMDevice methods */ -static void -take_down (NMDevice *device) -{ - NMDeviceWimax *self = NM_DEVICE_WIMAX (device); - - set_current_nsp (self, NULL); - remove_all_nsps (self); -} - static gboolean hw_bring_up (NMDevice *dev, gboolean *no_firmware) { @@ -1403,7 +1394,6 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *klass) object_class->get_property = get_property; object_class->dispose = dispose; - device_class->take_down = take_down; device_class->hw_bring_up = hw_bring_up; device_class->check_connection_compatible = check_connection_compatible; device_class->check_connection_available = check_connection_available;