[PACKAGE UPLOAD] VERSION 0.0.55
authorEunmi Son <eunmi.son@samsung.com>
Tue, 22 Jan 2013 18:52:39 +0000 (22:52 +0400)
committerEunmi Son <eunmi.son@samsung.com>
Tue, 22 Jan 2013 18:52:39 +0000 (22:52 +0400)
Fix the duplicated app name issue

Change-Id: I6aea3f029664efa292b8be04f63a340ef70d9f88

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

index 626c258..0841090 100644 (file)
@@ -3,7 +3,7 @@
 
 Name:          ug-setting-manage-applications-efl
 Summary:       Manage Application package
-Version:       0.0.54
+Version:       0.0.55
 Release:       0
 Group:         Applications/System
 License:       Flora Software License
index 466aba8..d557396 100644 (file)
@@ -28,12 +28,13 @@ extern "C" {
 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    *app_name;\r
        char    *pkg_name;\r
        char    *icon_path;\r
-       char    *app_type;\r
-       pkgmgrinfo_app_component component;\r
+//     char    *app_type;\r
+//     pkgmgrinfo_app_component component;\r
 \r
+       char    *pkg_label;\r
        char    *pkg_type;      \r
        int     total_size;\r
        int             data_size;\r
index 4393816..1dd3f8f 100755 (executable)
@@ -341,7 +341,7 @@ static void _uninstall_clicked_cb(void *data, Evas_Object *obj, void *event_info
        evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        snprintf(buf, sizeof(buf), "%s?", MGRAPP_STR_UNINSTALL);
        elm_object_text_set(popup, buf);
-       elm_object_part_text_set(popup, "title,text", _app_info->app_name);
+       elm_object_part_text_set(popup, "title,text", _app_info->pkg_label);
 
        btn_yes = elm_button_add(popup);
        ret_if(btn_yes == NULL);
@@ -639,18 +639,21 @@ static char *_gl_label_get(void *data, Evas_Object *obj, const char *part)
        char *label = NULL;
 
        char *package_name      = app_info->pkg_name;
-       char *app_name  = app_info->app_name;
+       char *package_label     = app_info->pkg_label;
+       //char *app_name        = app_info->app_name;
        char *icon_path         = app_info->icon_path;
        char *pkg_type          = app_info->pkg_type;
 
-       MGR_APP_DEBUG("package_name:[%s], app_name:[%s], x_slp_packagetype:[%s], icon_path:[%s]\n", package_name, app_name, pkg_type, icon_path);
+//     MGR_APP_DEBUG("package_name:[%s], app_name:[%s], x_slp_packagetype:[%s], icon_path:[%s]\n", package_name, app_name, pkg_type, icon_path);
+       MGR_APP_DEBUG("package_label:[%s], x_slp_packagetype:[%s], icon_path:[%s]\n", package_label, pkg_type, icon_path);
+
        MGR_APP_DEBUG("part:%s\n", part);
-       retv_if(app_name == NULL, NULL);
+       retv_if(package_label == NULL, NULL);
 
        /* label for 'elm.text' part */
        if (0 == strcmp(part, ELM_TEXT_1)) {
-               if (package_name) {
-                       MGR_APP_MEM_STRDUP(label, app_name);
+               if (package_label) {
+                       MGR_APP_MEM_STRDUP(label, package_label);
                }
        } else if (0 == strcmp(part, ELM_TEXT_2)) {
                label = _get_formated_size((float)app_info->total_size);
index a6b544a..40340e4 100755 (executable)
@@ -67,6 +67,7 @@ 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_Genlist_Item_Class *itc = NULL;
 static Elm_Genlist_Item_Class *itc_sep = NULL;
@@ -123,8 +124,9 @@ static void _gl_del(void *data, Evas_Object *obj)
 
        // TODO
        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_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);
@@ -163,16 +165,17 @@ static char *_gl_label_get(void *data, Evas_Object *obj, const char *part)
        mgr_app_app_info_t *app_info = (mgr_app_app_info_t *)data;
 
        char *label             = NULL;
-       char *package_name = app_info->pkg_name;
-       char *app_name  = app_info->app_name;
+       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_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);
 
        /* label for 'elm.text' part */
-       if (app_name && 0 == strcmp(part, ELM_TEXT)) {
-               MGR_APP_MEM_STRDUP(label, app_name);
+       if (package_label && 0 == strcmp(part, ELM_TEXT)) {
+               MGR_APP_MEM_STRDUP(label, package_label);
        } else {
                MGR_APP_MEM_STRDUP(label, MGRAPP_STR_ERROR);
        }
@@ -244,21 +247,21 @@ static gint _app_list_qsort_cb(gconstpointer a, gconstpointer b)
 
        mgr_app_app_info_t *app_info1 = (mgr_app_app_info_t *)a;
        mgr_app_app_info_t *app_info2 = (mgr_app_app_info_t *)b;
-       char *app_name1 = NULL;
-       char *app_name2 = NULL;
+       char *pkg_label1 = NULL;
+       char *pkg_label2 = NULL;
        int len = 0;
        int r = 0;
 
-       app_name1 = app_info1->app_name;
-       app_name2 = app_info2->app_name;
-       retv_if(NULL == app_name1, 0);
-       retv_if(NULL == app_name2, 0);
+       pkg_label1 = app_info1->pkg_label;
+       pkg_label2 = app_info2->pkg_label;
+       retv_if(NULL == pkg_label1, 0);
+       retv_if(NULL == pkg_label2, 0);
 
-       MGR_APP_DEBUG("app_name1: %s", app_name1);
-       MGR_APP_DEBUG("app_name2: %s", app_name2);
+       MGR_APP_DEBUG("pkg_label1: %s", pkg_label1);
+       MGR_APP_DEBUG("pkg_label2: %s", pkg_label2);
        
-       len = (strlen(app_name1) >= strlen(app_name2)) ? strlen(app_name1) : strlen(app_name2);
-       r = strncasecmp(app_name1, app_name2, len);
+       len = (strlen(pkg_label1) >= strlen(pkg_label2)) ? strlen(pkg_label1) : strlen(pkg_label2);
+       r = strncasecmp(pkg_label1, pkg_label2, len);
        if (r >= 0) {
                _target_idx++;
        }
@@ -316,15 +319,16 @@ static void _get_appinfo_from_pkgmgr(const pkgmgrinfo_appinfo_h handler, mgr_app
        ret_if(NULL == handler || NULL == app_info);
 
        int r = 0;
-       char *app_name = NULL;
+       //char *app_name = NULL;
        char *pkg_name = NULL;
        //char *appid = NULL;
        char *icon_path = NULL;
-       char *app_type = NULL;
+       //char *app_type = NULL;
        bool nodisplay = false;
        bool taskmanage = false;
-       pkgmgrinfo_app_component component;
-       
+       //pkgmgrinfo_app_component component;
+
+#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);
@@ -332,27 +336,12 @@ static void _get_appinfo_from_pkgmgr(const pkgmgrinfo_appinfo_h handler, mgr_app
        } else {
                MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_label failed");
        }
-       r = pkgmgrinfo_appinfo_get_pkgname(handler, &pkg_name);
+       r = pkgmgrinfo_appinfo_get_appid(handler, &appid);
        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);
+               MGR_APP_MEM_STRDUP(app_info->appid, appid);
+               MGR_APP_DEBUG("appid: %s", app_info->appid);
        } else {
-               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_pkgname 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_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");
+               MGR_APP_DEBUG_ERR("pkgmgrinfo_appinfo_get_appid failed");
        }
        r = pkgmgrinfo_appinfo_get_component(handler, &component);
        if (PMINFO_R_OK == r) {
@@ -367,7 +356,16 @@ static void _get_appinfo_from_pkgmgr(const pkgmgrinfo_appinfo_h handler, mgr_app
                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;
@@ -382,7 +380,14 @@ static void _get_appinfo_from_pkgmgr(const pkgmgrinfo_appinfo_h handler, mgr_app
        } 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");
+       }
+
        MGR_APP_END();
 }
 
@@ -393,16 +398,29 @@ static int _app_list_cb(const pkgmgrinfo_appinfo_h handler, void *user_data)
 {
        MGR_APP_BEGIN();
 
-       retv_if(NULL == handler, 0);
+       retv_if(NULL == handler || NULL == user_data, -1);
 
-       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);
+       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;
+       }
+
+       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));
 
