diff options
author | Minje Ahn <minje.ahn@samsung.com> | 2020-03-18 17:26:04 +0900 |
---|---|---|
committer | Minje Ahn <minje.ahn@samsung.com> | 2020-03-19 09:26:55 +0900 |
commit | cb3ef94fbb3822ef03918ba8655890dec414208f (patch) | |
tree | b0f301d0fcbef00c6bc0a14315ca10c306f1bd10 /src | |
parent | a891f94121be75cec7f17fec352c7ba90a316b9e (diff) | |
download | media-content-cb3ef94fbb3822ef03918ba8655890dec414208f.tar.gz media-content-cb3ef94fbb3822ef03918ba8655890dec414208f.tar.bz2 media-content-cb3ef94fbb3822ef03918ba8655890dec414208f.zip |
Remove unused keywords
Change-Id: Ic4f0a634cd0bbc94302ef57d6c3d032718bec73b
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/media_db.c | 84 |
1 files changed, 32 insertions, 52 deletions
diff --git a/src/media_db.c b/src/media_db.c index c706636..c39df01 100755 --- a/src/media_db.c +++ b/src/media_db.c @@ -1046,7 +1046,8 @@ int _media_db_get_group_item_count(const char *group_name, filter_h filter, grou char *tmp_query = NULL; char *condition_query = NULL; char *option_query = NULL; - bool is_simple = FALSE; + char *tmp_option = NULL; + bool need_bracket = false; filter_s *_filter = (filter_s *)filter; memset(select_query, 0x00, sizeof(select_query)); @@ -1055,7 +1056,8 @@ int _media_db_get_group_item_count(const char *group_name, filter_h filter, grou /* There are 2 ways to get count for media table for performance If user wants to set offset and count, use SQL SELECT_MEDIA_COUNT_FROM_MEDIA. If user wants to get count without setting count, SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE */ - if (_filter && ((_filter->offset < 0) && (_filter->count < 0))) { + if (_filter) { + if (_filter->offset < 0 && _filter->count < 0) { #ifdef _USE_TVPD_MODE if (STRING_VALID(_filter->storage_id)) snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE, _filter->storage_id); @@ -1067,12 +1069,19 @@ int _media_db_get_group_item_count(const char *group_name, filter_h filter, grou else snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE); #endif - is_simple = TRUE; + } else { +#ifdef _USE_TVPD_MODE + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA, DB_VIEW_MEDIA); +#else + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA); +#endif + need_bracket = true; + } } else { #ifdef _USE_TVPD_MODE - snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA, DB_VIEW_MEDIA); + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE, DB_VIEW_MEDIA); #else - snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA); + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE); #endif } } else if (group_type == MEDIA_GROUP_FOLDER) { @@ -1134,32 +1143,18 @@ int _media_db_get_group_item_count(const char *group_name, filter_h filter, grou return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } - ret = __media_db_make_query(filter, &condition_query, &option_query); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - if (tmp_query != NULL) - SQLITE3_SAFE_FREE(tmp_query); - return ret; - } - - if (group_type == MEDIA_GROUP_NONE) { - SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); - if (STRING_VALID(condition_query)) { - SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); - SAFE_STRLCAT(select_query, condition_query, sizeof(select_query)); - } - if (STRING_VALID(option_query)) - SAFE_STRLCAT(select_query, option_query, sizeof(select_query)); + SQLITE3_SAFE_FREE(tmp_query); - if (!is_simple) - SAFE_STRLCAT(select_query, QUERY_KEYWORD_BRACKET, sizeof(select_query)); + ret = __media_db_make_query(filter, &condition_query, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); - SAFE_FREE(condition_query); - SAFE_FREE(option_query); + if (need_bracket) { + tmp_option = g_strconcat(option_query, ")", NULL); + g_free(option_query); + option_query = tmp_option; } ret = _content_query_prepare(select_query, condition_query, option_query, &stmt); - if (tmp_query != NULL) - SQLITE3_SAFE_FREE(tmp_query); SAFE_FREE(condition_query); SAFE_FREE(option_query); media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); @@ -1411,6 +1406,7 @@ int _media_db_get_media_group_item_count(const char *group_name, filter_h filter sqlite3_stmt *stmt = NULL; char select_query[MAX_QUERY_SIZE] = {0, }; char *tmp_query = NULL; + char *tmp_option = NULL; char *condition_query = NULL; char *option_query = NULL; filter_s *_filter = (filter_s *)filter; @@ -1476,28 +1472,20 @@ int _media_db_get_media_group_item_count(const char *group_name, filter_h filter snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_GROUP_NULL, __media_db_get_group_name(group)); } #endif + SQLITE3_SAFE_FREE(tmp_query); + ret = __media_db_make_query(filter, &condition_query, &option_query); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - if (tmp_query != NULL) - SQLITE3_SAFE_FREE(tmp_query); - return ret; - } + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); - SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); - if (STRING_VALID(condition_query)) { - SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); - SAFE_STRLCAT(select_query, condition_query, sizeof(select_query)); + if (option_query) { + tmp_option = g_strconcat(option_query, ")", NULL); + g_free(option_query); + option_query = tmp_option; + } else { + SAFE_STRLCAT(select_query, ")", sizeof(select_query)); } - if (STRING_VALID(option_query)) - SAFE_STRLCAT(select_query, option_query, sizeof(select_query)); - SAFE_STRLCAT(select_query, QUERY_KEYWORD_BRACKET, sizeof(select_query)); - - SAFE_FREE(condition_query); - SAFE_FREE(option_query); ret = _content_query_prepare(select_query, condition_query, option_query, &stmt); - if (tmp_query != NULL) - SQLITE3_SAFE_FREE(tmp_query); SAFE_FREE(condition_query); SAFE_FREE(option_query); media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); @@ -1590,22 +1578,14 @@ int _media_db_get_media_group_item(const char *group_name, filter_h filter, medi int _media_db_get_storage(filter_h filter, media_storage_cb callback, void *user_data) { int ret = MEDIA_CONTENT_ERROR_NONE; - char select_query[DEFAULT_QUERY_SIZE] = {0, }; char *condition_query = NULL; char *option_query = NULL; sqlite3_stmt *stmt = NULL; - memset(select_query, 0x00, sizeof(select_query)); - - if (!SAFE_STRLCPY(select_query, SELECT_STORAGE_LIST, sizeof(select_query))) { - media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } - ret = __media_db_make_query(filter, &condition_query, &option_query); media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); - ret = _content_query_prepare(select_query, condition_query, option_query, &stmt); + ret = _content_query_prepare(SELECT_STORAGE_LIST, condition_query, option_query, &stmt); SAFE_FREE(condition_query); SAFE_FREE(option_query); media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); |