summaryrefslogtreecommitdiffstats
path: root/src/sim.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2012-11-21 07:11:46 -0600
committerDenis Kenzior <denkenz@gmail.com>2012-11-22 06:50:08 -0600
commit454ca9f40e7657e0b07c790ca49f737b9dffca9d (patch)
tree6ac7a7a7e7978969dad3ae3cf96c1553ce9a86db /src/sim.c
parente98dcc06164db84161634167ca037f435f4d2239 (diff)
downloadofono-454ca9f40e7657e0b07c790ca49f737b9dffca9d.tar.bz2
sim: destroy spn info as part of sim main state
Diffstat (limited to 'src/sim.c')
-rw-r--r--src/sim.c74
1 files changed, 38 insertions, 36 deletions
diff --git a/src/sim.c b/src/sim.c
index 8059d2b5..45514075 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -2316,6 +2316,42 @@ static void sim_free_early_state(struct ofono_sim *sim)
}
}
+static void sim_spn_close(struct ofono_sim *sim)
+{
+ if (sim->spn_watches) {
+ __ofono_watchlist_free(sim->spn_watches);
+ sim->spn_watches = NULL;
+ }
+
+ /*
+ * We have not initialized SPN logic at all yet, either because
+ * no netreg / gprs atom has been needed or we have not reached the
+ * post_sim state
+ */
+ if (sim->ef_spn_watch == 0)
+ return;
+
+ ofono_sim_remove_file_watch(sim->context, sim->ef_spn_watch);
+ sim->ef_spn_watch = 0;
+
+ ofono_sim_remove_file_watch(sim->context, sim->cphs_spn_watch);
+ sim->cphs_spn_watch = 0;
+
+ if (sim->cphs_spn_short_watch) {
+ ofono_sim_remove_file_watch(sim->context,
+ sim->cphs_spn_short_watch);
+ sim->cphs_spn_short_watch = 0;
+ }
+
+ sim->flags &= ~SIM_FLAG_READING_SPN;
+
+ g_free(sim->spn);
+ sim->spn = NULL;
+
+ g_free(sim->spn_dc);
+ sim->spn_dc = NULL;
+}
+
static void sim_free_main_state(struct ofono_sim *sim)
{
int i;
@@ -2384,6 +2420,8 @@ static void sim_free_main_state(struct ofono_sim *sim)
sim->fixed_dialing = FALSE;
sim->barred_dialing = FALSE;
+ sim_spn_close(sim);
+
if (sim->context) {
ofono_sim_context_free(sim->context);
sim->context = NULL;
@@ -2601,40 +2639,6 @@ static void sim_spn_init(struct ofono_sim *sim)
sim_spn_changed, sim, NULL);
}
-static void sim_spn_close(struct ofono_sim *sim)
-{
- __ofono_watchlist_free(sim->spn_watches);
- sim->spn_watches = NULL;
-
- /*
- * We have not initialized SPN logic at all yet, either because
- * no netreg / gprs atom has been needed or we have not reached the
- * post_sim state
- */
- if (sim->ef_spn_watch == 0)
- return;
-
- ofono_sim_remove_file_watch(sim->context, sim->ef_spn_watch);
- sim->ef_spn_watch = 0;
-
- ofono_sim_remove_file_watch(sim->context, sim->cphs_spn_watch);
- sim->cphs_spn_watch = 0;
-
- if (sim->cphs_spn_short_watch) {
- ofono_sim_remove_file_watch(sim->context,
- sim->cphs_spn_short_watch);
- sim->cphs_spn_short_watch = 0;
- }
-
- sim->flags &= ~SIM_FLAG_READING_SPN;
-
- g_free(sim->spn);
- sim->spn = NULL;
-
- g_free(sim->spn_dc);
- sim->spn_dc = NULL;
-}
-
ofono_bool_t ofono_sim_add_spn_watch(struct ofono_sim *sim, unsigned int *id,
ofono_sim_spn_cb_t cb, void *data,
ofono_destroy_func destroy)
@@ -2806,8 +2810,6 @@ static void sim_unregister(struct ofono_atom *atom)
__ofono_watchlist_free(sim->state_watches);
sim->state_watches = NULL;
- sim_spn_close(sim);
-
g_dbus_unregister_interface(conn, path, OFONO_SIM_MANAGER_INTERFACE);
ofono_modem_remove_interface(modem, OFONO_SIM_MANAGER_INTERFACE);
}