From 5bd3f7adcef7105b577414ee69779c7cc527cb99 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 2 Aug 2016 14:22:25 +0900 Subject: [PATCH] Remove unused apis Removed: pkgmgrinfo_pkginfo_get_total_size pkgmgrinfo_pkginfo_get_data_size pkgmgrinfo_pkginfo_get_size_from_xml pkgmgrinfo_pkginfo_get_location_from_xml libxml dependency is removed from pkgmgr-info. Change-Id: I46b9c98379ca909e205a34a76583b2960f77966b Signed-off-by: Sangyoon Jang --- CMakeLists.txt | 2 +- include/pkgmgr-info.h | 72 ------------ src/pkgmgrinfo_pkginfo.c | 299 ----------------------------------------------- 3 files changed, 1 insertion(+), 372 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6b1e3f..a9098d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ FOREACH(flag ${pkgs_CFLAGS}) ENDFOREACH(flag) -pkg_check_modules(libpkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1 libtzplatform-config libsmack bundle capi-system-info) +pkg_check_modules(libpkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util dbus-1 dbus-glib-1 libtzplatform-config libsmack bundle capi-system-info) FOREACH(flag ${libpkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index 4c36afb..15bddb4 100644 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -615,76 +615,6 @@ static int get_pkg_size(const char *pkgid) int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size); /** - * @fn int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size) - * @brief This API gets the installed package total size on the target. - * - * @par This API is for package-manager client application - * @par Sync (or) Async : Synchronous API - * - * @param[in] handle pointer to package info handle - * @param[out] size pointer to hold package total size - * @return 0 if success, error code(<0) if fail - * @retval PMINFO_R_OK success - * @retval PMINFO_R_EINVAL invalid argument - * @retval PMINFO_R_ERROR internal error - * @code -static int get_pkg_total_size(const char *pkgid) -{ - int ret = 0; - int size = 0; - pkgmgrinfo_pkginfo_h handle; - ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); - if (ret != PMINFO_R_OK) - return -1; - ret = pkgmgrinfo_pkginfo_get_total_size(handle, &size); - if (ret != PMINFO_R_OK) { - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - return -1; - } - printf("pkg total size: %d\n", size); - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - return 0; -} - * @endcode - */ - int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size); - -/** - * @fn int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size) - * @brief This API gets the installed package data size on the target. - * - * @par This API is for package-manager client application - * @par Sync (or) Async : Synchronous API - * - * @param[in] handle pointer to package info handle - * @param[out] size pointer to hold package data size - * @return 0 if success, error code(<0) if fail - * @retval PMINFO_R_OK success - * @retval PMINFO_R_EINVAL invalid argument - * @retval PMINFO_R_ERROR internal error - * @code -static int get_pkg_data_size(const char *pkgid) -{ - int ret = 0; - int size = 0; - pkgmgrinfo_pkginfo_h handle; - ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); - if (ret != PMINFO_R_OK) - return -1; - ret = pkgmgrinfo_pkginfo_get_data_size(handle, &size); - if (ret != PMINFO_R_OK) { - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - return -1; - } - printf("pkg data size: %d\n", size); - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - return 0; -} - * @endcode - */ - int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size); - -/** * @fn int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon) * @brief This API gets the package icon from the package ID * @@ -2049,8 +1979,6 @@ int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data); /* TODO: add doxygen comment here */ -int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size); -int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location); int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users); int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled); int pkgmgrinfo_appinfo_set_usr_state_enabled(const char *appid, bool enabled, uid_t uid); diff --git a/src/pkgmgrinfo_pkginfo.c b/src/pkgmgrinfo_pkginfo.c index 89dbc77..8423b8a 100644 --- a/src/pkgmgrinfo_pkginfo.c +++ b/src/pkgmgrinfo_pkginfo.c @@ -32,9 +32,6 @@ #include #include -#include -#include -#include #include #include @@ -96,37 +93,6 @@ static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data) return; } -static int __child_element(xmlTextReaderPtr reader, int depth) -{ - int ret = xmlTextReaderRead(reader); - int cur = xmlTextReaderDepth(reader); - while (ret == 1) { - - switch (xmlTextReaderNodeType(reader)) { - case XML_READER_TYPE_ELEMENT: - if (cur == depth + 1) - return 1; - break; - case XML_READER_TYPE_TEXT: - /*text is handled by each function separately*/ - if (cur == depth + 1) - return 0; - break; - case XML_READER_TYPE_END_ELEMENT: - if (cur == depth) - return 0; - break; - default: - if (cur <= depth) - return 0; - break; - } - ret = xmlTextReaderRead(reader); - cur = xmlTextReaderDepth(reader); - } - return ret; -} - long long _pkgmgr_calculate_dir_size(char *dirname) { long long total = 0; @@ -1010,164 +976,6 @@ API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *si return PMINFO_R_OK; } -API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size) -{ - char *pkgid; - char device_path[PKG_STRING_LEN_MAX] = { '\0', }; - long long rw_size = 0; - long long ro_size = 0; - long long tmp_size = 0; - long long total_size = 0; - struct stat fileinfo; - int ret; - - retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); - retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - - ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); - if (ret < 0) - return PMINFO_R_ERROR; - - /* RW area */ - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - /* RO area */ - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } - } - - /* Total size */ - total_size = rw_size + ro_size; - *size = (int)total_size; - - return PMINFO_R_OK; -} - -API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size) -{ - char *pkgid; - char device_path[PKG_STRING_LEN_MAX] = { '\0', }; - long long total_size = 0; - - retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); - retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - - if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid) < 0) - return PMINFO_R_ERROR; - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid); - if (access(device_path, R_OK) == 0) - total_size = _pkgmgr_calculate_dir_size(device_path); - if (total_size < 0) - return PMINFO_R_ERROR; - - *size = (int)total_size; - - return PMINFO_R_OK; -} - API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon) { const char *locale; @@ -1438,112 +1246,6 @@ API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url) return PMINFO_R_OK; } -API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size) -{ - const char *val = NULL; - const xmlChar *node; - xmlTextReaderPtr reader; - retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n"); - retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - - xmlInitParser(); - reader = xmlReaderForFile(manifest, NULL, 0); - - if (reader){ - if (__child_element(reader, -1)) { - node = xmlTextReaderConstName(reader); - if (!node) { - _LOGE("xmlTextReaderConstName value is NULL\n"); - xmlFreeTextReader(reader); - xmlCleanupParser(); - return PMINFO_R_ERROR; - } - - if (!strcmp(ASC_CHAR(node), "manifest")) { - if (xmlTextReaderGetAttribute(reader, XML_CHAR("size"))) - val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size"))); - - if (val) { - *size = atoi(val); - } else { - *size = 0; - _LOGE("package size is not specified\n"); - xmlFreeTextReader(reader); - xmlCleanupParser(); - return PMINFO_R_ERROR; - } - } else { - _LOGE("Unable to create xml reader\n"); - xmlFreeTextReader(reader); - xmlCleanupParser(); - return PMINFO_R_ERROR; - } - } - } else { - _LOGE("xmlReaderForFile value is NULL\n"); - xmlCleanupParser(); - return PMINFO_R_ERROR; - } - - xmlFreeTextReader(reader); - xmlCleanupParser(); - - return PMINFO_R_OK; -} - -API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location) -{ - const char *val = NULL; - const xmlChar *node; - xmlTextReaderPtr reader; - retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n"); - retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - - xmlInitParser(); - reader = xmlReaderForFile(manifest, NULL, 0); - - if (reader) { - if ( __child_element(reader, -1)) { - node = xmlTextReaderConstName(reader); - if (!node) { - _LOGE("xmlTextReaderConstName value is NULL\n"); - xmlFreeTextReader(reader); - xmlCleanupParser(); - return PMINFO_R_ERROR; - } - - if (!strcmp(ASC_CHAR(node), "manifest")) { - if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location"))) - val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location"))); - - if (val) { - if (strcmp(val, "internal-only") == 0) - *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY; - else if (strcmp(val, "prefer-external") == 0) - *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL; - else - *location = PMINFO_INSTALL_LOCATION_AUTO; - } - } else { - _LOGE("Unable to create xml reader\n"); - xmlFreeTextReader(reader); - xmlCleanupParser(); - return PMINFO_R_ERROR; - } - } - } else { - _LOGE("xmlReaderForFile value is NULL\n"); - xmlCleanupParser(); - return PMINFO_R_ERROR; - } - - xmlFreeTextReader(reader); - xmlCleanupParser(); - - return PMINFO_R_OK; -} - - API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path) { pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; @@ -1612,7 +1314,6 @@ API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *acce } /*check whether application is in internal or not */ - fp = fopen(app_dir_path, "r"); if (fp == NULL) { _LOGD(" app path in internal memory not accesible\n"); *accessible = 0; -- 2.7.4