add default code for flight mode
[apps/core/preloaded/settings.git] / src / setting-main.c
index 2261772..61f31f4 100755 (executable)
@@ -1,24 +1,19 @@
 /*
  * 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>
@@ -562,6 +557,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 +739,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 +821,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 +846,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 +955,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 +1006,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 +1051,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;
 }
 
@@ -1078,6 +1107,8 @@ bool is_3rdapp_installed_setting_cfg(char* pkgname)
 
 /**
  * @param data
+ * ex) name : AppSetting4
+ * ex) pkgname : UBKFwQidax.AppSetting4
  */
 static void draw_3rdapp(void* data, char* name, char* pkgname)
 {
@@ -1096,21 +1127,15 @@ 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;
@@ -1192,25 +1217,31 @@ static int get_downloadapp_list(void* data)
        ail_filter_h f;
 
        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)
+       if (pinfo) {
+               pinfo->ncount = 0;
+               pinfo->draw_app = draw_3rdapp;
+               pinfo->data = ad;
+
+               if (ail_filter_new(&f) == AIL_ERROR_OK)
                {
-                       SETTING_TRACE("ail filter error");
-                       return 0;
-               }
+                       if (ail_filter_add_bool(f, AIL_PROP_NODISPLAY_BOOL, false) != AIL_ERROR_OK)
+                       {
+                               SETTING_TRACE("ail filter error");
 
-               ail_filter_list_appinfo_foreach(f, __download_apps_cb, pinfo);
-               //---------------------------------------------------------------
-               ail_filter_destroy(f);
-       }
-       ncount = pinfo->ncount;
+                               free(pinfo);
+                               pinfo = NULL;
+
+                               ail_filter_destroy(f);
+                               return 0;
+                       }
+
+                       ail_filter_list_appinfo_foreach(f, __download_apps_cb, pinfo);
+                       //---------------------------------------------------------------
+                       ail_filter_destroy(f);
+               }
+               ncount = pinfo->ncount;
 
-       if (pinfo) {
                free(pinfo);
                pinfo = NULL;
        }
@@ -1427,6 +1458,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;
@@ -1442,9 +1526,12 @@ static bool __setting_create_main_view(void *data)
        elm_object_content_set(conform, ad->ly_main);
        evas_object_show(conform);
 
-       //elm_win_conformant_set(ad->win_main, EINA_TRUE);
+    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);
 
@@ -1616,6 +1703,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;
@@ -1689,6 +1780,7 @@ static int setting_main_create(void *cb)
 
        setting_view_main.is_create = 1;
 
+       setting_drawer_list_init();
        return SETTING_RETURN_SUCCESS;
 }
 
@@ -1704,6 +1796,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;
@@ -1746,6 +1842,9 @@ static int setting_main_destroy(void *cb)
 
        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;
@@ -1870,8 +1969,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,
@@ -2098,25 +2199,23 @@ 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;
-       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;
+       ad->plugin_path = strdup(selected_item->sub_desc);
+       SETTING_TRACE(" >> SELECTED plugin name : %s \n", ad->plugin_path);
 
-               #if 0
-               if(ad->plugin_path)
-               {
-                       free(ad->plugin_path);
-                       ad->plugin_path = NULL;
-               }
-               #endif
-       }
+       setting_dbus_handler_init( ad );
+
+       #if 1
+       PluginNode* plugin_node = setting_plugin_create(ad);
+       plugin_node->plugin_path = strdup(ad->plugin_path);
+       setting_plugin_load(plugin_node, (const char *)plugin_node->plugin_path);
+
+       ad->plugin_node = plugin_node; // the selected plugin name
+       #endif
 }
 
 /**
@@ -2134,7 +2233,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);
 }
 
 /**