diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/_cpu.c | 111 | ||||
-rwxr-xr-x | src/_cpu.h | 28 | ||||
-rwxr-xr-x | src/_eina.c | 310 | ||||
-rwxr-xr-x | src/_eina.h | 36 | ||||
-rwxr-xr-x | src/_genlist.c | 877 | ||||
-rwxr-xr-x | src/_genlist.h | 45 | ||||
-rwxr-xr-x | src/_info.c | 134 | ||||
-rwxr-xr-x | src/_info.h | 28 | ||||
-rwxr-xr-x | src/_logic.c | 414 | ||||
-rwxr-xr-x | src/_logic.h | 33 | ||||
-rwxr-xr-x | src/_progressbar.c | 51 | ||||
-rwxr-xr-x | src/_progressbar.h | 28 | ||||
-rwxr-xr-x | src/_util_efl.c | 288 | ||||
-rwxr-xr-x | src/_util_efl.h | 43 | ||||
-rwxr-xr-x | src/_util_log.h | 63 | ||||
-rw-r--r-- | src/genlist.c | 478 | ||||
-rw-r--r-- | src/genlist_item.c | 817 | ||||
-rwxr-xr-x | src/recent_apps.c | 804 | ||||
-rwxr-xr-x | src/task-mgr-lite.c | 477 | ||||
-rwxr-xr-x | src/taskmanager.c | 306 | ||||
-rwxr-xr-x | src/taskmanager.h | 135 |
21 files changed, 2576 insertions, 2930 deletions
diff --git a/src/_cpu.c b/src/_cpu.c deleted file mode 100755 index 0aaa89d..0000000 --- a/src/_cpu.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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 <unistd.h> -#include <stdio.h> -#include <sys/time.h> - -#include "_util_log.h" -#include "_cpu.h" - -int _get_sysconf(int *ncpu, long *tick) -{ - *ncpu = sysconf(_SC_NPROCESSORS_ONLN); - *ncpu = *ncpu < 1 ? 1 : *ncpu; - *tick = sysconf(_SC_CLK_TCK); - return 0; -} - -int _get_stat_info(pid_t pid, unsigned int *ut, unsigned int *st) -{ - FILE *fp; - char buf[128] = {0, }; - unsigned long cutime, cstime; - int i; - int ret = -1; - - snprintf(buf, sizeof(buf), "/proc/%d/stat", (int)pid); - - *ut = *st = 0; - cutime = cstime = 0; - fp = fopen(buf, "r"); - if (fp) { - retvm_if(fp == NULL, -1, "Failed to open %s\n", buf); - ret = fscanf(fp, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lu %lu %ld %ld", - ut, st, &cutime, &cstime); - if(ret < 0) - { - _E("Failed to fscanf() \n"); - fclose(fp); - return -1; - } - *ut += cutime; - *st += cstime; - fclose(fp); - - return 0; - } - return -1; -} - -double _get_cpu_ratio(void *data, int ncpu, long tick) -{ - struct _task_info *tinfo = (struct _task_info *)data; - unsigned int utime, stime; - struct timeval timev; - double usr, sys; - int r; - unsigned long long jiffy; - - retvm_if(tinfo == NULL, -1, "Invalid argument: tinfo is NULL\n"); - - utime = 0; - stime = 0; - r = _get_stat_info(tinfo->pid, &utime, &stime); - if (r < 0) { - _D("failed\n"); - return 0; - } - /* retvm_if(r < 0, -1, "Failed to get stat info\n"); */ - - gettimeofday(&timev, NULL); - jiffy = (timev.tv_sec - tinfo->oldtimev.tv_sec) * tick + - ((timev.tv_usec - tinfo->oldtimev.tv_usec) * tick) / 1000000; - - if(utime >= tinfo->oldutime) { - usr = ((double)(utime - tinfo->oldutime) * 100 / jiffy) / ncpu; - } else { - usr = 0.0; - } - if(stime >= tinfo->oldstime) { - sys = ((double)(stime - tinfo->oldstime) * 100 / jiffy) / ncpu; - } else { - sys = 0.0; - } - - /* _D("per:%lf] %lf %lf/ %u %u/ %u %u/ %u\n", - usr+sys, usr, sys, utime, stime, tinfo->oldutime, tinfo->oldstime, jiffy); - */ - - tinfo->oldutime = utime; - tinfo->oldstime = stime; - tinfo->oldtimev = timev; - - return usr + sys; -} - - diff --git a/src/_cpu.h b/src/_cpu.h deleted file mode 100755 index 2a95bf7..0000000 --- a/src/_cpu.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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. - */ - - -#ifndef __TASKMANAGER_CPU_H__ -#define __TASKMANAGER_CPU_H__ - -#include "taskmanager.h" - -int _get_sysconf(int *ncpu, long *tick); -double _get_cpu_ratio(void *data, int ncpu, long tick); - -#endif -/* __TASKMANAGER_CPU_H__ */ diff --git a/src/_eina.c b/src/_eina.c deleted file mode 100755 index dad2109..0000000 --- a/src/_eina.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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 <stdlib.h> -#include <string.h> -#include <stdio.h> - -#include <Eina.h> -#include <ail.h> -#include <aul.h> -#include <rua.h> - -#include "taskmanager.h" -#include "_util_log.h" - -#define TASKMANAGER_ICON_NAME "org.tizen.taskmgr.png" - -static int grp_cnt[TS_MAX]; - -void _init_grp_cnt(void) -{ - int i; - - for(i = 0; i < TS_MAX; i++) { - grp_cnt[i] = 0; - } -} - -int _get_grp_cnt(int which) -{ - return grp_cnt[which]; -} - -int runapp_info_get(const aul_app_info *ainfo, void *data) -{ - ail_appinfo_h handle; - ail_error_e ret; - - char *valc; - bool valb; - char buf[1024] = { 0, }; - struct appdata *ad = data; - struct _task_info *info; - - retvm_if(ainfo == NULL, -1, "Invalid argument: ainfo is NULL\n"); - retvm_if(data == NULL, -1, "Invalid argument: data is NULL\n"); - - retvm_if(ainfo->pid <= 0, -1, "Invalid pid(%u)\n", ainfo->pid); - - /* filtering */ - if (ainfo->pid == getpid()) { - return 0; - } - - retvm_if(ainfo->pkg_name == NULL, 0, "Invalid pkg_name(%s)\n", ainfo->pkg_name); - -// _D("running app is (%s)\n", ainfo->pkg_name); - ret = ail_package_get_appinfo(ainfo->pkg_name, &handle); - retvm_if(ret != AIL_ERROR_OK, -1, - "Failed to get appinfo, pkg_name:%s\n", ainfo->pkg_name); - - ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &valb); - if (valb == 0) { - goto exit; - } - info = calloc(1, sizeof(struct _task_info)); - if (info == NULL) { - _E("Failed to calloc task_info\n"); - goto exit; - } - info->pkg_name = strdup(ainfo->pkg_name); - - ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &valc); - if (valc == NULL) { - _D("%s: Failed to get ail name\n", ainfo->pkg_name); - valc = "Unknown"; - } - info->app_name = strdup(valc); - - ret = ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &valc); - if (valc == NULL || (ecore_file_exists(valc) == EINA_FALSE)) { - _D("%s: Failed to get ail icon\n", ainfo->pkg_name); - valc = TASKMANAGER_ICON_NAME; - } - - snprintf(buf, sizeof(buf), "%s", valc); - info->icn_path = strdup(buf); -// _D("get app name[%s] set [%s], icon path[%s]\n", ainfo->pkg_name, info->app_name, buf); - - info->ad = ad; - info->pid = ainfo->pid; - info->category = TS_INUSE; -// info->mem_total = ad->mem_total; - _D("%s/pid(%d)\n", info->app_name, info->pid); - - ad->applist[TS_INUSE] = eina_list_prepend(ad->applist[TS_INUSE], info); - grp_cnt[TS_INUSE]++; - - exit: - ret = ail_package_destroy_appinfo(handle); - retvm_if(ret != AIL_ERROR_OK, -1, "Failed to destroy appinfo\n"); - return 0; -} - -int taskmanager_get_history_app_info(void *data) -{ - struct appdata *ad = data; - struct _task_info *info, *info_r; - Eina_List *l_r; - int flag = 0; - - struct rua_rec rec_result = { 0, }; - char **table = NULL; - char buf[1024] = { 0, }; - int nrows = 0, ncols = 0; - int row = 0; - - ail_appinfo_h handle; - ail_error_e ret; - bool valb; - char *valc; - - retvm_if(data == NULL, -1, "Invalid argument: data is NULL\n"); - retvm_if(rua_init() == -1, -1, "Failed to rua_init\n"); - - if (rua_history_load_db(&table, &nrows, &ncols) == -1) { - rua_fini(); - return -1; - } - - if (nrows == 0) { - rua_history_unload_db(&table); - rua_fini(); - return 0; - } - - ad->applist[TS_HISTORY] = eina_list_nth_list(ad->applist[TS_HISTORY], 0); - for (row = 0; row < nrows; row++) { - rua_history_get_rec(&rec_result, table, nrows, ncols, row); - - /* filtering - * pkg_name could be NULL or 0 length because it is launch by fork. - */ - if (rec_result.pkg_name == NULL - || strlen(rec_result.pkg_name) < 1) { - continue; - } - - _D("%s\n", rec_result.pkg_name); - ret = ail_package_get_appinfo(rec_result.pkg_name, &handle); - if (ret != AIL_ERROR_OK) { - _D("Failed to get appinfo(%d)\n", ret); - continue; - } - - ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &valb); - if(valb == 0) { - _D("ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &valb) => valb is 0"); - goto cont; - } - - EINA_LIST_FOREACH(ad->applist[TS_INUSE], l_r, info_r) { - if (info_r != NULL) { - if (!strcmp - (rec_result.pkg_name, info_r->pkg_name)) { - flag = 1; - break; - } - } - } - - if (flag == 0) { - info = calloc(1, sizeof(struct _task_info)); - if(info == NULL) { - _E("Failed to calloc _task_info\n"); - if(handle) { - ret = ail_package_destroy_appinfo(handle); - } - return -1; - } - - info->pkg_name = strdup(rec_result.pkg_name); - - ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &valc); - if (valc == NULL) { - _D("Failed to get ail name\n"); - valc = "Unknown"; - } - info->app_name = strdup(valc); - _D("%s\n", info->app_name); - - ret = ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &valc); - if (valc == NULL || (ecore_file_exists(valc) == EINA_FALSE)) { - _D("Failed to get ail icon\n"); - valc = TASKMANAGER_ICON_NAME; - } - snprintf(buf, sizeof(buf), "%s", valc); - info->icn_path = strdup(buf); - _D("%s\n", info->icn_path); - - info->ad = ad; - info->pid = 0; - info->category = TS_HISTORY; - - if (rec_result.arg != NULL) { - if (strlen(rec_result.arg) > 0) { - info->b = bundle_decode( - (const bundle_raw *)rec_result.arg, - strlen(rec_result.arg)); - } - } - - ad->applist[TS_HISTORY] = - eina_list_append(ad->applist[TS_HISTORY], info); - grp_cnt[TS_HISTORY]++; - - } - - flag = 0; - -cont: - ret = ail_package_destroy_appinfo(handle); - } - - rua_history_unload_db(&table); - rua_fini(); - - return 0; -} - -int _free_einalist_all(struct appdata *ad) -{ - Eina_List *l; - struct _task_info *info = NULL; - int i; - - if (ad == NULL) { - _E("[Error] Invalid argument: appdata is NULL\n"); - return -1; - } - - for (i = 0; i < TS_MAX; i++) { - if (ad->applist[i] == NULL) - continue; - - EINA_LIST_FOREACH(ad->applist[i], l, info) { - if (info != NULL) { - if (info->b) - bundle_free(info->b); - - taskmanager_free_info(info); - info = NULL; - } - } - - eina_list_free(ad->applist[i]); - ad->applist[i] = NULL; - } - - return 0; -} - -int _subt_einalist_item(struct appdata *ad, int pid) -{ -_D("func\n"); - Eina_List *l; - int ret = -1; - struct _task_info *info; - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - retvm_if(ad->applist[TS_INUSE] == NULL, -1, "applist is NULL\n"); - - EINA_LIST_FOREACH(ad->applist[TS_INUSE], l, info) { - if (info == NULL) { - _E("Failed to get info\n"); - continue; - } - - if (pid > 0 && pid == info->pid) { - if(info->app_name) _D("killed [%s]\n", info->app_name); - ad->applist[TS_INUSE] = - eina_list_remove_list(ad->applist[TS_INUSE], l); - taskmanager_free_info(info); - info = NULL; - ret = 0; - } - } - return ret; -} - - - - diff --git a/src/_eina.h b/src/_eina.h deleted file mode 100755 index 98bf76f..0000000 --- a/src/_eina.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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. - */ - - - - -#ifndef __TASKMANAGER_EINA_H__ -#define __TASKMANAGER_EINA_H__ - -#include <aul.h> - -#include "taskmanager.h" - -void _init_grp_cnt(void); -int _get_grp_cnt(int which); -int runapp_info_get(const aul_app_info *ainfo, void *data); -int taskmanager_get_history_app_info(void *data); -int _free_einalist_all(struct appdata *ad); -int _subt_einalist_item(struct appdata *ad, int pid); - -#endif -/* __TASKMANAGER_EINA_H__ */ diff --git a/src/_genlist.c b/src/_genlist.c deleted file mode 100755 index 2cb208c..0000000 --- a/src/_genlist.c +++ /dev/null @@ -1,877 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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> -#include <unistd.h> -#include <appcore-efl.h> -#include <vconf.h> -#include <utilX.h> -#include <aul.h> -#include <rua.h> -#include <Ecore_X.h> -#include <Eina.h> -#include <unistd.h> -#include <time.h> -#include <sys/time.h> -#include <pthread.h> - -#include "taskmanager.h" -#include "_genlist.h" -#include "_util_log.h" -#include "_util_efl.h" -#include "_logic.h" -#include "_cpu.h" -#include "_eina.h" -#include "_info.h" -#include "_progressbar.h" - -static Elm_Object_Item *g_egi; - -/* group list:gl, data list:dl, button list:bl, no list: nl */ -static Elm_Genlist_Item_Class itc_gl; -static Elm_Genlist_Item_Class itc_hl; -static Elm_Genlist_Item_Class itc_dl; -static Elm_Genlist_Item_Class itc_bl; -static Elm_Genlist_Item_Class itc_nl; -static Elm_Genlist_Item_Class itc_separator4; -static Elm_Genlist_Item_Class itc_separator2; - -static char *button_text[TS_MAX] = { - "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); -static void delete_all_history_cb(void *data, Evas_Object *obj, - void *event_info); -void (*func_del[TS_MAX]) (void *data, Evas_Object *obj, void *event_info) = { -&end_all_inuse_cb, &delete_all_history_cb}; - -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_TASKMGR_HEADER_RUNNING", - "IDS_TASKMGR_MBODY_RECENTLY_USED" -}; - -static char *nolist_text[TS_MAX] = { - "IDS_TASKMGR_MBODY_NO_APPS_OPEN", - "IDS_TASKMGR_MBODY_NO_RECENTLY_USED_APPS" -}; - -static Evas_Object *group_btn[TS_MAX]; - -void taskmanager_free_info(struct _task_info *info); -Eina_Bool _update_list(void *data); - -static void clear_genlist(void *data) -{ - ret_if(data == NULL); - - struct appdata *ad = data; - - if (ad->gl) { - elm_genlist_clear(ad->gl); - } -} - -void clear_task_manager_list(void *data) -{ - ret_if(data == NULL); - - struct appdata *ad = data; - _free_einalist_all(ad); - clear_genlist(ad); -} - -static void app_genlist_item_update(void *data) -{ - ret_if(data == NULL); - - struct appdata *ad = (struct appdata *)data; - - Elm_Object_Item *it_r; - Eina_List *realized_item_list, *l_r; - unsigned int cnt = 0; - - realized_item_list = elm_genlist_realized_items_get(ad->gl); - cnt = eina_list_count(realized_item_list); - if (cnt > 0) { - EINA_LIST_FOREACH(realized_item_list, l_r, it_r) { - if (it_r != NULL) { - elm_genlist_item_update(it_r); - } - } - } -} - -Eina_Bool alert_app_info(void *data) -{ - retv_if(data == NULL, -1); - - struct appdata *ad = (struct appdata *)data; - - app_genlist_item_update(ad); - return ECORE_CALLBACK_CANCEL; -} - -static void end_all_inuse_cb(void *data, Evas_Object *obj, void *event_info) -{ - ret_if(data == NULL); - - struct appdata *ad = data; - char buf[_BUF_MAX] = { 0, }; - - ad->mode = MODE_END_ALL_INUSE; - 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; - } - if (!ad->flag_select) { - ad->popup_ask = _add_popup_ask(ad->win, buf, ad); - } -} - -static void -delete_all_history_cb(void *data, Evas_Object *obj, void *event_info) -{ -_D("func\n"); - ret_if(data == NULL); - - struct appdata *ad = data; - char buf[_BUF_MAX] = { 0, }; - - ad->mode = MODE_DEL_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; - } - if (!ad->flag_select) { - ad->popup_ask = _add_popup_ask(ad->win, buf, ad); - } -} - -static void end_inuse_cb(void *data, Evas_Object *obj, void *event_info) -{ - ret_if(data == NULL); - - struct _task_info *info_ev = (struct _task_info *)data; - struct appdata *ad = info_ev->ad; - char buf[_BUF_MAX] = { 0, }; - - ad->mode = MODE_END_INUSE; - snprintf(buf, _BUF_MAX, T_("IDS_TASKMGR_POP_CLOSE_PS_APP_Q_THIS_MAY_CAUSE_DATA_TO_BE_LOST"), - evas_textblock_text_utf8_to_markup(NULL, info_ev->app_name)); - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - if (!ad->flag_select) { - ad->popup_ask = _add_popup_ask(ad->win, buf, ad); - } - g_egi = (void *)info_ev->it; -} - -static void delete_history_cb(void *data, Evas_Object *obj, void *event_info) -{ - ret_if(data == NULL); - - struct _task_info *info_ev = (struct _task_info *)data; - struct appdata *ad = info_ev->ad; - char buf[_BUF_MAX] = { 0, }; - - ad->mode = MODE_DEL_HISTORY; - - snprintf(buf, _BUF_MAX, T_("IDS_TASKMGR_POP_CLEAR_PS_HISTORY_Q"), - evas_textblock_text_utf8_to_markup(NULL, info_ev->app_name)); - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - if (!ad->flag_select) { - ad->popup_ask = _add_popup_ask(ad->win, buf, ad); - } - g_egi = (void *)info_ev->it; -} - -static void nl_sel(void *data, Evas_Object *obj, void *event_info) -{ - _D("func\n"); - Elm_Object_Item *item = (Elm_Object_Item *) event_info; - elm_genlist_item_selected_set(item, EINA_FALSE); - return; -} - -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", T_(nolist_text[(int)data])); - - return strdup(buf); - } - return NULL; -} - -static void _gl_sel_app(void *data, Evas_Object *obj, void *event_info) -{ - _D("func\n"); - Elm_Object_Item *item = (Elm_Object_Item *) event_info; - struct appdata *ad = (struct appdata *)data; - struct _task_info *info; - /* parameter to block double click */ - static int selected = 0; - Elm_Object_Item *it = (Elm_Object_Item *) event_info; - int ret = -1; - - ad->flag_select = EINA_TRUE; - - elm_genlist_item_selected_set(it, EINA_FALSE); - - retm_if(ad == NULL, "Invalid argument: appdata is NULL\n"); - - if (ad->update_timer) { - ecore_timer_del(ad->update_timer); - ad->update_timer = NULL; - } - - if (selected == 1) - return; - selected = 1; - - if (item == NULL) { - _E("[Error] Cannot find genlist item\n"); - selected = 0; - return; - } - - info = (struct _task_info *)elm_object_item_data_get(item); - if (info == NULL) { - _E("[Error] Cannot get item data: info\n"); - selected = 0; - return; - } - if (info->ad == NULL) { - _E("[Error] Cannot get item data: info->ad\n"); - selected = 0; - return; - } - - if (info->pid) { - /* when application is alive */ - ret = aul_resume_pid(info->pid); - selected = 0; - } else { - /* when application is dead */ - if (info->pkg_name == NULL) { - util_show_popup_with_message(info->ad->win, - 3.0, - T_("IDS_TASKMGR_POP_UNABLE_TO_OPEN_APPLICATION")); - selected = 0; - - } else { - _unset_notification_level(info->ad->win); - - if (!strcmp(info->pkg_name, "org.tizen.phone")) { - /* exception : Because dialer doesn't need bundle - * since being unifyed dialer, voice call and video call - */ - ret = aul_open_app(info->pkg_name); - selected = 0; - } else { - ret = aul_open_app(info->pkg_name); - selected = 0; - } - } - } - if(ret == 0) { - _D("exit after 0.3 sec\n"); - ad->exit_timer = ecore_timer_add(0.3, _exit_cb, ad); - } -} - - -static Evas_Object *_gl_content_get_app(void *data, Evas_Object *obj, - const char *part) -{ - struct _task_info *info = (struct _task_info *)data; - char buf[_BUF_MAX] = { 0, }; - - Evas_Object *icon = NULL; - Evas_Object *btn = NULL; - - Evas_Object *rt, *icon_ly = NULL; - - retvm_if(data == NULL, NULL, "Invalid argument: task info is NULL\n"); - - if (!strcmp(part, "elm.icon.1")) { - snprintf(buf, sizeof(buf), "%s", info->icn_path); - retvm_if(buf == NULL, NULL, "%s icon is NULL\n", info->app_name); - if (!ecore_file_exists(buf) || strlen(buf) < 4) - snprintf((char *)buf, (size_t) sizeof(buf), - (const char *)IMAGEDIR "/icon_taskmgr.png"); - - icon = elm_icon_add(obj); - elm_image_file_set(icon, buf, NULL); - elm_image_preload_disabled_set(icon, EINA_TRUE); - - evas_object_size_hint_min_set(icon, - (int)72 * elm_config_scale_get(), - (int)72 * elm_config_scale_get()); - - return icon; - - } else if (!strcmp(part, "elm.icon.2")) { - btn = elm_button_add(obj); - /*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_propagate_events_set(btn, EINA_FALSE);*/ - - elm_object_style_set(btn, "icon_minus"); - evas_object_smart_callback_add(btn, "clicked", - func_end[info->category], info); - evas_object_propagate_events_set(btn, EINA_FALSE); - - return btn; - } - - return NULL; -} - -static char *_gl_text_get_app(void *data, Evas_Object *obj, const char *part) -{ - struct _task_info *info = (struct _task_info *)data; - char buf[_BUF_MAX] = { 0, }; - - retvm_if(data == NULL, NULL, "Invalid argument: task info is NULL\n"); - retvm_if(part == NULL, NULL, "Invalid argument: part is NULL\n"); - - if (!strcmp(part, "elm.text")) { - snprintf(buf, _BUF_MAX, "%s", info->app_name); - return strdup(buf); - - } - return NULL; -} - -static void _bl_sel(void *data, Evas_Object *obj, void *event_info) -{ - _D("func\n"); - Elm_Object_Item *item = (Elm_Object_Item *) event_info; - elm_genlist_item_selected_set(item, EINA_FALSE); - - _D("DBG : %x", group_btn[(int)data]); - elm_object_focus_set(group_btn[(int)data], EINA_TRUE); -} - -static Evas_Object *_bl_content_get(void *data, Evas_Object *obj, - const char *part) -{ - Evas_Object *btn = NULL; - struct appdata *ad = evas_object_data_get(obj, "appdata"); - retv_if(ad == NULL, NULL); - - if (part && !strcmp(part, "elm.icon")) { - - btn = elm_button_add(obj); - retvm_if(btn == NULL, NULL, "elm_button_add() failed"); - elm_object_style_set(btn, "default"); - - elm_object_text_set(btn, T_(button_text[(int)data])); - evas_object_smart_callback_add(btn, "clicked", - func_del[(int)data], ad); - - evas_object_size_hint_min_set(btn, 0, 50); - evas_object_size_hint_max_set(btn, 0, 50); - evas_object_propagate_events_set(btn, EINA_FALSE); - - _D("DBG : %x", btn); - group_btn[(int)data] = btn; - - return btn; - - } - return NULL; -} - -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)", - T_(group_name[(int)data]), _get_grp_cnt((int)data)); - return strdup(buf); - } - return NULL; -} - -static char *_gl_text_get_his(void *data, Evas_Object *obj, const char *part) -{ - struct _task_info *info = (struct _task_info *)data; - char buf[_BUF_MAX] = { 0, }; - - if (!strcmp(part, "elm.text")) { - snprintf(buf, _BUF_MAX, "%s", info->app_name); - return strdup(buf); - } - return NULL; -} - -static Evas_Object *_gl_content_get_his(void *data, Evas_Object *obj, - const char *part) -{ - struct _task_info *info = (struct _task_info *)data; - char buf[_BUF_MAX] = { 0, }; - - Evas_Object *icon = NULL; - Evas_Object *btn = NULL; - - retvm_if(data == NULL, NULL, "Invalid argument: task info is NULL\n"); - - if (!strcmp(part, "elm.icon.1")) { - snprintf(buf, sizeof(buf), "%s", info->icn_path); - retvm_if(buf == NULL, NULL, "%s icon is NULL\n", info->app_name); - if (!ecore_file_exists(buf) || strlen(buf) < 4) - snprintf((char *)buf, (size_t) sizeof(buf), - (const char *)IMAGEDIR "/icon_taskmgr.png"); - - icon = elm_icon_add(obj); - elm_image_file_set(icon, buf, NULL); - elm_image_preload_disabled_set(icon, EINA_TRUE); - - evas_object_size_hint_min_set(icon, - (int)72 * elm_config_scale_get(), - (int)72 * elm_config_scale_get()); - - return icon; - - } else if (!strcmp(part, "elm.icon.2")) { - btn = elm_button_add(obj); - /*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_propagate_events_set(btn, EINA_FALSE);*/ - - elm_object_style_set(btn, "icon_minus"); - evas_object_smart_callback_add(btn, "clicked", - func_end[info->category], info); - evas_object_propagate_events_set(btn, EINA_FALSE); - - return btn; - } - - return NULL; - -} - -void _set_itc(void) -{ - itc_gl.item_style = "grouptitle"; - itc_gl.func.text_get = _gl_text_get_title; - - //itc_dl.item_style = "2text.2icon.7"; - //itc_dl.item_style = "1text.2icon.4"; - itc_dl.item_style = "1text.2icon.6"; - 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.6"; - itc_hl.func.text_get = _gl_text_get_his; - itc_hl.func.content_get = _gl_content_get_his; - - itc_separator4.item_style = "seperator"; - itc_separator2.item_style = "seperator"; - - itc_bl.item_style = "1icon"; - itc_bl.func.content_get = _bl_content_get; - - itc_nl.item_style = "1text"; - itc_nl.func.text_get = nl_text_get; - -} - -int check_genlist(struct appdata *ad) -{ - Elm_Object_Item *egi; - struct _task_info *info; - - egi = elm_genlist_first_item_get(ad->gl); - while(egi) { - info = (struct _task_info *)elm_object_item_data_get(egi); - if(info) { - _D("%s info[0x%x]\n", (int)info < 3 ? "-" : info->app_name, info); - } else { - _D("group\n"); - } - egi = elm_genlist_item_next_get(egi); - } - - return 0; -} - -int _set_genlist_from_eina(struct appdata *ad) -{ - _D("func\n"); - Eina_List *l; - Elm_Object_Item *git, *item; - struct _task_info *info; - int i; - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - retvm_if(ad->gl == NULL, -1, "Invalid argument:genlist is NULL\n"); - - for (i = 0; i < TS_MAX; i++) { - git = elm_genlist_item_append(ad->gl, &itc_gl, - (void *)i, NULL, - ELM_GENLIST_ITEM_NONE, - NULL, NULL); - retvm_if(git == NULL, -1, "Failed append item\n"); - elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - - if (eina_list_count(ad->applist[i]) > 0) { - - item = elm_genlist_item_append(ad->gl, &itc_separator4, - NULL, NULL, - ELM_GENLIST_ITEM_NONE, - NULL, NULL); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - - elm_genlist_item_append(ad->gl, &itc_bl, - (void *)i, NULL, - ELM_GENLIST_ITEM_NONE, - _bl_sel, (void *)i); - - item = elm_genlist_item_append(ad->gl, &itc_separator2, - NULL, NULL, - ELM_GENLIST_ITEM_NONE, - NULL, NULL); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - - ad->applist[i] = eina_list_nth_list(ad->applist[i], 0); - EINA_LIST_FOREACH(ad->applist[i], l, info) { - if (info != NULL) { - info->it = elm_genlist_item_append(ad->gl, - (i == TS_INUSE) ? &itc_dl : &itc_hl, - (void *)info, NULL, - ELM_GENLIST_ITEM_NONE, - _gl_sel_app, ad); - } - } - } else { - item = elm_genlist_item_append(ad->gl, &itc_nl, - (void *)i, NULL, - ELM_GENLIST_ITEM_NONE, - nl_sel, NULL); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - } - } - return 0; -} - -void _set_genlist(struct appdata *ad) -{ -_D("func\n"); - 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(); - - 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 refresh_app_info(struct appdata *ad) -{ -_D("func\n"); - retm_if(ad == NULL, "Invalid argument: appdata is NULL\n"); - - _free_einalist_all(ad); - clear_genlist(ad); - - _set_genlist(ad); - - alert_app_info(ad); - -} - -void _del_popup_timer(struct appdata *ad) -{ - if (ad->popup_timer) { - ecore_timer_del(ad->popup_timer); - ad->popup_timer = NULL; - } -} - -void taskmanager_free_info(struct _task_info *info) -{ - if (info) { - if (info->app_name) { - free(info->app_name); - info->app_name = NULL; - } - if (info->pkg_name) { - free(info->pkg_name); - info->pkg_name = NULL; - } - if (info->icn_path) { - free(info->icn_path); - info->icn_path = NULL; - } - - free(info); - } -} - -int response_end_inuse(struct appdata *ad) -{ -_D("func\n"); - Eina_List *l, *l_next; - struct _task_info *info; - Eina_Bool dead = EINA_FALSE; - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\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); - dead = EINA_TRUE; - } - } - break; - } - } - ad->ending = EINA_FALSE; - - if(!dead){ - _D("matched applist is nothing\n"); - _del_progressbar(ad); - } - - return 0; -} - -Eina_Bool _refresh_idler_cb(void *data) -{ -_D("func\n"); - struct appdata *ad = (struct appdata *)data; - retvm_if(data == NULL, ECORE_CALLBACK_CANCEL, "Invalid argument: appdata is NULL\n:"); - - _del_popup_timer(ad); - _del_progressbar(ad); - refresh_app_info(ad); - return ECORE_CALLBACK_CANCEL; -} - -int response_end_all_inuse(struct appdata *ad) -{ - Eina_List *l; - struct _task_info *info; - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - - ad->ending = EINA_TRUE; - - if(ad->update_timer) { - ecore_timer_del(ad->update_timer); - ad->update_timer = NULL; - } - - ad->endcnt = eina_list_count(ad->applist[TS_INUSE]); - _D("set end count (%d)\n", ad->endcnt); - - 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->ending = EINA_FALSE; - return 0; -} - -int response_del_history(struct appdata *ad) -{ - Eina_List *l, *l_next; - struct _task_info *info; - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - - _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) { - break; - } - rua_delete_history_with_pkgname(info->pkg_name); - rua_fini(); - - ad->applist[TS_HISTORY] = - eina_list_remove_list(ad->applist[TS_HISTORY], l); - - if (info->b) { - bundle_free(info->b); - } - - elm_object_item_del(info->it); - taskmanager_free_info(info); - break; - } - } - alert_app_info(ad); - refresh_app_info(ad); - _del_popup_timer(ad); - _del_progressbar(ad); - - ad->mode = MODE_NONE; - return 0; -} - -int response_del_all_history(struct appdata *ad) -{ - Eina_List *l; - struct _task_info *info; - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - - if(ad->update_timer) { - _D("update timer is deleted\n"); - ecore_timer_del(ad->update_timer); - ad->update_timer = NULL; - } - - - _show_progressbar(ad); - - if (rua_init() == -1) { - return -1; - } - - EINA_LIST_FOREACH(ad->applist[TS_HISTORY], l, info) { - if (info != NULL) { - rua_delete_history_with_pkgname(info->pkg_name); - } - } - - if (eina_list_count(ad->applist[TS_INUSE]) == 0) { - rua_clear_history(); - } - - rua_fini(); - refresh_app_info(ad); - _del_popup_timer(ad); - _del_progressbar(ad); - - ad->mode = MODE_NONE; - return 0; -} - -int response_kill_inuse(struct appdata *ad) -{ - Eina_List *l, *l_next; - struct _task_info *info; - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - - _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); - } - - ad->applist[TS_INUSE] = - eina_list_remove_list(ad->applist[TS_INUSE], l); - taskmanager_free_info(info); - break; - } - } - refresh_app_info(ad); - _del_progressbar(ad); - - return 0; -} - -int response_kill_all_inuse(struct appdata *ad) -{ - Eina_List *l; - struct _task_info *info; - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - - _show_progressbar(ad); - - EINA_LIST_FOREACH(ad->applist[TS_INUSE], l, info) { - if (info != NULL) { - if (info->pid > 0) { - kill(info->pid, SIGKILL); - } - } - } - refresh_app_info(ad); - _del_progressbar(ad); - - return 0; -} - diff --git a/src/_genlist.h b/src/_genlist.h deleted file mode 100755 index ee47515..0000000 --- a/src/_genlist.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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. - */ - - - - -#ifndef __TASKMANAGER_GENLIST_H__ -#define __TASKMANAGER_GENLIST_H__ - -#include <Elementary.h> -#include "taskmanager.h" - -Eina_Bool alert_app_info(void *data); -void clear_task_manager_list(void *data); -void refresh_app_info(struct appdata *ad); -void load_task_manager_list(struct appdata *ad); -void _set_itc(void); -void _set_genlist(struct appdata *ad); -void _del_popup_timer(struct appdata *ad); -int response_end_inuse(struct appdata *ad); -int response_end_all_inuse(struct appdata *ad); -int response_del_history(struct appdata *ad); -int response_del_all_history(struct appdata *ad); -int response_kill_inuse(struct appdata *ad); -int response_kill_all_inuse(struct appdata *ad); -void _fini_pthread(void); -Eina_Bool _update_list(void *data); -void _restart_pthread(struct appdata *ad); - -#endif -/* __TASKMANAGER_GENLIST_H__ */ diff --git a/src/_info.c b/src/_info.c deleted file mode 100755 index 9ae42e7..0000000 --- a/src/_info.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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> - -#include <appcore-common.h> - -#include "taskmanager.h" -#include "_util_log.h" -#include "_util_efl.h" - -static void ctxpopup_clear(void *data) -{ - struct appdata *ad = data; - - retm_if(data == NULL, "Invalid argument: appdata is NULL\n"); - - if (ad->info_timer) { - ecore_timer_del(ad->info_timer); - ad->info_timer = NULL; - } - - if (ad->info_ctxpopup) { - evas_object_del(ad->info_ctxpopup); - ad->info_ctxpopup = NULL; - } - -} - -static void label_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - Evas_Object *ly = (Evas_Object *)data; - Evas_Coord w, h; - Evas_Coord pw, ph; - - retm_if(ly == NULL, "Invalid argument: Evas_Object is NULL\n"); - - edje_object_part_geometry_get(_EDJ(ly), - "padding/t", NULL, NULL, &pw, &ph); - evas_object_geometry_get(obj, NULL, NULL, &w, &h); - evas_object_size_hint_min_set(ly, (w + ph * 2), (h + ph * 2)); -} - -static void _ctxpopup_hide_cb(void *data, Evas_Object *obj, void *event_info) -{ - struct appdata *ad = (struct appdata *)data; - ctxpopup_clear(ad); -} - -int _util_move_ctxpopup(Evas_Object *eo, Evas_Object *target) -{ - double scale; - Evas_Coord tx, ty, tw, th; - Evas_Coord cx, cy; - - retvm_if(eo == NULL, -1, "Invalid argument: ctxpopup is NULL\n"); - - scale = elm_config_scale_get(); - - evas_object_geometry_get(target, &tx, &ty, &tw, &th); - - cx = tx + (int)(tw * 0.5); - cy = ty + (int)(10.0 * scale); - - evas_object_move(eo, cx, cy); - - return 0; -} - -static Eina_Bool info_hide_cb(void *data) -{ - struct appdata *ad = data; - - ctxpopup_clear(ad); - - return ECORE_CALLBACK_CANCEL; -} - -void create_info_ctxpopup(void *data, Evas_Object *obj, void *event_info) -{ - struct appdata *ad = (struct appdata *)data; - Evas_Object *lb, *ly; - double scale = 0.0; - char buf[128] = {0, }; - - retm_if(data == NULL, "Invalid argument: appdata is NULL\n"); - - if (ad->info_ctxpopup) { - evas_object_del(ad->info_ctxpopup); - ad->info_ctxpopup = NULL; - } - - scale = elm_config_scale_get(); - - ad->info_ctxpopup = _add_ctxpopup(ad->win); - evas_object_smart_callback_add(ad->info_ctxpopup, "dismissed", - _ctxpopup_hide_cb, ad); - - ly = _add_layout(ad->info_ctxpopup, NULL, NULL); - evas_object_resize(ly, (int)(240.0 * scale), (int)(105.0 * scale)); - elm_object_content_set(ad->info_ctxpopup, ly); - - snprintf(buf, sizeof(buf), - "<font_size=22>%s<font_size>", _("IDS_TASKMGR_INFO_MESSAGE")); - lb = _add_label(ly, buf); - evas_object_event_callback_add(lb, EVAS_CALLBACK_RESIZE, - label_resize_cb, ly); - elm_layout_content_set(ly, "swallow", lb); - - _util_move_ctxpopup(ad->info_ctxpopup, ad->info_btn); - - ad->info_timer = ecore_timer_add(3, info_hide_cb, ad); - - evas_object_show(ad->info_ctxpopup); -} - - diff --git a/src/_info.h b/src/_info.h deleted file mode 100755 index e555f82..0000000 --- a/src/_info.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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. - */ - - - - -#ifndef __TASKMANAGER_INFO_H__ -#define __TASKMANAGER_INFO_H__ - -void create_info_ctxpopup(void *data, Evas_Object *obj, void *event_info); - -#endif -/* __TASKMANAGER_INFO_H__ */ - diff --git a/src/_logic.c b/src/_logic.c deleted file mode 100755 index d2064c6..0000000 --- a/src/_logic.c +++ /dev/null @@ -1,414 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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 <appcore-common.h> -#include <ail.h> -#include <aul.h> -#include <Ecore_X.h> -#include <vconf.h> -#include <utilX.h> - -#include "taskmanager.h" -#include "_util_log.h" -#include "_util_efl.h" -#include "_genlist.h" -#include "_eina.h" -#include "_progressbar.h" -#include "_info.h" - -int _dead_cb(int pid, void *data) -{ -_D("func\n"); - /* redraw list */ - struct appdata *ad = (struct appdata *)data; - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - - int ret = -1; - - if (ad->update_timer) { - ecore_timer_del(ad->update_timer); - ad->update_timer = NULL; - } - - ret = _subt_einalist_item(ad, pid); - _D("mode(%d) count(%d) pid(%d) \n", ad->mode, ad->endcnt, pid); - - if (ret != -1) { - switch (ad->mode) { - default: - case MODE_END_INUSE: - case MODE_DEL_HISTORY: - case MODE_DEL_ALL_HISTORY: - case MODE_KILL_INUSE: - _D("aa\n"); - _del_popup_timer(ad); - _del_progressbar(ad); - refresh_app_info(ad); - //_restart_pthread(ad); - break; - - case MODE_END_ALL_INUSE: - case MODE_KILL_ALL_INUSE: - _D("bb\n"); - if (ad->endcnt <= 1) { - _D("count set 0\n"); - - if(ad->killall_timer) - { - ecore_timer_del(ad->killall_timer); - ad->killall_timer = NULL; - } - - _del_popup_timer(ad); - _del_progressbar(ad); - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - refresh_app_info(ad); - - } else { - ad->endcnt--; - } - break; - } - } - - return ret; -} - -Eina_Bool _back_cb(void* data, Elm_Object_Item *it) -{ - struct appdata *ad = (struct appdata *)data; - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - - if(ad->popup_progressbar){ - _D("Disabled back function when closing all apps is progressing.\n"); - return ECORE_CALLBACK_DONE; - } - else if(ad->popup_ask){ - _D("pop up is showed. Disenabled the pop up by back btn.\n"); - elm_genlist_realized_items_update(ad->gl); - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - else{ - _D("terminating taskmgr by back btn.\n"); - elm_exit(); - } - return EINA_FALSE; -} - -int _app_create(struct appdata *ad) -{ - Evas_Object *ly, *bg, *nv, *bt, *gl; - Evas_Object *conform = NULL; - Elm_Object_Item *nf_it; - int w, h; - - ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); - - retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n"); - ad->ending = EINA_FALSE; - - conform = elm_conformant_add(ad->win); - retvm_if(conform == NULL, -1, "Failed to add conformant \n"); - evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(ad->win, conform); - evas_object_show(conform); - - ly = _add_layout_main(conform, EINA_TRUE, EINA_FALSE); - retvm_if(ly == NULL, -1, "Failed to add layout main\n"); - elm_object_content_set(conform, ly); - evas_object_resize(ly, w, h); - - bg = _add_bg(ad->win, "group_list"); - retvm_if(bg == NULL, -1, "Failed to add bg\n"); - elm_object_part_content_set(ly, "elm.swallow.bg", bg); - - nv = _add_naviframe(ly); - retvm_if(nv == NULL, -1, "Failed to add naviframe\n"); - ad->nv = nv; - - /*ly = _add_layout(ad->nv, EDJ_NAME, GRP_TM); - retvm_if(ly == NULL, -1, "Failed to add layout\n"); - ad->ly = ly;*/ - - /* Load default content (running task) */ - gl = _add_genlist(nv); - retvm_if(gl == NULL, -1, "Failed to add genlist\n"); - elm_genlist_block_count_set(gl, 20); - evas_object_data_set(gl, "appdata", ad); - //elm_object_part_content_set(ly, "list", gl); - ad->gl = gl; - - nf_it = elm_naviframe_item_push(nv, - T_("IDS_TASKMGR_HEADER_TASK_SWITCHER"), - NULL, NULL, gl, NULL); - /* push naviframe item */ - elm_naviframe_item_pop_cb_set(nf_it, _back_cb, ad); - - ad->flag_select = EINA_FALSE; - - return 0; -} -static void _get_win_geometry(struct appdata *ad) -{ - Ecore_X_Window focus_win; - Ecore_X_Window root_win; - - focus_win = ecore_x_window_focus_get(); - root_win = ecore_x_window_root_get(focus_win); - ecore_x_window_size_get(root_win, &ad->root_w, &ad->root_h); -} - -/* this func is to exit taskmanager after launching application */ -static Eina_Bool __climsg_cb(void *data, int type, void *event) -{ -_D("%s\n", __func__); - static Atom a_deact; - pid_t pid_a, pid_d; - - struct appdata *ad = (struct appdata *)data; - Ecore_X_Event_Client_Message *ev = event; - - if(ev == NULL) { - _E("Invalid argument: event is NULL\n"); - _exit_cb(ad); - return ECORE_CALLBACK_CANCEL; - } - - pid_a = ev->data.l[1]; - pid_d = ev->data.l[3]; - a_deact = ecore_x_atom_get("_X_ILLUME_DEACTIVATE_WINDOW"); - - /* when pid_a == pid_d, this is useless data */ - if (pid_a == pid_d) { - return ECORE_CALLBACK_RENEW; - } - - if (ev->message_type == a_deact) { - _exit_cb(ad); - return ECORE_CALLBACK_CANCEL; - } else { - _D("messagre is act\n"); - - } - - return ECORE_CALLBACK_CANCEL; -} - -static int runapp_count = 0; - -int _runapp_info_get_count(const aul_app_info *ainfo, void *data) -{ - ail_appinfo_h handle; - ail_error_e ret; - bool is_taskmanage; - - retvm_if(ainfo == NULL, -1, "Invalid argument: ainfo is NULL\n"); - - retvm_if(ainfo->pid <= 0, -1, "Invalid pid(%u)\n", ainfo->pid); - - /* filtering */ - if (ainfo->pid == getpid()) - { - return 0; - } - - retvm_if(ainfo->pkg_name == NULL, 0, "Invalid pkg_name(%s)\n", ainfo->pkg_name); - - ret = ail_package_get_appinfo(ainfo->pkg_name, &handle); - retvm_if(ret != AIL_ERROR_OK, -1, - "Failed to get appinfo, pkg_name:%s\n", ainfo->pkg_name); - - ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &is_taskmanage); - if (is_taskmanage == 0) { - ret = ail_package_destroy_appinfo(handle); - retvm_if(ret != AIL_ERROR_OK, -1, "Failed to destroy appinfo\n"); - return 0; - } - - ++runapp_count; - _D("running(%s)\n", ainfo->pkg_name); - _D("runapp count : %d\n", runapp_count); - - ret = ail_package_destroy_appinfo(handle); - retvm_if(ret != AIL_ERROR_OK, -1, "Failed to destroy appinfo\n"); - return 0; -} - -Eina_Bool _kill_all_timer_cb(void *data) -{ - _D("func\n"); - - struct appdata *ad = data; - - int ret = AUL_R_ERROR; - int retry_cnt = 0; - int sleep_value = 500; - - runapp_count = 0; - - while(ret != AUL_R_OK && retry_cnt < 5) - { - usleep(sleep_value); - ret = aul_app_get_running_app_info(_runapp_info_get_count, ad); - - if(ret != AUL_R_OK) - { - _D("Fail to get running app information\n"); - } - - retry_cnt++; - sleep_value *= 2; - } - _D("runapp count : %d\n", runapp_count); - - /* count inuse app number */ - /** if(count == 0) dead_cb */ - if(runapp_count == 0) - { - _D("runapp_count == 0\n"); - _del_popup_timer(ad); - _del_progressbar(ad); - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - refresh_app_info(ad); - //_restart_pthread(ad); - return ECORE_CALLBACK_CANCEL; - } - - return ECORE_CALLBACK_RENEW; -} - -void _ok_response_cb(void *data, Evas_Object *obj, void *event_info) -{ - struct appdata *ad = (struct appdata *)data; - - retm_if(data == NULL, "Invalid argument: appdata is NULL\n"); - - switch (ad->mode) { - case MODE_END_INUSE: - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - _D("end inuse\n"); - _del_popup_timer(ad); - _show_progressbar(ad); - response_end_inuse(ad); - //_restart_pthread(ad); - break; - - case MODE_END_ALL_INUSE: - _D("end all inuse\n"); - if(ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - _del_popup_timer(ad); - _show_progressbar(ad); - response_end_all_inuse(ad); - ad->killall_timer = ecore_timer_add(2.0, _kill_all_timer_cb, ad); - break; - - case MODE_DEL_HISTORY: - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - _D("del inuse\n"); - _del_popup_timer(ad); - response_del_history(ad); - break; - - case MODE_DEL_ALL_HISTORY: - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - _D("del all inuse\n"); - _del_popup_timer(ad); - response_del_all_history(ad); - break; - - case MODE_KILL_INUSE: - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - _D("kill all inuse\n"); - response_kill_inuse(ad); - break; - - case MODE_KILL_ALL_INUSE: - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - _D("kill all inuse\n"); - response_kill_all_inuse(ad); - break; - - default: - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } - _E("[Wanning] taskmanager: check mode [%d]\n", - ad->mode); - break; - } -} - -void _cancel_response_cb(void *data, Evas_Object *obj, void *event_info) -{ - struct appdata *ad = (struct appdata *)data; - - retm_if(data == NULL, "Invalid argument: appdata is NULL\n"); - if (ad->popup_ask) { - evas_object_del(ad->popup_ask); - ad->popup_ask = NULL; - } -} - -Eina_Bool _create_idler_cb(void *data) -{ - struct appdata *ad = (struct appdata *)data; - retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "Invalid argument\n"); - - _check_show_state(); - - evas_object_show(ad->win); - - _key_grab(ad); - - _get_win_geometry(ad); - ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __climsg_cb, ad); - - - return ECORE_CALLBACK_CANCEL; -} - - - diff --git a/src/_logic.h b/src/_logic.h deleted file mode 100755 index a99dfab..0000000 --- a/src/_logic.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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. - */ - - - - -#ifndef __TASKMANAGER_LOGIC_H__ -#define __TASKMANAGER_LOGIC_H__ - -#include "taskmanager.h" - -int _dead_cb(int pid, void *data); -Eina_Bool _create_idler_cb(void *data); -int _app_create(struct appdata *ad); -void _ok_response_cb(void *data, Evas_Object *obj, void *event_info); -void _cancel_response_cb(void *data, Evas_Object *obj, void *event_info); - -#endif -/* __TASKMANAGER_LOGIC_H__ */ diff --git a/src/_progressbar.c b/src/_progressbar.c deleted file mode 100755 index ac33092..0000000 --- a/src/_progressbar.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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 "taskmanager.h" -#include "_util_log.h" -#include "_util_efl.h" - -void _del_progressbar(void *data) -{ - _D("%s\n", __func__); - struct appdata *ad = (struct appdata *)data; - retm_if(ad == NULL, "Invalid argument: appdata is NULL\n"); - - if (ad->popup_progressbar) { - evas_object_hide(ad->popup_progressbar); - evas_object_del(ad->popup_progressbar); - ad->popup_progressbar = NULL; - } -} - -void _show_progressbar(void *data) -{ - _D("%s\n", __func__); - struct appdata *ad = (struct appdata *)data; - retm_if(ad == NULL, "Invalid argument: appdata is NULL\n"); - - if (ad->popup_progressbar) - _del_progressbar(ad); - - ad->popup_progressbar = _add_progressbar(ad->win, "list_process", - ad->root_w, ad->root_h); - - evas_object_show(ad->popup_progressbar); -} diff --git a/src/_progressbar.h b/src/_progressbar.h deleted file mode 100755 index 56b5891..0000000 --- a/src/_progressbar.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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. - */ - - - - -#ifndef __TASKMANAGER_PROGRESSBAR_H__ -#define __TASKMANAGER_PROGRESSBAR_H__ - -void _show_progressbar(void *data); -void _del_progressbar(void *data); - -#endif -/* __TASKMANAGER_PROGRESSBAR_H__ */ diff --git a/src/_util_efl.c b/src/_util_efl.c deleted file mode 100755 index 43ebc65..0000000 --- a/src/_util_efl.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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 <appcore-efl.h> -#include <efl_assist.h> - -#include "taskmanager.h" -#include "_util_log.h" -#include "_util_efl.h" -#include "_logic.h" - -Evas_Object *_add_window(const char *name) -{ - Evas_Object *eo; - int w, h; - - eo = elm_win_add(NULL, name, ELM_WIN_BASIC); - if (eo) { - elm_win_title_set(eo, name); - elm_win_borderless_set(eo, EINA_TRUE); - ecore_x_window_size_get(ecore_x_window_root_first_get(), - &w, &h); - evas_object_resize(eo, w, h); - } - - return eo; -} - -Evas_Object *_add_bg(Evas_Object *parent, char *style) -{ - Evas_Object *bg; - - bg = elm_bg_add(parent); - retvm_if(bg == NULL, NULL, "Failed to add bg\n"); - if (style) elm_object_style_set(bg, style); - evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_show(bg); - return bg; -} - -Evas_Object *_add_genlist(Evas_Object *parent) -{ - Evas_Object *eo; - - eo = elm_genlist_add(parent); - if (eo == NULL) { - _D("[Error] Cannot add genlist\n"); - return NULL; - } - elm_genlist_mode_set(eo, ELM_LIST_COMPRESS); - - evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(eo, EVAS_HINT_FILL, EVAS_HINT_FILL); - - return eo; -} - -Evas_Object *_add_icon(Evas_Object *parent, const char *png) -{ - Evas_Object *eo; - char buf[128] = { 0, }; - - eo = elm_icon_add(parent); - if (eo == NULL) { - printf("[Error] Cannot add button\n"); - return NULL; - } - - snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, png); - elm_image_file_set(eo, buf, NULL); - elm_image_resizable_set(eo, 1, 1); - evas_object_size_hint_aspect_set(eo, EVAS_ASPECT_CONTROL_VERTICAL, 1, - 1); - - return eo; -} - -Evas_Object *_add_layout(Evas_Object *parent, const char *file, - const char *group) -{ - Evas_Object *eo = NULL; - int r; - - eo = elm_layout_add(parent); - if (eo == NULL) { - _E("[Error] Cannot add layout\n"); - return NULL; - } - - elm_layout_theme_set(eo, "layout", "application", "default"); - - evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - - return eo; -} - -Evas_Object *_add_ctxpopup(Evas_Object *parent) -{ - Evas_Object *eo = NULL; - - eo = elm_ctxpopup_add(parent); - if (eo == NULL) { - printf("[Error] Cannot add ctxpopup\n"); - return NULL; - } - - elm_ctxpopup_horizontal_set(eo, EINA_TRUE); - elm_ctxpopup_direction_priority_set(eo, - ELM_CTXPOPUP_DIRECTION_DOWN, - ELM_CTXPOPUP_DIRECTION_UP, - ELM_CTXPOPUP_DIRECTION_LEFT, - ELM_CTXPOPUP_DIRECTION_RIGHT); - - return eo; -} - -Evas_Object *_add_label(Evas_Object *parent, const char *msg) -{ - Evas_Object *eo = NULL; - - eo = elm_label_add(parent); - if (eo == NULL) { - _E("[Error] Cannot add label\n"); - return NULL; - } - - elm_label_line_wrap_set(eo, ELM_WRAP_WORD); - elm_object_text_set(eo, msg); - - return eo; -} - -static Eina_Bool _disappear_popup(void *data) -{ - Evas_Object *eo = (Evas_Object *)data; - if (eo == NULL) { - _E("[Error] Invalid argument: popup is NULL\n"); - return ECORE_CALLBACK_CANCEL; - } - evas_object_del(eo); - return ECORE_CALLBACK_CANCEL; -} - -void _diable_popup(void *data) -{ - Evas_Object *btn = NULL; - Evas_Object *eo = (Evas_Object *)data; - if(eo == NULL) { - _E("[Error] Invalid argument: popup is NULL\n"); - return; - } - - btn = elm_object_part_content_get(eo, "button1"); - if(btn) { - elm_object_disabled_set(btn, EINA_TRUE); - } - - btn = elm_object_part_content_get(eo, "button2"); - if(btn) { - elm_object_disabled_set(btn, EINA_TRUE); - } -} - -Evas_Object *_add_popup_ask(Evas_Object *parent, char *text, void *data) -{ - Evas_Object *pu, *bt1, *bt2; - retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n"); - - pu = elm_popup_add(parent); - retvm_if(pu == NULL, NULL, "Falied to add popup\n"); - evas_object_size_hint_weight_set(pu, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_object_part_text_set(pu, "title,text", S_("IDS_COM_POP_WARNING")); - elm_object_text_set(pu, text); - - bt1 = elm_button_add(pu); - elm_object_text_set(bt1, S_("IDS_COM_POP_CANCEL")); - elm_object_part_content_set(pu, "button1", bt1); - evas_object_smart_callback_add(bt1, "clicked", _cancel_response_cb, data); - - bt2 = elm_button_add(pu); - elm_object_text_set(bt2, S_("IDS_COM_SK_OK")); - elm_object_part_content_set(pu, "button2", bt2); - evas_object_smart_callback_add(bt2, "clicked", _ok_response_cb, data); - - evas_object_show(pu); - - return pu; -} - -void util_show_popup_with_message(Evas_Object *parent, double in, - const char *msg) -{ - Evas_Object *eo = NULL; - - eo = elm_popup_add(parent); - if (eo == NULL) { - _E("[Error] Cannot add popup\n"); - return; - } - - evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - elm_object_text_set(eo, msg); - - ecore_timer_add(in, _disappear_popup, eo); -} - -Evas_Object *_add_naviframe(Evas_Object *parent) -{ - Evas_Object *nv; - - retv_if(parent == NULL, NULL); - - nv = elm_naviframe_add(parent); - retvm_if(nv == NULL, NULL, "Failed to add naviframe\n"); - elm_object_part_content_set(parent, "elm.swallow.content", nv); - ea_object_event_callback_add(nv, EA_CALLBACK_BACK, ea_naviframe_back_cb, NULL); - - evas_object_show(nv); - - return nv; -} - -Evas_Object *_add_layout_main(Evas_Object *parent, - Eina_Bool content, Eina_Bool transparent) -{ - Evas_Object *ly; - - retv_if(parent == NULL, NULL); - - ly = elm_layout_add(parent); - retvm_if(ly == NULL, NULL, "Failed elm_layout_add.\n"); - - elm_layout_theme_set(ly, "layout", "application", "default"); - evas_object_size_hint_weight_set(ly, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(parent, ly); - if (content) - elm_object_signal_emit(ly, "elm,state,show,content", "elm"); - if (transparent) - elm_object_signal_emit(ly, "elm,bg,show,transparent", "elm"); - evas_object_show(ly); - return ly; -} - -Evas_Object *_add_progressbar(Evas_Object *parent, const char *style, - Evas_Coord w, Evas_Coord h) -{ - Evas_Object *pb; - double scale; - - retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n"); - - scale = elm_config_scale_get(); - - pb = elm_progressbar_add(parent); - retvm_if(pb == NULL, NULL, "Failed to add progressbar\n"); - - elm_object_style_set(pb, style); - evas_object_resize(pb, w, (int)(60 * scale)); - evas_object_move(pb, 0, h / 2); - elm_progressbar_pulse(pb, EINA_TRUE); - evas_object_show(pb); - - return pb; -} - - diff --git a/src/_util_efl.h b/src/_util_efl.h deleted file mode 100755 index 1c41009..0000000 --- a/src/_util_efl.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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. - */ - - - - -#ifndef __TASKMANAGER_UTIL_EFL_H__ -#define __TASKMANAGER_UTIL_EFL_H__ - -#include <Elementary.h> - -Evas_Object *_add_window(const char *name); -Evas_Object *_add_bg(Evas_Object *parent, char *style); -Evas_Object *_add_genlist(Evas_Object *parent); -Evas_Object *_add_icon(Evas_Object *parent, const char *png); -Evas_Object *_add_layout(Evas_Object *parent, const char *file, const char *group); -Evas_Object *_add_ctxpopup(Evas_Object *parent); -Evas_Object *_add_label(Evas_Object *parent, const char *msg); -Evas_Object *_add_naviframe(Evas_Object *parent); -Evas_Object *_add_layout_main(Evas_Object *parent, - Eina_Bool content, Eina_Bool transparent); -Evas_Object *_add_progressbar(Evas_Object *parent, const char *style, - Evas_Coord w, Evas_Coord h); -void _diable_popup(void *data); -Evas_Object *_add_popup_ask(Evas_Object *parent, char *text, void *data); -void util_show_popup_with_message(Evas_Object *parent, double in, const char *msg); - -#endif -/* __TASKMANAGER_UTIL_EFL_H__ */ diff --git a/src/_util_log.h b/src/_util_log.h deleted file mode 100755 index efd24e1..0000000 --- a/src/_util_log.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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. - */ - - - - -#ifndef __TASKMANAGER_UTIL_LOG_H__ -#define __TASKMANAGER_UTIL_LOG_H__ - -#include <unistd.h> -#include <dlog.h> - -#undef LOG_TAG -#define LOG_TAG "TASKMANAGER" -#define _E(fmt, arg...) LOGE("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg) -#define _D(fmt, arg...) LOGD("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg) - -#define retvm_if(expr, val, fmt, arg...) do { \ - if(expr) { \ - _E(fmt, ##arg); \ - _E("(%s) -> %s() return", #expr, __FUNCTION__); \ - return (val); \ - } \ -} while (0) - -#define retv_if(expr, val) do { \ - if(expr) { \ - _E("(%s) -> %s() return", #expr, __FUNCTION__); \ - return (val); \ - } \ -} while (0) - -#define retm_if(expr, fmt, arg...) do { \ - if(expr) { \ - _E(fmt, ##arg); \ - _E("(%s) -> %s() return", #expr, __FUNCTION__); \ - return; \ - } \ -} while (0) - -#define ret_if(expr) do { \ - if(expr) { \ - _E("(%s) -> %s() return", #expr, __FUNCTION__); \ - return; \ - } \ -} while (0) - -#endif -/* __TASKMANAGER_UTIL_LOG_H__ */ diff --git a/src/genlist.c b/src/genlist.c new file mode 100644 index 0000000..93f73c8 --- /dev/null +++ b/src/genlist.c @@ -0,0 +1,478 @@ +/* + * Task Manager + * + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.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 + * + * 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> +#include <stdlib.h> +#include <appcore-efl.h> +#include <Evas.h> +#include <Elementary.h> +#include <Eina.h> +#include <stdbool.h> +#include <aul.h> +#include <dlog.h> + +#include "genlist.h" +#include "recent_apps.h" +#include "task-mgr-lite.h" +#include "genlist_item.h" + +#define N_ITEMS 30 + +Ecore_Timer *timer_for_animation = NULL; + +int velocity_factor; +int index_for_animation; +Elm_Object_Item* clear_all_item; + +static struct +{ + // Evas_Object *task_mgr_genlist; + Evas_Object *selected_item_layout; + Elm_Genlist_Item_Class *recent_app_item_expanded; + + bool is_visible; + bool is_mouse_down; + bool is_expanded; + bool is_dragged; + bool is_scroll_anim_on; + bool is_longpressed; + + char *runned_app_pkgname; + + struct + { + int x; + int y; + } mouse_down_info; + + int recent_app_count; + + Elm_Theme *theme; + +} s_recent_app_info = { + // .task_mgr_genlist = NULL, + .recent_app_item_expanded = NULL, + .is_visible = true, + .is_mouse_down = false, + .is_expanded = false, + .is_dragged = false, + .is_scroll_anim_on = false, + .is_longpressed = false, + .runned_app_pkgname = NULL, + .recent_app_count = -1, + .theme = NULL, +}; + +static void recent_app_panel_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + LOGD("%s\n", __FUNCTION__); + + if (s_recent_app_info.theme) + { + elm_theme_free(s_recent_app_info.theme); + s_recent_app_info.theme = NULL; + } + + genlist_item_class_destroy(); + genlist_clear_all_class_destroy(); +} + +Evas_Object* recent_app_panel_create(Evas_Object *win) +{ + LOGD("Creating task_mgr_genlist widget, noti count is : [%d]", s_recent_app_info.recent_app_count); + Evas_Object *genlist; + + if (s_recent_app_info.theme) + { + LOGE("[CHECK] Theme is already created"); + } + else + { + s_recent_app_info.theme = elm_theme_new(); + if (!s_recent_app_info.theme) + { + LOGE("Failed to create a theme object"); + return NULL; + } + + elm_theme_extension_add(s_recent_app_info.theme, EDJE_DIR "recent_app-genlist-theme.edj"); + } + + genlist = elm_genlist_add(win); + if (!genlist) + { + LOGE("Failed to create a new genlist"); + LOGE("Failed to get genlist"); + elm_theme_free(s_recent_app_info.theme); + s_recent_app_info.theme = NULL; + return NULL; + } + + elm_layout_theme_set(genlist, "genlist", "base", "default"); + + genlist_item_class_create(); + genlist_clear_all_class_create(); + + elm_object_theme_set(genlist, s_recent_app_info.theme); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + + evas_object_event_callback_add(genlist, EVAS_CALLBACK_DEL, recent_app_panel_del_cb, NULL); + + return genlist; +} + +Eina_Bool genlist_update_timer_cb(void *data) +{ + LOGD("%s\n", __FUNCTION__); + Evas_Object *task_mgr_genlist = (Evas_Object*)data; + + if (elm_genlist_items_count(task_mgr_genlist) > 1) + { + evas_object_smart_callback_call(task_mgr_genlist, "genlist empty", (void*)0); + } + else + { + evas_object_smart_callback_call(task_mgr_genlist, "genlist empty", (void*)1); + } + + return EINA_FALSE; +} + +static void on_selected(void *data, Evas_Object *obj, void *event_info) +{ + LOGD("item selected"); +} + +static void genlist_add_item(list_type_default_s *item) +{ + LOGD("%s\n", __FUNCTION__); + + Evas_Object *task_mgr_genlist = task_mgr_get_list();; + Elm_Genlist_Item_Class *item_class = get_item_class(); + Elm_Object_Item *it = NULL; + + LOGD("Adding item: %p\n", item); + it = elm_genlist_item_append(task_mgr_genlist, item_class, + item, NULL, + ELM_GENLIST_ITEM_NONE, + on_selected, NULL); + + item->it = it; + item->pid = recent_apps_find_by_appid(item->appid); + + /** + * @TODO + * CHECK-THIS + * Do we really need to do this? + * While creating an item "it", it will carry the "item" as its callback-data. + * So we can access it when we need using elm_object_item_data_get without below function call. + */ + elm_object_item_data_set(it, item); +} + +void genlist_item_show(Evas_Object *genlist) +{ + LOGD("%s\n", __FUNCTION__); + int genlist_item_count; + Evas_Object *layout; + + layout = task_mgr_get_layout(); + + genlist_item_count = elm_genlist_items_count(genlist); + LOGD("ELM COUNT = %d\n", genlist_item_count); + + int width = task_mgr_get_screen_width(); + int item_n; + + char signal[13] = {0,}; + snprintf(signal, 12, "%d_item,show", genlist_item_count); + + if (width == 720) + { + item_n = 9; + } + else + { + item_n = 8; + } + + + if (genlist_item_count >= item_n) + { + elm_layout_signal_emit(layout, "default,show", "genlist"); + } + else if (genlist_item_count >= 2) + { + elm_layout_signal_emit(layout, signal, "genlist"); + } + else if (genlist_item_count == 1) + { + elm_layout_signal_emit(layout, "1_item,show", "genlist"); + evas_object_smart_callback_call(genlist, "genlist empty", (void*)1); + } +} + +static void on_genlist_state_changed(void *data, Evas_Object *obj, void *event_info) +{ + int is_empty = (int)event_info; + Evas_Object *layout = data; + + LOGD("GENLIST TASK SIGNAL"); + if (is_empty == 0) + { + elm_layout_signal_emit(layout, "no_apps_text,hide", "no_item_label"); + elm_layout_signal_emit(layout, "line,show", "static_line"); + elm_layout_signal_emit(layout, "clipper_show", "clipper"); + LOGD("Show TaskManager."); + } + else + { + elm_genlist_clear(obj); + + elm_object_part_text_set(layout, "no_item_label", D_("IDS_TASKMGR_NPBODY_NO_APPLICATIONS_ABB2")); + elm_layout_signal_emit(layout, "no_apps_text,show", "no_item_label"); + elm_layout_signal_emit(layout, "line,hide", "static_line"); + LOGD("Hide TaskManager(No Applications) - SHOW , Remove clear button. / STMS : %s", D_("IDS_TASKMGR_NPBODY_NO_APPLICATIONS_ABB2")); + } +} + +Evas_Object *genlist_init(Evas_Object *win, Evas_Object *layout, Eina_List *running_apps, Eina_List *recent_apps) +{ + LOGD("in gen list: %p %p\n", running_apps, recent_apps); + + if (!win) + { + LOGE("Win is NULL"); + return NULL; + } + + if (!layout) + { + LOGE("Layout is NULL"); + return NULL; + } + + Evas_Object *task_mgr_genlist = recent_app_panel_create(win); + + if (!task_mgr_genlist) + { + LOGE("Failed to create task_mgr_genlist panel"); + return NULL; + } + + elm_scroller_policy_set(task_mgr_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_object_part_content_set(layout, "genlist", task_mgr_genlist); + + evas_object_show(task_mgr_genlist); + + evas_object_smart_callback_add(task_mgr_genlist, "scroll", on_list_scroll_move, (void*)1); + evas_object_smart_callback_add(task_mgr_genlist, "scroll,drag,stop", on_list_scroll_drag_stop, (void*)0); + evas_object_smart_callback_add(task_mgr_genlist, "scroll,drag,start", on_list_scroll_drag_start, (void*)0); + evas_object_smart_callback_add(task_mgr_genlist, "scroll,anim,stop", on_list_scroll_drag_stop, (void*)0); + evas_object_smart_callback_add(task_mgr_genlist, "edge,top", on_list_scroll_move, (void*)0); + evas_object_smart_callback_add(task_mgr_genlist, "genlist empty", on_genlist_state_changed, layout); + + return task_mgr_genlist; +} + +void genlist_clear_list(Evas_Object *genlist) +{ + LOGD("%s\n", __FUNCTION__); + elm_genlist_clear(genlist); +} + +static Eina_Bool animator_callback(void *data, double timeline) +{ + LOGD("animator_callback"); + + int move_to_y = 0; + int object_x, object_y; + evas_object_geometry_get(data, &object_x, &object_y, NULL, NULL); + LOGD("evas_object_geometry_get : %d / %d", object_x, object_y); + move_to_y = object_y + velocity_factor*1.5; + + LOGD("animator_callback position : %d", move_to_y); + evas_object_move(data, object_x, move_to_y); + + if (move_to_y > 820 || timeline >= 1.0) + { + return ECORE_CALLBACK_CANCEL; + } + + return ECORE_CALLBACK_RENEW; /* re-issue the timer */ +} + +static Eina_Bool animator_callback_with_finished_cb(void *data, double timeline) +{ + LOGD("animator_callback_with_finished_cb"); + + int move_to_y = 0; + int object_x, object_y; + evas_object_geometry_get(data, &object_x, &object_y, NULL, NULL); + LOGD("evas_object_geometry_get : %d / %d", object_x, object_y); + move_to_y = object_y + velocity_factor*1.5; + + LOGD("animator_callback_with_finished_cb position : %d", move_to_y); + + evas_object_move(data, object_x, move_to_y); + + if (move_to_y > 820 || timeline >= 1.0) + { + LOGD("!! Finish animation and hide task-mgr !!"); + task_mgr_hide(); + return EINA_FALSE; + } + + velocity_factor++; + return EINA_TRUE; /* re-issue the timer */ +} + +void genlist_icon_transparent(Eina_List *recent_apps, Eina_List *running_apps) +{ + velocity_factor = 0; + int index = 0; + double duration = 2.0; + list_type_default_s *item = NULL; + + int genlist_item_count; + Evas_Object* task_mgr_genlist = task_mgr_get_list(); + + genlist_item_count = elm_genlist_items_count(task_mgr_genlist); + LOGD("khee :: ELM COUNT = %d\n", genlist_item_count); + + Elm_Object_Item *it = elm_genlist_first_item_get(task_mgr_genlist); + + // first_item(Clear_all item) has no "item"(item = NULL), so animation start from the second one. + it = elm_genlist_item_next_get(it); + if (it == NULL) + { + LOGE("it == NULL\n"); + return; + } + + elm_object_signal_emit(layout, "clear_all_text_fade_out", "layout"); + elm_object_signal_emit(layout, "clear_all_button_fade_out", "layout"); + + for (index = 0; index < 7; index++) + { + LOGD("START %d Icon's animation.", index); + item = elm_object_item_data_get(it); + if (item == NULL) + { + LOGD("Elm_Object_Item's item is NULL!"); + it = elm_genlist_item_next_get(it); + continue; + } + + // For fading "icon's line" out. + elm_object_signal_emit(item->data, "line,fade_out", "layout"); + + if (!index) + { + LOGD("Animation for the first icon"); + Ecore_Animator *anim; + anim = ecore_animator_timeline_add(duration, animator_callback_with_finished_cb, item->data); + if (!anim) + { + LOGE("Failed to create an animator"); + } + } + else + { + LOGD("Animation for others"); + Ecore_Animator *anim; + anim = ecore_animator_timeline_add(duration, animator_callback, item->data); + if (!anim) + { + LOGE("Failed to create an animator"); + } + } + + /** + * When could we delete this "anim" object? + */ + it = elm_genlist_item_next_get(it); + } +} + +static void add_clear_btn_to_genlist(Evas_Object *notification) +{ + LOGD("%s\n", __FUNCTION__); + Elm_Genlist_Item_Class *item_class = get_clear_all_class(); + + clear_all_item = elm_genlist_item_append(notification, item_class, + NULL, NULL, + ELM_GENLIST_ITEM_NONE, + NULL, NULL); + if (!clear_all_item) + { + LOGE("Failed to add clear all item to genlist"); + } +} + +void genlist_update(Evas_Object *genlist, Eina_List *recent_apps, Eina_List *running_apps) +{ + LOGD("%s\n", __FUNCTION__); + + genlist_clear_list(genlist); + + Eina_List *l; + list_type_default_s *item; + + if (eina_list_count(recent_apps) + eina_list_count(running_apps) > 0) + { + add_clear_btn_to_genlist(genlist); + } + + EINA_LIST_FOREACH(running_apps, l, item) + { + genlist_add_item(item); + } + + LOGD("Are there recent apps: %p\n", recent_apps); + LOGD("Adding recent apps... %d\n", eina_list_count(recent_apps)); + + EINA_LIST_FOREACH(recent_apps, l, item) + { + genlist_add_item(item); + } + + genlist_item_show(genlist); +} + +int genlist_count() +{ + Evas_Object *task_mgr_genlist = task_mgr_get_list(); + + if (!task_mgr_genlist) + { + return -1; + } + else + { + return elm_genlist_items_count(task_mgr_genlist); + } +} + +Elm_Object_Item *genlist_clear_all_item_btn(void) +{ + return clear_all_item; +} + diff --git a/src/genlist_item.c b/src/genlist_item.c new file mode 100644 index 0000000..6c4a5bf --- /dev/null +++ b/src/genlist_item.c @@ -0,0 +1,817 @@ +/* + * Task Manager + * + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.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 + * + * 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 <Elementary.h> +#include <stdbool.h> +#include <dlog.h> +#include <Ecore_X.h> +#include <feedback.h> +#include <math.h> + +#include "recent_apps.h" +#include "genlist_item.h" +#include "task-mgr-lite.h" +#include "genlist.h" + +#define ICON_X_COORD 203 +#define RECENT_APP_ITEM_WIDTH WVGA_SCREEN_WIDTH +#define RECENT_APP_ITEM_HEIGHT 116 +#define QUIT_TEXT_LEFT 75 +#define QUIT_TEXT_RIGHT 360 +#define BORDER 88 +#define HALF_LENGTH 240 +#define X_BORDER 36 +#define Y_BORDER 72 +#define Y_FIRST_BORDER 142 +#define Y_LAST1_BORDER 116 +#define Y_LAST2_BORDER 17 +#define TASKMGR_RES_PATH "/usr/apps/org.tizen.task-mgr/res" + +Evas_Object* recent_app_item_create(Evas_Object *win, char *icon, char *title, char *appid, list_type_default_s *item); +//static Evas_Object* _recent_app_item_scroller_create(Evas_Object *win); +static Evas_Object* _recent_app_item_main_create(Evas_Object *win, char *icon_path, char *title, char *appid, list_type_default_s *item); + +static void _icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _icon_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _icon_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info); + +Eina_Bool is_scrolling = EINA_FALSE; +Eina_Bool is_first = EINA_TRUE; +Eina_Bool no_shutdown = EINA_FALSE; +Eina_Bool icon_pressed = EINA_FALSE; + +static Elm_Genlist_Item_Class *genlist_class = NULL; +static Elm_Genlist_Item_Class *genlist_clear_all_class = NULL; + +static Ecore_Idler* idler = NULL; +Evas_Object *recent_app_item = NULL; + +static struct info { + Evas_Object *clear_item_layout; +} s_info = { + .clear_item_layout = NULL, +}; + +static struct +{ + int pressed; + int quit_visible; + int object_x; + int object_y; + int click_x; + // Evas_Object *data; + int layer_number; + Evas_Object *layout; + int layout_x; + int layout_y; + int touch_x; + int touch_y; + int is_moving; + int is_vertical_scrolling; + int is_vertical_scroll_lock; +} move_info = { + .pressed = 0, + .object_x = 0, + .object_y = 0, + .click_x = 0, + // .data = NULL, + .quit_visible = 0, + .layer_number = -1, + .layout = NULL, + .layout_x = 0, + .layout_y = 0, + .touch_x = 0, + .touch_y = 0, + .is_moving = 0, + .is_vertical_scrolling = 0, + .is_vertical_scroll_lock = 0 +}; + +typedef struct +{ + unsigned int running_app_count; + unsigned int recent_app_count; +} App_Counter; + +static App_Counter app_counter; + +void set_running_app_counter(int new_count) +{ + app_counter.running_app_count = new_count; +} + +void set_recent_app_counter(int new_count) +{ + app_counter.recent_app_count = new_count; +} + +void remove_item_from_genlist(Evas_Object *genlist, Elm_Object_Item *item_new) +{ + list_type_default_s *item = elm_object_item_data_get(item_new); + + if (item->pid > 0) { + } + + elm_object_item_del(item_new); + + app_counter.recent_app_count++; + app_counter.running_app_count--; + + LOGD("Running / Recent %s %d %d\n", __FUNCTION__, app_counter.running_app_count, app_counter.recent_app_count); + +} + +Elm_Genlist_Item_Class *get_item_class(void) +{ + return genlist_class; +} + +Elm_Genlist_Item_Class *get_clear_all_class(void) +{ + return genlist_clear_all_class; +} + +static Evas_Object* _recent_app_item_content_set(void *data, Evas_Object *obj, const char *part) +{ + LOGD("%s\n", __FUNCTION__); + list_type_default_s *item = data; + + if (strcmp(part, "elm.icon") != 0) { + LOGD("%s", part); + return NULL; + } + if (item) + LOGD("Setting content: %s; %s %p\n", item->icon, item->name, item->it); + else + { + LOGE("Item is NULL !!"); + return NULL; + } + + if (!item->isAlreadySet) + { + LOGD("It is already set."); + } + + + if (item->icon == NULL) + item->icon = "/usr/apps/com.samsung.task-mgr/res/images/default.png"; + + recent_app_item = recent_app_item_create(obj, item->icon, item->name, item->appid, item); + + Evas_Object *parent = elm_object_parent_widget_get(recent_app_item); + LOGD("Parent is: %s\n", elm_object_widget_type_get(parent)); + + item->isAlreadySet = true; + + LOGD("%s END\n", __FUNCTION__); + return recent_app_item; +} + +static void _recent_app_item_content_del(void *data, Evas_Object *obj) +{ + LOGD("%s\n", __FUNCTION__); + list_type_default_s *item = data; + + if (item->data) + { + LOGD("Data exist: %p", item->data); + + evas_object_del(item->data); + + LOGD("Item deleted"); + } + + item->isAlreadySet = false; +} + +static void _clear_all_button_del(void *data, Evas_Object *obj) +{ + LOGD("%s\n", __FUNCTION__); + if (s_info.clear_item_layout) + { + evas_object_del(s_info.clear_item_layout); + s_info.clear_item_layout = NULL; + } + + LOGD("%s END\n", __FUNCTION__); +} + +static void clear_all_btn_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + LOGD("Removing all items...\n"); + Evas_Object *layout = task_mgr_get_layout(); + if (!layout) + { + LOGE("layout == NULL"); + return; + } + + feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TAP); + + if (task_mgr_get_screen_width() == 720) + { + LOGD("On REDWOOD target (HD) : No Animation."); + task_mgr_hide(); + } + else + { + LOGD("On Kiran target (WVGA) : Animation."); + elm_layout_signal_emit(layout, "line_fade_out", "clipper"); + genlist_icon_transparent(task_mgr_history_list(), task_mgr_running_list()); + } +} + +static void _clear_all_btn_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + LOGD("%s\n", __FUNCTION__); + elm_layout_signal_emit(task_mgr_get_layout(), "line,show", "static_line"); +} + +static Evas_Object* _clear_all_button_create(void *data, Evas_Object *obj, const char *part) +{ + Evas_Object *win = task_mgr_get_win(); + Evas_Object *clear_button; + + if (!win) + { + LOGE("Failed to obtain the window"); + return NULL; + } + + s_info.clear_item_layout = elm_layout_add(win); + if (!s_info.clear_item_layout) + { + LOGE("Failed to create layout"); + return NULL; + } + + if (!elm_layout_file_set(s_info.clear_item_layout, TASKMGR_RES_PATH"/edje/recent_app-item.edj", "recent_app_item_main")) + { + LOGE("Failed to set file for notification item main layout"); + evas_object_del(s_info.clear_item_layout); + return NULL; + } + + clear_button = elm_button_add(win); + if (!clear_button) + { + LOGE("Failed to create button"); + evas_object_del(s_info.clear_item_layout); + return NULL; + } + + elm_object_style_set(clear_button, "naviframe/title_cancel"); + + elm_object_part_text_set(s_info.clear_item_layout, "clear_all_text", D_("IDS_TASKMGR_BUTTON_CLEAR_ALL")); + + /** + * clear_button --> for the accessibility (to build a focus chain) + */ + elm_object_part_content_set(s_info.clear_item_layout, "clear_all_button", clear_button); + elm_object_signal_callback_add(s_info.clear_item_layout, "mouse,clicked,1", "icon_button", clear_all_btn_clicked_cb, NULL); + + /** + * To show static_line, after clear_all button show. + */ + evas_object_event_callback_add(s_info.clear_item_layout, EVAS_CALLBACK_SHOW, _clear_all_btn_show_cb, NULL); + + evas_object_size_hint_min_set(s_info.clear_item_layout, ELM_SCALE_SIZE(RECENT_APP_ITEM_WIDTH), ELM_SCALE_SIZE(RECENT_APP_ITEM_HEIGHT)); + evas_object_size_hint_max_set(s_info.clear_item_layout, RECENT_APP_ITEM_WIDTH, RECENT_APP_ITEM_HEIGHT); + + evas_object_resize(s_info.clear_item_layout, RECENT_APP_ITEM_WIDTH, RECENT_APP_ITEM_HEIGHT); + + evas_object_show(s_info.clear_item_layout); + layout = s_info.clear_item_layout; + + return s_info.clear_item_layout; +} + +Elm_Genlist_Item_Class *genlist_item_class_create(void) +{ + LOGD("Genlist item class create"); + if (!genlist_class) + { + genlist_class = elm_genlist_item_class_new(); + genlist_class->item_style = "noti"; + genlist_class->func.content_get = _recent_app_item_content_set; + genlist_class->func.state_get = NULL; + genlist_class->func.del = _recent_app_item_content_del; + } + + return genlist_class; +} + +Elm_Genlist_Item_Class *genlist_clear_all_class_create(void) +{ + LOGD("Genlist clear all class create"); + if (!genlist_clear_all_class) + { + genlist_clear_all_class = elm_genlist_item_class_new(); + genlist_clear_all_class->item_style = "noti"; + genlist_clear_all_class->func.content_get = _clear_all_button_create; + genlist_clear_all_class->func.state_get = NULL; + genlist_clear_all_class->func.del = _clear_all_button_del; + } + + return genlist_clear_all_class; +} + +void genlist_item_class_destroy(void) +{ + if (genlist_class) + { + LOGD("Genlist class free"); + elm_genlist_item_class_free(genlist_class); + genlist_class = NULL; + } +} + +void genlist_clear_all_class_destroy(void) +{ + if (genlist_clear_all_class) + { + elm_genlist_item_class_free(genlist_clear_all_class); + genlist_clear_all_class = NULL; + } +} + +static Eina_Bool __idler_cb(void *data) +{ + int x = 0, y = 0, width = 0, height = 0, distance = 0; + Evas_Object* layout = task_mgr_get_layout(); + Evas_Object* track = elm_object_item_track(genlist_clear_all_item_btn()); // Get 'track Object'. + evas_object_geometry_get(track, &x, &y, &width, &height); // Get status of the 'track object' + + if ((x == 0 && y == 0 && width == 0 && height == 0)) // When "Clear all" icon is out of screen, center line do not need to move. + { + LOGD("Clear all icon is out of screen, so just return."); + distance = 100; + } + else + { + distance = (-1 * y) + 10; + } + + LOGD("distance : %d", distance); + Edje_Message_Int_Set *msg = malloc(sizeof(*msg) + 1 * sizeof(int)); + msg->count = 2; + msg->val[0] = distance; + edje_object_message_send(elm_layout_edje_get(layout), EDJE_MESSAGE_INT_SET, 1, msg); + free(msg); + + elm_object_item_untrack(genlist_clear_all_item_btn()); + idler = NULL; + + return ECORE_CALLBACK_CANCEL; +} +void on_list_scroll_drag_stop(void *data, Evas_Object *obj, void *event_info) // This is for moving center line. +{ + LOGD("on_list_scroll_drag_stop"); + move_info.is_vertical_scrolling = 0; +} +void on_list_scroll_drag_start(void *data, Evas_Object *obj, void *event_info) +{ + LOGD("on_list_scroll_drag_start"); + move_info.is_vertical_scrolling = 1; +} + +void on_list_scroll_move(void *data, Evas_Object *obj, void *event_info) // This is for moving center line. +{ + int x = 0, y = 0, width = 0, height = 0, distance = 0; + Evas_Object* layout = task_mgr_get_layout(); + Evas_Object* track = elm_object_item_track(genlist_clear_all_item_btn()); // Get 'track Object'. + int genlist_item_count = elm_genlist_items_count(task_mgr_get_list()); + int action = (int)data; + + move_info.is_vertical_scrolling = 1; + + LOGD("Action : %d", action); + if (action == 1) + { + is_scrolling = EINA_TRUE; + } + else if (action == 0 && icon_pressed == EINA_FALSE) + { + LOGE("Scroll end\n"); + //is_scrolling = EINA_FALSE; + } + + evas_object_geometry_get(track, &x, &y, &width, &height); // Get status of the 'track object' + LOGD("clear_all_ITEM's geometry information : %d,%d,%d,%d", x,y,width, height); + + if (genlist_item_count <= 7) + { + LOGD("genlist_item_count is %d (under 8). so just return.", genlist_item_count); + elm_object_item_untrack(genlist_clear_all_item_btn()); + return; + } + + if ((x == 0 && y == 0 && width == 0 && height == 0)) // When "Clear all" icon is out of screen, center line do not need to move. + { + LOGD("Clear all icon is out of screen, so just return."); + distance = 100; + } + else + { + distance = (-1 * y) + 10; + } + + LOGD("distance : %d", distance); + Edje_Message_Int_Set *msg = malloc(sizeof(*msg) + 1 * sizeof(int)); + msg->count = 2; + msg->val[0] = distance; + edje_object_message_send(elm_layout_edje_get(layout), EDJE_MESSAGE_INT_SET, 1, msg); + free(msg); + + elm_object_item_untrack(genlist_clear_all_item_btn()); // Untrack the 'track object' after use. + + if (action == 0) { + if (idler) { + ecore_idler_del(idler); + idler = NULL; + } + idler = ecore_idler_add(__idler_cb, NULL); + } +} + +void transparent_icon_cb(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Object *icon = NULL; + Evas_Object *layout = (Evas_Object *) data; + int object_x = 0, alpha = 255; + + if (!layout) + { + LOGE("Cannot get a layout"); + return; + } + + icon = elm_object_part_content_get(layout, "icon"); + + if (!icon) + { + LOGE("Cannot get a icon"); + return; + } + + evas_object_geometry_get(icon, &object_x, NULL, NULL, NULL); + + alpha = alpha - abs((ICON_X_COORD - object_x)); + + evas_object_color_set(layout, alpha, alpha, alpha, alpha); //color cannot be larger than alpha + + if ((object_x > QUIT_TEXT_RIGHT) || (object_x < QUIT_TEXT_LEFT)) + { + elm_object_signal_emit(layout, "quit,show", "layout"); + } + else + { + elm_object_signal_emit(layout, "quit,hide", "layout"); + } + +} + +static void on_scroller_edge(void *data) +{ + list_type_default_s *item = data; + char *appid = item->appid; + Evas_Object *genlist = task_mgr_get_list(); + + LOGD("Edge reached: %s\n", appid); + time_t launch_time = item->launch_time; + recent_apps_kill_selected(appid, item->pid); + + item->launch_time = launch_time; //needed because killing an app resets its running time + + remove_item_from_genlist(genlist, item->it); + + genlist_item_show(genlist); +} + +static void on_icon_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + list_type_default_s *item = data; + const char *appid = item->appid; + LOGD("%s\n", __FUNCTION__); + + no_shutdown = EINA_TRUE; + icon_pressed = EINA_FALSE; + + if (is_scrolling == EINA_FALSE) + { + launch_app(appid); + + feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TAP); + + if (item->pid < 0) + { + app_counter.recent_app_count--; + elm_object_item_del(item->it); + + genlist_item_show(task_mgr_get_list()); + + LOGE("Running / Recent %s %d %d\n", __FUNCTION__, app_counter.running_app_count, app_counter.recent_app_count); + } + // Exit task-mgr, after launch app. + elm_exit(); + } + else + { + is_scrolling = EINA_FALSE; + } +} + +Evas_Object* recent_app_item_create(Evas_Object *win, char *icon, char *title, char *appid, list_type_default_s *item) +{ + LOGD(""); + Evas_Object *box = NULL; + Evas_Object *item_main = NULL; + + if (!win) + { + LOGE("Failed to get lockscreen window"); + return NULL; + } + + item_main = _recent_app_item_main_create(win, icon, title, appid, item); + if (!item_main) + { + LOGE("Failed to create item main"); + return NULL; + } + + box = elm_box_add(win); + if (!box) + { + LOGE("Failed to create box"); + evas_object_del(item_main); + return NULL; + } + elm_box_horizontal_set(box, EINA_TRUE); + + evas_object_size_hint_min_set(box, ELM_SCALE_SIZE(RECENT_APP_ITEM_WIDTH * MULTIPLIER_PAGES), ELM_SCALE_SIZE(RECENT_APP_ITEM_HEIGHT)); + evas_object_size_hint_max_set(box, RECENT_APP_ITEM_WIDTH * MULTIPLIER_PAGES, RECENT_APP_ITEM_HEIGHT); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + elm_box_pack_end(box, item_main); + + evas_object_show(box); + + return box; //BOX temp +} + +static void _icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + int object_x, object_y; + if (move_info.pressed) + { + return; + } + + Evas_Object *scroller = task_mgr_get_list(); + + if (!scroller) + { + LOGE("Failed to get scroller"); + return; + } + +// elm_scroller_movement_block_set(scroller, ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL); + + list_type_default_s *item = (list_type_default_s*)data; + Evas_Object *edje_object = elm_layout_edje_get(item->data); + if (!edje_object) + { + return; + } + if (!item->icon_object) + { + return; + } + + move_info.layout = item->data; + int layout_x, layout_y; + evas_object_geometry_get(move_info.layout, &layout_x, &layout_y, NULL, NULL); + evas_object_geometry_get(item->icon_object, &object_x, &object_y, NULL, NULL); + move_info.object_x = object_x; + move_info.object_y = object_y; + move_info.layout_x = layout_x; + move_info.layout_y = layout_y; + + move_info.pressed = 1; + move_info.layer_number = evas_object_layer_get(item->icon_object); +} + +static void _icon_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + LOGE("Mouse up"); + if (!move_info.pressed) + { + return; + } + + list_type_default_s *item = (list_type_default_s*)data; + Evas_Object *scroller = task_mgr_get_list(); + + if (!scroller) + { + LOGE("Failed to get scroller"); + return; + } + if (!item->icon_object) + { + return; + } + + elm_scroller_movement_block_set(scroller, ELM_SCROLLER_MOVEMENT_NO_BLOCK); + move_info.is_vertical_scroll_lock = 0; + + is_first = EINA_TRUE; + + int object_x, object_y; + evas_object_geometry_get(item->icon_object, &object_x, &object_y, NULL, NULL); + move_info.pressed = 0; + + Ecore_X_Screen *screen = ecore_x_default_screen_get(); + int w; + int h; + ecore_x_screen_size_get (screen, &w, &h); + + if (object_x > w - ELM_SCALE_SIZE(BORDER) - move_info.click_x || object_x < ELM_SCALE_SIZE(BORDER) - move_info.click_x) + { + on_scroller_edge(data); + move_info.pressed = 0; + return; + } + if (object_x != move_info.object_x) + { + evas_object_move(item->data, move_info.layout_x, move_info.layout_y); + } + evas_object_layer_set(item->icon_object, move_info.layer_number); + move_info.object_x = -1; + move_info.object_y = -1; + move_info.layer_number = -1; + + move_info.is_moving = 0; + move_info.touch_x = 0; + move_info.touch_y = 0; + + int alpha = 255; + evas_object_color_set(item->icon_object, alpha, alpha, alpha, alpha); +} + +static void _icon_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + LOGD("Mouse move"); + Ecore_Event_Mouse_Move *move = event_info; + list_type_default_s *item = (list_type_default_s*)data; + if (!move_info.is_moving) + { + move_info.is_moving = 1; + move_info.touch_x = move->y; + move_info.touch_y = move->x; + return; + } + if ((!move_info.is_vertical_scroll_lock) && (abs(move_info.touch_x - move->y) < 30)) + { + LOGD("Under sensitive factor !!!!! :: %d", abs(move_info.touch_x - move->y)); + return; + } + if (move_info.is_vertical_scrolling) + { + LOGD("is_vertical_scrolling TRUE !!!!!"); + return; + } + + if (!move_info.pressed) + { + return; + } + + if (obj == NULL) + { + return; + } + if (!item->data) + { + return; + } + if (!item->icon_object) + { + return; + } + + int object_x = 0, object_y = 0, object_y1 = 0, alpha = 255; + + is_scrolling = EINA_TRUE; + elm_scroller_movement_block_set(task_mgr_get_list(), ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL); + move_info.is_vertical_scroll_lock = 1; + + evas_object_geometry_get(item->icon_object, &object_x, &object_y, NULL, NULL); + evas_object_geometry_get(item->data, NULL, &object_y1, NULL, NULL); + + move_info.layout_y = object_y1; + + alpha = alpha - abs(ELM_SCALE_SIZE(ICON_X_COORD) - object_x); + + evas_object_color_set(item->icon_object, alpha, alpha, alpha, alpha); //color cannot be larger than alpha + + Ecore_X_Screen *screen = ecore_x_default_screen_get(); + int w; + int h; + ecore_x_screen_size_get (screen, &w, &h); + + LOGE("%d %d", move->y, move->x); + + if (is_first == EINA_TRUE) + { + is_first = EINA_FALSE; + + if (w == 720) + move_info.click_x = (move->y - move_info.object_x)*0.25; + else + move_info.click_x = move->y - move_info.object_x; + } + + evas_object_move(item->data, ELM_SCALE_SIZE((move->y - move_info.object_x)- move_info.click_x) , move_info.layout_y); +} + +static void del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + LOGE("Deleted"); + list_type_default_s *item = data; + item->data = NULL; +} + +static Evas_Object* _recent_app_item_main_create(Evas_Object *win, char *icon_path, char *title, char *appid, list_type_default_s *item) +{ + LOGD(""); + Evas_Object *layout = NULL; + Evas_Object *icon = NULL; + + if (!win) + { + LOGE("Failed to get lockscreen window"); + return NULL; + } + + layout = elm_layout_add(win); + if (!layout) + { + LOGE("Failed to create layout"); + return NULL; + } + + if (!elm_layout_file_set(layout, EDJE_DIR"recent_app-item.edj", "recent_app_item_main")) + { + LOGE("Failed to set file for notification item main layout"); + return NULL; + } + + icon = elm_image_add(win); + if (!icon) + { + LOGE("Failed to create icon file"); + return NULL; + } + + item->data = layout; + item->icon_object = icon; + + evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_DOWN, _icon_mouse_down, item); + evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_UP, _icon_mouse_up, item); + evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_MOVE, _icon_mouse_move, item); + elm_object_signal_callback_add(layout, "mouse,clicked,*", "icon_button", on_icon_clicked, item); + + elm_image_file_set(icon, icon_path, NULL); + elm_object_part_content_set(layout, "icon_image", icon); + + if (title) + { + elm_object_part_text_set(layout, "icon_text", title); + } + + evas_object_show(icon); + evas_object_show(layout); + + evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, del_cb, item); + + return layout; +} diff --git a/src/recent_apps.c b/src/recent_apps.c new file mode 100755 index 0000000..d722f8b --- /dev/null +++ b/src/recent_apps.c @@ -0,0 +1,804 @@ +/* + * Task Manager + * + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.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 + * + * 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 <Elementary.h> +#include <aul.h> +#include <pkgmgr-info.h> +#include <rua.h> +#include <dlog.h> +#include <Evas.h> +#include <libintl.h> +#include <vconf.h> +#include <glib.h> + +#include "recent_apps.h" + +#define PACKAGE_SETTING_TIME_EFL "setting-time-efl" +#define PACKAGE_OMA_DM "com.samsung.oma-dm" +#define PACKAGE_CAMERA "com.samsung.camera-app-lite" +#define METADATA_MULTI_LAUNCH_KEY "http://developer.samsung.com/tizen/metadata/multiwindow" + +typedef enum { + RECENT_APPS_ERROR_OK = 0, + RECENT_APPS_ERROR_FAIL = -1, + RECENT_APPS_ERROR_DB_FAILED = -2, + RECENT_APPS_ERROR_OUT_OF_MEMORY = -3, + RECENT_APPS_ERROR_INVALID_PARAMETER = -4, + RECENT_APPS_ERROR_NO_DATA = -5, +} recent_apps_error_e; + +static struct info +{ + Eina_Bool is_usp_mode; +} s_info = { + .is_usp_mode = 0, +}; + +GHashTable *ai_tbl; +GHashTable *ar_tbl; + +struct appinfo { + char *appid; + bool taskmanage; + int support_mode; + char *pkgid; + char *icon; + char *name; + bool nodisplay; + int support_feature; +}; + +struct rinfo { + char *appid; +}; + +/* +struct timeval tv; +long long rua_history_load_db_startTime = 0LL; +long long rua_history_load_db_endTime = 0LL; + +long long rua_history_get_rec_startTime = 0LL; +long long rua_history_get_rec_endTime = 0LL; + +long long retrieve_item_startTime = 0LL; +long long retrieve_item_endTime = 0LL; + +long long for_total_startTime = 0LL; +long long for_total_endTime = 0LL; + +long long if_total_startTime = 0LL; +long long if_total_endTime = 0LL; + +long long pkgmgr_startTime = 0LL; +long long pkgmgr_endTime = 0LL; + +void stop_watch_start(long long startTime) +{ + +} +void stop_watch_end(char* name, long long startTime, long long endTime) +{ + +} +*/ + +static int get_app_taskmanage(const char *appid) +{ + int ret = 0; + bool taskmanage; + pkgmgrinfo_appinfo_h handle; + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + + if (ret != PMINFO_R_OK) + { + return -1; + } + + ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage); + + if (ret != PMINFO_R_OK) + { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + + LOGD("app %s is taskmanage: %d\n", appid, taskmanage); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + + return taskmanage; +} + +static Eina_Bool kill_pid(int pid) +{ + Eina_Bool ret = EINA_TRUE; + + if (aul_terminate_pid(pid) < 0) + { + if (kill(pid, SIGKILL) < 0) + { + LOGE("kill: %s (%d)", strerror(errno), pid); + ret = EINA_FALSE; + } + } + else + { + LOGD("terminate pid = %d\n", pid); + } + + return ret; +} + +static int recent_apps_kill_all_cb(const aul_app_info *ainfo, void *data) +{ + if ( ainfo && + ainfo->appid && + get_app_taskmanage(ainfo->appid) == 1 && + strcmp(ainfo->appid, "com.samsung.task-mgr") != 0 + ) + { + kill_pid(ainfo->pid); + } + + return 0; + +} + +void recent_apps_kill_all() +{ + LOGD("%s\n", __FUNCTION__); + aul_app_get_running_app_info(recent_apps_kill_all_cb, NULL); +} + +Eina_Bool launch_app(const char *appid) +{ + if (appid == NULL || strlen(appid) == 0) + { + LOGE("Fail to launch, due to Null appid."); + return EINA_FALSE; + } + LOGD("Launching: %s\n", appid); + Eina_Bool to_ret = aul_app_is_running(appid); + + if (to_ret) + { + LOGD("THE APP IS RUNNING: %d\n", to_ret); + aul_open_app(appid); + } + else + { + LOGD("THE APP IS NOT RUNNING: %d\n", to_ret); + aul_launch_app(appid, NULL); + } + + return to_ret; +} + +static int recent_apps_find_by_appid_cb(const aul_app_info *ainfo, void *data) +{ + Get_Pid_Struct *gps = data; + const char *appid = gps->appid; + + LOGD("Comparing: %s <> %s (%d)\n", appid, ainfo->appid, ainfo->pid); + + if (strcmp(appid, ainfo->appid) == 0) + { + LOGD("FOUND\n"); + gps->pid = ainfo->pid; + } + + return 0; +} + +int recent_apps_find_by_appid(char *appid) +{ + LOGD("%s\n", __FUNCTION__); + Get_Pid_Struct gps; + gps.appid = appid; + gps.pid = -1; + + aul_app_get_running_app_info(recent_apps_find_by_appid_cb, &gps); + + return gps.pid; +} + +Eina_Bool recent_apps_kill_selected(char *appid, int pid) +{ + int killed = EINA_FALSE; + + LOGD("%s\n", __FUNCTION__); + + LOGD("Pid returned: %d (%s)\n", pid, appid); + + if (appid == NULL) + { + LOGE("appid == NULL"); + return EINA_FALSE; + } + + if (pid > -1) + { + if (aul_app_is_running(appid) == EINA_TRUE) + { + killed = kill_pid(pid); + } + else + { + LOGE("Not running app[%s]", appid); + } + } + rua_delete_history_with_pkgname(appid); + + LOGD("END %d %s\n", killed, __FUNCTION__); + return killed; +} + +recent_apps_error_e list_sort(app_list *list, int (*_sort_cb)(const void *d1, const void *d2)) +{ + retv_if(NULL == list, RECENT_APPS_ERROR_INVALID_PARAMETER); + + list->list = eina_list_sort(list->list, eina_list_count(list->list), _sort_cb); + retv_if(NULL == list->list, RECENT_APPS_ERROR_FAIL); + + return RECENT_APPS_ERROR_OK; +} + +static int _app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data) +{ + retv_if(NULL == user_data, 0); + + LOGD("%s\n", metadata_name); + + if (metadata_name) { + *((bool *)user_data) = !strcmp(metadata_name, METADATA_MULTI_LAUNCH_KEY); + } + + return 0; +} + +bool list_is_multi_launch(pkgmgrinfo_appinfo_h app_handle) +{ + bool multi_launch = false; + + /** + * This function will invoke the callback before return. + * So the callback function can update this "multi_launch" value. + */ + if (PMINFO_R_OK != pkgmgrinfo_appinfo_foreach_metadata(app_handle, _app_metadata_list_cb, &multi_launch)) + { + return false; + } + + return multi_launch; +} + +static void list_unretrieve_item(list_type_default_s *default_info) +{ + ret_if(NULL == default_info); + list_type_default_s* item = default_info; + + LOGD("FREING %p %s 's Item(list_type_default_s) in %s\n", item, item->appid, __FUNCTION__); + + if (item->appid) + { + free(item->appid); + item->appid = NULL; + } + + if (item->pkgid) + { + free(item->pkgid); + item->pkgid = NULL; + } + + if (item->name) + { + free(item->name); + item->name = NULL; + } + + if (item->icon) + { + free(item->icon); + item->icon = NULL; + } + + if (item->arg) + { + free(item->arg); + item->arg = NULL; + } + + if (item) + { + free(item); + item = NULL; + } + + LOGD("%s END \n", __FUNCTION__); +} + +static list_type_default_s *list_retrieve_item(const char *appid, const char *arg, time_t launch_time) +{ + retv_if(NULL == appid, NULL); + + list_type_default_s *default_info = NULL; + bool taskmanage = false; + struct appinfo * ai; + int ret = 0, status = 0; + + ai = g_hash_table_lookup(ai_tbl, appid); + if (!ai) + { + LOGE("Fail to get ai table !!"); + return NULL; + } + + /** + * Check whether it supports taskmanage or not. + */ + taskmanage = ai->taskmanage; + if (!taskmanage) + { + LOGE("Not support taskmanage"); + return NULL; + } + + default_info = calloc(1, sizeof(*default_info)); + if (NULL == default_info) + { + LOGE("calloc: %s\n", strerror(errno)); + return NULL; + } + + default_info->appid = strdup(appid); + if (!default_info->appid) + { + LOGE("strdup: %s\n", strerror(errno)); + goto ERROR; + } + + if (!strcmp(default_info->appid, PACKAGE_CAMERA)) + { + LOGD("Should check camera app's status using vconfkey"); + ret = vconf_get_int("db/camera/display_state", &status); + LOGD("Camera App's display status :: %d", status); + /** + * Get camera app's status, and decide to show camera app's icon or not. + */ + if(ret == -1) { + LOGE("Fail to get vconf value (db/camera/display_state)!!"); + } + else + { + if(!status) + { + LOGD("Camera app must NOT display on task-mgr !!"); + goto ERROR; + } + } + } +/* + if (!strcmp(default_info->appid, PACKAGE_SETTING_TIME_EFL) || !strcmp(default_info->appid, PACKAGE_OMA_DM)) + { + LOGD("Date and time, oma-dm don't want to be shown on Task-Manager"); + free(default_info); + return NULL; + } +*/ + if (arg) + { + default_info->arg = strdup(arg); + if (!default_info->arg) + { + LOGE("strdup: %s\n", strerror(errno)); + goto ERROR; + } + } + + if (ai->pkgid) + { + default_info->pkgid = strdup(ai->pkgid); + } + else + { + LOGE("Fail to get pkgid from ai table !!"); + goto ERROR; + } + + if (ai->icon) + { + default_info->icon = strdup(ai->icon); + } + else + { + LOGE("Fail to get icon from ai table !!"); + goto ERROR; + } + + if (ai->name) + { + default_info->name = strdup(ai->name); + } + else + { + LOGE("Fail to get name from ai table !!"); + goto ERROR; + } + + LOGD("[%s]\n[%s]\n[%s]\n", ai->pkgid, ai->icon, ai->name); + + default_info->launch_time = launch_time; + + return default_info; + +ERROR: + if (default_info->icon) free(default_info->icon); + if (default_info->pkgid) free(default_info->pkgid); + if (default_info->appid) free(default_info->appid); + if (default_info->arg) free(default_info->arg); + if (default_info) free(default_info); + return NULL; +} + +static int _launch_time_sort_cb(const void *d1, const void *d2) +{ + list_type_default_s *tmp1 = (list_type_default_s *) d1; + list_type_default_s *tmp2 = (list_type_default_s *) d2; + + if (NULL == tmp1) return -1; + if (NULL == tmp2) return 1; + + if (NULL == tmp1->appid) return 1; + else if (NULL == tmp2->appid) return -1; + + return tmp1->launch_time >= tmp2->launch_time ? -1 : 1; +} + +void list_destroy(app_list *list) +{ + LOGD("START %s\n", __FUNCTION__); + + list_type_default_s *default_info = NULL; + + ret_if(NULL == list); + if (NULL == list->list) + { + free(list); + list = NULL; + return; + } + + LOGD("FREE ALL %s\n", __FUNCTION__); + + EINA_LIST_FREE(list->list, default_info) + { + if (NULL != default_info) + { + LOGD("FREING: %s %s\n", __FUNCTION__, default_info->appid); + list_unretrieve_item(default_info); + } + } + + free(list); + list = NULL; + LOGD("END %s\n", __FUNCTION__); +} + + +int __app_list_cb(pkgmgrinfo_appinfo_h app_handle, void *user_data) +{ + char *appid = NULL; + struct appinfo *ai; + char *pkgid = NULL; + char *name = NULL; + char *icon = NULL; + + ai = calloc(1, sizeof(*ai)); + + memset(ai, 0, sizeof(struct appinfo)); + + pkgmgrinfo_appinfo_get_appid(app_handle, &appid); + + ai->appid= strdup(appid); + + if (PMINFO_R_OK != pkgmgrinfo_appinfo_is_taskmanage(app_handle, &ai->taskmanage)) + { + goto ERROR; + } + + if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_support_mode(app_handle, &ai->support_mode)) { + goto ERROR; + } + + if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_pkgid(app_handle, &pkgid)) + { + goto ERROR; + } + + ai->pkgid = strdup(pkgid); + + if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_icon(app_handle, &icon)) + { + goto ERROR; + } + + if(icon) + ai->icon= strdup(icon); + + if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_label(app_handle, &name)) + { + goto ERROR; + } + if(name) + ai->name= strdup(name); + + if (PMINFO_R_OK != pkgmgrinfo_appinfo_is_nodisplay(app_handle, &ai->nodisplay)) + { + goto ERROR; + } + + if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_support_feature(app_handle, &ai->support_feature)) + { + goto ERROR; + } + + g_hash_table_insert(ai_tbl, ai->appid, ai); + return 0; + +ERROR: + if (ai->appid) free(ai->appid); + if (ai->pkgid) free(ai->pkgid); + if (ai->icon) free(ai->icon); + if (ai->name) free(ai->name); + free(ai); + return 0; +} + +static int iterfunc(const aul_app_info* info, void* data) +{ + struct rinfo *ri; + + ri = calloc(1, sizeof(*ri)); + memset(ri, 0, sizeof(struct rinfo)); + + ri->appid = strdup(info->appid); + + g_hash_table_insert(ar_tbl, ri->appid, ri); + + return 0; +} + + +static int __load_pkginfo() +{ + int ret = 0; + ai_tbl = g_hash_table_new(g_str_hash, g_str_equal); + + pkgmgrinfo_appinfo_filter_h handle; + + ret = pkgmgrinfo_appinfo_filter_create(&handle); + if (ret != PMINFO_R_OK) + { + return -1; + } + + ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_TASKMANAGE, 1); + if (ret != PMINFO_R_OK) + { + pkgmgrinfo_appinfo_filter_destroy(handle); + return -1; + } + + ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __app_list_cb, NULL); + if (ret != PMINFO_R_OK) + { + pkgmgrinfo_appinfo_filter_destroy(handle); + return -1; + } + + pkgmgrinfo_appinfo_filter_destroy(handle); + + ar_tbl = g_hash_table_new(g_str_hash, g_str_equal); + aul_app_get_running_app_info(iterfunc, NULL); + + return 0; +} + +int recent_app_list_create(app_list **history_list_p, app_list **running_list_p) +{ + LOGD("%s\n", __FUNCTION__); + rua_init(); + + list_type_default_s *default_info = NULL; + + char **table = NULL; + int nrows = 0; + int ncols = 0; + int row = 0; + app_list *history_list = NULL; + app_list *running_list = NULL; + int mode; + + if (__load_pkginfo() == -1) + { + LOGE("Fail to load pkginfo !!"); + return 0; + } + + if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &mode) == 0) + { + if (mode == SETTING_PSMODE_EMERGENCY) + { + LOGD("USP mode is enabled."); + s_info.is_usp_mode = 1; + } + else + { + LOGD("USP mode is disabled."); + s_info.is_usp_mode = 0; + } + } + else + { + LOGD("Fail to get VConfkey (VCONFKEY_SETAPPL_PSMODE)"); + s_info.is_usp_mode = 0; + } +/* + gettimeofday(&tv, 0); + rua_history_load_db_startTime = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; +*/ + if (-1 == rua_history_load_db(&table, &nrows, &ncols)) + { + if (table) + { + rua_history_unload_db(&table); + } + return 0; + } +/* + gettimeofday(&tv, 0); + rua_history_load_db_endTime = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; + LOGD("[TIME] [rua_history_load_db] time : %lld ms", (rua_history_load_db_endTime - rua_history_load_db_startTime)/1000); +*/ + + LOGD("Apps in history: %d\n", nrows); + + history_list = calloc(1, sizeof(*history_list)); + if (!history_list) + { + LOGE("calloc: %s\n", strerror(errno)); + if (table) + { + rua_history_unload_db(&table); + } + return 0; + } + + running_list = calloc(1, sizeof(*running_list)); + if (!running_list) + { + LOGE("calloc: %s\n", strerror(errno)); + if (table) + { + rua_history_unload_db(&table); + } + free(history_list); + return 0; + } +/* + gettimeofday(&tv, 0); + for_total_startTime = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; +*/ + // History list + for (; row < nrows; row++) { + struct rua_rec rec_result = {0,}; +/* + gettimeofday(&tv, 0); + rua_history_get_rec_startTime = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; +*/ + rua_history_get_rec(&rec_result, table, nrows, ncols, row); +/* + gettimeofday(&tv, 0); + rua_history_get_rec_endTime = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; + LOGD("[TIME] [rua_history_get_rec] time : %lld ms", (rua_history_get_rec_endTime - rua_history_get_rec_startTime)/1000); +*/ +/* + gettimeofday(&tv, 0); + retrieve_item_startTime = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; +*/ + default_info = list_retrieve_item(rec_result.pkg_name, rec_result.arg, rec_result.launch_time); +/* + gettimeofday(&tv, 0); + retrieve_item_endTime = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; + LOGD("[TIME] [list_retrieve_item] time : %lld ms", (retrieve_item_endTime - retrieve_item_startTime)/1000); +*/ + +/* + gettimeofday(&tv, 0); + if_total_startTime = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; +*/ + + if (default_info) + { + if (g_hash_table_lookup(ar_tbl, rec_result.pkg_name)) + { + LOGD("App added into the running_list : pkgid:%s - appid:%s", default_info->pkgid, default_info->appid); + running_list->list = eina_list_append(running_list->list, default_info); + } + else + { + LOGD("App added into the history_list : : pkgid:%s - appid:%s", default_info->pkgid, default_info->appid); + history_list->list = eina_list_append(history_list->list, default_info); + } + } +/* gettimeofday(&tv, 0); + if_total_endTime = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; + LOGD("[TIME] [IF_TOTAL] Total time : %lld ms", (if_total_endTime - if_total_startTime)/1000); +*/ + } +/* + gettimeofday(&tv, 0); + for_total_endTime = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; + LOGD("[TIME] [FOR_TOTAL] Total time : %lld ms", (for_total_endTime - for_total_startTime)/1000); +*/ + + if (history_list->list && RECENT_APPS_ERROR_OK != list_sort(history_list, _launch_time_sort_cb)) + { + LOGE("Cannot sort list for history apps"); + } + + if (running_list->list && RECENT_APPS_ERROR_OK != list_sort(running_list, _launch_time_sort_cb)) + { + LOGE("Cannot sort list for history apps"); + } + + rua_history_unload_db(&table); + + LOGD("HISTORY LIST: %p %d\n", history_list->list, eina_list_count(history_list->list)); + LOGD("RUNNING LIST: %p %d\n", running_list->list, eina_list_count(running_list->list)); + + *history_list_p = history_list; + *running_list_p = running_list; + + if (!eina_list_count(history_list->list) && !eina_list_count(running_list->list)) + { + LOGD("Don't need to init genlist."); + list_unretrieve_item(default_info); + return 0; + } + + return 1; +} + +void recent_app_list_destroy(app_list *history_list, app_list *running_list) +{ + LOGD("%s\n", __FUNCTION__); + + if (history_list && history_list->list != NULL) + { + list_destroy(history_list); + } + + if (running_list && running_list->list != NULL) + { + list_destroy(running_list); + } +} + +/* End of a file */ diff --git a/src/task-mgr-lite.c b/src/task-mgr-lite.c new file mode 100755 index 0000000..f8fae51 --- /dev/null +++ b/src/task-mgr-lite.c @@ -0,0 +1,477 @@ +/* + * Task Manager + * + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.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 + * + * 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> +#include <stdlib.h> +#include <appcore-efl.h> +#include <Evas.h> +#include <Elementary.h> +#include <Eina.h> +#include <aul.h> +#include <rua.h> +#include <bundle.h> +#include <Ecore_X.h> +#include <vconf.h> +#include <malloc.h> +#include <time.h> +#include <feedback.h> +#include <dlog.h> + +#include "genlist.h" +#include "recent_apps.h" +#include "genlist_item.h" +#include "task-mgr-lite.h" + +#define BUF_SIZE 1024 +#define WHITE "#F5F5F5" +#define LABEL_POSITION_X 203 +#define LABEL_POSITION_Y 367 +#define LABEL_RESIZE_HEIGHT 42 +#define KEY_BACK "XF86Stop" +#define KEY_HOME "XF86Phone" + +static struct +{ + Evas_Object *win; + Evas_Object *layout; + Evas_Object *list; + Evas_Object *bg; + app_list *history_list; + app_list *running_list; + int status; + int width; + int height; + Evas_Object *gesture_1; + Evas_Object *gesture_2; +} App_Info; + +/* +long long list_create_startTime = 0LL; +long long list_create_endTime = 0LL; + +struct timeval tv; +*/ +Evas_Object *task_mgr_get_win(void) +{ + return App_Info.win; +} + +Evas_Object *task_mgr_get_layout(void) +{ + return App_Info.layout; +} + +Evas_Object *task_mgr_get_list(void) +{ + return App_Info.list; +} + +Eina_List *task_mgr_history_list(void) +{ + return App_Info.history_list ? App_Info.history_list->list : NULL; +} + +Eina_List *task_mgr_running_list(void) +{ + return App_Info.running_list ? App_Info.running_list->list : NULL; +} + +int task_mgr_get_screen_width(void) +{ + return App_Info.width; +} + +void task_mgr_hide(void) +{ + if (elm_genlist_items_count(App_Info.list) > 1) + { + recent_apps_kill_all(); + elm_genlist_clear(App_Info.list); + rua_clear_history(); + + elm_exit(); + } +} + +static Eina_Bool on_hw_back(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info) +{ + LOGD("%s\n", __FUNCTION__); + Evas_Event_Key_Down *ev = event_info; + + if (type == EVAS_CALLBACK_KEY_DOWN && strncmp(KEY_BACK, ev->key, strlen(KEY_BACK)) == 0) + { + LOGD("KEY PRESSED: %s\n", ev->key); + + elm_exit(); + return EINA_TRUE; + } + else + { + return EINA_FALSE; + } + +} + +Eina_Bool on_tap_timer(void *data) +{ + LOGD("%s\n", __FUNCTION__); + if (no_shutdown == EINA_FALSE) + { +// set_autorotate(EINA_FALSE, EINA_FALSE); +// elm_win_withdrawn_set(App_Info.win, EINA_TRUE); + } + else + { + no_shutdown = EINA_FALSE; + } + + return ECORE_CALLBACK_CANCEL; +} + +static Evas_Event_Flags on_swipe_gesture(void *data, void *event_info) +{ + LOGD("%s\n", __FUNCTION__); + const char *number = data; + Elm_Gesture_Line_Info *info = event_info; + + LOGD("FLICK detected %s %f no_shutdown: %d\n", number, info->angle, no_shutdown); + + if (strcmp(number, "list") == 0) + { + is_scrolling = EINA_FALSE; + } + ecore_timer_add(1, on_tap_timer, NULL); + + return EVAS_EVENT_FLAG_NONE; +} + +static Evas_Object *add_layout(Evas_Object *parent, int w, int h) +{ + Evas_Object *layout = elm_layout_add(parent); + + if (!layout) + { + LOGE("Failed to create layout"); + return NULL; + } + evas_object_show(layout); + + evas_object_resize(layout, w, h); + + return layout; +} + +static Evas_Object *add_bg(Evas_Object *parent, int w, int h) +{ + Evas_Object *bg = elm_bg_add(parent); + if (!bg) + { + return NULL; + } + + evas_object_resize(bg, w, h); + evas_object_color_set(bg, 8, 8, 8, 100); + evas_object_show(bg); + + return bg; +} + +static int create_layout(void) +{ + LOGD("%s\n", __FUNCTION__); + Evas_Object *layout; + Eina_Bool layout_set = false; + + if (App_Info.layout) + { + LOGE("Already created"); + return 0; + } + + layout = add_layout(App_Info.win, App_Info.width, App_Info.height); + if (!layout) + { + LOGE("Failed to create layout"); + return -1; + } + + if (App_Info.width == 720 && App_Info.height == 1280) + { + LOGD("Resolution: HD"); + layout_set = elm_layout_file_set(layout, EDJE_DIR_TASK_MGR_LITE_HD, "task_mgr_ui"); + } + else if (App_Info.width == 480 && App_Info.height == 800) + { + LOGD("Resolution: WVGA"); + layout_set = elm_layout_file_set(layout, EDJE_DIR_TASK_MGR_LITE_WVGA, "task_mgr_ui"); + } + else + { + LOGD("Resolution: WVGA (default)"); + layout_set = elm_layout_file_set(layout, EDJE_DIR_TASK_MGR_LITE_WVGA, "task_mgr_ui"); + } + + if (EINA_FALSE == layout_set) + { + evas_object_del(layout); + LOGE("Cannot load layout"); + return -1; + } + + App_Info.layout = layout; + return 0; +} + +int init_gesture() +{ + App_Info.gesture_1 = elm_gesture_layer_add(App_Info.layout); + if (!App_Info.gesture_1) + { + LOGE("Failed to create gesture layer"); + return -1; + } + + elm_gesture_layer_attach(App_Info.gesture_1, App_Info.layout); + elm_gesture_layer_cb_set(App_Info.gesture_1, ELM_GESTURE_N_TAPS, ELM_GESTURE_STATE_END, on_swipe_gesture, "layout"); + + if (App_Info.list) + { + App_Info.gesture_2 = elm_gesture_layer_add(App_Info.list); + if (!App_Info.gesture_2) + { + LOGE("Failed to create gesture layer"); + evas_object_del(App_Info.gesture_1); + return -1; + } + + elm_gesture_layer_attach(App_Info.gesture_2, App_Info.list); + elm_gesture_layer_cb_set(App_Info.gesture_2, ELM_GESTURE_N_TAPS, ELM_GESTURE_STATE_END, on_swipe_gesture, "list"); + } + + return 0; +} + +static void delete_layout(void) +{ + LOGD("%s\n", __FUNCTION__); + if (App_Info.layout) + { + evas_object_del(App_Info.layout); + App_Info.layout = NULL; + } +} + +static int load_data(void) +{ + LOGD("%s\n", __FUNCTION__); + int ret = 0; + + if (App_Info.history_list || App_Info.running_list) { + LOGD("Already loaded"); + return 0; + } + + ret = recent_app_list_create(&App_Info.history_list, &App_Info.running_list); + + LOGD("LISTs : %p, %p", App_Info.history_list, App_Info.running_list); + if (!ret) + { + LOGD("No Applications should display !!"); + elm_object_part_text_set(App_Info.layout, "no_item_label", D_("IDS_TASKMGR_NPBODY_NO_APPLICATIONS_ABB2")); + elm_layout_signal_emit(App_Info.layout, "no_apps_text,show", "no_item_label"); + LOGD("Hide TaskManager(No Applications) - STMS : %s", D_("IDS_TASKMGR_NPBODY_NO_APPLICATIONS_ABB2")); + + return 0; + } + else + { + LOGD("App list should display !!"); + if (!App_Info.list) { + elm_layout_signal_emit(App_Info.layout, "no_apps_text,hide", "no_item_label"); + /** + * static_line show should be shown after clear all button flush ! + * static_line will be shown by _clear_all_btn_show_cb() in genlist_item.c + **/ + App_Info.list = genlist_init(App_Info.win, App_Info.layout, App_Info.running_list->list, App_Info.history_list->list); + elm_scroller_single_direction_set(App_Info.list, ELM_SCROLLER_SINGLE_DIRECTION_HARD); + + if (init_gesture() < 0) + { + LOGE("Failed to create a gesture layer"); + } + } + + genlist_update(App_Info.list, App_Info.history_list->list, App_Info.running_list->list); + } + + LOGD("%s END. \n", __FUNCTION__); + return 0; +} + +static int _create_app(void *data) +{ + elm_app_base_scale_set(1.8); + + LOGD("Application Create Callback "); + + int w = 0, h = 0; + + Evas_Object *win; + Ecore_X_Screen *screen; + + win = elm_win_add(NULL, "Taskmanager", ELM_WIN_BASIC); + if (!win) + { + LOGE("Failed to create win"); + return -1; + } + App_Info.win = win; + + screen = ecore_x_default_screen_get(); + if (!screen) { + evas_object_del(win); + return -1; + } + + ecore_x_screen_size_get (screen, &w, &h); + App_Info.width = w; + App_Info.height = h; + + feedback_initialize(); + + Evas_Object *bg = add_bg(win, w, h); + if (!bg) + { + LOGE("Failed to create bg"); + evas_object_del(win); + return -1; + } + App_Info.bg = bg; + + //4175 MB + + elm_object_event_callback_add(win, on_hw_back, NULL); + + elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_TRANSPARENT); + + elm_win_borderless_set(win, EINA_TRUE); + elm_win_alpha_set(win, EINA_TRUE); + evas_object_show(win); + + if (create_layout() < 0) + { + LOGE("Failed to create a layout"); + } + + if (load_data() < 0) + { + LOGE("Failed to load data"); + } + + return EXIT_SUCCESS; +} + +static int _terminate_app(void *data) +{ + LOGD("%s\n", __FUNCTION__); + + if (App_Info.gesture_1) + { + evas_object_del(App_Info.gesture_1); + App_Info.gesture_1 = NULL; + } + + if (App_Info.gesture_2) + { + evas_object_del(App_Info.gesture_2); + App_Info.gesture_2 = NULL; + } + + if (App_Info.list) + { + genlist_clear_list(App_Info.list); + evas_object_del(App_Info.list); + App_Info.list = NULL; + } + + delete_layout(); + + recent_app_list_destroy(App_Info.history_list, App_Info.running_list); + App_Info.history_list = NULL; + App_Info.running_list = NULL; + + rua_fini(); + + elm_cache_all_flush(); + malloc_trim(0); + appcore_flush_memory(); + + /** + * Even though the window is deleted automatically, + * It is good habit to delete window explicitly by your hands. + */ + + if (App_Info.bg) { + evas_object_del(App_Info.bg); + App_Info.bg = NULL; + } + + if (App_Info.win) { + evas_object_del(App_Info.win); + App_Info.win = NULL; + } + + return 0; +} + +static int _reset_app(bundle* bundle, void *data) +{ + LOGD("%s\n", __FUNCTION__); + + return EXIT_SUCCESS; +} + +static int _pause_app(void *data) +{ + LOGD("%s\n", __FUNCTION__); + + elm_exit(); + return EXIT_SUCCESS; +} + +int main(int argc, char **argv) +{ + LOGD("Application Main Function \n"); + int ret; + struct appcore_ops ops = + { + .create = _create_app, + .terminate = _terminate_app, + .reset = _reset_app, + .pause = _pause_app, + .resume = NULL, + }; + ops.data = &App_Info; + ret = appcore_efl_main("task-mgr", &argc, &argv, &ops); + + return ret; +} + +/* End of a file */ diff --git a/src/taskmanager.c b/src/taskmanager.c deleted file mode 100755 index 59fabf8..0000000 --- a/src/taskmanager.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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> -#include <unistd.h> -#include <appcore-efl.h> -#include <Elementary.h> -#include <Ecore_X.h> -#include <utilX.h> -#include <vconf.h> -#include <aul.h> -#include <sysman.h> - -#include "taskmanager.h" -#include "_util_log.h" -#include "_util_efl.h" -#include "_logic.h" -#include "_genlist.h" - -struct text_part { - char *part; - char *msgid; -}; - -enum { - IDLELOCK_OFF = 0x0, - IDLELOCK_ON, - IDLELOCK_MAX, -}; - -enum { - LCD_OFF = 0x0, - LCD_ON, - LCD_MAX, -}; - -static struct text_part main_txt[] = { -}; - -static void update_ts(Evas_Object *eo, struct text_part *tp, int size) -{ - int i; - - if (eo == NULL || tp == NULL || size < 0) - return; - - for (i = 0; i < size; i++) { - if (tp[i].part && tp[i].msgid) - edje_object_part_text_set(eo, - tp[i].part, _(tp[i].msgid)); - } -} - -static int _lang_changed(void *data) -{ - struct appdata *ad = data; - - if (ad->ly == NULL) - return 0; - - update_ts(elm_layout_edje_get(ad->ly), - main_txt, sizeof(main_txt) / sizeof(main_txt[0])); - - return 0; -} - -int _get_vconf_idlelock(void) -{ - int ret = -1; - int lock = IDLELOCK_OFF; - - ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock); - retvm_if(ret < 0, -1, "Failed to get vconf\n"); - _D("idlelock vconf:%d\n", lock); - - return lock == VCONFKEY_IDLE_LOCK ? IDLELOCK_ON : IDLELOCK_OFF; -} - -int _get_vconf_lcdstate(void) -{ - int ret = -1; - int lcd = 0; - - ret = vconf_get_int(VCONFKEY_PM_STATE, &lcd); - retvm_if(ret < 0, -1, "Failed to get vconf\n"); - _D("lcd vconf:%d\n", lcd); - - return lcd == VCONFKEY_PM_STATE_LCDOFF ? LCD_OFF : LCD_ON; -} - -Eina_Bool _exit_cb(void *data) -{ - /* - int lock = IDLELOCK_ON; - lock = _get_vconf_idlelock(); - - _D("lock(%d)\n", lock); - if(lock == IDLELOCK_OFF){ - _D("normal case\n"); - elm_exit(); - } - else{ - _D("IDLELOCK is set, taskmnager doesn't exit\n"); - return ECORE_CALLBACK_CANCEL; - } - return ECORE_CALLBACK_CANCEL; - */ - _D(""); - elm_exit(); - return ECORE_CALLBACK_CANCEL; -} - -void _key_grab(struct appdata *ad) -{ - int ret = 0; - Ecore_X_Window xwin; /* key grab */ - Ecore_X_Display *disp; /* key grab */ - - /* Key Grab */ - disp = ecore_x_display_get(); - xwin = elm_win_xwindow_get(ad->win); - - ret = utilx_grab_key(disp, xwin, KEY_SELECT, SHARED_GRAB); - retm_if(ret < 0, "Failed to grab home key\n"); -} - -int _set_launch_effect(Evas_Object *win) -{ - Ecore_X_Window xwin = 0; - static Ecore_X_Atom ATOM_WM_WINDOW_ROLE = 0; - static Ecore_X_Atom ATOM_NET_WM_NAME = 0; - retvm_if(win == NULL, -1, "[Error] Invalid argument: win is NULL\n"); - - ATOM_WM_WINDOW_ROLE = ecore_x_atom_get("WM_WINDOW_ROLE"); - if (!ATOM_WM_WINDOW_ROLE) { - _E("[App] %s(%d) XInternAtom(WM_WINDOW_ROLE) failed.\n", - __func__, __LINE__); - } - - ATOM_NET_WM_NAME = ecore_x_atom_get("_NET_WM_NAME"); - if (!ATOM_NET_WM_NAME) { - _E("[App] %s(%d) XInternAtom(ATOM_NET_WM_NAME) failed.\n", - __func__, __LINE__); - } - - xwin = elm_win_xwindow_get(win); - ecore_x_window_prop_string_set(xwin, ATOM_WM_WINDOW_ROLE, - "TASK_MANAGER"); - ecore_x_window_prop_string_set(xwin, ATOM_NET_WM_NAME, "TASK_MANAGER"); - - ecore_x_icccm_name_class_set(xwin, "TASK_MANAGER", "TASK_MANAGER"); - return 0; -} - -int _unset_notification_level(Evas_Object *win) -{ - Ecore_X_Window xwin; - - xwin = elm_win_xwindow_get(win); - ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NORMAL); - return 0; -} - -#if 0 -int _set_notification_level(Evas_Object *win, Utilx_Notification_Level level) -{ - Ecore_X_Window xwin = 0; - - xwin = elm_win_xwindow_get(win); - ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION); - utilx_set_system_notification_level(ecore_x_display_get(), xwin, level); - return 0; -} -#endif - -void _check_show_state(void) -{ - int lcd = LCD_OFF, idlelock = IDLELOCK_OFF; - lcd = _get_vconf_lcdstate(); - idlelock = _get_vconf_idlelock(); - if(lcd == LCD_OFF || idlelock == IDLELOCK_ON) - { - elm_exit(); - } -} - -int app_create(void *data) -{ - Evas_Object *win; - struct appdata *ad = data; - int r; - - win = _add_window(PACKAGE); - retv_if(win == NULL, -1); - elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW); - ad->win = win; - - _set_launch_effect(win); - - /* init internationalization */ - r = appcore_set_i18n(PACKAGE, LOCALEDIR); - retvm_if(r < 0, -1, "Failed to set i18n\n"); - /*_lang_changed(ad);*/ - - //elm_theme_extension_add(NULL, EDJ_THEME); - - _app_create(ad); - _set_itc(); - _set_genlist(ad); - - /* set dead signal listener */ - aul_listen_app_dead_signal(_dead_cb, ad); - - appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, - _lang_changed, ad); - - ecore_idler_add(_create_idler_cb, ad); - - return 0; -} - -static int app_terminate(void *data) -{ - return 0; -} - -static int app_pause(void *data) -{ - return 0; -} - -static int app_resume(void *data) -{ -_D("func\n"); - struct appdata *ad = data; - - refresh_app_info(ad); - if (ad->killall_timer) { - ecore_timer_del(ad->killall_timer); - ad->killall_timer = NULL; - } - if (ad->exit_timer) { - ecore_timer_del(ad->exit_timer); - ad->exit_timer = NULL; - } - - return 0; -} - -static int app_reset(bundle *b, void *data) -{ - struct appdata *ad = data; - - /* appcore measure time example */ - _D("from AUL to %s(): %d msec\n", __func__, - appcore_measure_time_from("APP_START_TIME")); - _D("from create to %s(): %d msec\n", __func__, - appcore_measure_time()); - - if (ad->win) { - elm_win_activate(ad->win); - ad->flag_select = EINA_FALSE; - } - - return 0; -} - -int main(int argc, char *argv[]) -{ - sysconf_set_mempolicy(OOM_IGNORE); - - struct appdata ad; - struct appcore_ops ops = { - .create = app_create, - .terminate = app_terminate, - .pause = app_pause, - .resume = app_resume, - .reset = app_reset, - }; - - /* appcore measure time example */ - _D("from AUL to %s(): %d msec\n", __func__, - appcore_measure_time_from("APP_START_TIME")); - - memset(&ad, 0x0, sizeof(struct appdata)); - ops.data = &ad; - - return appcore_efl_main(PACKAGE, &argc, &argv, &ops); -} diff --git a/src/taskmanager.h b/src/taskmanager.h deleted file mode 100755 index bedb288..0000000 --- a/src/taskmanager.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * org.tizen.taskmgr - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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, - * 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. - */ - - - - -#ifndef __TASKMANAGER_H__ -#define __TASKMANAGER_H__ - -#include <Elementary.h> -#include <Ecore_X.h> -#include <utilX.h> -#include <bundle.h> - -#if !defined(PACKAGE) -#define PACKAGE "taskmanager" -#endif - -#ifndef PREFIX -#define PREFIX "/usr/apps/org.tizen."PACKAGE -#endif - -#if !defined(RESDIR) -# define RESDIR PREFIX"/res" -#endif - -#if !defined(LOCALEDIR) -#define LOCALEDIR RESDIR"/locale" -#endif - -#if !defined(EDJDIR) -#define EDJDIR RESDIR"/edje"PACKAGE -#endif - -#if !defined(IMAGEDIR) -# define IMAGEDIR RESDIR"/images/"PACKAGE -#endif - -#define EDJ_NAME EDJDIR"/taskmgr.edj" -#define EDJ_THEME EDJDIR"/theme_taskmanager.edj" -#define GRP_TM "task_manager" - -#define S_(str) dgettext("sys_string", str) -#define T_(str) gettext(str) - -#define _BUF_MAX 256 -#define _EDJ(x) elm_layout_edje_get(x) - -#define POPUP_TIMER 1.0 -#define POPUP_TERMINATE_TIMER 1.5 - -struct appdata { - Evas *evas; - Evas_Object *win, *ly, *nv, *gl; - - Evas_Coord root_w, root_h; - - Eina_List *applist[2]; - /* runapp : 0, history: 1 */ - - Ecore_Timer *popup_timer; - Evas_Object *popup_ask; - Evas_Object *popup_progressbar; - - Ecore_Timer *update_timer; - Ecore_Timer *exit_timer; - - Ecore_Timer *killall_timer; - - double mem_total; - - int mode; - int ending; - int endcnt; - - Eina_Bool flag_select; -}; - -struct _task_info { - char *app_name; - char *pkg_name; - char *icn_path; - pid_t pid; - struct appdata *ad; - double mem, mem_total; - double cpu; - Elm_Object_Item *it; - int category; - bundle *b; - unsigned int oldutime, oldstime; - struct timeval oldtimev; -}; - - /* MODE_KILL_INUSE = MODE_END_INUSE * 2 - * MODE_KILL_ALL_INUSE = MODE_END_ALL_INUSE * 2 - */ -enum task_mode { - MODE_NONE = 0, - MODE_END_INUSE, - MODE_KILL_INUSE, - MODE_END_ALL_INUSE, - MODE_DEL_HISTORY, - MODE_DEL_ALL_HISTORY, - MODE_KILL_ALL_INUSE, -}; - -enum task_status { - TS_INUSE = 0, - TS_HISTORY, - TS_MAX, -}; - -Evas_Object *load_edj(Evas_Object *parent, const char *file, const char *group); -int _unset_notification_level(Evas_Object *win); -int _set_notification_level(Evas_Object *win, Utilx_Notification_Level level); -void _key_grab(struct appdata *ad); -Eina_Bool _exit_cb(void *data); -void _check_show_state(void); - -#endif -/* __TASKMANAGER_H___ */ |