4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include <setting-password.h>
22 #include <setting-password-main.h>
23 #include <security-server.h>
25 extern void setting_get_pin_lock_info_cb(TapiHandle *handle, int result, void *data, void *user_data);
28 #define UG_MODULE_API __attribute__ ((visibility("default")))
31 struct _pw_item pw_its[] = {
33 { SETTING_PW_TYPE_PASSWORD, "SETTING_PW_TYPE_PASSWORD", SETTING_PW_CATEGORY_LOCK, 1 },
34 { SETTING_PW_TYPE_SET_PASSWORD, "SETTING_PW_TYPE_SET_PASSWORD", SETTING_PW_CATEGORY_LOCK, 2 },
35 { SETTING_PW_TYPE_SIMPLE_PASSWORD, "SETTING_PW_TYPE_SIMPLE_PASSWORD", SETTING_PW_CATEGORY_LOCK+SETTING_PW_SUB_CATEGORY_SIMPLE, 1 },
36 { SETTING_PW_TYPE_SET_SIMPLE_PASSWORD, "SETTING_PW_TYPE_SET_SIMPLE_PASSWORD", SETTING_PW_CATEGORY_LOCK+SETTING_PW_SUB_CATEGORY_SIMPLE, 2 },
37 { SETTING_PW_TYPE_ENTER_LOCK_TYPE, "SETTING_PW_TYPE_ENTER_LOCK_TYPE", SETTING_PW_CATEGORY_LOCK, 1 },
38 { SETTING_PW_TYPE_SIM_LOCK_ON, "SETTING_PW_TYPE_SIM_LOCK_ON", SETTING_PW_CATEGORY_SIM, 2 },
39 { SETTING_PW_TYPE_SIM_LOCK_OFF, "SETTING_PW_TYPE_SIM_LOCK_OFF", SETTING_PW_CATEGORY_SIM, 1 },
40 { SETTING_PW_TYPE_PIN_LOCK_ON, "SETTING_PW_TYPE_PIN_LOCK_ON", SETTING_PW_CATEGORY_SIM, 1 },
41 { SETTING_PW_TYPE_PIN_LOCK_OFF, "SETTING_PW_TYPE_PIN_LOCK_OFF", SETTING_PW_CATEGORY_SIM, 1 },
42 { SETTING_PW_TYPE_CHANGE_PIN, "SETTING_PW_TYPE_CHANGE_PIN", SETTING_PW_CATEGORY_SIM, 3 },
43 { SETTING_PW_TYPE_CHANGE_PIN2, "SETTING_PW_TYPE_CHANGE_PIN2", SETTING_PW_CATEGORY_SIM, 3 },
44 { SETTING_PW_TYPE_PIN_BLOCKED, "SETTING_PW_TYPE_PIN_BLOCKED", SETTING_PW_CATEGORY_SIM, 3 },
45 { SETTING_PW_TYPE_PIN2_BLOCKED, "SETTING_PW_TYPE_PIN2_BLOCKED", SETTING_PW_CATEGORY_SIM, 3 },
46 { SETTING_PW_TYPE_MAX, NULL }
49 static void setting_password_ug_cb_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
51 //SettingPasswordUG *ad = (SettingPasswordUG *) data;
52 //setting_view_update(&setting_view_password_main, ad);
55 void __chk_cur_pw_status(SettingPasswordUG *ad, app_control_h service)
58 unsigned int attempt = 0;
59 unsigned int max_attempt = 0;
60 unsigned int expire_sec = 0;
62 ad->pw_status = SETTING_PW_STATUS_DEFAULT;
64 ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
65 SETTING_TRACE_DEBUG("status of password : %d (cur attempt %d, max %d, expire %d", ret, attempt, max_attempt, expire_sec);
67 if(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD)
69 SETTING_TRACE("security-server has no password!");
70 ad->pw_status = SETTING_PW_STATUS_EMPTY;
74 void __get_extra_data(SettingPasswordUG *ad, app_control_h service)
78 char *encryption = NULL;
81 app_control_get_extra_data(service, "viewtype", &(ad->view_type_string));
82 SETTING_TRACE("viewtype:%s", ad->view_type_string);
84 app_control_get_extra_data(service, "current", &(ad->cur_pwd));
86 SETTING_TRACE_SECURE_DEBUG("Receive current : %s", ad->cur_pwd);
89 void __get_password_view_type(SettingPasswordUG *ad, app_control_h service)
93 setting_pw_type ret_pw_type = 0;
96 for(i = 1; i < SETTING_PW_TYPE_MAX; i++)
98 if (0 == safeStrCmp(ad->view_type_string, pw_its[i].pw_type_string))
100 SETTING_TRACE_DEBUG("%s %d", ad->view_type_string, pw_its[i].pw_type_num);
101 ret_pw_type = pw_its[i].pw_type_num;
106 if(pw_its[ret_pw_type].category == SETTING_PW_CATEGORY_SIM)
108 SETTING_TRACE_DEBUG("SIM or Fingerprint do not need to check pw status. %d", pw_its[ret_pw_type].category);
109 ad->view_type = ret_pw_type;
113 __chk_cur_pw_status(ad, service);
115 /* Some pw types should be changed, according to pw status and current lock type */
116 if( ret_pw_type == SETTING_PW_TYPE_ENTER_LOCK_TYPE)
118 if(ad->pw_status == SETTING_PW_STATUS_EMPTY)
120 if(ad->screen_lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
121 ret_pw_type = SETTING_PW_TYPE_SET_PASSWORD;
122 else if(ad->screen_lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD)
123 ret_pw_type = SETTING_PW_TYPE_SET_SIMPLE_PASSWORD;
127 if(ad->screen_lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
128 ret_pw_type = SETTING_PW_TYPE_PASSWORD;
129 else if(ad->screen_lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD)
130 ret_pw_type = SETTING_PW_TYPE_SIMPLE_PASSWORD;
135 ad->view_type = ret_pw_type;
138 static setting_view * __initialize_view_node_table(int category)
140 setting_view_node_table_intialize();
142 if(category == SETTING_PW_CATEGORY_SIM)
144 setting_view_node_table_register(&setting_view_password_sim, NULL);
145 return &setting_view_password_sim;
147 else if(category & SETTING_PW_SUB_CATEGORY_SIMPLE)
149 setting_view_node_table_register(&setting_view_password_simple, NULL);
150 return &setting_view_password_simple;
154 setting_view_node_table_register(&setting_view_password_main, NULL);
155 return &setting_view_password_main;
159 static void __destroy_view(SettingPasswordUG *ad)
163 if(pw_its[ad->view_type].category == SETTING_PW_CATEGORY_SIM)
165 setting_view_destroy(&setting_view_password_sim, ad);
167 if(pw_its[ad->view_type].category & SETTING_PW_SUB_CATEGORY_SIMPLE)
169 setting_view_destroy(&setting_view_password_simple, ad);
173 /* delete the allocated objects. */
174 setting_view_destroy(&setting_view_password_main, ad);
178 static char *__gl_err_desc_text_get(void *data, Evas_Object *obj, const char *part)
181 retv_if(data == NULL, NULL);
182 char buf[256] = {0,};
184 snprintf(buf, 256, "<font color=#ff0000>%s</font>", (char*)data);
186 SETTING_TRACE_DEBUG("buf is %s", buf);
188 return (char*)g_strdup(buf);
191 static void __gl_err_desc_del(void *data, Evas_Object *obj)
197 SETTING_TRACE_DEBUG("free err_desc");
201 static void setting_password_rotated_cb(void *data, Evas_Object *obj, void *event)
204 SettingPasswordUG *ad = (SettingPasswordUG *)data;
206 if(ad == NULL || ad->win_get == NULL || obj == NULL)
209 /*int changed_ang = 0;
210 changed_ang = elm_win_rotation_get(obj);*/
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
215 || ad->view_type == SETTING_PW_TYPE_PIN_BLOCKED)
219 if(tel_get_sim_lock_info(ad->handle, TAPI_SIM_LOCK_SC, setting_get_pin_lock_info_cb, ad) != 0)
220 SETTING_TRACE_DEBUG("failed to call tel_get_sim_lock_info()");
223 else if(ad->view_type == SETTING_PW_TYPE_CHANGE_PIN2
224 || ad->view_type == SETTING_PW_TYPE_PIN2_BLOCKED)
228 if(tel_get_sim_lock_info(ad->handle, TAPI_SIM_LOCK_FD, setting_get_pin_lock_info_cb, ad) != 0)
229 SETTING_TRACE_DEBUG("failed to call tel_get_sim_lock_info()");
232 // it can manage the cursor self
233 if(ad->ed_pw1 && (ad->ed_pw1->isFocusFlag == TRUE))
235 if (ad->ed_pw1->eo_check)
237 SETTING_TRACE_DEBUG("set focus on first entry");
238 // no matter how many edifileds, it only need focus on 1st editfiled
239 elm_object_focus_set(ad->ed_pw1->eo_check, EINA_TRUE);
240 elm_entry_cursor_end_set(ad->ed_pw1->eo_check);
243 else if(ad->ed_pw2 && (ad->ed_pw2->isFocusFlag == TRUE))
245 if (ad->ed_pw2->eo_check)
247 SETTING_TRACE_DEBUG("set focus on second entry");
248 //no matter how many edifileds, it only need focus on 1st editfiled
249 elm_object_focus_set(ad->ed_pw2->eo_check, EINA_TRUE);
250 elm_entry_cursor_end_set(ad->ed_pw2->eo_check);
253 else if(ad->ed_pw3 && (ad->ed_pw3->isFocusFlag == TRUE))
255 if (ad->ed_pw3->eo_check)
257 SETTING_TRACE_DEBUG("set focus on third entry");
258 //no matter how many edifileds, it only need focus on 1st editfiled
259 elm_object_focus_set(ad->ed_pw3->eo_check, EINA_TRUE);
260 elm_entry_cursor_end_set(ad->ed_pw3->eo_check);
265 SETTING_TRACE_DEBUG("no entry to set focus");
269 static void *setting_password_ug_on_create(ui_gadget_h ug,
270 enum ug_mode mode, app_control_h service,
274 setting_retvm_if((!priv), NULL, "!priv");
276 SettingPasswordUG *passwordUG = (SettingPasswordUG *)priv;
278 passwordUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
279 passwordUG->win_get = (Evas_Object *) ug_get_window();
280 evas_object_show(passwordUG->win_main_layout);
281 passwordUG->evas = evas_object_evas_get(passwordUG->win_main_layout);
283 setting_retvm_if(passwordUG->win_main_layout == NULL, NULL,
284 "cannot get main window ");
287 //setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
288 bindtextdomain(SETTING_PACKAGE, SETTING_LOCALEDIR);
289 evas_object_smart_callback_add(passwordUG->win_get, "wm,rotation,changed", setting_password_rotated_cb, passwordUG);
291 setting_create_Gendial_itc("groupindex", &(passwordUG->itc_title));
292 setting_create_Gendial_itc("1icon",&(passwordUG->itc_variable_height));
294 passwordUG->itc_err_desc.item_style = "multiline_sub";
295 passwordUG->itc_err_desc.func.text_get = __gl_err_desc_text_get;
296 passwordUG->itc_err_desc.func.content_get = NULL;
297 passwordUG->itc_err_desc.func.state_get = NULL;
298 passwordUG->itc_err_desc.func.del = __gl_err_desc_del;
300 /* get screen lock type */
301 vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &(passwordUG->screen_lock_type));
302 SETTING_TRACE_DEBUG("screen lock type : %d", passwordUG->screen_lock_type);
305 __get_extra_data(passwordUG, service);
306 __get_password_view_type(passwordUG, service);
307 passwordUG->step1_str = NULL;
309 setting_view *main_view = __initialize_view_node_table(pw_its[passwordUG->view_type].category);
311 /* creating a view. */
312 setting_view_create(main_view,(void *)passwordUG);
313 evas_object_event_callback_add(passwordUG->win_main_layout,
314 EVAS_CALLBACK_RESIZE,
315 setting_password_ug_cb_resize,
318 return passwordUG->ly_main;
321 static void setting_password_ug_on_start(ui_gadget_h ug, app_control_h service, void *priv)
325 static void setting_password_ug_on_pause(ui_gadget_h ug, app_control_h service, void *priv)
328 SettingPasswordUG *passwordUG = (SettingPasswordUG *)priv;
330 if(pw_its[passwordUG->view_type].category & SETTING_PW_SUB_CATEGORY_SIMPLE)
332 /* If pause, simple password's SIP should be focused out.
333 If not, Our SIP will not be shown after using Other apps with independent SIP. */
334 if(passwordUG->imf_context)
336 ecore_imf_context_reset(passwordUG->imf_context);
337 ecore_imf_context_focus_out(passwordUG->imf_context);
342 static void setting_password_ug_on_resume(ui_gadget_h ug, app_control_h service, void *priv)
345 SettingPasswordUG *passwordUG = (SettingPasswordUG *)priv;
347 if(pw_its[passwordUG->view_type].category & SETTING_PW_SUB_CATEGORY_SIMPLE)
349 /* If resume, simple password's SIP should be focused in.
350 If not, Our SIP will not be shown after using Other apps with independent SIP. */
351 if(passwordUG->imf_context)
353 //ecore_imf_context_input_panel_show(passwordUG->imf_context);
354 ecore_imf_context_focus_in(passwordUG->imf_context);
359 static void setting_password_ug_on_destroy(ui_gadget_h ug, app_control_h service, void *priv)
362 SettingPasswordUG *passwordUG = (SettingPasswordUG *)priv;
364 evas_object_event_callback_del(passwordUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_password_ug_cb_resize); /* fix flash issue for gallery */
365 evas_object_smart_callback_del(passwordUG->win_get, "wm,rotation,changed", setting_password_rotated_cb);
368 if(passwordUG->view_type_string)
369 FREE(passwordUG->view_type_string);
371 if(passwordUG->cur_pwd)
372 FREE(passwordUG->cur_pwd);
374 if (passwordUG->t_info) {
375 FREE(passwordUG->t_info);
376 passwordUG->t_info = NULL;
379 if(pw_its[passwordUG->view_type].category & SETTING_PW_SUB_CATEGORY_SIMPLE)
381 if(passwordUG->imf_context)
383 ecore_imf_context_del(passwordUG->imf_context);
384 passwordUG->imf_context = NULL;
388 __destroy_view(passwordUG);
390 if (NULL != ug_get_layout(passwordUG->ug)) {
391 evas_object_hide((Evas_Object *) ug_get_layout(passwordUG->ug));
392 evas_object_del((Evas_Object *) ug_get_layout(passwordUG->ug));
397 static void setting_password_ug_on_message(ui_gadget_h ug, app_control_h msg,
398 app_control_h service, void *priv)
403 static void setting_password_ug_on_event(ui_gadget_h ug,
404 enum ug_event event, app_control_h service,
411 SettingPasswordUG *ad = (SettingPasswordUG*)priv;
412 //static int old_event = -1;
414 case UG_EVENT_LOW_MEMORY:
416 case UG_EVENT_LOW_BATTERY:
418 case UG_EVENT_LANG_CHANGE:
421 // update toolbar items
422 Evas_Object *toolbar = elm_object_item_part_content_get(ad->navi_it, "toolbar");
425 Elm_Object_Item *last_item = elm_toolbar_last_item_get(toolbar);
426 Elm_Object_Item *first_item = elm_toolbar_last_item_get(toolbar);
429 elm_object_item_text_set(last_item, _("IDS_COM_SK_DONE"));
430 if(first_item && (first_item != last_item))
431 elm_object_item_text_set(last_item, _("IDS_COM_SK_CANCEL"));
436 case UG_EVENT_ROTATE_PORTRAIT:
437 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
438 case UG_EVENT_ROTATE_LANDSCAPE:
439 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
441 case UG_EVENT_REGION_CHANGE:
448 static void setting_password_ug_on_key_event(ui_gadget_h ug,
449 enum ug_key_event event,
450 app_control_h service, void *priv)
455 SettingPasswordUG *ad = (SettingPasswordUG*)priv;
458 case UG_KEY_EVENT_END:
466 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
468 SettingPasswordUG *passwordUG = calloc(1, sizeof(SettingPasswordUG));
469 setting_retvm_if(!passwordUG, -1, "Create SettingPasswordUG obj failed");
471 ops->create = setting_password_ug_on_create;
472 ops->start = setting_password_ug_on_start;
473 ops->pause = setting_password_ug_on_pause;
474 ops->resume = setting_password_ug_on_resume;
475 ops->destroy = setting_password_ug_on_destroy;
476 ops->message = setting_password_ug_on_message;
477 ops->event = setting_password_ug_on_event;
478 ops->key_event = setting_password_ug_on_key_event;
479 ops->priv = passwordUG;
480 ops->opt = UG_OPT_INDICATOR_ENABLE;
482 memset(passwordUG, 0x00, sizeof(SettingPasswordUG));
487 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
490 struct SettingPasswordUG *passwordUG;
491 setting_retm_if(!ops, "ops == NULL");
493 passwordUG = ops->priv;
498 void setting_password_ug_popup_resp_cb(void *data, Evas_Object *obj,
501 retm_if(data == NULL, "Data parameter is NULL");
504 SettingPasswordUG *ad = (SettingPasswordUG *) data;
506 /* Success to Operate */
508 if (app_control_create(&svc))
511 app_control_add_extra_data(svc, "result", ad->view_type_string);
512 ug_send_result(ad->ug, svc);
513 SETTING_TRACE("Send Result : %s\n", ad->view_type_string);
515 app_control_destroy(svc);
516 /* Send destroy request */
517 ug_destroy_me(ad->ug);
519 if (ad->view_type == SETTING_PW_TYPE_PIN_BLOCKED)
521 ug_destroy_me(ad->ug);
524 else if (ad->view_type == SETTING_PW_TYPE_PIN2_BLOCKED)
526 ug_destroy_me(ad->ug);
530 char *diable_view_type = NULL;
531 if (ad->disable_item_type == SETTING_PW_TYPE_SIM_LOCK_OFF) {
532 diable_view_type = "SETTING_PW_TYPE_SIM_LOCK_DISABLE";
535 if (diable_view_type) {
536 /* Success to Operate */
538 if (app_control_create(&svc))
541 app_control_add_extra_data(svc, "result", diable_view_type);
542 ug_send_result(ad->ug, svc);
544 app_control_destroy(svc);
545 /* Send destroy request */
546 ug_destroy_me(ad->ug);
549 if (ad->focus_data) {
550 ad->focus_data->isFocusFlag = TRUE;
551 elm_object_item_data_set(ad->focus_data->item, ad->focus_data);
552 elm_genlist_item_update(ad->focus_data->item);
557 void setting_password_ug_display_desc(void *data, char *desc, int destroy)
560 ret_if(data == NULL || desc == NULL);
562 SettingPasswordUG *ad = (SettingPasswordUG *)data;
564 ad->destroy = destroy;
566 if(ad->scroller == NULL)
569 if(ad->err_desc && ad->err_desc->item)
571 elm_object_item_del(ad->err_desc->item);
575 ad->err_desc = setting_create_Gendial_field_helpitem_without_bottom_separator(
577 &(itc_multiline_text),
578 SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
581 /* if pw incorrect, show keyboard again. */
582 //if(ad->ed_pw1 && ad->ed_pw1->eo_check)
584 // elm_object_focus_set(ad->ed_pw1->eo_check, EINA_TRUE);
589 setting_password_ug_create_popup_notitle_nobtn(void *data, char *str,
593 retm_if(data == NULL, "Data parameter is NULL");
595 SettingPasswordUG *ad = (SettingPasswordUG *) data;
597 ad->destroy = destroy;
600 evas_object_del(ad->notify);
603 ad->notify = setting_create_popup_without_btn(ad, ad->ly_main, NULL, str,
604 setting_password_ug_popup_resp_cb,
605 POPUP_INTERVAL, FALSE, FALSE);
608 void setting_password_ug_check_attemps_left(void *data)
611 SettingPasswordUG *ad = (SettingPasswordUG *) data;
613 setting_int_slp_list item_attempts_left;
614 setting_str_slp_list item_lock_timestamp;
615 int attemps_left_max = 5;
617 if (ad->view_type == SETTING_PW_TYPE_PASSWORD) {
618 item_attempts_left = INT_SLP_SETTING_PHONE_LOCK_ATTEMPTS_LEFT;
619 item_lock_timestamp = STR_SLP_SETTING_PHONE_LOCK_TIMESTAMP;
620 attemps_left_max = PHONE_LOCK_ATTEMPS_MAX;
621 } else if (ad->view_type == SETTING_PW_TYPE_SIM_LOCK_OFF) {
622 item_attempts_left = INT_SLP_SETTING_SIM_LOCK_ATTEMPTS_LEFT;
623 item_lock_timestamp = STR_SLP_SETTING_SIM_LOCK_TIMESTAMP;
624 attemps_left_max = SIM_LOCK_ATTEMPS_MAX;
630 int err = SETTING_RETURN_SUCCESS;
631 setting_get_int_slp_key(item_attempts_left, &value, &err);
632 setting_retm_if(err == SETTING_RETURN_FAIL,
633 "[Error] get value of vconf fail.");
637 if (value > 0 && value <= attemps_left_max) {
638 setting_set_int_slp_key(item_attempts_left, value, &err);
639 setting_retm_if(err == SETTING_RETURN_FAIL, "[Error] set value of vconf fail.");
640 char temp_str[MAX_SPECIALIZITION_LEN] = {0,};
641 char temp[MAX_SPECIALIZITION_LEN] ={0,};
644 snprintf(temp, sizeof(temp), "%s. %s.", PW_ERR_DESC, ATTEMPTS_DESC);
646 snprintf(temp, sizeof(temp), "%s. %s.", PW_ERR_DESC, ATTEMPT_DESC);
648 int ret = snprintf(temp_str, MAX_SPECIALIZITION_LEN, temp, value);
652 setting_password_ug_display_desc(ad, temp_str, FALSE);
653 } else if (value == 0) {
654 /* store the lock timestamp */
655 time_t cur_time = time(NULL);
656 char cur_timestamp[LOCK_TIMESTAMP_LEN] = { 0, };
657 int ret = snprintf(cur_timestamp, sizeof(cur_timestamp), "%ld", cur_time);
660 setting_set_string_slp_key(item_lock_timestamp, cur_timestamp, &err);
661 setting_retm_if(err == SETTING_RETURN_FAIL,
662 "[Error] set value of vconf fail.");
664 setting_set_int_slp_key(item_attempts_left, value, &err);
665 setting_retm_if(err == SETTING_RETURN_FAIL,
666 "[Error] set value of vconf fail.");
668 ad->disable_item_type = ad->view_type;
670 char temp[MAX_SPECIALIZITION_LEN] = {0,};
671 snprintf(temp, sizeof(temp), PW_ERR_DELAY_DESC, PW_ERR_DELAY_TIME);
673 setting_password_ug_create_popup_notitle_nobtn(ad, temp, FALSE);
675 setting_password_ug_create_popup_notitle_nobtn(ad,
676 _("IDS_COM_POP_ERROR"), FALSE);
681 int setting_password_check_password(const char *challenge, unsigned int *remain_attempt, unsigned int *valid_sec)
684 retv_if(challenge == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
688 unsigned int current_attempt = 0;
689 unsigned int max_attempt = 0;
690 unsigned int valid_secs = 0;
692 inner_ret = security_server_chk_pwd(challenge, ¤t_attempt, &max_attempt, &valid_secs);
694 SETTING_TRACE_DEBUG("chk password : %d", inner_ret);
695 SETTING_TRACE_SECURE_DEBUG("current_attempt : %d, max_attempt : %d, valid_secs : %d secs", current_attempt, max_attempt, valid_secs);
697 if(valid_sec != NULL)
698 *valid_sec = valid_secs;
700 if(inner_ret == SECURITY_SERVER_API_SUCCESS)
702 ret = SETTING_RETURN_SUCCESS;
706 if(remain_attempt != NULL)
708 if((max_attempt > 0) && (max_attempt >= current_attempt))
709 *remain_attempt = max_attempt - current_attempt;
711 *remain_attempt = ATTEMPT_INFINITE; // infinite
713 ret = SETTING_RETURN_FAIL;
719 int setting_password_set_password(const char *cur_pwd, const char *new_pwd, void *data)
722 retv_if(new_pwd == NULL || data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
724 SettingPasswordUG *ad = (SettingPasswordUG*)data;
728 /* To support key manager */
730 //int ckmc_ret = CKMC_ERROR_NONE;
732 /* max attempt count will be handled in passwordug for a while. */
733 if(ad->pw_status == SETTING_PW_STATUS_EMPTY)
735 ret = security_server_set_pwd(NULL, new_pwd, 0, 0);
736 SETTING_TRACE_DEBUG("[security_server_set_pwd() + empty current] returns %d, INFINITE", ret);
737 if(ret == SECURITY_SERVER_API_SUCCESS)
740 ckmc_ret = ckmc_reset_user_password(user, new_pwd);
741 SETTING_TRACE("ckmc_reset_user_password() returns %d", ckmc_ret);
742 setting_set_int_slp_key(INT_SLP_SETTING_PHONE_LOCK_ATTEMPTS_LEFT, PHONE_LOCK_ATTEMPS_MAX, &err);
744 return SETTING_RETURN_SUCCESS;
748 return SETTING_PW_ERROR_UNKNOWN;
753 ret = security_server_set_pwd(cur_pwd, new_pwd, 0, 0);
754 SETTING_TRACE_DEBUG("[security_server_set_pwd()] returns %d, INFINITE", ret);
755 if(ret == SECURITY_SERVER_API_SUCCESS)
758 ckmc_ret = ckmc_change_user_password(user, cur_pwd, new_pwd);
759 SETTING_TRACE("ckmc_change_user_password() returns %d", ckmc_ret);
760 setting_set_int_slp_key(INT_SLP_SETTING_PHONE_LOCK_ATTEMPTS_LEFT, PHONE_LOCK_ATTEMPS_MAX, &err);
762 return SETTING_RETURN_SUCCESS;
766 return SETTING_PW_ERROR_UNKNOWN;