Apply new API of rotation
[apps/core/preloaded/settings.git] / src / setting-main.c
index 72c1075..0dc9869 100755 (executable)
@@ -1,34 +1,33 @@
 /*
  * setting
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
- *
- * Contact: MyoungJune Park <mj2004.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Flora License, Version 1.0 (the License);
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://floralicense.org/license/
  *
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
-
 #include <tapi_common.h>
 #include <aul.h>
 #include <ail.h>
 #include <time.h>
 #include <setting-main.h>
-#include <setting-plugin.h>
 #include <wifi.h>
+#include <tethering.h>
 #include <bluetooth.h>
 #include <nfc.h>
 
+#include <pkgmgr-info.h>
+
+#include <setting-common-plugin.h>
+
 #define PLUGIN_PREFIX "/opt"
 
 typedef struct _DrawAppInfo
@@ -381,9 +380,9 @@ static Setting_GenGroupItem_Data * __wifi_handler(void* data, char* keyStr, char
        int value, err;
        setting_get_int_slp_key(INT_SLP_SETTING_WIFI_STATUS, &value, &err);
 
-       char* pa_wifi = get_pa_Wi_Fi_on_off_str();
+       //char* pa_wifi = get_pa_Wi_Fi_on_off_str();
        ad->data_wifi = setting_create_Gendial_field_groupitem(genlist,
-                                                  &(ad->itc[GENDIAL_Type_2text_2icon_3]),
+                                                  &(ad->itc[GENDIAL_Type_1text_2icon]),
                                                   NULL,
                                                   setting_main_click_list_ex_ug_cb,
                                                   ug_args,
@@ -392,10 +391,12 @@ static Setting_GenGroupItem_Data * __wifi_handler(void* data, char* keyStr, char
                                                   NULL,
                                                   value,
                                                   keyStr,
-                                                  pa_wifi,
+                                                  NULL,
                                                   setting_main_click_list_wifi_mode_cb);
        __BACK_POINTER_SET(ad->data_wifi);
-       G_FREE(pa_wifi);
+       if(ad->data_wifi)
+               ad->data_wifi->userdata = ad;
+       //G_FREE(pa_wifi);
 
        return ad->data_wifi;
 }
@@ -407,7 +408,7 @@ static Setting_GenGroupItem_Data * __bluetooth_handler(void* data, char* keyStr,
        setting_get_int_slp_key(INT_SLP_SETTING_BT_STATUS, &value, &err);
 
        ad->data_bt = setting_create_Gendial_field_groupitem(genlist,
-                                                  &(ad->itc[GENDIAL_Type_2text_2icon_3]),
+                                                  &(ad->itc[GENDIAL_Type_1text_2icon]),
                                                   NULL,
                                                   setting_main_click_list_ex_ug_cb,
                                                   ug_args,
@@ -416,10 +417,11 @@ static Setting_GenGroupItem_Data * __bluetooth_handler(void* data, char* keyStr,
                                                   NULL,
                                                   value,
                                                   keyStr,
-                                                  get_BT_on_off_str
-                                                  (),
+                                                  NULL,
                                                   setting_main_click_list_bt_mode_cb);
        __BACK_POINTER_SET(ad->data_bt);
+       if(ad->data_bt)
+               ad->data_bt->userdata = ad;
 
        return ad->data_bt;
 }
@@ -469,7 +471,7 @@ static Setting_GenGroupItem_Data * __nfc_handler(void* data, char* keyStr, char*
        setting_get_bool_slp_key(BOOL_SLP_SETTING_NFC_STATUS, &value, &err);
 
        ad->data_nfc = setting_create_Gendial_field_groupitem(genlist,
-                                                  &(ad->itc[GENDIAL_Type_2text_2icon_3]),
+                                                  &(ad->itc[GENDIAL_Type_1text_2icon]),
                                                   NULL,
                                                   setting_main_click_list_ex_ug_cb,
                                                   ug_args,
@@ -478,9 +480,11 @@ static Setting_GenGroupItem_Data * __nfc_handler(void* data, char* keyStr, char*
                                                   NULL,
                                                   value,
                                                   keyStr,
-                                                  get_NFC_on_off_str(),
+                                                  NULL,
                                                   setting_main_click_list_nfc_mode_cb);
        __BACK_POINTER_SET(ad->data_nfc);
+       if(ad->data_nfc)
+               ad->data_nfc->userdata = ad;
 
 #if DISABLED_CODE
        setting_create_Gendial_field_def(genlist, &itc_multiline_text, NULL,
@@ -562,6 +566,8 @@ void __gl_realized(void *data, Evas_Object *obj, void *event_info)
                        elm_object_item_signal_emit(item, "elm,state,bottom", "");
                } else if (list_item->group_style == SETTING_GROUP_STYLE_CENTER) {
                        elm_object_item_signal_emit(item, "elm,state,center", "");
+               } else if (list_item->group_style == SETTING_GROUP_STYLE_NONE) {
+                       /* do nothing */
                } else {
                        SETTING_TRACE_ERROR("list_item->group_style is wrong");
                }
