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