tizen 2.3.1 release
[apps/home/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 <Ecore_X.h>
24 #include <utilX.h>
25 #include <efl_assist.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, Evas_Object *obj,
46                                                            void *event_info);
47 static Eina_Bool setting_reset_setting_item_popup_cb(void *data, Elm_Object_Item *it);
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                                                          app_control_h result,
53                                                          void *priv);
54 static int setting_done_list_item_selected_num(Setting_Done_List_Data *list_data);
55
56
57 /* ***************************************************
58  *
59  *basic func
60  *
61  ***************************************************/
62 static char *__result_gl_text_get(void *data, Evas_Object *obj,
63                                   const char *part)
64 {
65         retv_if(!data, NULL);
66         Setting_GenGroupItem_Data *item_data =
67             (Setting_GenGroupItem_Data *) data;
68         /*SETTING_TRACE("part:%s", part); */
69
70         if (!safeStrCmp(part, "elm.text") || !safeStrCmp(part, "elm.text.1")) { /* title */
71                 char label[HELP_MSG_BUFF_SIZE + 1] = { 0, };
72                 if (item_data->keyStr) {
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                         char desc[SETTING_STR_SLP_LEN + 1] = { 0, };
79                         snprintf(desc, SETTING_STR_SLP_LEN, ": %s", _(item_data->sub_desc));
80                         const char *sub_desc = setting_customize_text(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 bool __reset_all_idler(void *data)
110 {
111         SETTING_TRACE_BEGIN;
112         retv_if(!data, FALSE);
113         SettingResetUG *ad = data;
114
115         int i = 0;
116         int j = 0;
117         int idx = 0;
118         const char *result_str = RESET_SUCESS_STR;
119         char ug_file[PATH_MAX + 1];
120         char *path = NULL;
121         app_control_h svc;
122         int ret = -1;
123         char *ug_args;
124         char *item_name;
125
126         for (; i < setting_cfg_get_category_length(); i++) {
127                 /*SETTING_TRACE("group is:%s", _(setting_cfg_get_category_name(i))); */
128
129                 result_str = RESET_SUCESS_STR;
130                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
131                         /*SETTING_TRACE("i:%d\tj:%d", i, j);*/
132                         if (Cfg_Item_unResetable ==
133                             setting_cfg_get_resetable_flag_idx(i, j)) {
134                                 /*SETTING_TRACE("process %s:%s skipped",_(item_name), ug_args); */
135                                 continue;
136                         }
137                         ug_args = setting_cfg_get_ug_args_idx(i, j);
138                         item_name = setting_cfg_get_keyname_idx(i, j);
139                         if (item_name)
140                                 SETTING_TRACE(">>> process %s:%s", _(item_name), ug_args);
141
142                         idx++;
143                         if (NULL == ug_args) { /*special process*/
144                                 ret = -1;
145                                 if (!safeStrCmp(KeyStr_FlightMode, item_name)) {
146                                         /*Invoke aync API and ignore the response message */
147                                         ret = setting_reset_flight_mode();
148                                 } else if (!safeStrCmp(KeyStr_Landscape, item_name)) {
149                                         ret = setting_reset_rotation_lock();
150                                 }
151                                 /*.. */
152                                 if (0 > ret) {
153                                         result_str = RESET_FAILED_STR;
154                                 }
155
156
157                         } else {
158                                 path = get_ug_path_from_ug_args((void *)ug_args);
159                                 svc = get_bundle_from_ug_args((void *)ug_args);
160
161                                 /*if (snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH, path) < 0) */
162                                 /*      return FALSE; */
163
164                                 ret = setting_invoke_reset_function(path, svc, NULL);
165                                 /*SETTING_TRACE("load %s[plugin_ret:%d]", ug_file, ret); */
166
167                                 if (OPERATE_LIB_SUCESS > ret) {
168                                         result_str = RESET_FAILED_STR;
169
170                                 }
171
172                                 app_control_destroy(svc);
173                                 FREE(path);
174                                 memset(ug_file, 0, PATH_MAX);
175                         }
176                         SETTING_TRACE("process %s:%s %s", _(item_name), ug_args, _(result_str));
177                 }
178         }
179
180         /*list_data->cur_item_num = idx; */
181         SETTING_TRACE_DEBUG("Reset totally %d items. result_str:%s", idx, result_str);
182         /*setting_create_popup_with_notitle(NULL, ad->win_get, _(result_str)); */
183         elm_popup_desc_set(ad->notify, _(result_str));
184         elm_popup_mode_set(ad->notify, POPUP_INTERVAL);
185         elm_popup_timeout_set(ad->notify, 2);
186
187         if (ad->reset_all_idler) {
188                 ecore_idler_del(ad->reset_all_idler);
189                 ad->reset_all_idler = NULL;
190         }
191         return FALSE;
192 }
193
194 void __reset_all_button_cb(void *data, Evas_Object *obj, void *event_info)
195 {
196         SETTING_TRACE_BEGIN;
197         ret_if(!data);
198         Setting_GenGroupItem_Data *item_Data = data;
199         ret_if(!item_Data->userdata);
200         SettingResetUG *ad = item_Data->userdata;
201
202
203         char pw_pass[SETTING_STR_SLP_LEN] = { 0, };
204         int err = 0;
205
206         /*  Check Password Setting status */
207         int ret =
208             setting_get_string_slp_key(STR_SLP_LIST_PHONE_PASSWORD,
209                                        pw_pass, &err);
210         SETTING_TRACE("pw_pass:%s", pw_pass);
211         if (SETTING_RETURN_SUCCESS == ret && '\0' != pw_pass[0]) {
212                 setting_reset_settings_create_password_sg(ad);
213                 return;
214         }
215
216         /* key grab: before showing processing popup */
217         Ecore_X_Display *disp = ecore_x_display_get();
218         Ecore_X_Window xwin = elm_win_xwindow_get((Evas_Object *)ug_get_window());
219         ret = utilx_grab_key(disp, xwin, KEY_HOME, TOP_POSITION_GRAB);
220         if (ret) {
221                 SETTING_TRACE_ERROR("KEY_HOME grab error ret[%d]", ret);
222         }
223
224         ad->notify =
225             setting_create_popup_without_btn(ad, ad->win_get, NULL, _("IDS_COM_POP_PROCESSING"), __processing_popup_response_cb, 0, 1, 1);
226         if (ad->reset_all_idler) {
227                 ecore_idler_del(ad->reset_all_idler);
228                 ad->reset_all_idler = NULL;
229         }
230
231         ad->reset_all_idler =
232             ecore_idler_add((Ecore_Task_Cb) __reset_all_idler, ad);
233 }
234 #endif
235 static int setting_reset_settings_create(void *cb)
236 {
237         SETTING_TRACE_BEGIN;
238         /* error check */
239         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
240
241         SettingResetUG *ad = (SettingResetUG *) cb;
242         Evas_Object *scroller = NULL;
243
244         Evas_Object *view_layout = elm_layout_add(ad->win_main_layout);
245         elm_layout_file_set(view_layout, SETTING_THEME_EDJ_NAME,
246                             "selinfo_bottom");
247         evas_object_size_hint_weight_set(view_layout, EVAS_HINT_EXPAND, 0.0);
248
249         /*  Evas_Object * win_layout, Evas_Object * win_obj */
250         Elm_Object_Item *navi_it = setting_push_layout_navi_bar(_(RESET_SETTINGS_STR),
251                                                                 NULL,
252                                                                 _("IDS_COM_BODY_RESET"), _("IDS_COM_SK_CANCEL"),
253                                                                 NULL,
254                                                                 setting_reset_settings_click_softkey_reset_cb,
255                                                                 setting_reset_settings_click_softkey_cancel_cb, ad, view_layout, ad->navi_bar,
256                                                                 NULL);
257         elm_naviframe_item_pop_cb_set(navi_it, setting_reset_setting_item_popup_cb, ad);
258
259         /* ******************************************create frame */
260         Setting_Done_List_Data *list_data = &(ad->list_data);   /* define a handle */
261         int idx = 0;
262         list_data->win_main = ad->win_main_layout;
263         list_data->UG_data = ad;
264         list_data->ly_parent = view_layout;
265         list_data->select_all_checked = EINA_FALSE;
266         list_data->navi_it = navi_it;
267
268         char *ug_args;
269
270         int i = 0;
271         int j = 0;
272
273         for (; i < setting_cfg_get_category_length(); i++) {
274                 /*SETTING_TRACE("group is:%s", _(setting_cfg_get_category_name(i))); */
275
276                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
277                         if (Cfg_Item_unResetable ==
278                             setting_cfg_get_resetable_flag_idx(i, j)) {
279                                 continue;
280                         }
281                         ug_args = setting_cfg_get_ug_args_idx(i, j);
282                         if (!is_ug_installed_by_ug_args(ug_args)) {
283                                 continue;
284                         }
285
286                         list_data->chk_items[idx].ug_args = ug_args;
287                         list_data->chk_items[idx].item_name = setting_cfg_get_keyname_idx(i, j);
288
289                         /*SETTING_TRACE("process %s:\t%s",_(item_name), ug_args); */
290                         idx++;
291                 }
292         }
293
294         list_data->cur_item_num = idx;
295         SETTING_TRACE("list_data->cur_item_num:%d", list_data->cur_item_num);
296         scroller = setting_create_done_list(list_data, NULL);
297         elm_object_part_content_set(view_layout, "elm.swallow.contents", scroller);
298
299         if (idx == 0 || !setting_done_list_is_some_item_selected(list_data)) {
300                 Evas_Object *toolbar = elm_object_item_part_content_get(navi_it, "toolbar");
301                 elm_object_item_disabled_set(elm_toolbar_last_item_get(toolbar), EINA_TRUE);
302         }
303
304         ad->view_layout = view_layout;
305         ad->reset_list = elm_object_part_content_get(scroller, "bg_swallow");
306         /* *******************************************update info */
307
308         setting_view_reset_settings.is_create = 1;
309         ad->itc_1text.func.text_get = __result_gl_text_get;
310         return SETTING_RETURN_SUCCESS;
311 }
312
313 static int setting_reset_settings_destroy(void *cb)
314 {
315         SETTING_TRACE_BEGIN;
316         /* error check */
317         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
318
319         SettingResetUG *ad = (SettingResetUG *) cb;
320
321         if (ad->list_data.selInfoPop) {
322                 evas_object_del(ad->list_data.selInfoPop);
323                 ad->list_data.selInfoPop = NULL;
324         }
325         if (ad->notify) {
326                 evas_object_del(ad->notify);
327                 ad->notify = NULL;
328         }
329         if (ad->old_notify) {
330                 evas_object_del(ad->old_notify);
331                 ad->old_notify = NULL;
332         }
333         if (ad->pop) {
334                 evas_object_del(ad->pop);
335                 ad->pop = NULL;
336         }
337         if (ad->reset_process) {
338                 evas_object_del(ad->reset_process);
339         }
340         if (ad->pop_progress) {
341                 evas_object_del(ad->pop_progress);
342                 ad->pop_progress = NULL;
343         }
344         if (ad->ask_popup) {
345                 evas_object_del(ad->ask_popup);
346                 ad->ask_popup = NULL;
347         }
348         if (ad->animator) {
349                 ecore_animator_del(ad->animator);
350                 ad->animator = NULL;
351         }
352         if (ad->reset_all_idler) {
353                 ecore_idler_del(ad->reset_all_idler);
354                 ad->reset_all_idler = NULL;
355         }
356
357         elm_naviframe_item_pop(ad->navi_bar);
358         setting_view_reset_settings.is_create = 0;
359         SETTING_TRACE_END;
360         return SETTING_RETURN_SUCCESS;
361 }
362
363 static int setting_reset_settings_update(void *cb)
364 {
365         SETTING_TRACE_BEGIN;
366
367         return SETTING_RETURN_SUCCESS;
368 }
369
370 static int setting_reset_settings_cleanup(void *cb)
371 {
372         SETTING_TRACE_BEGIN;
373         /* error check */
374         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
375
376         /*SettingResetUG *ad = (SettingResetUG *) cb; */
377
378         setting_reset_settings_destroy(cb);
379
380         return SETTING_RETURN_SUCCESS;
381 }
382
383 /* ***************************************************
384  *
385  *general func
386  *
387  ***************************************************/
388 bool __delay_reset_location(void *data)
389 {
390         SETTING_TRACE_BEGIN;
391         retv_if(!data, FALSE);
392         Setting_GenGroupItem_Data *item_data = data;
393         int plugin_ret = setting_invoke_reset_function("setting-location-efl", NULL, NULL);
394         SETTING_TRACE("load libug-%s.so[plugin_ret:%d]", "setting-location-efl", plugin_ret);
395         const char *result_str = NULL;
396         if (LOAD_LIB_FAILED == plugin_ret) {/* -1 */
397                 result_str = LOAD_LIB_FAILED_STR;
398         } else if (UNDEFINED_LIB_SYMBOL == plugin_ret) { /* -2 */
399                 result_str = UNDEFINE_STR;
400         } else if (OPERATE_LIB_SUCESS > plugin_ret) { /* 0 */
401                 result_str = RESET_FAILED_STR;
402
403         } else {
404                 return FALSE;
405         }
406
407         item_data->sub_desc = (char *) g_strdup(_(result_str));
408         elm_object_item_data_set(item_data->item, item_data);
409         elm_genlist_item_update(item_data->item);
410         return FALSE;
411 }
412
413 static void __reset_an_item(Setting_Done_List_Data *list_data,
414                             const char *item_name,
415                             const char *ug_args)
416 {
417         SettingResetUG *ad = (SettingResetUG *) list_data->UG_data;
418         if (ad == NULL)
419                 return;
420
421         /*Evas_Object *genlist = elm_object_content_get(ad->notify); */
422         Setting_GenGroupItem_Data *item_data = NULL;
423
424         if (NULL == ug_args) { /*special process*/
425                 int ret = -1;
426                 if (!safeStrCmp(KeyStr_FlightMode, item_name)) {
427                         /*Invoke aync API and ignore the response message */
428                         ret = setting_reset_flight_mode();
429                 } else if (!safeStrCmp(KeyStr_Landscape, item_name)) {
430                         ret = setting_reset_rotation_lock();
431                 }
432         } else {
433                 char *path = get_ug_path_from_ug_args((void *)ug_args);
434                 app_control_h svc = get_bundle_from_ug_args((void *)ug_args);
435                 int plugin_ret = OPERATE_LIB_SUCESS;
436                 if (!isEmulBin() || 0 != safeStrCmp(KeyStr_Location, item_name)) { /*KeyStr_Location is too slow to display in emulator */
437                         plugin_ret = setting_invoke_reset_function(path, svc, NULL);
438                         SETTING_TRACE("load libug-%s.so[plugin_ret:%d]", path, plugin_ret);
439                 } else {
440                         ecore_idler_add((Ecore_Task_Cb) __delay_reset_location, item_data);
441                         app_control_destroy(svc);
442                         FREE(path);
443                         return;
444                 }
445                 app_control_destroy(svc);
446                 if (path) {
447                         FREE(path);
448                         path = NULL;
449                 }
450         }
451         /*
452         if (item_data) {
453                 elm_genlist_item_show(item_data->item, ELM_GENLIST_ITEM_SCROLLTO_IN);//show the last item
454         }
455         else {
456                 //SETTING_TRACE_ERROR("error : item_data is NULL");
457         }*/
458 }
459
460 static Eina_Bool __reset_animator_cb(void *data)
461 {
462         SettingResetUG *ad = (SettingResetUG *) data;
463
464         SETTING_TRACE("Processing the %dth of %d", ad->gl_index, ad->list_data.cur_item_num);
465
466         if (ad->gl_index < ad->list_data.cur_item_num && ad->list_data.chk_items[ad->gl_index].data_GenItem->chk_status) {
467                 ad->selected_index++;
468         }
469         char text[SYS_NOTI_NAME_LEN + 1] = {0, };
470         snprintf(text, SYS_NOTI_NAME_LEN, "%d/%d", ad->selected_index, ad->selected_num);
471         elm_object_part_text_set(ad->reset_sub_view, "elm.text.left", text);
472         double persent = (double)ad->gl_index / ad->list_data.cur_item_num;
473         elm_progressbar_value_set(ad->reset_process, persent);
474         /*SETTING_TRACE("Processing the %f",persent); */
475         if (ad->gl_index >=  ad->list_data.cur_item_num) {
476                 ecore_animator_del(ad->animator);
477                 ad->animator = NULL;
478                 if (ad->pop_progress) {
479                         evas_object_del(ad->pop_progress);
480                         ad->pop_progress = NULL;
481                 }
482                 Evas_Object *btn = elm_object_part_content_get(ad->notify, "button1");
483                 if (btn) {
484                         setting_enable_evas_object(btn);
485                         setting_undo_dim_evas_object(btn, TRUE);
486                 }
487
488                 if (ad->reset_list) {
489                         elm_genlist_item_show(elm_genlist_first_item_get(ad->reset_list), ELM_GENLIST_ITEM_SCROLLTO_TOP);
490                 }
491                 if (!setting_done_list_is_some_item_selected(&ad->list_data)) {
492                         if (ad->list_data.navi_it) {
493                                 Evas_Object *toolbar = elm_object_item_part_content_get(ad->list_data.navi_it, "toolbar");
494                                 elm_object_item_disabled_set(elm_toolbar_last_item_get(toolbar), EINA_TRUE);
495                                 elm_object_item_text_set(elm_toolbar_last_item_get(toolbar), _("IDS_COM_BODY_RESET"));
496                                 elm_object_item_text_set(elm_toolbar_item_prev_get(elm_toolbar_last_item_get(toolbar)), _("IDS_COM_SK_CANCEL"));
497                         }
498                 }
499                 elm_object_part_text_set(ad->reset_sub_view, "elm.text.right", _("IDS_ST_BODY_INSTALTAB_FINISH"));
500
501                 Evas_Object *obj = elm_object_part_content_get(ad->view_layout, "elm.swallow.contents");
502                 Evas_Object *genlist = elm_object_part_content_get(obj, "bg_swallow");
503                 elm_genlist_realized_items_update(genlist);
504
505                 elm_object_item_part_text_set(ad->list_data.navi_it, "elm.text.title", _(KeyStr_Select_Item));
506                 ad->reset_item_finish = TRUE;
507                 return ECORE_CALLBACK_CANCEL;
508         }
509         if (ad->list_data.chk_items[ad->gl_index].data_GenItem->chk_status) {
510                 elm_genlist_item_show(ad->list_data.chk_items[ad->gl_index].data_GenItem->item, ELM_GENLIST_ITEM_SCROLLTO_IN);/*show the last item */
511                 __reset_an_item(&(ad->list_data),
512                                 ad->list_data.chk_items[ad->gl_index].item_name,
513                                 ad->list_data.chk_items[ad->gl_index].ug_args);
514                 /*unselect item*/
515                 setting_update_gl_item_chk_status(ad->list_data.chk_items[ad->gl_index].data_GenItem, 0);
516         }
517
518         ad->gl_index++;
519         return ECORE_CALLBACK_RENEW;
520 }
521
522 bool __reset_delay_idler(void *data)
523 {
524         SETTING_TRACE_BEGIN;
525         retv_if(!data, FALSE);
526         SettingResetUG *ad = data;
527         ad->reset_item_finish = FALSE;
528         ad->gl_index = 0;
529         ad->selected_index = 0;
530         ad->selected_num = setting_done_list_item_selected_num(&ad->list_data);
531         if (ad->animator) {
532                 ecore_animator_del(ad->animator);
533                 ad->animator = NULL;
534         }
535         ad->animator = ecore_animator_add(__reset_animator_cb, ad);
536         return FALSE;
537 }
538 static int setting_done_list_item_selected_num(Setting_Done_List_Data *list_data)
539 {
540         SETTING_TRACE_BEGIN;
541         int idx = 0;
542         int num = 0;
543         for (; idx < list_data->cur_item_num; idx++) {
544                 if (list_data->chk_items[idx].data_GenItem->chk_status) {
545                         num++;
546                 }
547         }
548         SETTING_TRACE_END;
549         return num;
550 }
551 static void setting_reset_popup_cancel(void *data, Evas_Object *obj, void *event_info)
552 {
553         SETTING_TRACE_BEGIN;
554         setting_retm_if(data == NULL, "Data parameter is NULL");
555         SettingResetUG *ad = (SettingResetUG *)data;
556
557         if (ad->reset_item_finish) {
558                 if (ad->notify) {
559                         evas_object_del(ad->notify);
560                         ad->notify = NULL;
561                 }
562         }
563         SETTING_TRACE_END;
564 }
565
566 static void setting_reset_settings_check_state(Setting_Done_List_Data *list_data)
567 {
568         /* reset */
569         SETTING_TRACE_DEBUG("********resetting*******");
570
571         SettingResetUG *ad = (SettingResetUG *) list_data->UG_data;
572         ad->notify = elm_popup_add(ad->win_get);
573         /*setting_add_hardkey_features(ad->notify, ad); */
574         ea_object_event_callback_add(ad->notify, EA_CALLBACK_BACK, setting_reset_popup_cancel, ad);
575
576         elm_object_part_text_set(ad->notify, "title,text", _(RESET_SETTINGS_STR));
577         evas_object_size_hint_weight_set(ad->notify,
578                                          EVAS_HINT_EXPAND,
579                                          EVAS_HINT_EXPAND);
580         Evas_Object *btn = setting_create_button(ad->notify, _("IDS_COM_SK_OK"), NULL, setting_reset_result_popup_resp_cb, ad);
581         elm_object_part_content_set(ad->notify, "button1", btn);
582         elm_object_style_set(btn, "popup");
583         setting_disable_evas_object(btn);
584         setting_dim_evas_object(btn, TRUE);
585
586         ad->reset_sub_view = elm_layout_add(ad->notify);
587         elm_layout_file_set(ad->reset_sub_view, SETTING_THEME_EDJ_NAME, "backup_popup_progress");
588         evas_object_size_hint_weight_set(ad->reset_sub_view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
589
590         ad->reset_process = elm_progressbar_add(ad->notify);
591         elm_object_style_set(ad->reset_process, PROGRESSBAR_STYLE);
592         elm_progressbar_horizontal_set(ad->reset_process, EINA_TRUE);
593         evas_object_size_hint_align_set(ad->reset_process, EVAS_HINT_FILL, EVAS_HINT_FILL);
594         evas_object_size_hint_weight_set(ad->reset_process, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
595         elm_progressbar_value_set(ad->reset_process, 0.0);
596         evas_object_show(ad->reset_process);
597
598         elm_object_part_content_set(ad->reset_sub_view, "elm.swallow.content", ad->reset_process);
599         /*elm_object_part_text_set(ad->reset_sub_view, "elm.title", _(RESET_RESULT_STR)); */
600         elm_object_part_text_set(ad->reset_sub_view, "elm.text.right", _("IDS_ST_HEADER_PLEASE_WAIT"));
601
602         elm_object_content_set(ad->notify, ad->reset_sub_view);
603         ecore_idler_add((Ecore_Task_Cb) __reset_delay_idler, ad);
604         evas_object_show(ad->notify);
605         /* reset sel_all item */
606         /*elm_check_state_set(list_data->select_all_checkbox, 0); */
607         list_data->select_all_checked = EINA_FALSE;
608
609         elm_object_item_part_text_set(list_data->navi_it, "subtitle", "");
610         elm_object_item_signal_emit(list_data->navi_it, "elm,state,subtitle,hide", "elm");
611
612 }
613
614 static void
615 setting_reset_settings_result_password_ug_cb(ui_gadget_h ug, app_control_h result,
616                                              void *priv)
617 {
618         SETTING_TRACE_BEGIN;
619         /* error check */
620         retm_if(priv == NULL, "Data parameter is NULL");
621
622         SettingResetUG *ad = (SettingResetUG *) priv;
623
624         char *ret_str = NULL;
625
626         app_control_get_extra_data(result, "result", &ret_str);
627
628         retm_if(ret_str == NULL, "result paremeter is NULL");
629         SETTING_TRACE("result:%s", ret_str);
630
631         if (ret_str) {
632                 if (0 == safeStrCmp("Cancel", ret_str)) {
633                         /* Do not reset */
634                 } else if (!strncmp(ret_str, "SETTING_PW_TYPE_", strlen("SETTING_PW_TYPE_"))) {
635                         /*  Reset */
636 #if SIMPLY_SUPPORT_ALL_RESET
637                         ad->notify =
638                             setting_create_popup_witout_btn(ad, ad->win_get, _("IDS_COM_POP_PROCESSING"), NULL, __processing_popup_response_cb, 0);
639                         if (ad->reset_all_idler) {
640                                 ecore_idler_del(ad->reset_all_idler);
641                                 ad->reset_all_idler = NULL;
642                         }
643                         ad->reset_all_idler =
644                             ecore_idler_add((Ecore_Task_Cb) __reset_all_idler, ad);
645 #else
646                         /* if return value from passwordUG, create popup for resetting. */
647                         setting_reset_settings_check_state(&(ad->list_data));
648 #endif
649                 }
650                 FREE(ret_str);
651         }
652 }
653
654 static void
655 setting_reset_settings_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
656                                     void *priv)
657 {
658         /*SettingResetUG *ad = (SettingResetUG *) priv; */
659         Evas_Object *base;
660
661         if (!priv) {
662                 return;
663         }
664         SETTING_TRACE_BEGIN;
665
666         base = (Evas_Object *) ug_get_layout(ug);
667         if (!base) {
668                 return;
669         }
670         switch (mode) {
671                 case UG_MODE_FULLVIEW:
672                         evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
673                                                          EVAS_HINT_EXPAND);
674                         /*elm_win_resize_object_add(ad->win_get, base); */
675                         evas_object_show(base);
676                         break;
677                 default:
678                         break;
679         }
680         SETTING_TRACE_END;
681 }
682
683 static void setting_reset_settings_destroy_password_ug_cb(ui_gadget_h ug,
684                                                           void *priv)
685 {
686         SETTING_TRACE_BEGIN;
687         ret_if(!priv);
688         SettingResetUG *ad = (SettingResetUG *) priv;
689         if (ug) {
690                 setting_ug_destroy(ug);
691                 ad->ug_loading = NULL;
692         }
693
694 }
695
696 static bool setting_reset_settings_create_password_sg(void *data)
697 {
698         SETTING_TRACE_BEGIN;
699         /* error check */
700         retv_if(data == NULL, FALSE);
701
702         SettingResetUG *ad = (SettingResetUG *) data;
703
704         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
705         if (!cbs) {
706                 return FALSE;
707         }
708         cbs->layout_cb = setting_reset_settings_layout_ug_cb;
709         cbs->result_cb = setting_reset_settings_result_password_ug_cb;
710         cbs->destroy_cb = setting_reset_settings_destroy_password_ug_cb;
711         cbs->priv = (void *)ad;
712
713         app_control_h svc;
714         if (app_control_create(&svc)) {
715                 FREE(cbs);
716                 return FALSE;
717         }
718
719         /* if reset settings will be used, below viewtype should be changed. */
720         /* refer to setting_reset_main_create_password_sg() in setting-reset-main.c */
721         app_control_add_extra_data(svc, "viewtype", "SETTING_PW_TYPE_RESET");
722
723         elm_object_tree_focus_allow_set(ad->ly_main, EINA_FALSE);
724         ad->ug_loading =
725             setting_ug_create(ad->ug, "setting-password-efl", UG_MODE_FULLVIEW, svc, cbs);
726         if (NULL == ad->ug_loading) {   /* error handling */
727         }
728
729         app_control_destroy(svc);
730         FREE(cbs);
731
732         return TRUE;
733 }
734 static Eina_Bool setting_reset_setting_item_popup_cb(void *data, Elm_Object_Item *it)
735 {
736         SETTING_TRACE_BEGIN;
737         /* error check */
738         retvm_if(data == NULL, EINA_FALSE, "Data parameter is NULL");
739
740         SettingResetUG *ad = (SettingResetUG *) data;
741
742         setting_view_change(&setting_view_reset_settings, &setting_view_reset_main, ad);
743
744         return EINA_TRUE;
745 }
746
747 /* ***************************************************
748  *
749  *call back func
750  *
751  ***************************************************/
752
753 static void
754 setting_reset_settings_click_softkey_cancel_cb(void *data, Evas_Object *obj,
755                                                void *event_info)
756 {
757         SETTING_TRACE_BEGIN;
758         /* error check */
759         setting_retm_if(data == NULL, "Data parameter is NULL");
760
761         SettingResetUG *ad = (SettingResetUG *) data;
762
763         setting_view_change(&setting_view_reset_settings, &setting_view_reset_main, ad);
764
765 }
766
767 static void
768 setting_reset_settings_click_softkey_reset_cb(void *data, Evas_Object *obj,
769                                               void *event_info)
770 {
771         SETTING_TRACE_BEGIN;
772         /* error check */
773         retm_if(data == NULL, "Data parameter is NULL");
774
775         SettingResetUG *ad = (SettingResetUG *) data;
776         int screen_lock_type = 0;
777
778         /*every time clicking 'Reset' button, restore following VCONFs */
779         /*vconf_set_bool(VCONFKEY_SETAPPL_FONT_CHANGED, FALSE); */
780
781         if (ad->list_data.selInfoPop) {
782                 evas_object_del(ad->list_data.selInfoPop);
783                 ad->list_data.selInfoPop = NULL;
784         }
785
786         if (!setting_done_list_is_some_item_selected(&(ad->list_data))) {
787                 setting_create_simple_popup(NULL, ad->win_get, NULL, _("IDS_ST_POP_NO_ITEM_SELECTED"));
788         } else {
789                 vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &screen_lock_type);
790                 if (screen_lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD
791                     || screen_lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
792                         setting_reset_settings_create_password_sg(ad);
793                 } else {
794                         setting_reset_settings_check_state(&(ad->list_data));
795                 }
796         }
797 }