@@ -742,12 +748,21 @@ void __load_connectivity_menu_list(void *data, Cfg_Item_Position inputPos, Evas_
                        __BACK_POINTER_SET(ad->data_moreConnect);
 
                        /* if has <more ..> item , change the last item_date to SETTING_GROUP_STYLE_CENTER*/
-                       if (item_data) {
+                       if (item_data && index > 1) {
                                item_data->group_style = SETTING_GROUP_STYLE_CENTER;
                        }
                        ad->data_moreConnect->group_style = SETTING_GROUP_STYLE_BOTTOM;
+
+                       item_data = ad->data_moreConnect;
+                       index++;
                }
 #endif
+
+       if (index == 1) {
+               item_data->group_style = SETTING_GROUP_STYLE_NONE;
+       } else if (index == 2) {
+               item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
+       }
        SETTING_TRACE_END;
 }
 
@@ -815,6 +830,8 @@ void __load_system_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object
                                        continue; /* hide Memory in Emulator*/
                                } else if (!safeStrCmp(KeyStr_Powersaving, keyStr)) {
                                        continue; /* hide Powersaving in Emulator*/
+                               } else if (!safeStrCmp(KeyStr_FlightMode, keyStr)) {
+                                       continue; /* hide Powersaving in Emulator*/
                                } else {
                                        /* do nothing */
                                }
@@ -838,13 +855,15 @@ void __load_system_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object
                                continue;
                        }
 
-                       if (!safeStrCmp(KeyStr_Landscape, keyStr)) {    /* load special UG */
+                       if (!safeStrCmp(KeyStr_FlightMode, keyStr)) {   /* load special radio */
+                               // ug == NULL
+                               item_data = mainlist_table[MAINLIST_ENTRY_FLIGHT_MODE].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
+
+                       }
+                       else if (!safeStrCmp(KeyStr_Landscape, keyStr)) {       /* load special UG */
                                int value = 0;
                                vconf_get_bool
-                                   (VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, &value);
-                               // true  : auto rotation OFF
-                               // false : auto rotation ON
-                               value = !value;
+                                   (VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &value);
 
                                ad->data_rotationMode =
                                    setting_create_Gendial_field_groupitem(genlist,
@@ -945,12 +964,20 @@ void __load_system_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object
                        __BACK_POINTER_SET(ad->data_moreSystem);
 
                        /* if has <more ..> item , change the last item_date to SETTING_GROUP_STYLE_CENTER*/
-                       if (item_data) {
+                       if (item_data && index > 1) {
                                item_data->group_style = SETTING_GROUP_STYLE_CENTER;
                        }
                        ad->data_moreSystem->group_style = SETTING_GROUP_STYLE_BOTTOM;
+
+                       item_data = ad->data_moreSystem;
+                       index++;
                }
 #endif
+       if (index == 1) {
+               item_data->group_style = SETTING_GROUP_STYLE_NONE;
+       } else if (index == 2) {
+               item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
+       }
 }
 
 static void __load_system_level0_list(void *data)
@@ -988,7 +1015,7 @@ static void __load_applications_menu_list(void *data,
        int i, j;
 
        Setting_GenGroupItem_Data *item_data = NULL;
-
+       int index = 0;
        for (i = 0; i < setting_cfg_get_category_length(); i++) {
                if (safeStrCmp
                    (setting_cfg_get_category_name(i), KeyStr_Applications))
@@ -1033,10 +1060,21 @@ static void __load_applications_menu_list(void *data,
                                } else {
                                        item_data->group_style = SETTING_GROUP_STYLE_CENTER;
                                }
+
+                               if (index == 0) {
+                                       item_data->group_style = SETTING_GROUP_STYLE_TOP;
+                               }
+                               index++;
                        }
                }
        }
 
+       if (index == 1) {
+               item_data->group_style = SETTING_GROUP_STYLE_NONE;
+       } else if (index == 2) {
+               item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
+       }
+
        SETTING_TRACE_END;
 }
 
