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_BTN_UNINSTALL "btn_uninstall"
44 #define STR_POPUP "popup"
46 #define MAX_NAME_LEN 128
48 #define NUM_MEGA 1000000
49 #define NUM_GIGA 1000000000
51 #define ELM_TEXT_1 "elm.text.1"
52 #define ELM_TEXT_2 "elm.text.2"
53 #define ELM_TEXT "elm.text"
54 #define ELM_ICON_1 "elm.icon.1"
55 #define ELM_ICON_2 "elm.icon.2"
56 #define ELM_BUTTON_STYLE "popup_button/default"
58 #define ITC_ITEM_STYLE "dialogue/2text.1icon.2"
59 #define ITC_LIFE_ITEM_STYLE "dialogue/bg/2icon"
60 #define ITC_STO_TITLE_ITEM_STYLE "dialogue/title"
61 #define ITC_STO_TOTAL_ITEM_STYLE "dialogue/2text.2"
62 #define ITC_STO_APP_ITEM_STYLE "dialogue/2text.2"
63 #define ITC_STO_DATA_ITEM_STYLE "dialogue/2text.2"
64 #define ITC_DATA_ITEM_STYLE "dialogue/bg/2icon"
65 #define ITC_LAUNCH_TITLE_ITEM_STYLE "dialogue/title"
66 #define ITC_LAUNCH_ITEM_STYLE "dialogue/1text"
67 #define ITC_LAUNCH_TEXT_ITEM_STYLE "multiline/1text"
68 #define ITC_DETAIL_ITEM_STYLE "dialogue/1text"
69 #define ITC_SEP_10_ITEM_STYLE "dialogue/separator/10"
70 #define ITC_SEP_21_ITEM_STYLE "dialogue/separator/21/with_line"
72 typedef struct _app_info_view_data_t app_info_view_data_t;
74 struct _app_info_view_data_t {
76 Elm_Object_Item *cbar_item;
77 mgr_app_app_info_t *app_info;
80 static Evas_Object *mgr_app_view_app_info_create(void *data);
81 static Evas_Object *mgr_app_view_app_info_set_cbar(void *data);
82 static mgr_app_result_e mgr_app_view_app_info_set_navibar(void *data);
83 static mgr_app_result_e mgr_app_view_app_info_destory(void *data);
84 static mgr_app_result_e mgr_app_view_app_info_update(void *data);
85 static mgr_app_result_e mgr_app_view_app_info_cleanup(void *data);
87 static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data);
90 mgr_app_view_t mgr_app_view_app_info = {
91 .create = mgr_app_view_app_info_create,
92 .setcbar = mgr_app_view_app_info_set_cbar,
93 .setnavibar = mgr_app_view_app_info_set_navibar,
94 .destroy = mgr_app_view_app_info_destory,
95 .update = mgr_app_view_app_info_update,
98 static Elm_Genlist_Item_Class *itc = NULL;
99 static Elm_Genlist_Item_Class *itc_life = NULL;
100 static Elm_Genlist_Item_Class *itc_sto_title= NULL;
101 static Elm_Genlist_Item_Class *itc_sto_total= NULL;
102 static Elm_Genlist_Item_Class *itc_sto_app = NULL;
103 static Elm_Genlist_Item_Class *itc_sto_data = NULL;
104 static Elm_Genlist_Item_Class *itc_data = NULL;
105 static Elm_Genlist_Item_Class *itc_launch_title = NULL;
106 static Elm_Genlist_Item_Class *itc_launch = NULL;
107 static Elm_Genlist_Item_Class *itc_launch_text = NULL;
108 static Elm_Genlist_Item_Class *itc_detail = NULL;
109 static Elm_Genlist_Item_Class *itc_sep_10 = NULL;
110 static Elm_Genlist_Item_Class *itc_sep_21 = NULL;
113 static void _app_info_next_cb(void *data, Evas_Object *obj, void *event_info)
116 mgr_app_view_create(&mgr_app_view_app_info, data);
120 void _app_info_back_cb(void *data, Evas_Object *obj, void *event_info)
124 ret_if(data == NULL);
125 struct ug_data *ugd = (struct ug_data*)data;
129 MGR_APP_DEBUG("pc is freed");
130 pkgmgr_client_free(ugd->pc);
135 ret = ug_destroy(ugd->sub_ug);
137 MGR_APP_DEBUG_ERR("ug_destroy ugd->sub_ug is failed");
140 mgr_app_view_common_back_cb(ugd, EINA_FALSE);
142 elm_genlist_item_class_free(itc_sep_21);
143 elm_genlist_item_class_free(itc);
144 elm_genlist_item_class_free(itc_sep_10);
145 elm_genlist_item_class_free(itc_life);
146 elm_genlist_item_class_free(itc_sto_title);
147 elm_genlist_item_class_free(itc_sto_total);
148 elm_genlist_item_class_free(itc_sto_app);
149 elm_genlist_item_class_free(itc_sto_data);
150 elm_genlist_item_class_free(itc_data);
151 elm_genlist_item_class_free(itc_launch_title);
152 elm_genlist_item_class_free(itc_launch);
153 elm_genlist_item_class_free(itc_launch_text);
154 elm_genlist_item_class_free(itc_detail);
159 static void _force_stop_clicked_cb(void *data, Evas_Object *obj, void *event_info)
163 ret_if(data == NULL);
164 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
165 ret_if(app_info->pkg_name == NULL);
166 bool is_running = false;
167 int ret = APP_MANAGER_ERROR_NONE;
170 ret = app_manager_is_running(app_info->pkg_name, &is_running);
172 case APP_MANAGER_ERROR_NONE:
173 MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_NONE");
175 case APP_MANAGER_ERROR_INVALID_PARAMETER:
176 MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_INVALID_PARAMETER");
179 MGR_APP_DEBUG("default");
184 MGR_APP_DEBUG("%s app_is_running", app_info->pkg_name);
185 app_context_h app_context = {0, };
187 ret = app_manager_get_app_context(app_info->pkg_name, &app_context);
189 case APP_MANAGER_ERROR_NONE:
190 MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_NONE");
192 case APP_MANAGER_ERROR_INVALID_PARAMETER:
193 MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_INVALID_PARAMETER");
195 case APP_MANAGER_ERROR_DB_FAILED:
196 MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_DB_FAILED");
198 case APP_MANAGER_ERROR_OUT_OF_MEMORY:
199 MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_OUT_OF_MEMORY");
201 case APP_MANAGER_ERROR_NO_SUCH_APP:
202 MGR_APP_DEBUG("get_app_context APP_MANAGER_ERROR_NO_SUCH_APP");
205 MGR_APP_DEBUG("default");
209 ret = app_manager_terminate_app(app_context);
211 case APP_MANAGER_ERROR_NONE:
212 MGR_APP_DEBUG("terminate_app APP_MANAGER_ERROR_NONE");
214 case APP_MANAGER_ERROR_INVALID_PARAMETER:
215 MGR_APP_DEBUG("terminate_app APP_MANAGER_ERROR_INVALID_PARAMETER");
218 MGR_APP_DEBUG("default");
222 ret = app_context_destroy(app_context);
224 case APP_MANAGER_ERROR_NONE:
225 MGR_APP_DEBUG("context_destroy APP_MANAGER_ERROR_NONE");
227 case APP_MANAGER_ERROR_INVALID_PARAMETER:
228 MGR_APP_DEBUG("context_destroy APP_MANAGER_ERROR_INVALID_PARAMETER");
231 MGR_APP_DEBUG("default");
236 MGR_APP_DEBUG("%s app is not running", app_info->pkg_name);
241 elm_object_disabled_set(obj, EINA_TRUE);
247 static void _no_response_cb(void *data, Evas_Object *obj, void *event_info)
251 ret_if(data == NULL);
252 evas_object_del(data);
257 static void _uninstall_by_pkgmgr_cb(void *data, Evas_Object *obj, void *event_info)
262 ret_if(data == NULL);
263 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
265 ret_if(mgr_app_view_app_info.view_common_data == NULL);
266 mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_info.view_common_data;
268 ret_if(view_common_data->user_view_data == NULL);
269 app_info_view_data_t *app_info_view_data = view_common_data->user_view_data;
271 struct ug_data *ugd = NULL;
272 ugd = evas_object_data_get(app_info_view_data->genlist, STR_UGD);
275 Evas_Object *btn_uninstall = NULL;
276 btn_uninstall = (Evas_Object*)evas_object_data_get(obj, STR_BTN_UNINSTALL);
277 ret_if(btn_uninstall == NULL);
279 Evas_Object *popup = NULL;
280 popup = (Evas_Object*)evas_object_data_get(obj, STR_POPUP);
281 ret_if(popup == NULL);
283 evas_object_data_del(obj, STR_BTN_UNINSTALL);
284 evas_object_data_del(obj, STR_POPUP);
285 evas_object_del(popup);
287 _force_stop_clicked_cb(data, btn_uninstall, event_info);
289 MGR_APP_DEBUG("pkg type: %s, pkg_name: %s", app_info->pkg_type, app_info->pkg_name);
292 pkgmgr_client_free(ugd->pc);
295 ugd->pc = pkgmgr_client_new(PC_REQUEST);
297 MGR_APP_DEBUG_ERR("create new pkgmgr client is failed");
302 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);
305 MGR_APP_DEBUG("uninstall success, req_id=%d", req_id);
308 case PKGMGR_R_EINVAL: /* -3: Invalid argument */
309 MGR_APP_DEBUG("PKGMGR_R_EINVAL");
311 case PKGMGR_R_ECOMM: /* -2: Comunication Error */
312 MGR_APP_DEBUG("PKGMGR_R_ECOMM");
314 case PKGMGR_R_OK: /* 0: General success */
315 MGR_APP_DEBUG("PKGMGR_R_OK");
318 MGR_APP_DEBUG("default req_id=%d", req_id);
323 /* the select 'No' noti be available from pkg-mgr then add the condition */
324 elm_object_disabled_set(obj, EINA_FALSE);
329 static void _uninstall_clicked_cb(void *data, Evas_Object *obj, void *event_info)
334 Evas_Object *btn_uninstall = obj;
336 ret_if(data == NULL);
337 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
339 ret_if(mgr_app_view_app_info.view_common_data == NULL);
340 mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_info.view_common_data;
342 Evas_Object *popup = NULL;
343 Evas_Object *btn_yes = NULL;
344 Evas_Object *btn_no = NULL;
346 popup = elm_popup_add(view_common_data->common_navibar);
347 ret_if(popup == NULL);
348 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
349 elm_object_text_set(popup, "Uninstall?");
350 elm_object_part_text_set(popup, "title,text", app_info->app_name);
352 btn_yes = elm_button_add(popup);
353 ret_if(btn_yes == NULL);
354 elm_object_text_set(btn_yes, "Yes");
355 elm_object_part_content_set(popup, "button1", btn_yes);
356 elm_object_style_set(btn_yes, ELM_BUTTON_STYLE);
357 evas_object_smart_callback_add(btn_yes, "clicked", _uninstall_by_pkgmgr_cb, data);
358 evas_object_data_set(btn_yes, STR_BTN_UNINSTALL, btn_uninstall);
359 evas_object_data_set(btn_yes, STR_POPUP, popup);
361 btn_no = elm_button_add(popup);
362 ret_if(btn_no == NULL);
363 elm_object_text_set(btn_no, "No");
364 elm_object_part_content_set(popup, "button2", btn_no);
365 elm_object_style_set(btn_no, ELM_BUTTON_STYLE);
366 evas_object_smart_callback_add(btn_no, "clicked", _no_response_cb, (void*)popup);
368 evas_object_show(popup);
373 static void _clear_data_clicked_cb(void *data, Evas_Object *obj, void *event_info)
378 elm_object_disabled_set(obj, EINA_TRUE);
383 static void _gl_sel(void *data, Evas_Object *obj, void *event_info)
387 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
390 elm_genlist_item_selected_set(item, EINA_FALSE);
396 static void _gl_sel_launch(void *data, Evas_Object *obj, void *event_info)
400 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
401 ret_if(data == NULL);
402 struct ug_data *ugd = (struct ug_data*)data;
404 ret_if(ugd->data == NULL);
405 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)ugd->data;
407 ret_if(app_info->pkg_name == NULL);
408 char *package_name = NULL;
409 package_name = app_info->pkg_name;
412 elm_genlist_item_selected_set(item, EINA_FALSE);
413 elm_object_item_disabled_set(item, EINA_TRUE);
416 if (appsvc_is_defapp(package_name)) {
417 MGR_APP_DEBUG("%s is the default app", package_name);
418 if (appsvc_unset_defapp(package_name) != APPSVC_RET_OK) {
419 MGR_APP_DEBUG_ERR("unset the %s to default app is failed", package_name);
422 MGR_APP_DEBUG("%s is not the default app", package_name);
428 static void _layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
432 Evas_Object *base = NULL;
433 Evas_Object *win = NULL;
440 base = ug_get_layout(ug);
446 win = ug_get_window();
449 case UG_MODE_FULLVIEW:
450 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
451 elm_win_resize_object_add(win, base);
452 ug_disable_effect(ug);
453 evas_object_show(base);
462 static void _result_cb(ui_gadget_h ug, service_h service, void *priv)
466 struct ug_data *mydata = NULL;
476 int ret = SERVICE_ERROR_NONE;
478 ret = service_get_extra_data(service, "name", &val);
480 case SERVICE_ERROR_NONE:
481 MGR_APP_DEBUG_ERR("SERVICE_ERROR_NONE");
483 case SERVICE_ERROR_INVALID_PARAMETER:
484 MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_PARAMETER");
486 case SERVICE_ERROR_KEY_NOT_FOUND:
487 MGR_APP_DEBUG_ERR("SERVICE_ERROR_KEY_NOT_FOUND");
489 case SERVICE_ERROR_OUT_OF_MEMORY:
490 MGR_APP_DEBUG_ERR("SERVICE_ERROR_OUT_OF_MEMORY");
492 case SERVICE_ERROR_INVALID_DATA_TYPE:
493 MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_DATA_TYPE");
496 MGR_APP_DEBUG_ERR("ret value has an error. %d.", ret);
501 MGR_APP_DEBUG("The name of UI gadget that sends result is [%s]", val);
507 MGR_APP_DEBUG("mydata->sub_ug:%d", mydata->sub_ug);
509 mydata->sub_ug = NULL;
514 static void _destroy_cb(ui_gadget_h ug, void *priv)
523 struct ug_data *mydata = (struct ug_data*)priv;
526 mydata->sub_ug = NULL;
531 static void __create_ug(void *data)
535 ret_if(data == NULL);
536 struct ug_data *ugd = (struct ug_data*)data;
537 mgr_app_app_info_t *app_info = NULL;
539 ret_if(ugd->data == NULL);
540 app_info = (mgr_app_app_info_t*)ugd->data;
542 ui_gadget_h ug = {0, };
543 struct ug_cbs cbs = {0,};
544 service_h service = {0, };
545 int ret = MGR_APP_OK;
547 cbs.layout_cb = _layout_cb;
548 cbs.result_cb = _result_cb;
549 cbs.destroy_cb = _destroy_cb;
550 cbs.priv = (void*)ugd;
552 ret = service_create(&service);
554 case SERVICE_ERROR_NONE:
555 MGR_APP_DEBUG("service_create SERVICE_ERROR_NONE");
557 case SERVICE_ERROR_INVALID_PARAMETER:
558 MGR_APP_DEBUG_ERR("service_create SERVICE_ERROR_INVALID_PARAMETER");
560 case SERVICE_ERROR_OUT_OF_MEMORY:
561 MGR_APP_DEBUG_ERR("service_create SERVICE_ERROR_OUT_OF_MEMORY");
564 MGR_APP_DEBUG_ERR("service_create ret value has an error, %d.", ret);
568 if (app_info->pkg_type && !strncmp(app_info->pkg_type, WRT_PREFIX, strlen(WRT_PREFIX))) {
569 MGR_APP_DEBUG("app_info->pkg_type: %s", app_info->pkg_type);
570 MGR_APP_DEBUG("app_info->pkg_name : %s", app_info->pkg_name);
572 ret = service_add_extra_data(service, UG_PARAM_KEY_PKG_NAME, app_info->pkg_name);
574 case SERVICE_ERROR_NONE:
575 MGR_APP_DEBUG("service_add_extra_data SERVICE_ERROR_NONE");
577 case SERVICE_ERROR_INVALID_PARAMETER:
578 MGR_APP_DEBUG_ERR("service_add_extra_data SERVICE_ERROR_INVALID_PARAMETER");
580 case SERVICE_ERROR_KEY_REJECTED:
581 MGR_APP_DEBUG_ERR("service_add_extra_data SERVICE_ERROR_KEY_REJECTED");
584 MGR_APP_DEBUG_ERR("service_add_extra_data ret value has an error, %d.", ret);
588 /* wrt ug more detail info */
589 ug = ug_create(ugd->ug, UG_NAME_WEBAPP_INFO_EFL, UG_MODE_FULLVIEW, service, &cbs);
592 MGR_APP_DEBUG(">>> NOT SUPPORTED TYPE");
596 ret = service_destroy(service);
598 case SERVICE_ERROR_NONE:
599 MGR_APP_DEBUG("service_destroy SERVICE_ERROR_NONE");
601 case SERVICE_ERROR_INVALID_PARAMETER:
602 MGR_APP_DEBUG_ERR("service_destroy SERVICE_ERROR_INVALID_PARAMETER");
604 case SERVICE_ERROR_OUT_OF_MEMORY:
605 MGR_APP_DEBUG_ERR("service_destroy SERVICE_ERROR_OUT_OF_MEMORY");
608 MGR_APP_DEBUG_ERR("service_destroy ret value has an error, %d.", ret);
615 static void _gl_sel_detail(void *data, Evas_Object *obj, void *event_info)
619 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
620 struct ug_data *ugd = (struct ug_data*)data;
623 elm_genlist_item_selected_set(item, 0);
626 __create_ug((void*)ugd);
631 static char *__get_formated_size(float size)
635 char *buf = (char*)malloc(sizeof(char)*MAX_NAME_LEN);
636 retv_if(buf == NULL, NULL);
637 memset(buf, 0, MAX_NAME_LEN);
639 if (size < NUM_KILO) {
640 snprintf(buf, MAX_NAME_LEN, "%d %s", (int)size, dgettext(PACKAGE, "IDS_ST_BODY_BYTES"));
641 } else if (size >= NUM_KILO && size < NUM_MEGA) {
642 snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_KILO, dgettext(PACKAGE, "IDS_ST_BODY_KB"));
643 } else if (size >= NUM_MEGA && size < NUM_GIGA) {
644 snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_MEGA, dgettext(PACKAGE, "IDS_ST_BODY_MB"));
646 snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_GIGA, dgettext(PACKAGE, "IDS_ST_BODY_GB"));
653 static char *_gl_label_get(void *data, Evas_Object *obj, const char *part)
657 retv_if(data == NULL, NULL);
658 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
662 char *package_name = app_info->pkg_name;
663 char *app_name = app_info->app_name;
664 char *icon_path = app_info->icon_path;
665 char *pkg_type = app_info->pkg_type;
667 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);
668 MGR_APP_DEBUG("part:%s\n", part);
669 retv_if(app_name == NULL, NULL);
671 /* label for 'elm.text' part */
672 if (!strncmp(part, ELM_TEXT_1, strlen(ELM_TEXT_1))) {
674 MGR_APP_MEM_STRDUP(label, app_name);
676 } else if (!strncmp(part, ELM_TEXT_2, strlen(ELM_TEXT_2))) {
677 label = __get_formated_size((float)app_info->total_size);
679 MGR_APP_MEM_STRDUP(label, dgettext("sys_string", "IDS_COM_POP_ERROR"));
686 static char *_gl_label_get_sto_total(void *data, Evas_Object *obj, const char *part)
690 retv_if(data == NULL, NULL);
691 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
695 MGR_APP_DEBUG("part:%s\n", part);
697 /* label for 'elm.text' part */
698 if (!strncmp(part, ELM_TEXT_2, strlen(ELM_TEXT_2))) {
699 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_TOTAL"));
700 } else if (!strncmp(part, ELM_TEXT_1, strlen(ELM_TEXT_1))) {
701 label = __get_formated_size((float)app_info->total_size);
703 MGR_APP_MEM_STRDUP(label, dgettext("sys_string", "IDS_COM_POP_ERROR"));
710 static char *_gl_label_get_sto_app(void *data, Evas_Object *obj, const char *part)
714 retv_if(data == NULL, NULL);
715 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
719 MGR_APP_DEBUG("part:%s\n", part);
721 /* label for 'elm.text' part */
722 if (!strncmp(part, ELM_TEXT_2, strlen(ELM_TEXT_2))) {
723 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_APPLICATION"));
724 } else if (!strncmp(part, ELM_TEXT_1, strlen(ELM_TEXT_1))) {
725 label = __get_formated_size((float)app_info->total_size - (float)app_info->data_size);
727 MGR_APP_MEM_STRDUP(label, dgettext("sys_string", "IDS_COM_POP_ERROR"));
734 static char *_gl_label_get_sto_data(void *data, Evas_Object *obj, const char *part)
738 retv_if(data == NULL, NULL);
739 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
743 MGR_APP_DEBUG("part:%s\n", part);
745 /* label for 'elm.text' part */
746 if (!strncmp(part, ELM_TEXT_2, strlen(ELM_TEXT_2))) {
747 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_DATA"));
748 } else if (!strncmp(part, ELM_TEXT_1, strlen(ELM_TEXT_1))) {
749 label = __get_formated_size((float)app_info->data_size);
751 MGR_APP_MEM_STRDUP(label, dgettext("sys_string", "IDS_COM_POP_ERROR"));
758 static char *_gl_label_get_launch(void *data, Evas_Object *obj, const char *part)
764 MGR_APP_DEBUG("part:%s\n", part);
766 /* label for 'elm.text' part */
767 if (!strncmp(part, ELM_TEXT, strlen(ELM_TEXT))) {
768 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_CLEAR_DEFAULTS"));
775 static char *_gl_label_get_detail(void *data, Evas_Object *obj, const char *part)
781 MGR_APP_DEBUG("part:%s\n", part);
783 /* label for 'elm.text' part */
784 if (!strncmp(part, ELM_TEXT, strlen(ELM_TEXT))) {
785 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_MORE_DETAILS"));
792 static char *_gl_label_get_launch_text(void *data, Evas_Object *obj, const char *part)
798 MGR_APP_DEBUG("part:%s\n", part);
800 /* label for 'elm.text' part */
801 if (!strncmp(part, ELM_TEXT, strlen(ELM_TEXT))) {
802 MGR_APP_MEM_STRDUP(label, dgettext(PACKAGE, "IDS_ST_BODY_YOU_HAVE_SELECTED_TO_LAUNCH_THIS_APPLICATION_BY_DEFAULT_FOR_SOME_ACTIONS"));
809 static Evas_Object *_gl_icon_get(void *data, Evas_Object *obj, const char *part)
813 retv_if(data == NULL, NULL);
814 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
816 Evas_Object *icon = NULL;
817 char *icon_path = NULL;
819 retv_if(app_info->icon_path == NULL, NULL);
820 icon_path = app_info->icon_path;
822 MGR_APP_DEBUG("icon_path:[%s]\n", icon_path);
823 MGR_APP_DEBUG("part:%s\n", part);
825 /* icon for 'elm.icon' part */
826 icon = elm_icon_add(obj);
827 retv_if(icon == NULL, NULL);
828 elm_icon_file_set(icon, icon_path, STR_ICON);
830 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
837 static Evas_Object *_gl_icon_get_life(void *data, Evas_Object *obj, const char *part)
841 MGR_APP_DEBUG("part:%s\n", part);
842 retv_if(data == NULL, NULL);
843 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
845 Evas_Object *button = NULL;
846 if (!strncmp(part, ELM_ICON_1, strlen(ELM_ICON_1))) {
847 button = elm_button_add(obj);
849 elm_object_disabled_set(button, EINA_TRUE);
850 elm_object_text_set(button, dgettext(PACKAGE, "IDS_ST_BUTTON_FORCE_STOP"));
851 elm_object_style_set(button, ELM_BUTTON_STYLE);
852 evas_object_smart_callback_add(button, "clicked", _force_stop_clicked_cb, (void*)data);
854 if (app_info->taskmanage) {
855 bool is_running = false;
856 int ret = app_manager_is_running(app_info->pkg_name, &is_running);
859 case APP_MANAGER_ERROR_NONE:
860 MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_NONE");
862 elm_object_disabled_set(button, EINA_FALSE);
865 case APP_MANAGER_ERROR_INVALID_PARAMETER:
866 MGR_APP_DEBUG("is_running APP_MANAGER_ERROR_INVALID_PARAMETER");
869 MGR_APP_DEBUG("default");
874 } else if (!strncmp(part, ELM_ICON_2, strlen(ELM_ICON_2))) {
875 button = elm_button_add(obj);
877 elm_object_disabled_set(button, EINA_TRUE);
878 elm_object_text_set(button, dgettext(PACKAGE, "IDS_ST_BUTTON_UNINSTALL"));
879 elm_object_style_set(button, ELM_BUTTON_STYLE);
880 evas_object_smart_callback_add(button, "clicked", _uninstall_clicked_cb, (void*)data);
882 if (app_info->removable) {
883 elm_object_disabled_set(button, EINA_FALSE);
887 MGR_APP_DEBUG_ERR("elm icon part is wrong");
895 static Evas_Object *_gl_icon_get_data(void *data, Evas_Object *obj, const char *part)
899 MGR_APP_DEBUG("part:%s\n", part);
900 retv_if(data == NULL, NULL);
901 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)data;
903 Evas_Object *button = NULL;
904 if (!strncmp(part, ELM_ICON_2, strlen(ELM_ICON_2))) {
905 button = elm_button_add(obj);
907 elm_object_text_set(button, dgettext(PACKAGE, "IDS_ST_BUTTON_CLEAR_DATA"));
908 elm_object_style_set(button, ELM_BUTTON_STYLE);
909 evas_object_smart_callback_add(button, "clicked", _clear_data_clicked_cb, (void*)data);
910 if (app_info->data_size <= 0) {
911 elm_object_disabled_set(button, EINA_TRUE);
915 MGR_APP_DEBUG_ERR("empty button area");
923 static char *_gl_label_get_title(void *data, Evas_Object *obj, const char *part)
927 char *group_title = (char *)data;
930 MGR_APP_MEM_STRDUP(title, group_title);
936 static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
940 retv_if(data == NULL, NULL);
941 struct ug_data *ugd = (struct ug_data*)data;
943 Elm_Object_Item *item_app = NULL;
944 Elm_Object_Item *item_life = NULL;
945 Elm_Object_Item *item_sto_title = NULL;
946 Elm_Object_Item *item_sto_total = NULL;
947 Elm_Object_Item *item_sto_app = NULL;
948 Elm_Object_Item *item_sto_data = NULL;
949 Elm_Object_Item *item_data = NULL;
950 Elm_Object_Item *item_launch_text = NULL;
951 Elm_Object_Item *item_launch_title = NULL;
952 Elm_Object_Item *item_launch = NULL;
953 Elm_Object_Item *item_sep_10 = NULL;
954 Elm_Object_Item *item_sep_21 = NULL;
955 Elm_Object_Item *item_detail = NULL;
957 Evas_Object *genlist = NULL;
958 char *sto_title = NULL;
959 char *launch_title = NULL;
962 /* set the genlist item style */
963 itc_sep_21 = elm_genlist_item_class_new();
964 retv_if(itc_sep_21 == NULL, NULL);
965 itc = elm_genlist_item_class_new();
966 retv_if(itc == NULL, NULL);
967 itc_sep_10 = elm_genlist_item_class_new();
968 retv_if(itc_sep_10 == 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);
990 itc_sep_21->item_style = ITC_SEP_21_ITEM_STYLE;
991 itc_sep_21->func.text_get = NULL;
992 itc_sep_21->func.content_get = NULL;
993 itc_sep_21->func.state_get = NULL;
994 itc_sep_21->func.del = NULL;
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;
1002 itc_sep_10->item_style = ITC_SEP_10_ITEM_STYLE;
1003 itc_sep_10->func.text_get = NULL;
1004 itc_sep_10->func.content_get = NULL;
1005 itc_sep_10->func.state_get = NULL;
1006 itc_sep_10->func.del = NULL;
1008 itc_life->item_style = ITC_LIFE_ITEM_STYLE;
1009 itc_life->func.text_get = NULL;
1010 itc_life->func.content_get = _gl_icon_get_life;
1011 itc_life->func.state_get = NULL;
1012 itc_life->func.del = NULL;
1014 itc_sto_title->item_style = ITC_STO_TITLE_ITEM_STYLE;
1015 itc_sto_title->func.text_get = _gl_label_get_title;
1016 itc_sto_title->func.content_get = NULL;
1017 itc_sto_title->func.state_get = NULL;
1018 itc_sto_title->func.del = NULL;
1020 itc_sto_total->item_style = ITC_STO_TOTAL_ITEM_STYLE;
1021 itc_sto_total->func.text_get = _gl_label_get_sto_total;
1022 itc_sto_total->func.content_get = NULL;
1023 itc_sto_total->func.state_get = NULL;
1024 itc_sto_total->func.del = NULL;
1026 itc_sto_app->item_style = ITC_STO_APP_ITEM_STYLE;
1027 itc_sto_app->func.text_get = _gl_label_get_sto_app;
1028 itc_sto_app->func.content_get = NULL;
1029 itc_sto_app->func.state_get = NULL;
1030 itc_sto_app->func.del = NULL;
1032 itc_sto_data->item_style = ITC_STO_DATA_ITEM_STYLE;
1033 itc_sto_data->func.text_get = _gl_label_get_sto_data;
1034 itc_sto_data->func.content_get = NULL;
1035 itc_sto_data->func.state_get = NULL;
1036 itc_sto_data->func.del = NULL;
1038 itc_data->item_style = ITC_DATA_ITEM_STYLE;
1039 itc_data->func.text_get = NULL;
1040 itc_data->func.content_get = _gl_icon_get_data;
1041 itc_data->func.state_get = NULL;
1042 itc_data->func.del = NULL;
1044 itc_launch_title->item_style = ITC_LAUNCH_TITLE_ITEM_STYLE;
1045 itc_launch_title->func.text_get = _gl_label_get_title;
1046 itc_launch_title->func.content_get = NULL;
1047 itc_launch_title->func.state_get = NULL;
1048 itc_launch_title->func.del = NULL;
1050 itc_launch->item_style = ITC_LAUNCH_ITEM_STYLE;
1051 itc_launch->func.text_get = _gl_label_get_launch;
1052 itc_launch->func.content_get = NULL;
1053 itc_launch->func.state_get = NULL;
1054 itc_launch->func.del = NULL;
1056 itc_launch_text->item_style = ITC_LAUNCH_TEXT_ITEM_STYLE;
1057 itc_launch_text->func.text_get = _gl_label_get_launch_text;
1058 itc_launch_text->func.content_get = NULL;
1059 itc_launch_text->func.state_get = NULL;
1060 itc_launch_text->func.del = NULL;
1062 itc_detail->item_style = ITC_DETAIL_ITEM_STYLE;
1063 itc_detail->func.text_get = _gl_label_get_detail;
1064 itc_detail->func.content_get = NULL;
1065 itc_detail->func.state_get = NULL;
1066 itc_detail->func.del = NULL;
1069 retv_if(ugd->data == NULL, NULL);
1070 mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)ugd->data;
1072 /* get app size from pkgmgr */
1073 pkgmgr_info *pkg_info = pkgmgr_info_new(app_info->pkg_type, app_info->pkg_name);
1075 MGR_APP_DEBUG_ERR("pkg_info is null, couldn't get the sizes");
1076 app_info->data_size = 0;
1077 app_info->total_size = 0;
1081 buf = pkgmgr_info_get_string(pkg_info, STR_DATA_SIZE);
1083 app_info->data_size = atoi(buf);
1084 MGR_APP_MEM_FREE(buf);
1086 app_info->data_size = 0;
1090 buf = pkgmgr_info_get_string(pkg_info, STR_INSTALLED_SIZE);
1092 app_info->total_size = atoi(buf);
1093 MGR_APP_MEM_FREE(buf);
1095 app_info->total_size = 0;
1097 pkgmgr_info_free(pkg_info);
1101 genlist = elm_genlist_add(parent);
1102 retv_if(genlist == NULL, NULL);
1103 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1104 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1105 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1106 elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
1107 evas_object_data_set(genlist, STR_UGD, (void*)ugd);
1108 elm_object_style_set(genlist, "dialogue");
1109 evas_object_show(genlist);
1111 MGR_APP_MEM_STRDUP(sto_title, dgettext(PACKAGE, "IDS_ST_BODY_STORAGE"));
1112 MGR_APP_MEM_STRDUP(launch_title, dgettext(PACKAGE, "IDS_ST_BODY_LAUNCH_BY_DEFAULT"));
1116 item_app = elm_genlist_item_append(genlist, itc, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1118 elm_genlist_item_select_mode_set(item_app, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1121 /* separator with no bottom line */
1122 item_sep_10 = elm_genlist_item_append(genlist, itc_sep_10, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1124 elm_genlist_item_select_mode_set(item_sep_10, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1127 /* Force stop & Uninstall */
1128 item_life = elm_genlist_item_append(genlist, itc_life, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, NULL);
1132 item_sto_title = elm_genlist_item_append(genlist, itc_sto_title, sto_title, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1133 item_sto_total = elm_genlist_item_append(genlist, itc_sto_total, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1135 elm_genlist_item_select_mode_set(item_sto_total, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1136 item_sto_app = elm_genlist_item_append(genlist, itc_sto_app, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1138 elm_genlist_item_select_mode_set(item_sto_app, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1139 item_sto_data = elm_genlist_item_append(genlist, itc_sto_data, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1141 elm_genlist_item_select_mode_set(item_sto_data, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1144 /* separator with no bottom line */
1145 //item_sep_10 = elm_genlist_item_append(genlist, itc_sep_10, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1147 // elm_genlist_item_select_mode_set(item_sep_10, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1151 /* remove the button until the feature is supported */
1152 //item_data = elm_genlist_item_append(genlist, &itc_data, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, NULL);
1155 /* separator with bottom line */
1156 /* the separator is located bottom of Clear Data button */
1157 //item_sep_10 = elm_genlist_item_append(genlist, &itc_sep_10, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1159 // elm_genlist_item_select_mode_set(item_sep_10, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1163 item_launch_title = elm_genlist_item_append(genlist, itc_launch_title, launch_title, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
1164 item_launch = elm_genlist_item_append(genlist, itc_launch, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_launch, (void*)ugd);
1165 if (item_launch && !appsvc_is_defapp(app_info->pkg_name)) {
1166 elm_genlist_item_selected_set(item_launch, EINA_FALSE);
1167 elm_object_item_disabled_set(item_launch, EINA_TRUE);
1169 item_launch_text = elm_genlist_item_append(genlist, itc_launch_text, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1170 if (item_launch_text)
1171 elm_genlist_item_select_mode_set(item_launch_text, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1172 item_sep_21 = elm_genlist_item_append(genlist, itc_sep_21, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1174 elm_genlist_item_select_mode_set(item_sep_21, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1178 item_detail = elm_genlist_item_append(genlist, itc_detail, (void *)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_detail, (void*)ugd);
1179 if (app_info->pkg_type) {
1180 if (item_detail != NULL && (!strncmp(app_info->pkg_type, TPK_PREFIX, strlen(TPK_PREFIX)) || !strncmp(app_info->pkg_type, RPM_PREFIX, strlen(RPM_PREFIX)))) {
1181 elm_genlist_item_selected_set(item_detail, EINA_FALSE);
1182 elm_object_item_disabled_set(item_detail, EINA_TRUE);
1185 MGR_APP_DEBUG_ERR("app_info->pkg_type is NULL");
1188 if (elm_genlist_first_item_get(genlist)) {
1189 item_sep_21 = elm_genlist_item_prepend(genlist, itc_sep_21, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1191 elm_genlist_item_select_mode_set(item_sep_21, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1198 static Evas_Object *mgr_app_view_app_info_create(void *data)
1202 retv_if(data == NULL, NULL);
1203 struct ug_data *ugd = (struct ug_data*)data;
1205 retv_if(mgr_app_view_app_info.view_common_data == NULL, NULL);
1206 mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_info.view_common_data;
1208 MGR_APP_MEM_MALLOC(view_common_data->user_view_data, 1, app_info_view_data_t);
1209 retv_if(view_common_data->user_view_data == NULL, NULL);
1210 app_info_view_data_t *app_info_view_data = view_common_data->user_view_data;
1212 app_info_view_data->genlist = __create_genlist_app_info(view_common_data->common_navibar, (void*)ugd);
1215 return app_info_view_data->genlist;
1218 static Evas_Object *mgr_app_view_app_info_set_cbar(void *data)
1226 static mgr_app_result_e mgr_app_view_app_info_set_navibar(void *data)
1229 mgr_app_view_manager_set_navibar(mgr_app_view_app_info.view_common_data, dgettext(PACKAGE, "IDS_ST_HEADER_APPLICATION_INFO"), NULL, _app_info_back_cb, NULL, NULL);
1234 static mgr_app_result_e mgr_app_view_app_info_destory(void *data)
1238 retv_if(mgr_app_view_app_info.view_common_data == NULL, MGR_APP_ERROR);
1239 mgr_app_view_app_info.view_common_data->view_layout = NULL;
1245 static mgr_app_result_e mgr_app_view_app_info_update(void *data)
1249 retv_if(mgr_app_view_app_info.view_common_data == NULL, MGR_APP_ERROR);
1250 mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_info.view_common_data;
1252 retv_if(view_common_data->user_view_data == NULL, MGR_APP_ERROR);
1253 app_info_view_data_t *app_info_view_data = (app_info_view_data_t*)view_common_data->user_view_data;
1255 elm_genlist_realized_items_update(app_info_view_data->genlist);
1257 /* button disable */
1258 if (!app_info_view_data->genlist) {
1259 MGR_APP_DEBUG("genlist is null\n");
1260 elm_object_item_disabled_set(app_info_view_data->cbar_item, EINA_TRUE);
1266 static mgr_app_result_e mgr_app_view_app_info_cleanup(void *data)