From f8852bf4a4fdfb512c5a57abcef5145991b05731 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 17 Nov 2011 22:50:36 -0600 Subject: [PATCH] core: kill nm_device_interface_get_state() --- src/nm-device-bt.c | 6 +++--- src/nm-device-interface.c | 14 ++++---------- src/nm-device-interface.h | 2 -- src/nm-device-modem.c | 6 +++--- src/nm-device-wifi.c | 2 +- src/nm-device-wired.c | 6 +++--- src/nm-manager.c | 2 +- src/nm-policy.c | 2 +- src/wimax/nm-device-wimax.c | 8 ++++---- 9 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/nm-device-bt.c b/src/nm-device-bt.c index 57f2af9594..8a9ffc77d3 100644 --- a/src/nm-device-bt.c +++ b/src/nm-device-bt.c @@ -421,7 +421,7 @@ ppp_failed (NMModem *modem, NMDeviceStateReason reason, gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); - switch (nm_device_interface_get_state (NM_DEVICE_INTERFACE (device))) { + switch (nm_device_get_state (device)) { case NM_DEVICE_STATE_PREPARE: case NM_DEVICE_STATE_CONFIG: case NM_DEVICE_STATE_NEED_AUTH: @@ -478,7 +478,7 @@ modem_prepare_result (NMModem *modem, NMDevice *device = NM_DEVICE (user_data); NMDeviceState state; - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device)); + state = nm_device_get_state (device); g_return_if_fail (state == NM_DEVICE_STATE_CONFIG || state == NM_DEVICE_STATE_NEED_AUTH); if (success) { @@ -611,7 +611,7 @@ nm_device_bt_modem_added (NMDeviceBt *self, /* Can only accept the modem in stage2, but since the interface matched * what we were expecting, don't let anything else claim the modem either. */ - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self)); + state = nm_device_get_state (NM_DEVICE (self)); if (state != NM_DEVICE_STATE_CONFIG) { nm_log_warn (LOGD_BT | LOGD_MB, "(%s): modem found but device not in correct state (%d)", diff --git a/src/nm-device-interface.c b/src/nm-device-interface.c index fb471f577c..f44a7d4a66 100644 --- a/src/nm-device-interface.c +++ b/src/nm-device-interface.c @@ -334,11 +334,14 @@ gboolean nm_device_interface_disconnect (NMDeviceInterface *device, GError **error) { + NMDeviceState state; gboolean success = FALSE; g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), FALSE); - switch (nm_device_interface_get_state (device)) { + g_object_get (G_OBJECT (device), "state", &state, NULL); + + switch (state) { case NM_DEVICE_STATE_UNKNOWN: case NM_DEVICE_STATE_UNMANAGED: case NM_DEVICE_STATE_UNAVAILABLE: @@ -371,15 +374,6 @@ nm_device_interface_deactivate (NMDeviceInterface *device, NMDeviceStateReason r NM_DEVICE_INTERFACE_GET_INTERFACE (device)->deactivate (device, reason); } -NMDeviceState -nm_device_interface_get_state (NMDeviceInterface *device) -{ - NMDeviceState state; - - g_object_get (G_OBJECT (device), "state", &state, NULL); - return state; -} - gboolean nm_device_interface_spec_match_list (NMDeviceInterface *device, const GSList *specs) diff --git a/src/nm-device-interface.h b/src/nm-device-interface.h index 560cdfe517..e0ea59ea55 100644 --- a/src/nm-device-interface.h +++ b/src/nm-device-interface.h @@ -141,8 +141,6 @@ gboolean nm_device_interface_activate (NMDeviceInterface *device, void nm_device_interface_deactivate (NMDeviceInterface *device, NMDeviceStateReason reason); -NMDeviceState nm_device_interface_get_state (NMDeviceInterface *device); - gboolean nm_device_interface_spec_match_list (NMDeviceInterface *device, const GSList *specs); diff --git a/src/nm-device-modem.c b/src/nm-device-modem.c index f190ba1afa..797ffdc75e 100644 --- a/src/nm-device-modem.c +++ b/src/nm-device-modem.c @@ -69,7 +69,7 @@ ppp_failed (NMModem *modem, NMDeviceStateReason reason, gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); - switch (nm_device_interface_get_state (NM_DEVICE_INTERFACE (device))) { + switch (nm_device_get_state (device)) { case NM_DEVICE_STATE_PREPARE: case NM_DEVICE_STATE_CONFIG: case NM_DEVICE_STATE_NEED_AUTH: @@ -99,7 +99,7 @@ modem_prepare_result (NMModem *modem, NMDevice *device = NM_DEVICE (user_data); NMDeviceState state; - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device)); + state = nm_device_get_state (device); g_return_if_fail (state == NM_DEVICE_STATE_PREPARE); if (success) @@ -302,7 +302,7 @@ real_set_enabled (NMDeviceInterface *device, gboolean enabled) nm_modem_set_mm_enabled (priv->modem, enabled); if (enabled == FALSE) { - state = nm_device_interface_get_state (device); + state = nm_device_get_state (NM_DEVICE (device)); if (state == NM_DEVICE_STATE_ACTIVATED) { nm_device_state_changed (NM_DEVICE (device), NM_DEVICE_STATE_DISCONNECTED, diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c index 468cb33a08..622ed5b813 100644 --- a/src/nm-device-wifi.c +++ b/src/nm-device-wifi.c @@ -3071,7 +3071,7 @@ real_set_enabled (NMDeviceInterface *device, gboolean enabled) nm_device_get_iface (NM_DEVICE (device)), enabled ? "enabled" : "disabled"); - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self)); + state = nm_device_get_state (NM_DEVICE (self)); if (state < NM_DEVICE_STATE_UNAVAILABLE) { nm_log_dbg (LOGD_WIFI, "(%s): %s blocked by UNMANAGED state", enabled ? "enable" : "disable", diff --git a/src/nm-device-wired.c b/src/nm-device-wired.c index 6adbf6a5dd..5a26ec6e11 100644 --- a/src/nm-device-wired.c +++ b/src/nm-device-wired.c @@ -77,7 +77,7 @@ carrier_action_defer_cb (gpointer user_data) priv->carrier_action_defer_id = 0; - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self)); + state = nm_device_get_state (NM_DEVICE (self)); if (state == NM_DEVICE_STATE_UNAVAILABLE) { if (priv->carrier) nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_CARRIER); @@ -109,7 +109,7 @@ set_carrier (NMDeviceWired *self, priv->carrier = carrier; g_object_notify (G_OBJECT (self), "carrier"); - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self)); + state = nm_device_get_state (NM_DEVICE (self)); nm_log_info (LOGD_HW | NM_DEVICE_WIRED_LOG_LEVEL (NM_DEVICE (self)), "(%s): carrier now %s (device state %d%s)", nm_device_get_iface (NM_DEVICE (self)), @@ -166,7 +166,7 @@ carrier_off (NMNetlinkMonitor *monitor, * so that tripping over a cable, power-cycling a switch, or breaking * off the RJ45 locking tab isn't so catastrophic. */ - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self)); + state = nm_device_get_state (device); if (state > NM_DEVICE_STATE_DISCONNECTED) defer = TRUE; diff --git a/src/nm-manager.c b/src/nm-manager.c index f21a9fffb1..0e9d1cd10f 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2096,7 +2096,7 @@ nm_manager_activate_connection (NMManager *manager, return NULL; } - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device)); + state = nm_device_get_state (device); if (state < NM_DEVICE_STATE_DISCONNECTED) { g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNMANAGED_DEVICE, diff --git a/src/nm-policy.c b/src/nm-policy.c index 8086ef9983..729bdb7610 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -960,7 +960,7 @@ schedule_activate_check (NMPolicy *policy, NMDevice *device, guint delay_seconds if (nm_manager_get_state (policy->manager) == NM_STATE_ASLEEP) return; - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device)); + state = nm_device_get_state (device); if (state < NM_DEVICE_STATE_DISCONNECTED) return; diff --git a/src/wimax/nm-device-wimax.c b/src/wimax/nm-device-wimax.c index cf69930206..748511327a 100644 --- a/src/wimax/nm-device-wimax.c +++ b/src/wimax/nm-device-wimax.c @@ -322,7 +322,7 @@ update_availability (NMDeviceWimax *self, gboolean old_available) if (new_available == old_available) return FALSE; - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self)); + state = nm_device_get_state (device); if (state == NM_DEVICE_STATE_UNAVAILABLE) { if (new_available == TRUE) { nm_device_state_changed (device, @@ -879,7 +879,7 @@ wmx_state_change_cb (struct wmxsdk *wmxsdk, if (new_status == old_status) return; - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self)); + state = nm_device_get_state (NM_DEVICE (self)); old_available = nm_device_is_available (NM_DEVICE (self)); priv->status = new_status; @@ -994,7 +994,7 @@ wmx_media_status_cb (struct wmxsdk *wmxsdk, const char *iface; iface = nm_device_get_iface (NM_DEVICE (self)); - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self)); + state = nm_device_get_state (NM_DEVICE (self)); nm_log_dbg (LOGD_WIMAX, "(%s): media status change to %s", iface, iwmx_sdk_media_status_to_str (new_status)); @@ -1035,7 +1035,7 @@ wmx_connect_result_cb (struct wmxsdk *wmxsdk, NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); NMDeviceState state; - state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self)); + state = nm_device_get_state (NM_DEVICE (self)); if (IS_ACTIVATING_STATE (state)) { priv->connect_failed = (result == WIMAX_API_CONNECTION_SUCCESS); /* Wait for the state change so we can get the reason code; we