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