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