diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-08-18 21:03:04 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-08-18 21:03:04 -0500 |
commit | 53c5c9b0e24ed2a4a7fa33581c550e1631f77c1f (patch) | |
tree | 612c457a3f1467306ebfc5cca36db3628009a96e /src/network.c | |
parent | 3b53c9b251b8bed56a60166865a110879e6cfb8c (diff) | |
download | ofono-53c5c9b0e24ed2a4a7fa33581c550e1631f77c1f.tar.bz2 |
netreg: Make logic more readable
Diffstat (limited to 'src/network.c')
-rw-r--r-- | src/network.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/network.c b/src/network.c index 06351441..021f4d93 100644 --- a/src/network.c +++ b/src/network.c @@ -1167,6 +1167,16 @@ static void notify_status_watches(struct ofono_netreg *netreg) } } +static gboolean reset_available(struct network_operator_data *old, + const struct ofono_network_operator *new) +{ + if (old == NULL) + return; + + if (new == NULL || network_operator_compare(old, new) != 0) + set_network_operator_status(old, OPERATOR_STATUS_AVAILABLE); +} + static void current_operator_callback(const struct ofono_error *error, const struct ofono_network_operator *current, void *data) @@ -1198,11 +1208,7 @@ static void current_operator_callback(const struct ofono_error *error, /* We got a new network operator, reset the previous one's status */ /* It will be updated properly later */ - if (netreg->current_operator && - (!current || - network_operator_compare(netreg->current_operator, current))) - set_network_operator_status(netreg->current_operator, - OPERATOR_STATUS_AVAILABLE); + reset_available(netreg->current_operator, current); if (current) op = g_slist_find_custom(netreg->operator_list, current, |