Fix issue
[apps/home/taskmanager.git] / src / _genlist.c
old mode 100644 (file)
new mode 100755 (executable)
index 75e7246..74bab7a
@@ -1,18 +1,20 @@
- /*
-  * Copyright 2012  Samsung Electronics Co., Ltd
-  *
-  * 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.tizenopensource.org/license
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * 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.
-  */
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ * 
+ * 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.tizenopensource.org/license
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * 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 <stdio.h>
@@ -54,8 +56,8 @@ static Elm_Genlist_Item_Class itc_separator4;
 static Elm_Genlist_Item_Class itc_separator2;
 
 static char *button_text[TS_MAX] = {
-       "IDS_COM_SK3_END_ALL_APPLICATIONS",
-       "IDS_TASKMGR_DELETE_ALL_HISTORY"
+       "IDS_TASKMGR_BUTTON_CLOSE_ALL_APPLICATIONS",
+       "IDS_TASKMGR_BUTTON_CLEAR_HISTORY_ABB"
 };
 
 static void end_all_inuse_cb(void *data, Evas_Object *obj, void *event_info);
@@ -64,24 +66,19 @@ static void delete_all_history_cb(void *data, Evas_Object *obj,
 void (*func_del[TS_MAX]) (void *data, Evas_Object *obj, void *event_info) = {
 &end_all_inuse_cb, &delete_all_history_cb};
 
-static char *icon_text[TS_MAX] = {
-       "IDS_COM_BODY_END",
-       "IDS_COM_OPT_DELETE"
-};
-
 static void end_inuse_cb(void *data, Evas_Object *obj, void *event_info);
 static void delete_history_cb(void *data, Evas_Object *obj, void *event_info);
 void (*func_end[TS_MAX]) (void *data, Evas_Object *obj, void *event_info) = {
 &end_inuse_cb, &delete_history_cb};
 
 static char *group_name[TS_MAX] = {
-       "IDS_ST_BODY_IN_USE",
-       "IDS_MUSIC_OPT_HISTORY"
+       "IDS_TASKMGR_HEADER_RUNNING",
+       "IDS_TASKMGR_MBODY_RECENTLY_USED"
 };
 
 static char *nolist_text[TS_MAX] = {
-       "IDS_TASKMGR_NO_RUNNING_TASK",
-       "IDS_TASKMGR_NO_TASK_HISTORY"
+       "IDS_TASKMGR_MBODY_NO_APPS_OPEN",
+       "IDS_TASKMGR_MBODY_NO_RECENTLY_USED_APPS"
 };
 
 void taskmanager_free_info(struct _task_info *info);
@@ -146,7 +143,7 @@ static void end_all_inuse_cb(void *data, Evas_Object *obj, void *event_info)
        char buf[_BUF_MAX] = { 0, };
 
        ad->mode = MODE_END_ALL_INUSE;
-       snprintf(buf, sizeof(buf), _("IDS_TASKMGR_WARNNING_TERMINATE_ALL_TASKS"));
+       snprintf(buf, sizeof(buf), T_("IDS_TASKMGR_POP_CLOSE_ALL_APPS_Q_THIS_MAY_CAUSE_DATA_TO_BE_LOST"));
        if (ad->popup_ask) {
                evas_object_del(ad->popup_ask);
                ad->popup_ask = NULL;
@@ -163,10 +160,8 @@ _D("func\n");
        struct appdata *ad = data;
        char buf[_BUF_MAX] = { 0, };
 
-//     refresh_app_info(ad);
-
        ad->mode = MODE_DEL_ALL_HISTORY;
-       snprintf(buf, sizeof(buf), _("IDS_TASKMGR_ASK_DELETE_ALL_HISTORY"));
+       snprintf(buf, sizeof(buf), T_("IDS_TASKMGR_POP_CLEAR_ALL_APP_HISTORY_Q"));
        if (ad->popup_ask) {
                evas_object_del(ad->popup_ask);
                ad->popup_ask = NULL;
@@ -183,14 +178,13 @@ static void end_inuse_cb(void *data, Evas_Object *obj, void *event_info)
        char buf[_BUF_MAX] = { 0, };
 
        ad->mode = MODE_END_INUSE;
-       snprintf(buf, _BUF_MAX, _("IDS_TASKMGR_ASK_TERMINATE_TASK"), info_ev->app_name);
+       snprintf(buf, _BUF_MAX, T_("IDS_TASKMGR_POP_CLOSE_PS_APP_Q_THIS_MAY_CAUSE_DATA_TO_BE_LOST"), info_ev->app_name);
        if (ad->popup_ask) {
                evas_object_del(ad->popup_ask);
                ad->popup_ask = NULL;
        }
        ad->popup_ask = _add_popup_ask(ad->win, buf, ad);
        g_egi = (void *)info_ev->it;
-//     evas_object_data_set(ad->popup_ask, "selected_egi", (void *)info_ev->it);
 }
 
 static void delete_history_cb(void *data, Evas_Object *obj, void *event_info)
@@ -203,14 +197,13 @@ static void delete_history_cb(void *data, Evas_Object *obj, void *event_info)
 
        ad->mode = MODE_DEL_HISTORY;
 
-       snprintf(buf, _BUF_MAX, _("IDS_TASKMGR_ASK_CLEAR_HISTORY"), info_ev->app_name);
+       snprintf(buf, _BUF_MAX, T_("IDS_TASKMGR_POP_CLEAR_PS_HISTORY_Q"), info_ev->app_name);
        if (ad->popup_ask) {
                evas_object_del(ad->popup_ask);
                ad->popup_ask = NULL;
        }
        ad->popup_ask = _add_popup_ask(ad->win, buf, ad);
        g_egi = (void *)info_ev->it;
-//     evas_object_data_set(ad->popup_ask, "selected_egi", (void *)info_ev->it);
 }
 
 static void nl_sel(void *data, Evas_Object *obj, void *event_info)
@@ -226,7 +219,7 @@ static char *nl_text_get(void *data, Evas_Object *obj, const char *part)
        char buf[_BUF_MAX] = { 0, };
 
        if (!strcmp(part, "elm.text")) {
-               snprintf(buf, sizeof(buf), "%s", _(nolist_text[(int)data]));
+               snprintf(buf, sizeof(buf), "%s", T_(nolist_text[(int)data]));
 
                return strdup(buf);
        }
@@ -241,6 +234,9 @@ _D("func\n");
        struct _task_info *info;
        /* parameter to block double click */
        static int selected = 0;
+       Elm_Object_Item *it = (Elm_Object_Item *) event_info;
+
+       elm_genlist_item_selected_set(it, EINA_FALSE);
 
        retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
 
@@ -270,14 +266,13 @@ _D("func\n");
        if (info->pid) {
                /* when application is alive */
                aul_resume_pid(info->pid);
-               elm_exit();
-
+               selected = 0;
        } else {
                /* when application is dead */
                if (info->pkg_name == NULL) {
                        util_show_popup_with_message(info->ad->win,
                                        3.0,
-                                       _("IDS_TASKMGR_CANNOT_LAUNCH_APPLICATION"));
+                                       T_("IDS_TASKMGR_POP_UNABLE_TO_OPEN_APPLICATION"));
                        selected = 0;
 
                } else {
@@ -288,10 +283,10 @@ _D("func\n");
                                 * since being unifyed dialer, voice call and video call
                                 */
                                aul_launch_app(info->pkg_name, NULL);
-
+                               selected = 0;
                        } else {
                                aul_launch_app(info->pkg_name, info->b);
-
+                               selected = 0;
                        }
                }
        }
