From 84e919d6f329af9ac1e8c2fb6193a3dce67cab8e Mon Sep 17 00:00:00 2001 From: Jin Yoon Date: Wed, 6 Mar 2013 19:13:19 +0900 Subject: [PATCH] Merge with Private Menu-screen --- CMakeLists.txt | 1 + debian/control | 4 +- include/list.h | 1 + packaging/org.tizen.menu-screen.spec | 1 + src/all_apps/layout.c | 4 +- src/list.c | 1 + src/page_scroller.c | 67 ++++++++++++++++++++++++---- src/pkgmgr.c | 56 +++++++++++++++++++---- 8 files changed, 113 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4528b36..cb4b565 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ pkg_check_modules(MENU_PKGS REQUIRED evas heynoti pkgmgr + pkgmgr-info sysman syspopup-caller utilX diff --git a/debian/control b/debian/control index 1bb0f09..4f38e1f 100644 --- a/debian/control +++ b/debian/control @@ -2,14 +2,14 @@ Source: menu-screen Section: utils Priority: extra Maintainer: Jin Yoon -Build-Depends: debhelper (>= 5), libelm-dev, libslp-utilx-dev, libslp-setting-dev, libefreet-dev, libslp-sysman-dev, libslp-pm-dev, dlog-dev, libecore-dev, libaul-1-dev, libpkgmgr-client-dev, syspopup-caller-dev, libheynoti-dev, libail-0-dev, librua-dev, libslp-shortcut-dev, menu-daemon, capi-appfw-application-dev, libbadge-dev +Build-Depends: debhelper (>= 5), libelm-dev, libslp-utilx-dev, libslp-setting-dev, libefreet-dev, libslp-sysman-dev, libslp-pm-dev, dlog-dev, libecore-dev, libaul-1-dev, libpkgmgr-client-dev, syspopup-caller-dev, libheynoti-dev, libail-0-dev, librua-dev, libslp-shortcut-dev, menu-daemon, capi-appfw-application-dev, libbadge-dev, pkgmgr-info-dev Homepage: N/A Standards-Version: 0.1.0 Package: org.tizen.menu-screen Section: utils Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libelm, libeina, libslp-utilx-0, libslp-setting-0, libefreet, libslp-sysman, libslp-pm-0, libdlog-0, libaul-1, libpkgmgr-client-0, syspopup-caller-0, libheynoti-0, libail-0, menu-daemon, capi-appfw-application, libbadge +Depends: ${shlibs:Depends}, ${misc:Depends}, libelm, libeina, libslp-utilx-0, libslp-setting-0, libefreet, libslp-sysman, libslp-pm-0, libdlog-0, libaul-1, libpkgmgr-client-0, syspopup-caller-0, libheynoti-0, libail-0, menu-daemon, capi-appfw-application, libbadge, pkgmgr-info Description: inhouse menu-screen Package: org.tizen.menu-screen-dbg diff --git a/include/list.h b/include/list.h index 7e5465b..d749dc2 100644 --- a/include/list.h +++ b/include/list.h @@ -32,6 +32,7 @@ typedef struct char *icon; char *desktop; bool nodisplay; + bool enabled; bool x_slp_removable; bool x_slp_taskmanage; pid_t pid; diff --git a/packaging/org.tizen.menu-screen.spec b/packaging/org.tizen.menu-screen.spec index ae8891e..7c6cfb3 100644 --- a/packaging/org.tizen.menu-screen.spec +++ b/packaging/org.tizen.menu-screen.spec @@ -38,6 +38,7 @@ BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(evas) BuildRequires: pkgconfig(heynoti) BuildRequires: pkgconfig(pkgmgr) +BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(sysman) BuildRequires: pkgconfig(syspopup-caller) BuildRequires: pkgconfig(utilX) diff --git a/src/all_apps/layout.c b/src/all_apps/layout.c index 386b5f7..b525436 100644 --- a/src/all_apps/layout.c +++ b/src/all_apps/layout.c @@ -199,8 +199,8 @@ static menu_screen_error_e _load_item(Evas_Object *scroller, app_list_item *item retv_if(NULL == item, MENU_SCREEN_ERROR_FAIL); ai = item->data; - if (ai->nodisplay == true) { - return MENU_SCREEN_ERROR_FAIL; + if (ai->nodisplay || !ai->enabled) { + return MENU_SCREEN_ERROR_OK; } retv_if(MENU_SCREEN_ERROR_FAIL == page_scroller_push_item(scroller, ai), MENU_SCREEN_ERROR_FAIL); diff --git a/src/list.c b/src/list.c index af4b054..2aa4142 100644 --- a/src/list.c +++ b/src/list.c @@ -115,6 +115,7 @@ HAPI menu_screen_error_e list_get_values(const char *package, app_info_t *ai) break_if(ail_appinfo_get_str(appinfo_h, AIL_PROP_NAME_STR, &name) < 0); break_if(ail_appinfo_get_str(appinfo_h, AIL_PROP_ICON_STR, &icon) < 0); break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_NODISPLAY_BOOL, &ai->nodisplay) < 0); + break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_X_SLP_ENABLED_BOOL, &ai->enabled) < 0); break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_X_SLP_REMOVABLE_BOOL, &ai->x_slp_removable) < 0); break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &ai->x_slp_taskmanage) < 0); diff --git a/src/page_scroller.c b/src/page_scroller.c index 5d611d2..37b2e87 100644 --- a/src/page_scroller.c +++ b/src/page_scroller.c @@ -283,6 +283,54 @@ static menu_screen_error_e _find_position_by_package(Evas_Object *scroller, int +static menu_screen_error_e _find_position_by_name(Evas_Object *scroller, int *candidate_page, int *candidate_pos, void *data) +{ + Evas_Object *page; + Evas_Object *item; + register int page_no; + register int position_no; + unsigned int nr_of_pages; + int page_max_app; + app_info_t *ai = data; + + retv_if(NULL == scroller, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == candidate_page, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == candidate_pos, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == data, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == ai->name, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + *candidate_page = 0; + *candidate_pos = 0; + nr_of_pages = page_scroller_count_page(scroller); + page_max_app = (int) evas_object_data_get(scroller, "page_max_app"); + for (page_no = 0; page_no < nr_of_pages; page_no ++) { + page = page_scroller_get_page_at(scroller, page_no); + if (!page) { + _D("Page is not found at %d", page_no); + return MENU_SCREEN_ERROR_FAIL; + } + + for (position_no = 0; position_no < page_max_app; position_no ++) { + char *name; + + item = page_get_item_at(page, position_no); + if (!item) { + *candidate_page = page_no; + *candidate_pos = position_no; + return MENU_SCREEN_ERROR_OK; + } else if ((name = item_get_name(item)) && strcmp(name, ai->name) > 0) { + *candidate_page = page_no; + *candidate_pos = position_no; + return MENU_SCREEN_ERROR_OK; + } + } + } + + return MENU_SCREEN_ERROR_OK; +} + + + static menu_screen_error_e _animated_pack_item(Evas_Object *item, Evas_Object *scroller, Evas_Object *page, int from) { Evas_Object *item_out_page = NULL; @@ -418,7 +466,7 @@ HAPI menu_screen_error_e page_scroller_push_item(Evas_Object *scroller, app_info }, { .sort_type = PAGE_SCROLLER_SORT_BY_NAME, - .sort_func = NULL, + .sort_func = _find_position_by_name, }, { .sort_type = PAGE_SCROLLER_SORT_MAX, @@ -477,7 +525,8 @@ static inline menu_screen_error_e _create_cb(const char *package, void *data) break; } - if (ai.nodisplay) { + if (ai.nodisplay || !ai.enabled) + { Evas_Object *page; _D("package %s is not visible", package); @@ -485,7 +534,7 @@ static inline menu_screen_error_e _create_cb(const char *package, void *data) if (item) { if (page) { page_unpack_item(page, item); - page_trim_items(page); + page_scroller_trim_items(scroller); } item_destroy(item); @@ -545,14 +594,14 @@ static inline menu_screen_error_e _update_cb(const char *package, void *data) _D("There is no loaded item is found"); item = pkgmgr_find_pended_object(package, 1, scroller, &page); if (item) { - if (!ai.nodisplay) { + if (!ai.nodisplay && ai.enabled) { _D("Item is found for updating from the install list, Ignore this."); item_update(item, &ai); } else { _D("Item is found for updating from the install list, But nodisplay"); if (page) { page_unpack_item(page, item); - page_trim_items(page); + page_scroller_trim_items(scroller); } item_destroy(item); } @@ -560,7 +609,7 @@ static inline menu_screen_error_e _update_cb(const char *package, void *data) int ret; _D("Item is not found. Create a new one"); - ret = (ai.nodisplay == false ? page_scroller_push_item(scroller, &ai) : MENU_SCREEN_ERROR_OK); + ret = ((!ai.nodisplay && ai.enabled) ? page_scroller_push_item(scroller, &ai) : MENU_SCREEN_ERROR_OK); if (ret == MENU_SCREEN_ERROR_OK) { break; } else { @@ -577,7 +626,7 @@ static inline menu_screen_error_e _update_cb(const char *package, void *data) _D("Cannot find package in the install list"); } - if (ai.nodisplay == false) { + if (!ai.nodisplay && ai.enabled) { item_update(item, &ai); break; } @@ -585,7 +634,7 @@ static inline menu_screen_error_e _update_cb(const char *package, void *data) page = page_scroller_get_page_at(scroller, page_no); if (page) { page_unpack_item(page, item); - page_trim_items(page); + page_scroller_trim_items(scroller); } item_destroy(item); } @@ -1188,7 +1237,7 @@ HAPI void page_scroller_unedit(Evas_Object *scroller) if (NULL == page) break; count = page_count_item(page); - page_trim_items(page); + page_scroller_trim_items(scroller); for (position_no = 0; position_no < page_max_app; position_no ++) { item = page_get_item_at(page, position_no); diff --git a/src/pkgmgr.c b/src/pkgmgr.c index c4182c7..9b01b2f 100644 --- a/src/pkgmgr.c +++ b/src/pkgmgr.c @@ -18,6 +18,7 @@ #include #include +#include #include "conf.h" #include "index.h" @@ -48,21 +49,54 @@ static struct { HAPI inline menu_screen_error_e pkgmgr_uninstall(Evas_Object *item) { - pkgmgr_client *req_pc = NULL; int ret = MENU_SCREEN_ERROR_OK; retv_if(NULL == item, MENU_SCREEN_ERROR_FAIL); + char *pkgid = NULL; + char *appid = item_get_package(item); + retv_if(NULL == appid, MENU_SCREEN_ERROR_FAIL); + + pkgmgr_client *req_pc = NULL; req_pc = pkgmgr_client_new(PC_REQUEST); retv_if(NULL == req_pc, MENU_SCREEN_ERROR_FAIL); - if (pkgmgr_client_uninstall(req_pc, NULL, item_get_package(item), PM_QUIET, NULL, NULL) < 0) { + pkgmgrinfo_appinfo_h handle; + if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_appinfo(appid, &handle)) { + if (PKGMGR_R_OK != pkgmgr_client_free(req_pc)) { + _E("cannot free pkgmgr_client for request."); + } + return MENU_SCREEN_ERROR_FAIL; + } + + if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid)) { + if (PMINFO_R_OK != pkgmgrinfo_appinfo_destroy_appinfo(handle)) { + _E("cannot destroy the appinfo"); + } + + if (PKGMGR_R_OK != pkgmgr_client_free(req_pc)) { + _E("cannot free pkgmgr_client for request."); + } + + return MENU_SCREEN_ERROR_FAIL; + } + + if (!pkgid) pkgid = appid; + + _D("Uninstall a package[%s] from an app[%s]", pkgid, appid); + if (pkgmgr_client_uninstall(req_pc, NULL, pkgid, PM_QUIET, NULL, NULL) < 0) { _E("cannot uninstall %s.", item_get_package(item)); ret = MENU_SCREEN_ERROR_FAIL; } - if (pkgmgr_client_free(req_pc) != PKGMGR_R_OK) { - _E("cannot free pkgmgr_client for request."); + if (PMINFO_R_OK != pkgmgrinfo_appinfo_destroy_appinfo(handle)) { + _E("cannot destroy the appinfo"); + ret = MENU_SCREEN_ERROR_FAIL; + } + + if (PMINFO_R_OK != pkgmgr_client_free(req_pc)) { + _E("cannot free pkgmgr_client"); + ret = MENU_SCREEN_ERROR_FAIL; } return ret; @@ -116,6 +150,7 @@ static menu_screen_error_e _start_uninstall(const char *package, void *scroller) pi->status = UNINSTALL_BEGIN; pi->ai.package = strdup(package); pi->ai.nodisplay = false; + pi->ai.enabled = true; pi->item = page_scroller_find_item_by_package(scroller, package, &page_no); pi->page = page_scroller_get_page_at(scroller, page_no); @@ -157,6 +192,7 @@ static menu_screen_error_e _start_update(const char *package, void *scroller) if (pi->item && pi->page) { pi->ai.nodisplay = false; + pi->ai.enabled = true; } install_list = eina_list_append(install_list, pi); @@ -168,7 +204,7 @@ static menu_screen_error_e _start_update(const char *package, void *scroller) evas_object_data_set(scroller, "install_list", install_list); if (pi->item) { page_unpack_item(pi->page, pi->item); - page_trim_items(pi->page); + page_scroller_trim_items(scroller); item_destroy(pi->item); } @@ -241,6 +277,7 @@ static menu_screen_error_e _start_install(const char *package, void *scroller) if (pi->item && pi->page) { pi->ai.nodisplay = false; + pi->ai.enabled = true; } install_list = eina_list_append(install_list, pi); @@ -252,7 +289,7 @@ static menu_screen_error_e _start_install(const char *package, void *scroller) evas_object_data_set(scroller, "install_list", install_list); if (pi->item) { page_unpack_item(pi->page, pi->item); - page_trim_items(pi->page); + page_scroller_trim_items(scroller); item_destroy(pi->item); } @@ -352,6 +389,7 @@ static menu_screen_error_e _icon_path(const char *package, const char *val, void if (!pi->item) { _D("There is no item for [%s]", package); pi->ai.nodisplay = false; + pi->ai.enabled = true; if (MENU_SCREEN_ERROR_FAIL == page_scroller_push_item(scroller, &pi->ai)) { _E("Failed to create a new item, remove this package from the installing list"); @@ -398,7 +436,7 @@ static menu_screen_error_e _download_percent(const char *package, const char *va _D("Invalid state for %s, This is not started from the download_begin state(%s)", package, val); } - if (!pi->ai.nodisplay && pi->item) { + if (!pi->ai.nodisplay && pi->ai.enabled && pi->item) { if (!item_is_enabled_progress(pi->item)) { item_enable_progress(pi->item); } @@ -450,7 +488,7 @@ static menu_screen_error_e _install_percent(const char *package, const char *val _D("Invalid state for %s, This is not the uninstall or install_begin state(%s)", package, val); } - if (!pi->ai.nodisplay && pi->item) { + if (!pi->ai.nodisplay && pi->ai.enabled && pi->item) { if (!item_is_enabled_progress(pi->item)) { item_enable_progress(pi->item); } @@ -583,7 +621,7 @@ static menu_screen_error_e _end_unknown(const char *package, struct package_info { if (pi->page) { page_unpack_item(pi->page, pi->item); - page_trim_items(pi->page); + page_scroller_trim_items(scroller); } else { _D("Page is not valid (%s)", package); } -- 2.34.1