summaryrefslogtreecommitdiffstats
path: root/src/modem.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2011-04-14 14:39:55 -0500
committerDenis Kenzior <denkenz@gmail.com>2011-04-14 17:02:22 -0500
commit240a01260f6ee99c6eeef2928b3fb73c010477f5 (patch)
tree35193cca707a1a69ef9f87535015d46015f5d709 /src/modem.c
parentd26a3fd67bae24f7628720baa77e1e49a5aea400 (diff)
downloadofono-240a01260f6ee99c6eeef2928b3fb73c010477f5.tar.bz2
modem: Fix entering offline mode prematurely
A contextual change to __ofono_modem_find_atom has caused us to enter into offline mode prematurely. find_atom was changed to return only the atoms that were registered, however the modem really has to know whether the sim atom is created (not registered) in order to know whether to wait for the SIM to be initialized or not.
Diffstat (limited to 'src/modem.c')
-rw-r--r--src/modem.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/modem.c b/src/modem.c
index a8b8744d..9616a02a 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -564,6 +564,20 @@ void __ofono_modem_remove_powered_watch(struct ofono_modem *modem,
__ofono_watchlist_remove_item(modem->powered_watches, id);
}
+static gboolean modem_has_sim(struct ofono_modem *modem)
+{
+ GSList *l;
+ struct ofono_atom *atom;
+
+ for (l = modem->atoms; l; l = l->next) {
+ atom = l->data;
+
+ if (atom->type == OFONO_ATOM_TYPE_SIM)
+ return TRUE;
+ }
+
+ return FALSE;
+}
static void common_online_cb(const struct ofono_error *error, void *data)
{
struct ofono_modem *modem = data;
@@ -1074,8 +1088,7 @@ static DBusMessage *modem_set_property(DBusConnection *conn,
modem_change_state(modem, MODEM_STATE_PRE_SIM);
/* Force SIM Ready for devies with no sim atom */
- if (__ofono_modem_find_atom(modem,
- OFONO_ATOM_TYPE_SIM) == NULL)
+ if (modem_has_sim(modem) == FALSE)
sim_state_watch(OFONO_SIM_STATE_READY, modem);
} else {
set_online(modem, FALSE);
@@ -1155,8 +1168,7 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered)
modem_change_state(modem, MODEM_STATE_PRE_SIM);
/* Force SIM Ready for devices with no sim atom */
- if (__ofono_modem_find_atom(modem,
- OFONO_ATOM_TYPE_SIM) == NULL)
+ if (modem_has_sim(modem) == FALSE)
sim_state_watch(OFONO_SIM_STATE_READY, modem);
} else {
set_online(modem, FALSE);