From d1fbc2908592eb3c7fbc0d4cd0c0d96e2b9caf2f Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Wed, 13 May 2015 13:12:54 +0900 Subject: [PATCH] Get the icon of main uiapp if it fails to get it from widget info Change-Id: I135eb046b641b7a9b1d7053f44909fc2dc0a4fda Signed-off-by: Sung-jae Park --- packaging/libwidget_viewer.spec | 1 + widget_viewer_evas/CMakeLists.txt | 1 + widget_viewer_evas/src/widget_viewer_evas.c | 44 +++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/packaging/libwidget_viewer.spec b/packaging/libwidget_viewer.spec index 23631ad..e7b6102 100644 --- a/packaging/libwidget_viewer.spec +++ b/packaging/libwidget_viewer.spec @@ -19,6 +19,7 @@ BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(widget_service) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(pkgmgr-info) %if %{with wayland} %else diff --git a/widget_viewer_evas/CMakeLists.txt b/widget_viewer_evas/CMakeLists.txt index 3d6c743..254c5d1 100644 --- a/widget_viewer_evas/CMakeLists.txt +++ b/widget_viewer_evas/CMakeLists.txt @@ -16,6 +16,7 @@ pkg_check_modules(viewer_evas REQUIRED dlog widget_service elementary + pkgmgr-info ) SET(BUILD_SOURCE diff --git a/widget_viewer_evas/src/widget_viewer_evas.c b/widget_viewer_evas/src/widget_viewer_evas.c index c7390a5..df98468 100644 --- a/widget_viewer_evas/src/widget_viewer_evas.c +++ b/widget_viewer_evas/src/widget_viewer_evas.c @@ -27,6 +27,8 @@ #include #include +#include + #include #include #include @@ -2858,6 +2860,7 @@ static void __widget_move_cb(void *cbdata, Evas *e, Evas_Object *obj, void *even static char *get_package_icon(struct widget_data *data) { char *icon; + char *uiapp; if (data->size_type == WIDGET_SIZE_TYPE_UNKNOWN) { icon = widget_service_get_icon(data->widget_id, NULL); @@ -2872,11 +2875,48 @@ static char *get_package_icon(struct widget_data *data) if (icon) { ErrPrint("Failed to access an icon file: [%s]\n", icon); free(icon); + icon = NULL; + } + + uiapp = widget_service_get_main_app_id(data->widget_id); + if (uiapp) { + int ret; + pkgmgrinfo_appinfo_h appinfo_h; + + ret = pkgmgrinfo_appinfo_get_appinfo(uiapp, &appinfo_h); + free(uiapp); + + if (ret < 0) { + /** + * 'Icon' will be remained as NULL + */ + } else { + char *uiapp_icon = NULL; + + ret = pkgmgrinfo_appinfo_get_icon(appinfo_h, &uiapp_icon); + if (ret == PMINFO_R_OK && uiapp_icon && access(uiapp_icon, R_OK) == 0) { + DbgPrint("UI-App icon: [%s]\n", uiapp_icon); + icon = strdup(uiapp_icon); + if (!icon) { + ErrPrint("Heap: %d\n", strerror(errno)); + /** + * @note + * 'Icon' will be specified to "unknown" icon file (Default) + */ + } + } else { + ErrPrint("[%s] - %d\n", uiapp_icon, errno); + } + + pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h); + } } - icon = strdup(WIDGET_VIEWER_EVAS_UNKNOWN); if (!icon) { - ErrPrint("strdup: %d\n", errno); + icon = strdup(WIDGET_VIEWER_EVAS_UNKNOWN); + if (!icon) { + ErrPrint("strdup: %d\n", errno); + } } return icon; -- 2.7.4