Merge "change manifest for smack"
[apps/core/preloaded/settings.git] / src / setting-main.c
index 827d08e..bc8d9ab 100755 (executable)
@@ -26,6 +26,7 @@
 #include <setting-main.h>
 #include <setting-plugin.h>
 
+#define PLUGIN_PATH_FORMAT             "/opt/apps/%s/setting/setting.xml"
 
 typedef struct DrawAppInfo DrawAppInfo;
 typedef struct DrawAppInfo
@@ -432,7 +433,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,
@@ -444,7 +445,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)
@@ -590,6 +591,8 @@ void __load_connectivity_menu_list(void *data, Cfg_Item_Position inputPos, Evas_
                                        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 */
                                }
@@ -773,6 +776,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 =
@@ -952,13 +957,13 @@ 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;
-       // /opt/apps/
        char path[512];
 
-       if (snprintf(path, 512, "/opt/apps/%s/setting/setting.xml", pkgname) < 0)
+       if (snprintf(path, 512, PLUGIN_PATH_FORMAT, pkgname) < 0)
                return false;
 
        struct stat st;
@@ -974,7 +979,6 @@ bool is_3rdapp_installed_setting_cfg(char* pkgname)
        return result_opt;
 }
 
-
 /**
  * @param data
  */
@@ -989,18 +993,25 @@ static void draw_3rdapp(void* data, char* name, char* pkgname)
        //3rd cfg
        char fullpath[512];
 
-       if (snprintf(fullpath, 512, "/opt/apps/%s/setting/setting.xml", pkgname) < 0)
+       if (snprintf(fullpath, 512, PLUGIN_PATH_FORMAT, 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,
@@ -1395,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);
 }
 
 /**
@@ -1818,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);
@@ -1846,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;
@@ -1927,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);
@@ -2165,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)
 {
@@ -2182,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;
@@ -2197,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)
 {
@@ -2216,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); */
@@ -2227,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;