@@ -1053,7 +1091,6 @@ 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;
@@ -1076,8 +1113,64 @@ bool is_3rdapp_installed_setting_cfg(char* pkgname)
        return result_opt;
 }
 
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *data)
+{
+       SETTING_TRACE_BEGIN;
+
+       DrawAppInfo* pinfo = (DrawAppInfo*)data;
+
+       int ret = -1;
+       char *pkgid;
+       ret = pkgmgr_pkginfo_get_pkgid(handle, &pkgid);
+       if(ret < 0) {
+               SETTING_TRACE(">>>>> pkgmgr_pkginfo_get_pkgid() failed\n");
+       }
+
+       char *label;
+       ret = pkgmgr_pkginfo_get_label(handle, &label);
+       if(ret < 0) {
+               SETTING_TRACE(">>>>> pkgmgr_pkginfo_get_pkg_name() failed\n");
+       }
+       SETTING_TRACE(" 3rd party - pkg id : ----> %s,  pkg name ----> %s ", pkgid, label);
+
+       // appid - 1234567890.AppSetting2
+       // pkgid - 1234567890
+    char *name = pkgid;
+
+       if (is_3rdapp_installed_setting_cfg(pkgid) == true )
+       {
+               pinfo->ncount++;
+               // draw code here
+               if (pinfo->draw_app != NULL)
+               {
+                       SETTING_TRACE(">>> pkg name --> %s ", pkgid);
+                       pinfo->draw_app(pinfo->data, strdup(label)/* appname*/, strdup(pkgid)/* pkg_name*/);
+               }
+       }
+
+       SETTING_TRACE_END;
+    return 0;
+
+}
+
+static void get_3rdapp_installed_setting_list()
+{
+       SETTING_TRACE_BEGIN;
+       int val = 1;
+
+       pkgmgrinfo_pkginfo_filter_h handle;
+       pkgmgrinfo_pkginfo_filter_create(&handle);
+       pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, val);
+
+       pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL);
+}
+
+
+
 /**
  * @param data
+ * ex) name : AppSetting4
+ * ex) pkgname : UBKFwQidax.AppSetting4
  */
 static void draw_3rdapp(void* data, char* name, char* pkgname)
 {
@@ -1096,87 +1189,21 @@ static void draw_3rdapp(void* data, char* name, char* pkgname)
 
        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,
+               char* plugin_path =  strdup(fullpath);
+               Setting_GenGroupItem_Data * plugin_node = 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,
+                                                          0, name, plugin_path,        // <<-- refactoring
                                                           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
@@ -1188,33 +1215,36 @@ static int get_downloadapp_list(void* data)
 
        setting_main_appdata *ad = data;
 
-       int ncount = 0;
-       ail_filter_h f;
+       int val = 1;
+       pkgmgrinfo_pkginfo_filter_h handle;
+       pkgmgrinfo_pkginfo_filter_create(&handle);
+       pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, val);
+
 
+       int ncount = 0;
        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 0;
-               }
+       if (pinfo) {
+               pinfo->ncount = 0;
+               pinfo->draw_app = draw_3rdapp;
+               pinfo->data = ad;
+               pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, pinfo);
 
