summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/_cpu.c111
-rwxr-xr-xsrc/_cpu.h28
-rwxr-xr-xsrc/_eina.c303
-rwxr-xr-xsrc/_eina.h36
-rwxr-xr-xsrc/_genlist.c854
-rwxr-xr-xsrc/_genlist.h45
-rwxr-xr-xsrc/_info.c134
-rwxr-xr-xsrc/_info.h28
-rwxr-xr-xsrc/_logic.c352
-rwxr-xr-xsrc/_logic.h33
-rwxr-xr-xsrc/_progressbar.c51
-rwxr-xr-xsrc/_progressbar.h28
-rwxr-xr-xsrc/_util_efl.c270
-rwxr-xr-xsrc/_util_efl.h42
-rwxr-xr-xsrc/_util_log.h63
-rwxr-xr-xsrc/taskmanager.c301
-rwxr-xr-xsrc/taskmanager.h133
17 files changed, 2812 insertions, 0 deletions
diff --git a/src/_cpu.c b/src/_cpu.c
new file mode 100755
index 0000000..8a7f1df
--- /dev/null
+++ b/src/_cpu.c
@@ -0,0 +1,111 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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
new file mode 100755
index 0000000..c3d9717
--- /dev/null
+++ b/src/_cpu.h
@@ -0,0 +1,28 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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
new file mode 100755
index 0000000..f8f3e24
--- /dev/null
+++ b/src/_eina.c
@@ -0,0 +1,303 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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) {
+ 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));
+ retvm_if(info == NULL, -1, "Failed to calloc _task_info\n");
+
+ 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);
+
+ 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) {
+ printf("[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) {
+ _D("pid(%u):(%u)\n", pid, info->pid);
+ 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
new file mode 100755
index 0000000..59d2efe
--- /dev/null
+++ b/src/_eina.h
@@ -0,0 +1,36 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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
new file mode 100755
index 0000000..0b21d53
--- /dev/null
+++ b/src/_genlist.c
@@ -0,0 +1,854 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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"
+};
+
+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;
+ }
+ 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;
+ }
+ 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"), info_ev->app_name);
+ if (ad->popup_ask) {
+ evas_object_del(ad->popup_ask);
+ ad->popup_ask = NULL;
+ }
+ ad->popup_ask = _add_popup_ask(ad->win, buf, ad);
+ g_egi = (void *)info_ev->it;
+}
+
+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"), info_ev->app_name);
+ if (ad->popup_ask) {
+ evas_object_del(ad->popup_ask);
+ ad->popup_ask = NULL;
+ }
+ ad->popup_ask = _add_popup_ask(ad->win, buf, ad);
+ g_egi = (void *)info_ev->it;
+}
+
+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;
+
+ 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->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_launch_app(info->pkg_name, NULL);
+ selected = 0;
+ } else {
+ ret = aul_launch_app(info->pkg_name, info->b);
+ 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");
+
+ if (!strncmp(&buf[strlen(buf) - 3], "edj", 3)) {
+ icon_ly = _add_layout(obj, buf, "icon");
+
+ } else {
+ icon_ly = elm_icon_add(obj);
+ elm_image_file_set(icon_ly, buf, NULL);
+ }
+
+ icon = _add_layout(obj, EDJ_NAME, "icon");
+ retvm_if(icon == NULL, NULL, "Cannot add layout: icon\n");
+
+ rt = evas_object_rectangle_add(evas_object_evas_get(obj));
+ retvm_if(rt == NULL, NULL, "Failed to add rectangle\n");
+
+ evas_object_color_set(rt, 0, 0, 0, 0);
+ evas_object_size_hint_min_set(rt,
+ (int)72 * elm_config_scale_get(),
+ (int)72 * elm_config_scale_get());
+ elm_object_part_content_set(icon, "icon_ly", rt);
+
+ elm_object_part_content_set(icon, "icon", icon_ly);
+
+ 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);
+
+ 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);
+}
+
+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");
+
+ if (!strcmp(part, "elm.icon")) {
+
+ btn = elm_button_add(obj);
+ 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);
+ elm_object_focus_set(btn, EINA_FALSE);
+
+ evas_object_size_hint_min_set(btn, 0, 50);
+ evas_object_size_hint_max_set(btn, 0, 50);
+ evas_object_propagate_events_set(btn, EINA_FALSE);
+
+ 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);
+
+ 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.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.func.text_get = _gl_text_get_his;
+ itc_hl.func.content_get = _gl_content_get_his;
+
+ itc_separator4.item_style = "dialogue/seperator";
+ itc_separator2.item_style = "dialogue/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) {
+ _D("kill all applist pid : %d", info->pid);
+ 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
new file mode 100755
index 0000000..876f741
--- /dev/null
+++ b/src/_genlist.h
@@ -0,0 +1,45 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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
new file mode 100755
index 0000000..bb7419e
--- /dev/null
+++ b/src/_info.c
@@ -0,0 +1,134 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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, EDJ_NAME, "info");
+ 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
new file mode 100755
index 0000000..46b206f
--- /dev/null
+++ b/src/_info.h
@@ -0,0 +1,28 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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
new file mode 100755
index 0000000..41ec8b8
--- /dev/null
+++ b/src/_logic.c
@@ -0,0 +1,352 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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 "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);
+ refresh_app_info(ad);
+
+ } else {
+ ad->endcnt--;
+ }
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static void _back_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_exit();
+}
+
+int _app_create(struct appdata *ad)
+{
+ Evas_Object *ly, *bg, *nv, *bt, *gl;
+
+ retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
+ ad->ending = EINA_FALSE;
+
+ ly = _add_layout_main(ad->win, EINA_TRUE, EINA_FALSE);
+ retvm_if(ly == NULL, -1, "Failed to add layout main\n");
+
+ 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(ly);
+ 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;
+
+ bt = elm_button_add(nv);
+ retvm_if(bt == NULL, -1, "Failed to add button\n");
+ elm_object_style_set(bt, "naviframe/end_btn/default");
+ evas_object_smart_callback_add(bt, "clicked", _back_cb, ad);
+
+ elm_naviframe_item_push(nv,
+ T_("IDS_TASKMGR_HEADER_TASK_SWITCHER"),
+ bt, NULL, ly, NULL);
+
+ 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");
+ ad->exit_timer = ecore_timer_add(0.3, _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) {
+ ad->exit_timer = ecore_timer_add(0.3, _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);
+ 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");
+ if (ad->popup_ask) {
+ evas_object_del(ad->popup_ask);
+ ad->popup_ask = NULL;
+ }
+
+ switch (ad->mode) {
+ case MODE_END_INUSE:
+ _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");
+ _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:
+ _D("del inuse\n");
+ _del_popup_timer(ad);
+ response_del_history(ad);
+ break;
+
+ case MODE_DEL_ALL_HISTORY:
+ _D("del all inuse\n");
+ _del_popup_timer(ad);
+ response_del_all_history(ad);
+ break;
+
+ case MODE_KILL_INUSE:
+ _D("kill all inuse\n");
+ response_kill_inuse(ad);
+ break;
+
+ case MODE_KILL_ALL_INUSE:
+ _D("kill all inuse\n");
+ response_kill_all_inuse(ad);
+ break;
+
+ default:
+ printf("[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
new file mode 100755
index 0000000..c37c075
--- /dev/null
+++ b/src/_logic.h
@@ -0,0 +1,33 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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
new file mode 100755
index 0000000..abc615d
--- /dev/null
+++ b/src/_progressbar.c
@@ -0,0 +1,51 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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
new file mode 100755
index 0000000..bdb2885
--- /dev/null
+++ b/src/_progressbar.h
@@ -0,0 +1,28 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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
new file mode 100755
index 0000000..5a43787
--- /dev/null
+++ b/src/_util_efl.c
@@ -0,0 +1,270 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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 "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) {
+ printf("[Error] Cannot add genlist\n");
+ return NULL;
+ }
+
+ 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) {
+ printf("[Error] Cannot add layout\n");
+ return NULL;
+ }
+
+ r = elm_layout_file_set(eo, file, group);
+ if (!r) {
+ printf("[Error] Cannot set file layout\n");
+ evas_object_del(eo);
+ return NULL;
+ }
+
+ 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) {
+ printf("[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) {
+ printf("[Error] Invalid argument: popup is NULL\n");
+ return ECORE_CALLBACK_CANCEL;
+ }
+ evas_object_del(eo);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+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);
+ evas_object_show(pu);
+
+ bt1 = elm_button_add(pu);
+ elm_object_text_set(bt1, S_("IDS_COM_SK_OK"));
+ elm_object_part_content_set(pu, "button1", bt1);
+ evas_object_smart_callback_add(bt1, "clicked", _ok_response_cb, data);
+
+ bt2 = elm_button_add(pu);
+ elm_object_text_set(bt2, S_("IDS_COM_POP_CANCEL"));
+ elm_object_part_content_set(pu, "button2", bt2);
+ evas_object_smart_callback_add(bt2, "clicked", _cancel_response_cb, data);
+
+
+ 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) {
+ printf("[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);
+
+ 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
new file mode 100755
index 0000000..ac9cafe
--- /dev/null
+++ b/src/_util_efl.h
@@ -0,0 +1,42 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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);
+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
new file mode 100755
index 0000000..a5aca2f
--- /dev/null
+++ b/src/_util_log.h
@@ -0,0 +1,63 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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/taskmanager.c b/src/taskmanager.c
new file mode 100755
index 0000000..cc32e30
--- /dev/null
+++ b/src/taskmanager.c
@@ -0,0 +1,301 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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;
+}
+
+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) {
+ fprintf(stderr,
+ "[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) {
+ fprintf(stderr,
+ "[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;
+}
+
+
+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;
+}
+
+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);
+// _set_notification_level(win, UTILX_NOTIFICATION_LEVEL_NORMAL);
+
+ /* 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 */
+ printf("from AUL to %s(): %d msec\n", __func__,
+ appcore_measure_time_from("APP_START_TIME"));
+ printf("from create to %s(): %d msec\n", __func__,
+ appcore_measure_time());
+
+ if (ad->win)
+ elm_win_activate(ad->win);
+ 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
new file mode 100755
index 0000000..d85a2ad
--- /dev/null
+++ b/src/taskmanager.h
@@ -0,0 +1,133 @@
+/*
+ * org.tizen.taskmgr
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://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;
+};
+
+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___ */