Tizen 2.0 Release
[apps/home/settings.git] / setting-security / src / setting-security.c
1 /*
2  * setting
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Flora License, Version 1.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://floralicense.org/license/
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 /**
19  *@defgroup setting-security
20  *UG creation code for setting-security
21  */
22
23 #include <setting-security.h>
24 #define Max_Passwd_View_Type_Len        64
25 #ifndef UG_MODULE_API
26 #define UG_MODULE_API __attribute__ ((visibility("default")))
27 #endif
28
29
30 int pwd_handler_do_nothing(SettingSecurityUG *data, void* arg)
31 {
32         SETTING_TRACE_BEGIN;
33         //SettingSecurityUG *ad = (SettingSecurityUG *)data;
34         // DO NOTHING
35         return 0;
36 }
37
38 int pwd_handler_sec_pw_sim_lock_on(SettingSecurityUG *data, void* arg)
39 {
40         SETTING_TRACE_BEGIN;
41         SettingSecurityUG *ad = (SettingSecurityUG *)data;
42         if (tel_get_sim_facility(ad->handle, TAPI_SIM_LOCK_PS, setting_security_sim_get_facility_cb, ad) != TAPI_API_SUCCESS)
43         {
44                 SETTING_TRACE_ERROR("tel_get_sim_facility(TAPI_SIM_LOCK_PS) failed");
45         }
46         return 0;
47 }
48
49
50 int pwd_handler_sec_pw_sim_lock_off(SettingSecurityUG *data, void* arg)
51 {
52         SETTING_TRACE_BEGIN;
53         SettingSecurityUG *ad = (SettingSecurityUG *)data;
54         if (tel_get_sim_facility(ad->handle, TAPI_SIM_LOCK_PS, setting_security_sim_get_facility_cb, ad) != TAPI_API_SUCCESS)
55         {
56                 SETTING_TRACE_ERROR("tel_get_sim_facility(TAPI_SIM_LOCK_PS) failed");
57         }
58         return 0;
59 }
60
61
62 int pwd_handler_sec_pw_pin_lock_on(SettingSecurityUG *data, void* arg)
63 {
64         SETTING_TRACE_BEGIN;
65         SettingSecurityUG *ad = (SettingSecurityUG *)data;
66         if (tel_get_sim_facility(ad->handle, TAPI_SIM_LOCK_SC, setting_security_pin_get_facility_cb, ad) != TAPI_API_SUCCESS)
67         {
68                 SETTING_TRACE_ERROR("tel_get_sim_facility(TAPI_SIM_LOCK_PS) failed");
69         }
70         return 0;
71 }
72
73
74 int pwd_handler_sec_pw_pin_lock_off(SettingSecurityUG *data, void* arg)
75 {
76         SETTING_TRACE_BEGIN;
77         SettingSecurityUG *ad = (SettingSecurityUG *)data;
78         if (tel_get_sim_facility(ad->handle, TAPI_SIM_LOCK_SC, setting_security_pin_get_facility_cb, ad) != TAPI_API_SUCCESS)
79         {
80                 SETTING_TRACE_ERROR("tel_get_sim_facility(TAPI_SIM_LOCK_PS) failed");
81         }
82         return 0;
83 }
84
85
86 int pwd_handler_sec_pw_sim_lock_disabled(SettingSecurityUG *data, void* arg)
87 {
88         SETTING_TRACE_BEGIN;
89         SettingSecurityUG *ad = (SettingSecurityUG *)data;
90         // [in] Evas_Object *checkbtn
91         if (ad->data_sim_lk)
92                 setting_disable_genlist_item(ad->data_sim_lk->item);
93
94         return 0;
95 }
96
97
98 int pwd_handler_sec_pw_change_pin1(SettingSecurityUG *data, void* arg)
99 {
100         SETTING_TRACE_BEGIN;
101         SettingSecurityUG *ad = (SettingSecurityUG *)data;
102         if (tel_get_sim_facility(ad->handle, TAPI_SIM_LOCK_SC, setting_security_pin_get_facility_cb, ad) != TAPI_API_SUCCESS)
103         {
104                 SETTING_TRACE_ERROR("tel_get_sim_facility(TAPI_SIM_LOCK_PS) failed");
105         }
106         return 0;
107 }
108
109 int pwd_handler_sec_pw_change_pin2(SettingSecurityUG *data, void* arg)
110 {
111         SETTING_TRACE_BEGIN;
112         return 0;
113 }
114
115
116 int pwd_handler_sec_pw_pin1_blocked(SettingSecurityUG *data, void* arg)
117 {
118         SETTING_TRACE_BEGIN;
119         SettingSecurityUG *ad = (SettingSecurityUG *)data;
120 #if DISABLED_CODE
121         if (tel_get_sim_facility(ad->handle, TAPI_SIM_LOCK_SC, setting_security_sim_get_facility_cb, ad) != TAPI_API_SUCCESS)
122         {
123                 SETTING_TRACE_ERROR("tel_get_sim_facility(TAPI_SIM_LOCK_PS) failed");
124         }
125 #endif
126         return 0;
127 }
128
129
130 int pwd_handler_sec_pw_pin2_blocked(SettingSecurityUG *data, void* arg)
131 {
132         SETTING_TRACE_BEGIN;
133         SettingSecurityUG *ad = (SettingSecurityUG *)data;
134 #if SUPPORT_FDN
135         if (tel_get_sim_facility(ad->handle, TAPI_SIM_LOCK_FD, setting_security_sim_get_facility_cb, ad) != TAPI_API_SUCCESS)
136         {
137                 SETTING_TRACE_ERROR("tel_get_sim_facility(TAPI_SIM_LOCK_PS) failed");
138         }
139 #endif
140
141         return 0;
142 }
143
144 static struct _security_item security_table[] = {
145         { SETTING_SEC_PW_SIM_LOCK_ON,           "SETTING_PW_TYPE_SIM_LOCK_ON",                  pwd_handler_sec_pw_sim_lock_on },
146         { SETTING_SEC_PW_SIM_LOCK_OFF,          "SETTING_PW_TYPE_SIM_LOCK_OFF",                 pwd_handler_sec_pw_sim_lock_off },
147         { SETTING_SEC_PW_SIM_LOCK_DISABLED, "SETTING_PW_TYPE_SIM_LOCK_DISABLE",         pwd_handler_sec_pw_sim_lock_disabled},
148         { SETTING_SEC_PW_PIN_LOCK_ON,           "SETTING_PW_TYPE_PIN_LOCK_ON",                  pwd_handler_sec_pw_pin_lock_on },
149         { SETTING_SEC_PW_PIN_LOCK_OFF,          "SETTING_PW_TYPE_PIN_LOCK_OFF",                 pwd_handler_sec_pw_pin_lock_off },
150         { SETTING_SEC_PW_CHANGE_PIN1,           "SETTING_PW_TYPE_CHANGE_PIN1",                  pwd_handler_sec_pw_change_pin1},
151         { SETTING_SEC_PW_CHANGE_PIN2,           "SETTING_PW_TYPE_CHANGE_PIN2",                  pwd_handler_sec_pw_change_pin2},
152         { SETTING_SEC_PW_PIN1_BLOCKED,          "SETTING_PW_TYPE_PIN1_BLOCKED",                 pwd_handler_sec_pw_pin1_blocked},
153         { SETTING_SEC_PW_PIN2_BLOCKED,          "SETTING_PW_TYPE_PIN2_BLOCKED",                 pwd_handler_do_nothing},
154         { SETTING_SEC_PW_PIN1_UNBLOCKED,                "SETTING_PW_TYPE_PIN1_UNBLOCKED",               pwd_handler_sec_pw_pin_lock_on},
155         { SETTING_SEC_PW_PIN2_UNBLOCKED,                "SETTING_PW_TYPE_PIN2_UNBLOCKED",               pwd_handler_do_nothing},
156         /*------------------------------------------------------------------------------------------------------------*/
157         { SETTING_SEC_PW_MAX,                           NULL,                                                                   pwd_handler_do_nothing}
158 };
159
160 static void setting_security_ug_cb_resize(void *data, Evas *e,
161                                           Evas_Object *obj, void *event_info)
162 {
163         ret_if(data == NULL);
164
165         SettingSecurityUG *ad = (SettingSecurityUG *) data;     /* ad is point to data */
166         setting_view_update(&setting_view_security_main, ad);
167 }
168
169 static void *setting_security_ug_on_create(ui_gadget_h ug,
170                                            enum ug_mode mode, service_h service,
171                                            void *priv)
172 {
173         setting_retvm_if((!priv), NULL, "!priv");
174
175         SettingSecurityUG *securityUG = priv;
176         securityUG->ug = ug;
177
178         securityUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
179         securityUG->win_get = (Evas_Object *) ug_get_window();
180         evas_object_show(securityUG->win_main_layout);
181         securityUG->evas = evas_object_evas_get(securityUG->win_main_layout);
182
183         setting_retvm_if(securityUG->win_main_layout == NULL, NULL,
184                          "[Setting >> Security] cannot get main window ");
185
186         setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
187
188         /* register view node table */
189         setting_view_node_table_intialize();
190         setting_view_node_table_register(&setting_view_security_main, NULL);
191         setting_view_node_table_register(&setting_view_security_sim_settings, &setting_view_security_main);
192
193         setting_create_Gendial_itc("dialogue/1text", &(securityUG->itc_1text));
194         setting_create_Gendial_itc("dialogue/2text.3", &(securityUG->itc_2text_2));
195         setting_create_Gendial_itc("dialogue/1text.1icon", &(securityUG->itc_1text_1icon));
196
197         securityUG->itc_seperator.item_style = "dialogue/separator";
198         securityUG->itc_seperator.func.text_get = NULL;
199         securityUG->itc_seperator.func.content_get = NULL;
200         securityUG->itc_seperator.func.state_get = NULL;
201         securityUG->itc_seperator.func.del = NULL;
202
203         securityUG->update_view_timer = NULL;
204         /*  creating a view. */
205         securityUG->handle =  tel_init(NULL);
206         if (!securityUG->handle) {
207                 SETTING_TRACE_ERROR("*** [ERR] tel_init. ***");
208                 //return NULL;
209         }
210         else {
211                 if (TAPI_API_SUCCESS != tel_get_sim_facility(securityUG->handle, TAPI_SIM_LOCK_PS, setting_security_sim_get_facility_cb, securityUG)) {
212                         SETTING_TRACE_ERROR("*** [ERR] tel_get_sim_facility(sim_status). ***");
213                 }
214
215                 if (TAPI_API_SUCCESS != tel_get_sim_facility(securityUG->handle, TAPI_SIM_LOCK_SC, setting_security_sim_get_facility_cb, securityUG)) {
216                         SETTING_TRACE_ERROR("*** [ERR] tel_get_sim_facility(pin1). ***");
217                 }
218         }
219
220         setting_view_node_set_cur_view(&setting_view_security_main);
221         setting_view_create(&setting_view_security_main, (void *)securityUG);
222         evas_object_event_callback_add(securityUG->win_main_layout,
223                                        EVAS_CALLBACK_RESIZE,
224                                        setting_security_ug_cb_resize,
225                                        securityUG);
226
227         return securityUG->ly_main;
228 }
229
230 static void setting_security_ug_on_start(ui_gadget_h ug, service_h service,
231                                          void *priv)
232 {
233 }
234
235 static void setting_security_ug_on_pause(ui_gadget_h ug, service_h service,
236                                          void *priv)
237 {
238 }
239
240 static void setting_security_ug_on_resume(ui_gadget_h ug, service_h service,
241                                           void *priv)
242 {
243 }
244
245 static void setting_security_ug_on_destroy(ui_gadget_h ug, service_h service,
246                                            void *priv)
247 {
248         setting_retm_if((!priv), "!priv");
249         SettingSecurityUG *securityUG = priv;
250
251         evas_object_event_callback_del(securityUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_security_ug_cb_resize);       /* fix flash issue for gallery */
252         securityUG->ug = ug;
253         if (securityUG->handle && tel_deinit(securityUG->handle) != TAPI_API_SUCCESS) {
254                 SETTING_TRACE_DEBUG
255                     ("%s*** [ERR] setting_network_unsubscribe_tapi_events. ***%s",
256                      SETTING_FONT_RED, SETTING_FONT_BLACK);
257         }
258
259         /*  delete the allocated objects. */
260         if (TRUE == setting_view_security_sim_settings.is_create) {
261                 setting_view_destroy(&setting_view_security_sim_settings, securityUG);
262         }
263         if (TRUE == setting_view_security_main.is_create) {
264                 setting_view_destroy(&setting_view_security_main, securityUG);
265         }
266
267         if (NULL != ug_get_layout(securityUG->ug)) {
268                 evas_object_hide((Evas_Object *) ug_get_layout(securityUG->ug));
269                 evas_object_del((Evas_Object *) ug_get_layout(securityUG->ug));
270         }
271 }
272
273 static void setting_security_ug_on_message(ui_gadget_h ug, service_h msg,
274                                            service_h service, void *priv)
275 {
276
277 }
278
279 static void setting_security_ug_on_event(ui_gadget_h ug,
280                                          enum ug_event event, service_h service,
281                                          void *priv)
282 {
283         switch (event) {
284         case UG_EVENT_LOW_MEMORY:
285                 break;
286         case UG_EVENT_LOW_BATTERY:
287                 break;
288         case UG_EVENT_LANG_CHANGE:
289                 break;
290         case UG_EVENT_ROTATE_PORTRAIT:
291                 break;
292         case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
293                 break;
294         case UG_EVENT_ROTATE_LANDSCAPE:
295                 break;
296         case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
297                 break;
298         case UG_EVENT_REGION_CHANGE:
299                 break;
300         default:
301                 break;
302         }
303 }
304
305 static void setting_security_ug_on_key_event(ui_gadget_h ug,
306                                              enum ug_key_event event,
307                                              service_h service, void *priv)
308 {
309         if (!priv)
310                 return;
311         SettingSecurityUG *ad = (SettingSecurityUG *) priv;     /* ad is point to priv */
312         switch (event) {
313         case UG_KEY_EVENT_END:
314                 {
315                         if (elm_naviframe_top_item_get(ad->navi_bar) ==
316                            elm_naviframe_bottom_item_get(ad->navi_bar)) {
317                                 ug_destroy_me(ug);
318                         } else {
319                                 /* elm_naviframe_item_pop(ad->navi_bar); */
320                                 setting_view_cb_at_endKey(ad);
321                         }
322                 }
323                 break;
324
325         default:
326                 break;
327         }
328 }
329
330 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
331 {
332         SettingSecurityUG *securityUG = calloc(1, sizeof(SettingSecurityUG));
333         setting_retvm_if(!securityUG, -1,
334                          "Create SettingSecurityUG obj failed");
335
336         ops->create = setting_security_ug_on_create;
337         ops->start = setting_security_ug_on_start;
338         ops->pause = setting_security_ug_on_pause;
339         ops->resume = setting_security_ug_on_resume;
340         ops->destroy = setting_security_ug_on_destroy;
341         ops->message = setting_security_ug_on_message;
342         ops->event = setting_security_ug_on_event;
343         ops->key_event = setting_security_ug_on_key_event;
344         ops->priv = securityUG;
345         ops->opt = UG_OPT_INDICATOR_ENABLE;
346
347         return 0;
348 }
349
350 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
351 {
352         struct SettingSecurityUG *securityUG;
353         setting_retm_if(!ops, "ops == NULL");
354
355         securityUG = ops->priv;
356         if (securityUG)
357                 FREE(securityUG);
358 }
359
360 /* ***************************************************
361  *
362  *general func
363  *
364  ***************************************************/
365 void setting_security_sim_get_facility_cb(TapiHandle *handle, int result, void *data, void *user_data)
366 {
367         SETTING_TRACE_BEGIN;
368
369         ret_if(!user_data);
370         SETTING_TRACE_DEBUG("user_data is not NULL");
371
372         ret_if(!data);
373         SETTING_TRACE_DEBUG("data is not NULL");
374
375         TelSimPinOperationResult_t sec_rt = result;
376         TelSimFacilityInfo_t *fi = data;
377         SettingSecurityUG *ad = user_data;
378
379
380         if(ad->sim_popup)
381         {
382                 evas_object_del(ad->sim_popup);
383                 ad->sim_popup = NULL;
384         }
385
386         SETTING_TRACE("sec_rt[%d]", sec_rt);
387         SETTING_TRACE("fi->type[%d]", fi->type);
388         SETTING_TRACE("fi->f_status[%d]", fi->f_status);
389         if (sec_rt == TAPI_SIM_PIN_OPERATION_SUCCESS)
390         {
391                 SETTING_TRACE_DEBUG("PIN_OPERATION_SUCCESS");
392                 switch (fi->type)
393                 {
394                     case TAPI_SIM_LOCK_PS://sim status
395                         ad->sim_status = fi->f_status;
396                         break;
397                     default:
398                         break;
399                 }
400         }
401         else
402         {
403                 //if failed, do nothing..
404         }
405
406         /* Update SIM Settings view if created. */
407         if(setting_view_security_sim_settings.is_create == 1)
408         {
409                 SETTING_TRACE_DEBUG("SIM settings view is already created. [%d]", setting_view_security_sim_settings.is_create);
410                 setting_view_update(&setting_view_security_sim_settings, ad);
411         }
412         else
413         {
414                 SETTING_TRACE_DEBUG("Change view");
415                 setting_view_change(&setting_view_security_main, &setting_view_security_sim_settings, ad);
416         }
417
418         SETTING_TRACE_END;
419 }
420
421 void setting_security_pin_get_facility_cb(TapiHandle *handle, int result, void *data, void *user_data)
422 {
423         SETTING_TRACE_BEGIN;
424
425         ret_if(!user_data);
426         SETTING_TRACE_DEBUG("user_data is not NULL");
427
428         ret_if(!data);
429         SETTING_TRACE_DEBUG("data is not NULL");
430
431         TelSimPinOperationResult_t sec_rt = result;
432         TelSimFacilityInfo_t *fi = data;
433         SettingSecurityUG *ad = user_data;
434
435         if(ad->sim_popup)
436         {
437                 evas_object_del(ad->sim_popup);
438                 ad->sim_popup = NULL;
439         }
440
441         SETTING_TRACE("sec_rt[%d]", sec_rt);
442         SETTING_TRACE("fi->type[%d]", fi->type);
443         SETTING_TRACE("fi->f_status[%d]", fi->f_status);
444         if (sec_rt == TAPI_SIM_PIN_OPERATION_SUCCESS)
445         {
446                 SETTING_TRACE_DEBUG("PIN_OPERATION_SUCCESS");
447                 switch (fi->type)
448                 {
449                     case TAPI_SIM_LOCK_SC://pin1 status
450                         ad->pin1_status = fi->f_status;
451                         break;
452                     case TAPI_SIM_LOCK_FD://pin2/fdn status
453                         ad->pin2_status = fi->f_status;
454                         break;
455                     default:
456                         break;
457                 }
458         }
459         else
460         {
461                 //if failed, do nothing..
462         }
463
464         /* Update SIM Settings view if created. */
465         if(setting_view_security_sim_settings.is_create == 1)
466         {
467                 SETTING_TRACE_DEBUG("SIM settings view is already created. [%d]", setting_view_security_sim_settings.is_create);
468                 setting_view_update(&setting_view_security_sim_settings, ad);
469         }
470         else
471         {
472                 SETTING_TRACE_DEBUG("Change view");
473                 setting_view_change(&setting_view_security_main, &setting_view_security_sim_settings, ad);
474         }
475
476         SETTING_TRACE_END;
477 }
478
479 void setting_security_layout_passwd_ug_cb(ui_gadget_h ug,
480                                                  enum ug_mode mode, void *priv)
481 {
482         if (!priv)
483                 return;
484
485         SettingSecurityUG *ad = (SettingSecurityUG *) priv;
486         Evas_Object *base = ug_get_layout(ug);
487         if (!base)
488                 return;
489
490         switch (mode) {
491         case UG_MODE_FULLVIEW:
492                 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
493                                                  EVAS_HINT_EXPAND);
494                 //elm_win_resize_object_add(ad->win_get, base);
495                 evas_object_show(base);
496                 break;
497         default:
498                 break;
499         }
500
501         return;
502 }
503
504 void setting_security_destroy_password_ug_cb(ui_gadget_h ug,
505                                                     void *priv)
506 {
507         SETTING_TRACE_BEGIN;
508         ret_if(priv == NULL);
509         SettingSecurityUG *ad = (SettingSecurityUG *) priv;
510         if (ug) {
511                 ug_destroy(ug);
512                 ad->ug_passwd = NULL;
513         }
514 }
515
516 gboolean setting_security_create_password_sg(void *data)
517 {
518         SETTING_TRACE_BEGIN;
519         /* error check */
520         retv_if(data == NULL, FALSE);
521
522         SettingSecurityUG *ad = (SettingSecurityUG *) data;     /* ad is point to data */
523
524         /* prevent the ug from being loaded again due to window event queuing */
525         /* added by JTS: CQ H0100135346 */
526         if (ad->ug_passwd) {
527                 SETTING_TRACE("Password UG is already loaded.");
528                 return FALSE;
529         }
530
531         if((ad->pw_type < 0) || (ad->pw_type > SETTING_SEC_PW_MAX))
532                 return FALSE;
533
534         char str[Max_Passwd_View_Type_Len + 1] = { 0, };
535         safeCopyStr(str, security_table[ad->pw_type].pw_type_string, Max_Passwd_View_Type_Len);
536
537         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
538
539         if (!cbs)
540                 return FALSE;
541         cbs->layout_cb = setting_security_layout_passwd_ug_cb;
542         cbs->result_cb = setting_security_result_password_ug_cb;
543         cbs->destroy_cb = setting_security_destroy_password_ug_cb;
544         cbs->priv = (void *)ad;
545
546         service_h svc;
547         if (service_create(&svc)) {
548                 FREE(cbs);
549                 return FALSE;
550         }
551
552         service_add_extra_data(svc, "viewtype", str);
553         if(ad->input_pwd)
554         {
555                 SETTING_TRACE_DEBUG("Send current : %s", ad->input_pwd);
556                 service_add_extra_data(svc, "current", ad->input_pwd);
557         }
558         ad->ug_passwd = ug_create(ad->ug, "setting-password-efl", UG_MODE_FULLVIEW, svc, cbs);
559         if (NULL == ad->ug_passwd) {    /* error handling */
560                 evas_object_show(ad->ly_main);
561         }
562
563         service_destroy(svc);
564         FREE(cbs);
565
566         return TRUE;
567 }
568
569 /* ***************************************************
570  *
571  *call back func
572  *
573  ***************************************************/
574 // -1   on fail
575 // 0~n  on success
576 int _get_security_table_index(char* name)
577 {
578         int i=0;
579
580         for(i=0;i<SETTING_SEC_PW_MAX;i++)
581         {
582                 if (0 == safeStrCmp(name, security_table[i].pw_type_string))
583                         return i;
584         }
585         return -1;
586 }
587
588 void
589 setting_security_result_password_ug_cb(ui_gadget_h ug, service_h service,
590                                        void *priv)
591 {
592         SETTING_TRACE_BEGIN;
593         /* error check */
594         retm_if(priv == NULL, "Data paremeter is NULL");
595
596         SettingSecurityUG *ad = (SettingSecurityUG *) priv;     /* ad is point to priv */
597
598         char *result = NULL;
599         char *current = NULL;
600
601         service_get_extra_data(service, "result", &result);
602         service_get_extra_data(service, "current", &current);
603
604         /* divided pw view type */
605         SETTING_TRACE("ad->pw_type: %d result :%s", ad->pw_type, result);
606         ret_if(NULL == result);
607
608         if(safeStrCmp(result, "Cancel") == 0)
609         {
610                 /* To do : rollback previouse status. */
611         }
612         else
613         {
614                 int index =  _get_security_table_index(result);
615                 int ret;
616                 if (index != -1)
617                 {
618                         ret = security_table[index].passwd_handler(ad, NULL);
619                 } else {
620                         SETTING_TRACE_ERROR("no table entry");
621                 }
622                 if(ad->input_pwd)
623                         FREE(ad->input_pwd);
624         }
625
626         evas_object_show(ad->ly_main);
627         SETTING_TRACE_END;
628 }
629
630 #ifdef Status
631 #undef Status
632 #endif
633
634
635 /*****/
636 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
637 {
638         SETTING_TRACE_BEGIN;
639         int ret = 0;
640 #if SUPPORT_RUN_SYSTEM_COMMAND
641         ret += excuteCmd(SETTING_POSTINST_FILE, 1, "security");
642 #else
643
644         /* it may write some stragne thing into /opt/data/setting/set_info */
645         /* setting_store_init_password(""); */
646         struct stat st;
647         if (stat(PWD_FILE, &st) == 0)//file exist
648         {
649                 if (remove(PWD_FILE) != 0) //delete the file
650                 {
651                         perror("remove");
652                         SETTING_TRACE("Failed to remove %s", PWD_FILE);
653                         ret += -1;
654                 }
655         }
656
657         #if SUPPORT_RCS_FOR_DEMO
658         ret += vconf_set_bool("db/setting/rcs", FALSE);
659         #endif
660 #endif
661         return ret;
662 }
663