#include <media_info_private.h>
+#include <media_util_private.h>
#include <vconf.h>
-static const char *media_token[] =
-{
+static const char *media_token[] = {
" ",
"\"",
"'",
};
-typedef struct _token_t
-{
+typedef struct _token_t {
int type;
char *str;
-}token_t;
+} token_t;
-
-#define MAX_LEFT_VALUE 512
-#define SPACE_LEN 1
-#define SPACE " "
#define UNKNOWN_TYPE 1000
#define STRING_TYPE 100
/*Check CSC first*/
bool pinyin_support = FALSE;
media_svc_check_pinyin_support(&pinyin_support);
- if(pinyin_support)
- {
+ if (pinyin_support) {
/*Check Language Setting*/
lang = vconf_get_str(VCONFKEY_LANGSET);
media_content_retvm_if(lang == NULL, ret, "Fail to get string of language set");
- if((strncmp(china, lang, strlen(china)) == 0) ||
- (strncmp(hongkong, lang, strlen(hongkong)) == 0))
- {
+ if ((strncmp(china, lang, strlen(china)) == 0) ||
+ (strncmp(hongkong, lang, strlen(hongkong)) == 0)) {
ret = TRUE;
}
static char *__get_order_str(media_content_order_e order_enum)
{
- switch(order_enum) {
- case MEDIA_CONTENT_ORDER_ASC:
- return (char *)"ASC";
- case MEDIA_CONTENT_ORDER_DESC:
- return (char *)"DESC";
- default:
- return (char *)" ";
+ switch (order_enum) {
+ case MEDIA_CONTENT_ORDER_ASC:
+ return (char *)"ASC";
+ case MEDIA_CONTENT_ORDER_DESC:
+ return (char *)"DESC";
+ default:
+ return (char *)" ";
}
}
static char *__get_collate_str(media_content_collation_e collate_type)
{
- switch(collate_type) {
- case MEDIA_CONTENT_COLLATE_NOCASE:
+ switch (collate_type) {
+ case MEDIA_CONTENT_COLLATE_NOCASE:
+ return (char *)"NOCASE";
+ case MEDIA_CONTENT_COLLATE_RTRIM:
+ return (char *)"RTRIM";
+ case MEDIA_CONTENT_COLLATE_LOCALIZED:
+ if (__is_pinyin_needed())
return (char *)"NOCASE";
- case MEDIA_CONTENT_COLLATE_RTRIM:
- return (char *)"RTRIM";
- case MEDIA_CONTENT_COLLATE_LOCALIZED:
- if(__is_pinyin_needed())
- return (char *)"NOCASE";
- else
- return (char *)"localized";
- default: return (char *)" ";
+ else
+ return (char *)"localized";
+ default: return (char *)" ";
}
}
static void __filter_attribute_free_value(gpointer key, gpointer value, gpointer user_data)
{
- SAFE_FREE(key);
- SAFE_FREE(value);
+ SAFE_G_FREE(key);
+ SAFE_G_FREE(value);
}
static char *__media_filter_replace_attr(attribute_h attr, char *name)
char *generated_value = NULL;
attribute_s *_attr = (attribute_s *)attr;
- if(!g_hash_table_lookup_extended(_attr->attr_map,
- name,
- (gpointer)&key_temp, (gpointer)&generated_value))
- {
- //can't find the value
- //media_content_error("NOT_FOUND_VALUE(%s)", name);
+ if (!g_hash_table_lookup_extended(_attr->attr_map, name, (gpointer)&key_temp, (gpointer)&generated_value)) {
+ /* can't find the value */
+ /* media_content_error("NOT_FOUND_VALUE(%s)", name); */
return NULL;
}
- if(STRING_VALID(generated_value))
- {
+ if (STRING_VALID(generated_value))
return strdup(generated_value);
- }
media_content_error("__media_filter_replace_attr fail");
int ret = 0;
const char *tmp = str;
- if(token != NULL && STRING_VALID(tmp))
- {
+ if (token != NULL && STRING_VALID(tmp)) {
token->type = op_type;
int token_size = strlen(media_token[op_type]);
media_content_retvm_if(token_size == 0, -1, "Invalid token_size. op_type[%d]", op_type);
media_content_retvm_if(token->str == NULL, -1, "OUT_OF_MEMORY");
strncpy(token->str, tmp, token_size);
- //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+ /*media_content_debug("type : [%d] str : [%s]", token->type, token->str);*/
ret = token_size;
- }
- else
- {
+ } else {
ret = -1;
}
int ret = size;
const char *tmp = str;
- if(token != NULL && STRING_VALID(tmp) && size > 0)
- {
+ if (token != NULL && STRING_VALID(tmp) && size > 0) {
token->str = (char*)calloc(size+1, sizeof(char));
media_content_retvm_if(token->str == NULL, -1, "OUT_OF_MEMORY");
token->type = UNKNOWN_TYPE;
strncpy(token->str, tmp, size);
- //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
- }
- else
- {
+ /*media_content_debug("type : [%d] str : [%s]", token->type, token->str);*/
+ } else {
ret = -1;
}
const char *tmp = str;
const char *dst_ptr = str + strlen(str);
- for (idx = 0; (*(tmp+idx)) && (tmp < dst_ptr); idx++)
- {
- //media_content_debug("[%d] '%c'", idx, tmp[idx]);
- if(tmp[idx] == ' ') //" "
- {
- if(idx == 0) // ignore the space.
- {
+ for (idx = 0; (*(tmp+idx)) && (tmp < dst_ptr); idx++) {
+ /*media_content_debug("[%d] '%c'", idx, tmp[idx]);*/
+ if (tmp[idx] == ' ') { /* " " */
+ if (idx == 0) { /* ignore the space. */
tmp++;
idx = -1;
continue;
token->type = UNKNOWN_TYPE;
token->str = (char*)calloc(idx+1, sizeof(char));
- if(token->str == NULL)
- {
+ if (token->str == NULL) {
SAFE_FREE(token);
media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
return -1;
}
strncpy(token->str, tmp, idx);
- //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+ /*media_content_debug("type : [%d] str : [%s]", token->type, token->str);*/
*token_list = g_list_append(*token_list, token);
tmp = tmp +idx + strlen(media_token[0]);
idx = -1;
- }
- else if(tmp[idx] == ',') // " , "
- {
- if(idx != 0)
- {
+ } else if (tmp[idx] == ',') { /* " , " */
+ if (idx != 0) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
- }
- else
- {
+ } else {
*token_list = g_list_append(*token_list, token);
tmp = tmp + idx;
}
}
token_t *token = (token_t*)calloc(1, sizeof(token_t));
- int size = __tokenize_operator(token, tmp,3);
+ int size = __tokenize_operator(token, tmp, 3);
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
tmp += size;
idx = -1;
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
}
- if(*tmp) //remained string
- {
+ if (*tmp) { /* remained string */
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
const char *tmp = str;
const char *dst_ptr = str + strlen(str);
- for (idx = 0; (*(tmp+idx)) && (tmp < dst_ptr); idx++)
- {
- //media_content_debug("[%d] '%c'", idx, tmp[idx]);
- if(tmp[idx] == media_token[0][0]) //" "
- {
- if(idx == 0) // ignore the space.
- {
+ for (idx = 0; (*(tmp+idx)) && (tmp < dst_ptr); idx++) {
+ /* media_content_debug("[%d] '%c'", idx, tmp[idx]); */
+ if (tmp[idx] == media_token[0][0]) { /* " " */
+ if (idx == 0) { /* ignore the space. */
tmp++;
idx = -1;
continue;
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
token->type = UNKNOWN_TYPE;
- token->str = (char*)calloc(idx+1, sizeof(char));
- if(token->str == NULL)
- {
+ token->str = (char *)calloc(idx+1, sizeof(char));
+ if (token->str == NULL) {
SAFE_FREE(token);
media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
return -1;
}
strncpy(token->str, tmp, idx);
- //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+ /* media_content_debug("type : [%d] str : [%s]", token->type, token->str); */
*token_list = g_list_append(*token_list, token);
tmp = tmp +idx + strlen(media_token[0]);
idx = -1;
- }
- else if(tmp[idx] == media_token[1][0]) // " \" "
- {
+ } else if (tmp[idx] == media_token[1][0]) { /* " \" " */
int j;
bool flag = false;
- for(j = idx+1; tmp[j]; j++) //find next quotation
- {
- if(tmp[j] == media_token[1][0] && tmp[j+1] == media_token[1][0])
- {
+ for (j = idx+1; tmp[j]; j++) { /* find next quotation */
+ if (tmp[j] == media_token[1][0] && tmp[j+1] == media_token[1][0]) {
j += 1;
continue;
}
- if(tmp[j] == media_token[1][0])
- {
+ if (tmp[j] == media_token[1][0]) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
token->str = (char*) calloc(j+1+1, sizeof(char));
- if(token->str == NULL)
- {
+ if (token->str == NULL) {
SAFE_FREE(token);
media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
return -1;
}
token->type = STRING_TYPE;
strncpy(token->str, tmp, j+1);
- //media_content_debug("type : [%d] str : [%s], j : %d", token->type, token->str, j);
+ /* media_content_debug("type : [%d] str : [%s], j : %d", token->type, token->str, j); */
*token_list = g_list_append(*token_list, token);
tmp = tmp + strlen(token->str);
idx = -1;
}
}
- if(!flag && *tmp != '\0' && tmp[j]=='\0')
- {
+ if (!flag && *tmp != '\0' && tmp[j] == '\0') {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
- token->str = (char*) calloc(j+1,sizeof(char));
- if(token->str == NULL)
- {
+ token->str = (char *) calloc(j+1, sizeof(char));
+ if (token->str == NULL) {
SAFE_FREE(token);
media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
return -1;
}
token->type = UNKNOWN_TYPE;
- strncpy(token->str, tmp,j);
- //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+ strncpy(token->str, tmp, j);
+ /* media_content_debug("type : [%d] str : [%s]", token->type, token->str);*/
*token_list = g_list_append(*token_list, token);
tmp = tmp +strlen(token->str);
idx = -1;
}
- }
- else if(tmp[idx] == media_token[2][0]) // " \' "
- {
+ } else if (tmp[idx] == media_token[2][0]) { /* " \' "*/
int j;
bool flag = false;
- for(j = idx+1; tmp[j]; j++)
- {
- if(tmp[j] == media_token[2][0] && tmp[j+1] == media_token[2][0])
- {
+ for (j = idx+1; tmp[j]; j++) {
+ if (tmp[j] == media_token[2][0] && tmp[j+1] == media_token[2][0]) {
j += 1;
continue;
}
- if(tmp[j] == media_token[2][0])
- {
+ if (tmp[j] == media_token[2][0]) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
- token->str = (char*) calloc(j+1+1, sizeof(char));
- if(token->str == NULL)
- {
+ token->str = (char *) calloc(j+1+1, sizeof(char));
+ if (token->str == NULL) {
SAFE_FREE(token);
media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
return -1;
}
token->type = STRING_TYPE;
strncpy(token->str, tmp, j+1);
- //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+ /* media_content_debug("type : [%d] str : [%s]", token->type, token->str); */
*token_list = g_list_append(*token_list, token);
tmp = tmp + strlen(token->str);
idx = -1;
}
}
- if(!flag && *tmp != '\0' && tmp[j]=='\0')
- {
+ if (!flag && *tmp != '\0' && tmp[j] == '\0') {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
- token->str = (char*) calloc(j+1,sizeof(char));
- if(token->str == NULL)
- {
+ token->str = (char*) calloc(j+1, sizeof(char));
+ if (token->str == NULL) {
SAFE_FREE(token);
media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
return -1;
}
token->type = UNKNOWN_TYPE;
- strncpy(token->str, tmp,j);
- //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+ strncpy(token->str, tmp, j);
+ /* media_content_debug("type : [%d] str : [%s]", token->type, token->str); */
*token_list = g_list_append(*token_list, token);
tmp = tmp + strlen(token->str);
idx = -1;
}
- }
- else if(tmp[idx] == media_token[3][0]) //"("
- {
- if(idx != 0)
- {
+ } else if (tmp[idx] == media_token[3][0]) { /* "(" */
+ if (idx != 0) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
- }
- else
- {
+ } else {
*token_list = g_list_append(*token_list, token);
tmp = tmp + idx;
}
}
token_t *token = (token_t*)calloc(1, sizeof(token_t));
- int size = __tokenize_operator(token, tmp,3);
+ int size = __tokenize_operator(token, tmp, 3);
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
tmp += size;
idx = -1;
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
- }
- else if(tmp[idx] == media_token[4][0]) //")"
- {
- if(idx != 0)
- {
+ } else if (tmp[idx] == media_token[4][0]) { /* ")" */
+ if (idx != 0) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
- }
- else
- {
+ } else {
*token_list = g_list_append(*token_list, token);
tmp = tmp + idx;
}
}
token_t *token = (token_t*)calloc(1, sizeof(token_t));
- int size = __tokenize_operator(token, tmp,4);
+ int size = __tokenize_operator(token, tmp, 4);
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
tmp += size;
idx = -1;
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
- }
- else if(tmp[idx] == media_token[5][0]) //"="
- {
- if(idx != 0)
- {
+ } else if (tmp[idx] == media_token[5][0]) { /* "=" */
+ if (idx != 0) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
- }
- else
- {
+ } else {
*token_list = g_list_append(*token_list, token);
tmp = tmp + idx;
}
}
token_t *token = (token_t*)calloc(1, sizeof(token_t));
- int size = __tokenize_operator(token, tmp,5);
+ int size = __tokenize_operator(token, tmp, 5);
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
tmp += size;
idx = -1;
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
- }
- else if(tmp[idx] == media_token[6][0] && tmp[idx+1] == media_token[6][1]) //"<=",
- {
- if(idx != 0)
- {
+ } else if (tmp[idx] == media_token[6][0] && tmp[idx+1] == media_token[6][1]) { /* "<=", */
+ if (idx != 0) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
- }
- else
- {
+ } else {
*token_list = g_list_append(*token_list, token);
tmp = tmp + idx;
}
}
token_t *token = (token_t*)calloc(1, sizeof(token_t));
- int size = __tokenize_operator(token, tmp,6);
+ int size = __tokenize_operator(token, tmp, 6);
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
tmp += size;
idx = -1;
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
- }
- else if(tmp[idx] == media_token[7][0]) //"<",
- {
- if(idx != 0)
- {
+ } else if (tmp[idx] == media_token[7][0]) { /* "<", */
+ if (idx != 0) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
- }
- else
- {
+ } else {
*token_list = g_list_append(*token_list, token);
tmp = tmp + idx;
}
}
token_t *token = (token_t*)calloc(1, sizeof(token_t));
- int size = __tokenize_operator(token, tmp,7);
+ int size = __tokenize_operator(token, tmp, 7);
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
tmp += size;
idx = -1;
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
- }
- else if(tmp[idx] == media_token[8][0] && tmp[idx+1] == media_token[8][1]) //">=",
- {
- if(idx != 0)
- {
+ } else if (tmp[idx] == media_token[8][0] && tmp[idx+1] == media_token[8][1]) { /* ">=", */
+ if (idx != 0) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
- }
- else
- {
+ } else {
*token_list = g_list_append(*token_list, token);
tmp = tmp + idx;
}
}
token_t *token = (token_t*)calloc(1, sizeof(token_t));
- int size = __tokenize_operator(token, tmp,8);
+ int size = __tokenize_operator(token, tmp, 8);
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
tmp += size;
idx = -1;
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
- }
- else if(tmp[idx] == media_token[9][0]) //">",
- {
- if(idx != 0)
- {
+ } else if (tmp[idx] == media_token[9][0]) { /* ">", */
+ if (idx != 0) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
- }
- else
- {
+ } else {
*token_list = g_list_append(*token_list, token);
tmp = tmp + idx;
}
}
token_t *token = (token_t*)calloc(1, sizeof(token_t));
- int size = __tokenize_operator(token, tmp,9);
+ int size = __tokenize_operator(token, tmp, 9);
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
tmp += size;
idx = -1;
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
- }
- else if(tmp[idx] == media_token[10][0] && tmp[idx+1] == media_token[10][1]) //"!=",
- {
- if(idx != 0)
- {
+ } else if (tmp[idx] == media_token[10][0] && tmp[idx+1] == media_token[10][1]) { /* "!=", */
+ if (idx != 0) {
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
- }
- else
- {
+ } else {
*token_list = g_list_append(*token_list, token);
tmp = tmp + idx;
}
token_t *token = (token_t*)calloc(1, sizeof(token_t));
int size = __tokenize_operator(token, tmp, 10);
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
tmp += size;
idx = -1;
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
}
- if(*tmp) //remained string
- {
+ if (*tmp) { /* remained string */
token_t *token = (token_t*)calloc(1, sizeof(token_t));
media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
ret = __tokenize_string(token, tmp, idx);
- if (ret < 0)
- {
+ if (ret < 0) {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
}
- if(token != NULL && STRING_VALID(token->str))
- {
+ if (token != NULL && STRING_VALID(token->str)) {
*token_list = g_list_append(*token_list, token);
- }
- else
- {
+ } else {
SAFE_FREE(token);
media_content_error("tokenize error occured");
return -1;
attribute_s *_attr = (attribute_s*)calloc(1, sizeof(attribute_s));
media_content_retvm_if(_attr == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- _attr->attr_map = g_hash_table_new (g_str_hash, g_str_equal);
+ _attr->attr_map = g_hash_table_new(g_str_hash, g_str_equal);
*attr = (attribute_h)_attr;
return ret;
media_content_retvm_if(_attr == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid attr");
- if(STRING_VALID(user_attr) && STRING_VALID(platform_attr))
- {
- _user = strdup(user_attr);
+ if (STRING_VALID(user_attr) && STRING_VALID(platform_attr)) {
+ _user = g_strdup(user_attr);
media_content_retvm_if(_user == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- _platform = strdup(platform_attr);
- if(_platform == NULL)
- {
- SAFE_FREE(_user);
+ _platform = g_strdup(platform_attr);
+ if (_platform == NULL) {
+ SAFE_G_FREE(_user);
media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
- g_hash_table_insert (_attr->attr_map, _user, _platform);
- }
- else
- {
+ g_hash_table_insert(_attr->attr_map, _user, _platform);
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
media_content_retvm_if(_attr == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid attr");
- if(_attr->attr_map != NULL)
- {
+ if (_attr->attr_map != NULL) {
g_hash_table_foreach(_attr->attr_map, __filter_attribute_free_value, NULL);
g_hash_table_destroy(_attr->attr_map);
}
return ret;
}
-int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition)
+int _media_filter_attribute_generate(attribute_h attr, filter_h filter, char **generated_condition)
{
unsigned int idx = 0;
GList *token_list = NULL;
- int size = 0;
int ret = MEDIA_CONTENT_ERROR_NONE;
- int total_str_size = 0;
token_t *token;
+ filter_s *_filter = NULL;
+ char tmp_condition[MAX_QUERY_SIZE] = {0, };
- media_content_retvm_if(condition == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid condition");
- media_content_retvm_if(generated_condition == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid generated_condition");
media_content_retvm_if(attr == NULL, MEDIA_CONTENT_ERROR_DB_FAILED, "DB field mapping table doesn't exist. Check db connection");
+ media_content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid filter");
+ media_content_retvm_if(generated_condition == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid generated_condition");
+
+ _filter = (filter_s*)filter;
+
+ media_content_retvm_if(_filter->condition == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid condition");
+ media_content_retvm_if(_filter->condition_collate_type < MEDIA_CONTENT_COLLATE_DEFAULT ||
+ _filter->condition_collate_type > MEDIA_CONTENT_COLLATE_LOCALIZED, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid condition collate");
- if(__tokenize(&token_list, condition) < 0)
- {
+ if (__tokenize(&token_list, _filter->condition) < 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++)
- {
+ 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)
- {
+ if ((token != NULL) && (token->type == UNKNOWN_TYPE)) {
char *replace_str = __media_filter_replace_attr(attr, token->str);
- if(STRING_VALID(replace_str))
- {
+ if (STRING_VALID(replace_str)) {
SAFE_FREE(token->str);
token->str = replace_str;
+ } else {
+ SAFE_FREE(replace_str);
}
}
-
- total_str_size += strlen(token->str)+1;
- //media_content_debug("[%d][type:%d]:%s", idx, token->type, token->str);
}
- //make the statment
- size = total_str_size + COLLATE_STR_SIZE + 1;
- * generated_condition = (char*)calloc(size, sizeof(char));
+ /* make the statment */
+ memset(tmp_condition, 0, sizeof(tmp_condition));
+ SAFE_STRLCAT(tmp_condition, QUERY_KEYWORD_OPEN_BRACKET, sizeof(tmp_condition));
- for(idx = 0; idx < g_list_length(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))
- {
- SAFE_STRLCAT(*generated_condition, token->str, size);
- SAFE_STRLCAT(*generated_condition, SPACE, size);
+ if ((token != NULL) && STRING_VALID(token->str)) {
+ SAFE_STRLCAT(tmp_condition, token->str, sizeof(tmp_condition));
+ SAFE_STRLCAT(tmp_condition, QUERY_KEYWORD_SPACE, sizeof(tmp_condition));
SAFE_FREE(token->str);
SAFE_FREE(token);
}
}
- if(collate_type == MEDIA_CONTENT_COLLATE_NOCASE || collate_type == MEDIA_CONTENT_COLLATE_RTRIM ||collate_type == MEDIA_CONTENT_COLLATE_LOCALIZED) {
- SAFE_STRLCAT(*generated_condition, "COLLATE ", size);
- SAFE_STRLCAT(*generated_condition, __get_collate_str(collate_type), size);
- SAFE_STRLCAT(*generated_condition, SPACE, size);
+ /* Process for filter v1 */
+ if (_filter->is_full_condition == false && _filter->condition_collate_type != MEDIA_CONTENT_COLLATE_DEFAULT) {
+ SAFE_STRLCAT(tmp_condition, QUERY_KEYWORD_COLLATE, sizeof(tmp_condition));
+ SAFE_STRLCAT(tmp_condition, __get_collate_str(_filter->condition_collate_type), sizeof(tmp_condition));
+ SAFE_STRLCAT(tmp_condition, QUERY_KEYWORD_SPACE, sizeof(tmp_condition));
}
- //media_content_debug("statement : %s(%d) (total:%d)", *generated_condition, strlen(*generated_condition), total_str_size);
- media_content_sec_debug("Condition : %s", *generated_condition);
+ SAFE_STRLCAT(tmp_condition, QUERY_KEYWORD_BRACKET, sizeof(tmp_condition));
- //if(*generated_condition != NULL)
- // res = 1;
+ if (STRING_VALID(tmp_condition))
+ *generated_condition = g_strdup(tmp_condition);
+ else
+ *generated_condition = NULL;
- if(token_list != NULL)
+ media_content_sec_debug("Condition : %s", *generated_condition);
+
+ if (token_list != NULL) {
g_list_free(token_list);
+ token_list = NULL;
+ }
return ret;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
filter_s *_filter = NULL;
- char option_query[DEFAULT_QUERY_SIZE] = {0, };
- char condition[DEFAULT_QUERY_SIZE] = {0, };
- int size = 0;
- //bool order_by = true;
+ char query[DEFAULT_QUERY_SIZE] = {0, };
+ char option[DEFAULT_QUERY_SIZE] = {0, };
media_content_retvm_if(attr == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid attr");
media_content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid filter");
_filter = (filter_s*)filter;
- memset(option_query, 0x00, sizeof(option_query));
+ memset(query, 0x00, sizeof(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);
+ 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;
+ 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 ((token != NULL) && (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);
+ } else {
+ media_content_error("There is no matched db field for %s", token->str);
+ SAFE_FREE(replace_str);
+ }
+ }
+ }
+
+ /* make the statment */
+ SAFE_STRLCAT(query, QUERY_KEYWORD_ORDER_BY, sizeof(query));
+
+ 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)) {
+ SAFE_STRLCAT(query, token->str, sizeof(query));
+ SAFE_STRLCAT(query, QUERY_KEYWORD_SPACE, sizeof(query));
+
+ SAFE_FREE(token->str);
+ SAFE_FREE(token);
+ }
+ }
+
+ if (token_list != NULL) {
+ g_list_free(token_list);
+ token_list = NULL;
+ }
+ } else {
+ SAFE_STRLCAT(query, _filter->order_keyword, sizeof(query));
+ }
+ }
+
+ /* offset */
+ SAFE_STRLCAT(query, QUERY_KEYWORD_SPACE, sizeof(query));
+
+ memset(option, 0, sizeof(option));
+ snprintf(option, sizeof(option), "%s %d, %d", QUERY_KEYWORD_LIMIT, _filter->offset, _filter->count);
+
+ SAFE_STRLCAT(query, option, sizeof(query));
+
+ if (STRING_VALID(query)) {
+ *generated_option = g_strdup(query);
+ media_content_sec_debug("Option : %s", *generated_option);
+ } else {
+ *generated_option = NULL;
+ }
+
+ return ret;
+}
+
+int _media_filter_attribute_option_generate_with_full_query(attribute_h attr, filter_h filter, char **generated_option)
+{
+ unsigned int idx = 0;
+ GList *token_list = NULL;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ token_t *token = NULL;
+ filter_s * _filter = NULL;
+ char query[DEFAULT_QUERY_SIZE] = {0, };
+ char option[DEFAULT_QUERY_SIZE] = {0, };
+
+ media_content_retvm_if(attr == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid attr");
+ media_content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid filter");
+ media_content_retvm_if(generated_option == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid generated_option");
+
+ _filter = (filter_s*)filter;
+
+ memset(query, 0, sizeof(query));
+
+ /* Order by*/
+ if (STRING_VALID(_filter->order_keyword)) {
+ if (__tokenize_attribute(&token_list, _filter->order_keyword) < 0) {
+ media_content_error("INVALID_PARAMETER(0x%08x):Invalid the order", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- for(idx = 0; idx < g_list_length(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->type == UNKNOWN_TYPE)
- {
+ if ((token != NULL) && (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));
- }
-
+ if (STRING_VALID(replace_str)) {
SAFE_FREE(token->str);
- token->str = attr_str;
+ token->str = replace_str;
+ } else {
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);
}
- //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 */
+ SAFE_STRLCAT(query, QUERY_KEYWORD_ORDER_BY, sizeof(query));
- for(idx = 0; idx < g_list_length(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)) {
+ SAFE_STRLCAT(query, token->str, sizeof(query));
+ SAFE_STRLCAT(query, QUERY_KEYWORD_SPACE, sizeof(query));
SAFE_FREE(token->str);
SAFE_FREE(token);
}
}
- snprintf(condition, sizeof(condition), "ORDER BY %s", generated_condition);
- SAFE_STRLCAT(option_query, condition, sizeof(option_query));
-
- if(token_list != NULL)
+ if (token_list != NULL) {
g_list_free(token_list);
-
- SAFE_FREE(generated_condition);
+ token_list = NULL;
+ }
}
/* offset */
- SAFE_STRLCAT(option_query, SPACE, sizeof(option_query));
- snprintf(condition, sizeof(condition), "LIMIT %d, %d", _filter->offset, _filter->count);
- SAFE_STRLCAT(option_query, condition, sizeof(option_query));
+ SAFE_STRLCAT(query, QUERY_KEYWORD_SPACE, sizeof(query));
- if(STRING_VALID(option_query))
- {
- *generated_option = strdup(option_query);
- }
- else
- {
+ memset(option, 0, sizeof(option));
+ snprintf(option, sizeof(option), "%s %d, %d", QUERY_KEYWORD_LIMIT, _filter->offset, _filter->count);
+ SAFE_STRLCAT(query, option, sizeof(query));
+
+ if (STRING_VALID(query)) {
+ *generated_option = g_strdup(query);
+ media_content_sec_debug("Option : %s", *generated_option);
+ } else {
*generated_option = NULL;
}
return ret;
}
+
int media_filter_create(filter_h *filter)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
_filter->order_collate_type = MEDIA_CONTENT_COLLATE_DEFAULT;
_filter->offset = -1;
_filter->count = -1;
+ _filter->is_full_condition = false;
+ _filter->is_full_order = false;
*filter = (filter_h)_filter;
int ret = MEDIA_CONTENT_ERROR_NONE;
filter_s *_filter = (filter_s*)filter;
- if(_filter)
- {
+ if (_filter) {
SAFE_FREE(_filter->storage_id);
SAFE_FREE(_filter->condition);
SAFE_FREE(_filter->order_keyword);
SAFE_FREE(_filter);
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
filter_s *_filter = (filter_s*)filter;
- if(_filter != NULL)
- {
+ if (_filter != NULL) {
_filter->offset = offset;
_filter->count = count;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
filter_s *_filter = (filter_s*)filter;
- if((_filter != NULL) && STRING_VALID(condition)
- && ((collate_type >= MEDIA_CONTENT_COLLATE_DEFAULT) && (collate_type <= MEDIA_CONTENT_COLLATE_LOCALIZED)))
- {
- if(STRING_VALID(_filter->condition))
- {
+ if ((_filter != NULL) && STRING_VALID(condition)
+ && ((collate_type >= MEDIA_CONTENT_COLLATE_DEFAULT) && (collate_type <= MEDIA_CONTENT_COLLATE_LOCALIZED))) {
+
+ _filter->is_full_condition = false;
+
+ if (STRING_VALID(_filter->condition))
SAFE_FREE(_filter->condition);
- }
- _filter->condition = strdup(condition);
+ char new_condition[MAX_QUERY_SIZE] = {0, };
+ memset(new_condition, 0, sizeof(new_condition));
+ ret = _media_content_replace_path_in_condition(condition, new_condition, TRUE);
+ media_content_retvm_if(!STRING_VALID(new_condition), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+
+ _filter->condition = strdup(new_condition);
media_content_retvm_if(_filter->condition == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
media_content_sec_debug("Condition string : %s", _filter->condition);
_filter->condition_collate_type = collate_type;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
filter_s *_filter = (filter_s*)filter;
- if((_filter != NULL) && STRING_VALID(order_keyword)
- && ((order_type == MEDIA_CONTENT_ORDER_ASC) ||(order_type == MEDIA_CONTENT_ORDER_DESC))
- && ((collate_type >= MEDIA_CONTENT_COLLATE_DEFAULT) && (collate_type <= MEDIA_CONTENT_COLLATE_LOCALIZED)))
- {
+ if ((_filter != NULL) && STRING_VALID(order_keyword)
+ && ((order_type == MEDIA_CONTENT_ORDER_ASC) || (order_type == MEDIA_CONTENT_ORDER_DESC))
+ && ((collate_type >= MEDIA_CONTENT_COLLATE_DEFAULT) && (collate_type <= MEDIA_CONTENT_COLLATE_LOCALIZED))) {
+
+ _filter->is_full_order = false;
+
SAFE_FREE(_filter->order_keyword);
- if(STRING_VALID(order_keyword))
- {
- _filter->order_keyword = strdup(order_keyword);
- media_content_retvm_if(_filter->order_keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ _filter->order_keyword = strdup(order_keyword);
+ media_content_retvm_if(_filter->order_keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- _filter->order_type = order_type;
- _filter->order_collate_type = collate_type;
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
+ _filter->order_type = order_type;
+ _filter->order_collate_type = collate_type;
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int media_filter_set_storage(filter_h filter, const char *storage_id)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_content_warn("DEPRECATION WARNING: media_filter_set_storage() is deprecated and will be removed from next release. Use media_filter_set_condition() with MEDIA_PATH keyword instead.");
filter_s *_filter = (filter_s*)filter;
- if((_filter != NULL) && STRING_VALID(storage_id))
- {
- if(STRING_VALID(_filter->storage_id))
- {
+ if ((_filter != NULL) && STRING_VALID(storage_id)) {
+ if (STRING_VALID(_filter->storage_id))
SAFE_FREE(_filter->storage_id);
- }
_filter->storage_id = strdup(storage_id);
media_content_retvm_if(_filter->storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
media_content_sec_debug("storage_id : %s", _filter->storage_id);
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
filter_s *_filter = (filter_s*)filter;
- if(_filter)
- {
+ if (_filter) {
*offset = _filter->offset;
*count = _filter->count;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
filter_s *_filter = (filter_s*)filter;
- if(_filter)
- {
- if(STRING_VALID(_filter->condition))
- {
- *condition = strdup(_filter->condition);
+ if (_filter) {
+ if (STRING_VALID(_filter->condition) && _filter->is_full_condition == false) {
+ char new_condition[MAX_QUERY_SIZE] = {0, };
+ memset(new_condition, 0, sizeof(new_condition));
+ ret = _media_content_replace_path_in_condition(_filter->condition, new_condition, FALSE);
+ media_content_retvm_if(!STRING_VALID(new_condition), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+
+ *condition = strdup(new_condition);
media_content_retvm_if(*condition == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- else
- {
+ } else {
*condition = NULL;
}
*collate_type = _filter->condition_collate_type;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
filter_s *_filter = (filter_s*)filter;
- if(_filter)
- {
- if(STRING_VALID(_filter->order_keyword))
- {
+ if (_filter) {
+ if (STRING_VALID(_filter->order_keyword) && _filter->is_full_order == false) {
*order_keyword = strdup(_filter->order_keyword);
media_content_retvm_if(*order_keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- else
- {
+ } else {
*order_keyword = NULL;
}
*order_type = _filter->order_type;
*collate_type = _filter->order_collate_type;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int media_filter_get_storage(filter_h filter, char **storage_id)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_content_warn("DEPRECATION WARNING: media_filter_get_storage() is deprecated and will be removed from next release.");
filter_s *_filter = (filter_s*)filter;
- if(_filter)
- {
- if(STRING_VALID(_filter->storage_id))
- {
+ if (_filter) {
+ if (STRING_VALID(_filter->storage_id)) {
*storage_id = strdup(_filter->storage_id);
media_content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- else
- {
+ } else {
*storage_id = NULL;
}
+ } else {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- else
- {
+
+ return ret;
+}
+
+int media_filter_set_condition_v2(filter_h filter, const char *condition)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ filter_s *_filter = (filter_s*)filter;
+
+ if ((_filter != NULL) && STRING_VALID(condition)) {
+ _filter->is_full_condition = true;
+
+ if (STRING_VALID(_filter->condition))
+ SAFE_FREE(_filter->condition);
+
+ char new_condition[MAX_QUERY_SIZE] = {0, };
+ memset(new_condition, 0, sizeof(new_condition));
+ ret = _media_content_replace_path_in_condition(condition, new_condition, TRUE);
+ media_content_retvm_if(!STRING_VALID(new_condition), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+
+ _filter->condition = strdup(new_condition);
+ media_content_retvm_if(_filter->condition == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+
+ media_content_sec_debug("Condition string : %s", _filter->condition);
+ } else {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+int media_filter_get_condition_v2(filter_h filter, char **condition)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ filter_s *_filter = (filter_s*)filter;
+
+ if (_filter) {
+ if (STRING_VALID(_filter->condition) && _filter->is_full_condition == true) {
+ char new_condition[MAX_QUERY_SIZE] = {0, };
+ memset(new_condition, 0, sizeof(new_condition));
+ ret = _media_content_replace_path_in_condition(_filter->condition, new_condition, FALSE);
+ media_content_retvm_if(!STRING_VALID(new_condition), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+
+ *condition = strdup(new_condition);
+ media_content_retvm_if(*condition == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
+ *condition = NULL;
+ }
+ } else {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+int media_filter_set_order_v2(filter_h filter, const char *order)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ filter_s *_filter = (filter_s*)filter;
+
+ if ((_filter != NULL) && STRING_VALID(order)) {
+ _filter->is_full_order = true;
+
+ SAFE_FREE(_filter->order_keyword);
+
+ _filter->order_keyword = strdup(order);
+ media_content_retvm_if(_filter->order_keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
return ret;
}
+
+int media_filter_get_order_v2(filter_h filter, char **order)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ filter_s *_filter = (filter_s*)filter;
+
+ if (_filter) {
+ if (STRING_VALID(_filter->order_keyword) && _filter->is_full_order == true) {
+ *order = strdup(_filter->order_keyword);
+ media_content_retvm_if(*order == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
+ *order = NULL;
+ }
+ } else {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+