Tizen 2.0 Release
[apps/home/settings.git] / setting-reset / src / setting-reset-settings.c
1 /*
2  * setting
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Flora License, Version 1.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://floralicense.org/license/
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include <setting-cfg.h>
18 #include <setting-reset-settings.h>
19 #include <Ecore_X.h>
20 #include <utilX.h>
21
22 #define RESULT_FONT_SIZE 28//18
23 #define ITEM_NAME_FONT_SIZE 35//22
24
25 static int setting_reset_settings_create(void *cb);
26 static int setting_reset_settings_destroy(void *cb);
27 static int setting_reset_settings_update(void *cb);
28 static int setting_reset_settings_cleanup(void *cb);
29
30 setting_view setting_view_reset_settings = {
31         .create = setting_reset_settings_create,
32         .destroy = setting_reset_settings_destroy,
33         .update = setting_reset_settings_update,
34         .cleanup = setting_reset_settings_cleanup,
35 };
36
37 static void setting_reset_settings_click_softkey_reset_cb(void *data,
38                                                       Evas_Object *obj,
39                                                       void *event_info);
40 static void setting_reset_settings_click_softkey_cancel_cb(void *data,
41                                                        Evas_Object *obj,
42                                                        void *event_info);
43
44 static bool setting_reset_settings_create_password_sg(void *data);
45 static void setting_reset_settings_check_state(Setting_Done_List_Data *list_data);
46 static void setting_reset_settings_result_password_ug_cb(ui_gadget_h ug,
47                                                      service_h result,
48                                                      void *priv);
49
50 /* ***************************************************
51  *
52  *basic func
53  *
54  ***************************************************/
55 static char *__result_gl_text_get(void *data, Evas_Object *obj,
56                                    const char *part)
57 {
58         retv_if(!data, NULL);
59         Setting_GenGroupItem_Data *item_data =
60             (Setting_GenGroupItem_Data *) data;
61         //SETTING_TRACE("part:%s", part);
62
63         if (!safeStrCmp(part, "elm.text") || !safeStrCmp(part, "elm.text.1")) { /* title */
64                 char label[HELP_MSG_BUFF_SIZE + 1] = { 0, };
65                 if (item_data->keyStr)
66                 {
67                         const char *key = setting_customize_text(_(item_data->keyStr), ITEM_NAME_FONT_SIZE, NULL, NULL);
68                         safeStrNCat(label, key,HELP_MSG_BUFF_SIZE);
69                         FREE(key);
70                 }
71                 if (item_data->sub_desc)
72                 {
73                         char desc[SETTING_STR_SLP_LEN + 1] = { 0, };
74                         snprintf(desc, SETTING_STR_SLP_LEN, ": %s", _(item_data->sub_desc));
75                         const char *sub_desc = setting_customize_text(desc, RESULT_FONT_SIZE, NULL, NULL);
76                         safeStrNCat(label, sub_desc,HELP_MSG_BUFF_SIZE);
77                         FREE(sub_desc);
78                 }
79                 return (char *)g_strdup(label);
80         }
81         return NULL;
82 }
83 #if SIMPLY_SUPPORT_ALL_RESET
84 static void __processing_popup_response_cb(void *data, Evas_Object *obj,
85                                      void *event_info)
86 {
87         ret_if(!data);
88         SettingResetUG *ad = data;
89         setting_reset_special_process(ad);
90         if (obj) {
91                 evas_object_del(obj);
92                 obj = NULL;
93         }
94         ad->notify= NULL;
95
96         // key ungrab: after showing the result popup
97         Ecore_X_Display *disp = ecore_x_display_get();
98         Ecore_X_Window xwin = elm_win_xwindow_get((Evas_Object*)ug_get_window());
99         int ret = utilx_ungrab_key(disp, xwin, KEY_HOME);
100         if (ret) {
101                 SETTING_TRACE_ERROR("KEY_HOME ungrab error ret[%d]", ret);
102         }
103 }
104 bool __reset_all_idler(void *data)
105 {
106         SETTING_TRACE_BEGIN;
107         retv_if(!data, FALSE);
108         SettingResetUG *ad = data;
109
110         int i = 0;
111         int j = 0;
112         int idx = 0;
113         const char *result_str = RESET_SUCESS_STR;
114         char ug_file[PATH_MAX + 1];
115         char *path = NULL;
116         service_h svc;
117         int ret = -1;
118         char *ug_args;
119         char *item_name;
120
121         for (; i < setting_cfg_get_category_length(); i++) {
122                 //SETTING_TRACE("group is:%s", _(setting_cfg_get_category_name(i)));
123
124                 result_str = RESET_SUCESS_STR;
125                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
126                         /*SETTING_TRACE("i:%d\tj:%d", i, j);*/
127                         if (Cfg_Item_unResetable ==
128                             setting_cfg_get_resetable_flag_idx(i, j))
129                         {
130                                 //SETTING_TRACE("process %s:%s skipped",_(item_name), ug_args);
131                                 continue;
132                         }
133                         ug_args = setting_cfg_get_ug_args_idx(i, j);
134                         item_name = setting_cfg_get_keyname_idx(i, j);
135                         if (item_name)
136                                 SETTING_TRACE(">>> process %s:%s",_(item_name), ug_args);
137
138                         idx++;
139                         if (NULL == ug_args) /*special process*/
140                         {
141                                 ret = -1;
142                                 if (!safeStrCmp(KeyStr_FlightMode, item_name)) {
143                                         //Invoke aync API and ignore the response message
144                                         ret = setting_reset_flight_mode();
145                                 } else if (!safeStrCmp(KeyStr_Landscape, item_name)) {
146                                         ret = setting_reset_rotation_lock();
147                                 }
148                                 //..
149                                 if (0 > ret)
150                                 {
151                                         result_str = RESET_FAILED_STR;
152                                 }
153
154
155                         }
156                         else
157                         {
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                                 {
169                                         result_str = RESET_FAILED_STR;
170
171                                 }
172
173                                 service_destroy(svc);
174                                 FREE(path);
175                                 memset(ug_file, 0, PATH_MAX);
176                         }
177                         SETTING_TRACE("process %s:%s %s",_(item_name), ug_args, _(result_str));
178                 }
179         }
180
181         //list_data->cur_item_num = idx;
182         SETTING_TRACE_DEBUG("Reset totally %d items. result_str:%s", idx, result_str);
183         //setting_create_popup_with_notitle(NULL, ad->win_get, _(result_str));
184         elm_popup_desc_set(ad->notify, _(result_str));
185         elm_popup_mode_set(ad->notify, POPUP_INTERVAL);
186         elm_popup_timeout_set(ad->notify, 2);
187
188         if (ad->reset_all_idler) {
189                 ecore_idler_del(ad->reset_all_idler);
190                 ad->reset_all_idler = NULL;
191         }
192         return FALSE;
193 }
194
195 void __reset_all_button_cb(void *data, Evas_Object *obj, void *event_info)
196 {
197         SETTING_TRACE_BEGIN;
198         ret_if(!data);
199         Setting_GenGroupItem_Data *item_Data = data;
200         ret_if(!item_Data->userdata);
201         SettingResetUG *ad = item_Data->userdata;
202
203
204         char pw_pass[SETTING_STR_SLP_LEN] = { 0, };
205         int err = 0;
206
207         /*  Check Password Setting status */
208         int ret =
209             setting_get_string_slp_key(STR_SLP_LIST_PHONE_PASSWORD,
210                                        pw_pass, &err);
211         SETTING_TRACE("pw_pass:%s", pw_pass);
212         if (SETTING_RETURN_SUCCESS == ret && '\0' != pw_pass[0]) {
213                 setting_reset_settings_create_password_sg(ad);
214                 return;
215         }
216
217         // key grab: before showing processing popup
218         Ecore_X_Display *disp = ecore_x_display_get();
219         Ecore_X_Window xwin = elm_win_xwindow_get((Evas_Object*)ug_get_window());
220         ret = utilx_grab_key(disp, xwin, KEY_HOME, TOP_POSITION_GRAB);
221         if (ret) {
222                 SETTING_TRACE_ERROR("KEY_HOME grab error ret[%d]", ret);
223         }
224
225         ad->notify =
226                 setting_create_popup_without_btn(ad, ad->win_get, NULL, _("IDS_COM_POP_PROCESSING"), __processing_popup_response_cb, 0, 1, 1);
227         if (ad->reset_all_idler) {
228                 ecore_idler_del(ad->reset_all_idler);
229                 ad->reset_all_idler = NULL;
230         }
231
232         ad->reset_all_idler =
233             ecore_idler_add((Ecore_Task_Cb) __reset_all_idler, ad);
234 }
235 #endif
236 static int setting_reset_settings_create(void *cb)
237 {
238         SETTING_TRACE_BEGIN;
239         /* error check */
240         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
241
242         SettingResetUG *ad = (SettingResetUG *) cb;
243         Evas_Object *scroller = NULL;
244
245         Evas_Object *view_layout = elm_layout_add(ad->win_main_layout);
246         elm_layout_file_set(view_layout, SETTING_THEME_EDJ_NAME,
247                             "selinfo_bottom");
248         evas_object_size_hint_weight_set(view_layout, EVAS_HINT_EXPAND, 0.0);
249
250         /*  Evas_Object * win_layout, Evas_Object * win_obj */
251         Elm_Object_Item *navi_it = setting_push_layout_navi_bar(_(RESET_SETTINGS_STR),
252                                    _("IDS_COM_BODY_RESET"),
253                                    _("IDS_COM_SK_CANCEL"), NULL,
254                                    setting_reset_settings_click_softkey_reset_cb,
255                                    setting_reset_settings_click_softkey_cancel_cb,
256                                    NULL, ad, view_layout, ad->navi_bar,
257                                    NULL);
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         char *item_name;
270
271         int i = 0;
272         int j = 0;
273
274         for (; i < setting_cfg_get_category_length(); i++) {
275                 SETTING_TRACE("group is:%s", _(setting_cfg_get_category_name(i)));
276
277                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
278                         /*SETTING_TRACE("i:%d\tj:%d", i, j);*/
279                         if (Cfg_Item_unResetable ==
280                             setting_cfg_get_resetable_flag_idx(i, j))
281                         {
282                             continue;
283                         }
284                         ug_args = setting_cfg_get_ug_args_idx(i, j);
285                         if (!is_ug_installed_by_ug_args(ug_args))
286                         {
287                                 continue;
288                         }
289
290                         item_name = setting_cfg_get_keyname_idx(i, j);
291                         if (isEmulBin())
292                         {
293                                 if (!safeStrCmp(KeyStr_FlightMode, item_name)) {
294                                         continue; /* hide Flight Mode in Emulator*/
295                                 } else if (!safeStrCmp(KeyStr_WiFi, item_name)) {
296                                         continue; /* hide WIFI in Emulator*/
297                                 } else if (!safeStrCmp(KeyStr_MobileAP, item_name)) {
298                                         continue; /* hide Tethering in Emulator*/
299                                 } else if (!safeStrCmp(KeyStr_WiFiDirect, item_name)) {
300                                         continue; /* hide WiFiDirect in Emulator*/
301                                 } else if (!safeStrCmp(KeyStr_Network, item_name)) {
302                                         continue; /* hide Network in Emulator*/
303                                 } else if (!safeStrCmp(KeyStr_Bluetooth, item_name)) {
304                                         continue; /* hide Bluetooth in Emulator*/
305                                 } else if (!safeStrCmp(KeyStr_DateTime, item_name)) {
306                                         continue; /* hide Date&Time in Emulator*/
307                                 } else if (!safeStrCmp(KeyStr_Security, item_name)) {
308                                         continue; /* hide Security in Emulator*/
309                                 } else if (!safeStrCmp(KeyStr_Memory, item_name)) {
310                                         continue; /* hide Memory in Emulator*/
311                                 } else if (!safeStrCmp(KeyStr_Powersaving, item_name)) {
312                                         continue; /* hide Powersaving in Emulator*/
313                                 } else if (!safeStrCmp(KeyStr_Email, item_name)) {
314                                         continue;
315                                 }
316                         }
317
318                         list_data->chk_items[idx].ug_args = ug_args;
319                         list_data->chk_items[idx].item_name = item_name =
320                                         setting_cfg_get_keyname_idx(i, j);
321
322                         SETTING_TRACE("process %s:\t%s",_(item_name), ug_args);
323                         idx++;
324                 }
325         }
326
327         list_data->cur_item_num = idx;
328         SETTING_TRACE("list_data->cur_item_num:%d", list_data->cur_item_num);
329         scroller = setting_create_done_list(list_data);
330         elm_object_part_content_set(view_layout, "elm.swallow.contents", scroller);
331
332         if(idx == 0 || !setting_done_list_is_some_item_selected(list_data)) {
333                 Evas_Object *reset_btn = elm_object_item_part_content_get(navi_it, "toolbar_button1");
334                 elm_object_disabled_set(reset_btn, EINA_TRUE);
335         }
336
337         ad->view_layout = view_layout;
338         ad->reset_list = elm_object_part_content_get(scroller, "search_list");
339         /* *******************************************update info */
340
341         setting_view_reset_settings.is_create = 1;
342         ad->itc_1text.func.text_get = __result_gl_text_get;
343         return SETTING_RETURN_SUCCESS;
344 }
345
346 static int setting_reset_settings_destroy(void *cb)
347 {
348         SETTING_TRACE_BEGIN;
349         /* error check */
350         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
351
352         SettingResetUG *ad = (SettingResetUG *) cb;
353
354         if (ad->list_data.selInfoPop) {
355                 evas_object_del(ad->list_data.selInfoPop);
356                 ad->list_data.selInfoPop = NULL;
357         }
358         if (ad->notify) {
359                 evas_object_del(ad->notify);
360                 ad->notify = NULL;
361         }
362         if (ad->old_notify) {
363                 evas_object_del(ad->old_notify);
364                 ad->old_notify = NULL;
365         }
366         if (ad->pop)
367         {
368                 evas_object_del(ad->pop);
369                 ad->pop = NULL;
370         }
371         if (ad->pop_progress)
372         {
373                 evas_object_del(ad->pop_progress);
374                 ad->pop_progress = NULL;
375         }
376
377         if (ad->ask_popup)
378         {
379                 evas_object_del(ad->ask_popup);
380                 ad->ask_popup = NULL;
381         }
382         if (ad->animator)
383         {
384                 ecore_animator_del(ad->animator);
385                 ad->animator = NULL;
386         }
387
388         if (ad->reset_all_idler) {
389                 ecore_idler_del(ad->reset_all_idler);
390                 ad->reset_all_idler = NULL;
391         }
392
393         ad->pop_btn = NULL;
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
506                         service_destroy(svc);
507                         FREE(path);
508                         return;
509                 }
510
511                 if (LOAD_LIB_FAILED == plugin_ret) // -1
512                 {
513                         result_str = LOAD_LIB_FAILED_STR;
514
515                 } else if (UNDEFINED_LIB_SYMBOL == plugin_ret) // -2
516                 {
517                         result_str = UNDEFINE_STR;
518                 } else if (OPERATE_LIB_SUCESS <= plugin_ret){ // 0
519                         result_str = RESET_SUCESS_STR;
520
521                 } else {
522                         result_str = RESET_FAILED_STR;
523                 }
524
525                 service_destroy(svc);
526                 if (path){
527                         FREE(path);
528                         path = NULL;
529                 }
530
531                 item_data = setting_create_Gendial_field_def(genlist, &(ad->itc_1text),
532                                                  NULL, ad,
533                                                  SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
534                                                  NULL, NULL, 0,
535                                                  (char *)item_name,
536                                                  (char *)result_str, NULL);
537         }
538
539         if (item_data)
540                 elm_genlist_item_show(item_data->item, ELM_GENLIST_ITEM_SCROLLTO_IN);//show the last item
541         else
542                 SETTING_TRACE_ERROR("error : item_data is NULL");
543 }
544
545 static Eina_Bool __reset_animator_cb(void *data)
546 {
547         SettingResetUG *ad = (SettingResetUG *) data;
548
549         SETTING_TRACE("Processing the %dth of %d",
550                       ad->gl_index, ad->list_data.cur_item_num);
551         if (ad->gl_index >=  ad->list_data.cur_item_num) {
552                 ecore_animator_del(ad->animator);
553                 ad->animator = NULL;
554                 if (ad->pop_progress) {
555                         evas_object_del(ad->pop_progress);
556                         ad->pop_progress = NULL;
557                 }
558                 //Evas_Object *btn = elm_object_part_content_get(ad->notify, "button1");
559                 if (ad->pop_btn)
560                 {
561                         setting_enable_evas_object(ad->pop_btn);
562                         setting_undo_dim_evas_object(ad->pop_btn, TRUE);
563                 }
564
565                 Evas_Object *genlist = elm_object_content_get(ad->notify);
566                 if(genlist)
567                         elm_genlist_item_show(elm_genlist_first_item_get(genlist), ELM_GENLIST_ITEM_SCROLLTO_TOP);
568                 if(ad->reset_list)
569                         elm_genlist_item_show(elm_genlist_first_item_get(ad->reset_list), ELM_GENLIST_ITEM_SCROLLTO_TOP);
570
571                 if(!setting_done_list_is_some_item_selected(&ad->list_data)) {
572                         if (ad->list_data.navi_it) {
573                                 Evas_Object *button = elm_object_item_part_content_get(ad->list_data.navi_it, "toolbar_button1");
574                                 elm_object_disabled_set(button, EINA_TRUE);
575                         }
576                 }
577                 return ECORE_CALLBACK_CANCEL;
578         }
579         if (ad->list_data.chk_items[ad->gl_index].data_GenItem->chk_status) {
580                 elm_genlist_item_show(ad->list_data.chk_items[ad->gl_index].data_GenItem->item, ELM_GENLIST_ITEM_SCROLLTO_IN);//show the last item
581                 __reset_an_item(&(ad->list_data),
582                                 ad->list_data.chk_items[ad->gl_index].item_name,
583                                 ad->list_data.chk_items[ad->gl_index].ug_args);
584                 /*unselect item*/
585                 elm_check_state_set(ad->list_data.chk_items[ad->gl_index].data_GenItem->eo_check, 0);
586                 ad->list_data.chk_items[ad->gl_index].data_GenItem->chk_status = 0;
587         }
588
589         ad->gl_index++;
590         return ECORE_CALLBACK_RENEW;
591 }
592
593 bool __reset_delay_idler(void *data)
594 {
595         SETTING_TRACE_BEGIN;
596         retv_if(!data, FALSE);
597         SettingResetUG *ad = data;
598         ad->gl_index = 0;
599         ad->animator = ecore_animator_add(__reset_animator_cb, ad);
600         return FALSE;
601 }
602
603 static void setting_reset_settings_check_state(Setting_Done_List_Data *list_data)
604 {
605         /* reset */
606         SETTING_TRACE_DEBUG("********resetting*******");
607
608         SettingResetUG *ad = (SettingResetUG *) list_data->UG_data;
609         ad->notify = elm_popup_add(ad->win_get);
610         elm_object_style_set(ad->notify,"menustyle");
611         elm_object_part_text_set(ad->notify, "title,text", _(RESET_RESULT_STR));
612         evas_object_size_hint_weight_set(ad->notify,
613                                 EVAS_HINT_EXPAND,
614                                 EVAS_HINT_EXPAND);
615         Evas_Object *btn = setting_create_button(ad->notify, _("IDS_COM_SK_OK"), NULL, setting_reset_result_popup_resp_cb, ad);
616         elm_object_part_content_set(ad->notify, "button1", btn);
617         elm_object_style_set(btn, "popup_button/default");
618         setting_disable_evas_object(btn);
619         setting_dim_evas_object(btn, TRUE);
620         ad->pop_btn = btn;
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 static void
650 setting_reset_settings_result_password_ug_cb(ui_gadget_h ug, service_h result,
651                                          void *priv)
652 {
653         SETTING_TRACE_BEGIN;
654         /* error check */
655         retm_if(priv == NULL, "Data parameter is NULL");
656
657         SettingResetUG *ad = (SettingResetUG *) priv;
658
659         char *ret_str = NULL;
660
661         service_get_extra_data(result, "result", &ret_str);
662
663         retm_if(ret_str == NULL, "result paremeter is NULL");
664         SETTING_TRACE("result:%s", ret_str);
665
666         if (ret_str) {
667                 if (0 == safeStrCmp("Cancel", ret_str)) {
668                         /* Do not reset */
669                 }
670                 else if (0 == safeStrCmp("SETTING_PW_TYPE_RESET", ret_str)) {
671                         /*  Reset */
672 #if SIMPLY_SUPPORT_ALL_RESET
673                         ad->notify =
674                                 setting_create_popup_witout_btn(ad, ad->win_get, _("IDS_COM_POP_PROCESSING"), NULL, __processing_popup_response_cb, 0);
675                         if (ad->reset_all_idler) {
676                                 ecore_idler_del(ad->reset_all_idler);
677                                 ad->reset_all_idler = NULL;
678                         }
679                         ad->reset_all_idler =
680                             ecore_idler_add((Ecore_Task_Cb) __reset_all_idler, ad);
681 #else
682                         /* if return value from passwordUG, create popup for resetting. */
683                         setting_reset_settings_check_state(&(ad->list_data));
684 #endif
685                 }
686         }
687 }
688
689 static void
690 setting_reset_settings_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
691                                 void *priv)
692 {
693         SettingResetUG *ad = (SettingResetUG *) priv;
694         Evas_Object *base;
695
696         if (!priv)
697                 return;
698         SETTING_TRACE_BEGIN;
699
700         base = (Evas_Object *) ug_get_layout(ug);
701         if (!base)
702                 return;
703
704         switch (mode) {
705         case UG_MODE_FULLVIEW:
706                 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
707                                                  EVAS_HINT_EXPAND);
708                 //elm_win_resize_object_add(ad->win_get, base);
709                 evas_object_show(base);
710                 break;
711         default:
712                 break;
713         }
714         SETTING_TRACE_END;
715 }
716
717 static void setting_reset_settings_destroy_password_ug_cb(ui_gadget_h ug,
718                                                       void *priv)
719 {
720         SETTING_TRACE_BEGIN;
721         ret_if(!priv);
722         SettingResetUG *ad = (SettingResetUG *) priv;
723         if (ug) {
724                 ug_destroy(ug);
725                 ad->ug_loading = NULL;
726         }
727
728 }
729
730 static bool setting_reset_settings_create_password_sg(void *data)
731 {
732         SETTING_TRACE_BEGIN;
733         /* error check */
734         retv_if(data == NULL, FALSE);
735
736         SettingResetUG *ad = (SettingResetUG *) data;
737
738         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
739         if (!cbs)
740                 return FALSE;
741         cbs->layout_cb = setting_reset_settings_layout_ug_cb;
742         cbs->result_cb = setting_reset_settings_result_password_ug_cb;
743         cbs->destroy_cb = setting_reset_settings_destroy_password_ug_cb;
744         cbs->priv = (void *)ad;
745
746         service_h svc;
747         if (service_create(&svc)) {
748                 FREE(cbs);
749                 return FALSE;
750         }
751
752         service_add_extra_data(svc, "viewtype", "SETTING_PW_TYPE_RESET");
753
754         ad->ug_loading =
755             ug_create(ad->ug, "setting-password-efl", UG_MODE_FULLVIEW, svc, cbs);
756         if (NULL == ad->ug_loading) {   /* error handling */
757         }
758
759         service_destroy(svc);
760         FREE(cbs);
761
762         return TRUE;
763 }
764
765 /* ***************************************************
766  *
767  *call back func
768  *
769  ***************************************************/
770
771 static void
772 setting_reset_settings_click_softkey_cancel_cb(void *data, Evas_Object *obj,
773                                            void *event_info)
774 {
775         SETTING_TRACE_BEGIN;
776         /* error check */
777         retm_if(data == NULL, "Data parameter is NULL");
778
779         SettingResetUG *ad = (SettingResetUG *) data;
780
781         setting_view_change(&setting_view_reset_settings, &setting_view_reset_main, ad);
782 }
783
784 static void
785 setting_reset_settings_click_softkey_reset_cb(void *data, Evas_Object *obj,
786                                           void *event_info)
787 {
788         SETTING_TRACE_BEGIN;
789         /* error check */
790         retm_if(data == NULL, "Data parameter is NULL");
791
792         SettingResetUG *ad = (SettingResetUG *) data;
793         //int screen_lock_type = 0;
794
795         //every time clicking 'Reset' button, restore following VCONFs
796         //vconf_set_bool(VCONFKEY_SETAPPL_FONT_CHANGED, FALSE);
797
798         if (ad->list_data.selInfoPop) {
799                 evas_object_del(ad->list_data.selInfoPop);
800                 ad->list_data.selInfoPop = NULL;
801         }
802
803         if (!setting_done_list_is_some_item_selected(&(ad->list_data))) {
804                 setting_create_simple_popup(NULL, ad->win_get, NULL, "No item selected");
805         } else {
806
807                 setting_reset_settings_check_state(&(ad->list_data));
808
809         }
810 }