From 51916fc64428989cfbf2359a6b6d4014aacf446d Mon Sep 17 00:00:00 2001 From: Haejeong Kim Date: Wed, 5 Apr 2017 16:52:41 +0900 Subject: [PATCH] Rearrange the code regarding User Path (/opt/usr/media) per Each profile. And Thumbnail path which set by user, not replaced to system path. Change-Id: I3c7abb52889ea74dc2b352f88276aee089ae53b3 --- src/media_bookmark.c | 9 +-------- src/media_db.c | 31 +++---------------------------- src/media_folder.c | 7 +------ src/media_info.c | 16 ++++------------ src/media_playlist.c | 7 +------ src/media_util_private.c | 9 +++++++++ 6 files changed, 19 insertions(+), 60 deletions(-) diff --git a/src/media_bookmark.c b/src/media_bookmark.c index 9ca8440..4aef252 100755 --- a/src/media_bookmark.c +++ b/src/media_bookmark.c @@ -23,16 +23,9 @@ int media_bookmark_insert_to_db(const char *media_id, time_t time, const char *t { int ret = MEDIA_CONTENT_ERROR_NONE; char *sql = NULL; - char repl_path[MAX_QUERY_SIZE] = {0, }; if (STRING_VALID(media_id)) { - if (STRING_VALID(thumbnail_path)) { - memset(repl_path, 0, sizeof(repl_path)); - ret = _media_content_replace_path(thumbnail_path, repl_path); - sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, repl_path); - } else { - sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, thumbnail_path); - } + sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, thumbnail_path); ret = _content_query_sql(sql); SQLITE3_SAFE_FREE(sql); } else { diff --git a/src/media_db.c b/src/media_db.c index 959ef3b..913c3dd 100755 --- a/src/media_db.c +++ b/src/media_db.c @@ -588,10 +588,8 @@ int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_d sqlite3_stmt *stmt = NULL; attribute_h attr = NULL; filter_s *_filter = (filter_s*)filter; -#ifndef _USE_TV_PROFILE char *tmp_path = NULL; char repl_path[MAX_QUERY_SIZE] = {0, }; -#endif attr = _content_get_alias_attirbute_handle(); memset(select_query, 0x00, sizeof(select_query)); @@ -620,14 +618,12 @@ int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_d } _folder->folder_id = g_strdup((const char *)sqlite3_column_text(stmt, 0)); -#ifdef _USE_TV_PROFILE - _folder->path = g_strdup((const char *)sqlite3_column_text(stmt, 1)); -#else + tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, 1)); _media_content_rollback_path(tmp_path, repl_path); _folder->path = g_strdup(repl_path); SAFE_FREE(tmp_path); -#endif + _folder->name = g_strdup((const char *)sqlite3_column_text(stmt, 2)); _folder->storage_type = (int)sqlite3_column_int(stmt, 3); _folder->modified_time = (int)sqlite3_column_int(stmt, 4); @@ -656,10 +652,8 @@ int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *us char *option_query = NULL; sqlite3_stmt *stmt = NULL; attribute_h attr = NULL; -#ifndef _USE_TV_PROFILE char *tmp_path = NULL; char repl_path[MAX_QUERY_SIZE] = {0, }; -#endif attr = _content_get_attirbute_handle(); memset(select_query, 0x00, sizeof(select_query)); @@ -688,9 +682,7 @@ int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *us _playlist->playlist_id = (int)sqlite3_column_int(stmt, 0); _playlist->name = g_strdup((const char *)sqlite3_column_text(stmt, 1)); -#ifdef _USE_TV_PROFILE - _playlist->thumbnail_path = g_strdup((const char *)sqlite3_column_text(stmt, 2)); -#else + memset(repl_path, 0x00, sizeof(repl_path)); tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, 2)); if (STRING_VALID(tmp_path)) { @@ -700,7 +692,6 @@ int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *us } else { _playlist->thumbnail_path = NULL; } -#endif if (callback((media_playlist_h)_playlist, user_data) == false) { media_playlist_destroy((media_playlist_h)_playlist); @@ -827,10 +818,6 @@ int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark sqlite3_stmt *stmt = NULL; attribute_h attr = NULL; filter_s *_filter = (filter_s*)filter; -#ifndef _USE_TV_PROFILE - char *tmp_path = NULL; - char repl_path[MAX_QUERY_SIZE] = {0, }; -#endif attr = _content_get_attirbute_handle(); @@ -861,19 +848,7 @@ int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark bookmark->bookmark_id = (int)sqlite3_column_int(stmt, 0); bookmark->media_id = g_strdup((const char *)sqlite3_column_text(stmt, 1)); bookmark->marked_time = (int)sqlite3_column_int(stmt, 2); -#ifdef _USE_TV_PROFILE bookmark->thumbnail_path = g_strdup((const char *)sqlite3_column_text(stmt, 3)); -#else - tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, 3)); - if (STRING_VALID(tmp_path)) { - _media_content_rollback_path(tmp_path, repl_path); - bookmark->thumbnail_path = g_strdup(repl_path); - SAFE_FREE(tmp_path); - } else { - bookmark->thumbnail_path = NULL; - } -#endif - bookmark->name = g_strdup((const char *)sqlite3_column_text(stmt, 4)); if (callback((media_bookmark_h)bookmark, user_data) == false) { diff --git a/src/media_folder.c b/src/media_folder.c index 2c316ea..95f8738 100755 --- a/src/media_folder.c +++ b/src/media_folder.c @@ -351,10 +351,8 @@ int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folde int ret = MEDIA_CONTENT_ERROR_NONE; sqlite3_stmt *stmt = NULL; char select_query[DEFAULT_QUERY_SIZE]; -#ifndef _USE_TV_PROFILE char *tmp_path = NULL; char repl_path[MAX_QUERY_SIZE] = {0, }; -#endif if (!STRING_VALID(folder_id)) { media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); @@ -384,14 +382,11 @@ int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folde media_content_error("folder handle %x", _folder); _folder->folder_id = g_strdup((const char *)sqlite3_column_text(stmt, 0)); -#ifdef _USE_TV_PROFILE - _folder->path = g_strdup((const char *)sqlite3_column_text(stmt, 1)); -#else + tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, 1)); _media_content_rollback_path(tmp_path, repl_path); _folder->path = g_strdup(repl_path); SAFE_FREE(tmp_path); -#endif _folder->name = g_strdup((const char *)sqlite3_column_text(stmt, 2)); _folder->modified_time = (int)sqlite3_column_int(stmt, 3); diff --git a/src/media_info.c b/src/media_info.c index 6215cf6..f6a7ef4 100755 --- a/src/media_info.c +++ b/src/media_info.c @@ -264,20 +264,17 @@ static int __media_info_insert_batch(media_batch_insert_e insert_type, const cha void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media) { media_info_s *_media = (media_info_s*)media; -#ifndef _USE_TV_PROFILE + char *tmp_path = NULL; char repl_path[MAX_QUERY_SIZE] = {0, }; -#endif _media->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID)); -#ifdef _USE_TV_PROFILE - _media->file_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH)); -#else + tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH)); _media_content_rollback_path(tmp_path, repl_path); _media->file_path = g_strdup(repl_path); SAFE_FREE(tmp_path); -#endif + _media->display_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME)); _media->media_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_TYPE); _media->mime_type = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE)); @@ -3130,23 +3127,18 @@ int media_info_cancel_face_detection(media_info_h media) static int __media_info_map_data_usr_to_svc(media_info_s *media, media_svc_content_info_s **service_content, media_content_storage_e storage_type) { media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle"); -#ifndef _USE_TV_PROFILE char repl_path[MAX_QUERY_SIZE] = {0, }; char *tmp_path = NULL; -#endif media_svc_content_info_s *svc_content_info = calloc(1, sizeof(media_svc_content_info_s)); media_content_retvm_if(svc_content_info == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); -#ifdef _USE_TV_PROFILE - svc_content_info->path = g_strdup(media->file_path); -#else memset(repl_path, 0, sizeof(repl_path)); tmp_path = g_strdup(media->file_path); _media_content_replace_path(tmp_path, repl_path); svc_content_info->path = g_strdup(repl_path); SAFE_FREE(tmp_path); -#endif + svc_content_info->file_name = g_strdup(media->display_name); svc_content_info->media_type = media->media_type; svc_content_info->mime_type = g_strdup(media->mime_type); diff --git a/src/media_playlist.c b/src/media_playlist.c index 141779f..b8c6c5e 100755 --- a/src/media_playlist.c +++ b/src/media_playlist.c @@ -660,19 +660,14 @@ int media_playlist_set_thumbnail_path(media_playlist_h playlist, const char *pat { int ret = MEDIA_CONTENT_ERROR_NONE; media_playlist_s *_playlist = (media_playlist_s*)playlist; - char repl_path[MAX_QUERY_SIZE] = {0, }; if (_playlist != NULL && STRING_VALID(path)) { SAFE_FREE(_playlist->thumbnail_path); - memset(repl_path, 0, sizeof(repl_path)); - ret = _media_content_replace_path(path, repl_path); - media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed"); - media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s)); media_content_retvm_if(item == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); - item->thumbnail_path = strdup(repl_path); + item->thumbnail_path = g_strdup(path); item->function = MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH; if (item->thumbnail_path == NULL) { SAFE_FREE(item); diff --git a/src/media_util_private.c b/src/media_util_private.c index 666c341..c704de2 100755 --- a/src/media_util_private.c +++ b/src/media_util_private.c @@ -286,6 +286,9 @@ int _media_content_replace_path(const char *path, char *replace_path) { int ret = MEDIA_CONTENT_ERROR_NONE; +#ifdef _USE_TV_PROFILE + snprintf(replace_path, MAX_QUERY_SIZE, "%s", path); +#else if (!STRING_VALID(g_old_path)) { ret = storage_get_root_directory(STORAGE_TYPE_INTERNAL, &g_old_path); if (ret != STORAGE_ERROR_NONE) { @@ -300,6 +303,7 @@ int _media_content_replace_path(const char *path, char *replace_path) } else { snprintf(replace_path, MAX_QUERY_SIZE, "%s", path); } +#endif if (!STRING_VALID(replace_path)) { media_content_error("replace failed"); @@ -313,6 +317,10 @@ int _media_content_rollback_path(const char *path, char *replace_path) { int ret = MEDIA_CONTENT_ERROR_NONE; +#ifdef _USE_TV_PROFILE + snprintf(replace_path, MAX_QUERY_SIZE, "%s", path); +#else + if (!STRING_VALID(g_old_path)) { ret = storage_get_root_directory(STORAGE_TYPE_INTERNAL, &g_old_path); if (ret != STORAGE_ERROR_NONE) { @@ -327,6 +335,7 @@ int _media_content_rollback_path(const char *path, char *replace_path) } else { snprintf(replace_path, MAX_QUERY_SIZE, "%s", path); } +#endif if (!STRING_VALID(replace_path)) { media_content_error("replace failed"); -- 2.7.4