-               ail_filter_list_appinfo_foreach(f, __download_apps_cb, pinfo);
-               //---------------------------------------------------------------
-               ail_filter_destroy(f);
-       }
-       ncount = pinfo->ncount;
+               ncount = pinfo->ncount;
 
-       if (pinfo) {
                free(pinfo);
                pinfo = NULL;
        }
 
+       if (handle) {
+               if (PMINFO_R_OK == pkgmgrinfo_pkginfo_filter_destroy(handle)) {
+                       SETTING_TRACE("remove pkginfo successfully");
+               } else {
+                       SETTING_TRACE("failed removing pkginfo");
+               }
+               handle = NULL;
+       }
+
        SETTING_TRACE_END;
        return ncount;
 }
@@ -1276,7 +1306,8 @@ static void __load_downloaded_apps_menu_list(void *data,
                                                     ELM_GENLIST_ITEM_NONE,
                                                     KeyStr_DownloadedAPPs,
                                                     NULL);
-
+       get_downloadapp_list(ad);
+       //SETTING_TRACE("Exit %s with return[%d]",__FUNCTION__, downloaded_apps_num);
        SETTING_TRACE_END;
 }
 
@@ -1426,6 +1457,59 @@ static void __allFrequent_btn_cb(void *data, Evas_Object *obj, void *event_info)
        ad->refresh_idler = ecore_idler_add((Ecore_Task_Cb) __refresh_on_idle, ad);
 }
 
+static void __setting_show_title_toolbar(void *data, Evas_Object *obj, void *event_info)
+{
+    SETTING_TRACE_BEGIN;
+    //elm_object_item_signal_emit(data, "elm,state,sip,shown", "");
+    setting_main_appdata *ad = (setting_main_appdata *) data;
+
+    Evas_Object *navi_bar = NULL;
+
+    if (ad->isInUGMode && ad->ug) {
+        Evas_Object *layout = (Evas_Object *)ug_get_layout(ad->ug);
+        if (layout)
+            navi_bar = elm_object_part_content_get(layout, "elm.swallow.content");
+    } else {
+        navi_bar = ad->navibar_main;
+    }
+
+    const char *support = evas_object_data_get(navi_bar, "sip.naviframe.title_obj");
+    SETTING_TRACE("support:%s", support);
+    if (support)
+    {
+        Elm_Object_Item *top_item = elm_naviframe_top_item_get(navi_bar);
+        if (top_item)
+            elm_object_item_signal_emit(top_item, "elm,state,sip,shown", "");
+    }
+}
+
+static void __setting_hide_title_toolbar(void *data, Evas_Object *obj, void *event_info)
+{
+    SETTING_TRACE_BEGIN;
+    //elm_object_item_signal_emit(data, "elm,state,sip,hidden", "");
+    setting_main_appdata *ad = (setting_main_appdata *) data;
+
+    Evas_Object *navi_bar = NULL;
+
+    if (ad->isInUGMode && ad->ug) {
+        Evas_Object *layout = (Evas_Object *)ug_get_layout(ad->ug);
+        if (layout)
+            navi_bar = elm_object_part_content_get(layout, "elm.swallow.content");
+    } else {
+        navi_bar = ad->navibar_main;
+    }
+
+    const char *support = evas_object_data_get(navi_bar, "sip.naviframe.title_obj");
+
+    SETTING_TRACE("support:%s", support);
+    if (support)
+    {
+        Elm_Object_Item *top_item = elm_naviframe_top_item_get(navi_bar);
+        if (top_item)
+            elm_object_item_signal_emit(top_item, "elm,state,sip,hidden", "");
+    }
+}
+
 static bool __setting_create_main_view(void *data)
 {
        SETTING_TRACE_BEGIN;
@@ -1441,9 +1525,12 @@ static bool __setting_create_main_view(void *data)
        elm_object_content_set(conform, ad->ly_main);
        evas_object_show(conform);
 
+    evas_object_smart_callback_add(conform, "virtualkeypad,state,on", __setting_show_title_toolbar, ad);
+    evas_object_smart_callback_add(conform, "virtualkeypad,state,off", __setting_hide_title_toolbar, ad);
+
        elm_win_conformant_set(ad->win_main, EINA_TRUE);
 
-       ad->conformant = conform;
+       ad->conform = conform;
 
        ad->navibar_main = setting_create_navi_bar(ad->ly_main);
 
@@ -1615,6 +1702,10 @@ static void setting_main_tapi_event_cb(TapiHandle *handle, int result, void *dat
                break;
        default:
                /* do nothing */
+               SETTING_TRACE_DEBUG("default");
+               if(ad->data_flight)
+                       setting_set_bool_slp_key(BOOL_SLP_SETTING_FLIGHT_MODE,
+                                        ad->data_flight->chk_status, &err);
                break;
        }
        return;
@@ -1688,6 +1779,7 @@ static int setting_main_create(void *cb)
 
        setting_view_main.is_create = 1;
 
+       setting_drawer_list_init();
        return SETTING_RETURN_SUCCESS;
 }
 
