diff options
author | Dan Williams <dcbw@redhat.com> | 2013-06-03 16:01:57 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-05-06 21:48:55 -0500 |
commit | 6080425088470ffb1ba0e52076e65d3b3c58aa00 (patch) | |
tree | 578cd8e4b6f820407c88f41e2069b77f8155127d /src/devices/bluetooth | |
parent | bb1fece6e6bdae53bc8383d300fa866150032ebc (diff) | |
download | NetworkManager-6080425088470ffb1ba0e52076e65d3b3c58aa00.tar.gz |
wwan: use modem states instead of enabled/connected properties
Determining when the NMDeviceModem is available and when different
connections are available is easier if the modem's state is tracked,
instead of using the separate Enabled and Connected properties.
These properties could not accurately represent the SIM lock state
and prevented NetworkManager from making the modem available for
auto-activation when locked, even if a PIN was available.
In this new scheme, the NMDeviceModem is UNAVAILABLE when the
ModemManager modem state is FAILED, UNKNOWN, or INITIALIZING. It
transitions to the NM DISCONNECTED state when the modem has finished
initializing and has not failed.
Once the NMDeviceModem is in DISCONNECTED state it can be activated
even if the SIM is locked and a PIN is required; the PIN will be
requested when starting activation, either from the connection itself
or via a secrets request. This makes auto-activation of WWAN
connections possible.
This also allows us to consolidate code dealing with modem enable/disable
into the base NMModem class using the modem state, and to log more modem
information for debugging purposes.
Diffstat (limited to 'src/devices/bluetooth')
-rw-r--r-- | src/devices/bluetooth/nm-device-bt.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index 6998bb1e20..35c44763c4 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -572,6 +572,38 @@ modem_cleanup (NMDeviceBt *self) } static void +modem_state_cb (NMModem *modem, + NMModemState new_state, + NMModemState old_state, + gpointer user_data) +{ + NMDevice *device = NM_DEVICE (user_data); + NMDeviceState dev_state = nm_device_get_state (device); + + if (new_state <= NM_MODEM_STATE_DISABLING && old_state > NM_MODEM_STATE_DISABLING) { + /* Will be called whenever something external to NM disables the + * modem directly through ModemManager. + */ + if (nm_device_is_activating (device) || dev_state == NM_DEVICE_STATE_ACTIVATED) { + nm_device_state_changed (device, + NM_DEVICE_STATE_DISCONNECTED, + NM_DEVICE_STATE_REASON_USER_REQUESTED); + return; + } + } + + if (new_state < NM_MODEM_STATE_CONNECTING && + old_state >= NM_MODEM_STATE_CONNECTING && + dev_state >= NM_DEVICE_STATE_NEED_AUTH && + dev_state <= NM_DEVICE_STATE_ACTIVATED) { + /* Fail the device if the modem disconnects unexpectedly while the + * device is activating/activated. */ + nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER); + return; + } +} + +static void modem_removed_cb (NMModem *modem, gpointer user_data) { NMDeviceBt *self = NM_DEVICE_BT (user_data); @@ -652,6 +684,7 @@ component_added (NMDevice *device, GObject *component) g_signal_connect (modem, NM_MODEM_IP4_CONFIG_RESULT, G_CALLBACK (modem_ip4_config_result), self); g_signal_connect (modem, NM_MODEM_AUTH_REQUESTED, G_CALLBACK (modem_auth_requested), self); g_signal_connect (modem, NM_MODEM_AUTH_RESULT, G_CALLBACK (modem_auth_result), self); + g_signal_connect (modem, NM_MODEM_STATE_CHANGED, G_CALLBACK (modem_state_cb), self); g_signal_connect (modem, NM_MODEM_REMOVED, G_CALLBACK (modem_removed_cb), self); /* In the old ModemManager the data port is known from the very beginning; |