[PACKAGE UPLOAD] VERSION 0.0.58
authorEunmi Son <eunmi.son@samsung.com>
Thu, 24 Jan 2013 16:38:14 +0000 (20:38 +0400)
committerEunmi Son <eunmi.son@samsung.com>
Fri, 25 Jan 2013 12:07:28 +0000 (16:07 +0400)
Implement info view ug

Change-Id: Ib75427140439b8e170f5790a0631be7b4ef238e2

packaging/ug-setting-manage-applications-efl.spec
ug/include/mgr-app-view-common.h
ug/include/mgr-app-view-main.h
ug/src/mgr-app-uigadget.c
ug/src/mgr-app-view-app-info.c
ug/src/mgr-app-view-app-list.c
ug/src/mgr-app-view-common.c

index 927d01c..851ff57 100644 (file)
@@ -3,7 +3,7 @@
 
 Name:          ug-setting-manage-applications-efl
 Summary:       Manage Application package
-Version:       0.0.57
+Version:       0.0.58
 Release:       0
 Group:         Applications/System
 License:       Flora Software License
index 0b4dce1..63e0317 100644 (file)
@@ -29,6 +29,6 @@ void mgr_app_doubletap_sensor_set_cb(MGR_APP_DOUBLETAP_SENSOR_CB sensor_cb, void
 void mgr_app_doubletap_sensor_enable();\r
 void mgr_app_doubletap_sensor_disable();\r
 void mgr_app_doubletap_sensor_destroy();\r
-\r
+void mgr_app_set_default_icon(char **icon_path);\r
 \r
 #endif /*__MGR_APP_COMMON_H__*/\r
index d557396..47bb045 100644 (file)
@@ -27,12 +27,8 @@ extern "C" {
 \r
 typedef struct _mgr_app_app_info_t mgr_app_app_info_t;\r
 struct _mgr_app_app_info_t {\r
-//     char    *appid;\r
-//     char    *app_name;\r
        char    *pkg_name;\r
        char    *icon_path;\r
-//     char    *app_type;\r
-//     pkgmgrinfo_app_component component;\r
 \r
        char    *pkg_label;\r
        char    *pkg_type;      \r
@@ -45,7 +41,7 @@ struct _mgr_app_app_info_t {
 \r
 void mgrapp_view_list_create(void *data);\r
 void mgrapp_view_list_update(void *data);\r
-void mgrapp_view_info_create(char *appid, void *data);\r
+void mgrapp_view_info_create(char *pkg_name, void *data);\r
 void mgrapp_view_info_update(void *data);\r
 void mgrapp_view_info_destroy(void *data);\r
 \r
index a47b34a..7131712 100755 (executable)
@@ -28,7 +28,9 @@
 #include "mgr-app-widget.h"
 
 #define STR_VIEWTYPE                           "viewtype"
+#define STR_PKGNAME                                    "pkgname"
 #define STR_MANAGE_APPLICATIONS                "manage-applications"
+#define STR_APPLICATION_INFO           "application-info"
 
 #define EDC_FILE                                       EDJDIR"/ug-setting-manage-applications-efl/ug-setting-manage-applications-efl.edj"
 
@@ -38,6 +40,7 @@ static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, voi
 
        struct ug_data *ugd = NULL;
        char *arg = NULL;
+       char *arg2 = NULL;
        int ret = SERVICE_ERROR_NONE;
 
        retv_if(priv == NULL, NULL);
@@ -122,6 +125,29 @@ static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, voi
 
        if (arg && !strncmp(arg, STR_MANAGE_APPLICATIONS, strlen(STR_MANAGE_APPLICATIONS))) {
                mgrapp_view_list_create((void*)ugd);
+       } else if (arg && !strncmp(arg, STR_APPLICATION_INFO, strlen(STR_APPLICATION_INFO))) {
+               ret = service_get_extra_data(service, STR_PKGNAME, &arg2);
+               switch (ret) {
+               case SERVICE_ERROR_NONE:
+                       MGR_APP_DEBUG("SERVICE_ERROR_NONE. arg: %s", arg2);
+                       break;
+               case SERVICE_ERROR_INVALID_PARAMETER:
+                       MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_PARAMETER");
+                       break;
+               case SERVICE_ERROR_KEY_NOT_FOUND:
+                       MGR_APP_DEBUG_ERR("SERVICE_ERROR_KEY_NOT_FOUND");
+                       break;
+               case SERVICE_ERROR_OUT_OF_MEMORY:
+                       MGR_APP_DEBUG_ERR("SERVICE_ERROR_OUT_OF_MEMORY");
+                       break;
+               case SERVICE_ERROR_INVALID_DATA_TYPE:
+                       MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_DATA_TYPE");
+                       break;
+               default:
+                       MGR_APP_DEBUG_ERR("ret value has an error.");
+                       break;
+               }       
+               mgrapp_view_info_create(arg2, (void*)ugd);
        } else {
                MGR_APP_DEBUG_ERR("argument has an error.");
        }
index 1dd3f8f..5ad05b4 100755 (executable)
@@ -73,6 +73,8 @@
 #define ITC_DETAIL_ITEM_STYLE          "dialogue/1text"
 #define ITC_SEP_ITEM_STYLE                     "dialogue/separator"
 
+#define DEFAULT_ICON_FILE      IMGDIR"/ug-setting-manage-applications-efl/ManageApplications_default.png"
+
 enum {
        ELM_STATE_TOP = 0,
        ELM_STATE_BOTTOM,
@@ -1056,8 +1058,7 @@ static Evas_Object *_create_genlist_app_info(Evas_Object *parent, void *data)
        itc_detail->func.del                    = NULL;
 
        retv_if(ugd->data == NULL, NULL);
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)ugd->data;
-
+       mgr_app_app_info_t *app_info = (mgr_app_app_info_t *)ugd->data;
 
        /* add a genlist */
        genlist = elm_genlist_add(parent);
@@ -1173,69 +1174,151 @@ static void _doubletap_sensor_cb(void *data)
        MGR_APP_END();
 }
 
-static void _get_app_info_from_pkgmgr(char *appid, mgr_app_app_info_t *app_info)
+static void _get_app_info_from_pkgmgr(char *pkg_name, mgr_app_app_info_t *app_info)
 {
        MGR_APP_BEGIN();
 
-       pkgmgr_pkginfo_h handle = NULL;
+       ret_if(NULL == pkg_name);
+       
+       pkgmgrinfo_appinfo_h appinfo_h = NULL;
+       pkgmgrinfo_pkginfo_h pkginfo_h = NULL;
+       char *main_appid = NULL;
+       char *icon_path = NULL; 
+       char *pkg_label = NULL;
        char *pkg_type = NULL;
+       char *data_size = NULL;
+       char *total_size = NULL;
        int r = 0;
 
-       /* info view ug */
-       if (appid) {
-               // TODO
-               
-       /* create by list view */
-       } else {
-               r = pkgmgrinfo_pkginfo_get_pkginfo(app_info->pkg_name, &handle);
-               if (r < 0) {
-                       MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_pkginfo failed. %d", r);
-                       return;
-               } 
-               r = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
+       MGR_APP_DEBUG("pkg_name: %s", pkg_name);
+       MGR_APP_MEM_STRDUP(app_info->pkg_name, pkg_name);
+
+       r = pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &pkginfo_h);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_pkginfo is failed %d", r);
+               goto end;
+       }
+       MGR_APP_DEBUG("pkg_name: %s", pkg_name);
+
+       r = pkgmgrinfo_pkginfo_get_mainappid(pkginfo_h, &main_appid);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_mainappid is failed %d", r);
+               goto end;
+       }
+       MGR_APP_DEBUG("main_appid: %s", main_appid);
+
+       r = pkgmgrinfo_appinfo_get_appinfo(main_appid, &appinfo_h);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_appinfo is failed %d", r);
+               goto end;
+       }
+
+       if (NULL == app_info->icon_path) {
+               r = pkgmgrinfo_appinfo_get_icon(appinfo_h, &icon_path);
                if (r < 0) {
-                       MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_type failed. %d", r);
+                       MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_icon failed. %d", r);
+                       goto end;
+               } else if (icon_path) {
+                       MGR_APP_MEM_STRDUP(app_info->icon_path, icon_path);
+                       mgr_app_set_default_icon(&app_info->icon_path);
                } else {
-                       MGR_APP_MEM_STRDUP(app_info->pkg_type, pkg_type);
+                       MGR_APP_MEM_STRDUP(app_info->icon_path, DEFAULT_ICON_FILE);
                }
-               r = pkgmgrinfo_pkginfo_is_removable(handle, &app_info->removable);
-               if (r < 0) {
-                       MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_is_removable failed. %d", r);
-               } 
-               r = pkgmgrinfo_pkginfo_get_data_size(handle, &app_info->data_size);
+       } 
+       MGR_APP_DEBUG("icon_path: %s", icon_path);
+
+       if (NULL == app_info->pkg_label) {
+               r = pkgmgrinfo_appinfo_get_label(appinfo_h, &pkg_label);
                if (r < 0) {
-                       MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_data_size failed. %d", r);
-               } 
-               r = pkgmgrinfo_pkginfo_get_total_size(handle, &app_info->total_size);
+                       MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_label failed. %d", r);
+                       goto end;
+               } else if (pkg_label) {
+                       MGR_APP_MEM_STRDUP(app_info->pkg_label, pkg_label);
+               } else {
+                       MGR_APP_MEM_STRDUP(app_info->pkg_label, "");
+               }
+       } 
+       MGR_APP_DEBUG("pkg_label: %s", pkg_label);
+
+       if (NULL == app_info->pkg_type) {
+               r = pkgmgrinfo_pkginfo_get_type(pkginfo_h, &pkg_type);
                if (r < 0) {
-                       MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_total_size failed. %d", r);
-               } \r
+                       MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_type failed. %d", r);
+                       goto end;
+               } else if (pkg_type) {
+                       MGR_APP_MEM_STRDUP(app_info->pkg_type, pkg_type);
+               } else {
+                       MGR_APP_MEM_STRDUP(app_info->pkg_label, "");
+               }
+       } 
+       MGR_APP_DEBUG("pkg_type: %s", pkg_type);
+
+       r = pkgmgrinfo_pkginfo_get_data_size(pkginfo_h, &app_info->data_size);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_data_size failed. %d", r);
+               goto end;
+       } 
+       MGR_APP_DEBUG("data_size: %d", data_size);
+       
+       r = pkgmgrinfo_pkginfo_get_total_size(pkginfo_h, &app_info->total_size);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_total_size failed. %d", r);
+               goto end;
+       } 
+       MGR_APP_DEBUG("total_size: %d", total_size);
+
+       r = pkgmgrinfo_pkginfo_is_removable(pkginfo_h, &app_info->removable);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_is_removable failed. %d", r);
+               goto end;
+       } 
+
+       r = pkgmgrinfo_appinfo_is_taskmanage(appinfo_h, &app_info->taskmanage);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_is_taskmanage failed. %d", r);
+               goto end;
+       } 
+
+       r = pkgmgrinfo_appinfo_is_nodisplay(appinfo_h, &app_info->nodisplay);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_is_nodisplay failed. %d", r);
+               goto end;
+       } 
 
