Merge "support haptic"
[apps/core/preloaded/settings.git] / src / setting-main.c
index eae52b9..7898d1c 100755 (executable)
 
 #include <tapi_common.h>
 #include <aul.h>
+#include <ail.h>
 #include <time.h>
 #include <setting-main.h>
 #include <setting-plugin.h>
 
+
+typedef struct DrawAppInfo DrawAppInfo;
+typedef struct DrawAppInfo
+{
+       int ncount;
+       //------------------------------------
+       void (*draw_app)(void* arg, char* name, char* pkgname);
+       void* data;
+};
+
 static int setting_main_create(void *cb);
 static int setting_main_destroy(void *cb);
 static int setting_main_update(void *cb);
@@ -399,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;
@@ -443,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,
@@ -455,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)
@@ -477,8 +466,10 @@ static Setting_GenGroupItem_Data * __nfc_handler(void* data, char* keyStr, char*
        __BACK_POINTER_SET(ad->data_nfc);
 
        setting_create_Gendial_field_def(genlist, &itc_multiline_text, NULL,
-                ad, SWALLOW_Type_LAYOUT_SPECIALIZTION,
+                ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
                 NULL, NULL, 0, SETTING_NFC_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);
 
        return ad->data_nfc;
 }
@@ -500,12 +491,10 @@ static Setting_GenGroupItem_Data * __default_handler(void* data, char* keyStr, c
 
        if (!safeStrCmp(KeyStr_WiFiDirect, keyStr)) {
                setting_create_Gendial_field_def(genlist, &itc_multiline_text, NULL,
-                        ad, SWALLOW_Type_LAYOUT_SPECIALIZTION,
+                        ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
                         NULL, NULL, 0, SETTING_WIFI_DIRECT_DESC, NULL, NULL);
-       } else if (!safeStrCmp(KeyStr_KeisOverWifi, keyStr)) {
-               setting_create_Gendial_field_def(genlist, &itc_multiline_text, NULL,
-                        ad, SWALLOW_Type_LAYOUT_SPECIALIZTION,
-                        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 */
        }
@@ -525,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,
@@ -537,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
@@ -570,13 +557,15 @@ void __load_connectivity_menu_list(void *data, Cfg_Item_Position inputPos, Evas_
        }
 
        int idx_second_menu = 0;
-       
+
        char *keyStr = NULL;
        char *icon_path = NULL;
        char *ug_args = NULL;
        Cfg_Item_Position tmpPos = Cfg_Item_Pos_Uninstall;
        int i, j;
 
+       bool is_emulator = isEmulBin();
+
        for (i = 0; i < setting_cfg_get_category_length(); i++) {
                if (safeStrCmp
                    (setting_cfg_get_category_name(i), KeyStr_Connectivity))
@@ -589,13 +578,33 @@ void __load_connectivity_menu_list(void *data, Cfg_Item_Position inputPos, Evas_
                        icon_path = setting_cfg_get_icon_path_idx(i, j);
                        /* SETTING_TRACE_DEBUG("Got an item[keyStr:%s, ug_args:%s, pos:%d]", */
                        /*                     keyStr, ug_args, tmpPos); */
-                       
+
+                       if (is_emulator) {
+                               if (!safeStrCmp(KeyStr_FlightMode, keyStr)) {
+                                       continue; /* hide Flight Mode in Emulator*/
+                               } else if (!safeStrCmp(KeyStr_WiFi, keyStr)) {
+                                       continue; /* hide WIFI in Emulator*/
+                               } else if (!safeStrCmp(KeyStr_WiFiDirect, keyStr)) {
+                                       continue; /* hide WiFiDirect in Emulator*/
+                               } else if (!safeStrCmp(KeyStr_Network, keyStr)) {
+                                       continue; /* hide Network in Emulator*/
+                               } 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 */
+                               }
+                       }
+
                        if (idx_second_menu < MAX_MORE_MENU_NUM
                            && Cfg_Item_Pos_Level1 == tmpPos
                            && SETTING_VIEW_MAIN == ad->view_load
                            && MAIN_PROFILE_PREFERRED == ad->profile_type) {
-                           
-                               ad->more_connective_menus[idx_second_menu++] = keyStr;
+
+                               if (is_ug_installed_by_ug_args(ug_args)) {
+                                       ad->more_connective_menus[idx_second_menu++] = keyStr;
+                               }
                        }
 
                        if (Cfg_Item_Pos_Level_All == inputPos) {
@@ -603,7 +612,6 @@ void __load_connectivity_menu_list(void *data, Cfg_Item_Position inputPos, Evas_
                                continue;
                        }
 
-
                        if (!safeStrCmp(KeyStr_FlightMode, keyStr)) {   /* load special radio */
                                // ug == NULL
                                mainlist_table[MAINLIST_ENTRY_FLIGHT_MODE].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
@@ -620,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);
@@ -646,7 +650,7 @@ void __load_connectivity_menu_list(void *data, Cfg_Item_Position inputPos, Evas_
 
        //end group , only display in setting main view
 #if SUPPORT_MORE_ITEM_FUNCTION
-               if (SETTING_VIEW_MAIN == ad->view_load && MAIN_PROFILE_PREFERRED == ad->profile_type)
+               if (SETTING_VIEW_MAIN == ad->view_load && MAIN_PROFILE_PREFERRED == ad->profile_type && idx_second_menu > 0)
                {
                        char sub_text[MAX_COMMON_BUFFER_LEN] = {0, };
                        int idx = 0;
@@ -716,6 +720,8 @@ void __load_system_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object
        int ncount = 0;
        int i, j;
 
+       bool is_emulator = isEmulBin();
+
        //SETTING_TRACE("setting_cfg_get_category_length() :: %d ", setting_cfg_get_category_length());
        for (i = 0; i < setting_cfg_get_category_length(); i++) {
                if (safeStrCmp(setting_cfg_get_category_name(i), KeyStr_System))
@@ -729,14 +735,34 @@ void __load_system_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object
                        icon_path = setting_cfg_get_icon_path_idx(i, j);
                        ug_args = setting_cfg_get_ug_args_idx(i, j);
 
+                       //SETTING_TRACE("KeyString :  %s , tmpPos : %d , inputPos : %d ", keyStr, tmpPos, inputPos );
+
+                       if (is_emulator) {
+                               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_Memory, keyStr)) {
+                                       continue; /* hide Memory in Emulator*/
+                               } else if (!safeStrCmp(KeyStr_Powersaving, keyStr)) {
+                                       continue; /* hide Powersaving in Emulator*/
+                               } else {
+                                       /* do nothing */
+                               }
+                       }
+
                        if (idx_second_menu < MAX_MORE_MENU_NUM
                            && Cfg_Item_Pos_Level1 == tmpPos
                            && SETTING_VIEW_MAIN == ad->view_load
                            && MAIN_PROFILE_PREFERRED == ad->profile_type) {
+
+                           if (is_ug_installed_by_ug_args(ug_args)) {
                                ad->more_system_menus[idx_second_menu++] = keyStr;
+                           }
                        }
 
-                       //SETTING_TRACE("KeyString :  %s , tmpPos : %d , inputPos : %d ", keyStr, tmpPos, inputPos );
                        if (Cfg_Item_Pos_Level_All == inputPos) {
                                // do nothing
                                //SETTING_TRACE("Cfg_Item_Pos_Level_All == inputPos ---> no draw --- WHY?? ");
@@ -749,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 =
@@ -807,7 +835,7 @@ void __load_system_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object
        }
        //end group, only display in setting main view
 #if SUPPORT_MORE_ITEM_FUNCTION
-               if (SETTING_VIEW_MAIN == ad->view_load && MAIN_PROFILE_PREFERRED == ad->profile_type)
+               if (SETTING_VIEW_MAIN == ad->view_load && MAIN_PROFILE_PREFERRED == ad->profile_type && idx_second_menu > 0)
                {
                        char sub_text[MAX_COMMON_BUFFER_LEN] = {0, };
                        int idx = 0;
@@ -820,7 +848,7 @@ void __load_system_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object
                                safeStrNCat(sub_text, _(ad->more_system_menus[idx]), MAX_COMMON_BUFFER_LEN);
                                idx++;
                        }
-                       
+
                        ad->data_moreSystem =
                                setting_create_Gendial_field_groupitem(ad->main_genlist,
                                                                       &(ad->itc[GENDIAL_Type_2text_3]),
@@ -859,6 +887,8 @@ static void __load_applications_menu_list(void *data,
        SETTING_TRACE_DEBUG("pos :%d", inputPos);
        setting_main_appdata *ad = data;
 
+       bool is_emulator = isEmulBin();
+
        //group title
        setting_create_Gendial_field_group_titleItem(ad->main_genlist,
                                                     &(ad->itc[GENDIAL_Type_group_item]),
@@ -888,6 +918,15 @@ static void __load_applications_menu_list(void *data,
                                continue;
                        }
 
+                       if (is_emulator) {
+                                /* hide all except Email */
+                               if (safeStrCmp(KeyStr_Email, keyStr)) {
+                                       continue;
+                               } else {
+                                       /* do nothing */
+                               }
+                       }
+
                        setting_create_Gendial_field_groupitem(ad->main_genlist,
                                                               &(ad->itc[GENDIAL_Type_1text_1icon_2]),
                                                               NULL,
@@ -917,6 +956,174 @@ static void __load_applications_level_all_list(void *data)
        __load_applications_menu_list(ad, Cfg_Item_Pos_Level_All);
 }
 
+bool is_3rdapp_installed_setting_cfg(char* pkgname)
+{
+       SETTING_TRACE_BEGIN;
+       // /usr/apps/
+       char path[512];
+
+       if (snprintf(path, 512, "/usr/apps/%s/setting/setting.xml", pkgname) < 0)
+               return false;
+
+       struct stat st;
+       bool result_opt = false;
+
+       if(stat(path, &st) == 0) {
+               result_opt = true;
+       } else {
+               SETTING_TRACE_ERROR(" %s is *NOT* present\n", path);
+               result_opt = false;
+       }
+
+       return result_opt;
+}
+
+
+/**
+ * @param data
+ */
+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, "/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,
+                                                          ad,
+                                                          SWALLOW_Type_INVALID,
+                                                          IMG_DefaultIcon, NULL,
+                                                          0, name, NULL,
+                                                          NULL);
+       }
+       SETTING_TRACE_END;
+}
+
+/**
+ *
+ * ail code here
+ */
+static ail_cb_ret_e __download_apps_cb(ail_appinfo_h ai, void* data)
+{
+       DrawAppInfo* pinfo = (DrawAppInfo*)data;
+    char *id;
+
+       if (AIL_ERROR_OK == ail_appinfo_get_str(ai, AIL_PROP_PACKAGE_STR, &id))
+       {
+               //SETTING_TRACE(" 3rd party - app name : ----> %s ", id);
+       }
+
+    ail_appinfo_h handle;
+
+    char *name = NULL;
+    char *icon = NULL;
+    int installed_time;
+    bool nodisplay = false;
+    bool removable = true;
+
+    if (AIL_ERROR_OK == ail_package_get_appinfo(id, &handle))
+       {
+               if (AIL_ERROR_OK != ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &name))
+                       SETTING_TRACE("cannot get name");
+
+               if (AIL_ERROR_OK != ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &icon))
+                       SETTING_TRACE("cannot get icon");
+
+               if (AIL_ERROR_OK != ail_appinfo_get_bool(handle, AIL_PROP_NODISPLAY_BOOL, &nodisplay))
+                       SETTING_TRACE("cannot get nodisplay");
+
+               if (AIL_ERROR_OK != ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_REMOVABLE_BOOL, &removable))
+                       SETTING_TRACE("cannot get removable");
+
+               if (AIL_ERROR_OK != ail_appinfo_get_int(handle, AIL_PROP_X_SLP_INSTALLEDTIME_INT, &installed_time))
+                       SETTING_TRACE("cannot get installed_time");
+
+               //SETTING_TRACE("installed_time = %d ", installed_time);
+               if (installed_time != 0 && is_3rdapp_installed_setting_cfg(id) == true )
+               {
+                       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);
+                               pinfo->draw_app(pinfo->data, strdup(name)/* appname*/, strdup(id)/* pkg_name*/);
+                       }
+               }
+       }
+       SETTING_TRACE_END;
+    return AIL_CB_RET_CONTINUE;
+}
+
+
+/**
+ * get 3rd party applist from AIL & searching dir/file by the defined rule
+ * @param data ad
+ * if data is NULL --> just get how many items are there
+ * if data is NOT NULL --> draw UI code
+ */
+static int get_downloadapp_list(void* data)
+{
+       SETTING_TRACE_BEGIN;
+
+       setting_main_appdata *ad = data;
+
+       int ncount = 0;
+       ail_filter_h f;
+       ail_appinfo_h handle;
+
+       DrawAppInfo* pinfo = (DrawAppInfo*)malloc(sizeof(DrawAppInfo));
+       pinfo->ncount = 0;
+       pinfo->draw_app = draw_3rdapp;
+       pinfo->data = ad;
+
+       if (ail_filter_new(&f) == AIL_ERROR_OK)
+       {
+               if (ail_filter_add_bool(f, AIL_PROP_NODISPLAY_BOOL, false) != AIL_ERROR_OK)
+               {
+                       SETTING_TRACE("ail filter error");
+                       return;
+               }
+
+               ail_filter_list_appinfo_foreach(f, __download_apps_cb, pinfo);
+               //---------------------------------------------------------------
+               ail_filter_destroy(f);
+       }
+       ncount = pinfo->ncount;
+
+       if (pinfo) {
+               free(pinfo);
+               pinfo = NULL;
+       }
+
+       SETTING_TRACE_END;
+       return ncount;
+}
+
 static int __get_downloaded_apps_num(Cfg_Item_Position inputPos)
 {
        SETTING_TRACE_BEGIN;
@@ -940,28 +1147,16 @@ static int __get_downloaded_apps_num(Cfg_Item_Position inputPos)
                }
        }
 
