diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-01-12 11:27:31 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-01-12 11:27:31 -0600 |
commit | 0382f6435357ec41be496702aa8d27bd6e1bf4c3 (patch) | |
tree | 4adfc3c8fdd0018205a5508f1abead37b884f639 | |
parent | 2b231c3f8487f51ee0691e2e97ef1207bbf79e0d (diff) | |
download | ofono-0382f6435357ec41be496702aa8d27bd6e1bf4c3.tar.bz2 |
Refactor: Rename & Restructure cphs_support
- Rename to cphs_service_table to be more inline with the specification.
- Since the spec allows arbitrary length service tables, use an unsigned
char * return instead of a short.
- Use bit_field function instead of defining an enum
-rw-r--r-- | include/sim.h | 2 | ||||
-rw-r--r-- | src/message-waiting.c | 12 | ||||
-rw-r--r-- | src/sim.c | 12 |
3 files changed, 16 insertions, 10 deletions
diff --git a/include/sim.h b/include/sim.h index 29a0847f..6ff29f74 100644 --- a/include/sim.h +++ b/include/sim.h @@ -171,7 +171,7 @@ const char *ofono_sim_get_imsi(struct ofono_sim *sim); enum ofono_sim_phase ofono_sim_get_phase(struct ofono_sim *sim); enum ofono_sim_cphs_phase ofono_sim_get_cphs_phase(struct ofono_sim *sim); -unsigned short ofono_sim_get_cphs_support(struct ofono_sim *sim); +const unsigned char *ofono_sim_get_cphs_service_table(struct ofono_sim *sim); unsigned int ofono_sim_add_ready_watch(struct ofono_sim *sim, ofono_sim_ready_notify_cb_t cb, diff --git a/src/message-waiting.c b/src/message-waiting.c index 05d05edb..3ac5553a 100644 --- a/src/message-waiting.c +++ b/src/message-waiting.c @@ -895,6 +895,8 @@ void ofono_message_waiting_register(struct ofono_message_waiting *mw) sim_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM); if (sim_atom) { + const unsigned char *st; + /* Assume that if sim atom exists, it is ready */ mw->sim = __ofono_atom_get_data(sim_atom); @@ -906,9 +908,13 @@ void ofono_message_waiting_register(struct ofono_message_waiting *mw) OFONO_SIM_FILE_STRUCTURE_FIXED, mw_mbi_read_cb, mw); - if ((ofono_sim_get_cphs_support(mw->sim) & - OFONO_SIM_CPHS_ST_MAILBOX_NUMBERS_MASK) == - OFONO_SIM_CPHS_ST_MAILBOX_NUMBERS_MASK) { + st = ofono_sim_get_cphs_service_table(mw->sim); + + /* + * Mailbox numbers located in Byte 1, bits 6 & 5, + * Check for Activated & Allocated + */ + if (st && bit_field(st[0], 5, 2) == 3) { ofono_sim_read(mw->sim, SIM_EF_CPHS_MWIS_FILEID, OFONO_SIM_FILE_STRUCTURE_TRANSPARENT, mw_cphs_mwis_read_cb, mw); @@ -89,7 +89,7 @@ struct ofono_sim { unsigned char *efli; unsigned char efli_length; enum ofono_sim_cphs_phase cphs_phase; - unsigned short cphs_support; + unsigned char cphs_service_table[2]; struct ofono_watchlist *ready_watches; const struct ofono_sim_driver *driver; void *driver_data; @@ -969,7 +969,7 @@ static void sim_cphs_information_read_cb(int ok, int length, int record, else if (data[0] >= 0x02) sim->cphs_phase = OFONO_SIM_CPHS_PHASE_2G; - sim->cphs_support = (data[2] << 8) | data[1]; + memcpy(sim->cphs_service_table, data + 1, 2); ready: ofono_sim_set_ready(sim); @@ -1729,17 +1729,17 @@ enum ofono_sim_phase ofono_sim_get_phase(struct ofono_sim *sim) enum ofono_sim_cphs_phase ofono_sim_get_cphs_phase(struct ofono_sim *sim) { if (sim == NULL) - return OFONO_SIM_CPHS_NONE; + return OFONO_SIM_CPHS_PHASE_NONE; return sim->cphs_phase; } -unsigned short ofono_sim_get_cphs_support(struct ofono_sim *sim) +const unsigned char *ofono_sim_get_cphs_service_table(struct ofono_sim *sim) { if (sim == NULL) - return 0; + return NULL; - return sim->cphs_support; + return sim->cphs_service_table; } unsigned int ofono_sim_add_ready_watch(struct ofono_sim *sim, |