+end:
+       if (appinfo_h) {
+               pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
        }
 
-       if (handle) {
-               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       if (pkginfo_h) {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo_h);
        }
        
        MGR_APP_END();
 }
 
 
-void mgrapp_view_info_create(char *appid, void *data)
+void mgrapp_view_info_create(char *pkg_name, void *data)
 {
        MGR_APP_BEGIN();
 
-       ret_if(data == NULL);
+       ret_if(NULL == pkg_name || NULL == data);
        struct ug_data *ugd = (struct ug_data*)data;
-       ret_if(ugd->data == NULL);
        Evas_Object *back_btn = NULL;
 
        mgrapp_set_view_type(VIEW_TYPE_APP_INFO);
-       
-       _app_info = (mgr_app_app_info_t*)ugd->data;
 
-       _get_app_info_from_pkgmgr(appid, _app_info);
+       if (ugd->data) {
+               _app_info = (mgr_app_app_info_t*)ugd->data;
+       } else {
+               _app_info = (mgr_app_app_info_t*)malloc(sizeof(mgr_app_app_info_t));
+               ret_if(_app_info == NULL);
+               memset(_app_info, 0, sizeof(mgr_app_app_info_t));
+               ugd->data = (void*)_app_info;
+       }
 
+       _get_app_info_from_pkgmgr(pkg_name, _app_info);
+       
        _genlist = _create_genlist_app_info(ugd->navi_bar, (void*)ugd);
 
        /* back button */
index e44f34e..7ed6482 100755 (executable)
@@ -35,9 +35,6 @@
 #define RPM_PREFIX                     "rpm"
 
 #define STR_ICON                       "icon"
-#define STR_PNG                                ".png"
-#define STR_EDJ                                ".edj"
-#define DEFAULT_ICON_FILE      IMGDIR"/ug-setting-manage-applications-efl/ManageApplications_default.png"
 
 #define EDC_FILE                       EDJDIR"/ug-setting-manage-applications-efl/ug-setting-manage-applications-efl.edj"
 #define EDC_GROUPS                     "mgr-app-list"
@@ -69,7 +66,6 @@ static Eina_Bool _initialize = false;
 static GList *_installed_list = NULL;
 static int _installed_cnt = 0;
 static int _target_idx = 0;
-static Eina_Bool _is_done = false;
 static Elm_Object_Item *_tabbar_item[VIEW_TYPE_MAX] = {NULL,};
 static Elm_Object_Item *_navi_it = NULL;
 
@@ -95,11 +91,8 @@ static void _free_resources(struct ug_data * ugd)
                }
                MGR_APP_MEM_FREE(app_info->pkg_label);
                MGR_APP_MEM_FREE(app_info->pkg_name);