+       // draw UI with AUL code
 #ifdef PLUGIN
-       //3rd cfg
-       DIR *dp = opendir (PLUGIN_CFG_DIR);
-       if (dp != NULL)
-       {
-               struct dirent *ep;
-               while (ep = readdir (dp))
-               {
-                               if (0 == safeStrCmp(".", ep->d_name)
-                                   || 0 == safeStrCmp("..", ep->d_name))
-                               {
-                                       continue;
-                               }
-                               downloaded_apps_num++;
-               }
-               (void) closedir (dp);
-       }
-#endif
+       downloaded_apps_num = get_downloadapp_list(NULL);
        SETTING_TRACE("Exit %s with return[%d]",__FUNCTION__, downloaded_apps_num);
+#endif
+
        return downloaded_apps_num;
 }
 
+
 static void __load_downloaded_apps_menu_list(void *data,
                                             Cfg_Item_Position inputPos)
 {
@@ -985,6 +1180,7 @@ static void __load_downloaded_apps_menu_list(void *data,
                                                     ELM_GENLIST_ITEM_NONE,
                                                     KeyStr_DownloadedAPPs,
                                                     NULL);
+#if DISABLED_CODE
        char *keyStr = NULL;
        char *icon_path = NULL;
        char *ug_args = NULL;
@@ -1020,8 +1216,11 @@ static void __load_downloaded_apps_menu_list(void *data,
 
                }
        }
