int media_info_insert_to_db(const char *path, media_info_h *info)
{
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
- char repl_path[MAX_PATH_LEN] = {0, };
int ret = MEDIA_CONTENT_ERROR_NONE;
ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
int modified_time = 0;
content_retip_if_fail(STRING_VALID(path));
content_retip_if_fail(info);
- ret = _media_content_replace_path(path, repl_path);
- content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
- ret = __media_info_check_file_validity(repl_path);
+ ret = __media_info_check_file_validity(path);
content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
+ ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
content_error("media_svc_get_storage_id failed : %d", ret);
return _content_error_capi(ret);
}
- ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
+ ret = ms_user_get_storage_type(_content_get_uid(), path, &storage_type);
if (ret != MS_MEDIA_ERR_NONE) {
content_sec_error("ms_user_get_storage_type failed : %d", ret);
return _content_error_capi(ret);
}
/* Get modified time for check exists */
- ret = media_svc_get_modified_time(_content_get_db_handle(), storage_id, repl_path, &modified_time);
+ ret = media_svc_get_modified_time(_content_get_db_handle(), storage_id, path, &modified_time);
if (ret == MS_MEDIA_ERR_NONE) {
/* Refresh if need */
- if (modified_time != _media_util_get_file_time(repl_path)) {
- ret = media_svc_refresh_item(_content_get_db_handle(), false, storage_id, storage_type, repl_path, _content_get_uid());
+ if (modified_time != _media_util_get_file_time(path)) {
+ ret = media_svc_refresh_item(_content_get_db_handle(), false, storage_id, storage_type, path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
content_error("media_svc_refresh_item failed : %d", ret);
return _content_error_capi(ret);
}
}
} else if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
- content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", repl_path);
- content_retvm_if(!_media_util_check_support_media_type(repl_path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
+ 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, storage_type, repl_path, _content_get_uid());
+ ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, 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)", repl_path);
+ content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", path);
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
+ content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
}
return _content_error_capi(ret);
}
} else {
- content_sec_error("media_svc_get_modified_time failed : %d (%s)", ret, repl_path);
+ content_sec_error("media_svc_get_modified_time failed : %d (%s)", ret, path);
return _content_error_capi(ret);
}
#ifdef _USE_TVPD_MODE
if (STRING_VALID(storage_id))
- ret = _media_info_get_media_info_from_db(repl_path, storage_id, (media_info_h)_media);
+ ret = _media_info_get_media_info_from_db(path, storage_id, (media_info_h)_media);
else
- ret = _media_info_get_media_info_from_db(repl_path, DB_TABLE_MEDIA, (media_info_h)_media);
+ ret = _media_info_get_media_info_from_db(path, DB_TABLE_MEDIA, (media_info_h)_media);
*info = (media_info_h)_media;
#else
- ret = _media_info_get_media_info_from_db(repl_path, (media_info_h)_media);
+ ret = _media_info_get_media_info_from_db(path, (media_info_h)_media);
*info = (media_info_h)_media;
#endif
int media_info_insert_batch_to_db(const char **path_array, unsigned int array_length, media_insert_completed_cb completed_cb, void *user_data)
{
- char **repl_path_array = NULL;
- int idx = 0;
- int ret = MS_MEDIA_ERR_NONE;
- char repl_path[MAX_PATH_LEN] = {0, };
-
content_retip_if_fail(path_array);
content_retip_if_fail(array_length > 0);
content_retip_if_fail(completed_cb);
- repl_path_array = g_malloc0(sizeof(char *) * array_length);
-
- for (idx = 0; idx < array_length; idx++) {
- if (STRING_VALID(path_array[idx])) {
- memset(repl_path, 0, sizeof(repl_path));
- _media_content_replace_path(path_array[idx], repl_path);
- repl_path_array[idx] = g_strndup(repl_path, strlen(repl_path));
- } else {
- content_error("path[%d] is invalid string", idx);
- }
- }
-
- ret = __media_info_insert_batch((const char **)repl_path_array, array_length, completed_cb, user_data);
- for (idx = 0; idx < array_length; idx++)
- g_free(repl_path_array[idx]);
-
- g_free(repl_path_array);
-
- return ret;
+ return __media_info_insert_batch(path_array, array_length, completed_cb, user_data);
}
+
#ifdef _USE_TVPD_MODE
int media_info_get_media_info_by_path_from_db(const char* path, media_info_h* media)
{
return ret;
}
+int media_info_get_media_from_db_by_path(const char *path, media_info_h *media)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_info_s *_media = NULL;
+
+ content_retip_if_fail(STRING_VALID(path));
+ content_retip_if_fail(media);
+ ret = _media_util_check_file_exist(path);
+ content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "_media_util_check_file_exist failed : %d", ret);
+
+#ifdef _USE_TVPD_MODE
+ char storage_id[MEDIA_CONTENT_UUID_SIZE + 1] = {0, };
+
+ ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_error("media_svc_get_storage_id failed : %d", ret);
+ return _content_error_capi(ret);
+ }
+#endif
+
+ _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);
+#else
+ ret = _media_info_get_media_info_from_db(path, (media_info_h)_media);
+#endif
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ g_free(_media);
+ _media = NULL;
+ }
+
+ *media = (media_info_h)_media;
+
+ return ret;
+}
+
int media_info_set_favorite(media_info_h media, bool favorite)
{
media_info_s *_media = (media_info_s*)media;
if (ret == MEDIA_CONTENT_ERROR_NONE) {
/* Send notification for this update */
- content_debug("Update is successfull. Send notification for this");
+ content_debug("Update is successful. Send notification for this");
if (_media->file_path && _media->mime_type)
media_svc_publish_noti(MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
else
{
int ret = MEDIA_CONTENT_ERROR_NONE;
char repl_path[MAX_PATH_LEN] = {0, };
+ media_info_s *_info = NULL;
+#ifdef _USE_TVPD_MODE
+ char storage_id[MEDIA_CONTENT_UUID_SIZE + 1] = {0, };
+#endif
content_retip_if_fail(media);
content_retip_if_fail(STRING_VALID(dst_path));
- ret = _media_content_replace_path(dst_path, repl_path);
- content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
media_info_s *_media = (media_info_s*)media;
/* If dst_path is folder, append file_name */
+ SAFE_STRLCPY(repl_path, dst_path, sizeof(repl_path));
+
if (g_file_test(repl_path, G_FILE_TEST_IS_DIR)) {
if (repl_path[strlen(repl_path) - 1] != '/')
SAFE_STRLCAT(repl_path, "/", sizeof(repl_path));
content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
ret = media_svc_move_item(_content_get_db_handle(), _media->file_path, repl_path, _media->media_id, _media->media_type, _media->mime_type, _content_get_uid());
- return _content_error_capi(ret);
+ ret = _content_error_capi(ret);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ /* Update media_info handle */
+ _info = g_new0(media_info_s, 1);
+
+#ifdef _USE_TVPD_MODE
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ ret = _media_info_get_media_info_from_db(repl_path, storage_id, (media_info_h)_info);
+#else
+ ret = _media_info_get_media_info_from_db(repl_path, (media_info_h)_info);
+#endif
+
+ SAFE_FREE(_media->display_name);
+ _media->display_name = g_strdup(_info->display_name);
+ SAFE_FREE(_media->file_path);
+ _media->file_path = g_strdup(_info->file_path);
+ _media->storage_type = _info->storage_type;
+ SAFE_FREE(_media->storage_uuid);
+ _media->storage_uuid = g_strdup(_info->storage_uuid);
+ SAFE_FREE(_media->thumbnail_path);
+ _media->thumbnail_path = NULL;
+
+ media_info_destroy((media_info_h)_info);
+
+ return ret;
}
int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)