select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
- ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+ ret = _content_get_result(select_query, &stmt);
SQLITE3_SAFE_FREE(select_query);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
if (_cb_data) {
if (result)
- ret = _content_error_capi(MEDIA_CONTENT_TYPE, result->result);
+ ret = _content_error_capi(result->result);
if (_cb_data->insert_completed_cb) {
media_content_debug("User callback is being called now");
if (STRING_VALID(path))
media->thumbnail_path = g_strdup(path);
else
- media->thumbnail_path = g_strdup(EMPTY_STR);
+ media->thumbnail_path = g_strdup(MEDIA_CONTENT_EMPTY_STRING);
}
media_content_debug("error [%d], thumbnail_path [%s]", error, path);
- error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
+ error_value = _content_error_capi(error);
if (_thumb_cb->thumbnail_completed_cb)
_thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
}
if (_face_cb != NULL) {
media_content_debug("error [%d], face_count [%d]", error, face_count);
- error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
+ error_value = _content_error_capi(error);
if (_face_cb->face_completed_cb)
_face_cb->face_completed_cb(error_value, face_count, _face_cb->user_data);
}
media_content_error("media_files_register failed : %d", ret);
if (unlink(list_path) < 0)
media_content_stderror("failed to delete");
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ return _content_error_capi(ret);
}
return ret;
folder_path = g_path_get_dirname(path);
ret = _media_util_check_ignore_dir(folder_path, &ignore);
- SAFE_FREE(folder_path);
+ g_free(folder_path);
media_content_retvm_if(ignore == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
return MEDIA_CONTENT_ERROR_NONE;
_media->altitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_ALTITUDE);
_media->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
_media->timeline = (double)sqlite3_column_double(stmt, MEDIA_INFO_TIMELINE);
- _media->sync_status = (int)sqlite3_column_int(stmt, MEDIA_INFO_SYNC_STATUS);
_media->storage_uuid = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_STORAGE_UUID));
_media->is_360 = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_360);
#ifdef _USE_TVPD_MODE
_media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
_media->image_meta->date_taken = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
_media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
- _media->image_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
_media->image_meta->exposure_time = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
_media->image_meta->model = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
}
_media->video_meta->media_id = g_strdup(_media->media_id);
_media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
_media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
- _media->video_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
_media->video_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
_media->video_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
_media->video_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
_media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
if (_media->audio_meta) {
_media->audio_meta->media_id = g_strdup(_media->media_id);
- _media->audio_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
_media->audio_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
_media->audio_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
_media->audio_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
}
}
}
-
+#ifdef _USE_TVPD_MODE
int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, storage_id, path);
- ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+ ret = _content_get_result(select_query, &stmt);
SQLITE3_SAFE_FREE(select_query);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
return ret;
}
+#else
+int _media_info_get_media_info_from_db(const char *path, media_info_h media)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ sqlite3_stmt *stmt = NULL;
+ char *select_query = NULL;
+ media_info_s *_media = (media_info_s*)media;
+
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
+
+ select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
+
+ ret = _content_get_result(select_query, &stmt);
+ SQLITE3_SAFE_FREE(select_query);
+ media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ _media_info_item_get_detail(stmt, (media_info_h)_media);
+ } else {
+ media_content_sec_error("No media : path[%s]", path);
+ ret = MEDIA_CONTENT_ERROR_DB_FAILED;
+ }
+
+ SQLITE3_FINALIZE(stmt);
+
+ return ret;
+}
+#endif
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;
media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
media_content_retvm_if(info == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_get_storage_id failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ return _content_error_capi(ret);
}
- ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
- if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
+ ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_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);
+ 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 (ret != MS_MEDIA_ERR_NONE) {
+ media_content_error("media_svc_refresh_item failed : %d", ret);
+ return _content_error_capi(ret);
+ }
+ }
+ } else if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
media_content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", repl_path);
media_content_retvm_if(!_media_util_check_support_media_type(repl_path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
- ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
-
- ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_content_sec_error("ms_user_get_storage_type failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
-
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
media_content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
}
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ return _content_error_capi(ret);
}
- } else if (ret != MS_MEDIA_ERR_NONE) {
- media_content_sec_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, repl_path);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ } else {
+ media_content_sec_error("media_svc_get_modified_time failed : %d (%s)", ret, repl_path);
+ return _content_error_capi(ret);
}
media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
+#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);
else
ret = _media_info_get_media_info_from_db(repl_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);
+
+ *info = (media_info_h)_media;
+#endif
return ret;
}
return ret;
}
+#ifdef _USE_TVPD_MODE
+int media_info_get_media_info_by_path_from_db(const char* path, media_info_h* media)
+{
+ char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
+ media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
+
+ memset(storage_id, 0x00, sizeof(storage_id));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, tzplatform_getuid(TZ_USER_NAME));
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_content_error("media_svc_get_storage_id failed : %d", ret);
+ return _content_error_capi(ret);
+ }
+
+ media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+
+ ret = _media_info_get_media_info_from_db(path, storage_id, (media_info_h)_media);
+ *media = (media_info_h)_media;
+
+ return ret;
+}
+#endif
int media_info_delete_from_db(const char *media_id)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
char *path = NULL;
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+ char *storage_id = NULL;
media_content_warn("DEPRECATION WARNING: media_info_delete_from_db() is deprecated and will be removed from next release. Use media_content_scan_file() instead.");
if (!STRING_VALID(media_id)) {
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- memset(storage_id, 0x00, sizeof(storage_id));
-
ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
return ret;
}
- ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
+ ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
SAFE_FREE(path);
ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, _content_get_uid());
SAFE_FREE(path);
+ SAFE_FREE(storage_id);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ return _content_error_capi(ret);
}
int media_info_destroy(media_info_h media)
SAFE_FREE(_media->image_meta->date_taken);
SAFE_FREE(_media->image_meta->exposure_time);
SAFE_FREE(_media->image_meta->model);
- SAFE_FREE(_media->image_meta->title);
SAFE_FREE(_media->image_meta);
}
if (_media->video_meta) {
SAFE_FREE(_media->video_meta->media_id);
- SAFE_FREE(_media->video_meta->title);
SAFE_FREE(_media->video_meta->album);
SAFE_FREE(_media->video_meta->artist);
SAFE_FREE(_media->video_meta->album_artist);
if (_media->audio_meta) {
SAFE_FREE(_media->audio_meta->media_id);
- SAFE_FREE(_media->audio_meta->title);
SAFE_FREE(_media->audio_meta->album);
SAFE_FREE(_media->audio_meta->artist);
SAFE_FREE(_media->audio_meta->album_artist);
_dst->favourite = _src->favourite;
_dst->is_drm = _src->is_drm;
_dst->storage_type = _src->storage_type;
- _dst->sync_status = _src->sync_status;
_dst->request_id = _src->request_id;
_dst->face_request_id = _src->face_request_id;
_dst->is_360 = _src->is_360;
_dst->video_meta->media_id = g_strdup(_src->video_meta->media_id);
media_content_retv_free_info_if(_dst->video_meta->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
}
- if (_src->video_meta->title != NULL) {
- _dst->video_meta->title = g_strdup(_src->video_meta->title);
- media_content_retv_free_info_if(_dst->video_meta->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
- }
if (_src->video_meta->album != NULL) {
_dst->video_meta->album = g_strdup(_src->video_meta->album);
media_content_retv_free_info_if(_dst->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
_dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id);
media_content_retv_free_info_if(_dst->audio_meta->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
}
- if (_src->audio_meta->title != NULL) {
- _dst->audio_meta->title = g_strdup(_src->audio_meta->title);
- media_content_retv_free_info_if(_dst->audio_meta->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
- }
if (_src->audio_meta->album != NULL) {
_dst->audio_meta->album = g_strdup(_src->audio_meta->album);
media_content_retv_free_info_if(_dst->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
_image->fnumber = _media->image_meta->fnumber;
_image->iso = _media->image_meta->iso;
_image->date_taken = g_strdup(_media->image_meta->date_taken);
- _image->title = g_strdup(_media->image_meta->title);
_image->exposure_time = g_strdup(_media->image_meta->exposure_time);
_image->model = g_strdup(_media->image_meta->model);
media_content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
_video->media_id = g_strdup(_media->media_id);
- _video->title = g_strdup(_media->video_meta->title);
_video->album = g_strdup(_media->video_meta->album);
_video->artist = g_strdup(_media->video_meta->artist);
_video->album_artist = g_strdup(_media->video_meta->album_artist);
media_content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
_audio->media_id = g_strdup(_media->media_id);
- _audio->title = g_strdup(_media->audio_meta->title);
_audio->album = g_strdup(_media->audio_meta->album);
_audio->artist = g_strdup(_media->audio_meta->artist);
_audio->album_artist = g_strdup(_media->audio_meta->album_artist);
{
int ret = MEDIA_CONTENT_ERROR_NONE;
char *path = NULL;
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
+ char *storage_id = NULL;
if (!STRING_VALID(media_id)) {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- memset(storage_id, 0x00, sizeof(storage_id));
-
ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
return ret;
}
- ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
+ ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
SAFE_FREE(path);
}
ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
+ SAFE_FREE(storage_id);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
media_content_error("remove from DB failed : %d", ret);
SAFE_FREE(path);
ret = media_svc_remove_file(path);
SAFE_FREE(path);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ return _content_error_capi(ret);
}
int media_info_get_contact(media_info_h media, char **contact)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
char select_query[DEFAULT_QUERY_SIZE] = {0, };
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
sqlite3_stmt *stmt = NULL;
if (!STRING_VALID(media_id) || (media == NULL)) {
}
memset(select_query, 0x00, sizeof(select_query));
- memset(storage_id, 0x00, sizeof(storage_id));
- ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+#ifdef _USE_TVPD_MODE
+ char *storage_id = NULL;
+ ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
+ media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
-
- ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+ SAFE_FREE(storage_id);
+#else
+ snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
+#endif
+ ret = _content_get_result(select_query, &stmt);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
media_info_s *_media = NULL;
#ifdef _USE_TVPD_MODE
#ifdef _USE_SENIOR_MODE
if (_media_content_is_support_senior_mode()) {
- set_sql = sqlite3_mprintf("file_name=%Q, description=%Q, longitude=%f, latitude=%f, file_name_pinyin=%Q, description_pinyin=%Q, played_count=%d, last_played_time=%d, last_played_position=%d, favourite=%d, contact=%Q, app_data=%Q",
- _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->played_count, _media->played_time, _media->played_position, _media->favourite, _media->contact, _media->app_data);
+ set_sql = sqlite3_mprintf("media_display_name=%Q, media_description=%Q, media_longitude=%f, media_latitude=%f, media_file_name_pinyin=%Q, media_description_pinyin=%Q, played_count=%d, last_played_time=%d, last_played_position=%d, media_rating=%d, media_favourite=%d, contact=%Q, app_data=%Q",
+ _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->played_count, _media->played_time, _media->played_position, _media->rating, _media->favourite, _media->contact, _media->app_data);
} else
#endif
{
- set_sql = sqlite3_mprintf("file_name=%Q, description=%Q, longitude=%f, latitude=%f, file_name_pinyin=%Q, description_pinyin=%Q, played_count=%d, last_played_time=%d, last_played_position=%d, favourite=%d",
- _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->played_count, _media->played_time, _media->played_position, _media->favourite);
+ set_sql = sqlite3_mprintf("media_display_name=%Q, media_description=%Q, media_longitude=%f, media_latitude=%f, media_file_name_pinyin=%Q, media_description_pinyin=%Q, played_count=%d, last_played_time=%d, last_played_position=%d, media_rating=%d, media_favourite=%d",
+ _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->played_count, _media->played_time, _media->played_position, _media->rating, _media->favourite);
}
#else
- set_sql = sqlite3_mprintf("file_name=%Q, description=%Q, longitude=%f, latitude=%f, file_name_pinyin=%Q, description_pinyin=%Q, favourite=%d", _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->favourite);
+ set_sql = sqlite3_mprintf("media_display_name=%Q, media_description=%Q, media_longitude=%f, media_latitude=%f, media_file_name_pinyin=%Q, media_description_pinyin=%Q, media_rating=%d, media_favourite=%d", _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->rating, _media->favourite);
+#endif
+#ifdef _USE_TVPD_MODE
+ sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_id=%Q", _media->storage_uuid, set_sql, _media->media_id);
+#else
+ sql = sqlite3_mprintf("UPDATE %q SET %s WHERE media_id=%Q", DB_TABLE_MEDIA, set_sql, _media->media_id);
#endif
-
- sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
-
ret = _content_query_sql(sql);
SQLITE3_SAFE_FREE(set_sql);
SQLITE3_SAFE_FREE(sql);
+ SAFE_FREE(file_name_pinyin);
SAFE_FREE(description_pinyin);
if (ret == MEDIA_CONTENT_ERROR_NONE) {
/* Send notification for this update */
media_content_debug("Update is successfull. Send notification for this");
if (_media->file_path && _media->mime_type)
- media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
+ media_svc_publish_noti(MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
else
media_content_error("Can't Send Noti : path or mime type is NULL");
}
int media_info_move_to_db(media_info_h media, const char* dst_path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
char repl_path[MAX_PATH_LEN] = {0, };
- char org_repl_path[MAX_PATH_LEN] = {0, };
media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
media_content_retvm_if(!STRING_VALID(dst_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dst_path");
memset(repl_path, 0, sizeof(repl_path));
- memset(org_repl_path, 0, sizeof(org_repl_path));
ret = _media_content_replace_path(dst_path, repl_path);
media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
media_info_s *_media = (media_info_s*)media;
- ret = _media_content_replace_path(_media->file_path, org_repl_path);
- media_content_retvm_if(!STRING_VALID(org_repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+ /* If dst_path is folder, append file_name */
+ 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));
+
+ SAFE_STRLCAT(repl_path, _media->display_name, sizeof(repl_path));
+ }
/* If the two paths are the same, do nothing */
- media_content_retvm_if(g_strcmp0(repl_path, org_repl_path) == 0, MEDIA_CONTENT_ERROR_NONE, "Same path");
+ media_content_retvm_if(g_strcmp0(repl_path, _media->file_path) == 0, MEDIA_CONTENT_ERROR_NONE, "Same path");
ret = __media_info_check_file_validity(repl_path);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- memset(storage_id, 0x00, sizeof(storage_id));
- ret = media_svc_get_storage_id(_content_get_db_handle(), org_repl_path, storage_id, _content_get_uid());
- if (ret != MS_MEDIA_ERR_NONE) {
- media_content_error("media_svc_get_storage_id failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
-
- ret = media_svc_move_item(_content_get_db_handle(), org_repl_path, repl_path, _content_get_uid());
- return _content_error_capi(MEDIA_CONTENT_TYPE, 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);
}
int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
int ret = MEDIA_CONTENT_ERROR_NONE;
media_content_warn("DEPRECATION WARNING: media_info_create_thumbnail() is deprecated and will be removed from next release. Use media_info_generate_thumbnail() instead.");
static unsigned int req_id = 0;
- char repl_path[MAX_PATH_LEN] = {0, };
media_info_s *_media = (media_info_s*)media;
if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
- memset(repl_path, 0, sizeof(repl_path));
- ret = _media_content_replace_path(_media->file_path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
media_content_retvm_if(_thumb_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
req_id++;
_thumb_cb->user_data = user_data;
_thumb_cb->thumbnail_completed_cb = callback;
- ret = thumbnail_request_from_db_async(_media->request_id, repl_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, _content_get_uid());
- ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+ ret = thumbnail_request_from_db_async(_media->request_id, _media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, _content_get_uid());
+ ret = _content_error_capi(ret);
} else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
int media_info_generate_thumbnail(media_info_h media)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- char repl_path[MAX_PATH_LEN] = {0, };
char *thumb_path = NULL;
media_info_s *_media = (media_info_s*)media;
if (STRING_VALID(_media->thumbnail_path))
return MEDIA_CONTENT_ERROR_NONE;
- memset(repl_path, 0, sizeof(repl_path));
- ret = _media_content_replace_path(_media->file_path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
- ret = media_svc_create_thumbnail(_media->storage_uuid, repl_path, _media->media_type, _content_get_uid(), &thumb_path);
- ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+ ret = media_svc_create_thumbnail(_media->file_path, _media->media_type, _content_get_uid(), &thumb_path);
+ ret = _content_error_capi(ret);
if (ret == MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT) {
SAFE_FREE(thumb_path);
return ret;
if (_media != NULL && STRING_VALID(_media->media_id) && _media->request_id > 0) {
ret = thumbnail_request_cancel_media(_media->request_id);
- ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+ ret = _content_error_capi(ret);
} else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
int ret = MEDIA_CONTENT_ERROR_NONE;
static unsigned int req_id = 0;
media_info_s *_media = (media_info_s*)media;
- char repl_path[MAX_PATH_LEN] = {0, };
if (!__media_info_isFaceRecognition_feature_supported()) {
media_content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
}
if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
- memset(repl_path, 0, sizeof(repl_path));
- ret = _media_content_replace_path(_media->file_path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+ if (g_strcmp0(_media->mime_type, "image/jpeg") != 0 && g_strcmp0(_media->mime_type, "image/png") != 0 && g_strcmp0(_media->mime_type, "image/bmp") != 0) {
+ media_content_error("Unsupported mime type");
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
media_face_cb_s *_face_cb = (media_face_cb_s*)calloc(1, sizeof(media_face_cb_s));
media_content_retvm_if(_face_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
req_id++;
_face_cb->user_data = user_data;
_face_cb->face_completed_cb = callback;
- ret = dcm_request_extract_face_async(_media->face_request_id, repl_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, _content_get_uid());
- ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+ ret = dcm_request_extract_face_async(_media->face_request_id, _media->file_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, _content_get_uid());
+ ret = _content_error_capi(ret);
} else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
if (_media != NULL && STRING_VALID(_media->media_id) && _media->face_request_id > 0) {
ret = dcm_request_cancel_face(_media->face_request_id);
- ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+ ret = _content_error_capi(ret);
} else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
return ret;
}
+#ifdef TIZEN_FEATURE_COMPATIBILITY
+int media_info_set_added_time(media_info_h media, time_t added_time)
+{
+ media_content_warn("DEPRECATION WARNING: media_info_set_added_time() is removed from 5.5.");
-int media_info_set_display_name(media_info_h media, const char *display_name)
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_delete_batch_from_db(filter_h filter)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_display_name() is deprecated and will be removed from next release.");
- media_info_s *_media = (media_info_s*)media;
+ media_content_warn("DEPRECATION WARNING: media_info_delete_batch_from_db() is removed from 5.5.");
- if (_media != NULL && STRING_VALID(display_name)) {
- SAFE_FREE(_media->display_name);
+ return MEDIA_CONTENT_ERROR_NONE;
+}
- _media->display_name = strdup(display_name);
- media_content_retvm_if(_media->display_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+int media_info_create(const char *path, media_info_h *media)
+{
+ media_content_warn("DEPRECATION WARNING: media_info_create() is removed from 5.5.");
- return ret;
-}
\ No newline at end of file
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_refresh_metadata_to_db(const char *media_id)
+{
+ media_content_warn("DEPRECATION WARNING: media_info_refresh_metadata_to_db() is removed from 5.5.");
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_set_display_name(media_info_h media, const char *display_name)
+{
+ media_content_warn("DEPRECATION WARNING: media_info_set_display_name() is removed from 5.5.");
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+#endif