From c1f8c07d47b99c67bcc018ad741173e050cef966 Mon Sep 17 00:00:00 2001 From: Kairong Yin Date: Wed, 3 Apr 2013 19:03:35 +0800 Subject: [PATCH] Fix the BS issue of RSA TREL-9 --- packaging/org.tizen.setting.spec | 1 + setting-storage/CMakeLists.txt | 2 +- setting-storage/include/setting-storage.h | 1 + setting-storage/src/setting-storage-main.c | 105 ++++++++--------------------- 4 files changed, 32 insertions(+), 77 deletions(-) diff --git a/packaging/org.tizen.setting.spec b/packaging/org.tizen.setting.spec index ee72814..6634e43 100755 --- a/packaging/org.tizen.setting.spec +++ b/packaging/org.tizen.setting.spec @@ -65,6 +65,7 @@ BuildRequires: pkgconfig(capi-network-tethering) BuildRequires: pkgconfig(capi-network-nfc) BuildRequires: pkgconfig(ecore-evas) BuildRequires: pkgconfig(pkgmgr) +BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: sysman-internal-devel BuildRequires: cmake BuildRequires: edje-tools diff --git a/setting-storage/CMakeLists.txt b/setting-storage/CMakeLists.txt index 234769b..ebe2ecd 100755 --- a/setting-storage/CMakeLists.txt +++ b/setting-storage/CMakeLists.txt @@ -4,7 +4,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${SETTING_COMMON}/include) INCLUDE(FindPkgConfig) pkg_check_modules(pkgs_storage REQUIRED ecore ecore-file evas elementary appcore-common appcore-efl ui-gadget-1 capi-appfw-application sysman fontconfig -libxml-2.0 ail pkgmgr capi-content-media-content) +libxml-2.0 ail pkgmgr pkgmgr-info capi-content-media-content) FOREACH(flag ${pkgs_storage_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/setting-storage/include/setting-storage.h b/setting-storage/include/setting-storage.h index d21c323..f5832c0 100755 --- a/setting-storage/include/setting-storage.h +++ b/setting-storage/include/setting-storage.h @@ -205,6 +205,7 @@ struct _SettingStorageUG { Eina_Bool exit_flag; update_type type; pthread_t tid; + double total_size; pthread_mutex_t exit_mutex; pthread_mutex_t update_mutex; diff --git a/setting-storage/src/setting-storage-main.c b/setting-storage/src/setting-storage-main.c index 86e8ef1..4173394 100755 --- a/setting-storage/src/setting-storage-main.c +++ b/setting-storage/src/setting-storage-main.c @@ -17,6 +17,7 @@ #include #include #include +#include #include static int setting_storage_main_create(void *cb); @@ -1151,29 +1152,28 @@ static ail_cb_ret_e __setting_storage_main_appinfo_func_cb(const ail_appinfo_h a return AIL_CB_RET_CONTINUE; } -static void __setting_storage_main_applications_list_get(Eina_List **apps_list) +void __setting_storage_pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *data) { SETTING_TRACE_BEGIN; - /* get app_info from AIL */ - ail_filter_h filter_rpm = NULL; - ail_filter_h filter_wrt = NULL; - ail_filter_h filter_tpk = NULL; - - ail_filter_new(&filter_rpm); - ail_filter_new(&filter_wrt); - ail_filter_new(&filter_tpk); - - ail_filter_add_str(filter_rpm, AIL_PROP_X_SLP_PACKAGETYPE_STR, RPM_PREFIX); - ail_filter_add_str(filter_wrt, AIL_PROP_X_SLP_PACKAGETYPE_STR, WRT_PREFIX); - ail_filter_add_str(filter_tpk, AIL_PROP_X_SLP_PACKAGETYPE_STR, TPK_PREFIX); - - ail_filter_list_appinfo_foreach(filter_rpm, __setting_storage_main_appinfo_func_cb, (void*)apps_list); - ail_filter_list_appinfo_foreach(filter_wrt, __setting_storage_main_appinfo_func_cb, (void*)apps_list); - ail_filter_list_appinfo_foreach(filter_tpk, __setting_storage_main_appinfo_func_cb, (void*)apps_list); - - ail_filter_destroy(filter_rpm); - ail_filter_destroy(filter_wrt); - ail_filter_destroy(filter_tpk); + setting_retvm_if(data == NULL, 0.0, "Data parameter is NULL"); + SettingStorageUG *ad = (SettingStorageUG *)data; + + int ret = -1; + int size = 0; + char *pkgid; + ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); + if(ret < 0) { + SETTING_TRACE_ERROR("pkgmgrinfo_pkginfo_get_pkgid() failed"); + return; + } + ret = pkgmgrinfo_pkginfo_get_total_size(handle, &size); + if(ret < 0) { + SETTING_TRACE_ERROR("pkgmgrinfo_pkginfo_get_total_size() failed"); + return; + } + SETTING_TRACE("pkg id = %s", pkgid); + SETTING_TRACE("app size = %d", size); + ad->total_size += size; } static double __setting_storage_main_applications_status_get(void *data) @@ -1182,62 +1182,15 @@ static double __setting_storage_main_applications_status_get(void *data) setting_retvm_if(data == NULL, 0.0, "Data parameter is NULL"); SettingStorageUG *ad = (SettingStorageUG *)data; - Eina_List *apps_list = NULL; - __setting_storage_main_applications_list_get(&apps_list); - - SETTING_TRACE("count = %d", eina_list_count(apps_list)); - - double total_size = 0.0; - - Eina_List *l = NULL; - App_Info *app_info = NULL; - EINA_LIST_FOREACH (apps_list, l, app_info) - { - int exit_flag = 0; - pthread_mutex_lock(&ad->exit_mutex); - exit_flag = ad->exit_flag; - pthread_mutex_unlock(&ad->exit_mutex); - - if (exit_flag == 1) { - SETTING_TRACE("exit_flag is 1"); - break; - } - - //SETTING_TRACE("pkg_name: %s ", app_info->pkg_name); - //SETTING_TRACE("pkg_type: %s", app_info->pkg_type); - pkgmgr_info *pkg_info = pkgmgr_info_new(app_info->pkg_type, app_info->pkg_name); - if (!pkg_info) { - //SETTING_TRACE("pkg_info is null, couldn't get the sizes"); - app_info->total_size = 0; - } else { - char *buf = NULL; - buf = pkgmgr_info_get_string(pkg_info, STR_INSTALLED_SIZE); - if (buf) { - //SETTING_TRACE("size : %s", buf); - app_info->total_size = atoi(buf); - G_FREE(buf); - } else { - app_info->total_size = 0; - } - pkgmgr_info_free(pkg_info); - } - - total_size += app_info->total_size; - } - - /* free the list */ - Eina_List *tmp = NULL; - app_info = NULL; - EINA_LIST_FOREACH(apps_list, tmp, app_info) - { - G_FREE(app_info->pkg_name); - G_FREE(app_info->pkg_type); - FREE(app_info); + ad->total_size = 0.0; + int ret = -1; + ret = pkgmgrinfo_pkginfo_get_list(__setting_storage_pkg_list_cb, data); + if(ret < 0) { + SETTING_TRACE_ERROR("pkgmgrinfo_pkginfo_get_list() failed"); + return 0; } - eina_list_free(apps_list); - apps_list = NULL; - - return total_size; + SETTING_TRACE("ad->total_size = %f", ad->total_size); + return ad->total_size; } void __setting_storage_main_pipe_cb(void *data, void *buffer, unsigned int nbyte) -- 2.7.4