2 * Copyright 2012 Samsung Electronics Co., Ltd
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
8 * http://www.tizenopensource.org/license
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.
18 #include "mgr-app-common-debug.h"
19 #include "mgr-app-common-error.h"
20 #include "mgr-app-view-manager.h"
21 #include "mgr-app-widget.h"
22 #include "mgr-app-view-factory.h"
23 #include "mgr-app-common-util.h"
24 #include "mgr-app-uigadget.h"
25 #include <package-manager.h>
27 #include <app_manager.h>
30 #define WRT_PREFIX "wgt"
31 #define RPM_PREFIX "rpm"
32 #define TPK_PREFIX "tpk"
34 #define UG_NAME_MIDLET_INFO_EFL "midlet-info-efl"
35 #define UG_NAME_WEBAPP_INFO_EFL "webapp-detail-efl"
36 #define UG_PARAM_KEY_PKG_NAME "pkg_name"
38 #define STR_ICON "icon"
40 #define STR_INSTALLED_SIZE "installed_size"
41 #define STR_DATA_SIZE "data_size"
43 #define STR_TITLE_APPLICATION_INFO "APPLICATION INFO"
44 #define STR_FORCE_STOP "Force stop"
45 #define STR_UNINSTALL "Uninstall"
46 #define STR_CLEAR_DATA "Clear data"
48 #define STR_BTN_UNINSTALL "btn_uninstall"
49 #define STR_POPUP "popup"
51 #define MAX_NAME_LEN 128
53 #define NUM_MEGA 1000000
54 #define NUM_GIGA 1000000000
56 #define ELM_TEXT_1 "elm.text.1"
57 #define ELM_TEXT_2 "elm.text.2"
58 #define ELM_TEXT "elm.text"
59 #define ELM_ICON_1 "elm.icon.1"
60 #define ELM_ICON_2 "elm.icon.2"
61 #define ELM_BUTTON_STYLE "popup_button/default"
63 #define ITC_ITEM_STYLE "dialogue/2text.1icon.2"
64 #define ITC_LIFE_ITEM_STYLE "dialogue/bg/2icon"
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_10_ITEM_STYLE "dialogue/separator/10"
75 #define ITC_SEP_21_ITEM_STYLE "dialogue/separator/21/with_line"
77 typedef struct _app_info_view_data_t app_info_view_data_t;
79 struct _app_info_view_data_t {
81 Elm_Object_Item *cbar_item;
82 mgr_app_app_info_t *app_info;
85 static Evas_Object *mgr_app_view_app_info_create(void *data);
86 static Evas_Object *mgr_app_view_app_info_set_cbar(void *data);
87 static mgr_app_result_e mgr_app_view_app_info_set_navibar(void *data);
88 static mgr_app_result_e mgr_app_view_app_info_destory(void *data);
89 static mgr_app_result_e mgr_app_view_app_info_update(void *data);
90 static mgr_app_result_e mgr_app_view_app_info_cleanup(void *data);
92 static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data);
95 mgr_app_view_t mgr_app_view_app_info = {
96 .create = mgr_app_view_app_info_create,
97 .setcbar = mgr_app_view_app_info_set_cbar,
98 .setnavibar = mgr_app_view_app_info_set_navibar,
99 .destroy = mgr_app_view_app_info_destory,
100 .update = mgr_app_view_app_info_update,
103 static Elm_Genlist_Item_Class *itc = NULL;
104 static Elm_Genlist_Item_Class *itc_life = NULL;
105 static Elm_Genlist_Item_Class *itc_sto_title= NULL;
106 static Elm_Genlist_Item_Class *itc_sto_total= NULL;
107 static Elm_Genlist_Item_Class *itc_sto_app = NULL;
108 static Elm_Genlist_Item_Class *itc_sto_data = NULL;
109 static Elm_Genlist_Item_Class *itc_data = NULL;
110 static Elm_Genlist_Item_Class *itc_launch_title = NULL;
111 static Elm_Genlist_Item_Class *itc_launch = NULL;
112 static Elm_Genlist_Item_Class *itc_launch_text = NULL;
113 static Elm_Genlist_Item_Class *itc_detail = NULL;
114 static Elm_Genlist_Item_Class *itc_sep_10 = NULL;
115 static Elm_Genlist_Item_Class *itc_sep_21 = NULL;
118 static void _app_info_next_cb(void *data, Evas_Object *obj, void *event_info)
121 mgr_app_view_create(&mgr_app_view_app_info, data);
125 void _app_info_back_cb(void *data, Evas_Object *obj, void *event_info)
129 ret_if(data == NULL);
130 struct ug_data *ugd = (struct ug_data*)data;
134 MGR_APP_DEBUG("pc is freed");
135 pkgmgr_client_free(ugd->pc);
140 ret = ug_destroy(ugd->sub_ug);
142 MGR_APP_DEBUG_ERR("ug_destroy ugd->sub_ug is failed");
145 mgr_app_view_common_back_cb(ugd, EINA_FALSE);
147 elm_genlist_item_class_free(itc_sep_21);
148 elm_genlist_item_class_free(itc);
149 elm_genlist_item_class_free(itc_sep_10);
150 elm_genlist_item_class_free(itc_life);
151 elm_genlist_item_class_free(itc_sto_title);
152 elm_genlist_item_class_free(itc_sto_total);
153 elm_genlist_item_class_free(itc_sto_app);
154 elm_genlist_item_class_free(itc_sto_data);
155 elm_genlist_item_class_free(itc_data);
156 elm_genlist_item_class_free(itc_launch_title);
157 elm_genlist_item_class_free(itc_launch);
158 elm_genlist_item_class_free(itc_launch_text);
159 elm_genlist_item_class_free(itc_detail);
164 static void _force_stop_clicked_cb(void *data, Evas_Object *obj, void *event_info)
168 ret_if(data == NULL);
169 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
170 ret_if(app_info->pkg_name == NULL);
171 bool is_running = false;
172 int ret = APP_MANAGER_ERROR_NONE;
175 ret = app_manager_is_running(app_info->pkg_name, &is_running);
177 case APP_MANAGER_ERROR_NONE:
178 MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_NONE");
180 case APP_MANAGER_ERROR_INVALID_PARAMETER:
181 MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_INVALID_PARAMETER");
184 MGR_APP_DEBUG("default");
189 MGR_APP_DEBUG("%s app_is_running", app_info->pkg_name);
190 app_context_h app_context = {0, };
192 ret = app_manager_get_app_context(app_info->pkg_name, &app_context);
194 case APP_MANAGER_ERROR_NONE:
195 MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_NONE");
197 case APP_MANAGER_ERROR_INVALID_PARAMETER:
198 MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_INVALID_PARAMETER");
200 case APP_MANAGER_ERROR_DB_FAILED:
201 MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_DB_FAILED");
203 case APP_MANAGER_ERROR_OUT_OF_MEMORY:
204 MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_OUT_OF_MEMORY");
206 case APP_MANAGER_ERROR_NO_SUCH_APP:
207 MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_NO_SUCH_APP");
210 MGR_APP_DEBUG("default");
214 ret = app_manager_terminate_app(app_context);
216 case APP_MANAGER_ERROR_NONE:
217 MGR_APP_DEBUG("terminate_app APP_MANAGER_ERROR_NONE");
219 case APP_MANAGER_ERROR_INVALID_PARAMETER:
220 MGR_APP_DEBUG("terminate_app APP_MANAGER_ERROR_INVALID_PARAMETER");
223 MGR_APP_DEBUG("default");
227 ret = app_context_destroy(app_context);
229 case APP_MANAGER_ERROR_NONE:
230 MGR_APP_DEBUG("context_destroy APP_MANAGER_ERROR_NONE");
232 case APP_MANAGER_ERROR_INVALID_PARAMETER:
233 MGR_APP_DEBUG("context_destroy APP_MANAGER_ERROR_INVALID_PARAMETER");
236 MGR_APP_DEBUG("default");
241 MGR_APP_DEBUG("%s app is not running", app_info->pkg_name);
246 elm_object_disabled_set(obj, EINA_TRUE);
252 static void _no_response_cb(void *data, Evas_Object *obj, void *event_info)
256 ret_if(data == NULL);
257 evas_object_del(data);
262 static void _uninstall_by_pkgmgr_cb(void *data, Evas_Object *obj, void *event_info)
267 ret_if(data == NULL);
268 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
270 ret_if(mgr_app_view_app_info.view_common_data == NULL);
271 mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_info.view_common_data;
273 ret_if(view_common_data->user_view_data == NULL);
274 app_info_view_data_t *app_info_view_data = view_common_data->user_view_data;
276 struct ug_data *ugd = NULL;
277 ugd = evas_object_data_get(app_info_view_data->genlist, STR_UGD);
280 Evas_Object *btn_uninstall = NULL;
281 btn_uninstall = (Evas_Object*)evas_object_data_get(obj, STR_BTN_UNINSTALL);
282 ret_if(btn_uninstall == NULL);
284 Evas_Object *popup = NULL;
285 popup = (Evas_Object*)evas_object_data_get(obj, STR_POPUP);
286 ret_if(popup == NULL);
288 evas_object_data_del(obj, STR_BTN_UNINSTALL);
289 evas_object_data_del(obj, STR_POPUP);
290 evas_object_del(popup);
292 _force_stop_clicked_cb(data, btn_uninstall, event_info);
294 MGR_APP_DEBUG("pkg type: %s, pkg_name: %s", app_info->pkg_type, app_info->pkg_name);
297 pkgmgr_client_free(ugd->pc);
300 ugd->pc = pkgmgr_client_new(PC_REQUEST);
302 MGR_APP_DEBUG_ERR("create new pkgmgr client is failed");
307 req_id = pkgmgr_client_uninstall(ugd->pc, app_info->pkg_type, app_info->pkg_name, PM_QUIET, /*mgr_app_view_listen_cb*/NULL, /*(void*)ugd*/NULL);
310 MGR_APP_DEBUG("uninstall success, req_id=%d", req_id);
313 case PKGMGR_R_EINVAL: /* -3: Invalid argument */
314 MGR_APP_DEBUG("PKGMGR_R_EINVAL");
316 case PKGMGR_R_ECOMM: /* -2: Comunication Error */
317 MGR_APP_DEBUG("PKGMGR_R_ECOMM");
319 case PKGMGR_R_OK: /* 0: General success */
320 MGR_APP_DEBUG("PKGMGR_R_OK");
323 MGR_APP_DEBUG("default req_id=%d", req_id);
328 /* the select 'No' noti be available from pkg-mgr then add the condition */
329 elm_object_disabled_set(obj, EINA_FALSE);
334 static void _uninstall_clicked_cb(void *data, Evas_Object *obj, void *event_info)
339 Evas_Object *btn_uninstall = obj;
341 ret_if(data == NULL);
342 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
344 ret_if(mgr_app_view_app_info.view_common_data == NULL);
345 mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_info.view_common_data;
347 Evas_Object *popup = NULL;
348 Evas_Object *btn_yes = NULL;
349 Evas_Object *btn_no = NULL;
351 popup = elm_popup_add(view_common_data->common_navibar);
352 ret_if(popup == NULL);
353 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
354 elm_object_text_set(popup, "Uninstall?");
355 elm_object_part_text_set(popup, "title,text", app_info->app_name);
357 btn_yes = elm_button_add(popup);
358 ret_if(btn_yes == NULL);
359 elm_object_text_set(btn_yes, "Yes");
360 elm_object_part_content_set(popup, "button1", btn_yes);
361 elm_object_style_set(btn_yes, ELM_BUTTON_STYLE);
362 evas_object_smart_callback_add(btn_yes, "clicked", _uninstall_by_pkgmgr_cb, data);
363 evas_object_data_set(btn_yes, STR_BTN_UNINSTALL, btn_uninstall);
364 evas_object_data_set(btn_yes, STR_POPUP, popup);
366 btn_no = elm_button_add(popup);
367 ret_if(btn_no == NULL);
368 elm_object_text_set(btn_no, "No");
369 elm_object_part_content_set(popup, "button2", btn_no);
370 elm_object_style_set(btn_no, ELM_BUTTON_STYLE);
371 evas_object_smart_callback_add(btn_no, "clicked", _no_response_cb, (void*)popup);
373 evas_object_show(popup);
378 static void _clear_data_clicked_cb(void *data, Evas_Object *obj, void *event_info)
383 elm_object_disabled_set(obj, EINA_TRUE);
388 static void _gl_sel(void *data, Evas_Object *obj, void *event_info)
392 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
395 elm_genlist_item_selected_set(item, EINA_FALSE);
401 static void _gl_sel_launch(void *data, Evas_Object *obj, void *event_info)
405 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
406 ret_if(data == NULL);
407 struct ug_data *ugd = (struct ug_data*)data;
409 ret_if(ugd->data == NULL);
410 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)ugd->data;
412 ret_if(app_info->pkg_name == NULL);
413 char *package_name = NULL;
414 package_name = app_info->pkg_name;
417 elm_genlist_item_selected_set(item, EINA_FALSE);
418 elm_object_item_disabled_set(item, EINA_TRUE);
421 if (appsvc_is_defapp(package_name)) {
422 MGR_APP_DEBUG("%s is the default app", package_name);
423 if (appsvc_unset_defapp(package_name) != APPSVC_RET_OK) {
424 MGR_APP_DEBUG_ERR("unset the %s to default app is failed", package_name);
427 MGR_APP_DEBUG("%s is not the default app", package_name);
433 static void _layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
437 Evas_Object *base = NULL;
438 Evas_Object *win = NULL;
445 base = ug_get_layout(ug);
451 win = ug_get_window();
454 case UG_MODE_FULLVIEW:
455 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
456 elm_win_resize_object_add(win, base);
457 ug_disable_effect(ug);
458 evas_object_show(base);
467 static void _result_cb(ui_gadget_h ug, service_h service, void *priv)
471 struct ug_data *mydata = NULL;
481 int ret = SERVICE_ERROR_NONE;
483 ret = service_get_extra_data(service, "name", &val);
485 case SERVICE_ERROR_NONE:
486 MGR_APP_DEBUG_ERR("SERVICE_ERROR_NONE");
488 case SERVICE_ERROR_INVALID_PARAMETER:
489 MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_PARAMETER");
491 case SERVICE_ERROR_KEY_NOT_FOUND:
492 MGR_APP_DEBUG_ERR("SERVICE_ERROR_KEY_NOT_FOUND");
494 case SERVICE_ERROR_OUT_OF_MEMORY:
495 MGR_APP_DEBUG_ERR("SERVICE_ERROR_OUT_OF_MEMORY");
497 case SERVICE_ERROR_INVALID_DATA_TYPE:
498 MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_DATA_TYPE");
501 MGR_APP_DEBUG_ERR("ret value has an error. %d.", ret);
506 MGR_APP_DEBUG("The name of UI gadget that sends result is [%s]", val);
512 MGR_APP_DEBUG("mydata->sub_ug:%d", mydata->sub_ug);
514 mydata->sub_ug = NULL;
519 static void _destroy_cb(ui_gadget_h ug, void *priv)
528 struct ug_data *mydata = (struct ug_data*)priv;
531 mydata->sub_ug = NULL;
536 static void __create_ug(void *data)
540 ret_if(data == NULL);
541 struct ug_data *ugd = (struct ug_data*)data;
542 mgr_app_app_info_t *app_info = NULL;
544 ret_if(ugd->data == NULL);
545 app_info = (mgr_app_app_info_t*)ugd->data;
547 ui_gadget_h ug = {0, };
548 struct ug_cbs cbs = {0,};
549 service_h service = {0, };
550 int ret = MGR_APP_OK;
552 cbs.layout_cb = _layout_cb;
553 cbs.result_cb = _result_cb;
554 cbs.destroy_cb = _destroy_cb;
555 cbs.priv = (void*)ugd;
557 ret = service_create(&service);
559 case SERVICE_ERROR_NONE:
560 MGR_APP_DEBUG("service_create SERVICE_ERROR_NONE");
562 case SERVICE_ERROR_INVALID_PARAMETER:
563 MGR_APP_DEBUG_ERR("service_create SERVICE_ERROR_INVALID_PARAMETER");
565 case SERVICE_ERROR_OUT_OF_MEMORY:
566 MGR_APP_DEBUG_ERR("service_create SERVICE_ERROR_OUT_OF_MEMORY");
569 MGR_APP_DEBUG_ERR("service_create ret value has an error, %d.", ret);
573 if (app_info->pkg_type && !strncmp(app_info->pkg_type, WRT_PREFIX, strlen(WRT_PREFIX))) {
574 MGR_APP_DEBUG("app_info->pkg_type: %s", app_info->pkg_type);
575 MGR_APP_DEBUG("app_info->pkg_name : %s", app_info->pkg_name);
577 ret = service_add_extra_data(service, UG_PARAM_KEY_PKG_NAME, app_info->pkg_name);
579 case SERVICE_ERROR_NONE:
580 MGR_APP_DEBUG("service_add_extra_data SERVICE_ERROR_NONE");
582 case SERVICE_ERROR_INVALID_PARAMETER:
583 MGR_APP_DEBUG_ERR("service_add_extra_data SERVICE_ERROR_INVALID_PARAMETER");
585 case SERVICE_ERROR_KEY_REJECTED:
586 MGR_APP_DEBUG_ERR("service_add_extra_data SERVICE_ERROR_KEY_REJECTED");
589 MGR_APP_DEBUG_ERR("service_add_extra_data ret value has an error, %d.", ret);
593 /* wrt ug more detail info */
594 ug = ug_create(ugd->ug, UG_NAME_WEBAPP_INFO_EFL, UG_MODE_FULLVIEW, service, &cbs);
597 MGR_APP_DEBUG(">>> NOT SUPPORTED TYPE");
601 ret = service_destroy(service);
603 case SERVICE_ERROR_NONE:
604 MGR_APP_DEBUG("service_destroy SERVICE_ERROR_NONE");
606 case SERVICE_ERROR_INVALID_PARAMETER:
607 MGR_APP_DEBUG_ERR("service_destroy SERVICE_ERROR_INVALID_PARAMETER");
609 case SERVICE_ERROR_OUT_OF_MEMORY:
610 MGR_APP_DEBUG_ERR("service_destroy SERVICE_ERROR_OUT_OF_MEMORY");
613 MGR_APP_DEBUG_ERR("service_destroy ret value has an error, %d.", ret);
620 static void _gl_sel_detail(void *data, Evas_Object *obj, void *event_info)
624 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
625 struct ug_data *ugd = (struct ug_data*)data;
628 elm_genlist_item_selected_set(item, 0);
631 __create_ug((void*)ugd);
636 static char *__get_formated_size(float size)
640 char *buf = (char*)malloc(sizeof(char)*MAX_NAME_LEN);
641 retv_if(buf == NULL, NULL);
642 memset(buf, 0, MAX_NAME_LEN);
644 if (size < NUM_KILO) {
645 snprintf(buf, MAX_NAME_LEN, "%d %s", (int)size, dgettext(PACKAGE, "IDS_ST_BODY_BYTES"));
646 } else if (size >= NUM_KILO && size < NUM_MEGA) {
647 snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_KILO, dgettext(PACKAGE, "IDS_ST_BODY_KB"));
648 } else if (size >= NUM_MEGA && size < NUM_GIGA) {
649 snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_MEGA, dgettext(PACKAGE, "IDS_ST_BODY_MB"));
651 snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_GIGA, dgettext(PACKAGE, "IDS_ST_BODY_GB"));
658 static char *_gl_label_get(void *data, Evas_Object *obj, const char *part)
662 retv_if(data == NULL, NULL);
663 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
667 char *package_name = app_info->pkg_name;
668 char *app_name = app_info->app_name;
669 char *icon_path = app_info->icon_path;
670 char *pkg_type = app_info->pkg_type;
672 MGR_APP_DEBUG("package_name:[%s], x_slp_packagetype:[%s], icon_path:[%s]\n", app_name, pkg_type, icon_path);
673 MGR_APP_DEBUG("part:%s\n", part);
674 retv_if(app_name == NULL, NULL);
676 /* label for 'elm.text' part */
677 if (!strncmp(part, ELM_TEXT_1, strlen(ELM_TEXT_1))) {
679 MGR_APP_MEM_STRDUP(label, app_name);
681 } else if (!strncmp(part, ELM_TEXT_2, strlen(ELM_TEXT_2))) {
682 label = __get_formated_size((float)app_info->total_size);
684 MGR_APP_MEM_STRDUP(label, dgettext("sys_string", "IDS_COM_POP_ERROR"));
691 static char *_gl_label_get_sto_total(void *data, Evas_Object *obj, const char *part)
695 retv_if(data == NULL, NULL);
696 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
700 MGR_APP_DEBUG("part:%s\n", part);
702 /* label for 'elm.text' part */
703 if (!strncmp(part, ELM_TEXT_2, strlen(ELM_TEXT_2))) {
704 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_TOTAL"));
705 } else if (!strncmp(part, ELM_TEXT_1, strlen(ELM_TEXT_1))) {
706 label = __get_formated_size((float)app_info->total_size);
708 MGR_APP_MEM_STRDUP(label, dgettext("sys_string", "IDS_COM_POP_ERROR"));
715 static char *_gl_label_get_sto_app(void *data, Evas_Object *obj, const char *part)
719 retv_if(data == NULL, NULL);
720 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
724 MGR_APP_DEBUG("part:%s\n", part);
726 /* label for 'elm.text' part */
727 if (!strncmp(part, ELM_TEXT_2, strlen(ELM_TEXT_2))) {
728 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_APPLICATION"));
729 } else if (!strncmp(part, ELM_TEXT_1, strlen(ELM_TEXT_1))) {
730 label = __get_formated_size((float)app_info->total_size - (float)app_info->data_size);
732 MGR_APP_MEM_STRDUP(label, dgettext("sys_string", "IDS_COM_POP_ERROR"));
739 static char *_gl_label_get_sto_data(void *data, Evas_Object *obj, const char *part)
743 retv_if(data == NULL, NULL);
744 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
748 MGR_APP_DEBUG("part:%s\n", part);
750 /* label for 'elm.text' part */
751 if (!strncmp(part, ELM_TEXT_2, strlen(ELM_TEXT_2))) {
752 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_DATA"));
753 } else if (!strncmp(part, ELM_TEXT_1, strlen(ELM_TEXT_1))) {
754 label = __get_formated_size((float)app_info->data_size);
756 MGR_APP_MEM_STRDUP(label, dgettext("sys_string", "IDS_COM_POP_ERROR"));
763 static char *_gl_label_get_launch(void *data, Evas_Object *obj, const char *part)
769 MGR_APP_DEBUG("part:%s\n", part);
771 /* label for 'elm.text' part */
772 if (!strncmp(part, ELM_TEXT, strlen(ELM_TEXT))) {
773 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_CLEAR_DEFAULTS"));
780 static char *_gl_label_get_detail(void *data, Evas_Object *obj, const char *part)
786 MGR_APP_DEBUG("part:%s\n", part);
788 /* label for 'elm.text' part */
789 if (!strncmp(part, ELM_TEXT, strlen(ELM_TEXT))) {
790 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_MORE_DETAILS"));
797 static char *_gl_label_get_launch_text(void *data, Evas_Object *obj, const char *part)
803 MGR_APP_DEBUG("part:%s\n", part);
805 /* label for 'elm.text' part */
806 if (!strncmp(part, ELM_TEXT, strlen(ELM_TEXT))) {
807 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_YOU_HAVE_SELECTED_TO_LAUNCH_THIS_APPLICATION_BY_DEFAULT_FOR_SOME_ACTIONS"));
814 static Evas_Object *_gl_icon_get(void *data, Evas_Object *obj, const char *part)
818 retv_if(data == NULL, NULL);
819 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
821 Evas_Object *icon = NULL;
822 char *icon_path = NULL;
824 retv_if(app_info->icon_path == NULL, NULL);
825 icon_path = app_info->icon_path;
827 MGR_APP_DEBUG("icon_path:[%s]\n", icon_path);
828 MGR_APP_DEBUG("part:%s\n", part);
830 /* icon for 'elm.icon' part */
831 icon = elm_icon_add(obj);
832 retv_if(icon == NULL, NULL);
833 elm_icon_file_set(icon, icon_path, STR_ICON);
835 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
842 static Evas_Object *_gl_icon_get_life(void *data, Evas_Object *obj, const char *part)
846 MGR_APP_DEBUG("part:%s\n", part);
847 retv_if(data == NULL, NULL);
848 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
850 Evas_Object *button = NULL;
851 if (!strncmp(part, ELM_ICON_1, strlen(ELM_ICON_1))) {
852 button = elm_button_add(obj);
854 elm_object_disabled_set(button, EINA_TRUE);
855 elm_object_text_set(button, STR_FORCE_STOP);
856 elm_object_style_set(button, ELM_BUTTON_STYLE);
857 evas_object_smart_callback_add(button, "clicked", _force_stop_clicked_cb, (void*)data);
859 if (app_info->taskmanage) {
860 bool is_running = false;
861 int ret = app_manager_is_running(app_info->pkg_name, &is_running);
864 case APP_MANAGER_ERROR_NONE:
865 MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_NONE");
867 elm_object_disabled_set(button, EINA_FALSE);
870 case APP_MANAGER_ERROR_INVALID_PARAMETER:
871 MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_INVALID_PARAMETER");
874 MGR_APP_DEBUG("default");
879 } else if (!strncmp(part, ELM_ICON_2, strlen(ELM_ICON_2))) {
880 button = elm_button_add(obj);
882 elm_object_disabled_set(button, EINA_TRUE);
883 elm_object_text_set(button, STR_UNINSTALL);
884 elm_object_style_set(button, ELM_BUTTON_STYLE);
885 evas_object_smart_callback_add(button, "clicked", _uninstall_clicked_cb, (void*)data);
887 if (app_info->removable) {
888 elm_object_disabled_set(button, EINA_FALSE);
892 MGR_APP_DEBUG_ERR("elm icon part is wrong");
900 static Evas_Object *_gl_icon_get_data(void *data, Evas_Object *obj, const char *part)
904 MGR_APP_DEBUG("part:%s\n", part);
905 retv_if(data == NULL, NULL);
906 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
908 Evas_Object *button = NULL;
909 if (!strncmp(part, ELM_ICON_2, strlen(ELM_ICON_2))) {
910 button = elm_button_add(obj);
912 elm_object_text_set(button, STR_CLEAR_DATA);
913 elm_object_style_set(button, ELM_BUTTON_STYLE);
914 evas_object_smart_callback_add(button, "clicked", _clear_data_clicked_cb, (void*)data);
915 if (app_info->data_size <= 0) {
916 elm_object_disabled_set(button, EINA_TRUE);
920 MGR_APP_DEBUG_ERR("empty button area");
928 static char *_gl_label_get_title(void *data, Evas_Object *obj, const char *part)
932 char *group_title = (char *)data;
935 MGR_APP_MEM_STRDUP(title, group_title);
941 static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
945 retv_if(data == NULL, NULL);
946 struct ug_data *ugd = (struct ug_data*)data;
948 Elm_Object_Item *item_app = NULL;
949 Elm_Object_Item *item_life = NULL;
950 Elm_Object_Item *item_sto_title = NULL;
951 Elm_Object_Item *item_sto_total = NULL;
952 Elm_Object_Item *item_sto_app = NULL;
953 Elm_Object_Item *item_sto_data = NULL;
954 Elm_Object_Item *item_data = NULL;
955 Elm_Object_Item *item_launch_text = NULL;
956 Elm_Object_Item *item_launch_title = NULL;
957 Elm_Object_Item *item_launch = NULL;
958 Elm_Object_Item *item_sep_10 = NULL;
959 Elm_Object_Item *item_sep_21 = NULL;
960 Elm_Object_Item *item_detail = NULL;
962 Evas_Object *genlist = NULL;
963 char *sto_title = NULL;
964 char *launch_title = NULL;
967 /* set the genlist item style */
968 itc_sep_21 = elm_genlist_item_class_new();
969 retv_if(itc_sep_21 == NULL, NULL);
970 itc = elm_genlist_item_class_new();
971 retv_if(itc == NULL, NULL);
972 itc_sep_10 = elm_genlist_item_class_new();
973 retv_if(itc_sep_10 == NULL, NULL);
974 itc_life = elm_genlist_item_class_new();
975 retv_if(itc_life == NULL, NULL);
976 itc_sto_title = elm_genlist_item_class_new();
977 retv_if(itc_sto_title == NULL, NULL);
978 itc_sto_total = elm_genlist_item_class_new();
979 retv_if(itc_sto_total == NULL, NULL);
980 itc_sto_app = elm_genlist_item_class_new();
981 retv_if(itc_sto_app == NULL, NULL);
982 itc_sto_data = elm_genlist_item_class_new();
983 retv_if(itc_sto_data == NULL, NULL);
984 itc_data = elm_genlist_item_class_new();
985 retv_if(itc_data == NULL, NULL);
986 itc_launch_title = elm_genlist_item_class_new();
987 retv_if(itc_launch_title == NULL, NULL);
988 itc_launch = elm_genlist_item_class_new();
989 retv_if(itc_launch == NULL, NULL);
990 itc_launch_text = elm_genlist_item_class_new();
991 retv_if(itc_launch_text == NULL, NULL);
992 itc_detail = elm_genlist_item_class_new();
993 retv_if(itc_detail == NULL, NULL);
995 itc_sep_21->item_style = ITC_SEP_21_ITEM_STYLE;
996 itc_sep_21->func.text_get = NULL;
997 itc_sep_21->func.content_get = NULL;
998 itc_sep_21->func.state_get = NULL;
999 itc_sep_21->func.del = NULL;
1001 itc->item_style = ITC_ITEM_STYLE;
1002 itc->func.text_get = _gl_label_get;
1003 itc->func.content_get = _gl_icon_get;
1004 itc->func.state_get = NULL;
1005 itc->func.del = NULL;
1007 itc_sep_10->item_style = ITC_SEP_10_ITEM_STYLE;
1008 itc_sep_10->func.text_get = NULL;
1009 itc_sep_10->func.content_get = NULL;
1010 itc_sep_10->func.state_get = NULL;
1011 itc_sep_10->func.del = NULL;
1013 itc_life->item_style = ITC_LIFE_ITEM_STYLE;
1014 itc_life->func.text_get = NULL;
1015 itc_life->func.content_get = _gl_icon_get_life;
1016 itc_life->func.state_get = NULL;
1017 itc_life->func.del = NULL;
1019 itc_sto_title->item_style = ITC_STO_TITLE_ITEM_STYLE;
1020 itc_sto_title->func.text_get = _gl_label_get_title;
1021 itc_sto_title->func.content_get = NULL;
1022 itc_sto_title->func.state_get = NULL;
1023 itc_sto_title->func.del = NULL;
1025 itc_sto_total->item_style = ITC_STO_TOTAL_ITEM_STYLE;
1026 itc_sto_total->func.text_get = _gl_label_get_sto_total;
1027 itc_sto_total->func.content_get = NULL;
1028 itc_sto_total->func.state_get = NULL;
1029 itc_sto_total->func.del = NULL;
1031 itc_sto_app->item_style = ITC_STO_APP_ITEM_STYLE;
1032 itc_sto_app->func.text_get = _gl_label_get_sto_app;
1033 itc_sto_app->func.content_get = NULL;
1034 itc_sto_app->func.state_get = NULL;
1035 itc_sto_app->func.del = NULL;
1037 itc_sto_data->item_style = ITC_STO_DATA_ITEM_STYLE;
1038 itc_sto_data->func.text_get = _gl_label_get_sto_data;
1039 itc_sto_data->func.content_get = NULL;
1040 itc_sto_data->func.state_get = NULL;
1041 itc_sto_data->func.del = NULL;
1043 itc_data->item_style = ITC_DATA_ITEM_STYLE;
1044 itc_data->func.text_get = NULL;
1045 itc_data->func.content_get = _gl_icon_get_data;
1046 itc_data->func.state_get = NULL;
1047 itc_data->func.del = NULL;
1049 itc_launch_title->item_style = ITC_LAUNCH_TITLE_ITEM_STYLE;
1050 itc_launch_title->func.text_get = _gl_label_get_title;
1051 itc_launch_title->func.content_get = NULL;
1052 itc_launch_title->func.state_get = NULL;
1053 itc_launch_title->func.del = NULL;
1055 itc_launch->item_style = ITC_LAUNCH_ITEM_STYLE;
1056 itc_launch->func.text_get = _gl_label_get_launch;
1057 itc_launch->func.content_get = NULL;
1058 itc_launch->func.state_get = NULL;
1059 itc_launch->func.del = NULL;
1061 itc_launch_text->item_style = ITC_LAUNCH_TEXT_ITEM_STYLE;
1062 itc_launch_text->func.text_get = _gl_label_get_launch_text;
1063 itc_launch_text->func.content_get = NULL;
1064 itc_launch_text->func.state_get = NULL;
1065 itc_launch_text->func.del = NULL;
1067 itc_detail->item_style = ITC_DETAIL_ITEM_STYLE;
1068 itc_detail->func.text_get = _gl_label_get_detail;
1069 itc_detail->func.content_get = NULL;
1070 itc_detail->func.state_get = NULL;
1071 itc_detail->func.del = NULL;
1074 retv_if(ugd->data == NULL, NULL);
1075 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)ugd->data;
1077 /* get app size from pkgmgr */
1078 pkgmgr_info *pkg_info = pkgmgr_info_new(app_info->pkg_type, app_info->pkg_name);
1080 MGR_APP_DEBUG_ERR("pkg_info is null, couldn't get the sizes");
1081 app_info->data_size = 0;
1082 app_info->total_size = 0;
1086 buf = pkgmgr_info_get_string(pkg_info, STR_DATA_SIZE);
1088 app_info->data_size = atoi(buf);
1089 MGR_APP_MEM_FREE(buf);
1091 app_info->data_size = 0;
1095 buf = pkgmgr_info_get_string(pkg_info, STR_INSTALLED_SIZE);
1097 app_info->total_size = atoi(buf);
1098 MGR_APP_MEM_FREE(buf);
1100 app_info->total_size = 0;
1102 pkgmgr_info_free(pkg_info);
1106 genlist = elm_genlist_add(parent);
1107 retv_if(genlist == NULL, NULL);
1108 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1109 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1110 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1111 elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
1112 evas_object_data_set(genlist, STR_UGD, (void*)ugd);
1113 elm_object_style_set(genlist, "dialogue");
1114 evas_object_show(genlist);
1116 MGR_APP_MEM_STRDUP(sto_title, dgettext(PACKAGE, "IDS_ST_BODY_STORAGE"));
1117 MGR_APP_MEM_STRDUP(launch_title, dgettext(PACKAGE, "IDS_ST_BODY_LAUNCH_BY_DEFAULT"));
1121 item_app = elm_genlist_item_append(genlist, itc, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1123 elm_genlist_item_select_mode_set(item_app, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1126 /* separator with no bottom line */
1127 item_sep_10 = elm_genlist_item_append(genlist, itc_sep_10, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1129 elm_genlist_item_select_mode_set(item_sep_10, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1132 /* Force stop & Uninstall */
1133 item_life = elm_genlist_item_append(genlist, itc_life, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, NULL);
1137 item_sto_title = elm_genlist_item_append(genlist, itc_sto_title, sto_title, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1138 item_sto_total = elm_genlist_item_append(genlist, itc_sto_total, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1140 elm_genlist_item_select_mode_set(item_sto_total, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1141 item_sto_app = elm_genlist_item_append(genlist, itc_sto_app, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1143 elm_genlist_item_select_mode_set(item_sto_app, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1144 item_sto_data = elm_genlist_item_append(genlist, itc_sto_data, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1146 elm_genlist_item_select_mode_set(item_sto_data, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1149 /* separator with no bottom line */
1150 //item_sep_10 = elm_genlist_item_append(genlist, itc_sep_10, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1152 // elm_genlist_item_select_mode_set(item_sep_10, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1156 /* remove the button until the feature is supported */
1157 //item_data = elm_genlist_item_append(genlist, &itc_data, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, NULL);
1160 /* separator with bottom line */
1161 /* the separator is located bottom of Clear Data button */
1162 //item_sep_10 = elm_genlist_item_append(genlist, &itc_sep_10, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1164 // elm_genlist_item_select_mode_set(item_sep_10, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1168 item_launch_title = elm_genlist_item_append(genlist, itc_launch_title, launch_title, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1169 item_launch = elm_genlist_item_append(genlist, itc_launch, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_launch, (void*)ugd);
1170 if (item_launch && !appsvc_is_defapp(app_info->pkg_name)) {
1171 elm_genlist_item_selected_set(item_launch, EINA_FALSE);
1172 elm_object_item_disabled_set(item_launch, EINA_TRUE);
1174 item_launch_text = elm_genlist_item_append(genlist, itc_launch_text, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1175 if (item_launch_text)
1176 elm_genlist_item_select_mode_set(item_launch_text, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1177 item_sep_21 = elm_genlist_item_append(genlist, itc_sep_21, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1179 elm_genlist_item_select_mode_set(item_sep_21, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1183 item_detail = elm_genlist_item_append(genlist, itc_detail, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_detail, (void*)ugd);
1184 if (app_info->pkg_type) {
1185 if (item_detail != NULL && (!strncmp(app_info->pkg_type, TPK_PREFIX, strlen(TPK_PREFIX)) || !strncmp(app_info->pkg_type, RPM_PREFIX, strlen(RPM_PREFIX)))) {
1186 elm_genlist_item_selected_set(item_detail, EINA_FALSE);
1187 elm_object_item_disabled_set(item_detail, EINA_TRUE);
1190 MGR_APP_DEBUG_ERR("app_info->pkg_type is NULL");
1193 if (elm_genlist_first_item_get(genlist)) {
1194 item_sep_21 = elm_genlist_item_prepend(genlist, itc_sep_21, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1196 elm_genlist_item_select_mode_set(item_sep_21, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1203 static Evas_Object *mgr_app_view_app_info_create(void *data)
1207 retv_if(data == NULL, NULL);
1208 struct ug_data *ugd = (struct ug_data*)data;
1210 retv_if(mgr_app_view_app_info.view_common_data == NULL, NULL);
1211 mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_info.view_common_data;
1213 MGR_APP_MEM_MALLOC(view_common_data->user_view_data, 1, app_info_view_data_t);
1214 retv_if(view_common_data->user_view_data == NULL, NULL);
1215 app_info_view_data_t *app_info_view_data = view_common_data->user_view_data;
1217 app_info_view_data->genlist = __create_genlist_app_info(view_common_data->common_navibar, (void*)ugd);
1220 return app_info_view_data->genlist;
1223 static Evas_Object *mgr_app_view_app_info_set_cbar(void *data)
1231 static mgr_app_result_e mgr_app_view_app_info_set_navibar(void *data)
1234 mgr_app_view_manager_set_navibar(mgr_app_view_app_info.view_common_data, /*dgettext(PACKAGE, "IDS_ST_HEADER_APPLICATION_INFO")*/STR_TITLE_APPLICATION_INFO, NULL, _app_info_back_cb, NULL, NULL);
1239 static mgr_app_result_e mgr_app_view_app_info_destory(void *data)
1243 retv_if(mgr_app_view_app_info.view_common_data == NULL, MGR_APP_ERROR);
1244 mgr_app_view_app_info.view_common_data->view_layout = NULL;
1250 static mgr_app_result_e mgr_app_view_app_info_update(void *data)
1254 retv_if(mgr_app_view_app_info.view_common_data == NULL, MGR_APP_ERROR);
1255 mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_info.view_common_data;
1257 retv_if(view_common_data->user_view_data == NULL, MGR_APP_ERROR);
1258 app_info_view_data_t *app_info_view_data = (app_info_view_data_t*)view_common_data->user_view_data;
1260 elm_genlist_realized_items_update(app_info_view_data->genlist);
1262 /* button disable */
1263 if (!app_info_view_data->genlist) {
1264 MGR_APP_DEBUG("genlist is null\n");
1265 elm_object_item_disabled_set(app_info_view_data->cbar_item, EINA_TRUE);
1271 static mgr_app_result_e mgr_app_view_app_info_cleanup(void *data)