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