apply FSL(Flora Software License)
[apps/core/preloaded/settings.git] / setting-reset / src / setting-reset-main.c
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *     http://www.tizenopensource.org/license
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16 #include <setting-reset-main.h>
17 #include <heynoti.h>
18 #include <setting-cfg.h>
19 #include <Ecore_X.h>
20 #include <utilX.h>
21
22 #define RESULT_FONT_SIZE 28             /* 18->28 */
23 #define ITEM_NAME_FONT_SIZE 35          /* 22->35 */
24
25 static int setting_reset_main_create(void *cb);
26 static int setting_reset_main_destroy(void *cb);
27 static int setting_reset_main_update(void *cb);
28 static int setting_reset_main_cleanup(void *cb);
29
30 setting_view setting_view_reset_main = {
31         .create = setting_reset_main_create,
32         .destroy = setting_reset_main_destroy,
33         .update = setting_reset_main_update,
34         .cleanup = setting_reset_main_cleanup,
35 };
36
37 static void setting_reset_main_click_softkey_reset_cb(void *data,
38                                                       Evas_Object *obj,
39                                                       void *event_info);
40 static void setting_reset_main_click_softkey_cancel_cb(void *data,
41                                                        Evas_Object *obj,
42                                                        void *event_info);
43
44 static gboolean setting_reset_main_create_password_sg(void *data);
45 static void setting_reset_check_state(Setting_Done_List_Data *list_data);
46 static void setting_reset_main_result_password_ug_cb(struct ui_gadget *ug,
47                                                      bundle *result,
48                                                      void *priv);
49
50 /* ***************************************************
51  *
52  *basic func
53  *
54  ***************************************************/
55  #if SUPPORT_DYNAMIC_THEME_CHANGING
56 static void setting_reset_vconf_change_cb(keynode_t *key, void *data)
57 {
58         SETTING_TRACE_BEGIN;
59         
60         ret_if(data == NULL);
61         SettingResetUG *ad = data;
62         char *vconf_name = vconf_keynode_get_name(key);
63         SETTING_TRACE("the value of [ %s ] just changed", vconf_name);
64         if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_WIDGET_THEME_STR)) {
65                 //elm_theme_all_set(vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR));
66                 elm_theme_set(NULL, vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR));
67                 elm_config_all_flush();
68                 
69                 int is_them_changed = FALSE;
70                 vconf_get_bool(VCONFKEY_SETAPPL_THEM_CHANGED, &is_them_changed);
71
72                 if (is_them_changed && ad->notify) {
73                         setting_reset_result_popup_update(ad);
74                         if (ad->pop_progress)
75                         {
76                                 evas_object_del(ad->pop_progress);
77                                 ad->pop_progress = NULL;
78                         }
79                         
80                         ad->pop_progress = setting_create_popup_with_progressbar(ad, ad->win_get,
81                                                  "list_prosess",
82                                                  NULL, NULL, NULL, 0);
83                         evas_object_show(ad->pop_progress);
84                 }
85                 return;
86         }
87 }
88 #endif
89
90 static char *__result_gl_text_get(void *data, Evas_Object *obj,
91                                    const char *part)
92 {
93         retv_if(!data, NULL);
94         Setting_GenGroupItem_Data *item_data =
95             (Setting_GenGroupItem_Data *) data;
96         
97         if (!safeStrCmp(part, "elm.text.1")) {  /* title */
98                 char label[HELP_MSG_BUFF_SIZE + 1] = { 0, };
99                 if (item_data->keyStr)
100                 {
101                         const char *key = setting_customize_text(_(item_data->keyStr), ITEM_NAME_FONT_SIZE, NULL, NULL);
102                         safeStrNCat(label, key,HELP_MSG_BUFF_SIZE);
103                         FREE(key);
104                 }
105                 if (item_data->sub_desc)
106                 {
107                         safeStrNCat(label, ": ",HELP_MSG_BUFF_SIZE);
108                         const char *sub_desc = setting_customize_text(_(item_data->sub_desc), RESULT_FONT_SIZE, NULL, NULL);
109                         safeStrNCat(label, sub_desc,HELP_MSG_BUFF_SIZE);
110                         FREE(sub_desc);
111                 }
112                 return (char *)g_strdup(label);
113         }
114         return NULL;
115 }
116
117 static void __processing_popup_response_cb(void *data, Evas_Object *obj,
118                                      void *event_info)
119 {
120         ret_if(!data);
121         SettingResetUG *ad = data;
122         setting_reset_special_process(ad);
123         if (ad->notify) {
124                 evas_object_del(ad->notify);
125                 ad->notify = NULL;
126         }
127
128         // key ungrab: after showing the result popup
129         Ecore_X_Display *disp = ecore_x_display_get();
130         Ecore_X_Window xwin = elm_win_xwindow_get((Evas_Object*)ug_get_window());
131         int ret = utilx_ungrab_key(disp, xwin, KEY_HOME);
132         if (ret) {
133                 SETTING_TRACE_ERROR("KEY_HOME ungrab error ret[%d]", ret);
134         }
135 }
136
137 bool __reset_all_idler(void *data)
138 {
139         SETTING_TRACE_BEGIN;
140         retv_if(!data, FALSE);
141         SettingResetUG *ad = data;
142
143         int i = 0;
144         int j = 0;
145         int idx = 0;
146         const char *result_str = RESET_SUCESS_STR;
147         char ug_file[PATH_MAX + 1];
148         char *path = NULL;
149         bundle *b = NULL;
150         int ret = -1;
151         char *ug_args;
152         char *item_name = NULL;
153
154         for (; i < setting_cfg_get_category_length(); i++) {
155                 SETTING_TRACE("group is:%s", _(setting_cfg_get_category_name(i)));
156
157                 // init state   
158                 result_str = RESET_SUCESS_STR;
159         
160                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
161                         SETTING_TRACE("i:%d\tj:%d", i, j);
162                         if (Cfg_Item_unResetable == 
163                             setting_cfg_get_resetable_flag_idx(i, j))
164                         {
165                                 // SETTING_TRACE("process %s:%s skipped",_(item_name), ug_args);
166                                 continue;
167                         }
168                         ug_args = setting_cfg_get_ug_args_idx(i, j);
169                         item_name = setting_cfg_get_keyname_idx(i, j);
170                         SETTING_TRACE(">>> process %s:%s",_(item_name), ug_args);
171                         
172                         idx++;
173                         if (NULL == ug_args) /*special process*/
174                         {
175                                 if (!safeStrCmp(KeyStr_DataRoaming, item_name)) {
176                                         ret = setting_reset_data_roaming();
177                                 } else if (!safeStrCmp(KeyStr_Landscape, item_name)) {
178                                         ret = setting_reset_rotation_lock();
179                                 } 
180                                 //..
181                                 if (0 > ret)
182                                 {
183                                         result_str = RESET_FAILED_STR;
184                                 } 
185                         } 
186                         else
187                         {
188                                 path = get_ug_path_from_ug_args((void *)ug_args);
189                                 b = get_bundle_from_ug_args((void *)ug_args);
190                                 
191                                 if (snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH, path) < 0) {
192                                         ad->reset_all_idler = NULL;
193                                         return FALSE;
194                                 }
195                                         
196                                 ret = setting_invoke_reset_function(ug_file, b, NULL);
197                                 //SETTING_TRACE("load %s[plugin_ret:%d]", ug_file, ret);
198                                 
199                                 if (OPERATE_LIB_SUCESS > ret)
200                                 {
201                                         result_str = RESET_FAILED_STR;
202                                         
203                                 } 
204                                 
205                                 if (b){
206                                         bundle_free(b);
207                                         b = NULL;
208                                 }
209                                 FREE(path);
210                                 memset(ug_file, 0, PATH_MAX);
211                         }
212                         SETTING_TRACE("process %s:%s %s",_(item_name), ug_args, _(result_str));
213                 }
214         }
215
216         SETTING_TRACE_DEBUG("Reset totally %d items. result_str:%s", idx, result_str);
217         elm_object_text_set(ad->notify, _(result_str));
218         elm_popup_timeout_set(ad->notify, 2);
219         ad->reset_all_idler = NULL;
220         return FALSE;
221 }
222
223 static void __reset_all_button_cb(void *data, Evas_Object *obj, void *event_info)
224 {
225         SETTING_TRACE_BEGIN;
226         ret_if(!data);
227         Setting_GenGroupItem_Data *item_Data = data;
228         ret_if(!item_Data->userdata);
229         SettingResetUG *ad = item_Data->userdata;
230         
231
232         char pw_pass[SETTING_STR_SLP_LEN] = { 0, };
233         int err = 0;
234         
235         /*  Check Password Setting status */
236         int ret =
237             setting_get_string_slp_key(STR_SLP_LIST_PHONE_PASSWORD,
238                                        pw_pass, &err);
239         SETTING_TRACE("pw_pass:%s", pw_pass);
240         if (SETTING_RETURN_SUCCESS == ret && '\0' != pw_pass[0]) {
241                 setting_reset_main_create_password_sg(ad);
242                 return;
243         } 
244
245         // key grab: before showing processing popup
246         Ecore_X_Display *disp = ecore_x_display_get();
247         Ecore_X_Window xwin = elm_win_xwindow_get((Evas_Object*)ug_get_window());
248         ret = utilx_grab_key(disp, xwin, KEY_HOME, TOP_POSITION_GRAB);
249         if (ret) {
250                 SETTING_TRACE_ERROR("KEY_HOME grab error ret[%d]", ret);
251         }
252
253         ad->notify =
254             setting_create_popup_without_btn(ad, ad->win_get, _("IDS_COM_POP_PROCESSING"), NULL, __processing_popup_response_cb, 0);
255         if (ad->reset_all_idler) {
256                 ecore_idler_del(ad->reset_all_idler);
257                 ad->reset_all_idler = NULL;
258         }
259         ad->reset_all_idler =
260             ecore_idler_add((Ecore_Task_Cb) __reset_all_idler, ad);
261 }
262
263 static int setting_reset_main_create(void *cb)
264 {
265         SETTING_TRACE_BEGIN;
266         /* error check */
267         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
268
269         SettingResetUG *ad = (SettingResetUG *) cb;
270         Evas_Object *scroller = NULL;
271 #if SIMPLY_SUPPORT_ALL_RESET    
272         ad->ly_main =
273             setting_create_layout_navi_bar_genlist(ad->win_main_layout,
274                                                    ad->win_get,
275                                                    _("IDS_COM_BODY_RESET"),
276                                                    _("IDS_COM_BODY_BACK"), NULL,
277                                                    setting_reset_main_click_softkey_cancel_cb,
278                                                    NULL, ad, &scroller,
279                                                    &(ad->navi_bar));
280         /* Description */
281         setting_create_Gendial_field_def(scroller, &(ad->itc_1text), NULL,
282                                          ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
283                                          NULL, NULL, 0, RESET_ALL_DESC,
284                                          NULL, NULL);
285         /* Button */
286         Setting_GenGroupItem_Data *item_data =
287             (Setting_GenGroupItem_Data *) calloc(1,
288                                                  sizeof
289                                                  (Setting_GenGroupItem_Data));
290         setting_retvm_if(!item_data, SETTING_RETURN_FAIL, "calloc failed");
291         item_data->userdata = ad;
292         item_data->keyStr = (char *)g_strdup(RESET_ALL);
293         item_data->swallow_type = SWALLOW_Type_1BUTTON;
294
295         if (Theme_Tizen_Black == setting_get_theme())
296                 item_data->r_swallow_path = (char *)g_strdup("sweep");//pass button style
297
298         item_data->chk_change_cb = __reset_all_button_cb;
299         item_data->item = elm_genlist_item_append(scroller, &(ad->itc_1icon), item_data, NULL,
300                                                     ELM_GENLIST_ITEM_NONE,
301                                                     NULL, NULL);
302         setting_view_reset_main.is_create = 1;
303         ad->main_scroller = scroller;
304         return SETTING_RETURN_SUCCESS;
305 #endif
306
307
308         Evas_Object *navi_bar = NULL;
309
310         Evas_Object *controllbar = NULL;
311
312         Evas_Object *view_layout = elm_layout_add(ad->win_main_layout);
313         elm_layout_file_set(view_layout, SETTING_THEME_EDJ_NAME,
314                             "selinfo_bottom");
315         evas_object_size_hint_weight_set(view_layout, EVAS_HINT_EXPAND, 0.0);
316
317         ad->ly_main =
318             setting_create_layout_navi_bar(ad->win_main_layout, ad->win_get,
319                                            S_("IDS_COM_BODY_RESET"),
320                                            _("IDS_COM_SK_CANCEL"),
321                                            _("IDS_COM_BODY_RESET"), NULL,
322                                            setting_reset_main_click_softkey_cancel_cb,
323                                            setting_reset_main_click_softkey_reset_cb,
324                                            NULL, ad, view_layout, &navi_bar,
325                                            &controllbar);
326         elm_object_item_disabled_set(elm_toolbar_last_item_get
327                                          (controllbar), EINA_TRUE);
328
329         /* ******************************************create frame */
330         Setting_Done_List_Data *list_data = &(ad->list_data);   /* define a handle */
331         int idx = 0;
332         list_data->win_main = ad->ly_main;
333         list_data->UG_data = ad;
334         list_data->ly_parent = view_layout;
335         list_data->controllbar = controllbar;
336
337
338         list_data->chk_items[idx++].item_name = KeyStr_Select_All;
339         char *ug_args;
340         char *item_name;
341
342         int i = 0;
343         int j = 0;
344         
345         for (; i < setting_cfg_get_category_length(); i++) {
346                 SETTING_TRACE("group is:%s", _(setting_cfg_get_category_name(i)));
347                 
348                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
349                         if (Cfg_Item_unResetable == 
350                             setting_cfg_get_resetable_flag_idx(i, j))
351                         {
352                             continue;
353                         }
354                         list_data->chk_items[idx].ug_args = ug_args = 
355                                         setting_cfg_get_ug_args_idx(i, j);
356                         list_data->chk_items[idx].item_name = item_name = 
357                                         setting_cfg_get_keyname_idx(i, j);
358                         
359                         SETTING_TRACE("process %s:\t%s",_(item_name), ug_args);
360                         idx++;
361                 }
362         }
363
364         list_data->cur_item_num = idx;
365         SETTING_TRACE("list_data->cur_item_num:%d", list_data->cur_item_num);
366         scroller = setting_create_done_list(list_data);
367         elm_object_part_content_set(view_layout, "elm.swallow.contents", scroller);
368
369         ad->view_layout = view_layout;
370         ad->navi_bar = navi_bar;
371         ad->controllbar = controllbar;
372         /* *******************************************update info */
373
374         setting_view_reset_main.is_create = 1;
375         ad->itc_1text.func.text_get = __result_gl_text_get;
376         #if SUPPORT_DYNAMIC_THEME_CHANGING
377         (void) vconf_notify_key_changed(VCONFKEY_SETAPPL_WIDGET_THEME_STR,
378                                         setting_reset_vconf_change_cb, ad);
379         #endif
380         return SETTING_RETURN_SUCCESS;
381 }
382
383 static int setting_reset_main_destroy(void *cb)
384 {
385         SETTING_TRACE_BEGIN;
386         /* error check */
387         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
388
389         SettingResetUG *ad = (SettingResetUG *) cb;
390         #if SUPPORT_DYNAMIC_THEME_CHANGING
391         (void)vconf_ignore_key_changed(VCONFKEY_SETAPPL_WIDGET_THEME_STR,
392                                         setting_reset_vconf_change_cb);
393         #endif
394         if (ad->notify) {
395                 evas_object_del(ad->notify);
396                 ad->notify = NULL;
397         }
398         if (ad->old_notify) {
399                 evas_object_del(ad->old_notify);
400                 ad->old_notify = NULL;
401         }
402         if (ad->pop_progress)
403         {
404                 evas_object_del(ad->pop_progress);
405                 ad->pop_progress = NULL;
406         }
407         
408         if (ad->ask_popup)
409         {
410                 evas_object_del(ad->ask_popup);
411                 ad->ask_popup = NULL;
412         }       
413         if (ad->animator)
414         {
415                 ecore_animator_del(ad->animator);
416                 ad->animator = NULL;
417         }
418
419         if (ad->ly_main != NULL) {
420                 evas_object_del(ad->ly_main);
421                 setting_view_reset_main.is_create = 0;
422         }
423
424         return SETTING_RETURN_SUCCESS;
425 }
426
427 static int setting_reset_main_update(void *cb)
428 {
429         SETTING_TRACE_BEGIN;
430         /* error check */
431         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
432
433         SettingResetUG *ad = (SettingResetUG *) cb;
434
435         if (ad->ly_main != NULL) {
436                 evas_object_show(ad->ly_main);
437         }
438
439         return SETTING_RETURN_SUCCESS;
440 }
441
442 static int setting_reset_main_cleanup(void *cb)
443 {
444         SETTING_TRACE_BEGIN;
445         /* error check */
446         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
447
448         SettingResetUG *ad = (SettingResetUG *) cb;
449
450         if (ad->ly_main != NULL) {
451                 evas_object_hide(ad->ly_main);
452         }
453
454         return SETTING_RETURN_SUCCESS;
455 }
456
457 /* ***************************************************
458  *
459  *general func
460  *
461  ***************************************************/
462
463 static void __reset_an_item(Setting_Done_List_Data *list_data,
464                                 const char *item_name, 
465                                 const char *ug_args)
466 {
467         SettingResetUG *ad = (SettingResetUG *) list_data->UG_data;
468         Evas_Object *genlist = elm_object_content_get(ad->notify);
469         Setting_GenGroupItem_Data *item_data = NULL;
470         const char *result_str = RESET_SUCESS_STR;
471         if (NULL == ug_args) /*special process*/
472         {
473                 int ret = -1;
474                 if (!safeStrCmp(KeyStr_DataRoaming, item_name)) {
475                         ret = setting_reset_data_roaming();
476                 } else if (!safeStrCmp(KeyStr_Landscape, item_name)) {
477                         ret = setting_reset_rotation_lock();
478                 } 
479                 //..
480                 if (0 > ret)
481                 {
482                         result_str = VCONF_RESET_FAILED_STR;
483                 } 
484                 
485                 item_data = setting_create_Gendial_field_def(genlist, &(ad->itc_1text),
486                                                  NULL, ad,
487                                                  SWALLOW_Type_LAYOUT_SPECIALIZTION,
488                                                  NULL, NULL, 0, 
489                                                  (char *)item_name, 
490                                                  (char *)result_str, NULL);
491
492         } else
493         {
494                 char *path = get_ug_path_from_ug_args((void *)ug_args);
495                 bundle *b = get_bundle_from_ug_args((void *)ug_args);
496                 char ug_file[PATH_MAX];
497                 if (snprintf(ug_file, PATH_MAX, 
498                         "%s/libug-%s.so", SETTING_UG_PATH, path) < 0) return;
499                         
500                 int plugin_ret = setting_invoke_reset_function(ug_file, b, NULL);
501                 SETTING_TRACE("load %s[plugin_ret:%d]", ug_file, plugin_ret);
502                 
503                 if (LOAD_LIB_FAILED == plugin_ret) // -1
504                 {
505                         result_str = LOAD_LIB_FAILED_STR;
506                         
507                 } else if (UNDEFINED_LIB_SYMBOL == plugin_ret) // -2
508                 {
509                         result_str = UNDEFINE_STR;
510                 } else if (OPERATE_LIB_SUCESS <= plugin_ret){ // 0
511                         result_str = RESET_SUCESS_STR;
512
513                 } else {
514                         result_str = RESET_FAILED_STR;
515                 }
516                 
517                 if (b){
518                         bundle_free(b);
519                         b = NULL;
520                 }
521                 if (path){
522                         FREE(path);
523                         path = NULL;
524                 }
525                 
526                 item_data = setting_create_Gendial_field_def(genlist, &(ad->itc_1text),
527                                                  NULL, ad,
528                                                  SWALLOW_Type_LAYOUT_SPECIALIZTION,
529                                                  NULL, NULL, 0, 
530                                                  (char *)item_name, 
531                                                  (char *)result_str, NULL);
532         }
533
534         if (item_data)
535                 elm_genlist_item_show(item_data->item, ELM_GENLIST_ITEM_SCROLLTO_IN);//show the last item
536         else
537                 SETTING_TRACE_ERROR("error : item_data is NULL");
538 }
539
540 static Eina_Bool __reset_animator_cb(void *data)
541 {
542         SettingResetUG *ad = (SettingResetUG *) data;
543
544         SETTING_TRACE("Processing the %dth of %d", 
545                       ad->gl_index, ad->list_data.cur_item_num);
546         if (ad->gl_index >=  ad->list_data.cur_item_num) {
547                 ecore_animator_del(ad->animator);
548                 ad->animator = NULL;
549                 if (ad->pop_progress) {
550                         evas_object_del(ad->pop_progress);
551                         ad->pop_progress = NULL;
552                 }
553
554                 return ECORE_CALLBACK_CANCEL;
555         }
556         if (ad->list_data.chk_items[ad->gl_index].data_GenItem->chk_status) {
557                 __reset_an_item(&(ad->list_data),
558                                 ad->list_data.chk_items[ad->gl_index].item_name,
559                                 ad->list_data.chk_items[ad->gl_index].ug_args);
560
561                 /*unselect item*/
562                 elm_check_state_set(ad->list_data.chk_items[ad->gl_index].data_GenItem->eo_check, 0);
563                 ad->list_data.chk_items[ad->gl_index].data_GenItem->chk_status = 0;
564         }
565
566         ad->gl_index++;
567         return ECORE_CALLBACK_RENEW;
568 }
569
570
571 static void setting_reset_check_state(Setting_Done_List_Data *list_data)
572 {
573         /* reset */
574         SETTING_TRACE_DEBUG("********resetting*******");
575
576         SettingResetUG *ad = (SettingResetUG *) list_data->UG_data;
577         
578         //some item must have been selected, or else cannot go into setting_reset_check_state()
579         ad->notify = elm_popup_add(ad->win_get);
580         elm_object_style_set(ad->notify,"menustyle");
581         elm_object_part_text_set(ad->notify, "title,text", RESET_RESULT_STR);
582         evas_object_size_hint_weight_set(ad->notify, 
583                                 EVAS_HINT_EXPAND, 
584                                 EVAS_HINT_EXPAND);
585
586         Evas_Object *btn = setting_create_button(ad->notify, _("IDS_COM_SK_OK"), NULL, setting_reset_result_popup_resp_cb, ad);
587         elm_object_part_content_set(ad->notify, "button1", btn);        
588
589         
590         Evas_Object *genlist = elm_genlist_add(ad->notify);
591         evas_object_size_hint_weight_set(genlist, 
592                                 EVAS_HINT_EXPAND,
593                                 EVAS_HINT_EXPAND);
594         evas_object_size_hint_align_set(genlist, 
595                                 EVAS_HINT_FILL, 
596                                 EVAS_HINT_FILL);
597         
598         elm_object_content_set(ad->notify, genlist);
599
600         evas_object_show(ad->notify);
601         ad->pop_progress = setting_create_popup_with_progressbar(ad, ad->win_get,
602                                  "list_prosess",
603                                  NULL, NULL, NULL, 0);
604
605         ad->gl_index = 0;
606         ad->animator = ecore_animator_add(__reset_animator_cb, ad);
607
608         /* reset sel_all item */
609         elm_check_state_set(list_data->chk_items[0].data_GenItem->eo_check, 0);
610         list_data->chk_items[0].data_GenItem->chk_status = 0;
611
612 }
613
614
615 static void
616 setting_reset_main_result_password_ug_cb(struct ui_gadget *ug, bundle *result,
617                                          void *priv)
618 {
619         SETTING_TRACE_BEGIN;
620         /* error check */
621         retm_if(priv == NULL, "Data parameter is NULL");
622
623         SettingResetUG *ad = (SettingResetUG *) priv;
624
625         const char *ret_str = bundle_get_val(result, "result");
626         SETTING_TRACE("result:%s", ret_str);
627
628         retm_if(ret_str == NULL, "result paremeter is NULL");
629
630         if (ret_str) {
631                 if (0 == safeStrCmp("SETTING_PW_TYPE_RESET", ret_str)) {
632                         /*  Reset */
633                         #if SIMPLY_SUPPORT_ALL_RESET
634                         ad->notify =
635                             setting_create_popup_without_btn(ad, ad->win_get, _("IDS_COM_POP_PROCESSING"), NULL, __processing_popup_response_cb, 0);
636                         if (ad->reset_all_idler) {
637                                 ecore_idler_del(ad->reset_all_idler);
638                                 ad->reset_all_idler = NULL;
639                         }
640                         ad->reset_all_idler =
641                             ecore_idler_add((Ecore_Task_Cb) __reset_all_idler, ad);
642                         #else
643                         setting_reset_check_state(&(ad->list_data));
644                         #endif
645                 }
646         }
647 }
648
649 static void
650 setting_reset_main_layout_ug_cb(struct ui_gadget *ug, enum ug_mode mode,
651                                 void *priv)
652 {
653         SettingResetUG *ad = (SettingResetUG *) priv;
654         Evas_Object *base;
655
656         if (!ug || !priv)
657                 return;
658         SETTING_TRACE_BEGIN;
659
660         base = (Evas_Object *) ug_get_layout(ug);
661         if (!base)
662                 return;
663
664         switch (mode) {
665         case UG_MODE_FULLVIEW:
666                 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
667                                                  EVAS_HINT_EXPAND);
668                 elm_win_resize_object_add(ad->win_get, base);
669                 evas_object_show(base);
670                 break;
671         default:
672                 break;
673         }
674
675         /*  TODO  animation effect here */
676         SETTING_TRACE_END;
677 }
678
679 static void setting_reset_main_destroy_password_ug_cb(struct ui_gadget *ug,
680                                                       void *priv)
681 {
682         SETTING_TRACE_BEGIN;
683
684         ret_if(!priv);
685         SettingResetUG *ad = (SettingResetUG *) priv;
686         if (ug) {
687                 ug_destroy(ug);
688                 ad->ug_loading = NULL;
689         }
690
691 }
692
693 static gboolean setting_reset_main_create_password_sg(void *data)
694 {
695         SETTING_TRACE_BEGIN;
696         /* error check */
697         retv_if(data == NULL, FALSE);
698
699         SettingResetUG *ad = (SettingResetUG *) data;
700
701         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
702         if (!cbs)
703                 return FALSE;
704         cbs->layout_cb = setting_reset_main_layout_ug_cb;
705         cbs->result_cb = setting_reset_main_result_password_ug_cb;
706         cbs->destroy_cb = setting_reset_main_destroy_password_ug_cb;
707         cbs->priv = (void *)ad;
708         bundle *b = bundle_create();
709         if (!b) {
710                 FREE(cbs);
711                 return FALSE;
712         }
713         bundle_add(b, "viewtype", "SETTING_PW_TYPE_RESET");
714
715         ad->ug_loading =
716             ug_create(ad->ug, "setting-password-efl", UG_MODE_FULLVIEW, b, cbs);
717         if (NULL == ad->ug_loading) {   /* error handling */
718         }
719
720         bundle_free(b);
721         FREE(cbs);
722
723         return TRUE;
724 }
725
726 /* ***************************************************
727  *
728  *call back func
729  *
730  ***************************************************/
731
732 static void
733 setting_reset_main_click_softkey_cancel_cb(void *data, Evas_Object *obj,
734                                            void *event_info)
735 {
736         SETTING_TRACE_BEGIN;
737         /* error check */
738         retm_if(data == NULL, "Data parameter is NULL");
739
740         SettingResetUG *ad = (SettingResetUG *) data;
741         if (ad->list_data.selInfoPop) {
742                 evas_object_del(ad->list_data.selInfoPop);
743                 ad->list_data.selInfoPop = NULL;
744         }
745         /* Send destroy request */
746         ug_destroy_me(ad->ug);
747 }
748
749 static void
750 setting_reset_main_click_softkey_reset_cb(void *data, Evas_Object *obj,
751                                           void *event_info)
752 {
753         SETTING_TRACE_BEGIN;
754         /* error check */
755         retm_if(data == NULL, "Data parameter is NULL");
756
757         SettingResetUG *ad = (SettingResetUG *) data;
758
759         //every time clicking 'Reset' button, restore following VCONFs  
760         vconf_set_bool(VCONFKEY_SETAPPL_FONT_CHANGED, FALSE);
761         vconf_set_bool(VCONFKEY_SETAPPL_THEM_CHANGED, FALSE);
762
763         if (ad->list_data.selInfoPop) {
764                 evas_object_del(ad->list_data.selInfoPop);
765                 ad->list_data.selInfoPop = NULL;
766         }
767
768         if (!setting_done_list_is_some_item_selected(&(ad->list_data))) {
769                 setting_create_popup_without_title(NULL, ad->win_get,
770                                                   "No item selected");
771         } else {
772                 char pw_pass[SETTING_STR_SLP_LEN] = { 0, };
773                 int err = 0;
774
775                 /*  Check Password Setting status */
776                 int ret =
777                     setting_get_string_slp_key(STR_SLP_LIST_PHONE_PASSWORD,
778                                                pw_pass, &err);
779                 SETTING_TRACE("pw_pass:%s", pw_pass);
780                 if (SETTING_RETURN_SUCCESS == ret && '\0' != pw_pass[0]) {
781                         setting_reset_main_create_password_sg(ad);
782                 } else {
783                         setting_reset_check_state(&(ad->list_data));
784                 }
785
786         }
787 }