Use Common API in libmedia-util to get thumb store path
[platform/core/multimedia/libmedia-thumbnail.git] / src / media-thumb-internal.c
index 99e0cc1..ecd7d8e 100755 (executable)
@@ -1567,42 +1567,6 @@ int _media_thumb_video(const char *origin_path,
        return err;
 }
 
-static char* _media_thumb_mmc_get_path(uid_t uid)
-{
-       int ret = 0;
-       char *result_path = NULL;
-
-       ret = tzplatform_set_user(uid);
-       if (ret != 0) {
-               thumb_err("Invalid UID[%d]", uid);
-               return NULL;
-       } else {
-               const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/mmc");
-               result_path = strndup(result, strlen(result));
-               tzplatform_reset_user();
-       }
-
-       return result_path;
-}
-
-static char* _media_thumb_phone_get_path(uid_t uid)
-{
-       int ret = 0;
-       char *result_path = NULL;
-
-       ret = tzplatform_set_user(uid);
-       if (ret != 0) {
-               thumb_err("Invalid UID[%d]", uid);
-               return NULL;
-       } else {
-               const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/phone");
-               result_path = strndup(result, strlen(result));
-               tzplatform_reset_user();
-       }
-
-       return result_path;
-}
-
 int _media_thumb_get_hash_name(const char *file_full_path,
                                 char *thumb_hash_path, size_t max_thumb_path, uid_t uid)
 {
@@ -1612,7 +1576,7 @@ int _media_thumb_get_hash_name(const char *file_full_path,
        char *get_path = NULL;
        int ret_len = 0;
        ms_user_storage_type_t store_type = -1;
-       int ret = 0;
+       int ret = MS_MEDIA_ERR_NONE;
 
        if (file_full_path == NULL || thumb_hash_path == NULL || max_thumb_path <= 0) {
                thumb_err("file_full_path==NULL || thumb_hash_path == NULL || max_thumb_path <= 0");
@@ -1634,15 +1598,15 @@ int _media_thumb_get_hash_name(const char *file_full_path,
        }
 
        if (store_type == MS_USER_STORAGE_INTERNAL) {
-               get_path = _media_thumb_phone_get_path(uid);
+               ret = ms_user_get_default_thumb_store_path(uid, &get_path);
                if (get_path != NULL)
                        ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
        } else if (store_type == MS_USER_STORAGE_EXTERNAL) {
-               get_path = _media_thumb_mmc_get_path(uid);
+               ret = ms_user_get_mmc_thumb_store_path(uid, &get_path);
                if (get_path != NULL)
                        ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
        } else {
-               get_path = _media_thumb_phone_get_path(uid);
+               ret = ms_user_get_default_thumb_store_path(uid, &get_path);
                if (get_path != NULL)
                        ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
        }