4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include <appcore-common.h>
27 #include "setting-plugin.h"
28 #include "setting-main.h"
29 #include <elm_object.h>
32 extern void setting_update_gl_item(void* data);
34 #define KEY_END "XF86Stop"
36 int g_geometry_x, g_geometry_y, g_geometry_w, g_geometry_h;
37 extern int aul_listen_app_dead_signal(int (*func)(int signal, void *data), void *data);
39 static void __main_motion_sensor_cb( unsigned long long timestamp, void *data)
41 /* The code 'return ;' will be deleted after the defect of elm_genlist_item_top_show() is fixed */
43 setting_retm_if(NULL == data, "NULL == data");
45 setting_main_appdata *ad = (setting_main_appdata *) data;
47 SETTING_TRACE(">>>>>>>Double tap event detected");
48 //If it is in UG mode, Setting just send the event to the loaded UG
50 if (ad->isInUGMode && ad->ug) {
51 #ifdef SUPPORT_UG_MESSAGE
52 SETTING_TRACE(">>>>>>>Send event to UG");
55 if(service_create(&svc))
58 service_add_extra_data(svc, "Detected", "Double_tap_event");
59 if (ug_send_message(ad->ug, svc) != 0) {
60 SETTING_TRACE_ERROR("call ug_send_message fail");
65 //Methord: instead of send message to UG and its sub-UGs,
66 //1.To get the layout of UG ,and then
67 //2.To get the naviframe of the layout, and then,
68 //3.To get the toppest item of naviframe, and then
69 //4.To get the content of naviframe toppest item,that is content
70 //5.content ia mainly a genlist,but it is not fixed,it maybe a conformant or another layout
71 // if it is a genlist,directly show its top item
72 // if it is a conformant or another layout,to get all of its sub-objects,then ask turnly
73 // whether it is a genlist,if it is(some sub-object), topply show it.
75 Evas_Object *layout = (Evas_Object *)ug_get_layout(ad->ug);
77 Evas_Object *genlist = NULL;
78 Evas_Object *navi_bar = elm_object_part_content_get(layout, "elm.swallow.content");
79 Elm_Object_Item *item = elm_naviframe_top_item_get(navi_bar);
80 Evas_Object *content = elm_object_item_content_get(item);
81 //SETTING_TRACE("content:%p", content);
83 const char *type = elm_object_widget_type_get(content);
84 SETTING_TRACE("content type:%s", type);
85 if (0 == safeStrCmp(type, "genlist")) {
87 //} else if (0 == safeStrCmp(type, "layout") || 0 == safeStrCmp(type, "conformant")) {
88 } else if (NULL != type) {//type="layout","conformant" etc..
90 //genlist = elm_object_part_content_get(content, "elm.swallow.contents");
91 const Eina_List *subobjs = elm_widget_sub_object_list_get(content);
96 //just only search the first objects level
97 EINA_LIST_FOREACH(subobjs, l, subobj) {
98 if (!subobj) continue;
99 type = elm_object_widget_type_get(subobj);
100 if (0 == safeStrCmp(type, "genlist")) {
102 SETTING_TRACE("Get the genlist:%p", genlist);
103 Elm_Object_Item *first_item = elm_genlist_first_item_get(genlist);
105 elm_genlist_item_show(first_item, ELM_GENLIST_ITEM_SCROLLTO_TOP);
109 return;//to return,because for this case,we need special process.
111 //keep genlist to be NULL.
113 SETTING_TRACE("genlist(:%p) type:%s", genlist, elm_object_widget_type_get(genlist));
114 if (genlist && 0 == safeStrCmp(elm_object_widget_type_get(genlist), "genlist")) {
115 SETTING_TRACE("Get the genlist:%p", genlist);
116 Elm_Object_Item *first_item = elm_genlist_first_item_get(genlist);
118 elm_genlist_item_show(first_item, ELM_GENLIST_ITEM_SCROLLTO_TOP);
124 setting_go_to_navibar_list_top(ad->navibar_main);
129 * The event process when hard key is pressed.
132 static int setting_main_keydown_cb(void *data, int type, void *event)
136 static int s_count = 0;
137 Ecore_Event_Key *ev = event;
138 #if APPLIED_BACK_KEY_UG
139 if (!safeStrCmp(ev->keyname, KEY_END)) {
140 Evas_Object *popup = get_toppest_popup_window(ad->evas);
142 /* "progressbar"ÀàÐ͵Äpopup, ²»×÷´¦Àí */
143 Evas_Object *content = elm_object_content_get(popup);
144 const char *type = elm_widget_type_get(content);
145 if (type && !safeStrCmp(type, "progressbar")) {
147 ("Found popup[%p], but it respresent a progress bar, so skip it.",
150 evas_object_smart_callback_call(popup,
155 /*Evas_Object *popup2 = get_toppest_popup_window(ad->evas);
158 SETTING_TRACE_ERROR("error handling");
159 evas_object_del(popup);
166 if (ad->isInUGMode) { /* have some ug being loaded, it was reset to be FALSE in setting_main_destroy_ug_cb() */
167 SETTING_TRACE("Send UG_KEY_EVENT_END to ug");
168 ug_send_key_event(UG_KEY_EVENT_END);
170 if (elm_naviframe_top_item_get(ad->navibar_main)
171 == elm_naviframe_bottom_item_get(ad->navibar_main)) {
172 SETTING_TRACE("To exit Setting App");
175 SETTING_TRACE("To pre-view of Setting App");
176 elm_naviframe_item_pop(ad->navibar_main);
180 #else /* FOR MWC DEMO 2010.02.07 */
181 if (ev && !safeStrCmp(ev->keyname, KEY_END)) {
182 /* do nothing except exit */
183 SETTING_TRACE("before --- elm_exit ");
186 s_count = s_count + 1;
187 SETTING_TRACE("after --- elm_exit = %d ", s_count);
195 #if LOW_BATTERY_DO_NOTHING
197 /* in case of low battery, don't terminate itself.*/
200 * The event process when battery becomes low.
202 static int setting_main_low_battery_cb(void *data)
205 setting_main_appdata *ad = data;
208 ug_send_event(UG_EVENT_LOW_BATTERY);
214 #if SUPPORT_APP_ROATION
217 * To active rotation effect in Setting App
219 static int setting_main_rotate(enum appcore_rm m, void *data)
222 setting_main_appdata *ad = data;
225 if (ad == NULL || ad->win_main == NULL)
229 case APPCORE_RM_PORTRAIT_NORMAL:
232 case APPCORE_RM_PORTRAIT_REVERSE:
235 case APPCORE_RM_LANDSCAPE_NORMAL:
238 case APPCORE_RM_LANDSCAPE_REVERSE:
247 elm_win_rotation_with_resize_set(ad->win_main, r);
254 * The event process when region is changes.
256 static int setting_main_region_changed_cb(void *data)
258 setting_main_appdata *ad = data;
261 ug_send_event(UG_EVENT_REGION_CHANGE);
267 * The event process when win object is destroyed
269 static void setting_main_del_win(void *data, Evas_Object *obj, void *event)
275 * To create a win object, the win is shared between the App and all its UGs
277 static Evas_Object *setting_main_create_win(const char *name)
283 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
285 elm_win_title_set(eo, name);
286 elm_win_borderless_set(eo, EINA_TRUE);
287 evas_object_smart_callback_add(eo, "delete,request",
288 setting_main_del_win, NULL);
289 ecore_x_window_size_get(ecore_x_window_root_first_get(),
291 evas_object_resize(eo, w, h);
298 * exceptional process, reset the env vars by Setting vconf VCONFKEY_LANGSET
300 static int setting_main_lang_changed_cb(void *data)
303 setting_main_appdata *ad = data;
307 str = (char *)get_pa_Wi_Fi_on_off_str();
308 if ( ! str) str = g_strdup("err");
309 ad->data_wifi->sub_desc = str;
312 str = (char *)g_strdup(get_BT_on_off_str());
313 if ( ! str) str = g_strdup("err");
314 ad->data_bt->sub_desc = str;
317 str = (char *)g_strdup(get_NFC_on_off_str());
318 if ( ! str) str = g_strdup("err");
319 ad->data_nfc->sub_desc = str;
321 if (ad->data_mobileApp) {
322 str = (char *)g_strdup(get_Mobile_AP_on_off_str());
323 if ( ! str) str = g_strdup("err");
324 ad->data_mobileApp->sub_desc = str;
326 if (ad->data_bright) {
327 str = (char*)g_strdup(get_brightness_mode_str());
328 if ( ! str) str = g_strdup("err");
329 ad->data_bright->sub_desc = str;
332 if (ad->data_moreConnect) {
333 char sub_text[MAX_COMMON_BUFFER_LEN] = {0, };
335 while (idx < MAX_MORE_MENU_NUM && ad->more_connective_menus[idx])
339 safeStrNCat(sub_text, ", ", MAX_COMMON_BUFFER_LEN);
341 safeStrNCat(sub_text, _(ad->more_connective_menus[idx]), MAX_COMMON_BUFFER_LEN);
344 ad->data_moreConnect->sub_desc = g_strdup(sub_text);
347 if (ad->data_moreSystem) {
348 char sub_text[MAX_COMMON_BUFFER_LEN] = {0, };
350 while (idx < MAX_MORE_MENU_NUM && ad->more_system_menus[idx])
354 safeStrNCat(sub_text, ", ", MAX_COMMON_BUFFER_LEN);
356 safeStrNCat(sub_text, _(ad->more_system_menus[idx]), MAX_COMMON_BUFFER_LEN);
359 ad->data_moreSystem->sub_desc = g_strdup(sub_text);
362 if (ad->main_genlist) elm_genlist_realized_items_update(ad->main_genlist);
363 if (ad->genlist_load) elm_genlist_realized_items_update(ad->genlist_load);
365 Elm_Object_Item *navi_it = NULL;
366 #if SUPPORT_MORE_ITEM_FUNCTION
367 navi_it = elm_naviframe_top_item_get(ad->navibar_main);
368 if (navi_it) elm_object_item_text_set(navi_it, _(KeyStr_MoreSystem));
371 navi_it = elm_naviframe_bottom_item_get(ad->navibar_main);
373 elm_object_item_text_set(navi_it, _("IDS_COM_BODY_SETTINGS"));
377 #if SUPPORT_BOTTOM_BTNS
378 elm_object_item_text_set(ad->edit_item, _(EDIT_PREFERRED_STR));
380 //elm_object_text_set(ad->edit_item, _(EDIT_PREFERRED_STR));
381 Evas_Object *eo_btn = elm_object_item_part_content_get(ad->edit_item, "object");
382 setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
383 elm_object_text_set(eo_btn, _(EDIT_PREFERRED_STR));
387 if (ad->segment_all) elm_object_item_text_set(ad->segment_all, _(ALL_STR));
388 if (ad->segment_preferred) elm_object_item_text_set(ad->segment_preferred,
391 Elm_Object_Item *item = NULL;
392 item = elm_toolbar_first_item_get(ad->controlbar);
393 setting_retvm_if(!item, SETTING_RETURN_FAIL, "get toolbar first item failed");
394 char tmp_text[MAX_DISPLAY_NAME_LEN_ON_UI + 1] = {0,};
395 if (MAIN_PROFILE_ALL == ad->profile_type) {
396 snprintf(tmp_text, MAX_DISPLAY_NAME_LEN_ON_UI, "%s", _(PREFERRED_STR));
397 } else if (MAIN_PROFILE_PREFERRED == ad->profile_type) {
398 snprintf(tmp_text, MAX_DISPLAY_NAME_LEN_ON_UI, "%s", _(ALL_STR));
402 elm_object_item_text_set(item, tmp_text);
405 ug_send_event(UG_EVENT_LANG_CHANGE);
407 return SETTING_RETURN_SUCCESS;
411 * the event process when other VCONFS changes
413 static void setting_other_vconf_change_cb(keynode_t *key, void *data)
415 setting_main_appdata *ad = data;
416 retm_if(!data, "Invalid argument: data is NULL");
418 Setting_GenGroupItem_Data* item_to_update = NULL;
419 char *vconf_name = vconf_keynode_get_name(key);
420 //SETTING_TRACE("the value of [ %s ] just changed", vconf_name);
422 if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_WIDGET_THEME_STR)) {
424 } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL)) {
425 item_to_update = ad->data_flight;
426 retm_if(!item_to_update, "ad->data_flight is NULL");
429 vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, &status);
430 item_to_update->chk_status = status;
431 if (ad->bAppPause || ad->ug) {
432 ad->updateItems[GL_ITEM_FLIGHT] = EINA_TRUE;
433 } else { // app is not in pause without ug
434 elm_check_state_set(item_to_update->eo_check, status);
437 } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL)) {
438 item_to_update = ad->data_rotationMode;
439 retm_if(!item_to_update, "ad->data_rotationMode is NULL");
442 vconf_get_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, &status);
444 item_to_update->chk_status = !status;
446 if (ad->bAppPause || ad->ug) {
447 ad->updateItems[GL_ITEM_ROTATION] = EINA_TRUE;
448 } else { // app is not in pause without ug
449 elm_check_state_set(item_to_update->eo_check, item_to_update->chk_status);
452 } else if (!safeStrCmp(vconf_name, VCONFKEY_NFC_STATE)) {
453 SETTING_TRACE_DEBUG("%s updated", vconf_name);
454 item_to_update = ad->data_nfc;
455 retm_if(!item_to_update, "ad->data_nfc is NULL");
457 item_to_update->sub_desc = (char *)g_strdup(get_NFC_on_off_str());
459 SETTING_TRACE_DEBUG("%s", item_to_update->sub_desc);
461 if (ad->bAppPause || ad->ug) {
462 ad->updateItems[GL_ITEM_NFC] = EINA_TRUE;
463 } else { // app is not in pause without ug
464 elm_object_item_data_set(item_to_update->item, item_to_update);
465 elm_genlist_item_update(item_to_update->item);
471 * the event process when int VCONFS changes
473 static void setting_int_vconf_change_cb(keynode_t *key, void *data)
475 setting_main_appdata *ad = data;
476 retm_if(!data, "Invalid argument: data is NULL");
478 int status = vconf_keynode_get_int(key);
479 char *vconf_name = vconf_keynode_get_name(key);
480 SETTING_TRACE("Enter %s(%s=%d)", __FUNCTION__, vconf_name, status);
482 char *pa_wifi_device = NULL;
483 Setting_GenGroupItem_Data* item_to_update = NULL;
485 if (!safeStrCmp(vconf_name, VCONFKEY_WIFI_STATE)) {
486 item_to_update = ad->data_wifi;
487 retm_if(!item_to_update, "ad->data_wifi is NULL");
490 case VCONFKEY_WIFI_OFF:
491 item_to_update->sub_desc = (char *)g_strdup(_("IDS_COM_BODY_OFF_M_STATUS"));
494 case VCONFKEY_WIFI_UNCONNECTED:
495 case VCONFKEY_WIFI_CONNECTED:
496 case VCONFKEY_WIFI_TRANSFER:
497 pa_wifi_device = vconf_get_str(VCONFKEY_WIFI_CONNECTED_AP_NAME);
498 if (NULL != pa_wifi_device && '\0' != pa_wifi_device[0]) {
499 item_to_update->sub_desc = (char *)g_strdup(pa_wifi_device);
501 item_to_update->sub_desc = (char *)g_strdup(_("IDS_COM_BODY_ON_M_STATUS"));
503 FREE(pa_wifi_device);
506 SETTING_TRACE_ERROR("Invalid wifi status!");
510 if (ad->bAppPause || ad->ug) {
511 ad->updateItems[GL_ITEM_WIFI] = EINA_TRUE;
512 } else { // app is not in pause without ug
513 elm_object_item_data_set(item_to_update->item, item_to_update);
514 elm_genlist_item_update(item_to_update->item);
516 } else if (!safeStrCmp(vconf_name, VCONFKEY_BT_STATUS)) {
517 item_to_update = ad->data_bt;
518 retm_if(!item_to_update, "ad->data_bt is NULL");
520 if (FALSE == status) {
521 item_to_update->sub_desc = (char *)g_strdup(_("IDS_COM_BODY_OFF_M_STATUS"));
523 item_to_update->sub_desc = (char *)g_strdup(_("IDS_COM_BODY_ON_M_STATUS"));
526 if (ad->bAppPause || ad->ug) {
527 ad->updateItems[GL_ITEM_BT] = EINA_TRUE;
528 } else { // app is not in pause without ug
529 elm_object_item_data_set(item_to_update->item, item_to_update);
530 elm_genlist_item_update(item_to_update->item);
532 } else if (!safeStrCmp(vconf_name, VCONFKEY_MOBILE_HOTSPOT_MODE)) {
533 item_to_update = ad->data_mobileApp;
534 retm_if(!item_to_update, "ad->data_mobileApp is NULL");
536 /* For other vconfs */
537 if (FALSE == status) {
538 item_to_update->sub_desc = (char *)g_strdup(_("IDS_COM_BODY_OFF_M_STATUS"));
540 item_to_update->sub_desc = (char *)g_strdup(_("IDS_COM_BODY_ON_M_STATUS"));
543 if (ad->bAppPause || ad->ug) {
544 ad->updateItems[GL_ITEM_MAP] = EINA_TRUE;
545 } else { // app is not in pause without ug
546 elm_object_item_data_set(item_to_update->item, item_to_update);
547 elm_genlist_item_update(item_to_update->item);
549 } else if (!safeStrCmp(vconf_name, VCONFKEY_SYSMAN_BATTERY_STATUS_LOW)) {
550 if (status <= VCONFKEY_SYSMAN_BAT_CRITICAL_LOW) {
551 if (ad->data_bright) {
552 setting_disable_genlist_item(ad->data_bright->item);
555 if (ad->data_bright) {
556 setting_enable_genlist_item(ad->data_bright->item);
560 }else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT)) {
564 ad->data_bright->sub_desc = (char *)g_strdup(get_brightness_mode_str());
565 elm_object_item_data_set(ad->data_bright->item, ad->data_bright);
566 elm_genlist_item_update(ad->data_bright->item);
569 SETTING_TRACE_ERROR("vconf_name is bad[%s]", vconf_name);
576 * the event process when string VCONFS changes
578 static void setting_string_vconf_change_cb(keynode_t *key, void *data)
581 setting_main_appdata *ad = data;
582 retm_if(!data, "Invalid argument: data is NULL");
584 char *value = vconf_keynode_get_str(key);
585 char *vconf_name = vconf_keynode_get_name(key);
586 Setting_GenGroupItem_Data* item_to_update = NULL;
588 if (!safeStrCmp(vconf_name, VCONFKEY_WIFI_CONNECTED_AP_NAME)) {
590 item_to_update = ad->data_wifi;
591 retm_if(!item_to_update, "ad->data_wifi is NULL");
593 if (0 != vconf_get_int(VCONFKEY_WIFI_STATE, &status)) {
594 SETTING_TRACE_ERROR("vconf_get err: %s", VCONFKEY_WIFI_STATE);
597 SETTING_TRACE("status:%d", status);
599 case VCONFKEY_WIFI_OFF:
600 item_to_update->sub_desc =
601 (char *)g_strdup(setting_gettext ("IDS_COM_BODY_OFF_M_STATUS"));
604 case VCONFKEY_WIFI_UNCONNECTED:
605 case VCONFKEY_WIFI_CONNECTED:
606 case VCONFKEY_WIFI_TRANSFER:
607 if (NULL != value && '\0' != value[0]) {
608 SETTING_TRACE("wifi_device:%s", value);
609 item_to_update->sub_desc = (char *)g_strdup(value);
611 item_to_update->sub_desc =
612 (char *) g_strdup(setting_gettext ("IDS_COM_BODY_ON_M_STATUS"));
616 SETTING_TRACE_ERROR("Invalid wifi status!");
619 if (ad->bAppPause || ad->ug) {
620 ad->updateItems[GL_ITEM_WIFI] = EINA_TRUE;
621 } else { // app is not in pause without ug
622 elm_object_item_data_set(item_to_update->item, item_to_update);
623 elm_genlist_item_update(item_to_update->item);
625 } // vconf_name == VCONFKEY_WIFI_CONNECTED_AP_NAME
630 * Do the process which cost much time
632 static Eina_Bool setting_on_idle_lazy(void *data)
635 setting_main_appdata *ad = data;
637 /* A. add system event callback */
638 if (sensor_create(&ad->sf_handle) != SENSOR_ERROR_NONE) {
639 SETTING_TRACE_ERROR("sensor attach fail");
643 if (sensor_motion_doubletap_set_cb(ad->sf_handle, __main_motion_sensor_cb, ad) != SENSOR_ERROR_NONE) {
644 SETTING_TRACE("sensor_motion_doubletap_set_cb fail to gather data");
647 if (sensor_start(ad->sf_handle, SENSOR_MOTION_DOUBLETAP) != SENSOR_ERROR_NONE) {
648 SETTING_TRACE_ERROR("sensor_start fail");
651 appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE,
652 setting_main_lang_changed_cb, ad);
654 #if LOW_BATTERY_DO_NOTHING
655 appcore_set_event_callback(APPCORE_EVENT_LOW_BATTERY,
656 setting_main_low_battery_cb, ad);
659 appcore_set_event_callback(APPCORE_EVENT_REGION_CHANGE,
660 setting_main_region_changed_cb, ad);
662 #if SUPPORT_APP_ROATION
663 appcore_set_rotation_cb(setting_main_rotate, ad);
664 evas_object_geometry_get(ad->win_main, &g_geometry_x, &g_geometry_y, &g_geometry_w, &g_geometry_h);
671 * The function is called to create Setting view widgets
673 static int setting_main_app_create(void *data)
676 //fprintf(stderr, "[TIME] 3. it taked %d msec from main to setting_main_app_create \n", appcore_measure_time());
677 SETTING_TRACE("[TIME] 3. it taked %d msec from main to setting_main_app_create ", appcore_measure_time());
678 appcore_measure_start();
679 setting_main_appdata *ad = data;
681 ad->data_roaming_popup = NULL;
684 ad->win_main = setting_main_create_win(SETTING_PACKAGE);
685 setting_retvm_if(ad->win_main == NULL, SETTING_RETURN_FAIL, "window is null");
686 evas_object_show(ad->win_main);
687 UG_INIT_EFL(ad->win_main, UG_OPT_INDICATOR_ENABLE);
688 ad->evas = evas_object_evas_get(ad->win_main);
690 /* load config file */
691 int cfg_operation_ret = setting_cfg_init();
694 elm_theme_extension_add(NULL, SETTING_THEME_EDJ_NAME);
695 #if SUPPORT_LCD_TIMEOUT_KEEPING
696 /* to keep according with each other */
697 int origin_backlight_value;
699 vconf_get_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL,
700 &origin_backlight_value)) {
702 vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 30);
703 origin_backlight_value = 30;
705 /* to set intial value */
706 vconf_set_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP,
707 origin_backlight_value);
709 /* Firstly, Setting is running in foreground, LCD_TIMEOUT must be 600s(/10m) */
710 vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 600);
713 elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_SHOW);
715 setting_view_create(&setting_view_main, ad);
716 setting_view_node_table_register(&setting_view_main, NULL);
717 setting_view_node_table_register(&setting_view_more_menu, &setting_view_main);
720 if (Cfg_Error_Type_Sucess != cfg_operation_ret) {
721 SETTING_TRACE_ERROR("cfg_operation_ret: %d", cfg_operation_ret);
722 const char *notifyStr = NULL;
723 switch (cfg_operation_ret) {
725 case Cfg_Error_Type_CreateCfg_Failed:
727 notifyStr = _("failed to create config file, <br>re-install org.tizen.setting please");
730 case Cfg_Error_Type_Mkdir_Failed:
732 notifyStr = _("file system missed<br>/opt/data/setting, <br>re-install org.tizen.setting please");
735 case Cfg_Error_Type_RemoveCfg_Failed:
737 notifyStr = _("config file size 0 byte<br>and failed to re-create it.<br>try to startup the app again");
740 case Cfg_Error_Type_ReadCfg_Failed:
742 notifyStr = _("failed to read config file, <br>try to startup the app again");
745 case Cfg_Error_Type_DirPermissionDenied:
748 _("the dir of config file permission denied");
751 case Cfg_Error_Type_FilePermissionDenied:
753 notifyStr = _("config file permission denied");
758 notifyStr = _("Invalid Result, try to startup the app again");
762 setting_create_popup_without_btn(ad, ad->win_main, NULL, (char *)notifyStr, NULL, 10, FALSE, FALSE);
763 return SETTING_RETURN_FAIL;
765 //fprintf(stderr, "[TIME] 4. setting_main_app_create taked %d msec \n", appcore_measure_time());
766 SETTING_TRACE("[TIME] 4. setting_main_app_create taked %d msec ", appcore_measure_time());
767 appcore_measure_start();
773 * The function is called when Setting is terminated
775 static int setting_main_app_terminate(void *data)
778 setting_main_appdata *ad = data;
781 clear_system_service_data();
786 SETTING_TRACE("%s*** SETTING APPLICATION CLOSED ***%s",
787 SETTING_FONT_BGREEN, SETTING_FONT_BLACK);
789 DEREGISTER_VCONFS(ad->listened_list);
791 if (sensor_motion_doubletap_unset_cb(ad->sf_handle) != SENSOR_ERROR_NONE) {
792 SETTING_TRACE("sensor_motion_doubletap_unset_cb fail to gather data");
794 sensor_stop(ad->sf_handle, SENSOR_MOTION_DOUBLETAP);
795 sensor_destroy(ad->sf_handle);
797 #if SUPPORT_LCD_TIMEOUT_KEEPING
798 /* once Setting is not running, LCD_TIMEOUT must be backuped */
800 vconf_get_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, &back_value);
801 vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, back_value);
803 setting_view_destroy(&setting_view_more_menu, ad);
804 setting_view_destroy(&setting_view_main, ad);
805 SETTING_TRACE("!!! After setting_view_destroy");
807 evas_object_del(ad->win_main);
816 * The function is called when Setting begins run in background from forground
818 static int setting_main_app_pause(void *data)
821 setting_main_appdata *ad = data;
823 ad->bAppPause = EINA_TRUE;
827 #if SUPPORT_LCD_TIMEOUT_KEEPING
828 /* once Setting is running in background, LCD_TIMEOUT must be backuped */
830 vconf_get_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, &back_value);
831 vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, back_value);
834 sensor_stop(ad->sf_handle, SENSOR_MOTION_DOUBLETAP);
840 * The function is called when Setting begins run in forground from background
842 static int setting_main_app_resume(void *data)
845 setting_main_appdata *ad = data;
847 if (sensor_start(ad->sf_handle, SENSOR_MOTION_DOUBLETAP) != SENSOR_ERROR_NONE) {
848 SETTING_TRACE_ERROR("sf_start fail");
854 #if SUPPORT_LCD_TIMEOUT_KEEPING
855 /* once Setting is running in foreground, LCD_TIMEOUT must be reset to 600 */
856 vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 600);
859 // update main genlist in resuming app.
860 ad->bAppPause = EINA_FALSE;
861 if(!ad->ug) { // top-level view is not on UG
862 SETTING_TRACE("update main genlist in resuming app without UG");
863 setting_update_gl_item(ad); // update genlist sub-texts
870 * The function is called by app-fwk after app_create. It always do the process which cost much time.
872 static int setting_main_app_reset(service_h service, void *data)
875 setting_main_appdata *ad = data;
877 #if SUPPORT_LIVEBOX_DEMO
878 char *ug_name = NULL;
881 ug_name = (char*)appsvc_get_data(b, "ug");
884 SETTING_TRACE_DEBUG("get ug_name : %s", ug_name);
885 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
886 setting_retm_if(!cbs, "calloc failed");
887 cbs->layout_cb = setting_main_layout_ug_cb;
888 cbs->result_cb = setting_main_result_ug_cb;
889 cbs->destroy_cb = setting_main_destroy_ug_cb;
890 cbs->priv = (void *)ad;
892 char *path = get_ug_path_from_ug_args(data);
893 service_h svc = get_bundle_from_ug_args(data);
894 ad->ug = ug_create(NULL, ug_name, UG_MODE_FULLVIEW, svc, cbs);
896 ad->isInUGMode = TRUE;
899 evas_object_show(ad->ly_main);
901 SETTING_TRACE_ERROR("errno:%d", errno);
902 setting_create_simple_popup(ad, ad->win_main, NULL, NO_UG_FOUND_MSG);
910 service_destroy(svc);
914 SETTING_TRACE_DEBUG("ug_name is NULL");
919 SETTING_TRACE_DEBUG("bundle is NULL");
922 vconf_callback_fn cb = NULL;
924 cb = setting_int_vconf_change_cb;
925 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_BT_STATUS, cb, data);
926 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_WIFI_STATE, cb, ad);
927 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_MOBILE_HOTSPOT_MODE, cb, ad);
928 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, cb, ad);
929 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, cb, data);
931 cb = setting_string_vconf_change_cb;
932 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_WIFI_CONNECTED_AP_NAME, cb, ad);
934 cb = setting_other_vconf_change_cb;
935 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_USB_MODE_INT, cb, ad);
936 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_WIDGET_THEME_STR, cb, ad);
938 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, cb, ad);
939 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, cb, ad);
940 REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_NFC_STATE, cb, ad);
943 elm_win_activate(ad->win_main);
945 ecore_idler_add(setting_on_idle_lazy, ad);
947 //fprintf(stderr, "[TIME] 5. app_create -> app_resume (first display) : %d msec\n", appcore_measure_time());
948 SETTING_TRACE("[TIME] 5. app_create -> app_resume (first display) : %d msec", appcore_measure_time());
949 //fprintf(stderr, "[TIME] Total. aul_launch -> app_resume (first display) : %d msec\n", appcore_measure_time_from("APP_START_TIME"));
950 SETTING_TRACE("[TIME] Total. aul_launch -> app_resume (first display) : %d msec", appcore_measure_time_from("APP_START_TIME"));
955 int main(int argc, char *argv[])
958 setting_main_appdata ad;
960 elm_init(argc, argv);
961 #if SUPPORT_GL_ENGINE
962 // opengl_x11 or software_x11
963 elm_config_engine_set("software_x11");
966 //fprintf(stderr, "[TIME] 1. aul_launch -> main :: Setting main : %d msec \n", appcore_measure_time_from("APP_START_TIME"));
967 SETTING_TRACE("[TIME] 1. aul_launch -> main :: Setting main : %d msec ", appcore_measure_time_from("APP_START_TIME"));
968 appcore_measure_start();
970 struct appcore_ops ops = {
971 .create = setting_main_app_create,
972 .terminate = setting_main_app_terminate,
973 .pause = setting_main_app_pause,
974 .resume = setting_main_app_resume,
975 .reset = setting_main_app_reset,
978 memset(&ad, 0x0, sizeof(setting_main_appdata));
981 //fprintf(stderr, "[TIME] 2. main : %d msec \n", appcore_measure_time());
982 SETTING_TRACE("[TIME] 2. main : %d msec ", appcore_measure_time());
983 appcore_measure_start();
984 r = appcore_efl_main(SETTING_PACKAGE, &argc, &argv, &ops);
985 retv_if(r == -1, -1);