-               //MGR_APP_MEM_FREE(app_info->app_name);
-               //MGR_APP_MEM_FREE(app_info->app_type);
                MGR_APP_MEM_FREE(app_info->pkg_type);
                MGR_APP_MEM_FREE(app_info->icon_path);
-               //MGR_APP_MEM_FREE(app_info->appid);
                _installed_list = g_list_remove(_installed_list, app_info);
        }
 
@@ -147,11 +140,8 @@ static void _gl_del(void *data, Evas_Object *obj)
        // TODO
        MGR_APP_MEM_FREE(app_info->pkg_name);
        MGR_APP_MEM_FREE(app_info->pkg_label);
-//     MGR_APP_MEM_FREE(app_info->app_name);
-//     MGR_APP_MEM_FREE(app_info->app_type);
        MGR_APP_MEM_FREE(app_info->pkg_type);
        MGR_APP_MEM_FREE(app_info->icon_path);
-       //MGR_APP_MEM_FREE(app_info->appid);
        //MGR_APP_MEM_FREE(app_info);
 #endif
 
@@ -176,7 +166,7 @@ static void _gl_sel(void *data, Evas_Object *obj, void *event_info)
 
        /* create app info view */
        ugd->data = (void*)app_info;
-       mgrapp_view_info_create(NULL, (void*)ugd);
+       mgrapp_view_info_create(app_info->pkg_name, (void*)ugd);
 
        MGR_APP_END();
 }