@@ -1703,6 +1795,10 @@ static int setting_main_destroy(void *cb)
                //already not exsit
                return SETTING_RETURN_SUCCESS;
        }
+
+    evas_object_smart_callback_del(ad->conform, "virtualkeypad,state,on", __setting_show_title_toolbar);
+    evas_object_smart_callback_del(ad->conform, "virtualkeypad,state,off", __setting_hide_title_toolbar);
+
        if (ad->refresh_idler) {
                ecore_idler_del(ad->refresh_idler);
                ad->refresh_idler = NULL;
@@ -1736,15 +1832,11 @@ static int setting_main_destroy(void *cb)
                ad->flight_popup = NULL;
        }
 
-#if 0
-       if (ad->plugin_node)
-       {
-               setting_plugin_destroy(ad->plugin_node);
-       }
-#endif
-
        evas_object_smart_callback_del(ad->main_genlist, "realized", __gl_realized);
 
+       setting_dbus_handler_fini();
+       setting_drawer_list_fini();
+
        setting_view_main.is_create = 0;
        SETTING_TRACE_END;
        return SETTING_RETURN_SUCCESS;
@@ -1869,8 +1961,10 @@ void setting_main_destroy_ug_cb(ui_gadget_h ug, void *priv)
 void setting_main_result_ug_cb(ui_gadget_h ug, service_h service,
                                      void *priv)
 {
-       if (!priv)
-               return;
+       if (!priv) return;
+
+       // set default local automatically
+       set_defaultLangICU();
 }
 
 void setting_main_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
@@ -2097,27 +2191,21 @@ 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_GenGroupItem_Data *selected_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
 
        setting_main_appdata *ad = data;
