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