@@ -190,10 +180,8 @@ static char *_gl_label_get(void *data, Evas_Object *obj, const char *part)
 
        char *label             = NULL;
        char *package_label = app_info->pkg_label;
-//     char *app_name  = app_info->app_name;
        char *icon_path         = app_info->icon_path;
 
-//     MGR_APP_DEBUG("package_name:[%s], app_name:[%s], icon_path:[%s]\n", package_name, app_name, icon_path);
        MGR_APP_DEBUG("package_label:[%s], icon_path:[%s]\n", package_label, icon_path);
        MGR_APP_DEBUG("part:%s\n", part);
 
@@ -294,195 +282,64 @@ static gint _app_list_qsort_cb(gconstpointer a, gconstpointer b)
        return r;
 }
 
-static void _set_default_icon(char **icon_path)
-{
-       MGR_APP_BEGIN();
-
-       FILE *stream = NULL;
-       char *p = NULL;
-       
-       if (*icon_path) {
-               /* TODO - avoid the slow-down change effect due to edj icon */
-               if (((p = strrchr(*icon_path, '.'))) && (!strcasecmp(p, ".edj"))) {
-                       MGR_APP_MEM_FREE(*icon_path);
-                       MGR_APP_MEM_STRDUP(*icon_path, DEFAULT_ICON_FILE);
-               } else if ((stream = fopen(*icon_path, "r")) != NULL && strlen(*icon_path) > strlen(STR_PNG)) {
-                       fclose(stream);
-                       stream = NULL;
-
-                       char *p_extension = NULL;
-                       p_extension = *icon_path + (strlen(*icon_path) - strlen(STR_PNG));
-
-                       /* default icon : icon_path's extension is wrong */
-                       if (strncmp(p_extension, STR_PNG, strlen(STR_PNG)) != 0 && strncmp(p_extension, STR_EDJ, strlen(STR_EDJ)) != 0) {
-                               MGR_APP_MEM_FREE(*icon_path);
-                               MGR_APP_MEM_STRDUP(*icon_path, DEFAULT_ICON_FILE);
-                       }
-               /* default icon : icon_path isn't exist */
-               } else {
-                       MGR_APP_MEM_FREE(*icon_path);
-                       MGR_APP_MEM_STRDUP(*icon_path, DEFAULT_ICON_FILE);
-                       if (stream) {
-                               fclose(stream);
-                               stream = NULL;
-                       }
-               }
-       /* default icon : icon_path == NULL */
-       } else {
-               MGR_APP_MEM_FREE(*icon_path);
-               MGR_APP_MEM_STRDUP(*icon_path, DEFAULT_ICON_FILE);
-       }
-       
-       MGR_APP_END();
-}
-
-static void _get_appinfo_from_pkgmgr(const pkgmgrinfo_appinfo_h handler, mgr_app_app_info_t *app_info)
+static void _get_appinfo_from_pkgmgr(const pkgmgrinfo_pkginfo_h handler, mgr_app_app_info_t *app_info)
 {
        MGR_APP_BEGIN();
 
        ret_if(NULL == handler || NULL == app_info);
 
        int r = 0;
-       //char *app_name = NULL;
        char *pkg_name = NULL;
-       //char *appid = NULL;
        char *icon_path = NULL;
-       //char *app_type = NULL;
-       bool nodisplay = false;
-       bool taskmanage = false;
-       //pkgmgrinfo_app_component component;
+       char *main_appid = NULL;
+       char *pkg_label = NULL;
+       pkgmgrinfo_appinfo_h appinfo_h = NULL;
 
-#if 0
-       r = pkgmgrinfo_appinfo_get_label(handler, &app_name);
-       if (PMINFO_R_OK == r) {
-               MGR_APP_MEM_STRDUP(app_info->app_name, app_name);
-               MGR_APP_DEBUG("app_name: %s", app_info->app_name);
-       } else {
-               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_label failed");
-       }
-       r = pkgmgrinfo_appinfo_get_appid(handler, &appid);
-       if (PMINFO_R_OK == r) {
-               MGR_APP_MEM_STRDUP(app_info->appid, appid);
-               MGR_APP_DEBUG("appid: %s", app_info->appid);
-       } else {
-               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_appid failed");
-       }
-       r = pkgmgrinfo_appinfo_get_component(handler, &component);
-       if (PMINFO_R_OK == r) {
-               app_info->component = component;
-               MGR_APP_DEBUG("component: %d", app_info->component);
-       } else {
-               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_component failed");
-       }
-       r = pkgmgrinfo_appinfo_get_apptype(handler, &app_type);
-       if (PMINFO_R_OK == r) {
-               MGR_APP_MEM_STRDUP(app_info->app_type, app_type);
-               MGR_APP_DEBUG("app_type: %s", app_info->app_type);
-       } else {
-               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_apptype failed");
-       }
-#endif
-       r = pkgmgrinfo_appinfo_get_icon(handler, &icon_path);
-       if (PMINFO_R_OK == r) {
-               MGR_APP_MEM_STRDUP(app_info->icon_path, icon_path);
-               _set_default_icon(&app_info->icon_path);
-               MGR_APP_DEBUG("icon_path: %s", app_info->icon_path);
-       } else {
-               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_icon failed");
-       }
-       r = pkgmgrinfo_appinfo_is_nodisplay(handler, &nodisplay);
-       if (PMINFO_R_OK == r) {
-               app_info->nodisplay = nodisplay;
-               MGR_APP_DEBUG("nodisplay: %d", app_info->nodisplay);
-       } else {
-               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_is_nodisplay failed");
-       }       
-       r = pkgmgrinfo_appinfo_is_taskmanage(handler, &taskmanage);
-       if (PMINFO_R_OK == r) {
-               app_info->taskmanage = taskmanage;
-               MGR_APP_DEBUG("taskmanage: %d", app_info->taskmanage);
-       } else {
-               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_is_taskmanage failed");
-       }
-       r = pkgmgrinfo_appinfo_get_pkgname(handler, &pkg_name);
-       if (PMINFO_R_OK == r) {
-               MGR_APP_MEM_STRDUP(app_info->pkg_name, pkg_name);
-               MGR_APP_DEBUG("pkg_name: %s", app_info->pkg_name);
-       } else {
-               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_pkgname failed");
+       r = pkgmgrinfo_pkginfo_get_pkgid(handler, &pkg_name);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_pkgid is failed %d", r);
+               goto end;
        }
+       MGR_APP_MEM_STRDUP(app_info->pkg_name, pkg_name);
+       MGR_APP_DEBUG("pkg_name: %s", pkg_name);
 
-       MGR_APP_END();
-}
-
-/*
- * @return 0 if success, negative value(<0) if fail. Callback is not called if return value is negative.
- */
-static int _app_list_cb(const pkgmgrinfo_appinfo_h handler, void *user_data)
-{
-       MGR_APP_BEGIN();
-
-       retv_if(NULL == handler || NULL == user_data, -1);
+       /* get label/icon from mainapp */
+       r = pkgmgrinfo_pkginfo_get_mainappid(handler, &main_appid);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_pkginfo_get_mainappid is failed %d", r);
+               goto end;
+       }
+       MGR_APP_DEBUG("main_appid: %s", main_appid);
 
