Remove unused keywords 30/228030/3
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 18 Mar 2020 08:26:04 +0000 (17:26 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 19 Mar 2020 00:26:55 +0000 (09:26 +0900)
Change-Id: Ic4f0a634cd0bbc94302ef57d6c3d032718bec73b
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media_info_private.h
include_product/media_info_private.h
src/media_db.c

index ec414eb..f03e8e5 100755 (executable)
@@ -69,7 +69,6 @@ extern "C" {
 #define MAX_QUERY_SIZE 4096
 #define MAX_PATH_LEN 4096
 #define DEFAULT_QUERY_SIZE 1024
-#define COLLATE_STR_SIZE 32
 #define MEDIA_CONTENT_UUID_SIZE        36
 #define BATCH_REQUEST_MAX 300
 
@@ -374,17 +373,6 @@ typedef struct _media_content_cb_data {
 #define DB_FIELD_MEDIA_LATITUDE                "media_latitude"
 #define DB_FIELD_MEDIA_ALTITUDE                "media_altitude"
 
-/* DB Query Keyword */
-#define QUERY_KEYWORD_AND "AND "
-#define QUERY_KEYWORD_OR "OR "
-#define QUERY_KEYWORD_ORDER_BY "ORDER BY "
-#define QUERY_KEYWORD_LIMIT "limit"
-#define QUERY_KEYWORD_DESC "DESC"
-#define QUERY_KEYWORD_SPACE " "
-#define QUERY_KEYWORD_OPEN_BRACKET "("
-#define QUERY_KEYWORD_BRACKET ")"
-#define QUERY_KEYWORD_COLLATE " COLLATE "
-
 /* DB TABLE JOIN */
 #define FOLDER_MEDIA_JOIN              DB_TABLE_FOLDER" NATURAL LEFT OUTER JOIN "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
 #define BOOKMARK_MEDIA_JOIN            DB_TABLE_BOOKMARK" NATURAL JOIN "DB_TABLE_MEDIA" WHERE validity IN (1, 2) "
index 621002b..978bb6e 100755 (executable)
@@ -72,7 +72,6 @@ extern "C" {
 #define MAX_QUERY_SIZE 4096
 #define MAX_PATH_LEN 4096
 #define DEFAULT_QUERY_SIZE 1024
-#define COLLATE_STR_SIZE 32
 #define MEDIA_CONTENT_UUID_SIZE        36
 #define BATCH_REQUEST_MAX 300
 
@@ -550,14 +549,8 @@ typedef struct _media_content_scan_cb_data_v2 {
 
 /* DB Query Keyword */
 #define QUERY_KEYWORD_AND "AND "
-#define QUERY_KEYWORD_OR "OR "
-#define QUERY_KEYWORD_ORDER_BY "ORDER BY "
-#define QUERY_KEYWORD_LIMIT "limit"
-#define QUERY_KEYWORD_DESC "DESC"
 #define QUERY_KEYWORD_SPACE " "
-#define QUERY_KEYWORD_OPEN_BRACKET "("
 #define QUERY_KEYWORD_BRACKET ")"
-#define QUERY_KEYWORD_COLLATE " COLLATE "
 
 /* DB TABLE JOIN */
 #define FOLDER_MEDIA_JOIN              DB_TABLE_FOLDER" NATURAL LEFT OUTER JOIN '%s' WHERE validity=1 "
index c706636..c39df01 100755 (executable)
@@ -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);