diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-09-21 23:04:53 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-09-22 00:07:07 -0500 |
commit | 5fd083f6f4b1daf9affc9a6c8415db015a57d8c7 (patch) | |
tree | bee72ce32dc04af6db383ffa59af304dda29351e | |
parent | 7d7732d63747f742bdf1fcfb0b804515786da58e (diff) | |
download | ofono-5fd083f6f4b1daf9affc9a6c8415db015a57d8c7.tar.bz2 |
Refactor: Do not use int instead of enum
27.007 does not define an enumeration for SIM PIN/PUK values. This
should be handled by ofono enum instead
-rw-r--r-- | drivers/atmodem/sim.c | 12 | ||||
-rw-r--r-- | include/sim.h | 7 | ||||
-rw-r--r-- | src/sim.c | 9 |
3 files changed, 15 insertions, 13 deletions
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c index 1c668b17..b7d83684 100644 --- a/drivers/atmodem/sim.c +++ b/drivers/atmodem/sim.c @@ -565,21 +565,21 @@ static const char *const at_clck_cpwd_fac[] = { [OFONO_SIM_PASSWORD_PHCORP_PIN] = "PC", }; -static void at_pin_enable(struct ofono_sim *sim, int passwd_type, int enable, - const char *passwd, - ofono_sim_lock_unlock_cb_t cb, void *data) +static void at_pin_enable(struct ofono_sim *sim, + enum ofono_sim_password_type passwd_type, + int enable, const char *passwd, + ofono_sim_lock_unlock_cb_t cb, void *data) { GAtChat *chat = ofono_sim_get_data(sim); struct cb_data *cbd = cb_data_new(cb, data); char buf[64]; int ret; - int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac); + unsigned int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac); if (!cbd) goto error; - if (passwd_type < 0 || passwd_type >= len || - !at_clck_cpwd_fac[passwd_type]) + if (passwd_type >= len || !at_clck_cpwd_fac[passwd_type]) goto error; snprintf(buf, sizeof(buf), "AT+CLCK=\"%s\",%i,\"%s\"", diff --git a/include/sim.h b/include/sim.h index 3d618270..af2fd1eb 100644 --- a/include/sim.h +++ b/include/sim.h @@ -85,7 +85,8 @@ typedef void (*ofono_sim_file_read_cb_t)(int ok, typedef void (*ofono_sim_file_write_cb_t)(int ok, void *userdata); typedef void (*ofono_sim_passwd_cb_t)(const struct ofono_error *error, - int passwd_type, void *data); + enum ofono_sim_password_type type, + void *data); typedef void (*ofono_sim_lock_unlock_cb_t)(const struct ofono_error *error, void *data); @@ -127,8 +128,8 @@ struct ofono_sim_driver { enum ofono_sim_password_type type, const char *old, const char *new, ofono_sim_lock_unlock_cb_t cb, void *data); - void (*lock)(struct ofono_sim *sim, int passwd_type, int enable, - const char *passwd, + void (*lock)(struct ofono_sim *sim, enum ofono_sim_password_type type, + int enable, const char *passwd, ofono_sim_lock_unlock_cb_t cb, void *data); }; @@ -78,7 +78,7 @@ struct ofono_sim { GSList *service_numbers; gboolean sdn_ready; gboolean ready; - int pin_type; + enum ofono_sim_password_type pin_type; char **language_prefs; GQueue *simop_q; gint simop_source; @@ -569,7 +569,7 @@ static DBusMessage *sim_enter_pin(DBusConnection *conn, DBusMessage *msg, struct ofono_sim *sim = data; DBusMessageIter iter; const char *typestr; - int type; + enum ofono_sim_password_type type; const char *pin; if (!sim->driver->send_passwd) @@ -611,7 +611,7 @@ static DBusMessage *sim_reset_pin(DBusConnection *conn, DBusMessage *msg, struct ofono_sim *sim = data; DBusMessageIter iter; const char *typestr; - int type; + enum ofono_sim_password_type type; const char *puk; const char *pin; @@ -926,7 +926,8 @@ static void sim_retrieve_imsi(struct ofono_sim *sim) sim->driver->read_imsi(sim, sim_imsi_cb, sim); } -static void sim_pin_query_cb(const struct ofono_error *error, int pin_type, +static void sim_pin_query_cb(const struct ofono_error *error, + enum ofono_sim_password_type pin_type, void *data) { struct ofono_sim *sim = data; |