-       mgr_app_app_info_t *app_info = NULL;
-       char *pkg_label = NULL;
-       
-       if (EINA_TRUE == _is_done) {
-               MGR_APP_DEBUG("app info is already loaded");
-               return -1;
+       r = pkgmgrinfo_appinfo_get_appinfo(main_appid, &appinfo_h);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_appinfo is failed %d", r);
+               goto end;
        }
 
-       app_info = (mgr_app_app_info_t*)malloc(sizeof(mgr_app_app_info_t));
-       retv_if(app_info == NULL, -1);
-       memset(app_info, 0, sizeof(mgr_app_app_info_t));
+       r = pkgmgrinfo_appinfo_get_icon(appinfo_h, &icon_path);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_icon is failed %d", r);
+               goto end;
+       }
+       MGR_APP_MEM_STRDUP(app_info->icon_path, icon_path);
+       mgr_app_set_default_icon(&app_info->icon_path);
+       MGR_APP_DEBUG("icon_path: %s", icon_path);
 
-       pkg_label = (char*)user_data;
+       r = pkgmgrinfo_appinfo_get_label(appinfo_h, &pkg_label);
+       if (r < 0) {
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_label is failed %d", r);
+               goto end;
+       }
        MGR_APP_MEM_STRDUP(app_info->pkg_label, pkg_label);
