diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-08-13 18:17:04 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-08-13 18:17:04 -0500 |
commit | d6f81ef17aad9a0f5f04553ce95038e9e438b49d (patch) | |
tree | 6b217874bfa7a8c93e4ceb30f2613ebd78e4f14e | |
parent | f51b8af585ceb2ede7de167834a9fbc83e9795a2 (diff) | |
download | ofono-d6f81ef17aad9a0f5f04553ce95038e9e438b49d.tar.bz2 |
gprs: Fix up some attach/detach logic issues
Parts of it are related to Meego bug 5193, namely that we don't properly
signal the Attached status when powering down.
Another part of the fix is that we automatically detach in case our
conditions are not fulfilled if the modem attaches automatically (e.g.
Auto-Attach is enabled)
-rw-r--r-- | src/gprs.c | 33 |
1 files changed, 23 insertions, 10 deletions
@@ -1375,26 +1375,39 @@ static GDBusSignalTable manager_signals[] = { void ofono_gprs_detached_notify(struct ofono_gprs *gprs) { - if (gprs->driver_attached == FALSE) - return; - gprs->driver_attached = FALSE; - gprs_attached_update(gprs); - /* TODO: The network forced a detach, we should wait for some time - * and try to re-attach + /* + * TODO: The network forced a detach, we should wait for some time + * and try to re-attach. This might also be related to a suspend + * event while voicecall is active. */ } void ofono_gprs_status_notify(struct ofono_gprs *gprs, int status) { - /* If we are not attached and haven't tried to attach, ignore */ - if (gprs->driver_attached == FALSE) - return; - gprs->status = status; gprs_attached_update(gprs); + + if (status != NETWORK_REGISTRATION_STATUS_REGISTERED && + status != NETWORK_REGISTRATION_STATUS_ROAMING) + return; + + /* We registered without being powered */ + if (gprs->powered == FALSE) + goto detach; + + if (gprs->roaming_allowed == FALSE && + status == NETWORK_REGISTRATION_STATUS_ROAMING) + goto detach; + + gprs->driver_attached = TRUE; + return; + +detach: + gprs->flags |= GPRS_FLAG_ATTACHING; + gprs->driver->set_attached(gprs, FALSE, gprs_attach_callback, gprs); } void ofono_gprs_set_cid_range(struct ofono_gprs *gprs, |