From e9cdbe92704890fe11d43154046a992d8442e439 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Thu, 17 Aug 2017 17:16:58 +0900 Subject: [PATCH] Merge function for getting thumbnail folder Change-Id: I62f8355638aa441fe2352ae323021ac1d97d1f48 Signed-off-by: Minje Ahn --- packaging/libmedia-service.spec | 2 +- src/common/media-svc-util.c | 28 ++++++++-------------------- src/common/media-svc.c | 20 +++++--------------- 3 files changed, 14 insertions(+), 36 deletions(-) diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec index 3948a37..3ef1e8f 100644 --- a/packaging/libmedia-service.spec +++ b/packaging/libmedia-service.spec @@ -1,6 +1,6 @@ Name: libmedia-service Summary: Media information service library for multimedia applications -Version: 0.3.15 +Version: 0.3.16 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 and PD diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 4aec387..2ad5b82 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -907,29 +907,20 @@ int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *t int ret = MS_MEDIA_ERR_NONE; char savename[MEDIA_SVC_PATHNAME_SIZE] = {0, }; char file_ext[MEDIA_SVC_FILE_EXT_LEN_MAX + 1] = {0, }; - char *thumb_dir = NULL; char hash[255 + 1] = {0, }; char *thumbfile_ext = NULL; - char *internal_thumb_path = NULL; - char *external_thumb_path = NULL; - - ret = ms_user_get_default_thumb_store_path(uid, &internal_thumb_path); - ret = ms_user_get_mmc_thumb_store_path(uid, &external_thumb_path); + char *thumb_dir = NULL; - if (!STRING_VALID(internal_thumb_path) || !STRING_VALID(external_thumb_path)) { - media_svc_error("fail to get thumbnail path"); - SAFE_FREE(internal_thumb_path); - SAFE_FREE(external_thumb_path); + ret = ms_user_get_thumb_store_path(uid, storage_type, &thumb_dir); + if (!STRING_VALID(thumb_dir)) { + media_svc_error("ms_user_get_thumb_store_path failed"); return MS_MEDIA_ERR_INTERNAL; } - thumb_dir = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? internal_thumb_path : external_thumb_path; - ret = __media_svc_check_thumb_dir(thumb_dir); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("__media_svc_check_thumb_dir"); - SAFE_FREE(internal_thumb_path); - SAFE_FREE(external_thumb_path); + SAFE_FREE(thumb_dir); return MS_MEDIA_ERR_INTERNAL; } @@ -940,8 +931,7 @@ int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *t ret = mb_svc_generate_hash_code(pathname, hash, sizeof(hash)); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("mb_svc_generate_hash_code failed : %d", ret); - SAFE_FREE(internal_thumb_path); - SAFE_FREE(external_thumb_path); + SAFE_FREE(thumb_dir); return MS_MEDIA_ERR_INTERNAL; } @@ -957,8 +947,7 @@ int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *t thumbfile_ext = (char *)"bmp"; } else { media_svc_error("Not proper img format"); - SAFE_FREE(internal_thumb_path); - SAFE_FREE(external_thumb_path); + SAFE_FREE(thumb_dir); return MS_MEDIA_ERR_INTERNAL; } @@ -966,8 +955,7 @@ int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *t SAFE_STRLCPY(thumb_path, savename, MEDIA_SVC_PATHNAME_SIZE); /*media_svc_debug("thumb_path is [%s]", thumb_path); */ - SAFE_FREE(internal_thumb_path); - SAFE_FREE(external_thumb_path); + SAFE_FREE(thumb_dir); return MS_MEDIA_ERR_NONE; } diff --git a/src/common/media-svc.c b/src/common/media-svc.c index 3454c08..8787e3c 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -745,6 +745,7 @@ int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id int media_svc_delete_all_items_in_storage(const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; + char *thumb_path = NULL; media_svc_debug("media_svc_delete_all_items_in_storage [%d]", storage_type); @@ -755,25 +756,14 @@ int media_svc_delete_all_items_in_storage(const char *storage_id, media_svc_stor media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); if (storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) { - char *internal_thumb_path = NULL; - char *external_thumb_path = NULL; - - ret = ms_user_get_default_thumb_store_path(uid, &internal_thumb_path); - ret = ms_user_get_mmc_thumb_store_path(uid, &external_thumb_path); - - if (!STRING_VALID(internal_thumb_path) || !STRING_VALID(external_thumb_path)) { + ret = ms_user_get_thumb_store_path(uid, (ms_user_storage_type_e)storage_type, &thumb_path); + if (!STRING_VALID(thumb_path)) { media_svc_error("fail to get thumbnail path"); - SAFE_FREE(internal_thumb_path); - SAFE_FREE(external_thumb_path); return MS_MEDIA_ERR_INTERNAL; } - const char *dirpath = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? internal_thumb_path : external_thumb_path; - /* remove thumbnails */ - if (STRING_VALID(dirpath)) - ret = _media_svc_remove_all_files_in_dir(dirpath); - SAFE_FREE(internal_thumb_path); - SAFE_FREE(external_thumb_path); + ret = _media_svc_remove_all_files_in_dir(thumb_path); + SAFE_FREE(thumb_path); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); } -- 2.7.4