+       MGR_APP_DEBUG("pkg_label: %s", pkg_label);
 
-       _get_appinfo_from_pkgmgr(handler, app_info);
-
-       _installed_list = g_list_append(_installed_list, (gpointer)app_info);
-       _installed_cnt++;
-       _is_done = EINA_TRUE;
-       
-       MGR_APP_DEBUG("installed cnt %d", _installed_cnt);
-       \r       
-       MGR_APP_END();
-       return 0;
-}
-
-/*
- * @return 0 if success, negative value(<0) if fail. Callback is not called if return value is negative.
- */
-static int _app_list_install_cb(const pkgmgrinfo_appinfo_h handler, void *user_data)
-{
-       MGR_APP_BEGIN();
-
-       retv_if(NULL == handler, 0);
-
-       if (EINA_TRUE == _is_done) {
-               MGR_APP_DEBUG("app info is already loaded");
-               return;
+end:
+       if (appinfo_h) {
+               pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
        }
 
-       mgr_app_app_info_t *app_info = (mgr_app_app_info_t*)malloc(sizeof(mgr_app_app_info_t));
-       retv_if(app_info == NULL, 0);
-       memset(app_info, 0, sizeof(mgr_app_app_info_t));
-
-       int r = 0;
-       
-       _get_appinfo_from_pkgmgr(handler, app_info);
-       
-       _target_idx = 1; // 0: genlist separator item
-       _installed_list = g_list_insert_sorted(_installed_list, (gpointer)app_info, _app_list_qsort_cb);
-       _installed_cnt++;
-
-       _is_done = EINA_TRUE;
-
-       _insert_to_app_list(app_info, user_data);
-       
        MGR_APP_END();
-       return 0;
 }
 
 static void _insert_to_app_list(mgr_app_app_info_t *app_info_new, void *user_data)
@@ -680,6 +537,7 @@ static void mgrapp_view_list_update_by_install(const char *pkg_type, const char
        
        struct ug_data *ugd = (struct ug_data*)data;
        pkgmgr_pkginfo_h pkg_handle = NULL;
+       mgr_app_app_info_t *app_info = NULL;
        int r = 0;
 
        _initialize = EINA_FALSE;
@@ -687,16 +545,28 @@ static void mgrapp_view_list_update_by_install(const char *pkg_type, const char
        r = pkgmgr_pkginfo_get_pkginfo(pkg_name, &pkg_handle);
        if (r < 0) {
                MGR_APP_DEBUG_ERR("pkgmgr_pkginfo_get_pkginfo is failed. %d", r);
-               return;
+               goto end;
        }
-       r = pkgmgr_appinfo_get_list(pkg_handle, PM_ALL_APP, _app_list_install_cb, (void*)ugd);
-       if (r < 0) {
-               MGR_APP_DEBUG_ERR("pkgmgr_pkginfo_get_pkginfo is failed. %d", r);
-               return;
-       }       
 
-       // free pkginfo handler
+       app_info = (mgr_app_app_info_t*)malloc(sizeof(mgr_app_app_info_t));
+       if (NULL == app_info) {
+               goto end;
+       }
+       memset(app_info, 0, sizeof(mgr_app_app_info_t));
+
+       _get_appinfo_from_pkgmgr(pkg_handle, app_info);
        
+       _target_idx = 1; // 0: genlist separator item
+       _installed_list = g_list_insert_sorted(_installed_list, (gpointer)app_info, _app_list_qsort_cb);
+       _installed_cnt++;
+
+       _insert_to_app_list(app_info, (void*)ugd);
+
+end:
+       if (pkg_handle) {
+               pkgmgr_pkginfo_destroy_pkginfo(pkg_handle);
+       }
+
        MGR_APP_END();
 }
 
@@ -1010,31 +880,24 @@ static void _gl_realized(void *data, Evas_Object *obj, void *event_info)
        MGR_APP_END();
 }
 
-//static int _pkgmgr_iter_fn(const char* pkg_type, const char* pkgid,  const char* version, void *data)
 static int _pkgmgr_iter_fn(pkgmgr_pkginfo_h handle, void *data)
 {
        MGR_APP_BEGIN();
 
        retv_if(NULL == handle, 0);
 
-       char *pkg_label = NULL;
-       int r = 0;
-       
-       r = pkgmgrinfo_pkginfo_get_label(handle, &pkg_label);
-       if (r < 0) {
-               MGR_APP_DEBUG_ERR("pkgmgr_appinfo_get_list is failed %d", r);
-               return 0;
-       }
-       MGR_APP_DEBUG("pkg_label: %s", pkg_label);
-       
-       _is_done = EINA_FALSE;
+       mgr_app_app_info_t *app_info = NULL;
 
-       r = pkgmgr_appinfo_get_list(handle, PM_ALL_APP, _app_list_cb, pkg_label);
-       if (r < 0) {
-               MGR_APP_DEBUG_ERR("pkgmgr_appinfo_get_list is failed %d", r);
-               return 0;
-       }
+       app_info = (mgr_app_app_info_t*)malloc(sizeof(mgr_app_app_info_t));
+       retv_if(app_info == NULL, -1);
+       memset(app_info, 0, sizeof(mgr_app_app_info_t));
        
+       _get_appinfo_from_pkgmgr(handle, app_info);
+
+       _installed_list = g_list_append(_installed_list, (gpointer)app_info);
+       _installed_cnt++;
+       MGR_APP_DEBUG("installed cnt %d", _installed_cnt);
+
        MGR_APP_END();
        return 0;
 }
@@ -1239,14 +1102,7 @@ void mgrapp_view_list_create(void *data)
 
        _navi_it = navi_it = elm_naviframe_item_push(ugd->navi_bar, MGRAPP_STR_MANAGE_APPLICATIONS, back_btn, NULL, nocontents, "tabbar");
 
-#if 0
-       //r = pkgmgrinfo_appinfo_get_installed_list(_app_list_cb, NULL);
-       //if (PKGMGR_R_OK != r) {
-       //      MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_installed_list failed. %d", r);
-       //}
-#endif
        r = pkgmgr_pkginfo_get_list(_pkgmgr_iter_fn, data);
-       //r = pkgmgr_get_pkg_list(_pkgmgr_iter_fn, data); // deprecated api ??
        if (PKGMGR_R_OK != r) {
                MGR_APP_DEBUG_ERR("pkgmgr_get_pkg_list failed. %d", r);
        }
index 2ad17c7..da2f873 100644 (file)
 \r
 #include "mgr-app-view-common.h"\r
 #include "mgr-app-common-debug.h"\r
+#include "mgr-app-common-util.h"\r
 \r
 #include <sensors.h>\r
 \r
+#define DEFAULT_ICON_FILE      IMGDIR"/ug-setting-manage-applications-efl/ManageApplications_default.png"\r
+#define STR_PNG                                ".png"\r
+#define STR_EDJ                                ".edj"\r
+\r
 static sensor_h _dt_handle = NULL;\r
 static bool _is_sensor_enabled = false;\r
 static MGR_APP_DOUBLETAP_SENSOR_CB _sensor_cb = NULL;\r
@@ -124,3 +129,45 @@ void mgr_app_doubletap_sensor_destroy()
        MGR_APP_END();\r
 }\r
 \r
