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