remove some menu of Reset settings if emulator
[apps/core/preloaded/settings.git] / setting-reset / src / setting-reset-settings.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 #include <setting-cfg.h>
22 #include <setting-reset-settings.h>
23 #include <heynoti.h>
24 #include <Ecore_X.h>
25 #include <utilX.h>
26
27 #define RESULT_FONT_SIZE 28//18
28 #define ITEM_NAME_FONT_SIZE 35//22
29
30 static int setting_reset_settings_create(void *cb);
31 static int setting_reset_settings_destroy(void *cb);
32 static int setting_reset_settings_update(void *cb);
33 static int setting_reset_settings_cleanup(void *cb);
34
35 setting_view setting_view_reset_settings = {
36         .create = setting_reset_settings_create,
37         .destroy = setting_reset_settings_destroy,
38         .update = setting_reset_settings_update,
39         .cleanup = setting_reset_settings_cleanup,
40 };
41
42 static void setting_reset_settings_click_softkey_reset_cb(void *data,
43                                                       Evas_Object *obj,
44                                                       void *event_info);
45 static void setting_reset_settings_click_softkey_cancel_cb(void *data,
46                                                        Evas_Object *obj,
47                                                        void *event_info);
48 #if SUPPORT_SECURITY
49 static bool setting_reset_settings_create_password_sg(void *data);
50 static void setting_reset_settings_result_password_ug_cb(ui_gadget_h ug,
51                                                      service_h result,
52                                                      void *priv);
53 #endif
54 static void setting_reset_settings_check_state(Setting_Done_List_Data *list_data);
55
56 /* ***************************************************
57  *
58  *basic func
59  *
60  ***************************************************/
61 static char *__result_gl_text_get(void *data, Evas_Object *obj,
62                                    const char *part)
63 {
64         retv_if(!data, NULL);
65         Setting_GenGroupItem_Data *item_data =
66             (Setting_GenGroupItem_Data *) data;
67         //SETTING_TRACE("part:%s", part);
68
69         if (!safeStrCmp(part, "elm.text.1")) {  /* title */
70                 char label[HELP_MSG_BUFF_SIZE + 1] = { 0, };
71                 if (item_data->keyStr)
72                 {
73                         const char *key = setting_customize_text(_(item_data->keyStr), ITEM_NAME_FONT_SIZE, NULL, NULL);
74                         safeStrNCat(label, key,HELP_MSG_BUFF_SIZE);
75                         FREE(key);
76                 }
77                 if (item_data->sub_desc)
78                 {
79                         safeStrNCat(label, ": ",HELP_MSG_BUFF_SIZE);
80                         const char *sub_desc = setting_customize_text(_(item_data->sub_desc), RESULT_FONT_SIZE, NULL, NULL);
81                         safeStrNCat(label, sub_desc,HELP_MSG_BUFF_SIZE);
82                         FREE(sub_desc);
83                 }
84                 return (char *)g_strdup(label);
85         }
86         return NULL;
87 }
88 #if SIMPLY_SUPPORT_ALL_RESET
89 static void __processing_popup_response_cb(void *data, Evas_Object *obj,
90                                      void *event_info)
91 {
92         ret_if(!data);
93         SettingResetUG *ad = data;
94         setting_reset_special_process(ad);
95         if (obj) {
96                 evas_object_del(obj);
97                 obj = NULL;
98         }
99         ad->notify= NULL;
100
101         // key ungrab: after showing the result popup
102         Ecore_X_Display *disp = ecore_x_display_get();
103         Ecore_X_Window xwin = elm_win_xwindow_get((Evas_Object*)ug_get_window());
104         int ret = utilx_ungrab_key(disp, xwin, KEY_HOME);
105         if (ret) {
106                 SETTING_TRACE_ERROR("KEY_HOME ungrab error ret[%d]", ret);
107         }
108 }
109 #endif
110 #if SIMPLY_SUPPORT_ALL_RESET
111 bool __reset_all_idler(void *data)
112 {
113         SETTING_TRACE_BEGIN;
114         retv_if(!data, FALSE);
115         SettingResetUG *ad = data;
116
117         int i = 0;
118         int j = 0;
119         int idx = 0;
120         const char *result_str = RESET_SUCESS_STR;
121         char ug_file[PATH_MAX + 1];
122         char *path = NULL;
123         service_h svc;
124         int ret = -1;
125         char *ug_args;
126         char *item_name;
127
128         for (; i < setting_cfg_get_category_length(); i++) {
129                 //SETTING_TRACE("group is:%s", _(setting_cfg_get_category_name(i)));
130
131                 result_str = RESET_SUCESS_STR;
132                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
133                         /*SETTING_TRACE("i:%d\tj:%d", i, j);*/
134                         if (Cfg_Item_unResetable ==
135                             setting_cfg_get_resetable_flag_idx(i, j))
136                         {
137                                 //SETTING_TRACE("process %s:%s skipped",_(item_name), ug_args);
138                                 continue;
139                         }
140                         ug_args = setting_cfg_get_ug_args_idx(i, j);
141                         item_name = setting_cfg_get_keyname_idx(i, j);
142                         if (item_name)
143                                 SETTING_TRACE(">>> process %s:%s",_(item_name), ug_args);
144
145                         idx++;
146                         if (NULL == ug_args) /*special process*/
147                         {
148                                 ret = -1;
149                                 if (!safeStrCmp(KeyStr_FlightMode, item_name)) {
150                                         //Invoke aync API and ignore the response message
151                                         ret = setting_reset_flight_mode();
152                                 } else if (!safeStrCmp(KeyStr_Landscape, item_name)) {
153                                         ret = setting_reset_rotation_lock();
154                                 }
155                                 //..
156                                 if (0 > ret)
157                                 {
158                                         result_str = RESET_FAILED_STR;
159                                 }
160
161
162                         }
163                         else
164                         {
165                                 path = get_ug_path_from_ug_args((void *)ug_args);
166                                 svc = get_bundle_from_ug_args((void *)ug_args);
167
168                                 //if (snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH, path) < 0)
169                                 //      return FALSE;
170
171                                 ret = setting_invoke_reset_function(path, svc, NULL);
172                                 //SETTING_TRACE("load %s[plugin_ret:%d]", ug_file, ret);
173
174                                 if (OPERATE_LIB_SUCESS > ret)
175                                 {
176                                         result_str = RESET_FAILED_STR;
177
178                                 }
179
180                                 service_destroy(svc);
181                                 FREE(path);
182                                 memset(ug_file, 0, PATH_MAX);
183                         }
184                         SETTING_TRACE("process %s:%s %s",_(item_name), ug_args, _(result_str));
185                 }
186         }
187
188         //list_data->cur_item_num = idx;
189         SETTING_TRACE_DEBUG("Reset totally %d items. result_str:%s", idx, result_str);
190         //setting_create_popup_with_notitle(NULL, ad->win_get, _(result_str));
191         elm_popup_desc_set(ad->notify, _(result_str));
192         elm_popup_mode_set(ad->notify, POPUP_INTERVAL);
193         elm_popup_timeout_set(ad->notify, 2);
194
195         if (ad->reset_all_idler) {
196                 ecore_idler_del(ad->reset_all_idler);
197                 ad->reset_all_idler = NULL;
198         }
199         return FALSE;
200 }
201 #endif
202 #if SIMPLY_SUPPORT_ALL_RESET
203 static void __reset_all_button_cb(void *data, Evas_Object *obj, void *event_info)
204 {
205         SETTING_TRACE_BEGIN;
206         ret_if(!data);
207         Setting_GenGroupItem_Data *item_Data = data;
208         ret_if(!item_Data->userdata);
209         SettingResetUG *ad = item_Data->userdata;
210
211
212         char pw_pass[SETTING_STR_SLP_LEN] = { 0, };
213         int err = 0;
214
215         /*  Check Password Setting status */
216         int ret =
217             setting_get_string_slp_key(STR_SLP_LIST_PHONE_PASSWORD,
218                                        pw_pass, &err);
219         SETTING_TRACE("pw_pass:%s", pw_pass);
220         if (SETTING_RETURN_SUCCESS == ret && '\0' != pw_pass[0]) {
221                 setting_reset_settings_create_password_sg(ad);
222                 return;
223         }
224
225         // key grab: before showing processing popup
226         Ecore_X_Display *disp = ecore_x_display_get();
227         Ecore_X_Window xwin = elm_win_xwindow_get((Evas_Object*)ug_get_window());
228         ret = utilx_grab_key(disp, xwin, KEY_HOME, TOP_POSITION_GRAB);
229         if (ret) {
230                 SETTING_TRACE_ERROR("KEY_HOME grab error ret[%d]", ret);
231         }
232
233         ad->notify =
234                 setting_create_popup_without_btn(ad, ad->win_get, NULL, _("IDS_COM_POP_PROCESSING"), __processing_popup_response_cb, 0, 1, 1);
235         if (ad->reset_all_idler) {
236                 ecore_idler_del(ad->reset_all_idler);
237                 ad->reset_all_idler = NULL;
238         }
239
240         ad->reset_all_idler =
241             ecore_idler_add((Ecore_Task_Cb) __reset_all_idler, ad);
242 }
243 #endif
244 static int setting_reset_settings_create(void *cb)
245 {
246         SETTING_TRACE_BEGIN;
247         /* error check */
248         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
249
250         SettingResetUG *ad = (SettingResetUG *) cb;
251         Evas_Object *scroller = NULL;
252         Evas_Object *controllbar = NULL;
253
254         Evas_Object *view_layout = elm_layout_add(ad->win_main_layout);
255         elm_layout_file_set(view_layout, SETTING_THEME_EDJ_NAME,
256                             "selinfo_bottom");
257         evas_object_size_hint_weight_set(view_layout, EVAS_HINT_EXPAND, 0.0);
258
259         /*  Evas_Object * win_layout, Evas_Object * win_obj */
260         setting_push_layout_navi_bar(_(RESET_SETTINGS_STR),
261                                    _("IDS_COM_BODY_RESET"),
262                                    _("IDS_COM_SK_CANCEL"), NULL,
263                                    setting_reset_settings_click_softkey_reset_cb,
264                                    setting_reset_settings_click_softkey_cancel_cb,
265                                    NULL, ad, view_layout, ad->navi_bar,
266                                    &controllbar);
267
268         /* ******************************************create frame */
269         Setting_Done_List_Data *list_data = &(ad->list_data);   /* define a handle */
270         int idx = 0;
271         list_data->win_main = ad->win_main_layout;
272         list_data->UG_data = ad;
273         list_data->ly_parent = view_layout;
274         list_data->controllbar = controllbar;
275         list_data->select_all_checked = EINA_FALSE;
276         bool is_emulator = isEmulBin();
277
278         char *ug_args;
279         char *item_name;
280
281         int i = 0;
282         int j = 0;
283
284         for (; i < setting_cfg_get_category_length(); i++) {
285                 SETTING_TRACE("group is:%s", _(setting_cfg_get_category_name(i)));
286
287                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
288                         /*SETTING_TRACE("i:%d\tj:%d", i, j);*/
289                         if (Cfg_Item_unResetable ==
290                             setting_cfg_get_resetable_flag_idx(i, j))
291                         {
292                             continue;
293                         }
294                         ug_args = setting_cfg_get_ug_args_idx(i, j);
295                         if (!is_ug_installed_by_ug_args(ug_args))
296                         {
297                                 continue;
298                         }
299
300                         item_name = setting_cfg_get_keyname_idx(i, j);
301                         if (is_emulator)
302                         {
303                                 if (!safeStrCmp(KeyStr_FlightMode, item_name)) {
304                                         continue; /* hide Flight Mode in Emulator*/
305                                 } else if (!safeStrCmp(KeyStr_WiFi, item_name)) {
306                                         continue; /* hide WIFI in Emulator*/
307                                 } else if (!safeStrCmp(KeyStr_WiFiDirect, item_name)) {
308                                         continue; /* hide WiFiDirect in Emulator*/
309                                 } else if (!safeStrCmp(KeyStr_Network, item_name)) {
310                                         continue; /* hide Network in Emulator*/
311                                 } else if (!safeStrCmp(KeyStr_Bluetooth, item_name)) {
312                                         continue; /* hide Bluetooth in Emulator*/
313                                 } else if (!safeStrCmp(KeyStr_Security, item_name)) {
314                                         continue; /* hide Security in Emulator*/
315                                 } else if (!safeStrCmp(KeyStr_Motions, item_name)) {
316                                         continue; /* hide Motion in Emulator*/
317                                 } else if (!safeStrCmp(KeyStr_Accessibility, item_name)) {
318                                         continue; /* hide Accessibility in Emulator*/
319                                 } else if (!safeStrCmp(KeyStr_Memory, item_name)) {
320                                         continue; /* hide Memory in Emulator*/
321                                 } else if (!safeStrCmp(KeyStr_Powersaving, item_name)) {
322                                         continue; /* hide Powersaving in Emulator*/
323                                 } else if (safeStrCmp(KeyStr_Email, item_name)) {
324                                         continue;
325                                 }
326                         }
327
328                         list_data->chk_items[idx].ug_args = ug_args;
329                         list_data->chk_items[idx].item_name = item_name;
330
331                         SETTING_TRACE("process %s:\t%s",_(item_name), ug_args);
332                         idx++;
333                 }
334         }
335
336         list_data->cur_item_num = idx;
337         SETTING_TRACE("list_data->cur_item_num:%d", list_data->cur_item_num);
338         scroller = setting_create_done_list(list_data);
339         elm_object_part_content_set(view_layout, "elm.swallow.contents", scroller);
340
341         ad->view_layout = view_layout;
342         ad->controllbar = controllbar;
343         /* *******************************************update info */
344
345         setting_view_reset_settings.is_create = 1;
346         ad->itc_1text.func.text_get = __result_gl_text_get;
347         return SETTING_RETURN_SUCCESS;
348 }
349
350 static int setting_reset_settings_destroy(void *cb)
351 {
352         SETTING_TRACE_BEGIN;
353         /* error check */
354         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
355
356         SettingResetUG *ad = (SettingResetUG *) cb;
357
358         if (ad->list_data.selInfoPop) {
359                 evas_object_del(ad->list_data.selInfoPop);
360                 ad->list_data.selInfoPop = NULL;
361         }
362         if (ad->notify) {
363                 evas_object_del(ad->notify);
364                 ad->notify = NULL;
365         }
366         if (ad->old_notify) {
367                 evas_object_del(ad->old_notify);
368                 ad->old_notify = NULL;
369         }
370         if (ad->pop)
371         {
372                 evas_object_del(ad->pop);
373                 ad->pop = NULL;
374         }
375         if (ad->pop_progress)
376         {
377                 evas_object_del(ad->pop_progress);
378                 ad->pop_progress = NULL;
379         }
380
381         if (ad->ask_popup)
382         {
383                 evas_object_del(ad->ask_popup);
384                 ad->ask_popup = NULL;
385         }
386         if (ad->animator)
387         {
388                 ecore_animator_del(ad->animator);
389                 ad->animator = NULL;
390         }
391
392         if (ad->reset_all_idler) {
393                 ecore_idler_del(ad->reset_all_idler);
394                 ad->reset_all_idler = NULL;
395         }
396
397         elm_naviframe_item_pop(ad->navi_bar);
398         setting_view_reset_settings.is_create = 0;
399
400         return SETTING_RETURN_SUCCESS;
401 }
402
403 static int setting_reset_settings_update(void *cb)
404 {
405         SETTING_TRACE_BEGIN;
406
407         return SETTING_RETURN_SUCCESS;
408 }
409
410 static int setting_reset_settings_cleanup(void *cb)
411 {
412         SETTING_TRACE_BEGIN;
413         /* error check */
414         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
415
416         //SettingResetUG *ad = (SettingResetUG *) cb;
417
418         setting_reset_settings_destroy(cb);
419
420         return SETTING_RETURN_SUCCESS;
421 }
422
423 /* ***************************************************
424  *
425  *general func
426  *
427  ***************************************************/
428
429 static void __reset_an_item(Setting_Done_List_Data *list_data,
430                                 const char *item_name,
431                                 const char *ug_args)
432 {
433         SettingResetUG *ad = (SettingResetUG *) list_data->UG_data;
434         if(ad == NULL)
435                 return;
436
437         Evas_Object *genlist = elm_object_content_get(ad->notify);
438         Setting_GenGroupItem_Data *item_data = NULL;
439         const char *result_str = RESET_SUCESS_STR;
440         if (NULL == ug_args) /*special process*/
441         {
442                 int ret = -1;
443                 if (!safeStrCmp(KeyStr_FlightMode, item_name)) {
444                         //Invoke aync API and ignore the response message
445                         ret = setting_reset_flight_mode();
446                 } else if (!safeStrCmp(KeyStr_Landscape, item_name)) {
447                         ret = setting_reset_rotation_lock();
448                 }
449                 //..
450                 if (0 > ret)
451                 {
452                         result_str = VCONF_RESET_FAILED_STR;
453                 }
454
455                 item_data = setting_create_Gendial_field_def(genlist, &(ad->itc_1text),
456                                                  NULL, ad,
457                                                  SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
458                                                  NULL, NULL, 0,
459                                                  (char *)item_name,
460                                                  (char *)result_str, NULL);
461                 elm_genlist_item_select_mode_set(elm_genlist_item_append(genlist, &(itc_seperator), NULL, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL),
462                                                  ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
463
464         } else
465         {
466                 char *path = get_ug_path_from_ug_args((void *)ug_args);
467                 service_h svc = get_bundle_from_ug_args((void *)ug_args);
468
469                 int plugin_ret = setting_invoke_reset_function(path, svc, NULL);
470                 SETTING_TRACE("load libug-%s.so[plugin_ret:%d]", path, plugin_ret);
471
472                 if (LOAD_LIB_FAILED == plugin_ret) // -1
473                 {
474                         result_str = LOAD_LIB_FAILED_STR;
475
476                 } else if (UNDEFINED_LIB_SYMBOL == plugin_ret) // -2
477                 {
478                         result_str = UNDEFINE_STR;
479                 } else if (OPERATE_LIB_SUCESS <= plugin_ret){ // 0
480                         result_str = RESET_SUCESS_STR;
481
482                 } else {
483                         result_str = RESET_FAILED_STR;
484                 }
485
486                 service_destroy(svc);
487                 if (path){
488                         FREE(path);
489                         path = NULL;
490                 }
491
492                 item_data = setting_create_Gendial_field_def(genlist, &(ad->itc_1text),
493                                                  NULL, ad,
494                                                  SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
495                                                  NULL, NULL, 0,
496                                                  (char *)item_name,
497                                                  (char *)result_str, NULL);
498                 elm_genlist_item_select_mode_set(elm_genlist_item_append(genlist, &(itc_seperator), NULL, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL),
499                                                  ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
500         }
501
502         if (item_data)
503                 elm_genlist_item_show(item_data->item, ELM_GENLIST_ITEM_SCROLLTO_IN);//show the last item
504         else
505                 SETTING_TRACE_ERROR("error : item_data is NULL");
506 }
507
508 static Eina_Bool __reset_animator_cb(void *data)
509 {
510         SettingResetUG *ad = (SettingResetUG *) data;
511
512         SETTING_TRACE("Processing the %dth of %d",
513                       ad->gl_index, ad->list_data.cur_item_num);
514         if (ad->gl_index >=  ad->list_data.cur_item_num) {
515                 ecore_animator_del(ad->animator);
516                 ad->animator = NULL;
517                 if (ad->pop_progress) {
518                         evas_object_del(ad->pop_progress);
519                         ad->pop_progress = NULL;
520                 }
521
522                 return ECORE_CALLBACK_CANCEL;
523         }
524         if (ad->list_data.chk_items[ad->gl_index].data_GenItem->chk_status) {
525                 __reset_an_item(&(ad->list_data),
526                                 ad->list_data.chk_items[ad->gl_index].item_name,
527                                 ad->list_data.chk_items[ad->gl_index].ug_args);
528
529                 /*unselect item*/
530                 elm_check_state_set(ad->list_data.chk_items[ad->gl_index].data_GenItem->eo_check, 0);
531                 ad->list_data.chk_items[ad->gl_index].data_GenItem->chk_status = 0;
532         }
533
534         ad->gl_index++;
535         return ECORE_CALLBACK_RENEW;
536 }
537
538 bool __reset_delay_idler(void *data)
539 {
540         SETTING_TRACE_BEGIN;
541         retv_if(!data, FALSE);
542         SettingResetUG *ad = data;
543         ad->gl_index = 0;
544         ad->animator = ecore_animator_add(__reset_animator_cb, ad);
545         return FALSE;
546 }
547
548 static void setting_reset_settings_check_state(Setting_Done_List_Data *list_data)
549 {
550         /* reset */
551         SETTING_TRACE_DEBUG("********resetting*******");
552
553         SettingResetUG *ad = (SettingResetUG *) list_data->UG_data;
554
555         //some item must have been selected, or else cannot go into setting_reset_check_state()
556         ad->notify = elm_popup_add(ad->win_get);
557         elm_object_style_set(ad->notify,"menustyle");
558         elm_object_part_text_set(ad->notify, "title,text", _(RESET_RESULT_STR));
559         evas_object_size_hint_weight_set(ad->notify,
560                                 EVAS_HINT_EXPAND,
561                                 EVAS_HINT_EXPAND);
562         Evas_Object *btn = setting_create_button(ad->notify, _("IDS_COM_SK_OK"), NULL, setting_reset_result_popup_resp_cb, ad);
563         elm_object_part_content_set(ad->notify, "button1", btn);
564
565         Evas_Object *genlist = elm_genlist_add(ad->notify);
566         elm_object_style_set(genlist, "dialogue");
567         evas_object_size_hint_weight_set(genlist,
568                                 EVAS_HINT_EXPAND,
569                                 EVAS_HINT_EXPAND);
570         evas_object_size_hint_align_set(genlist,
571                                 EVAS_HINT_FILL,
572                                 EVAS_HINT_FILL);
573
574         elm_object_content_set(ad->notify, genlist);
575         evas_object_show(ad->notify);
576
577         ad->pop_progress = setting_create_popup_with_progressbar(ad, ad->win_get,
578                                  "list_process",
579                                  NULL, NULL, NULL, 0, 1, 1);
580
581         //ad->gl_index = 0;
582         //ad->animator = ecore_animator_add(__reset_animator_cb, ad);
583         //Don't append any item until the popup is fully showed up
584         ecore_idler_add((Ecore_Task_Cb) __reset_delay_idler, ad);
585
586         /* reset sel_all item */
587         elm_check_state_set(list_data->select_all_checkbox, 0);
588         list_data->select_all_checked = EINA_FALSE;
589
590 }
591
592 #if SUPPORT_SECURITY
593 static void
594 setting_reset_settings_result_password_ug_cb(ui_gadget_h ug, service_h result,
595                                          void *priv)
596 {
597         SETTING_TRACE_BEGIN;
598         /* error check */
599         retm_if(priv == NULL, "Data parameter is NULL");
600
601         SettingResetUG *ad = (SettingResetUG *) priv;
602
603         char *ret_str = NULL;
604
605         service_get_extra_data(result, "result", &ret_str);
606
607         retm_if(ret_str == NULL, "result paremeter is NULL");
608         SETTING_TRACE("result:%s", ret_str);
609
610         if (ret_str) {
611                 if (0 == safeStrCmp("Cancel", ret_str)) {
612                         /* Do not reset */
613                 }
614                 else if (0 == safeStrCmp("SETTING_PW_TYPE_RESET", ret_str)) {
615                         /*  Reset */
616 #if SIMPLY_SUPPORT_ALL_RESET
617                         ad->notify =
618                                 setting_create_popup_witout_btn(ad, ad->win_get, _("IDS_COM_POP_PROCESSING"), NULL, __processing_popup_response_cb, 0);
619                         if (ad->reset_all_idler) {
620                                 ecore_idler_del(ad->reset_all_idler);
621                                 ad->reset_all_idler = NULL;
622                         }
623                         ad->reset_all_idler =
624                             ecore_idler_add((Ecore_Task_Cb) __reset_all_idler, ad);
625 #else
626                         /* if return value from passwordUG, create popup for resetting. */
627                         setting_reset_settings_check_state(&(ad->list_data));
628 #endif
629                 }
630         }
631 }
632
633 static void
634 setting_reset_settings_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
635                                 void *priv)
636 {
637         SettingResetUG *ad = (SettingResetUG *) priv;
638         Evas_Object *base;
639
640         if (!priv)
641                 return;
642         SETTING_TRACE_BEGIN;
643
644         base = (Evas_Object *) ug_get_layout(ug);
645         if (!base)
646                 return;
647
648         switch (mode) {
649         case UG_MODE_FULLVIEW:
650                 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
651                                                  EVAS_HINT_EXPAND);
652                 elm_win_resize_object_add(ad->win_get, base);
653                 evas_object_show(base);
654                 break;
655         default:
656                 break;
657         }
658         SETTING_TRACE_END;
659 }
660
661 static void setting_reset_settings_destroy_password_ug_cb(ui_gadget_h ug,
662                                                       void *priv)
663 {
664         SETTING_TRACE_BEGIN;
665         ret_if(!priv);
666         SettingResetUG *ad = (SettingResetUG *) priv;
667         if (ug) {
668                 ug_destroy(ug);
669                 ad->ug_loading = NULL;
670         }
671
672 }
673
674 static bool setting_reset_settings_create_password_sg(void *data)
675 {
676         SETTING_TRACE_BEGIN;
677         /* error check */
678         retv_if(data == NULL, FALSE);
679
680         SettingResetUG *ad = (SettingResetUG *) data;
681
682         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
683         if (!cbs)
684                 return FALSE;
685         cbs->layout_cb = setting_reset_settings_layout_ug_cb;
686         cbs->result_cb = setting_reset_settings_result_password_ug_cb;
687         cbs->destroy_cb = setting_reset_settings_destroy_password_ug_cb;
688         cbs->priv = (void *)ad;
689
690         service_h svc;
691         if (service_create(&svc)) {
692                 FREE(cbs);
693                 return FALSE;
694         }
695
696         service_add_extra_data(svc, "viewtype", "SETTING_PW_TYPE_RESET");
697
698         ad->ug_loading =
699             ug_create(ad->ug, "setting-password-efl", UG_MODE_FULLVIEW, svc, cbs);
700         if (NULL == ad->ug_loading) {   /* error handling */
701         }
702
703         service_destroy(svc);
704         FREE(cbs);
705
706         return TRUE;
707 }
708 #endif
709 /* ***************************************************
710  *
711  *call back func
712  *
713  ***************************************************/
714
715 static void
716 setting_reset_settings_click_softkey_cancel_cb(void *data, Evas_Object *obj,
717                                            void *event_info)
718 {
719         SETTING_TRACE_BEGIN;
720         /* error check */
721         retm_if(data == NULL, "Data parameter is NULL");
722
723         SettingResetUG *ad = (SettingResetUG *) data;
724
725         setting_view_change(&setting_view_reset_settings, &setting_view_reset_main, ad);
726 }
727
728 static void
729 setting_reset_settings_click_softkey_reset_cb(void *data, Evas_Object *obj,
730                                           void *event_info)
731 {
732         SETTING_TRACE_BEGIN;
733         /* error check */
734         retm_if(data == NULL, "Data parameter is NULL");
735
736         SettingResetUG *ad = (SettingResetUG *) data;
737         //int screen_lock_type = 0;
738
739         //every time clicking 'Reset' button, restore following VCONFs
740         vconf_set_bool(VCONFKEY_SETAPPL_FONT_CHANGED, FALSE);
741
742         if (ad->list_data.selInfoPop) {
743                 evas_object_del(ad->list_data.selInfoPop);
744                 ad->list_data.selInfoPop = NULL;
745         }
746
747         if (!setting_done_list_is_some_item_selected(&(ad->list_data))) {
748                 setting_create_simple_popup(NULL, ad->win_get, NULL, "No item selected");
749         } else {
750 #if SUPPORT_SECURITY
751                 vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &screen_lock_type);
752                 if(screen_lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD
753                         || screen_lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD)
754                 {
755                         setting_reset_settings_create_password_sg(ad);
756                 }
757                 else
758                 {
759 #endif
760                         setting_reset_settings_check_state(&(ad->list_data));
761 #if SUPPORT_SECURITY
762                 }
763 #endif
764         }
765 }