+       pkg_label = (char*)user_data;
+       MGR_APP_MEM_STRDUP(app_info->pkg_label, 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();
@@ -418,6 +436,11 @@ static int _app_list_install_cb(const pkgmgrinfo_appinfo_h handler, void *user_d
 
        retv_if(NULL == handler, 0);
 
+       if (EINA_TRUE == _is_done) {
+               MGR_APP_DEBUG("app info is already loaded");
+               return;
+       }
+
        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));
@@ -430,6 +453,8 @@ static int _app_list_install_cb(const pkgmgrinfo_appinfo_h handler, void *user_d
        _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();
@@ -464,12 +489,12 @@ static void _insert_to_app_list(mgr_app_app_info_t *app_info_new, void *user_dat
                ret_if(NULL == new_item);
        }
 
-       if (NULL == app_info_new->app_name) {
-               MGR_APP_DEBUG_ERR("app_name_new is null");
+       if (NULL == app_info_new->pkg_label) {
+               MGR_APP_DEBUG_ERR("pkg_name_new is null");
                goto end;
        }
 
-       letter_new = _convert_char_to_string(app_info_new->app_name[0]);
+       letter_new = _convert_char_to_string(app_info_new->pkg_label[0]);
        if (NULL == letter_new) {
                MGR_APP_DEBUG_ERR("letter_new is null");
                goto end;
@@ -487,12 +512,12 @@ static void _insert_to_app_list(mgr_app_app_info_t *app_info_new, void *user_dat
                next_info = (mgr_app_app_info_t *)elm_object_item_data_get(next_item);
                ret_if(NULL == next_info);      
 
-               if (NULL == next_info->app_name) {
-                       MGR_APP_DEBUG_ERR("app_name is null");
+               if (NULL == next_info->pkg_label) {
+                       MGR_APP_DEBUG_ERR("pkg_label is null");
                        goto end;
                }
 
-               letter = _convert_char_to_string(next_info->app_name[0]);
+               letter = _convert_char_to_string(next_info->pkg_label[0]);
                if (NULL == letter) {
                        MGR_APP_DEBUG_ERR("letter is null");
                        goto end;
@@ -523,21 +548,21 @@ static void _insert_to_app_list(mgr_app_app_info_t *app_info_new, void *user_dat
                next_info = (mgr_app_app_info_t *)elm_object_item_data_get(next_item);
                ret_if(NULL == next_info);
 
-               if (NULL == prev_info->app_name) {
-                       MGR_APP_DEBUG_ERR("prev_info->app_name is null");
+               if (NULL == prev_info->pkg_label) {
+                       MGR_APP_DEBUG_ERR("prev_info->pkg_label is null");
                        goto end;
                }       
-               if (NULL == next_info->app_name) {
-                       MGR_APP_DEBUG_ERR("next_info->app_name is null");
+               if (NULL == next_info->pkg_label) {
+                       MGR_APP_DEBUG_ERR("next_info->pkg_label is null");
                        goto end;
                }       
 
-               letter = _convert_char_to_string(prev_info->app_name[0]);
+               letter = _convert_char_to_string(prev_info->pkg_label[0]);
                if (NULL == letter) {
                        MGR_APP_DEBUG_ERR("letter is null");
                        goto end;
                }
-               letter2 = _convert_char_to_string(next_info->app_name[0]);
+               letter2 = _convert_char_to_string(next_info->pkg_label[0]);
                if (NULL == letter2) {
                        MGR_APP_DEBUG_ERR("letter2 is null");
                        goto end;
@@ -573,12 +598,12 @@ static void _insert_to_app_list(mgr_app_app_info_t *app_info_new, void *user_dat
                prev_info = (mgr_app_app_info_t *)elm_object_item_data_get(prev_item);
                ret_if(NULL == prev_info);      
 
-               if (NULL == next_info->app_name) {
-                       MGR_APP_DEBUG_ERR("app_name is null");
+               if (NULL == next_info->pkg_label) {
+                       MGR_APP_DEBUG_ERR("pkg_label is null");
                        goto end;
                }
 
-               letter = _convert_char_to_string(next_info->app_name[0]);
+               letter = _convert_char_to_string(next_info->pkg_label[0]);
                if (NULL == letter) {
                        MGR_APP_DEBUG_ERR("letter is null");
                        goto end;
@@ -817,7 +842,7 @@ static int _compare_data_index_item_letter_cb(const void *a, const void *b)
        retv_if(app_info1 == NULL, -1);
        retv_if(app_info2 == NULL, -1);
 
-       MGR_APP_DEBUG("letter1: %s, letter2: %s", app_info1->app_name, app_info2->app_name);
+       MGR_APP_DEBUG("letter1: %s, letter2: %s", app_info1->pkg_label, app_info2->pkg_label);
 
        MGR_APP_END();
        return 0;
@@ -891,7 +916,7 @@ static void _index_del_item_cb(void *data, Evas_Object *obj, void *event_info)
                index_item = (Elm_Object_Item*)event_info;
                ret_if(index_item == NULL);
 
-               next_letter = _convert_char_to_string(next_app_info->app_name[0]);
+               next_letter = _convert_char_to_string(next_app_info->pkg_label[0]);
                ret_if(next_letter == NULL);
 
                letter = elm_index_item_letter_get(index_item);
@@ -914,7 +939,7 @@ static void _index_del_item_cb(void *data, Evas_Object *obj, void *event_info)
                                goto end;
                        }
 
-                       char *prev_letter = _convert_char_to_string(prev_app_info->app_name[0]);
+                       char *prev_letter = _convert_char_to_string(prev_app_info->pkg_label[0]);
                        if (!prev_letter) {
                                MGR_APP_DEBUG_ERR("prev_letter is null.");
                                goto end;
@@ -963,6 +988,35 @@ 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;
+
+       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;
+       }
+       
+       MGR_APP_END();
+       return 0;
+}
+
 static void _create_genlist_app_list(Evas_Object *parent, void *data)
 {
        MGR_APP_BEGIN();
@@ -1025,13 +1079,19 @@ static void _create_genlist_app_list(Evas_Object *parent, void *data)
        _index = index;
        _index_cnt = 0;
 
-
-       r = pkgmgrinfo_appinfo_get_installed_list(_app_list_cb, NULL);
+#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("pkgmgrinfo_appinfo_get_installed_list failed. %d", r);
+               MGR_APP_DEBUG_ERR("pkgmgr_get_pkg_list failed. %d", r);
        }
 
-       /* sorting by app_name */
+       /* sorting by pkg_name */
        _installed_list = g_list_sort(_installed_list, _app_list_qsort_cb);
 
        /* header border */
@@ -1046,12 +1106,12 @@ static void _create_genlist_app_list(Evas_Object *parent, void *data)
                        MGR_APP_DEBUG_ERR("app_info is a null");
                        continue;
                }
-               MGR_APP_DEBUG("genlist %d app_info->app_name: %s", i, app_info->app_name);
+               MGR_APP_DEBUG("genlist %d app_info->pkg_label: %s", i, app_info->pkg_label);
 
                item = elm_genlist_item_append(genlist, itc, (void*)app_info, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, (void*)ugd);
 
                /* fast scroll insertion */
-               letter = _convert_char_to_string(app_info->app_name[0]);
+               letter = _convert_char_to_string(app_info->pkg_label[0]);
                if (item && strncmp(letter, prev_letter, MAX_BUF_SIZE) != 0) {
                        _register_index_item(index, letter, item, EINA_TRUE);
                        strncpy(prev_letter, letter, MAX_BUF_SIZE);