+void mgr_app_set_default_icon(char **icon_path)\r
+{\r
+       MGR_APP_BEGIN();\r
+\r
+       FILE *stream = NULL;\r
+       char *p = NULL;\r
+       \r
+       if (*icon_path) {\r
+               /* TODO - avoid the slow-down change effect due to edj icon */\r
+               if (((p = strrchr(*icon_path, '.'))) && (!strcasecmp(p, ".edj"))) {\r
+                       MGR_APP_MEM_FREE(*icon_path);\r
+                       MGR_APP_MEM_STRDUP(*icon_path, DEFAULT_ICON_FILE);\r
+               } else if ((stream = fopen(*icon_path, "r")) != NULL && strlen(*icon_path) > strlen(STR_PNG)) {\r
+                       fclose(stream);\r
+                       stream = NULL;\r
+\r
+                       char *p_extension = NULL;\r
+                       p_extension = *icon_path + (strlen(*icon_path) - strlen(STR_PNG));\r
+\r
+                       /* default icon : icon_path's extension is wrong */\r
+                       if (strncmp(p_extension, STR_PNG, strlen(STR_PNG)) != 0 && strncmp(p_extension, STR_EDJ, strlen(STR_EDJ)) != 0) {\r
+                               MGR_APP_MEM_FREE(*icon_path);\r
+                               MGR_APP_MEM_STRDUP(*icon_path, DEFAULT_ICON_FILE);\r
+                       }\r
+               /* default icon : icon_path isn't exist */\r
+               } else {\r
+                       MGR_APP_MEM_FREE(*icon_path);\r
+                       MGR_APP_MEM_STRDUP(*icon_path, DEFAULT_ICON_FILE);\r
+                       if (stream) {\r
+                               fclose(stream);\r
+                               stream = NULL;\r
+                       }\r
+               }\r
+       /* default icon : icon_path == NULL */\r
+       } else {\r
+               MGR_APP_MEM_FREE(*icon_path);\r
+               MGR_APP_MEM_STRDUP(*icon_path, DEFAULT_ICON_FILE);\r
+       }\r
+       \r
+       MGR_APP_END();\r
+}\r
+\r