@@ -332,11 +327,9 @@ static Evas_Object *_gl_content_get_app(void *data, Evas_Object *obj,
                retvm_if(rt == NULL, NULL, "Failed to add rectangle\n");
 
                evas_object_color_set(rt, 0, 0, 0, 0);
-               evas_object_size_hint_min_set(rt, 50, 50);
-//             evas_object_size_hint_min_set(rt, (int)(50.0 * scale),
-//                                           (int)(50.0 * scale));
-//             evas_object_size_hint_max_set(rt, (int)(50.0 * scale),
-//                                           (int)(50.0 * scale));
+               evas_object_size_hint_min_set(rt, 
+                                       (int)72 * elm_scale_get(), 
+                                       (int)72 * elm_scale_get());
                elm_object_part_content_set(icon, "icon_ly", rt);
 
                elm_object_part_content_set(icon, "icon", icon_ly);
@@ -345,18 +338,12 @@ static Evas_Object *_gl_content_get_app(void *data, Evas_Object *obj,
 
        } else if (!strcmp(part, "elm.icon.2")) {
                btn = elm_button_add(obj);
-               elm_object_text_set(btn, _("IDS_COM_BODY_END"));
+               elm_object_text_set(btn, S_("IDS_COM_BODY_END"));
                elm_object_style_set(btn, "default");
 
                evas_object_smart_callback_add(btn, "clicked",
                                               func_end[info->category], info);
                elm_object_focus_set(btn, EINA_FALSE);
-
-//             evas_object_size_hint_min_set(btn, (int)(90.0 * scale),
-//                                           (int)(47.0 * scale));
-//             evas_object_size_hint_max_set(btn, (int)(90.0 * scale),
-//                                           (int)(47.0 * scale));
-
                evas_object_propagate_events_set(btn, EINA_FALSE);
 
                return btn;
@@ -406,7 +393,7 @@ _D("func\n");
 static char *_bl_text_get(void *data, Evas_Object *obj, const char *part)
 {
        if (!strcmp(part, "elm.text")) {
-               return strdup(_(button_text[(int)data]));
+               return strdup(T_(button_text[(int)data]));
 
        }
        return NULL;
@@ -423,16 +410,13 @@ static Evas_Object *_bl_content_get(void *data, Evas_Object *obj,
                btn = elm_button_add(obj);
                elm_object_style_set(btn, "default");
 
-               elm_object_text_set(btn, _(button_text[(int)data]));
+               elm_object_text_set(btn, T_(button_text[(int)data]));
                evas_object_smart_callback_add(btn, "clicked",
                                               func_del[(int)data], ad);
                elm_object_focus_set(btn, EINA_FALSE);
 
                evas_object_size_hint_min_set(btn, 0, 50);
                evas_object_size_hint_max_set(btn, 0, 50);
-//             evas_object_size_hint_min_set(btn, 0, (int)(47.0 * scale));
-//             evas_object_size_hint_max_set(btn, 0, (int)(47.0 * scale));
-
                evas_object_propagate_events_set(btn, EINA_FALSE);
 
                return btn;
@@ -446,8 +430,8 @@ static char *_gl_text_get_title(void *data, Evas_Object *obj, const char *part)
        char buf[_BUF_MAX];
 
        if (!strcmp(part, "elm.text")) {
-               snprintf(buf, sizeof(buf), "%s (%d)", _(group_name[(int)data]),
-                        _get_grp_cnt((int)data));
+               snprintf(buf, sizeof(buf), "%s (%d)",
+                               T_(group_name[(int)data]), _get_grp_cnt((int)data));
                return strdup(buf);
        }
        return NULL;
@@ -500,11 +484,9 @@ static Evas_Object *_gl_content_get_his(void *data, Evas_Object *obj,
                retvm_if (rt == NULL, NULL, "Failed to add rectangle\n");
 
                evas_object_color_set(rt, 0, 0, 0, 0);
-               evas_object_size_hint_min_set(rt, 50, 50);
-//             evas_object_size_hint_min_set(rt, (int)(50.0 * scale),
-//                                           (int)(50.0 * scale));
-//             evas_object_size_hint_max_set(rt, (int)(50.0 * scale),
-//                                           (int)(50.0 * scale));
+               evas_object_size_hint_min_set(rt, 
+                                       (int)72 * elm_scale_get(), 
+                                       (int)72 * elm_scale_get());
                elm_object_part_content_set(icon, "icon_ly", rt);
 
                elm_object_part_content_set(icon, "icon", icon_ly);
@@ -513,18 +495,12 @@ static Evas_Object *_gl_content_get_his(void *data, Evas_Object *obj,
 
        } else if (!strcmp(part, "elm.icon.2")) {
                btn = elm_button_add(obj);
-               elm_object_text_set(btn, _("IDS_COM_OPT_DELETE"));
+               elm_object_text_set(btn, S_("IDS_COM_OPT_DELETE"));
                elm_object_style_set(btn, "default");
 
                evas_object_smart_callback_add(btn, "clicked",
                                               func_end[info->category], info);
                elm_object_focus_set(btn, EINA_FALSE);
-
-       //      evas_object_size_hint_min_set(btn, (int)(90.0 * scale),
-       //                                    (int)(47.0 * scale));
-       //      evas_object_size_hint_max_set(btn, (int)(90.0 * scale),
-       //                                    (int)(47.0 * scale));
-
                evas_object_propagate_events_set(btn, EINA_FALSE);
 
                return btn;
@@ -539,11 +515,11 @@ void _set_itc(void)
        itc_gl.item_style = "grouptitle";
        itc_gl.func.text_get = _gl_text_get_title;
 
-       itc_dl.item_style = "2text.2icon.4";
+       itc_dl.item_style = "2text.2icon.7";
        itc_dl.func.text_get = _gl_text_get_app;
        itc_dl.func.content_get = _gl_content_get_app;
 
-       itc_hl.item_style = "1text.2icon.4";
+       itc_hl.item_style = "1text.2icon.1";
        itc_hl.func.text_get = _gl_text_get_his;
        itc_hl.func.content_get = _gl_content_get_his;
 
@@ -551,7 +527,6 @@ void _set_itc(void)
        itc_separator2.item_style = "dialogue/seperator.2";
 
        itc_bl.item_style = "dialogue/bg/1icon";
-//     itc_bl.item_style = "1icon";
        itc_bl.func.content_get = _bl_content_get;
 
        itc_nl.item_style = "1text";
@@ -633,6 +608,7 @@ _D("func\n");
                                                (void *)i, git,
                                                ELM_GENLIST_ITEM_NONE,
                                                nl_sel, NULL);
+                       elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
                }
        }
        return 0;
@@ -705,17 +681,28 @@ _D("func\n");
 void _set_genlist(struct appdata *ad)
 {
 _D("func\n");
-       int ret;
        retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
+       int ret = AUL_R_ERROR;
+       int retry_cnt = 0;
+       int sleep_value = 1000;
 
        _init_grp_cnt();
 
-       aul_app_get_running_app_info(runapp_info_get, ad);
-       taskmanager_get_history_app_info(ad);
-       ret = _set_genlist_from_eina(ad);
-       if (ret < 0) {
-               elm_exit();
+       while (ret != AUL_R_OK && retry_cnt < 5) {
+               usleep(sleep_value);
+               ret = aul_app_get_running_app_info(runapp_info_get, ad);
+
+               if (ret != AUL_R_OK) {
+                       _D("Fail to get running app information from ail");
+               }
+
+               retry_cnt++;
+               sleep_value *= 2;
        }
+
+       taskmanager_get_history_app_info(ad);
+       _set_genlist_from_eina(ad);
+
 }
 
 void _init_pthread(void)
@@ -801,13 +788,13 @@ _D("func\n");
        ad->ending = EINA_TRUE;
 
        EINA_LIST_FOREACH_SAFE(ad->applist[TS_INUSE], l, l_next, info) {
+               _D("applist pid : %d", info->pid);
                if (info->it == g_egi) {
+                       _D("matched applist pid : %d", info->pid);
                        if (info->pid > 0) {
                                if (aul_terminate_pid(info->pid) < 0) {
                                        kill(info->pid, SIGKILL);
                                }
-//                             ad->applist[TS_INUSE] =
-//                                     eina_list_remove_list(ad->applist[TS_INUSE], l);
                        }
                        break;
                }
@@ -848,13 +835,12 @@ int response_end_all_inuse(struct appdata *ad)
 
        EINA_LIST_FOREACH(ad->applist[TS_INUSE], l, info) {
                if (info != NULL) {
+                       _D("applist pid : %d", info->pid);
                        if (info->pid > 0) {
                                if (aul_terminate_pid(info->pid) < 0) {
                                        kill(info->pid, SIGKILL);
                                }
                                _D("terminated\n");
-//                             ad->applist[TS_INUSE] =
-//                                     eina_list_remove_list(ad->applist[TS_INUSE], l);
                        }
                }
        }
@@ -872,6 +858,7 @@ int response_del_history(struct appdata *ad)
 
        _show_progressbar(ad);
        EINA_LIST_FOREACH_SAFE(ad->applist[TS_HISTORY], l, l_next, info) {
+               _D("history applist pid : %d", info->pid);
                if (info->it == g_egi) {
 
                        if (rua_init() == -1) {
@@ -951,6 +938,7 @@ int response_kill_inuse(struct appdata *ad)
        _show_progressbar(ad);
 
        EINA_LIST_FOREACH_SAFE(ad->applist[TS_INUSE], l, l_next, info) {
+               _D("kill applist pid : %d", info->pid);
                if (info->it == g_egi) {
                        if (info->pid > 0) {
                                kill(info->pid, SIGKILL);
@@ -978,6 +966,7 @@ int response_kill_all_inuse(struct appdata *ad)
        _show_progressbar(ad);
 
        EINA_LIST_FOREACH(ad->applist[TS_INUSE], l, info) {
+               _D("kill all applist pid : %d", info->pid);
                if (info != NULL) {
                        if (info->pid > 0) {
                                kill(info->pid, SIGKILL);