Get the icon of main uiapp if it fails to get it from widget info
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 13 May 2015 04:12:54 +0000 (13:12 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 13 May 2015 04:13:48 +0000 (13:13 +0900)
Change-Id: I135eb046b641b7a9b1d7053f44909fc2dc0a4fda
Signed-off-by: Sung-jae Park <nicesj.park@samsung.com>
packaging/libwidget_viewer.spec
widget_viewer_evas/CMakeLists.txt
widget_viewer_evas/src/widget_viewer_evas.c

index 23631ad3b916322c8a40b3288605a42ba62a48fa..e7b610254a9cc8303027bd55677e25f09cb29310 100644 (file)
@@ -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
index 3d6c7431f51e43e78fe7f536c260f2fc01efe031..254c5d133abbf94af1732d967b05b57e09d52fec 100644 (file)
@@ -16,6 +16,7 @@ pkg_check_modules(viewer_evas REQUIRED
        dlog
        widget_service
        elementary
+       pkgmgr-info
 )
 
 SET(BUILD_SOURCE
index c7390a55f3f0e021590aff7e4c43e28256482083..df984687809d9d7fe3c098f0ac5f66581c93f43e 100644 (file)
@@ -27,6 +27,8 @@
 #include <Evas.h>
 #include <Edje.h>
 
+#include <pkgmgr-info.h>
+
 #include <widget_errno.h>
 #include <widget_viewer.h>
 #include <widget_viewer_internal.h>
@@ -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;