57
57
static const char *clck_prefix[] = { "+CLCK:", NULL };
58
58
static const char *huawei_cpin_prefix[] = { "^CPIN:", NULL };
59
59
static const char *xpincnt_prefix[] = { "+XPINCNT:", NULL };
60
static const char *cpinr_prefixes[] = { "+CPINR:", "+CPINRE:", NULL };
61
static const char *epin_prefix[] = { "*EPIN:", NULL };
60
62
static const char *none_prefix[] = { NULL };
62
64
static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
144
146
cbd = cb_data_new(cb, data);
148
148
snprintf(buf, sizeof(buf), "AT+CRSM=192,%i", fileid);
150
150
switch (sd->vendor) {
151
151
case OFONO_VENDOR_HUAWEI:
152
case OFONO_VENDOR_SIERRA:
152
153
case OFONO_VENDOR_QUALCOMM_MSM:
153
154
strcat(buf, ",0,0,255"); /* Maximum possible length */
219
221
struct cb_data *cbd = cb_data_new(cb, data);
225
224
snprintf(buf, sizeof(buf), "AT+CRSM=176,%i,%i,%i,%i", fileid,
226
225
start >> 8, start & 0xff, length);
429
423
struct sim_data *sd = ofono_sim_get_data(sim);
430
424
struct cb_data *cbd = cb_data_new(cb, data);
435
426
if (g_at_chat_send(sd->chat, "AT+CIMI", NULL,
436
427
at_cimi_cb, cbd, g_free) > 0)
442
432
CALLBACK_WITH_FAILURE(cb, NULL, data);
566
556
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
559
static void at_epin_cb(gboolean ok, GAtResult *result, gpointer user_data)
561
struct cb_data *cbd = user_data;
562
ofono_sim_pin_retries_cb_t cb = cbd->cb;
563
const char *final = g_at_result_final_response(result);
565
struct ofono_error error;
566
int retries[OFONO_SIM_PASSWORD_INVALID];
568
static enum ofono_sim_password_type password_types[] = {
569
OFONO_SIM_PASSWORD_SIM_PIN,
570
OFONO_SIM_PASSWORD_SIM_PUK,
571
OFONO_SIM_PASSWORD_SIM_PIN2,
572
OFONO_SIM_PASSWORD_SIM_PUK2,
575
decode_at_error(&error, final);
578
cb(&error, NULL, cbd->data);
582
g_at_result_iter_init(&iter, result);
584
if (!g_at_result_iter_next(&iter, "*EPIN:"))
587
BUILD_PIN_RETRIES_ARRAY(password_types, ARRAY_SIZE(password_types),
590
cb(&error, retries, cbd->data);
595
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
598
static void at_cpinr_cb(gboolean ok, GAtResult *result, gpointer user_data)
600
struct cb_data *cbd = user_data;
601
ofono_sim_pin_retries_cb_t cb = cbd->cb;
603
struct ofono_error error;
604
int retries[OFONO_SIM_PASSWORD_INVALID];
605
size_t len = sizeof(at_sim_name) / sizeof(*at_sim_name);
608
decode_at_error(&error, g_at_result_final_response(result));
611
cb(&error, NULL, cbd->data);
615
for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
618
g_at_result_iter_init(&iter, result);
620
/* Ignore +CPINRE results... */
621
while (g_at_result_iter_next(&iter, "+CPINR:")) {
625
if (!g_at_result_iter_next_unquoted_string(&iter, &name))
628
if (!g_at_result_iter_next_number(&iter, &val))
631
for (i = 1; i < len; i++) {
632
if (!strcmp(name, at_sim_name[i].name)) {
639
cb(&error, retries, cbd->data);
569
642
static void at_pin_retries_query(struct ofono_sim *sim,
570
643
ofono_sim_pin_retries_cb_t cb,
664
case OFONO_VENDOR_MBM:
665
if (g_at_chat_send(sd->chat, "AT*EPIN?", epin_prefix,
666
at_epin_cb, cbd, g_free) > 0)
671
if (g_at_chat_send(sd->chat, "AT+CPINR", cpinr_prefixes,
672
at_cpinr_cb, cbd, g_free) > 0)
601
679
CALLBACK_WITH_FAILURE(cb, NULL, data);
662
740
struct sim_data *sd = ofono_sim_get_data(sim);
663
741
struct cb_data *cbd = cb_data_new(cb, data);
670
745
if (g_at_chat_send(sd->chat, "AT+CPIN?", cpin_prefix,
671
746
at_cpin_cb, cbd, g_free) > 0)
677
751
CALLBACK_WITH_FAILURE(cb, -1, data);
882
945
static void at_change_passwd(struct ofono_sim *sim,
883
946
enum ofono_sim_password_type passwd_type,
884
const char *old, const char *new,
947
const char *old_passwd, const char *new_passwd,
885
948
ofono_sim_lock_unlock_cb_t cb, void *data)
887
950
struct sim_data *sd = ofono_sim_get_data(sim);
891
954
unsigned int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac);
896
956
if (passwd_type >= len ||
897
957
at_clck_cpwd_fac[passwd_type] == NULL)
900
960
snprintf(buf, sizeof(buf), "AT+CPWD=\"%s\",\"%s\",\"%s\"",
901
at_clck_cpwd_fac[passwd_type], old, new);
961
at_clck_cpwd_fac[passwd_type], old_passwd, new_passwd);
903
963
ret = g_at_chat_send(sd->chat, buf, none_prefix,
904
964
at_lock_unlock_cb, cbd, g_free);