Fix N_SE-13547 and N_SE-13516
[apps/core/preloaded/settings.git] / src / setting.c
index 192edcf..c702afb 100755 (executable)
@@ -19,6 +19,8 @@
  *
  */
 #include <setting.h>
+#include <app.h>
+
 #include <appcore-common.h>
 #include <heynoti.h>
 #include <Ecore_X.h>
@@ -41,7 +43,6 @@ static void __main_motion_sensor_cb( unsigned long long timestamp, void *data)
        /* The code 'return ;' will be deleted after the defect of elm_genlist_item_top_show() is fixed */
 
        setting_retm_if(NULL == data, "NULL == data");
-       SETTING_TRACE_BEGIN;
        setting_main_appdata *ad = (setting_main_appdata *) data;
 
        SETTING_TRACE(">>>>>>>Double tap event detected");
@@ -81,7 +82,7 @@ static void __main_motion_sensor_cb( unsigned long long timestamp, void *data)
                        //SETTING_TRACE("content:%p", content);
 
                        const char *type = elm_object_widget_type_get(content);
-                       SETTING_TRACE("content type:%s", type);
+                       //SETTING_TRACE("content type:%s", type);
                        if (0 == safeStrCmp(type, "genlist")) {
                                genlist = content;
                        //} else if (0 == safeStrCmp(type, "layout") || 0 == safeStrCmp(type, "conformant")) {
@@ -99,7 +100,7 @@ static void __main_motion_sensor_cb( unsigned long long timestamp, void *data)
                                        type = elm_object_widget_type_get(subobj);
                                        if (0 == safeStrCmp(type, "genlist")) {
                                                genlist = subobj;
-                                               SETTING_TRACE("Get the genlist:%p", genlist);
+                                               //SETTING_TRACE("Get the genlist:%p", genlist);
                                                Elm_Object_Item *first_item = elm_genlist_first_item_get(genlist);
                                                if (first_item) {
                                                        elm_genlist_item_show(first_item, ELM_GENLIST_ITEM_SCROLLTO_TOP);
@@ -110,7 +111,7 @@ static void __main_motion_sensor_cb( unsigned long long timestamp, void *data)
                        } else {
                                //keep genlist to be NULL.
                        }
-                       SETTING_TRACE("genlist(:%p) type:%s", genlist, elm_object_widget_type_get(genlist));
+                       //SETTING_TRACE("genlist(:%p) type:%s", genlist, elm_object_widget_type_get(genlist));
                        if (genlist && 0 == safeStrCmp(elm_object_widget_type_get(genlist), "genlist")) {
                                SETTING_TRACE("Get the genlist:%p", genlist);
                                Elm_Object_Item *first_item = elm_genlist_first_item_get(genlist);
@@ -199,15 +200,13 @@ static int setting_main_keydown_cb(void *data, int type, void *event)
 /**
 * The event process when battery becomes low.
 */
-static int setting_main_low_battery_cb(void *data)
+static void setting_main_low_battery_cb(void *data)
 {
        SETTING_TRACE_BEGIN;
        setting_main_appdata *ad = data;
 
        if (ad->ug)
                ug_send_event(UG_EVENT_LOW_BATTERY);
-
-       return 0;
 }
 #endif
 
@@ -216,51 +215,27 @@ static int setting_main_low_battery_cb(void *data)
 /**
 * To active rotation effect in Setting App
 */
-static int setting_main_rotate(enum appcore_rm m, void *data)
+static void setting_main_rotate(enum appcore_rm m, void *data)
 {
        SETTING_TRACE_BEGIN;
        setting_main_appdata *ad = data;
-       int r;
 
        if (ad == NULL || ad->win_main == NULL)
-               return 0;
-
-       switch (m) {
-       case APPCORE_RM_PORTRAIT_NORMAL:
-               r = 0;
-               break;
-       case APPCORE_RM_PORTRAIT_REVERSE:
-               r = 180;
-               break;
-       case APPCORE_RM_LANDSCAPE_NORMAL:
-               r = 270;
-               break;
-       case APPCORE_RM_LANDSCAPE_REVERSE:
-               r = 90;
-               break;
-       default:
-               r = -1;
-               break;
-       }
-
-       if (r >= 0)
-               elm_win_rotation_with_resize_set(ad->win_main, r);
+               return;
 
-       return 0;
+       elm_win_rotation_with_resize_set(ad->win_main, m);
 }
 #endif
 
 /**
 * The event process when region is changes.
 */
-static int setting_main_region_changed_cb(void *data)
+static void setting_main_region_changed_cb(void *data)
 {
        setting_main_appdata *ad = data;
 
        if (ad->ug)
                ug_send_event(UG_EVENT_REGION_CHANGE);
-
-       return 0;
 }
 
 /**
@@ -297,7 +272,7 @@ static Evas_Object *setting_main_create_win(const char *name)
 /**
 * exceptional process, reset the env vars by Setting vconf VCONFKEY_LANGSET
 */
-static int setting_main_lang_changed_cb(void *data)
+static void setting_main_lang_changed_cb(void *data)
 {
        SETTING_TRACE_BEGIN;
        setting_main_appdata *ad = data;
@@ -398,8 +373,6 @@ static int setting_main_lang_changed_cb(void *data)
 
        if (ad->ug)
                ug_send_event(UG_EVENT_LANG_CHANGE);
-
-       return SETTING_RETURN_SUCCESS;
 }
 
 /**
@@ -423,10 +396,20 @@ static void setting_other_vconf_change_cb(keynode_t *key, void *data)
                int status = 0;
                vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, &status);
                item_to_update->chk_status = status;
-               if (ad->bAppPause || ad->ug) {
-                       ad->updateItems[GL_ITEM_FLIGHT] = EINA_TRUE;
-               } else { // app is not in pause without ug
-                       elm_check_state_set(item_to_update->eo_check, status);
+               //do not need delay for checks
+               elm_check_state_set(item_to_update->eo_check, item_to_update->chk_status);
+
+               //Flight mode is ON : Network menu dimmed
+               if (ad->data_network)
+               {
+                       if (status)
+                       {
+                               setting_disable_genlist_item(ad->data_network->item);
+                       }
+                       else
+                       {
+                               setting_enable_genlist_item(ad->data_network->item);
+                       }
                }
                return;
        } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL)) {
@@ -437,12 +420,17 @@ static void setting_other_vconf_change_cb(keynode_t *key, void *data)
                vconf_get_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, &status);
 
                item_to_update->chk_status = !status;
-
-               if (ad->bAppPause || ad->ug) {
-                       ad->updateItems[GL_ITEM_ROTATION] = EINA_TRUE;
-               } else { // app is not in pause without ug
-                       elm_check_state_set(item_to_update->eo_check, item_to_update->chk_status);
+               //do not need delay for checks
+               elm_check_state_set(item_to_update->eo_check, item_to_update->chk_status);
+               SETTING_TRACE("item_to_update->chk_status:%d", item_to_update->chk_status);
+               if (item_to_update->chk_status) //rotation function is not blocked
+               {
+                       SETTING_TRACE("Rotation function is on, it is necessary to adjust the device orientation");
+                       int mode = APP_DEVICE_ORIENTATION_0;
+                       mode = app_get_device_orientation();
+                       elm_win_rotation_with_resize_set(ad->win_main, mode);
                }
+
                return;
        } else if (!safeStrCmp(vconf_name, VCONFKEY_NFC_STATE)) {
                SETTING_TRACE_DEBUG("%s updated", vconf_name);
@@ -508,6 +496,22 @@ static void setting_int_vconf_change_cb(keynode_t *key, void *data)
                        elm_object_item_data_set(item_to_update->item, item_to_update);
                        elm_genlist_item_update(item_to_update->item);
                }
+       }
+       else if (!safeStrCmp(vconf_name, VCONFKEY_CALL_STATE)) {
+               //In call situation : Wi-fi / Tethering / Network menu dimmed
+               if (VCONFKEY_CALL_OFF != status)
+               {
+                       if (ad->data_network) setting_disable_genlist_item(ad->data_network->item);
+                       if (ad->data_wifi) setting_disable_genlist_item(ad->data_wifi->item);
+                       //if (ad->data_mobileApp) setting_disable_genlist_item(ad->data_mobileApp->item);
+               }
+               else
+               {
+                       if (ad->data_network) setting_enable_genlist_item(ad->data_network->item);
+                       if (ad->data_wifi) setting_enable_genlist_item(ad->data_wifi->item);
+                       //if (ad->data_mobileApp) setting_enable_genlist_item(ad->data_mobileApp->item);
+               }
+
        } else if (!safeStrCmp(vconf_name, VCONFKEY_BT_STATUS)) {
                item_to_update = ad->data_bt;
                retm_if(!item_to_update, "ad->data_bt is NULL");
@@ -626,19 +630,16 @@ static Eina_Bool setting_on_idle_lazy(void *data)
                SETTING_TRACE_ERROR("sensor_start fail");
        }
 
-       appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE,
-                                  setting_main_lang_changed_cb, ad);
+//     appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, setting_main_lang_changed_cb, ad);
 
 #if LOW_BATTERY_DO_NOTHING
-       appcore_set_event_callback(APPCORE_EVENT_LOW_BATTERY,
-                                  setting_main_low_battery_cb, ad);
+//     appcore_set_event_callback(APPCORE_EVENT_LOW_BATTERY, setting_main_low_battery_cb, ad);
 #endif
 
-       appcore_set_event_callback(APPCORE_EVENT_REGION_CHANGE,
-                                  setting_main_region_changed_cb, ad);
+//     appcore_set_event_callback(APPCORE_EVENT_REGION_CHANGE, setting_main_region_changed_cb, ad);
 
 #if SUPPORT_APP_ROATION
-       appcore_set_rotation_cb(setting_main_rotate, ad);
+//     appcore_set_rotation_cb(setting_main_rotate, ad);
        evas_object_geometry_get(ad->win_main, &g_geometry_x, &g_geometry_y, &g_geometry_w, &g_geometry_h);
 #endif
 
@@ -652,8 +653,8 @@ static int setting_main_app_create(void *data)
 {
        SETTING_TRACE_BEGIN;
        //fprintf(stderr, "[TIME] 3. it taked %d msec from main to setting_main_app_create \n", appcore_measure_time());
-       SETTING_TRACE("[TIME] 3. it taked %d msec from main to setting_main_app_create ", appcore_measure_time());
-       appcore_measure_start();
+       //SETTING_TRACE("[TIME] 3. it taked %d msec from main to setting_main_app_create ", appcore_measure_time());
+       //appcore_measure_start();
        setting_main_appdata *ad = data;
 
        ad->data_roaming_popup = NULL;
@@ -667,7 +668,7 @@ static int setting_main_app_create(void *data)
 
        /* load config file */
        int cfg_operation_ret = setting_cfg_init();
-       PLUGIN_INIT;
+       PLUGIN_INIT(ad);
 
        elm_theme_extension_add(NULL, SETTING_THEME_EDJ_NAME);
 #if SUPPORT_LCD_TIMEOUT_KEEPING
@@ -741,16 +742,16 @@ static int setting_main_app_create(void *data)
                return SETTING_RETURN_FAIL;
        }
        //fprintf(stderr, "[TIME] 4. setting_main_app_create taked %d msec \n", appcore_measure_time());
-       SETTING_TRACE("[TIME] 4. setting_main_app_create taked %d msec ", appcore_measure_time());
-       appcore_measure_start();
+       //SETTING_TRACE("[TIME] 4. setting_main_app_create taked %d msec ", appcore_measure_time());
+       //appcore_measure_start();
 
-       return 0;
+       return true;
 }
 
 /**
 * The function is called when Setting is terminated
 */
-static int setting_main_app_terminate(void *data)
+static void setting_main_app_terminate(void *data)
 {
        SETTING_TRACE_BEGIN;
        setting_main_appdata *ad = data;
@@ -793,7 +794,7 @@ static int setting_main_app_terminate(void *data)
 /**
 * The function is called when Setting begins run in background from forground
 */
-static int setting_main_app_pause(void *data)
+static void setting_main_app_pause(void *data)
 {
        SETTING_TRACE_BEGIN;
        setting_main_appdata *ad = data;
@@ -810,14 +811,12 @@ static int setting_main_app_pause(void *data)
 #endif
 
        sensor_stop(ad->sf_handle, SENSOR_MOTION_DOUBLETAP);
-
-       return 0;
 }
 
 /**
 * The function is called when Setting begins run in forground from background
 */
-static int setting_main_app_resume(void *data)
+static void setting_main_app_resume(void *data)
 {
        SETTING_TRACE_BEGIN;
        setting_main_appdata *ad = data;
@@ -840,8 +839,6 @@ static int setting_main_app_resume(void *data)
                SETTING_TRACE("update main genlist in resuming app without UG");
                setting_update_gl_item(ad);     // update genlist sub-texts
        }
-
-       return 0;
 }
 
 /**
@@ -852,6 +849,17 @@ static int setting_main_app_reset(service_h service, void *data)
        SETTING_TRACE_BEGIN;
        setting_main_appdata *ad = data;
 
+       int value = 0;
+       vconf_get_bool (VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, &value);
+       SETTING_TRACE("value:%d", value);
+       if (!value) //rotation function is not blocked
+       {
+               SETTING_TRACE("Rotation function is on, it is necessary to adjust the device orientation");
+               int mode = APP_DEVICE_ORIENTATION_0;
+               mode = app_get_device_orientation();
+               elm_win_rotation_with_resize_set(ad->win_main, mode);
+       }
+
 #if SUPPORT_LIVEBOX_DEMO
        char *ug_name = NULL;
        if(b != NULL)
@@ -902,7 +910,9 @@ static int setting_main_app_reset(service_h service, void *data)
        cb = setting_int_vconf_change_cb;
        REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_BT_STATUS, cb, data);
        REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_WIFI_STATE, cb, ad);
-       REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, cb, ad);
+       REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_CALL_STATE, cb, ad);
+       //do need to disable 'Brightness' menu,just disable sub-items in 'Brightness' menu
+       //REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, cb, ad);
        REGISTER_VCONF_NODE(ad->listened_list, VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, cb, data);
 
        cb = setting_string_vconf_change_cb;
@@ -921,12 +931,21 @@ static int setting_main_app_reset(service_h service, void *data)
 
        ecore_idler_add(setting_on_idle_lazy, ad);
 
-       //fprintf(stderr, "[TIME] 5. app_create -> app_resume (first display) : %d msec\n", appcore_measure_time());
-       SETTING_TRACE("[TIME] 5. app_create -> app_resume (first display) : %d msec", appcore_measure_time());
-       //fprintf(stderr, "[TIME] Total. aul_launch -> app_resume (first display) : %d msec\n", appcore_measure_time_from("APP_START_TIME"));
-       SETTING_TRACE("[TIME] Total. aul_launch -> app_resume (first display) : %d msec", appcore_measure_time_from("APP_START_TIME"));
+       int flight_mode = 0;
+       vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, &flight_mode);
+       if (flight_mode)
+       {
+               if (ad->data_network) setting_disable_genlist_item(ad->data_network->item);
+       }
 
-       return 0;
+       int call_status = VCONFKEY_CALL_OFF;
+       vconf_get_int(VCONFKEY_CALL_STATE, &call_status);
+       if (VCONFKEY_CALL_OFF != call_status)
+       {
+               if (ad->data_network) setting_disable_genlist_item(ad->data_network->item);
+               if (ad->data_wifi) setting_disable_genlist_item(ad->data_wifi->item);
+               //if (ad->data_mobileApp) setting_disable_genlist_item(ad->data_mobileApp->item);
+       }
 }
 
 int main(int argc, char *argv[])
@@ -941,24 +960,28 @@ int main(int argc, char *argv[])
 #endif
 
        //fprintf(stderr, "[TIME] 1. aul_launch -> main :: Setting main : %d msec \n", appcore_measure_time_from("APP_START_TIME"));
-       SETTING_TRACE("[TIME] 1. aul_launch -> main :: Setting main : %d msec ", appcore_measure_time_from("APP_START_TIME"));
-       appcore_measure_start();
+       //SETTING_TRACE("[TIME] 1. aul_launch -> main :: Setting main : %d msec ", appcore_measure_time_from("APP_START_TIME"));
+       //appcore_measure_start();
 
-       struct appcore_ops ops = {
+       app_event_callback_s ops = {
                .create = setting_main_app_create,
                .terminate = setting_main_app_terminate,
                .pause = setting_main_app_pause,
                .resume = setting_main_app_resume,
-               .reset = setting_main_app_reset,
+               .service = setting_main_app_reset,
+               .low_battery = setting_main_low_battery_cb,
+               .language_changed = setting_main_lang_changed_cb,
+               .region_format_changed = setting_main_region_changed_cb,
+               .device_orientation = setting_main_rotate,
        };
 
        memset(&ad, 0x0, sizeof(setting_main_appdata));
-       ops.data = &ad;
+       //ops.data = &ad;
 
        //fprintf(stderr, "[TIME] 2. main : %d msec \n", appcore_measure_time());
-       SETTING_TRACE("[TIME] 2. main : %d msec ", appcore_measure_time());
-       appcore_measure_start();
-       r = appcore_efl_main(SETTING_PACKAGE, &argc, &argv, &ops);
+       //SETTING_TRACE("[TIME] 2. main : %d msec ", appcore_measure_time());
+       //appcore_measure_start();
+       r = app_efl_main(&argc, &argv, &ops, &ad);
        retv_if(r == -1, -1);
 
        return 0;