From bb176dbaf91fa60ad4f08a3760adfcd84654af85 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Wed, 3 Apr 2019 14:17:18 +0900 Subject: [PATCH] Match columns of playlist with filter keyword Change-Id: I0ddb9f28c88745db1bfc442eebfc3c77fddcd7bd Signed-off-by: Minje Ahn --- include/media_info_private.h | 27 +++++++++++---------------- include_product/media_info_private.h | 27 +++++++++++---------------- src/media_content.c | 8 -------- src/media_playlist.c | 3 +-- 4 files changed, 23 insertions(+), 42 deletions(-) diff --git a/include/media_info_private.h b/include/media_info_private.h index 4186189..c936622 100755 --- a/include/media_info_private.h +++ b/include/media_info_private.h @@ -434,12 +434,6 @@ typedef struct _media_content_cb_data { #define DB_FIELD_FOLDER_STORAGE_TYPE "storage_type" #define DB_FIELD_FOLDER_NAME_PINYIN "name_pinyin" -/* DB field for playlist */ -#define DB_FIELD_PLAYLIST_ID "playlist_id" -#define DB_FIELD_PLAYLIST_NAME "name" -#define DB_FIELD_PLAYLIST_MEMBER_ORDER "play_order" -#define DB_FIELD_PLAYLIST_MEDIA_COUNT "media_count" - /* DB field for Storage*/ #define DB_FIELD_STORAGE_ID "storage_uuid" #define DB_FIELD_STORAGE_PATH "storage_path" @@ -468,7 +462,7 @@ typedef struct _media_content_cb_data { #define SELECT_FOLDER_LIST "SELECT DISTINCT f.folder_uuid, f.path, f.name, f.storage_type, f.storage_uuid FROM "FOLDER_MEDIA_JOIN #define SELECT_FOLDER_LIST_BY_STORAGE_ID SELECT_FOLDER_LIST"AND f.storage_uuid='%s' " #define SELECT_TAG_LIST "SELECT DISTINCT tag_id, tag_name FROM "DB_VIEW_TAG" WHERE 1 " -#define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, name, p_thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 " +#define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, playlist_name, p_thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 " /* Get Group Count */ #define SELECT_ALBUM_COUNT "SELECT COUNT(DISTINCT album_id) FROM "ALBUM_MEDIA_JOIN @@ -489,12 +483,12 @@ typedef struct _media_content_cb_data { #define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND folder_uuid='%q'" #define SELECT_MEDIA_COUNT_FROM_STORAGE "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND storage_uuid='%q'" #define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND tag_media_count>0) " -#define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) " +#define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and playlist_media_count>0) " /* Get Group Info by Group ID*/ #define SELECT_ALBUM_FROM_ALBUM "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d" #define SELECT_FOLDER_FROM_FOLDER "SELECT folder_uuid, path, name, storage_type, storage_uuid FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'" -#define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT name, thumbnail_path FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d" +#define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT playlist_name, thumbnail_path FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d" #define SELECT_TAG_FROM_TAG "SELECT tag_name FROM "DB_TABLE_TAG" WHERE tag_id=%d" #define SELECT_TAG_BY_NAME "SELECT tag_id FROM "DB_TABLE_TAG" WHERE tag_name='%q'" @@ -513,15 +507,16 @@ typedef struct _media_content_cb_data { timeline, sync_status, storage_uuid, is_360" /* Playlist Info */ -#define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)" -#define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d;" +#define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (playlist_name) VALUES (%Q)" +#define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET playlist_name='%q' WHERE playlist_id=%d;" #define UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET thumbnail_path='%q' WHERE playlist_id=%d;" -#define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'" -#define SELECT_PLAYLIST_ITEM_ALL_FROM_PLAYLIST_VIEW "SELECT "MEDIA_INFO_ITEM", pm_id FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) " -#define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT play_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d" -#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(play_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d" +#define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE playlist_name='%q'" +#define SELECT_PLAYLIST_ITEM_ALL_FROM_PLAYLIST_VIEW "SELECT "MEDIA_INFO_ITEM", pm_id FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and playlist_media_count>0) " +#define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT playlist_member_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d" +#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(playlist_member_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d" #define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d;" -#define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d;" +#define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET playlist_member_order=%d WHERE playlist_id=%d AND _id=%d;" +#define INSERT_PLAYLIST_ITEM_TO_PLAYLIST_MAP "INSERT INTO "DB_TABLE_PLAYLIST_MAP" (playlist_id, media_uuid, playlist_member_order) VALUES (%d, '%q', %d);" /* Bookmark */ #define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, bookmark_marked_time, thumbnail_path, bookmark_name) VALUES ('%q', '%d', %Q, %Q)" diff --git a/include_product/media_info_private.h b/include_product/media_info_private.h index dc0d0e8..557efff 100755 --- a/include_product/media_info_private.h +++ b/include_product/media_info_private.h @@ -547,12 +547,6 @@ typedef struct _media_content_scan_cb_data_v2 { #define DB_FIELD_FOLDER_STORAGE_TYPE "storage_type" #define DB_FIELD_FOLDER_NAME_PINYIN "name_pinyin" -/* DB field for playlist */ -#define DB_FIELD_PLAYLIST_ID "playlist_id" -#define DB_FIELD_PLAYLIST_NAME "name" -#define DB_FIELD_PLAYLIST_MEMBER_ORDER "play_order" -#define DB_FIELD_PLAYLIST_MEDIA_COUNT "media_count" - /* DB field for Storage*/ #define DB_FIELD_STORAGE_ID "storage_uuid" #define DB_FIELD_STORAGE_PATH "storage_path" @@ -636,7 +630,7 @@ typedef struct _media_content_scan_cb_data_v2 { #define SELECT_FOLDER_LIST "SELECT DISTINCT f.folder_uuid, f.path, f.name, f.storage_type, f.storage_uuid FROM "FOLDER_MEDIA_JOIN #define SELECT_FOLDER_LIST_BY_STORAGE_ID SELECT_FOLDER_LIST"AND f.storage_uuid='%s' " #define SELECT_TAG_LIST "SELECT DISTINCT tag_id, tag_name FROM "DB_VIEW_TAG" WHERE 1 " -#define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, name, p_thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 " +#define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, playlist_name, p_thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 " /* Get Group Count */ #define SELECT_ALBUM_COUNT "SELECT COUNT(DISTINCT album_id) FROM "ALBUM_MEDIA_JOIN @@ -657,12 +651,12 @@ typedef struct _media_content_scan_cb_data_v2 { #define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND folder_uuid='%q'" #define SELECT_MEDIA_COUNT_FROM_STORAGE "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND storage_uuid='%q'" #define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND tag_media_count>0) " -#define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) " +#define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and playlist_media_count>0) " /* Get Group Info by Group ID*/ #define SELECT_ALBUM_FROM_ALBUM "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d" #define SELECT_FOLDER_FROM_FOLDER "SELECT folder_uuid, path, name, storage_type, storage_uuid FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'" -#define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT name, thumbnail_path FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d" +#define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT playlist_name, thumbnail_path FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d" #define SELECT_TAG_FROM_TAG "SELECT tag_name FROM "DB_TABLE_TAG" WHERE tag_id=%d" #define SELECT_TAG_BY_NAME "SELECT tag_id FROM "DB_TABLE_TAG" WHERE tag_name='%q'" @@ -690,15 +684,16 @@ typedef struct _media_content_scan_cb_data_v2 { #endif /* Playlist Info */ -#define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)" -#define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d;" +#define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (playlist_name) VALUES (%Q)" +#define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET playlist_name='%q' WHERE playlist_id=%d;" #define UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET thumbnail_path='%q' WHERE playlist_id=%d;" -#define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'" -#define SELECT_PLAYLIST_ITEM_ALL_FROM_PLAYLIST_VIEW "SELECT "MEDIA_INFO_ITEM", pm_id FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) " -#define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT play_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d" -#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(play_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d" +#define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE playlist_name='%q'" +#define SELECT_PLAYLIST_ITEM_ALL_FROM_PLAYLIST_VIEW "SELECT "MEDIA_INFO_ITEM", pm_id FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and playlist_media_count>0) " +#define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT playlist_member_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d" +#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(playlist_member_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d" #define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d;" -#define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d;" +#define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET playlist_member_order=%d WHERE playlist_id=%d AND _id=%d;" +#define INSERT_PLAYLIST_ITEM_TO_PLAYLIST_MAP "INSERT INTO "DB_TABLE_PLAYLIST_MAP" (playlist_id, media_uuid, playlist_member_order) VALUES (%d, '%q', %d);" /* Bookmark */ #define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, bookmark_marked_time, thumbnail_path, bookmark_name) VALUES ('%q', '%d', %Q, %Q)" diff --git a/src/media_content.c b/src/media_content.c index 2104d21..cd7b52c 100755 --- a/src/media_content.c +++ b/src/media_content.c @@ -94,14 +94,6 @@ static media_content_attribute_info_s g_content_attrs_info[] = { {FOLDER_STORAGE_TYPE, NULL, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_STORAGE_TYPE}, {FOLDER_NAME_PINYIN, NULL, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_NAME_PINYIN}, - /* Playlist */ - {MEDIA_PLAYLIST_ID, DB_FIELD_PLAYLIST_ID, NULL}, - {PLAYLIST_NAME, DB_FIELD_PLAYLIST_NAME, NULL}, - {PLAYLIST_MEMBER_ORDER, DB_FIELD_PLAYLIST_MEMBER_ORDER, NULL}, - - /* Playlist View */ - {PLAYLIST_MEDIA_COUNT, DB_FIELD_PLAYLIST_MEDIA_COUNT, NULL}, - /* Storage */ {MEDIA_STORAGE_ID, DB_FIELD_STORAGE_ID, NULL}, {MEDIA_STORAGE_PATH, DB_FIELD_STORAGE_PATH, NULL}, diff --git a/src/media_playlist.c b/src/media_playlist.c index 69b23ab..9e75b30 100755 --- a/src/media_playlist.c +++ b/src/media_playlist.c @@ -119,8 +119,7 @@ static int __media_playlist_insert_item_to_playlist(int playlist_id, const char ++play_order; - query_str = sqlite3_mprintf("INSERT INTO %q (playlist_id, media_uuid, play_order) values (%d, '%q', %d);", - DB_TABLE_PLAYLIST_MAP, playlist_id, media_id, play_order); + query_str = sqlite3_mprintf(INSERT_PLAYLIST_ITEM_TO_PLAYLIST_MAP, playlist_id, media_id, play_order); ret = media_svc_append_query(query_str, _content_get_uid()); return _content_error_capi(MEDIA_CONTENT_TYPE, ret); -- 2.7.4