tizen 2.4 release
[apps/home/settings.git] / setting-password / src / setting-password-sim.c
1 /*
2 * setting
3 *
4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5 *
6 * Contact: MyoungJune Park <mj2004.park@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
22 #include <setting-password.h>
23 #include <setting-password-sim.h>
24 #include <setting-common-data-slp-setting.h>
25 #include <setting-debug.h>
26 #include <dd-haptic.h>
27 #include <Ecore_IMF.h>
28 #include <Ecore_IMF_Evas.h>
29 #include <Ecore_X.h>
30 #include <Ecore.h>
31 #include <utilX.h>
32 #include <time.h>
33 #include <notification.h>
34
35 static int setting_password_sim_create(void *cb);
36 static int setting_password_sim_destroy(void *cb);
37 static int setting_password_sim_update(void *cb);
38 static int setting_password_sim_cleanup(void *cb);
39
40 setting_view setting_view_password_sim = {
41         .create = setting_password_sim_create,
42         .destroy = setting_password_sim_destroy,
43         .update = setting_password_sim_update,
44         .cleanup = setting_password_sim_cleanup,
45 };
46
47 static void setting_password_sim_done(void *data);
48
49
50 /* ***************************************************
51  *
52  *basic func
53  *
54  ***************************************************/
55 static void
56 __password_sim_gl_mouse_up(void *data, Evas *e, Evas_Object *obj,
57                            void *event)
58 {
59         ret_if(!data);
60         /*SettingPasswordUG *ad = (SettingPasswordUG *) data; */
61
62         /* P131121-05156 : do not hide input panel when genlist scrolls,
63                                                 plz compare with [about device > device name] item */
64 }
65
66 static char *setting_password_sim_get_title_str(void *data)
67 {
68         retvm_if(data == NULL, NULL,
69                  "[Setting > Password] Data parameter is NULL");
70         SettingPasswordUG *ad = (SettingPasswordUG *) data;
71
72         switch (ad->view_type) {
73                 case SETTING_PW_TYPE_SIM_LOCK_ON:
74                 case SETTING_PW_TYPE_SIM_LOCK_OFF:
75                         return "IDS_ST_BODY_PASSWORD";
76                         break;
77                 case SETTING_PW_TYPE_PIN_LOCK_ON:
78                 case SETTING_PW_TYPE_PIN_LOCK_OFF:
79                         return _("IDS_ST_BODY_PIN");
80                         break;
81                 case SETTING_PW_TYPE_CHANGE_PIN:
82                         return _("IDS_ST_HEADER_CHANGE_PIN_ABB");
83                         break;
84
85                 case SETTING_PW_TYPE_CHANGE_PIN2:
86                         return _("IDS_ST_BODY_CHANGE_PIN2");
87                         break;
88
89                 case SETTING_PW_TYPE_PIN_BLOCKED:
90                         return _("IDS_ST_BODY_PUK1_CODE");
91                         break;
92                 case SETTING_PW_TYPE_PIN2_BLOCKED:
93
94                         return _("IDS_ST_BODY_PUK2");
95                         break;
96                 default:
97                         SETTING_TRACE_DEBUG("%s*** Unknown Password Type. ***%s",
98                                             SETTING_FONT_BGREEN, SETTING_FONT_BLACK);
99                         break;
100         }
101         return NULL;
102
103 }
104
105 static Eina_Bool setting_password_sim_click_softkey_cancel_cb(void *data, Elm_Object_Item *it)
106 {
107         SETTING_TRACE_BEGIN;
108         /* error check */
109         retvm_if(data == NULL, EINA_FALSE, "[Setting > Password] Data parameter is NULL");
110
111         SettingPasswordUG *ad = (SettingPasswordUG *) data;
112 #if 0
113         /* if IME is displayed, hide IME. or Destroy password ug. */
114         if (ad->ed_pw1 && ad->ed_pw1->isFocusFlag == TRUE && elm_object_focus_get(ad->ed_pw1->eo_check)) {
115                 SETTING_TRACE_DEBUG("wait to hide IME");
116                 elm_object_focus_set(ad->ed_pw1->eo_check, EINA_FALSE);
117                 return EINA_FALSE;
118         } else if (ad->ed_pw2 && ad->ed_pw2->isFocusFlag == TRUE && elm_object_focus_get(ad->ed_pw2->eo_check)) {
119                 SETTING_TRACE_DEBUG("wait to hide IME");
120                 elm_object_focus_set(ad->ed_pw2->eo_check, EINA_FALSE);
121                 return EINA_FALSE;
122         } else if (ad->ed_pw3 && ad->ed_pw3->isFocusFlag == TRUE && elm_object_focus_get(ad->ed_pw3->eo_check)) {
123                 SETTING_TRACE_DEBUG("wait to hide IME");
124                 elm_object_focus_set(ad->ed_pw3->eo_check, EINA_FALSE);
125                 return EINA_FALSE;
126         }
127 #endif
128         if (ad->focus_timer) {
129                 ecore_timer_del(ad->focus_timer);
130                 ad->focus_timer = NULL;
131         }
132
133         /* send result : Cancel */
134         app_control_h svc;
135         if (app_control_create(&svc) == 0) {
136                 app_control_add_extra_data(svc, "result", "Cancel");
137                 ug_send_result(ad->ug, svc);
138                 SETTING_TRACE("Send Result : %s\n", "Cancel");
139
140                 app_control_destroy(svc);
141         }
142         /* Send destroy request */
143         ug_destroy_me(ad->ug);
144
145         return EINA_TRUE;
146 }
147
148 static int __create_sim_layout(void *data)
149 {
150         SETTING_TRACE_BEGIN;
151         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
152
153         SettingPasswordUG *ad = (SettingPasswordUG *)data;
154         static int count = 0;
155
156         count++;
157         /* CONTENT */
158         if (ad->scroller != NULL) {
159                 evas_object_del(ad->scroller);
160                 ad->scroller = NULL;
161         }
162
163         /* PIN related views have 2 toolbar buttons. CANCEL and DONE button */
164         ad->ly_main = setting_create_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get, setting_password_sim_get_title_str(ad),
165                                                              _("IDS_ST_BUTTON_BACK"),
166                                                              NULL,
167                                                              (setting_call_back_func)setting_password_sim_click_softkey_cancel_cb,
168                                                              NULL,
169                                                              ad,
170                                                              &(ad->scroller),
171                                                              &(ad->navi_bar));
172
173         ad->navi_it = elm_naviframe_top_item_get(ad->navi_bar);
174         ad->bottom_btn = elm_button_add(ad->navi_bar);
175
176         Evas_Object *btn_cancel = elm_button_add(ad->navi_bar);
177         elm_object_style_set(btn_cancel, "naviframe/title_cancel");
178         evas_object_smart_callback_add(btn_cancel, "clicked", setting_password_sim_click_softkey_cancel_cb, ad);
179         elm_object_item_part_content_set(ad->navi_it, "title_left_btn", btn_cancel);
180
181         Evas_Object *btn_done = elm_button_add(ad->navi_bar);
182         elm_object_style_set(btn_done, "naviframe/title_done");
183         evas_object_smart_callback_add(btn_done, "clicked", setting_password_sim_click_softkey_done_cb, ad);
184         elm_object_item_part_content_set(ad->navi_it, "title_right_btn", btn_done);
185
186         if (!ad->scroller) {
187                 SETTING_TRACE("genlist is NULL");
188                 return SETTING_RETURN_FAIL;
189         }
190
191         /* Disable Done button if exist */
192         elm_object_disabled_set(ad->bottom_btn, EINA_TRUE);
193         elm_object_focus_allow_set(ad->bottom_btn, EINA_FALSE);
194         elm_object_item_signal_emit(ad->navi_it, "elm,state,sip,shown", "");
195
196         elm_genlist_mode_set(ad->scroller, ELM_LIST_COMPRESS);
197         /*evas_object_smart_callback_add(ad->scroller, "drag", __password_main_gl_drag, ad); */
198         evas_object_event_callback_add(ad->scroller, EVAS_CALLBACK_MOUSE_UP,
199                                        __password_sim_gl_mouse_up, ad);
200
201         ADD_GL_SEPARATOR(ad->scroller)
202
203         return SETTING_RETURN_SUCCESS;
204 }
205
206 static Eina_Bool __setting_password_sim_rotate_cb(void *data)
207 {
208         /* error check */
209         SETTING_TRACE_BEGIN;
210         retv_if(data == NULL, FALSE);
211
212         SettingPasswordUG *ad = (SettingPasswordUG *) data;
213
214         if (ad->view_type == SETTING_PW_TYPE_PIN_LOCK_OFF
215             || ad->view_type == SETTING_PW_TYPE_PIN_LOCK_ON
216             || ((ad->view_type == SETTING_PW_TYPE_CHANGE_PIN) && !ad->cur_pwd)
217             || ad->view_type == SETTING_PW_TYPE_PIN_BLOCKED) {
218                 if (tel_get_sim_lock_info(ad->handle, TAPI_SIM_LOCK_SC, setting_get_pin_lock_info_cb, ad) != 0)
219                         SETTING_TRACE_DEBUG("failed to call tel_get_sim_lock_info()");
220         } else if (((ad->view_type == SETTING_PW_TYPE_CHANGE_PIN2) && !ad->cur_pwd)
221                    || ad->view_type == SETTING_PW_TYPE_PIN2_BLOCKED) {
222                 if (tel_get_sim_lock_info(ad->handle, TAPI_SIM_LOCK_FD, setting_get_pin_lock_info_cb, ad) != 0)
223                         SETTING_TRACE_DEBUG("failed to call tel_get_sim_lock_info()");
224         }
225
226         /* it can manage the cursor self */
227         if (ad->ed_pw1 && ad->ed_pw1->isFocusFlag) {
228                 if (ad->ed_pw1->eo_check) {
229                         SETTING_TRACE_DEBUG("set focus on first entry");
230                         /* no matter how many edifileds, it only need focus on 1st editfiled */
231                         elm_object_focus_set(ad->ed_pw1->eo_check, EINA_TRUE);
232                         elm_entry_cursor_end_set(ad->ed_pw1->eo_check);
233                 }
234         } else if (ad->ed_pw2 && ad->ed_pw2->isFocusFlag) {
235                 if (ad->ed_pw2->eo_check) {
236                         SETTING_TRACE_DEBUG("set focus on second entry");
237                         /*no matter how many edifileds, it only need focus on 1st editfiled */
238                         elm_object_focus_set(ad->ed_pw2->eo_check, EINA_TRUE);
239                         elm_entry_cursor_end_set(ad->ed_pw2->eo_check);
240                 }
241         } else if (ad->ed_pw3 && ad->ed_pw3->isFocusFlag) {
242                 if (ad->ed_pw3->eo_check) {
243                         SETTING_TRACE_DEBUG("set focus on third entry");
244                         /*no matter how many edifileds, it only need focus on 1st editfiled */
245                         elm_object_focus_set(ad->ed_pw3->eo_check, EINA_TRUE);
246                         elm_entry_cursor_end_set(ad->ed_pw3->eo_check);
247                 }
248         }
249
250         ad->focus_timer = NULL;
251
252         return ECORE_CALLBACK_CANCEL;
253 }
254
255 static void __init_tapi(SettingPasswordUG *ad)
256 {
257         ad->handle =  tel_init(NULL);
258         if (!ad->handle) {
259                 SETTING_TRACE_DEBUG("%s*** [ERR] tel_init. ***%s",
260                                     SETTING_FONT_RED, SETTING_FONT_BLACK);
261                 setting_password_ug_create_popup_notitle_nobtn(ad,
262                                                                _("IDS_ST_POP_ERROR"),
263                                                                FALSE);
264         }
265 }
266
267 static void __deinit_tapi(SettingPasswordUG *ad)
268 {
269         if (ad->handle) {
270                 if (tel_deinit(ad->handle) != TAPI_API_SUCCESS) {
271                         SETTING_TRACE_DEBUG("%s*** [ERR] setting_network_unsubscribe_tapi_events. ***%s",
272                                             SETTING_FONT_RED, SETTING_FONT_BLACK);
273                         setting_password_ug_create_popup_notitle_nobtn(ad,
274                                                                        _("IDS_ST_POP_ERROR"),
275                                                                        FALSE);
276                 }
277                 ad->handle = NULL;
278         }
279 }
280
281 static int setting_password_sim_create(void *cb)
282 {
283         SETTING_TRACE_BEGIN;
284         /* error check */
285         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
286
287         SettingPasswordUG *ad = (SettingPasswordUG *) cb;
288         int ret = 0;
289
290         ret = __create_sim_layout(ad);
291
292         if (ret < 0)
293                 return SETTING_RETURN_FAIL;
294
295         __init_tapi(ad);
296
297         setting_password_sim_create_ui(ad);
298
299         ad->focus_timer = ecore_timer_add(0.5, __setting_password_sim_rotate_cb, ad);
300
301         setting_view_password_sim.is_create = 1;
302
303         SETTING_TRACE_END;
304         return SETTING_RETURN_SUCCESS;
305 }
306
307 static int setting_password_sim_destroy(void *cb)
308 {
309         SETTING_TRACE_BEGIN;
310         /* error check */
311         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
312
313         SettingPasswordUG *ad = (SettingPasswordUG *) cb;
314
315         __deinit_tapi(ad);
316
317         if (ad->remove_timer) {
318                 ecore_timer_del(ad->remove_timer);
319                 ad->remove_timer = NULL;
320         }
321         if (ad->notify) {
322                 evas_object_del(ad->notify);
323                 ad->notify = NULL;
324         }
325         /*FREE(ad->guide_str); */
326
327         if (ad->ly_main != NULL) {
328                 evas_object_del(ad->ly_main);
329                 ad->ly_main = NULL;
330                 setting_view_password_sim.is_create = 0;
331         }
332         SETTING_TRACE_END;
333         return SETTING_RETURN_SUCCESS;
334 }
335
336 static int setting_password_sim_update(void *cb)
337 {
338         SETTING_TRACE_BEGIN;
339         /* error check */
340         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
341
342         SettingPasswordUG *ad = (SettingPasswordUG *) cb;
343
344         if (ad->ly_main != NULL) {
345                 evas_object_show(ad->ly_main);
346         }
347         if (ad->puk_verified_flag == TRUE && ad->view_type == SETTING_PW_TYPE_PIN_BLOCKED) {
348                 ad->puk_verified_flag = FALSE;
349                 SETTING_TRACE_DEBUG("view type : PIN1_BLOCKED, change view");
350                 if (ad->scroller) {
351                         elm_genlist_clear(ad->scroller);
352                         ADD_GL_SEPARATOR(ad->scroller)
353                         if (ad->cur_pwd) {
354                                 setting_password_sim_draw_2line_entry(ad, NULL);
355                         } else {
356                                 setting_password_sim_draw_1line_entry(ad, NULL);
357                                 ad->focus_timer = ecore_timer_add(0.5, __setting_password_sim_rotate_cb, ad);
358                         }
359                 }
360         }
361         return SETTING_RETURN_SUCCESS;
362 }
363
364 static int setting_password_sim_cleanup(void *cb)
365 {
366         /* error check */
367         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
368
369         SettingPasswordUG *ad = (SettingPasswordUG *) cb;
370
371         if (ad->ly_main != NULL) {
372                 evas_object_hide(ad->ly_main);
373         }
374
375         return SETTING_RETURN_SUCCESS;
376 }
377
378 /* ***************************************************
379  *
380  *general func
381  *
382  ***************************************************/
383
384 int setting_password_sim_create_ui(void *data)
385 {
386         /* error check */
387         retvm_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER,
388                  "[Setting > Password] Data parameter is NULL");
389
390         SettingPasswordUG *ad = (SettingPasswordUG *) data;
391
392         SETTING_TRACE_DEBUG("ad->view_type=%d ***", ad->view_type);
393
394         switch (ad->view_type) {
395                 case SETTING_PW_TYPE_SIM_LOCK_OFF:
396                 case SETTING_PW_TYPE_PIN_LOCK_ON:
397                 case SETTING_PW_TYPE_PIN_LOCK_OFF:
398                 case SETTING_PW_TYPE_PIN_BLOCKED:
399                 case SETTING_PW_TYPE_CHANGE_PIN:
400                 case SETTING_PW_TYPE_CHANGE_PIN2:
401                         setting_password_sim_draw_1line_entry(ad, NULL);
402                         break;
403                 case SETTING_PW_TYPE_SIM_LOCK_ON:
404                         setting_password_sim_draw_2line_entry(ad, NULL);
405                         break;
406                 case SETTING_PW_TYPE_PIN2_BLOCKED:
407                         setting_password_sim_draw_3line_entry(ad, NULL);
408                         break;
409                 default:
410                         SETTING_TRACE_DEBUG("%s*** Unknown Password Type. ***%s",
411                                             SETTING_FONT_BGREEN, SETTING_FONT_BLACK);
412                         break;
413         }
414
415         /** @todo this function always return 0, not verifying the function flow with the value */
416         return 0;
417 }
418
419 static void
420 setting_password_sim_entry_changed_cb(void *data, Evas_Object *obj,
421                                       void *event_info)
422 {
423         SETTING_TRACE_BEGIN;
424         retm_if(data == NULL, "[Setting > Password] Data parameter is NULL");
425         retm_if(obj == NULL, "[Setting > Password] Data parameter is NULL");
426         Setting_GenGroupItem_Data *list_item =
427             (Setting_GenGroupItem_Data *) data;
428         SettingPasswordUG *ad = (SettingPasswordUG *) list_item->userdata;
429         const char *entry_str = elm_entry_entry_get(obj);
430         list_item->sub_desc = (char *)g_strdup(entry_str);
431         bool isFoundEmptyEntry = FALSE;
432
433         elm_object_part_text_set(obj, "elm.guide", "");
434
435         do {
436                 if (ad->ed_pw1) {
437                         entry_str = ad->ed_pw1->sub_desc;
438                         if (NULL == entry_str || '\0' == entry_str[0]) {
439                                 isFoundEmptyEntry = TRUE;
440                                 elm_object_part_text_set(obj, "elm.guide", _("IDS_ST_HEADER_ENTER_PIN_ABB3"));
441                                 elm_object_item_signal_emit(ad->ed_pw1->item, "elm,state,eraser,hide", "");
442                                 break;
443                         } else if (ad->ed_pw1->isFocusFlag) {
444                                 elm_object_item_signal_emit(ad->ed_pw1->item, "elm,state,eraser,show", "");
445                                 break;
446                         }
447                 }
448                 if (ad->ed_pw2) {
449                         entry_str = ad->ed_pw2->sub_desc;
450                         if (NULL == entry_str || '\0' == entry_str[0]) {
451                                 isFoundEmptyEntry = TRUE;
452                                 elm_object_part_text_set(obj, "elm.guide", _("IDS_ST_HEADER_ENTER_PIN_ABB3"));
453                                 elm_object_item_signal_emit(ad->ed_pw2->item, "elm,state,eraser,hide", "");
454                                 break;
455                         } else if (ad->ed_pw2->isFocusFlag) {
456                                 elm_object_item_signal_emit(ad->ed_pw2->item, "elm,state,eraser,show", "");
457                                 break;
458                         }
459                 }
460                 if (ad->ed_pw3) {
461                         entry_str = ad->ed_pw3->sub_desc;
462                         if (NULL == entry_str || '\0' == entry_str[0]) {
463                                 isFoundEmptyEntry = TRUE;
464                                 elm_object_part_text_set(obj, "elm.guide", _("IDS_ST_HEADER_ENTER_PIN_ABB3"));
465                                 elm_object_item_signal_emit(ad->ed_pw3->item, "elm,state,eraser,hide", "");
466                                 break;
467                         } else if (ad->ed_pw3->isFocusFlag) {
468                                 elm_object_item_signal_emit(ad->ed_pw3->item, "elm,state,eraser,show", "");
469                                 break;
470                         }
471                 }
472
473         } while (0);
474
475         Eina_Bool item_disabled = elm_object_item_disabled_get(list_item->item);
476         if (item_disabled)
477                 return;
478
479         /* For disable toolbar (done) item */
480         bool disableFlag = isFoundEmptyEntry;
481         if (ad->view_type == SETTING_PW_TYPE_PIN_BLOCKED
482             || ad->view_type == SETTING_PW_TYPE_PIN2_BLOCKED) {
483                 if (ad->ed_pw1) {
484                         if (!ad->cur_pwd && ad->ed_pw1->eo_check && (safeStrLen(elm_entry_entry_get(ad->ed_pw1->eo_check)) < 8)) {
485                                 SETTING_TRACE_DEBUG("disable flag becomes TRUE");
486                                 disableFlag = TRUE;
487                         }
488                 }
489         } else {
490                 if (ad->ed_pw1 && ad->ed_pw1->eo_check && (safeStrLen(elm_entry_entry_get(ad->ed_pw1->eo_check)) < 4))
491                         disableFlag = TRUE;
492                 if (ad->ed_pw2 && ad->ed_pw2->eo_check && (safeStrLen(elm_entry_entry_get(ad->ed_pw2->eo_check)) < 4))
493                         disableFlag = TRUE;
494                 if (ad->ed_pw3 && ad->ed_pw3->eo_check && (safeStrLen(elm_entry_entry_get(ad->ed_pw3->eo_check)) < 4))
495                         disableFlag = TRUE;
496         }
497
498         if (disableFlag) {
499                 elm_object_disabled_set(ad->bottom_btn, EINA_TRUE);
500         } else {
501                 elm_object_disabled_set(ad->bottom_btn, EINA_FALSE);
502                 if (ad->err_desc && ad->err_desc->item) {
503                         elm_object_item_del(ad->err_desc->item);
504                         ad->err_desc = NULL;
505                 }
506         }
507 }
508
509 #if 0
510 static void __reached_max_pwlength_cb(void *data, Evas_Object *obj, void *event_info)
511 {
512         SETTING_TRACE_BEGIN;
513         retm_if(data == NULL, "Data parameter is NULL");
514         retm_if(!elm_object_focus_get(obj), "Entry is not focused");/*notify only when entry is being focused on. */
515
516         int err = 0;
517
518         /*Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data; */
519         /*SettingPasswordUG *ad = (SettingPasswordUG *) list_item->userdata; */
520
521         int haptic_return = 0;
522         haptic_device_h haptic_handle;
523         haptic_return = haptic_open(HAPTIC_DEVICE_0, &haptic_handle);
524         SETTING_TRACE("haptic_handle : %d", haptic_handle);
525         if (haptic_return < 0) {
526                 SETTING_TRACE_DEBUG("%s*** [ERR] Failed haptic_open ***%s",
527                                     SETTING_FONT_RED, SETTING_FONT_BLACK);
528         }
529
530         err = haptic_vibrate_file_with_detail(haptic_handle, "/usr/share/feedback/haptic/touch/touch.ivt", 1, HAPTIC_FEEDBACK_AUTO, HAPTIC_PRIORITY_MIN, NULL);
531
532         if (err < 0)
533                 SETTING_TRACE("Failed to play haptic");
534
535         haptic_close(haptic_handle);
536 }
537 #endif
538
539 static void __entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
540 {
541         SETTING_TRACE_BEGIN;
542         retm_if(data == NULL, "Data parameter is NULL");
543
544         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
545         SettingPasswordUG *ad = (SettingPasswordUG *) list_item->userdata;
546
547         if (elm_object_disabled_get(ad->bottom_btn) == EINA_FALSE) {
548                 elm_object_focus_set(obj, EINA_FALSE);
549                 /* call done cb. */
550                 setting_password_sim_done(ad);
551         }
552
553         if (obj == ad->ed_pw1->eo_check) {
554                 if (ad->view_type == SETTING_PW_TYPE_PIN_BLOCKED
555                     || ad->view_type == SETTING_PW_TYPE_PIN2_BLOCKED) {
556                         /* PUK should be 8 chars always */
557                         if (safeStrLen(elm_entry_entry_get(ad->ed_pw1->eo_check)) < SETTING_PW_UG_PUK_MAX_LENGTH) {
558                                 SETTING_TRACE_DEBUG("do not move focus to next entry.");
559                                 ad->ed_pw1->isFocusFlag = TRUE;
560                                 elm_object_focus_set(ad->ed_pw1->eo_check, EINA_TRUE);
561                                 return;
562                         }
563                 }
564                 if (ad->ed_pw2 && ad->ed_pw2->eo_check) {
565                         elm_object_focus_set(ad->ed_pw2->eo_check, EINA_TRUE);
566                         ad->ed_pw2->isFocusFlag = TRUE;
567                 }
568         } else if (obj == ad->ed_pw2->eo_check) {
569                 if (ad->ed_pw3 && ad->ed_pw3->eo_check) {
570                         elm_object_focus_set(ad->ed_pw3->eo_check, EINA_TRUE);
571                         ad->ed_pw3->isFocusFlag = TRUE;
572                 }
573         }
574 }
575
576 static void __entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
577 {
578         SETTING_TRACE_BEGIN;
579         retm_if(data == NULL, "Data parameter is NULL");
580
581         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
582         SettingPasswordUG *ad = (SettingPasswordUG *)list_item->userdata;
583
584         if (!elm_entry_is_empty(obj)) {
585                 elm_object_item_signal_emit(list_item->item, "elm,state,eraser,show", "");
586         }
587         elm_object_item_signal_emit(list_item->item, "elm,state,rename,hide", "");
588
589         if (ad == NULL)
590                 return;
591
592         if (ad->ed_pw1 && obj == ad->ed_pw1->eo_check) {
593                 ad->ed_pw1->isFocusFlag = TRUE;
594                 if (ad->ed_pw2)
595                         ad->ed_pw2->isFocusFlag = FALSE;
596                 if (ad->ed_pw3)
597                         ad->ed_pw3->isFocusFlag = FALSE;
598         } else if (ad->ed_pw2 && obj == ad->ed_pw2->eo_check) {
599                 ad->ed_pw2->isFocusFlag = TRUE;
600                 if (ad->ed_pw1)
601                         ad->ed_pw1->isFocusFlag = FALSE;
602                 if (ad->ed_pw3)
603                         ad->ed_pw3->isFocusFlag = FALSE;
604         } else if (ad->ed_pw3 && obj == ad->ed_pw3->eo_check) {
605                 ad->ed_pw3->isFocusFlag = TRUE;
606                 if (ad->ed_pw1)
607                         ad->ed_pw1->isFocusFlag = FALSE;
608                 if (ad->ed_pw2)
609                         ad->ed_pw2->isFocusFlag = FALSE;
610         }
611 }
612
613 static void __entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
614 {
615         SETTING_TRACE_BEGIN;
616         retm_if(data == NULL, "Data parameter is NULL");
617         retm_if(obj == NULL, "Data parameter is NULL");
618
619         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
620
621         list_item->isFocusFlag = FALSE;
622
623         if (list_item->item) {
624                 elm_object_item_signal_emit(list_item->item, "elm,state,eraser,hide", "");
625                 elm_object_item_signal_emit(list_item->item, "elm,state,rename,show", "");
626         }
627 }
628
629 int setting_password_sim_draw_1line_entry(void *data, void *cb)
630 {
631         SETTING_TRACE_BEGIN;
632         /* error check */
633         retvm_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER,
634                  "[Setting > Password] Data parameter is NULL");
635
636         SettingPasswordUG *ad = (SettingPasswordUG *) data;
637
638         switch (ad->view_type) {
639                 case SETTING_PW_TYPE_SIM_LOCK_OFF:
640                         ad->ed_pw1 =
641                             setting_create_Gendial_field_editfield(ad->scroller,
642                                                                    &(itc_editfield),
643                                                                    NULL, ad,
644                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
645                                                                    "IDS_ST_BODY_SIM_PASSWORD",
646                                                                    NULL,
647                                                                    setting_password_sim_entry_changed_cb,
648                                                                    __entry_focused_cb,
649                                                                    __entry_unfocused_cb,
650                                                                    NULL,
651                                                                    NULL,
652                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
653                                                                    TRUE, TRUE,
654                                                                    SETTING_PW_UG_SIM_MAX_LENGTH,
655                                                                    0, "0123456789", NULL);
656                         break;
657
658                 case SETTING_PW_TYPE_PIN_LOCK_ON:
659                 case SETTING_PW_TYPE_PIN_LOCK_OFF:
660                         ad->ed_pw1 =
661                             setting_create_Gendial_field_editfield(ad->scroller,
662                                                                    &(itc_editfield),
663                                                                    NULL, ad,
664                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
665                                                                    "IDS_ST_BODY_PIN", NULL,
666                                                                    setting_password_sim_entry_changed_cb,
667                                                                    __entry_focused_cb,
668                                                                    __entry_unfocused_cb,
669                                                                    __entry_activated_cb,
670                                                                    NULL,
671                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
672                                                                    TRUE, TRUE,
673                                                                    SETTING_PW_UG_PIN_MAX_LENGTH,
674                                                                    0, "0123456789", NULL);
675                         if (ad->ed_pw1)
676                                 ad->ed_pw1->guide_text = (char *)g_strdup(_("IDS_ST_HEADER_ENTER_PIN_ABB3"));
677                         break;
678                 case SETTING_PW_TYPE_PIN_BLOCKED:
679                         ad->ed_pw1 =
680                             setting_create_Gendial_field_editfield(ad->scroller,
681                                                                    &(itc_editfield),
682                                                                    NULL, ad,
683                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
684                                                                    "IDS_ST_BODY_PUK1_CODE",
685                                                                    NULL,
686                                                                    setting_password_sim_entry_changed_cb,
687                                                                    __entry_focused_cb,
688                                                                    __entry_unfocused_cb,
689                                                                    __entry_activated_cb,
690                                                                    NULL,
691                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
692                                                                    TRUE, TRUE,
693                                                                    SETTING_PW_UG_PUK_MAX_LENGTH,
694                                                                    0, "0123456789", NULL);
695                         break;
696                 case SETTING_PW_TYPE_CHANGE_PIN:
697                 case SETTING_PW_TYPE_CHANGE_PIN2:
698                         ad->ed_pw1 =
699                             setting_create_Gendial_field_editfield(ad->scroller,
700                                                                    &(itc_editfield),
701                                                                    NULL, ad,
702                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
703                                                                    PW_SHORT_GUIDE_CURRENT,
704                                                                    NULL,
705                                                                    setting_password_sim_entry_changed_cb,
706                                                                    __entry_focused_cb,
707                                                                    __entry_unfocused_cb,
708                                                                    __entry_activated_cb,
709                                                                    NULL,
710                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
711                                                                    TRUE, TRUE,
712                                                                    SETTING_PW_UG_PIN_MAX_LENGTH,
713                                                                    0, "0123456789", NULL);
714                         if (ad->ed_pw1)
715                                 ad->ed_pw1->guide_text = (char *)g_strdup(_("IDS_ST_HEADER_ENTER_PIN_ABB3"));
716                         break;
717                 default:
718                         break;
719         }
720
721         ad->ed_pw2 = NULL;
722         ad->ed_pw3 = NULL;
723         ad->cur_pwd = NULL;
724
725         return 0;
726 }
727
728 int setting_password_sim_clear_1line_entry(void *data)
729 {
730         /* error check */
731         retvm_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER,
732                  "[Setting > Password] Data parameter is NULL");
733
734         SettingPasswordUG *ad = (SettingPasswordUG *) data;
735         retv_if(NULL == ad->ed_pw1, -1);
736
737         ad->ed_pw1->sub_desc = NULL;
738         ad->ed_pw1->isFocusFlag = FALSE;
739
740         elm_entry_entry_set(ad->ed_pw1->eo_check, "");
741         elm_object_part_text_set(ad->ed_pw1->eo_check, "elm.guide", _("Enter PIN"));
742
743         return 0;
744 }
745
746 int setting_password_sim_draw_2line_entry(void *data, void *cb)
747 {
748         /* error check */
749         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
750
751         SettingPasswordUG *ad = (SettingPasswordUG *) data;
752
753         switch (ad->view_type) {
754                 case SETTING_PW_TYPE_SIM_LOCK_ON:
755                         ad->ed_pw1 =
756                             setting_create_Gendial_field_editfield(ad->scroller,
757                                                                    &(itc_editfield),
758                                                                    NULL, ad,
759                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
760                                                                    PW_SHORT_GUIDE_NEW,
761                                                                    NULL,
762                                                                    setting_password_sim_entry_changed_cb,
763                                                                    __entry_focused_cb,
764                                                                    __entry_unfocused_cb,
765                                                                    __entry_activated_cb,
766                                                                    NULL,
767                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
768                                                                    TRUE, TRUE,
769                                                                    SETTING_PW_UG_SIM_MAX_LENGTH,
770                                                                    0, "0123456789", NULL);
771
772                         ad->ed_pw2 =
773                             setting_create_Gendial_field_editfield(ad->scroller,
774                                                                    &(itc_editfield),
775                                                                    NULL, ad,
776                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
777                                                                    PW_SHORT_GUIDE_CONFIRM,
778                                                                    NULL,
779                                                                    setting_password_sim_entry_changed_cb,
780                                                                    __entry_focused_cb,
781                                                                    __entry_unfocused_cb,
782                                                                    NULL,
783                                                                    NULL,
784                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
785                                                                    TRUE, FALSE,
786                                                                    SETTING_PW_UG_SIM_MAX_LENGTH,
787                                                                    0, "0123456789", NULL);
788                         break;
789                 case SETTING_PW_TYPE_PIN_BLOCKED:
790                 case SETTING_PW_TYPE_CHANGE_PIN:
791                 case SETTING_PW_TYPE_CHANGE_PIN2:
792                         ad->ed_pw1 =
793                             setting_create_Gendial_field_editfield(ad->scroller,
794                                                                    &(itc_editfield),
795                                                                    NULL, ad,
796                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
797                                                                    PW_SHORT_GUIDE_NEW,
798                                                                    NULL,
799                                                                    setting_password_sim_entry_changed_cb,
800                                                                    __entry_focused_cb,
801                                                                    __entry_unfocused_cb,
802                                                                    __entry_activated_cb,
803                                                                    NULL,
804                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
805                                                                    TRUE, TRUE,
806                                                                    SETTING_PW_UG_PIN_MAX_LENGTH,
807                                                                    0, "0123456789", NULL);
808                         if (ad->ed_pw1)
809                                 ad->ed_pw1->guide_text = (char *)g_strdup(_("IDS_ST_HEADER_ENTER_PIN_ABB3"));
810
811                         ad->ed_pw2 =
812                             setting_create_Gendial_field_editfield(ad->scroller,
813                                                                    &(itc_editfield),
814                                                                    NULL, ad,
815                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
816                                                                    PW_SHORT_GUIDE_CONFIRM,
817                                                                    NULL,
818                                                                    setting_password_sim_entry_changed_cb,
819                                                                    __entry_focused_cb,
820                                                                    __entry_unfocused_cb,
821                                                                    __entry_activated_cb,
822                                                                    NULL,
823                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
824                                                                    TRUE, FALSE,
825                                                                    SETTING_PW_UG_PIN_MAX_LENGTH,
826                                                                    0, "0123456789", NULL);
827                         if (ad->ed_pw2)
828                                 ad->ed_pw2->guide_text = (char *)g_strdup(_("IDS_ST_HEADER_ENTER_PIN_ABB3"));
829                         break;
830                 default:
831                         break;
832         }
833
834         ad->ed_pw3 = NULL;
835         return 0;
836 }
837
838 int setting_password_sim_clear_2line_entry(void *data)
839 {
840         SETTING_TRACE_BEGIN;
841         /* error check */
842         retvm_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER,
843                  "[Setting > Password] Data parameter is NULL");
844
845         SettingPasswordUG *ad = (SettingPasswordUG *) data;
846
847         retv_if(NULL == ad->ed_pw1, -1);
848         ad->ed_pw1->sub_desc = NULL;
849         ad->ed_pw1->isFocusFlag = FALSE;
850         elm_entry_entry_set(ad->ed_pw1->eo_check, "");
851         elm_object_part_text_set(ad->ed_pw1->eo_check, "elm.guide", _("Enter PIN"));
852
853         retv_if(NULL == ad->ed_pw2, -1);
854         ad->ed_pw2->sub_desc = NULL;
855         ad->ed_pw2->isFocusFlag = FALSE;
856         elm_entry_entry_set(ad->ed_pw2->eo_check, "");
857         elm_object_part_text_set(ad->ed_pw1->eo_check, "elm.guide", _("Enter PIN"));
858         return 0;
859 }
860
861 int setting_password_sim_draw_3line_entry(void *data, void *cb)
862 {
863         /* error check */
864         retvm_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER,
865                  "[Setting > Password] Data parameter is NULL");
866
867         SettingPasswordUG *ad = (SettingPasswordUG *) data;
868
869         switch (ad->view_type) {
870                 case SETTING_PW_TYPE_PIN_BLOCKED:
871                         ad->ed_pw1 =
872                             setting_create_Gendial_field_editfield(ad->scroller,
873                                                                    &(itc_editfield),
874                                                                    NULL, ad,
875                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
876                                                                    "IDS_ST_BODY_PUK1_CODE",
877                                                                    NULL,
878                                                                    setting_password_sim_entry_changed_cb,
879                                                                    __entry_focused_cb,
880                                                                    __entry_unfocused_cb,
881                                                                    __entry_activated_cb,
882                                                                    NULL,
883                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
884                                                                    TRUE, TRUE,
885                                                                    SETTING_PW_UG_PUK_MAX_LENGTH,
886                                                                    0, "0123456789", NULL);
887
888                         ad->ed_pw2 =
889                             setting_create_Gendial_field_editfield(ad->scroller,
890                                                                    &(itc_editfield),
891                                                                    NULL, ad,
892                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
893                                                                    "IDS_ST_BODY_NEW_PIN1",
894                                                                    NULL,
895                                                                    setting_password_sim_entry_changed_cb,
896                                                                    __entry_focused_cb,
897                                                                    __entry_unfocused_cb,
898                                                                    __entry_activated_cb,
899                                                                    NULL,
900                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
901                                                                    TRUE, FALSE,
902                                                                    SETTING_PW_UG_PIN_MAX_LENGTH,
903                                                                    0, "0123456789", NULL);
904
905                         ad->ed_pw3 =
906                             setting_create_Gendial_field_editfield(ad->scroller,
907                                                                    &(itc_editfield),
908                                                                    NULL, ad,
909                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
910                                                                    "IDS_ST_BODY_CONFIRM_NEW_PIN1",
911                                                                    NULL,
912                                                                    setting_password_sim_entry_changed_cb,
913                                                                    __entry_focused_cb,
914                                                                    __entry_unfocused_cb,
915                                                                    NULL,
916                                                                    NULL,
917                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
918                                                                    TRUE, FALSE,
919                                                                    SETTING_PW_UG_PIN_MAX_LENGTH,
920                                                                    0, "0123456789", NULL);
921                         break;
922                 case SETTING_PW_TYPE_PIN2_BLOCKED:
923                         ad->ed_pw1 =
924                             setting_create_Gendial_field_editfield(ad->scroller,
925                                                                    &(itc_editfield),
926                                                                    NULL, ad,
927                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
928                                                                    "IDS_ST_BODY_PUK2", NULL,
929                                                                    setting_password_sim_entry_changed_cb,
930                                                                    __entry_focused_cb,
931                                                                    __entry_unfocused_cb,
932                                                                    __entry_activated_cb,
933                                                                    NULL,
934                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
935                                                                    TRUE, TRUE,
936                                                                    SETTING_PW_UG_PIN_MAX_LENGTH,
937                                                                    0, "0123456789", NULL);
938
939                         ad->ed_pw2 =
940                             setting_create_Gendial_field_editfield(ad->scroller,
941                                                                    &(itc_editfield),
942                                                                    NULL, ad,
943                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
944                                                                    "IDS_ST_BODY_NEW_PIN2",
945                                                                    NULL,
946                                                                    setting_password_sim_entry_changed_cb,
947                                                                    __entry_focused_cb,
948                                                                    __entry_unfocused_cb,
949                                                                    __entry_activated_cb,
950                                                                    NULL,
951                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
952                                                                    TRUE, FALSE,
953                                                                    SETTING_PW_UG_PIN_MAX_LENGTH,
954                                                                    0, "0123456789", NULL);
955
956                         ad->ed_pw3 =
957                             setting_create_Gendial_field_editfield(ad->scroller,
958                                                                    &(itc_editfield),
959                                                                    NULL, ad,
960                                                                    SWALLOW_Type_LAYOUT_EDITFIELD,
961                                                                    "IDS_ST_BODY_CONFIRM_NEW_PIN2",
962                                                                    NULL,
963                                                                    setting_password_sim_entry_changed_cb,
964                                                                    __entry_focused_cb,
965                                                                    __entry_unfocused_cb,
966                                                                    NULL,
967                                                                    NULL,
968                                                                    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY,
969                                                                    TRUE, FALSE,
970                                                                    SETTING_PW_UG_PIN_MAX_LENGTH,
971                                                                    0, "0123456789", NULL);
972                         break;
973
974                 default:
975                         break;
976         }
977         return 0;
978 }
979
980 int setting_password_sim_clear_3line_entry(void *data)
981 {
982         /* error check */
983         retvm_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER,
984                  "[Setting > Password] Data parameter is NULL");
985
986         SettingPasswordUG *ad = (SettingPasswordUG *) data;
987         /*Evas_Object *layout = NULL; */
988
989         retv_if(NULL == ad->ed_pw1, -1);
990         ad->ed_pw1->sub_desc = NULL;
991         ad->ed_pw1->isFocusFlag = FALSE;
992         elm_entry_entry_set(ad->ed_pw1->eo_check, "");
993         elm_object_part_text_set(ad->ed_pw1->eo_check, "elm.guide", _("Enter PUK"));
994
995         retv_if(NULL == ad->ed_pw2, -1);
996         ad->ed_pw2->sub_desc = NULL;
997         ad->ed_pw2->isFocusFlag = FALSE;
998         elm_entry_entry_set(ad->ed_pw2->eo_check, "");
999         elm_object_part_text_set(ad->ed_pw2->eo_check, "elm.guide", _("Enter PIN"));
1000
1001         retv_if(NULL == ad->ed_pw3, -1);
1002         ad->ed_pw3->sub_desc = NULL;
1003         ad->ed_pw3->isFocusFlag = FALSE;
1004         elm_entry_entry_set(ad->ed_pw3->eo_check, "");
1005         elm_object_part_text_set(ad->ed_pw3->eo_check, "elm.guide", _("Enter PIN"));
1006
1007         return 0;
1008 }
1009
1010 int setting_password_sim_check_1line_entry(void *data)
1011 {
1012         /* error check */
1013         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1014
1015         SettingPasswordUG *ad = (SettingPasswordUG *) data;
1016
1017         const char *entry_str = ad->ed_pw1->sub_desc;
1018         ad->focus_data = ad->ed_pw1;
1019
1020         /*  Length Check */
1021         int entry_str_len = safeStrLen(entry_str);
1022         switch (ad->view_type) {
1023                 case SETTING_PW_TYPE_PIN_LOCK_ON:
1024                 case SETTING_PW_TYPE_PIN_LOCK_OFF:
1025                 case SETTING_PW_TYPE_CHANGE_PIN:
1026                 case SETTING_PW_TYPE_CHANGE_PIN2: {
1027                                 if (entry_str_len < SETTING_PW_UG_PIN_MIN_LENGTH
1028                                     || entry_str_len > SETTING_PW_UG_PIN_MAX_LENGTH) {
1029                                         setting_password_sim_warning_entry_added_byte_popup
1030                                         (ad, SETTING_PW_UG_PIN_MIN_LENGTH, SETTING_PW_UG_PIN_MAX_LENGTH);
1031                                         return SETTING_ENTRY_REQUIRED_CORRECT_DIGIT_PW;
1032                                 }
1033                         }
1034                         break;
1035                 case SETTING_PW_TYPE_SIM_LOCK_OFF: {
1036                                 if (entry_str_len < SETTING_PW_UG_SIM_MIN_LENGTH
1037                                     || entry_str_len > SETTING_PW_UG_SIM_MAX_LENGTH) {
1038                                         setting_password_sim_warning_entry_added_byte_popup
1039                                         (ad, SETTING_PW_UG_SIM_MIN_LENGTH, SETTING_PW_UG_SIM_MAX_LENGTH);
1040                                         return SETTING_ENTRY_REQUIRED_CORRECT_DIGIT_PW;
1041                                 }
1042                         }
1043                 default:
1044                         break;
1045         }
1046         return SETTING_RETURN_SUCCESS;
1047 }
1048
1049 int setting_password_sim_check_2line_entry(void *data)
1050 {
1051         /* error check */
1052         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1053
1054         SettingPasswordUG *ad = (SettingPasswordUG *) data;
1055         if (ad->ed_pw1 == NULL || ad->ed_pw2 == NULL)
1056                 return SETTING_GENERAL_ERR_NULL_DATA_PARAMETER;
1057
1058         const char *entry_str1 = ad->ed_pw1->sub_desc;
1059         const char *entry_str2 = ad->ed_pw2->sub_desc;
1060         ad->focus_data = ad->ed_pw1;
1061
1062         /*  Match Check */
1063         if (0 != safeStrCmp(entry_str1, entry_str2)) {
1064                 setting_password_sim_clear_2line_entry(ad);
1065                 if (ad->view_type == SETTING_PW_TYPE_PIN_BLOCKED
1066                     || ad->view_type == SETTING_PW_TYPE_CHANGE_PIN
1067                     || ad->view_type == SETTING_PW_TYPE_PIN2_BLOCKED) {
1068                         setting_password_ug_display_desc(ad, _("IDS_IDLE_BODY_NEW_PIN_AND_CONFIRM_PIN_DO_NOT_MATCH"), FALSE);
1069                 } else if (ad->view_type == SETTING_PW_TYPE_CHANGE_PIN2) {
1070                         setting_password_ug_display_desc(ad, _("IDS_ST_BODY_NEW_PIN2_AND_CONFIRM_PIN2_DO_NOT_MATCH"), FALSE);
1071                 }
1072
1073                 return SETTING_ENTRY_NOT_MATCH_NEW_CONF_PW;
1074         }
1075
1076 #if SUPPORT_SIMLOCK
1077         /*  Length Check */
1078         int entry_str_len = safeStrLen(entry_str1);
1079         if (ad->view_type == SETTING_PW_TYPE_SIM_LOCK_ON) {
1080                 if (entry_str_len < SETTING_PW_UG_SIM_MIN_LENGTH
1081                     || entry_str_len > SETTING_PW_UG_SIM_MAX_LENGTH) {
1082                         setting_password_sim_warning_entry_added_byte_popup
1083                         (ad, SETTING_PW_UG_SIM_MIN_LENGTH, SETTING_PW_UG_SIM_MAX_LENGTH);
1084                         return SETTING_ENTRY_REQUIRED_CORRECT_DIGIT_PW;
1085                 }
1086         }
1087 #endif
1088
1089         return SETTING_RETURN_SUCCESS;
1090 }
1091
1092 void setting_password_sim_warning_entry_added_byte_popup(SettingPasswordUG *ad,
1093                                                          int min, int max)
1094 {
1095         char str[MAX_SPECIALIZITION_LEN + 1] = { 0 };
1096
1097         safeCopyStr(str, _("IDS_COM_BODY_TYPE_A_PIN_THAT_IS_4_TO_8_NUMBERS"), MAX_SPECIALIZITION_LEN);
1098         setting_password_ug_display_desc(ad, str, FALSE);
1099 }
1100
1101 int setting_password_sim_check_3line_entry(void *data)
1102 {
1103         /* error check */
1104         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1105
1106         SettingPasswordUG *ad = (SettingPasswordUG *) data;
1107
1108         const char *entry_str1 = ad->ed_pw1->sub_desc;
1109         const char *entry_str2 = ad->ed_pw2->sub_desc;
1110         const char *entry_str3 = ad->ed_pw3->sub_desc;
1111         ad->focus_data = ad->ed_pw1;
1112
1113         /*  Length Check */
1114         int entry_str1_len = safeStrLen(entry_str1);
1115         int entry_str2_len = safeStrLen(entry_str2);
1116         int entry_str3_len = safeStrLen(entry_str3);
1117
1118         /* PUK code always should be 8 chars. */
1119         if (entry_str1_len != SETTING_PW_UG_PUK_MAX_LENGTH) {
1120                 setting_password_sim_warning_entry_added_byte_popup
1121                 (ad, SETTING_PW_UG_PUK_MAX_LENGTH, SETTING_PW_UG_PUK_MAX_LENGTH);
1122                 return SETTING_ENTRY_REQUIRED_CORRECT_DIGIT_PW;
1123         }
1124         if (entry_str2_len < SETTING_PW_UG_PIN_MIN_LENGTH
1125             || entry_str2_len > SETTING_PW_UG_PIN_MAX_LENGTH) {
1126                 ad->focus_data = ad->ed_pw2;
1127                 setting_password_sim_warning_entry_added_byte_popup
1128                 (ad, SETTING_PW_UG_PIN_MIN_LENGTH, SETTING_PW_UG_PIN_MAX_LENGTH);
1129                 return SETTING_ENTRY_REQUIRED_CORRECT_DIGIT_PW;
1130         }
1131         if (entry_str3_len < SETTING_PW_UG_PIN_MIN_LENGTH
1132             || entry_str3_len > SETTING_PW_UG_PIN_MAX_LENGTH) {
1133                 ad->focus_data = ad->ed_pw3;
1134                 setting_password_sim_warning_entry_added_byte_popup
1135                 (ad, SETTING_PW_UG_PIN_MIN_LENGTH, SETTING_PW_UG_PIN_MAX_LENGTH);
1136                 return SETTING_ENTRY_REQUIRED_CORRECT_DIGIT_PW;
1137         }
1138
1139         return SETTING_RETURN_SUCCESS;
1140 }
1141
1142 static void setting_password_sim_done(void *data)
1143 {
1144         SETTING_TRACE_BEGIN;
1145         ret_if(data == NULL);
1146         SettingPasswordUG *ad = (SettingPasswordUG *) data;
1147
1148         app_control_h svc;
1149         if (app_control_create(&svc)) {
1150                 SETTING_TRACE_ERROR("app_control_create() failed");
1151                 return;
1152         }
1153
1154         SETTING_TRACE("ad->view_type:%d", ad->view_type);
1155         int ret = 0;
1156
1157         switch (ad->view_type) {
1158                 case SETTING_PW_TYPE_PIN_LOCK_ON: {
1159                                 SETTING_TRACE("case SETTING_PW_TYPE_PIN_LOCK_ON");
1160
1161                                 ret = setting_password_sim_check_1line_entry(ad);
1162
1163                                 if (ret == SETTING_RETURN_SUCCESS) {
1164                                         TelSimFacilityPw_t sim_sec_data = { 0, };
1165                                         int tapi_ret = TAPI_API_SUCCESS;
1166                                         const char *entry_str;
1167
1168                                         entry_str = ad->ed_pw1->sub_desc;
1169                                         if (isEmptyStr(entry_str)) {
1170                                                 ad->focus_data = ad->ed_pw1;
1171                                                 SETTING_TRACE_ERROR("[ERR] elm_entry_entry_get(ad->ed_pw1) return NULL!");
1172                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1173                                                 app_control_destroy(svc);
1174                                                 return;
1175                                         }
1176
1177                                         sim_sec_data.lock_type = TAPI_SIM_LOCK_SC;/*TAPI_SIM_PTYPE_PIN1 */
1178                                         sim_sec_data.pw = (unsigned char *)entry_str;
1179                                         sim_sec_data.pw_len = safeStrLen(entry_str);
1180
1181                                         tapi_ret = tel_enable_sim_facility(ad->handle, &sim_sec_data, setting_sim_facility_enable_cb, ad);
1182                                         setting_password_sim_clear_1line_entry(ad);
1183
1184                                         if (TAPI_API_SUCCESS != tapi_ret) {
1185                                                 ad->focus_data = ad->ed_pw1;
1186                                                 SETTING_TRACE_DEBUG("%s*** [ERR] tel_disable_sim_facility err=%d ***%s",
1187                                                                     SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
1188                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1189                                         } else {
1190                                                 /*  Success. Send Message to Caller for Modify Pin Lock slider status                                           */
1191                                         }
1192                                 } else {
1193                                         setting_password_sim_clear_1line_entry(ad);
1194                                 }
1195                         }
1196                         app_control_destroy(svc);
1197                         return;
1198                 case SETTING_PW_TYPE_PIN_LOCK_OFF: {
1199                                 SETTING_TRACE("case SETTING_PW_TYPE_PIN_LOCK_OFF");
1200
1201                                 ret = setting_password_sim_check_1line_entry(ad);
1202
1203                                 if (ret == SETTING_RETURN_SUCCESS) {
1204                                         TelSimFacilityPw_t sim_sec_data = { 0, };
1205                                         int tapi_ret = TAPI_API_SUCCESS;
1206                                         const char *entry_str;
1207
1208                                         entry_str = ad->ed_pw1->sub_desc;
1209                                         if (isEmptyStr(entry_str)) {
1210                                                 ad->focus_data = ad->ed_pw1;
1211                                                 SETTING_TRACE_ERROR("[ERR] elm_entry_entry_get(ad->ed_pw1) return NULL!");
1212                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1213                                                 app_control_destroy(svc);
1214                                                 return;
1215                                         }
1216
1217                                         sim_sec_data.lock_type = TAPI_SIM_LOCK_SC;/*TAPI_SIM_PTYPE_PIN1 */
1218                                         sim_sec_data.pw = (unsigned char *)entry_str;
1219                                         sim_sec_data.pw_len = safeStrLen(entry_str);
1220
1221                                         tapi_ret = tel_disable_sim_facility(ad->handle, &sim_sec_data, setting_sim_facility_disable_cb, ad);
1222                                         setting_password_sim_clear_1line_entry(ad);
1223
1224                                         if (TAPI_API_SUCCESS != tapi_ret) {
1225                                                 ad->focus_data = ad->ed_pw1;
1226                                                 SETTING_TRACE_DEBUG("%s*** [ERR] tel_disable_sim_facility err=%d ***%s",
1227                                                                     SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
1228                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1229                                         } else {
1230                                                 /*  Success. Send Message to Caller for Modify Pin Lock slider status                                           */
1231                                         }
1232                                 } else {
1233                                         setting_password_sim_clear_1line_entry(ad);
1234                                 }
1235                         }
1236                         app_control_destroy(svc);
1237                         return;
1238                 case SETTING_PW_TYPE_PIN_BLOCKED: {
1239                                 /*  PIN1 Status is "Blocked": User should input puk code and new pin1 code. */
1240                                 /*  If puk code is correct and success to modify pin1 code, display pin1 code change popup */
1241                                 /*  But, if this menu is "Pin Lock", pinlock status will not be changed. */
1242                                 SETTING_TRACE("case SETTING_PW_TYPE_PIN_BLOCKED");
1243                                 if (ad->cur_pwd == NULL) {
1244                                         ret = setting_password_sim_check_1line_entry(ad);
1245                                         if (ret == SETTING_RETURN_SUCCESS) {
1246                                                 ad->cur_pwd = (char *)strdup(ad->ed_pw1->sub_desc);
1247                                                 elm_genlist_clear(ad->scroller);
1248                                                 ADD_GL_SEPARATOR(ad->scroller)
1249                                                 setting_password_sim_draw_2line_entry(ad, NULL);
1250                                         } else {
1251                                                 setting_password_sim_clear_1line_entry(ad);
1252                                         }
1253                                 } else {
1254                                         ret = setting_password_sim_check_2line_entry(ad);
1255
1256                                         if (ret == SETTING_RETURN_SUCCESS) {
1257                                                 TelSimSecPw_t puk1_data = { 0, };
1258                                                 TelSimSecPw_t pin1_data = { 0, };
1259                                                 int tapi_ret = TAPI_API_SUCCESS;
1260                                                 const char *puk;
1261                                                 const char *new_pin1;
1262
1263                                                 puk = ad->cur_pwd;
1264                                                 new_pin1 = ad->ed_pw1->sub_desc;
1265
1266                                                 puk1_data.type = TAPI_SIM_PTYPE_PUK1;
1267                                                 puk1_data.pw = (unsigned char *)puk;
1268                                                 puk1_data.pw_len = safeStrLen(puk);
1269
1270                                                 pin1_data.type = TAPI_SIM_PTYPE_PIN1;
1271                                                 pin1_data.pw = (unsigned char *)new_pin1;
1272                                                 pin1_data.pw_len = safeStrLen(new_pin1);
1273
1274                                                 tapi_ret = tel_verify_sim_puks(ad->handle, &puk1_data, &pin1_data, setting_sim_verify_puks_cb, ad);
1275                                                 FREE(ad->cur_pwd);
1276                                                 ad->cur_pwd = NULL;
1277
1278                                                 setting_password_sim_clear_2line_entry(ad);
1279
1280                                                 if (TAPI_API_SUCCESS != tapi_ret) {
1281                                                         ad->focus_data = ad->ed_pw1;
1282                                                         SETTING_TRACE_DEBUG("%s*** [ERR] tel_verify_sim_puks err=%d ***%s",
1283                                                                             SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
1284                                                         setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1285                                                 } else {
1286                                                         /*  Success. Send Message to Caller for Modify Pin Lock slider status */
1287
1288                                                 }
1289                                         } else {
1290                                                 setting_password_sim_clear_2line_entry(ad);
1291                                         }
1292                                 }
1293                         }
1294                         app_control_destroy(svc);
1295                         return;
1296                 case SETTING_PW_TYPE_PIN2_BLOCKED: {
1297                                 SETTING_TRACE("case SETTING_PW_TYPE_PIN2_BLOCKED");
1298                                 ret = setting_password_sim_check_3line_entry(ad);
1299
1300                                 if (ret == SETTING_RETURN_SUCCESS) {
1301                                         TelSimSecPw_t puk2_data = { 0, };
1302                                         TelSimSecPw_t pin2_data = { 0, };
1303                                         int tapi_ret = TAPI_API_SUCCESS;
1304                                         const char *puk;
1305                                         const char *new_pin2;
1306
1307                                         puk = ad->ed_pw1->sub_desc;
1308                                         new_pin2 = ad->ed_pw2->sub_desc;
1309                                         if (isEmptyStr(puk)) {
1310                                                 ad->focus_data = ad->ed_pw1;
1311                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1312                                                 app_control_destroy(svc);
1313                                                 return;
1314                                         }
1315
1316                                         if (isEmptyStr(new_pin2)) {
1317                                                 ad->focus_data = ad->ed_pw2;
1318                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1319                                                 app_control_destroy(svc);
1320                                                 return;
1321                                         }
1322
1323                                         puk2_data.type = TAPI_SIM_PTYPE_PUK2;
1324                                         puk2_data.pw = (unsigned char *)puk;
1325                                         puk2_data.pw_len = safeStrLen(puk);
1326
1327                                         pin2_data.type = TAPI_SIM_PTYPE_PIN2;
1328                                         pin2_data.pw = (unsigned char *)new_pin2;
1329                                         pin2_data.pw_len = safeStrLen(new_pin2);
1330
1331                                         tapi_ret = tel_verify_sim_puks(ad->handle, &puk2_data, &pin2_data, setting_sim_verify_puks_cb, ad);
1332                                         setting_password_sim_clear_3line_entry(ad);
1333
1334                                         if (TAPI_API_SUCCESS != tapi_ret) {
1335                                                 ad->focus_data = ad->ed_pw1;
1336                                                 SETTING_TRACE_DEBUG("%s*** [ERR] tel_verify_sim_puks err=%d ***%s",
1337                                                                     SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
1338                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1339                                         } else {
1340                                                 /*  Success. Send Message to Caller for Modify Pin Lock slider status */
1341
1342                                         }
1343                                 } else {
1344                                         setting_password_sim_clear_3line_entry(ad);
1345                                 }
1346                         }
1347                         app_control_destroy(svc);
1348                         return;
1349                 case SETTING_PW_TYPE_CHANGE_PIN: {
1350                                 SETTING_TRACE("case SETTING_PW_TYPE_CHANGE_PIN");
1351                                 if (ad->cur_pwd) {
1352                                         SETTING_TRACE("step #2. new pins");
1353                                         ret = setting_password_sim_check_2line_entry(ad);
1354                                         if (ret == SETTING_RETURN_SUCCESS) {
1355                                                 const char *old_pw;
1356                                                 const char *new_pw;
1357                                                 TelSimSecPw_t sim_old_sec_data = { 0, };
1358                                                 TelSimSecPw_t sim_new_sec_data = { 0, };
1359                                                 int tapi_ret = TAPI_API_SUCCESS;
1360
1361                                                 old_pw = ad->cur_pwd;
1362                                                 new_pw = ad->ed_pw1->sub_desc;
1363                                                 sim_old_sec_data.type = TAPI_SIM_PTYPE_PIN1;
1364                                                 sim_new_sec_data.type = TAPI_SIM_PTYPE_PIN1;
1365                                                 sim_old_sec_data.pw = (unsigned char *)old_pw;
1366                                                 sim_old_sec_data.pw_len = safeStrLen(old_pw);
1367                                                 sim_new_sec_data.pw = (unsigned char *)new_pw;
1368                                                 sim_new_sec_data.pw_len = safeStrLen(new_pw);
1369
1370                                                 tapi_ret = tel_change_sim_pins(ad->handle, &sim_old_sec_data, &sim_new_sec_data, setting_sim_change_pins_cb, ad);
1371                                                 setting_password_sim_clear_2line_entry(ad);
1372
1373                                                 if (TAPI_API_SUCCESS != tapi_ret) {
1374                                                         ad->focus_data = ad->ed_pw1;
1375                                                         SETTING_TRACE_DEBUG("%s*** [ERR] TelTapiSimChangePIN err=%d ***%s",
1376                                                                             SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
1377                                                         setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1378                                                 }
1379                                         } else {
1380                                                 setting_password_sim_clear_2line_entry(ad);
1381                                         }
1382                                 } else {
1383                                         SETTING_TRACE("step #1. current pin");
1384                                         /* keep cur_pwd */
1385                                         ret = setting_password_sim_check_1line_entry(ad);
1386                                         if (ret == SETTING_RETURN_SUCCESS) {
1387                                                 ad->cur_pwd = (char *)strdup(ad->ed_pw1->sub_desc);
1388                                                 /*ad->update_change_pin1_flag = TRUE; */
1389                                                 /*setting_view_update(&setting_view_password_main, ad); */
1390
1391                                                 Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(ad->ed_pw1->eo_check);
1392                                                 if (imf_context) {
1393                                                         SETTING_TRACE_DEBUG("imf_context (0x%.8x) : clear event callbacks", imf_context);
1394                                                         ecore_imf_context_input_panel_event_callback_clear(imf_context);
1395                                                 }
1396
1397                                                 elm_genlist_clear(ad->scroller);
1398                                                 ADD_GL_SEPARATOR(ad->scroller)
1399                                                 setting_password_sim_draw_2line_entry(ad, NULL);
1400                                                 ad->focus_timer = ecore_timer_add(0.5, __setting_password_sim_rotate_cb, ad);
1401                                         } else {
1402                                                 setting_password_sim_clear_1line_entry(ad);
1403                                         }
1404                                 }
1405                         }
1406                         app_control_destroy(svc);
1407                         return;
1408                 case SETTING_PW_TYPE_CHANGE_PIN2: {
1409                                 SETTING_TRACE("case SETTING_PW_TYPE_CHANGE_PIN2");
1410                                 if (ad->cur_pwd) {
1411                                         SETTING_TRACE("step #2. new pin2s");
1412                                         ret = setting_password_sim_check_2line_entry(ad);
1413                                         if (ret == SETTING_RETURN_SUCCESS) {
1414                                                 const char *old_pw;
1415                                                 const char *new_pw;
1416                                                 TelSimSecPw_t sim_old_sec_data = { 0, };
1417                                                 TelSimSecPw_t sim_new_sec_data = { 0, };
1418                                                 int tapi_ret = TAPI_API_SUCCESS;
1419
1420                                                 old_pw = ad->cur_pwd;
1421                                                 new_pw = ad->ed_pw1->sub_desc;
1422
1423                                                 sim_old_sec_data.type = TAPI_SIM_PTYPE_PIN2;
1424                                                 sim_new_sec_data.type = TAPI_SIM_PTYPE_PIN2;
1425                                                 sim_old_sec_data.pw = (unsigned char *)old_pw;
1426                                                 sim_old_sec_data.pw_len = safeStrLen(old_pw);
1427                                                 sim_new_sec_data.pw = (unsigned char *)new_pw;
1428                                                 sim_new_sec_data.pw_len = safeStrLen(new_pw);
1429
1430                                                 tapi_ret = tel_change_sim_pins(ad->handle, &sim_old_sec_data, &sim_new_sec_data, setting_sim_change_pins_cb, ad);
1431                                                 setting_password_sim_clear_2line_entry(ad);
1432
1433                                                 if (TAPI_API_SUCCESS != tapi_ret) {
1434                                                         ad->focus_data = ad->ed_pw1;
1435                                                         SETTING_TRACE_DEBUG("%s*** [ERR] TelTapiSimChangePIN err=%d ***%s",
1436                                                                             SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
1437                                                         setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1438                                                 }
1439                                         } else {
1440                                                 setting_password_sim_clear_2line_entry(ad);
1441                                         }
1442                                 } else {
1443                                         SETTING_TRACE("step #1. current pin2");
1444                                         /* keep cur_pwd */
1445                                         ret = setting_password_sim_check_1line_entry(ad);
1446                                         if (ret == SETTING_RETURN_SUCCESS) {
1447                                                 ad->cur_pwd = (char *)strdup(ad->ed_pw1->sub_desc);
1448
1449                                                 Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(ad->ed_pw1->eo_check);
1450                                                 if (imf_context) {
1451                                                         SETTING_TRACE_DEBUG("imf_context (0x%.8x) : clear event callbacks", imf_context);
1452                                                         ecore_imf_context_input_panel_event_callback_clear(imf_context);
1453                                                 }
1454
1455                                                 elm_genlist_clear(ad->scroller);
1456                                                 ADD_GL_SEPARATOR(ad->scroller)
1457                                                 setting_password_sim_draw_2line_entry(ad, NULL);
1458                                                 ad->focus_timer = ecore_timer_add(0.5, __setting_password_sim_rotate_cb, ad);
1459                                         } else {
1460                                                 setting_password_sim_clear_1line_entry(ad);
1461                                         }
1462                                 }
1463                         }
1464                         app_control_destroy(svc);
1465                         return;
1466 #if SUPPORT_SIMLOCK
1467                 case SETTING_PW_TYPE_SIM_LOCK_ON: {
1468                                 SETTING_TRACE("case SETTING_PW_TYPE_SIM_LOCK_ON");
1469
1470                                 ret = setting_password_sim_check_2line_entry(ad);
1471
1472                                 if (ret == SETTING_RETURN_SUCCESS) {
1473                                         TelSimFacilityPw_t sim_sec_data = { 0, };
1474                                         int tapi_ret = TAPI_API_SUCCESS;
1475                                         const char *entry_str;
1476                                         entry_str = ad->ed_pw1->sub_desc;
1477                                         if (isEmptyStr(entry_str)) {
1478                                                 ad->focus_data = ad->ed_pw1;
1479                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1480                                                 app_control_destroy(svc);
1481                                                 return;
1482                                         }
1483
1484                                         sim_sec_data.lock_type = TAPI_SIM_LOCK_PS;/*TAPI_SIM_PTYPE_SIM */
1485                                         sim_sec_data.pw = (unsigned char *)entry_str;
1486                                         sim_sec_data.pw_len = safeStrLen(entry_str);
1487
1488                                         tapi_ret = tel_enable_sim_facility(ad->handle, &sim_sec_data, setting_sim_facility_enable_cb, ad);
1489                                         setting_password_sim_clear_2line_entry(ad);
1490
1491                                         SETTING_TRACE_SECURE_DEBUG("SIM Lock password : %s\n", (char *)(sim_sec_data.pw));
1492                                         if (TAPI_API_SUCCESS != tapi_ret) {
1493                                                 ad->focus_data = ad->ed_pw1;
1494                                                 SETTING_TRACE_DEBUG("%s*** [ERR] tel_enable_sim_facility err=%d ***%s",
1495                                                                     SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
1496                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1497                                         } else {
1498                                                 /*  Success. Send Message to Caller for Modify Pin Lock slider status */
1499
1500                                         }
1501                                 } else {
1502                                         setting_password_sim_clear_2line_entry(ad);
1503                                 }
1504                         }
1505                         app_control_destroy(svc);
1506                         return;
1507                 case SETTING_PW_TYPE_SIM_LOCK_OFF: {
1508                                 SETTING_TRACE("case SETTING_PW_TYPE_SIM_LOCK_OFF");
1509
1510                                 ret = setting_password_sim_check_1line_entry(ad);
1511                                 if (ret == SETTING_RETURN_SUCCESS) {
1512                                         TelSimFacilityPw_t sim_sec_data = { 0, };
1513                                         int tapi_ret = TAPI_API_SUCCESS;
1514                                         const char *entry_str;
1515
1516                                         entry_str = ad->ed_pw1->sub_desc;
1517                                         if (isEmptyStr(entry_str)) {
1518                                                 ad->focus_data = ad->ed_pw1;
1519                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1520                                                 app_control_destroy(svc);
1521                                                 return;
1522                                         }
1523
1524                                         sim_sec_data.lock_type = TAPI_SIM_LOCK_PS;/*TAPI_SIM_PTYPE_SIM */
1525                                         sim_sec_data.pw = (unsigned char *)entry_str;
1526                                         sim_sec_data.pw_len = safeStrLen(entry_str);
1527
1528                                         tapi_ret = tel_disable_sim_facility(ad->handle, &sim_sec_data, setting_sim_facility_disable_cb, ad);
1529                                         setting_password_sim_clear_1line_entry(ad);
1530
1531                                         if (TAPI_API_SUCCESS != tapi_ret) {
1532                                                 ad->focus_data = ad->ed_pw1;
1533                                                 SETTING_TRACE_DEBUG("%s*** [ERR] tel_disable_sim_facility err=%d ***%s",
1534                                                                     SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
1535                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1536                                         } else {
1537                                                 /*  Success. Send Message to Caller for Modify Pin Lock slider status */
1538
1539                                         }
1540                                 } else {
1541                                         setting_password_sim_clear_1line_entry(ad);
1542                                 }
1543                         }
1544                         app_control_destroy(svc);
1545                         return;
1546 #endif
1547 #if SUPPORT_FDN
1548                 case SETTING_PW_TYPE_FDN_MODE_ON: {
1549                                 SETTING_TRACE("case SETTING_PW_TYPE_FDN_MODE_ON");
1550                                 ret = setting_password_sim_check_1line_entry(ad);
1551
1552                                 if (ret == SETTING_RETURN_SUCCESS) {
1553                                         const char *entry_str;
1554                                         int tapi_ret = TAPI_API_INVALID_INPUT;
1555
1556                                         TelSimFacilityPw_t sim_sec_data = {0,};
1557                                         int ReqId;
1558
1559                                         entry_str = ad->ed_pw1->sub_desc;
1560                                         if (isEmptyStr(entry_str)) {
1561                                                 ad->focus_data = ad->ed_pw1;
1562                                                 SETTING_TRACE_ERROR("[ERR] elm_entry_entry_get(ad->ed_pw1) return NULL!");
1563                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1564                                                 app_control_destroy(svc);
1565                                                 return;
1566                                         }
1567                                         sim_sec_data.lock_type = TAPI_SIM_LOCK_FD;/*TAPI_SIM_PTYPE_PIN2; */
1568                                         sim_sec_data.pw_len = safeStrLen(entry_str);
1569                                         sim_sec_data.pw = (unsigned char *)entry_str;
1570
1571                                         tapi_ret = tel_enable_sim_facility(ad->handle, &sim_sec_data, setting_sim_facility_enable_cb, ad);
1572                                         setting_password_sim_clear_1line_entry(ad);
1573
1574                                         if (tapi_ret != TAPI_API_SUCCESS) {
1575                                                 ad->focus_data = ad->ed_pw1;
1576                                                 SETTING_TRACE_ERROR("[ERR] Failed to enable FDN. Tapi return %d", tapi_ret);
1577                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1578                                                 app_control_destroy(svc);
1579                                                 return;
1580                                         }
1581
1582                                         app_control_add_extra_data(svc, "result", ad->view_type_string);
1583                                         ug_send_result(ad->ug, svc);
1584                                         SETTING_TRACE("Send Result : %s\n", ad->view_type_string);
1585                                         app_control_destroy(svc);
1586                                         /*ug_destroy_me(ad->ug); */
1587                                 } else {
1588                                         /* check failed */
1589                                         setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), TRUE);
1590                                 }
1591                         }
1592                         break;
1593                 case SETTING_PW_TYPE_FDN_MODE_OFF: {
1594                                 SETTING_TRACE("case SETTING_PW_TYPE_FDN_MODE_OFF");
1595                                 ret = setting_password_sim_check_1line_entry(ad);
1596
1597                                 if (ret == SETTING_RETURN_SUCCESS) {
1598                                         const char *entry_str;
1599                                         int tapi_ret = TAPI_API_INVALID_INPUT;
1600
1601                                         TelSimFacilityPw_t sim_sec_data = {0,};
1602
1603                                         entry_str = ad->ed_pw1->sub_desc;
1604                                         if (isEmptyStr(entry_str)) {
1605                                                 ad->focus_data = ad->ed_pw1;
1606                                                 SETTING_TRACE_ERROR("[ERR] elm_entry_entry_get(ad->ed_pw1) return NULL!");
1607                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1608                                                 app_control_destroy(svc);
1609                                                 return;
1610                                         }
1611                                         sim_sec_data.lock_type = TAPI_SIM_LOCK_FD;/*TAPI_SIM_PTYPE_PIN2 */
1612                                         sim_sec_data.pw_len = safeStrLen(entry_str);
1613                                         sim_sec_data.pw = (unsigned char *)entry_str;
1614
1615                                         tapi_ret = tel_disable_sim_facility(ad->handle, &sim_sec_data, setting_sim_facility_disable_cb, ad);
1616                                         setting_password_sim_clear_1line_entry(ad);
1617
1618                                         if (tapi_ret != TAPI_API_SUCCESS) {
1619                                                 ad->focus_data = ad->ed_pw1;
1620                                                 SETTING_TRACE_ERROR("[ERR] Failed to disable FDN. Tapi return %d", tapi_ret);
1621                                                 setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), FALSE);
1622                                                 app_control_destroy(svc);
1623                                                 return;
1624                                         }
1625
1626                                         app_control_add_extra_data(svc, "result", ad->view_type_string);
1627                                         ug_send_result(ad->ug, svc);
1628                                         SETTING_TRACE("Send Result : %s\n", ad->view_type_string);
1629
1630                                         app_control_destroy(svc);
1631                                         /*ug_destroy_me(ad->ug); */
1632                                 } else {
1633                                         /* check failed */
1634                                         setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_ERROR"), TRUE);
1635                                 }
1636                         }
1637                         break;
1638 #endif
1639                 default:
1640                         app_control_destroy(svc);
1641                         return;
1642         }
1643
1644 #if SUPPORT_FDN
1645         app_control_add_extra_data(svc, "result", ad->view_type_string);
1646         ug_send_result(ad->ug, svc);
1647         SETTING_TRACE("Send Result : %s\n", ad->view_type_string);
1648
1649         app_control_destroy(svc);
1650         /* Send destroy request */
1651         ug_destroy_me(ad->ug);
1652 #endif
1653 }
1654
1655 void setting_password_sim_click_softkey_done_cb(void *data, Evas_Object *obj,
1656                                                 void *event_info)
1657 {
1658         SETTING_TRACE_BEGIN;
1659         /* error check */
1660         retm_if(data == NULL, "[Setting > Password] Data parameter is NULL");
1661
1662         SettingPasswordUG *ad = (SettingPasswordUG *) data;
1663
1664         if (ad->ed_pw1 && ad->ed_pw1->eo_check) {
1665                 elm_object_focus_set(ad->ed_pw1->eo_check, EINA_FALSE);
1666         }
1667         if (ad->ed_pw2 && ad->ed_pw2->eo_check) {
1668                 elm_object_focus_set(ad->ed_pw2->eo_check, EINA_FALSE);
1669         }
1670         if (ad->ed_pw3 && ad->ed_pw3->eo_check) {
1671                 elm_object_focus_set(ad->ed_pw3->eo_check, EINA_FALSE);
1672         }
1673
1674         if (ad->err_desc && ad->err_desc->item) {
1675                 elm_object_item_del(ad->err_desc->item);
1676                 ad->err_desc = NULL;
1677         }
1678
1679         setting_password_sim_done(ad);
1680 }
1681
1682 void setting_get_sim_lock_info_cb(TapiHandle *handle, int result, void *data, void *user_data)
1683 {
1684         SETTING_TRACE_BEGIN;
1685         ret_if(data == NULL || user_data == NULL);
1686
1687         TelSimPinOperationResult_t sec_rt = result;
1688         TelSimLockInfo_t *lock = data;
1689
1690         SettingPasswordUG *ad = (SettingPasswordUG *)user_data;
1691
1692         SETTING_TRACE_SECURE_DEBUG("sec_ret[%d], lock_type[%d], lock_status[%d], retry_count[%d]", sec_rt, lock->lock_type, lock->lock_status, lock->retry_count);
1693
1694         char temp[256] = {0,};
1695         if (lock->retry_count > 1)
1696                 snprintf(temp, 256, _(ATTEMPTS_DESC), lock->retry_count);
1697         else if (lock->retry_count > 0)
1698                 snprintf(temp, 256, _(ATTEMPT_DESC), lock->retry_count);
1699
1700         if (ad->err_desc && ad->err_desc->item) {
1701                 elm_object_item_del(ad->err_desc->item);
1702                 ad->err_desc = NULL;
1703         }
1704         ad->err_desc = setting_create_Gendial_field_helpitem_without_bottom_separator(
1705                            ad->scroller,
1706                            &(itc_multiline_text),
1707                            SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
1708                            temp);
1709 }
1710
1711 void setting_get_pin_lock_info_cb(TapiHandle *handle, int result, void *data, void *user_data)
1712 {
1713         SETTING_TRACE_BEGIN;
1714
1715         TelSimPinOperationResult_t sec_rt = result;
1716         TelSimLockInfo_t *lock = data;
1717
1718
1719         SettingPasswordUG *ad = (SettingPasswordUG *)user_data;
1720
1721         SETTING_TRACE_SECURE_DEBUG("sec_ret[%d], lock_type[%d], lock_status[%d], retry_count[%d]", sec_rt, lock->lock_type, lock->lock_status, lock->retry_count);
1722
1723         char temp[256] = {0,};
1724         if (ad->view_type == SETTING_PW_TYPE_CHANGE_PIN) {
1725                 char rtemp[SETTING_STR_SLP_LEN] = {0,};
1726                 if (ad->incorrect_pin1_flag) {
1727                         if (lock->retry_count > 1) {
1728                                 snprintf(rtemp, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_BODY_INCORRECT_PIN_E"), _(ATTEMPTS_DESC));
1729                                 snprintf(temp, SETTING_STR_SLP_LEN, rtemp, lock->retry_count);
1730                         } else {
1731                                 snprintf(rtemp, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_BODY_INCORRECT_PIN_E"), _(ATTEMPT_DESC));
1732                                 snprintf(temp, SETTING_STR_SLP_LEN, rtemp, lock->retry_count);
1733                         }
1734                 } else {
1735                         if (lock->retry_count > 1)
1736                                 snprintf(temp, 256, _(ATTEMPTS_DESC), lock->retry_count);
1737                         else if (lock->retry_count > 0)
1738                                 snprintf(temp, 256, _(ATTEMPT_DESC), lock->retry_count);
1739                 }
1740         } else if (ad->view_type == SETTING_PW_TYPE_CHANGE_PIN2) {
1741                 char rtemp[SETTING_STR_SLP_LEN] = {0,};
1742                 if (ad->incorrect_pin2_flag) {
1743                         if (lock->retry_count > 1) {
1744                                 snprintf(rtemp, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_POP_INCORRECT_PIN2"), _(ATTEMPTS_DESC));
1745                                 snprintf(temp, SETTING_STR_SLP_LEN, rtemp, lock->retry_count);
1746                         } else {
1747                                 snprintf(rtemp, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_POP_INCORRECT_PIN2"), _(ATTEMPT_DESC));
1748                                 snprintf(temp, SETTING_STR_SLP_LEN, rtemp, lock->retry_count);
1749                         }
1750                 } else {
1751                         if (lock->retry_count > 1)
1752                                 snprintf(temp, 256, _(ATTEMPTS_DESC), lock->retry_count);
1753                         else if (lock->retry_count > 0)
1754                                 snprintf(temp, 256, _(ATTEMPT_DESC), lock->retry_count);
1755                 }
1756         } else {
1757                 if (lock->retry_count > 1)
1758                         snprintf(temp, 256, _(ATTEMPTS_DESC), lock->retry_count);
1759                 else if (lock->retry_count > 0)
1760                         snprintf(temp, 256, _(ATTEMPT_DESC), lock->retry_count);
1761         }
1762
1763         if (ad->err_desc && ad->err_desc->item) {
1764                 elm_object_item_del(ad->err_desc->item);
1765                 ad->err_desc = NULL;
1766         }
1767         ad->err_desc = setting_create_Gendial_field_helpitem_without_bottom_separator(
1768                            ad->scroller,
1769                            &(itc_multiline_text),
1770                            SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
1771                            temp);
1772 }
1773
1774 void setting_sim_change_pins_cb(TapiHandle *handle, int result, void *data, void *user_data)
1775 {
1776         SETTING_TRACE_BEGIN;
1777         ret_if(!user_data || !data);
1778         TelSimPinOperationResult_t sec_rt = result;
1779         tapi_receive_info result_info = { 0, };
1780         TelSimSecResult_t *sim_event_data = (TelSimSecResult_t *) data;
1781         SETTING_TRACE_SECURE_DEBUG("sec_rt[%d]", sec_rt);
1782         SETTING_TRACE_SECURE_DEBUG("sim_event_data->type:%d", sim_event_data->type);
1783         SETTING_TRACE_SECURE_DEBUG("sim_event_data->retry_count[%d]", sim_event_data->retry_count);
1784
1785         if (TAPI_SIM_PIN_OPERATION_SUCCESS == sec_rt) {
1786                 if (TAPI_SIM_PTYPE_PIN1 == sim_event_data->type)
1787                         result_info.stat = SIM_PIN1_CHANGE_SUCCESS;
1788                 else if (TAPI_SIM_PTYPE_PIN2 == sim_event_data->type)
1789                         result_info.stat = SIM_PIN2_CHANGE_SUCCESS;
1790         } else if (TAPI_SIM_PIN_INCORRECT_PASSWORD == sec_rt) {
1791                 if (TAPI_SIM_PTYPE_PIN1 == sim_event_data->type) {
1792                         result_info.stat = SIM_INCORRECT_PIN1_CODE;
1793                         result_info.retry_cnt = sim_event_data->retry_count;
1794                 } else if (TAPI_SIM_PTYPE_PIN2 == sim_event_data->type) {
1795                         result_info.stat = SIM_INCORRECT_PIN2_CODE;
1796                         result_info.retry_cnt = sim_event_data->retry_count;
1797                 }
1798         } else if (TAPI_SIM_PUK_REQUIRED == sec_rt) {
1799                 if (TAPI_SIM_PTYPE_PIN1 == sim_event_data->type)
1800                         result_info.stat = SIM_PIN1_BLOCKED;
1801                 else if (TAPI_SIM_PTYPE_PIN2 == sim_event_data->type)
1802                         result_info.stat = SIM_PIN2_BLOCKED;
1803         } else {
1804                 SETTING_TRACE_DEBUG
1805                 ("%s*** [ERR] INCORRECTED ***%s",
1806                  SETTING_FONT_RED, SETTING_FONT_BLACK);
1807                 return;
1808         }
1809         setting_password_ug_display_result_popup(&result_info, user_data);
1810 }
1811
1812 void setting_sim_verify_puks_cb(TapiHandle *handle, int result, void *data, void *user_data)
1813 {
1814         SETTING_TRACE_BEGIN;
1815
1816         ret_if(!user_data || !data);
1817         SettingPasswordUG *ad = user_data;
1818         TelSimPinOperationResult_t sec_rt = result;
1819         tapi_receive_info result_info = { 0, };
1820         TelSimSecResult_t *sim_event_data = (TelSimSecResult_t *) data;
1821         ad->verify_puks_result = sim_event_data;
1822         SETTING_TRACE_SECURE_DEBUG("sec_rt[%d]", sec_rt);
1823         SETTING_TRACE_SECURE_DEBUG("sim_event_data->type:%d", sim_event_data->type);
1824         SETTING_TRACE_SECURE_DEBUG("sim_event_data->retry_count[%d]", sim_event_data->retry_count);
1825
1826         if (TAPI_SIM_PTYPE_PUK1 == sim_event_data->type) {
1827                 /*if (TAPI_SIM_PIN_REQUIRED == sec_rt){ */
1828                 if (TAPI_SIM_PIN_OPERATION_SUCCESS == sec_rt) {
1829                         SETTING_TRACE_DEBUG("SIM_PIN1_UNBLOCKED");
1830                         safeCopyStr(ad->view_type_string, "SETTING_PW_TYPE_PIN1_UNBLOCKED", sizeof("SETTING_PW_TYPE_PIN1_UNBLOCKED") + 1);
1831
1832                         char tmp_str[SETTING_STR_SLP_LEN] = {0,};
1833                         snprintf(tmp_str, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_POP_PUK1_VERIFIED"), _("IDS_ST_POP_PIN_UNBLOCKED"));
1834                         setting_password_ug_create_popup_notitle_nobtn(ad, tmp_str, TRUE);
1835                         return;
1836                 } else if (TAPI_SIM_PIN_INCORRECT_PASSWORD == sec_rt) {
1837                         result_info.stat = SIM_INCORRECT_PUK1_CODE;
1838                         result_info.retry_cnt = sim_event_data->retry_count;
1839                         ad->puk_verified_flag = TRUE;
1840                         setting_view_update(&setting_view_password_main, ad);
1841                 } else if (TAPI_SIM_PUK_INCORRECT_PASSWORD == sec_rt) {
1842                         if (sim_event_data->retry_count <= 0) {
1843                                 result_info.stat = SIM_PUK1_BLOCKED;
1844                                 result_info.retry_cnt = 0;
1845                         } else {
1846                                 result_info.stat = SIM_INCORRECT_PUK1_CODE;
1847                                 result_info.retry_cnt = sim_event_data->retry_count;
1848                                 ad->puk_verified_flag = TRUE;
1849                                 setting_view_update(&setting_view_password_main, ad);
1850                         }
1851                 } else if (TAPI_SIM_PERM_BLOCKED == sec_rt) {
1852                         result_info.stat = SIM_PUK1_BLOCKED;
1853                         result_info.retry_cnt = 0;
1854                 } else {
1855                         result_info.stat = SIM_UNKNOWN_ERROR;
1856                 }
1857         }
1858
1859         else if (TAPI_SIM_PTYPE_PUK2 == sim_event_data->type) {
1860                 SETTING_TRACE_DEBUG("sec_rt : %d", sec_rt);
1861                 /*if (TAPI_SIM_PUK_REQUIRED == sec_rt) */
1862                 if (TAPI_SIM_PIN_OPERATION_SUCCESS == sec_rt) {
1863                         SETTING_TRACE_DEBUG("SIM_PIN2_UNBLOCKED");
1864                         safeCopyStr(ad->view_type_string, "SETTING_PW_TYPE_PIN2_UNBLOCKED", sizeof("SETTING_PW_TYPE_PIN2_UNBLOCKED") + 1);
1865                         /*char tmp_str[SETTING_STR_SLP_LEN] = {0,}; */
1866                         /*snprintf(tmp_str, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_POP_PUK2_VERIFIED"), _("IDS_ST_POP_PIN2_UNBLOCKED")); */
1867                         setting_password_ug_create_popup_notitle_nobtn(ad, _("IDS_ST_POP_PIN2_UNBLOCKED"), TRUE);
1868                         return;
1869                 } else if (TAPI_SIM_PIN_INCORRECT_PASSWORD == sec_rt) {
1870                         SETTING_TRACE_DEBUG("stat : SIM_INCORRECT_PUK2_CODE");
1871                         result_info.stat = SIM_INCORRECT_PUK2_CODE;
1872                         result_info.retry_cnt = sim_event_data->retry_count;
1873                 } else if (TAPI_SIM_PUK_INCORRECT_PASSWORD == sec_rt) {
1874                         SETTING_TRACE_DEBUG("stat : SIM_INCORRECT_PUK2_CODE");
1875                         if (sim_event_data->retry_count <= 0) {
1876                                 result_info.stat = SIM_PUK2_BLOCKED;
1877                                 result_info.retry_cnt = 0;
1878                         } else {
1879                                 result_info.stat = SIM_INCORRECT_PUK2_CODE;
1880                                 result_info.retry_cnt = sim_event_data->retry_count;
1881                         }
1882                 } else if (TAPI_SIM_PERM_BLOCKED == sec_rt) {
1883                         result_info.stat = SIM_PUK2_BLOCKED;
1884                         result_info.retry_cnt = 0;
1885                 } else {
1886                         result_info.stat = SIM_UNKNOWN_ERROR;
1887                 }
1888         } else {
1889                 result_info.stat = SIM_UNKNOWN_ERROR;
1890         }
1891         setting_password_ug_display_result_popup(&result_info, user_data);
1892 }
1893
1894 void setting_sim_facility_enable_cb(TapiHandle *handle, int result, void *data, void *user_data)
1895 {
1896         SETTING_TRACE_BEGIN;
1897         ret_if(!user_data);
1898
1899         SETTING_TRACE_SECURE_DEBUG("result[%d]", result);
1900         if (result == TAPI_API_SIM_LOCKED) {    /* -503 error */
1901                 setting_password_ug_create_popup_notitle_nobtn(user_data, _("IDS_ST_HEADER_UNAVAILABLE"), TRUE);
1902                 return;
1903         }
1904         ret_if(!data);
1905         tapi_receive_info result_info = { 0, };
1906         TelSimFacilityResult_t *sim_event_data = (TelSimFacilityResult_t *) data;
1907
1908         SETTING_TRACE_SECURE_DEBUG("sim_event_data->type:%d", sim_event_data->type);
1909         SETTING_TRACE_SECURE_DEBUG("sim_event_data->retry_count[%d]", sim_event_data->retry_count);
1910
1911         /*  Sim Lock  */
1912         if (TAPI_SIM_LOCK_PS == sim_event_data->type) {
1913                 SETTING_TRACE("CASE TAPI_SIM_PTYPE_SIM == sim_event_data->type");
1914                 if (TAPI_SIM_PIN_OPERATION_SUCCESS == result)
1915                         result_info.stat = SIM_LOCK_ON_SUCCESS;
1916                 else if (TAPI_SIM_PIN_INCORRECT_PASSWORD == result)
1917                         result_info.stat = SIM_LOCK_INCORRECT_PASSWORD;
1918                 else {
1919                         SETTING_TRACE_DEBUG("%s*** [ERR] INCORRECTED ***%s",
1920                                             SETTING_FONT_RED,
1921                                             SETTING_FONT_BLACK);
1922                         return;
1923                 }
1924         }
1925         /*  Pin Lock */
1926         else if (TAPI_SIM_LOCK_SC == sim_event_data->type) {
1927                 SETTING_TRACE("CASE TAPI_SIM_PTYPE_PIN1 == sim_event_data->type");
1928                 if (TAPI_SIM_PIN_OPERATION_SUCCESS == result)
1929                         result_info.stat = SIM_PIN_LOCK_ON_SUCCESS;
1930                 else if (TAPI_SIM_PIN_INCORRECT_PASSWORD == result) {
1931                         result_info.stat = SIM_INCORRECT_PIN1_CODE;
1932                         result_info.retry_cnt = sim_event_data->retry_count;
1933                 } else if (TAPI_SIM_PUK_REQUIRED == result)
1934                         result_info.stat = SIM_PIN1_BLOCKED;
1935
1936                 /*  Pre CCF */
1937                 else if (TAPI_SIM_INCOMPATIBLE_PIN_OPERATION == result
1938                          || TAPI_SIM_CARD_ERROR == result) {
1939                         /*  popup */
1940                         result_info.stat = SIM_OPERATION_UNAVAILABLE;
1941                 } else {
1942                         SETTING_TRACE_DEBUG
1943                         ("%s*** [ERR] INCORRECTED ***%s",
1944                          SETTING_FONT_RED,
1945                          SETTING_FONT_BLACK);
1946                         return;
1947                 }
1948         }
1949         setting_password_ug_display_result_popup(&result_info, user_data);
1950 }
1951
1952 void setting_sim_facility_disable_cb(TapiHandle *handle, int result, void *data, void *user_data)
1953 {
1954         SETTING_TRACE_BEGIN;
1955         ret_if(!user_data);
1956
1957         SETTING_TRACE_SECURE_DEBUG("result[%d]", result);
1958         if (result == TAPI_API_SIM_LOCKED) { /* -503 error */
1959                 setting_password_ug_create_popup_notitle_nobtn(user_data, _("IDS_ST_HEADER_UNAVAILABLE"), TRUE);
1960                 return;
1961         }
1962         ret_if(!data);
1963         tapi_receive_info result_info = { 0, };
1964         TelSimFacilityResult_t *sim_event_data = (TelSimFacilityResult_t *) data;
1965
1966         SETTING_TRACE_SECURE_DEBUG("sim_event_data->type:%d", sim_event_data->type);
1967         SETTING_TRACE_SECURE_DEBUG("sim_event_data->retry_count[%d]", sim_event_data->retry_count);
1968
1969         /*  Sim Lock  */
1970         if (TAPI_SIM_LOCK_PS == sim_event_data->type) {
1971                 SETTING_TRACE_DEBUG("SIM lOCK");
1972                 if (TAPI_SIM_PIN_OPERATION_SUCCESS == result)
1973                         result_info.stat = SIM_LOCK_OFF_SUCCESS;
1974                 else if (TAPI_SIM_PIN_INCORRECT_PASSWORD == result)
1975                         result_info.stat = SIM_LOCK_INCORRECT_PASSWORD;
1976                 else {
1977                         SETTING_TRACE_DEBUG
1978                         ("%s*** [ERR] INCORRECTED ***%s",
1979                          SETTING_FONT_RED,
1980                          SETTING_FONT_BLACK);
1981                         return;
1982                 }
1983         }
1984         /*  Pin Lock */
1985         else if (TAPI_SIM_LOCK_SC == sim_event_data->type) {
1986                 SETTING_TRACE_DEBUG("PIN LOCK");
1987                 if (TAPI_SIM_PIN_OPERATION_SUCCESS == result)
1988                         result_info.stat = SIM_PIN_LOCK_OFF_SUCCESS;
1989                 else if (TAPI_SIM_PIN_INCORRECT_PASSWORD == result) {
1990                         result_info.stat = SIM_INCORRECT_PIN1_CODE;
1991                         result_info.retry_cnt = sim_event_data->retry_count;
1992                 } else if (TAPI_SIM_PUK_REQUIRED == result)
1993                         result_info.stat = SIM_PIN1_BLOCKED;
1994
1995                 /*  Pre CCF */
1996                 else if (TAPI_SIM_INCOMPATIBLE_PIN_OPERATION == result
1997                          || TAPI_SIM_CARD_ERROR == result) {
1998                         /*  popup */
1999                         result_info.stat = SIM_OPERATION_UNAVAILABLE;
2000                 } else {
2001                         SETTING_TRACE_DEBUG
2002                         ("%s*** [ERR] INCORRECTED ***%s",
2003                          SETTING_FONT_RED,
2004                          SETTING_FONT_BLACK);
2005                         return;
2006                 }
2007         }
2008         setting_password_ug_display_result_popup(&result_info, user_data);
2009 }
2010
2011 static void setting_password_ug_display_result_popup(tapi_receive_info *result,
2012                                                      SettingPasswordUG *ad)
2013 {
2014         SETTING_TRACE_BEGIN;
2015         switch (result->stat) {
2016                 case SIM_OPERATION_OK:
2017                 case SIM_LOCK_ON_SUCCESS:
2018                 case SIM_LOCK_OFF_SUCCESS:
2019                 case SIM_PIN_LOCK_ON_SUCCESS:
2020                 case SIM_PIN_LOCK_OFF_SUCCESS: {
2021                                 if (ad->view_type ==
2022                                     SETTING_PW_TYPE_SIM_LOCK_OFF) {
2023                                         int err = SETTING_RETURN_SUCCESS;
2024                                         /*  reset VCONF */
2025                                         setting_set_int_slp_key
2026                                         (INT_SLP_SETTING_SIM_LOCK_ATTEMPTS_LEFT,
2027                                          SIM_LOCK_ATTEMPS_MAX, &err);
2028                                         setting_retm_if(err == SETTING_RETURN_FAIL,
2029                                                         "[Error] set value of vconf fail.");
2030                                 }
2031                                 /*  Success to Operate */
2032                                 app_control_h svc;
2033                                 if (app_control_create(&svc))
2034                                         return;
2035
2036                                 app_control_add_extra_data(svc, "result", ad->view_type_string);
2037                                 ug_send_result(ad->ug, svc);
2038                                 SETTING_TRACE("Send Result : %s\n", ad->view_type_string);
2039
2040                                 app_control_destroy(svc);
2041                                 /* Send destroy request */
2042                                 ug_destroy_me(ad->ug);
2043                         }
2044                         break;
2045
2046                 case SIM_PIN1_BLOCKED: {
2047                                 SETTING_TRACE_DEBUG("SIM_PIN1_BLOCKED");
2048                                 /*ad->view_type = SETTING_PW_TYPE_PIN_BLOCKED; */
2049                                 /*  Success to Operate */
2050                                 app_control_h svc;
2051                                 if (app_control_create(&svc))
2052                                         return;
2053
2054                                 app_control_add_extra_data(svc, "result", "SETTING_PW_TYPE_PIN_BLOCKED");
2055                                 ug_send_result(ad->ug, svc);
2056                                 SETTING_TRACE("Send Result : %s\n", "SETTING_PW_TYPE_PIN_BLOCKED");
2057
2058                                 app_control_destroy(svc);
2059                                 /* Send destroy request */
2060                                 ug_destroy_me(ad->ug);
2061                         }
2062                         break;
2063                 case SIM_PIN2_BLOCKED: {
2064                                 SETTING_TRACE_DEBUG("SIM_PIN2_BLOCKED");
2065                                 /*ad->view_type = SETTING_PW_TYPE_PIN2_BLOCKED; */
2066                                 app_control_h svc;
2067                                 if (app_control_create(&svc))
2068                                         return;
2069
2070                                 app_control_add_extra_data(svc, "result", "SETTING_PW_TYPE_PIN2_BLOCKED");
2071                                 ug_send_result(ad->ug, svc);
2072                                 SETTING_TRACE("Send Result : %s\n", "SETTING_PW_TYPE_PIN2_BLOCKED");
2073
2074                                 app_control_destroy(svc);
2075                                 /* Send destroy request */
2076                                 ug_destroy_me(ad->ug);
2077                                 /*safeCopyStr(ad->view_type_string, "SETTING_PW_TYPE_PIN2_BLOCKED", safeStrLen("SETTING_PW_TYPE_PIN2_BLOCKED")+1); */
2078                                 /*setting_password_ug_create_popup_notitle_nobtn(ad, */
2079                                 /*                                             _("IDS_ST_POP_PIN2_BLOCKED"), TRUE); */
2080                         }
2081                         break;
2082                 case SIM_LOCK_INCORRECT_PASSWORD: {
2083                                 SETTING_TRACE_DEBUG("SIM LOCK INCORRECT PASSWORD");
2084                                 ad->focus_data = ad->ed_pw1;
2085                                 setting_password_ug_display_desc(ad, PW_ERR_DESC, FALSE);
2086                         }
2087                         break;
2088                 case SIM_INCORRECT_PIN1_CODE: {
2089                                 if (ad->view_type == SETTING_PW_TYPE_CHANGE_PIN) {
2090                                         ad->incorrect_pin1_flag = TRUE;
2091                                         FREE(ad->cur_pwd);
2092                                         elm_genlist_clear(ad->scroller);
2093                                         ADD_GL_SEPARATOR(ad->scroller)
2094                                         setting_password_sim_draw_1line_entry(ad, NULL);
2095                                         ad->focus_timer = ecore_timer_add(0.5, __setting_password_sim_rotate_cb, ad);
2096                                         return;
2097                                 }
2098
2099                                 const char *ret_str = NULL;
2100                                 char tmp_str[SETTING_STR_SLP_LEN] = {0,};
2101
2102                                 if (result->retry_cnt > 1) {
2103                                         /* there has '%d' in 'IDS_ST_POP_INCORRECT_PIN_PD_ATTEMPTS_LEFT', must transform */
2104                                         char tmp_str2[SETTING_STR_SLP_LEN] = {0,};
2105                                         snprintf(tmp_str2, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_BODY_INCORRECT_PIN_E"), _(ATTEMPTS_DESC));
2106                                         int ret = snprintf(tmp_str, SETTING_STR_SLP_LEN, tmp_str2, result->retry_cnt);
2107                                         setting_retm_if(ret < 0, "snprintf fail");
2108                                         ret_str = tmp_str;
2109                                 } else {
2110                                         char tmp_str2[SETTING_STR_SLP_LEN] = {0,};
2111                                         snprintf(tmp_str2, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_BODY_INCORRECT_PIN_E"), _(ATTEMPT_DESC));
2112                                         int ret = snprintf(tmp_str, SETTING_STR_SLP_LEN, tmp_str2, result->retry_cnt);
2113                                         setting_retm_if(ret < 0, "snprintf fail");
2114                                         ret_str = tmp_str;
2115                                         /*ret_str = _("IDS_ST_POP_INCORRECT_PIN1_ATTEMPT_LEFT"); */
2116                                 }
2117
2118                                 ad->focus_data = ad->ed_pw1;
2119 #ifdef SUPPORT_POPUP
2120                                 setting_password_ug_create_popup_notitle_nobtn(ad, (char *)ret_str, FALSE);
2121 #else
2122                                 setting_password_ug_display_desc(ad, (char *)ret_str, FALSE);
2123 #endif
2124                         }
2125                         break;
2126                 case SIM_INCORRECT_PIN2_CODE: {
2127                                 if (ad->view_type == SETTING_PW_TYPE_CHANGE_PIN2) {
2128                                         ad->incorrect_pin2_flag = TRUE;
2129                                         FREE(ad->cur_pwd);
2130                                         elm_genlist_clear(ad->scroller);
2131                                         ADD_GL_SEPARATOR(ad->scroller)
2132                                         setting_password_sim_draw_1line_entry(ad, NULL);
2133                                         ad->focus_timer = ecore_timer_add(0.5, __setting_password_sim_rotate_cb, ad);
2134                                         return;
2135                                 }
2136
2137                                 char *ret_str = NULL;
2138                                 char tmp_str[SETTING_STR_SLP_LEN] = {0,};
2139
2140                                 if (result->retry_cnt > 1) {
2141                                         /* there has '%d' in 'IDS_ST_POP_INCORRECT_PIN_PD_ATTEMPTS_LEFT', must transform */
2142                                         char tmp_str2[SETTING_STR_SLP_LEN] = {0,};
2143                                         snprintf(tmp_str2, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_POP_INCORRECT_PIN2"), _(ATTEMPTS_DESC));
2144                                         int ret = snprintf(tmp_str, SETTING_STR_SLP_LEN, tmp_str2, result->retry_cnt);
2145                                         setting_retm_if(ret < 0, "snprintf fail");
2146                                         ret_str = tmp_str;
2147                                 } else {
2148                                         char tmp_str2[SETTING_STR_SLP_LEN] = {0,};
2149                                         snprintf(tmp_str2, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_POP_INCORRECT_PIN2"), _(ATTEMPT_DESC));
2150                                         int ret = snprintf(tmp_str, SETTING_STR_SLP_LEN, tmp_str2, result->retry_cnt);
2151                                         setting_retm_if(ret < 0, "snprintf fail");
2152                                         ret_str = tmp_str;
2153                                         /*ret_str = _("IDS_ST_POP_INCORRECT_PIN1_ATTEMPT_LEFT"); */
2154                                 }
2155
2156                                 ad->focus_data = ad->ed_pw1;
2157 #ifdef SUPPORT_POPUP
2158                                 setting_password_ug_create_popup_notitle_nobtn(ad, ret_str, FALSE);
2159 #else
2160                                 setting_password_ug_display_desc(ad, ret_str, FALSE);
2161 #endif
2162                         }
2163                         break;
2164                 case SIM_INCORRECT_PUK1_CODE: {
2165                                 char *ret_str = NULL;
2166                                 char tmp_str[SETTING_STR_SLP_LEN] = {0,};
2167
2168                                 if (result->retry_cnt > 1) {
2169                                         /* there has '%d' in 'IDS_ST_POP_INCORRECT_PUK1_PD_ATTEMPTS_LEFT', must transform */
2170                                         int ret = snprintf(tmp_str, SETTING_STR_SLP_LEN, PUK1_ERR_DESC, result->retry_cnt);
2171                                         setting_retm_if(ret < 0, "snprintf fail");
2172                                         ret_str = tmp_str;
2173                                 } else {
2174                                         ret_str = _("IDS_ST_POP_INCORRECT_PUK1_CODE");
2175                                 }
2176
2177                                 ad->focus_data = ad->ed_pw1;
2178 #ifdef SUPPORT_POPUP
2179                                 setting_password_ug_create_popup_notitle_nobtn(ad, ret_str, FALSE);
2180 #else
2181                                 setting_password_ug_display_desc(ad, ret_str, FALSE);
2182 #endif
2183                         }
2184                         break;
2185                 case SIM_INCORRECT_PUK2_CODE: {
2186                                 char *ret_str = NULL;
2187                                 char tmp_str[SETTING_STR_SLP_LEN] = {0,};
2188
2189                                 if (result->retry_cnt > 1) {
2190                                         /* there has '%d' in 'IDS_ST_POP_INCORRECT_PIN_PD_ATTEMPTS_LEFT', must transform */
2191                                         char tmp_str2[SETTING_STR_SLP_LEN] = {0,};
2192                                         snprintf(tmp_str2, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_POP_INCORRECT_PUK2"), _(ATTEMPTS_DESC));
2193                                         int ret = snprintf(tmp_str, SETTING_STR_SLP_LEN, tmp_str2, result->retry_cnt);
2194                                         setting_retm_if(ret < 0, "snprintf fail");
2195                                         ret_str = tmp_str;
2196                                 } else {
2197                                         char tmp_str2[SETTING_STR_SLP_LEN] = {0,};
2198                                         snprintf(tmp_str2, SETTING_STR_SLP_LEN, "%s. %s.", _("IDS_ST_POP_INCORRECT_PUK2"), _(ATTEMPT_DESC));
2199                                         int ret = snprintf(tmp_str, SETTING_STR_SLP_LEN, tmp_str2, result->retry_cnt);
2200                                         setting_retm_if(ret < 0, "snprintf fail");
2201                                         ret_str = tmp_str;
2202                                         ret_str = _("IDS_ST_POP_INCORRECT_PIN1_ATTEMPT_LEFT");
2203                                 }
2204                                 ad->focus_data = ad->ed_pw1;
2205 #ifdef SUPPORT_POPUP
2206                                 setting_password_ug_create_popup_notitle_nobtn(ad, ret_str, FALSE);
2207 #else
2208                                 setting_password_ug_display_desc(ad, ret_str, FALSE);
2209 #endif
2210                         }
2211                         break;
2212
2213                 case SIM_PIN1_CHANGE_SUCCESS: {
2214                                 SETTING_TRACE_DEBUG("SIM_PIN1_CHANGE_SUCCESS");
2215                                 /*ad->view_type = SETTING_PW_TYPE_PIN_BLOCKED; */
2216                                 /*  Success to Operate */
2217                                 app_control_h svc;
2218                                 if (app_control_create(&svc))
2219                                         return;
2220
2221                                 app_control_add_extra_data(svc, "result", ad->view_type_string);
2222                                 ug_send_result(ad->ug, svc);
2223                                 SETTING_TRACE("Send Result : %s\n", ad->view_type_string);
2224
2225                                 app_control_destroy(svc);
2226                                 /* Send destroy request */
2227                                 ug_destroy_me(ad->ug);
2228                         }
2229                         /*setting_password_ug_create_popup_notitle_nobtn(ad, */
2230                         /*                                             _("IDS_ST_POP_PIN1_CHANGED"), TRUE); */
2231                         break;
2232                 case SIM_PIN2_CHANGE_SUCCESS:
2233                         setting_password_ug_create_popup_notitle_nobtn(ad,
2234                                                                        _("IDS_ST_POP_PIN2_CHANGED"), TRUE);
2235                         break;
2236                 case SIM_PIN1_UNBLOCKED:
2237                         SETTING_TRACE_DEBUG("SIM_PIN1_UNBLOCKED");
2238                         safeCopyStr(ad->view_type_string, "SETTING_PW_TYPE_PIN_LOCK_ON", safeStrLen("SETTING_PW_TYPE_PIN_LOCK_ON") + 1);
2239                         setting_password_ug_create_popup_notitle_nobtn(ad,
2240                                                                        _("IDS_ST_POP_PIN_UNBLOCKED"), TRUE);
2241                         break;
2242                 case SIM_PIN2_UNBLOCKED:
2243                         setting_password_ug_create_popup_notitle_nobtn(ad,
2244                                                                        _("IDS_ST_POP_PIN2_UNBLOCKED"), TRUE);
2245                         break;
2246                 case SIM_PUK1_BLOCKED: {
2247                                 char *ret_str = NULL;
2248                                 ret_str = PUK1_BLOCKED;
2249
2250                                 safeCopyStr(ad->view_type_string, "SETTING_PW_TYPE_PUK1_BLOCKED", safeStrLen("SETTING_PW_TYPE_PUK1_BLOCKED") + 1);
2251                                 setting_password_ug_create_popup_notitle_nobtn(ad,
2252                                                                                ret_str, TRUE);
2253                                 /*  Phone blocked. Call Permernent UG */
2254                         }
2255                         break;
2256                 case SIM_PUK2_BLOCKED: {
2257                                 app_control_h svc;
2258                                 if (app_control_create(&svc))
2259                                         return;
2260
2261                                 app_control_add_extra_data(svc, "result", "SETTING_PW_TYPE_PUK2_BLOCKED");
2262                                 ug_send_result(ad->ug, svc);
2263                                 SETTING_TRACE("Send Result : %s\n", "SETTING_PW_TYPE_PUK2_BLOCKED");
2264
2265                                 app_control_destroy(svc);
2266                                 /* Send destroy request */
2267                                 ug_destroy_me(ad->ug);
2268                         }
2269                         /*  Call Permernent UG */
2270                         break;
2271                 case SIM_REQUIRED_PUK_CODE:
2272                         SETTING_TRACE_DEBUG("SIM_REQUIRED_PUK_CODE");
2273                         safeCopyStr(ad->view_type_string, "SETTING_PW_TYPE_PIN_BLOCKED", safeStrLen("SETTING_PW_TYPE_PIN_BLOCKED") + 1);
2274                         setting_password_ug_create_popup_notitle_nobtn(ad,
2275                                                                        _("IDS_ST_POP_PIN1_BLOCKED"), TRUE);
2276                         break;
2277                 case SIM_OPERATION_UNAVAILABLE:
2278                         setting_password_ug_create_popup_notitle_nobtn(ad,
2279                                                                        _("IDS_ST_HEADER_UNAVAILABLE"), TRUE);
2280                         break;
2281                 case SIM_UNKNOWN_ERROR:
2282                         setting_password_ug_create_popup_notitle_nobtn(ad,
2283                                                                        _("IDS_CST_POP_UNKNOWN_OPERATION"), FALSE);
2284                         break;
2285                 case SIM_ERROR:
2286                 case SIM_REQ_PIN:
2287                 case SIM_OPERATION_OFF:
2288                 case SIM_LOCK_ON_FAIL:
2289                         SETTING_TRACE_DEBUG("SIM_LOCK_ON_FAIL");
2290                         {
2291                                 if (result->retry_cnt > 0) {
2292                                         setting_password_ug_display_desc(ad, PW_ERR_DESC, FALSE);
2293                                 } else {
2294                                         char tmp_str[SETTING_STR_SLP_LEN] = {0,};
2295                                         snprintf(tmp_str, SETTING_STR_SLP_LEN, PW_ERR_DELAY_DESC, PW_ERR_DELAY_TIME);
2296                                         safeCopyStr(ad->view_type_string, "SETTING_PW_TYPE_SIM_LOCK_DISABLE", safeStrLen("SETTING_PW_TYPE_SIM_LOCK_DISABLE") + 1);
2297                                         setting_password_ug_create_popup_notitle_nobtn(ad, tmp_str, TRUE);
2298                                 }
2299                         }
2300                         break;
2301                 case SIM_PIN1_CHANGE_FAIL:
2302                 case SIM_PIN2_CHANGE_FAIL:
2303                         setting_password_ug_create_popup_notitle_nobtn(ad,
2304                                                                        _("Change Failed"), TRUE);
2305                         break;
2306                 default:
2307                         break;
2308         }
2309
2310         SETTING_TRACE_END;
2311 }