+#endif
+
 
-       #ifdef PLUGIN
+       //#ifdef PLUGIN
+       #if 0
        //3rd cfg
        DIR *dp = opendir (PLUGIN_CFG_DIR);
        if (dp != NULL)
@@ -1059,6 +1258,13 @@ static void __load_downloaded_apps_menu_list(void *data,
                }
                (void) closedir (dp);
        }
+       #else
+       // TODO: DRAW 3RD PARTY APPS LIST here with EFL code
+       int downloaded_apps_num = get_downloadapp_list(ad);
+
+       // loop condition : 0 ---> ncount
+       //
+
        #endif
        SETTING_TRACE_END;
 }
@@ -1200,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);
 }
 
 /**
@@ -1513,8 +1740,10 @@ static void setting_main_tapi_event_cb(TapiHandle *handle, int result, void *dat
                                             FALSE, FALSE);
 
                        //It is need to rollback the status,
-                       ad->data_flight->chk_status = !ad->data_flight->chk_status;
-                       elm_check_state_set(ad->data_flight->eo_check, ad->data_flight->chk_status);
+                       if (ad->data_flight) {
+                               ad->data_flight->chk_status = !ad->data_flight->chk_status;
+                               elm_check_state_set(ad->data_flight->eo_check, ad->data_flight->chk_status);
+                       }
                        return;
                }
 
@@ -1530,8 +1759,10 @@ static void setting_main_tapi_event_cb(TapiHandle *handle, int result, void *dat
                                     NULL, POPUP_INTERVAL, FALSE, FALSE);
 
                //It is need to rollback the status,
-               ad->data_flight->chk_status = !ad->data_flight->chk_status;
-               elm_check_state_set(ad->data_flight->eo_check, ad->data_flight->chk_status);
+               if (ad->data_flight) {
+                       ad->data_flight->chk_status = !ad->data_flight->chk_status;
+                       elm_check_state_set(ad->data_flight->eo_check, ad->data_flight->chk_status);
+               }
                break;
        default:
                /* do nothing */
@@ -1600,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;
@@ -1618,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);
@@ -1646,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;
@@ -1714,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;
@@ -1730,13 +1970,16 @@ void setting_update_gl_item(void* data)
                                continue;
                        }
 
-                       if(bGlUpdate) {
-                               SETTING_TRACE("gl update:%d", nDx);
-                               elm_object_item_data_set(item_to_update->item, item_to_update);
-                               elm_genlist_item_update(item_to_update->item);
-                       } else {
-                               SETTING_TRACE("chk update:%d", nDx);
-                               elm_check_state_set(item_to_update->eo_check, item_to_update->chk_status);
+                       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);
+                                       elm_genlist_item_update(item_to_update->item);
+                               } else {
+                                       SETTING_TRACE("chk update:%d", nDx);
+                                       elm_check_state_set(item_to_update->eo_check, item_to_update->chk_status);
+                               }
                        }
 
                        ad->updateItems[nDx] = EINA_FALSE;
@@ -1869,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;
@@ -2001,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)
 {
@@ -2018,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;
@@ -2033,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)
 {
@@ -2052,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); */
@@ -2063,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;