Initialize Tizen 2.3
[framework/telephony/libslp-tapi.git] / wearable / test_src / sim.c
1 /*
2  * Telephony test application
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <sys/time.h>
25 #include <unistd.h>
26 #include <glib.h>
27
28 #include <tapi_common.h>
29 #include <ITapiSim.h>
30 #include <TapiUtility.h>
31
32 #include "menu.h"
33 #include "sim.h"
34
35 #define CHECK_RT(x) \
36 { \
37         if((x) != 0) { \
38                 msg("api call failed with[%d]",x); \
39                 return 0; \
40         } \
41 }
42
43 #define CHECK_ACCESS_RT(x) \
44 { \
45         if((x) != 0) { \
46                 msg("api call failed with[%d]",x); \
47                 return; \
48         } \
49 }
50
51 static char data_sim_set_language[MENU_DATA_SIZE + 1] = { 0x01, };
52
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] = { };
66
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] = { };
79
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] = { };
91
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,
95                 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,
98                 200, };
99
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] = { };
102
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] = { };
106
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] = "";
110
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] = { };
113
114 static char data_sim_enable_facility_type[MENU_DATA_SIZE + 1] = { };
115 static char data_sim_enable_facility_pw[MENU_DATA_SIZE + 1] = { };
116
117 static char data_sim_get_facility_type[MENU_DATA_SIZE + 1] = "1";
118
119 static char data_sim_get_lock_type[MENU_DATA_SIZE + 1] = "1";
120
121 static char data_sim_transmit_apdu_apdu[MENU_DATA_SIZE + 1] = "0070000000";
122
123 static char data_sim_op_type[MENU_DATA_SIZE + 1] = "1";
124
125 static int _sim_str_to_hex (char a)
126 {
127         int ret = 0;
128
129         if (a >= '0' && a <= '9')
130                 ret = a - '0';
131         else if (a >= 'a' && a <= 'f')
132                 ret = a - 'a' + 10;
133         //printf("'%c' => %d(0x%x)\n", a, ret, ret);
134         return ret;
135 }
136
137 static void on_noti_sim_status (TapiHandle *handle, const char *noti_id,
138                 void *data, void *user_data)
139 {
140         TelSimCardStatus_t *status = data;
141
142         msg("");
143         msgb("event(%s) receive !!", TAPI_NOTI_SIM_STATUS);
144         msg("status[%d]", *status);
145 }
146
147 static int run_sim_get_init_info (MManager *mm, struct menu_data *menu)
148 {
149         TapiHandle *handle = menu_manager_ref_user_data (mm);
150         int rt = 0;
151         TelSimCardStatus_t o_status = 0;
152         gboolean o_new = FALSE;
153
154         msg("call [%s] tapi service !!!", menu->title);
155
156         rt = tel_get_sim_init_info (handle, &o_status, &o_new);
157         CHECK_RT(rt);
158
159         msg("status[%d]", o_status);
160         msg("new_sim[%d]", o_new);
161         return 0;
162 }
163
164 static int run_sim_get_card_type (MManager *mm, struct menu_data *menu)
165 {
166         TapiHandle *handle = menu_manager_ref_user_data (mm);
167         int rt = 0;
168         TelSimCardType_t o_type = 0;
169
170         msg("call [%s] tapi service !!!", menu->title);
171
172         rt = tel_get_sim_type (handle, &o_type);
173         CHECK_RT(rt);
174
175         msg("card type[%d]", o_type);
176         return 0;
177 }
178
179 static int run_sim_get_imsi (MManager *mm, struct menu_data *menu)
180 {
181         TapiHandle *handle = menu_manager_ref_user_data (mm);
182         int rt = 0;
183         TelSimImsiInfo_t imsi;
184         memset (&imsi, 0, sizeof(TelSimImsiInfo_t));
185
186         msg("call [%s] tapi service !!!", menu->title);
187
188         rt = tel_get_sim_imsi (handle, &imsi);
189         CHECK_RT(rt);
190
191         msg("mcc[%s]", imsi.szMcc);
192         msg("mnc[%s]", imsi.szMnc);
193         msg("msin[%s]", imsi.szMsin);
194         return 0;
195 }
196
197 static int run_sim_get_ecc (MManager *mm, struct menu_data *menu)
198 {
199         TapiHandle *handle = menu_manager_ref_user_data (mm);
200         int rt = 0;
201         TelSimEccList_t ecc_list;
202         int i = 0;
203         memset (&ecc_list, 0, sizeof(TelSimEccList_t));
204
205         msg("call [%s] tapi service !!!", menu->title);
206
207         rt = tel_get_sim_ecc (handle, &ecc_list);
208         CHECK_RT(rt);
209
210         msg("ecc_list.ecc_count[%d]", ecc_list.ecc_count);
211
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);
216         }
217         return 0;
218 }
219
220 static void on_sim_get_iccid (TapiHandle *handle, int result, void *data,
221                 void *user_data)
222 {
223         TelSimAccessResult_t access_rt = result;
224         TelSimIccIdInfo_t *iccid = data;
225
226         msg("TAPI_SERVICE_SIM_GET_ICCID response received");
227
228         CHECK_ACCESS_RT(access_rt);
229
230         msg("access_rt[%d]", access_rt);
231         msg("iccid length[%d]", iccid->icc_length);
232         msg("iccid[%s]", iccid->icc_num);
233 }
234
235 static int run_sim_get_iccid (MManager *mm, struct menu_data *menu)
236 {
237         TapiHandle *handle = menu_manager_ref_user_data (mm);
238         int rt = 0;
239
240         msg("call [%s] tapi service !!!", menu->title);
241
242         rt = tel_get_sim_iccid (handle, on_sim_get_iccid, NULL );
243         CHECK_RT(rt);
244         return 0;
245 }
246
247 static void on_sim_get_language (TapiHandle *handle, int result, void *data,
248                 void *user_data)
249 {
250         TelSimLanguagePreferenceCode_t *language = data;
251         TelSimAccessResult_t access_rt = result;
252
253         msg("TAPI_SERVICE_SIM_GET_LANGUAGE response received");
254
255         CHECK_ACCESS_RT(access_rt);
256
257         msg("access rt[%d]", access_rt);
258         msg("language[%d]", *language);
259 }
260
261 static int run_sim_get_language (MManager *mm, struct menu_data *menu)
262 {
263         TapiHandle *handle = menu_manager_ref_user_data (mm);
264         int rt = 0;
265
266         msg("call [%s] tapi service !!!", menu->title);
267
268         rt = tel_get_sim_language (handle, on_sim_get_language, NULL );
269         CHECK_RT(rt);
270         return 0;
271 }
272
273 static void on_sim_set_language (TapiHandle *handle, int result, void *data,
274                 void *user_data)
275 {
276         TelSimAccessResult_t access_rt = result;
277
278         msg("TAPI_SERVICE_SIM_SET_LANGUAGE response received");
279
280         CHECK_ACCESS_RT(access_rt);
281
282         msg("access_rt[%d]", access_rt);
283 }
284
285 static int run_sim_set_language (MManager *mm, struct menu_data *menu)
286 {
287         TapiHandle *handle = menu_manager_ref_user_data (mm);
288         int rt = 0;
289
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 );
294         CHECK_RT(rt);
295         return 0;
296 }
297
298 static void on_sim_get_cf (TapiHandle *handle, int result, void *data,
299                 void *user_data)
300 {
301         TelSimAccessResult_t access_rt = result;
302         TelSimCallForwardingResp_t *cf = data;
303         int i = 0;
304         msg("TAPI_SERVICE_SIM_GET_CF response received");
305
306         CHECK_ACCESS_RT(access_rt);
307
308         msg("access_rt[%d]", access_rt);
309         msg("cf->b_cphs[%d]", cf->b_cphs);
310
311         if (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);
316         }
317         else {
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);
330                 }
331         }
332 }
333
334 static int run_sim_get_cf (MManager *mm, struct menu_data *menu)
335 {
336         TapiHandle *handle = menu_manager_ref_user_data (mm);
337         int rt = 0;
338
339         msg("call [%s] tapi service !!!", menu->title);
340         rt = tel_get_sim_callforwarding_info (handle, on_sim_get_cf, NULL );
341         CHECK_RT(rt);
342         return 0;
343 }
344
345 static void on_sim_set_cf (TapiHandle *handle, int result, void *data,
346                 void *user_data)
347 {
348         TelSimAccessResult_t access_rt = result;
349
350         msg("response received");
351
352         CHECK_ACCESS_RT(access_rt);
353
354         msg("access_rt[%d]", access_rt);
355 }
356
357 static int run_sim_set_cf (MManager *mm, struct menu_data *menu)
358 {
359         TapiHandle *handle = menu_manager_ref_user_data (mm);
360         int rt = 0;
361         TelSimCallForwardingReq_t cf;
362         memset (&cf, 0, sizeof(TelSimCallForwardingReq_t));
363
364         msg("call [%s] tapi service !!!", menu->title);
365
366         cf.b_cphs = data_sim_set_cf_b_cphs[0] - '0';
367         if (cf.b_cphs) {
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';
372         }
373         else {
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';
383         }
384
385         rt = tel_set_sim_callforwarding_info (handle, &cf, on_sim_set_cf, NULL );
386         CHECK_RT(rt);
387         return 0;
388 }
389
390 static void on_sim_get_mw (TapiHandle *handle, int result, void *data,
391                 void *user_data)
392 {
393         TelSimAccessResult_t access_rt = result;
394         TelSimMessageWaitingResp_t *mw = data;
395         int i = 0;
396
397         msg("TAPI_SERVICE_SIM_GET_MW response received");
398
399         CHECK_ACCESS_RT(access_rt);
400
401         msg("access_rt[%d]", access_rt);
402         msg("mw->b_cphs[%d]", mw->b_cphs);
403
404         if (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);
409         }
410         else {
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);
426                 }
427         }
428 }
429
430 static int run_sim_get_mw (MManager *mm, struct menu_data *menu)
431 {
432         TapiHandle *handle = menu_manager_ref_user_data (mm);
433         int rt = 0;
434
435         msg("call [%s] tapi service !!!", menu->title);
436         rt = tel_get_sim_messagewaiting_info (handle, on_sim_get_mw, NULL );
437         CHECK_RT(rt);
438         return 0;
439 }
440
441 static void on_sim_set_mw (TapiHandle *handle, int result, void *data,
442                 void *user_data)
443 {
444         TelSimAccessResult_t access_rt = result;
445
446         msg("response received");
447
448         CHECK_ACCESS_RT(access_rt);
449
450         msg("access_rt[%d]", access_rt);
451 }
452
453 static int run_sim_set_mw (MManager *mm, struct menu_data *menu)
454 {
455         TapiHandle *handle = menu_manager_ref_user_data (mm);
456         int rt = 0;
457         TelSimMessageWaitingReq_t mw;
458
459         memset (&mw, 0, sizeof(TelSimMessageWaitingReq_t));
460
461         msg("call [%s] tapi service !!!", menu->title);
462
463         mw.b_cphs = data_sim_set_mw_b_cphs[0] - '0';
464
465         if (mw.b_cphs) {
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';
470         }
471         else {
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]
474                                 - '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';
480         }
481
482         rt = tel_set_sim_messagewaiting_info (handle, &mw, on_sim_set_mw, NULL );
483         CHECK_RT(rt);
484         return 0;
485 }
486
487 static void on_sim_get_mb (TapiHandle *handle, int result, void *data,
488                 void *user_data)
489 {
490         TelSimAccessResult_t access_rt = result;
491         TelSimMailboxList_t *list = data;
492         int i = 0;
493
494         msg("TAPI_SERVICE_SIM_GET_MB response received");
495
496         CHECK_ACCESS_RT(access_rt);
497
498         msg("access_rt[%d]", access_rt);
499         msg("count[%d]", list->count);
500
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);
514         }
515 }
516
517 static int run_sim_get_mb (MManager *mm, struct menu_data *menu)
518 {
519         TapiHandle *handle = menu_manager_ref_user_data (mm);
520         int rt = 0;
521
522         msg("call [%s] tapi service !!!", menu->title);
523         rt = tel_get_sim_mailbox_info (handle, on_sim_get_mb, NULL );
524         CHECK_RT(rt);
525         return 0;
526 }
527
528 static void on_sim_set_mb (TapiHandle *handle, int result, void *data,
529                 void *user_data)
530 {
531         TelSimAccessResult_t access_rt = result;
532
533         msg("response received");
534
535         CHECK_ACCESS_RT(access_rt);
536
537         msg("access_rt[%d]", access_rt);
538 }
539
540 static int run_sim_set_mb (MManager *mm, struct menu_data *menu)
541 {
542         TapiHandle *handle = menu_manager_ref_user_data (mm);
543         int rt = 0;
544         TelSimMailBoxNumber_t mb;
545
546         msg("call [%s] tapi service !!!", menu->title);
547
548         memset (&mb, 0, sizeof(TelSimMailBoxNumber_t));
549
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';
562
563         rt = tel_set_sim_mailbox_info (handle, &mb, on_sim_set_mb, NULL );
564         CHECK_RT(rt);
565         return 0;
566 }
567
568 static void on_sim_get_cphs_info (TapiHandle *handle, int result, void *data,
569                 void *user_data)
570 {
571         TelSimAccessResult_t access_rt = result;
572         TelSimCphsInfo_t *cphs = data;
573
574         msg("TAPI_SERVICE_SIM_GET_CPHSINFO response received");
575
576         CHECK_ACCESS_RT(access_rt);
577
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);
590 }
591
592 static void on_sim_get_service_table (TapiHandle *handle, int result,
593                 void *data, void *user_data)
594 {
595         TelSimAccessResult_t access_rt = result;
596         TelSimServiceTable_t *svct = (TelSimServiceTable_t *) data;
597
598         msg("TAPI_SERVICE_SIM_GET_SERVICE_TABLE response received");
599
600         CHECK_ACCESS_RT(access_rt);
601
602         msg("access_rt[%d]", access_rt);
603
604         if (svct->sim_type == TAPI_SIM_CARD_TYPE_GSM) {
605                 int i = 0, size = sizeof(TelSimSST_t);
606                 char *temp = NULL;
607                 if ( (temp = (char *) calloc (size + 1, 1)) != NULL ) {
608                         memcpy (temp, &svct->table.sst, size);
609                         for (i = 0; i < size; i++) {
610                                 if (temp[i] == 1)
611                                         temp[i] = '1';
612                                 else
613                                         temp[i] = '0';
614                         }
615                         msg("svct->table.sst=[%s]", temp);
616                         free (temp);
617                 }
618         }
619         else if (svct->sim_type == TAPI_SIM_CARD_TYPE_USIM) {
620                 int i = 0, size = sizeof(TelSimUST_t);
621                 char *temp = NULL;
622                 if ( (temp = (char *) calloc (size + 1, 1)) != NULL ) {
623                         memcpy (temp, &svct->table.ust, size);
624                         for (i = 0; i < size; i++) {
625                                 if (temp[i] == 1)
626                                         temp[i] = '1';
627                                 else
628                                         temp[i] = '0';
629                         }
630                         msg("svct->table.ust=[%s]", temp);
631                         free (temp);
632                 }
633         }
634         else {
635                 msg("Unknown sim type");
636         }
637 }
638
639 static int run_sim_get_cphs_info (MManager *mm, struct menu_data *menu)
640 {
641         TapiHandle *handle = menu_manager_ref_user_data (mm);
642         int rt = 0;
643
644         msg("call [%s] tapi service !!!", menu->title);
645         rt = tel_get_sim_cphs_info (handle, on_sim_get_cphs_info, NULL );
646         CHECK_RT(rt);
647         return 0;
648 }
649
650 static int run_sim_get_service_table (MManager *mm, struct menu_data *menu)
651 {
652         TapiHandle *handle = menu_manager_ref_user_data (mm);
653         int rt = 0;
654
655         msg("call [%s] tapi service !!!", menu->title);
656         rt = tel_get_sim_service_table (handle, on_sim_get_service_table, NULL );
657         CHECK_RT(rt);
658         return 0;
659 }
660
661 static void on_sim_get_msisdn (TapiHandle *handle, int result, void *data,
662                 void *user_data)
663 {
664         TelSimAccessResult_t access_rt = result;
665         TelSimMsisdnList_t *list = data;
666         int i = 0;
667         msg("TAPI_SERVICE_SIM_GET_MSISDN response received");
668
669         CHECK_ACCESS_RT(access_rt);
670
671         msg("access_rt[%d]", access_rt);
672
673         msg("list->count[%d]", list->count);
674
675         for (i = 0; i < list->count; i++)
676                 msg("index[%d] - name[%s], num[%s]", i, list->list[i].name,
677                                 list->list[i].num);
678 }
679
680 static int run_sim_get_msisdn (MManager *mm, struct menu_data *menu)
681 {
682         TapiHandle *handle = menu_manager_ref_user_data (mm);
683         int rt = 0;
684
685         msg("call [%s] tapi service !!!", menu->title);
686         rt = tel_get_sim_msisdn (handle, on_sim_get_msisdn, NULL );
687         CHECK_RT(rt);
688         return 0;
689 }
690
691 static void on_sim_get_oplmnwact (TapiHandle *handle, int result, void *data,
692                 void *user_data)
693 {
694         TelSimAccessResult_t access_rt = result;
695         TelSimOplmnwactList_t *list = data;
696         int i = 0;
697
698         msg("TAPI_SERVICE_SIM_GET_OPLMNWACT response received");
699
700         CHECK_ACCESS_RT(access_rt);
701
702         msg("access_rt[%d]", access_rt);
703         msg("list->count[%d]", list->count);
704
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);
708         }
709 }
710
711 static int run_sim_get_oplmnwact (MManager *mm, struct menu_data *menu)
712 {
713         TapiHandle *handle = menu_manager_ref_user_data (mm);
714         int rt = 0;
715
716         msg("call [%s] tapi service !!!", menu->title);
717         rt = tel_get_sim_oplmnwact (handle, on_sim_get_oplmnwact, NULL );
718         CHECK_RT(rt);
719         return 0;
720 }
721
722 static void on_sim_get_spn (TapiHandle *handle, int result, void *data,
723                 void *user_data)
724 {
725         TelSimAccessResult_t access_rt = result;
726         TelSimSpn_t *spn_info = data;
727
728         msg("TAPI_SERVICE_SIM_GET_SPN response received");
729
730         CHECK_ACCESS_RT(access_rt);
731
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);
735 }
736
737 static int run_sim_get_spn (MManager *mm, struct menu_data *menu)
738 {
739         TapiHandle *handle = menu_manager_ref_user_data (mm);
740         int rt = 0;
741
742         msg("call [%s] tapi service !!!", menu->title);
743         rt = tel_get_sim_spn (handle, on_sim_get_spn, NULL );
744         CHECK_RT(rt);
745         return 0;
746 }
747
748 static void on_sim_get_cphs_netname (TapiHandle *handle, int result, void *data,
749                 void *user_data)
750 {
751         TelSimAccessResult_t access_rt = result;
752         TelSimCphsNetName_t *cphs_net = data;
753
754         msg("TAPI_SERVICE_SIM_GET_CPHS_NETNAME response received");
755
756         CHECK_ACCESS_RT(access_rt);
757
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);
761 }
762
763 static int run_sim_get_cphs_netname (MManager *mm, struct menu_data *menu)
764 {
765         TapiHandle *handle = menu_manager_ref_user_data (mm);
766         int rt = 0;
767
768         msg("call [%s] tapi service !!!", menu->title);
769         rt = tel_get_sim_cphs_netname (handle, on_sim_get_cphs_netname, NULL );
770         CHECK_RT(rt);
771         return 0;
772 }
773
774 static void on_sim_req_authentication (TapiHandle *handle, int result,
775                 void *data, void *user_data)
776 {
777         TelSimAccessResult_t access_rt = result;
778         TelSimAuthenticationResponse_t *auth_resp = data;
779         int i = 0;
780
781         msg("TAPI_SERVICE_SIM_AUTHENTICATION response received");
782
783         CHECK_ACCESS_RT(access_rt);
784
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);
788
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]);
795         }
796
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]);
802         }
803
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]);
809         }
810
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]);
815         }
816
817 }
818
819 static int run_sim_req_authentication (MManager *mm, struct menu_data *menu)
820 {
821         TapiHandle *handle = menu_manager_ref_user_data (mm);
822         int rt = 0;
823         TelSimAuthenticationData_t auth;
824         memset (&auth, 0, sizeof(TelSimAuthenticationData_t));
825
826         msg("call [%s] tapi service !!!", menu->title);
827
828         data_sim_req_authentication_type[0] = data_sim_req_authentication_type[0]
829                         - '0';
830
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,
834                         auth.autn_length);
835         auth.rand_length = strlen (data_sim_req_authentication_rand_data);
836         memcpy (&auth.rand_data, data_sim_req_authentication_rand_data,
837                         auth.rand_length);
838
839         rt = tel_req_sim_authentication (handle, &auth, on_sim_req_authentication,
840                         NULL );
841         CHECK_RT(rt);
842         return 0;
843 }
844
845 static void on_sim_security_op_resp (TapiHandle *handle, int result, void *data,
846                 void *user_data)
847 {
848         TelSimPinOperationResult_t sec_rt = result;
849         TelSimSecResult_t *rt = data;
850
851         msg("TAPI_SERVICE_SIM security response received");
852
853         CHECK_ACCESS_RT(sec_rt);
854
855         msg("sec_rt[%d]", sec_rt);
856         msg("rt->type[%d]", rt->type);
857         msg("rt->retry_count[%d]", rt->retry_count);
858 }
859
860 static int run_sim_verify_pins (MManager *mm, struct menu_data *menu)
861 {
862         TapiHandle *handle = menu_manager_ref_user_data (mm);
863         int rt = 0;
864         TelSimSecPw_t pwt;
865         memset (&pwt, 0, sizeof(TelSimSecPw_t));
866
867         msg("call [%s] tapi service !!!", menu->title);
868
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;
874
875         rt = tel_verifiy_sim_pins (handle, &pwt, on_sim_security_op_resp, NULL );
876         CHECK_RT(rt);
877         return 0;
878 }
879
880 static int run_sim_verify_puks (MManager *mm, struct menu_data *menu)
881 {
882         TapiHandle *handle = menu_manager_ref_user_data (mm);
883         int rt = 0;
884         TelSimSecPw_t puk_t;
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);
889
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;
895
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;
900
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;
904
905         rt = tel_verify_sim_puks (handle, &puk_t, &new_pin_t,
906                         on_sim_security_op_resp, NULL );
907         CHECK_RT(rt);
908         return 0;
909 }
910
911 static int run_sim_change_pins (MManager *mm, struct menu_data *menu)
912 {
913         TapiHandle *handle = menu_manager_ref_user_data (mm);
914         int rt = 0;
915         TelSimSecPw_t old;
916         TelSimSecPw_t new;
917         memset (&old, 0, sizeof(TelSimSecPw_t));
918         memset (&new, 0, sizeof(TelSimSecPw_t));
919
920         msg("call [%s] tapi service !!!", menu->title);
921
922         data_sim_change_pins_type[0] = data_sim_change_pins_type[0] - '0';
923
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;
928
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;
933
934         rt = tel_change_sim_pins (handle, &old, &new, on_sim_security_op_resp,
935                         NULL );
936         CHECK_RT(rt);
937         return 0;
938 }
939
940 static void on_sim_facility_op_resp (TapiHandle *handle, int result, void *data,
941                 void *user_data)
942 {
943         TelSimPinOperationResult_t sec_rt = result;
944         TelSimFacilityResult_t *f_rt = data;
945
946         msg("TAPI_SERVICE_SIM facility response received");
947
948         CHECK_ACCESS_RT(sec_rt);
949
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);
953 }
954
955 static int run_sim_disable_facility (MManager *mm, struct menu_data *menu)
956 {
957         TapiHandle *handle = menu_manager_ref_user_data (mm);
958         int rt = 0;
959         TelSimFacilityPw_t fpw;
960         msg("call [%s] tapi service !!!", menu->title);
961
962         memset (&fpw, 0, sizeof (fpw));
963
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;
969
970         msg("fpw.lock_type[%d], fpw.pw_len[%d], fpw.pw[%s]", fpw.lock_type,
971                         fpw.pw_len, fpw.pw);
972         rt = tel_disable_sim_facility (handle, &fpw, on_sim_facility_op_resp,
973                         NULL );
974         CHECK_RT(rt);
975         return 0;
976 }
977
978 static int run_sim_enable_facility (MManager *mm, struct menu_data *menu)
979 {
980         TapiHandle *handle = menu_manager_ref_user_data (mm);
981         int rt = 0;
982         TelSimFacilityPw_t fpw;
983         msg("call [%s] tapi service !!!", menu->title);
984
985         memset (&fpw, 0, sizeof (fpw));
986
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;
992
993         msg("fpw.lock_type[%d], fpw.pw_len[%d], fpw.pw[%s]", fpw.lock_type,
994                         fpw.pw_len, fpw.pw);
995         rt = tel_enable_sim_facility (handle, &fpw, on_sim_facility_op_resp, NULL );
996         CHECK_RT(rt);
997         return 0;
998 }
999
1000 static void on_sim_get_facility (TapiHandle *handle, int result, void *data,
1001                 void *user_data)
1002 {
1003         TelSimPinOperationResult_t sec_rt = result;
1004         TelSimFacilityInfo_t *fi = data;
1005
1006         msg("TAPI_SERVICE_SIM facility response received");
1007
1008         CHECK_ACCESS_RT(sec_rt);
1009
1010         msg("sec_rt[%d]", sec_rt);
1011         msg("fi->type[%d]", fi->type);
1012         msg("fi->f_status[%d]", fi->f_status);
1013 }
1014
1015 static int run_sim_get_facility (MManager *mm, struct menu_data *menu)
1016 {
1017         TapiHandle *handle = menu_manager_ref_user_data (mm);
1018         int rt = 0;
1019         TelSimLockType_t t = 0;
1020         msg("call [%s] tapi service !!!", menu->title);
1021
1022         data_sim_get_facility_type[0] = data_sim_get_facility_type[0] - '0';
1023
1024         switch (data_sim_get_facility_type[0]) {
1025                 case 1:
1026                         t = TAPI_SIM_LOCK_PS;
1027                         break;
1028                 case 2:
1029                         t = TAPI_SIM_LOCK_PF;
1030                         break;
1031                 case 3:
1032                         t = TAPI_SIM_LOCK_SC;
1033                         break;
1034                 case 4:
1035                         t = TAPI_SIM_LOCK_FD;
1036                         break;
1037                 case 5:
1038                         t = TAPI_SIM_LOCK_PN;
1039                         break;
1040                 case 6:
1041                         t = TAPI_SIM_LOCK_PU;
1042                         break;
1043                 case 7:
1044                         t = TAPI_SIM_LOCK_PP;
1045                         break;
1046                 case 8:
1047                         t = TAPI_SIM_LOCK_PC;
1048                         break;
1049                 default:
1050                         msg("not handled type[%d]", data_sim_get_facility_type[0])
1051                         ;
1052                         break;
1053         }
1054         rt = tel_get_sim_facility (handle, t, on_sim_get_facility, NULL );
1055         CHECK_RT(rt);
1056         return 0;
1057 }
1058
1059 static void on_sim_get_lock_info (TapiHandle *handle, int result, void *data,
1060                 void *user_data)
1061 {
1062         TelSimPinOperationResult_t sec_rt = result;
1063         TelSimLockInfo_t *lock = data;
1064
1065         msg("TAPI_SERVICE_SIM lock info response received");
1066
1067         CHECK_ACCESS_RT(sec_rt);
1068
1069         msg("sec_rt[%d]", sec_rt);
1070         msg("lock->lock_type[%d]", lock->lock_type);
1071         msg(
1072                         "lock->lock_status[%d]-0:not need, 1:pin, 2:puk, 3:pin2, 4:puk2, 5:blocked",
1073                         lock->lock_status);
1074         msg("lock->retry_count[%d]", lock->retry_count);
1075 }
1076
1077 static int run_sim_get_lock_info (MManager *mm, struct menu_data *menu)
1078 {
1079         TapiHandle *handle = menu_manager_ref_user_data (mm);
1080         int rt = 0;
1081         TelSimLockType_t t = 0;
1082         msg("call [%s] tapi service !!!", menu->title);
1083
1084         data_sim_get_lock_type[0] = data_sim_get_lock_type[0] - '0';
1085
1086         switch (data_sim_get_lock_type[0]) {
1087                 case 1:
1088                         t = TAPI_SIM_LOCK_PS;
1089                         break;
1090                 case 2:
1091                         t = TAPI_SIM_LOCK_PF;
1092                         break;
1093                 case 3:
1094                         t = TAPI_SIM_LOCK_SC;
1095                         break;
1096                 case 4:
1097                         t = TAPI_SIM_LOCK_FD;
1098                         break;
1099                 case 5:
1100                         t = TAPI_SIM_LOCK_PN;
1101                         break;
1102                 case 6:
1103                         t = TAPI_SIM_LOCK_PU;
1104                         break;
1105                 case 7:
1106                         t = TAPI_SIM_LOCK_PP;
1107                         break;
1108                 case 8:
1109                         t = TAPI_SIM_LOCK_PC;
1110                         break;
1111                 default:
1112                         msg("not handled type[%d]", data_sim_get_lock_type[0])
1113                         ;
1114                         break;
1115         }
1116         rt = tel_get_sim_lock_info (handle, t, on_sim_get_lock_info, NULL );
1117         CHECK_RT(rt);
1118         return 0;
1119 }
1120
1121 static void on_sim_transmit_apdu (TapiHandle *handle, int result, void *data,
1122                 void *user_data)
1123 {
1124         TelSimAccessResult_t access_rt = result;
1125         TelSimApduResp_t *r_apdu = data;
1126         int i = 0;
1127
1128         msg("TAPI_SERVICE_SIM_APDU response received");
1129
1130         CHECK_ACCESS_RT(access_rt);
1131
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]);
1137         }
1138 }
1139
1140 static int run_sim_transmit_apdu (MManager *mm, struct menu_data *menu)
1141 {
1142         TapiHandle *handle = menu_manager_ref_user_data (mm);
1143         int rt = 0;
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;
1147
1148         memset (&t_apdu, 0, sizeof(TelSimApdu_t));
1149
1150         msg("call [%s] tapi service !!!", menu->title);
1151
1152         len = strlen (data_sim_transmit_apdu_apdu);
1153
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);
1158
1159                 result_apdu[j] = hex;
1160         }
1161
1162         for (i = 0; i < len / 2; i++) {
1163                 printf ("[%02d] = 0x%02x\n", i, result_apdu[i]);
1164         }
1165
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);
1169
1170         rt = tel_req_sim_apdu (handle, &t_apdu, on_sim_transmit_apdu, NULL );
1171         if (t_apdu.apdu)
1172                 free(t_apdu.apdu);
1173         CHECK_RT(rt);
1174         return 0;
1175 }
1176
1177 static void on_sim_get_atr (TapiHandle *handle, int result, void *data,
1178                 void *user_data)
1179 {
1180         TelSimAccessResult_t access_rt = result;
1181         TelSimAtrResp_t *r_atr = data;
1182         int i = 0;
1183         msg("TAPI_SERVICE_SIM_APDU response received");
1184
1185         CHECK_ACCESS_RT(access_rt);
1186
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]);
1192         }
1193 }
1194
1195 static int run_sim_get_atr(MManager *mm, struct menu_data *menu)
1196 {
1197         TapiHandle *handle = menu_manager_ref_user_data(mm);
1198         int rt = 0;
1199
1200         msg("call [%s] tapi service !!!", menu->title);
1201
1202         rt = tel_req_sim_atr(handle, on_sim_get_atr, NULL);
1203         CHECK_RT(rt);
1204         return 0;
1205 }
1206
1207 static int run_sim_request_sync (MManager *mm, struct menu_data *menu)
1208 {
1209         TapiHandle *handle = menu_manager_ref_user_data (mm);
1210         int rt = 0;
1211         TelSimResponseData_t outparam;
1212         TelSimRequestData_t inparam;
1213         int i = 0;
1214         unsigned char op = 0;
1215
1216         memset (&outparam, 0, sizeof(TelSimResponseData_t));
1217         memset (&inparam, 0, sizeof(TelSimRequestData_t));
1218
1219         msg("call [%s] tapi service !!!", menu->title);
1220
1221         if (strlen(data_sim_op_type) == 1) {
1222                 op = data_sim_op_type[0] - '0';
1223         } else {
1224                 op = ((data_sim_op_type[0] - '0') * 10) + (data_sim_op_type[1] - '0');
1225         }
1226         msg("op = [%d]\n", op);
1227
1228         switch(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);
1234                 break;
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);
1239                 break;
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);
1244                 break;
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);
1251                 break;
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);
1256                 break;
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);
1261                 break;
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);
1270
1271                         result_apdu[j] = hex;
1272                 }
1273                 for (i = 0; i < len / 2; i++) {
1274                         printf ("[%02d] = 0x%02x\n", i, result_apdu[i]);
1275                 }
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);
1282                 } else {
1283                         msg("Memory allocation failed");
1284                 }
1285
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]);
1290                 }
1291
1292         }       break;
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]);
1299                 }
1300                 break;
1301
1302         default:
1303                 break;
1304         }
1305
1306         CHECK_RT(rt);
1307
1308         return 0;
1309 }
1310
1311 static void on_sim_request_async (TapiHandle *handle, int result, void *data,
1312                 void *user_data)
1313 {
1314         TelSimAccessResult_t access_rt = result;
1315         TelSimResponseData_t *resp = data;
1316         TelSimTapiOperation_t *op = user_data;
1317         int i = 0;
1318
1319         msg("tel_sim_request_async() response received");
1320         msg("access_rt[%d]", access_rt);
1321         CHECK_ACCESS_RT(access_rt);
1322
1323         if(!op)
1324                 return;
1325
1326         switch(*op) {
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);
1330                 break;
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);
1335                 break;
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);
1339                 break;
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);
1345                 break;
1346         case TAPI_SIM_GET_SPN:
1347                 msg("spn name[%s]", resp->spn.spn);
1348                 msg("spn condition[0x%x]", resp->spn.display_condition);
1349                 break;
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);
1353                 break;
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]);
1359                 }
1360
1361         }       break;
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]);
1367                 }
1368                 break;
1369
1370         default:
1371                 break;
1372         }
1373
1374         if(op)
1375                 free(op);
1376 }
1377
1378 static int run_sim_request_async (MManager *mm, struct menu_data *menu)
1379 {
1380         TapiHandle *handle = menu_manager_ref_user_data (mm);
1381         int rt = 0;
1382         TelSimResponseData_t outparam;
1383         TelSimRequestData_t inparam;
1384         unsigned char *op = NULL;
1385
1386         memset (&outparam, 0, sizeof(TelSimResponseData_t));
1387         memset (&inparam, 0, sizeof(TelSimRequestData_t));
1388         op = (unsigned char*)malloc(1);
1389         if(!op)
1390                 return 0;
1391
1392         msg("call [%s] tapi service !!!", menu->title);
1393
1394         if (strlen(data_sim_op_type) == 1) {
1395                 *op = data_sim_op_type[0] - '0';
1396         } else {
1397                 *op = ((data_sim_op_type[0] - '0') * 10) + (data_sim_op_type[1] - '0');
1398         }
1399         msg("op = [%d]\n", *op);
1400
1401         switch(*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);
1410                 break;
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);
1419
1420                         result_apdu[j] = hex;
1421                 }
1422                 for (i = 0; i < len / 2; i++) {
1423                         printf ("[%02d] = 0x%02x\n", i, result_apdu[i]);
1424                 }
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);
1431                 } else {
1432                         msg("Memory allocation failed");
1433                 }
1434         }       break;
1435         default:
1436                         msg(" default case called !!!");
1437                 break;
1438         }
1439
1440         if(op)
1441                 free(op);
1442         CHECK_RT(rt);
1443
1444         return 0;
1445 }
1446
1447 static struct menu_data menu_sim_get_init_info[] = {
1448         { "1", "run", NULL, run_sim_get_init_info, NULL},
1449         { NULL, NULL, },
1450 };
1451
1452 static struct menu_data menu_sim_get_card_type[] = {
1453         { "1", "run", NULL, run_sim_get_card_type, NULL},
1454         { NULL, NULL, },
1455 };
1456
1457 static struct menu_data menu_sim_get_imsi[] = {
1458         { "1", "run", NULL, run_sim_get_imsi, NULL},
1459         { NULL, NULL, },
1460 };
1461
1462 static struct menu_data menu_sim_get_ecc[] = {
1463         { "1", "run", NULL, run_sim_get_ecc, NULL},
1464         { NULL, NULL, },
1465 };
1466
1467 static struct menu_data menu_sim_get_iccid[] = {
1468         { "1", "run", NULL, run_sim_get_iccid, NULL},
1469         { NULL, NULL, },
1470 };
1471
1472 static struct menu_data menu_sim_get_language[] = {
1473                 {"1", "run", NULL, run_sim_get_language, NULL},
1474                 {NULL, NULL},
1475 };
1476
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},
1480                 {NULL, NULL},
1481 };
1482
1483 static struct menu_data menu_sim_get_cf[] = {
1484                 {"1", "run", NULL, run_sim_get_cf, NULL},
1485                 {NULL, NULL},
1486 };
1487
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},
1503                 {NULL, NULL},
1504 };
1505
1506 static struct menu_data menu_sim_get_mw[] = {
1507                 {"1", "run", NULL, run_sim_get_mw, NULL},
1508                 {NULL, NULL},
1509 };
1510
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},
1525                 {NULL, NULL},
1526 };
1527
1528 static struct menu_data menu_sim_get_mb[] = {
1529                 {"1", "run", NULL, run_sim_get_mb, NULL},
1530                 {NULL, NULL},
1531 };
1532
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},
1546                 {NULL, NULL},
1547 };
1548
1549 static struct menu_data menu_sim_get_cphs_info[] = {
1550                 {"1", "run", NULL, run_sim_get_cphs_info, NULL},
1551                 {NULL, NULL},
1552 };
1553
1554 static struct menu_data menu_sim_get_service_table[] = {
1555                 {"1", "run", NULL, run_sim_get_service_table, NULL},
1556                 {NULL, NULL},
1557 };
1558
1559 static struct menu_data menu_sim_get_msisdn[] = {
1560                 {"1", "run", NULL, run_sim_get_msisdn, NULL},
1561                 {NULL, NULL},
1562 };
1563
1564 static struct menu_data menu_sim_get_oplmnwact[] = {
1565                 {"1", "run", NULL, run_sim_get_oplmnwact, NULL},
1566                 {NULL, NULL},
1567 };
1568
1569 static struct menu_data menu_sim_get_spn[] = {
1570                 {"1", "run", NULL, run_sim_get_spn, NULL},
1571                 {NULL, NULL},
1572 };
1573
1574 static struct menu_data menu_sim_get_cphs_netname[] = {
1575                 {"1", "run", NULL, run_sim_get_cphs_netname, NULL},
1576                 {NULL, NULL},
1577 };
1578
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},
1584                 {NULL, NULL},
1585 };
1586
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},
1591                 {NULL, NULL},
1592 };
1593
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},
1599                 {NULL, NULL},
1600 };
1601
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},
1607                 {NULL, NULL},
1608 };
1609
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},
1614                 {NULL, NULL},
1615 };
1616
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},
1621                 {NULL, NULL},
1622 };
1623
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},
1627                 {NULL, NULL},
1628 };
1629
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},
1633                 {NULL, NULL},
1634 };
1635
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},
1639                 {NULL, NULL},
1640 };
1641
1642 static struct menu_data menu_sim_get_atr[] = {
1643                 {"1", "run", NULL, run_sim_get_atr, NULL},
1644                 {NULL, NULL},
1645 };
1646
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},
1652         { NULL, NULL, },
1653 };
1654
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},
1660         { NULL, NULL, },
1661 };
1662
1663
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},
1696         { NULL, NULL, },
1697 };
1698
1699 void register_sim_event (TapiHandle *handle)
1700 {
1701         int ret;
1702
1703         /* SIM */
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);
1708         }
1709 }