summaryrefslogtreecommitdiff
path: root/src/ps_searcher.cpp
diff options
context:
space:
mode:
authorJunghyun Kim <jh1114.kim@samsung.com>2012-08-21 20:20:51 +0900
committerJunghyun Kim <jh1114.kim@samsung.com>2012-08-21 20:20:51 +0900
commit705b925c45567f2fc5a002fd3fd89d94e66bc2f6 (patch)
tree2074280b0ea934170b6eef3dbe445bf9bccddd73 /src/ps_searcher.cpp
parentbf8879b3c9c9a58111b20ea76263a5845a2f56fb (diff)
downloadsmartsearch-705b925c45567f2fc5a002fd3fd89d94e66bc2f6.tar.gz
smartsearch-705b925c45567f2fc5a002fd3fd89d94e66bc2f6.tar.bz2
smartsearch-705b925c45567f2fc5a002fd3fd89d94e66bc2f6.zip
Update changed code
Diffstat (limited to 'src/ps_searcher.cpp')
-rwxr-xr-xsrc/ps_searcher.cpp2015
1 files changed, 1302 insertions, 713 deletions
diff --git a/src/ps_searcher.cpp b/src/ps_searcher.cpp
index 58414c6..ff74b42 100755
--- a/src/ps_searcher.cpp
+++ b/src/ps_searcher.cpp
@@ -1,12 +1,12 @@
/*
* Copyright 2012 Samsung Electronics Co., Ltd
- *
+ *
* Licensed under the Flora License, Version 1.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.tizenopensource.org/license
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,21 +27,43 @@
#include <calendar-svc-provider.h>
#include <memo-db.h>
-#include <email-types.h>
-#include <email-api.h>
+#include <email-api-mail.h>
-#include <visual-svc.h>
-#include <visual-svc-types.h>
-#include <audio-svc.h>
-#include <audio-svc-types.h>
-#include <audio-svc-error.h>
+#include <favorites.h>
+#include <media_content.h>
-#include <ail.h>
+#include <msg_storage.h>
+#include <msg_storage_types.h>
+#include <msg.h>
-static GList *g_history_list;
+#include <ail.h>
+#include <unicode/ucal.h>
+#include <unicode/ustring.h>
+#include <unicode/ustdio.h>
+#include <unicode/udat.h>
char* g_keyword = NULL;
+struct search_cb_data {
+ struct search_content_object *obj;
+ struct appdata *ad;
+ char *keyword;
+ struct search_genlist_info *result_info;
+};
+
+struct search_cb_data_browser {
+ struct search_content_object *obj;
+ struct appdata *ad;
+ char *keyword;
+ struct search_genlist_info *result_info;
+ struct search_more_result *info;
+};
+
+struct media_cb_data {
+ bool is_sdcard;
+ char *dirname;
+};
+
int search_sql_stmt_init(sqlite3_stmt * sql_stmt)
{
SEARCH_FUNC_START;
@@ -61,6 +83,8 @@ int search_sql_stmt_init(sqlite3_stmt * sql_stmt)
}
SEARCH_FUNC_END;
+
+ return SEARCH_RET_SUCCESS;
}
int search_sql_stmt_finalize(sqlite3_stmt * stmt)
@@ -101,45 +125,88 @@ int search_sql_prepare_stmt(sqlite3 *db_handle, const char *query,
return ret;
}
+int search_sql_bind_text(sqlite3* db_handle, sqlite3_stmt *sql_stmt, int col, char *data)
+{
+ int rc = 0;
+ int ret = SEARCH_RET_SEARCH_NONE;
+
+ rc = sqlite3_bind_text(sql_stmt, col, data, strlen(data), SQLITE_STATIC);
+ if (rc != SQLITE_OK) {
+ SEARCH_DEBUG_ERROR("SQL BIND TEXT ERROR : %s(%d) / %s\n",
+ sqlite3_errmsg(db_handle),
+ rc,
+ data);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ }
+
+ return ret;
+}
+
+int search_sql_bind_int(sqlite3* db_handle, sqlite3_stmt *sql_stmt, int col, int data)
+{
+ int rc = 0;
+ int ret = SEARCH_RET_SEARCH_NONE;
+
+ rc = sqlite3_bind_int(sql_stmt, col, data);
+ if (rc != SQLITE_OK) {
+ SEARCH_DEBUG_ERROR("SQL BIND INT ERROR : %s(%d) / %d\n",
+ sqlite3_errmsg(db_handle),
+ rc,
+ data);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ }
+ return ret;
+}
+
static int __search_sql_contact_search_result_cb(CTSvalue * value,
void *user_data)
{
SEARCH_FUNC_START;
- struct appdata *ad = (struct appdata *)user_data;
+ struct search_cb_data *scd = (struct search_cb_data*)user_data;
- struct search_item_sel *sel_mem = NULL;
- int type = SEARCH_TYPE_PHONE_CONTACTS;
+ struct appdata *ad = scd->ad;
+ struct search_content_object* obj = scd->obj;
+ struct search_genlist_info *result_info = scd->result_info;
+ char *keyword = scd->keyword;
struct search_item_sel *sel_mem_info = NULL;
+ struct search_item_more_sel *sel_mem_more = NULL;
+ struct search_genlist_item_info *gen_item = NULL;
+
+ const char* contact_img_path = NULL;
char display_name[128] = { 0, };
const char *first, *last, *display, *number;
bool is_word_in_str;
- if (ad->cate_info[type].next_point == 0) {
- //### Set group title
-
- sel_mem =
- (struct search_item_sel *)calloc(1,
- sizeof(struct
- search_item_sel));
- sel_mem->type = type;
-
- ad->gl_result_group_item[type] =
- elm_genlist_item_append(ad->search_gl,
- (ad->itc_grouptitle), sel_mem,
- (Elm_Object_Item *) NULL,
- ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ if (obj->mr_info.next_point == 0) {
+ //### Set group title
+ result_info->group = search_add_genlist_item(SEARCH_GENLIST_GROUP,
+ obj,
+ ad->itc_grouptitle,
+ obj,
+ NULL);
}
- if (ad->cate_info[type].next_point <
- ad->cate_info[type].offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
+ if (obj->mr_info.next_point <
+ obj->mr_info.offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
sel_mem_info =
(struct search_item_sel *)calloc(1,
sizeof(struct
search_item_sel));
- sel_mem_info->type = type;
+ sel_mem_info->type = obj->contents_type;
+
+ contact_img_path = contacts_svc_value_get_str(value,
+ CTS_LIST_NUM_CONTACT_IMG_PATH_STR);
+
+ if (contact_img_path != NULL) {
+ strncpy(sel_mem_info->icon1_path, contact_img_path,
+ MAX_LENGTH_PER_PATH - 1);
+ }
+ else if (obj->obj_icon_path)
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
/************ START : set search result to sel_mem_info buf ************/
@@ -202,64 +269,58 @@ static int __search_sql_contact_search_result_cb(CTSvalue * value,
}
}
- if((display_name) && strlen(display_name) > 0) {
- char* markup_text_1line = elm_entry_utf8_to_markup(display_name);
-
+ SEARCH_DEBUG_LOG("display_name : %s", display_name);
+
+ if(strlen(display_name) > 0) {
strncpy(sel_mem_info->main_buf,
- search_markup_keyword(markup_text_1line, ad->not_markup_search_word, &is_word_in_str),
+ search_markup_keyword(display_name, keyword, &is_word_in_str),
MAX_LENGTH_PER_LINE - 1);
-
- SEARCH_FREE(markup_text_1line);
- }
+ }
/***********************************************************************/
number = contacts_svc_value_get_str(value, CTS_LIST_NUM_NUMBER_STR);
if((number) && strlen(number) > 0) {
- char* markup_text_2line = elm_entry_utf8_to_markup(number);
-
strncpy(sel_mem_info->sub_buf,
- search_markup_keyword(markup_text_2line, ad->not_markup_search_word, &is_word_in_str),
+ search_markup_keyword(number, keyword, &is_word_in_str),
MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_2line);
}
-
+
/***********************************************************************/
snprintf(sel_mem_info->main_id, MAX_LENGTH_PER_ID - 1, "%d",
contacts_svc_value_get_int(value,
CTS_LIST_NUM_CONTACT_ID_INT));
-
+ SEARCH_DEBUG_LOG("Search CT_ID: %d", sel_mem_info->main_id);
/***********************************************************************/
/************ END : set search result to sel_mem_info buf **************/
-
- elm_genlist_item_append(ad->search_gl, (ad->itc_pslist_2line),
+ gen_item = search_add_genlist_item(SEARCH_GENLIST_ITEM,
+ obj,
+ ad->itc_pslist_2line_1icon,
sel_mem_info,
- ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_phone_result_sel, ad);
-
- ad->cate_info[type].next_point++;
- } else if (ad->cate_info[type].next_point ==
- ad->cate_info[type].offset +
+ obj->gl_result_grp);
+ result_info->itemlist = g_list_append(result_info->itemlist, (void*)gen_item);
+ obj->mr_info.next_point++;
+ } else if (obj->mr_info.next_point ==
+ obj->mr_info.offset +
SEARCH_CATEGORY_LIST_MORE_CNT) {
/* Set more title to genlist (under 'search all') */
- sel_mem =
- (struct search_item_sel *)calloc(1,
+ sel_mem_more =
+ (struct search_item_more_sel *)calloc(1,
sizeof(struct
- search_item_sel));
- sel_mem->type = type;
-
- elm_genlist_item_append(ad->search_gl, (ad->itc_listmore),
- sel_mem, ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_result_more_item_append_cb,
- ad);
+ search_item_more_sel));
+ sel_mem_more->obj = obj;
+
+ result_info->more = search_add_genlist_item(SEARCH_GENLIST_MORE,
+ obj,
+ ad->itc_listmore,
+ sel_mem_more,
+ obj->gl_result_grp);
} else {
SEARCH_DEBUG_WARNING
("__search_sql_contact_search_result_cb wrong index : %d",
- ad->cate_info[type].next_point);
+ obj->mr_info.next_point);
}
SEARCH_FUNC_END;
@@ -267,26 +328,28 @@ static int __search_sql_contact_search_result_cb(CTSvalue * value,
return 0;
}
-int search_sql_contact_search_result_by_api(int type, int offset, int limit,
- void *data)
+int search_sql_contact_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit, char *keyword, void *data, struct search_genlist_info *result_info)
{
SEARCH_FUNC_START;
struct appdata *ad = (struct appdata *)data;
+ struct search_cb_data scd = {obj, ad, keyword, result_info};
+
int ret = 0;
/* Check whether search result is exist or not */
ret =
- contacts_svc_smartsearch_excl(ad->search_word, limit, offset,
+ contacts_svc_smartsearch_excl(keyword, limit, offset,
__search_sql_contact_search_result_cb,
- data);
+ &scd);
if (ret != CTS_SUCCESS) {
SEARCH_DEBUG_WARNING("contacts svc search return error : %d",
ret);
return SEARCH_RET_SEARCH_FAIL;
}
- if (ad->cate_info[type].next_point == 0) {
+ if (obj->mr_info.next_point == 0) {
SEARCH_DEBUG_WARNING("contacts svc search no result");
return SEARCH_RET_SEARCH_NONE;
}
@@ -296,8 +359,8 @@ int search_sql_contact_search_result_by_api(int type, int offset, int limit,
return SEARCH_RET_SEARCH_SUCCESS;
}
-int search_sql_calendar_search_result_by_api(int type, int offset, int limit,
- void *data)
+int search_sql_calendar_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit, char *keyword, void *data, struct search_genlist_info *result_info)
{
SEARCH_FUNC_START;
@@ -307,22 +370,23 @@ int search_sql_calendar_search_result_by_api(int type, int offset, int limit,
cal_struct *event = NULL;
cal_iter *iter = NULL;
- struct search_item_sel *sel_mem = NULL;
- Elm_Object_Item *git = NULL;
- Evas_Object *glist;
-
struct search_item_sel *sel_mem_info = NULL;
+ struct search_item_more_sel *sel_mem_more = NULL;
+ struct search_genlist_item_info *gen_item = NULL;
+
int loop_cnt = 0;
char *summary = NULL;
bool is_word_in_str;
- time_t start_time = 0;
+ int time_type = 0;
- ret =
- calendar_svc_search_list(0, 0, CAL_STRUCT_SCHEDULE,
- CAL_VALUE_TXT_SUMMARY, ad->search_word,
- offset, limit, &iter);
+ long long int start_time = 0;
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *cal;
+ int y = 0, m = 0, d = 0;
+
+ ret = calendar_svc_smartsearch_excl(keyword, offset, limit, &iter);
if (ret == CAL_SUCCESS) {
ret = calendar_svc_iter_next(iter);
@@ -332,24 +396,12 @@ int search_sql_calendar_search_result_by_api(int type, int offset, int limit,
return SEARCH_RET_SEARCH_NONE;
}
/* Set group title */
- glist = ad->search_gl;
-
if (offset == 0) {
- sel_mem =
- (struct search_item_sel *)calloc(1,
- sizeof(struct
- search_item_sel));
- sel_mem->type = type;
-
- git =
- elm_genlist_item_append(glist,
- (ad->itc_grouptitle),
- sel_mem,
- (Elm_Object_Item *) NULL,
- ELM_GENLIST_ITEM_GROUP,
- NULL, NULL);
-
- ad->gl_result_group_item[type] = git;
+ result_info->group = search_add_genlist_item(SEARCH_GENLIST_GROUP,
+ obj,
+ ad->itc_grouptitle,
+ obj,
+ NULL);
}
/* Set search result to genlist */
do {
@@ -368,48 +420,60 @@ int search_sql_calendar_search_result_by_api(int type, int offset, int limit,
sizeof
(struct
search_item_sel));
- sel_mem_info->type = type;
+ sel_mem_info->type = obj->contents_type;
+
+ if (obj->obj_icon_path)
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
summary =
calendar_svc_struct_get_str(event,
CAL_VALUE_TXT_SUMMARY);
- if ((summary) && (strlen(summary) > 0)) {
- char* markup_text_1line = elm_entry_utf8_to_markup(summary);
-
+ if ((summary) && (strlen(summary) > 0)) {
strncpy(sel_mem_info->main_buf,
- search_markup_keyword(markup_text_1line,
- ad->not_markup_search_word,
+ search_markup_keyword(summary,
+ keyword,
&is_word_in_str),
MAX_LENGTH_PER_LINE - 1);
-
- SEARCH_FREE(markup_text_1line);
- }
+ }
snprintf(sel_mem_info->main_id,
MAX_LENGTH_PER_ID - 1, "%d",
calendar_svc_struct_get_int(event,
CAL_VALUE_INT_INDEX));
- start_time =
- calendar_svc_struct_get_time(event,
- CAL_VALUE_GMT_START_DATE_TIME,
- CAL_TZ_FLAG_GMT);
- search_util_date_time_format_get_val(localtime
- (&start_time),
- sel_mem_info->sub_buf);
+ time_type = calendar_svc_struct_get_int(event, CALS_VALUE_INT_DTSTART_TYPE);
+
+ if (time_type == CALS_TIME_LOCALTIME) {
+ y = calendar_svc_struct_get_int(event, CALS_VALUE_INT_DTSTART_YEAR);
+ m = calendar_svc_struct_get_int(event, CALS_VALUE_INT_DTSTART_MONTH);
+ d = calendar_svc_struct_get_int(event, CALS_VALUE_INT_DTSTART_MDAY);
+ } else if (time_type == CALS_TIME_UTIME) {
+ start_time = calendar_svc_struct_get_lli(event,
+ CALS_VALUE_LLI_DTEND_UTIME);
+ UChar *_tzid;
+ _tzid = (UChar *)malloc(sizeof(UChar) * (strlen("Europe/Berlin") + 1));
+ if (_tzid) u_uastrcpy(_tzid, "Europe/Berlin");
+
+ cal = ucal_open(_tzid, u_strlen(_tzid), "en_US", UCAL_TRADITIONAL, &status);
+ ucal_setMillis(cal, (double)(start_time * 1000.0), &status);
+ y = ucal_get(cal, UCAL_YEAR, &status);
+ m = ucal_get(cal, UCAL_MONTH, &status);
+ d = ucal_get(cal, UCAL_DATE, &status);
+ ucal_close(cal);
+ }
+ snprintf(sel_mem_info->sub_buf, MAX_LENGTH_PER_LINE, "%d.%d.%d", y,m,d);
calendar_svc_struct_free(&event);
summary = NULL;
- elm_genlist_item_append(glist,
- (ad->itc_pslist_1line),
+ gen_item = search_add_genlist_item(SEARCH_GENLIST_ITEM,
+ obj,
+ ad->itc_pslist_2line_1icon,
sel_mem_info,
- ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_phone_result_sel,
- ad);
- sel_mem_info = NULL;
+ obj->gl_result_grp);
+ result_info->itemlist = g_list_append(result_info->itemlist, (void*)gen_item);
} else {
SEARCH_DEBUG_WARNING
("calendar_svc_iter_get_info fail : %d",
@@ -426,19 +490,19 @@ int search_sql_calendar_search_result_by_api(int type, int offset, int limit,
/* Set more title to genlist (under 'search all') */
if (loop_cnt == limit) {
- ad->cate_info[type].next_point = offset + limit - 1;
+ obj->mr_info.next_point = offset + limit - 1;
- sel_mem =
- (struct search_item_sel *)calloc(1,
+ sel_mem_more =
+ (struct search_item_more_sel *)calloc(1,
sizeof(struct
- search_item_sel));
- sel_mem->type = type;
-
- elm_genlist_item_append(ad->search_gl, (ad->itc_listmore),
- sel_mem, ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_result_more_item_append_cb,
- ad);
+ search_item_more_sel));
+ sel_mem_more->obj = obj;
+
+ result_info->more = search_add_genlist_item(SEARCH_GENLIST_MORE,
+ obj,
+ ad->itc_listmore,
+ sel_mem_more,
+ obj->gl_result_grp);
}
SEARCH_FUNC_END;
@@ -450,12 +514,16 @@ static void __search_sql_memo_search_result_cb(memo_data_t * value,
{
SEARCH_FUNC_START;
- struct appdata *ad = (struct appdata *)user_data;
-
- struct search_item_sel *sel_mem = NULL;
- int type = SEARCH_TYPE_PHONE_MEMO;
+ struct search_cb_data *scd = (struct search_cb_data *)user_data;
+ struct appdata *ad = scd->ad;
+ struct search_content_object *obj = scd->obj;
+ struct search_genlist_info *result_info = scd->result_info;
+ struct search_genlist_item_info *gen_item = NULL;
struct search_item_sel *sel_mem_info = NULL;
+ struct search_item_more_sel *sel_mem_more = NULL;
+
+ char *keyword = scd->keyword;
bool is_word_in_str;
@@ -464,51 +532,41 @@ static void __search_sql_memo_search_result_cb(memo_data_t * value,
return;
}
- if (ad->cate_info[type].next_point == 0) {
+ if (obj->mr_info.next_point == 0) {
/* Set group title */
-
- sel_mem =
- (struct search_item_sel *)calloc(1,
- sizeof(struct
- search_item_sel));
- sel_mem->type = type;
-
- ad->gl_result_group_item[type] =
- elm_genlist_item_append(ad->search_gl,
- (ad->itc_grouptitle), sel_mem,
- (Elm_Object_Item *) NULL,
- ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ result_info->group = search_add_genlist_item(SEARCH_GENLIST_GROUP,
+ obj,
+ ad->itc_grouptitle,
+ obj,
+ NULL);
}
- if (ad->cate_info[type].next_point <
- ad->cate_info[type].offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
+ if (obj->mr_info.next_point <
+ obj->mr_info.offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
sel_mem_info =
(struct search_item_sel *)calloc(1,
sizeof(struct
search_item_sel));
- sel_mem_info->type = type;
+ sel_mem_info->type = obj->contents_type;
/********** START : set search result to sel_mem_info buf ************/
+
+ if (obj->obj_icon_path)
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
+
/* First, We should check comment field. It means drawing memo
* If comment field is NULL, then we check content field */
if ((value->comment) && (strlen(value->comment) > 0)) {
- char* markup_text_1line = elm_entry_utf8_to_markup(value->comment);
-
strncpy(sel_mem_info->main_buf,
- search_markup_keyword(markup_text_1line, ad->not_markup_search_word,
+ search_markup_keyword(value->comment, keyword,
&is_word_in_str),
MAX_LENGTH_PER_LINE - 1);
-
- SEARCH_FREE(markup_text_1line);
} else if ((value->content) && (strlen(value->content) > 0)) {
- char* markup_text_1line = elm_entry_utf8_to_markup(value->content);
-
strncpy(sel_mem_info->main_buf,
- search_markup_keyword(markup_text_1line, ad->not_markup_search_word,
+ search_markup_keyword(value->content, keyword,
&is_word_in_str),
MAX_LENGTH_PER_LINE - 1);
-
- SEARCH_FREE(markup_text_1line);
}
snprintf(sel_mem_info->main_id, MAX_LENGTH_PER_ID - 1, "%d", value->id);
@@ -518,32 +576,32 @@ static void __search_sql_memo_search_result_cb(memo_data_t * value,
/********** END : set search result to sel_mem_info buf *************/
- elm_genlist_item_append(ad->search_gl, (ad->itc_pslist_1line),
+ gen_item = search_add_genlist_item(SEARCH_GENLIST_ITEM,
+ obj,
+ ad->itc_pslist_2line_1icon,
sel_mem_info,
- ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_phone_result_sel, ad);
+ obj->gl_result_grp);
+ result_info->itemlist = g_list_append(result_info->itemlist, (void*)gen_item);
- ad->cate_info[type].next_point++;
- } else if (ad->cate_info[type].next_point ==
- ad->cate_info[type].offset +
- SEARCH_CATEGORY_LIST_MORE_CNT) {
+ obj->mr_info.next_point++;
+ } else if (obj->mr_info.next_point ==
+ obj->mr_info.offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
/* Set more title to genlist (under 'search all') */
- sel_mem =
- (struct search_item_sel *)calloc(1,
+ sel_mem_more =
+ (struct search_item_more_sel *)calloc(1,
sizeof(struct
- search_item_sel));
- sel_mem->type = type;
-
- elm_genlist_item_append(ad->search_gl, (ad->itc_listmore),
- sel_mem, ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_result_more_item_append_cb,
- ad);
+ search_item_more_sel));
+ sel_mem_more->obj = obj;
+
+ result_info->more = search_add_genlist_item(SEARCH_GENLIST_MORE,
+ obj,
+ ad->itc_listmore,
+ sel_mem_more,
+ obj->gl_result_grp);
} else {
SEARCH_DEBUG_WARNING
("__search_sql_memo_search_result_cb wrong index : %d",
- ad->cate_info[type].next_point);
+ obj->mr_info.next_point);
}
SEARCH_FUNC_END;
@@ -551,20 +609,21 @@ static void __search_sql_memo_search_result_cb(memo_data_t * value,
return;
}
-int search_sql_memo_search_result_by_api(int type, int offset, int limit,
- void *data)
+int search_sql_memo_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit, char *keyword, void *data, struct search_genlist_info *result_info)
{
SEARCH_FUNC_START;
struct appdata *ad = (struct appdata *)data;
+ struct search_cb_data scd = {obj, ad, keyword, result_info};
- memo_search_data(ad->search_word,
- limit, offset,
+ memo_search_data(keyword,
+ limit, offset,
MEMO_SORT_TITLE_ASC,
- __search_sql_memo_search_result_cb,
- data);
+ __search_sql_memo_search_result_cb,
+ &scd);
- if (ad->cate_info[type].next_point == 0) {
+ if (obj->mr_info.next_point == 0) {
SEARCH_DEBUG_WARNING("no memo search result");
return SEARCH_RET_SEARCH_NONE;
}
@@ -573,35 +632,71 @@ int search_sql_memo_search_result_by_api(int type, int offset, int limit,
return SEARCH_RET_SEARCH_SUCCESS;
}
-int search_sql_email_search_result_by_api(int type, int offset, int limit,
- void *data)
+int search_sql_email_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit, char *keyword, void *data, struct search_genlist_info *result_info)
{
SEARCH_FUNC_START;
struct appdata *ad = (struct appdata *)data;
- int result_cnt = 0;
- int ret = 0;
+ int ret = EMAIL_ERROR_NONE;
int i = 0;
- emf_mail_list_item_t *mail_list = NULL;
+ email_mail_list_item_t *mail_list = NULL;
+ email_list_filter_t *filter_list = NULL;
+ email_list_sorting_rule_t *sorting_rule_list = NULL;
- struct search_item_sel *sel_mem = NULL;
- Elm_Object_Item *git = NULL;
- Evas_Object *glist;
+ int filter_list_count = 5;
+ int sorting_rule_list_count = 1;
+ int mail_count = 0;
+ struct search_genlist_item_info *gen_item = NULL;
struct search_item_sel *sel_mem_info = NULL;
+ struct search_item_more_sel *sel_mem_more = NULL;
bool is_word_in_str;
- ret = email_find_mail(0, NULL, 0, EMF_SEARCH_FILTER_ALL ,
- ad->search_word, offset, limit, EMF_SORT_DATETIME_HIGH,
- &mail_list, &result_cnt);
+ filter_list = (email_list_filter_t *)malloc(sizeof(email_list_filter_t) * filter_list_count);
+ memset(filter_list, 0 , sizeof(email_list_filter_t) * filter_list_count);
+
+ filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
+ filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT;
+ filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
+ filter_list[0].list_filter_item.rule.key_value.string_type_value = keyword;
+ filter_list[0].list_filter_item.rule.case_sensitivity = EMAIL_CASE_INSENSITIVE;
+
+ filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
+ filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR;
+
+ filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
+ filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO;
+ filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
+ filter_list[2].list_filter_item.rule.key_value.string_type_value = keyword;
+ filter_list[2].list_filter_item.rule.case_sensitivity = EMAIL_CASE_INSENSITIVE;
- if(ret < 1) {
- SEARCH_DEBUG_WARNING("no email search result");
+ filter_list[3].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
+ filter_list[3].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR;
+
+ filter_list[4].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
+ filter_list[4].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_FROM;
+ filter_list[4].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
+ filter_list[4].list_filter_item.rule.key_value.string_type_value = keyword;
+ filter_list[4].list_filter_item.rule.case_sensitivity = EMAIL_CASE_INSENSITIVE;
+
+ sorting_rule_list = (email_list_sorting_rule_t *)malloc(sizeof(email_list_sorting_rule_t) * sorting_rule_list_count);
+ memset(sorting_rule_list, 0, sizeof(email_list_sorting_rule_t) * sorting_rule_list_count);
+
+ sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT;
+ sorting_rule_list[0].sort_order = EMAIL_SORT_ORDER_ASCEND;
+
+ ret = email_get_mail_list_ex(filter_list, filter_list_count, sorting_rule_list, sorting_rule_list_count,
+ offset, limit, &mail_list, &mail_count);
+
+
+ if (ret != EMAIL_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("no email search result");
return SEARCH_RET_SEARCH_FAIL;
}
- if(result_cnt == 0) {
+ if (mail_count == 0) {
SEARCH_DEBUG_WARNING("no email search result");
return SEARCH_RET_SEARCH_NONE;
}
@@ -612,497 +707,561 @@ int search_sql_email_search_result_by_api(int type, int offset, int limit,
}
/* Set group title */
- glist = ad->search_gl;
-
if (offset == 0) {
- sel_mem = (struct search_item_sel *)calloc(1,
- sizeof(struct search_item_sel));
-
- sel_mem->type = type;
-
- git = elm_genlist_item_append(glist,
- (ad->itc_grouptitle),
- sel_mem,
- (Elm_Object_Item *) NULL,
- ELM_GENLIST_ITEM_GROUP,
- NULL, NULL);
-
- ad->gl_result_group_item[type] = git;
+ result_info->group = search_add_genlist_item(SEARCH_GENLIST_GROUP,
+ obj,
+ ad->itc_grouptitle,
+ obj,
+ NULL);
}
/* Set search result to genlist */
- for(i=0;i<result_cnt;i++) {
+ for(i = 0 ; i < mail_count ; i++) {
if(i == limit -1)
break;
-
+
sel_mem_info = (struct search_item_sel *)calloc(1,
sizeof(struct search_item_sel));
- sel_mem_info->type = type;
+ sel_mem_info->type = obj->contents_type;
+
+ if (obj->obj_icon_path)
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
snprintf(sel_mem_info->main_id, MAX_LENGTH_PER_ID - 1, "%d", mail_list[i].mail_id);
- snprintf(sel_mem_info->path, MAX_LENGTH_PER_PATH - 1, "%d %d %s",
- mail_list[i].account_id, mail_list[i].mail_id, mail_list[i].mailbox_name);
+ snprintf(sel_mem_info->path, MAX_LENGTH_PER_PATH - 1, "%d %d %d",
+ mail_list[i].account_id, mail_list[i].mail_id, mail_list[i].mailbox_id);
SEARCH_DEBUG_LOG("subject : %s", mail_list[i].subject);
if((mail_list[i].subject) && (strlen(mail_list[i].subject) > 0)) {
- char* markup_text_1line = elm_entry_utf8_to_markup(mail_list[i].subject);
-
strncpy(sel_mem_info->main_buf,
- search_markup_keyword(markup_text_1line, ad->not_markup_search_word, &is_word_in_str),
+ search_markup_keyword(mail_list[i].subject, ad->search_word, &is_word_in_str),
MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_1line);
- }
+ }
if((mail_list[i].from) && (strlen(mail_list[i].from) > 0)) {
- char* markup_text_2line = elm_entry_utf8_to_markup(mail_list[i].from);
-
strncpy(sel_mem_info->sub_buf,
- search_markup_keyword(markup_text_2line, ad->not_markup_search_word, &is_word_in_str),
+ search_markup_keyword(mail_list[i].from, ad->search_word, &is_word_in_str),
MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_2line);
- }
+ }
if(is_word_in_str == false && (mail_list[i].recipients) && (strlen(mail_list[i].recipients) > 0)) {
- char* markup_text_2line = elm_entry_utf8_to_markup(mail_list[i].recipients);
-
strncpy(sel_mem_info->sub_buf,
- search_markup_keyword(markup_text_2line, ad->not_markup_search_word, &is_word_in_str),
+ search_markup_keyword(mail_list[i].recipients, ad->search_word, &is_word_in_str),
MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_2line);
}
- elm_genlist_item_append(glist,
- (ad->itc_pslist_2line),
+ gen_item = search_add_genlist_item(SEARCH_GENLIST_ITEM,
+ obj,
+ ad->itc_pslist_2line_1icon,
sel_mem_info,
- ad->gl_result_group_item
- [type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_phone_result_sel,
- ad);
- sel_mem_info = NULL;
+ obj->gl_result_grp);
+ result_info->itemlist = g_list_append(result_info->itemlist, (void*)gen_item);
}
SEARCH_FREE(mail_list);
-
- /* Set more title to genlist (under 'search all') */
- if (result_cnt == limit) {
- ad->cate_info[type].next_point = offset + result_cnt - 1;
-
- sel_mem =
- (struct search_item_sel *)calloc(1,
- sizeof(struct search_item_sel));
- sel_mem->type = type;
- elm_genlist_item_append(ad->search_gl, (ad->itc_listmore),
- sel_mem, ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_result_more_item_append_cb,
- ad);
+ /* Set more title to genlist (under 'search all') */
+ if (mail_count == limit) {
+ obj->mr_info.next_point = offset + mail_count - 1;
+
+ sel_mem_more =
+ (struct search_item_more_sel *)calloc(1,
+ sizeof(struct search_item_more_sel));
+ sel_mem_more->obj = obj;
+
+ result_info->more = search_add_genlist_item(SEARCH_GENLIST_MORE,
+ obj,
+ ad->itc_listmore,
+ sel_mem_more,
+ obj->gl_result_grp);
}
+ SEARCH_FREE(filter_list);
+ SEARCH_FREE(sorting_rule_list);
+
SEARCH_FUNC_END;
return SEARCH_RET_SEARCH_SUCCESS;
}
-static int __search_sql_media_search_item_list_search_cb( Mitem* item, void* user_data)
+static bool __search_media_info_cb(media_info_h media, void *user_data)
{
- GList** list = (GList**) user_data;
- *list = g_list_append( *list, item );
+ char *media_id = NULL;
+ char *media_name = NULL;
+ char *media_path = NULL;
+ char *media_thumbnail = NULL;
- return 0;
-}
-
-static int __search_sql_media_search_result_by_api(int type, int offset, int limit,
- minfo_file_type media_type, void *data)
-{
- SEARCH_FUNC_START;
+ struct search_item_sel *sel_mem_info = NULL;
+ Elm_Genlist_Item_Class *itc_style = NULL;
+ bool is_word_in_str = false;
- struct appdata *ad = (struct appdata *)data;
+ struct search_cb_data *scd = (struct search_cb_data*)user_data;
+ struct appdata *ad = scd->ad;
+ struct search_content_object *obj = scd->obj;
+ struct search_genlist_info *result_info = scd->result_info;
+ char *keyword = scd->keyword;
- int result_cnt = 0;
- int ret = 0;
- int i = 0;
- int func_ret = SEARCH_RET_SEARCH_SUCCESS;
+ struct search_genlist_item_info *gen_item = NULL;
- struct search_item_sel *sel_mem = NULL;
- Elm_Object_Item *git = NULL;
- Evas_Object *glist;
+ media_info_get_media_id(media, &media_id);
+ media_info_get_display_name(media, &media_name);
+ media_info_get_file_path(media, &media_path);
+ media_info_get_thumbnail_path(media, &media_thumbnail);
- struct search_item_sel *sel_mem_info = NULL;
- bool is_word_in_str;
-
- GList *p_media_list = NULL;
- Mitem* item = NULL;
- minfo_item_filter item_filter;
-
- memset(&item_filter, 0x00, sizeof(minfo_item_filter));
-
- minfo_search_field_t search_field = MINFO_SEARCH_BY_NAME;
- minfo_folder_type folder_type = MINFO_CLUSTER_TYPE_ALL;
-
- item_filter.file_type = media_type;
-
- /* MINFO_MEDIA_SORT_BY_NAME_DESC, MINFO_MEDIA_SORT_BY_DATE_DESC, MINFO_MEDIA_SORT_BY_DATE_ASC ... */
- item_filter.sort_type = MINFO_MEDIA_SORT_BY_NAME_ASC;
-
- item_filter.start_pos = offset;
- item_filter.end_pos = offset+limit-1;
-
- item_filter.with_meta = 0;
- item_filter.favorite = MINFO_MEDIA_FAV_ALL;
-
- /* get a set of items */
- ret = minfo_get_item_list_search(ad->media_handle,
- search_field,
- ad->search_word,
- folder_type,
- item_filter,
- __search_sql_media_search_item_list_search_cb,
- &p_media_list);
- if (ret < 0) {
- SEARCH_DEBUG_WARNING("minfo_get_item_list_search failed : %d\n", ret);
- func_ret = SEARCH_RET_SEARCH_FAIL;
- goto out_func;
- }
+ sel_mem_info = (struct search_item_sel *)calloc(1,
+ sizeof(struct search_item_sel));
- if (p_media_list == NULL) {
- SEARCH_DEBUG_WARNING("minfo_get_item_list_search media list null\n");
- func_ret = SEARCH_RET_SEARCH_FAIL;
- goto out_func;
+ sel_mem_info->type = obj->contents_type;
+
+ if ((media_thumbnail) && (strlen(media_thumbnail) > 0)
+ && ecore_file_exists(media_thumbnail) == EINA_TRUE) {
+ strncpy(sel_mem_info->icon1_path, media_thumbnail,
+ MAX_LENGTH_PER_PATH - 1);
+ } else if (obj->obj_icon_path)
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
+
+ if (media_name && strlen(media_name)) {
+ strncpy(sel_mem_info->main_buf,
+ search_markup_keyword(media_name,
+ keyword,
+ &is_word_in_str),
+ MAX_LENGTH_PER_LINE - 1);
}
- result_cnt = g_list_length(p_media_list);
- if (result_cnt == 0) {
- SEARCH_DEBUG_WARNING("minfo_item_list length 0\n");
- func_ret = SEARCH_RET_SEARCH_FAIL;
- goto out_func;
- }
+ if (media_id)
+ snprintf(sel_mem_info->main_id, MAX_LENGTH_PER_ID, "%s",
+ media_id);
- /* Set group title */
- glist = ad->search_gl;
+ if (media_path)
+ snprintf(sel_mem_info->path, MAX_LENGTH_PER_PATH - 1, "%s",
+ media_path);
- if (offset == 0) {
- sel_mem = (struct search_item_sel *)calloc(1,
- sizeof(struct search_item_sel));
+ itc_style = ad->itc_pslist_1line_1icon;
- sel_mem->type = type;
+ /* Add Info to genlist */
+ gen_item = search_add_genlist_item(SEARCH_GENLIST_ITEM,
+ obj,
+ itc_style,
+ sel_mem_info,
+ obj->gl_result_grp);
+ result_info->itemlist = g_list_append(result_info->itemlist, (void*)gen_item);
- git = elm_genlist_item_append(glist,
- (ad->itc_grouptitle),
- sel_mem,
- (Elm_Object_Item *) NULL,
- ELM_GENLIST_ITEM_GROUP,
- NULL, NULL);
+ SEARCH_FREE(media_id);
+ SEARCH_FREE(media_name);
+ SEARCH_FREE(media_thumbnail);
+ SEARCH_FREE(media_path);
- ad->gl_result_group_item[type] = git;
+ return true;
}
- /* Set search result to genlist */
- for (i = 0; i < result_cnt; i++) {
+static bool __search_sql_music_info_cb(media_info_h media, void *user_data)
+{
+ char *media_id = NULL;
+ char *media_path = NULL;
+ char *media_thumbnail = NULL;
+ char *title = NULL;
+ char *artist = NULL;
+ char *album = NULL;
- if(i == limit -1)
- break;
+ audio_meta_h a_handle;
- item = NULL;
- item = (Mitem*)g_list_nth_data(p_media_list, i);
+ media_content_storage_e storage_type = MEDIA_CONTENT_STORAGE_INTERNAL;
- if(item == NULL) {
- break;
+ struct search_item_sel *sel_mem_info = NULL;
+ Elm_Genlist_Item_Class *itc_style = NULL;
+ bool is_word_in_str = false;
+
+ struct search_cb_data *scd = (struct search_cb_data*)user_data;
+ struct appdata *ad = scd->ad;
+ struct search_content_object* obj = scd->obj;
+ struct search_genlist_info *result_info = scd->result_info;
+ char *keyword = scd->keyword;
+
+ struct search_genlist_item_info *gen_item = NULL;
+
+ media_info_get_media_id(media, &media_id);
+ media_info_get_file_path(media, &media_path);
+ media_info_get_storage_type(media, &storage_type);
+ media_info_get_thumbnail_path(media, &media_thumbnail);
+
+ media_info_get_audio(media, &a_handle);
+ audio_meta_get_title(a_handle, &title);
+ audio_meta_get_album(a_handle, &album);
+ audio_meta_get_artist(a_handle, &artist);
+
+ sel_mem_info = (struct search_item_sel *)calloc(1,
+ sizeof(struct search_item_sel));
+
+ sel_mem_info->type = obj->contents_type;;
+
+ if ((media_thumbnail) && (strlen(media_thumbnail) > 0)
+ && ecore_file_exists(media_thumbnail) == EINA_TRUE) {
+ strncpy(sel_mem_info->icon1_path , media_thumbnail,
+ MAX_LENGTH_PER_PATH -1 );
+ } else if(obj->obj_icon_path) {
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
}
-
- sel_mem_info = (struct search_item_sel *)calloc(1,
- sizeof(struct search_item_sel));
- sel_mem_info->type = type;
+ if ((title) && (strlen(title) > 0)) {
+ strncpy(sel_mem_info->main_buf,
+ search_markup_keyword(title, keyword, &is_word_in_str),
+ MAX_LENGTH_PER_LINE - 1);
+ }
+
+ if (is_word_in_str) {
+ if ((artist) && (strlen(artist) > 0)) {
+ strncpy(sel_mem_info->sub_buf,
+ search_markup_keyword(artist,
+ keyword,
+ &is_word_in_str),
+ MAX_LENGTH_PER_LINE - 1);
+ }
+ } else {
+ memset(sel_mem_info->sub_buf, '\0', MAX_LENGTH_PER_LINE);
- if ((item->display_name) && (strlen(item->display_name) > 0)) {
- char* markup_text_1line = elm_entry_utf8_to_markup(item->display_name);
-
- strncpy(sel_mem_info->main_buf,
- search_markup_keyword(markup_text_1line,
- ad->not_markup_search_word,
+ if ((artist) && (strlen(artist) > 0)) {
+ strncpy(sel_mem_info->sub_buf,
+ search_markup_keyword(artist,
+ keyword,
+ &is_word_in_str),
+ MAX_LENGTH_PER_LINE - 1);
+ }
+
+ if (is_word_in_str == false && (album) && (strlen(album) > 0)) {
+ strncpy(sel_mem_info->sub_buf,
+ search_markup_keyword(album,
+ keyword,
&is_word_in_str),
MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_1line);
- }
+ }
+
+ if (is_word_in_str == false) {
+ SEARCH_DEBUG_LOG("search_result is 0. No match keyword in title,album,artist string");
+ }
+ }
- snprintf(sel_mem_info->main_id, MAX_LENGTH_PER_ID, "%d",
- item->type);
+ if (storage_type == MEDIA_CONTENT_STORAGE_EXTERNAL) {
+ itc_style = ad->itc_pslist_2line_2icon;
+ strncpy(sel_mem_info->icon2_path, SEARCH_SDCARD_ICON,
+ MAX_LENGTH_PER_PATH - 1);
+ }
+ else {
+ itc_style = ad->itc_pslist_2line_1icon;
+ }
- snprintf(sel_mem_info->path, MAX_LENGTH_PER_PATH - 1, "%s",
- item->file_url);
+ if (media_id)
+ snprintf(sel_mem_info->main_id,
+ MAX_LENGTH_PER_ID - 1, "%s", media_id);
- elm_genlist_item_append(glist,
- (ad->itc_pslist_1line),
+ if (media_path)
+ strncpy(sel_mem_info->path, media_path, MAX_LENGTH_PER_PATH);
+
+ /* Add Information to genlist */
+ gen_item = search_add_genlist_item(SEARCH_GENLIST_ITEM,
+ obj,
+ itc_style,
sel_mem_info,
- ad->gl_result_group_item
- [type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_phone_result_sel,
- ad);
- sel_mem_info = NULL;
+ obj->gl_result_grp);
+ result_info->itemlist = g_list_append(result_info->itemlist, (void*)gen_item);
+
+ SEARCH_FREE(media_id);
+ SEARCH_FREE(media_path);
+ SEARCH_FREE(media_thumbnail);
+ SEARCH_FREE(title);
+ SEARCH_FREE(artist);
+ SEARCH_FREE(album);
+
+ return true;
}
- /* delete list to avoid memory leak */
- for (i = 0; i < result_cnt; i++) {
- item = (Mitem*)g_list_nth_data(p_media_list, i);
- minfo_destroy_mtype_item(item);
+static int __search_sql_media_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit,
+ char *keyword,
+ filter_h filter,
+ media_info_cb func_cb,
+ void *data,
+ struct search_genlist_info *result_info)
+{
+ SEARCH_FUNC_START;
+
+ struct appdata *ad = (struct appdata *)data;
+ struct search_cb_data scd = {obj, ad, keyword, result_info};
+
+ int result_cnt = 0;
+ int ret = 0;
+ int func_ret = SEARCH_RET_SEARCH_SUCCESS;
+
+ struct search_item_more_sel *sel_mem_more = NULL;
+
+ media_info_get_media_count_from_db(filter, &result_cnt);
+
+ if (result_cnt != 0) {
+ /* Set group title */
+ if (obj->mr_info.offset== 0) {
+ result_info->group = search_add_genlist_item(SEARCH_GENLIST_GROUP,
+ obj,
+ ad->itc_grouptitle,
+ obj,
+ NULL);
}
- g_list_free(p_media_list);
- p_media_list = NULL;
+ ret = media_info_foreach_media_from_db(filter, func_cb, &scd);
+
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_info_foreach_media_from_db failed : %d\n", ret);
+ func_ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
/* Set more title to genlist (under 'search all') */
if (result_cnt == limit) {
- ad->cate_info[type].next_point = offset + result_cnt - 1;
-
- sel_mem =
- (struct search_item_sel *)calloc(1,
- sizeof(struct search_item_sel));
- sel_mem->type = type;
-
- elm_genlist_item_append(ad->search_gl, (ad->itc_listmore),
- sel_mem, ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_result_more_item_append_cb,
- ad);
+ obj->mr_info.next_point = offset + result_cnt - 1;
+
+ sel_mem_more =
+ (struct search_item_more_sel *)calloc(1,
+ sizeof(struct search_item_more_sel));
+ sel_mem_more->obj = obj;
+
+ result_info->more = search_add_genlist_item(SEARCH_GENLIST_MORE,
+ obj,
+ ad->itc_listmore,
+ sel_mem_more,
+ obj->gl_result_grp);
+ }
+ } else {
+ func_ret = SEARCH_RET_SEARCH_NONE;
}
out_func:
SEARCH_FUNC_END;
- return SEARCH_RET_SEARCH_SUCCESS;
+
+ return func_ret;
}
-int search_sql_image_search_result_by_api(int type, int offset, int limit,
- void *data)
+int search_sql_image_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit,
+ char *keyword,
+ void *data,
+ struct search_genlist_info *result_info)
{
SEARCH_FUNC_START;
- int ret;
+ int ret = SEARCH_RET_SEARCH_SUCCESS;
+ int len = 0;
+ char *search_query = NULL;
+ char *escape_added_keyword = NULL;
- ret = __search_sql_media_search_result_by_api(type,
- offset,
- limit,
- MINFO_ITEM_IMAGE,
- data);
+ const char *image_query = "(MEDIA_TYPE=0 and MEDIA_DISPLAY_NAME like \"%%%s%%\" ESCAPE (\"%s\"))";
- SEARCH_FUNC_END;
+ SEARCH_MALLOC(escape_added_keyword, strlen(keyword)*2+5, char);
+ memset(escape_added_keyword, 0x0, strlen(keyword)*2+5);
+ search_sql_make_keyword_bind_value(keyword, escape_added_keyword, SEARCH_SQL_BIND_TYPE_DUPLEX);
- return ret;
+ len = strlen(escape_added_keyword) + strlen(DB_ESCAPE_CHAR) + strlen(image_query) + 1;
+ search_query = (char*)calloc(1, len);
+
+ snprintf(search_query, len, image_query, escape_added_keyword, "%");
+
+ SEARCH_DEBUG_WARNING("keyword :%s", keyword);
+ SEARCH_DEBUG_WARNING("search_query :%s", escape_added_keyword);
+
+ filter_h filter;
+
+ ret = media_filter_create(&filter);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_create failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
+
+ ret = media_filter_set_offset(filter, offset, limit);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_set_offset failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
+
+ ret = media_filter_set_condition(filter, search_query, MEDIA_CONTENT_COLLATE_DEFAULT);
+ if(ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_set_condition failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
}
-int search_sql_video_search_result_by_api(int type, int offset, int limit,
- void *data)
-{
- SEARCH_FUNC_START;
+ ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_DISPLAY_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_set_order failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
- int ret;
- ret = __search_sql_media_search_result_by_api(type,
- offset,
- limit,
- MINFO_ITEM_VIDEO,
- data);
+ ret = __search_sql_media_search_result_by_api(obj,
+ offset,
+ limit,
+ keyword,
+ filter,
+ __search_media_info_cb,
+ data,
+ result_info);
+
+out_func:
+ SEARCH_FREE(search_query);
+ SEARCH_FREE(escape_added_keyword);
+ media_filter_destroy(filter);
SEARCH_FUNC_END;
return ret;
}
-int search_sql_music_search_result_by_api(int type, int offset, int limit,
- void *data)
+int search_sql_video_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit, char *keyword, void *data, struct search_genlist_info *result_info)
{
SEARCH_FUNC_START;
- struct appdata *ad = (struct appdata *)data;
+ int ret = SEARCH_RET_SEARCH_SUCCESS;
+ int len = 0;
+ char *search_query = NULL;
+ char *escape_added_keyword = NULL;
- int loop_cnt = 0;
- int ret = SEARCH_RET_SEARCH_NONE;
- int i = 0;
- int rc = 0;
+ const char *video_query = "(MEDIA_TYPE=1 and MEDIA_DISPLAY_NAME LIKE \"%%%s%%\" ESCAPE (\"%s\"))";
- struct search_item_sel *sel_mem = NULL;
- Elm_Object_Item *git = NULL;
+ SEARCH_MALLOC(escape_added_keyword, strlen(keyword)*2+5, char);
+ memset(escape_added_keyword, 0x0, strlen(keyword)*2+5);
+ search_sql_make_keyword_bind_value(keyword, escape_added_keyword, SEARCH_SQL_BIND_TYPE_DUPLEX);
- struct search_item_sel *sel_mem_info = NULL;
- bool is_word_in_str;
-
- AudioHandleType *handle = NULL;
+ len = strlen(escape_added_keyword) + strlen(DB_ESCAPE_CHAR) + strlen(video_query) + 1;
+ search_query = (char*)calloc(1, len);
- rc = audio_svc_search_item_new(&handle, limit);
- if (rc < 0) {
- SEARCH_DEBUG_WARNING("audio_svc_search_item_new failed:%d\n",
- rc);
- return -1;
- }
+ snprintf(search_query, len, video_query, escape_added_keyword, DB_ESCAPE_CHAR);
- rc = audio_svc_list_by_search(ad->media_handle,
- handle,
- AUDIO_SVC_ORDER_BY_TITLE_ASC,
- offset,
- limit,
- AUDIO_SVC_SEARCH_TITLE,
- ad->search_word,
- strlen(ad->search_word),
- AUDIO_SVC_SEARCH_ALBUM,
- ad->search_word,
- strlen(ad->search_word),
- AUDIO_SVC_SEARCH_ARTIST,
- ad->search_word,
- strlen(ad->search_word),
- -1);
-
- if (rc != AUDIO_SVC_ERROR_NONE) {
- SEARCH_DEBUG_WARNING("audio_svc_list_by_search error : %d",
- rc);
+ filter_h filter;
+ ret = media_filter_create(&filter);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_create failed : %d\n", ret);
ret = SEARCH_RET_SEARCH_FAIL;
goto out_func;
}
- for (loop_cnt = 0; loop_cnt < limit; loop_cnt++) {
- AudioHandleType *item = NULL;
- char *title = NULL;
- char *artist = NULL;
- char *pathname = NULL;
- char *album = NULL;
- int size = 0;
- char* audio_id = NULL;
-
- rc = audio_svc_search_item_get(handle, loop_cnt, &item);
- if (rc < 0) {
- break;
- } else {
- if (loop_cnt == limit -1)
- break;
+ ret = media_filter_set_offset(filter, offset, limit);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_set_offset failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
- audio_svc_item_get_val(item,
- AUDIO_SVC_TRACK_DATA_AUDIO_ID, &audio_id, &size,
- AUDIO_SVC_TRACK_DATA_PATHNAME, &pathname, &size,
- AUDIO_SVC_TRACK_DATA_TITLE, &title, &size,
- AUDIO_SVC_TRACK_DATA_ARTIST, &artist, &size,
- AUDIO_SVC_TRACK_DATA_ALBUM, &album, &size,
- -1);
+ ret = media_filter_set_condition(filter, search_query, MEDIA_CONTENT_COLLATE_DEFAULT);
+ if(ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_set_condition failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
- if( audio_id == NULL) {
- SEARCH_DEBUG_WARNING("audio_id value error. loop break");
- break;
- }
+ ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_DISPLAY_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_set_order failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
- ret = SEARCH_RET_SEARCH_SUCCESS;
+ ret = __search_sql_media_search_result_by_api(obj,
+ offset,
+ limit,
+ keyword,
+ filter,
+ __search_media_info_cb,
+ data,
+ result_info);
- if ((loop_cnt == 0) && (offset == 0)) {
- /* Set group title */
- sel_mem = (struct search_item_sel *)calloc(1,
- sizeof(struct search_item_sel));
+out_func:
- sel_mem->type = type;
+ SEARCH_FREE(search_query);
+ SEARCH_FREE(escape_added_keyword);
+ media_filter_destroy(filter);
- git = elm_genlist_item_append(ad->search_gl,
- (ad->itc_grouptitle),
- sel_mem,
- (Elm_Object_Item *) NULL,
- ELM_GENLIST_ITEM_GROUP,
- NULL, NULL);
+ SEARCH_FUNC_END;
- ad->gl_result_group_item[type] = git;
+ return ret;
}
- sel_mem_info = (struct search_item_sel *)calloc(1,
- sizeof(struct search_item_sel));
+int search_sql_music_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit,
+ char *keyword,
+ void *data,
+ struct search_genlist_info *result_info)
+{
+ SEARCH_FUNC_START;
- sel_mem_info->type = type;
+ int ret = SEARCH_RET_SEARCH_SUCCESS;
+ int len = 0;
+ char *search_query = NULL;
+ char *escape_added_keyword = NULL;
- if ((title) && (strlen(title) > 0)) {
- char* markup_text_1line = elm_entry_utf8_to_markup(title);
+ const char *music_query = "(MEDIA_TYPE=3 and MEDIA_TITLE LIKE \"%%%s%%\" or MEDIA_ALBUM LIKE \"%%%s%%\" or MEDIA_ARTIST LIKE \"%%%s%%\" ESCAPE (\"%s\"))";
- strncpy(sel_mem_info->main_buf,
- search_markup_keyword(markup_text_1line, ad->not_markup_search_word, &is_word_in_str),
- MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_1line);
- }
+ SEARCH_MALLOC(escape_added_keyword, strlen(keyword)*2+5, char);
+ memset(escape_added_keyword, 0x0, strlen(keyword)*2+5);
+ search_sql_make_keyword_bind_value(keyword, escape_added_keyword, SEARCH_SQL_BIND_TYPE_DUPLEX);
- if (is_word_in_str) {
- if ((artist) && (strlen(artist) > 0)) {
- char* markup_text_2line = elm_entry_utf8_to_markup(artist);
-
- strncpy(sel_mem_info->sub_buf,
- search_markup_keyword(markup_text_2line,
- ad->not_markup_search_word,
- &is_word_in_str),
- MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_2line);
- }
- } else {
- memset(sel_mem_info->sub_buf, '\0', MAX_LENGTH_PER_LINE);
-
- if ((artist) && (strlen(artist) > 0)) {
- char* markup_text_2line = elm_entry_utf8_to_markup(artist);
-
- strncpy(sel_mem_info->sub_buf,
- search_markup_keyword(markup_text_2line,
- ad->not_markup_search_word,
- &is_word_in_str),
- MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_2line);
- }
-
- if (is_word_in_str == false && (album) && (strlen(album) > 0)) {
- char* markup_text_2line = elm_entry_utf8_to_markup(album);
-
- strncpy(sel_mem_info->sub_buf,
- search_markup_keyword(markup_text_2line,
- ad->not_markup_search_word,
- &is_word_in_str),
- MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_2line);
- }
+ len = strlen(escape_added_keyword) + strlen(DB_ESCAPE_CHAR) + strlen(music_query) + 1;
+ search_query = (char*)calloc(1, len);
- if (is_word_in_str == false) {
- SEARCH_DEBUG_LOG("search_result is 0. No match keyword in title,album,artist string");
+ snprintf(search_query, len, music_query, escape_added_keyword,
+ escape_added_keyword, escape_added_keyword, DB_ESCAPE_CHAR);
+
+ filter_h filter;
+
+ ret = media_filter_create(&filter);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_create failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
}
- }
- snprintf(sel_mem_info->main_id,
- MAX_LENGTH_PER_ID - 1, "%s", audio_id);
+ ret = media_filter_set_offset(filter, offset, limit);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_set_offset failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
- strncpy(sel_mem_info->path, pathname, MAX_LENGTH_PER_PATH);
+ ret = media_filter_set_condition(filter, search_query, MEDIA_CONTENT_COLLATE_DEFAULT);
+ if(ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_set_condition failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
- elm_genlist_item_append(ad->search_gl,
- (ad->itc_pslist_2line),
- sel_mem_info,
- ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_phone_result_sel,
- ad);
- sel_mem_info = NULL;
- }
+ ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SEARCH_DEBUG_WARNING("media_filter_set_order failed : %d\n", ret);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
}
- /* Set more title to genlist (under 'search all') */
- if (loop_cnt == limit) {
- ad->cate_info[type].next_point = offset + loop_cnt - 1;
+ ret = __search_sql_media_search_result_by_api(obj,
+ offset,
+ limit,
+ keyword,
+ filter,
+ __search_sql_music_info_cb,
+ data,
+ result_info);
- sel_mem =
- (struct search_item_sel *)calloc(1,
- sizeof(struct search_item_sel));
- sel_mem->type = type;
-
- elm_genlist_item_append(ad->search_gl, (ad->itc_listmore),
- sel_mem, ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_result_more_item_append_cb,
- ad);
- }
-
-out_func:
+out_func:
- audio_svc_search_item_free(handle);
+ SEARCH_FREE(search_query);
+ SEARCH_FREE(escape_added_keyword);
+ media_filter_destroy(filter);
SEARCH_FUNC_END;
@@ -1110,120 +1269,127 @@ out_func:
}
ail_cb_ret_e __search_sql_menu_search_result_cb(
- const ail_appinfo_h appinfo,
+ const ail_appinfo_h appinfo,
void *data)
{
SEARCH_FUNC_START;
-
- struct appdata *ad = (struct appdata *)data;
- struct search_item_sel *sel_mem = NULL;
- struct search_item_sel *sel_mem_info = NULL;
+ struct search_cb_data *scd = (struct search_cb_data*)data;
+ struct appdata *ad = scd->ad;
+ struct search_content_object* obj = scd->obj;
+ struct search_genlist_info *result_info = scd->result_info;
+ char *keyword = scd->keyword;
- int type = SEARCH_TYPE_PHONE_MENU;
+ struct search_genlist_item_info *gen_item = NULL;
+ struct search_item_sel *sel_mem_info = NULL;
+ struct search_item_more_sel *sel_mem_more = NULL;
bool is_word_in_str;
ail_cb_ret_e ret;
- if(ad->cate_info[type].loop_cnt < ad->cate_info[type].next_point) {
- ad->cate_info[type].loop_cnt++;
+ if (obj->mr_info.loop_cnt < obj->mr_info.next_point) {
+ obj->mr_info.loop_cnt++;
return AIL_CB_RET_CONTINUE;
}
- if(ad->cate_info[type].next_point <
- ad->cate_info[type].offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
-
+ if(obj->mr_info.next_point <
+ obj->mr_info.offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
+
sel_mem_info = (struct search_item_sel *)calloc(1, sizeof(struct search_item_sel));
- sel_mem_info->type = type;
+ sel_mem_info->type = obj->contents_type;;
/********** START : set search result to sel_mem_info buf ************/
char *name = NULL;
char *package = NULL;
+ char *icon = NULL;
+
+ ail_appinfo_get_str(appinfo, AIL_PROP_ICON_STR, &icon);
+
+ if (icon)
+ strncpy(sel_mem_info->icon1_path, icon,
+ MAX_LENGTH_PER_PATH - 1);
ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
if ((package) && (strlen(package) > 0)) {
- if(strcmp(package, SEARCHPKG) == 0) {
- ad->cate_info[type].loop_cnt++;
+ if(strcmp(package, "org.tizen.smartsearch") == 0) {
+ SEARCH_DEBUG_LOG("'smartsearch' does not appended");
+ obj->mr_info.loop_cnt++;
SEARCH_FREE(sel_mem_info);
return AIL_CB_RET_CONTINUE;
}
strncpy(sel_mem_info->path, package, MAX_LENGTH_PER_PATH - 1);
+
+ SEARCH_DEBUG_LOG("package : %s", package);
+ } else {
+ SEARCH_DEBUG_LOG("package : null");
}
ail_appinfo_get_str(appinfo, AIL_PROP_NAME_STR, &name);
if ((name) && (strlen(name) > 0)) {
- char* markup_text_1line = elm_entry_utf8_to_markup(name);
-
strncpy(sel_mem_info->main_buf,
- search_markup_keyword(markup_text_1line, ad->not_markup_search_word,&is_word_in_str),
+ search_markup_keyword(name, keyword, &is_word_in_str),
MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_1line);
-
+
SEARCH_DEBUG_LOG("name : %s", name);
} else {
SEARCH_DEBUG_LOG("name : null");
}
-if(ad->cate_info[type].next_point == 0) {
+
+ if(obj->mr_info.next_point == 0) {
/* Set group title */
- sel_mem = (struct search_item_sel *)calloc(1, sizeof(struct search_item_sel));
- sel_mem->type = type;
- ad->gl_result_group_item[type] = elm_genlist_item_append(
- ad->search_gl,
- (ad->itc_grouptitle),
- sel_mem,
- (Elm_Object_Item *) NULL,
- ELM_GENLIST_ITEM_GROUP,
- NULL,
+ result_info->group = search_add_genlist_item(SEARCH_GENLIST_GROUP,
+ obj,
+ ad->itc_grouptitle,
+ obj,
NULL);
}
/********** END : set search result to sel_mem_info buf *************/
- elm_genlist_item_append(ad->search_gl,
- (ad->itc_pslist_1line),
+ gen_item = search_add_genlist_item(SEARCH_GENLIST_ITEM,
+ obj,
+ ad->itc_pslist_1line_1icon,
sel_mem_info,
- ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_phone_result_sel,
- ad);
-
- ad->cate_info[type].next_point++;
- ad->cate_info[type].loop_cnt++;
+ obj->gl_result_grp);
+ result_info->itemlist = g_list_append(result_info->itemlist, (void*)gen_item);
+ obj->mr_info.next_point++;
+ obj->mr_info.loop_cnt++;
ret = AIL_CB_RET_CONTINUE;
-
- } else if (ad->cate_info[type].next_point ==
- ad->cate_info[type].offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
+
+ } else if (obj->mr_info.next_point ==
+ obj->mr_info.offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
/* Check that only "SMARTSEARCH" is left in more result */
- if(ad->cate_info[type].next_point == ad->cate_info[type].result_cnt-1) {
+ if(obj->mr_info.next_point == obj->mr_info.result_cnt-1) {
char *package = NULL;
ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
- if ((package) && (strlen(package) > 0) && (strcmp(package, SEARCHPKG) == 0)) {
+ if ((package) && (strlen(package) > 0) && (strcmp(package, "org.tizen.smartsearch") == 0)) {
+ SEARCH_DEBUG_LOG("Only 'SMARTSEARCH' is left in more result");
return AIL_CB_RET_CANCEL;
}
}
/* Set more title to genlist (under 'search all') */
- sel_mem = (struct search_item_sel *)calloc(1, sizeof(struct search_item_sel));
- sel_mem->type = type;
+ sel_mem_more = (struct search_item_more_sel *)calloc(1, sizeof(struct search_item_more_sel));
+ sel_mem_more->obj = obj;
- elm_genlist_item_append(ad->search_gl, (ad->itc_listmore),
- sel_mem, ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_result_more_item_append_cb,
- ad);
+ result_info->more = search_add_genlist_item(SEARCH_GENLIST_MORE,
+ obj,
+ ad->itc_listmore,
+ sel_mem_more,
+ obj->gl_result_grp);
ret = AIL_CB_RET_CANCEL;
} else {
SEARCH_DEBUG_WARNING
("__search_sql_memo_search_result_cb wrong index : %d",
- ad->cate_info[type].next_point);
+ obj->mr_info.next_point);
ret = AIL_CB_RET_CANCEL;
}
@@ -1233,12 +1399,16 @@ if(ad->cate_info[type].next_point == 0) {
return ret;
}
-int search_sql_menu_search_result_by_api(int type, int offset, int limit,
- char *keyword, void *data)
+int search_sql_menu_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit,
+ char *keyword,
+ void *data,
+ struct search_genlist_info *result_info)
{
SEARCH_FUNC_START;
struct appdata *ad = (struct appdata *)data;
+ struct search_cb_data scd = {obj, ad, keyword, result_info};
int cnt = 0;
int ret = 0;
@@ -1246,13 +1416,18 @@ int search_sql_menu_search_result_by_api(int type, int offset, int limit,
ail_filter_h filter;
ail_error_e rc;
+ char *escape_added_keyword = NULL;
+ SEARCH_MALLOC(escape_added_keyword, strlen(keyword)*2+5, char);
+ memset(escape_added_keyword, 0x0, strlen(keyword)*2+5);
+ search_sql_make_keyword_bind_value(keyword, escape_added_keyword, SEARCH_SQL_BIND_TYPE_DUPLEX);
+
rc = ail_filter_new(&filter);
if (rc != AIL_ERROR_OK) {
SEARCH_DEBUG_WARNING("menu search - ail_filter_new error : %d", rc);
return SEARCH_RET_SEARCH_FAIL;
}
- rc = ail_filter_add_str(filter, AIL_PROP_NAME_STR, keyword);
+ rc = ail_filter_add_str(filter, AIL_PROP_NAME_STR, escape_added_keyword);
if (rc != AIL_ERROR_OK) {
SEARCH_DEBUG_WARNING("menu search - ail_filter_add_str error : %d", rc);
ret = SEARCH_RET_SEARCH_FAIL;
@@ -1273,18 +1448,19 @@ int search_sql_menu_search_result_by_api(int type, int offset, int limit,
goto out_func;
}
- ad->cate_info[type].result_cnt = cnt;
+ SEARCH_DEBUG_LOG("ail search result : %d", cnt);
+ obj->mr_info.result_cnt = cnt;
if(cnt > 0) {
- ad->cate_info[type].loop_cnt = 0;
- rc = ail_filter_list_appinfo_foreach(filter, __search_sql_menu_search_result_cb, data);
+ obj->mr_info.loop_cnt = 0;
+ rc = ail_filter_list_appinfo_foreach(filter, __search_sql_menu_search_result_cb, &scd);
if( rc != AIL_ERROR_OK) {
SEARCH_DEBUG_WARNING("menu search - ail_filter_list_appinfo_foreach error : %d", rc);
ret = SEARCH_RET_SEARCH_FAIL;
goto out_func;
}
- if(ad->cate_info[type].next_point == 0) {
+ if (obj->mr_info.next_point == 0) {
ret = SEARCH_RET_SEARCH_NONE;
} else {
ret = SEARCH_RET_SEARCH_SUCCESS;
@@ -1295,47 +1471,334 @@ int search_sql_menu_search_result_by_api(int type, int offset, int limit,
out_func:
ail_filter_destroy(filter);
+ SEARCH_FREE(escape_added_keyword);
+ SEARCH_FUNC_END;
+
+ return ret;
+}
+bool __search_sql_browser_bookmark_result_cb(favorites_bookmark_entry_s *item, void *user_data)
+{
+ SEARCH_FUNC_START;
+ struct search_item_sel *sel_mem_info = NULL;
+
+ bool ret = false;
+ bool is_word_in_str_main = false;
+ bool is_word_in_str_sub = false;
+
+ const char* match_str = NULL;
+
+ struct search_cb_data_browser *scd = (struct search_cb_data_browser*)user_data;
+ struct appdata *ad = scd->ad;
+ struct search_content_object *obj = scd->obj;
+ struct search_genlist_info *result_info = scd->result_info;
+ char *keyword = scd->keyword;
+
+ struct search_genlist_item_info *gen_item = NULL;
+ struct search_more_result *info = scd->info;
+
+ if (info->loop_cnt < info->next_point) {
+ info->loop_cnt++;
+ return true;
+ }
+
+ if (info->next_point <
+ info->offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
+
+ sel_mem_info = (struct search_item_sel *)calloc(1, sizeof(struct search_item_sel));
+ sel_mem_info->type = obj->contents_type;;
+
+ /********** START : set search result to sel_mem_info buf ************/
+
+ if (item != NULL && item->title) {
+ match_str = search_markup_keyword(item->title, keyword, &is_word_in_str_main);
+ strncpy(sel_mem_info->main_buf,
+ match_str,
+ MAX_LENGTH_PER_LINE - 1);
+ }
+
+ if (item != NULL && item->address) {
+ match_str = search_markup_keyword(item->address, keyword, &is_word_in_str_sub);
+ strncpy(sel_mem_info->sub_buf,
+ match_str,
+ MAX_LENGTH_PER_LINE - 1);
+ strncpy(sel_mem_info->path,
+ item->address,
+ MAX_LENGTH_PER_PATH - 1);
+ }
+
+ if (is_word_in_str_main == true || is_word_in_str_sub == true) {
+ if (obj->gl_result_grp == NULL ) {
+ /* Set group title */
+ result_info->group = search_add_genlist_item(SEARCH_GENLIST_GROUP,
+ obj,
+ ad->itc_grouptitle,
+ obj,
+ NULL);
+ }
+
+ if (obj->obj_icon_path)
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
+
+ strncpy(sel_mem_info->icon2_path,
+ SEARCH_FAVORITE_ICON,
+ MAX_LENGTH_PER_PATH - 1);
+
+ gen_item = search_add_genlist_item(SEARCH_GENLIST_ITEM,
+ obj,
+ ad->itc_pslist_2line_2icon,
+ sel_mem_info,
+ obj->gl_result_grp);
+ result_info->itemlist = g_list_append(result_info->itemlist, (void*)gen_item);
+ }
+
+ /********** END : set search result to sel_mem_info buf *************/
+ info->next_point++;
+ info->loop_cnt++;
+
+ ret = true;
+ } else if (info->next_point ==
+ info->offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
+ info->offset = info->next_point;
+ ret = false;
+ } else {
+ SEARCH_DEBUG_WARNING
+ ("__search_sql_browser_bookmark_result_cb wrong index : %d",
+ info->next_point);
+
+ ret = false;
+ }
SEARCH_FUNC_END;
+ return ret;
+
+}
+
+bool __search_sql_browser_history_result_cb(favorites_history_entry_s *item, void *user_data)
+{
+ SEARCH_FUNC_START;
+ struct search_item_sel *sel_mem_info = NULL;
+
+ bool ret = false;
+ bool is_word_in_str_main = false;
+
+ const char* match_str = NULL;
+
+ struct search_cb_data_browser *scd = (struct search_cb_data_browser*)user_data;
+ struct appdata *ad = scd->ad;
+ struct search_content_object *obj = scd->obj;
+ struct search_genlist_info *result_info = scd->result_info;
+ char *keyword = scd->keyword;
+
+ struct search_more_result *info = scd->info;
+ struct search_genlist_item_info *gen_item = NULL;
+
+ if (info->loop_cnt < info->next_point) {
+ info->loop_cnt++;
+ return true;
+ }
+
+ if (info->next_point <
+ info->offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
+
+ sel_mem_info = (struct search_item_sel *)calloc(1, sizeof(struct search_item_sel));
+ sel_mem_info->type = obj->contents_type;;
+
+ /********** START : set search result to sel_mem_info buf ************/
+
+ if (item != NULL && item->address) {
+ SEARCH_DEBUG_WARNING("BROWSER : %s %s", item->address, keyword);
+ match_str = search_markup_keyword(item->address, keyword, &is_word_in_str_main);
+ }
+
+ if (is_word_in_str_main != false ) {
+ if (obj->gl_result_grp == NULL ) {
+ /* Set group title */
+ result_info->group = search_add_genlist_item(SEARCH_GENLIST_GROUP,
+ obj,
+ ad->itc_grouptitle,
+ obj,
+ NULL);
+ }
+
+ if (obj->obj_icon_path)
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
+
+ if (item->address)
+ strncpy(sel_mem_info->path, item->address, MAX_LENGTH_PER_PATH - 1);
+ strncpy(sel_mem_info->main_buf,
+ match_str,
+ MAX_LENGTH_PER_LINE - 1);
+
+ gen_item = search_add_genlist_item(SEARCH_GENLIST_ITEM,
+ obj,
+ ad->itc_pslist_1line_1icon,
+ sel_mem_info,
+ obj->gl_result_grp);
+ result_info->itemlist = g_list_append(result_info->itemlist, (void*)gen_item);
+ }
+
+ info->next_point++;
+ info->loop_cnt++;
+
+ ret = true;
+
+ } else if (info->next_point ==
+ info->offset + SEARCH_CATEGORY_LIST_MORE_CNT) {
+ info->offset = info->next_point;
+ ret = false;
+ } else {
+ SEARCH_DEBUG_WARNING
+ ("__search_sql_browser_history_result_cb wrong index : %d",
+ info->next_point);
+
+ ret = false;
+ }
+
+ SEARCH_FUNC_END;
return ret;
}
-int search_sql_msg_search_result_by_api(int type, int offset, int limit,
- void *data)
+int search_sql_browser_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit,
+ char *keyword,
+ void *data,
+ struct search_genlist_info *result_info)
{
SEARCH_FUNC_START;
struct appdata *ad = (struct appdata *)data;
+ struct search_cb_data_browser scd_browser = {obj, ad, keyword, result_info, NULL};
+ struct search_cb_data_browser scd_history = {obj, ad, keyword, result_info, NULL};
+
+ static struct search_more_result browser_result[2];
+ struct search_item_more_sel *sel_mem_more = NULL;
- int loop_cnt = 0;
int ret = 0;
+ int bookmark_cnt = 0, history_cnt = 0;
+ int bookmark_ret = 0, history_ret = 0;
+
+ if (offset == 0) {
+ /* offset 0 means first search result, so we initialize struct */
+ memset(browser_result, 0x0, sizeof(browser_result));
+
+ favorites_bookmark_get_count(&browser_result[0].result_cnt);
+ favorites_history_get_count(&browser_result[1].result_cnt);
+
+ bookmark_cnt = browser_result[0].result_cnt;
+ history_cnt = browser_result[1].result_cnt;
+ browser_result[0].ad = browser_result[1].ad = ad;
+ obj->gl_result_grp = NULL;
+
+ if ( bookmark_cnt <= 0 && history_cnt <= 0 )
+ return SEARCH_RET_SEARCH_NONE;
+ } else {
+ bookmark_cnt = browser_result[0].result_cnt;
+ history_cnt = browser_result[1].result_cnt;
+ browser_result[0].loop_cnt = 0;
+ browser_result[1].loop_cnt = 0;
+ }
+
+ if (offset >= bookmark_cnt + history_cnt) {
+ /* We need not to search */
+ return SEARCH_RET_SEARCH_NONE;
+ }
+
+ scd_browser.info = &browser_result[0];
+ scd_history.info = &browser_result[1];
- struct search_item_sel *sel_mem = NULL;
- Elm_Object_Item *git = NULL;
+ /* offset check */
+ if (bookmark_cnt > browser_result[0].next_point )
+ bookmark_ret = favorites_bookmark_foreach(__search_sql_browser_bookmark_result_cb,
+ &scd_browser);
+ if (history_cnt > browser_result[1].next_point )
+ history_ret = favorites_history_foreach(__search_sql_browser_history_result_cb,
+ &scd_history);
+
+ if (bookmark_ret == FAVORITES_ERROR_DB_FAILED
+ && history_ret == FAVORITES_ERROR_DB_FAILED ) {
+ ret = SEARCH_RET_SEARCH_FAIL;
+ }
+ else if (obj->gl_result_grp == NULL) {
+ /* It means we can't get matched results */
+ ret = SEARCH_RET_SEARCH_NONE;
+ }
+ else {
+ /* Make More button */
+ if (browser_result[0].next_point < bookmark_cnt
+ || browser_result[1].next_point < history_cnt) {
+ sel_mem_more = (struct search_item_more_sel *)calloc(1, sizeof(struct search_item_more_sel));
+ sel_mem_more->obj = obj;
+
+ result_info->more = search_add_genlist_item(SEARCH_GENLIST_MORE,
+ obj,
+ ad->itc_listmore,
+ sel_mem_more,
+ obj->gl_result_grp);
+ }
+
+ /* return check */
+ obj->mr_info.next_point = browser_result[0].next_point
+ + browser_result[1].next_point;
+ ret = SEARCH_RET_SEARCH_SUCCESS;
+ }
+
+ return ret;
+
+ SEARCH_FUNC_END;
+}
+
+int search_sql_msg_search_result_by_api(struct search_content_object *obj,
+ int offset, int limit,
+ char *keyword,
+ void *data,
+ struct search_genlist_info *result_info)
+{
+ SEARCH_FUNC_START;
+
+ int loop_cnt = 0;
+ int ret = 0;
struct search_item_sel *sel_mem_info = NULL;
- bool is_word_in_str;
+ struct search_item_more_sel *sel_mem_more = NULL;
+ struct appdata *ad = (struct appdata *)data;
+ struct search_genlist_item_info *gen_item = NULL;
- Evas_Object *glist;
+ bool is_word_in_str;
- MSG_HANDLE_T msgHandle = NULL;
- MSG_ERROR_T err = MSG_SUCCESS;
- MSG_LIST_S msgList;
int i = 0;
int j = 0;
bool is_more_btn = false;
bool is_word_in_title = false;
- int address_cnt = 0;
+ msg_error_t err = MSG_SUCCESS;
+ msg_struct_list_s msgList;
+ msg_struct_t search_s = NULL;
+ msg_struct_list_s *addr_list = NULL;
+
+ search_s = msg_create_struct(MSG_STRUCT_SEARCH_CONDITION);
- MSG_SEARCH_CONDITION_S searchCon = {0,};
+ err = msg_set_int_value(search_s, MSG_SEARCH_CONDITION_FOLDERID_INT, MSG_ALLBOX_ID);
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to make search struct : MSG_SEARCH_CONDITION_FOLDERID_INT");
+ return SEARCH_RET_SEARCH_FAIL;
+ };
+
+ err = msg_set_int_value(search_s, MSG_SEARCH_CONDITION_MSGTYPE_INT, MSG_TYPE_INVALID);
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to make search struct : MSG_SEARCH_CONDITION_MSGTYPE_INT");
+ return SEARCH_RET_SEARCH_FAIL;
+ }
- searchCon.msgType = MSG_TYPE_INVALID;
- searchCon.folderId = MSG_ALLBOX_ID;
- searchCon.pSearchVal = ad->search_word;
+ err = msg_set_str_value(search_s, MSG_SEARCH_CONDITION_SEARCH_VALUE_STR, keyword, strlen(keyword));
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to make search struct : MSG_SEARCH_CONDITION_SEARCH_VALUE_STR");
+ return SEARCH_RET_SEARCH_FAIL;
+ }
- err = msg_search_message(ad->msg_handle, &searchCon, offset, limit, &msgList);
+ err = msg_search_message(ad->msg_handle, search_s, offset, limit, &msgList);
if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
SEARCH_DEBUG_WARNING("msg_search_message is failed : %d", err);
@@ -1348,24 +1811,13 @@ int search_sql_msg_search_result_by_api(int type, int offset, int limit,
} else {
/* Set group title */
- glist = ad->search_gl;
-
if (offset == 0) {
- sel_mem =
- (struct search_item_sel *)calloc(1,
- sizeof(struct
- search_item_sel));
- sel_mem->type = type;
-
- git =
- elm_genlist_item_append(glist,
- (ad->itc_grouptitle),
- sel_mem,
- (Elm_Object_Item *) NULL,
- ELM_GENLIST_ITEM_GROUP,
- NULL, NULL);
-
- ad->gl_result_group_item[type] = git;
+ /* Set group title */
+ result_info->group = search_add_genlist_item(SEARCH_GENLIST_GROUP,
+ obj,
+ ad->itc_grouptitle,
+ obj,
+ NULL);
}
/* Set search result to genlist */
@@ -1381,78 +1833,185 @@ int search_sql_msg_search_result_by_api(int type, int offset, int limit,
/********** START : set search result to sel_mem_info buf ************/
for (i = 0; i < loop_cnt; i++) {
+ int ret = 0;
const char *text_1line = NULL;
- const char *text_2line = NULL;
- const char *msg_address = NULL;
const char *markup_keyword = NULL;
+ const char *img_path = NULL;
+
+ int msg_type = 0;
+ int contact_id = -1;
+ int message_id = -1;
+
+ char subject[MAX_SUBJECT_LEN] = {0};
+ char str_number[MAX_ADDRESS_VAL_LEN] = {0,};
+ char str_name[MAX_DISPLAY_NAME_LEN] = {0,};
+ char msg_text[MAX_MSG_TEXT_LEN] = {0,};
+
+ CTSstruct *contact = NULL;
sel_mem_info = (struct search_item_sel *)
calloc(1,sizeof(struct search_item_sel));
- sel_mem_info->type = type;
+ sel_mem_info->type = obj->contents_type;;
+
+ err = msg_get_int_value(msgList.msg_struct_info[i], MSG_MESSAGE_ID_INT, &message_id);
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to make search struct : MSG_MESSAGE_ID_INT %d", err);
+ goto out_func;
+ }
+ snprintf(sel_mem_info->main_id, MAX_LENGTH_PER_ID - 1, "%d", message_id);
- snprintf(sel_mem_info->main_id, MAX_LENGTH_PER_ID - 1, "%d", msg_get_message_id(msgList.msgInfo[i]));
+ err = msg_get_int_value(msgList.msg_struct_info[i], MSG_MESSAGE_TYPE_INT, &msg_type);
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to make search struct : MSG_MESSAGE_TYPE_INT %d", err);
+ goto out_func;
+ }
+
+ SEARCH_DEBUG_LOG("mms : %d", msg_type);
/* Set 1st line string */
- if(msg_is_mms(msgList.msgInfo[i])) {
- /* MMS case */
- char* markup_text_1line = NULL;
-
- text_1line = msg_get_subject(msgList.msgInfo[i]);
- markup_text_1line = elm_entry_utf8_to_markup(text_1line);
-
- markup_keyword = search_markup_keyword(markup_text_1line,
- ad->not_markup_search_word,
+ if (msg_type == MSG_TYPE_MMS) {
+ /* MMS case */
+ err = msg_get_str_value(msgList.msg_struct_info[i], MSG_MESSAGE_SUBJECT_STR,
+ subject, MAX_SUBJECT_LEN);
+
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to get sms context %d", err);
+ goto out_func;
+ }
+
+ text_1line = subject;
+ markup_keyword = search_markup_keyword(text_1line,
+ keyword,
&is_word_in_title);
if (!is_word_in_title) {
- text_1line = msg_mms_get_text_contents(msgList.msgInfo[i]);
- markup_text_1line = elm_entry_utf8_to_markup(text_1line);
- markup_keyword = search_markup_keyword(markup_text_1line,
- ad->not_markup_search_word,
+ memset(msg_text, 0x00, sizeof(msg_text));
+ err = msg_get_str_value(msgList.msg_struct_info[i],
+ MSG_MESSAGE_MMS_TEXT_STR,
+ msg_text,
+ sizeof(msg_text));
+
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to get mms context %d", err);
+ goto out_func;
+ }
+
+ text_1line = msg_text;
+
+ markup_keyword = search_markup_keyword(text_1line,
+ keyword,
&is_word_in_title);
- }
+ }
+
+ SEARCH_DEBUG_LOG("1st string : %s", text_1line);
if ((text_1line) && (strlen(text_1line) > 0 ))
strncpy(sel_mem_info->main_buf, markup_keyword, MAX_LENGTH_PER_LINE - 1);
-
- SEARCH_FREE(markup_text_1line);
} else {
/* SMS Case */
- char* markup_text_1line = NULL;
-
- text_1line = msg_sms_get_message_body(msgList.msgInfo[i]);
- markup_text_1line = elm_entry_utf8_to_markup(text_1line);
- markup_keyword = search_markup_keyword(markup_text_1line,
- ad->not_markup_search_word,
+ err = msg_get_str_value(msgList.msg_struct_info[i],
+ MSG_MESSAGE_SMS_DATA_STR,
+ msg_text,
+ sizeof(msg_text));
+
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to get sms context %d", err);
+ goto out_func;
+ }
+
+ text_1line = msg_text;
+
+ markup_keyword = search_markup_keyword(text_1line,
+ keyword,
&is_word_in_title);
+ SEARCH_DEBUG_LOG("1st string : %s", text_1line);
if ((text_1line) && (strlen(text_1line) > 0))
strncpy(sel_mem_info->main_buf, markup_keyword, MAX_LENGTH_PER_LINE - 1);
+ }
+
+ err = msg_get_list_handle(msgList.msg_struct_info[i],
+ MSG_MESSAGE_ADDR_LIST_STRUCT,
+ (void **)&addr_list);
- SEARCH_FREE(markup_text_1line);
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to get address list handle! %d", err);
+ goto out_func;
}
/* Set 2nd line string */
- address_cnt = msg_get_address_count(msgList.msgInfo[i]);
+ for ( j=0; j<addr_list->nCount; j++) {
+ memset(str_number, 0, sizeof(str_number));
+ memset(str_name, 0, sizeof(str_name));
+ contact_id = -1;
+ is_word_in_str = false;
+
+ /* First We set text_2line to first address data */
+ err = msg_get_str_value(addr_list->msg_struct_info[j],
+ MSG_ADDRESS_INFO_ADDRESS_VALUE_STR,
+ str_number,
+ MAX_ADDRESS_VAL_LEN);
+
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to get data! : MSG_ADDRESS_INFO_DISPLAYNAME_STR %d", err);
+ goto out_func;
+ }
- for(j = 0; j < address_cnt; j++) {
+ err = msg_get_str_value(addr_list->msg_struct_info[j],
+ MSG_ADDRESS_INFO_DISPLAYNAME_STR,
+ str_name,
+ MAX_DISPLAY_NAME_LEN);
- if(msg_get_ith_contact_id(msgList.msgInfo[i],j) > 0) {
- text_2line = msg_get_ith_name(msgList.msgInfo[i],j);
- } else {
- text_2line = msg_get_ith_address(msgList.msgInfo[i],j);
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to get data! : MSG_ADDRESS_INFO_ADDRESS_VALUE_STR %d", err);
+ goto out_func;
}
- if ((text_2line) && (strlen(text_2line) > 0)) {
- char* markup_text_2line = NULL;
+ err = msg_get_int_value(addr_list->msg_struct_info[j],
+ MSG_ADDRESS_INFO_CONTACT_ID_INT,
+ &contact_id);
- markup_text_2line = elm_entry_utf8_to_markup(text_2line);
- strncpy(sel_mem_info->sub_buf,
- search_markup_keyword(markup_text_2line,
- ad->not_markup_search_word,
- &is_word_in_str),
- MAX_LENGTH_PER_LINE - 1);
- SEARCH_FREE(markup_text_2line);
+ if (err != MSG_SUCCESS) {
+ SEARCH_DEBUG_WARNING("Fail to get data! : MSG_ADDRESS_INFO_CONTACT_ID_INT %d", err);
+ goto out_func;
+ }
+
+ /* Set text_2line */
+ markup_keyword = search_markup_keyword(str_number, keyword, &is_word_in_str);
+
+ if( 0 == j || true == is_word_in_str) {
+ if (strlen(str_name) > 0) {
+ strncpy(sel_mem_info->sub_buf, str_name, MAX_LENGTH_PER_LINE - 1);
+ } else {
+ strncpy(sel_mem_info->sub_buf, markup_keyword, MAX_LENGTH_PER_LINE - 1);
+ }
+
+ /* Set Thumbnail Image */
+ if (contact_id == -1) {
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
+ }
+ else {
+ ret = contacts_svc_get_contact(contact_id, &contact);
+
+ if (ret == CTS_SUCCESS) {
+ CTSvalue* value = NULL;
+ ret = contacts_svc_struct_get_value(contact, CTS_CF_BASE_INFO_VALUE, &value);
+
+ if (ret == CTS_SUCCESS)
+ img_path = contacts_svc_value_get_str(value, CTS_BASE_VAL_IMG_PATH_STR);
+
+ if (img_path != NULL)
+ strncpy(sel_mem_info->icon1_path , img_path,
+ MAX_LENGTH_PER_PATH -1 );
+ else if (obj->obj_icon_path)
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
+ }
+ else if (obj->obj_icon_path)
+ strncpy(sel_mem_info->icon1_path, obj->obj_icon_path,
+ MAX_LENGTH_PER_PATH - 1);
+ }
}
if ((is_word_in_title) || (is_word_in_str)) {
@@ -1460,37 +2019,67 @@ int search_sql_msg_search_result_by_api(int type, int offset, int limit,
}
}
- elm_genlist_item_append(glist,
- (ad->itc_pslist_2line),
+ SEARCH_DEBUG_LOG("sel_mem_info->sub_buf : %s", sel_mem_info->sub_buf);
+
+ gen_item = search_add_genlist_item(SEARCH_GENLIST_ITEM,
+ obj,
+ ad->itc_pslist_2line_1icon,
sel_mem_info,
- ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_phone_result_sel,
- ad);
- sel_mem_info = NULL;
+ obj->gl_result_grp);
+
+ result_info->itemlist = g_list_append(result_info->itemlist, (void*)gen_item);
}
- msg_release_message_list(&msgList);
-
+ msg_release_list_struct(&msgList);
+
/* Set more title to genlist (under 'search all') */
if (is_more_btn) {
- ad->cate_info[type].next_point = offset + limit - 1;
+ obj->mr_info.next_point = offset + limit - 1;
- sel_mem = (struct search_item_sel *)
- calloc(1,sizeof(struct search_item_sel));
- sel_mem->type = type;
+ sel_mem_more = (struct search_item_more_sel *)
+ calloc(1,sizeof(struct search_item_more_sel));
+ sel_mem_more->obj = obj;
- elm_genlist_item_append(ad->search_gl, (ad->itc_listmore),
- sel_mem, ad->gl_result_group_item[type],
- ELM_GENLIST_ITEM_NONE,
- search_gl_result_more_item_append_cb,
- ad);
+ result_info->more = search_add_genlist_item(SEARCH_GENLIST_MORE,
+ obj,
+ ad->itc_listmore,
+ sel_mem_more,
+ obj->gl_result_grp);
}
ret = SEARCH_RET_SEARCH_SUCCESS;
}
+out_func:
SEARCH_FUNC_END;
return ret;
-}
-
+}
+
+void search_sql_update_result_object(struct search_content_object* result_obj, sqlite3* db_handle, sqlite3_stmt** db_sql)
+{
+ SEARCH_FUNC_START;
+
+ int rc = 0;
+
+ sqlite3_stmt *sql_stmt = db_sql[SEARCH_STMT_UPDATE_OBJECT_INFO];
+ SEARCH_RET_IF(sql_stmt==NULL);
+
+ search_sql_bind_text(db_handle, sql_stmt, 1, result_obj->name);
+ search_sql_bind_int(db_handle, sql_stmt, 2, result_obj->string_type);
+ search_sql_bind_int(db_handle, sql_stmt, 3, result_obj->visible);
+ search_sql_bind_int(db_handle, sql_stmt, 4, result_obj->order);
+ search_sql_bind_int(db_handle, sql_stmt, 5, result_obj->contents_type);
+ search_sql_bind_int(db_handle, sql_stmt, 6, result_obj->category_type);
+ search_sql_bind_text(db_handle, sql_stmt, 7, result_obj->def_pkg_name);
+ search_sql_bind_int(db_handle, sql_stmt, 8, result_obj->contents_type);
+
+ rc = sqlite3_step(sql_stmt);
+
+ if (rc == SQLITE_OK)
+ SEARCH_DEBUG_LOG("INSERT STEP SUCCESS");
+
+ search_sql_stmt_init(sql_stmt);
+
+ SEARCH_FUNC_END;
+
+}