-#ifdef PLUGIN
-       if (ad->plugin_path)
-       {
-               PluginNode* plugin_node = setting_plugin_create();
 
-               plugin_node->plugin_path = strdup(ad->plugin_path);
+       ad->plugin_path = strdup(selected_item->sub_desc);
+       SETTING_TRACE(" >> SELECTED plugin name : %s \n", ad->plugin_path);
 
-               setting_plugin_load(plugin_node, (const char *)ad->plugin_path);
-               ad->plugin_node = (void*)plugin_node;
+       PluginNode* plugin_node = setting_plugin_create(g_main_ad->navibar_main, g_main_ad->win_main);
+       plugin_node->plugin_path = strdup(selected_item->sub_desc);
+       ad->plugin_node = plugin_node; // the selected plugin name
 
-               #if 0
-               if(ad->plugin_path)
-               {
-                       free(ad->plugin_path);
-                       ad->plugin_path = NULL;
-               }
-               #endif
-       }
-#endif
+       setting_drawer_list_init();
+       setting_dbus_handler_init( ad->plugin_node );
+
+       setting_plugin_load(plugin_node, (const char *)plugin_node->plugin_path);
 }
 
 /**
@@ -2135,7 +2223,7 @@ static void __rotate_lock_handler(int chk_status, setting_main_appdata *ad )
        } else {
                elm_win_rotation_with_resize_set(ad->win_main, 0);
        }
-       vconf_set_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, !chk_status);
+       vconf_set_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, chk_status);
 }
 
 /**
@@ -2243,77 +2331,241 @@ void __alternate_flight_mode(Evas_Object *check)
        SETTING_TRACE_END;
 }
 
-void __alternate_wifi_mode(Evas_Object *check)
+static void __tethering_disabled_cb(tethering_error_e error, tethering_type_e type, tethering_disabled_cause_e code, void *data)
 {
-       SETTING_TRACE_BEGIN;
        int ret;
-       Eina_Bool status =  elm_check_state_get(check);
-       SETTING_TRACE("wifi mode status : %d", status);
+
+       if (data) {
+               tethering_h th = (tethering_h)data;
+               tethering_destroy(th);
+       }
 
        ret = wifi_initialize();
        setting_retm_if(ret < 0, "*** [ERR] wifi_initialize() ***");
 
-
-       if (status) {
-               ret = wifi_activate(NULL, NULL);
-               setting_retm_if(ret < 0,
-                               "*** [ERR] wifi_activate() ***");
-       } else {
-               ret = wifi_deactivate(NULL, NULL);
-               setting_retm_if(ret < 0,
-                               "*** [ERR] wifi_deactivate() ***");
+       ret = wifi_activate(NULL, NULL);
+       if (ret < 0) {
+               wifi_deinitialize();
        }
+       setting_retm_if(ret < 0, "*** [ERR] wifi_activate() ***");
+
        ret = wifi_deinitialize();
        setting_retm_if(ret < 0, "*** [ERR] wifi_deinitialize() ***");
+}
+
+static void __tethering_turn_off_resp_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       setting_retm_if(NULL == obj, "NULL == obj");
+       int response_type = btn_type(obj);
+       Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
+
+       if (g_main_ad)
+       {
+               evas_object_del(g_main_ad->popup);
+               g_main_ad->popup = NULL;
+       }
+
+       if (POPUP_RESPONSE_OK == response_type)
+       {
+               tethering_h th = NULL;
+               tethering_error_e ret = TETHERING_ERROR_NONE;
+
+               ret = tethering_create(&th);
+               if (ret != TETHERING_ERROR_NONE) {
+                       list_item->swallow_type = SWALLOW_Type_1ICON_1RADIO;
+                       list_item->chk_status = EINA_FALSE;
+                       elm_object_item_data_set(list_item->item, list_item);
+                       elm_genlist_item_update(list_item->item);
+               }
+
+               ret = tethering_set_disabled_cb(th, TETHERING_TYPE_WIFI, __tethering_disabled_cb, th);
+               if (ret != TETHERING_ERROR_NONE) {
+                       list_item->swallow_type = SWALLOW_Type_1ICON_1RADIO;
+                       list_item->chk_status = EINA_FALSE;
+                       elm_object_item_data_set(list_item->item, list_item);
+                       elm_genlist_item_update(list_item->item);
+
+                       tethering_destroy(th);
+                       return;
+               }
+
+               tethering_disable(th, TETHERING_TYPE_WIFI);
+       }
+       else if (POPUP_RESPONSE_CANCEL == response_type)
+       {
+               list_item->swallow_type = SWALLOW_Type_1ICON_1RADIO;
+               list_item->chk_status = EINA_FALSE;
+               elm_object_item_data_set(list_item->item, list_item);
+               elm_genlist_item_update(list_item->item);
+       }
+}
+
+void __alternate_wifi_mode(Setting_GenGroupItem_Data *list_item, Evas_Object *check)
+{
+       SETTING_TRACE_BEGIN;
+       int ret;
+       Eina_Bool status =  elm_check_state_get(check);
+       SETTING_TRACE("wifi mode status : %d", status);
+
+       int value, err;
+
+       if (tethering_is_enabled(NULL, TETHERING_TYPE_WIFI) == TRUE) {
+               list_item->swallow_type = SWALLOW_Type_1ICON_1PROCESS;
+               elm_object_item_data_set(list_item->item, list_item);
+               elm_genlist_item_update(list_item->item);
+
+               g_main_ad->popup = setting_create_popup_with_btn(list_item,
+                               g_main_ad->win_main, NULL,
+                               _("Connecting Wi-Fi will turn off Mobile hotspot. Continue?"),
+                               __tethering_turn_off_resp_cb,
+                               0, 2, _("IDS_COM_SK_OK"), _("IDS_COM_SK_CANCEL"));
+       } else {
+               ret = wifi_initialize();
+               if (ret < 0) {
+                       setting_get_int_slp_key(INT_SLP_SETTING_WIFI_STATUS, &value, &err);
+                       list_item->chk_status = value;
+                       elm_object_item_data_set(list_item->item, list_item);
+                       elm_genlist_item_update(list_item->item);
+               }
+               setting_retm_if(ret < 0, "*** [ERR] wifi_initialize() ***");
+
+               if (status) {
+                       ret = wifi_activate(NULL, NULL);
+                       if (ret < 0) {
+                               setting_get_int_slp_key(INT_SLP_SETTING_WIFI_STATUS, &value, &err);
+                               list_item->chk_status = value;
+                               elm_object_item_data_set(list_item->item, list_item);
+                               elm_genlist_item_update(list_item->item);
+                               wifi_deinitialize();
+                       }
+                       setting_retm_if(ret < 0, "*** [ERR] wifi_activate() ***");
+               } else {
+                       ret = wifi_deactivate(NULL, NULL);
+                       if (ret < 0) {
+                               setting_get_int_slp_key(INT_SLP_SETTING_WIFI_STATUS, &value, &err);
+                               list_item->chk_status = value;
+                               elm_object_item_data_set(list_item->item, list_item);
+                               elm_genlist_item_update(list_item->item);
+                               wifi_deinitialize();
+                       }
+                       setting_retm_if(ret < 0, "*** [ERR] wifi_deactivate() ***");
+               }
+
+               ret = wifi_deinitialize();
+               if (ret < 0) {
+                       setting_get_int_slp_key(INT_SLP_SETTING_WIFI_STATUS, &value, &err);
+                       list_item->chk_status = value;
+                       elm_object_item_data_set(list_item->item, list_item);
+                       elm_genlist_item_update(list_item->item);
+               }
+               setting_retm_if(ret < 0, "*** [ERR] wifi_deinitialize() ***");
+
+               list_item->swallow_type = SWALLOW_Type_1ICON_1PROCESS;
+               elm_object_item_data_set(list_item->item, list_item);
+               elm_genlist_item_update(list_item->item);
 
+       }
        SETTING_TRACE_END;
 }
 
-void __alternate_bt_mode(Evas_Object *check)
+void __alternate_bt_mode(Setting_GenGroupItem_Data *list_item, Evas_Object *check)
 {
        SETTING_TRACE_BEGIN;
        int ret;
        Eina_Bool status =  elm_check_state_get(check);
        SETTING_TRACE("bt mode status : %d", status);
 
+       int value, err;
+
        ret = bt_initialize();
+       if (ret < 0) {
+               setting_get_int_slp_key(INT_SLP_SETTING_BT_STATUS, &value, &err);
+               list_item->chk_status = value;
+               elm_object_item_data_set(list_item->item, list_item);
+               elm_genlist_item_update(list_item->item);
+       }
        setting_retm_if(ret < 0, "*** [ERR] bt_initialize() ***");
 
 
        if (status) {
                ret = bt_adapter_enable();
-               setting_retm_if(ret < 0,
-                               "*** [ERR] bt_adapter_enable() ***");
+               if (ret < 0) {
+                       setting_get_int_slp_key(INT_SLP_SETTING_BT_STATUS, &value, &err);
+                       list_item->chk_status = value;
+                       elm_object_item_data_set(list_item->item, list_item);
+                       elm_genlist_item_update(list_item->item);
+                       bt_deinitialize();
+               }
+               setting_retm_if(ret < 0, "*** [ERR] bt_adapter_enable() ***");
        } else {
                ret = bt_adapter_disable();
-               setting_retm_if(ret < 0,
-                               "*** [ERR] bt_adapter_disable() ***");
+               if (ret < 0) {
+                       setting_get_int_slp_key(INT_SLP_SETTING_BT_STATUS, &value, &err);
+                       list_item->chk_status = value;
+                       elm_object_item_data_set(list_item->item, list_item);
+                       elm_genlist_item_update(list_item->item);
+                       bt_deinitialize();
+               }
+               setting_retm_if(ret < 0, "*** [ERR] bt_adapter_disable() ***");
        }
 
        ret = bt_deinitialize();
+       if (ret < 0) {
+               setting_get_int_slp_key(INT_SLP_SETTING_BT_STATUS, &value, &err);
+               list_item->chk_status = value;
+               elm_object_item_data_set(list_item->item, list_item);
+               elm_genlist_item_update(list_item->item);
+       }
        setting_retm_if(ret < 0, "*** [ERR] bt_deinitialize() ***");
 
+       list_item->swallow_type = SWALLOW_Type_1ICON_1PROCESS;
+       elm_object_item_data_set(list_item->item, list_item);
+       elm_genlist_item_update(list_item->item);
+
        SETTING_TRACE_END;
 }
 
-void __alternate_nfc_mode(Evas_Object *check)
+void __alternate_nfc_mode(Setting_GenGroupItem_Data *list_item, Evas_Object *check)
 {
        SETTING_TRACE_BEGIN;
        int ret;
        Eina_Bool status =  elm_check_state_get(check);
        SETTING_TRACE("nfc mode status : %d", status);
 
+       int value, err;
+
        ret = nfc_manager_initialize(NULL, NULL);
+       if (ret < 0) {
+               setting_get_bool_slp_key(BOOL_SLP_SETTING_NFC_STATUS, &value, &err);
+               list_item->chk_status = value;
+               elm_object_item_data_set(list_item->item, list_item);
+               elm_genlist_item_update(list_item->item);
+       }
        setting_retm_if(ret < 0, "*** [ERR] nfc_manager_initialize() ***");
 
-
        ret = nfc_manager_set_activation(status, NULL, NULL);
-       setting_retm_if(ret < 0,
-                       "*** [ERR] nfc_manager_set_activation() ***");
+       if (ret < 0) {
+               setting_get_bool_slp_key(BOOL_SLP_SETTING_NFC_STATUS, &value, &err);
+               list_item->chk_status = value;
+               elm_object_item_data_set(list_item->item, list_item);
+               elm_genlist_item_update(list_item->item);
+               nfc_manager_deinitialize();
+       }
+       setting_retm_if(ret < 0, "*** [ERR] nfc_manager_set_activation() ***");
 
        ret = nfc_manager_deinitialize();
+       if (ret < 0) {
+               setting_get_bool_slp_key(BOOL_SLP_SETTING_NFC_STATUS, &value, &err);
+               list_item->chk_status = value;
+               elm_object_item_data_set(list_item->item, list_item);
+               elm_genlist_item_update(list_item->item);
+       }
        setting_retm_if(ret < 0, "*** [ERR] nfc_manager_deinitialize() ***");
 
+       list_item->swallow_type = SWALLOW_Type_1ICON_1PROCESS;
+       elm_object_item_data_set(list_item->item, list_item);
+       elm_genlist_item_update(list_item->item);
+
        SETTING_TRACE_END;
 }
 
@@ -2449,7 +2701,7 @@ setting_main_click_list_wifi_mode_cb(void *data, Evas_Object *obj,
        SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
                      list_item->chk_status);
 
-       __alternate_wifi_mode(obj);
+       __alternate_wifi_mode(list_item, obj);
        SETTING_TRACE_END;
 }
 
@@ -2468,7 +2720,7 @@ setting_main_click_list_bt_mode_cb(void *data, Evas_Object *obj,
        SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
                      list_item->chk_status);
 
-       __alternate_bt_mode(obj);
+       __alternate_bt_mode(list_item, obj);
        SETTING_TRACE_END;
 }
 
@@ -2487,7 +2739,7 @@ setting_main_click_list_nfc_mode_cb(void *data, Evas_Object *obj,
        SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
                      list_item->chk_status);
 
-       __alternate_nfc_mode(obj);
+       __alternate_nfc_mode(list_item, obj);
        SETTING_TRACE_END;
 }