Change the display text from size to version
[apps/core/preloaded/ug-setting-manage-applications-efl.git] / ug / src / mgr-app-view-app-info.c
1 /*
2  *      Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  *      Licensed under the Flora License, Version 1.0 (the "License");
5  *      you may not use this file except in compliance with the License.
6  *      You may obtain a copy of the License at
7  *
8  *              http://floralicense.org/license/
9  *
10  *      Unless required by applicable law or agreed to in writing, software
11  *      distributed under the License is distributed on an "AS IS" BASIS,
12  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *      See the License for the specific language governing permissions and
14  *      limitations under the License.
15  */
16
17
18 #include "mgr-app-common-debug.h"
19 #include "mgr-app-common-error.h"
20 #include "mgr-app-common-util.h"
21 #include "mgr-app-view-main.h"
22 #include "mgr-app-view-common.h"
23 #include "mgr-app-string.h"
24 #include "mgr-app-widget.h"
25 #include "mgr-app-uigadget.h"
26
27 #include <stdbool.h>
28 #include <pkgmgr-info.h>
29 #include <package-manager.h>
30 #include <appsvc.h>
31 #include <app_manager.h>
32
33
34 #define WRT_PREFIX                                      "wgt"
35 #define RPM_PREFIX                                      "rpm"
36 #define TPK_PREFIX                                      "tpk"
37
38 #define UG_NAME_MIDLET_INFO_EFL         "midlet-info-efl"
39 #define UG_NAME_WEBAPP_INFO_EFL         "webapp-detail-efl"
40 #define UG_PARAM_KEY_PKG_NAME           "pkg_name"
41
42 #define STR_ICON                                        "icon"
43 #define STR_UGD                                         "ugd"
44 #define STR_INSTALLED_SIZE                      "installed_size"
45 #define STR_DATA_SIZE                           "data_size"
46
47 #define STR_BTN_UNINSTALL                       "btn_uninstall"
48 #define STR_POPUP                                       "popup"
49
50 #define MAX_NAME_LEN                            128
51 #define NUM_KILO                                        (1024)
52 #define NUM_MEGA                                        (1024*1024)
53 #define NUM_GIGA                                        (1024*1024*1024)
54
55 #define ELM_TEXT_1                                      "elm.text.1"
56 #define ELM_TEXT_2                                      "elm.text.2"
57 #define ELM_TEXT                                        "elm.text"
58 #define ELM_ICON                                        "elm.icon"
59 #define ELM_ICON_SWALLOW_1                      "elm.slide.swallow.1"
60 #define ELM_ICON_SWALLOW_2                      "elm.slide.swallow.2"
61 #define ELM_BUTTON_STYLE                        "popup_button/default"
62
63 #define ITC_ITEM_STYLE                          "dialogue/2text.1icon.2"
64 #define ITC_LIFE_ITEM_STYLE                     "mode/slide2/custom"
65 #define ITC_STO_TITLE_ITEM_STYLE        "dialogue/title"
66 #define ITC_STO_TOTAL_ITEM_STYLE        "dialogue/2text.2"
67 #define ITC_STO_APP_ITEM_STYLE          "dialogue/2text.2"
68 #define ITC_STO_DATA_ITEM_STYLE         "dialogue/2text.2"
69 #define ITC_DATA_ITEM_STYLE             "dialogue/bg/2icon"
70 #define ITC_LAUNCH_TITLE_ITEM_STYLE     "dialogue/title"
71 #define ITC_LAUNCH_ITEM_STYLE           "dialogue/1text"
72 #define ITC_LAUNCH_TEXT_ITEM_STYLE      "multiline/1text"
73 #define ITC_DETAIL_ITEM_STYLE           "dialogue/1text"
74 #define ITC_SEP_ITEM_STYLE                      "dialogue/separator"
75
76 enum {
77         ELM_STATE_TOP = 0,
78         ELM_STATE_BOTTOM,
79         ELM_STATE_CENTER,
80         ELM_STATE_DEFAULT,
81 };
82
83 static Evas_Object *_genlist = NULL;
84 static mgr_app_app_info_t *_app_info = NULL;
85
86 static Elm_Genlist_Item_Class *itc = NULL;
87 static Elm_Genlist_Item_Class *itc_life = NULL;
88 static Elm_Genlist_Item_Class *itc_sto_title = NULL;
89 static Elm_Genlist_Item_Class *itc_sto_total = NULL;
90 static Elm_Genlist_Item_Class *itc_sto_app = NULL;
91 static Elm_Genlist_Item_Class *itc_sto_data = NULL;
92 static Elm_Genlist_Item_Class *itc_data = NULL;
93 static Elm_Genlist_Item_Class *itc_launch_title = NULL;
94 static Elm_Genlist_Item_Class *itc_launch = NULL;
95 static Elm_Genlist_Item_Class *itc_launch_text = NULL;
96 static Elm_Genlist_Item_Class *itc_detail = NULL;
97 static Elm_Genlist_Item_Class *itc_sep = NULL;
98
99 static void _free_resources(struct ug_data *ugd)
100 {
101         MGR_APP_BEGIN();
102
103         int ret = 0;
104
105         if (ugd && ugd->pc) {
106                 MGR_APP_DEBUG("pc is freed");
107                 pkgmgr_client_free(ugd->pc);
108                 ugd->pc = NULL;
109         }
110
111         /* ug destroy */
112         if (ugd && ugd->sub_ug) {
113                 ret = ug_destroy(ugd->sub_ug);
114                 if (-1 == ret) {
115                         MGR_APP_DEBUG_ERR("ug_destroy ugd->sub_ug is failed");
116                 } else {
117                         ugd->sub_ug = NULL;
118                 }
119         }
120         
121         elm_genlist_item_class_free(itc_sep);
122         elm_genlist_item_class_free(itc);
123         elm_genlist_item_class_free(itc_life);
124         elm_genlist_item_class_free(itc_sto_title);
125         elm_genlist_item_class_free(itc_sto_total);
126         elm_genlist_item_class_free(itc_sto_app);
127         elm_genlist_item_class_free(itc_sto_data);
128         elm_genlist_item_class_free(itc_data);
129         elm_genlist_item_class_free(itc_launch_title);
130         elm_genlist_item_class_free(itc_launch);
131         elm_genlist_item_class_free(itc_launch_text);
132         elm_genlist_item_class_free(itc_detail);
133
134         MGR_APP_END();
135 }
136
137 static void _app_info_back_cb(void *data, Evas_Object *obj, void *event_info)
138 {
139         MGR_APP_BEGIN();
140
141         ret_if(data == NULL);
142         struct ug_data *ugd = (struct ug_data*)data;
143
144         _free_resources(ugd);
145
146         mgr_app_doubletap_sensor_disable();
147
148         elm_naviframe_item_pop(ugd->navi_bar);
149
150         mgrapp_set_view_type(VIEW_TYPE_APP_LIST);
151
152         MGR_APP_END();
153 }
154
155 static void _force_stop_clicked_cb(void *data, Evas_Object *obj, void *event_info)
156 {
157         MGR_APP_BEGIN();
158
159         ret_if(_app_info == NULL);
160         mgr_app_app_info_t *app_info = _app_info;
161         ret_if(app_info->pkg_name == NULL);
162         bool is_running = false;
163         int ret = APP_MANAGER_ERROR_NONE;
164         struct ug_data *ugd = NULL;
165
166         ret = app_manager_is_running(app_info->main_appid, &is_running);
167         switch (ret) {
168         case APP_MANAGER_ERROR_NONE:
169                 MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_NONE");
170                 break;
171         case APP_MANAGER_ERROR_INVALID_PARAMETER:
172                 MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_INVALID_PARAMETER");
173                 return;
174         default:
175                 MGR_APP_DEBUG("default");
176                 return;
177         }
178
179         if (is_running) {
180                 MGR_APP_DEBUG("%s app_is_running", app_info->main_appid);
181                 app_context_h app_context = {0, };
182
183                 ret = app_manager_get_app_context(app_info->main_appid, &app_context);
184                 switch (ret) {
185                 case APP_MANAGER_ERROR_NONE:
186                         MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_NONE");
187                         break;
188                 case APP_MANAGER_ERROR_INVALID_PARAMETER:
189                         MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_INVALID_PARAMETER");
190                         return;
191                 case APP_MANAGER_ERROR_DB_FAILED:
192                         MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_DB_FAILED");
193                         return;
194                 case APP_MANAGER_ERROR_OUT_OF_MEMORY:
195                         MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_OUT_OF_MEMORY");
196                         return;
197                 case APP_MANAGER_ERROR_NO_SUCH_APP:
198                         MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_NO_SUCH_APP");
199                         return;
200                 default:
201                         MGR_APP_DEBUG("default");
202                         return;
203                 }
204
205                 ret = app_manager_terminate_app(app_context);
206                 switch (ret) {
207                 case APP_MANAGER_ERROR_NONE:
208                         MGR_APP_DEBUG("terminate_app APP_MANAGER_ERROR_NONE");
209                         break;
210                 case APP_MANAGER_ERROR_INVALID_PARAMETER:
211                         MGR_APP_DEBUG("terminate_app APP_MANAGER_ERROR_INVALID_PARAMETER");
212                         return;
213                 default:
214                         MGR_APP_DEBUG("default");
215                         return;
216                 }
217
218                 ret = app_context_destroy(app_context);
219                 switch (ret) {
220                 case APP_MANAGER_ERROR_NONE:
221                         MGR_APP_DEBUG("context_destroy APP_MANAGER_ERROR_NONE");
222                         break;
223                 case APP_MANAGER_ERROR_INVALID_PARAMETER:
224                         MGR_APP_DEBUG("context_destroy APP_MANAGER_ERROR_INVALID_PARAMETER");
225                         break;
226                 default:
227                         MGR_APP_DEBUG("default");
228                         break;
229                 }
230                 ugd = evas_object_data_get(_genlist, STR_UGD);
231                 mgrapp_view_list_update_by_uninstall(app_info->pkg_type, app_info->pkg_name, (void*)ugd);
232
233         } else {
234                 MGR_APP_DEBUG("%s app is not running", app_info->main_appid);
235         }
236
237
238         if (obj) {
239                 elm_object_disabled_set(obj, EINA_TRUE);
240         }
241
242         MGR_APP_END();
243 }
244
245 static void _no_response_cb(void *data, Evas_Object *obj, void *event_info)
246 {
247         MGR_APP_BEGIN();
248
249         ret_if(data == NULL);
250         evas_object_del(data);
251
252         MGR_APP_END();
253 }
254
255 static void _uninstall_by_pkgmgr_cb(void *data, Evas_Object *obj, void *event_info)
256 {
257         MGR_APP_BEGIN();
258
259         ret_if(obj == NULL);
260         ret_if(_app_info == NULL);
261         mgr_app_app_info_t *app_info = _app_info;
262
263         struct ug_data *ugd = NULL;
264         ugd             = evas_object_data_get(_genlist, STR_UGD);
265         ret_if(ugd == NULL);
266
267         Evas_Object *btn_uninstall = NULL;
268         btn_uninstall = (Evas_Object*)evas_object_data_get(obj, STR_BTN_UNINSTALL);
269         ret_if(btn_uninstall == NULL);
270
271         Evas_Object *popup = NULL;
272         popup = (Evas_Object*)evas_object_data_get(obj, STR_POPUP);
273         ret_if(popup == NULL);
274
275         evas_object_data_del(obj, STR_BTN_UNINSTALL);
276         evas_object_data_del(obj, STR_POPUP);
277         evas_object_del(popup);
278
279         mgr_app_create_popup_progressbar(ugd->win_main, MGRAPP_STR_UNINSTALLING);
280
281         _force_stop_clicked_cb(data, btn_uninstall, event_info);
282
283         MGR_APP_DEBUG("pkg_type: %s, pkg_name: %s", app_info->pkg_type, app_info->pkg_name);
284         int req_id = 0;
285         if (ugd->pc) {
286                 pkgmgr_client_free(ugd->pc);
287                 ugd->pc = NULL;
288         }
289         ugd->pc = pkgmgr_client_new(PC_REQUEST);
290         if (!ugd->pc) {
291                 MGR_APP_DEBUG_ERR("create new pkgmgr client is failed");
292                 MGR_APP_END();
293                 return;
294         }
295
296         req_id = pkgmgr_client_uninstall(ugd->pc, app_info->pkg_type, app_info->pkg_name, PM_QUIET, /*mgrapp_view_listen_cb*/NULL, /*(void*)ugd*/NULL);
297
298         if (req_id > 0) {
299                 MGR_APP_DEBUG("uninstall success, req_id=%d", req_id);
300         } else {
301                 switch (req_id) {
302                 case PKGMGR_R_EINVAL:   /* -3: Invalid argument */
303                         MGR_APP_DEBUG("PKGMGR_R_EINVAL");
304                         break;
305                 case PKGMGR_R_ECOMM:    /* -2: Comunication Error */
306                         MGR_APP_DEBUG("PKGMGR_R_ECOMM");
307                         break;
308                 case PKGMGR_R_OK:               /* 0: General success */
309                         MGR_APP_DEBUG("PKGMGR_R_OK");
310                         break;
311                 default:
312                         MGR_APP_DEBUG("default req_id=%d", req_id);
313                         break;
314                 }
315         }
316
317         /* the select 'No' noti be available from pkg-mgr then add the condition */
318         elm_object_disabled_set(obj, EINA_FALSE);
319
320         MGR_APP_END();
321 }
322
323 static void _uninstall_clicked_cb(void *data, Evas_Object *obj, void *event_info)
324 {
325         MGR_APP_BEGIN();
326
327         ret_if(obj == NULL);
328         Evas_Object *btn_uninstall = obj;
329
330         ret_if(_app_info == NULL);
331
332         Evas_Object *popup = NULL;
333         Evas_Object *btn_yes = NULL;
334         Evas_Object *btn_no = NULL;
335         char buf[MAX_NAME_LEN] = {0, };
336         struct ug_data *ugd = NULL;
337
338         ugd = evas_object_data_get(_genlist, STR_UGD);
339         ret_if(ugd == NULL);
340
341         popup = elm_popup_add(ugd->navi_bar);
342         ret_if(popup == NULL);
343         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
344         snprintf(buf, sizeof(buf), "%s?", MGRAPP_STR_UNINSTALL);
345         elm_object_text_set(popup, buf);
346         elm_object_part_text_set(popup, "title,text", _app_info->pkg_label);
347
348         btn_yes = elm_button_add(popup);
349         ret_if(btn_yes == NULL);
350         elm_object_text_set(btn_yes, MGRAPP_STR_YES);
351         elm_object_part_content_set(popup, "button1", btn_yes);
352         elm_object_style_set(btn_yes, ELM_BUTTON_STYLE);
353         evas_object_smart_callback_add(btn_yes, "clicked", _uninstall_by_pkgmgr_cb, data);
354         evas_object_data_set(btn_yes, STR_BTN_UNINSTALL, btn_uninstall);
355         evas_object_data_set(btn_yes, STR_POPUP, popup);
356
357         btn_no = elm_button_add(popup);
358         ret_if(btn_no == NULL);
359         elm_object_text_set(btn_no, MGRAPP_STR_NO);
360         elm_object_part_content_set(popup, "button2", btn_no);
361         elm_object_style_set(btn_no, ELM_BUTTON_STYLE);
362         evas_object_smart_callback_add(btn_no, "clicked", _no_response_cb, (void*)popup);
363
364         evas_object_show(popup);
365
366         MGR_APP_END();
367 }
368
369 static void _clear_data_clicked_cb(void *data, Evas_Object *obj, void *event_info)
370 {
371         MGR_APP_BEGIN();
372         /* TODO */
373         if (obj) {
374                 elm_object_disabled_set(obj, EINA_TRUE);
375         }
376         MGR_APP_END();
377 }
378
379 static void _gl_sel(void *data, Evas_Object *obj, void *event_info)
380 {
381         MGR_APP_BEGIN();
382
383         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
384
385         if (item) {
386                 elm_genlist_item_selected_set(item, EINA_FALSE);
387         }
388
389         MGR_APP_END();
390 }
391
392 static void _gl_sel_launch(void *data, Evas_Object *obj, void *event_info)
393 {
394         MGR_APP_BEGIN();
395
396         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
397         ret_if(data == NULL);
398         struct ug_data *ugd = (struct ug_data*)data;
399
400         ret_if(_app_info == NULL);
401         mgr_app_app_info_t *app_info = _app_info;
402
403         ret_if(app_info->pkg_name == NULL);
404         char *package_name = NULL;
405         package_name = app_info->pkg_name;
406
407         if (item) {
408                 elm_genlist_item_selected_set(item, EINA_FALSE);
409                 elm_object_item_disabled_set(item, EINA_TRUE);
410         }
411
412         if (appsvc_is_defapp(package_name)) {
413                 MGR_APP_DEBUG("%s is the default app", package_name);
414                 if (appsvc_unset_defapp(package_name) != APPSVC_RET_OK) {
415                         MGR_APP_DEBUG_ERR("unset the %s to default app is failed", package_name);
416                 }
417         } else {
418                 MGR_APP_DEBUG("%s is not the default app", package_name);
419         }
420
421         MGR_APP_END();
422 }
423
424 static void _layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
425 {
426         MGR_APP_BEGIN();
427
428         ret_if(NULL == priv);
429
430         Evas_Object *base = NULL;
431
432         base = ug_get_layout(ug);
433         ret_if(NULL == base);
434
435         switch (mode) {
436         case UG_MODE_FULLVIEW:
437                 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
438                 ug_disable_effect(ug);
439                 evas_object_show(base);
440                 break;
441         default:
442                 break;
443         }
444
445         MGR_APP_END();
446 }
447
448 static void _result_cb(ui_gadget_h ug, service_h service, void *priv)
449 {
450         MGR_APP_BEGIN();
451
452         ret_if(NULL == priv);
453         
454         struct ug_data *mydata = NULL;
455         char *val = NULL;
456
457         mydata = priv;
458         if (service) {
459                 int ret = SERVICE_ERROR_NONE;
460
461                 ret = service_get_extra_data(service, "name", &val);
462                 switch (ret) {
463                 case SERVICE_ERROR_NONE:
464                         MGR_APP_DEBUG_ERR("SERVICE_ERROR_NONE");
465                         break;
466                 case SERVICE_ERROR_INVALID_PARAMETER:
467                         MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_PARAMETER");
468                         break;
469                 case SERVICE_ERROR_KEY_NOT_FOUND:
470                         MGR_APP_DEBUG_ERR("SERVICE_ERROR_KEY_NOT_FOUND");
471                         break;
472                 case SERVICE_ERROR_OUT_OF_MEMORY:
473                         MGR_APP_DEBUG_ERR("SERVICE_ERROR_OUT_OF_MEMORY");
474                         break;
475                 case SERVICE_ERROR_INVALID_DATA_TYPE:
476                         MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_DATA_TYPE");
477                         break;
478                 default:
479                         MGR_APP_DEBUG_ERR("ret value has an error. %d.", ret);
480                         break;
481                 }
482
483                 if (val) {
484                         MGR_APP_DEBUG("The name of UI gadget that sends result is [%s]", val);
485                 }
486         }
487
488         ug_destroy(ug);
489
490         MGR_APP_DEBUG("mydata->sub_ug:%d", mydata->sub_ug);
491
492         mydata->sub_ug = NULL;
493
494         MGR_APP_END();
495 }
496
497 static void _destroy_cb(ui_gadget_h ug, void *priv)
498 {
499         MGR_APP_BEGIN();
500
501         ret_if(NULL == ug);
502         ret_if(NULL == priv);
503
504         struct ug_data *mydata = (struct ug_data*)priv;
505
506         ug_destroy(ug);
507         mydata->sub_ug = NULL;
508
509         MGR_APP_END();
510 }
511
512 static void _create_ug(void *data)
513 {
514         MGR_APP_BEGIN();
515
516         ret_if(data == NULL);
517         struct ug_data *ugd = (struct ug_data*)data;
518         mgr_app_app_info_t *app_info = NULL;
519
520         ret_if(ugd->data == NULL);
521         app_info = (mgr_app_app_info_t*)ugd->data;
522
523         ui_gadget_h ug = {0, };
524         struct ug_cbs cbs = {0,};
525         service_h service = {0, };
526         int ret = MGR_APP_OK;
527
528         cbs.layout_cb   = _layout_cb;
529         cbs.result_cb   = _result_cb;
530         cbs.destroy_cb  = _destroy_cb;
531         cbs.priv                = (void*)ugd;
532
533         ret = service_create(&service);
534         switch (ret) {
535         case SERVICE_ERROR_NONE:
536                 MGR_APP_DEBUG("service_create SERVICE_ERROR_NONE");
537                 break;
538         case SERVICE_ERROR_INVALID_PARAMETER:
539                 MGR_APP_DEBUG_ERR("service_create SERVICE_ERROR_INVALID_PARAMETER");
540                 return;
541         case SERVICE_ERROR_OUT_OF_MEMORY:
542                 MGR_APP_DEBUG_ERR("service_create SERVICE_ERROR_OUT_OF_MEMORY");
543                 return;
544         default:
545                 MGR_APP_DEBUG_ERR("service_create ret value has an error, %d.", ret);
546                 return;
547         }
548
549         if (app_info->pkg_type && 0 == strncmp(app_info->pkg_type, WRT_PREFIX, strlen(WRT_PREFIX))) {
550                 MGR_APP_DEBUG("app_info->pkg_type: %s", app_info->pkg_type);
551                 MGR_APP_DEBUG("app_info->pkg_name : %s", app_info->pkg_name);
552
553                 ret = service_add_extra_data(service, UG_PARAM_KEY_PKG_NAME, app_info->pkg_name);
554                 switch (ret) {
555                 case SERVICE_ERROR_NONE:
556                         MGR_APP_DEBUG("service_add_extra_data SERVICE_ERROR_NONE");
557                         break;
558                 case SERVICE_ERROR_INVALID_PARAMETER:
559                         MGR_APP_DEBUG_ERR("service_add_extra_data SERVICE_ERROR_INVALID_PARAMETER");
560                         goto end;
561                 case SERVICE_ERROR_KEY_REJECTED:
562                         MGR_APP_DEBUG_ERR("service_add_extra_data SERVICE_ERROR_KEY_REJECTED");
563                         goto end;
564                 default:
565                         MGR_APP_DEBUG_ERR("service_add_extra_data ret value has an error, %d.", ret);
566                         goto end;
567                 }
568
569                 /* wrt ug more detail info */
570                 ug = ug_create(ugd->ug, UG_NAME_WEBAPP_INFO_EFL, UG_MODE_FULLVIEW, service, &cbs);
571                 ugd->sub_ug = ug;
572         } else {
573                 MGR_APP_DEBUG(">>> NOT SUPPORTED TYPE");
574         }
575
576 end:
577         ret = service_destroy(service);
578         switch (ret) {
579         case SERVICE_ERROR_NONE:
580                 MGR_APP_DEBUG("service_destroy SERVICE_ERROR_NONE");
581                 break;
582         case SERVICE_ERROR_INVALID_PARAMETER:
583                 MGR_APP_DEBUG_ERR("service_destroy SERVICE_ERROR_INVALID_PARAMETER");
584                 break;
585         case SERVICE_ERROR_OUT_OF_MEMORY:
586                 MGR_APP_DEBUG_ERR("service_destroy SERVICE_ERROR_OUT_OF_MEMORY");
587                 break;
588         default:
589                 MGR_APP_DEBUG_ERR("service_destroy ret value has an error, %d.", ret);
590                 break;
591         }
592
593         MGR_APP_END();
594 }
595
596 static void _gl_sel_detail(void *data, Evas_Object *obj, void *event_info)
597 {
598         MGR_APP_BEGIN();
599
600         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
601         struct ug_data *ugd = (struct ug_data*)data;
602
603         if (item) {
604                 elm_genlist_item_selected_set(item, 0);
605         }
606
607         _create_ug((void*)ugd);
608
609         MGR_APP_END();
610 }
611
612 static char *_get_formated_size(float size)
613 {
614         MGR_APP_BEGIN();
615
616         char *buf = (char*)malloc(sizeof(char)*MAX_NAME_LEN);
617         retv_if(buf == NULL, NULL);
618         memset(buf, 0, MAX_NAME_LEN);
619
620         if (size < NUM_KILO) {
621                 snprintf(buf, MAX_NAME_LEN, "%d %s", (int)size, MGRAPP_STR_BYTES);
622         } else if (size >= NUM_KILO && size < NUM_MEGA) {
623                 snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_KILO, MGRAPP_STR_KB);
624         } else if (size >= NUM_MEGA && size < NUM_GIGA) {
625                 snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_MEGA, MGRAPP_STR_MB);
626         } else {
627                 snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_GIGA, MGRAPP_STR_GB);
628         }
629
630         MGR_APP_END();
631         return buf;
632 }
633
634 static char *_gl_label_get(void *data, Evas_Object *obj, const char *part)
635 {
636         MGR_APP_BEGIN();
637
638         retv_if(_app_info == NULL, NULL);
639         mgr_app_app_info_t *app_info = _app_info;
640
641         char *label = NULL;
642         char buf[MAX_NAME_LEN] = {0, };
643
644         char *package_name      = app_info->pkg_name;
645         char *package_label     = app_info->pkg_label;
646         //char *app_name        = app_info->app_name;
647         char *icon_path         = app_info->icon_path;
648         char *pkg_type          = app_info->pkg_type;
649
650 //      MGR_APP_DEBUG("package_name:[%s], app_name:[%s], x_slp_packagetype:[%s], icon_path:[%s]\n", package_name, app_name, pkg_type, icon_path);
651         MGR_APP_DEBUG("package_label:[%s], x_slp_packagetype:[%s], icon_path:[%s]\n", package_label, pkg_type, icon_path);
652
653         MGR_APP_DEBUG("part:%s\n", part);
654         retv_if(package_label == NULL, NULL);
655
656         /* label for 'elm.text' part */
657         if (0 == strcmp(part, ELM_TEXT_1)) {
658                 if (package_label) {
659                         MGR_APP_MEM_STRDUP(label, package_label);
660                 }
661         } else if (0 == strcmp(part, ELM_TEXT_2)) {
662                 snprintf(buf, MAX_NAME_LEN, "%s: %s", MGRAPP_STR_VERSION, app_info->pkg_version);
663                 MGR_APP_MEM_STRDUP(label, buf);
664         } else {
665                 MGR_APP_MEM_STRDUP(label, MGRAPP_STR_ERROR);
666         }
667
668         MGR_APP_END();
669         return label;
670 }
671
672 static char *_gl_label_get_sto_total(void *data, Evas_Object *obj, const char *part)
673 {
674         MGR_APP_BEGIN();
675
676         retv_if(_app_info == NULL, NULL);
677         mgr_app_app_info_t *app_info = _app_info;
678
679         char *label = NULL;
680
681         MGR_APP_DEBUG("part:%s\n", part);
682
683         /* label for 'elm.text' part */
684         if (0 == strcmp(part, ELM_TEXT_2)) {
685                 MGR_APP_MEM_STRDUP(label, MGRAPP_STR_TOTAL);
686         } else if (0 == strcmp(part, ELM_TEXT_1)) {
687                 label = _get_formated_size((float)app_info->total_size);
688         } else {
689                 MGR_APP_MEM_STRDUP(label, MGRAPP_STR_ERROR);
690         }
691
692         MGR_APP_END();
693         return label;
694 }
695
696 static char *_gl_label_get_sto_app(void *data, Evas_Object *obj, const char *part)
697 {
698         MGR_APP_BEGIN();
699
700         retv_if(_app_info == NULL, NULL);
701         mgr_app_app_info_t *app_info = _app_info;
702
703         char *label = NULL;
704
705         MGR_APP_DEBUG("part:%s\n", part);
706
707         /* label for 'elm.text' part */
708         if (0 == strcmp(part, ELM_TEXT_2)) {
709                 MGR_APP_MEM_STRDUP(label, MGRAPP_STR_APPLICATION);
710         } else if (0 == strcmp(part, ELM_TEXT_1)) {
711                 label = _get_formated_size((float)app_info->total_size - (float)app_info->data_size);
712         } else {
713                 MGR_APP_MEM_STRDUP(label, MGRAPP_STR_ERROR);
714         }
715
716         MGR_APP_END();
717         return label;
718 }
719
720 static char *_gl_label_get_sto_data(void *data, Evas_Object *obj, const char *part)
721 {
722         MGR_APP_BEGIN();
723
724         retv_if(_app_info == NULL, NULL);
725         mgr_app_app_info_t *app_info = _app_info;
726
727         char *label = NULL;
728
729         MGR_APP_DEBUG("part:%s\n", part);
730
731         /* label for 'elm.text' part */
732         if (0 == strcmp(part, ELM_TEXT_2)) {
733                 MGR_APP_MEM_STRDUP(label, MGRAPP_STR_DATA);
734         } else if (0 == strcmp(part, ELM_TEXT_1)) {
735                 label = _get_formated_size((float)app_info->data_size);
736         } else {
737                 MGR_APP_MEM_STRDUP(label, MGRAPP_STR_ERROR);
738         }
739
740         MGR_APP_END();
741         return label;
742 }
743
744 static char *_gl_label_get_launch(void *data, Evas_Object *obj, const char *part)
745 {
746         MGR_APP_BEGIN();
747
748         char *label = NULL;
749
750         MGR_APP_DEBUG("part:%s\n", part);
751
752         /* label for 'elm.text' part */
753         if (0 == strcmp(part, ELM_TEXT)) {
754                 MGR_APP_MEM_STRDUP(label, MGRAPP_STR_CLEAR_DEFAULTS);
755         }
756
757         MGR_APP_END();
758         return label;
759 }
760
761 static char *_gl_label_get_detail(void *data, Evas_Object *obj, const char *part)
762 {
763         MGR_APP_BEGIN();
764
765         char *label = NULL;
766
767         MGR_APP_DEBUG("part:%s\n", part);
768
769         /* label for 'elm.text' part */
770         if (0 == strcmp(part, ELM_TEXT)) {
771                 MGR_APP_MEM_STRDUP(label, MGRAPP_STR_MORE_DETAILS);
772         }
773
774         MGR_APP_END();
775         return label;
776 }
777
778 static char *_gl_label_get_launch_text(void *data, Evas_Object *obj, const char *part)
779 {
780         MGR_APP_BEGIN();
781
782         char *label = NULL;
783
784         MGR_APP_DEBUG("part:%s\n", part);
785
786         /* label for 'elm.text' part */
787         if (0 == strcmp(part, ELM_TEXT)) {
788                 MGR_APP_MEM_STRDUP(label, MGRAPP_STR_DEFAULT_DESC);
789         }
790
791         MGR_APP_END();
792         return label;
793 }
794
795 static Evas_Object *_gl_icon_get(void *data, Evas_Object *obj, const char *part)
796 {
797         MGR_APP_BEGIN();
798
799         retv_if(_app_info == NULL, NULL);
800         mgr_app_app_info_t *app_info = _app_info;
801
802         Evas_Object *icon = NULL;
803         char *icon_path = NULL;
804
805         retv_if(app_info->icon_path == NULL, NULL);
806         icon_path = app_info->icon_path;
807
808         MGR_APP_DEBUG("icon_path:[%s]\n", icon_path);
809         MGR_APP_DEBUG("part:%s\n", part);
810
811         /* icon for 'elm.icon' part */
812         icon = elm_icon_add(obj);
813         retv_if(icon == NULL, NULL);
814         elm_image_file_set(icon, icon_path, STR_ICON);
815
816         evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
817
818         MGR_APP_END();
819
820         return icon;
821 }
822
823 static Evas_Object *_gl_icon_get_life(void *data, Evas_Object *obj, const char *part)
824 {
825         MGR_APP_BEGIN();
826
827         MGR_APP_DEBUG("part:%s\n", part);
828         retv_if(_app_info == NULL, NULL);
829         mgr_app_app_info_t *app_info = _app_info;
830
831         Evas_Object *button = NULL;
832         if (0 == strcmp(part, ELM_ICON_SWALLOW_2)) {
833                 button = elm_button_add(obj);
834                 if (button) {
835                         elm_object_style_set(button, ELM_BUTTON_STYLE);
836                         elm_object_disabled_set(button, EINA_TRUE);
837                         elm_object_text_set(button, MGRAPP_STR_UNINSTALL);
838                         evas_object_smart_callback_add(button, "clicked", _uninstall_clicked_cb, (void*)data);
839
840                         if (app_info->removable) {
841                                 elm_object_disabled_set(button, EINA_FALSE);
842                         }
843                 }
844         } else if (0 == strcmp(part, ELM_ICON_SWALLOW_1)) {
845                 button = elm_button_add(obj);
846                 if (button) {
847                         elm_object_style_set(button, ELM_BUTTON_STYLE);
848                         elm_object_disabled_set(button, EINA_TRUE);
849                         elm_object_text_set(button, MGRAPP_STR_FORCE_STOP);
850                         evas_object_smart_callback_add(button, "clicked", _force_stop_clicked_cb, (void*)data);
851
852                         if (app_info->taskmanage) {
853                                 bool is_running = false;
854                                 int ret = app_manager_is_running(app_info->main_appid, &is_running);
855
856                                 switch (ret) {
857                                 case APP_MANAGER_ERROR_NONE:
858                                         MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_NONE");
859                                         if (is_running) {
860                                                 elm_object_disabled_set(button, EINA_FALSE);
861                                         }
862                                         break;
863                                 case APP_MANAGER_ERROR_INVALID_PARAMETER:
864                                         MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_INVALID_PARAMETER");
865                                         break;
866                                 default:
867                                         MGR_APP_DEBUG("default");
868                                         break;
869                                 }
870                         }
871                 }
872         } else {
873                 MGR_APP_DEBUG_ERR("elm icon part is wrong");
874                 button = NULL;
875         }
876
877         MGR_APP_END();
878         return button;
879 }
880
881 static Evas_Object *_gl_icon_get_data(void *data, Evas_Object *obj, const char *part)
882 {
883         MGR_APP_BEGIN();
884
885         MGR_APP_DEBUG("part:%s\n", part);
886         retv_if(_app_info == NULL, NULL);
887         mgr_app_app_info_t *app_info = _app_info;
888
889         Evas_Object *button = NULL;
890         if (0 == strcmp(part, ELM_ICON)) {
891                 button = elm_button_add(obj);
892                 if (button) {
893                         elm_object_text_set(button, MGRAPP_STR_CLEAR_DATA);
894                         elm_object_style_set(button, ELM_BUTTON_STYLE);
895                         evas_object_smart_callback_add(button, "clicked", _clear_data_clicked_cb, (void*)data);
896                         if (app_info->data_size <= 0) {
897                                 elm_object_disabled_set(button, EINA_TRUE);
898                         }
899                 }
900         } else {
901                 MGR_APP_DEBUG_ERR("empty button area");
902                 button = NULL;
903         }
904
905         MGR_APP_END();
906         return button;
907 }
908
909 static char *_gl_label_get_title(void *data, Evas_Object *obj, const char *part)
910 {
911         MGR_APP_BEGIN();
912
913         char *group_title = (char *)data;
914         char *title = NULL;
915
916         MGR_APP_MEM_STRDUP(title, group_title);
917         MGR_APP_END();
918
919         return title;
920 }
921
922 static void _gl_realized(void *data, Evas_Object *obj, void *event_info)
923 {
924         MGR_APP_BEGIN();
925
926         ret_if(event_info == NULL);
927
928         int type = (int)elm_object_item_data_get(event_info);
929
930         if (type == ELM_STATE_TOP) {
931                 elm_object_item_signal_emit(event_info, "elm,state,top", "");
932         } else if (type == ELM_STATE_CENTER) {
933                 elm_object_item_signal_emit(event_info, "elm,state,center", "");
934         } else if (type == ELM_STATE_BOTTOM) {
935                 elm_object_item_signal_emit(event_info, "elm,state,bottom", "");
936         }
937
938         MGR_APP_END();
939 }
940
941 static Evas_Object *_create_genlist_app_info(Evas_Object *parent, void *data)
942 {
943         MGR_APP_BEGIN();
944
945         retv_if(data == NULL, NULL);
946         struct ug_data *ugd = (struct ug_data*)data;
947
948         Elm_Object_Item *item_app                       = NULL;
949         Elm_Object_Item *item_life                      = NULL;
950         Elm_Object_Item *item_sto_total = NULL;
951         Elm_Object_Item *item_sto_app           = NULL;
952         Elm_Object_Item *item_sto_data          = NULL;
953         Elm_Object_Item *item_data                      = NULL;
954         Elm_Object_Item *item_launch_text       = NULL;
955         Elm_Object_Item *item_launch            = NULL;
956         Elm_Object_Item *item_sep               = NULL;
957         Elm_Object_Item *item_detail            = NULL;
958
959         Evas_Object     *genlist        = NULL;
960         char *sto_title                 = NULL;
961         char *launch_title              = NULL;
962
963
964         /* set the genlist item style */
965         itc_sep = elm_genlist_item_class_new();
966         retv_if(itc_sep == NULL, NULL);
967         itc = elm_genlist_item_class_new();
968         retv_if(itc == NULL, NULL);
969         itc_life = elm_genlist_item_class_new();
970         retv_if(itc_life == NULL, NULL);
971         itc_sto_title = elm_genlist_item_class_new();
972         retv_if(itc_sto_title == NULL, NULL);
973         itc_sto_total = elm_genlist_item_class_new();
974         retv_if(itc_sto_total == NULL, NULL);
975         itc_sto_app = elm_genlist_item_class_new();
976         retv_if(itc_sto_app == NULL, NULL);
977         itc_sto_data = elm_genlist_item_class_new();
978         retv_if(itc_sto_data == NULL, NULL);
979         itc_data = elm_genlist_item_class_new();
980         retv_if(itc_data == NULL, NULL);
981         itc_launch_title = elm_genlist_item_class_new();
982         retv_if(itc_launch_title == NULL, NULL);
983         itc_launch = elm_genlist_item_class_new();
984         retv_if(itc_launch == NULL, NULL);
985         itc_launch_text = elm_genlist_item_class_new();
986         retv_if(itc_launch_text == NULL, NULL);
987         itc_detail = elm_genlist_item_class_new();
988         retv_if(itc_detail == NULL, NULL);
989
990         itc_sep->item_style                     = ITC_SEP_ITEM_STYLE;
991         itc_sep->func.text_get          = NULL;
992         itc_sep->func.content_get       = NULL;
993         itc_sep->func.state_get         = NULL;
994         itc_sep->func.del                       = NULL;
995
996         itc->item_style                         = ITC_ITEM_STYLE;
997         itc->func.text_get                      = _gl_label_get;
998         itc->func.content_get           = _gl_icon_get;
999         itc->func.state_get                     = NULL;
1000         itc->func.del                           = NULL;
1001
1002         itc_life->item_style            = ITC_LIFE_ITEM_STYLE;
1003         itc_life->func.text_get         = NULL;
1004         itc_life->func.content_get      = _gl_icon_get_life;
1005         itc_life->func.state_get        = NULL;
1006         itc_life->func.del                      = NULL;
1007
1008         itc_sto_title->item_style               = ITC_STO_TITLE_ITEM_STYLE;
1009         itc_sto_title->func.text_get    = _gl_label_get_title;
1010         itc_sto_title->func.content_get = NULL;
1011         itc_sto_title->func.state_get   = NULL;
1012         itc_sto_title->func.del                 = NULL;
1013
1014         itc_sto_total->item_style               = ITC_STO_TOTAL_ITEM_STYLE;
1015         itc_sto_total->func.text_get    = _gl_label_get_sto_total;
1016         itc_sto_total->func.content_get = NULL;
1017         itc_sto_total->func.state_get   = NULL;
1018         itc_sto_total->func.del                 = NULL;
1019
1020         itc_sto_app->item_style                 = ITC_STO_APP_ITEM_STYLE;
1021         itc_sto_app->func.text_get              = _gl_label_get_sto_app;
1022         itc_sto_app->func.content_get   = NULL;
1023         itc_sto_app->func.state_get     = NULL;
1024         itc_sto_app->func.del                   = NULL;
1025
1026         itc_sto_data->item_style                = ITC_STO_DATA_ITEM_STYLE;
1027         itc_sto_data->func.text_get             = _gl_label_get_sto_data;
1028         itc_sto_data->func.content_get  = NULL;
1029         itc_sto_data->func.state_get    = NULL;
1030         itc_sto_data->func.del                  = NULL;
1031
1032         itc_data->item_style                    = ITC_DATA_ITEM_STYLE;
1033         itc_data->func.text_get                 = NULL;
1034         itc_data->func.content_get              = _gl_icon_get_data;
1035         itc_data->func.state_get                = NULL;
1036         itc_data->func.del                              = NULL;
1037
1038         itc_launch_title->item_style    = ITC_LAUNCH_TITLE_ITEM_STYLE;
1039         itc_launch_title->func.text_get = _gl_label_get_title;
1040         itc_launch_title->func.content_get      = NULL;
1041         itc_launch_title->func.state_get        = NULL;
1042         itc_launch_title->func.del              = NULL;
1043
1044         itc_launch->item_style                  = ITC_LAUNCH_ITEM_STYLE;
1045         itc_launch->func.text_get               = _gl_label_get_launch;
1046         itc_launch->func.content_get    = NULL;
1047         itc_launch->func.state_get              = NULL;
1048         itc_launch->func.del                    = NULL;
1049
1050         itc_launch_text->item_style     = ITC_LAUNCH_TEXT_ITEM_STYLE;
1051         itc_launch_text->func.text_get  = _gl_label_get_launch_text;
1052         itc_launch_text->func.content_get       = NULL;
1053         itc_launch_text->func.state_get = NULL;
1054         itc_launch_text->func.del               = NULL;
1055
1056         itc_detail->item_style                  = ITC_DETAIL_ITEM_STYLE;
1057         itc_detail->func.text_get               = _gl_label_get_detail;
1058         itc_detail->func.content_get    = NULL;
1059         itc_detail->func.state_get              = NULL;
1060         itc_detail->func.del                    = NULL;
1061
1062         retv_if(ugd->data == NULL, NULL);
1063         mgr_app_app_info_t *app_info = (mgr_app_app_info_t *)ugd->data;
1064
1065         /* add a genlist */
1066         genlist = elm_genlist_add(parent);
1067         retv_if(genlist == NULL, NULL);
1068         evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1069         evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1070         elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1071         elm_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
1072         evas_object_data_set(genlist, STR_UGD, (void*)ugd);
1073         evas_object_show(genlist);
1074         evas_object_smart_callback_add(genlist, "realized", _gl_realized, NULL);
1075
1076         MGR_APP_MEM_STRDUP(sto_title, MGRAPP_STR_STORAGE);
1077         MGR_APP_MEM_STRDUP(launch_title, MGRAPP_STR_LAUNCH_BY_DEFAULT);
1078
1079
1080         /* app info */
1081         item_app = elm_genlist_item_append(genlist, itc, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1082         if (item_app)
1083                 elm_genlist_item_select_mode_set(item_app, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1084
1085         /* Force stop & Uninstall */
1086         item_life = elm_genlist_item_append(genlist, itc_life, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1087         if (item_life)
1088                 elm_genlist_item_select_mode_set(item_life, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1089
1090         /* Storage */
1091         elm_genlist_item_append(genlist, itc_sto_title, sto_title, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1092         item_sto_total = elm_genlist_item_append(genlist, itc_sto_total, ELM_STATE_TOP, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1093         if (item_sto_total)
1094                 elm_genlist_item_select_mode_set(item_sto_total, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1095         item_sto_app = elm_genlist_item_append(genlist, itc_sto_app, ELM_STATE_CENTER, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1096         if (item_sto_app)
1097                 elm_genlist_item_select_mode_set(item_sto_app, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1098         item_sto_data = elm_genlist_item_append(genlist, itc_sto_data, ELM_STATE_BOTTOM, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1099         if (item_sto_data)
1100                 elm_genlist_item_select_mode_set(item_sto_data, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1101
1102
1103         /* separator with no bottom line */
1104         item_sep = elm_genlist_item_append(genlist, itc_sep, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1105         if (item_sep)
1106                 elm_genlist_item_select_mode_set(item_sep, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1107
1108 #if 0
1109         /* Clear Data */
1110         /* remove the button until the feature is supported */
1111         item_data = elm_genlist_item_append(genlist, &itc_data, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, NULL);
1112
1113
1114         /* separator with bottom line */
1115         /* the separator is located bottom of Clear Data button */
1116         item_sep = elm_genlist_item_append(genlist, &itc_sep, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1117         if (item_sep)
1118                 elm_genlist_item_select_mode_set(item_sep, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1119 #endif
1120
1121         /* Launch */
1122         elm_genlist_item_append(genlist, itc_launch_title, launch_title, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1123         item_launch = elm_genlist_item_append(genlist, itc_launch, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_launch, (void*)ugd);
1124         if (item_launch && !appsvc_is_defapp(app_info->pkg_name)) {
1125                 elm_genlist_item_selected_set(item_launch, EINA_FALSE);
1126                 elm_object_item_disabled_set(item_launch, EINA_TRUE);
1127         }
1128         item_launch_text = elm_genlist_item_append(genlist, itc_launch_text, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1129         if (item_launch_text)
1130                 elm_genlist_item_select_mode_set(item_launch_text, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1131         item_sep = elm_genlist_item_append(genlist, itc_sep, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1132         if (item_sep)
1133                 elm_genlist_item_select_mode_set(item_sep, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1134
1135
1136         /* More Detail */
1137         item_detail = elm_genlist_item_append(genlist, itc_detail, ELM_STATE_DEFAULT, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_detail, (void*)ugd);
1138         if (item_detail) {
1139                 elm_genlist_item_selected_set(item_detail, EINA_FALSE);
1140                 elm_object_item_disabled_set(item_detail, EINA_TRUE);
1141         }
1142 #if 0
1143         if (app_info->pkg_type) {
1144                 if (item_detail && (!strncmp(app_info->pkg_type, TPK_PREFIX, strlen(TPK_PREFIX)) || !strncmp(app_info->pkg_type, RPM_PREFIX, strlen(RPM_PREFIX)))) {
1145                         elm_genlist_item_selected_set(item_detail, EINA_FALSE);
1146                         elm_object_item_disabled_set(item_detail, EINA_TRUE);
1147                 }
1148         } else {
1149                 MGR_APP_DEBUG_ERR("app_info->pkg_type is NULL");
1150         }
1151 #endif
1152
1153         /* footer border */
1154         item_sep = elm_genlist_item_append(genlist, itc_sep, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1155         if (item_sep)
1156                 elm_genlist_item_select_mode_set(item_sep, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1157
1158         if (elm_genlist_first_item_get(genlist)) {
1159                 item_sep = elm_genlist_item_prepend(genlist, itc_sep, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1160                 if (item_sep)
1161                         elm_genlist_item_select_mode_set(item_sep, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1162         }
1163
1164         MGR_APP_END();
1165         return genlist;
1166 }
1167
1168 static void _doubletap_sensor_cb(void *data)
1169 {
1170         MGR_APP_BEGIN();
1171
1172         ret_if(NULL == data);
1173
1174         Evas_Object *genlist = (Evas_Object*)data;
1175         Elm_Object_Item *item = NULL;
1176
1177         item = elm_genlist_first_item_get(genlist);
1178         ret_if(NULL == item);
1179         
1180         elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1181                 
1182         MGR_APP_END();
1183 }
1184
1185 static void _get_app_info_from_pkgmgr(char *pkg_name, mgr_app_app_info_t *app_info)
1186 {
1187         MGR_APP_BEGIN();
1188
1189         ret_if(NULL == pkg_name);
1190         
1191         pkgmgrinfo_appinfo_h appinfo_h = NULL;
1192         pkgmgrinfo_pkginfo_h pkginfo_h = NULL;
1193         char *main_appid = NULL;
1194         char *icon_path = NULL; 
1195         char *pkg_label = NULL;
1196         char *pkg_type = NULL;
1197         char *pkg_version = NULL;
1198         char *data_size = NULL;
1199         char *total_size = NULL;
1200         int r = 0;
1201
1202         MGR_APP_DEBUG("pkg_name: %s", pkg_name);
1203         MGR_APP_MEM_STRDUP(app_info->pkg_name, pkg_name);
1204
1205         r = pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &pkginfo_h);
1206         if (r < 0) {
1207                 MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_pkginfo is failed %d", r);
1208                 goto end;
1209         }
1210         MGR_APP_DEBUG("pkg_name: %s", pkg_name);
1211
1212         r = pkgmgrinfo_pkginfo_get_mainappid(pkginfo_h, &main_appid);
1213         if (r < 0) {
1214                 MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_mainappid is failed %d", r);
1215                 goto end;
1216         }
1217         MGR_APP_DEBUG("main_appid: %s", main_appid);
1218
1219         r = pkgmgrinfo_appinfo_get_appinfo(main_appid, &appinfo_h);
1220         if (r < 0) {
1221                 MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_appinfo is failed %d", r);
1222                 goto end;
1223         }
1224
1225         if (NULL == app_info->pkg_label) {
1226                 r = pkgmgrinfo_appinfo_get_label(appinfo_h, &pkg_label);
1227                 if (r < 0) {
1228                         MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_label failed. %d", r);
1229                         goto end;
1230                 } else if (pkg_label) {
1231                         MGR_APP_MEM_STRDUP(app_info->pkg_label, pkg_label);
1232                 } else {
1233                         MGR_APP_MEM_STRDUP(app_info->pkg_label, "");
1234                 }
1235         } 
1236         MGR_APP_DEBUG("pkg_label: %s", pkg_label);
1237
1238         if (NULL == app_info->pkg_type) {
1239                 r = pkgmgrinfo_pkginfo_get_type(pkginfo_h, &pkg_type);
1240                 if (r < 0) {
1241                         MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_type failed. %d", r);
1242                         goto end;
1243                 } else if (pkg_type) {
1244                         MGR_APP_MEM_STRDUP(app_info->pkg_type, pkg_type);
1245                 } else {
1246                         MGR_APP_MEM_STRDUP(app_info->pkg_type, "");
1247                 }
1248         } 
1249         MGR_APP_DEBUG("pkg_type: %s", pkg_type);
1250
1251         if (NULL == app_info->pkg_version) {
1252                 r = pkgmgrinfo_pkginfo_get_version(pkginfo_h, &pkg_version);
1253                 if (r < 0) {
1254                         MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_version failed. %d", r);
1255                         goto end;
1256                 } else if (pkg_version) {
1257                         MGR_APP_MEM_STRDUP(app_info->pkg_version, pkg_version);
1258                 } else {
1259                         MGR_APP_MEM_STRDUP(app_info->pkg_version, "");
1260                 }
1261         } 
1262         MGR_APP_DEBUG("pkg_version: %s", pkg_version);
1263
1264         r = pkgmgrinfo_pkginfo_get_data_size(pkginfo_h, &app_info->data_size);
1265         if (r < 0) {
1266                 MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_data_size failed. %d", r);
1267                 goto end;
1268         } 
1269         MGR_APP_DEBUG("data_size: %d", data_size);
1270         
1271         r = pkgmgrinfo_pkginfo_get_total_size(pkginfo_h, &app_info->total_size);
1272         if (r < 0) {
1273                 MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_total_size failed. %d", r);
1274                 goto end;
1275         } 
1276         MGR_APP_DEBUG("total_size: %d", total_size);
1277
1278         r = pkgmgrinfo_pkginfo_is_removable(pkginfo_h, &app_info->removable);
1279         if (r < 0) {
1280                 MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_is_removable failed. %d", r);
1281                 goto end;
1282         } 
1283
1284         r = pkgmgrinfo_appinfo_is_taskmanage(appinfo_h, &app_info->taskmanage);
1285         if (r < 0) {
1286                 MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_is_taskmanage failed. %d", r);
1287                 goto end;
1288         } 
1289
1290         r = pkgmgrinfo_appinfo_is_nodisplay(appinfo_h, &app_info->nodisplay);
1291         if (r < 0) {
1292                 MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_is_nodisplay failed. %d", r);
1293                 goto end;
1294         } 
1295
1296         if (NULL == app_info->icon_path) {
1297                 r = pkgmgrinfo_appinfo_get_icon(appinfo_h, &icon_path);
1298                 if (r < 0) {
1299                         MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_icon failed. %d", r);
1300                         goto end;
1301                 } else if (icon_path) {
1302                         MGR_APP_MEM_STRDUP(app_info->icon_path, icon_path);
1303                 } else {
1304                         MGR_APP_MEM_STRDUP(app_info->icon_path, "");
1305                 }
1306
1307                 if (app_info->nodisplay) {
1308                         mgr_app_set_default_icon(&app_info->icon_path, DEFAULT_ICON_SERVICE);
1309                 } else {
1310                         mgr_app_set_default_icon(&app_info->icon_path, DEFAULT_ICON_APP);
1311                 }
1312         } 
1313         MGR_APP_DEBUG("icon_path: %s", icon_path);
1314
1315 end:
1316         if (appinfo_h) {
1317                 pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
1318         }
1319
1320         if (pkginfo_h) {
1321                 pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h);
1322         }
1323         
1324         MGR_APP_END();
1325 }
1326
1327
1328 void mgrapp_view_info_create(char *pkg_name, void *data)
1329 {
1330         MGR_APP_BEGIN();
1331
1332         ret_if(NULL == pkg_name || NULL == data);
1333         struct ug_data *ugd = (struct ug_data*)data;
1334         Evas_Object *back_btn = NULL;
1335
1336         mgrapp_set_view_type(VIEW_TYPE_APP_INFO);
1337
1338         if (ugd->data) {
1339                 _app_info = (mgr_app_app_info_t*)ugd->data;
1340         } else {
1341                 _app_info = (mgr_app_app_info_t*)malloc(sizeof(mgr_app_app_info_t));
1342                 ret_if(_app_info == NULL);
1343                 memset(_app_info, 0, sizeof(mgr_app_app_info_t));
1344                 ugd->data = (void*)_app_info;
1345         }
1346
1347         _get_app_info_from_pkgmgr(pkg_name, _app_info);
1348         
1349         _genlist = _create_genlist_app_info(ugd->navi_bar, (void*)ugd);
1350
1351         /* back button */
1352         back_btn = elm_button_add(ugd->navi_bar);
1353         ret_if(NULL == back_btn);
1354         elm_object_style_set(back_btn, "naviframe/end_btn/default");
1355         evas_object_smart_callback_add(back_btn, "clicked", _app_info_back_cb, (void*)ugd);
1356
1357         elm_naviframe_item_push(ugd->navi_bar, MGRAPP_STR_APPLICATION_INFO, back_btn, NULL, _genlist, NULL);
1358
1359         mgr_app_doubletap_sensor_set_cb(_doubletap_sensor_cb, _genlist);
1360         mgr_app_doubletap_sensor_enable();
1361
1362         MGR_APP_END();
1363 }
1364
1365 void mgrapp_view_info_update(void *data)
1366 {
1367         MGR_APP_BEGIN();
1368
1369         if (_genlist) {
1370                 elm_genlist_realized_items_update(_genlist);
1371         }
1372
1373         MGR_APP_END();
1374 }
1375
1376 void mgrapp_view_info_destroy(void *data)
1377 {
1378         MGR_APP_BEGIN();
1379
1380         ret_if(data == NULL);
1381         struct ug_data *ugd = (struct ug_data*)data;
1382
1383         _free_resources(ugd);
1384
1385         mgr_app_doubletap_sensor_disable();
1386
1387         elm_naviframe_item_pop(ugd->navi_bar);
1388
1389         mgrapp_set_view_type(VIEW_TYPE_APP_LIST);
1390
1391 #if 0
1392         /* for Always ug */
1393         /* bg must delete before starting on_destroy */
1394         if (ugd->bg) {
1395                 evas_object_del(ugd->bg);
1396                 ugd->bg = NULL;
1397         }
1398
1399         if (ugd->ug) {
1400                 ug_destroy_me(ugd->ug);
1401                 ugd->ug = NULL;
1402         }
1403 #endif
1404
1405         MGR_APP_END();
1406 }