4 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
28 #include <tapi_common.h>
30 #include <TapiUtility.h>
38 msg("api call failed with[%d]",x); \
43 #define CHECK_ACCESS_RT(x) \
46 msg("api call failed with[%d]",x); \
51 static char data_sim_set_language[MENU_DATA_SIZE + 1] = { 0x01, };
52 static char data_sim_set_state[MENU_DATA_SIZE + 1] = { 0x01, };
55 static char data_sim_set_cf_b_cphs[MENU_DATA_SIZE + 1] = { };
56 static char data_sim_set_cf_rec_index[MENU_DATA_SIZE + 1] = { };
57 static char data_sim_set_cf_msp_num[MENU_DATA_SIZE + 1] = { };
58 static char data_sim_set_cf_cfu_status[MENU_DATA_SIZE + 1] = { };
59 static char data_sim_set_cf_ton[MENU_DATA_SIZE + 1] = { };
60 static char data_sim_set_cf_npi[MENU_DATA_SIZE + 1] = { };
61 static char data_sim_set_cf_number[MENU_DATA_SIZE + 1] = { };
62 static char data_sim_set_cf_cc2_id[MENU_DATA_SIZE + 1] = { };
63 static char data_sim_set_cf_ext7_id[MENU_DATA_SIZE + 1] = { };
64 static char data_sim_set_cf_cphs_line1[MENU_DATA_SIZE + 1] = { };
65 static char data_sim_set_cf_cphs_line2[MENU_DATA_SIZE + 1] = { };
66 static char data_sim_set_cf_cphs_fax[MENU_DATA_SIZE + 1] = { };
67 static char data_sim_set_cf_cphs_data[MENU_DATA_SIZE + 1] = { };
69 static char data_sim_set_mw_b_cphs[MENU_DATA_SIZE + 1] = { };
70 static char data_sim_set_mw_rec_index[MENU_DATA_SIZE + 1] = { };
71 static char data_sim_set_mw_indicator_status[MENU_DATA_SIZE + 1] = { };
72 static char data_sim_set_mw_voice_cnt[MENU_DATA_SIZE + 1] = { };
73 static char data_sim_set_mw_fax_cnt[MENU_DATA_SIZE + 1] = { };
74 static char data_sim_set_mw_email_cnt[MENU_DATA_SIZE + 1] = { };
75 static char data_sim_set_mw_other_cnt[MENU_DATA_SIZE + 1] = { };
76 static char data_sim_set_mw_video_cnt[MENU_DATA_SIZE + 1] = { };
77 static char data_sim_set_mw_cphs_voice1[MENU_DATA_SIZE + 1] = { };
78 static char data_sim_set_mw_cphs_voice2[MENU_DATA_SIZE + 1] = { };
79 static char data_sim_set_mw_cphs_fax[MENU_DATA_SIZE + 1] = { };
80 static char data_sim_set_mw_cphs_data[MENU_DATA_SIZE + 1] = { };
82 static char data_sim_set_mb_b_cphs[MENU_DATA_SIZE + 1] = { };
83 static char data_sim_set_mb_type[MENU_DATA_SIZE + 1] = { };
84 static char data_sim_set_mb_rec_index[MENU_DATA_SIZE + 1] = { };
85 static char data_sim_set_mb_profile_num[MENU_DATA_SIZE + 1] = { };
86 static char data_sim_set_mb_alpha_id_max_len[MENU_DATA_SIZE + 1] = { };
87 static char data_sim_set_mb_alpha_id[MENU_DATA_SIZE + 1] = { };
88 static char data_sim_set_mb_ton[MENU_DATA_SIZE + 1] = { };
89 static char data_sim_set_mb_npi[MENU_DATA_SIZE + 1] = { };
90 static char data_sim_set_mb_number[MENU_DATA_SIZE + 1] = { };
91 static char data_sim_set_mb_cc_id[MENU_DATA_SIZE + 1] = { };
92 static char data_sim_set_mb_ext1_id[MENU_DATA_SIZE + 1] = { };
94 static char data_sim_req_authentication_type[MENU_DATA_SIZE + 1] = { 0x01, }; //SIM_AUTH_TYPE_GSM
95 static char data_sim_req_authentication_autn_data[MENU_DATA_SIZE + 1] = { 200,
96 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
98 static char data_sim_req_authentication_rand_data[MENU_DATA_SIZE + 1] = { 200,
99 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
102 static char data_sim_verify_pins_type[MENU_DATA_SIZE + 1] = "0";
103 static char data_sim_verify_pins_pw[MENU_DATA_SIZE + 1] = { };
105 static char data_sim_verify_puks_type[MENU_DATA_SIZE + 1] = "2";
106 static char data_sim_verify_puks_puk[MENU_DATA_SIZE + 1] = { };
107 static char data_sim_verify_puks_pin[MENU_DATA_SIZE + 1] = { };
109 static char data_sim_change_pins_type[MENU_DATA_SIZE + 1] = "0";
110 static char data_sim_change_pins_old_pw[MENU_DATA_SIZE + 1] = "";
111 static char data_sim_change_pins_new_pw[MENU_DATA_SIZE + 1] = "";
113 static char data_sim_disable_facility_type[MENU_DATA_SIZE + 1] = "1";
114 static char data_sim_disable_facility_pw[MENU_DATA_SIZE + 1] = { };
116 static char data_sim_enable_facility_type[MENU_DATA_SIZE + 1] = { };
117 static char data_sim_enable_facility_pw[MENU_DATA_SIZE + 1] = { };
119 static char data_sim_get_facility_type[MENU_DATA_SIZE + 1] = "1";
121 static char data_sim_get_lock_type[MENU_DATA_SIZE + 1] = "1";
123 static char data_sim_transmit_apdu_apdu[MENU_DATA_SIZE + 1] = "0070000000";
125 static int _sim_str_to_hex (char a)
129 if (a >= '0' && a <= '9')
131 else if (a >= 'a' && a <= 'f')
133 //printf("'%c' => %d(0x%x)\n", a, ret, ret);
137 static void on_noti_sim_status (TapiHandle *handle, const char *noti_id,
138 void *data, void *user_data)
140 TelSimCardStatus_t *status = data;
143 msgb("event(%s) receive !!", TAPI_NOTI_SIM_STATUS);
144 msg("status[%d]", *status);
147 static void on_noti_sim_cf_state(TapiHandle *handle, const char *noti_id,
148 void *data, void *user_data)
152 msgp ("property(%s) receive !!", TAPI_PROP_SIM_CALL_FORWARD_STATE);
154 msg("status[%d]", *status);
157 static int run_sim_get_init_info (MManager *mm, struct menu_data *menu)
159 TapiHandle *handle = menu_manager_ref_user_data (mm);
161 TelSimCardStatus_t o_status = 0;
162 gboolean o_new = FALSE;
164 msg("call [%s] tapi service !!!", menu->title);
166 rt = tel_get_sim_init_info (handle, &o_status, &o_new);
169 msg("status[%d]", o_status);
170 msg("new_sim[%d]", o_new);
174 static int run_sim_get_card_type (MManager *mm, struct menu_data *menu)
176 TapiHandle *handle = menu_manager_ref_user_data (mm);
178 TelSimCardType_t o_type = 0;
180 msg("call [%s] tapi service !!!", menu->title);
182 rt = tel_get_sim_type (handle, &o_type);
185 msg("card type[%d]", o_type);
189 static int run_sim_get_imsi (MManager *mm, struct menu_data *menu)
191 TapiHandle *handle = menu_manager_ref_user_data (mm);
193 TelSimImsiInfo_t imsi;
194 memset (&imsi, 0, sizeof(TelSimImsiInfo_t));
196 msg("call [%s] tapi service !!!", menu->title);
198 rt = tel_get_sim_imsi (handle, &imsi);
201 msg("mcc[%s]", imsi.szMcc);
202 msg("mnc[%s]", imsi.szMnc);
203 msg("msin[%s]", imsi.szMsin);
207 static int run_sim_get_ecc (MManager *mm, struct menu_data *menu)
209 TapiHandle *handle = menu_manager_ref_user_data (mm);
211 TelSimEccList_t ecc_list;
213 memset (&ecc_list, 0, sizeof(TelSimEccList_t));
215 msg("call [%s] tapi service !!!", menu->title);
217 rt = tel_get_sim_ecc (handle, &ecc_list);
220 msg("ecc_list.ecc_count[%d]", ecc_list.ecc_count);
222 for (i = 0; i < ecc_list.ecc_count; i++) {
223 msg("ecc_list.list[%d].name[%s]", i, ecc_list.list[i].name);
224 msg("ecc_list.list[%d].number[%s]", i, ecc_list.list[i].number);
225 msg("ecc_list.list[%d].category[%d]", i, ecc_list.list[i].category);
230 static void on_sim_get_iccid (TapiHandle *handle, int result, void *data,
233 TelSimAccessResult_t access_rt = result;
234 TelSimIccIdInfo_t *iccid = data;
236 msg("TAPI_SERVICE_SIM_GET_ICCID response received");
238 CHECK_ACCESS_RT(access_rt);
240 msg("access_rt[%d]", access_rt);
241 msg("iccid length[%d]", iccid->icc_length);
242 msg("iccid[%s]", iccid->icc_num);
245 static int run_sim_get_iccid (MManager *mm, struct menu_data *menu)
247 TapiHandle *handle = menu_manager_ref_user_data (mm);
250 msg("call [%s] tapi service !!!", menu->title);
252 rt = tel_get_sim_iccid (handle, on_sim_get_iccid, NULL );
257 static void on_sim_get_language (TapiHandle *handle, int result, void *data,
260 TelSimLanguagePreferenceCode_t *language = data;
261 TelSimAccessResult_t access_rt = result;
263 msg("TAPI_SERVICE_SIM_GET_LANGUAGE response received");
265 CHECK_ACCESS_RT(access_rt);
267 msg("access rt[%d]", access_rt);
268 msg("language[%d]", *language);
271 static int run_sim_get_language (MManager *mm, struct menu_data *menu)
273 TapiHandle *handle = menu_manager_ref_user_data (mm);
276 msg("call [%s] tapi service !!!", menu->title);
278 rt = tel_get_sim_language (handle, on_sim_get_language, NULL );
283 static void on_sim_set_language (TapiHandle *handle, int result, void *data,
286 TelSimAccessResult_t access_rt = result;
288 msg("TAPI_SERVICE_SIM_SET_LANGUAGE response received");
290 CHECK_ACCESS_RT(access_rt);
292 msg("access_rt[%d]", access_rt);
295 static int run_sim_set_language (MManager *mm, struct menu_data *menu)
297 TapiHandle *handle = menu_manager_ref_user_data (mm);
300 msg("call [%s] tapi service !!!", menu->title);
301 data_sim_set_language[0] = data_sim_set_language[0] - '0';
302 rt = tel_set_sim_language (handle, data_sim_set_language[0],
303 on_sim_set_language, NULL );
308 static void on_sim_get_cf (TapiHandle *handle, int result, void *data,
311 TelSimAccessResult_t access_rt = result;
312 TelSimCallForwardingResp_t *cf = data;
314 msg("TAPI_SERVICE_SIM_GET_CF response received");
316 CHECK_ACCESS_RT(access_rt);
318 msg("access_rt[%d]", access_rt);
319 msg("cf->b_cphs[%d]", cf->b_cphs);
322 msg("cf->cphs_cf.b_line1[%d]", cf->cphs_cf.b_line1);
323 msg("cf->cphs_cf.b_line2[%d]", cf->cphs_cf.b_line2);
324 msg("cf->cphs_cf.b_fax[%d]", cf->cphs_cf.b_fax);
325 msg("cf->cphs_cf.b_data[%d]", cf->cphs_cf.b_data);
328 for (i = 0; i < cf->cf_list.profile_count; i++) {
329 msg("cf->cf_list.cf[%d].rec_index[%d]", i,
330 cf->cf_list.cf[i].rec_index);
331 msg("cf->cf_list.cf[%d].msp_num[%d]", i, cf->cf_list.cf[i].msp_num);
332 msg("cf->cf_list.cf[%d].cfu_status[0x%x]", i,
333 cf->cf_list.cf[i].cfu_status);
334 msg("cf->cf_list.cf[%d].cfu_num[%s]", i, cf->cf_list.cf[i].cfu_num);
335 msg("cf->cf_list.cf[%d].ton[%d]", i, cf->cf_list.cf[i].ton);
336 msg("cf->cf_list.cf[%d].npi[%d]", i, cf->cf_list.cf[i].npi);
337 msg("cf->cf_list.cf[%d].cc2_id[0x%x]", i, cf->cf_list.cf[i].cc2_id);
338 msg("cf->cf_list.cf[%d].ext7_id[0x%x]", i,
339 cf->cf_list.cf[i].ext7_id);
344 static int run_sim_get_cf (MManager *mm, struct menu_data *menu)
346 TapiHandle *handle = menu_manager_ref_user_data (mm);
349 msg("call [%s] tapi service !!!", menu->title);
350 rt = tel_get_sim_callforwarding_info (handle, on_sim_get_cf, NULL );
355 static void on_sim_set_cf (TapiHandle *handle, int result, void *data,
358 TelSimAccessResult_t access_rt = result;
360 msg("response received");
362 CHECK_ACCESS_RT(access_rt);
364 msg("access_rt[%d]", access_rt);
367 static int run_sim_set_cf (MManager *mm, struct menu_data *menu)
369 TapiHandle *handle = menu_manager_ref_user_data (mm);
371 TelSimCallForwardingReq_t cf;
372 memset (&cf, 0, sizeof(TelSimCallForwardingReq_t));
374 msg("call [%s] tapi service !!!", menu->title);
376 cf.b_cphs = data_sim_set_cf_b_cphs[0] - '0';
378 cf.cf_data_u.cphs_cf.b_line1 = data_sim_set_cf_cphs_line1[0] - '0';
379 cf.cf_data_u.cphs_cf.b_line2 = data_sim_set_cf_cphs_line2[0] - '0';
380 cf.cf_data_u.cphs_cf.b_fax = data_sim_set_cf_cphs_fax[0] - '0';
381 cf.cf_data_u.cphs_cf.b_data = data_sim_set_cf_cphs_data[0] - '0';
384 cf.cf_data_u.cf.rec_index = data_sim_set_cf_rec_index[0] - '0';
385 cf.cf_data_u.cf.msp_num = data_sim_set_cf_msp_num[0] - '0';
386 cf.cf_data_u.cf.cfu_status = data_sim_set_cf_cfu_status[0] - '0';
387 cf.cf_data_u.cf.ton = data_sim_set_cf_ton[0] - '0';
388 cf.cf_data_u.cf.npi = data_sim_set_cf_npi[0] - '0';
389 memcpy (&cf.cf_data_u.cf.cfu_num, data_sim_set_cf_number,
390 sizeof (cf.cf_data_u.cf.cfu_num));
391 cf.cf_data_u.cf.cc2_id = data_sim_set_cf_cc2_id[0] - '0';
392 cf.cf_data_u.cf.ext7_id = data_sim_set_cf_ext7_id[0] - '0';
395 rt = tel_set_sim_callforwarding_info (handle, &cf, on_sim_set_cf, NULL );
400 static void on_sim_get_mw (TapiHandle *handle, int result, void *data,
403 TelSimAccessResult_t access_rt = result;
404 TelSimMessageWaitingResp_t *mw = data;
407 msg("TAPI_SERVICE_SIM_GET_MW response received");
409 CHECK_ACCESS_RT(access_rt);
411 msg("access_rt[%d]", access_rt);
412 msg("mw->b_cphs[%d]", mw->b_cphs);
415 msg("mw->cphs_mw.b_voice1[%d]", mw->cphs_mw.b_voice1);
416 msg("mw->cphs_mw.b_voice2[%d]", mw->cphs_mw.b_voice2);
417 msg("mw->cphs_mw.b_fax[%d]", mw->cphs_mw.b_fax);
418 msg("mw->cphs_mw.b_data[%d]", mw->cphs_mw.b_data);
421 for (i = 0; i < mw->mw_list.profile_count; i++) {
422 msg("mw->mw_list.mw[%d].rec_index[%d]", i,
423 mw->mw_list.mw[i].rec_index);
424 msg("mw->mw_list.mw[%d].indicator_status[0x%x]", i,
425 mw->mw_list.mw[i].indicator_status);
426 msg("mw->mw_list.mw[%d].voice_count[%d]", i,
427 mw->mw_list.mw[i].voice_count);
428 msg("mw->mw_list.mw[%d].fax_count[%d]", i,
429 mw->mw_list.mw[i].fax_count);
430 msg("mw->mw_list.mw[%d].email_count[%d]", i,
431 mw->mw_list.mw[i].email_count);
432 msg("mw->mw_list.mw[%d].other_count[%d]", i,
433 mw->mw_list.mw[i].other_count);
434 msg("mw->mw_list.mw[%d].video_count[%d]", i,
435 mw->mw_list.mw[i].video_count);
440 static int run_sim_get_mw (MManager *mm, struct menu_data *menu)
442 TapiHandle *handle = menu_manager_ref_user_data (mm);
445 msg("call [%s] tapi service !!!", menu->title);
446 rt = tel_get_sim_messagewaiting_info (handle, on_sim_get_mw, NULL );
451 static void on_sim_set_mw (TapiHandle *handle, int result, void *data,
454 TelSimAccessResult_t access_rt = result;
456 msg("response received");
458 CHECK_ACCESS_RT(access_rt);
460 msg("access_rt[%d]", access_rt);
463 static int run_sim_set_mw (MManager *mm, struct menu_data *menu)
465 TapiHandle *handle = menu_manager_ref_user_data (mm);
467 TelSimMessageWaitingReq_t mw;
469 memset (&mw, 0, sizeof(TelSimMessageWaitingReq_t));
471 msg("call [%s] tapi service !!!", menu->title);
473 mw.b_cphs = data_sim_set_mw_b_cphs[0] - '0';
476 mw.mw_data_u.cphs_mw.b_voice1 = data_sim_set_mw_cphs_voice1[0] - '0';
477 mw.mw_data_u.cphs_mw.b_voice2 = data_sim_set_mw_cphs_voice2[0] - '0';
478 mw.mw_data_u.cphs_mw.b_fax = data_sim_set_mw_cphs_fax[0] - '0';
479 mw.mw_data_u.cphs_mw.b_data = data_sim_set_mw_cphs_data[0] - '0';
482 mw.mw_data_u.mw.rec_index = data_sim_set_mw_rec_index[0] - '0';
483 mw.mw_data_u.mw.indicator_status = data_sim_set_mw_indicator_status[0]
485 mw.mw_data_u.mw.voice_count = data_sim_set_mw_voice_cnt[0] - '0';
486 mw.mw_data_u.mw.fax_count = data_sim_set_mw_fax_cnt[0] - '0';
487 mw.mw_data_u.mw.email_count = data_sim_set_mw_email_cnt[0] - '0';
488 mw.mw_data_u.mw.other_count = data_sim_set_mw_other_cnt[0] - '0';
489 mw.mw_data_u.mw.video_count = data_sim_set_mw_video_cnt[0] - '0';
492 rt = tel_set_sim_messagewaiting_info (handle, &mw, on_sim_set_mw, NULL );
497 static void on_sim_get_mb (TapiHandle *handle, int result, void *data,
500 TelSimAccessResult_t access_rt = result;
501 TelSimMailboxList_t *list = data;
504 msg("TAPI_SERVICE_SIM_GET_MB response received");
506 CHECK_ACCESS_RT(access_rt);
508 msg("access_rt[%d]", access_rt);
509 msg("count[%d]", list->count);
511 for (i = 0; i < list->count; i++) {
512 msg("list->list[%d].b_cphs[%d]", i, list->list[i].b_cphs);
513 msg("list->list[%d].rec_index[%d]", i, list->list[i].rec_index);
514 msg("list->list[%d].profile_num[%d]", i, list->list[i].profile_num);
515 msg("list->list[%d].mb_type[%d]", i, list->list[i].mb_type);
516 msg("list->list[%d].alpha_id_max_len[%d]", i,
517 list->list[i].alpha_id_max_len);
518 msg("list->list[%d].alpha_id[%s]", i, list->list[i].alpha_id);
519 msg("list->list[%d].ton[0x%x]", i, list->list[i].ton);
520 msg("list->list[%d].npi[0x%x]", i, list->list[i].npi);
521 msg("list->list[%d].num[%s]", i, list->list[i].num);
522 msg("list->list[%d].cc_id[0x%x]", i, list->list[i].cc_id);
523 msg("list->list[%d].ext1_id[0x%x]", i, list->list[i].ext1_id);
527 static int run_sim_get_mb (MManager *mm, struct menu_data *menu)
529 TapiHandle *handle = menu_manager_ref_user_data (mm);
532 msg("call [%s] tapi service !!!", menu->title);
533 rt = tel_get_sim_mailbox_info (handle, on_sim_get_mb, NULL );
538 static void on_sim_set_mb (TapiHandle *handle, int result, void *data,
541 TelSimAccessResult_t access_rt = result;
543 msg("response received");
545 CHECK_ACCESS_RT(access_rt);
547 msg("access_rt[%d]", access_rt);
550 static int run_sim_set_mb (MManager *mm, struct menu_data *menu)
552 TapiHandle *handle = menu_manager_ref_user_data (mm);
554 TelSimMailBoxNumber_t mb;
556 msg("call [%s] tapi service !!!", menu->title);
558 memset (&mb, 0, sizeof(TelSimMailBoxNumber_t));
560 mb.b_cphs = data_sim_set_mb_b_cphs[0] - '0';
561 mb.mb_type = data_sim_set_mb_type[0] - '0';
562 mb.rec_index = data_sim_set_mb_rec_index[0] - '0';
563 mb.profile_num = data_sim_set_mb_profile_num[0] - '0';
564 mb.alpha_id_max_len = data_sim_set_mb_alpha_id_max_len[0] - '0';
565 memcpy (&mb.alpha_id, data_sim_set_mb_alpha_id,
566 TAPI_SIM_XDN_ALPHA_ID_MAX_LEN);
567 mb.ton = data_sim_set_mb_ton[0] - '0';
568 mb.npi = data_sim_set_mb_npi[0] - '0';
569 memcpy (&mb.num, data_sim_set_mb_number, sizeof (mb.num));
570 mb.cc_id = data_sim_set_mb_cc_id[0] - '0';
571 mb.ext1_id = data_sim_set_mb_ext1_id[0] - '0';
573 rt = tel_set_sim_mailbox_info (handle, &mb, on_sim_set_mb, NULL );
578 static void on_sim_get_cphs_info (TapiHandle *handle, int result, void *data,
581 TelSimAccessResult_t access_rt = result;
582 TelSimCphsInfo_t *cphs = data;
584 msg("TAPI_SERVICE_SIM_GET_CPHSINFO response received");
586 CHECK_ACCESS_RT(access_rt);
588 msg("access_rt[%d]", access_rt);
589 msg("cphs->CphsPhase[%d]", cphs->CphsPhase);
590 msg("cphs->CphsServiceTable.bOperatorNameShortForm[%d]",
591 cphs->CphsServiceTable.bOperatorNameShortForm);
592 msg("cphs->CphsServiceTable.bMailBoxNumbers[%d]",
593 cphs->CphsServiceTable.bMailBoxNumbers);
594 msg("cphs->CphsServiceTable.bServiceStringTable[%d]",
595 cphs->CphsServiceTable.bServiceStringTable);
596 msg("cphs->CphsServiceTable.bCustomerServiceProfile[%d]",
597 cphs->CphsServiceTable.bCustomerServiceProfile);
598 msg("cphs->CphsServiceTable.bInformationNumbers[%d]",
599 cphs->CphsServiceTable.bInformationNumbers);
602 static void on_sim_get_service_table (TapiHandle *handle, int result,
603 void *data, void *user_data)
605 TelSimAccessResult_t access_rt = result;
606 TelSimServiceTable_t *svct = (TelSimServiceTable_t *) data;
608 msg("TAPI_SERVICE_SIM_GET_SERVICE_TABLE response received");
610 CHECK_ACCESS_RT(access_rt);
612 msg("access_rt[%d]", access_rt);
614 if (svct->sim_type == TAPI_SIM_CARD_TYPE_GSM) {
615 int i = 0, size = sizeof(TelSimSST_t);
617 if ( (temp = (char *) calloc (size + 1, 1)) != NULL ) {
618 memcpy (temp, &svct->table.sst, size);
619 for (i = 0; i < size; i++) {
625 msg("svct->table.sst=[%s]", temp);
629 else if (svct->sim_type == TAPI_SIM_CARD_TYPE_USIM) {
630 int i = 0, size = sizeof(TelSimUST_t);
632 if ( (temp = (char *) calloc (size + 1, 1)) != NULL ) {
633 memcpy (temp, &svct->table.ust, size);
634 for (i = 0; i < size; i++) {
640 msg("svct->table.ust=[%s]", temp);
645 msg("Unknown sim type");
649 static int run_sim_get_cphs_info (MManager *mm, struct menu_data *menu)
651 TapiHandle *handle = menu_manager_ref_user_data (mm);
654 msg("call [%s] tapi service !!!", menu->title);
655 rt = tel_get_sim_cphs_info (handle, on_sim_get_cphs_info, NULL );
660 static int run_sim_get_service_table (MManager *mm, struct menu_data *menu)
662 TapiHandle *handle = menu_manager_ref_user_data (mm);
665 msg("call [%s] tapi service !!!", menu->title);
666 rt = tel_get_sim_service_table (handle, on_sim_get_service_table, NULL );
671 static void on_sim_get_msisdn (TapiHandle *handle, int result, void *data,
674 TelSimAccessResult_t access_rt = result;
675 TelSimMsisdnList_t *list = data;
677 msg("TAPI_SERVICE_SIM_GET_MSISDN response received");
679 CHECK_ACCESS_RT(access_rt);
681 msg("access_rt[%d]", access_rt);
683 msg("list->count[%d]", list->count);
685 for (i = 0; i < list->count; i++)
686 msg("index[%d] - name[%s], num[%s]", i, list->list[i].name,
690 static int run_sim_get_msisdn (MManager *mm, struct menu_data *menu)
692 TapiHandle *handle = menu_manager_ref_user_data (mm);
695 msg("call [%s] tapi service !!!", menu->title);
696 rt = tel_get_sim_msisdn (handle, on_sim_get_msisdn, NULL );
701 static void on_sim_get_oplmnwact (TapiHandle *handle, int result, void *data,
704 TelSimAccessResult_t access_rt = result;
705 TelSimOplmnwactList_t *list = data;
708 msg("TAPI_SERVICE_SIM_GET_OPLMNWACT response received");
710 CHECK_ACCESS_RT(access_rt);
712 msg("access_rt[%d]", access_rt);
713 msg("list->count[%d]", list->count);
715 for (i = 0; i < list->count; i++) {
716 msg("index[%d] - plmn[%s], b_umts[%d], b_gsm[%d]", i,
717 list->list[i].plmn, list->list[i].b_umts, list->list[i].b_gsm);
721 static int run_sim_get_oplmnwact (MManager *mm, struct menu_data *menu)
723 TapiHandle *handle = menu_manager_ref_user_data (mm);
726 msg("call [%s] tapi service !!!", menu->title);
727 rt = tel_get_sim_oplmnwact (handle, on_sim_get_oplmnwact, NULL );
732 static void on_sim_get_spn (TapiHandle *handle, int result, void *data,
735 TelSimAccessResult_t access_rt = result;
736 TelSimSpn_t *spn_info = data;
738 msg("TAPI_SERVICE_SIM_GET_SPN response received");
740 CHECK_ACCESS_RT(access_rt);
742 msg("access_rt[%d]", access_rt);
743 msg("spn name[%s]", spn_info->spn);
744 msg("spn condition[0x%x]", spn_info->display_condition);
747 static int run_sim_get_spn (MManager *mm, struct menu_data *menu)
749 TapiHandle *handle = menu_manager_ref_user_data (mm);
752 msg("call [%s] tapi service !!!", menu->title);
753 rt = tel_get_sim_spn (handle, on_sim_get_spn, NULL );
758 static void on_sim_get_cphs_netname (TapiHandle *handle, int result, void *data,
761 TelSimAccessResult_t access_rt = result;
762 TelSimCphsNetName_t *cphs_net = data;
764 msg("TAPI_SERVICE_SIM_GET_CPHS_NETNAME response received");
766 CHECK_ACCESS_RT(access_rt);
768 msg("access_rt[%d]", access_rt);
769 msg("cphs full name[%s]", cphs_net->full_name);
770 msg("cphs short name[%s]", cphs_net->short_name);
773 static int run_sim_get_cphs_netname (MManager *mm, struct menu_data *menu)
775 TapiHandle *handle = menu_manager_ref_user_data (mm);
778 msg("call [%s] tapi service !!!", menu->title);
779 rt = tel_get_sim_cphs_netname (handle, on_sim_get_cphs_netname, NULL );
784 static void on_sim_req_authentication (TapiHandle *handle, int result,
785 void *data, void *user_data)
787 TelSimAccessResult_t access_rt = result;
788 TelSimAuthenticationResponse_t *auth_resp = data;
791 msg("TAPI_SERVICE_SIM_AUTHENTICATION response received");
793 CHECK_ACCESS_RT(access_rt);
795 msg("access_rt[%d]", access_rt);
796 msg("auth_resp->auth_type[%d]", auth_resp->auth_type);
797 msg("auth_resp->auth_result[%d]", auth_resp->auth_result);
799 msg("auth_resp->authentication_key_length[%d]",
800 auth_resp->authentication_key_length);
801 if (auth_resp->authentication_key_length) {
802 for (i = 0; i < auth_resp->authentication_key_length; i++)
803 msg("auth_resp->authentication_key[%d][0x%2x]", i,
804 auth_resp->authentication_key[i]);
807 msg("auth_resp->cipher_length[%d]", auth_resp->cipher_length);
808 if (auth_resp->cipher_length) {
809 for (i = 0; i < auth_resp->cipher_length; i++)
810 msg("auth_resp->cipher_data[%d][0x%2x]", i,
811 auth_resp->cipher_data[i]);
814 msg("auth_resp->integrity_length[%d]", auth_resp->integrity_length);
815 if (auth_resp->integrity_length) {
816 for (i = 0; i < auth_resp->integrity_length; i++)
817 msg("auth_resp->integrity_data[%d][0x%2x]", i,
818 auth_resp->integrity_data[i]);
821 msg("auth_resp->resp_length[%d]", auth_resp->resp_length);
822 if (auth_resp->resp_length) {
823 for (i = 0; i < auth_resp->resp_length; i++)
824 msg("auth_resp->resp_data[%d][0x%2x]", i, auth_resp->resp_data[i]);
829 static int run_sim_req_authentication (MManager *mm, struct menu_data *menu)
831 TapiHandle *handle = menu_manager_ref_user_data (mm);
833 TelSimAuthenticationData_t auth;
834 memset (&auth, 0, sizeof(TelSimAuthenticationData_t));
836 msg("call [%s] tapi service !!!", menu->title);
838 data_sim_req_authentication_type[0] = data_sim_req_authentication_type[0]
841 auth.auth_type = data_sim_req_authentication_type[0];
842 auth.autn_length = strlen (data_sim_req_authentication_autn_data);
843 memcpy (&auth.autn_data, data_sim_req_authentication_autn_data,
845 auth.rand_length = strlen (data_sim_req_authentication_rand_data);
846 memcpy (&auth.rand_data, data_sim_req_authentication_rand_data,
849 rt = tel_req_sim_authentication (handle, &auth, on_sim_req_authentication,
855 static void on_sim_security_op_resp (TapiHandle *handle, int result, void *data,
858 TelSimPinOperationResult_t sec_rt = result;
859 TelSimSecResult_t *rt = data;
861 msg("TAPI_SERVICE_SIM security response received");
863 if (sec_rt == TAPI_SIM_PIN_INCORRECT_PASSWORD ||
864 sec_rt == TAPI_SIM_PUK_INCORRECT_PASSWORD) {
865 msg("SIM operation: Password Incorrect[%d]",sec_rt);
867 CHECK_ACCESS_RT(sec_rt);
870 msg("sec_rt[%d]", sec_rt);
871 msg("rt->type[%d]", rt->type);
872 msg("rt->retry_count[%d]", rt->retry_count);
875 static int run_sim_verify_pins (MManager *mm, struct menu_data *menu)
877 TapiHandle *handle = menu_manager_ref_user_data (mm);
880 memset (&pwt, 0, sizeof(TelSimSecPw_t));
882 msg("call [%s] tapi service !!!", menu->title);
884 data_sim_verify_pins_type[0] = data_sim_verify_pins_type[0] - '0';
885 data_sim_verify_pins_pw[MENU_DATA_SIZE] = '\0';
886 pwt.type = data_sim_verify_pins_type[0];
887 pwt.pw_len = strlen (data_sim_verify_pins_pw);
888 pwt.pw = (unsigned char *) data_sim_verify_pins_pw;
890 rt = tel_verifiy_sim_pins (handle, &pwt, on_sim_security_op_resp, NULL );
895 static int run_sim_verify_puks (MManager *mm, struct menu_data *menu)
897 TapiHandle *handle = menu_manager_ref_user_data (mm);
900 TelSimSecPw_t new_pin_t;
901 memset (&puk_t, 0, sizeof(TelSimSecPw_t));
902 memset (&new_pin_t, 0, sizeof(TelSimSecPw_t));
903 msg("call [%s] tapi service !!!", menu->title);
905 data_sim_verify_puks_type[0] = data_sim_verify_puks_type[0] - '0';
906 data_sim_verify_puks_puk[MENU_DATA_SIZE] = '\0';
907 puk_t.type = data_sim_verify_puks_type[0];
908 puk_t.pw_len = strlen (data_sim_verify_puks_puk);
909 puk_t.pw = (unsigned char*) data_sim_verify_puks_puk;
911 if (puk_t.type == TAPI_SIM_PTYPE_PUK1)
912 new_pin_t.type = TAPI_SIM_PTYPE_PIN1;
913 if (puk_t.type == TAPI_SIM_PTYPE_PUK2)
914 new_pin_t.type = TAPI_SIM_PTYPE_PIN2;
916 data_sim_verify_puks_pin[MENU_DATA_SIZE] = '\0';
917 new_pin_t.pw_len = strlen (data_sim_verify_puks_pin);
918 new_pin_t.pw = (unsigned char*) data_sim_verify_puks_pin;
920 rt = tel_verify_sim_puks (handle, &puk_t, &new_pin_t,
921 on_sim_security_op_resp, NULL );
926 static int run_sim_change_pins (MManager *mm, struct menu_data *menu)
928 TapiHandle *handle = menu_manager_ref_user_data (mm);
932 memset (&old, 0, sizeof(TelSimSecPw_t));
933 memset (&new, 0, sizeof(TelSimSecPw_t));
935 msg("call [%s] tapi service !!!", menu->title);
937 data_sim_change_pins_type[0] = data_sim_change_pins_type[0] - '0';
939 data_sim_change_pins_old_pw[MENU_DATA_SIZE] = '\0';
940 old.type = data_sim_change_pins_type[0];
941 old.pw_len = strlen (data_sim_change_pins_old_pw);
942 old.pw = (unsigned char*) data_sim_change_pins_old_pw;
944 data_sim_change_pins_new_pw[MENU_DATA_SIZE] = '\0';
945 new.type = data_sim_change_pins_type[0];
946 new.pw_len = strlen (data_sim_change_pins_new_pw);
947 new.pw = (unsigned char*) data_sim_change_pins_new_pw;
949 rt = tel_change_sim_pins (handle, &old, &new, on_sim_security_op_resp,
955 static void on_sim_facility_op_resp (TapiHandle *handle, int result, void *data,
958 TelSimPinOperationResult_t sec_rt = result;
959 TelSimFacilityResult_t *f_rt = data;
961 msg("TAPI_SERVICE_SIM facility response received");
963 if (sec_rt == TAPI_SIM_PIN_INCORRECT_PASSWORD ||
964 sec_rt == TAPI_SIM_PUK_INCORRECT_PASSWORD) {
965 msg("SIM operation: Password Incorrect[%d]",sec_rt);
967 CHECK_ACCESS_RT(sec_rt);
970 msg("sec_rt[%d]", sec_rt);
971 msg("f_rt->type[%d]", f_rt->type);
972 msg("f_rt->retry_count[%d]", f_rt->retry_count);
975 static int run_sim_disable_facility (MManager *mm, struct menu_data *menu)
977 TapiHandle *handle = menu_manager_ref_user_data (mm);
979 TelSimFacilityPw_t fpw;
980 msg("call [%s] tapi service !!!", menu->title);
982 memset (&fpw, 0, sizeof (fpw));
984 data_sim_disable_facility_type[0] = data_sim_disable_facility_type[0] - '0';
985 data_sim_disable_facility_pw[MENU_DATA_SIZE] = '\0';
986 fpw.lock_type = data_sim_disable_facility_type[0];
987 fpw.pw_len = strlen (data_sim_disable_facility_pw);
988 fpw.pw = (unsigned char*) data_sim_disable_facility_pw;
990 msg("fpw.lock_type[%d], fpw.pw_len[%d], fpw.pw[%s]", fpw.lock_type,
992 rt = tel_disable_sim_facility (handle, &fpw, on_sim_facility_op_resp,
998 static int run_sim_enable_facility (MManager *mm, struct menu_data *menu)
1000 TapiHandle *handle = menu_manager_ref_user_data (mm);
1002 TelSimFacilityPw_t fpw;
1003 msg("call [%s] tapi service !!!", menu->title);
1005 memset (&fpw, 0, sizeof (fpw));
1007 data_sim_enable_facility_type[0] = data_sim_enable_facility_type[0] - '0';
1008 data_sim_enable_facility_pw[MENU_DATA_SIZE] = '\0';
1009 fpw.lock_type = data_sim_enable_facility_type[0];
1010 fpw.pw_len = strlen (data_sim_enable_facility_pw);
1011 fpw.pw = (unsigned char*) data_sim_enable_facility_pw;
1013 msg("fpw.lock_type[%d], fpw.pw_len[%d], fpw.pw[%s]", fpw.lock_type,
1014 fpw.pw_len, fpw.pw);
1015 rt = tel_enable_sim_facility (handle, &fpw, on_sim_facility_op_resp, NULL );
1020 static void on_sim_get_facility (TapiHandle *handle, int result, void *data,
1023 TelSimPinOperationResult_t sec_rt = result;
1024 TelSimFacilityInfo_t *fi = data;
1026 msg("TAPI_SERVICE_SIM facility response received");
1028 CHECK_ACCESS_RT(sec_rt);
1030 msg("sec_rt[%d]", sec_rt);
1031 msg("fi->type[%d]", fi->type);
1032 msg("fi->f_status[%d]", fi->f_status);
1035 static int run_sim_get_facility (MManager *mm, struct menu_data *menu)
1037 TapiHandle *handle = menu_manager_ref_user_data (mm);
1039 TelSimLockType_t t = 0;
1040 msg("call [%s] tapi service !!!", menu->title);
1042 data_sim_get_facility_type[0] = data_sim_get_facility_type[0] - '0';
1044 switch (data_sim_get_facility_type[0]) {
1046 t = TAPI_SIM_LOCK_PS;
1049 t = TAPI_SIM_LOCK_PF;
1052 t = TAPI_SIM_LOCK_SC;
1055 t = TAPI_SIM_LOCK_FD;
1058 t = TAPI_SIM_LOCK_PN;
1061 t = TAPI_SIM_LOCK_PU;
1064 t = TAPI_SIM_LOCK_PP;
1067 t = TAPI_SIM_LOCK_PC;
1070 msg("not handled type[%d]", data_sim_get_facility_type[0])
1074 rt = tel_get_sim_facility (handle, t, on_sim_get_facility, NULL );
1079 static void on_sim_get_lock_info (TapiHandle *handle, int result, void *data,
1082 TelSimPinOperationResult_t sec_rt = result;
1083 TelSimLockInfo_t *lock = data;
1085 msg("TAPI_SERVICE_SIM lock info response received");
1087 CHECK_ACCESS_RT(sec_rt);
1089 msg("sec_rt[%d]", sec_rt);
1090 msg("lock->lock_type[%d]", lock->lock_type);
1092 "lock->lock_status[%d]-0:not need, 1:pin, 2:puk, 3:pin2, 4:puk2, 5:blocked",
1094 msg("lock->retry_count[%d]", lock->retry_count);
1097 static int run_sim_get_lock_info (MManager *mm, struct menu_data *menu)
1099 TapiHandle *handle = menu_manager_ref_user_data (mm);
1101 TelSimLockType_t t = 0;
1102 msg("call [%s] tapi service !!!", menu->title);
1104 data_sim_get_lock_type[0] = data_sim_get_lock_type[0] - '0';
1106 switch (data_sim_get_lock_type[0]) {
1108 t = TAPI_SIM_LOCK_PS;
1111 t = TAPI_SIM_LOCK_PF;
1114 t = TAPI_SIM_LOCK_SC;
1117 t = TAPI_SIM_LOCK_FD;
1120 t = TAPI_SIM_LOCK_PN;
1123 t = TAPI_SIM_LOCK_PU;
1126 t = TAPI_SIM_LOCK_PP;
1129 t = TAPI_SIM_LOCK_PC;
1132 msg("not handled type[%d]", data_sim_get_lock_type[0])
1136 rt = tel_get_sim_lock_info (handle, t, on_sim_get_lock_info, NULL );
1141 static void on_sim_transmit_apdu (TapiHandle *handle, int result, void *data,
1144 TelSimAccessResult_t access_rt = result;
1145 TelSimApduResp_t *r_apdu = data;
1148 msg("TAPI_SERVICE_SIM_APDU response received");
1150 CHECK_ACCESS_RT(access_rt);
1152 msg("access_rt[%d]", access_rt);
1153 msg("r_apdu->apdu_resp_len[%d]", r_apdu->apdu_resp_len);
1154 if (r_apdu->apdu_resp_len) {
1155 for (i = 0; i < r_apdu->apdu_resp_len; i++)
1156 msg("[%d]`s byte is [0x%x]", i, r_apdu->apdu_resp[i]);
1160 static int run_sim_transmit_apdu (MManager *mm, struct menu_data *menu)
1162 TapiHandle *handle = menu_manager_ref_user_data (mm);
1164 TelSimApdu_t t_apdu;
1165 unsigned char result_apdu[MENU_DATA_SIZE + 1] = { 0, };
1166 int i = 0, j = 0, len = 0, hex = 0;
1168 memset (&t_apdu, 0, sizeof(TelSimApdu_t));
1170 msg("call [%s] tapi service !!!", menu->title);
1172 len = strlen (data_sim_transmit_apdu_apdu);
1174 for (i = 0, j = 0; i < len; i += 2, j++) {
1175 hex = (_sim_str_to_hex (data_sim_transmit_apdu_apdu[i]) << 4)
1176 | (_sim_str_to_hex (data_sim_transmit_apdu_apdu[i + 1]));
1177 printf ("0x%x\n", hex);
1179 result_apdu[j] = hex;
1182 for (i = 0; i < len / 2; i++) {
1183 printf ("[%02d] = 0x%02x\n", i, result_apdu[i]);
1186 t_apdu.apdu_len = len / 2;
1187 t_apdu.apdu = (unsigned char*) malloc (t_apdu.apdu_len);
1188 memcpy (t_apdu.apdu, result_apdu, t_apdu.apdu_len);
1190 rt = tel_req_sim_apdu (handle, &t_apdu, on_sim_transmit_apdu, NULL );
1197 static void on_sim_get_atr (TapiHandle *handle, int result, void *data,
1200 TelSimAccessResult_t access_rt = result;
1201 TelSimAtrResp_t *r_atr = data;
1203 msg("TAPI_SERVICE_SIM_APDU response received");
1205 CHECK_ACCESS_RT(access_rt);
1207 msg("access_rt[%d]", access_rt);
1208 msg("r_atr->atr_resp_len[%d]", r_atr->atr_resp_len);
1209 if (r_atr->atr_resp_len) {
1210 for (i = 0; i < r_atr->atr_resp_len; i++)
1211 msg("[%d]`s byte is [0x%x]", i, r_atr->atr_resp[i]);
1215 static int run_sim_get_atr(MManager *mm, struct menu_data *menu)
1217 TapiHandle *handle = menu_manager_ref_user_data(mm);
1220 msg("call [%s] tapi service !!!", menu->title);
1222 rt = tel_req_sim_atr(handle, on_sim_get_atr, NULL);
1227 static void on_sim_set_power_state (TapiHandle *handle, int result, void *data,
1230 TelSimPowerSetResult_t access_rt = result;
1232 msg("TAPI_SERVICE_SIM_SET_POWER_STATE response received");
1234 CHECK_ACCESS_RT(access_rt);
1236 msg("access_rt[%d]", access_rt);
1239 static int run_sim_set_power_state(MManager *mm, struct menu_data *menu)
1241 TapiHandle *handle = menu_manager_ref_user_data (mm);
1244 msg("call [%s] tapi service !!!", menu->title);
1245 data_sim_set_state[0] = data_sim_set_state[0] - '0';
1246 rt = tel_set_sim_power_state (handle, data_sim_set_state[0],
1247 on_sim_set_power_state, NULL );
1253 static struct menu_data menu_sim_get_init_info[] = {
1254 { "1", "run", NULL, run_sim_get_init_info, NULL},
1258 static struct menu_data menu_sim_get_card_type[] = {
1259 { "1", "run", NULL, run_sim_get_card_type, NULL},
1263 static struct menu_data menu_sim_get_imsi[] = {
1264 { "1", "run", NULL, run_sim_get_imsi, NULL},
1268 static struct menu_data menu_sim_get_ecc[] = {
1269 { "1", "run", NULL, run_sim_get_ecc, NULL},
1273 static struct menu_data menu_sim_get_iccid[] = {
1274 { "1", "run", NULL, run_sim_get_iccid, NULL},
1278 static struct menu_data menu_sim_get_language[] = {
1279 {"1", "run", NULL, run_sim_get_language, NULL},
1283 static struct menu_data menu_sim_set_language[] = {
1284 {"1", "select language", NULL, NULL, (char*)data_sim_set_language},
1285 {"2", "run", NULL, run_sim_set_language, NULL},
1289 static struct menu_data menu_sim_change_state[] = {
1290 {"1", "change state(0:OFF, 1:ON)", NULL, NULL, (char*)data_sim_set_state},
1291 {"2", "run", NULL, run_sim_set_power_state, NULL},
1296 static struct menu_data menu_sim_get_cf[] = {
1297 {"1", "run", NULL, run_sim_get_cf, NULL},
1301 static struct menu_data menu_sim_set_cf[] = {
1302 {"1", "b_cphs no/yes => 0/1", NULL, NULL, data_sim_set_cf_b_cphs},
1303 {"2", "rec_index int", NULL, NULL, data_sim_set_cf_rec_index},
1304 {"3", "msp_num int", NULL, NULL, data_sim_set_cf_msp_num},
1305 {"4", "cfu_status int", NULL, NULL, data_sim_set_cf_cfu_status},
1306 {"5", "ton int", NULL, NULL, data_sim_set_cf_ton},
1307 {"6", "npi int", NULL, NULL, data_sim_set_cf_npi},
1308 {"7", "number string", NULL, NULL, data_sim_set_cf_number},
1309 {"8", "cc2_id int", NULL, NULL, data_sim_set_cf_cc2_id},
1310 {"9", "ext7_id int", NULL, NULL, data_sim_set_cf_ext7_id},
1311 {"10", "cphs_line1 no/yes => 0/1", NULL, NULL, data_sim_set_cf_cphs_line1},
1312 {"11", "cphs_line2 no/yes => 0/1", NULL, NULL, data_sim_set_cf_cphs_line2},
1313 {"12", "cphs_fax no/yes => 0/1", NULL, NULL, data_sim_set_cf_cphs_fax},
1314 {"13", "cphs_data no/yes => 0/1", NULL, NULL, data_sim_set_cf_cphs_data},
1315 {"14", "run", NULL, run_sim_set_cf, NULL},
1319 static struct menu_data menu_sim_get_mw[] = {
1320 {"1", "run", NULL, run_sim_get_mw, NULL},
1324 static struct menu_data menu_sim_set_mw[] = {
1325 {"1", "b_cphs no/yes => 0/1", NULL, NULL, data_sim_set_mw_b_cphs},
1326 {"2", "rec_index int", NULL, NULL, data_sim_set_mw_rec_index},
1327 {"3", "indicator_status int", NULL, NULL, data_sim_set_mw_indicator_status},
1328 {"4", "voice_cnt int", NULL, NULL, data_sim_set_mw_voice_cnt},
1329 {"5", "fax_cnt int", NULL, NULL, data_sim_set_mw_fax_cnt},
1330 {"6", "email_cnt int", NULL, NULL, data_sim_set_mw_email_cnt},
1331 {"7", "other_cnt int", NULL, NULL, data_sim_set_mw_other_cnt},
1332 {"8", "video_cnt int", NULL, NULL, data_sim_set_mw_video_cnt},
1333 {"9", "cphs_voice1 no/yes => 0/1", NULL, NULL, data_sim_set_mw_cphs_voice1},
1334 {"10", "cphs_voice2 no/yes => 0/1", NULL, NULL, data_sim_set_mw_cphs_voice2},
1335 {"11", "cphs_fax no/yes => 0/1", NULL, NULL, data_sim_set_mw_cphs_fax},
1336 {"12", "cphs_data no/yes => 0/1", NULL, NULL, data_sim_set_mw_cphs_data},
1337 {"13", "run", NULL, run_sim_set_mw, NULL},
1341 static struct menu_data menu_sim_get_mb[] = {
1342 {"1", "run", NULL, run_sim_get_mb, NULL},
1346 static struct menu_data menu_sim_set_mb[] = {
1347 {"1", "b_cphs no/yes => 0/1", NULL, NULL, data_sim_set_mb_b_cphs},
1348 {"2", "type 1voice 2voice2 3fax 4data 5email 6other int", NULL, NULL, data_sim_set_mb_type},
1349 {"3", "rec_index int", NULL, NULL, data_sim_set_mb_rec_index},
1350 {"4", "profile_num int", NULL, NULL, data_sim_set_mb_profile_num},
1351 {"5", "alpha_id_max_len int", NULL, NULL, data_sim_set_mb_alpha_id_max_len},
1352 {"6", "alpha_id string", NULL, NULL, data_sim_set_mb_alpha_id},
1353 {"7", "ton int", NULL, NULL, data_sim_set_mb_ton},
1354 {"8", "npi int", NULL, NULL, data_sim_set_mb_npi},
1355 {"9", "number string", NULL, NULL, data_sim_set_mb_number},
1356 {"10", "cc_id int", NULL, NULL, data_sim_set_mb_cc_id},
1357 {"11", "ext1_id int", NULL, NULL, data_sim_set_mb_ext1_id},
1358 {"12", "run", NULL, run_sim_set_mb, NULL},
1362 static struct menu_data menu_sim_get_cphs_info[] = {
1363 {"1", "run", NULL, run_sim_get_cphs_info, NULL},
1367 static struct menu_data menu_sim_get_service_table[] = {
1368 {"1", "run", NULL, run_sim_get_service_table, NULL},
1372 static struct menu_data menu_sim_get_msisdn[] = {
1373 {"1", "run", NULL, run_sim_get_msisdn, NULL},
1377 static struct menu_data menu_sim_get_oplmnwact[] = {
1378 {"1", "run", NULL, run_sim_get_oplmnwact, NULL},
1382 static struct menu_data menu_sim_get_spn[] = {
1383 {"1", "run", NULL, run_sim_get_spn, NULL},
1387 static struct menu_data menu_sim_get_cphs_netname[] = {
1388 {"1", "run", NULL, run_sim_get_cphs_netname, NULL},
1392 static struct menu_data menu_sim_req_authentication[] = {
1393 {"1", "type", NULL, NULL, data_sim_req_authentication_type},
1394 {"2", "autn_data", NULL, NULL, data_sim_req_authentication_autn_data},
1395 {"3", "rand_data", NULL, NULL, data_sim_req_authentication_rand_data},
1396 {"4", "run", NULL, run_sim_req_authentication, NULL},
1400 static struct menu_data menu_sim_verify_pins[] = {
1401 {"1", "type(0:pin1, 1:pin2, 6:sim)", NULL, NULL, data_sim_verify_pins_type},
1402 {"2", "pw", NULL, NULL, data_sim_verify_pins_pw},
1403 {"3", "run", NULL, run_sim_verify_pins, NULL},
1407 static struct menu_data menu_sim_verify_puks[] = {
1408 {"1", "type(2:puk1, 3:puk2)", NULL, NULL, data_sim_verify_puks_type},
1409 {"2", "puk", NULL, NULL, data_sim_verify_puks_puk},
1410 {"3", "pin", NULL, NULL, data_sim_verify_puks_pin},
1411 {"4", "run", NULL, run_sim_verify_puks, NULL},
1415 static struct menu_data menu_sim_change_pins[] = {
1416 {"1", "type(0:pin1, 1:pin2)", NULL, NULL, data_sim_change_pins_type},
1417 {"2", "old_pw", NULL, NULL, data_sim_change_pins_old_pw},
1418 {"3", "new_pw", NULL, NULL, data_sim_change_pins_new_pw},
1419 {"4", "run", NULL, run_sim_change_pins, NULL},
1423 static struct menu_data menu_sim_disable_facility[] = {
1424 {"1", "type(1:simlock, 3:pinlock., 4:fdnlock, 5:net, 6:netsub, 7:sp, 8:cp)", NULL, NULL, data_sim_disable_facility_type},
1425 {"2", "pw", NULL, NULL, data_sim_disable_facility_pw},
1426 {"3", "run", NULL, run_sim_disable_facility, NULL},
1430 static struct menu_data menu_sim_enable_facility[] = {
1431 {"1", "type(1:simlock, 3:pinlock., 4:fdnlock, 5:net, 6:netsub, 7:sp, 8:cp)", NULL, NULL, data_sim_enable_facility_type},
1432 {"2", "pw", NULL, NULL, data_sim_enable_facility_pw},
1433 {"3", "run", NULL, run_sim_enable_facility, NULL},
1437 static struct menu_data menu_sim_get_facility[] = {
1438 {"1", "type(1:simlock, 3:pinlock., 4:fdnlock, 5:net, 6:netsub, 7:sp, 8:cp)", NULL, NULL, data_sim_get_facility_type},
1439 {"2", "run", NULL, run_sim_get_facility, NULL},
1443 static struct menu_data menu_sim_get_lock_info[] = {
1444 {"1", "type(1:simlock, 3:pinlock., 4:fdnlock, 5:net, 6:netsub, 7:sp, 8:cp)", NULL, NULL, data_sim_get_lock_type},
1445 {"2", "run", NULL, run_sim_get_lock_info, NULL},
1449 static struct menu_data menu_sim_transmit_apdu[] = {
1450 {"1", "apdu", NULL, NULL, data_sim_transmit_apdu_apdu},
1451 {"2", "run", NULL, run_sim_transmit_apdu, NULL},
1455 static struct menu_data menu_sim_get_atr[] = {
1456 {"1", "run", NULL, run_sim_get_atr, NULL},
1460 struct menu_data menu_sim[] = {
1461 {"1", "sim init info", menu_sim_get_init_info, NULL, NULL},
1462 {"2", "card type", menu_sim_get_card_type, NULL, NULL},
1463 {"3", "imsi", menu_sim_get_imsi, NULL, NULL},
1464 {"4", "ecc", menu_sim_get_ecc, NULL, NULL},
1465 {"5", "iccid", menu_sim_get_iccid, NULL, NULL},
1466 {"6", "language", menu_sim_get_language, NULL, NULL},
1467 {"7", "update language", menu_sim_set_language, NULL, NULL},
1468 {"8", "cf info", menu_sim_get_cf, NULL, NULL},
1469 {"9", "update cf info", menu_sim_set_cf, NULL, NULL},
1470 {"10", "mw info", menu_sim_get_mw, NULL, NULL},
1471 {"11", "update mw info", menu_sim_set_mw, NULL, NULL},
1472 {"12", "mailbox info", menu_sim_get_mb, NULL, NULL},
1473 {"13", "update mailbox info", menu_sim_set_mb, NULL, NULL},
1474 {"14", "cphs info(svc table, phase)", menu_sim_get_cphs_info, NULL, NULL},
1475 {"15", "msisdn", menu_sim_get_msisdn, NULL, NULL},
1476 {"16", "oplmnwact", menu_sim_get_oplmnwact, NULL, NULL},
1477 {"17", "spn", menu_sim_get_spn, NULL, NULL},
1478 {"18", "cphs operator name info", menu_sim_get_cphs_netname, NULL, NULL},
1479 {"19", "authentication", menu_sim_req_authentication, NULL, NULL},
1480 {"20", "verify pins", menu_sim_verify_pins, NULL, NULL},
1481 {"21", "verify puks", menu_sim_verify_puks, NULL, NULL},
1482 {"22", "change pins", menu_sim_change_pins, NULL, NULL},
1483 {"23", "disable facility", menu_sim_disable_facility, NULL, NULL},
1484 {"24", "enable facility", menu_sim_enable_facility, NULL, NULL},
1485 {"25", "facility(en/dis status) info", menu_sim_get_facility, NULL, NULL},
1486 {"26", "lock status(status,retry count) info", menu_sim_get_lock_info, NULL, NULL},
1487 {"27", "apdu", menu_sim_transmit_apdu, NULL, NULL},
1488 {"28", "atr info", menu_sim_get_atr, NULL, NULL},
1489 {"29", "service table", menu_sim_get_service_table, NULL, NULL},
1490 {"30", "Change State", menu_sim_change_state, NULL, NULL},
1494 void register_sim_event (TapiHandle *handle)
1499 ret = tel_register_noti_event (handle, TAPI_NOTI_SIM_STATUS,
1500 on_noti_sim_status, NULL );
1501 ret = tel_register_noti_event (handle, TAPI_PROP_SIM_CALL_FORWARD_STATE,
1502 on_noti_sim_cf_state, NULL );
1503 if (ret != TAPI_API_SUCCESS) {
1504 msg("event register failed(%d)", ret);