Remove SMACK rule file(.rule) according three domain model
[apps/core/preloaded/taskmanager.git] / src / _genlist.c
1 /*
2  * org.tizen.taskmgr
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Flora License, Version 1.1 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://floralicense.org/license/
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18
19
20
21 #include <stdio.h>
22 #include <unistd.h>
23 #include <appcore-efl.h>
24 #include <vconf.h>
25 #include <utilX.h>
26 #include <aul.h>
27 #include <rua.h>
28 #include <Ecore_X.h>
29 #include <Eina.h>
30 #include <unistd.h>
31 #include <time.h>
32 #include <sys/time.h>
33 #include <pthread.h>
34
35 #include "taskmanager.h"
36 #include "_genlist.h"
37 #include "_util_log.h"
38 #include "_util_efl.h"
39 #include "_logic.h"
40 #include "_cpu.h"
41 #include "_eina.h"
42 #include "_info.h"
43 #include "_progressbar.h"
44
45 static Elm_Object_Item *g_egi;
46
47 /* group list:gl, data list:dl, button list:bl, no list: nl */
48 static Elm_Genlist_Item_Class itc_gl;
49 static Elm_Genlist_Item_Class itc_hl;
50 static Elm_Genlist_Item_Class itc_dl;
51 static Elm_Genlist_Item_Class itc_bl;
52 static Elm_Genlist_Item_Class itc_nl;
53 static Elm_Genlist_Item_Class itc_separator4;
54 static Elm_Genlist_Item_Class itc_separator2;
55
56 static char *button_text[TS_MAX] = {
57         "IDS_TASKMGR_BUTTON_CLOSE_ALL_APPLICATIONS",
58         "IDS_TASKMGR_BUTTON_CLEAR_HISTORY_ABB"
59 };
60
61 static void end_all_inuse_cb(void *data, Evas_Object *obj, void *event_info);
62 static void delete_all_history_cb(void *data, Evas_Object *obj,
63                                   void *event_info);
64 void (*func_del[TS_MAX]) (void *data, Evas_Object *obj, void *event_info) = {
65 &end_all_inuse_cb, &delete_all_history_cb};
66
67 static void end_inuse_cb(void *data, Evas_Object *obj, void *event_info);
68 static void delete_history_cb(void *data, Evas_Object *obj, void *event_info);
69 void (*func_end[TS_MAX]) (void *data, Evas_Object *obj, void *event_info) = {
70 &end_inuse_cb, &delete_history_cb};
71
72 static char *group_name[TS_MAX] = {
73         "IDS_TASKMGR_HEADER_RUNNING",
74         "IDS_TASKMGR_MBODY_RECENTLY_USED"
75 };
76
77 static char *nolist_text[TS_MAX] = {
78         "IDS_TASKMGR_MBODY_NO_APPS_OPEN",
79         "IDS_TASKMGR_MBODY_NO_RECENTLY_USED_APPS"
80 };
81
82 void taskmanager_free_info(struct _task_info *info);
83 Eina_Bool _update_list(void *data);
84
85 static void clear_genlist(void *data)
86 {
87         ret_if(data == NULL);
88
89         struct appdata *ad = data;
90
91         if (ad->gl) {
92                 elm_genlist_clear(ad->gl);
93         }
94 }
95
96 void clear_task_manager_list(void *data)
97 {
98         ret_if(data == NULL);
99
100         struct appdata *ad = data;
101         _free_einalist_all(ad);
102         clear_genlist(ad);
103 }
104
105 static void app_genlist_item_update(void *data)
106 {
107         ret_if(data == NULL);
108
109         struct appdata *ad = (struct appdata *)data;
110
111         Elm_Object_Item *it_r;
112         Eina_List *realized_item_list, *l_r;
113         unsigned int cnt = 0;
114
115         realized_item_list = elm_genlist_realized_items_get(ad->gl);
116         cnt = eina_list_count(realized_item_list);
117         if (cnt > 0) {
118                 EINA_LIST_FOREACH(realized_item_list, l_r, it_r) {
119                         if (it_r != NULL) {
120                                 elm_genlist_item_update(it_r);
121                         }
122                 }
123         }
124 }
125
126 Eina_Bool alert_app_info(void *data)
127 {
128         retv_if(data == NULL, -1);
129
130         struct appdata *ad = (struct appdata *)data;
131
132         app_genlist_item_update(ad);
133         return ECORE_CALLBACK_CANCEL;
134 }
135
136 static void end_all_inuse_cb(void *data, Evas_Object *obj, void *event_info)
137 {
138         ret_if(data == NULL);
139
140         struct appdata *ad = data;
141         char buf[_BUF_MAX] = { 0, };
142
143         ad->mode = MODE_END_ALL_INUSE;
144         snprintf(buf, sizeof(buf), T_("IDS_TASKMGR_POP_CLOSE_ALL_APPS_Q_THIS_MAY_CAUSE_DATA_TO_BE_LOST"));
145         if (ad->popup_ask) {
146                 evas_object_del(ad->popup_ask);
147                 ad->popup_ask = NULL;
148         }
149         ad->popup_ask = _add_popup_ask(ad->win, buf, ad);
150 }
151
152 static void
153 delete_all_history_cb(void *data, Evas_Object *obj, void *event_info)
154 {
155 _D("func\n");
156         ret_if(data == NULL);
157
158         struct appdata *ad = data;
159         char buf[_BUF_MAX] = { 0, };
160
161         ad->mode = MODE_DEL_ALL_HISTORY;
162         snprintf(buf, sizeof(buf), T_("IDS_TASKMGR_POP_CLEAR_ALL_APP_HISTORY_Q"));
163         if (ad->popup_ask) {
164                 evas_object_del(ad->popup_ask);
165                 ad->popup_ask = NULL;
166         }
167         ad->popup_ask = _add_popup_ask(ad->win, buf, ad);
168 }
169
170 static void end_inuse_cb(void *data, Evas_Object *obj, void *event_info)
171 {
172         ret_if(data == NULL);
173
174         struct _task_info *info_ev = (struct _task_info *)data;
175         struct appdata *ad = info_ev->ad;
176         char buf[_BUF_MAX] = { 0, };
177
178         ad->mode = MODE_END_INUSE;
179         snprintf(buf, _BUF_MAX, T_("IDS_TASKMGR_POP_CLOSE_PS_APP_Q_THIS_MAY_CAUSE_DATA_TO_BE_LOST"), info_ev->app_name);
180         if (ad->popup_ask) {
181                 evas_object_del(ad->popup_ask);
182                 ad->popup_ask = NULL;
183         }
184         ad->popup_ask = _add_popup_ask(ad->win, buf, ad);
185         g_egi = (void *)info_ev->it;
186 }
187
188 static void delete_history_cb(void *data, Evas_Object *obj, void *event_info)
189 {
190         ret_if(data == NULL);
191
192         struct _task_info *info_ev = (struct _task_info *)data;
193         struct appdata *ad = info_ev->ad;
194         char buf[_BUF_MAX] = { 0, };
195
196         ad->mode = MODE_DEL_HISTORY;
197
198         snprintf(buf, _BUF_MAX, T_("IDS_TASKMGR_POP_CLEAR_PS_HISTORY_Q"), info_ev->app_name);
199         if (ad->popup_ask) {
200                 evas_object_del(ad->popup_ask);
201                 ad->popup_ask = NULL;
202         }
203         ad->popup_ask = _add_popup_ask(ad->win, buf, ad);
204         g_egi = (void *)info_ev->it;
205 }
206
207 static void nl_sel(void *data, Evas_Object *obj, void *event_info)
208 {
209 _D("func\n");
210         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
211         elm_genlist_item_selected_set(item, EINA_FALSE);
212         return;
213 }
214
215 static char *nl_text_get(void *data, Evas_Object *obj, const char *part)
216 {
217         char buf[_BUF_MAX] = { 0, };
218
219         if (!strcmp(part, "elm.text")) {
220                 snprintf(buf, sizeof(buf), "%s", T_(nolist_text[(int)data]));
221
222                 return strdup(buf);
223         }
224         return NULL;
225 }
226
227 static void _gl_sel_app(void *data, Evas_Object *obj, void *event_info)
228 {
229 _D("func\n");
230         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
231         struct appdata *ad = (struct appdata *)data;
232         struct _task_info *info;
233         /* parameter to block double click */
234         static int selected = 0;
235         Elm_Object_Item *it = (Elm_Object_Item *) event_info;
236         int ret = -1;
237
238         elm_genlist_item_selected_set(it, EINA_FALSE);
239
240         retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
241
242         if (ad->update_timer) {
243                 ecore_timer_del(ad->update_timer);
244                 ad->update_timer = NULL;
245         }
246
247         if (selected == 1)
248                 return;
249         selected = 1;
250
251         if (item == NULL) {
252                 _E("[Error] Cannot find genlist item\n");
253                 selected = 0;
254                 return;
255         }
256
257         info = (struct _task_info *)elm_object_item_data_get(item);
258         if (info == NULL) {
259                 _E("[Error] Cannot get item data: info\n");
260                 selected = 0;
261                 return;
262         }
263
264         if (info->pid) {
265                 /* when application is alive */
266                 ret = aul_resume_pid(info->pid);
267                 selected = 0;
268         } else {
269                 /* when application is dead */
270                 if (info->pkg_name == NULL) {
271                         util_show_popup_with_message(info->ad->win,
272                                         3.0,
273                                         T_("IDS_TASKMGR_POP_UNABLE_TO_OPEN_APPLICATION"));
274                         selected = 0;
275
276                 } else {
277                         _unset_notification_level(info->ad->win);
278
279                         if (!strcmp(info->pkg_name, "org.tizen.phone")) {
280                                 /* exception : Because dialer doesn't need bundle
281                                  * since being unifyed dialer, voice call and video call
282                                  */
283                                 ret = aul_open_app(info->pkg_name);
284                                 selected = 0;
285                         } else {
286                                 ret = aul_open_app(info->pkg_name);
287                                 selected = 0;
288                         }
289                 }
290         }
291         if(ret == 0) {
292                 _D("exit after 0.3 sec\n");
293                 ad->exit_timer = ecore_timer_add(0.3, _exit_cb, ad);
294         }
295 }
296
297
298 static Evas_Object *_gl_content_get_app(void *data, Evas_Object *obj,
299                                      const char *part)
300 {
301         struct _task_info *info = (struct _task_info *)data;
302         char buf[_BUF_MAX] = { 0, };
303
304         Evas_Object *icon = NULL;
305         Evas_Object *btn = NULL;
306
307         Evas_Object *rt, *icon_ly = NULL;
308
309         retvm_if(data == NULL, NULL, "Invalid argument: task info is NULL\n");
310
311         if (!strcmp(part, "elm.icon.1")) {
312                 snprintf(buf, sizeof(buf), "%s", info->icn_path);
313                 retvm_if(buf == NULL, NULL, "%s icon is NULL\n", info->app_name);
314                 if (!ecore_file_exists(buf) || strlen(buf) < 4)
315                         snprintf((char *)buf, (size_t) sizeof(buf),
316                                  (const char *)IMAGEDIR "/icon_taskmgr.png");
317
318                 if (!strncmp(&buf[strlen(buf) - 3], "edj", 3)) {
319                         icon_ly = _add_layout(obj, buf, "icon");
320
321                 } else {
322                         icon_ly = elm_icon_add(obj);
323                         elm_image_file_set(icon_ly, buf, NULL);
324                 }
325
326                 icon = _add_layout(obj, EDJ_NAME, "icon");
327                 retvm_if(icon == NULL, NULL, "Cannot add layout: icon\n");
328
329                 rt = evas_object_rectangle_add(evas_object_evas_get(obj));
330                 retvm_if(rt == NULL, NULL, "Failed to add rectangle\n");
331
332                 evas_object_color_set(rt, 0, 0, 0, 0);
333                 evas_object_size_hint_min_set(rt,
334                                         (int)72 * elm_config_scale_get(),
335                                         (int)72 * elm_config_scale_get());
336                 elm_object_part_content_set(icon, "icon_ly", rt);
337
338                 elm_object_part_content_set(icon, "icon", icon_ly);
339
340                 return icon;
341
342         } else if (!strcmp(part, "elm.icon.2")) {
343                 btn = elm_button_add(obj);
344                 elm_object_text_set(btn, S_("IDS_COM_BODY_END"));
345                 elm_object_style_set(btn, "default");
346
347                 evas_object_smart_callback_add(btn, "clicked",
348                                                func_end[info->category], info);
349                 elm_object_focus_set(btn, EINA_FALSE);
350                 evas_object_propagate_events_set(btn, EINA_FALSE);
351
352                 return btn;
353         }
354
355         return NULL;
356 }
357
358 static char *_gl_text_get_app(void *data, Evas_Object *obj, const char *part)
359 {
360         struct _task_info *info = (struct _task_info *)data;
361         char buf[_BUF_MAX] = { 0, };
362
363         retvm_if(data == NULL, NULL, "Invalid argument: task info is NULL\n");
364         retvm_if(part == NULL, NULL, "Invalid argument: part is NULL\n");
365
366         if (!strcmp(part, "elm.text")) {
367                 snprintf(buf, _BUF_MAX, "%s", info->app_name);
368                 return strdup(buf);
369
370         }
371         return NULL;
372 }
373
374 static void _bl_sel(void *data, Evas_Object *obj, void *event_info)
375 {
376 _D("func\n");
377         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
378         elm_genlist_item_selected_set(item, EINA_FALSE);
379 }
380
381 static Evas_Object *_bl_content_get(void *data, Evas_Object *obj,
382                                 const char *part)
383 {
384         Evas_Object *btn = NULL;
385         struct appdata *ad = evas_object_data_get(obj, "appdata");
386
387         if (!strcmp(part, "elm.icon")) {
388
389                 btn = elm_button_add(obj);
390                 elm_object_style_set(btn, "default");
391
392                 elm_object_text_set(btn, T_(button_text[(int)data]));
393                 evas_object_smart_callback_add(btn, "clicked",
394                                                func_del[(int)data], ad);
395                 elm_object_focus_set(btn, EINA_FALSE);
396
397                 evas_object_size_hint_min_set(btn, 0, 50);
398                 evas_object_size_hint_max_set(btn, 0, 50);
399                 evas_object_propagate_events_set(btn, EINA_FALSE);
400
401                 return btn;
402
403         }
404         return NULL;
405 }
406
407 static char *_gl_text_get_title(void *data, Evas_Object *obj, const char *part)
408 {
409         char buf[_BUF_MAX];
410
411         if (!strcmp(part, "elm.text")) {
412                 snprintf(buf, sizeof(buf), "%s (%d)",
413                                 T_(group_name[(int)data]), _get_grp_cnt((int)data));
414                 return strdup(buf);
415         }
416         return NULL;
417 }
418
419 static char *_gl_text_get_his(void *data, Evas_Object *obj, const char *part)
420 {
421         struct _task_info *info = (struct _task_info *)data;
422         char buf[_BUF_MAX] = { 0, };
423
424         if (!strcmp(part, "elm.text")) {
425                 snprintf(buf, _BUF_MAX, "%s", info->app_name);
426                 return strdup(buf);
427         }
428         return NULL;
429 }
430
431 static Evas_Object *_gl_content_get_his(void *data, Evas_Object *obj,
432                                      const char *part)
433 {
434         struct _task_info *info = (struct _task_info *)data;
435         char buf[_BUF_MAX] = { 0, };
436
437         Evas_Object *icon = NULL;
438         Evas_Object *btn = NULL;
439
440         retvm_if(data == NULL, NULL, "Invalid argument: task info is NULL\n");
441
442         if (!strcmp(part, "elm.icon.1")) {
443                 snprintf(buf, sizeof(buf), "%s", info->icn_path);
444                 retvm_if(buf == NULL, NULL, "%s icon is NULL\n", info->app_name);
445                 if (!ecore_file_exists(buf) || strlen(buf) < 4)
446                         snprintf((char *)buf, (size_t) sizeof(buf),
447                                  (const char *)IMAGEDIR "/icon_taskmgr.png");
448
449                 icon = elm_icon_add(obj);
450                 elm_image_file_set(icon, buf, NULL);
451                 elm_image_preload_disabled_set(icon, EINA_TRUE);
452
453                 evas_object_size_hint_min_set(icon,
454                                         (int)72 * elm_config_scale_get(),
455                                         (int)72 * elm_config_scale_get());
456
457                 return icon;
458
459         } else if (!strcmp(part, "elm.icon.2")) {
460                 btn = elm_button_add(obj);
461                 elm_object_text_set(btn, S_("IDS_COM_OPT_DELETE"));
462                 elm_object_style_set(btn, "default");
463
464                 evas_object_smart_callback_add(btn, "clicked",
465                                                func_end[info->category], info);
466                 elm_object_focus_set(btn, EINA_FALSE);
467                 evas_object_propagate_events_set(btn, EINA_FALSE);
468
469                 return btn;
470         }
471
472         return NULL;
473
474 }
475
476 void _set_itc(void)
477 {
478         itc_gl.item_style = "grouptitle";
479         itc_gl.func.text_get = _gl_text_get_title;
480
481         //itc_dl.item_style = "2text.2icon.7";
482         itc_dl.item_style = "1text.2icon.4";
483         itc_dl.func.text_get = _gl_text_get_app;
484         itc_dl.func.content_get = _gl_content_get_app;
485
486         itc_hl.item_style = "1text.2icon.4";
487         itc_hl.func.text_get = _gl_text_get_his;
488         itc_hl.func.content_get = _gl_content_get_his;
489
490         itc_separator4.item_style = "dialogue/seperator";
491         itc_separator2.item_style = "dialogue/seperator";
492
493         itc_bl.item_style = "1icon";
494         itc_bl.func.content_get = _bl_content_get;
495
496         itc_nl.item_style = "1text";
497         itc_nl.func.text_get = nl_text_get;
498
499 }
500
501 int check_genlist(struct appdata *ad)
502 {
503         Elm_Object_Item *egi;
504         struct _task_info *info;
505
506         egi = elm_genlist_first_item_get(ad->gl);
507         while(egi) {
508                 info = (struct _task_info *)elm_object_item_data_get(egi);
509                 if(info) {
510                         _D("%s info[0x%x]\n", (int)info < 3 ? "-" : info->app_name, info);
511                 } else {
512                         _D("group\n");
513                 }
514                 egi = elm_genlist_item_next_get(egi);
515         }
516
517         return 0;
518 }
519
520 int _set_genlist_from_eina(struct appdata *ad)
521 {
522 _D("func\n");
523         Eina_List *l;
524         Elm_Object_Item *git, *item;
525         struct _task_info *info;
526         int i;
527
528         retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
529         retvm_if(ad->gl == NULL, -1, "Invalid argument:genlist is NULL\n");
530
531         for (i = 0; i < TS_MAX; i++) {
532                 git = elm_genlist_item_append(ad->gl, &itc_gl,
533                                                  (void *)i, NULL,
534                                                  ELM_GENLIST_ITEM_NONE,
535                                               NULL, NULL);
536                 retvm_if(git == NULL, -1, "Failed append item\n");
537                 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
538
539                 if (eina_list_count(ad->applist[i]) > 0) {
540
541                         item = elm_genlist_item_append(ad->gl, &itc_separator4,
542                                                 NULL, NULL,
543                                                 ELM_GENLIST_ITEM_NONE,
544                                                 NULL, NULL);
545                         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
546
547                         elm_genlist_item_append(ad->gl, &itc_bl,
548                                                 (void *)i, NULL,
549                                                 ELM_GENLIST_ITEM_NONE,
550                                                 _bl_sel, (void *)i);
551
552                         item = elm_genlist_item_append(ad->gl, &itc_separator2,
553                                                 NULL, NULL,
554                                                 ELM_GENLIST_ITEM_NONE,
555                                                 NULL, NULL);
556                         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
557
558                         ad->applist[i] = eina_list_nth_list(ad->applist[i], 0);
559                         EINA_LIST_FOREACH(ad->applist[i], l, info) {
560                                 if (info != NULL) {
561                                         info->it = elm_genlist_item_append(ad->gl,
562                                                                     (i == TS_INUSE) ? &itc_dl : &itc_hl,
563                                                                     (void *)info, NULL,
564                                                                     ELM_GENLIST_ITEM_NONE,
565                                                                     _gl_sel_app, ad);
566                                 }
567                         }
568                 } else {
569                         item = elm_genlist_item_append(ad->gl, &itc_nl,
570                                                 (void *)i, NULL,
571                                                 ELM_GENLIST_ITEM_NONE,
572                                                 nl_sel, NULL);
573                         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
574                 }
575         }
576         return 0;
577 }
578
579 void _set_genlist(struct appdata *ad)
580 {
581 _D("func\n");
582         retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
583         int ret = AUL_R_ERROR;
584         int retry_cnt = 0;
585         int sleep_value = 1000;
586
587         _init_grp_cnt();
588
589         while (ret != AUL_R_OK && retry_cnt < 5) {
590                 usleep(sleep_value);
591                 ret = aul_app_get_running_app_info(runapp_info_get, ad);
592
593                 if (ret != AUL_R_OK) {
594                         _D("Fail to get running app information from ail");
595                 }
596
597                 retry_cnt++;
598                 sleep_value *= 2;
599         }
600
601         taskmanager_get_history_app_info(ad);
602         _set_genlist_from_eina(ad);
603
604 }
605
606 void refresh_app_info(struct appdata *ad)
607 {
608 _D("func\n");
609         retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
610
611         _free_einalist_all(ad);
612         clear_genlist(ad);
613
614         _set_genlist(ad);
615
616         alert_app_info(ad);
617
618 }
619
620 void _del_popup_timer(struct appdata *ad)
621 {
622         if (ad->popup_timer) {
623                 ecore_timer_del(ad->popup_timer);
624                 ad->popup_timer = NULL;
625         }
626 }
627
628 void taskmanager_free_info(struct _task_info *info)
629 {
630         if (info) {
631                 if (info->app_name) {
632                         free(info->app_name);
633                         info->app_name = NULL;
634                 }
635                 if (info->pkg_name) {
636                         free(info->pkg_name);
637                         info->pkg_name = NULL;
638                 }
639                 if (info->icn_path) {
640                         free(info->icn_path);
641                         info->icn_path = NULL;
642                 }
643
644                 free(info);
645         }
646 }
647
648 int response_end_inuse(struct appdata *ad)
649 {
650 _D("func\n");
651         Eina_List *l, *l_next;
652         struct _task_info *info;
653         Eina_Bool dead = EINA_FALSE;
654
655         retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
656
657         ad->ending = EINA_TRUE;
658
659         EINA_LIST_FOREACH_SAFE(ad->applist[TS_INUSE], l, l_next, info) {
660                 _D("applist pid : %d", info->pid);
661                 if (info->it == g_egi) {
662                         _D("matched applist pid : %d", info->pid);
663                         if (info->pid > 0) {
664                                 if (aul_terminate_pid(info->pid) < 0) {
665                                         kill(info->pid, SIGKILL);
666                                         dead = EINA_TRUE;
667                                 }
668                         }
669                         break;
670                 }
671         }
672         ad->ending = EINA_FALSE;
673
674         if(!dead){
675                 _D("matched applist is nothing\n");
676                 _del_progressbar(ad);
677         }
678
679         return 0;
680 }
681
682 Eina_Bool _refresh_idler_cb(void *data)
683 {
684 _D("func\n");
685         struct appdata *ad = (struct appdata *)data;
686         retvm_if(data == NULL, ECORE_CALLBACK_CANCEL, "Invalid argument: appdata is NULL\n:");
687
688         _del_popup_timer(ad);
689         _del_progressbar(ad);
690         refresh_app_info(ad);
691         return ECORE_CALLBACK_CANCEL;
692 }
693
694 int response_end_all_inuse(struct appdata *ad)
695 {
696         Eina_List *l;
697         struct _task_info *info;
698
699         retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
700
701         ad->ending = EINA_TRUE;
702
703         if(ad->update_timer) {
704                 ecore_timer_del(ad->update_timer);
705                 ad->update_timer = NULL;
706         }
707
708         ad->endcnt = eina_list_count(ad->applist[TS_INUSE]);
709         _D("set end count (%d)\n", ad->endcnt);
710
711         EINA_LIST_FOREACH(ad->applist[TS_INUSE], l, info) {
712                 if (info != NULL) {
713                         _D("applist pid : %d", info->pid);
714                         if (info->pid > 0) {
715                                 if (aul_terminate_pid(info->pid) < 0) {
716                                         kill(info->pid, SIGKILL);
717                                 }
718                                 _D("terminated\n");
719                         }
720                 }
721         }
722         ad->ending = EINA_FALSE;
723         return 0;
724 }
725
726 int response_del_history(struct appdata *ad)
727 {
728         Eina_List *l, *l_next;
729         struct _task_info *info;
730
731         retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
732
733         _show_progressbar(ad);
734         EINA_LIST_FOREACH_SAFE(ad->applist[TS_HISTORY], l, l_next, info) {
735                 _D("history applist pid : %d", info->pid);
736                 if (info->it == g_egi) {
737
738                         if (rua_init() == -1) {
739                                 break;
740                         }
741                         rua_delete_history_with_pkgname(info->pkg_name);
742                         rua_fini();
743
744                         ad->applist[TS_HISTORY] =
745                             eina_list_remove_list(ad->applist[TS_HISTORY], l);
746
747                         if (info->b) {
748                                 bundle_free(info->b);
749                         }
750
751                         elm_object_item_del(info->it);
752                         taskmanager_free_info(info);
753                         break;
754                 }
755         }
756         alert_app_info(ad);
757         refresh_app_info(ad);
758         _del_popup_timer(ad);
759         _del_progressbar(ad);
760
761         ad->mode = MODE_NONE;
762         return 0;
763 }
764
765 int response_del_all_history(struct appdata *ad)
766 {
767         Eina_List *l;
768         struct _task_info *info;
769
770         retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
771
772         if(ad->update_timer) {
773                 _D("update timer is deleted\n");
774                 ecore_timer_del(ad->update_timer);
775                 ad->update_timer = NULL;
776         }
777
778
779         _show_progressbar(ad);
780
781         if (rua_init() == -1) {
782                 return -1;
783         }
784
785         EINA_LIST_FOREACH(ad->applist[TS_HISTORY], l, info) {
786                 if (info != NULL) {
787                         rua_delete_history_with_pkgname(info->pkg_name);
788                 }
789         }
790
791         if (eina_list_count(ad->applist[TS_INUSE]) == 0) {
792                 rua_clear_history();
793         }
794
795         rua_fini();
796         refresh_app_info(ad);
797         _del_popup_timer(ad);
798         _del_progressbar(ad);
799
800         ad->mode = MODE_NONE;
801         return 0;
802 }
803
804 int response_kill_inuse(struct appdata *ad)
805 {
806         Eina_List *l, *l_next;
807         struct _task_info *info;
808
809         retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
810
811         _show_progressbar(ad);
812
813         EINA_LIST_FOREACH_SAFE(ad->applist[TS_INUSE], l, l_next, info) {
814                 _D("kill applist pid : %d", info->pid);
815                 if (info->it == g_egi) {
816                         if (info->pid > 0) {
817                                 kill(info->pid, SIGKILL);
818                         }
819
820                         ad->applist[TS_INUSE] =
821                             eina_list_remove_list(ad->applist[TS_INUSE], l);
822                         taskmanager_free_info(info);
823                         break;
824                 }
825         }
826         refresh_app_info(ad);
827         _del_progressbar(ad);
828
829         return 0;
830 }
831
832 int response_kill_all_inuse(struct appdata *ad)
833 {
834         Eina_List *l;
835         struct _task_info *info;
836
837         retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
838
839         _show_progressbar(ad);
840
841         EINA_LIST_FOREACH(ad->applist[TS_INUSE], l, info) {
842                 _D("kill all applist pid : %d", info->pid);
843                 if (info != NULL) {
844                         if (info->pid > 0) {
845                                 kill(info->pid, SIGKILL);
846                         }
847                 }
848         }
849         refresh_app_info(ad);
850         _del_progressbar(ad);
851
852         return 0;
853 }
854