Merge "support haptic"
[apps/core/preloaded/settings.git] / src / setting-main.c
index 30d58a3..7898d1c 100755 (executable)
@@ -410,28 +410,6 @@ static Setting_GenGroupItem_Data * __bluetooth_handler(void* data, char* keyStr,
        return ad->data_bt;
 }
 
-static Setting_GenGroupItem_Data * __mobileap_handler(void* data, char* keyStr, char* icon_path, char* ug_args, Evas_Object *genlist)
-{
-       setting_main_appdata *ad = (setting_main_appdata *)data;
-
-       ad->data_mobileApp = setting_create_Gendial_field_groupitem(genlist,
-                                                  &(ad->itc[GENDIAL_Type_1icon_2text]),
-                                                  NULL,
-                                                  setting_main_click_list_ex_ug_cb,
-                                                  ug_args,
-                                                  SWALLOW_Type_INVALID,
-                                                  icon_path,
-                                                  NULL,
-                                                  0,
-                                                  keyStr,
-                                                  get_Mobile_AP_on_off_str
-                                                  (),
-                                                  NULL);
-       __BACK_POINTER_SET(ad->data_mobileApp);
-
-       return ad->data_mobileApp;
-}
-
 static Setting_GenGroupItem_Data * __allshare_handler(void* data, char* keyStr, char* icon_path, char* ug_args, Evas_Object *genlist)
 {
        setting_main_appdata *ad = (setting_main_appdata *)data;
@@ -454,7 +432,7 @@ static Setting_GenGroupItem_Data * __network_handler(void* data, char* keyStr, c
 {
        setting_main_appdata *ad = (setting_main_appdata *)data;
 
-       Setting_GenGroupItem_Data * obj = setting_create_Gendial_field_groupitem(genlist,
+       ad->data_network = setting_create_Gendial_field_groupitem(genlist,
                                                                       &(ad->itc[GENDIAL_Type_1text_1icon_2]),
                                                                       NULL,
                                                                       setting_main_click_list_network_ug_cb,
@@ -466,7 +444,7 @@ static Setting_GenGroupItem_Data * __network_handler(void* data, char* keyStr, c
                                                                       NULL,
                                                                       NULL);
 
-       return obj;
+       return ad->data_network;
 }
 
 static Setting_GenGroupItem_Data * __nfc_handler(void* data, char* keyStr, char* icon_path, char* ug_args, Evas_Object *genlist)
@@ -517,12 +495,6 @@ static Setting_GenGroupItem_Data * __default_handler(void* data, char* keyStr, c
                         NULL, NULL, 0, SETTING_WIFI_DIRECT_DESC, NULL, NULL);
                elm_genlist_item_select_mode_set(elm_genlist_item_append(genlist, &(itc_seperator), NULL, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL),
                                                 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-       } else if (!safeStrCmp(KeyStr_KeisOverWifi, keyStr)) {
-               setting_create_Gendial_field_def(genlist, &itc_multiline_text, NULL,
-                        ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
-                        NULL, NULL, 0, SETTING_KIES_VIA_WIFI_DESC, NULL, NULL);
-               elm_genlist_item_select_mode_set(elm_genlist_item_append(genlist, &(itc_seperator), NULL, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL),
-                                                ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
        } else {
                /* do nothing */
        }
@@ -542,7 +514,6 @@ enum {
        MAINLIST_ENTRY_FLIGHT_MODE = 0,
        MAINLIST_ENTRY_WIFI,
        MAINLIST_ENTRY_BT,
-       MAINLIST_ENTRY_MOBILEAP,
        MAINLIST_ENTRY_ALLSHARE,
        MAINLIST_ENTRY_NETWORK,
        MAINLIST_ENTRY_NFC,
@@ -554,7 +525,6 @@ static mainlist_entry mainlist_table[] = {
                {KeyStr_FlightMode,     __flightmode_handler},                  // 0 --> NOT UG
                {KeyStr_WiFi,                   __wifi_handler},                                // 1 --> UG
                {KeyStr_Bluetooth,              __bluetooth_handler},                   // 1 --> UG
-               {KeyStr_MobileAP,               __mobileap_handler},                    // 1 --> UG
                {KeyStr_AllShare,               __allshare_handler},                    // NOT UG
                {KeyStr_Network,                __network_handler},                             // 1 --> UG
                {KeyStr_NFC,                    __nfc_handler},                                 // 1 --> UG
@@ -614,21 +584,15 @@ void __load_connectivity_menu_list(void *data, Cfg_Item_Position inputPos, Evas_
                                        continue; /* hide Flight Mode in Emulator*/
                                } else if (!safeStrCmp(KeyStr_WiFi, keyStr)) {
                                        continue; /* hide WIFI in Emulator*/
-                               } else if (!safeStrCmp(KeyStr_MobileAP, keyStr)) {
-                                       continue; /* hide Tethering in Emulator*/
                                } else if (!safeStrCmp(KeyStr_WiFiDirect, keyStr)) {
                                        continue; /* hide WiFiDirect in Emulator*/
-                               } else if (!safeStrCmp(KeyStr_AllShareCast, keyStr)) {
-                                       continue; /* hide AllShareCast in Emulator*/
-                               } else if (!safeStrCmp(KeyStr_NearbyDevices, keyStr)) {
-                                       continue; /* hide NearbyDevices in Emulator*/
-                               } else if (!safeStrCmp(KeyStr_KeisOverWifi, keyStr)) {
-                                       continue; /* hide KeisOverWifi in Emulator*/
-                               } else if (!safeStrCmp(KeyStr_Synchronise, keyStr)) {
-                                       continue; /* hide Synchronise in Emulator*/
                                } else if (!safeStrCmp(KeyStr_Network, keyStr)) {
                                        continue; /* hide Network in Emulator*/
-                               }else {
+                               } else if (!safeStrCmp(KeyStr_Bluetooth, keyStr)) {
+                                       continue; /* hide Bluetooth in Emulator*/
+                               } else if (!safeStrCmp(KeyStr_MobileAP, keyStr)) {
+                                       continue; /* hide Tethering in Emulator*/
+                               } else {
                                        /* do nothing */
                                }
                        }
@@ -664,10 +628,6 @@ void __load_connectivity_menu_list(void *data, Cfg_Item_Position inputPos, Evas_
 
                                mainlist_table[MAINLIST_ENTRY_BT].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
 
-                       } else if (!safeStrCmp(KeyStr_MobileAP, keyStr) && is_ug_installed_by_ug_args(ug_args)) {       /* load special icon */
-
-                               mainlist_table[MAINLIST_ENTRY_MOBILEAP].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
-
                        } else if (!safeStrCmp(KeyStr_Network, keyStr) && is_ug_installed_by_ug_args(ug_args)) {        /* load special UG */
 
                                mainlist_table[MAINLIST_ENTRY_NETWORK].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
@@ -778,22 +738,16 @@ void __load_system_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object
                        //SETTING_TRACE("KeyString :  %s , tmpPos : %d , inputPos : %d ", keyStr, tmpPos, inputPos );
 
                        if (is_emulator) {
-                               if (!safeStrCmp(KeyStr_EventsNotifications, keyStr)) {
-                                       continue; /* hide EventsNotifications in Emulator*/
-                               } else if (!safeStrCmp(KeyStr_Security, keyStr)) {
+                               if (!safeStrCmp(KeyStr_Security, keyStr)) {
                                        continue; /* hide Security in Emulator*/
                                } else if (!safeStrCmp(KeyStr_Motions, keyStr)) {
                                        continue; /* hide Motion in Emulator*/
                                } else if (!safeStrCmp(KeyStr_Accessibility, keyStr)) {
                                        continue; /* hide Accessibility in Emulator*/
-                               } else if (!safeStrCmp(KeyStr_VoiceInOut, keyStr)) {
-                                       continue; /* hide VoiceInOut in Emulator*/
-                               } else if (!safeStrCmp(keystr_Drivingmode, keyStr)) {
-                                       continue; /* hide Drivingmode in Emulator*/
-                               } else if (!safeStrCmp(KeyStr_License, keyStr)) {
-                                       continue; /* hide License in Emulator*/
                                } else if (!safeStrCmp(KeyStr_Memory, keyStr)) {
                                        continue; /* hide Memory in Emulator*/
+                               } else if (!safeStrCmp(KeyStr_Powersaving, keyStr)) {
+                                       continue; /* hide Powersaving in Emulator*/
                                } else {
                                        /* do nothing */
                                }
@@ -821,6 +775,8 @@ void __load_system_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object
                                int value = 0;
                                vconf_get_bool
                                    (VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, &value);
+                               // true  : auto rotation OFF
+                               // false : auto rotation ON
                                value = !value;
 
                                ad->data_rotationMode =
@@ -1003,11 +959,10 @@ static void __load_applications_level_all_list(void *data)
 bool is_3rdapp_installed_setting_cfg(char* pkgname)
 {
        SETTING_TRACE_BEGIN;
-       // /opt/apps/
+       // /usr/apps/
        char path[512];
 
-       SETTING_TRACE("1");
-       if (snprintf(path, 512, "/opt/apps/%s/setting/setting.xml", pkgname) < 0)
+       if (snprintf(path, 512, "/usr/apps/%s/setting/setting.xml", pkgname) < 0)
                return false;
 
        struct stat st;
@@ -1030,23 +985,33 @@ bool is_3rdapp_installed_setting_cfg(char* pkgname)
 static void draw_3rdapp(void* data, char* name, char* pkgname)
 {
        SETTING_TRACE_BEGIN;
+       SETTING_TRACE(" name : %s", name);
+       SETTING_TRACE(" pkgname : %s", pkgname);
+
        setting_main_appdata *ad = data;
 
        //3rd cfg
        char fullpath[512];
 
-       if (snprintf(fullpath, 512, "/opt/apps/%s/setting/setting.xml", pkgname) < 0)
+       if (snprintf(fullpath, 512, "/usr/apps/%s/setting/setting.xml", pkgname) < 0)
                return false;
 
        SETTING_TRACE(" fullpath : %s", fullpath);
 
        if (ad)
        {
+               if (ad->plugin_path)
+               {
+                       free(ad->plugin_path);
+                       ad->plugin_path = NULL;
+               }
+               ad->plugin_path = strdup(fullpath);
+
                setting_create_Gendial_field_groupitem(ad->main_genlist,
                                                           &(ad->itc[GENDIAL_Type_1text_1icon_2]),
                                                           NULL,
                                                           setting_main_click_list_plugin_cb,
-                                                          strdup(fullpath),
+                                                          ad,
                                                           SWALLOW_Type_INVALID,
                                                           IMG_DefaultIcon, NULL,
                                                           0, name, NULL,
@@ -1061,8 +1026,6 @@ static void draw_3rdapp(void* data, char* name, char* pkgname)
  */
 static ail_cb_ret_e __download_apps_cb(ail_appinfo_h ai, void* data)
 {
-       SETTING_TRACE_BEGIN;
-
        DrawAppInfo* pinfo = (DrawAppInfo*)data;
     char *id;
 
@@ -1099,20 +1062,19 @@ static ail_cb_ret_e __download_apps_cb(ail_appinfo_h ai, void* data)
                //SETTING_TRACE("installed_time = %d ", installed_time);
                if (installed_time != 0 && is_3rdapp_installed_setting_cfg(id) == true )
                {
-                       SETTING_TRACE(" 3rd party - app name : ----> %s ", id);
+                       SETTING_TRACE(" 3rd party - app name : ----> id : %s --- name : %s ", id, name);
+                       SETTING_TRACE(" 3rd party - icon : ----> %s ", icon);
+                       SETTING_TRACE(" 3rd party - nodisplay :  ----> %d ", nodisplay);
                        pinfo->ncount++;
 
                        // draw code here
                        if (pinfo->draw_app != NULL)
                        {
                                SETTING_TRACE(">>> pkg name --> %s ", id);
-                               // draw !!!
-                               pinfo->draw_app(pinfo->data, strdup(id)/* appname*/, strdup(id)/* pkg_name*/);
+                               pinfo->draw_app(pinfo->data, strdup(name)/* appname*/, strdup(id)/* pkg_name*/);
                        }
-
                }
        }
-
        SETTING_TRACE_END;
     return AIL_CB_RET_CONTINUE;
 }
@@ -1444,40 +1406,61 @@ static void __btnback_clicked_cb(void *data, Evas_Object *obj, void *event_info)
        elm_win_lower(ad->win_main);
 }
 
+static Eina_Bool __refresh_on_idle(void *data)
+{
+       SETTING_TRACE_BEGIN;
+       retv_if(!data, FALSE);
+       setting_main_appdata *ad = data;
+       if (MAIN_PROFILE_ALL == ad->profile_type)
+       {
+               ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level_all_list;
+               ad->load_fns[Func_Type_System] = __load_system_level_all_list;
+               ad->load_fns[Func_Type_Apps] = __load_applications_level_all_list;
+               ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level_all_list;
+               setting_main_refresh(ad);
+       }
+       else if (MAIN_PROFILE_PREFERRED == ad->profile_type)
+       {
+               ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level0_list;
+               ad->load_fns[Func_Type_System] = __load_system_level0_list;
+               ad->load_fns[Func_Type_Apps] = __load_applications_level0_list;
+               ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level0_list;
+               setting_main_refresh(ad);
+       }
+       ad->refresh_idler = NULL;
+       return FALSE;
+}
+
 static void __allFrequent_btn_cb(void *data, Evas_Object *obj, void *event_info)
 {
        SETTING_TRACE_BEGIN;
        ret_if(!data || !obj);
        setting_main_appdata *ad = (setting_main_appdata *) data;
+       //if already has the task,cancel the old task with ecore_idler_del,then add new idler task.
+       if (ad->refresh_idler) {
+               ecore_idler_del(ad->refresh_idler);
+               ad->refresh_idler = NULL;
+       }
+
        Elm_Object_Item *item = elm_toolbar_first_item_get(obj);
        ret_if(!item);
-
        if (MAIN_PROFILE_ALL == ad->profile_type)
        {
                SETTING_TRACE("Change to Preferred view");
                elm_object_item_text_set(item, _(ALL_STR));
                ad->profile_type = MAIN_PROFILE_PREFERRED;
-               ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level0_list;
-               ad->load_fns[Func_Type_System] = __load_system_level0_list;
-               ad->load_fns[Func_Type_Apps] = __load_applications_level0_list;
-               ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level0_list;
-               setting_main_refresh(ad);
        }
        else if (MAIN_PROFILE_PREFERRED == ad->profile_type)
        {
                SETTING_TRACE("Change to ALL view");
                elm_object_item_text_set(item, _(PREFERRED_STR));
                ad->profile_type = MAIN_PROFILE_ALL;
-               ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level_all_list;
-               ad->load_fns[Func_Type_System] = __load_system_level_all_list;
-               ad->load_fns[Func_Type_Apps] = __load_applications_level_all_list;
-               ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level_all_list;
-               setting_main_refresh(ad);
        }
        else
        {
                return;
        }
+       ad->refresh_idler = ecore_idler_add((Ecore_Task_Cb) __refresh_on_idle, ad);
 }
 
 /**
@@ -1848,7 +1831,8 @@ static int setting_main_create(void *cb)
        setting_create_Gendial_itc("dialogue/2text.3", &(ad->itc[GENDIAL_Type_2text_3]));
 
        ad->view_type = SETTING_VIEW_MAIN;
-       __setting_create_main_view(ad);
+       bool ret = __setting_create_main_view(ad);
+       SETTING_TRACE(" >>>> ret = %d ", ret);
        setting_view_main.is_create = 1;
 
        return SETTING_RETURN_SUCCESS;
@@ -1866,6 +1850,10 @@ static int setting_main_destroy(void *cb)
                //already not exsit
                return SETTING_RETURN_SUCCESS;
        }
+       if (ad->refresh_idler) {
+               ecore_idler_del(ad->refresh_idler);
+               ad->refresh_idler = NULL;
+       }
 
        if (ad->handle) {
                int tapi_ret = tel_deinit(ad->handle);
@@ -1894,6 +1882,14 @@ static int setting_main_destroy(void *cb)
                evas_object_del(ad->flight_popup);
                ad->flight_popup = NULL;
        }
+
+#if 0
+       if (ad->plugin_node)
+       {
+               setting_plugin_destroy(ad->plugin_node);
+       }
+#endif
+
        setting_view_main.is_create = 0;
        SETTING_TRACE_END;
        return SETTING_RETURN_SUCCESS;
@@ -1962,10 +1958,6 @@ void setting_update_gl_item(void* data)
                                item_to_update = ad->data_nfc;
                                bGlUpdate = EINA_TRUE;
                                break;
-                       case GL_ITEM_MAP:
-                               item_to_update = ad->data_mobileApp;
-                               bGlUpdate = EINA_TRUE;
-                               break;
                        case GL_ITEM_FLIGHT:
                                item_to_update = ad->data_flight;
                                bGlUpdate = EINA_FALSE;
@@ -1979,6 +1971,7 @@ void setting_update_gl_item(void* data)
                        }
 
                        if (item_to_update) {
+                               SETTING_TRACE("gl update [%s], bGlUpdate:%d", _(item_to_update->keyStr), bGlUpdate);
                                if(bGlUpdate) {
                                        SETTING_TRACE("gl update:%d", nDx);
                                        elm_object_item_data_set(item_to_update->item, item_to_update);
@@ -2119,40 +2112,6 @@ setting_main_click_list_default_ug_cb(void *data, Evas_Object *obj,
                                          NO_UG_FOUND_MSG);
 }
 
-void
-setting_main_click_list_usb_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       SETTING_TRACE_BEGIN;
-       retm_if(event_info == NULL, "Invalid argument: event info is NULL");
-
-       int err;
-       int value = -1;
-       char *str_text = USB_NEED_OFF;
-
-       Elm_Object_Item *item = (Elm_Object_Item *) event_info;
-
-       setting_get_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, &value, &err);
-       if (err != 0)
-       {
-               SETTING_TRACE_ERROR("FAIL: VCONFKEY_MOBILE_HOTSPOT_MODE may not exist\n");
-               setting_main_click_list_ex_ug_cb(data, obj, item);
-               return;
-       }
-
-       /* If mobile hotspot is on, going USB utilties is blocked by a popup*/
-       if (value & VCONFKEY_MOBILE_HOTSPOT_MODE_USB)
-       {
-               elm_genlist_item_selected_set(item, EINA_FALSE);
-               setting_create_simple_popup(g_main_ad, g_main_ad->win_main, NULL, (str_text));
-       }
-       else
-       {
-               setting_main_click_list_ex_ug_cb(data, obj, item);
-       }
-
-       SETTING_TRACE_END;
-}
-
 void setting_main_click_list_more_cb(void *data, Evas_Object *obj, void *event_info)
 {
        SETTING_TRACE_BEGIN;
@@ -2251,11 +2210,50 @@ setting_main_click_list_plugin_cb(void *data, Evas_Object *obj,
        retm_if(event_info == NULL, "Invalid argument: event info is NULL");
        Elm_Object_Item *item = (Elm_Object_Item *) event_info;
        elm_genlist_item_selected_set(item, EINA_FALSE);
+
+       setting_main_appdata *ad = data;
 #ifdef PLUGIN
-       setting_plugin_load((const char *)data);
+       if (ad->plugin_path)
+       {
+               PluginNode* plugin_node = setting_plugin_create();
+
+               plugin_node->plugin_path = strdup(ad->plugin_path);
+
+               setting_plugin_load(plugin_node, (const char *)ad->plugin_path);
+               ad->plugin_node = (void*)plugin_node;
+
+               #if 0
+               if(ad->plugin_path)
+               {
+                       free(ad->plugin_path);
+                       ad->plugin_path = NULL;
+               }
+               #endif
+       }
 #endif
 }
 
+/**
+ * @see [caller] setting_main_list_mouse_up_cb
+ * @see [caller] setting_main_sel_list_mouse_up_cb
+ */
+static void __rotate_lock_handler(int chk_status, setting_main_appdata *ad )
+{
+       SETTING_TRACE_BEGIN;
+       if( chk_status == 1)
+       {
+               // toggle : 0 --> 1
+               int angle = elm_win_rotation_get(ad->win_main);
+               elm_win_rotation_with_resize_set(ad->win_main, angle);
+       } else {
+               elm_win_rotation_with_resize_set(ad->win_main, 0);
+       }
+       vconf_set_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, !chk_status);
+}
+
+/**
+ * toggle cb
+ */
 void setting_main_list_mouse_up_cb(void *data, Evas_Object *eo,
                                          void *event_info)
 {
@@ -2268,7 +2266,7 @@ void setting_main_list_mouse_up_cb(void *data, Evas_Object *eo,
 
        SETTING_TRACE("change radio[%s], status is:%d", _(list_item->keyStr),
                      list_item->chk_status);
-       /*setting_main_appdata *ad = g_main_ad;*/
+       setting_main_appdata *ad = g_main_ad;
 
        if (!safeStrCmp(KeyStr_UsePacketData, list_item->keyStr)) {
                int err;
@@ -2283,12 +2281,15 @@ void setting_main_list_mouse_up_cb(void *data, Evas_Object *eo,
                }
 
        } else if (!safeStrCmp(KeyStr_Landscape, list_item->keyStr)) {
-               vconf_set_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, ! list_item->chk_status);
+               __rotate_lock_handler(list_item->chk_status, ad);
        }
 
        return;
 }
 
+/**
+ * genlist touch cb
+ */
 void setting_main_sel_list_mouse_up_cb(void *data, Evas_Object *eo,
                                              void *event_info)
 {
@@ -2302,9 +2303,12 @@ void setting_main_sel_list_mouse_up_cb(void *data, Evas_Object *eo,
            (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
 
        list_item->chk_status = elm_check_state_get(list_item->eo_check);
+
        /* new status */
+    list_item->chk_status = !list_item->chk_status;
+    elm_check_state_set(list_item->eo_check, list_item->chk_status);
 
-       /*setting_main_appdata *ad = (setting_main_appdata *) data;*/
+       setting_main_appdata *ad = (setting_main_appdata *) data;
 
        if (!safeStrCmp(KeyStr_UsePacketData, list_item->keyStr)) {
                /* setting_reset_slp_key_by_status(eo, BOOL_SLP_SETTING_USE_PACKET_DATA); */
@@ -2313,7 +2317,7 @@ void setting_main_sel_list_mouse_up_cb(void *data, Evas_Object *eo,
                                         list_item->chk_status, &err);
 
        } else if (!safeStrCmp(KeyStr_Landscape, list_item->keyStr)) {
-               vconf_set_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, (list_item->chk_status));
+               __rotate_lock_handler(list_item->chk_status, ad);
        }
 
        return;