return;
}
-static bool __media_info_isFaceRecognition_feature_supported()
+static bool __media_info_isFaceRecognition_feature_supported(void)
{
bool isFaceRecognitionSupported = false;
memset(list_path, 0x00, sizeof(list_path));
continue;
} else {
- content_debug("The request file list path : %s", list_path);
+ content_sec_debug("The request file list path : %s", list_path);
break;
}
}
fp = fopen(list_path, "w");
if (fp == NULL) {
- content_error("failed to open file : [%s]", list_path);
+ content_sec_error("failed to open file : [%s]", list_path);
content_stderror("failed to open file");
return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
}
_media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
_media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
_media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
+ } else if (_media->media_type == MEDIA_CONTENT_TYPE_BOOK) {
+ _media->book_meta = g_new0(book_meta_s, 1);
+ _media->book_meta->subject = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
+ _media->book_meta->author = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
+ _media->book_meta->date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
+ _media->book_meta->publisher = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
}
}
#ifdef _USE_TVPD_MODE
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)
{
g_free(_media->modified_month);
#endif
g_free(_media->storage_uuid);
-#ifdef _USE_SENIOR_MODE
- g_free(_media->contact);
- g_free(_media->app_data);
-#endif
if (_media->image_meta) {
g_free(_media->image_meta->media_id);
g_free(_media->audio_meta);
}
+ if (_media->book_meta) {
+ g_free(_media->book_meta->media_id);
+ g_free(_media->book_meta->author);
+ g_free(_media->book_meta->date);
+ g_free(_media->book_meta->publisher);
+ g_free(_media->book_meta->subject);
+
+ g_free(_media->book_meta);
+ }
+
g_free(_media);
return MEDIA_CONTENT_ERROR_NONE;
#ifdef _USE_TVPD_MODE
_dst->modified_month = g_strdup(_src->modified_month);
#endif
-#ifdef _USE_SENIOR_MODE
- _dst->contact = g_strdup(_src->contact);
- _dst->app_data = g_strdup(_src->app_data);
-#endif
-
_dst->media_type = _src->media_type;
_dst->size = _src->size;
_dst->added_time = _src->added_time;
_dst->audio_meta->duration = _src->audio_meta->duration;
_dst->audio_meta->bitrate = _src->audio_meta->bitrate;
_dst->audio_meta->bitpersample = _src->audio_meta->bitpersample;
+ } else if (_src->media_type == MEDIA_CONTENT_TYPE_BOOK && _src->book_meta) {
+ _dst->book_meta = g_new0(book_meta_s, 1);
+
+ _dst->book_meta->media_id = g_strdup(_src->book_meta->media_id);
+ _dst->book_meta->author = g_strdup(_src->book_meta->author);
+ _dst->book_meta->date = g_strdup(_src->book_meta->date);
+ _dst->book_meta->publisher = g_strdup(_src->book_meta->publisher);
+ _dst->book_meta->subject = g_strdup(_src->book_meta->subject);
}
*dst = (media_info_h)_dst;
return ret;
}
+int media_info_get_book(media_info_h media, book_meta_h *book)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ media_info_s *_media = (media_info_s*)media;
+
+ content_retip_if_fail(media);
+ content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_BOOK);
+ content_retip_if_fail(book);
+
+ book_meta_s *_book = g_new0(book_meta_s, 1);
+
+ _book->media_id = g_strdup(_media->media_id);
+ _book->author = g_strdup(_media->book_meta->author);
+ _book->publisher = g_strdup(_media->book_meta->publisher);
+ _book->date = g_strdup(_media->book_meta->date);
+ _book->subject = g_strdup(_media->book_meta->subject);
+
+ *book = (book_meta_h)_book;
+
+ return ret;
+}
+
int media_info_get_media_id(media_info_h media, char **media_id)
{
media_info_s *_media = (media_info_s*)media;
return MEDIA_CONTENT_ERROR_NONE;
}
-#ifdef _USE_SENIOR_MODE
-int media_info_set_contact(media_info_h media, const char *contact)
-{
- media_info_s *_media = (media_info_s*)media;
-
- content_retip_if_fail(media);
-
- g_free(_media->contact);
- _media->contact = g_strdup(contact);
-
- return MEDIA_CONTENT_ERROR_NONE;
-}
-
-int media_info_set_app_data(media_info_h media, const char *app_data)
-{
- media_info_s *_media = (media_info_s*)media;
-
- content_retip_if_fail(media);
-
- g_free(_media->app_data);
- _media->app_data = g_strdup(app_data);
-
- return MEDIA_CONTENT_ERROR_NONE;
-}
-
-int media_info_insert_to_db_with_contact_data(const char *path, const char* contact, const char* app_data, media_info_h *info)
-{
- int ret = media_info_insert_to_db(path, info);
- content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_insert_to_db [%s] failed", path);
-
- ret = media_info_set_contact(*info, contact);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- content_error("media_info_set_contact [%s] failed", contact);
-
- media_info_s* _media_info = (media_info_s*)*info;
- ret = media_info_delete_from_db(_media_info->media_id);
- content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_delete_from_db [%s] failed", _media_info->media_id);
-
- media_info_destroy(*info);
- return ret;
- }
-
- ret = media_info_set_app_data(*info, app_data);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- content_error("media_info_set_app_data [%s] failed", app_data);
-
- media_info_s* _media_info = (media_info_s*)*info;
- ret = media_info_delete_from_db(_media_info->media_id);
- content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_delete_from_db [%s] failed", _media_info->media_id);
-
- media_info_destroy(*info);
- return ret;
- }
-
- ret = media_info_update_to_db(*info);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- content_error("media_info_update_to_db [] failed");
-
- media_info_s* _media_info = (media_info_s*)*info;
- ret = media_info_delete_from_db(_media_info->media_id);
- content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_delete_from_db [%s] failed", _media_info->media_id);
-
- media_info_destroy(*info);
- return ret;
- }
-
- return ret;
-}
-
-int media_info_delete_contact_from_db(const char* contact, const char* storage_id)
-{
- return -1;
-}
-
-int media_info_delete_item(const char *media_id)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char *path = NULL;
- char *storage_id = NULL;
-
- content_retip_if_fail(STRING_VALID(media_id));
-
- ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
- g_free(path);
- return ret;
- }
-
- ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
- g_free(path);
- return ret;
- }
-
- ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
- g_free(storage_id);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- content_error("remove from DB failed : %d", ret);
- g_free(path);
- return ret;
- }
-
- ret = media_svc_remove_file(path);
- g_free(path);
-
- return _content_error_capi(ret);
-}
-
-int media_info_get_contact(media_info_h media, char **contact)
-{
- media_info_s *_media = (media_info_s*)media;
-
- content_retip_if_fail(media);
- content_retip_if_fail(contact);
-
- *contact = g_strdup(_media->contact);
-
- return MEDIA_CONTENT_ERROR_NONE;
-}
-
-int media_info_get_app_data(media_info_h media, char **app_data)
-{
- media_info_s *_media = (media_info_s*)media;
-
- content_retip_if_fail(media);
- content_retip_if_fail(app_data);
-
- *app_data = g_strdup(_media->app_data);
-
- return MEDIA_CONTENT_ERROR_NONE;
-}
-#endif
#ifdef _USE_TVPD_MODE
int media_info_get_played_count(media_info_h media, int *played_count)
{
content_retip_if_fail(media);
content_retip_if_fail(stitched_info);
+ *stitched_info = (_media->stitched_info & 0xFFFF0000) >> 16;
+
return MEDIA_CONTENT_ERROR_NONE;
}
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;
media_svc_get_pinyin(_media->description, &description_pinyin);
}
#ifdef _USE_TVPD_MODE
-#ifdef _USE_SENIOR_MODE
- if (_media_content_is_support_senior_mode()) {
- 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("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",
+ 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("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
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)