From: minje.ahn Date: Wed, 6 Mar 2024 04:05:42 +0000 (+0900) Subject: Use tzplatform API directly X-Git-Tag: accepted/tizen/unified/20240308.174226~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eecdb3ec4082d8cb737761f3fe315a32a6257944;p=platform%2Fcore%2Fmultimedia%2Fmedia-server.git Use tzplatform API directly Change-Id: Idd3ac5edc57bbb92baa578f5d0662eaaadce1b70 Signed-off-by: minje.ahn --- diff --git a/lib/include/media-util.h b/lib/include/media-util.h index 494ac99..741d40e 100644 --- a/lib/include/media-util.h +++ b/lib/include/media-util.h @@ -31,14 +31,6 @@ #include -#define MEDIA_ROOT_PATH_INTERNAL tzplatform_getenv(TZ_USER_CONTENT) -#define MEDIA_ROOT_PATH_EXTERNAL tzplatform_getenv(TZ_SYS_STORAGE) -#define MEDIA_ROOT_PATH_SDCARD tzplatform_mkpath(TZ_SYS_STORAGE, "SDCard") -#define MEDIA_ROOT_PATH_USB tzplatform_getenv(TZ_SYS_STORAGE) -#ifndef _USE_TVPD_MODE -#define MEDIA_SHARE_PATH tzplatform_getenv(TZ_SYS_MEDIASHARED) -#endif - #ifdef _USE_TVPD_MODE #define MEDIA_DB_SIZE_LIMIT_2 20000000 #define MEDIA_DB_SIZE_LIMIT_1 10000000 diff --git a/lib/media-util-user.c b/lib/media-util-user.c index 4c133ee..849dc3f 100644 --- a/lib/media-util-user.c +++ b/lib/media-util-user.c @@ -96,7 +96,7 @@ int ms_user_get_internal_root_path(uid_t uid, char **path) if (uid != getuid()) return __ms_user_get_path(INTERNAL_ROOT, uid, path); - *path = g_strndup(MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL)); + *path = g_strdup(tzplatform_getenv(TZ_USER_CONTENT)); return MS_MEDIA_ERR_NONE; } @@ -119,7 +119,7 @@ bool ms_user_is_valid_path(uid_t uid, const char *path) if (__ms_user_is_internal(uid, path)) return true; - if (MS_STRING_VALID(MEDIA_ROOT_PATH_EXTERNAL) && g_str_has_prefix(path, MEDIA_ROOT_PATH_EXTERNAL)) + if (g_str_has_prefix(path, tzplatform_getenv(TZ_SYS_STORAGE))) return true; MSAPI_DBG_ERR("Invalid path[%s]", path); @@ -132,7 +132,7 @@ bool ms_user_thumb_support(uid_t uid, const char *path) if (__ms_user_is_internal(uid, path)) return true; - if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && g_str_has_prefix(path, MEDIA_ROOT_PATH_SDCARD)) + if (g_str_has_prefix(path, tzplatform_mkpath(TZ_SYS_STORAGE, "SDCard"))) return true; return false; diff --git a/src/common/media-common-utils-tv.c b/src/common/media-common-utils-tv.c index a7a40cc..9451c81 100644 --- a/src/common/media-common-utils-tv.c +++ b/src/common/media-common-utils-tv.c @@ -130,7 +130,7 @@ bool ms_storage_mount_status(const char *start_path) char *remain_path = NULL; int remain_len = 0; - remain_path = strstr(start_path + strlen(MEDIA_ROOT_PATH_USB) + 1, "/"); + remain_path = strstr(start_path + strlen(tzplatform_getenv(TZ_SYS_STORAGE)) + 1, "/"); if (remain_path != NULL) remain_len = strlen(remain_path); @@ -296,12 +296,12 @@ int ms_check_scan_ignore(char *path, uid_t uid) MS_DBG_ERR("g_file_test fails[%s]", path); ret = MS_MEDIA_ERR_INVALID_PARAMETER; - if (!MS_STRING_VALID(MEDIA_ROOT_PATH_USB)) { + if (!tzplatform_getenv(TZ_SYS_STORAGE)) { MS_DBG_ERR("Fail to get USB path"); return ret; } - if (strstr(path, MEDIA_ROOT_PATH_USB) != NULL) { + if (strstr(path, tzplatform_getenv(TZ_SYS_STORAGE)) != NULL) { /*if the directory does not exist, check the device is unmounted*/ if (!ms_storage_mount_status(path)) { MS_DBG_ERR("Device is unmounted[%s]", path); diff --git a/src/common/media-common-utils.c b/src/common/media-common-utils.c index 9ca042c..3536ad8 100644 --- a/src/common/media-common-utils.c +++ b/src/common/media-common-utils.c @@ -90,7 +90,7 @@ bool ms_is_valid_symlink(const char *path) if (!real_path) return false; - return (g_strcmp0(real_path, MEDIA_SHARE_PATH) == 0); + return (g_strcmp0(real_path, tzplatform_getenv(TZ_SYS_MEDIASHARED)) == 0); } int ms_check_scan_ignore(char *path, uid_t uid) @@ -109,9 +109,9 @@ int ms_check_scan_ignore(char *path, uid_t uid) /* Get trimmed path */ org_path = g_canonicalize_filename(path, NULL); - if (g_str_has_prefix(tmp_path, MEDIA_SHARE_PATH)) { + if (g_str_has_prefix(tmp_path, tzplatform_getenv(TZ_SYS_MEDIASHARED))) { ms_user_get_mediashared_path(uid, &mediashared); - snprintf(replace, MAX_FILEPATH_LEN, "%s%s", mediashared, tmp_path + strlen(MEDIA_SHARE_PATH)); + snprintf(replace, MAX_FILEPATH_LEN, "%s%s", mediashared, tmp_path + strlen(tzplatform_getenv(TZ_SYS_MEDIASHARED))); MS_SAFE_FREE(mediashared); if (g_strcmp0(replace, org_path) != 0) { MS_SAFE_FREE(tmp_path); diff --git a/src/scanner-v2/media-scanner-extract-v2.c b/src/scanner-v2/media-scanner-extract-v2.c index 6ad5368..a1b56e1 100644 --- a/src/scanner-v2/media-scanner-extract-v2.c +++ b/src/scanner-v2/media-scanner-extract-v2.c @@ -328,7 +328,7 @@ gpointer msc_storage_extract_thread(gpointer data) goto NEXT; } - if (MEDIA_ROOT_PATH_EXTERNAL && g_str_has_prefix(extract_data->msg, MEDIA_ROOT_PATH_EXTERNAL)) { + if (g_str_has_prefix(extract_data->msg, tzplatform_getenv(TZ_SYS_STORAGE))) { if (!ms_storage_mount_status(extract_data->msg)) { MS_DBG_ERR("%s is unmounted", extract_data->msg); ret = MS_MEDIA_ERR_USB_UNMOUNTED; diff --git a/src/scanner-v2/media-scanner-scan-v2.c b/src/scanner-v2/media-scanner-scan-v2.c index c0ef135..a383c97 100644 --- a/src/scanner-v2/media-scanner-scan-v2.c +++ b/src/scanner-v2/media-scanner-scan-v2.c @@ -559,12 +559,12 @@ NEXT_SCAN: usleep(SCAN_SLEEP_TIME); } - if (!MS_STRING_VALID(MEDIA_ROOT_PATH_USB)) { + if (!tzplatform_getenv(TZ_SYS_STORAGE)) { MS_DBG_ERR("Fail to get USB path"); goto END_SCAN; } - if (strstr(new_start_path, MEDIA_ROOT_PATH_USB) != NULL) { + if (strstr(new_start_path, tzplatform_getenv(TZ_SYS_STORAGE)) != NULL) { if (!ms_storage_mount_status(new_start_path)) { MS_DBG_ERR("start path is unmounted"); goto END_SCAN; @@ -659,12 +659,12 @@ static int __msc_dir_and_storage_scan_same_path(char *start_path) char *remain_path = NULL; size_t remain_len = 0; - if (!MS_STRING_VALID(MEDIA_ROOT_PATH_USB)) { + if (!tzplatform_getenv(TZ_SYS_STORAGE)) { MS_DBG_ERR("Fail to get USB path"); return MS_MEDIA_ERR_INTERNAL; } - remain_path = strstr(start_path+strlen(MEDIA_ROOT_PATH_USB) +1, "/"); + remain_path = strstr(start_path+strlen(tzplatform_getenv(TZ_SYS_STORAGE)) +1, "/"); if (remain_path != NULL) remain_len = strlen(remain_path); diff --git a/src/server/media-server-socket.c b/src/server/media-server-socket.c index 9d43eb1..c52c289 100644 --- a/src/server/media-server-socket.c +++ b/src/server/media-server-socket.c @@ -212,7 +212,7 @@ gboolean ms_read_scanner_dispatcher_socket_func(GIOChannel *src, GIOCondition co if (ret != MS_MEDIA_ERR_NONE) goto ERROR; - if (strncmp(recv_msg.msg, MEDIA_ROOT_PATH_EXTERNAL, strlen(MEDIA_ROOT_PATH_EXTERNAL)) == 0) + if (g_str_has_prefix(recv_msg.msg, tzplatform_getenv(TZ_SYS_STORAGE))) ret = ms_cynara_check(&creds, EXTERNAL_STORAGE_PRIVILEGE); else ret = ms_cynara_check(&creds, MEDIA_STORAGE_PRIVILEGE);