mirror of git://git.sysmocom.de/ofono
Handle EFen list when SIM inserted / removed
This commit is contained in:
parent
54552f1c33
commit
1ca8671d11
|
@ -54,6 +54,7 @@ struct ofono_voicecall {
|
||||||
gint emit_calls_source;
|
gint emit_calls_source;
|
||||||
gint emit_multi_source;
|
gint emit_multi_source;
|
||||||
unsigned int sim_watch;
|
unsigned int sim_watch;
|
||||||
|
unsigned int sim_state_watch;
|
||||||
const struct ofono_voicecall_driver *driver;
|
const struct ofono_voicecall_driver *driver;
|
||||||
void *driver_data;
|
void *driver_data;
|
||||||
struct ofono_atom *atom;
|
struct ofono_atom *atom;
|
||||||
|
@ -1784,6 +1785,10 @@ static void voicecall_unregister(struct ofono_atom *atom)
|
||||||
static void voicecall_remove(struct ofono_atom *atom)
|
static void voicecall_remove(struct ofono_atom *atom)
|
||||||
{
|
{
|
||||||
struct ofono_voicecall *vc = __ofono_atom_get_data(atom);
|
struct ofono_voicecall *vc = __ofono_atom_get_data(atom);
|
||||||
|
struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
|
||||||
|
struct ofono_atom *sim_atom =
|
||||||
|
__ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM);
|
||||||
|
struct ofono_sim *sim = NULL;
|
||||||
|
|
||||||
DBG("atom: %p", atom);
|
DBG("atom: %p", atom);
|
||||||
|
|
||||||
|
@ -1805,6 +1810,14 @@ static void voicecall_remove(struct ofono_atom *atom)
|
||||||
vc->new_en_list = NULL;
|
vc->new_en_list = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sim_atom && __ofono_atom_get_registered(sim_atom))
|
||||||
|
sim = __ofono_atom_get_data(sim_atom);
|
||||||
|
|
||||||
|
if (sim && vc->sim_state_watch) {
|
||||||
|
ofono_sim_remove_state_watch(sim, vc->sim_state_watch);
|
||||||
|
vc->sim_state_watch = 0;
|
||||||
|
}
|
||||||
|
|
||||||
g_free(vc);
|
g_free(vc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1843,15 +1856,17 @@ struct ofono_voicecall *ofono_voicecall_create(struct ofono_modem *modem,
|
||||||
return vc;
|
return vc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sim_watch(struct ofono_atom *atom,
|
static void sim_state_watch(void *user, enum ofono_sim_state new_state)
|
||||||
enum ofono_atom_watch_condition cond, void *data)
|
|
||||||
{
|
{
|
||||||
struct ofono_voicecall *vc = data;
|
struct ofono_voicecall *vc = user;
|
||||||
struct ofono_sim *sim = __ofono_atom_get_data(atom);
|
|
||||||
|
|
||||||
if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
|
if (new_state == OFONO_SIM_STATE_INSERTED) {
|
||||||
return;
|
struct ofono_modem *modem =
|
||||||
}
|
__ofono_atom_get_modem(vc->atom);
|
||||||
|
struct ofono_atom *sim_atom =
|
||||||
|
__ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM);
|
||||||
|
struct ofono_sim *sim =
|
||||||
|
__ofono_atom_get_data(sim_atom);
|
||||||
|
|
||||||
/* Try both formats, only one or none will work */
|
/* Try both formats, only one or none will work */
|
||||||
ofono_sim_read(sim, SIM_EFECC_FILEID,
|
ofono_sim_read(sim, SIM_EFECC_FILEID,
|
||||||
|
@ -1860,6 +1875,42 @@ static void sim_watch(struct ofono_atom *atom,
|
||||||
ofono_sim_read(sim, SIM_EFECC_FILEID,
|
ofono_sim_read(sim, SIM_EFECC_FILEID,
|
||||||
OFONO_SIM_FILE_STRUCTURE_FIXED,
|
OFONO_SIM_FILE_STRUCTURE_FIXED,
|
||||||
ecc_g3_read_cb, vc);
|
ecc_g3_read_cb, vc);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_state != OFONO_SIM_STATE_NOT_PRESENT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (vc->call_list) {
|
||||||
|
/* TODO: Must release all non-emergency calls */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vc->new_en_list) {
|
||||||
|
g_slist_foreach(vc->new_en_list, (GFunc) g_free, NULL);
|
||||||
|
g_slist_free(vc->new_en_list);
|
||||||
|
vc->new_en_list = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_to_en_list(&vc->new_en_list, default_en_list_no_sim);
|
||||||
|
set_new_ecc(vc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sim_watch(struct ofono_atom *atom,
|
||||||
|
enum ofono_atom_watch_condition cond, void *data)
|
||||||
|
{
|
||||||
|
struct ofono_voicecall *vc = data;
|
||||||
|
struct ofono_sim *sim = __ofono_atom_get_data(atom);
|
||||||
|
|
||||||
|
if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
|
||||||
|
vc->sim_state_watch = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vc->sim_state_watch = ofono_sim_add_state_watch(sim,
|
||||||
|
sim_state_watch, vc, NULL);
|
||||||
|
|
||||||
|
sim_state_watch(vc, ofono_sim_get_state(sim));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ofono_voicecall_register(struct ofono_voicecall *vc)
|
void ofono_voicecall_register(struct ofono_voicecall *vc)
|
||||||
|
|
Loading…
Reference in New Issue