Add other type for media filter 08/72708/1 accepted/tizen/common/20160603.150906 accepted/tizen/ivi/20160606.121110 accepted/tizen/mobile/20160606.120722 accepted/tizen/tv/20160606.120912 accepted/tizen/wearable/20160606.121034 submit/tizen/20160603.021103 submit/tizen/20160603.061849
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 2 Jun 2016 06:58:02 +0000 (15:58 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 2 Jun 2016 06:58:02 +0000 (15:58 +0900)
Change-Id: Ifa6afe1ab296fce27042fee10763daacb63e1ad1
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media_content_type.h
src/media_filter.c

index d5ac633..5757cb0 100755 (executable)
@@ -115,6 +115,7 @@ typedef enum {
 typedef enum {
        MEDIA_CONTENT_ORDER_ASC   = 0,      /**< Ascending order*/
        MEDIA_CONTENT_ORDER_DESC  = 1,      /**< Descending order*/
+       MEDIA_CONTENT_ORDER_OTHER = 2,          /** order by order key**/
 } media_content_order_e;
 
 /**
index c3ed4de..93609ff 100755 (executable)
@@ -779,73 +779,78 @@ int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, c
        memset(option_query, 0x00, sizeof(option_query));
 
        /* Order by*/
-       if (STRING_VALID(_filter->order_keyword) && ((_filter->order_type == MEDIA_CONTENT_ORDER_ASC) || (_filter->order_type == MEDIA_CONTENT_ORDER_DESC))) {
-               unsigned int idx = 0;
-               int total_str_size = 0;
-               GList *token_list = NULL;
-               token_t *token;
-               char *attr_str;
-
-               if (__tokenize_attribute(&token_list, _filter->order_keyword) < 0) {
-                       media_content_error("INVALID_PARAMETER(0x%08x):Invalid the condition", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-               }
-
-               for (idx = 0; idx < g_list_length(token_list); idx++) {
-                       token = (token_t*)g_list_nth_data(token_list, idx);
+       if (STRING_VALID(_filter->order_keyword)) {
+               if ((_filter->order_type == MEDIA_CONTENT_ORDER_ASC) || (_filter->order_type == MEDIA_CONTENT_ORDER_DESC)) {
+                       unsigned int idx = 0;
+                       int total_str_size = 0;
+                       GList *token_list = NULL;
+                       token_t *token;
+                       char *attr_str;
+
+                       if (__tokenize_attribute(&token_list, _filter->order_keyword) < 0) {
+                               media_content_error("INVALID_PARAMETER(0x%08x):Invalid the condition", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+                       }
 
-                       if (token->type == UNKNOWN_TYPE) {
-                               char *replace_str = __media_filter_replace_attr(attr, token->str);
-                               if (STRING_VALID(replace_str)) {
-                                       attr_str = (char*)calloc(strlen(replace_str) + COLLATE_STR_SIZE + 1, sizeof(char));
-                                       if (attr_str == NULL) {
-                                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       for (idx = 0; idx < g_list_length(token_list); idx++) {
+                               token = (token_t*)g_list_nth_data(token_list, idx);
+
+                               if (token->type == UNKNOWN_TYPE) {
+                                       char *replace_str = __media_filter_replace_attr(attr, token->str);
+                                       if (STRING_VALID(replace_str)) {
+                                               attr_str = (char*)calloc(strlen(replace_str) + COLLATE_STR_SIZE + 1, sizeof(char));
+                                               if (attr_str == NULL) {
+                                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                                       SAFE_FREE(replace_str);
+                                                       continue;
+                                               }
+
+                                               if (_filter->order_collate_type == MEDIA_CONTENT_COLLATE_NOCASE || _filter->order_collate_type == MEDIA_CONTENT_COLLATE_RTRIM || _filter->order_collate_type == MEDIA_CONTENT_COLLATE_LOCALIZED)
+                                                       snprintf(attr_str, strlen(replace_str) + COLLATE_STR_SIZE + 1, "%s COLLATE %s %s", replace_str, __get_collate_str(_filter->order_collate_type), __get_order_str(_filter->order_type));
+                                               else
+                                                       snprintf(attr_str, strlen(replace_str) + COLLATE_STR_SIZE + 1, "%s %s", replace_str, __get_order_str(_filter->order_type));
+
+                                               SAFE_FREE(token->str);
+                                               token->str = attr_str;
                                                SAFE_FREE(replace_str);
-                                               continue;
+                                       } else {
+                                               media_content_error("There is no matched db field for %s", token->str);
                                        }
-
-                                       if (_filter->order_collate_type == MEDIA_CONTENT_COLLATE_NOCASE || _filter->order_collate_type == MEDIA_CONTENT_COLLATE_RTRIM || _filter->order_collate_type == MEDIA_CONTENT_COLLATE_LOCALIZED)
-                                               snprintf(attr_str, strlen(replace_str) + COLLATE_STR_SIZE + 1, "%s COLLATE %s %s", replace_str, __get_collate_str(_filter->order_collate_type), __get_order_str(_filter->order_type));
-                                       else
-                                               snprintf(attr_str, strlen(replace_str) + COLLATE_STR_SIZE + 1, "%s %s", replace_str, __get_order_str(_filter->order_type));
-
-                                       SAFE_FREE(token->str);
-                                       token->str = attr_str;
-                                       SAFE_FREE(replace_str);
-                               } else {
-                                       media_content_error("There is no matched db field for %s", token->str);
                                }
-                       }
 
-                       total_str_size += strlen(token->str) + 1;
-                       /* media_content_debug("[%d][type:%d]:%s", idx, token->type, token->str); */
-               }
+                               total_str_size += strlen(token->str) + 1;
+                               /* media_content_debug("[%d][type:%d]:%s", idx, token->type, token->str); */
+                       }
 
-               /* make the statment */
-               char *generated_condition = NULL;
-               size = total_str_size + COLLATE_STR_SIZE + 1;
-               generated_condition = (char*)calloc(size, sizeof(char));
+                       /* make the statment */
+                       char *generated_condition = NULL;
+                       size = total_str_size + COLLATE_STR_SIZE + 1;
+                       generated_condition = (char*)calloc(size, sizeof(char));
 
-               for (idx = 0; idx < g_list_length(token_list); idx++) {
-                       token = (token_t*)g_list_nth_data(token_list, idx);
+                       for (idx = 0; idx < g_list_length(token_list); idx++) {
+                               token = (token_t*)g_list_nth_data(token_list, idx);
 
-                       if ((token != NULL) && STRING_VALID(token->str)) {
-                               /* media_content_debug("[%d] %s", idx, token->str); */
-                               SAFE_STRLCAT(generated_condition, token->str, size);
-                               SAFE_STRLCAT(generated_condition, SPACE, size);
+                               if ((token != NULL) && STRING_VALID(token->str)) {
+                                       /* media_content_debug("[%d] %s", idx, token->str); */
+                                       SAFE_STRLCAT(generated_condition, token->str, size);
+                                       SAFE_STRLCAT(generated_condition, SPACE, size);
 
-                               SAFE_FREE(token->str);
-                               SAFE_FREE(token);
+                                       SAFE_FREE(token->str);
+                                       SAFE_FREE(token);
+                               }
                        }
-               }
 
-               snprintf(condition, sizeof(condition), "ORDER BY %s", generated_condition);
-               SAFE_STRLCAT(option_query, condition, sizeof(option_query));
+                       snprintf(condition, sizeof(condition), "ORDER BY %s", generated_condition);
+                       SAFE_STRLCAT(option_query, condition, sizeof(option_query));
 
-               if (token_list != NULL)
-                       g_list_free(token_list);
+                       if (token_list != NULL)
+                               g_list_free(token_list);
 
-               SAFE_FREE(generated_condition);
+                       SAFE_FREE(generated_condition);
+               } else {
+                       SAFE_STRLCAT(option_query, _filter->order_keyword, sizeof(option_query));
+                       media_content_error("option_query [%s]", option_query);
+               }
        }
 
        /* offset */