Revert "Revert "Use package info for Multi application"" 63/86463/1 submit/tizen/20160901.121044
authorYOUNG HUN JO <hoon.cho@samsung.com>
Thu, 1 Sep 2016 09:02:29 +0000 (02:02 -0700)
committerYOUNG HUN JO <hoon.cho@samsung.com>
Thu, 1 Sep 2016 09:02:29 +0000 (02:02 -0700)
This reverts commit 5f5329efd9a54d9e3bf731a4c6bfa6b369a26953.

Change-Id: I1665f22d657b45f69afa5d2d28501ec95157e12d

inc/apps_package_manager.h
src/apps_data.c
src/apps_package_manager.c

index 0e44dbb..e8b0549 100755 (executable)
@@ -27,7 +27,7 @@
 #include "apps_data.h"
 
 void apps_package_manager_init();
-Eina_Bool apps_package_manger_get_list(Eina_List **list);
+Eina_Bool apps_package_manager_get_list(Eina_List **list);
 void apps_package_manager_update_label(const char *app_id, app_data_t *item);
 
 #endif /* __APPS_PACKAGE_MANAGER_H__ */
index 1847fc0..cfa53a2 100755 (executable)
@@ -43,7 +43,7 @@ void apps_data_init(void *data, Ecore_Thread *th)
        Eina_List *pkg_find_list, *db_find_list;
        app_data_t *pkg_item = NULL, *db_item = NULL;
        apps_package_manager_init();
-       apps_package_manger_get_list(&pkg_list);
+       apps_package_manager_get_list(&pkg_list);
 
        if (!apps_db_create()) {
                apps_db_get_app_list(&db_list);
index 7d8dc7a..331a51d 100755 (executable)
@@ -25,6 +25,7 @@ static void __apps_package_manager_event_cb(const char *type, const char *packag
                package_manager_event_type_e event_type, package_manager_event_state_e event_state, int progress,
                package_manager_error_e error, void *user_data);
 static bool __apps_data_pkg_get_apps_info(app_info_h app_handle, app_data_t **item);
+static bool __apps_data_get_app_info_from_pkg(package_info_app_component_type_e comp_type, const char *app_id, void *data);
 static bool __apps_package_manager_get_item(app_info_h app_handle, void *data);
 static void __apps_package_manager_install(const char *package);
 static void __apps_package_manager_uninstall(const char *package);
@@ -73,7 +74,7 @@ static void __apps_package_manager_event_cb(const char *type, const char *packag
        }
 }
 
-Eina_Bool apps_package_manger_get_list(Eina_List **list)
+Eina_Bool apps_package_manager_get_list(Eina_List **list)
 {
        int ret;
        app_info_filter_h handle = NULL;
@@ -204,17 +205,45 @@ void apps_package_manager_update_label(const       char *app_id, app_data_t *item)
        }
 }
 
-static void __apps_package_manager_install(const char *package)
+static bool __apps_data_get_app_info_from_pkg(package_info_app_component_type_e comp_type, const char *app_id, void *data)
 {
+       int ret = PACKAGE_MANAGER_ERROR_NONE;
        app_info_h app_info = NULL;
        app_data_t *item = NULL;
 
-       app_manager_get_app_info(package, &app_info);
+       ret = app_manager_get_app_info(app_id, &app_info);
+       if (APP_MANAGER_ERROR_NONE != ret) {
+               LOGE("Failed to get app_info, return: [%d]", ret);
+               return false;
+       }
+
        if (__apps_data_pkg_get_apps_info(app_info, &item)) {
                apps_data_install(item);
        }
        app_info_destroy(app_info);
 
+       return true;
+}
+
+static void __apps_package_manager_install(const char *package)
+{
+       app_info_h app_info = NULL;
+       package_info_h package_info = NULL;
+       app_data_t *item = NULL;
+       int ret = PACKAGE_MANAGER_ERROR_NONE;
+
+       ret = package_info_create(package, &package_info);
+       if (PACKAGE_MANAGER_ERROR_NONE != ret) {
+               LOGE("Failed to create pakcage info for %s", package);
+               return;
+       }
+
+       ret = package_info_foreach_app_from_package(package_info, PACKAGE_INFO_ALLAPP, __apps_data_get_app_info_from_pkg, NULL);
+       if (PACKAGE_MANAGER_ERROR_NONE != ret) {
+               LOGE("Failed to install app from %s", package);
+               return;
+       }
+       package_info_destroy(package_info);
 }
 
 static void __apps_package_manager_uninstall(const char *package)