int media_type = -1;
bool is_supported = false;
- media_content_retvm_if(!STRING_VALID(path), false, "path is empty");
+ content_retvm_if(!STRING_VALID(path), false, "path is empty");
if (MEDIA_CONTENT_OTHER_SUPPORT == -1) {
ret = system_info_get_platform_bool("http://tizen.org/feature/content.scanning.others", &is_supported);
if (ret != SYSTEM_INFO_ERROR_NONE) {
- media_content_debug("SYSTEM_INFO_ERROR: content.scanning.others [%d]", ret);
+ content_debug("SYSTEM_INFO_ERROR: content.scanning.others [%d]", ret);
return false;
}
/* If not, check media type */
if (!MEDIA_CONTENT_OTHER_SUPPORT) {
ret = media_svc_get_media_type(path, &media_type);
- media_content_retvm_if(ret != MS_MEDIA_ERR_NONE, false, "Failed to get media type");
+ content_retvm_if(ret != MS_MEDIA_ERR_NONE, false, "Failed to get media type");
if (media_type == MEDIA_CONTENT_TYPE_OTHERS)
return false;
exist = open(path, O_RDONLY);
if (exist < 0) {
if (errno == EACCES || errno == EPERM) {
- media_content_stderror("open file fail");
- media_content_sec_debug("path [%s]", path);
+ content_stderror("open file fail");
+ content_sec_debug("path [%s]", path);
return MEDIA_CONTENT_ERROR_PERMISSION_DENIED;
} else {
- media_content_stderror("open file fail");
- media_content_sec_debug("path [%s]", path);
+ content_stderror("open file fail");
+ content_sec_debug("path [%s]", path);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
}
memset(&statbuf, 0, sizeof(struct stat));
ret = stat(path, &statbuf);
if (ret == -1) {
- media_content_stderror("stat failed");
+ content_stderror("stat failed");
return ret;
}
int _media_util_check_ignore_file(const char *path, bool *ignore)
{
- media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
+ content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
*ignore = FALSE;
char *tmp_path = NULL;
/* Check is exist (It may be the path to the deleted file) */
if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
- media_content_sec_debug("removed path[%s]", path);
+ content_sec_debug("removed path[%s]", path);
return MEDIA_CONTENT_ERROR_NONE;
}
/* Check symbolic link file */
if (g_file_test(path, G_FILE_TEST_IS_SYMLINK)) {
*ignore = TRUE;
- media_content_error("symbolic link(file)");
- media_content_sec_debug("path : %s", path);
+ content_error("symbolic link(file)");
+ content_sec_debug("path : %s", path);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
/* Check hidden path */
if (strstr(path, "/.") != NULL) {
*ignore = TRUE;
- media_content_error("hidden path");
- media_content_sec_debug("path : %s", path);
+ content_error("hidden path");
+ content_sec_debug("path : %s", path);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
#ifdef _USE_TVPD_MODE
if (g_strcmp0(tmp_path, org_path) != 0) {
*ignore = TRUE;
- media_content_error("symbolic link(directory)");
- media_content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
+ content_error("symbolic link(directory)");
+ content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
SAFE_FREE(tmp_path);
SAFE_FREE(org_path);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
snprintf(replace, MAX_PATH_LEN, "%s%s", tzplatform_getenv(TZ_USER_MEDIASHARED), tmp_path + strlen(MEDIA_SHARE_PATH));
if (g_strcmp0(replace, org_path) != 0) {
*ignore = TRUE;
- media_content_error("symbolic link(directory)");
- media_content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
+ content_error("symbolic link(directory)");
+ content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
SAFE_FREE(tmp_path);
SAFE_FREE(org_path);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
} else {
if (g_strcmp0(tmp_path, org_path) != 0) {
*ignore = TRUE;
- media_content_error("symbolic link(directory)");
- media_content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
+ content_error("symbolic link(directory)");
+ content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
SAFE_FREE(tmp_path);
SAFE_FREE(org_path);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
result = g_file_test(ignore_path, G_FILE_TEST_EXISTS);
if (result)
- media_content_error("scan ignore file exist [%s]", ignore_path);
+ content_error("scan ignore file exist [%s]", ignore_path);
SAFE_FREE(ignore_path);
int ret = MEDIA_CONTENT_ERROR_NONE;
ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
- media_content_retvm_if(!STRING_VALID(dir_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dir_path");
- media_content_sec_debug("dir_path : %s", dir_path);
+ content_retvm_if(!STRING_VALID(dir_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dir_path");
+ content_sec_debug("dir_path : %s", dir_path);
*ignore = false;
/*1. Check Hidden Directory*/
if (strstr(dir_path, "/.") != NULL) {
*ignore = true;
- media_content_error("hidden path");
+ content_error("hidden path");
return MEDIA_CONTENT_ERROR_NONE;
}
/*2. Check Scan Ignore Directory*/
ret = ms_user_get_storage_type(_content_get_uid(), dir_path, &storage_type);
if (ret != MS_MEDIA_ERR_NONE) {
- media_content_error("ms_user_get_storage_type failed : %d", ret);
+ content_error("ms_user_get_storage_type failed : %d", ret);
return _content_error_capi(ret);
}
char search_path[MAX_PATH_LEN] = {0, };
memset(search_path, 0, sizeof(search_path));
- if (!SAFE_STRLCPY(search_path, dir_path, sizeof(search_path))) {
- media_content_error("MEDIA_CONTENT_ERROR_INVALID_OPERATION(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_OPERATION);
- return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- }
+ SAFE_STRLCPY(search_path, dir_path, sizeof(search_path));
while (STRING_VALID(search_path)) {
if ((*ignore = __is_scan_ignore_exist(search_path)))
dp = opendir(path);
if (dp == NULL) {
if (errno == EACCES || errno == EPERM) {
- media_content_stderror("open dir fail");
- media_content_sec_error("path [%s]", path);
+ content_stderror("open dir fail");
+ content_sec_error("path [%s]", path);
return MEDIA_CONTENT_ERROR_PERMISSION_DENIED;
} else {
- media_content_stderror("open dir fail");
- media_content_sec_error("path [%s]", path);
+ content_stderror("open dir fail");
+ content_sec_error("path [%s]", path);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
}
#ifdef _USE_TVPD_MODE
if (g_strcmp0(real, origin) != 0) {
- media_content_error("symbolic link(directory)");
- media_content_sec_debug("path[%s] real[%s]", origin, real);
+ content_error("symbolic link(directory)");
+ content_sec_debug("path[%s] real[%s]", origin, real);
SAFE_FREE(real);
SAFE_FREE(origin);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
/* If shared dirctory, it should be change path to TZ_USER_SHARE from realpath */
snprintf(result_path, MAX_PATH_LEN, "%s%s", tzplatform_getenv(TZ_USER_MEDIASHARED), real + strlen(MEDIA_SHARE_PATH));
if (g_strcmp0(result_path, origin) != 0) {
- media_content_error("symbolic link(directory)");
- media_content_sec_debug("path[%s] real[%s]", origin, real);
+ content_error("symbolic link(directory)");
+ content_sec_debug("path[%s] real[%s]", origin, real);
SAFE_FREE(real);
SAFE_FREE(origin);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
} else {
if (g_strcmp0(real, origin) != 0) {
- media_content_error("symbolic link(directory)");
- media_content_sec_debug("path[%s] real[%s]", origin, real);
+ content_error("symbolic link(directory)");
+ content_sec_debug("path[%s] real[%s]", origin, real);
SAFE_FREE(real);
SAFE_FREE(origin);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
-int _media_content_replace_path_in_condition(const char *condition, char *replace_condition, bool replace)
+/* FIXME : If there are no issue reports related to this, it will be deleted in tizen 6.5 or after. */
+char * _media_content_replace_path_in_condition(const char *condition)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
-#ifdef _USE_TVPD_MODE
- snprintf(replace_condition, MAX_QUERY_SIZE, "%s", condition);
-#else
- char old_condition[MAX_QUERY_SIZE] = {0, };
- char new_condition[MAX_QUERY_SIZE] = {0, };
- char *find = NULL;
- unsigned int str_len = 0;
-
- char *find_str = NULL;
- char *to_replace_str = NULL;
-
- if (replace == TRUE) { //change User session path to System session path
- find_str = g_strdup(MEDIA_ROOT_PATH_INTERNAL_OLD);
- if (!STRING_VALID(find_str)) {
- media_content_error("strdup failed");
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
-
- to_replace_str = g_strdup(MEDIA_ROOT_PATH_INTERNAL);
- if (!STRING_VALID(to_replace_str)) {
- media_content_error("Get TZ_USER_CONTENT failed");
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
- } else {
- find_str = g_strdup(MEDIA_ROOT_PATH_INTERNAL);
- if (!STRING_VALID(find_str)) {
- media_content_error("Get TZ_USER_CONTENT failed");
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
-
- to_replace_str = g_strdup(MEDIA_ROOT_PATH_INTERNAL_OLD);
- if (!STRING_VALID(to_replace_str)) {
- media_content_error("strdup failed");
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
- }
-
- memset(old_condition, 0, sizeof(old_condition));
- memset(new_condition, 0, sizeof(new_condition));
-
- media_content_sec_debug("Old condition[%s]", condition);
-
- if (!SAFE_STRLCPY(new_condition, condition, sizeof(new_condition))) {
- media_content_error("MEDIA_CONTENT_ERROR_INVALID_OPERATION(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_OPERATION);
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
-
- if (g_strcmp0(find_str, to_replace_str))
- find = strstr(new_condition, find_str);
-
- while (find != NULL) {
- str_len = find - new_condition;
-
- memset(old_condition, 0, sizeof(old_condition));
- if (!SAFE_STRLCPY(old_condition, new_condition, sizeof(old_condition))) {
- media_content_error("MEDIA_CONTENT_ERROR_INVALID_OPERATION(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_OPERATION);
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
- memset(new_condition, 0, sizeof(new_condition));
-
- snprintf(new_condition, str_len + 1, "%s", old_condition);
+ return g_strdup(condition);
+#if 0
+ char **split_list = NULL;
+ char *result = NULL;
- SAFE_STRLCAT(new_condition, to_replace_str, sizeof(new_condition));
- SAFE_STRLCAT(new_condition, old_condition + str_len + strlen(find_str), sizeof(new_condition));
-
- find = strstr(new_condition, find_str);
- }
+ if (!STRING_VALID(MEDIA_ROOT_PATH_INTERNAL_OLD) || !STRING_VALID(MEDIA_ROOT_PATH_INTERNAL))
+ return NULL;
- if (!SAFE_STRLCPY(replace_condition, new_condition, MAX_QUERY_SIZE)) {
- media_content_error("MEDIA_CONTENT_ERROR_INVALID_OPERATION(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_OPERATION);
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
+ content_sec_debug("Old condition[%s]", condition);
- media_content_sec_debug("repl cond[%s]", replace_condition);
+ split_list = g_strsplit(condition, MEDIA_ROOT_PATH_INTERNAL_OLD, -1);
+ if (!split_list)
+ return NULL;
- if (!STRING_VALID(replace_condition)) {
- media_content_error("replace failed");
- ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- goto ERROR;
- }
+ result = g_strjoinv(MEDIA_ROOT_PATH_INTERNAL, split_list);
+ g_strfreev(split_list);
-ERROR:
- SAFE_FREE(find_str);
- SAFE_FREE(to_replace_str);
+ return result;
#endif
-
- return ret;
}
+/* FIXME : If there are no issue reports related to this, it will be deleted in Tizen 6.5 or after. */
int _media_content_replace_path(const char *path, char *replace_path)
{
-#ifdef _USE_TVPD_MODE
+ content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
+
snprintf(replace_path, MAX_PATH_LEN, "%s", path);
-#else
+#if 0
if (strncmp(path, MEDIA_ROOT_PATH_INTERNAL_OLD, strlen(MEDIA_ROOT_PATH_INTERNAL_OLD)) == 0) {
- media_content_sec_debug("Old path[%s]", path);
+ content_sec_debug("Old path[%s]", path);
snprintf(replace_path, MAX_PATH_LEN, "%s%s", MEDIA_ROOT_PATH_INTERNAL, path + strlen(MEDIA_ROOT_PATH_INTERNAL_OLD));
} else {
snprintf(replace_path, MAX_PATH_LEN, "%s", path);
}
#endif
- if (!STRING_VALID(replace_path)) {
- media_content_error("replace failed");
- return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- }
-
return MEDIA_CONTENT_ERROR_NONE;
}
bool bSupportSeniorMode = false;
if (system_info_get_value_bool(SYSTEM_INFO_KEY_GET_SENIOR_MODE_SUPPORTED, &bSupportSeniorMode) != SYSTEM_INFO_ERROR_NONE) {
- media_content_debug("Get senior mode support failed");
+ content_debug("Get senior mode support failed");
return false;
}
- /* media_content_debug("Senior mode Support : [%d]", bSupportSeniorMode); */
+ /* content_debug("Senior mode Support : [%d]", bSupportSeniorMode); */
return bSupportSeniorMode;
}
#endif