Hi Pekka,

On 10/05/2010 06:35 AM, [email protected] wrote:
> From: Pekka Pessi <[email protected]>
> 
> Indicate detach when modem is in offline state.
> ---
>  src/gprs.c |   26 ++++++++++++++++++++++++++
>  1 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/src/gprs.c b/src/gprs.c
> index 3f085ed..431275c 100644
> --- a/src/gprs.c
> +++ b/src/gprs.c
> @@ -76,6 +76,7 @@ struct ofono_gprs {
>       struct ofono_netreg *netreg;
>       unsigned int netreg_watch;
>       unsigned int status_watch;
> +     unsigned int online_watch;
>       GKeyFile *settings;
>       char *imsi;
>       DBusMessage *pending;
> @@ -1048,8 +1049,17 @@ static void gprs_attach_callback(const struct 
> ofono_error *error, void *data)
>  
>  static void gprs_netreg_update(struct ofono_gprs *gprs)
>  {
> +     struct ofono_modem *modem = __ofono_atom_get_modem(gprs->atom);
>       ofono_bool_t attach;
>  
> +     if (!ofono_modem_get_online(modem)) {
> +             gprs->flags &= ~(GPRS_FLAG_RECHECK | GPRS_FLAG_ATTACHING);
> +             gprs->netreg_status = NETWORK_REGISTRATION_STATUS_UNKNOWN;
> +             gprs->driver_attached = FALSE;
> +             gprs_attached_update(gprs);
> +             return;
> +     }
> +
>       attach = gprs->netreg_status == NETWORK_REGISTRATION_STATUS_REGISTERED;
>  
>       attach = attach || (gprs->roaming_allowed &&
> @@ -1740,6 +1750,11 @@ static void gprs_unregister(struct ofono_atom *atom)
>               gprs->cid_map = NULL;
>       }
>  
> +     if (gprs->online_watch) {
> +             __ofono_modem_remove_state_watch(modem, gprs->online_watch);
> +             gprs->online_watch = 0;
> +     }
> +
>       if (gprs->netreg_watch) {
>               if (gprs->status_watch) {
>                       __ofono_netreg_remove_status_watch(gprs->netreg,
> @@ -1844,6 +1859,14 @@ static void netreg_watch(struct ofono_atom *atom,
>       gprs_netreg_update(gprs);
>  }
>  
> +static void online_watch(enum ofono_modem_state modem_state, void *data)
> +{
> +     struct ofono_gprs *gprs = data;
> +
> +     if (modem_state != MODEM_STATE_ONLINE)
> +             gprs_netreg_update(gprs);

So again, the question is whether it is better to watch for the netreg
atom going away instead of using an online/offline watch...

> +}
> +
>  static gboolean load_context(struct ofono_gprs *gprs, const char *group)
>  {
>       char *name = NULL;
> @@ -2041,6 +2064,9 @@ void ofono_gprs_register(struct ofono_gprs *gprs)
>       ofono_modem_add_interface(modem,
>                               OFONO_CONNECTION_MANAGER_INTERFACE);
>  
> +     gprs->online_watch = __ofono_modem_add_state_watch(modem,
> +                                     online_watch, gprs, NULL);
> +
>       sim_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM);
>  
>       if (sim_atom) {

Regards,
-Denis
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to