}
g_free(_cb_data);
-
- return;
}
// LCOV_EXCL_START
static bool __media_info_isFaceRecognition_feature_supported(void)
return isFaceRecognitionSupported;
}
-
// LCOV_EXCL_STOP
static int __media_info_insert_batch(const char **path_array,
unsigned int array_length,
FILE *fp = NULL;
char list_path[BATCH_REQUEST_FILE_LEN] = {0, };
unsigned int idx = 0;
- int nwrites = 0;
+ size_t size = 0;
for (idx = 0; idx < BATCH_REQUEST_MAX; idx++) {
- snprintf(list_path, BATCH_REQUEST_FILE_LEN, "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), idx);
+ snprintf(list_path, BATCH_REQUEST_FILE_LEN, "/tmp/request-%ld-%d", media_content_gettid(), idx);
if (g_file_test(list_path, G_FILE_TEST_EXISTS)) {
memset(list_path, 0x00, BATCH_REQUEST_FILE_LEN);
}
}
- if (idx == BATCH_REQUEST_MAX) {
- content_error("Too many batch request for one thread");
- return MEDIA_CONTENT_ERROR_DB_BUSY;
- }
+ content_retvm_if(idx == BATCH_REQUEST_MAX, MEDIA_CONTENT_ERROR_DB_BUSY, "Too many request");
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;
}
for (idx = 0; idx < array_length; idx++) {
- if (STRING_VALID(path_array[idx])) {
- int size = strlen(path_array[idx]);
-
- ret = __media_info_check_file_validity(path_array[idx]);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- fclose(fp);
- if (unlink(list_path) < 0)
- content_stderror("failed to delete");
- return ret;
- }
+ if (!STRING_VALID(path_array[idx])) {
+ content_error("path[%d] is invalid string", idx);
+ continue;
+ }
- if (!_media_util_check_support_media_type(path_array[idx])) {
- fclose(fp);
- if (unlink(list_path) < 0)
- content_stderror("failed to delete");
- return MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
- }
+ ret = __media_info_check_file_validity(path_array[idx]);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ goto ERROR;
- nwrites = fwrite(path_array[idx], 1, size, fp);
- if (nwrites != size) {
- content_stderror("failed to write");
- fclose(fp);
- if (unlink(list_path) < 0)
- content_stderror("failed to delete");
- return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- }
+ if (!_media_util_check_support_media_type(path_array[idx])) {
+ content_error("Not supported type: index[%d]", idx);
+ ret = MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
+ goto ERROR;
+ }
- nwrites = fwrite("\n", 1, 1, fp);
- if (nwrites != 1) {
- content_stderror("failed to write");
- fclose(fp);
- if (unlink(list_path) < 0)
- content_stderror("failed to delete");
- return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- }
- } else {
- content_error("path[%d] is invalid string", idx);
+ size = strlen(path_array[idx]);
+ if (fwrite(path_array[idx], 1, size, fp) != size) {
+ content_stderror("failed to write");
+ ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+ goto ERROR;
+ }
+
+ if (fwrite("\n", 1, 1, fp) != 1) {
+ content_stderror("failed to write");
+ ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+ goto ERROR;
}
}
return _content_error_capi(ret);
}
+ return MEDIA_CONTENT_ERROR_NONE;
+ERROR:
+ fclose(fp);
+ if (unlink(list_path) < 0)
+ content_stderror("failed to delete");
+
return ret;
}
static int __media_info_check_file_validity(const char *path)
{
- char *folder_path = NULL;
+ g_autofree gchar *folder_path = NULL;
int ret = MEDIA_CONTENT_ERROR_NONE;
content_retip_if_fail(path);
-
content_retvm_if(_media_util_is_ignorable_file(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid ignore path");
ret = _media_util_check_file_exist(path);
folder_path = g_path_get_dirname(path);
if (_media_util_is_ignorable_dir(folder_path))
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-
- g_free(folder_path);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
+void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media)
{
media_info_s *_media = (media_info_s*)media;
select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, storage_id, path);
ret = _content_get_result(select_query, &stmt);
- SQLITE3_SAFE_FREE(select_query);
+ sqlite3_free(select_query);
content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
if (sqlite3_step(stmt) == SQLITE_ROW) {
ret = MEDIA_CONTENT_ERROR_DB_FAILED;
}
- SQLITE3_FINALIZE(stmt);
+ sqlite3_finalize(stmt);
return ret;
}
select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
ret = _content_get_result(select_query, &stmt);
- SQLITE3_SAFE_FREE(select_query);
+ sqlite3_free(select_query);
content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
if (sqlite3_step(stmt) == SQLITE_ROW) {
ret = MEDIA_CONTENT_ERROR_DB_FAILED;
}
- SQLITE3_FINALIZE(stmt);
+ sqlite3_finalize(stmt);
return ret;
}
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);
}
media_info_s *_media = g_new0(media_info_s, 1);
#ifdef _USE_TVPD_MODE
- if (STRING_VALID(storage_id))
+ if (strlen(storage_id) > 0)
ret = _media_info_get_media_info_from_db(path, storage_id, (media_info_h)_media);
else
ret = _media_info_get_media_info_from_db(path, DB_TABLE_MEDIA, (media_info_h)_media);
select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
ret = _content_get_result(select_query, &stmt);
- SQLITE3_SAFE_FREE(select_query);
+ sqlite3_free(select_query);
content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
if (sqlite3_step(stmt) == SQLITE_ROW) {
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- SQLITE3_FINALIZE(stmt);
+ sqlite3_finalize(stmt);
return ret;
}
g_free(_media->thumbnail_path);
g_free(_media->description);
g_free(_media->title);
-#ifdef _USE_TVPD_MODE
- g_free(_media->modified_month);
-#endif
g_free(_media->storage_uuid);
if (_media->image_meta) {
_dst->description = g_strdup(_src->description);
_dst->title = g_strdup(_src->title);
_dst->storage_uuid = g_strdup(_src->storage_uuid);
-#ifdef _USE_TVPD_MODE
- _dst->modified_month = g_strdup(_src->modified_month);
-#endif
_dst->media_type = _src->media_type;
_dst->size = _src->size;
_dst->added_time = _src->added_time;
_dst->rating = _src->rating;
_dst->favourite = _src->favourite;
_dst->is_drm = _src->is_drm;
- _dst->request_id = _src->request_id;
_dst->face_request_id = _src->face_request_id;
_dst->is_360 = _src->is_360;
#ifdef _USE_TVPD_MODE
return _media_db_get_tag(media_id, filter, callback, user_data);
}
-// LCOV_EXCL_STOP
+
int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
{
+ content_warn("DEPRECATION WARNING: media_info_get_bookmark_count_from_db() is deprecated and will be removed from next release.");
content_retip_if_fail(STRING_VALID(media_id));
content_retip_if_fail(bookmark_count);
int media_info_foreach_bookmark_from_db(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
{
+ content_warn("DEPRECATION WARNING: media_info_foreach_bookmark_from_db() is deprecated and will be removed from next release.");
content_retip_if_fail(STRING_VALID(media_id));
content_retip_if_fail(callback);
return _media_db_get_bookmark(media_id, filter, callback, user_data);
}
-// LCOV_EXCL_START
+
int media_info_get_face_count_from_db(const char *media_id, filter_h filter, int *face_count)
{
content_warn("DEPRECATION WARNING: media_info_get_face_count_from_db() is deprecated and will be removed from next release.");
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;
return MEDIA_CONTENT_ERROR_NONE;
}
-
-int media_info_get_modified_month(media_info_h media, char **modified_month)
-{
- media_info_s *_media = (media_info_s*)media;
-
- content_retip_if_fail(media);
- content_retip_if_fail(modified_month);
-
- *modified_month = g_strdup(_media->modified_month);
-
- return MEDIA_CONTENT_ERROR_NONE;
-}
-
#endif
int media_info_get_media_from_db(const char *media_id, media_info_h *media)
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- SQLITE3_FINALIZE(stmt);
+ sqlite3_finalize(stmt);
return ret;
}
_media = g_new0(media_info_s, 1);
#ifdef _USE_TVPD_MODE
- ret = _media_info_get_media_info_from_db(path, STRING_VALID(storage_id) ? storage_id : DB_TABLE_MEDIA, (media_info_h)_media);
+ ret = _media_info_get_media_info_from_db(path, (strlen(storage_id) > 0) ? storage_id : DB_TABLE_MEDIA, (media_info_h)_media);
#else
ret = _media_info_get_media_info_from_db(path, (media_info_h)_media);
#endif
sql = sqlite3_mprintf("UPDATE %q SET media_favourite=%d WHERE media_id=%Q", DB_TABLE_MEDIA, _media->favourite, _media->media_id);
#endif
ret = _content_query_sql(sql);
- SQLITE3_SAFE_FREE(sql);
+ sqlite3_free(sql);
if (ret == MEDIA_CONTENT_ERROR_NONE) {
/* Send notification for this update */
media_info_s *_media = (media_info_s*)media;
/* If dst_path is folder, append file_name */
- SAFE_STRLCPY(repl_path, dst_path, MAX_PATH_LEN);
+ g_strlcpy(repl_path, dst_path, MAX_PATH_LEN);
if (g_file_test(repl_path, G_FILE_TEST_IS_DIR)) {
if (repl_path[strlen(repl_path) - 1] != '/')
- SAFE_STRLCAT(repl_path, "/", MAX_PATH_LEN);
+ g_strlcat(repl_path, "/", MAX_PATH_LEN);
- SAFE_STRLCAT(repl_path, _media->display_name, MAX_PATH_LEN);
+ g_strlcat(repl_path, _media->display_name, MAX_PATH_LEN);
}
/* If the two paths are the same, do nothing */
ret = _media_info_get_media_info_from_db(repl_path, (media_info_h)_info);
#endif
- SAFE_FREE(_media->display_name);
+ g_free(_media->display_name);
_media->display_name = g_strdup(_info->display_name);
- SAFE_FREE(_media->file_path);
+ g_free(_media->file_path);
_media->file_path = g_strdup(_info->file_path);
- SAFE_FREE(_media->storage_uuid);
+ g_free(_media->storage_uuid);
_media->storage_uuid = g_strdup(_info->storage_uuid);
- SAFE_FREE(_media->thumbnail_path);
+ g_free(_media->thumbnail_path);
_media->thumbnail_path = NULL;
media_info_destroy((media_info_h)_info);