Fix the app list update logic when newly app has been installed.
authorEunmi Son <eunmi.son@samsung.com>
Sun, 9 Sep 2012 06:53:53 +0000 (15:53 +0900)
committerEunmi Son <eunmi.son@samsung.com>
Sun, 9 Sep 2012 06:53:53 +0000 (15:53 +0900)
packaging/ug-setting-manage-applications-efl.spec
view/src/mgr-app-view-app-info.c
view/src/mgr-app-view-app-list.c

index d1d27e5..65e8966 100644 (file)
@@ -1,14 +1,13 @@
 %define _optdir        /opt
 %define _ugdir %{_optdir}/ug
 
-
-Name:          ug-setting-manage-applications-efl
-Summary:       Manage Application package
-Version:       0.0.26
-Release:       0
-Group:         TO_BE/FILLED_IN
-License:       Flora Software License
-Source0:       %{name}-%{version}.tar.gz
+Name:       ug-setting-manage-applications-efl
+Summary:    Manage Application package
+Version:    0.0.28
+Release:    0
+Group:      Applications/System
+License:    Flora Software License
+Source0:    %{name}-%{version}.tar.gz
 BuildRequires: cmake
 BuildRequires: gettext-tools
 BuildRequires: edje-tools
index 62e1bb2..314b34c 100755 (executable)
@@ -44,9 +44,9 @@
 #define STR_POPUP                                      "popup"
 
 #define MAX_NAME_LEN                           128
-#define NUM_KILO                                       1024
-#define NUM_MEGA                                       1024*1024
-#define NUM_GIGA                                       1024*1024*1024
+#define NUM_KILO                                       (1024)
+#define NUM_MEGA                                       (1024*1024)
+#define NUM_GIGA                                       (1024*1024*1024)
 
 #define ELM_TEXT_1                                     "elm.text.1"
 #define ELM_TEXT_2                                     "elm.text.2"
@@ -641,11 +641,11 @@ static char *__get_formated_size(float size)
        if (size < NUM_KILO) {
                snprintf(buf, MAX_NAME_LEN, "%d %s", (int)size, dgettext(PACKAGE, "IDS_ST_BODY_BYTES"));
        } else if (size >= NUM_KILO && size < NUM_MEGA) {
-               snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / (NUM_KILO), dgettext(PACKAGE, "IDS_ST_BODY_KB"));
+               snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_KILO, dgettext(PACKAGE, "IDS_ST_BODY_KB"));
        } else if (size >= NUM_MEGA && size < NUM_GIGA) {
-               snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / (NUM_MEGA), dgettext(PACKAGE, "IDS_ST_BODY_MB"));
+               snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_MEGA, dgettext(PACKAGE, "IDS_ST_BODY_MB"));
        } else {
-               snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / (NUM_GIGA), dgettext(PACKAGE, "IDS_ST_BODY_GB"));
+               snprintf(buf, MAX_NAME_LEN, "%'.2f %s", size / NUM_GIGA, dgettext(PACKAGE, "IDS_ST_BODY_GB"));
        }
 
        MGR_APP_END();
