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
This commit is contained in:
Denis Kenzior 2009-09-21 23:04:53 -05:00
parent 7d7732d637
commit 5fd083f6f4
3 changed files with 15 additions and 13 deletions

View File

@ -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\"",

View File

@ -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);
};

View File

@ -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;