From bc72cca91b070f61c0cecb0090937eb758e91b24 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 26 Oct 2009 16:55:03 -0500 Subject: [PATCH] Fix: notify_attached was only used when detached The standard only specifies that the context might have been detached by the network / mobile equipment. Not attached. --- drivers/atmodem/gprs.c | 2 +- include/gprs.h | 2 +- src/gprs.c | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c index 27a3f569..6f4933a7 100644 --- a/drivers/atmodem/gprs.c +++ b/drivers/atmodem/gprs.c @@ -200,7 +200,7 @@ static void cgev_notify(GAtResult *result, gpointer user_data) if (g_str_has_prefix(event, "NW DETACH ") || g_str_has_prefix(event, "ME DETACH ")) { - ofono_gprs_attach_notify(gprs, 0); + ofono_gprs_detached_notify(gprs); return; } } diff --git a/include/gprs.h b/include/gprs.h index 65c34347..5cec510f 100644 --- a/include/gprs.h +++ b/include/gprs.h @@ -51,7 +51,7 @@ struct ofono_gprs_driver { void ofono_gprs_status_notify(struct ofono_gprs *gprs, int status, int lac, int ci, int tech); -void ofono_gprs_attach_notify(struct ofono_gprs *gprs, int attached); +void ofono_gprs_detached_notify(struct ofono_gprs *gprs); int ofono_gprs_driver_register(const struct ofono_gprs_driver *d); void ofono_gprs_driver_unregister(const struct ofono_gprs_driver *d); diff --git a/src/gprs.c b/src/gprs.c index 8443f1bf..3aa4721e 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -894,14 +894,18 @@ static GDBusSignalTable manager_signals[] = { { } }; -void ofono_gprs_attach_notify(struct ofono_gprs *gprs, int attached) +void ofono_gprs_detached_notify(struct ofono_gprs *gprs) { - if (gprs->driver_attached != attached && - !(gprs->flags & GPRS_FLAG_ATTACHING)) { - gprs->driver_attached = attached; + if (gprs->driver_attached == FALSE) + return; - gprs_netreg_update(gprs); - } + 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 + */ } static void set_registration_status(struct ofono_gprs *gprs, int status)