9c0f6fe2a588e204850a3452fc9ed806da4126be
[apps/home/settings.git] / src / setting.c
1 /*
2  * setting
3  * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
4  *
5  * Contact: MyoungJune Park <mj2004.park@samsung.com>
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 #include <setting.h>
21 #include <app.h>
22 #include <sound_manager.h>
23
24 #include <appcore-common.h>
25 #include <Ecore_X.h>
26 #include <sensor.h>
27 #include <aul.h>
28 #include "setting-main.h"
29
30
31 #include <setting-cfg.h>
32
33 #include <setting-common-search.h>
34 #include <elm_object.h>
35 #include <appsvc.h>
36 /*#include <nfc.h> */
37 #include <signal.h>
38 #include <system_settings.h>
39
40 #define KEY_END "XF86Stop"
41 /*#define SUPPORT_UG_MESSAGE */
42
43
44 #define SETTING_SOUND_VOL_MAX 15
45 #define SETTING_DEFAULT_RINGTONE_VOL_INT        11
46 #define SETTING_DEFAULT_NOTI_VOL_INT            11
47 #define SETTING_DEFAULT_MEDIA_VOL_INT           9
48
49 const char *fixed_grid_pref_key[] = {
50         "PREFKEY_GRID0",
51         "PREFKEY_GRID1",
52         "PREFKEY_GRID2",
53         "PREFKEY_GRID3",
54         "PREFKEY_GRID4",
55         "PREFKEY_GRID5",
56         "PREFKEY_GRID6",
57         "PREFKEY_GRID7",
58         "PREFKEY_GRID8",
59         "PREFKEY_GRID9",
60         "PREFKEY_GRID10",
61         "PREFKEY_GRID11",
62 };
63
64 int g_geometry_x, g_geometry_y, g_geometry_w, g_geometry_h;
65 extern int aul_listen_app_dead_signal(int (*func)(int signal, void *data), void *data);
66
67 /* This API is defined in <app_service_private.h>. But, cannot include and it is not a managed API.
68         The way to resolve : 1. Add extern.
69                                                  2. Use bundle pointer originally
70         At first, choose No.1 */
71 extern int app_control_create_request(bundle *data, app_control_h *service);
72
73
74 setting_main_appdata *g_main_ad;
75 const char *menu_group[] = {KeyStr_Connectivity,
76                             KeyStr_ShareAndTransfer,
77                             KeyStr_SoundDisplay,
78                             KeyStr_Personal,
79                             KeyStr_MotionControl,
80                             KeyStr_BackupOption,
81                             KeyStr_System,
82                             KeyStr_DownloadedAPPs,
83                            };
84
85 static Cfg_Item_Type setting_main_sfinder_handler(app_control_h service, void *data, int (*func)(void *d1));
86
87 static Ea_Theme_Color_Table *_changeable_colors_set()
88 {
89         Ea_Theme_Color_Table *table;
90
91         table = ea_theme_color_table_new("/usr/apps/org.tizen.setting/shared/res/tables/org.tizen.setting.xml");
92         ea_theme_colors_set(table, EA_THEME_STYLE_LIGHT);
93
94         return table;
95 }
96
97 static void _changeable_colors_free(Ea_Theme_Color_Table *table)
98 {
99         /* when the process is killed, you don’t need to call this */
100         ea_theme_colors_unset(table, EA_THEME_STYLE_LIGHT);
101         ea_theme_color_table_free(table);
102 }
103
104
105
106 void termination_handler(int signum)
107 {
108         SETTING_TRACE_BEGIN;
109         /* do something for signal handling */
110         /*SETTING_TRACE_DEBUG(">>>>>>>>>>>>>>>>> SIGTERM >>>>>>>>>>>>>>> SETTING "); */
111
112         elm_exit();
113 }
114
115
116 #if LOW_BATTERY_DO_NOTHING
117
118 /*  in case of low battery, don't terminate itself.*/
119
120 /**
121 * The event process when battery becomes low.
122 */
123 static void setting_main_low_battery_cb(void *data)
124 {
125         SETTING_TRACE_BEGIN;
126         setting_main_appdata *ad = data;
127
128         if (ad->ug) {
129                 ug_send_event(UG_EVENT_LOW_BATTERY);
130         }
131 }
132 #endif
133
134
135 #if SUPPORT_APP_ROATION
136 static void _rot_changed_cb(void *data, Evas_Object *obj, void *event_info)
137 {
138         SETTING_TRACE_BEGIN;
139         setting_main_appdata *ad = (setting_main_appdata *)data;
140         if (ad == NULL || ad->win_main == NULL) {
141                 return;
142         }
143         int change_ang = elm_win_rotation_get(ad->win_main);
144         SETTING_TRACE_DEBUG("....change_ang:%d", change_ang);
145         SETTING_TRACE_DEBUG("current_rotation:%d", ad->current_rotation);
146         /*Send the rotation event to UGs.. */
147         enum ug_event event = UG_EVENT_ROTATE_PORTRAIT;
148         switch (change_ang) {
149                 case APP_DEVICE_ORIENTATION_0:
150                         event = UG_EVENT_ROTATE_PORTRAIT;
151                         break;
152                 case APP_DEVICE_ORIENTATION_180:
153                         event = UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN;
154                         break;
155                 case APP_DEVICE_ORIENTATION_270:
156                         event = UG_EVENT_ROTATE_LANDSCAPE;
157                         break;
158                 case APP_DEVICE_ORIENTATION_90:
159                         event = UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN;
160                         break;
161                 default:
162                         return;
163         }
164         SETTING_TRACE_DEBUG("diff:%d", elm_win_rotation_get(ad->win_main) - ad->current_rotation);
165
166         if (change_ang != ad->current_rotation) {
167                 int diff = change_ang - ad->current_rotation;
168                 if (diff < 0) {
169                         diff = -diff;
170                 }
171                 /**
172                 * @todo if app didn't launch UG, is the call required to invoke?
173                 */
174                 ug_send_event(event);
175                 if (diff == 180) {
176                         /* do nothing */
177                 } else {
178                         if (ad->list_type == SETTING_GRID_VIEW) {
179                                 Elm_Object_Item *it;
180                                 Evas_Object *genlist = NULL;
181
182                                 genlist = ad->sc_gl[SC_All_Grid];
183                                 if (genlist) {
184                                         /*elm_genlist_realized_items_update(ad->sc_gl[SC_All_Grid]); */
185                                         /*list = elm_genlist_realized_items_get(ad->sc_gl[SC_All_Grid]); */
186                                         it = elm_genlist_first_item_get(genlist);
187                                         while (it) {
188                                                 elm_genlist_item_update(it);
189                                                 it = elm_genlist_item_next_get(it);
190                                         }
191                                 }
192
193                                 genlist = ad->edit_genlist;
194                                 if (ad->edit_genlist) {
195                                         /*elm_genlist_realized_items_update(ad->edit_genlist); */
196                                         it = elm_genlist_first_item_get(genlist);
197                                         while (it) {
198                                                 elm_genlist_item_update(it);
199                                                 it = elm_genlist_item_next_get(it);
200                                         }
201                                 }
202                         }
203                 }
204                 ad->current_rotation = change_ang;
205         }
206 }
207 #endif
208
209
210 /**
211 * The event process when region is changes.
212 */
213 static void setting_main_region_changed_cb(void *data)
214 {
215         setting_main_appdata *ad = data;
216
217         if (ad->ug) {
218                 ug_send_event(UG_EVENT_REGION_CHANGE);
219         }
220 }
221
222 /**
223 * The event process when win object is destroyed
224 */
225 static void setting_main_del_win(void *data, Evas_Object *obj, void *event)
226 {
227         elm_exit();
228 }
229
230 void profile_changed_cb(void *data, Evas_Object *obj, void *event)
231 {
232         const char *profile = elm_config_profile_get();
233
234         if (strcmp(profile, "desktop") == 0) {
235                 elm_win_indicator_mode_set(obj, ELM_WIN_INDICATOR_HIDE);
236         } else {
237                 elm_win_indicator_mode_set(obj, ELM_WIN_INDICATOR_SHOW);
238         }
239 }
240
241 /**
242 * To create a win object, the win is shared between the App and all its UGs
243 */
244 static Evas_Object *setting_main_create_win(const char *name)
245 {
246         SETTING_TRACE_BEGIN;
247         LAUNCH_SETTING_IN();
248         Evas_Object *eo;
249         int w, h;
250
251         eo = (Evas_Object *) app_get_preinitialized_window(name);
252         if (!eo)
253                 eo = elm_win_util_standard_add(name, name);
254         else {
255                 /* elm_win_util_standard_add creates bg inside */
256                 Evas_Object *bg;
257
258                 /*bg = elm_bg_add(eo); */
259                 bg = app_get_preinitialized_background();
260                 if (!bg)
261                         bg = elm_bg_add(eo);
262
263
264                 if (!bg) {
265                         evas_object_del(eo);
266                         return NULL;
267                 }
268                 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
269                 elm_win_resize_object_add(eo, bg);
270                 evas_object_show(bg);
271         }
272         if (eo) {
273                 elm_win_title_set(eo, name);
274                 evas_object_smart_callback_add(eo, "delete,request", setting_main_del_win, NULL);
275                 evas_object_smart_callback_add(eo, "profile,changed", profile_changed_cb, NULL);
276                 /*elm_win_conformant_set(eo, EINA_TRUE); */
277                 ecore_x_window_size_get(ecore_x_window_root_first_get(),
278                                         &w, &h);
279                 evas_object_resize(eo, w, h);
280         }
281         LAUNCH_SETTING_OUT();
282         return eo;
283 }
284
285
286 /**
287 * exceptional process, reset the env vars by Setting vconf VCONFKEY_LANGSET
288 */
289 static void setting_main_lang_changed_cb(void *data)
290 {
291         SETTING_TRACE_BEGIN;
292         retm_if(!data, "Invalid argument: data is NULL");
293         /*FIX the crash when switch from Portrait mode to landscape mode, */
294         /*It is so strange the data is no longer correct */
295         /*and ....why it is invoked */
296         /*setting_main_appdata *ad = data; */
297         setting_main_appdata *ad = g_main_ad;
298
299         char *tab_str[] = {
300                 Keystr_Connection,
301                 KeyStr_Device,
302                 KeyStr_MotionControl,
303                 "IDS_ST_BODY_GENERAL",
304                 KeyStr_DownloadedAPPs
305         };
306         int i = 0;
307
308         for (; i < 5; i++) {
309                 /*SETTING_TRACE("_(tab_str[%d]):%s", i, _(tab_str[i])); */
310                 if (ad->ctrl_item[i])
311                         elm_object_item_text_set(ad->ctrl_item[i], _(tab_str[i]));
312         }
313
314         char *tmp = NULL;
315         if (ad->data_bright) {
316                 tmp = ad->data_bright->sub_desc;
317                 ad->data_bright->sub_desc = (char *)g_strdup(get_brightness_mode_str());
318                 FREE(tmp)
319         }
320         if (ad->data_backlight) {
321                 tmp = ad->data_backlight->sub_desc;
322                 ad->data_backlight->sub_desc = get_pa_backlight_time_str();
323                 FREE(tmp)
324         }
325         if (ad->data_screenmode) {
326                 tmp = ad->data_screenmode->sub_desc;
327                 ad->data_screenmode->sub_desc = get_pa_screen_mode_str();
328                 FREE(tmp)
329         }
330
331         Eina_List *list, *l;
332         Elm_Object_Item *it;
333         i = SETTING_TAB_VIEW_INVALID;
334         for (i = SETTING_TAB_VIEW_QUICK_SETTINGS; i < SETTING_TAB_VIEW_MAX; i++) {
335                 if (ad->sub_view[i]) {
336                         list = elm_genlist_realized_items_get(ad->sub_view[i]);
337                         EINA_LIST_FOREACH(list, l, it) {
338                                 __add_gl_tts_feature(it);
339                                 elm_genlist_item_update(it);
340                         }
341                 }
342         }
343
344
345         /* update all tabs */
346         for (i = SC_All_List; i < SC_Max; i++) {
347                 /*if (ad->sc_gl[i]) elm_genlist_realized_items_update(ad->sc_gl[i]); */
348                 if (ad->sc_gl[i]) {
349                         list = elm_genlist_realized_items_get(ad->sc_gl[i]);
350                         EINA_LIST_FOREACH(list, l, it) {
351                                 __add_gl_tts_feature(it);
352                                 elm_genlist_item_update(it);
353                         }
354                 }
355         }
356         /* For UGs */
357
358         elm_object_item_part_text_set(ad->main_navi_it, "elm.text.title", _("IDS_ST_OPT_SETTINGS"));
359         setting_navi_items_update(ad->navibar_main);
360
361         if (ad->isInUGMode && ad->ug) {
362                 Evas_Object *layout = (Evas_Object *)ug_get_layout(ad->ug);
363                 if (layout) {
364                         Evas_Object *navi_bar = NULL;
365                         navi_bar = elm_object_part_content_get(layout, "elm.swallow.content");
366                         setting_navi_items_update(navi_bar);
367                 }
368                 ug_send_event(UG_EVENT_LANG_CHANGE);
369         }
370
371 }
372
373 static Eina_Bool __update_gengrid_delayer(void *data)
374 {
375         SETTING_TRACE_BEGIN;
376         setting_main_appdata *ad = data;
377         retvm_if(!data, ECORE_CALLBACK_CANCEL, "Invalid argument: data is NULL");
378         if (ad->gengrid) {
379                 elm_gengrid_realized_items_update(ad->gengrid);
380         }
381         /*After return False, the idler will be deleted directly,so here set ad->set_idler as NULL directly. */
382         ad->update_idler = NULL;
383         return ECORE_CALLBACK_CANCEL;
384 }
385
386 /**
387 * the event process when other VCONFS changes
388 */
389 static void setting_other_vconf_change_cb(keynode_t *key, void *data)
390 {
391         setting_main_appdata *ad = data;
392         retm_if(!data, "Invalid argument: data is NULL");
393
394         Setting_GenGroupItem_Data *item_to_update = NULL;
395         char *vconf_name = vconf_keynode_get_name(key);
396         SETTING_TRACE("the value of [ %s ] just changed", vconf_name);
397         int i = 0;
398
399         if (!safeStrCmp(vconf_name, VCONFKEY_TELEPHONY_FLIGHT_MODE)) {
400                 int flightmode = 0;
401                 vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flightmode);
402                 /*Flight mode is ON : Network menu dimmed */
403                 SETTING_TRACE("vconf flight [%d]", flightmode);
404                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
405                         setting_genlist_item_disabled_set(ad->gl_data_item[i][GL_Network], flightmode);
406                         setting_genlist_item_disabled_set(ad->gl_data_item[i][GL_PM], flightmode);
407                         item_to_update = ad->gl_data_item[i][GL_FlightMode];
408                         if (item_to_update) {
409                                 item_to_update->chk_status = flightmode;
410                                 const char *tmp = item_to_update->l_swallow_path;
411                                 SETTING_TRACE("status:%d", flightmode);
412                                 if (!flightmode) {
413                                         item_to_update->l_swallow_path = (char *)g_strdup(SETTING_ICON_PATH_CFG"settings_flightoff1.png");
414                                 } else {
415                                         item_to_update->l_swallow_path = (char *)g_strdup(SETTING_ICON_PATH_CFG"A01-1_icon_Flight_Mode.png");
416                                 }
417                                 G_FREE(tmp);
418
419                                 elm_genlist_item_fields_update(item_to_update->item, "*", ELM_GENLIST_ITEM_FIELD_CONTENT);
420                         }
421
422                 }
423
424                 SETTING_TRACE_END;
425                 return;
426 #if SUPPORT_NETWORK_RESTRICTION
427         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE)) {
428                 int status = 0;
429                 vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &status);
430
431                 /* Update network restriction mode UI */
432                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
433                         setting_genlist_item_disabled_set(ad->gl_data_item[i][GL_MobileApp], status);
434                         setting_genlist_item_disabled_set(ad->gl_data_item[i][GL_WiFi], status);
435                         setting_force_update_gl_item_chk_status(ad->gl_data_item[i][GL_NetRestriction], status);
436                 }
437
438                 return;
439 #endif
440         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL)) {
441                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
442                 int status = 0;
443                 vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &status);
444                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
445                         setting_force_update_gl_item_chk_status(ad->gl_data_item[i][GL_Landscape], status);
446                 }
447
448                 if (status) {
449                         int angle = elm_win_rotation_get(ad->win_main);
450                         elm_win_rotation_with_resize_set(ad->win_main, angle);
451                 } else {
452                         elm_win_rotation_with_resize_set(ad->win_main, 0);
453                 }
454                 return;
455         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_WALLPAPER_APPLY_COLORTHEME_BOOL)) {
456 #if 0
457                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
458                 int status = 0;
459                 vconf_get_bool(VCONFKEY_SETAPPL_WALLPAPER_APPLY_COLORTHEME_BOOL, &status);
460
461                 /* only work if status = 1, else it skip the procedure */
462                 if (status == 0)
463                         return;
464
465                 char *homescreen_path = NULL;
466                 int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, &homescreen_path);
467                 SETTING_TRACE("current homescreen_path : (%s) ", homescreen_path);
468
469                 /*----------------------------------------------------------------------------------------------- */
470                 /* homescreen_path */
471                 int i;
472                 int theme_index = 0;            /* default = 0 */
473
474                 int *pcolor = mp_collect_color_set_image(homescreen_path, 1);
475                 SETTING_TRACE("******************************************************");
476                 SETTING_TRACE(" (homescreen: %s) -- mp_collect_color_set_image: (%d) ", homescreen_path, *pcolor);
477                 int *rgb = mp_collect_color_get_RGB(pcolor, 1);
478                 SETTING_TRACE("r=%d, g=%d, b=%d", rgb[0], rgb[1], rgb[2]);
479                 FREE(pcolor);
480                 theme_index = ea_theme_suitable_theme_get(rgb[0], rgb[1], rgb[2]);
481                 SETTING_TRACE(" (theme index: %d) - ea_theme_suitable_theme_get", theme_index);
482                 SETTING_TRACE("******************************************************");
483
484                 /*----------------------------------------------------------------------------------------------- */
485                 /* function call with the index & vconf set */
486                 vconf_set_int(VCONFKEY_SETAPPL_CHANGE_UI_THEME_INT, theme_index);
487                 /* LOGIC HERE */
488                 Eina_Bool result = ea_theme_input_colors_set(theme_index);
489                 if (result == EINA_TRUE) {
490                         ea_theme_system_colors_apply();
491                 }
492 #endif
493                 return;
494
495         } else if (!safeStrCmp(vconf_name, VCONFKEY_NFC_STATE)) {
496                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
497                 if (ad->nfc_timer) {
498                         ecore_timer_del(ad->nfc_timer);
499                         ad->nfc_timer = NULL;
500                 }
501
502                 int status = 0;
503                 vconf_get_bool(VCONFKEY_NFC_STATE, &status);
504
505                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
506                         item_to_update = ad->gl_data_item[i][GL_NFC];
507                         if (item_to_update) {
508                                 item_to_update->swallow_type = SWALLOW_Type_1ICON_1RADIO;
509                                 item_to_update->chk_status = status;
510                                 elm_object_item_data_set(item_to_update->item, item_to_update);
511                                 elm_genlist_item_fields_update(item_to_update->item, "elm.icon.2", ELM_GENLIST_ITEM_FIELD_CONTENT);
512                         }
513                 }
514
515                 if (!status) {
516                         int sbeam_status = 0;
517                         vconf_get_bool(VCONFKEY_NFC_SBEAM, &sbeam_status);
518                         if (sbeam_status) {
519                                 vconf_set_bool(VCONFKEY_NFC_SBEAM, !sbeam_status);
520                         }
521                 }
522         } else if (!safeStrCmp(vconf_name, VCONFKEY_NFC_SBEAM)) {
523                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
524
525                 int status = 0;
526                 vconf_get_bool(VCONFKEY_NFC_SBEAM, &status);
527                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
528                         item_to_update = ad->gl_data_item[i][GL_SBeam];
529                         if (item_to_update) {
530                                 item_to_update->chk_status = status;
531                                 elm_genlist_item_fields_update(item_to_update->item, "elm.icon.2", ELM_GENLIST_ITEM_FIELD_CONTENT);
532                         }
533                 }
534
535         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_DM_DRIVING_MODE)) {
536                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
537                 /* cfg set_item_state has do the work, need to del it, or it will be a issue */
538
539                 int status = 0;
540                 vconf_get_bool(VCONFKEY_SETAPPL_DM_DRIVING_MODE, &status);
541                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
542                         item_to_update = ad->gl_data_item[i][GL_DM];
543                         setting_force_update_gl_item_chk_status(item_to_update, status);
544                 }
545 #if SUPPORT_POWERSAVING
546         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS)) {
547                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
548                 int status = 0;
549                 vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &status);
550                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
551                         item_to_update = ad->gl_data_item[i][GL_PM];
552                         setting_force_update_gl_item_chk_status(item_to_update, status);
553                 }
554 #endif
555 #if SUPPORT_BLOCKINGMODE
556         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE)) {
557                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
558                 int status = 0;
559                 vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, &status);
560                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
561                         item_to_update = ad->gl_data_item[i][GL_BM];
562                         setting_force_update_gl_item_chk_status(item_to_update, status);
563                 }
564 #endif
565 #if SUPPORT_PERSONALPAGE
566         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_PERSONAL_MODE_STATUS_BOOL)) {
567                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
568
569                 int status = 0;
570                 vconf_get_bool(VCONFKEY_SETAPPL_PERSONAL_MODE_STATUS_BOOL, &status);
571
572                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
573                         item_to_update = ad->gl_data_item[i][GL_PersonalPage];
574                         setting_force_update_gl_item_chk_status(item_to_update, status);
575                 }
576 #endif
577 #if SUPPORT_GUESTMODE
578         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_GM_GUEST_MODE)) {
579                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
580                 int status = 0;
581                 vconf_get_bool(VCONFKEY_SETAPPL_GM_GUEST_MODE, &status);
582
583                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
584                         item_to_update = ad->gl_data_item[i][GL_GuestMode];
585                         setting_force_update_gl_item_chk_status(item_to_update, status);
586                 }
587 #endif
588         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_ACCESSIBILITY_TTS)) {
589                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
590                 SETTING_TRACE_DEBUG(" TTS update genlist -------------- portrait ");
591                 SETTING_TRACE_DEBUG(" TTS update genlist -------------- landscape ");
592                 /*ad->isTopUpdate = true; */
593                 SETTING_TRACE("...........");
594                 /*elm_gengrid_realized_items_update(ad->gengrid); */
595
596                 if (ad->update_idler) {
597                         ecore_timer_del(ad->update_idler);
598                         ad->update_idler = NULL;
599                 }
600                 ad->update_idler = ecore_timer_add(0.5, (Ecore_Task_Cb) __update_gengrid_delayer, ad);
601
602         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_SOUND_STATUS_BOOL)
603                    || !safeStrCmp(vconf_name, VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL)) {
604         } else if (!safeStrCmp(vconf_name, VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED)) {
605                 int status = -1;
606                 vconf_get_bool(VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED, &status);
607
608                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
609                         item_to_update = ad->gl_data_item[i][GL_MultiWin];
610                         setting_force_update_gl_item_chk_status(item_to_update, status);
611                 }
612         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE)) {
613                 /*int dev_op_state = 0; */
614 #ifndef BINARY_RELEASE_TYPE_ENG
615                 /*for user binary: need to check develop_option_state vconf value*/
616                 if (ad->sub_view[SETTING_TAB_VIEW_GENERAL]) {
617                         SETTING_TRACE("redraw Gernel Tab");
618                         evas_object_del(ad->sub_view[SETTING_TAB_VIEW_GENERAL]);
619                         ad->sub_view[SETTING_TAB_VIEW_GENERAL] = NULL;
620                 }
621
622                 setting_search_genlist_update(ad);
623 #endif
624
625         }  else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_ENHANCED_TOUCH)) {
626                 int status = 0;
627                 vconf_get_bool(VCONFKEY_SETAPPL_ENHANCED_TOUCH, &status);
628
629                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
630                         SETTING_TRACE("ad->gl_data_item[%d][GL_TouchSens]:%p", i, ad->gl_data_item[i][GL_TouchSens]);
631                         item_to_update = ad->gl_data_item[i][GL_TouchSens];
632                         setting_force_update_gl_item_chk_status(item_to_update, status);
633                 }
634         }
635 }
636
637 /**
638 * the event process when int VCONFS changes
639 * @todo code clean - it has big if-else structure
640 */
641 static void setting_int_vconf_change_cb(keynode_t *key, void *data)
642 {
643         setting_main_appdata *ad = data;
644         retm_if(!data, "Invalid argument: data is NULL");
645
646         int status = vconf_keynode_get_int(key);
647         char *vconf_name = vconf_keynode_get_name(key);
648         SETTING_TRACE("Enter %s(%s=%d)", __FUNCTION__, vconf_name, status);
649
650         Setting_GenGroupItem_Data *item_to_update = NULL;
651         int i = 0;
652         if (!safeStrCmp(vconf_name, VCONFKEY_WIFI_STATE)) {
653                 /* do handling in case of VCONFKEY_WIFI_STATE */
654                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
655                 SETTING_TRACE("status:%d", status);
656                 int on_off_state = EINA_FALSE;
657                 switch (status) {
658                         case VCONFKEY_WIFI_OFF:
659                                 on_off_state = EINA_FALSE;
660                                 break;
661
662                         case VCONFKEY_WIFI_UNCONNECTED: {
663                                         /*item_to_update->chk_status = EINA_FALSE; */
664                                         /*item_to_update->swallow_type = SWALLOW_Type_1ICON_1PROCESS; */
665                                         /*elm_object_item_data_set(item_to_update->item, item_to_update); */
666                                         /*elm_genlist_item_update(item_to_update->item); */
667                                         /*return; */
668                                         bool last_state = FALSE;
669                                         int r = preference_get_boolean(WIFI_LAST_ON_OFF_STATE, &last_state);
670                                         if (0 != r) {
671                                                 SETTING_TRACE("ERROR, r:%d", r);
672                                         }
673                                         char *ap_name = vconf_get_str(VCONFKEY_WIFI_CONNECTED_AP_NAME);
674                                         SETTING_TRACE("Connect AP:%s", ap_name);
675                                         if (last_state) {
676                                                 /*on -> off */
677                                                 SETTING_TRACE("on -> off");
678                                                 if (isEmptyStr(ap_name)) {
679                                                         if (OP_WIFI_TURNING_ON == ad->wifi_op
680                                                             || OP_WIFI_TURNING_OFF == ad->wifi_op) {
681                                                                 SETTING_TRACE("Operating in Setting(ad->wifi_op:%d)", ad->wifi_op);
682                                                                 /*ad->wifi_op = OP_WIFI_TURNING_INVALID; */
683                                                                 /*on_off_state = EINA_FALSE; */
684                                                                 return;
685                                                         } else {
686                                                                 SETTING_TRACE("Operating in Other App");
687                                                                 return;
688                                                         }
689                                                 } else {
690                                                         on_off_state = EINA_FALSE;
691                                                 }
692                                         } else {
693                                                 /*off -> on */
694                                                 SETTING_TRACE("off -> on");
695                                                 on_off_state = EINA_TRUE;
696                                         }
697                                         break;
698                                 }
699                         case VCONFKEY_WIFI_CONNECTED:
700                         case VCONFKEY_WIFI_TRANSFER:
701
702                                 on_off_state = EINA_TRUE;
703                                 break;
704                         default:
705                                 SETTING_TRACE_ERROR("Invalid wifi status!");
706                                 return;
707                 }
708                 ad->wifi_op = OP_WIFI_TURNING_INVALID;
709                 if (ad->wifi_timer) {
710                         ecore_timer_del(ad->wifi_timer);
711                         ad->wifi_timer = NULL;
712                 }
713
714                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
715                         item_to_update = ad->gl_data_item[i][GL_WiFi];
716                         if (item_to_update) {
717
718                                 item_to_update->chk_status = on_off_state;
719                                 item_to_update->swallow_type = SWALLOW_Type_1ICON_1RADIO;
720                                 elm_object_item_data_set(item_to_update->item, item_to_update);
721                                 elm_genlist_item_update(item_to_update->item);
722                         }
723                 }
724                 preference_set_boolean(WIFI_LAST_ON_OFF_STATE, on_off_state);
725         } else if (!safeStrCmp(vconf_name, VCONFKEY_CALL_STATE)) {
726                 /* do handling in case of VCONFKEY_CALL_STATE */
727                 /*In call situation : Wi-fi / Tethering / Network menu dimmed */
728                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
729                         status = (VCONFKEY_CALL_OFF != status);
730                         setting_genlist_item_disabled_set(ad->gl_data_item[i][GL_WiFi], status);
731                         setting_genlist_item_disabled_set(ad->gl_data_item[i][GL_MobileApp], status);
732                 }
733
734         } else if (!safeStrCmp(vconf_name, VCONFKEY_BT_STATUS)) {
735                 /* do handling in case of VCONFKEY_BT_STATUS */
736                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
737                 if (ad->bt_timer) {
738                         ecore_timer_del(ad->bt_timer);
739                         ad->bt_timer = NULL;
740                 }
741
742                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
743                         item_to_update = ad->gl_data_item[i][GL_BT];
744                         if (item_to_update) {
745                                 item_to_update->swallow_type = SWALLOW_Type_1ICON_1RADIO;
746                                 item_to_update->chk_status = status;
747                                 elm_object_item_data_set(item_to_update->item, item_to_update);
748                                 elm_genlist_item_fields_update(item_to_update->item, "elm.icon.2", ELM_GENLIST_ITEM_FIELD_CONTENT);
749                         }
750                 }
751
752         } else if (!safeStrCmp(vconf_name, VCONFKEY_ALLSHARE_STATUS)) {
753                 /* do handling in case of VCONFKEY_BT_STATUS */
754                 SETTING_TRACE_DEBUG("%s updated", vconf_name);
755
756                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
757                         item_to_update = ad->gl_data_item[i][GL_NearByDev];
758                         if (item_to_update) {
759                                 item_to_update->swallow_type = SWALLOW_Type_1ICON_1RADIO;
760                                 item_to_update->chk_status = status;
761                                 elm_object_item_data_set(item_to_update->item, item_to_update);
762                                 elm_genlist_item_fields_update(item_to_update->item, "elm.icon.2", ELM_GENLIST_ITEM_FIELD_CONTENT);
763                         }
764                 }
765
766         } else if (!safeStrCmp(vconf_name, VCONFKEY_MOBILE_HOTSPOT_MODE)) {
767         } else if (!safeStrCmp(vconf_name, VCONFKEY_SYSMAN_BATTERY_STATUS_LOW)) {
768                 /* do handling in case of VCONFKEY_SYSMAN_BATTERY_STATUS_LOW */
769                 status  = (status <= VCONFKEY_SYSMAN_BAT_CRITICAL_LOW);
770                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
771                         setting_genlist_item_disabled_set(ad->gl_data_item[i][GL_Bright], status);
772                 }
773
774         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT)) {
775                 /* do handling in case of VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT */
776                 /*update directly */
777                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
778                         item_to_update = ad->gl_data_item[i][GL_Bright];
779                         if (item_to_update) {
780                                 G_FREE(item_to_update->sub_desc);
781                                 item_to_update->sub_desc = (char *)g_strdup(get_brightness_mode_str());
782                                 elm_object_item_data_set(item_to_update->item, item_to_update);
783                                 elm_genlist_item_update(item_to_update->item);
784                         }
785                 }
786         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL)) {
787                 /*update directly */
788                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
789                         item_to_update = ad->gl_data_item[i][GL_Backlight];
790                         if (item_to_update) {
791                                 char backlight_time_str[MAX_DISPLAY_NAME_LEN_ON_UI];
792                                 if (status == 0) {
793                                         snprintf(backlight_time_str, sizeof(backlight_time_str), "%s",
794                                                  _("IDS_ST_BODY_ALWAYS_ON"));
795                                 } else if (status == 60) {
796                                         snprintf(backlight_time_str, sizeof(backlight_time_str), "%s",
797                                                  _("IDS_COM_BODY_1_MINUTE"));
798                                 } else if (status > 60) {
799                                         snprintf(backlight_time_str, sizeof(backlight_time_str),
800                                                  "%d %s", status / 60, (char *)(_("IDS_COM_BODY_MINUTES_LC")));
801                                 } else {
802                                         snprintf(backlight_time_str, sizeof(backlight_time_str),
803                                                  "%d %s", status, (char *)(_("IDS_COM_BODY_SECONDS_LC")));
804                                 }
805                                 SETTING_TRACE("backlight_time_str:%s", backlight_time_str);
806                                 G_FREE(item_to_update->sub_desc);
807                                 item_to_update->sub_desc = (char *)g_strdup(backlight_time_str);
808                                 elm_object_item_data_set(item_to_update->item, item_to_update);
809                                 elm_genlist_item_update(item_to_update->item);
810                         }
811                 }
812         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE)) {
813
814                 /* do nothing */
815
816         } else if (!safeStrCmp(vconf_name, VCONFKEY_SYSMAN_BATTERY_CAPACITY)) {
817         } else {
818                 SETTING_TRACE_ERROR("vconf_name is bad[%s]", vconf_name);
819         }
820
821         return;
822 }
823
824
825 /**
826 * the event process when string VCONFS changes
827 */
828 static void setting_string_vconf_change_cb(keynode_t *key, void *data)
829 {
830         setting_main_appdata *ad = data;
831         retm_if(!data, "Invalid argument: data is NULL");
832
833         char *value = vconf_keynode_get_str(key);
834         char *vconf_name = vconf_keynode_get_name(key);
835         SETTING_TRACE("Enter %s(%s=%s)", __FUNCTION__, vconf_name, value);
836
837         if (!safeStrCmp(vconf_name, VCONFKEY_WIFI_CONNECTED_AP_NAME)) {
838         } /* vconf_name == VCONFKEY_WIFI_CONNECTED_AP_NAME */
839         else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_MOST_RECENTLY_SETTING)) {
840         } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_SCREENMODE_SELNAME)) {
841                 int i;
842                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
843                         Setting_GenGroupItem_Data *item_to_update = ad->gl_data_item[i][GL_Screenmode];
844                         if (item_to_update) {
845                                 char *tmp = item_to_update->sub_desc;
846                                 item_to_update->sub_desc = get_pa_screen_mode_str();
847
848                                 SETTING_TRACE("item_to_update->sub_desc:%s", item_to_update->sub_desc);
849                                 elm_object_item_data_set(item_to_update->item, item_to_update);
850                                 elm_genlist_item_update(item_to_update->item);
851                                 G_FREE(tmp);
852                         }
853                 }
854         } else if (!safeStrCmp(vconf_name, VCONFKEY_BGSET)
855                    || !safeStrCmp(vconf_name, VCONFKEY_IDLE_LOCK_BGSET)) {
856         }
857 }
858
859 bool ___account_subscribe_cb(const char *event_type, int account_id, void *user_data)
860 {
861         SETTING_TRACE_BEGIN;
862         setting_main_appdata *ad = user_data;
863         if (event_type) {
864                 SETTING_TRACE("event_type = %s\n", event_type);
865         }
866         SETTING_TRACE("account id = %d\n", account_id);
867
868         int is_insert = 0;
869         int is_delete = 0;
870
871         if (0 == safeStrCmp(event_type, ACCOUNT_NOTI_NAME_INSERT))
872                 is_insert = 1;
873         if (0 == safeStrCmp(event_type, ACCOUNT_NOTI_NAME_DELETE))
874                 is_delete = 1;
875
876         if (!(is_insert | is_delete))
877                 return TRUE;
878
879         bool need_disconnect = FALSE;
880         char *package_name = NULL;
881         do {
882                 int ret = 0;
883                 ret = account_connect();
884                 if (ret != ACCOUNT_ERROR_NONE) break;
885                 need_disconnect = TRUE;
886
887                 account_h account = NULL;
888                 if (account_create(&account) != ACCOUNT_ERROR_NONE)
889                         break;
890
891                 if (account_query_account_by_account_id(account_id, &account) != ACCOUNT_ERROR_NONE)
892                         break;
893
894                 if (account_get_package_name(account, &package_name) == ACCOUNT_ERROR_NONE) {
895                         SETTING_TRACE("package_name : %s", package_name);
896                 } else {
897                         SETTING_TRACE("failed");
898                 }
899
900                 if (account_destroy(account) != ACCOUNT_ERROR_NONE)
901                         break;
902         } while (0);
903
904         if (need_disconnect)
905                 account_disconnect();
906
907         if (0 != safeStrCmp(package_name, "ims-service")) { /*must from joyn service */
908                 /*SETTING_TRACE(""); */
909                 FREE(package_name);
910                 return TRUE;
911         }
912         FREE(package_name);
913
914
915         int i;
916         Setting_GenGroupItem_Data *item_to_update = NULL;
917         Setting_GenGroupItem_Data *item_parent = NULL;
918         for (i = VIEW_All_List; i < VIEW_Max; i += 3) { /*just for VIEW_All_List and VIEW_Common */
919                 item_to_update = ad->gl_data_item[i][GL_Joyn];
920                 item_parent = ad->gl_data_item[i][GL_WiFi];
921                 if (!item_parent) continue;
922
923                 if (!safeStrCmp(event_type, ACCOUNT_NOTI_NAME_DELETE)) {
924                         if (item_to_update && item_to_update->item) {
925                                 SETTING_TRACE("To remove joyn");
926                                 elm_object_item_del(item_to_update->item);
927                         }
928                         item_to_update = NULL;
929                         setting_genlist_item_groupstyle_set(item_parent, SETTING_GROUP_STYLE_TOP);
930                 } else if (!safeStrCmp(event_type, ACCOUNT_NOTI_NAME_INSERT)) {
931                         if (!item_to_update || !item_to_update->item) {
932                                 SETTING_TRACE("To add joyn");
933                                 item_to_update = (Setting_GenGroupItem_Data *) calloc(1, sizeof(Setting_GenGroupItem_Data));
934                                 setting_retvm_if(item_to_update == NULL, TRUE, "calloc failed");
935                                 item_to_update->keyStr = (char *)g_strdup(KeyStr_Joyn);
936                                 item_to_update->swallow_type = SWALLOW_Type_INVALID;
937                                 item_to_update->userdata = ad;
938                                 item_to_update->l_swallow_path = (char *)g_strdup(IMG_Joyn);
939
940                                 item_to_update->item = elm_genlist_item_insert_before(ad->sub_view[SETTING_TAB_VIEW_CONNECTION],
941                                                                                       &(ad->itc[GENDIAL_Type_1text_1icon_2]),
942                                                                                       item_to_update, NULL,
943                                                                                       item_parent->item, ELM_GENLIST_ITEM_NONE,
944                                                                                       setting_main_click_list_ex_ug_cb,
945                                                                                       "setting-joyn-efl");
946                                 setting_genlist_item_groupstyle_set(item_to_update, SETTING_GROUP_STYLE_TOP);
947                                 setting_genlist_item_groupstyle_set(item_parent, SETTING_GROUP_STYLE_CENTER);
948                         }
949                         /*set back */
950                         if (0 == i) {
951                                 ad->data_joyn = item_to_update;
952                                 __BACK_POINTER_SET(ad->data_joyn);
953                         } else if (1 == i) {
954                                 ad->gl_data_item[VIEW_All_List][GL_Joyn] = item_to_update;
955                                 __BACK_POINTER_SET(ad->gl_data_item[VIEW_All_List][GL_Joyn]);
956                         } else {
957                                 ad->gl_data_item[VIEW_Common][GL_Joyn] = item_to_update;
958                                 __BACK_POINTER_SET(ad->gl_data_item[VIEW_All_List][GL_Joyn]);
959                         }
960                 }
961         }
962
963         return TRUE;
964 }
965 /**
966 * The function is called to create Setting view widgets
967 */
968 static bool setting_main_app_create(void *data)
969 {
970         SETTING_TRACE_BEGIN;
971         LAUNCH_SETTING_IN();
972         SETTING_TRACE_DEBUG("[TIME] 3. it taked %d msec from main to setting_main_app_create ", appcore_measure_time());
973         appcore_measure_start();
974
975         /*elm_config_preferred_engine_set("opengl_x11"); */
976         ug_create_cb(setting_ug_create_cb, NULL);
977
978 #ifdef TIZEN_BUILD_TARGET
979         SETTING_TRACE_DEBUG(" ------------------------> TIZEN_BUILD_TARGET is ON");
980 #endif
981
982 #ifdef TIZEN_BUILD_EMULATOR
983         SETTING_TRACE_DEBUG(" ------------------------> TIZEN_BUILD_EMULATOR is ON");
984 #endif
985
986 #if SUPPORT_DRI
987         setenv("EVAS_DRI_SWAPBUF", "1", 1);
988 #endif
989
990         setting_main_appdata *ad = data;
991         /* regitering sigterm */
992         if (signal(SIGTERM, termination_handler) == SIG_IGN) {
993                 signal(SIGTERM, SIG_IGN);
994         }
995
996 #if 1
997         bundle *b = ad->b;
998         app_control_h svc;
999         app_control_create(&svc);
1000         /*app_control_create_request(b, &svc); */
1001         /*ad->is_searchmode = setting_main_sfinder_handler(svc, ad, NULL); */
1002         app_control_destroy(svc);
1003         svc = NULL;
1004 #endif
1005         /*--------------------------------------------------------------------------------------------- */
1006         ad->data_roaming_popup = NULL;
1007
1008         elm_app_base_scale_set(2.4);
1009
1010         /* create window */
1011         ad->win_main = setting_main_create_win(SETTING_PACKAGE);
1012         setting_retvm_if(ad->win_main == NULL, SETTING_RETURN_FAIL, "window is null");
1013         UG_INIT_EFL(ad->win_main, UG_OPT_INDICATOR_ENABLE);
1014         ad->evas = evas_object_evas_get(ad->win_main);
1015         ad->current_rotation = elm_win_rotation_get(ad->win_main);
1016         SETTING_TRACE_DEBUG("ad->current_rotation:%d", ad->current_rotation);
1017         if (elm_win_wm_rotation_supported_get(ad->win_main)) {
1018                 int rots[4] = { 0, 90, 180, 270 };  /* rotation value that app may want */
1019                 elm_win_wm_rotation_available_rotations_set(ad->win_main, rots, 4);
1020         }
1021         evas_object_smart_callback_add(ad->win_main, "wm,rotation,changed", _rot_changed_cb, ad);
1022
1023         /* load config file */
1024         int cfg_operation_ret = setting_cfg_init();
1025         /*PLUGIN_INIT(ad); */
1026         /*if ( ! ad->is_searchmode) */
1027         /*{ */
1028         elm_theme_extension_add(NULL, SETTING_THEME_EDJ_NAME);
1029         elm_theme_extension_add(NULL, SETTING_NEWUX_EDJ_NAME);
1030         elm_theme_extension_add(NULL, SETTING_GENLIST_EDJ_NAME);
1031         elm_theme_extension_add(NULL, SETTING_NEW_GENLIST_EDJ_NAME);
1032         elm_theme_extension_add(NULL, SETTING_SLIDER_EDJ_NAME);
1033         /*} */
1034
1035         elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_SHOW);
1036         elm_win_indicator_opacity_set(ad->win_main, ELM_WIN_INDICATOR_OPAQUE);
1037
1038         evas_object_show(ad->win_main);
1039
1040         g_main_ad = ad;
1041         setting_view_create(&setting_view_main, ad);
1042
1043         /* error handling */
1044         if (Cfg_Error_Type_Sucess != cfg_operation_ret) {
1045                 SETTING_TRACE_ERROR("cfg_operation_ret: %d", cfg_operation_ret);
1046                 const char *notifyStr = NULL;
1047                 switch (cfg_operation_ret) {
1048
1049                         case Cfg_Error_Type_CreateCfg_Failed: {
1050                                         notifyStr = _("failed to create config file, <br>re-install org.tizen.setting please");
1051                                         break;
1052                                 }
1053                         case Cfg_Error_Type_Mkdir_Failed: {
1054                                         notifyStr = _("file system missed<br>/opt/usr/data/setting, <br>re-install org.tizen.setting please");
1055                                         break;
1056                                 }
1057                         case Cfg_Error_Type_RemoveCfg_Failed: {
1058                                         notifyStr = _("config file size 0 byte<br>and failed to re-create it.<br>try to startup the app again");
1059                                         break;
1060                                 }
1061                         case Cfg_Error_Type_ReadCfg_Failed: {
1062                                         notifyStr = _("failed to read config file, <br>try to startup the app again");
1063                                         break;
1064                                 }
1065                         case Cfg_Error_Type_DirPermissionDenied: {
1066                                         notifyStr =
1067                                             _("the dir of config file permission denied");
1068                                         break;
1069                                 }
1070                         case Cfg_Error_Type_FilePermissionDenied: {
1071                                         notifyStr = _("config file permission denied");
1072                                         break;
1073                                 }
1074                         default: {
1075                                         notifyStr = _("Invalid Result, try to startup the app again");
1076                                         break;
1077                                 }
1078                 }
1079                 setting_create_popup_without_btn(ad, ad->win_main, NULL, (char *)notifyStr, NULL, 10, FALSE, FALSE);
1080                 return SETTING_RETURN_FAIL;
1081         }
1082
1083
1084         ad->theme_table = _changeable_colors_set();
1085
1086         SETTING_TRACE_DEBUG("[TIME] 4. setting_main_app_create taked %d msec ", appcore_measure_time());
1087         appcore_measure_start();
1088         LAUNCH_SETTING_OUT();
1089         return true;
1090 }
1091
1092 /**
1093 * The function is called when Setting is terminated
1094 */
1095 static void setting_main_app_terminate(void *data)
1096 {
1097         SETTING_TRACE_BEGIN;
1098         setting_main_appdata *ad = data;
1099         if (ad->account_subscribe_handle) {
1100                 (void)account_unsubscribe_notification(ad->account_subscribe_handle);
1101         }
1102         vconf_set_bool(VCONFKEY_SETAPPL_ROTATE_HOLD_BOOL, FALSE);
1103         evas_object_smart_callback_del(ad->win_main, "wm,rotation,changed", _rot_changed_cb);
1104
1105
1106         (void)preference_set_int(PREFKEY_VIEW_TYPE, ad->list_type);
1107         (void)preference_set_int(PREFKEY_TAB_VIEW_TAB, ad->view_type);
1108
1109
1110         _changeable_colors_free(ad->theme_table);
1111
1112         /*PLUGIN_FINI; */
1113         setting_cfg_exit();
1114         clear_system_service_data();
1115
1116         ug_destroy_all();
1117         ad->ug = NULL;
1118
1119         ug_create_cb(NULL , NULL);
1120
1121         SETTING_TRACE_DEBUG("%s*** SETTING APPLICATION CLOSED ***%s", SETTING_FONT_BGREEN, SETTING_FONT_BLACK);
1122         DEREGISTER_VCONFS(ad->listened_list);
1123
1124
1125 #if SUPPORT_LCD_TIMEOUT_KEEPING
1126         /* once Setting is not running, LCD_TIMEOUT must be backuped */
1127         int back_value = 0;
1128         vconf_get_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, &back_value);
1129         vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, back_value);
1130 #endif
1131         setting_view_destroy(&setting_view_main, ad);
1132
1133         SETTING_TRACE_DEBUG("!!! After setting_view_destroy");
1134         if (ad->win_main) {
1135                 evas_object_del(ad->win_main);
1136                 ad->win_main = NULL;
1137         }
1138
1139         if (ad->b) {
1140                 bundle_free(ad->b);
1141                 ad->b = NULL;
1142         }
1143
1144         SETTING_TRACE_END;
1145         return;
1146 }
1147
1148 /**
1149 * The function is called when Setting begins run in background from forground
1150 */
1151 static void setting_main_app_pause(void *data)
1152 {
1153         SETTING_TRACE_BEGIN;
1154         setting_main_appdata *ad = data;
1155         if (ad->ug) {
1156                 ug_pause();
1157         }
1158
1159 #if SUPPORT_LCD_TIMEOUT_KEEPING
1160         /* once Setting is running in background, LCD_TIMEOUT must be backuped */
1161         int back_value = 0;
1162         vconf_get_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, &back_value);
1163         vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, back_value);
1164 #endif
1165
1166 }
1167
1168 /**
1169 * The function is called when Setting begins run in forground from background
1170 */
1171 static void setting_main_app_resume(void *data)
1172 {
1173         SETTING_TRACE_BEGIN;
1174         setting_main_appdata *ad = data;
1175
1176 #if SUPPORT_LCD_TIMEOUT_KEEPING
1177         /* once Setting is running in foreground, LCD_TIMEOUT must be reset to 600 */
1178         vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 600);
1179 #endif
1180         _rot_changed_cb(ad, ad->win_main, NULL);/*to fix P131121-02103 */
1181
1182         if (ad->is_searchmode % 10 == Cfg_Item_AppLauncher_Node) {
1183                 /* app-launching exit */
1184                 elm_exit();
1185         }
1186
1187         if (!(ad->isInUGMode && ad->ug)) {      /* top-level view is not on UG */
1188                 SETTING_TRACE("update main genlist in resuming app without UG");
1189                 Eina_Bool is_freezed = evas_object_freeze_events_get(ad->navibar_main);
1190                 SETTING_TRACE_DEBUG("is_freezed : %d", is_freezed);
1191                 if (is_freezed) {
1192                         evas_object_freeze_events_set(ad->navibar_main, EINA_FALSE);
1193                 }
1194
1195                 /* update personal mode toggle */
1196                 Setting_GenGroupItem_Data *item_to_update;
1197                 int status = 0;
1198                 vconf_get_bool(VCONFKEY_SETAPPL_PERSONAL_MODE_STATUS_BOOL, &status);
1199                 int i;
1200                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
1201                         item_to_update = ad->gl_data_item[i][GL_PersonalPage];
1202                         setting_force_update_gl_item_chk_status(item_to_update, status);
1203                 }
1204         } else if (ad->ug) {
1205                 ug_resume();
1206         }
1207 }
1208
1209 static Cfg_Item_Type setting_main_sfinder_handler(app_control_h service, void *data, int (*func)(void *d1))
1210 {
1211         SETTING_TRACE_BEGIN;
1212         setting_main_appdata *ad = data;
1213         Cfg_Item_Type ret_code = Cfg_Item_Node_Error;
1214
1215         /* s finder code */
1216         if (service) {
1217                 char *uri = NULL;
1218
1219                 char *type = NULL;
1220                 char *infostr = NULL;
1221                 char *viewname = NULL;
1222                 char *fieldname = NULL;
1223                 char *title = NULL;
1224                 char *check_value = NULL;
1225
1226                 /*int ret_action = -1; */
1227                 int ret = app_control_get_uri(service, &uri);
1228                 if (APP_CONTROL_ERROR_NONE == ret && uri && !safeStrCmp(uri, S_FINDER_SETTING_STR)) {
1229
1230                         app_control_get_extra_data(service, "type", &type);
1231                         app_control_get_extra_data(service, "infostr", &infostr);
1232                         app_control_get_extra_data(service, "viewname", &viewname);
1233                         app_control_get_extra_data(service, "fieldname", &fieldname);
1234                         app_control_get_extra_data(service, "title", &title);
1235                         app_control_get_extra_data(service, "s_finder_setting_check_value_set", &check_value);
1236
1237                         SETTING_TRACE("-------------------------------------");
1238                         SETTING_TRACE("S-finder launched org.tizen.setting : %s", uri);
1239                         SETTING_TRACE("title %s", title);
1240                         SETTING_TRACE("type %s", type);
1241                         SETTING_TRACE("infostr %s", infostr);
1242                         SETTING_TRACE("viewname %s", viewname);
1243                         SETTING_TRACE("fieldname %s", fieldname);
1244                         SETTING_TRACE("s_finder_setting_check_value_set %s", check_value);
1245                         SETTING_TRACE("-------------------------------------");
1246
1247                         ret_code = setting_search_type(type);
1248
1249                         ListItemObject *plistitem = calloc(1, sizeof(ListItemObject));
1250                         setting_retvm_if(!plistitem, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "plistitem is NULL");
1251
1252                         if (title) {
1253                                 plistitem->title = strdup(title);
1254                                 plistitem->title2 = strdup(title);
1255                         }
1256                         if (type)
1257                                 plistitem->type = strdup(type);
1258                         if (infostr)
1259                                 plistitem->infostr = strdup(infostr);
1260                         if (viewname)
1261                                 plistitem->viewname = strdup(viewname);
1262                         if (fieldname)
1263                                 plistitem->fieldname = strdup(fieldname);
1264                         if (check_value)
1265                                 plistitem->check_value_set = strdup(check_value);
1266
1267                         plistitem->data = ad;
1268
1269                         if (func) {
1270                                 func(plistitem);
1271
1272                                 /* toggle handler */
1273                                 /* switch */
1274                                 int toggle_state = -1;
1275                                 if (!safeStrCmp(check_value, "1")) {
1276                                         toggle_state = 1;
1277                                 } else if (!safeStrCmp(check_value, "0")) {
1278                                         toggle_state = 0;
1279                                 }
1280                                 if (toggle_state >= 0) {
1281                                         Setting_Cfg_Node_T *pnode = get_cfg_node_by_keystr(_(plistitem->title2));
1282                                         if (pnode && pnode->tfunc && pnode->tfunc->set_item_state) {
1283                                                 pnode->tfunc->set_item_state(toggle_state, plistitem, ad);
1284                                                 SETTING_TRACE("OOOOOOOOOO CALL set_item_state from tfunc");
1285                                         } else if (!pnode && plistitem->viewname) {
1286                                                 /* if get_cfg_node_by_keystr returns NULL, search for UG's keyword */
1287                                                 int ret =  setting_search_set_module_item_state(plistitem->title2, plistitem->viewname, toggle_state, NULL);
1288                                                 SETTING_TRACE("---------------------------------------");
1289                                                 SETTING_TRACE(" >>>  ret : %d, state : %d <<< ", ret, toggle_state);
1290                                                 SETTING_TRACE("---------------------------------------");
1291                                         }
1292                                 }
1293                         }
1294                         /* free plistitem */
1295                         FREE(plistitem->title);
1296                         FREE(plistitem->title2);
1297                         FREE(plistitem->type);
1298                         FREE(plistitem->viewname);
1299                         FREE(plistitem->infostr);
1300                         FREE(plistitem->fieldname);
1301                         FREE(plistitem->check_value_set);
1302                         FREE(plistitem);
1303                 } else {
1304                         /* if svc == 0, return the previous status */
1305                         ret_code = ad->is_searchmode;
1306                         SETTING_TRACE(" HERE !!!! >>>> previous ad->is_searchmode = %d ", ad->is_searchmode);
1307                 }
1308                 FREE(title);
1309                 FREE(type);
1310                 FREE(infostr);
1311                 FREE(viewname);
1312                 FREE(fieldname);
1313                 FREE(uri);
1314         } else {
1315                 /* if svc == 0, return the previous status */
1316                 ret_code = ad->is_searchmode;
1317                 SETTING_TRACE(" >>>> previous ad->is_searchmode = %d ", ad->is_searchmode);
1318         }
1319
1320         return ret_code;
1321 }
1322
1323 /**
1324  * The function is called by app-fwk after app_create. It always do the process which cost much time.
1325  */
1326 static void setting_main_app_reset(app_control_h service, void *data)
1327 {
1328         SETTING_TRACE_BEGIN;
1329         setting_main_appdata *ad = data;
1330
1331         if (is_searchmode_app(ad->is_searchmode)) {
1332                 evas_object_hide(ad->view_layout);
1333         } else {
1334                 evas_object_show(ad->view_layout);
1335         }
1336         vconf_callback_fn cb = NULL;
1337
1338         cb = setting_int_vconf_change_cb;
1339         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_BT_STATUS, cb, data);
1340         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_WIFI_STATE, cb, ad);
1341         /*REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_MOBILE_HOTSPOT_MODE, cb, ad); */
1342         /*REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_CALL_STATE, cb, ad); */
1343
1344         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, cb, data);
1345         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, cb, data);
1346         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, cb, data);
1347         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SYSMAN_BATTERY_CAPACITY, cb, data);
1348         /*REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_ALLSHARE_STATUS, cb, data); */
1349
1350
1351         cb = setting_string_vconf_change_cb;
1352         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_WIFI_CONNECTED_AP_NAME, cb, ad);
1353         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_MOST_RECENTLY_SETTING, cb, ad);
1354         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_SCREENMODE_SELNAME, cb, ad);
1355         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_BGSET, cb, ad);
1356         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_IDLE_LOCK_BGSET, cb, ad);
1357
1358         cb = setting_other_vconf_change_cb;
1359         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_USB_MODE_INT, cb, ad);
1360         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, cb, ad);
1361         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_TELEPHONY_FLIGHT_MODE, cb, ad);
1362 #if SUPPORT_NETWORK_RESTRICTION
1363         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, cb, ad);
1364 #endif
1365         /*REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_NFC_STATE, cb, ad); */
1366         /*REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_NFC_SBEAM, cb, ad); */
1367         /*REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_DM_DRIVING_MODE, cb, ad); */
1368 #if SUPPORT_POWERSAVING
1369         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, cb, ad);
1370 #endif
1371         /*REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED, cb, ad); */
1372
1373         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_WALLPAPER_APPLY_COLORTHEME_BOOL, cb, ad);
1374
1375 #if SUPPORT_BLOCKINGMODE
1376         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, cb, ad);
1377 #endif
1378 #if SUPPORT_GUESTMODE
1379         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_GM_GUEST_MODE, cb, ad);
1380 #endif
1381
1382         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, cb, ad);
1383         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, cb, ad);
1384 #if SUPPORT_PERSONALPAGE
1385         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_PERSONAL_MODE_STATUS_BOOL, cb, ad);
1386         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_PERSONAL_MODE_UNLOCK_METHOD_INT, cb, ad);
1387 #endif
1388         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, cb, ad);
1389 #ifndef BINARY_RELEASE_TYPE_ENG
1390         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, cb, ad);
1391 #endif
1392         REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_ENHANCED_TOUCH, cb, ad);
1393         /*---------------------------------------------------------------------------------- */
1394
1395         /*---------------------------------------------------------------------------------- */
1396
1397         if (ad->win_main) {
1398                 elm_win_activate(ad->win_main);
1399         }
1400         int flight_mode = 0;
1401         vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode);
1402         if (flight_mode) {
1403                 if (ad->data_network) setting_disable_genlist_item(ad->data_network->item);
1404                 if (ad->data_powersaving) setting_disable_genlist_item(ad->data_powersaving->item);
1405         }
1406
1407
1408         /* account - Joyn */
1409         /*account_subscribe_h account_subscribe_handle = NULL; */
1410
1411         /*ad->is_searchmode = setting_main_sfinder_handler(service, ad, setting_search_move_action); */
1412
1413         if (! is_searchmode_app(ad->is_searchmode)) {
1414                 if (ACCOUNT_ERROR_NONE == account_subscribe_create(&(ad->account_subscribe_handle))
1415                     && ad->account_subscribe_handle) {
1416                         (void)account_subscribe_notification(ad->account_subscribe_handle, ___account_subscribe_cb, ad);
1417                 }
1418         }
1419 }
1420
1421 EXPORT_PUBLIC
1422 int main(int argc, char *argv[])
1423 {
1424         int r = 0;
1425         setting_main_appdata ad;
1426
1427         SETTING_TRACE_DEBUG("[TIME] 1. aul_launch -> main :: Setting main : %d msec ", appcore_measure_time_from("APP_START_TIME"));
1428         appcore_measure_start();
1429
1430
1431         app_event_callback_s ops = {
1432                 .create = setting_main_app_create,
1433                 .terminate = setting_main_app_terminate,
1434                 .pause = setting_main_app_pause,
1435                 .resume = setting_main_app_resume,
1436                 .app_control = setting_main_app_reset,
1437                 .low_battery = setting_main_low_battery_cb,
1438                 .language_changed = setting_main_lang_changed_cb,
1439                 .region_format_changed = setting_main_region_changed_cb,
1440                 .device_orientation = NULL,
1441         };
1442
1443
1444         memset(&ad, 0x00, sizeof(setting_main_appdata));
1445
1446         bundle *b = NULL;
1447         b = bundle_import_from_argv(argc, argv);
1448         ad.b = b;
1449
1450         SETTING_TRACE_DEBUG("[TIME] 2. main : %d msec ", appcore_measure_time());
1451         appcore_measure_start();
1452         r = app_efl_main(&argc, &argv, &ops, &ad);
1453         retv_if(r == -1, -1);
1454
1455         return 0;
1456 }