summaryrefslogtreecommitdiffstats
path: root/src/modem.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-09-17 10:14:02 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-09-17 10:14:02 -0500
commit0698fc2788303385920ee3c4fb8c5b636697c6cb (patch)
treed1213fa40f5337937754406798f51cf4b7088528 /src/modem.c
parent35cb156ba9e72c2c90bfec3e24b77d09c9454a45 (diff)
downloadofono-0698fc2788303385920ee3c4fb8c5b636697c6cb.tar.bz2
Split populate modem driver method
Introduce two new methods - pre_sim - SIM is not inserted or locked. This should populate the modem with atoms that can be used without the SIM. Generally this is the devinfo atom, the sim atom and the voice call atom (emergency calls only) - post_sim - SIM is ready. This method should populate the modem with the remaining atoms
Diffstat (limited to 'src/modem.c')
-rw-r--r--src/modem.c57
1 files changed, 45 insertions, 12 deletions
diff --git a/src/modem.c b/src/modem.c
index d621bf42..26dba5d8 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -60,6 +60,9 @@ struct ofono_modem {
ofono_bool_t powered_persistent;
guint timeout;
GHashTable *properties;
+ struct ofono_sim *sim;
+ unsigned int sim_watch;
+ unsigned int sim_ready_watch;
const struct ofono_modem_driver *driver;
void *driver_data;
char *driver_type;
@@ -494,10 +497,8 @@ static DBusMessage *modem_set_property(DBusConnection *conn,
&powered);
if (powered) {
- if (modem->driver->populate)
- modem->driver->populate(modem);
-
- __ofono_history_probe_drivers(modem);
+ if (modem->driver->pre_sim)
+ modem->driver->pre_sim(modem);
} else {
remove_all_atoms(modem);
}
@@ -558,10 +559,8 @@ void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered)
&dbus_powered);
if (powered) {
- if (modem->driver->populate)
- modem->driver->populate(modem);
-
- __ofono_history_probe_drivers(modem);
+ if (modem->driver->pre_sim)
+ modem->driver->pre_sim(modem);
} else {
remove_all_atoms(modem);
}
@@ -1050,6 +1049,35 @@ static void emit_modems()
g_free(modems);
}
+static void modem_sim_ready(void *user)
+{
+ struct ofono_modem *modem = user;
+
+ if (modem->driver->post_sim)
+ modem->driver->post_sim(modem);
+
+ __ofono_history_probe_drivers(modem);
+}
+
+static void sim_watch(struct ofono_atom *atom,
+ enum ofono_atom_watch_condition cond, void *data)
+{
+ struct ofono_modem *modem = data;
+
+ if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
+ modem->sim_ready_watch = 0;
+ return;
+ }
+
+ modem->sim = __ofono_atom_get_data(atom);
+ modem->sim_ready_watch = ofono_sim_add_ready_watch(modem->sim,
+ modem_sim_ready,
+ modem, NULL);
+
+ if (ofono_sim_get_ready(modem->sim))
+ modem_sim_ready(modem);
+}
+
int ofono_modem_register(struct ofono_modem *modem)
{
DBusConnection *conn = ofono_dbus_get_connection();
@@ -1097,14 +1125,16 @@ int ofono_modem_register(struct ofono_modem *modem)
emit_modems();
+ modem->sim_watch = __ofono_modem_add_atom_watch(modem,
+ OFONO_ATOM_TYPE_SIM,
+ sim_watch, modem, NULL);
+
/* TODO: Read powered property from store */
if (modem->powered_persistent)
set_powered(modem, TRUE);
- if (modem->powered == TRUE && modem->driver->populate) {
- modem->driver->populate(modem);
- __ofono_history_probe_drivers(modem);
- }
+ if (modem->powered == TRUE && modem->driver->pre_sim)
+ modem->driver->pre_sim(modem);
return 0;
}
@@ -1121,6 +1151,9 @@ static void modem_unregister(struct ofono_modem *modem)
__ofono_watchlist_free(modem->atom_watches);
modem->atom_watches = NULL;
+ modem->sim_watch = 0;
+ modem->sim_ready_watch = 0;
+
g_slist_foreach(modem->interface_list, (GFunc)g_free, NULL);
g_slist_free(modem->interface_list);
modem->interface_list = NULL;