From 5470710328cf782264df2f1a0231b5b1d4b761f1 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Thu, 13 Apr 2017 18:46:32 +0900 Subject: [PATCH] Remove unused code Remove some index and code Change-Id: I45013235225d3371c34a1cbadc48654a227aee4b Signed-off-by: Minje Ahn --- packaging/libmedia-service.spec | 2 +- src/common/media-svc-db-utils.c | 53 +++++++++++++++++------------------------ 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec index a719b18..db95258 100644 --- a/packaging/libmedia-service.spec +++ b/packaging/libmedia-service.spec @@ -1,6 +1,6 @@ Name: libmedia-service Summary: Media information service library for multimedia applications -Version: 0.2.97 +Version: 0.3.0 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 and PD diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c index 67b763c..639d49f 100755 --- a/src/common/media-svc-db-utils.c +++ b/src/common/media-svc-db-utils.c @@ -259,10 +259,8 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e char trigger_query[MEDIA_SVC_QUERY_LEN_NORMAL] = {0, }; char table_query_sub[1024] = {0, }; char temp[1024] = {0 ,}; - int sflag = false; - int index_len = 0; - int trigger_len = 0; - int table_sub_len = 0; + bool flag = false; + bool sub_flag = false; int len = 0; int i = 0; @@ -283,19 +281,19 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e col_ptr = g_slist_nth_data(column_list[list], i); /*create table */ if (col_ptr->has_option) { - if (sflag == true) { + if (flag == true) { snprintf(temp, sizeof(temp), ", %s %s %s", col_ptr->name, col_ptr->type, col_ptr->option); } else { snprintf(temp, sizeof(temp), "%s %s %s", col_ptr->name, col_ptr->type, col_ptr->option); - sflag = true; + flag = true; } SAFE_STRLCAT(table_query, temp, sizeof(table_query)); } else { - if (sflag == true) { + if (flag == true) { snprintf(temp, sizeof(temp), ", %s %s", col_ptr->name, col_ptr->type); } else { snprintf(temp, sizeof(temp), "%s %s", col_ptr->name, col_ptr->type); - sflag = true; + flag = true; } SAFE_STRLCAT(table_query, temp, sizeof(table_query)); } @@ -303,25 +301,20 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e /*unique */ if (col_ptr->is_unique) { - if (table_sub_len > 0) { + if (sub_flag == true) { snprintf(temp, sizeof(temp), ", %s", col_ptr->name); } else { snprintf(temp, sizeof(temp), "%s", col_ptr->name); + sub_flag = true; } SAFE_STRLCAT(table_query_sub, temp, sizeof(table_query_sub)); - table_sub_len = strlen(table_query_sub); } memset(temp, 0, sizeof(temp)); /*create index */ if (col_ptr->is_index) { - if (index_len > 0) { - snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_INDEX, col_ptr->index_name, table_name, col_ptr->name); - } else { - snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_INDEX, col_ptr->index_name, table_name, col_ptr->name); - } + snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_INDEX, col_ptr->index_name, table_name, col_ptr->name); SAFE_STRLCAT(index_query, temp, sizeof(index_query)); - index_len = strlen(index_query); } memset(temp, 0, sizeof(temp)); @@ -334,7 +327,6 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_TRIGGER, tb->trigger_name, tb->event_table, tb->action_table, col_ptr->name, col_ptr->name); } SAFE_STRLCAT(trigger_query, temp, sizeof(trigger_query)); - trigger_len = strlen(trigger_query); } else { media_svc_error("invalid trigger name"); } @@ -343,7 +335,7 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e } /*send queries */ - if (table_sub_len > 0) { + if (sub_flag == true) { sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_TABLE_WITH_UNIQUE, table_name, table_query, table_query_sub); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -358,20 +350,20 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); } - if (index_len > 0) { + if (STRING_VALID(index_query)) { ret = _media_svc_sql_query(index_query, uid); memset(index_query, 0, sizeof(index_query)); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); } - if (trigger_len > 0) { + if (STRING_VALID(trigger_query)) { ret = _media_svc_sql_query(trigger_query, uid); memset(trigger_query, 0, sizeof(trigger_query)); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); } /*create view */ - sflag = false; + flag = false; if (tb != NULL && tb->view_name != NULL) { if (strncmp(table_name, MEDIA_SVC_DB_TABLE_MEDIA, strlen(MEDIA_SVC_DB_TABLE_MEDIA)) == 0) { sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_VIEW_MEDIA, tb->view_name, table_name); @@ -384,14 +376,14 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e for (i = 1; i < len; i++) { col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_PLAYLIST], i); if (col_ptr->is_view) { - if (sflag == true) { + if (flag == true) { if (strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_THUMBNAIL, strlen(MEDIA_SVC_DB_COLUMN_THUMBNAIL)) == 0) snprintf(temp, sizeof(temp), ", playlist.%s AS p_thumbnail_path", col_ptr->name); else snprintf(temp, sizeof(temp), ", playlist.%s", col_ptr->name); } else { snprintf(temp, sizeof(temp), "playlist.%s", col_ptr->name); - sflag = true; + flag = true; } SAFE_STRLCAT(table_query, temp, sizeof(table_query)); } @@ -429,11 +421,11 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e for (i = 1; i < len; i++) { col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_TAG], i); if (col_ptr->is_view) { - if (sflag == true) { + if (flag == true) { snprintf(temp, sizeof(temp), ", tag.%s", col_ptr->name); } else { snprintf(temp, sizeof(temp), "tag.%s", col_ptr->name); - sflag = true; + flag = true; } SAFE_STRLCAT(table_query, temp, sizeof(table_query)); } @@ -465,7 +457,6 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - } } @@ -593,7 +584,7 @@ int _media_svc_init_table_query(const char *event_table_name) media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "genre", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, "media_genre_idx", false, false, true); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "composer", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, "media_composer_idx", false, false, true); + ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "composer", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "year", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -649,15 +640,15 @@ int _media_svc_init_table_query(const char *event_table_name) media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "favourite", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V2, NULL, false, false, true); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "author", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, "media_author_idx", false, false, true); + ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "author", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "provider", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, "media_provider_idx", false, false, true); + ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "provider", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "content_name", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, "media_content_name_idx", false, false, true); + ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "content_name", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "category", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "location_tag", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, "media_location_tag_idx", false, false, true); + ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "location_tag", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_MEDIA], "age_rating", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, true); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); -- 2.7.4