sim: add sim_ready_notify function
PATCH 1/1 sim: add sim_ready_notify function
--- include/sim.h | 1 + src/sim.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 0 deletions(-)
include/sim.h +1 -0
@@ -186,6 +186,7 @@ void ofono_sim_remove_state_watch(struct ofono_sim *sim, unsigned int id);enum ofono_sim_state ofono_sim_get_state (struct ofono_sim *sim);void ofono_sim_inserted_notify (struct ofono_sim *sim,ofono_bool_t inserted); +void ofono_sim_ready_notify (struct ofono_sim *sim);/* This will queue an operation to read all available records with id from the * SIM. Callback cb will be called every time a record has been read, or once
src/sim.c +22 -0
@@ -48,6 +48,8 @@#define SIM_CACHE_PATH_LEN (imsilen) (strlen(SIM_CACHE_PATH) - 3 + imsilen)#define SIM_CACHE_HEADER_SIZE 6 +#define SIM_FLAG_WAIT_FOR_READY 0x1 +static GSList *g_drivers =NULL ;static gboolean sim_op_next (gpointer user_data);
@@ -99,6 +101,7 @@ struct ofono_sim {unsigned char efust_length;unsigned char *efest;unsigned char efest_length; +int flags; };struct msisdn_set_request {
@@ -694,6 +697,9 @@ static void sim_enter_pin_cb(const struct ofono_error *error, void *data)__ofono_dbus_pending_reply (&sim->pending, reply); +if (sim->flags &SIM_FLAG_WAIT_FOR_READY ) +return ; +sim_pin_check (sim); }
@@ -724,6 +730,9 @@ static DBusMessage *sim_enter_pin(DBusConnection *conn, DBusMessage *msg,if (!is_valid_pin (pin,PIN_TYPE_PIN ))return __ofono_error_invalid_format (msg); +if (type ==OFONO_SIM_PASSWORD_SIM_PIN ) + sim->flags |=SIM_FLAG_WAIT_FOR_READY ; + sim->pending =dbus_message_ref (msg); sim->driver->send_passwd (sim, pin, sim_enter_pin_cb, sim);
@@ -762,6 +771,9 @@ static DBusMessage *sim_reset_pin(DBusConnection *conn, DBusMessage *msg,if (!is_valid_pin (pin,PIN_TYPE_PIN ))return __ofono_error_invalid_format (msg); +if (type ==OFONO_SIM_PASSWORD_SIM_PUK ) + sim->flags |=SIM_FLAG_WAIT_FOR_READY ; + sim->pending =dbus_message_ref (msg); sim->driver->reset_passwd (sim, puk, pin, sim_enter_pin_cb, sim);
@@ -2002,6 +2014,7 @@ static void sim_free_state(struct ofono_sim *sim) } sim->mnc_length =0 ; + sim->flags =0 ; }void ofono_sim_inserted_notify (struct ofono_sim *sim,ofono_bool_t inserted)
@@ -2034,6 +2047,15 @@ void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted)sim_free_state (sim); } +void ofono_sim_ready_notify (struct ofono_sim *sim) +{ +if (!(sim->flags &SIM_FLAG_WAIT_FOR_READY )) +return ; + + sim->flags &= ~SIM_FLAG_WAIT_FOR_READY ; +sim_pin_check (sim); +} +unsigned int ofono_sim_add_state_watch (struct ofono_sim *sim,ofono_sim_state_event_notify_cb_t notify,void *data,ofono_destroy_func destroy)
Signature · 1 line
1.7.0.4