Merge function for getting thumbnail folder 08/144608/2 accepted/tizen/4.0/unified/20170829.015810 accepted/tizen/unified/20170822.023752 accepted/tizen/unified/20170824.051005 submit/tizen/20170821.010252 submit/tizen/20170824.010707 submit/tizen_4.0/20170828.100004 submit/tizen_4.0/20170828.110004
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 17 Aug 2017 08:16:58 +0000 (17:16 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 17 Aug 2017 08:20:17 +0000 (17:20 +0900)
Change-Id: I62f8355638aa441fe2352ae323021ac1d97d1f48
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
packaging/libmedia-service.spec
src/common/media-svc-util.c
src/common/media-svc.c

index 3948a37..3ef1e8f 100644 (file)
@@ -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
index 4aec387..2ad5b82 100755 (executable)
@@ -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;
 }
index 3454c08..8787e3c 100755 (executable)
@@ -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);
        }