@@ -1082,7 +1082,6 @@ static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
 
                buf = pkgmgr_info_get_string(pkg_info, STR_DATA_SIZE);
                if (buf) {
-                       MGR_APP_DEBUG_ERR("data size: %s", buf);
                        app_info->data_size = atoi(buf);
                        MGR_APP_MEM_FREE(buf);
                } else {
@@ -1091,9 +1090,7 @@ static Evas_Object *__create_genlist_app_info(Evas_Object *parent, void *data)
 
                buf = NULL;
                buf = pkgmgr_info_get_string(pkg_info, STR_INSTALLED_SIZE);
-
                if (buf) {
-                       MGR_APP_DEBUG_ERR("installed size: %s", buf);
                        app_info->total_size = atoi(buf);
                        MGR_APP_MEM_FREE(buf);
                } else {
index ecc76f6..4f8edef 100755 (executable)
@@ -314,6 +314,9 @@ static ail_cb_ret_e _appinfo_func_cb(const ail_appinfo_h ail_info, void *user_da
                MGR_APP_DEBUG_ERR(">>> get package_name failed");
                return AIL_CB_RET_CONTINUE;
        }
+       if (p_app_info_list->pkg_name && !strstr(package_name, p_app_info_list->pkg_name)) {
+               return;
+       }
        ail_appinfo_get_str(ail_info, AIL_PROP_NAME_STR, &app_name);
        if (!app_name) {
                MGR_APP_DEBUG_ERR(">>> get app_name failed");
@@ -381,7 +384,10 @@ static void _response_cb(void *data, Evas_Object *obj, void *event_info)
 {
        MGR_APP_BEGIN();
 
-       evas_object_del(data);
+       if (data) {
+               evas_object_del(data);
+               data = NULL;
+       }
 
        MGR_APP_END();
 }
@@ -414,6 +420,9 @@ static void _list_update_by_install(char *pkg_type, const char *pkg_name, void *
        ret_if(pkg_type == NULL);
        ret_if(data == NULL);
        struct ug_data *ugd = (struct ug_data*)data;
+       mgr_app_app_info_t *app_info = NULL;
+       Elm_Object_Item *item = NULL;
+       int i = 0;
 
        ret_if(mgr_app_view_app_list.view_common_data == NULL);
        mgr_app_view_common_data_t *view_common_data = mgr_app_view_app_list.view_common_data;
@@ -432,7 +441,11 @@ static void _list_update_by_install(char *pkg_type, const char *pkg_name, void *
        ail_filter_h filter = {0};
        ail_filter_new(&filter);
        ail_filter_add_str(filter, AIL_PROP_X_SLP_PACKAGETYPE_STR, pkg_type);
-       ail_filter_add_str(filter, AIL_PROP_PACKAGE_STR, pkg_name);
+       if (EINA_FALSE == ugd->uninstall) {
+               app_info_new->pkg_name = pkg_name;
+       } else {
+               ail_filter_add_str(filter, AIL_PROP_PACKAGE_STR, pkg_name);
+       }
        app_list_view_data->initialize = EINA_FALSE;
        ail_filter_list_appinfo_foreach(filter, _appinfo_func_cb, (void*)app_info_new);
        ail_filter_destroy(filter);
@@ -443,105 +456,119 @@ static void _list_update_by_install(char *pkg_type, const char *pkg_name, void *
                return;
        }
 
-       int i = 0;
-       Elm_Object_Item *item = elm_genlist_first_item_get(app_list_view_data->genlist);
-       if (!item) {
-               elm_genlist_item_append(app_list_view_data->genlist, itc_sep_21, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-       }
-       mgr_app_app_info_t *app_info = NULL;
+       item = elm_genlist_first_item_get(app_list_view_data->genlist);
+       if (item) {
+               for (i = 0; i < app_list_view_data->app_info_idx; i++) {
+                       /* First item from genlist is a separator */
+                       item = elm_genlist_item_next_get(item);
+                       app_info = (mgr_app_app_info_t*)elm_object_item_data_get(item);
+                       if (!app_info) {
+                               MGR_APP_DEBUG_ERR("app_info is null");
+                               MGR_APP_MEM_FREE(app_info_new);
+                               return;
+                       }
 
-       for (i = 0; i < app_list_view_data->app_info_idx; i++) {
+                       int len = 0;
+                       len = (strlen(app_info_new->app_name) >= strlen(app_info->app_name)) ? strlen(app_info_new->app_name) : strlen(app_info->app_name);
 
-               app_info = (mgr_app_app_info_t*)elm_object_item_data_get(item);
-               if (!app_info) {
-                       MGR_APP_DEBUG_ERR("app_info is null");
-                       MGR_APP_MEM_FREE(app_info_new);
-                       return;
-               }
+                       if (strncasecmp(app_info_new->app_name, app_info->app_name, len) < 0) {
 
-               int len = 0;
-               len = (strlen(app_info_new->app_name) >= strlen(app_info->app_name)) ? strlen(app_info_new->app_name) : strlen(app_info->app_name);
+                               Elm_Object_Item *prev_item = elm_genlist_item_prev_get(item);
+                               Elm_Object_Item *new_item = elm_genlist_item_insert_before(app_list_view_data->genlist, itc, (void*)app_info_new, NULL, item, ELM_GENLIST_ITEM_NONE, _gl_sel, (void*)ugd);
+                               ret_if(new_item == NULL);
 
-               if (strncasecmp(app_info_new->app_name, app_info->app_name, len) < 0) {
+                               char *letter_new = __convert_char_to_string(app_info_new->app_name[0]);
+                               ret_if(letter_new == NULL);
+                               char *letter = __convert_char_to_string(app_info->app_name[0]);
+                               if (!letter) {
+                                       MGR_APP_MEM_FREE(letter_new);
+                                       return;
+                               }
 
-                       Elm_Object_Item *prev_item = elm_genlist_item_prev_get(item);
-                       Elm_Object_Item *new_item = elm_genlist_item_insert_before(app_list_view_data->genlist, itc, (void*)app_info_new, NULL, item, ELM_GENLIST_ITEM_NONE, _gl_sel, (void*)ugd);
-                       ret_if(new_item == NULL);
+                               /* the top of item */
+                               if (!prev_item) {
+                                       if (letter_new[0] == letter[0]) {
+                                               /* B'-B, index item must be replaced from B to B' */
+                                               elm_object_item_del(item);
+                                       } else {
+                                               /* B'-C, just add the index item */
+                                               __register_index_item(app_list_view_data->index, letter_new, new_item, EINA_FALSE);
+                                       }
+                               } else {
+
+                                       mgr_app_app_info_t *app_info_prev = elm_object_item_data_get(prev_item);
+                                       if (!app_info_prev) {
+                                               MGR_APP_MEM_FREE(letter);
+                                               return;
+                                       }
+
+                                       char *letter_prev = __convert_char_to_string(app_info_prev->app_name[0]);
+                                       if (!letter_prev) {
+                                               MGR_APP_MEM_FREE(letter);
+                                               return;
+                                       }
+
+                                       if (letter_prev[0] == letter_new[0]) {
+                                               /* B-B', nothing to do for index */
+
+                                       } else if (letter_prev[0] < letter_new[0] && letter_new[0] < letter[0]) {
+                                               /* A-B'-C, B' must be inserted to index */
+                                               __register_index_item(app_list_view_data->index, letter_new, new_item, EINA_FALSE);
+
+                                       } else if (letter_prev[0] < letter_new[0] && letter_new[0] == letter[0]) {
+                                               /* A-B'-B, index item must be replaced from B to B' */
+                                               elm_object_item_del(item);
+                                       }
+                                       MGR_APP_MEM_FREE(letter_prev);
+                               }
 
-                       char *letter_new = __convert_char_to_string(app_info_new->app_name[0]);
-                       ret_if(letter_new == NULL);
-                       char *letter = __convert_char_to_string(app_info->app_name[0]);
-                       if (!letter) {
                                MGR_APP_MEM_FREE(letter_new);
-                               return;
-                       }
+                               MGR_APP_MEM_FREE(letter);
+                               app_list_view_data->app_info_idx++;
 
-                       /* the top of item */
-                       if (!prev_item) {
-                               if (letter_new[0] == letter[0]) {
-                                       /* B'-B, index item must be replaced from B to B' */
-                                       elm_object_item_del(item);
-                               } else {
-                                       /* B'-C, just add the index item */
-                                       __register_index_item(app_list_view_data->index, letter_new, new_item, EINA_FALSE);
-                               }
+                               break;
                        } else {
-
-                               mgr_app_app_info_t *app_info_prev = elm_object_item_data_get(prev_item);
-                               if (!app_info_prev) {
-                                       MGR_APP_MEM_FREE(letter);
+                               item = elm_genlist_item_next_get(item);
+                               if (!item) {
+                                       MGR_APP_DEBUG_ERR("item is null");
+                                       MGR_APP_MEM_FREE(app_info_new);
                                        return;
                                }
 
-                               char *letter_prev = __convert_char_to_string(app_info_prev->app_name[0]);
-                               if (!letter_prev) {
-                                       MGR_APP_MEM_FREE(letter);
-                                       return;
-                               }
+                               /* check the item and append after last item */
+                               if (item == elm_genlist_last_item_get(app_list_view_data->genlist)) {
+                                       char *letter_new = __convert_char_to_string(app_info_new->app_name[0]);
+                                       ret_if(letter_new == NULL);
 
-                               if (letter_prev[0] == letter_new[0]) {
-                                       /* B-B', nothing to do for index */
+                                       Elm_Object_Item *new_item = elm_genlist_item_append(app_list_view_data->genlist, itc, (void*)app_info_new, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, (void*)ugd);
+                                       ret_if(new_item == NULL);
 
-                               } else if (letter_prev[0] < letter_new[0] && letter_new[0] < letter[0]) {
-                                       /* A-B'-C, B' must be inserted to index */
                                        __register_index_item(app_list_view_data->index, letter_new, new_item, EINA_FALSE);
 
-                               } else if (letter_prev[0] < letter_new[0] && letter_new[0] == letter[0]) {
-                                       /* A-B'-B, index item must be replaced from B to B' */
-                                       elm_object_item_del(item);
-                               }
-                               MGR_APP_MEM_FREE(letter_prev);
-                       }
-
-                       MGR_APP_MEM_FREE(letter_new);
-                       MGR_APP_MEM_FREE(letter);
-                       app_list_view_data->app_info_idx++;
+                                       MGR_APP_MEM_FREE(letter_new);
+                                       app_list_view_data->app_info_idx++;
 
-                       break;
-               } else {
-                       item = elm_genlist_item_next_get(item);
-                       if (!item) {
-                               MGR_APP_DEBUG_ERR("item is null");
-                               MGR_APP_MEM_FREE(app_info_new);
-                               return;
+                                       break;
+                               }
                        }
+               }
+       /* There are no installed app in list */
+       } else {
+               char *letter_new = NULL;
+               Elm_Object_Item *new_item = NULL;
 
-                       /* check the item and append after last item */
-                       if (item == elm_genlist_last_item_get(app_list_view_data->genlist)) {
-                               char *letter_new = __convert_char_to_string(app_info_new->app_name[0]);
-                               ret_if(letter_new == NULL);
+               elm_genlist_item_append(app_list_view_data->genlist, itc_sep_21, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
 
-                               Elm_Object_Item *new_item = elm_genlist_item_append(app_list_view_data->genlist, itc, (void*)app_info_new, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, (void*)ugd);
-                               ret_if(new_item == NULL);
+               letter_new = __convert_char_to_string(app_info_new->app_name[0]);
+               ret_if(letter_new == NULL);
 
-                               __register_index_item(app_list_view_data->index, letter_new, new_item, EINA_FALSE);
+               new_item = elm_genlist_item_append(app_list_view_data->genlist, itc, (void*)app_info_new, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel, (void*)ugd);
+               ret_if(new_item == NULL);
 
-                               MGR_APP_MEM_FREE(letter_new);
-                               app_list_view_data->app_info_idx++;
+               __register_index_item(app_list_view_data->index, letter_new, new_item, EINA_FALSE);
 
-                               break;
-                       }
-               }
+               MGR_APP_MEM_FREE(letter_new);
+               app_list_view_data->app_info_idx++;
        }
 
        elm_genlist_realized_items_update(app_list_view_data->genlist);
@@ -583,7 +610,6 @@ static void _list_update_by_uninstall(char *pkg_type, const char *pkg_name, void
                        MGR_APP_DEBUG("deleted");
                        app_list_view_data->app_info_idx--;
                        break;
-               /* temporary code - tpk backend should be passed full pkg name */
                } else if (0 == strcmp(pkg_type, TPK_PREFIX) && strstr(app_info->pkg_name, pkg_name)) {
                                Elm_Object_Item *idx_item = elm_index_item_find(app_list_view_data->index, item);
                                elm_object_item_del(idx_item);