-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6...2.8.12)
SET(fw_name "capi-content-media-content")
PROJECT(${fw_name})
Name: capi-content-media-content
Summary: A Media content library in Tizen Native API
-Version: 0.4.31
+Version: 0.5.0
Release: 0
Group: Multimedia/API
License: Apache-2.0
content_retip_if_fail(_content_get_db_handle());
content_retip_if_fail(query);
- content_sec_debug("Query[%s]", query);
+ content_debug("Query[%s]", query);
err = sqlite3_prepare_v2(_content_get_db_handle(), query, strlen(query), stmt, NULL);
if (err != SQLITE_OK) {
ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
- content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", path);
+ content_error("This item is already inserted. This may be normal operation because other process already did this");
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
+ content_error("media_svc_insert_item_immediately failed : %d", ret);
}
return _content_error_capi(ret);
ret = _media_content_check_dir(path);
content_retvm_if(ret == MEDIA_CONTENT_ERROR_PERMISSION_DENIED, ret, "Permission Denied");
+ content_sec_debug("Path : %s", path);
+
if (ret == MEDIA_CONTENT_ERROR_NONE) {
/* If directory exist check that's ignore directory or not*/
content_retvm_if(_media_util_is_ignorable_dir(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
/* This means this folder has to be deleted */
/* Or, it is real invalid path.. check storage type */
if (!ms_user_is_valid_path(_content_get_uid(), path)) {
- content_sec_error("ms_user_is_valid_path failed : %d (%s)", ret, path);
+ content_error("ms_user_is_valid_path failed : %d", ret);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
content_retip_if_fail(STRING_VALID(path));
content_retip_if_fail(callback);
+ content_sec_debug("Path : %s", path);
+
content_retvm_if(!_is_mounted(path), MEDIA_CONTENT_ERROR_PERMISSION_DENIED, "path is not mounted");
content_retvm_if(_media_util_is_ignorable_dir(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
case MEDIA_GROUP_FOLDER:
select_query = g_strdup(SELECT_FOLDER_COUNT);
break;
-
+// LCOV_EXCL_START
case MEDIA_GROUP_PLAYLIST:
select_query = g_strdup(SELECT_PLAYLIST_COUNT);
break;
case MEDIA_GROUP_FACE:
select_query = g_strdup(SELECT_FACE_COUNT);
break;
-
+// LCOV_EXCL_STOP
default:
content_error("Invalid group type [%d]", group_type);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
return ret;
}
-
+// LCOV_EXCL_START
int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
return ret;
}
-
+// LCOV_EXCL_STOP
int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
select_query = g_strdup_printf(SELECT_MEDIA_COUNT_FROM_ALBUM, group_id);
#endif
break;
-
+// LCOV_EXCL_START
case MEDIA_GROUP_PLAYLIST:
select_query = g_strdup_printf(SELECT_MEDIA_COUNT_FROM_PLAYLIST, group_id);
break;
case MEDIA_GROUP_TAG:
select_query = g_strdup_printf(SELECT_MEDIA_COUNT_FROM_TAG, group_id);
break;
-
+// LCOV_EXCL_STOP
default:
content_error("INVALID_PARAMETER");
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
select_query = g_strdup_printf(SELECT_MEDIA_FROM_ALBUM, group_id);
#endif
break;
-
+// LCOV_EXCL_START
case MEDIA_GROUP_PLAYLIST:
#ifdef _USE_TVPD_MODE
if (_filter && STRING_VALID(_filter->storage_id))
select_query = g_strdup_printf(SELECT_MEDIA_FROM_TAG, group_id);
#endif
break;
-
+// LCOV_EXCL_STOP
default:
content_error("INVALID_PARAMETER");
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
else
*result = g_strdup_printf("(%s%s)", condition, __get_collate_str(collate_type));
- content_sec_debug("Condition : %s", *result);
+ content_debug("Condition : %s", *result);
return MEDIA_CONTENT_ERROR_NONE;
}
_filter->condition = g_strdup(condition);
- content_sec_debug("Condition string : %s", _filter->condition);
+ content_debug("Condition string : %s", _filter->condition);
_filter->condition_collate_type = collate_type;
g_free(_filter->storage_id);
_filter->storage_id = g_strdup(storage_id);
- content_sec_debug("storage_id : %s", _filter->storage_id);
+ content_debug("storage_id : %s", _filter->storage_id);
return MEDIA_CONTENT_ERROR_NONE;
}
return MEDIA_CONTENT_ERROR_NONE;
}
-
+// LCOV_EXCL_START
int media_filter_set_condition_v2(filter_h filter, const char *condition)
{
filter_s *_filter = (filter_s *)filter;
_filter->condition = g_strdup(condition);
- content_sec_debug("Condition string : %s", _filter->condition);
+ content_debug("Condition string : %s", _filter->condition);
return MEDIA_CONTENT_ERROR_NONE;
}
return MEDIA_CONTENT_ERROR_NONE;
}
+// LCOV_EXCL_STOP
\ No newline at end of file
fp = fopen(list_path, "w");
if (fp == NULL) {
- content_sec_error("failed to open file : [%s]", list_path);
content_stderror("failed to open file");
return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
}
content_retip_if_fail(STRING_VALID(path));
content_retip_if_fail(info);
+ content_sec_debug("path [%s]", path);
+
ret = __media_info_check_file_validity(path);
content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
}
}
} else if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
- content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", path);
content_retvm_if(!_media_util_check_support_media_type(path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
- content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", path);
+ content_info("This item is already inserted. This may be normal operation because other process already did this");
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
+ content_error("media_svc_insert_item_immediately failed : %d", ret);
}
return _content_error_capi(ret);
}
} else {
- content_sec_error("media_svc_get_modified_time failed : %d (%s)", ret, path);
+ content_error("media_svc_get_modified_time failed : %d", ret);
return _content_error_capi(ret);
}
return ret;
}
-
+// LCOV_EXCL_START
int media_info_get_video(media_info_h media, video_meta_h *video)
{
content_warn("DEPRECATION WARNING: media_info_get_video() is deprecated and will be removed from next release.");
return ret;
}
-
+// LCOV_EXCL_STOP
int media_info_get_audio(media_info_h media, audio_meta_h *audio)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
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) {
- content_debug("SYSTEM_INFO_ERROR: content.scanning.others [%d]", ret);
- return false;
- }
+ content_retvm_if(ret != SYSTEM_INFO_ERROR_NONE, false, "SYSTEM_INFO_ERROR: content.scanning.others [%d]", ret);
MEDIA_CONTENT_OTHER_SUPPORT = is_supported;
}
if (!MEDIA_CONTENT_OTHER_SUPPORT) {
ret = media_svc_get_media_type(path, &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;
+ content_retv_if(media_type == MEDIA_CONTENT_TYPE_OTHERS, false);
}
return true;
if (exist < 0) {
if (errno == EACCES || errno == EPERM) {
content_stderror("open file fail");
- content_sec_debug("path [%s]", path);
return MEDIA_CONTENT_ERROR_PERMISSION_DENIED;
} else {
content_stderror("open file fail");
- content_sec_debug("path [%s]", path);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
}
int _media_util_get_file_time(const char *path)
{
- struct stat statbuf;
- int ret = 0;
-
- memset(&statbuf, 0, sizeof(struct stat));
- ret = stat(path, &statbuf);
- if (ret == -1) {
- content_stderror("stat failed");
- return ret;
- }
+ struct stat statbuf = { 0, };
+
+ content_retvm_if(stat(path, &statbuf) == -1, 0, "stat failed");
return statbuf.st_mtime;
}
bool _media_util_is_ignorable_file(const char *path)
{
char *tmp_path = NULL;
- char *org_path = NULL;
+ g_autofree gchar *org_path = NULL;
#ifndef _USE_TVPD_MODE
char replace[MAX_PATH_LEN] = {0, };
content_retip_if_fail(STRING_VALID(path));
/* Check is exist (It may be the path to the deleted file) */
- if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
- content_sec_debug("removed path[%s]", path);
- return false;
- }
+ content_retvm_if(!g_file_test(path, G_FILE_TEST_EXISTS), false, "removed path");
/* Check symbolic link file */
- if (g_file_test(path, G_FILE_TEST_IS_SYMLINK)) {
- content_error("symbolic link(file)");
- content_sec_debug("path : %s", path);
- return true;
- }
+ content_retvm_if(g_file_test(path, G_FILE_TEST_IS_SYMLINK), true, "symbolic link(file)");
/* Check hidden path */
- if (strstr(path, "/.") != NULL) {
- content_error("hidden path");
- content_sec_debug("path : %s", path);
- return true;
- }
+ content_retvm_if(strstr(path, "/."), true, "hidden path");
/* Check symbolic directory */
tmp_path = realpath(path, NULL);
#ifdef _USE_TVPD_MODE
if (g_strcmp0(tmp_path, org_path) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
SAFE_FREE(tmp_path);
- g_free(org_path);
return true;
}
#else
snprintf(replace, MAX_PATH_LEN, "%s%s", tzplatform_getenv(TZ_USER_MEDIASHARED), tmp_path + strlen(tzplatform_getenv(TZ_SYS_MEDIASHARED)));
if (g_strcmp0(replace, org_path) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
SAFE_FREE(tmp_path);
- g_free(org_path);
return true;
}
} else {
if (g_strcmp0(tmp_path, org_path) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
SAFE_FREE(tmp_path);
- g_free(org_path);
return true;
}
}
#endif
SAFE_FREE(tmp_path);
- g_free(org_path);
return false;
}
bool _media_util_is_ignorable_dir(const char *dir_path)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
if (!STRING_VALID(dir_path))
return true;
- content_sec_debug("dir_path : %s", dir_path);
-
/*1. Check Hidden Directory*/
- if (strstr(dir_path, "/.") != NULL) {
- content_error("hidden path");
- return true;
- }
+ content_retvm_if(strstr(dir_path, "/."), true, "hidden path");
/*2. Check Scan Ignore Directory*/
- if (!ms_user_is_valid_path(_content_get_uid(), dir_path)) {
- content_error("ms_user_is_valid_path failed : %d", ret);
- return true;
- }
+ content_retvm_if(!ms_user_is_valid_path(_content_get_uid(), dir_path), true, "ms_user_is_valid_path failed");
char *leaf_path = NULL;
char search_path[MAX_PATH_LEN] = {0, };
{
DIR *dp = NULL;
char *real = NULL;
- char *origin = NULL;
+ g_autofree gchar *origin = NULL;
#ifndef _USE_TVPD_MODE
char result_path[MAX_PATH_LEN] = {0, };
#endif
if (dp == NULL) {
if (errno == EACCES || errno == EPERM) {
content_stderror("open dir fail");
- content_sec_error("path [%s]", path);
return MEDIA_CONTENT_ERROR_PERMISSION_DENIED;
} else {
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) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", origin, real);
SAFE_FREE(real);
- g_free(origin);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
#else
snprintf(result_path, MAX_PATH_LEN, "%s%s", tzplatform_getenv(TZ_USER_MEDIASHARED), real + strlen(tzplatform_getenv(TZ_SYS_MEDIASHARED)));
if (g_strcmp0(result_path, origin) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", origin, real);
SAFE_FREE(real);
- g_free(origin);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
} else {
if (g_strcmp0(real, origin) != 0) {
content_error("symbolic link(directory)");
- content_sec_debug("path[%s] real[%s]", origin, real);
SAFE_FREE(real);
- g_free(origin);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
}
#endif
SAFE_FREE(real);
- g_free(origin);
return MEDIA_CONTENT_ERROR_NONE;
}