Fixed uninstall issue 20/63820/11 accepted/tizen/ivi/20160408.004410 accepted/tizen/mobile/20160408.004513 submit/tizen/20160407.152521 submit/tizen_app/20160408.075241
authorjuhee,park <juhee82.park@samsung.com>
Mon, 28 Mar 2016 03:17:45 +0000 (12:17 +0900)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Thu, 7 Apr 2016 15:24:40 +0000 (08:24 -0700)
Signed-off-by: juhee,park <juhee82.park@samsung.com>
Change-Id: I846bdc9d949f38784dd92e772982c72d125550db

inc/app_icon.h
inc/data_model.h
src/app_icon.c
src/app_mgr.c
src/data_model.c

index a0d027e..e2e7694 100644 (file)
@@ -158,4 +158,11 @@ void app_icon_set_label_black(Evas_Object *icon_layout);
  */
 void app_icon_remove(Evas_Object *icon_layout);
 
+/**
+ * @brief Removes application icon and data.
+ * @param icon_layout Pointer to app_icon layout.
+ */
+void app_icon_uninstall(void *data);
+
+
 #endif /* APP_ICON_H_ */
index 8b51916..3d51287 100644 (file)
@@ -205,5 +205,13 @@ extern void data_model_update_item(Tree_node_t *node);
 extern void data_model_detach_from_folder(Tree_node_t *folder_node,
        Tree_node_t *node);
 
+/**
+ * @brief Search node with package name.
+ *
+ * @param package name
+ * @return node or NULL
+ */
+Tree_node_t *data_model_search_package(const char* pkg_str);
+
 
 #endif /* DATA_MODEL_H_ */
index 6f5082f..a35c840 100644 (file)
@@ -56,8 +56,6 @@ static void __app_icon_check_cb(void *data, Evas_Object *obj, const char *emissi
 static void __app_icon_uncheck_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
 static Evas_Object *__app_icon_load(Evas_Object *parent, const char *icon_path);
 static void __app_icon_uninstall_button_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
-
-static void __app_icon_uninstall(void *data);
 static void __app_icon_highlight_folder_icon_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void __app_icon_unhighlight_folder_icon_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void __app_icon_higlight_impossible_folder_icon_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
@@ -622,7 +620,7 @@ static void __app_icon_uninstall_button_clicked_cb(void *data, Evas_Object *obj,
                p_data->popup_confirm_text = strdup(_("IDS_ST_BUTTON_REMOVE_ABB2"));
                p_data->popup_cancel_text = strdup(_("IDS_CAM_SK_CANCEL"));
                p_data->orientation = ELM_POPUP_ORIENT_CENTER;
-               popup_show(p_data, __app_icon_uninstall, NULL, (void *) obj);
+               popup_show(p_data, app_icon_uninstall, NULL, (void *) obj);
        } else if (app_node->data->type == APP_ITEM_ICON) {
                snprintf(buf, sizeof(buf), _("IDS_HS_POP_PS_WILL_BE_UNINSTALLED"), app_node->data->label);
                p_data->type = POPUP_TWO_BUTTONS;
@@ -631,14 +629,14 @@ static void __app_icon_uninstall_button_clicked_cb(void *data, Evas_Object *obj,
                p_data->popup_confirm_text = strdup(_("IDS_AT_BODY_UNINSTALL"));
                p_data->popup_cancel_text = strdup(_("IDS_CAM_SK_CANCEL"));
                p_data->orientation = ELM_POPUP_ORIENT_CENTER;
-               popup_show(p_data, __app_icon_uninstall, NULL, (void *) obj);
+               popup_show(p_data, app_icon_uninstall, NULL, (void *) obj);
        } else {
-               __app_icon_uninstall((void *) obj);
+               app_icon_uninstall((void *) obj);
                popup_data_free(p_data);
        }
 }
 
-static void __app_icon_uninstall(void *data)
+void app_icon_uninstall(void *data)
 {
        Tree_node_t *app_node = NULL;
        Evas_Object *icon = NULL;
index 004d006..07cd317 100644 (file)
@@ -248,7 +248,22 @@ static void __app_mgr_event_cb(const char *type, const char *package,
        }
 
        if (PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL == event_type && progress == 100)
+       {
                LOGI("%s", package);
+               Tree_node_t *it = data_model_search_package(package);
+               Tree_node_t *parent_folder = NULL;
+
+               if (it != NULL) {
+                       if (it->parent && it->parent->parent
+                                       && (it->parent->parent->data->type == APP_ITEM_FOLDER))
+                               parent_folder = it->parent->parent;
+
+                       app_icon_uninstall(it->data->layout);
+
+                       if (parent_folder != NULL)
+                               app_icon_update_folder_icon(parent_folder);
+               }
+       }
 }
 
 static bool __app_info_cb(app_info_h ai, void *ud)
index 34f284c..99bf127 100644 (file)
@@ -36,6 +36,11 @@ static struct {
        .home = NULL,
 };
 
+typedef struct {
+       Tree_node_t *data;
+       char *search;
+} search_package_t;
+
 static bool __data_model_get_empty_page(Tree_node_t *nothing, Tree_node_t *page, void *data);
 static void __data_model_load_item(Tree_node_t *parent, Tree_node_t **item, db_item_t* db_item, Eina_List* apps_db);
 static void __data_model_free_subtree(Tree_node_t *root_node);
@@ -53,6 +58,8 @@ static Eina_Inarray *__data_model_sort_children(const Tree_node_t *const root,
 static void __add_default_widget(widget_info_t *widget);
 
 static Eina_Bool __data_model_reattach_children(const void *container, void *node, void *fdata);
+static bool __data_model_search_package_cb(Tree_node_t *parent, Tree_node_t *node, void *data);
+
 
 HAPI Tree_node_t *data_model_get_data(void)
 {
@@ -601,6 +608,27 @@ HAPI void data_model_sort(Eina_Compare_Cb sort_compare_function)
        }
 }
 
+Tree_node_t *data_model_search_package(const char* pkg_str)
+{
+       search_package_t search;
+       search.data = NULL;
+       search.search = pkg_str;
+
+       tree_in_depth_browse(s_info.all_apps, __data_model_search_package_cb, &search);
+
+       return search.data;
+}
+
+static bool __data_model_search_package_cb(Tree_node_t *parent, Tree_node_t *node, void *data)
+{
+       search_package_t *search_data = (search_package_t *)data;
+
+       if (node->data->appid && strcmp(search_data->search, node->data->appid) == 0)
+               search_data->data = node;
+
+       return true;
+}
+
 static bool __data_model_get_empty_page(Tree_node_t *nothing, Tree_node_t *page, void *data)
 {
        Tree_node_t **empty_page = (Tree_node_t **)data;