From 0ecc99973a2ccafcacd1c24c976d85950fb6cbae Mon Sep 17 00:00:00 2001 From: Andrzej Zaborowski Date: Sat, 29 Jan 2011 01:29:20 +0100 Subject: [PATCH] sim: ofono_sim_context api header changes This patch introduces sim FS contexts which are used to queue file read and write operations. When a context is freed all pending operations in that context are cancelled preventing callbacks from being called causing segfaults. --- include/sim.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/sim.h b/include/sim.h index 5e3ba5ba..137e8253 100644 --- a/include/sim.h +++ b/include/sim.h @@ -29,6 +29,7 @@ extern "C" { #include struct ofono_sim; +struct ofono_sim_context; /* 51.011 Section 9.3 */ enum ofono_sim_file_structure { @@ -195,6 +196,9 @@ 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); +struct ofono_sim_context *ofono_sim_context_create(struct ofono_sim *sim); +void ofono_sim_context_free(struct ofono_sim_context *context); + /* 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 * if an error has occurred. For transparent files, the callback will only @@ -202,16 +206,16 @@ void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted); * * Returns 0 if the request could be queued, -1 otherwise. */ -int ofono_sim_read(struct ofono_sim *sim, int id, +int ofono_sim_read(struct ofono_sim_context *context, int id, enum ofono_sim_file_structure expected, ofono_sim_file_read_cb_t cb, void *data); -int ofono_sim_write(struct ofono_sim *sim, int id, +int ofono_sim_write(struct ofono_sim_context *context, int id, ofono_sim_file_write_cb_t cb, enum ofono_sim_file_structure structure, int record, const unsigned char *data, int length, void *userdata); -int ofono_sim_read_bytes(struct ofono_sim *sim, int id, +int ofono_sim_read_bytes(struct ofono_sim_context *context, int id, unsigned short offset, unsigned short num_bytes, ofono_sim_file_read_cb_t cb, void *data); #ifdef __cplusplus