Merge with Private Menu-screen
authorJin Yoon <jinny.yoon@samsung.com>
Wed, 6 Mar 2013 10:13:19 +0000 (19:13 +0900)
committerJin Yoon <jinny.yoon@samsung.com>
Wed, 6 Mar 2013 10:13:19 +0000 (19:13 +0900)
CMakeLists.txt
debian/control
include/list.h
packaging/org.tizen.menu-screen.spec
src/all_apps/layout.c
src/list.c
src/page_scroller.c
src/pkgmgr.c

index 4528b3624d4dc030ec7b9da1a7c9645e220d51ea..cb4b565a4cd5a3c8d6ce8659e3a04c398120154a 100644 (file)
@@ -33,6 +33,7 @@ pkg_check_modules(MENU_PKGS REQUIRED
        evas
        heynoti
        pkgmgr
+       pkgmgr-info
        sysman
        syspopup-caller
        utilX
index 1bb0f091dd81790bc036b228699659bf6c43f684..4f38e1fbb1acd81e2ec260c99d84180f7c1d0a19 100644 (file)
@@ -2,14 +2,14 @@ Source: menu-screen
 Section: utils
 Priority: extra
 Maintainer: Jin Yoon <jinny.yoon@samsung.com>
-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
index 7e5465bd5fb83bba67aac3bd30955ddc39ecd4be..d749dc2c14c796c09f191c5ccd27247ff4656d65 100644 (file)
@@ -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;
index ae8891eda4f107636a01d273782fcfa574e0927b..7c6cfb32ffd46fbbb791150a5e76c8fdd9a5e3d9 100644 (file)
@@ -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)
index 386b5f77ab20ca95710ecc8ad558397921a17b81..b5254363d861f6d31f4b016dfa028d6d22a3e488 100644 (file)
@@ -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);
index af4b0547f73e1bdc222b6686f77eef3a8e6d9f8f..2aa41429c2274091d5c607a2d099f05639b3a239 100644 (file)
@@ -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);
 
index 5d611d256ac0a1ce504488467ece45c72a6aad92..37b2e87ee505e62140afaaf7d03fbc7fa4de3d7a 100644 (file)
@@ -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);
index c4182c7b48b041e9c1985b1a28ef02b3cacd4cd0..9b01b2f7db7c8b3064ca704362fc1642493937ab 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <Elementary.h>
 #include <package-manager.h>
+#include <pkgmgr-info.h>
 
 #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);
                        }