From 603d626db2f442cd7f8544c5d3d51aaa59adaf0c Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Thu, 9 Apr 2020 14:04:33 +0900 Subject: [PATCH] Rename db related define Change-Id: I9c12d2e14b1ef6aef53c939337e467a771debf00 Signed-off-by: Minje Ahn --- src/common/media-svc-album.c | 6 +- src/common/media-svc-db-utils.c | 340 ++++++++++++++++---------------- src/common/media-svc-media-folder.c | 12 +- src/common/media-svc-media.c | 24 +-- src/common/media-svc-storage.c | 24 +-- src/common/media-svc.c | 28 +-- src/include/common/media-svc-db-utils.h | 4 +- src/include/common/media-svc-env.h | 98 ++++----- 8 files changed, 271 insertions(+), 265 deletions(-) diff --git a/src/common/media-svc-album.c b/src/common/media-svc-album.c index e45ddfc..451d6ff 100755 --- a/src/common/media-svc-album.c +++ b/src/common/media-svc-album.c @@ -35,9 +35,9 @@ int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *arti media_svc_retvm_if(album == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "album is NULL"); if (artist != NULL) - sql = sqlite3_mprintf("SELECT album_id FROM %s WHERE name = '%q' AND artist = '%q';", MEDIA_SVC_DB_TABLE_ALBUM, album, artist); + sql = sqlite3_mprintf("SELECT album_id FROM %s WHERE name = '%q' AND artist = '%q';", DB_TABLE_ALBUM, album, artist); else - sql = sqlite3_mprintf("SELECT album_id FROM %s WHERE name = '%q' AND artist IS NULL;", MEDIA_SVC_DB_TABLE_ALBUM, album); + sql = sqlite3_mprintf("SELECT album_id FROM %s WHERE name = '%q' AND artist IS NULL;", DB_TABLE_ALBUM, album); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); @@ -61,7 +61,7 @@ int _media_svc_append_album(sqlite3 *handle, bool is_direct, const char *album, { int ret = MS_MEDIA_ERR_NONE; - char *sql = sqlite3_mprintf("INSERT INTO %s (name, artist, album_art) values (%Q, %Q, %Q);", MEDIA_SVC_DB_TABLE_ALBUM, album, artist, album_art); + char *sql = sqlite3_mprintf("INSERT INTO %s (name, artist, album_art) values (%Q, %Q, %Q);", DB_TABLE_ALBUM, album, artist, album_art); if (is_direct) ret = _media_svc_sql_query_direct(sql, uid); else diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c index 47a11b1..d9c5e44 100755 --- a/src/common/media-svc-db-utils.c +++ b/src/common/media-svc-db-utils.c @@ -31,7 +31,7 @@ #include "media-svc-media.h" static GHashTable *table; -static GSList *column_list[MEDIA_SVC_DB_LIST_MAX]; +static GSList *column_list[DB_LIST_MAX]; typedef struct { char *trigger_name; @@ -51,15 +51,20 @@ typedef struct { bool is_view; } column_info_s; -static int __media_svc_add_table_info(const char *name, const char *trigger_name, const char *event_table, const char *action_table, const char *view_name) +static void __add_table_info(const char *name, + const char *trigger_name, + const char *event_table, + const char *action_table, + const char *view_name) { table_info_s *tbl = NULL; - media_svc_retvm_if(!STRING_VALID(name), MS_MEDIA_ERR_INVALID_PARAMETER, "name is NULL"); + if (!STRING_VALID(name)) + return; if (STRING_VALID(trigger_name)) { - media_svc_retvm_if(!STRING_VALID(event_table), MS_MEDIA_ERR_INVALID_PARAMETER, "event_table is NULL"); - media_svc_retvm_if(!STRING_VALID(action_table), MS_MEDIA_ERR_INVALID_PARAMETER, "action_table is NULL"); + if(!STRING_VALID(event_table) || !STRING_VALID(action_table)) + return; } tbl = g_new0(table_info_s, 1); @@ -74,11 +79,17 @@ static int __media_svc_add_table_info(const char *name, const char *trigger_name tbl->view_name = g_strdup(view_name); g_hash_table_insert(table, (gpointer)name, (gpointer)tbl); - - return MS_MEDIA_ERR_NONE; } -static void __media_svc_add_column_info(GSList **slist, const char *name, const char *type, const char *option, int version, const char *index_name, bool is_unique, bool is_trigger, bool is_view) +static void __add_column_info(GSList **slist, + const char *name, + const char *type, + const char *option, + int version, + const char *index_name, + bool is_unique, + bool is_trigger, + bool is_view) { column_info_s *col = g_new0(column_info_s, 1); @@ -104,7 +115,7 @@ static int __create_playlist_view(uid_t uid) GString *table_query = g_string_new(NULL); media_svc_retvm_if(!table_query, MS_MEDIA_ERR_INTERNAL, "g_string_new failed"); - for (iter = column_list[MEDIA_SVC_DB_LIST_PLAYLIST]; iter; iter = g_slist_next(iter)) { + for (iter = column_list[DB_LIST_PLAYLIST]; iter; iter = g_slist_next(iter)) { col_ptr = iter->data; if (!col_ptr) @@ -112,7 +123,7 @@ static int __create_playlist_view(uid_t uid) if (col_ptr->is_view) { if (table_query->len != 0) { - if (strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_THUMBNAIL, strlen(MEDIA_SVC_DB_COLUMN_THUMBNAIL)) == 0) + if (strncmp(col_ptr->name, DB_COLUMN_THUMBNAIL, strlen(DB_COLUMN_THUMBNAIL)) == 0) g_string_append_printf(table_query, ", playlist.%s AS p_thumbnail_path", col_ptr->name); else g_string_append_printf(table_query, ", playlist.%s", col_ptr->name); @@ -122,21 +133,21 @@ static int __create_playlist_view(uid_t uid) } } - for (iter = column_list[MEDIA_SVC_DB_LIST_PLAYLIST_MAP]; iter; iter = g_slist_next(iter)) { + for (iter = column_list[DB_LIST_PLAYLIST_MAP]; iter; iter = g_slist_next(iter)) { col_ptr = iter->data; if (!col_ptr) continue; if (col_ptr->is_view) { - if (strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_MAP_ID, strlen(MEDIA_SVC_DB_COLUMN_MAP_ID)) == 0) + if (strncmp(col_ptr->name, DB_COLUMN_MAP_ID, strlen(DB_COLUMN_MAP_ID)) == 0) g_string_append_printf(table_query, ", playlist_media_count IS NOT NULL AS playlist_media_count, playlist_map.%s AS pm_id", col_ptr->name); else g_string_append_printf(table_query, ", playlist_map.%s", col_ptr->name); } } - for (iter = column_list[MEDIA_SVC_DB_LIST_MEDIA]; iter; iter = g_slist_next(iter)) { + for (iter = column_list[DB_LIST_MEDIA]; iter; iter = g_slist_next(iter)) { col_ptr = iter->data; if (!col_ptr) @@ -146,7 +157,7 @@ static int __create_playlist_view(uid_t uid) g_string_append_printf(table_query, ", media.%s", col_ptr->name); } - sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_VIEW_PLAYLIST, MEDIA_SVC_DB_VIEW_PLAYLIST, table_query->str); + sql = sqlite3_mprintf(DB_QUERY_VIEW_PLAYLIST, DB_VIEW_PLAYLIST, table_query->str); g_string_free(table_query, TRUE); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -163,7 +174,7 @@ static int __create_tag_view(uid_t uid) GString *table_query = g_string_new(NULL); media_svc_retvm_if(!table_query, MS_MEDIA_ERR_INTERNAL, "g_string_new failed"); - for (iter = column_list[MEDIA_SVC_DB_LIST_TAG]; iter; iter = g_slist_next(iter)) { + for (iter = column_list[DB_LIST_TAG]; iter; iter = g_slist_next(iter)) { col_ptr = iter->data; if (!col_ptr) @@ -177,21 +188,21 @@ static int __create_tag_view(uid_t uid) } } - for (iter = column_list[MEDIA_SVC_DB_LIST_TAG_MAP]; iter; iter = g_slist_next(iter)) { + for (iter = column_list[DB_LIST_TAG_MAP]; iter; iter = g_slist_next(iter)) { col_ptr = iter->data; if (!col_ptr) continue; if (col_ptr->is_view) { - if (strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_MAP_ID, strlen(MEDIA_SVC_DB_COLUMN_MAP_ID)) == 0) + if (strncmp(col_ptr->name, DB_COLUMN_MAP_ID, strlen(DB_COLUMN_MAP_ID)) == 0) g_string_append_printf(table_query, ", tag_media_count IS NOT NULL AS tag_media_count, tag_map.%s AS tm_id", col_ptr->name); else g_string_append_printf(table_query, ", tag_map.%s", col_ptr->name); } } - for (iter = column_list[MEDIA_SVC_DB_LIST_MEDIA]; iter; iter = g_slist_next(iter)) { + for (iter = column_list[DB_LIST_MEDIA]; iter; iter = g_slist_next(iter)) { col_ptr = iter->data; if (!col_ptr) @@ -201,7 +212,7 @@ static int __create_tag_view(uid_t uid) g_string_append_printf(table_query, ", media.%s", col_ptr->name); } - sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_VIEW_TAG, MEDIA_SVC_DB_VIEW_TAG, table_query->str); + sql = sqlite3_mprintf(DB_QUERY_VIEW_TAG, DB_VIEW_TAG, table_query->str); g_string_free(table_query, TRUE); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -214,7 +225,8 @@ static int __drop_views(uid_t uid) int ret = MS_MEDIA_ERR_NONE; char *sql = NULL; - sql = sqlite3_mprintf("DROP VIEW IF EXISTS %q;DROP VIEW IF EXISTS %q;DROP VIEW IF EXISTS %q", MEDIA_SVC_DB_VIEW_PLAYLIST, MEDIA_SVC_DB_VIEW_TAG, MEDIA_SVC_DB_VIEW_MEDIA); + sql = sqlite3_mprintf("DROP VIEW IF EXISTS %q;DROP VIEW IF EXISTS %q;DROP VIEW IF EXISTS %q", + DB_VIEW_PLAYLIST, DB_VIEW_TAG, DB_VIEW_MEDIA); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -290,15 +302,20 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e /*create index */ if (col_ptr->index_name) - g_string_append_printf(index_query, MEDIA_SVC_DB_QUERY_INDEX, col_ptr->index_name, table_name, col_ptr->name); + g_string_append_printf(index_query, DB_QUERY_INDEX, col_ptr->index_name, table_name, col_ptr->name); /*create trigger */ if (col_ptr->is_trigger) { if (STRING_VALID(tb->trigger_name)) { - if (strncmp(table_name, MEDIA_SVC_DB_TABLE_ALBUM, strlen(MEDIA_SVC_DB_TABLE_ALBUM)) == 0) - g_string_append_printf(trigger_query, MEDIA_SVC_DB_QUERY_TRIGGER_WITH_COUNT, tb->trigger_name, tb->event_table, tb->action_table, tb->event_table, col_ptr->name, col_ptr->name, col_ptr->name, col_ptr->name); - else - g_string_append_printf(trigger_query, MEDIA_SVC_DB_QUERY_TRIGGER, tb->trigger_name, tb->event_table, tb->action_table, col_ptr->name, col_ptr->name); + if (strncmp(table_name, DB_TABLE_ALBUM, strlen(DB_TABLE_ALBUM)) == 0) { + g_string_append_printf(trigger_query, DB_QUERY_TRIGGER_WITH_COUNT, + tb->trigger_name, tb->event_table, tb->action_table, tb->event_table, + col_ptr->name, col_ptr->name, col_ptr->name, col_ptr->name); + } else { + g_string_append_printf(trigger_query, DB_QUERY_TRIGGER, + tb->trigger_name, tb->event_table, tb->action_table, + col_ptr->name, col_ptr->name); + } } else { media_svc_error("invalid trigger name"); } @@ -307,9 +324,9 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e /*send queries */ if (unique_query->len > 0) - sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_TABLE_WITH_UNIQUE, table_name, table_query->str, unique_query->str); + sql = sqlite3_mprintf(DB_QUERY_TABLE_WITH_UNIQUE, table_name, table_query->str, unique_query->str); else - sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_TABLE, table_name, table_query->str); + sql = sqlite3_mprintf(DB_QUERY_TABLE, table_name, table_query->str); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -329,9 +346,9 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e } /*create view */ - if (strncmp(table_name, MEDIA_SVC_DB_TABLE_PLAYLIST, strlen(MEDIA_SVC_DB_TABLE_PLAYLIST)) == 0) + if (strncmp(table_name, DB_TABLE_PLAYLIST, strlen(DB_TABLE_PLAYLIST)) == 0) ret = __create_playlist_view(uid); - else if (strncmp(table_name, MEDIA_SVC_DB_TABLE_TAG, strlen(MEDIA_SVC_DB_TABLE_TAG)) == 0) + else if (strncmp(table_name, DB_TABLE_TAG, strlen(DB_TABLE_TAG)) == 0) ret = __create_tag_view(uid); ERROR: @@ -381,13 +398,13 @@ static int __media_svc_upgrade_table_query(sqlite3 *db_handle, const char *table snprintf(temp, sizeof(temp), "%s %s %s", col_ptr->name, col_ptr->type, col_ptr->option); else snprintf(temp, sizeof(temp), "%s %s", col_ptr->name, col_ptr->type); - sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_ALTER_TABLE, table_name, temp); + sql = sqlite3_mprintf(DB_QUERY_ALTER_TABLE, table_name, temp); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); //create index if (col_ptr->index_name) { - sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_INDEX, col_ptr->index_name, table_name, col_ptr->name); + sql = sqlite3_mprintf(DB_QUERY_INDEX, col_ptr->index_name, table_name, col_ptr->name); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -420,165 +437,154 @@ static void __media_svc_column_free(gpointer data) g_free(col); } -int _media_svc_init_table_query(const char *event_table_name) +int _media_svc_init_table_query(void) { int ret = MS_MEDIA_ERR_NONE; /*variable initialize.. */ table = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, __media_svc_table_free); - /*table specification.. (table_name, index, unique set, trigger, view, trigger name, event table, action table, view name) */ - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_MEDIA, NULL, NULL, NULL, NULL); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_FOLDER, NULL, NULL, NULL, NULL); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_PLAYLIST_MAP, MEDIA_SVC_DB_TRIGGER_PLAYLIST_MAP, event_table_name, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP, NULL); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_PLAYLIST, MEDIA_SVC_DB_TRIGGER_PLAYLIST_MAP1, MEDIA_SVC_DB_TABLE_PLAYLIST, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP, MEDIA_SVC_DB_VIEW_PLAYLIST); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_ALBUM, MEDIA_SVC_DB_TRIGGER_ALBUM, event_table_name, MEDIA_SVC_DB_TABLE_ALBUM, NULL); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_TAG_MAP, MEDIA_SVC_DB_TRIGGER_TAG_MAP, event_table_name, MEDIA_SVC_DB_TABLE_TAG_MAP, NULL); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_TAG, MEDIA_SVC_DB_TRIGGER_TAG_MAP1, MEDIA_SVC_DB_TABLE_TAG, MEDIA_SVC_DB_TABLE_TAG_MAP, MEDIA_SVC_DB_VIEW_TAG); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_BOOKMARK, MEDIA_SVC_DB_TRIGGER_BOOKMARK, event_table_name, MEDIA_SVC_DB_TABLE_BOOKMARK, NULL); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_STORAGE, NULL, NULL, NULL, NULL); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_FACE_SCAN_LIST, MEDIA_SVC_DB_TRIGGER_FACE_SCAN_LIST, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_FACE_SCAN_LIST, NULL); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_FACE, MEDIA_SVC_DB_TRIGGER_FACE, MEDIA_SVC_DB_TABLE_FACE_SCAN_LIST, MEDIA_SVC_DB_TABLE_FACE, NULL); - media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); + /*table specification.. (table_name, trigger name, event table, action table, view name) */ + __add_table_info(DB_TABLE_MEDIA, NULL, NULL, NULL, NULL); + __add_table_info(DB_TABLE_FOLDER, NULL, NULL, NULL, NULL); + __add_table_info(DB_TABLE_PLAYLIST_MAP, DB_TRIGGER_PLAYLIST_MAP, DB_TABLE_MEDIA, DB_TABLE_PLAYLIST_MAP, NULL); + __add_table_info(DB_TABLE_PLAYLIST, DB_TRIGGER_PLAYLIST_MAP1, DB_TABLE_PLAYLIST, DB_TABLE_PLAYLIST_MAP, DB_VIEW_PLAYLIST); + __add_table_info(DB_TABLE_ALBUM, DB_TRIGGER_ALBUM, DB_TABLE_MEDIA, DB_TABLE_ALBUM, NULL); + __add_table_info(DB_TABLE_TAG_MAP, DB_TRIGGER_TAG_MAP, DB_TABLE_MEDIA, DB_TABLE_TAG_MAP, NULL); + __add_table_info(DB_TABLE_TAG, DB_TRIGGER_TAG_MAP1, DB_TABLE_TAG, DB_TABLE_TAG_MAP, DB_VIEW_TAG); + __add_table_info(DB_TABLE_BOOKMARK, DB_TRIGGER_BOOKMARK, DB_TABLE_MEDIA, DB_TABLE_BOOKMARK, NULL); + __add_table_info(DB_TABLE_STORAGE, NULL, NULL, NULL, NULL); + __add_table_info(DB_TABLE_FACE_SCAN_LIST, DB_TRIGGER_FACE_SCAN_LIST, DB_TABLE_MEDIA, DB_TABLE_FACE_SCAN_LIST, NULL); + __add_table_info(DB_TABLE_FACE, DB_TRIGGER_FACE, DB_TABLE_FACE_SCAN_LIST, DB_TABLE_FACE, NULL); /*insert column info.. */ /*media*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_id", MEDIA_SVC_DB_TYPE_TEXT, "PRIMARY KEY", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_path", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL UNIQUE", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_display_name", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_type", MEDIA_SVC_DB_TYPE_INT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_mime_type", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_size", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_added_time", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_modified_time", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "folder_id", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_thumbnail_path", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_title", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "album_id", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_album", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_artist", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_album_artist", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_genre", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_composer", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_year", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_recorded_date", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_copyright", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_track_num", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_description", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_bitrate", MEDIA_SVC_DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_bitpersample", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V3, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_samplerate", MEDIA_SVC_DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_channel", MEDIA_SVC_DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_duration", MEDIA_SVC_DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_longitude", MEDIA_SVC_DB_TYPE_DOUBLE, "DEFAULT 0", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_latitude", MEDIA_SVC_DB_TYPE_DOUBLE, "DEFAULT 0", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_altitude", MEDIA_SVC_DB_TYPE_DOUBLE, "DEFAULT 0", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "exposure_time", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V4, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "fnumber", MEDIA_SVC_DB_TYPE_DOUBLE, "DEFAULT 0", USER_V4, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "iso", MEDIA_SVC_DB_TYPE_INT, "DEFAULT -1", USER_V4, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "model", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V4, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_width", MEDIA_SVC_DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_height", MEDIA_SVC_DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_datetaken", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_orientation", MEDIA_SVC_DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_rating", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_favourite", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_is_drm", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_storage_type", MEDIA_SVC_DB_TYPE_INT, NULL, USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_timeline", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_file_name_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_title_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_album_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_artist_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_album_artist_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_genre_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_composer_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_copyright_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_description_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_id", DB_TYPE_TEXT, "PRIMARY KEY", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_path", DB_TYPE_TEXT, "NOT NULL UNIQUE", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_display_name", DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_type", DB_TYPE_INT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_mime_type", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_size", DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_added_time", DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_modified_time", DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "folder_id", DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_thumbnail_path", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_title", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "album_id", DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_album", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_artist", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_album_artist", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_genre", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_composer", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_year", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_recorded_date", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_copyright", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_track_num", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_description", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_bitrate", DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_bitpersample", DB_TYPE_INT, "DEFAULT 0", USER_V3, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_samplerate", DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_channel", DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_duration", DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_longitude", DB_TYPE_DOUBLE, "DEFAULT 0", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_latitude", DB_TYPE_DOUBLE, "DEFAULT 0", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_altitude", DB_TYPE_DOUBLE, "DEFAULT 0", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "exposure_time", DB_TYPE_TEXT, NULL, USER_V4, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "fnumber", DB_TYPE_DOUBLE, "DEFAULT 0", USER_V4, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "iso", DB_TYPE_INT, "DEFAULT -1", USER_V4, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "model", DB_TYPE_TEXT, NULL, USER_V4, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_width", DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_height", DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_datetaken", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_orientation", DB_TYPE_INT, "DEFAULT -1", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_rating", DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_favourite", DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_is_drm", DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_storage_type", DB_TYPE_INT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_timeline", DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_file_name_pinyin", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_title_pinyin", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_album_pinyin", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_artist_pinyin", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_album_artist_pinyin", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_genre_pinyin", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_composer_pinyin", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_copyright_pinyin", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_description_pinyin", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); /* storage_uuid column is added in DB v4. When doing DB upgrade to v4, if storage_uuid is NOT NULL, alter table failed. */ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "storage_uuid", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V4, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "validity", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 1", USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_MEDIA], "storage_uuid", DB_TYPE_TEXT, NULL, USER_V4, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "validity", DB_TYPE_INT, "DEFAULT 1", USER_V2, NULL, false, false, false); /* color column is added with dcm. (DB v5) */ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "media_360", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V5, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_MEDIA], "media_360", DB_TYPE_INT, "DEFAULT 0", USER_V5, NULL, false, false, true); /*folder*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "folder_id", MEDIA_SVC_DB_TYPE_TEXT, "PRIMARY KEY", USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "folder_path", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, true, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "folder_name", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "folder_modified_time", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "folder_name_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "folder_storage_type", MEDIA_SVC_DB_TYPE_INT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_FOLDER], "folder_id", DB_TYPE_TEXT, "PRIMARY KEY", USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_FOLDER], "folder_path", DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, true, false, false); + __add_column_info(&column_list[DB_LIST_FOLDER], "folder_name", DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_FOLDER], "folder_modified_time", DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_FOLDER], "folder_name_pinyin", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_FOLDER], "folder_storage_type", DB_TYPE_INT, NULL, USER_V2, NULL, false, false, false); /* storage_uuid column is added in DB v4. When doing DB upgrade to v4, if storage_uuid is NOT NULL, alter table failed. */ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "storage_uuid", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V4, NULL, true, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "validity", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 1", USER_V4, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_FOLDER], "storage_uuid", DB_TYPE_TEXT, NULL, USER_V4, NULL, true, false, false); + __add_column_info(&column_list[DB_LIST_FOLDER], "validity", DB_TYPE_INT, "DEFAULT 1", USER_V4, NULL, false, false, false); /*playlist_map*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_PLAYLIST_MAP], "_id", MEDIA_SVC_DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_PLAYLIST_MAP], "playlist_id", MEDIA_SVC_DB_TYPE_INT, "NOT NULL", USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_PLAYLIST_MAP], "media_id", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, true, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_PLAYLIST_MAP], "playlist_member_order", MEDIA_SVC_DB_TYPE_INT, "NOT NULL", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_PLAYLIST_MAP], "_id", DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_PLAYLIST_MAP], "playlist_id", DB_TYPE_INT, "NOT NULL", USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_PLAYLIST_MAP], "media_id", DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, true, false); + __add_column_info(&column_list[DB_LIST_PLAYLIST_MAP], "playlist_member_order", DB_TYPE_INT, "NOT NULL", USER_V2, NULL, false, false, true); /*playlist*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_PLAYLIST], "playlist_id", MEDIA_SVC_DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, true, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_PLAYLIST], "playlist_name", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL UNIQUE", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_PLAYLIST], "thumbnail_path", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_PLAYLIST], "playlist_id", DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, true, true); + __add_column_info(&column_list[DB_LIST_PLAYLIST], "playlist_name", DB_TYPE_TEXT, "NOT NULL UNIQUE", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_PLAYLIST], "thumbnail_path", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); /*album*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_ALBUM], "album_id", MEDIA_SVC_DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, true, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_ALBUM], "name", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_ALBUM], "artist", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_ALBUM], "album_art", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_ALBUM], "album_id", DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, true, false); + __add_column_info(&column_list[DB_LIST_ALBUM], "name", DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_ALBUM], "artist", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_ALBUM], "album_art", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); /*tag_map*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_TAG_MAP], "_id", MEDIA_SVC_DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, false, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_TAG_MAP], "tag_id", MEDIA_SVC_DB_TYPE_INT, "NOT NULL", USER_V2, NULL, true, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_TAG_MAP], "media_id", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, true, true, false); + __add_column_info(&column_list[DB_LIST_TAG_MAP], "_id", DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_TAG_MAP], "tag_id", DB_TYPE_INT, "NOT NULL", USER_V2, NULL, true, false, false); + __add_column_info(&column_list[DB_LIST_TAG_MAP], "media_id", DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, true, true, false); /*tag*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_TAG], "tag_id ", MEDIA_SVC_DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, true, true); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_TAG], "tag_name", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL UNIQUE", USER_V2, NULL, false, false, true); + __add_column_info(&column_list[DB_LIST_TAG], "tag_id ", DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, true, true); + __add_column_info(&column_list[DB_LIST_TAG], "tag_name", DB_TYPE_TEXT, "NOT NULL UNIQUE", USER_V2, NULL, false, false, true); /*bookmark*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_BOOKMARK], "bookmark_id", MEDIA_SVC_DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_BOOKMARK], "media_id", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, true, true, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_BOOKMARK], "bookmark_marked_time", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, true, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_BOOKMARK], "bookmark_thumbnail_path", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_BOOKMARK], "bookmark_name", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V6, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_BOOKMARK], "bookmark_id", DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_BOOKMARK], "media_id", DB_TYPE_TEXT, "NOT NULL", USER_V2, NULL, true, true, false); + __add_column_info(&column_list[DB_LIST_BOOKMARK], "bookmark_marked_time", DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, true, false, false); + __add_column_info(&column_list[DB_LIST_BOOKMARK], "bookmark_thumbnail_path", DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_BOOKMARK], "bookmark_name", DB_TYPE_TEXT, NULL, USER_V6, NULL, false, false, false); /*storage*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_STORAGE], "storage_id", MEDIA_SVC_DB_TYPE_TEXT, "PRIMARY KEY", USER_V3, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_STORAGE], "storage_path", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V3, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_STORAGE], "storage_type", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V3, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_STORAGE], "validity", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 1", USER_V3, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_STORAGE], "storage_id", DB_TYPE_TEXT, "PRIMARY KEY", USER_V3, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_STORAGE], "storage_path", DB_TYPE_TEXT, "NOT NULL", USER_V3, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_STORAGE], "storage_type", DB_TYPE_INT, "DEFAULT 0", USER_V3, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_STORAGE], "validity", DB_TYPE_INT, "DEFAULT 1", USER_V3, NULL, false, false, false); /*face scan list*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FACE_SCAN_LIST], "media_id", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL UNIQUE", USER_V4, NULL, false, true, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FACE_SCAN_LIST], "modified_time", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V6, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_FACE_SCAN_LIST], "media_id", DB_TYPE_TEXT, "NOT NULL UNIQUE", USER_V4, NULL, false, true, false); + __add_column_info(&column_list[DB_LIST_FACE_SCAN_LIST], "modified_time", DB_TYPE_INT, "DEFAULT 0", USER_V6, NULL, false, false, false); /*face*/ - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FACE], "media_face_id", MEDIA_SVC_DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V4, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FACE], "media_id", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V4, NULL, true, true, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FACE], "face_rect_x", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, true, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FACE], "face_rect_y", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, true, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FACE], "face_rect_w", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, true, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FACE], "face_rect_h", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, true, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FACE], "face_orientation", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, false, false, false); - __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FACE], "media_face_tag", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V4, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_FACE], "media_face_id", DB_TYPE_INT, "PRIMARY KEY AUTOINCREMENT", USER_V4, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_FACE], "media_id", DB_TYPE_TEXT, "NOT NULL", USER_V4, NULL, true, true, false); + __add_column_info(&column_list[DB_LIST_FACE], "face_rect_x", DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, true, false, false); + __add_column_info(&column_list[DB_LIST_FACE], "face_rect_y", DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, true, false, false); + __add_column_info(&column_list[DB_LIST_FACE], "face_rect_w", DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, true, false, false); + __add_column_info(&column_list[DB_LIST_FACE], "face_rect_h", DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, true, false, false); + __add_column_info(&column_list[DB_LIST_FACE], "face_orientation", DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, false, false, false); + __add_column_info(&column_list[DB_LIST_FACE], "media_face_tag", DB_TYPE_TEXT, NULL, USER_V4, NULL, false, false, false); return ret; } -void _media_svc_destroy_table_query() +void _media_svc_destroy_table_query(void) { int i = 0; @@ -586,7 +592,7 @@ void _media_svc_destroy_table_query() g_hash_table_destroy(table); /* Column Free */ - for (i = 0; i < MEDIA_SVC_DB_LIST_MAX; i++) + for (i = 0; i < DB_LIST_MAX; i++) g_slist_free_full(column_list[i], __media_svc_column_free); } /* NOTICE : This function will be used someday.. Do not remove. @@ -594,28 +600,28 @@ static int __alter_table(sqlite3 *db_handle, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - ret = __media_svc_upgrade_table_query(db_handle, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_LIST_MEDIA, uid); + ret = __media_svc_upgrade_table_query(db_handle, DB_TABLE_MEDIA, DB_LIST_MEDIA, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "fail to __media_svc_upgrade_table_query [%d]", ret); - ret = __media_svc_upgrade_table_query(db_handle, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP, MEDIA_SVC_DB_LIST_PLAYLIST_MAP, uid); + ret = __media_svc_upgrade_table_query(db_handle, DB_TABLE_PLAYLIST_MAP, DB_LIST_PLAYLIST_MAP, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "fail to __media_svc_upgrade_table_query [%d]", ret); - ret = __media_svc_upgrade_table_query(db_handle, MEDIA_SVC_DB_TABLE_PLAYLIST, MEDIA_SVC_DB_LIST_PLAYLIST, uid); + ret = __media_svc_upgrade_table_query(db_handle, DB_TABLE_PLAYLIST, DB_LIST_PLAYLIST, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "fail to __media_svc_upgrade_table_query [%d]", ret); - ret = __media_svc_upgrade_table_query(db_handle, MEDIA_SVC_DB_TABLE_ALBUM, MEDIA_SVC_DB_LIST_ALBUM, uid); + ret = __media_svc_upgrade_table_query(db_handle, DB_TABLE_ALBUM, DB_LIST_ALBUM, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "fail to __media_svc_upgrade_table_query [%d]", ret); - ret = __media_svc_upgrade_table_query(db_handle, MEDIA_SVC_DB_TABLE_TAG_MAP, MEDIA_SVC_DB_LIST_TAG_MAP, uid); + ret = __media_svc_upgrade_table_query(db_handle, DB_TABLE_TAG_MAP, DB_LIST_TAG_MAP, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "fail to __media_svc_upgrade_table_query [%d]", ret); - ret = __media_svc_upgrade_table_query(db_handle, MEDIA_SVC_DB_TABLE_TAG, MEDIA_SVC_DB_LIST_TAG, uid); + ret = __media_svc_upgrade_table_query(db_handle, DB_TABLE_TAG, DB_LIST_TAG, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "fail to __media_svc_upgrade_table_query [%d]", ret); - ret = __media_svc_upgrade_table_query(db_handle, MEDIA_SVC_DB_TABLE_BOOKMARK, MEDIA_SVC_DB_LIST_BOOKMARK, uid); + ret = __media_svc_upgrade_table_query(db_handle, DB_TABLE_BOOKMARK, DB_LIST_BOOKMARK, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "fail to __media_svc_upgrade_table_query [%d]", ret); - ret = __media_svc_upgrade_table_query(db_handle, MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_LIST_STORAGE, uid); + ret = __media_svc_upgrade_table_query(db_handle, DB_TABLE_STORAGE, DB_LIST_STORAGE, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "fail to __media_svc_upgrade_table_query [%d]", ret); return ret; @@ -626,7 +632,7 @@ static void __media_svc_merge_table(gpointer data, gpointer user_data) int ret = MS_MEDIA_ERR_NONE; uid_t uid = GPOINTER_TO_INT(user_data); char *storage_id = (char *)data; - char *sql = sqlite3_mprintf("INSERT INTO %q SELECT * FROM %Q;DROP TABLE %Q;", MEDIA_SVC_DB_TABLE_MEDIA, storage_id, storage_id); + char *sql = sqlite3_mprintf("INSERT INTO %q SELECT * FROM %Q;DROP TABLE %Q;", DB_TABLE_MEDIA, storage_id, storage_id); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -654,7 +660,7 @@ static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); /* Insert items in external tables into media table, and drop external tables (5.5 to 6.0)*/ - sql = sqlite3_mprintf("SELECT storage_id FROM %q", MEDIA_SVC_DB_TABLE_STORAGE); + sql = sqlite3_mprintf("SELECT storage_id FROM %q", DB_TABLE_STORAGE); ret = media_db_get_result(db_handle, sql, &stmt); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Query failed. err[%d]", ret); @@ -675,7 +681,7 @@ static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid } /* Rebuilding view */ - ret = _media_svc_init_table_query(MEDIA_SVC_DB_TABLE_MEDIA); + ret = _media_svc_init_table_query(); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_init_table_query failed"); ret = __media_svc_rebuild_view_query(db_handle, uid); _media_svc_destroy_table_query(); @@ -956,7 +962,7 @@ void _media_svc_sql_query_release(GList **query_list) int _media_svc_check_db_upgrade(sqlite3 *db_handle, int user_version, uid_t uid) { if (user_version < LATEST_DB_VERSION) { - media_svc_error("Current DB is out of date(%d).. So start to upgrade DB(%d)", user_version, LATEST_DB_VERSION); + media_svc_error("Upgrade media DB from (%d) to (%d)", user_version, LATEST_DB_VERSION); return __media_svc_db_upgrade(db_handle, user_version, uid); } else { return MS_MEDIA_ERR_NONE; diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c index 06c6f10..1669b21 100755 --- a/src/common/media-svc-media-folder.c +++ b/src/common/media-svc-media-folder.c @@ -33,7 +33,7 @@ int _media_svc_get_folder_id_by_path(sqlite3 *handle, const char *storage_id, co sqlite3_stmt *sql_stmt = NULL; char *sql = NULL; - sql = sqlite3_mprintf("SELECT folder_id FROM %q WHERE folder_path=%Q AND storage_uuid=%Q", MEDIA_SVC_DB_TABLE_FOLDER, path, storage_id); + sql = sqlite3_mprintf("SELECT folder_id FROM %q WHERE folder_path=%Q AND storage_uuid=%Q", DB_TABLE_FOLDER, path, storage_id); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_sql_prepare_to_step failed [%d]", ret); @@ -60,7 +60,7 @@ static int __media_svc_append_folder(bool is_direct, const char *storage_id, ms_ _media_svc_get_pinyin_str(folder_name, &folder_name_pinyin); /* Sometime SQLITE3 returns NO_RECORD, so need to consider conflict case.. */ char *sql = sqlite3_mprintf("INSERT OR IGNORE INTO %q (folder_id, folder_path, folder_name, storage_uuid, folder_storage_type, folder_modified_time, folder_name_pinyin) values (%Q, %Q, %Q, %Q, '%d', '%d', %Q); ", - MEDIA_SVC_DB_TABLE_FOLDER, folder_id, folder_path, folder_name, storage_id, storage_type, folder_modified_date, folder_name_pinyin); + DB_TABLE_FOLDER, folder_id, folder_path, folder_name, storage_id, storage_type, folder_modified_date, folder_name_pinyin); if (is_direct) ret = _media_svc_sql_query_direct(sql, uid); @@ -82,7 +82,7 @@ int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uui modified_time = _media_svc_get_file_time(folder_path); - char *sql = sqlite3_mprintf("UPDATE %q SET folder_modified_time=%d WHERE folder_id=%Q;", MEDIA_SVC_DB_TABLE_FOLDER, modified_time, folder_uuid); + char *sql = sqlite3_mprintf("UPDATE %q SET folder_modified_time=%d WHERE folder_id=%Q;", DB_TABLE_FOLDER, modified_time, folder_uuid); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -189,10 +189,10 @@ int _media_svc_set_folder_validity(bool is_direct, const char *storage_id, const if (is_recursive) { sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_uuid='%q' AND (folder_path LIKE '%q/%%' OR folder_path='%q');", - MEDIA_SVC_DB_TABLE_FOLDER, validity, storage_id, start_path, start_path); + DB_TABLE_FOLDER, validity, storage_id, start_path, start_path); } else { sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_uuid='%q' AND folder_path='%q';", - MEDIA_SVC_DB_TABLE_FOLDER, validity, storage_id, start_path); + DB_TABLE_FOLDER, validity, storage_id, start_path); } if (is_direct) @@ -214,7 +214,7 @@ int _media_svc_check_folder_by_path(sqlite3 *handle, const char *storage_id, con media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL"); media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); - sql = sqlite3_mprintf("SELECT 1 FROM %q WHERE folder_path=%Q AND storage_uuid=%Q", MEDIA_SVC_DB_TABLE_FOLDER, path, storage_id); + sql = sqlite3_mprintf("SELECT 1 FROM %q WHERE folder_path=%Q AND storage_uuid=%Q", DB_TABLE_FOLDER, path, storage_id); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c index 7fbb832..a9d503b 100755 --- a/src/common/media-svc-media.c +++ b/src/common/media-svc-media.c @@ -43,7 +43,7 @@ int _media_svc_check_data_by_path(sqlite3 *handle, const char *path) media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Path is NULL"); - sql = sqlite3_mprintf("SELECT 1 FROM %q WHERE media_path=%Q", MEDIA_SVC_DB_TABLE_MEDIA, path); + sql = sqlite3_mprintf("SELECT 1 FROM %q WHERE media_path=%Q", DB_TABLE_MEDIA, path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); SQLITE3_FINALIZE(sql_stmt); @@ -59,7 +59,7 @@ int _media_svc_get_modified_time(sqlite3 *handle, const char *path, int *modifie media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Path is NULL"); - sql = sqlite3_mprintf("SELECT media_modified_time FROM %q WHERE media_path=%Q", MEDIA_SVC_DB_TABLE_MEDIA, path); + sql = sqlite3_mprintf("SELECT media_modified_time FROM %q WHERE media_path=%Q", DB_TABLE_MEDIA, path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -114,7 +114,7 @@ int _media_svc_insert_item_with_data(bool is_direct, media_svc_content_info_s *c %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d, \ %d, %d, %d, %d, %d, %.6f, %.6f, %.6f, %Q, %.6f, %d, %Q, %d, %d, %Q, %d, \ %d, %d, %d, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d);", - MEDIA_SVC_DB_TABLE_MEDIA, db_fields, + DB_TABLE_MEDIA, db_fields, content_info->media_uuid, content_info->path, content_info->file_name, @@ -177,7 +177,7 @@ int _media_svc_insert_item_with_data(bool is_direct, media_svc_content_info_s *c SQLITE3_SAFE_FREE(sql); sql = sqlite3_mprintf("INSERT INTO %q(%q) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, %Q, %d, %d, %d, %d, %d, %d, %d, %Q, %Q, %d);", - MEDIA_SVC_DB_TABLE_MEDIA, db_fields_basic, + DB_TABLE_MEDIA, db_fields_basic, content_info->media_uuid, content_info->path, content_info->file_name, @@ -225,7 +225,7 @@ int _media_svc_update_meta_with_data(media_svc_content_info_s *content_info) SQLITE3_SAFE_FREE(test_sql); char *sql = sqlite3_mprintf("UPDATE %q SET media_title=%Q, media_album=%Q, media_artist=%Q, media_album_artist=%Q, media_genre=%Q, media_composer=%Q, media_copyright=%Q, media_description=%Q WHERE media_path=%Q;", - MEDIA_SVC_DB_TABLE_MEDIA, + DB_TABLE_MEDIA, content_info->media_meta.title, content_info->media_meta.album, content_info->media_meta.artist, @@ -282,7 +282,7 @@ int _media_svc_update_item_with_data(bool is_direct, media_svc_content_info_s *c char *sql = sqlite3_mprintf("UPDATE %q SET media_size=%lld, media_modified_time=%d, media_thumbnail_path=%Q, media_title=%Q, album_id=%d, media_album=%Q, media_artist=%Q, media_album_artist=%Q, media_genre=%Q, \ media_composer=%Q, media_year=%Q, media_recorded_date=%Q, media_copyright=%Q, media_track_num=%Q, media_description=%Q, media_bitrate=%d, media_bitpersample=%d, media_samplerate=%d, media_channel=%d, media_duration=%d, \ media_longitude=%f, media_latitude=%f, media_altitude=%f, exposure_time=%Q, fnumber=%f, iso=%d, model=%Q, media_width=%d, media_height=%d, media_datetaken=%Q, media_orientation=%d WHERE media_path=%Q;", - MEDIA_SVC_DB_TABLE_MEDIA, + DB_TABLE_MEDIA, content_info->size, content_info->modified_time, content_info->thumbnail_path, @@ -336,7 +336,7 @@ int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, cha media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); - sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM %q WHERE media_path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path); + sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM %q WHERE media_path='%q'", DB_TABLE_MEDIA, path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); @@ -363,7 +363,7 @@ int _media_svc_delete_item_by_path(const char *path, uid_t uid) media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); - sql = sqlite3_mprintf("DELETE FROM %q WHERE media_path=%Q;", MEDIA_SVC_DB_TABLE_MEDIA, path); + sql = sqlite3_mprintf("DELETE FROM %q WHERE media_path=%Q;", DB_TABLE_MEDIA, path); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -381,7 +381,7 @@ int _media_svc_update_item_validity(const char *path, int validity, bool stack_q media_svc_debug("path=[%s], validity=[%d]", path, validity); - sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE media_path='%q';", MEDIA_SVC_DB_TABLE_MEDIA, validity, path); + sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE media_path='%q';", DB_TABLE_MEDIA, validity, path); if (!stack_query) { ret = _media_svc_sql_query_direct(sql, uid); @@ -397,7 +397,7 @@ int _media_svc_update_thumbnail_path(const char *path, const char *thumb_path, u { int ret = MS_MEDIA_ERR_NONE; - char *sql = sqlite3_mprintf("UPDATE %q SET media_thumbnail_path=%Q WHERE media_path=%Q;", MEDIA_SVC_DB_TABLE_MEDIA, thumb_path, path); + char *sql = sqlite3_mprintf("UPDATE %q SET media_thumbnail_path=%Q WHERE media_path=%Q;", DB_TABLE_MEDIA, thumb_path, path); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -410,7 +410,7 @@ int _media_svc_update_item_by_path(const char *src_path, const char *dst_storage int ret = MS_MEDIA_ERR_NONE; char *query = sqlite3_mprintf("UPDATE %q SET media_path=%Q, media_display_name=%Q, media_modified_time=%d, folder_id=%Q, media_storage_type=%d, storage_uuid='%q' WHERE media_path=%Q;", - MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, dest_storage, dst_storage_id, src_path); + DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, dest_storage, dst_storage_id, src_path); ret = _media_svc_sql_query(query, uid); SQLITE3_SAFE_FREE(query); @@ -487,7 +487,7 @@ int _media_svc_get_noti_info(sqlite3 *handle, const char *path, media_svc_noti_i media_svc_retvm_if(item == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "item is NULL"); media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); - sql = sqlite3_mprintf("SELECT media_id, media_type, media_mime_type FROM %q WHERE media_path=%Q", MEDIA_SVC_DB_TABLE_MEDIA, path); + sql = sqlite3_mprintf("SELECT media_id, media_type, media_mime_type FROM %q WHERE media_path=%Q", DB_TABLE_MEDIA, path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_sql_prepare_to_step() failed [%d]", ret); diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c index 9ffb0fa..b3d9765 100755 --- a/src/common/media-svc-storage.c +++ b/src/common/media-svc-storage.c @@ -39,7 +39,7 @@ int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **sto *storage_path = NULL; *validity = 0; - sql = sqlite3_mprintf("SELECT storage_path, validity FROM %q WHERE storage_id=%Q", MEDIA_SVC_DB_TABLE_STORAGE, storage_id); + sql = sqlite3_mprintf("SELECT storage_path, validity FROM %q WHERE storage_id=%Q", DB_TABLE_STORAGE, storage_id); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -55,7 +55,7 @@ int _media_svc_append_storage(const char *storage_id, const char *storage_path, { int ret = MS_MEDIA_ERR_NONE; char *sql = sqlite3_mprintf("INSERT INTO %q (storage_id, storage_path, storage_type) values (%Q, %Q, %d);", - MEDIA_SVC_DB_TABLE_STORAGE, storage_id, storage_path, storage_type); + DB_TABLE_STORAGE, storage_id, storage_path, storage_type); ret = _media_svc_sql_query_direct(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -78,7 +78,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); /*Storage table update*/ - sql = sqlite3_mprintf("UPDATE %q SET storage_path=%Q WHERE storage_id=%Q", MEDIA_SVC_DB_TABLE_STORAGE, path, storage_id); + sql = sqlite3_mprintf("UPDATE %q SET storage_path=%Q WHERE storage_id=%Q", DB_TABLE_STORAGE, path, storage_id); ret = _media_svc_sql_query_direct(sql, uid); SQLITE3_SAFE_FREE(sql); if (ret != MS_MEDIA_ERR_NONE) { @@ -87,7 +87,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons } /*Folder table update*/ - sql = sqlite3_mprintf("UPDATE %q SET folder_path=REPLACE(folder_path, %Q, %Q) WHERE storage_uuid=%Q", MEDIA_SVC_DB_TABLE_FOLDER, old_storage_path, path, storage_id); + sql = sqlite3_mprintf("UPDATE %q SET folder_path=REPLACE(folder_path, %Q, %Q) WHERE storage_uuid=%Q", DB_TABLE_FOLDER, old_storage_path, path, storage_id); ret = _media_svc_sql_query_direct(sql, uid); SQLITE3_SAFE_FREE(sql); if (ret != MS_MEDIA_ERR_NONE) { @@ -96,7 +96,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons } /*Media table update*/ - sql = sqlite3_mprintf("UPDATE %q SET media_path=REPLACE(media_path, %Q, %Q) WHERE storage_uuid=%Q", MEDIA_SVC_DB_TABLE_MEDIA, old_storage_path, path, storage_id); + sql = sqlite3_mprintf("UPDATE %q SET media_path=REPLACE(media_path, %Q, %Q) WHERE storage_uuid=%Q", DB_TABLE_MEDIA, old_storage_path, path, storage_id); ret = _media_svc_sql_query_direct(sql, uid); SQLITE3_SAFE_FREE(sql); g_free(old_storage_path); @@ -111,7 +111,7 @@ static int __media_svc_delete_thumbnail(sqlite3 *handle) char *sql = NULL; sqlite3_stmt *sql_stmt = NULL; - sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM %q WHERE validity=0 AND media_thumbnail_path is not null", MEDIA_SVC_DB_TABLE_MEDIA); + sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM %q WHERE validity=0 AND media_thumbnail_path is not null", DB_TABLE_MEDIA); ret = _media_svc_sql_prepare_to_step_simple(handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -132,7 +132,7 @@ int _media_svc_delete_invalid_storage(sqlite3 *handle, uid_t uid) media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to remove thumbnail"); sql = sqlite3_mprintf("DELETE FROM %q WHERE validity=0;DELETE FROM %q WHERE validity=0;DELETE FROM %q WHERE validity=0;", - MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_FOLDER); + DB_TABLE_MEDIA, DB_TABLE_STORAGE, DB_TABLE_FOLDER); ret = _media_svc_sql_query_direct(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -146,9 +146,9 @@ int _media_svc_update_storage_validity(const char *storage_id, int validity, uid char *sql = NULL; if (storage_id == NULL) - sql = sqlite3_mprintf("UPDATE %q SET validity=%d", MEDIA_SVC_DB_TABLE_STORAGE, validity); + sql = sqlite3_mprintf("UPDATE %q SET validity=%d", DB_TABLE_STORAGE, validity); else - sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_id=%Q", MEDIA_SVC_DB_TABLE_STORAGE, validity, storage_id); + sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_id=%Q", DB_TABLE_STORAGE, validity, storage_id); ret = _media_svc_sql_query_direct(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -169,14 +169,14 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get root path"); if (STRING_VALID(internal_path) && strncmp(path, internal_path, strlen(internal_path)) == 0) { - SAFE_STRLCPY(storage_id, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_UUID_SIZE+1); + SAFE_STRLCPY(storage_id, DB_TABLE_MEDIA, MEDIA_SVC_UUID_SIZE+1); g_free(internal_path); return MS_MEDIA_ERR_NONE; } g_free(internal_path); - sql = sqlite3_mprintf("SELECT storage_id FROM %q WHERE validity=1 AND instr(%Q, storage_path)", MEDIA_SVC_DB_TABLE_STORAGE, path); + sql = sqlite3_mprintf("SELECT storage_id FROM %q WHERE validity=1 AND instr(%Q, storage_path)", DB_TABLE_STORAGE, path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -203,7 +203,7 @@ int _media_svc_get_storage_path(sqlite3 *handle, GPtrArray **storage_path) media_svc_retvm_if(!storage_path, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_path is NULL"); - sql = sqlite3_mprintf("SELECT storage_path FROM %q WHERE validity=1", MEDIA_SVC_DB_TABLE_STORAGE); + sql = sqlite3_mprintf("SELECT storage_path FROM %q WHERE validity=1", DB_TABLE_STORAGE); ret = _media_svc_sql_prepare_to_step_simple(handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); diff --git a/src/common/media-svc.c b/src/common/media-svc.c index c27ebac..3ec4ce7 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -49,83 +49,83 @@ int media_svc_create_table(uid_t uid) media_svc_debug_fenter(); - ret = _media_svc_init_table_query(MEDIA_SVC_DB_TABLE_MEDIA); + ret = _media_svc_init_table_query(); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_init_table_query fail."); goto ERROR; } /*create media table*/ - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_LIST_MEDIA, uid); + ret = _media_svc_make_table_query(DB_TABLE_MEDIA, DB_LIST_MEDIA, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; } /*create folder table*/ - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_LIST_FOLDER, uid); + ret = _media_svc_make_table_query(DB_TABLE_FOLDER, DB_LIST_FOLDER, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; } /*create playlist_map table*/ - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_PLAYLIST_MAP, MEDIA_SVC_DB_LIST_PLAYLIST_MAP, uid); + ret = _media_svc_make_table_query(DB_TABLE_PLAYLIST_MAP, DB_LIST_PLAYLIST_MAP, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; } /*create playlist table*/ - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_PLAYLIST, MEDIA_SVC_DB_LIST_PLAYLIST, uid); + ret = _media_svc_make_table_query(DB_TABLE_PLAYLIST, DB_LIST_PLAYLIST, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; } /* create album table*/ - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_ALBUM, MEDIA_SVC_DB_LIST_ALBUM, uid); + ret = _media_svc_make_table_query(DB_TABLE_ALBUM, DB_LIST_ALBUM, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; } /*create tag_map table*/ - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_TAG_MAP, MEDIA_SVC_DB_LIST_TAG_MAP, uid); + ret = _media_svc_make_table_query(DB_TABLE_TAG_MAP, DB_LIST_TAG_MAP, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; } /*create tag table*/ - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_TAG, MEDIA_SVC_DB_LIST_TAG, uid); + ret = _media_svc_make_table_query(DB_TABLE_TAG, DB_LIST_TAG, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; } /*create bookmark table*/ - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_BOOKMARK, MEDIA_SVC_DB_LIST_BOOKMARK, uid); + ret = _media_svc_make_table_query(DB_TABLE_BOOKMARK, DB_LIST_BOOKMARK, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; } /*create storage table from tizen 2.4 */ - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_LIST_STORAGE, uid); + ret = _media_svc_make_table_query(DB_TABLE_STORAGE, DB_LIST_STORAGE, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; } /*create face table. from tizen 3.0*/ - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_FACE_SCAN_LIST, MEDIA_SVC_DB_LIST_FACE_SCAN_LIST, uid); + ret = _media_svc_make_table_query(DB_TABLE_FACE_SCAN_LIST, DB_LIST_FACE_SCAN_LIST, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; } - ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_FACE, MEDIA_SVC_DB_LIST_FACE, uid); + ret = _media_svc_make_table_query(DB_TABLE_FACE, DB_LIST_FACE, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_make_table_query fail."); goto ERROR; @@ -597,7 +597,7 @@ int media_svc_update_item_meta(sqlite3 *handle, uid_t uid) path_list = g_ptr_array_new_with_free_func(g_free); media_svc_retvm_if(!path_list, MS_MEDIA_ERR_OUT_OF_MEMORY, "Allocation failed"); - sql = sqlite3_mprintf("SELECT media_path FROM %q WHERE media_type=3 AND validity=1", MEDIA_SVC_DB_TABLE_MEDIA); + sql = sqlite3_mprintf("SELECT media_path FROM %q WHERE media_type=3 AND validity=1", DB_TABLE_MEDIA); ret = _media_svc_get_media(handle, sql, &path_list); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("Fail to get media list"); @@ -751,7 +751,7 @@ int media_svc_create_thumbnail(const char *file_path, int media_type, uid_t uid, } // 3. Update creation result to media db - sql = sqlite3_mprintf("UPDATE %q SET media_thumbnail_path='%q' WHERE media_path='%q';", MEDIA_SVC_DB_TABLE_MEDIA, thumb_path, file_path); + sql = sqlite3_mprintf("UPDATE %q SET media_thumbnail_path='%q' WHERE media_path='%q';", DB_TABLE_MEDIA, thumb_path, file_path); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); diff --git a/src/include/common/media-svc-db-utils.h b/src/include/common/media-svc-db-utils.h index aa272d0..0f56259 100755 --- a/src/include/common/media-svc-db-utils.h +++ b/src/include/common/media-svc-db-utils.h @@ -31,8 +31,8 @@ #define SQLITE3_SAFE_FREE(x) {if (x != NULL) {sqlite3_free(x); x = NULL; } } int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e list, uid_t uid); -int _media_svc_init_table_query(const char *event_table_name); -void _media_svc_destroy_table_query(); +int _media_svc_init_table_query(void); +void _media_svc_destroy_table_query(void); int _media_svc_sql_query(const char *sql_str, uid_t uid); int _media_svc_sql_query_direct(const char *sql_str, uid_t uid); int _media_svc_get_user_version(sqlite3 *db_handle, int *user_version); diff --git a/src/include/common/media-svc-env.h b/src/include/common/media-svc-env.h index c4be6f0..c440274 100755 --- a/src/include/common/media-svc-env.h +++ b/src/include/common/media-svc-env.h @@ -57,69 +57,69 @@ extern "C" { /** * Table Name */ -#define MEDIA_SVC_DB_TABLE_MEDIA "media" /**< media table*/ -#define MEDIA_SVC_DB_TABLE_FOLDER "folder" /**< media_folder table*/ -#define MEDIA_SVC_DB_TABLE_PLAYLIST "playlist" /**< playlist table*/ -#define MEDIA_SVC_DB_TABLE_PLAYLIST_MAP "playlist_map" /**< playlist_map table*/ -#define MEDIA_SVC_DB_TABLE_ALBUM "album" /**< album table*/ -#define MEDIA_SVC_DB_TABLE_TAG "tag" /**< tag table*/ -#define MEDIA_SVC_DB_TABLE_TAG_MAP "tag_map" /**< tag_map table*/ -#define MEDIA_SVC_DB_TABLE_BOOKMARK "bookmark" /**< bookmark table*/ -#define MEDIA_SVC_DB_TABLE_STORAGE "storage" /**< storage table*/ -#define MEDIA_SVC_DB_TABLE_TMP_TABLE "tmp" /**< tmp table for backup*/ -#define MEDIA_SVC_DB_TABLE_FACE "face" /**< face table*/ -#define MEDIA_SVC_DB_TABLE_FACE_SCAN_LIST "face_scan_list" /**< face_scan_list table*/ +#define DB_TABLE_MEDIA "media" /**< media table*/ +#define DB_TABLE_FOLDER "folder" /**< media_folder table*/ +#define DB_TABLE_PLAYLIST "playlist" /**< playlist table*/ +#define DB_TABLE_PLAYLIST_MAP "playlist_map" /**< playlist_map table*/ +#define DB_TABLE_ALBUM "album" /**< album table*/ +#define DB_TABLE_TAG "tag" /**< tag table*/ +#define DB_TABLE_TAG_MAP "tag_map" /**< tag_map table*/ +#define DB_TABLE_BOOKMARK "bookmark" /**< bookmark table*/ +#define DB_TABLE_STORAGE "storage" /**< storage table*/ +#define DB_TABLE_TMP_TABLE "tmp" /**< tmp table for backup*/ +#define DB_TABLE_FACE "face" /**< face table*/ +#define DB_TABLE_FACE_SCAN_LIST "face_scan_list" /**< face_scan_list table*/ /** * View Name */ -#define MEDIA_SVC_DB_VIEW_MEDIA "media_view" /**< media_view(For upgrade func) */ -#define MEDIA_SVC_DB_VIEW_PLAYLIST "playlist_view" /**< playlist_view*/ -#define MEDIA_SVC_DB_VIEW_TAG "tag_view" /**< tag_view*/ +#define DB_VIEW_MEDIA "media_view" /**< media_view(For upgrade func) */ +#define DB_VIEW_PLAYLIST "playlist_view" /**< playlist_view*/ +#define DB_VIEW_TAG "tag_view" /**< tag_view*/ /** * Trigger Name */ -#define MEDIA_SVC_DB_TRIGGER_PLAYLIST_MAP "playlist_map_cleanup" /**< media to map*/ -#define MEDIA_SVC_DB_TRIGGER_PLAYLIST_MAP1 "playlist_map_cleanup_1" /**< playlist to map*/ -#define MEDIA_SVC_DB_TRIGGER_ALBUM "album_cleanup" -#define MEDIA_SVC_DB_TRIGGER_TAG_MAP "tag_map_cleanup" /**< media to map*/ -#define MEDIA_SVC_DB_TRIGGER_TAG_MAP1 "tag_map_cleanup_1" /**< tag to map*/ -#define MEDIA_SVC_DB_TRIGGER_BOOKMARK "bookmark_cleanup" -#define MEDIA_SVC_DB_TRIGGER_FACE_SCAN_LIST "face_scan_list_cleanup" -#define MEDIA_SVC_DB_TRIGGER_FACE "face_cleanup" +#define DB_TRIGGER_PLAYLIST_MAP "playlist_map_cleanup" /**< media to map*/ +#define DB_TRIGGER_PLAYLIST_MAP1 "playlist_map_cleanup_1" /**< playlist to map*/ +#define DB_TRIGGER_ALBUM "album_cleanup" +#define DB_TRIGGER_TAG_MAP "tag_map_cleanup" /**< media to map*/ +#define DB_TRIGGER_TAG_MAP1 "tag_map_cleanup_1" /**< tag to map*/ +#define DB_TRIGGER_BOOKMARK "bookmark_cleanup" +#define DB_TRIGGER_FACE_SCAN_LIST "face_scan_list_cleanup" +#define DB_TRIGGER_FACE "face_cleanup" /** - * Trigger Name + * Column Name for view */ -#define MEDIA_SVC_DB_COLUMN_THUMBNAIL "thumbnail_path" -#define MEDIA_SVC_DB_COLUMN_MAP_ID "_id" +#define DB_COLUMN_THUMBNAIL "thumbnail_path" +#define DB_COLUMN_MAP_ID "_id" /** * option */ -#define MEDIA_SVC_DB_TYPE_TEXT "TEXT" -#define MEDIA_SVC_DB_TYPE_INT "INTEGER" -#define MEDIA_SVC_DB_TYPE_DOUBLE "DOUBLE" +#define DB_TYPE_TEXT "TEXT" +#define DB_TYPE_INT "INTEGER" +#define DB_TYPE_DOUBLE "DOUBLE" /** * Query form */ -#define MEDIA_SVC_DB_QUERY_TABLE_WITH_UNIQUE "CREATE TABLE IF NOT EXISTS '%s' (%s, unique(%s));" -#define MEDIA_SVC_DB_QUERY_TABLE "CREATE TABLE IF NOT EXISTS '%s' (%s);" -#define MEDIA_SVC_DB_QUERY_INDEX "CREATE INDEX IF NOT EXISTS %s on '%s' (%s);" -#define MEDIA_SVC_DB_QUERY_TRIGGER "CREATE TRIGGER IF NOT EXISTS '%s' DELETE ON '%s' BEGIN DELETE FROM %s WHERE %s=old.%s;END;" -#define MEDIA_SVC_DB_QUERY_TRIGGER_WITH_COUNT "CREATE TRIGGER IF NOT EXISTS '%s' DELETE ON '%s' BEGIN DELETE FROM %s WHERE (SELECT count(*) FROM '%s' WHERE %s=old.%s)=1 AND %s=old.%s;END;" -#define MEDIA_SVC_DB_QUERY_VIEW_PLAYLIST "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM playlist \ +#define DB_QUERY_TABLE_WITH_UNIQUE "CREATE TABLE IF NOT EXISTS '%s' (%s, unique(%s));" +#define DB_QUERY_TABLE "CREATE TABLE IF NOT EXISTS '%s' (%s);" +#define DB_QUERY_INDEX "CREATE INDEX IF NOT EXISTS %s on '%s' (%s);" +#define DB_QUERY_TRIGGER "CREATE TRIGGER IF NOT EXISTS '%s' DELETE ON '%s' BEGIN DELETE FROM %s WHERE %s=old.%s;END;" +#define DB_QUERY_TRIGGER_WITH_COUNT "CREATE TRIGGER IF NOT EXISTS '%s' DELETE ON '%s' BEGIN DELETE FROM %s WHERE (SELECT count(*) FROM '%s' WHERE %s=old.%s)=1 AND %s=old.%s;END;" +#define DB_QUERY_VIEW_PLAYLIST "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM playlist \ LEFT OUTER JOIN playlist_map ON playlist.playlist_id = playlist_map.playlist_id \ LEFT OUTER JOIN media ON (playlist_map.media_id = media.media_id AND media.validity=1) \ LEFT OUTER JOIN (SELECT count(playlist_id) as playlist_media_count, playlist_id FROM playlist_map group by playlist_id) as cnt_tbl ON (cnt_tbl.playlist_id=playlist_map.playlist_id AND media.validity=1);" -#define MEDIA_SVC_DB_QUERY_VIEW_TAG "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM tag \ +#define DB_QUERY_VIEW_TAG "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM tag \ LEFT OUTER JOIN tag_map ON tag.tag_id=tag_map.tag_id \ LEFT OUTER JOIN media ON (tag_map.media_id = media.media_id AND media.validity=1) \ LEFT OUTER JOIN (SELECT count(tag_id) as tag_media_count, tag_id FROM tag_map group by tag_id) as cnt_tbl ON (cnt_tbl.tag_id=tag_map.tag_id AND media.validity=1);" -#define MEDIA_SVC_DB_QUERY_ALTER_TABLE "ALTER TABLE %s ADD COLUMN %s;" +#define DB_QUERY_ALTER_TABLE "ALTER TABLE %s ADD COLUMN %s;" #define MEDIA_SVC_METADATA_LEN_MAX 512 /**< Length of metadata*/ @@ -137,18 +137,18 @@ typedef enum { } media_svc_query_type_e; typedef enum { - MEDIA_SVC_DB_LIST_MEDIA = 0, - MEDIA_SVC_DB_LIST_FOLDER, - MEDIA_SVC_DB_LIST_PLAYLIST_MAP, - MEDIA_SVC_DB_LIST_PLAYLIST, - MEDIA_SVC_DB_LIST_ALBUM, - MEDIA_SVC_DB_LIST_TAG_MAP, - MEDIA_SVC_DB_LIST_TAG, - MEDIA_SVC_DB_LIST_BOOKMARK, - MEDIA_SVC_DB_LIST_STORAGE, - MEDIA_SVC_DB_LIST_FACE_SCAN_LIST, - MEDIA_SVC_DB_LIST_FACE, - MEDIA_SVC_DB_LIST_MAX, + DB_LIST_MEDIA = 0, + DB_LIST_FOLDER, + DB_LIST_PLAYLIST_MAP, + DB_LIST_PLAYLIST, + DB_LIST_ALBUM, + DB_LIST_TAG_MAP, + DB_LIST_TAG, + DB_LIST_BOOKMARK, + DB_LIST_STORAGE, + DB_LIST_FACE_SCAN_LIST, + DB_LIST_FACE, + DB_LIST_MAX, } media_svc_table_slist_e; #ifdef __cplusplus -- 2.7.4