2 * Telephony test application
4 * Copyright (c) 2012 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, };
53 static char data_sim_set_cf_b_cphs[MENU_DATA_SIZE + 1] = { };
54 static char data_sim_set_cf_rec_index[MENU_DATA_SIZE + 1] = { };
55 static char data_sim_set_cf_msp_num[MENU_DATA_SIZE + 1] = { };
56 static char data_sim_set_cf_cfu_status[MENU_DATA_SIZE + 1] = { };
57 static char data_sim_set_cf_ton[MENU_DATA_SIZE + 1] = { };
58 static char data_sim_set_cf_npi[MENU_DATA_SIZE + 1] = { };
59 static char data_sim_set_cf_number[MENU_DATA_SIZE + 1] = { };
60 static char data_sim_set_cf_cc2_id[MENU_DATA_SIZE + 1] = { };
61 static char data_sim_set_cf_ext7_id[MENU_DATA_SIZE + 1] = { };
62 static char data_sim_set_cf_cphs_line1[MENU_DATA_SIZE + 1] = { };
63 static char data_sim_set_cf_cphs_line2[MENU_DATA_SIZE + 1] = { };
64 static char data_sim_set_cf_cphs_fax[MENU_DATA_SIZE + 1] = { };
65 static char data_sim_set_cf_cphs_data[MENU_DATA_SIZE + 1] = { };
67 static char data_sim_set_mw_b_cphs[MENU_DATA_SIZE + 1] = { };
68 static char data_sim_set_mw_rec_index[MENU_DATA_SIZE + 1] = { };
69 static char data_sim_set_mw_indicator_status[MENU_DATA_SIZE + 1] = { };
70 static char data_sim_set_mw_voice_cnt[MENU_DATA_SIZE + 1] = { };
71 static char data_sim_set_mw_fax_cnt[MENU_DATA_SIZE + 1] = { };
72 static char data_sim_set_mw_email_cnt[MENU_DATA_SIZE + 1] = { };
73 static char data_sim_set_mw_other_cnt[MENU_DATA_SIZE + 1] = { };
74 static char data_sim_set_mw_video_cnt[MENU_DATA_SIZE + 1] = { };
75 static char data_sim_set_mw_cphs_voice1[MENU_DATA_SIZE + 1] = { };
76 static char data_sim_set_mw_cphs_voice2[MENU_DATA_SIZE + 1] = { };
77 static char data_sim_set_mw_cphs_fax[MENU_DATA_SIZE + 1] = { };
78 static char data_sim_set_mw_cphs_data[MENU_DATA_SIZE + 1] = { };
80 static char data_sim_set_mb_b_cphs[MENU_DATA_SIZE + 1] = { };
81 static char data_sim_set_mb_type[MENU_DATA_SIZE + 1] = { };
82 static char data_sim_set_mb_rec_index[MENU_DATA_SIZE + 1] = { };
83 static char data_sim_set_mb_profile_num[MENU_DATA_SIZE + 1] = { };
84 static char data_sim_set_mb_alpha_id_max_len[MENU_DATA_SIZE + 1] = { };
85 static char data_sim_set_mb_alpha_id[MENU_DATA_SIZE + 1] = { };
86 static char data_sim_set_mb_ton[MENU_DATA_SIZE + 1] = { };
87 static char data_sim_set_mb_npi[MENU_DATA_SIZE + 1] = { };
88 static char data_sim_set_mb_number[MENU_DATA_SIZE + 1] = { };
89 static char data_sim_set_mb_cc_id[MENU_DATA_SIZE + 1] = { };
90 static char data_sim_set_mb_ext1_id[MENU_DATA_SIZE + 1] = { };
92 static char data_sim_req_authentication_type[MENU_DATA_SIZE + 1] = { 0x01, }; //SIM_AUTH_TYPE_GSM
93 static char data_sim_req_authentication_autn_data[MENU_DATA_SIZE + 1] = { 200,
94 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
96 static char data_sim_req_authentication_rand_data[MENU_DATA_SIZE + 1] = { 200,
97 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
100 static char data_sim_verify_pins_type[MENU_DATA_SIZE + 1] = "0";
101 static char data_sim_verify_pins_pw[MENU_DATA_SIZE + 1] = { };
103 static char data_sim_verify_puks_type[MENU_DATA_SIZE + 1] = "2";
104 static char data_sim_verify_puks_puk[MENU_DATA_SIZE + 1] = { };
105 static char data_sim_verify_puks_pin[MENU_DATA_SIZE + 1] = { };
107 static char data_sim_change_pins_type[MENU_DATA_SIZE + 1] = "0";
108 static char data_sim_change_pins_old_pw[MENU_DATA_SIZE + 1] = "";
109 static char data_sim_change_pins_new_pw[MENU_DATA_SIZE + 1] = "";
111 static char data_sim_disable_facility_type[MENU_DATA_SIZE + 1] = "1";
112 static char data_sim_disable_facility_pw[MENU_DATA_SIZE + 1] = { };
114 static char data_sim_enable_facility_type[MENU_DATA_SIZE + 1] = { };
115 static char data_sim_enable_facility_pw[MENU_DATA_SIZE + 1] = { };
117 static char data_sim_get_facility_type[MENU_DATA_SIZE + 1] = "1";
119 static char data_sim_get_lock_type[MENU_DATA_SIZE + 1] = "1";
121 static char data_sim_transmit_apdu_apdu[MENU_DATA_SIZE + 1] = "0070000000";
123 static char data_sim_op_type[MENU_DATA_SIZE + 1] = "1";
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 int run_sim_get_init_info (MManager *mm, struct menu_data *menu)
149 TapiHandle *handle = menu_manager_ref_user_data (mm);
151 TelSimCardStatus_t o_status = 0;
152 gboolean o_new = FALSE;
154 msg("call [%s] tapi service !!!", menu->title);
156 rt = tel_get_sim_init_info (handle, &o_status, &o_new);
159 msg("status[%d]", o_status);
160 msg("new_sim[%d]", o_new);
164 static int run_sim_get_card_type (MManager *mm, struct menu_data *menu)
166 TapiHandle *handle = menu_manager_ref_user_data (mm);
168 TelSimCardType_t o_type = 0;
170 msg("call [%s] tapi service !!!", menu->title);
172 rt = tel_get_sim_type (handle, &o_type);
175 msg("card type[%d]", o_type);
179 static int run_sim_get_imsi (MManager *mm, struct menu_data *menu)
181 TapiHandle *handle = menu_manager_ref_user_data (mm);
183 TelSimImsiInfo_t imsi;
184 memset (&imsi, 0, sizeof(TelSimImsiInfo_t));
186 msg("call [%s] tapi service !!!", menu->title);
188 rt = tel_get_sim_imsi (handle, &imsi);
191 msg("mcc[%s]", imsi.szMcc);
192 msg("mnc[%s]", imsi.szMnc);
193 msg("msin[%s]", imsi.szMsin);
197 static int run_sim_get_ecc (MManager *mm, struct menu_data *menu)
199 TapiHandle *handle = menu_manager_ref_user_data (mm);
201 TelSimEccList_t ecc_list;
203 memset (&ecc_list, 0, sizeof(TelSimEccList_t));
205 msg("call [%s] tapi service !!!", menu->title);
207 rt = tel_get_sim_ecc (handle, &ecc_list);
210 msg("ecc_list.ecc_count[%d]", ecc_list.ecc_count);
212 for (i = 0; i < ecc_list.ecc_count; i++) {
213 msg("ecc_list.list[%d].name[%s]", i, ecc_list.list[i].name);
214 msg("ecc_list.list[%d].number[%s]", i, ecc_list.list[i].number);
215 msg("ecc_list.list[%d].category[%d]", i, ecc_list.list[i].category);
220 static void on_sim_get_iccid (TapiHandle *handle, int result, void *data,
223 TelSimAccessResult_t access_rt = result;
224 TelSimIccIdInfo_t *iccid = data;
226 msg("TAPI_SERVICE_SIM_GET_ICCID response received");
228 CHECK_ACCESS_RT(access_rt);
230 msg("access_rt[%d]", access_rt);
231 msg("iccid length[%d]", iccid->icc_length);
232 msg("iccid[%s]", iccid->icc_num);
235 static int run_sim_get_iccid (MManager *mm, struct menu_data *menu)
237 TapiHandle *handle = menu_manager_ref_user_data (mm);
240 msg("call [%s] tapi service !!!", menu->title);
242 rt = tel_get_sim_iccid (handle, on_sim_get_iccid, NULL );
247 static void on_sim_get_language (TapiHandle *handle, int result, void *data,
250 TelSimLanguagePreferenceCode_t *language = data;
251 TelSimAccessResult_t access_rt = result;
253 msg("TAPI_SERVICE_SIM_GET_LANGUAGE response received");
255 CHECK_ACCESS_RT(access_rt);
257 msg("access rt[%d]", access_rt);
258 msg("language[%d]", *language);
261 static int run_sim_get_language (MManager *mm, struct menu_data *menu)
263 TapiHandle *handle = menu_manager_ref_user_data (mm);
266 msg("call [%s] tapi service !!!", menu->title);
268 rt = tel_get_sim_language (handle, on_sim_get_language, NULL );
273 static void on_sim_set_language (TapiHandle *handle, int result, void *data,
276 TelSimAccessResult_t access_rt = result;
278 msg("TAPI_SERVICE_SIM_SET_LANGUAGE response received");
280 CHECK_ACCESS_RT(access_rt);
282 msg("access_rt[%d]", access_rt);
285 static int run_sim_set_language (MManager *mm, struct menu_data *menu)
287 TapiHandle *handle = menu_manager_ref_user_data (mm);
290 msg("call [%s] tapi service !!!", menu->title);
291 data_sim_set_language[0] = data_sim_set_language[0] - '0';
292 rt = tel_set_sim_language (handle, data_sim_set_language[0],
293 on_sim_set_language, NULL );
298 static void on_sim_get_cf (TapiHandle *handle, int result, void *data,
301 TelSimAccessResult_t access_rt = result;
302 TelSimCallForwardingResp_t *cf = data;
304 msg("TAPI_SERVICE_SIM_GET_CF response received");
306 CHECK_ACCESS_RT(access_rt);
308 msg("access_rt[%d]", access_rt);
309 msg("cf->b_cphs[%d]", cf->b_cphs);
312 msg("cf->cphs_cf.b_line1[%d]", cf->cphs_cf.b_line1);
313 msg("cf->cphs_cf.b_line2[%d]", cf->cphs_cf.b_line2);
314 msg("cf->cphs_cf.b_fax[%d]", cf->cphs_cf.b_fax);
315 msg("cf->cphs_cf.b_data[%d]", cf->cphs_cf.b_data);
318 for (i = 0; i < cf->cf_list.profile_count; i++) {
319 msg("cf->cf_list.cf[%d].rec_index[%d]", i,
320 cf->cf_list.cf[i].rec_index);
321 msg("cf->cf_list.cf[%d].msp_num[%d]", i, cf->cf_list.cf[i].msp_num);
322 msg("cf->cf_list.cf[%d].cfu_status[0x%x]", i,
323 cf->cf_list.cf[i].cfu_status);
324 msg("cf->cf_list.cf[%d].cfu_num[%s]", i, cf->cf_list.cf[i].cfu_num);
325 msg("cf->cf_list.cf[%d].ton[%d]", i, cf->cf_list.cf[i].ton);
326 msg("cf->cf_list.cf[%d].npi[%d]", i, cf->cf_list.cf[i].npi);
327 msg("cf->cf_list.cf[%d].cc2_id[0x%x]", i, cf->cf_list.cf[i].cc2_id);
328 msg("cf->cf_list.cf[%d].ext7_id[0x%x]", i,
329 cf->cf_list.cf[i].ext7_id);
334 static int run_sim_get_cf (MManager *mm, struct menu_data *menu)
336 TapiHandle *handle = menu_manager_ref_user_data (mm);
339 msg("call [%s] tapi service !!!", menu->title);
340 rt = tel_get_sim_callforwarding_info (handle, on_sim_get_cf, NULL );
345 static void on_sim_set_cf (TapiHandle *handle, int result, void *data,
348 TelSimAccessResult_t access_rt = result;
350 msg("response received");
352 CHECK_ACCESS_RT(access_rt);
354 msg("access_rt[%d]", access_rt);
357 static int run_sim_set_cf (MManager *mm, struct menu_data *menu)
359 TapiHandle *handle = menu_manager_ref_user_data (mm);
361 TelSimCallForwardingReq_t cf;
362 memset (&cf, 0, sizeof(TelSimCallForwardingReq_t));
364 msg("call [%s] tapi service !!!", menu->title);
366 cf.b_cphs = data_sim_set_cf_b_cphs[0] - '0';
368 cf.cf_data_u.cphs_cf.b_line1 = data_sim_set_cf_cphs_line1[0] - '0';
369 cf.cf_data_u.cphs_cf.b_line2 = data_sim_set_cf_cphs_line2[0] - '0';
370 cf.cf_data_u.cphs_cf.b_fax = data_sim_set_cf_cphs_fax[0] - '0';
371 cf.cf_data_u.cphs_cf.b_data = data_sim_set_cf_cphs_data[0] - '0';
374 cf.cf_data_u.cf.rec_index = data_sim_set_cf_rec_index[0] - '0';
375 cf.cf_data_u.cf.msp_num = data_sim_set_cf_msp_num[0] - '0';
376 cf.cf_data_u.cf.cfu_status = data_sim_set_cf_cfu_status[0] - '0';
377 cf.cf_data_u.cf.ton = data_sim_set_cf_ton[0] - '0';
378 cf.cf_data_u.cf.npi = data_sim_set_cf_npi[0] - '0';
379 memcpy (&cf.cf_data_u.cf.cfu_num, data_sim_set_cf_number,
380 sizeof (cf.cf_data_u.cf.cfu_num));
381 cf.cf_data_u.cf.cc2_id = data_sim_set_cf_cc2_id[0] - '0';
382 cf.cf_data_u.cf.ext7_id = data_sim_set_cf_ext7_id[0] - '0';
385 rt = tel_set_sim_callforwarding_info (handle, &cf, on_sim_set_cf, NULL );
390 static void on_sim_get_mw (TapiHandle *handle, int result, void *data,
393 TelSimAccessResult_t access_rt = result;
394 TelSimMessageWaitingResp_t *mw = data;
397 msg("TAPI_SERVICE_SIM_GET_MW response received");
399 CHECK_ACCESS_RT(access_rt);
401 msg("access_rt[%d]", access_rt);
402 msg("mw->b_cphs[%d]", mw->b_cphs);
405 msg("mw->cphs_mw.b_voice1[%d]", mw->cphs_mw.b_voice1);
406 msg("mw->cphs_mw.b_voice2[%d]", mw->cphs_mw.b_voice2);
407 msg("mw->cphs_mw.b_fax[%d]", mw->cphs_mw.b_fax);
408 msg("mw->cphs_mw.b_data[%d]", mw->cphs_mw.b_data);
411 for (i = 0; i < mw->mw_list.profile_count; i++) {
412 msg("mw->mw_list.mw[%d].rec_index[%d]", i,
413 mw->mw_list.mw[i].rec_index);
414 msg("mw->mw_list.mw[%d].indicator_status[0x%x]", i,
415 mw->mw_list.mw[i].indicator_status);
416 msg("mw->mw_list.mw[%d].voice_count[%d]", i,
417 mw->mw_list.mw[i].voice_count);
418 msg("mw->mw_list.mw[%d].fax_count[%d]", i,
419 mw->mw_list.mw[i].fax_count);
420 msg("mw->mw_list.mw[%d].email_count[%d]", i,
421 mw->mw_list.mw[i].email_count);
422 msg("mw->mw_list.mw[%d].other_count[%d]", i,
423 mw->mw_list.mw[i].other_count);
424 msg("mw->mw_list.mw[%d].video_count[%d]", i,
425 mw->mw_list.mw[i].video_count);
430 static int run_sim_get_mw (MManager *mm, struct menu_data *menu)
432 TapiHandle *handle = menu_manager_ref_user_data (mm);
435 msg("call [%s] tapi service !!!", menu->title);
436 rt = tel_get_sim_messagewaiting_info (handle, on_sim_get_mw, NULL );
441 static void on_sim_set_mw (TapiHandle *handle, int result, void *data,
444 TelSimAccessResult_t access_rt = result;
446 msg("response received");
448 CHECK_ACCESS_RT(access_rt);
450 msg("access_rt[%d]", access_rt);
453 static int run_sim_set_mw (MManager *mm, struct menu_data *menu)
455 TapiHandle *handle = menu_manager_ref_user_data (mm);
457 TelSimMessageWaitingReq_t mw;
459 memset (&mw, 0, sizeof(TelSimMessageWaitingReq_t));
461 msg("call [%s] tapi service !!!", menu->title);
463 mw.b_cphs = data_sim_set_mw_b_cphs[0] - '0';
466 mw.mw_data_u.cphs_mw.b_voice1 = data_sim_set_mw_cphs_voice1[0] - '0';
467 mw.mw_data_u.cphs_mw.b_voice2 = data_sim_set_mw_cphs_voice2[0] - '0';
468 mw.mw_data_u.cphs_mw.b_fax = data_sim_set_mw_cphs_fax[0] - '0';
469 mw.mw_data_u.cphs_mw.b_data = data_sim_set_mw_cphs_data[0] - '0';
472 mw.mw_data_u.mw.rec_index = data_sim_set_mw_rec_index[0] - '0';
473 mw.mw_data_u.mw.indicator_status = data_sim_set_mw_indicator_status[0]
475 mw.mw_data_u.mw.voice_count = data_sim_set_mw_voice_cnt[0] - '0';
476 mw.mw_data_u.mw.fax_count = data_sim_set_mw_fax_cnt[0] - '0';
477 mw.mw_data_u.mw.email_count = data_sim_set_mw_email_cnt[0] - '0';
478 mw.mw_data_u.mw.other_count = data_sim_set_mw_other_cnt[0] - '0';
479 mw.mw_data_u.mw.video_count = data_sim_set_mw_video_cnt[0] - '0';
482 rt = tel_set_sim_messagewaiting_info (handle, &mw, on_sim_set_mw, NULL );
487 static void on_sim_get_mb (TapiHandle *handle, int result, void *data,
490 TelSimAccessResult_t access_rt = result;
491 TelSimMailboxList_t *list = data;
494 msg("TAPI_SERVICE_SIM_GET_MB response received");
496 CHECK_ACCESS_RT(access_rt);
498 msg("access_rt[%d]", access_rt);
499 msg("count[%d]", list->count);
501 for (i = 0; i < list->count; i++) {
502 msg("list->list[%d].b_cphs[%d]", i, list->list[i].b_cphs);
503 msg("list->list[%d].rec_index[%d]", i, list->list[i].rec_index);
504 msg("list->list[%d].profile_num[%d]", i, list->list[i].profile_num);
505 msg("list->list[%d].mb_type[%d]", i, list->list[i].mb_type);
506 msg("list->list[%d].alpha_id_max_len[%d]", i,
507 list->list[i].alpha_id_max_len);
508 msg("list->list[%d].alpha_id[%s]", i, list->list[i].alpha_id);
509 msg("list->list[%d].ton[0x%x]", i, list->list[i].ton);
510 msg("list->list[%d].npi[0x%x]", i, list->list[i].npi);
511 msg("list->list[%d].num[%s]", i, list->list[i].num);
512 msg("list->list[%d].cc_id[0x%x]", i, list->list[i].cc_id);
513 msg("list->list[%d].ext1_id[0x%x]", i, list->list[i].ext1_id);
517 static int run_sim_get_mb (MManager *mm, struct menu_data *menu)
519 TapiHandle *handle = menu_manager_ref_user_data (mm);
522 msg("call [%s] tapi service !!!", menu->title);
523 rt = tel_get_sim_mailbox_info (handle, on_sim_get_mb, NULL );
528 static void on_sim_set_mb (TapiHandle *handle, int result, void *data,
531 TelSimAccessResult_t access_rt = result;
533 msg("response received");
535 CHECK_ACCESS_RT(access_rt);
537 msg("access_rt[%d]", access_rt);
540 static int run_sim_set_mb (MManager *mm, struct menu_data *menu)
542 TapiHandle *handle = menu_manager_ref_user_data (mm);
544 TelSimMailBoxNumber_t mb;
546 msg("call [%s] tapi service !!!", menu->title);
548 memset (&mb, 0, sizeof(TelSimMailBoxNumber_t));
550 mb.b_cphs = data_sim_set_mb_b_cphs[0] - '0';
551 mb.mb_type = data_sim_set_mb_type[0] - '0';
552 mb.rec_index = data_sim_set_mb_rec_index[0] - '0';
553 mb.profile_num = data_sim_set_mb_profile_num[0] - '0';
554 mb.alpha_id_max_len = data_sim_set_mb_alpha_id_max_len[0] - '0';
555 memcpy (&mb.alpha_id, data_sim_set_mb_alpha_id,
556 TAPI_SIM_XDN_ALPHA_ID_MAX_LEN);
557 mb.ton = data_sim_set_mb_ton[0] - '0';
558 mb.npi = data_sim_set_mb_npi[0] - '0';
559 memcpy (&mb.num, data_sim_set_mb_number, sizeof (mb.num));
560 mb.cc_id = data_sim_set_mb_cc_id[0] - '0';
561 mb.ext1_id = data_sim_set_mb_ext1_id[0] - '0';
563 rt = tel_set_sim_mailbox_info (handle, &mb, on_sim_set_mb, NULL );
568 static void on_sim_get_cphs_info (TapiHandle *handle, int result, void *data,
571 TelSimAccessResult_t access_rt = result;
572 TelSimCphsInfo_t *cphs = data;
574 msg("TAPI_SERVICE_SIM_GET_CPHSINFO response received");
576 CHECK_ACCESS_RT(access_rt);
578 msg("access_rt[%d]", access_rt);
579 msg("cphs->CphsPhase[%d]", cphs->CphsPhase);
580 msg("cphs->CphsServiceTable.bOperatorNameShortForm[%d]",
581 cphs->CphsServiceTable.bOperatorNameShortForm);
582 msg("cphs->CphsServiceTable.bMailBoxNumbers[%d]",
583 cphs->CphsServiceTable.bMailBoxNumbers);
584 msg("cphs->CphsServiceTable.bServiceStringTable[%d]",
585 cphs->CphsServiceTable.bServiceStringTable);
586 msg("cphs->CphsServiceTable.bCustomerServiceProfile[%d]",
587 cphs->CphsServiceTable.bCustomerServiceProfile);
588 msg("cphs->CphsServiceTable.bInformationNumbers[%d]",
589 cphs->CphsServiceTable.bInformationNumbers);
592 static void on_sim_get_service_table (TapiHandle *handle, int result,
593 void *data, void *user_data)
595 TelSimAccessResult_t access_rt = result;
596 TelSimServiceTable_t *svct = (TelSimServiceTable_t *) data;
598 msg("TAPI_SERVICE_SIM_GET_SERVICE_TABLE response received");
600 CHECK_ACCESS_RT(access_rt);
602 msg("access_rt[%d]", access_rt);
604 if (svct->sim_type == TAPI_SIM_CARD_TYPE_GSM) {
605 int i = 0, size = sizeof(TelSimSST_t);
607 if ( (temp = (char *) calloc (size + 1, 1)) != NULL ) {
608 memcpy (temp, &svct->table.sst, size);
609 for (i = 0; i < size; i++) {
615 msg("svct->table.sst=[%s]", temp);
619 else if (svct->sim_type == TAPI_SIM_CARD_TYPE_USIM) {
620 int i = 0, size = sizeof(TelSimUST_t);
622 if ( (temp = (char *) calloc (size + 1, 1)) != NULL ) {
623 memcpy (temp, &svct->table.ust, size);
624 for (i = 0; i < size; i++) {
630 msg("svct->table.ust=[%s]", temp);
635 msg("Unknown sim type");
639 static int run_sim_get_cphs_info (MManager *mm, struct menu_data *menu)
641 TapiHandle *handle = menu_manager_ref_user_data (mm);
644 msg("call [%s] tapi service !!!", menu->title);
645 rt = tel_get_sim_cphs_info (handle, on_sim_get_cphs_info, NULL );
650 static int run_sim_get_service_table (MManager *mm, struct menu_data *menu)
652 TapiHandle *handle = menu_manager_ref_user_data (mm);
655 msg("call [%s] tapi service !!!", menu->title);
656 rt = tel_get_sim_service_table (handle, on_sim_get_service_table, NULL );
661 static void on_sim_get_msisdn (TapiHandle *handle, int result, void *data,
664 TelSimAccessResult_t access_rt = result;
665 TelSimMsisdnList_t *list = data;
667 msg("TAPI_SERVICE_SIM_GET_MSISDN response received");
669 CHECK_ACCESS_RT(access_rt);
671 msg("access_rt[%d]", access_rt);
673 msg("list->count[%d]", list->count);
675 for (i = 0; i < list->count; i++)
676 msg("index[%d] - name[%s], num[%s]", i, list->list[i].name,
680 static int run_sim_get_msisdn (MManager *mm, struct menu_data *menu)
682 TapiHandle *handle = menu_manager_ref_user_data (mm);
685 msg("call [%s] tapi service !!!", menu->title);
686 rt = tel_get_sim_msisdn (handle, on_sim_get_msisdn, NULL );
691 static void on_sim_get_oplmnwact (TapiHandle *handle, int result, void *data,
694 TelSimAccessResult_t access_rt = result;
695 TelSimOplmnwactList_t *list = data;
698 msg("TAPI_SERVICE_SIM_GET_OPLMNWACT response received");
700 CHECK_ACCESS_RT(access_rt);
702 msg("access_rt[%d]", access_rt);
703 msg("list->count[%d]", list->count);
705 for (i = 0; i < list->count; i++) {
706 msg("index[%d] - plmn[%s], b_umts[%d], b_gsm[%d]", i,
707 list->list[i].plmn, list->list[i].b_umts, list->list[i].b_gsm);
711 static int run_sim_get_oplmnwact (MManager *mm, struct menu_data *menu)
713 TapiHandle *handle = menu_manager_ref_user_data (mm);
716 msg("call [%s] tapi service !!!", menu->title);
717 rt = tel_get_sim_oplmnwact (handle, on_sim_get_oplmnwact, NULL );
722 static void on_sim_get_spn (TapiHandle *handle, int result, void *data,
725 TelSimAccessResult_t access_rt = result;
726 TelSimSpn_t *spn_info = data;
728 msg("TAPI_SERVICE_SIM_GET_SPN response received");
730 CHECK_ACCESS_RT(access_rt);
732 msg("access_rt[%d]", access_rt);
733 msg("spn name[%s]", spn_info->spn);
734 msg("spn condition[0x%x]", spn_info->display_condition);
737 static int run_sim_get_spn (MManager *mm, struct menu_data *menu)
739 TapiHandle *handle = menu_manager_ref_user_data (mm);
742 msg("call [%s] tapi service !!!", menu->title);
743 rt = tel_get_sim_spn (handle, on_sim_get_spn, NULL );
748 static void on_sim_get_cphs_netname (TapiHandle *handle, int result, void *data,
751 TelSimAccessResult_t access_rt = result;
752 TelSimCphsNetName_t *cphs_net = data;
754 msg("TAPI_SERVICE_SIM_GET_CPHS_NETNAME response received");
756 CHECK_ACCESS_RT(access_rt);
758 msg("access_rt[%d]", access_rt);
759 msg("cphs full name[%s]", cphs_net->full_name);
760 msg("cphs short name[%s]", cphs_net->short_name);
763 static int run_sim_get_cphs_netname (MManager *mm, struct menu_data *menu)
765 TapiHandle *handle = menu_manager_ref_user_data (mm);
768 msg("call [%s] tapi service !!!", menu->title);
769 rt = tel_get_sim_cphs_netname (handle, on_sim_get_cphs_netname, NULL );
774 static void on_sim_req_authentication (TapiHandle *handle, int result,
775 void *data, void *user_data)
777 TelSimAccessResult_t access_rt = result;
778 TelSimAuthenticationResponse_t *auth_resp = data;
781 msg("TAPI_SERVICE_SIM_AUTHENTICATION response received");
783 CHECK_ACCESS_RT(access_rt);
785 msg("access_rt[%d]", access_rt);
786 msg("auth_resp->auth_type[%d]", auth_resp->auth_type);
787 msg("auth_resp->auth_result[%d]", auth_resp->auth_result);
789 msg("auth_resp->authentication_key_length[%d]",
790 auth_resp->authentication_key_length);
791 if (auth_resp->authentication_key_length) {
792 for (i = 0; i < auth_resp->authentication_key_length; i++)
793 msg("auth_resp->authentication_key[%d][0x%2x]", i,
794 auth_resp->authentication_key[i]);
797 msg("auth_resp->cipher_length[%d]", auth_resp->cipher_length);
798 if (auth_resp->cipher_length) {
799 for (i = 0; i < auth_resp->cipher_length; i++)
800 msg("auth_resp->cipher_data[%d][0x%2x]", i,
801 auth_resp->cipher_data[i]);
804 msg("auth_resp->integrity_length[%d]", auth_resp->integrity_length);
805 if (auth_resp->integrity_length) {
806 for (i = 0; i < auth_resp->integrity_length; i++)
807 msg("auth_resp->integrity_data[%d][0x%2x]", i,
808 auth_resp->integrity_data[i]);
811 msg("auth_resp->resp_length[%d]", auth_resp->resp_length);
812 if (auth_resp->resp_length) {
813 for (i = 0; i < auth_resp->resp_length; i++)
814 msg("auth_resp->resp_data[%d][0x%2x]", i, auth_resp->resp_data[i]);
819 static int run_sim_req_authentication (MManager *mm, struct menu_data *menu)
821 TapiHandle *handle = menu_manager_ref_user_data (mm);
823 TelSimAuthenticationData_t auth;
824 memset (&auth, 0, sizeof(TelSimAuthenticationData_t));
826 msg("call [%s] tapi service !!!", menu->title);
828 data_sim_req_authentication_type[0] = data_sim_req_authentication_type[0]
831 auth.auth_type = data_sim_req_authentication_type[0];
832 auth.autn_length = strlen (data_sim_req_authentication_autn_data);
833 memcpy (&auth.autn_data, data_sim_req_authentication_autn_data,
835 auth.rand_length = strlen (data_sim_req_authentication_rand_data);
836 memcpy (&auth.rand_data, data_sim_req_authentication_rand_data,
839 rt = tel_req_sim_authentication (handle, &auth, on_sim_req_authentication,
845 static void on_sim_security_op_resp (TapiHandle *handle, int result, void *data,
848 TelSimPinOperationResult_t sec_rt = result;
849 TelSimSecResult_t *rt = data;
851 msg("TAPI_SERVICE_SIM security response received");
853 CHECK_ACCESS_RT(sec_rt);
855 msg("sec_rt[%d]", sec_rt);
856 msg("rt->type[%d]", rt->type);
857 msg("rt->retry_count[%d]", rt->retry_count);
860 static int run_sim_verify_pins (MManager *mm, struct menu_data *menu)
862 TapiHandle *handle = menu_manager_ref_user_data (mm);
865 memset (&pwt, 0, sizeof(TelSimSecPw_t));
867 msg("call [%s] tapi service !!!", menu->title);
869 data_sim_verify_pins_type[0] = data_sim_verify_pins_type[0] - '0';
870 data_sim_verify_pins_pw[MENU_DATA_SIZE] = '\0';
871 pwt.type = data_sim_verify_pins_type[0];
872 pwt.pw_len = strlen (data_sim_verify_pins_pw);
873 pwt.pw = (unsigned char *) data_sim_verify_pins_pw;
875 rt = tel_verifiy_sim_pins (handle, &pwt, on_sim_security_op_resp, NULL );
880 static int run_sim_verify_puks (MManager *mm, struct menu_data *menu)
882 TapiHandle *handle = menu_manager_ref_user_data (mm);
885 TelSimSecPw_t new_pin_t;
886 memset (&puk_t, 0, sizeof(TelSimSecPw_t));
887 memset (&new_pin_t, 0, sizeof(TelSimSecPw_t));
888 msg("call [%s] tapi service !!!", menu->title);
890 data_sim_verify_puks_type[0] = data_sim_verify_puks_type[0] - '0';
891 data_sim_verify_puks_puk[MENU_DATA_SIZE] = '\0';
892 puk_t.type = data_sim_verify_puks_type[0];
893 puk_t.pw_len = strlen (data_sim_verify_puks_puk);
894 puk_t.pw = (unsigned char*) data_sim_verify_puks_puk;
896 if (puk_t.type == TAPI_SIM_PTYPE_PUK1)
897 new_pin_t.type = TAPI_SIM_PTYPE_PIN1;
898 if (puk_t.type == TAPI_SIM_PTYPE_PUK2)
899 new_pin_t.type = TAPI_SIM_PTYPE_PIN2;
901 data_sim_verify_puks_pin[MENU_DATA_SIZE] = '\0';
902 new_pin_t.pw_len = strlen (data_sim_verify_puks_pin);
903 new_pin_t.pw = (unsigned char*) data_sim_verify_puks_pin;
905 rt = tel_verify_sim_puks (handle, &puk_t, &new_pin_t,
906 on_sim_security_op_resp, NULL );
911 static int run_sim_change_pins (MManager *mm, struct menu_data *menu)
913 TapiHandle *handle = menu_manager_ref_user_data (mm);
917 memset (&old, 0, sizeof(TelSimSecPw_t));
918 memset (&new, 0, sizeof(TelSimSecPw_t));
920 msg("call [%s] tapi service !!!", menu->title);
922 data_sim_change_pins_type[0] = data_sim_change_pins_type[0] - '0';
924 data_sim_change_pins_old_pw[MENU_DATA_SIZE] = '\0';
925 old.type = data_sim_change_pins_type[0];
926 old.pw_len = strlen (data_sim_change_pins_old_pw);
927 old.pw = (unsigned char*) data_sim_change_pins_old_pw;
929 data_sim_change_pins_new_pw[MENU_DATA_SIZE] = '\0';
930 new.type = data_sim_change_pins_type[0];
931 new.pw_len = strlen (data_sim_change_pins_new_pw);
932 new.pw = (unsigned char*) data_sim_change_pins_new_pw;
934 rt = tel_change_sim_pins (handle, &old, &new, on_sim_security_op_resp,
940 static void on_sim_facility_op_resp (TapiHandle *handle, int result, void *data,
943 TelSimPinOperationResult_t sec_rt = result;
944 TelSimFacilityResult_t *f_rt = data;
946 msg("TAPI_SERVICE_SIM facility response received");
948 CHECK_ACCESS_RT(sec_rt);
950 msg("sec_rt[%d]", sec_rt);
951 msg("f_rt->type[%d]", f_rt->type);
952 msg("f_rt->retry_count[%d]", f_rt->retry_count);
955 static int run_sim_disable_facility (MManager *mm, struct menu_data *menu)
957 TapiHandle *handle = menu_manager_ref_user_data (mm);
959 TelSimFacilityPw_t fpw;
960 msg("call [%s] tapi service !!!", menu->title);
962 memset (&fpw, 0, sizeof (fpw));
964 data_sim_disable_facility_type[0] = data_sim_disable_facility_type[0] - '0';
965 data_sim_disable_facility_pw[MENU_DATA_SIZE] = '\0';
966 fpw.lock_type = data_sim_disable_facility_type[0];
967 fpw.pw_len = strlen (data_sim_disable_facility_pw);
968 fpw.pw = (unsigned char*) data_sim_disable_facility_pw;
970 msg("fpw.lock_type[%d], fpw.pw_len[%d], fpw.pw[%s]", fpw.lock_type,
972 rt = tel_disable_sim_facility (handle, &fpw, on_sim_facility_op_resp,
978 static int run_sim_enable_facility (MManager *mm, struct menu_data *menu)
980 TapiHandle *handle = menu_manager_ref_user_data (mm);
982 TelSimFacilityPw_t fpw;
983 msg("call [%s] tapi service !!!", menu->title);
985 memset (&fpw, 0, sizeof (fpw));
987 data_sim_enable_facility_type[0] = data_sim_enable_facility_type[0] - '0';
988 data_sim_enable_facility_pw[MENU_DATA_SIZE] = '\0';
989 fpw.lock_type = data_sim_enable_facility_type[0];
990 fpw.pw_len = strlen (data_sim_enable_facility_pw);
991 fpw.pw = (unsigned char*) data_sim_enable_facility_pw;
993 msg("fpw.lock_type[%d], fpw.pw_len[%d], fpw.pw[%s]", fpw.lock_type,
995 rt = tel_enable_sim_facility (handle, &fpw, on_sim_facility_op_resp, NULL );
1000 static void on_sim_get_facility (TapiHandle *handle, int result, void *data,
1003 TelSimPinOperationResult_t sec_rt = result;
1004 TelSimFacilityInfo_t *fi = data;
1006 msg("TAPI_SERVICE_SIM facility response received");
1008 CHECK_ACCESS_RT(sec_rt);
1010 msg("sec_rt[%d]", sec_rt);
1011 msg("fi->type[%d]", fi->type);
1012 msg("fi->f_status[%d]", fi->f_status);
1015 static int run_sim_get_facility (MManager *mm, struct menu_data *menu)
1017 TapiHandle *handle = menu_manager_ref_user_data (mm);
1019 TelSimLockType_t t = 0;
1020 msg("call [%s] tapi service !!!", menu->title);
1022 data_sim_get_facility_type[0] = data_sim_get_facility_type[0] - '0';
1024 switch (data_sim_get_facility_type[0]) {
1026 t = TAPI_SIM_LOCK_PS;
1029 t = TAPI_SIM_LOCK_PF;
1032 t = TAPI_SIM_LOCK_SC;
1035 t = TAPI_SIM_LOCK_FD;
1038 t = TAPI_SIM_LOCK_PN;
1041 t = TAPI_SIM_LOCK_PU;
1044 t = TAPI_SIM_LOCK_PP;
1047 t = TAPI_SIM_LOCK_PC;
1050 msg("not handled type[%d]", data_sim_get_facility_type[0])
1054 rt = tel_get_sim_facility (handle, t, on_sim_get_facility, NULL );
1059 static void on_sim_get_lock_info (TapiHandle *handle, int result, void *data,
1062 TelSimPinOperationResult_t sec_rt = result;
1063 TelSimLockInfo_t *lock = data;
1065 msg("TAPI_SERVICE_SIM lock info response received");
1067 CHECK_ACCESS_RT(sec_rt);
1069 msg("sec_rt[%d]", sec_rt);
1070 msg("lock->lock_type[%d]", lock->lock_type);
1072 "lock->lock_status[%d]-0:not need, 1:pin, 2:puk, 3:pin2, 4:puk2, 5:blocked",
1074 msg("lock->retry_count[%d]", lock->retry_count);
1077 static int run_sim_get_lock_info (MManager *mm, struct menu_data *menu)
1079 TapiHandle *handle = menu_manager_ref_user_data (mm);
1081 TelSimLockType_t t = 0;
1082 msg("call [%s] tapi service !!!", menu->title);
1084 data_sim_get_lock_type[0] = data_sim_get_lock_type[0] - '0';
1086 switch (data_sim_get_lock_type[0]) {
1088 t = TAPI_SIM_LOCK_PS;
1091 t = TAPI_SIM_LOCK_PF;
1094 t = TAPI_SIM_LOCK_SC;
1097 t = TAPI_SIM_LOCK_FD;
1100 t = TAPI_SIM_LOCK_PN;
1103 t = TAPI_SIM_LOCK_PU;
1106 t = TAPI_SIM_LOCK_PP;
1109 t = TAPI_SIM_LOCK_PC;
1112 msg("not handled type[%d]", data_sim_get_lock_type[0])
1116 rt = tel_get_sim_lock_info (handle, t, on_sim_get_lock_info, NULL );
1121 static void on_sim_transmit_apdu (TapiHandle *handle, int result, void *data,
1124 TelSimAccessResult_t access_rt = result;
1125 TelSimApduResp_t *r_apdu = data;
1128 msg("TAPI_SERVICE_SIM_APDU response received");
1130 CHECK_ACCESS_RT(access_rt);
1132 msg("access_rt[%d]", access_rt);
1133 msg("r_apdu->apdu_resp_len[%d]", r_apdu->apdu_resp_len);
1134 if (r_apdu->apdu_resp_len) {
1135 for (i = 0; i < r_apdu->apdu_resp_len; i++)
1136 msg("[%d]`s byte is [0x%x]", i, r_apdu->apdu_resp[i]);
1140 static int run_sim_transmit_apdu (MManager *mm, struct menu_data *menu)
1142 TapiHandle *handle = menu_manager_ref_user_data (mm);
1144 TelSimApdu_t t_apdu;
1145 unsigned char result_apdu[MENU_DATA_SIZE + 1] = { 0, };
1146 int i = 0, j = 0, len = 0, hex = 0;
1148 memset (&t_apdu, 0, sizeof(TelSimApdu_t));
1150 msg("call [%s] tapi service !!!", menu->title);
1152 len = strlen (data_sim_transmit_apdu_apdu);
1154 for (i = 0, j = 0; i < len; i += 2, j++) {
1155 hex = (_sim_str_to_hex (data_sim_transmit_apdu_apdu[i]) << 4)
1156 | (_sim_str_to_hex (data_sim_transmit_apdu_apdu[i + 1]));
1157 printf ("0x%x\n", hex);
1159 result_apdu[j] = hex;
1162 for (i = 0; i < len / 2; i++) {
1163 printf ("[%02d] = 0x%02x\n", i, result_apdu[i]);
1166 t_apdu.apdu_len = len / 2;
1167 t_apdu.apdu = (unsigned char*) malloc (t_apdu.apdu_len);
1168 memcpy (t_apdu.apdu, result_apdu, t_apdu.apdu_len);
1170 rt = tel_req_sim_apdu (handle, &t_apdu, on_sim_transmit_apdu, NULL );
1177 static void on_sim_get_atr (TapiHandle *handle, int result, void *data,
1180 TelSimAccessResult_t access_rt = result;
1181 TelSimAtrResp_t *r_atr = data;
1183 msg("TAPI_SERVICE_SIM_APDU response received");
1185 CHECK_ACCESS_RT(access_rt);
1187 msg("access_rt[%d]", access_rt);
1188 msg("r_atr->atr_resp_len[%d]", r_atr->atr_resp_len);
1189 if (r_atr->atr_resp_len) {
1190 for (i = 0; i < r_atr->atr_resp_len; i++)
1191 msg("[%d]`s byte is [0x%x]", i, r_atr->atr_resp[i]);
1195 static int run_sim_get_atr(MManager *mm, struct menu_data *menu)
1197 TapiHandle *handle = menu_manager_ref_user_data(mm);
1200 msg("call [%s] tapi service !!!", menu->title);
1202 rt = tel_req_sim_atr(handle, on_sim_get_atr, NULL);
1207 static int run_sim_request_sync (MManager *mm, struct menu_data *menu)
1209 TapiHandle *handle = menu_manager_ref_user_data (mm);
1211 TelSimResponseData_t outparam;
1212 TelSimRequestData_t inparam;
1214 unsigned char op = 0;
1216 memset (&outparam, 0, sizeof(TelSimResponseData_t));
1217 memset (&inparam, 0, sizeof(TelSimRequestData_t));
1219 msg("call [%s] tapi service !!!", menu->title);
1221 if (strlen(data_sim_op_type) == 1) {
1222 op = data_sim_op_type[0] - '0';
1224 op = ((data_sim_op_type[0] - '0') * 10) + (data_sim_op_type[1] - '0');
1226 msg("op = [%d]\n", op);
1229 case TAPI_SIM_GET_IMSI:
1230 rt = tel_request_sim_sync(handle, op, NULL, &outparam);
1231 msg("mcc[%s]", outparam.imsi_info.szMcc);
1232 msg("mnc[%s]", outparam.imsi_info.szMnc);
1233 msg("msin[%s]", outparam.imsi_info.szMsin);
1235 case TAPI_SIM_GET_ICCID:
1236 rt = tel_request_sim_sync(handle, op, NULL, &outparam);
1237 msg("iccid length[%d]", outparam.iccid_info.icc_length);
1238 msg("iccid[%s]", outparam.iccid_info.icc_num);
1240 case TAPI_SIM_GET_INIT_STATUS:
1241 rt = tel_request_sim_sync(handle, op, NULL, &outparam);
1242 msg("status[%d]", outparam.init_info.card_status);
1243 msg("new_sim[%d]", outparam.init_info.b_is_changed);
1245 case TAPI_SIM_GET_MSISDN:
1246 rt = tel_request_sim_sync(handle, op, NULL, &outparam);
1247 msg("list->count[%d]", outparam.msisdn_list.count);
1248 for (i = 0; i < outparam.msisdn_list.count; i++)
1249 msg("index[%d] - name[%s], num[%s]", i, outparam.msisdn_list.list[i].name,
1250 outparam.msisdn_list.list[i].num);
1252 case TAPI_SIM_GET_SPN:
1253 rt = tel_request_sim_sync(handle, op, NULL, &outparam);
1254 msg("spn name[%s]", outparam.spn.spn);
1255 msg("spn condition[0x%x]", outparam.spn.display_condition);
1257 case TAPI_SIM_GET_CPHS_NET_NAME:
1258 rt = tel_request_sim_sync(handle, op, NULL, &outparam);
1259 msg("cphs full name[%s]", outparam.cphs_netname.full_name);
1260 msg("cphs short name[%s]", outparam.cphs_netname.short_name);
1262 case TAPI_SIM_TRANSFER_APDU: {
1263 unsigned char result_apdu[MENU_DATA_SIZE + 1] = { 0, };
1264 int i = 0, j = 0, len = 0, hex = 0;
1265 len = strlen (data_sim_transmit_apdu_apdu);
1266 for (i = 0, j = 0; i < len; i += 2, j++) {
1267 hex = (_sim_str_to_hex (data_sim_transmit_apdu_apdu[i]) << 4)
1268 | (_sim_str_to_hex (data_sim_transmit_apdu_apdu[i + 1]));
1269 printf ("0x%x\n", hex);
1271 result_apdu[j] = hex;
1273 for (i = 0; i < len / 2; i++) {
1274 printf ("[%02d] = 0x%02x\n", i, result_apdu[i]);
1276 inparam.apdu.apdu_len = len / 2;
1277 inparam.apdu.apdu = (unsigned char*) calloc (inparam.apdu.apdu_len, 1);
1278 if(inparam.apdu.apdu != NULL) {
1279 memcpy (inparam.apdu.apdu, result_apdu, inparam.apdu.apdu_len);
1280 rt = tel_request_sim_sync(handle, op, &inparam, &outparam);
1281 free(inparam.apdu.apdu);
1283 msg("Memory allocation failed");
1286 msg("outparam.apdu_resp.apdu_resp_len[%d]", outparam.apdu_resp.apdu_resp_len);
1287 if (outparam.apdu_resp.apdu_resp_len) {
1288 for (i = 0; i < outparam.apdu_resp.apdu_resp_len; i++)
1289 msg("[%d]`s byte is [0x%x]", i, outparam.apdu_resp.apdu_resp[i]);
1293 case TAPI_SIM_GET_ATR:
1294 rt = tel_request_sim_sync(handle, op, NULL, &outparam);
1295 msg("r_atr->atr_resp_len[%d]", outparam.atr_resp.atr_resp_len);
1296 if (outparam.atr_resp.atr_resp_len) {
1297 for (i = 0; i < outparam.atr_resp.atr_resp_len; i++)
1298 msg("[%d]`s byte is [0x%x]", i, outparam.atr_resp.atr_resp[i]);
1311 static void on_sim_request_async (TapiHandle *handle, int result, void *data,
1314 TelSimAccessResult_t access_rt = result;
1315 TelSimResponseData_t *resp = data;
1316 TelSimTapiOperation_t *op = user_data;
1319 msg("tel_sim_request_async() response received");
1320 msg("access_rt[%d]", access_rt);
1321 CHECK_ACCESS_RT(access_rt);
1327 case TAPI_SIM_GET_INIT_STATUS:
1328 msg("status[%d]", resp->init_info.card_status);
1329 msg("new_sim[%d]", resp->init_info.b_is_changed);
1331 case TAPI_SIM_GET_IMSI:
1332 msg("mcc[%s]", resp->imsi_info.szMcc);
1333 msg("mnc[%s]", resp->imsi_info.szMnc);
1334 msg("msin[%s]", resp->imsi_info.szMsin);
1336 case TAPI_SIM_GET_ICCID:
1337 msg("iccid length[%d]", resp->iccid_info.icc_length);
1338 msg("iccid[%s]", resp->iccid_info.icc_num);
1340 case TAPI_SIM_GET_MSISDN:
1341 msg("list->count[%d]", resp->msisdn_list.count);
1342 for (i = 0; i < resp->msisdn_list.count; i++)
1343 msg("index[%d] - name[%s], num[%s]", i, resp->msisdn_list.list[i].name,
1344 resp->msisdn_list.list[i].num);
1346 case TAPI_SIM_GET_SPN:
1347 msg("spn name[%s]", resp->spn.spn);
1348 msg("spn condition[0x%x]", resp->spn.display_condition);
1350 case TAPI_SIM_GET_CPHS_NET_NAME:
1351 msg("cphs full name[%s]", resp->cphs_netname.full_name);
1352 msg("cphs short name[%s]", resp->cphs_netname.short_name);
1354 case TAPI_SIM_TRANSFER_APDU: {
1355 msg("outparam.apdu_resp.apdu_resp_len[%d]", resp->apdu_resp.apdu_resp_len);
1356 if (resp->apdu_resp.apdu_resp_len) {
1357 for (i = 0; i < resp->apdu_resp.apdu_resp_len; i++)
1358 msg("[%d]`s byte is [0x%x]", i, resp->apdu_resp.apdu_resp[i]);
1362 case TAPI_SIM_GET_ATR:
1363 msg("atr_resp_len[%d]", resp->atr_resp.atr_resp_len);
1364 if (resp->atr_resp.atr_resp_len) {
1365 for (i = 0; i < resp->atr_resp.atr_resp_len; i++)
1366 msg("[%d]`s byte is [0x%x]", i, resp->atr_resp.atr_resp[i]);
1378 static int run_sim_request_async (MManager *mm, struct menu_data *menu)
1380 TapiHandle *handle = menu_manager_ref_user_data (mm);
1382 TelSimResponseData_t outparam;
1383 TelSimRequestData_t inparam;
1384 unsigned char *op = NULL;
1386 memset (&outparam, 0, sizeof(TelSimResponseData_t));
1387 memset (&inparam, 0, sizeof(TelSimRequestData_t));
1388 op = (unsigned char*)malloc(1);
1392 msg("call [%s] tapi service !!!", menu->title);
1394 if (strlen(data_sim_op_type) == 1) {
1395 *op = data_sim_op_type[0] - '0';
1397 *op = ((data_sim_op_type[0] - '0') * 10) + (data_sim_op_type[1] - '0');
1399 msg("op = [%d]\n", *op);
1402 case TAPI_SIM_GET_INIT_STATUS:
1403 case TAPI_SIM_GET_IMSI:
1404 case TAPI_SIM_GET_ICCID:
1405 case TAPI_SIM_GET_MSISDN:
1406 case TAPI_SIM_GET_SPN:
1407 case TAPI_SIM_GET_CPHS_NET_NAME:
1408 case TAPI_SIM_GET_ATR:
1409 rt = tel_request_sim_async(handle, *op, NULL, on_sim_request_async, op);
1411 case TAPI_SIM_TRANSFER_APDU: {
1412 unsigned char result_apdu[MENU_DATA_SIZE + 1] = { 0, };
1413 int i = 0, j = 0, len = 0, hex = 0;
1414 len = strlen (data_sim_transmit_apdu_apdu);
1415 for (i = 0, j = 0; i < len; i += 2, j++) {
1416 hex = (_sim_str_to_hex (data_sim_transmit_apdu_apdu[i]) << 4)
1417 | (_sim_str_to_hex (data_sim_transmit_apdu_apdu[i + 1]));
1418 printf ("0x%x\n", hex);
1420 result_apdu[j] = hex;
1422 for (i = 0; i < len / 2; i++) {
1423 printf ("[%02d] = 0x%02x\n", i, result_apdu[i]);
1425 inparam.apdu.apdu_len = len / 2;
1426 inparam.apdu.apdu = (unsigned char*) calloc (inparam.apdu.apdu_len, 1);
1427 if(inparam.apdu.apdu != NULL) {
1428 memcpy (inparam.apdu.apdu, result_apdu, inparam.apdu.apdu_len);
1429 rt = tel_request_sim_async(handle, *op, &inparam, on_sim_request_async, op);
1430 free(inparam.apdu.apdu);
1432 msg("Memory allocation failed");
1436 msg(" default case called !!!");
1447 static struct menu_data menu_sim_get_init_info[] = {
1448 { "1", "run", NULL, run_sim_get_init_info, NULL},
1452 static struct menu_data menu_sim_get_card_type[] = {
1453 { "1", "run", NULL, run_sim_get_card_type, NULL},
1457 static struct menu_data menu_sim_get_imsi[] = {
1458 { "1", "run", NULL, run_sim_get_imsi, NULL},
1462 static struct menu_data menu_sim_get_ecc[] = {
1463 { "1", "run", NULL, run_sim_get_ecc, NULL},
1467 static struct menu_data menu_sim_get_iccid[] = {
1468 { "1", "run", NULL, run_sim_get_iccid, NULL},
1472 static struct menu_data menu_sim_get_language[] = {
1473 {"1", "run", NULL, run_sim_get_language, NULL},
1477 static struct menu_data menu_sim_set_language[] = {
1478 {"1", "select language", NULL, NULL, (char*)data_sim_set_language},
1479 {"2", "run", NULL, run_sim_set_language, NULL},
1483 static struct menu_data menu_sim_get_cf[] = {
1484 {"1", "run", NULL, run_sim_get_cf, NULL},
1488 static struct menu_data menu_sim_set_cf[] = {
1489 {"1", "b_cphs no/yes => 0/1", NULL, NULL, data_sim_set_cf_b_cphs},
1490 {"2", "rec_index int", NULL, NULL, data_sim_set_cf_rec_index},
1491 {"3", "msp_num int", NULL, NULL, data_sim_set_cf_msp_num},
1492 {"4", "cfu_status int", NULL, NULL, data_sim_set_cf_cfu_status},
1493 {"5", "ton int", NULL, NULL, data_sim_set_cf_ton},
1494 {"6", "npi int", NULL, NULL, data_sim_set_cf_npi},
1495 {"7", "number string", NULL, NULL, data_sim_set_cf_number},
1496 {"8", "cc2_id int", NULL, NULL, data_sim_set_cf_cc2_id},
1497 {"9", "ext7_id int", NULL, NULL, data_sim_set_cf_ext7_id},
1498 {"10", "cphs_line1 no/yes => 0/1", NULL, NULL, data_sim_set_cf_cphs_line1},
1499 {"11", "cphs_line2 no/yes => 0/1", NULL, NULL, data_sim_set_cf_cphs_line2},
1500 {"12", "cphs_fax no/yes => 0/1", NULL, NULL, data_sim_set_cf_cphs_fax},
1501 {"13", "cphs_data no/yes => 0/1", NULL, NULL, data_sim_set_cf_cphs_data},
1502 {"14", "run", NULL, run_sim_set_cf, NULL},
1506 static struct menu_data menu_sim_get_mw[] = {
1507 {"1", "run", NULL, run_sim_get_mw, NULL},
1511 static struct menu_data menu_sim_set_mw[] = {
1512 {"1", "b_cphs no/yes => 0/1", NULL, NULL, data_sim_set_mw_b_cphs},
1513 {"2", "rec_index int", NULL, NULL, data_sim_set_mw_rec_index},
1514 {"3", "indicator_status int", NULL, NULL, data_sim_set_mw_indicator_status},
1515 {"4", "voice_cnt int", NULL, NULL, data_sim_set_mw_voice_cnt},
1516 {"5", "fax_cnt int", NULL, NULL, data_sim_set_mw_fax_cnt},
1517 {"6", "email_cnt int", NULL, NULL, data_sim_set_mw_email_cnt},
1518 {"7", "other_cnt int", NULL, NULL, data_sim_set_mw_other_cnt},
1519 {"8", "video_cnt int", NULL, NULL, data_sim_set_mw_video_cnt},
1520 {"9", "cphs_voice1 no/yes => 0/1", NULL, NULL, data_sim_set_mw_cphs_voice1},
1521 {"10", "cphs_voice2 no/yes => 0/1", NULL, NULL, data_sim_set_mw_cphs_voice2},
1522 {"11", "cphs_fax no/yes => 0/1", NULL, NULL, data_sim_set_mw_cphs_fax},
1523 {"12", "cphs_data no/yes => 0/1", NULL, NULL, data_sim_set_mw_cphs_data},
1524 {"13", "run", NULL, run_sim_set_mw, NULL},
1528 static struct menu_data menu_sim_get_mb[] = {
1529 {"1", "run", NULL, run_sim_get_mb, NULL},
1533 static struct menu_data menu_sim_set_mb[] = {
1534 {"1", "b_cphs no/yes => 0/1", NULL, NULL, data_sim_set_mb_b_cphs},
1535 {"2", "type 1voice 2voice2 3fax 4data 5email 6other int", NULL, NULL, data_sim_set_mb_type},
1536 {"3", "rec_index int", NULL, NULL, data_sim_set_mb_rec_index},
1537 {"4", "profile_num int", NULL, NULL, data_sim_set_mb_profile_num},
1538 {"5", "alpha_id_max_len int", NULL, NULL, data_sim_set_mb_alpha_id_max_len},
1539 {"6", "alpha_id string", NULL, NULL, data_sim_set_mb_alpha_id},
1540 {"7", "ton int", NULL, NULL, data_sim_set_mb_ton},
1541 {"8", "npi int", NULL, NULL, data_sim_set_mb_npi},
1542 {"9", "number string", NULL, NULL, data_sim_set_mb_number},
1543 {"10", "cc_id int", NULL, NULL, data_sim_set_mb_cc_id},
1544 {"11", "ext1_id int", NULL, NULL, data_sim_set_mb_ext1_id},
1545 {"12", "run", NULL, run_sim_set_mb, NULL},
1549 static struct menu_data menu_sim_get_cphs_info[] = {
1550 {"1", "run", NULL, run_sim_get_cphs_info, NULL},
1554 static struct menu_data menu_sim_get_service_table[] = {
1555 {"1", "run", NULL, run_sim_get_service_table, NULL},
1559 static struct menu_data menu_sim_get_msisdn[] = {
1560 {"1", "run", NULL, run_sim_get_msisdn, NULL},
1564 static struct menu_data menu_sim_get_oplmnwact[] = {
1565 {"1", "run", NULL, run_sim_get_oplmnwact, NULL},
1569 static struct menu_data menu_sim_get_spn[] = {
1570 {"1", "run", NULL, run_sim_get_spn, NULL},
1574 static struct menu_data menu_sim_get_cphs_netname[] = {
1575 {"1", "run", NULL, run_sim_get_cphs_netname, NULL},
1579 static struct menu_data menu_sim_req_authentication[] = {
1580 {"1", "type", NULL, NULL, data_sim_req_authentication_type},
1581 {"2", "autn_data", NULL, NULL, data_sim_req_authentication_autn_data},
1582 {"3", "rand_data", NULL, NULL, data_sim_req_authentication_rand_data},
1583 {"4", "run", NULL, run_sim_req_authentication, NULL},
1587 static struct menu_data menu_sim_verify_pins[] = {
1588 {"1", "type(0:pin1, 1:pin2, 6:sim)", NULL, NULL, data_sim_verify_pins_type},
1589 {"2", "pw", NULL, NULL, data_sim_verify_pins_pw},
1590 {"3", "run", NULL, run_sim_verify_pins, NULL},
1594 static struct menu_data menu_sim_verify_puks[] = {
1595 {"1", "type(2:puk1, 3:puk2)", NULL, NULL, data_sim_verify_puks_type},
1596 {"2", "puk", NULL, NULL, data_sim_verify_puks_puk},
1597 {"3", "pin", NULL, NULL, data_sim_verify_puks_pin},
1598 {"4", "run", NULL, run_sim_verify_puks, NULL},
1602 static struct menu_data menu_sim_change_pins[] = {
1603 {"1", "type(0:pin1, 1:pin2)", NULL, NULL, data_sim_change_pins_type},
1604 {"2", "old_pw", NULL, NULL, data_sim_change_pins_old_pw},
1605 {"3", "new_pw", NULL, NULL, data_sim_change_pins_new_pw},
1606 {"4", "run", NULL, run_sim_change_pins, NULL},
1610 static struct menu_data menu_sim_disable_facility[] = {
1611 {"1", "type(1:simlock, 3:pinlock., 4:fdnlock, 5:net, 6:netsub, 7:sp, 8:cp)", NULL, NULL, data_sim_disable_facility_type},
1612 {"2", "pw", NULL, NULL, data_sim_disable_facility_pw},
1613 {"3", "run", NULL, run_sim_disable_facility, NULL},
1617 static struct menu_data menu_sim_enable_facility[] = {
1618 {"1", "type(1:simlock, 3:pinlock., 4:fdnlock, 5:net, 6:netsub, 7:sp, 8:cp)", NULL, NULL, data_sim_enable_facility_type},
1619 {"2", "pw", NULL, NULL, data_sim_enable_facility_pw},
1620 {"3", "run", NULL, run_sim_enable_facility, NULL},
1624 static struct menu_data menu_sim_get_facility[] = {
1625 {"1", "type(1:simlock, 3:pinlock., 4:fdnlock, 5:net, 6:netsub, 7:sp, 8:cp)", NULL, NULL, data_sim_get_facility_type},
1626 {"2", "run", NULL, run_sim_get_facility, NULL},
1630 static struct menu_data menu_sim_get_lock_info[] = {
1631 {"1", "type(1:simlock, 3:pinlock., 4:fdnlock, 5:net, 6:netsub, 7:sp, 8:cp)", NULL, NULL, data_sim_get_lock_type},
1632 {"2", "run", NULL, run_sim_get_lock_info, NULL},
1636 static struct menu_data menu_sim_transmit_apdu[] = {
1637 {"1", "apdu", NULL, NULL, data_sim_transmit_apdu_apdu},
1638 {"2", "run", NULL, run_sim_transmit_apdu, NULL},
1642 static struct menu_data menu_sim_get_atr[] = {
1643 {"1", "run", NULL, run_sim_get_atr, NULL},
1647 static struct menu_data menu_sim_call_sync[] = {
1648 { "1", "op_type (1:get_init_status, 3:get_imsi, 5:get_iccid,\n\t\t"
1649 "16:get_msisdn, 18:get_spn, 19:get_cphs_net_name, 28:transfer_apdu,\n\t\t"
1650 "29:get_atr)", NULL, NULL, data_sim_op_type},
1651 { "2", "run", NULL, run_sim_request_sync, NULL},
1655 static struct menu_data menu_sim_call_async[] = {
1656 { "1", "op_type (1:get_init_status, 3:get_imsi, 5:get_iccid,\n\t\t"
1657 "16:get_msisdn, 18:get_spn, 19:get_cphs_net_name, 28:transfer_apdu,\n\t\t"
1658 "29:get_atr)", NULL, NULL, data_sim_op_type},
1659 { "2", "run", NULL, run_sim_request_async, NULL},
1664 struct menu_data menu_sim[] = {
1665 {"1", "sim init info", menu_sim_get_init_info, NULL, NULL},
1666 {"2", "card type", menu_sim_get_card_type, NULL, NULL},
1667 {"3", "imsi", menu_sim_get_imsi, NULL, NULL},
1668 {"4", "ecc", menu_sim_get_ecc, NULL, NULL},
1669 {"5", "iccid", menu_sim_get_iccid, NULL, NULL},
1670 {"6", "language", menu_sim_get_language, NULL, NULL},
1671 {"7", "update language", menu_sim_set_language, NULL, NULL},
1672 {"8", "cf info", menu_sim_get_cf, NULL, NULL},
1673 {"9", "update cf info", menu_sim_set_cf, NULL, NULL},
1674 {"10", "mw info", menu_sim_get_mw, NULL, NULL},
1675 {"11", "update mw info", menu_sim_set_mw, NULL, NULL},
1676 {"12", "mailbox info", menu_sim_get_mb, NULL, NULL},
1677 {"13", "update mailbox info", menu_sim_set_mb, NULL, NULL},
1678 {"14", "cphs info(svc table, phase)", menu_sim_get_cphs_info, NULL, NULL},
1679 {"15", "msisdn", menu_sim_get_msisdn, NULL, NULL},
1680 {"16", "oplmnwact", menu_sim_get_oplmnwact, NULL, NULL},
1681 {"17", "spn", menu_sim_get_spn, NULL, NULL},
1682 {"18", "cphs operator name info", menu_sim_get_cphs_netname, NULL, NULL},
1683 {"19", "authentication", menu_sim_req_authentication, NULL, NULL},
1684 {"20", "verify pins", menu_sim_verify_pins, NULL, NULL},
1685 {"21", "verify puks", menu_sim_verify_puks, NULL, NULL},
1686 {"22", "change pins", menu_sim_change_pins, NULL, NULL},
1687 {"23", "disable facility", menu_sim_disable_facility, NULL, NULL},
1688 {"24", "enable facility", menu_sim_enable_facility, NULL, NULL},
1689 {"25", "facility(en/dis status) info", menu_sim_get_facility, NULL, NULL},
1690 {"26", "lock status(status,retry count) info", menu_sim_get_lock_info, NULL, NULL},
1691 {"27", "apdu", menu_sim_transmit_apdu, NULL, NULL},
1692 {"28", "atr info", menu_sim_get_atr, NULL, NULL},
1693 {"29", "service table", menu_sim_get_service_table, NULL, NULL},
1694 {"50", "tel_call_sim_sync", menu_sim_call_sync, NULL, NULL},
1695 {"51", "tel_call_sim_async", menu_sim_call_async, NULL, NULL},
1699 void register_sim_event (TapiHandle *handle)
1704 ret = tel_register_noti_event (handle, TAPI_NOTI_SIM_STATUS,
1705 on_noti_sim_status, NULL );
1706 if (ret != TAPI_API_SUCCESS) {
1707 msg("event register failed(%d)", ret);