fix for applying wayland (removing X)
[apps/home/settings.git] / setting-password / src / setting-password-fingerprint.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-fingerprint.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 <fingerprint_manager.h>
31 #include <fingerprint_event.h>
32
33 static int setting_password_fingerprint_create(void *cb);
34 static int setting_password_fingerprint_destroy(void *cb);
35 static int setting_password_fingerprint_update(void *cb);
36 static int setting_password_fingerprint_cleanup(void *cb);
37
38 setting_view setting_view_password_fingerprint = {
39         .create = setting_password_fingerprint_create,
40         .destroy = setting_password_fingerprint_destroy,
41         .update = setting_password_fingerprint_update,
42         .cleanup = setting_password_fingerprint_cleanup,
43 };
44
45 static void setting_password_fingerprint_done(void *data);
46
47
48 /* ***************************************************
49  *
50  *basic func
51  *
52  ***************************************************/
53
54 static char *setting_password_fingerprint_get_title_str(void *data)
55 {
56         retvm_if(data == NULL, NULL,
57                  "[Setting > Password] Data parameter is NULL");
58         SettingPasswordUG *ad = (SettingPasswordUG *) data;
59
60         switch (ad->view_type) {
61                 case SETTING_PW_TYPE_SET_FP_ALT_PASSWORD:
62                         return "Create password";
63                         break;
64                 case SETTING_PW_TYPE_VERIFY_FP_ALT_PASSWORD:
65                         return "Confirm password";
66                         break;
67                 case SETTING_PW_TYPE_CHANGE_FP_ALT_PASSWORD:
68                         return "Change password";
69                         break;
70                 default:
71                         SETTING_TRACE_DEBUG("%s*** Unknown Password Type. ***%s",
72                                             SETTING_FONT_BGREEN, SETTING_FONT_BLACK);
73                         break;
74         }
75         return NULL;
76
77 }
78
79 static Eina_Bool setting_password_fingerprint_click_softkey_cancel_cb(void *data, Elm_Object_Item *it)
80 {
81         SETTING_TRACE_BEGIN;
82         /* error check */
83         retvm_if(data == NULL, EINA_FALSE, "[Setting > Password] Data parameter is NULL");
84
85         SettingPasswordUG *ad = (SettingPasswordUG *) data;
86
87         /* if IME is displayed, hide IME. or Destroy password ug. */
88         if (ad->ed_pw1 && ad->ed_pw1->isFocusFlag == TRUE && elm_object_focus_get(ad->ed_pw1->eo_check)) {
89                 SETTING_TRACE_DEBUG("wait to hide IME");
90                 elm_object_focus_set(ad->ed_pw1->eo_check, EINA_FALSE);
91                 return EINA_FALSE;
92         }
93
94         if (ad->focus_timer) {
95                 ecore_timer_del(ad->focus_timer);
96                 ad->focus_timer = NULL;
97         }
98
99         /* send result : Cancel */
100         app_control_h svc;
101         if (app_control_create(&svc) == 0) {
102                 app_control_add_extra_data(svc, "result", "Cancel");
103                 ug_send_result(ad->ug, svc);
104                 SETTING_TRACE("Send Result : %s\n", "Cancel");
105
106                 app_control_destroy(svc);
107         }
108         /* Send destroy request */
109         ug_destroy_me(ad->ug);
110
111         return EINA_TRUE;
112 }
113
114 static int __create_fingerprint_layout(void *data)
115 {
116         SETTING_TRACE_BEGIN;
117         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
118
119         SettingPasswordUG *ad = (SettingPasswordUG *)data;
120
121         /* CONTENT */
122         if (ad->scroller != NULL) {
123                 evas_object_del(ad->scroller);
124                 ad->scroller = NULL;
125         }
126
127         /* PIN related views have 2 toolbar buttons. CANCEL and DONE button */
128         ad->ly_main = setting_create_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get, setting_password_fingerprint_get_title_str(ad),
129                                                              _("IDS_ST_BUTTON_CANCEL_ABB"),
130                                                              _("IDS_SA_BUTTON_DONE_ABB"),
131                                                              (setting_call_back_func)setting_password_fingerprint_click_softkey_cancel_cb,
132                                                              setting_password_fingerprint_click_softkey_done_cb,
133                                                              ad,
134                                                              &(ad->scroller),
135                                                              &(ad->navi_bar));
136
137         if (!ad->scroller) {
138                 SETTING_TRACE("genlist is NULL");
139                 return SETTING_RETURN_FAIL;
140         }
141
142         /* Disable Done button if exist */
143         if (ad->navi_bar) {
144                 ad->navi_it = elm_naviframe_top_item_get(ad->navi_bar);
145                 Evas_Object *toolbar = elm_object_item_part_content_get(ad->navi_it, "toolbar");
146                 if (toolbar) {
147                         elm_object_item_disabled_set(elm_toolbar_last_item_get(toolbar), EINA_TRUE);
148                         evas_object_show(toolbar);
149                 }
150                 elm_object_item_signal_emit(ad->navi_it, "elm,state,sip,shown", "");
151         }
152
153         elm_genlist_mode_set(ad->scroller, ELM_LIST_COMPRESS);
154
155         ADD_GL_SEPARATOR(ad->scroller)
156
157         return SETTING_RETURN_SUCCESS;
158 }
159
160 static Eina_Bool __setting_password_fingerprint_rotate_cb(void *data)
161 {
162         /* error check */
163         SETTING_TRACE_BEGIN;
164         retv_if(data == NULL, FALSE);
165
166         SettingPasswordUG *ad = (SettingPasswordUG *) data;
167
168         /* it can manage the cursor self */
169         if (ad->ed_pw1 && ad->ed_pw1->isFocusFlag) {
170                 if (ad->ed_pw1->eo_check) {
171                         SETTING_TRACE_DEBUG("set focus on first entry");
172                         /* no matter how many edifileds, it only need focus on 1st editfiled */
173                         elm_object_focus_set(ad->ed_pw1->eo_check, EINA_TRUE);
174                         elm_entry_cursor_end_set(ad->ed_pw1->eo_check);
175                 }
176         }
177
178         ad->focus_timer = NULL;
179
180         return ECORE_CALLBACK_CANCEL;
181 }
182
183 static int setting_password_fingerprint_create(void *cb)
184 {
185         SETTING_TRACE_BEGIN;
186         /* error check */
187         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
188
189         SettingPasswordUG *ad = (SettingPasswordUG *) cb;
190         int ret = 0;
191
192         ret = __create_fingerprint_layout(ad);
193
194         if (ret < 0)
195                 return SETTING_RETURN_FAIL;
196
197         ad->cur_step = 1;
198         setting_password_fingerprint_draw_1line_entry(ad, NULL);
199
200         /*ad->focus_timer = ecore_timer_add(0.5, __setting_password_fingerprint_rotate_cb, ad); */
201
202         setting_view_password_fingerprint.is_create = 1;
203
204         SETTING_TRACE_END;
205         return SETTING_RETURN_SUCCESS;
206 }
207
208 static int setting_password_fingerprint_destroy(void *cb)
209 {
210         SETTING_TRACE_BEGIN;
211         /* error check */
212         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
213
214         SettingPasswordUG *ad = (SettingPasswordUG *) cb;
215
216         if (ad->notify) {
217                 evas_object_del(ad->notify);
218                 ad->notify = NULL;
219         }
220         FREE(ad->cur_pwd);
221
222         if (ad->ly_main != NULL) {
223                 evas_object_del(ad->ly_main);
224                 ad->ly_main = NULL;
225                 setting_view_password_fingerprint.is_create = 0;
226         }
227         SETTING_TRACE_END;
228         return SETTING_RETURN_SUCCESS;
229 }
230
231 static int setting_password_fingerprint_update(void *cb)
232 {
233         SETTING_TRACE_BEGIN;
234         /* error check */
235         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
236
237         SettingPasswordUG *ad = (SettingPasswordUG *) cb;
238
239         if (ad->ly_main != NULL) {
240                 evas_object_show(ad->ly_main);
241         }
242
243         return SETTING_RETURN_SUCCESS;
244 }
245
246 static int setting_password_fingerprint_cleanup(void *cb)
247 {
248         /* error check */
249         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
250
251         SettingPasswordUG *ad = (SettingPasswordUG *) cb;
252
253         if (ad->ly_main != NULL) {
254                 evas_object_hide(ad->ly_main);
255         }
256
257         return SETTING_RETURN_SUCCESS;
258 }
259
260 /* ***************************************************
261  *
262  *general func
263  *
264  ***************************************************/
265
266 static void
267 setting_password_fingerprint_entry_changed_cb(void *data, Evas_Object *obj,
268                                               void *event_info)
269 {
270         SETTING_TRACE_BEGIN;
271         retm_if(data == NULL, "[Setting > Password] Data parameter is NULL");
272         retm_if(obj == NULL, "[Setting > Password] Data parameter is NULL");
273         Setting_GenGroupItem_Data *list_item =
274             (Setting_GenGroupItem_Data *) data;
275         SettingPasswordUG *ad = (SettingPasswordUG *) list_item->userdata;
276         const char *entry_str = elm_entry_entry_get(obj);
277         list_item->sub_desc = (char *)g_strdup(entry_str);
278         bool isFoundEmptyEntry = FALSE;
279
280         elm_object_part_text_set(obj, "elm.guide", "");
281
282         do {
283                 if (ad->ed_pw1) {
284                         entry_str = ad->ed_pw1->sub_desc;
285                         if (NULL == entry_str || '\0' == entry_str[0]) {
286                                 isFoundEmptyEntry = TRUE;
287                                 elm_object_part_text_set(obj, "elm.guide", _("Enter password"));
288                                 elm_object_item_signal_emit(ad->ed_pw1->item, "elm,state,eraser,hide", "");
289                                 break;
290                         } else if (ad->ed_pw1->isFocusFlag) {
291                                 elm_object_item_signal_emit(ad->ed_pw1->item, "elm,state,eraser,show", "");
292                                 break;
293                         }
294                 }
295         } while (0);
296
297         Eina_Bool item_disabled = elm_object_item_disabled_get(list_item->item);
298         if (item_disabled)
299                 return;
300
301         /* For disable toolbar (done) item */
302         bool disableFlag = isFoundEmptyEntry;
303         if (ad->ed_pw1 && ad->ed_pw1->eo_check && (safeStrLen(elm_entry_entry_get(ad->ed_pw1->eo_check)) < 4))
304                 disableFlag = TRUE;
305
306         Evas_Object *toolbar = elm_object_item_part_content_get(ad->navi_it, "toolbar");
307         if (disableFlag) {
308                 elm_object_item_disabled_set(elm_toolbar_last_item_get(toolbar), EINA_TRUE);
309         } else {
310                 elm_object_item_disabled_set(elm_toolbar_last_item_get(toolbar), EINA_FALSE);
311                 if (ad->err_desc && ad->err_desc->item) {
312                         elm_object_item_del(ad->err_desc->item);
313                         ad->err_desc = NULL;
314                 }
315         }
316 }
317
318 #if 0
319 static void __reached_max_pwlength_cb(void *data, Evas_Object *obj, void *event_info)
320 {
321         SETTING_TRACE_BEGIN;
322         retm_if(data == NULL, "Data parameter is NULL");
323         retm_if(!elm_object_focus_get(obj), "Entry is not focused");/*notify only when entry is being focused on. */
324
325         int err = 0;
326
327         /*Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data; */
328         /*SettingPasswordUG *ad = (SettingPasswordUG *) list_item->userdata; */
329
330         int haptic_return = 0;
331         haptic_device_h haptic_handle;
332         haptic_return = haptic_open(HAPTIC_DEVICE_0, &haptic_handle);
333         SETTING_TRACE("haptic_handle : %d", haptic_handle);
334         if (haptic_return < 0) {
335                 SETTING_TRACE_DEBUG("%s*** [ERR] Failed haptic_open ***%s",
336                                     SETTING_FONT_RED, SETTING_FONT_BLACK);
337         }
338
339         err = haptic_vibrate_file_with_detail(haptic_handle, "/usr/share/feedback/haptic/touch/touch.ivt", 1, HAPTIC_FEEDBACK_AUTO, HAPTIC_PRIORITY_MIN, NULL);
340
341         if (err < 0)
342                 SETTING_TRACE("Failed to play haptic");
343
344         haptic_close(haptic_handle);
345 }
346 #endif
347
348 static void __entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
349 {
350         SETTING_TRACE_BEGIN;
351         retm_if(data == NULL, "Data parameter is NULL");
352
353         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
354         SettingPasswordUG *ad = (SettingPasswordUG *) list_item->userdata;
355
356         Evas_Object *toolbar = elm_object_item_part_content_get(ad->navi_it, "toolbar");
357         if (toolbar) {
358                 Elm_Object_Item *done_item = elm_toolbar_last_item_get(toolbar);
359                 if (done_item) {
360                         if (elm_object_item_disabled_get(done_item) == EINA_FALSE) {
361                                 elm_object_focus_set(obj, EINA_FALSE);
362                                 /* call done cb. */
363                                 setting_password_fingerprint_done(ad);
364                         }
365                 }
366         }
367 }
368
369 static void __entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
370 {
371         SETTING_TRACE_BEGIN;
372         retm_if(data == NULL, "Data parameter is NULL");
373
374         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
375         SettingPasswordUG *ad = (SettingPasswordUG *)list_item->userdata;
376
377         if (!elm_entry_is_empty(obj)) {
378                 elm_object_item_signal_emit(list_item->item, "elm,state,eraser,show", "");
379         }
380         elm_object_item_signal_emit(list_item->item, "elm,state,rename,hide", "");
381
382         if (ad == NULL)
383                 return;
384
385         if (ad->ed_pw1 && obj == ad->ed_pw1->eo_check) {
386                 ad->ed_pw1->isFocusFlag = TRUE;
387                 if (ad->ed_pw2)
388                         ad->ed_pw2->isFocusFlag = FALSE;
389                 if (ad->ed_pw3)
390                         ad->ed_pw3->isFocusFlag = FALSE;
391         }
392 }
393
394 static void __entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
395 {
396         SETTING_TRACE_BEGIN;
397         retm_if(data == NULL, "Data parameter is NULL");
398         retm_if(obj == NULL, "Data parameter is NULL");
399
400         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
401
402         list_item->isFocusFlag = FALSE;
403
404         if (list_item->item) {
405                 elm_object_item_signal_emit(list_item->item, "elm,state,eraser,hide", "");
406                 elm_object_item_signal_emit(list_item->item, "elm,state,rename,show", "");
407         }
408 }
409
410 static void __entry_max_length_cb(void *data, Evas_Object *obj, void *event_info)
411 {
412         SETTING_TRACE_BEGIN;
413         retm_if(data == NULL, "Data parameter is NULL");
414         retm_if(!elm_object_focus_get(obj), "Entry is not focused");/*notify only when entry is being focused on. */
415
416         int err = 0;
417
418         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
419         SettingPasswordUG *ad = (SettingPasswordUG *) list_item->userdata;
420
421         /* Display help text. */
422         char temp[128] = {0,};
423         snprintf(temp, 128, _(PW_ST_PW_MAX_LENGTH_HELP), list_item->limit_filter_data->max_char_count);
424         setting_password_ug_display_desc(ad, temp, FALSE);
425
426         int haptic_return = 0;
427         haptic_device_h haptic_handle;
428         haptic_return = haptic_open(HAPTIC_DEVICE_0, &haptic_handle);
429         SETTING_TRACE("haptic_handle : %d", haptic_handle);
430         if (haptic_return < 0) {
431                 SETTING_TRACE_DEBUG("%s*** [ERR] Failed haptic_open ***%s",
432                                     SETTING_FONT_RED, SETTING_FONT_BLACK);
433         }
434
435         err = haptic_vibrate_file_with_detail(haptic_handle, "/usr/share/feedback/haptic/touch/touch.ivt", 1, HAPTIC_FEEDBACK_AUTO, HAPTIC_PRIORITY_MIN, NULL);
436
437         if (err < 0)
438                 SETTING_TRACE("Failed to play haptic");
439
440         haptic_close(haptic_handle);
441 }
442
443 static char *__get_title_of_entry(int viewtype, int step)
444 {
445         if ((viewtype == SETTING_PW_TYPE_SET_FP_ALT_PASSWORD && step == 1)
446             || (viewtype == SETTING_PW_TYPE_CHANGE_FP_ALT_PASSWORD && step == 2)) {
447                 return "Enter password";
448         } else {
449                 return "Confirm password";
450         }
451 }
452
453 int setting_password_fingerprint_draw_1line_entry(void *data, void *cb)
454 {
455         SETTING_TRACE_BEGIN;
456         /* error check */
457         retvm_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER,
458                  "[Setting > Password] Data parameter is NULL");
459
460         SettingPasswordUG *ad = (SettingPasswordUG *) data;
461
462         if (ad->scroller)
463                 elm_genlist_clear(ad->scroller);
464
465         ADD_GL_SEPARATOR(ad->scroller);
466
467         ad->ed_pw1 = setting_create_Gendial_field_editfield(ad->scroller,
468                                                             &(itc_editfield),
469                                                             NULL, ad,
470                                                             SWALLOW_Type_LAYOUT_EDITFIELD,
471                                                             __get_title_of_entry(ad->view_type, ad->cur_step),
472                                                             NULL,
473                                                             setting_password_fingerprint_entry_changed_cb,
474                                                             __entry_focused_cb,
475                                                             __entry_unfocused_cb,
476                                                             __entry_activated_cb,
477                                                             __entry_max_length_cb,
478                                                             ELM_INPUT_PANEL_LAYOUT_PASSWORD,
479                                                             TRUE, TRUE,
480                                                             SETTING_PW_UG_NORMAL_PASSWORD_MAX_LENGTH,
481                                                             0, NULL, NULL);
482
483         if (ad->view_type == SETTING_PW_TYPE_SET_FP_ALT_PASSWORD && ad->cur_step == 1)
484                 ADD_GL_LABLE(ad->scroller, "Enter a password to use as an alternative to your fingerprints.");
485
486         ad->ed_pw2 = NULL;
487         ad->ed_pw3 = NULL;
488         /*ad->cur_pwd = NULL; */
489
490         ad->focus_timer = ecore_timer_add(0.5, __setting_password_fingerprint_rotate_cb, ad);
491
492         return 0;
493 }
494
495 int setting_password_fingerprint_clear_1line_entry(void *data)
496 {
497         /* error check */
498         retvm_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER,
499                  "[Setting > Password] Data parameter is NULL");
500
501         SettingPasswordUG *ad = (SettingPasswordUG *) data;
502         retv_if(NULL == ad->ed_pw1, -1);
503
504         ad->ed_pw1->sub_desc = NULL;
505         ad->ed_pw1->isFocusFlag = FALSE;
506
507         elm_entry_entry_set(ad->ed_pw1->eo_check, "");
508         elm_object_part_text_set(ad->ed_pw1->eo_check, "elm.guide", _("Enter password"));
509
510         elm_object_focus_set(ad->ed_pw1->eo_check, EINA_TRUE);
511
512         return 0;
513 }
514
515 int setting_password_fingerprint_check_1line_entry(void *data)
516 {
517         /* error check */
518         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
519
520         SettingPasswordUG *ad = (SettingPasswordUG *) data;
521
522         const char *entry_str = ad->ed_pw1->sub_desc;
523         ad->focus_data = ad->ed_pw1;
524
525         /*  Length Check */
526         int entry_str_len = safeStrLen(entry_str);
527         switch (ad->view_type) {
528                 case SETTING_PW_TYPE_PIN_LOCK_ON:
529                 case SETTING_PW_TYPE_PIN_LOCK_OFF:
530                 case SETTING_PW_TYPE_CHANGE_PIN:
531                 case SETTING_PW_TYPE_CHANGE_PIN2: {
532                                 if (entry_str_len < SETTING_PW_UG_PIN_MIN_LENGTH
533                                     || entry_str_len > SETTING_PW_UG_PIN_MAX_LENGTH) {
534                                         setting_password_fingerprint_warning_entry_added_byte_popup
535                                         (ad, SETTING_PW_UG_PIN_MIN_LENGTH, SETTING_PW_UG_PIN_MAX_LENGTH);
536                                         return SETTING_ENTRY_REQUIRED_CORRECT_DIGIT_PW;
537                                 }
538                         }
539                         break;
540                 case SETTING_PW_TYPE_SIM_LOCK_OFF: {
541                                 if (entry_str_len < SETTING_PW_UG_SIM_MIN_LENGTH
542                                     || entry_str_len > SETTING_PW_UG_SIM_MAX_LENGTH) {
543                                         setting_password_fingerprint_warning_entry_added_byte_popup
544                                         (ad, SETTING_PW_UG_SIM_MIN_LENGTH, SETTING_PW_UG_SIM_MAX_LENGTH);
545                                         return SETTING_ENTRY_REQUIRED_CORRECT_DIGIT_PW;
546                                 }
547                         }
548                 default:
549                         break;
550         }
551         return SETTING_RETURN_SUCCESS;
552 }
553
554 void setting_password_fingerprint_warning_entry_added_byte_popup(SettingPasswordUG *ad,
555                                                                  int min, int max)
556 {
557         char str[MAX_SPECIALIZITION_LEN + 1] = { 0 };
558
559         safeCopyStr(str, _("IDS_COM_BODY_TYPE_A_PIN_THAT_IS_4_TO_8_NUMBERS"), MAX_SPECIALIZITION_LEN);
560         setting_password_ug_display_desc(ad, str, FALSE);
561 }
562
563 static void setting_password_fingerprint_display_desc(void *data, char *desc)
564 {
565         SETTING_TRACE_BEGIN;
566         ret_if(data == NULL || desc == NULL);
567
568         SettingPasswordUG *ad = (SettingPasswordUG *)data;
569
570         if (ad->scroller == NULL)
571                 return;
572
573         if (ad->err_desc && ad->err_desc->item) {
574                 elm_object_item_del(ad->err_desc->item);
575                 ad->err_desc = NULL;
576         }
577
578         ad->err_desc = setting_create_Gendial_field_helpitem_without_bottom_separator(
579                            ad->scroller,
580                            &(itc_multiline_text),
581                            SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
582                            desc);
583
584         /* if pw incorrect, show keyboard again. */
585         if (ad->ed_pw1 && ad->ed_pw1->eo_check) {
586                 SETTING_TRACE_DEBUG("FOCUS IN");
587                 elm_object_focus_set(ad->ed_pw1->eo_check, EINA_TRUE);
588         }
589 }
590
591 static void setting_password_fingerprint_done(void *data)
592 {
593         SETTING_TRACE_BEGIN;
594         ret_if(data == NULL);
595         SettingPasswordUG *ad = (SettingPasswordUG *) data;
596
597         SETTING_TRACE("ad->view_type:%d, ad->cur_step:%d", ad->view_type, ad->cur_step);
598
599         char *input = ad->ed_pw1->sub_desc;
600
601         /* case 1 : verify current */
602         if (ad->view_type == SETTING_PW_TYPE_VERIFY_FP_ALT_PASSWORD
603             || (ad->view_type == SETTING_PW_TYPE_CHANGE_FP_ALT_PASSWORD && ad->cur_step == 1)) {
604                 SETTING_TRACE_DEBUG("Verify");
605                 fpResult_t result = FINGERPRINT_RESULT_ERROR;
606                 result = fp_verify_password(input);
607                 setting_password_fingerprint_clear_1line_entry(ad);
608                 if (result != FINGERPRINT_RESULT_OK) {
609                         SETTING_TRACE_DEBUG("fp_verify_password() failed. %d", result);
610                         /* help text : enter again. etc */
611                         setting_password_fingerprint_display_desc(ad, "Verify failed.");
612                         return;
613                 }
614                 /* change entry's title */
615                 if (ad->view_type == SETTING_PW_TYPE_CHANGE_FP_ALT_PASSWORD) {
616                         ad->cur_step++;
617                         setting_password_fingerprint_draw_1line_entry(ad, NULL);
618                         return;
619                 }
620         }
621         /* case 2 : enter new */
622         else if ((ad->view_type == SETTING_PW_TYPE_SET_FP_ALT_PASSWORD && ad->cur_step == 1)
623                  || (ad->view_type == SETTING_PW_TYPE_CHANGE_FP_ALT_PASSWORD && ad->cur_step == 2)) {
624                 SETTING_TRACE_DEBUG("New");
625                 /* check */
626                 if (setting_password_fingerprint_check_1line_entry(ad) == SETTING_RETURN_SUCCESS) {
627                         ad->cur_pwd = (char *)strdup(ad->ed_pw1->sub_desc);
628                         SETTING_TRACE_DEBUG("input1 : %s", ad->cur_pwd);
629                         ad->cur_step++;
630                         setting_password_fingerprint_draw_1line_entry(ad, NULL);
631                         return;
632                 } else {
633                         setting_password_fingerprint_clear_1line_entry(ad);
634                         setting_password_fingerprint_display_desc(ad, "Input check failed.");
635                 }
636         }
637         /* case 3 : enter new again */
638         else if ((ad->view_type == SETTING_PW_TYPE_SET_FP_ALT_PASSWORD && ad->cur_step == 2)
639                  || (ad->view_type == SETTING_PW_TYPE_CHANGE_FP_ALT_PASSWORD && ad->cur_step == 3)) {
640                 SETTING_TRACE_DEBUG("Confirm New, input1 %s, input2 %s", ad->cur_pwd, input);
641                 /* check match with ad->cur_pwd */
642                 if (!safeStrCmp(ad->cur_pwd, input)) {
643                         fpResult_t result = FINGERPRINT_RESULT_ERROR;
644                         result = fp_set_password(input);
645                         setting_password_fingerprint_clear_1line_entry(ad);
646                         if (result != FINGERPRINT_RESULT_OK) {
647                                 SETTING_TRACE_DEBUG("fp_set_password() failed. %d", result);
648                                 setting_password_fingerprint_display_desc(ad, "Set failed.");
649                                 return;
650                         }
651                         FREE(ad->cur_pwd);
652                 } else {
653                         setting_password_fingerprint_clear_1line_entry(ad);
654                         /* help text : new and confirm mismatched etc */
655                         setting_password_fingerprint_display_desc(ad, "New and Confirm do not mismatched.");
656
657                         return;
658                 }
659         }
660
661         /* send result to caller */
662         app_control_h svc;
663         if (app_control_create(&svc)) {
664                 SETTING_TRACE_ERROR("app_control_create() failed");
665                 return;
666         }
667
668         app_control_add_extra_data(svc, "result", ad->view_type_string);
669         ug_send_result(ad->ug, svc);
670         SETTING_TRACE("Send Result : %s\n", ad->view_type_string);
671
672         app_control_destroy(svc);
673         /* Send destroy request */
674         ug_destroy_me(ad->ug);
675 }
676
677 void setting_password_fingerprint_click_softkey_done_cb(void *data, Evas_Object *obj,
678                                                         void *event_info)
679 {
680         SETTING_TRACE_BEGIN;
681         /* error check */
682         retm_if(data == NULL, "[Setting > Password] Data parameter is NULL");
683
684         SettingPasswordUG *ad = (SettingPasswordUG *) data;
685
686         if (ad->ed_pw1 && ad->ed_pw1->eo_check) {
687                 elm_object_focus_set(ad->ed_pw1->eo_check, EINA_FALSE);
688         }
689
690         if (ad->err_desc && ad->err_desc->item) {
691                 elm_object_item_del(ad->err_desc->item);
692                 ad->err_desc = NULL;
693         }
694
695         setting_password_fingerprint_done(ad);
696 }