summaryrefslogtreecommitdiff
path: root/src/ps_searcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ps_searcher.cpp')
-rwxr-xr-xsrc/ps_searcher.cpp1496
1 files changed, 1496 insertions, 0 deletions
diff --git a/src/ps_searcher.cpp b/src/ps_searcher.cpp
new file mode 100755
index 0000000..58414c6
--- /dev/null
+++ b/src/ps_searcher.cpp
@@ -0,0 +1,1496 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+
+
+
+#include "smartsearch.h"
+
+#include <sqlite3.h>
+
+#include <contacts-svc.h>
+#include <calendar-svc-provider.h>
+#include <memo-db.h>
+
+#include <email-types.h>
+#include <email-api.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 <ail.h>
+
+static GList *g_history_list;
+
+char* g_keyword = NULL;
+
+int search_sql_stmt_init(sqlite3_stmt * sql_stmt)
+{
+ SEARCH_FUNC_START;
+
+ int rc = 0;
+
+ rc = sqlite3_clear_bindings(sql_stmt);
+ if (rc != SQLITE_OK) {
+ SEARCH_DEBUG_ERROR("sqlite3_clear_bindings error");
+ return SEARCH_RET_FAIL;
+ }
+
+ rc = sqlite3_reset(sql_stmt);
+ if (rc != SQLITE_OK) {
+ SEARCH_DEBUG_ERROR("sqlite3_reset error");
+ return SEARCH_RET_FAIL;
+ }
+
+ SEARCH_FUNC_END;
+}
+
+int search_sql_stmt_finalize(sqlite3_stmt * stmt)
+{
+ SEARCH_FUNC_START;
+
+ int ret;
+
+ ret = sqlite3_finalize(stmt);
+ if (ret != SQLITE_OK) {
+ SEARCH_DEBUG_ERROR("sqlite3_finalize error : %d ", ret);
+ return -1;
+ }
+
+ SEARCH_FUNC_END;
+
+ return 0;
+}
+
+int search_sql_prepare_stmt(sqlite3 *db_handle, const char *query,
+ sqlite3_stmt ** stmt_out)
+{
+ SEARCH_FUNC_START;
+
+ int rc = 0;
+ int ret = 0;
+
+ rc = sqlite3_prepare(db_handle, query, strlen(query), stmt_out, NULL);
+ if (rc != SQLITE_OK) {
+ SEARCH_DEBUG_ERROR("sql preapre error : %d / %s", rc, query);
+ ret = SEARCH_RET_FAIL;
+ } else {
+ ret = SEARCH_RET_SUCCESS;
+ }
+
+ SEARCH_FUNC_END;
+
+ 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_item_sel *sel_mem = NULL;
+ int type = SEARCH_TYPE_PHONE_CONTACTS;
+
+ struct search_item_sel *sel_mem_info = 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 (ad->cate_info[type].next_point <
+ ad->cate_info[type].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;
+
+ /************ START : set search result to sel_mem_info buf ************/
+
+ /***********************************************************************/
+
+ memset(display_name, 0x00, sizeof(display_name));
+
+ display =
+ contacts_svc_value_get_str(value,
+ CTS_LIST_NUM_CONTACT_DISPLAY_STR);
+
+ if (display) {
+ snprintf(display_name, sizeof(display_name), "%s",
+ display);
+ } else {
+ first =
+ contacts_svc_value_get_str(value,
+ CTS_LIST_NUM_CONTACT_FIRST_STR);
+ last =
+ contacts_svc_value_get_str(value,
+ CTS_LIST_NUM_CONTACT_LAST_STR);
+
+ if (CTS_ORDER_NAME_FIRSTLAST ==
+ contacts_svc_get_order(CTS_ORDER_OF_DISPLAY)) {
+ if (first) {
+ if (last) {
+ snprintf(display_name,
+ sizeof(display_name),
+ "%s %s", first, last);
+ } else {
+ snprintf(display_name,
+ sizeof(display_name),
+ "%s", first);
+ }
+ } else {
+ if (last) {
+ snprintf(display_name,
+ sizeof(display_name),
+ "%s", last);
+ }
+ }
+ } else {
+ if (last) {
+ if (first) {
+ snprintf(display_name,
+ sizeof(display_name),
+ "%s %s", last, first);
+ } else {
+ snprintf(display_name,
+ sizeof(display_name),
+ "%s", last);
+ }
+ } else {
+ if (first) {
+ snprintf(display_name,
+ sizeof(display_name),
+ "%s", first);
+ }
+ }
+ }
+ }
+
+ if((display_name) && strlen(display_name) > 0) {
+ char* markup_text_1line = elm_entry_utf8_to_markup(display_name);
+
+ 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);
+ }
+
+ /***********************************************************************/
+
+ 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),
+ 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));
+
+ /***********************************************************************/
+ /************ END : set search result to sel_mem_info buf **************/
+
+ 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);
+
+ ad->cate_info[type].next_point++;
+ } else if (ad->cate_info[type].next_point ==
+ ad->cate_info[type].offset +
+ SEARCH_CATEGORY_LIST_MORE_CNT) {
+ /* 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;
+
+ 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);
+ } else {
+ SEARCH_DEBUG_WARNING
+ ("__search_sql_contact_search_result_cb wrong index : %d",
+ ad->cate_info[type].next_point);
+ }
+
+ SEARCH_FUNC_END;
+
+ return 0;
+}
+
+int search_sql_contact_search_result_by_api(int type, int offset, int limit,
+ void *data)
+{
+ SEARCH_FUNC_START;
+
+ struct appdata *ad = (struct appdata *)data;
+ int ret = 0;
+
+ /* Check whether search result is exist or not */
+ ret =
+ contacts_svc_smartsearch_excl(ad->search_word, limit, offset,
+ __search_sql_contact_search_result_cb,
+ data);
+ 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) {
+ SEARCH_DEBUG_WARNING("contacts svc search no result");
+ return SEARCH_RET_SEARCH_NONE;
+ }
+
+ SEARCH_FUNC_END;
+
+ return SEARCH_RET_SEARCH_SUCCESS;
+}
+
+int search_sql_calendar_search_result_by_api(int type, int offset, int limit,
+ void *data)
+{
+ SEARCH_FUNC_START;
+
+ int ret;
+ struct appdata *ad = (struct appdata *)data;
+
+ 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;
+ int loop_cnt = 0;
+
+ char *summary = NULL;
+ bool is_word_in_str;
+
+ time_t start_time = 0;
+
+ ret =
+ calendar_svc_search_list(0, 0, CAL_STRUCT_SCHEDULE,
+ CAL_VALUE_TXT_SUMMARY, ad->search_word,
+ offset, limit, &iter);
+
+ if (ret == CAL_SUCCESS) {
+ ret = calendar_svc_iter_next(iter);
+ if (ret != CAL_SUCCESS) {
+ SEARCH_DEBUG_WARNING
+ ("calendar svc search no result : %d", ret);
+ 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;
+ }
+ /* Set search result to genlist */
+ do {
+ loop_cnt++;
+
+ if (loop_cnt == limit) {
+ break;
+ }
+ /********** START : set search result to sel_mem_info buf ************/
+
+ ret = calendar_svc_iter_get_info(iter, &event);
+
+ if (ret == CAL_SUCCESS) {
+ sel_mem_info =
+ (struct search_item_sel *)calloc(1,
+ sizeof
+ (struct
+ search_item_sel));
+ sel_mem_info->type = type;
+
+ 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);
+
+ 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);
+ }
+
+ 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);
+
+ calendar_svc_struct_free(&event);
+ summary = NULL;
+
+ elm_genlist_item_append(glist,
+ (ad->itc_pslist_1line),
+ sel_mem_info,
+ ad->gl_result_group_item[type],
+ ELM_GENLIST_ITEM_NONE,
+ search_gl_phone_result_sel,
+ ad);
+ sel_mem_info = NULL;
+ } else {
+ SEARCH_DEBUG_WARNING
+ ("calendar_svc_iter_get_info fail : %d",
+ ret);
+ break;
+ }
+
+ }
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS);
+ } else {
+ SEARCH_DEBUG_WARNING("calendar_svc_search_list fail : %d", ret);
+ return SEARCH_RET_SEARCH_FAIL;
+ }
+
+ /* Set more title to genlist (under 'search all') */
+ if (loop_cnt == limit) {
+ ad->cate_info[type].next_point = offset + limit - 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);
+ }
+
+ SEARCH_FUNC_END;
+ return SEARCH_RET_SEARCH_SUCCESS;
+}
+
+static void __search_sql_memo_search_result_cb(memo_data_t * value,
+ void *user_data)
+{
+ 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_item_sel *sel_mem_info = NULL;
+
+ bool is_word_in_str;
+
+ if(!value) {
+ SEARCH_DEBUG_WARNING("memo data value is null");
+ return;
+ }
+
+ 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 (ad->cate_info[type].next_point <
+ ad->cate_info[type].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;
+
+ /********** START : set search result to sel_mem_info buf ************/
+ /* 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,
+ &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,
+ &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);
+
+ search_util_date_time_format_get_val(localtime
+ (&value->modi_time),
+ sel_mem_info->sub_buf);
+
+ /********** END : set search result to sel_mem_info buf *************/
+
+ elm_genlist_item_append(ad->search_gl, (ad->itc_pslist_1line),
+ 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 +
+ SEARCH_CATEGORY_LIST_MORE_CNT) {
+ /* 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;
+
+ 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);
+ } else {
+ SEARCH_DEBUG_WARNING
+ ("__search_sql_memo_search_result_cb wrong index : %d",
+ ad->cate_info[type].next_point);
+ }
+
+ SEARCH_FUNC_END;
+
+ return;
+}
+
+int search_sql_memo_search_result_by_api(int type, int offset, int limit,
+ void *data)
+{
+ SEARCH_FUNC_START;
+
+ struct appdata *ad = (struct appdata *)data;
+
+ memo_search_data(ad->search_word,
+ limit, offset,
+ MEMO_SORT_TITLE_ASC,
+ __search_sql_memo_search_result_cb,
+ data);
+
+ if (ad->cate_info[type].next_point == 0) {
+ SEARCH_DEBUG_WARNING("no memo search result");
+ return SEARCH_RET_SEARCH_NONE;
+ }
+
+ SEARCH_FUNC_END;
+ return SEARCH_RET_SEARCH_SUCCESS;
+}
+
+int search_sql_email_search_result_by_api(int type, int offset, int limit,
+ void *data)
+{
+ SEARCH_FUNC_START;
+
+ struct appdata *ad = (struct appdata *)data;
+
+ int result_cnt = 0;
+ int ret = 0;
+ int i = 0;
+ emf_mail_list_item_t *mail_list = NULL;
+
+ struct search_item_sel *sel_mem = NULL;
+ Elm_Object_Item *git = NULL;
+ Evas_Object *glist;
+
+ struct search_item_sel *sel_mem_info = 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);
+
+ if(ret < 1) {
+ SEARCH_DEBUG_WARNING("no email search result");
+ return SEARCH_RET_SEARCH_FAIL;
+ }
+
+ if(result_cnt == 0) {
+ SEARCH_DEBUG_WARNING("no email search result");
+ return SEARCH_RET_SEARCH_NONE;
+ }
+
+ if(mail_list == NULL) {
+ SEARCH_DEBUG_WARNING("mail_list is null");
+ 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;
+ }
+
+ /* Set search result to genlist */
+ for(i=0;i<result_cnt;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;
+
+ 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);
+
+ 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),
+ 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),
+ 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),
+ MAX_LENGTH_PER_LINE - 1);
+ SEARCH_FREE(markup_text_2line);
+ }
+
+ elm_genlist_item_append(glist,
+ (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;
+ }
+
+ 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);
+ }
+
+ SEARCH_FUNC_END;
+ return SEARCH_RET_SEARCH_SUCCESS;
+}
+
+static int __search_sql_media_search_item_list_search_cb( Mitem* item, void* user_data)
+{
+ GList** list = (GList**) user_data;
+ *list = g_list_append( *list, item );
+
+ 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 appdata *ad = (struct appdata *)data;
+
+ int result_cnt = 0;
+ int ret = 0;
+ int i = 0;
+ int func_ret = SEARCH_RET_SEARCH_SUCCESS;
+
+ struct search_item_sel *sel_mem = NULL;
+ Elm_Object_Item *git = NULL;
+ Evas_Object *glist;
+
+ 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;
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+
+ /* 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 search result to genlist */
+ for (i = 0; i < result_cnt; i++) {
+
+ if(i == limit -1)
+ break;
+
+ item = NULL;
+ item = (Mitem*)g_list_nth_data(p_media_list, i);
+
+ if(item == NULL) {
+ break;
+ }
+
+ sel_mem_info = (struct search_item_sel *)calloc(1,
+ sizeof(struct search_item_sel));
+
+ sel_mem_info->type = type;
+
+ 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,
+ &is_word_in_str),
+ MAX_LENGTH_PER_LINE - 1);
+ SEARCH_FREE(markup_text_1line);
+ }
+
+ snprintf(sel_mem_info->main_id, MAX_LENGTH_PER_ID, "%d",
+ item->type);
+
+ snprintf(sel_mem_info->path, MAX_LENGTH_PER_PATH - 1, "%s",
+ item->file_url);
+
+ elm_genlist_item_append(glist,
+ (ad->itc_pslist_1line),
+ sel_mem_info,
+ ad->gl_result_group_item
+ [type],
+ ELM_GENLIST_ITEM_NONE,
+ search_gl_phone_result_sel,
+ ad);
+ sel_mem_info = NULL;
+ }
+
+ /* 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);
+ }
+
+ g_list_free(p_media_list);
+ p_media_list = NULL;
+
+ /* 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);
+ }
+
+out_func:
+ SEARCH_FUNC_END;
+ return SEARCH_RET_SEARCH_SUCCESS;
+}
+
+
+int search_sql_image_search_result_by_api(int type, int offset, int limit,
+ void *data)
+{
+ SEARCH_FUNC_START;
+
+ int ret;
+
+ ret = __search_sql_media_search_result_by_api(type,
+ offset,
+ limit,
+ MINFO_ITEM_IMAGE,
+ data);
+
+ SEARCH_FUNC_END;
+
+ return ret;
+}
+
+int search_sql_video_search_result_by_api(int type, int offset, int limit,
+ void *data)
+{
+ SEARCH_FUNC_START;
+
+ int ret;
+
+ ret = __search_sql_media_search_result_by_api(type,
+ offset,
+ limit,
+ MINFO_ITEM_VIDEO,
+ data);
+
+ SEARCH_FUNC_END;
+
+ return ret;
+}
+
+int search_sql_music_search_result_by_api(int type, int offset, int limit,
+ void *data)
+{
+ SEARCH_FUNC_START;
+
+ struct appdata *ad = (struct appdata *)data;
+
+ int loop_cnt = 0;
+ int ret = SEARCH_RET_SEARCH_NONE;
+ int i = 0;
+ int rc = 0;
+
+ struct search_item_sel *sel_mem = NULL;
+ Elm_Object_Item *git = NULL;
+
+ struct search_item_sel *sel_mem_info = NULL;
+ bool is_word_in_str;
+
+ AudioHandleType *handle = NULL;
+
+ 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;
+ }
+
+ 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);
+
+ 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;
+
+ 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);
+
+ if( audio_id == NULL) {
+ SEARCH_DEBUG_WARNING("audio_id value error. loop break");
+ break;
+ }
+
+ ret = SEARCH_RET_SEARCH_SUCCESS;
+
+ if ((loop_cnt == 0) && (offset == 0)) {
+ /* Set group title */
+ sel_mem = (struct search_item_sel *)calloc(1,
+ sizeof(struct search_item_sel));
+
+ sel_mem->type = type;
+
+ git = elm_genlist_item_append(ad->search_gl,
+ (ad->itc_grouptitle),
+ sel_mem,
+ (Elm_Object_Item *) NULL,
+ ELM_GENLIST_ITEM_GROUP,
+ NULL, NULL);
+
+ ad->gl_result_group_item[type] = git;
+ }
+
+ sel_mem_info = (struct search_item_sel *)calloc(1,
+ sizeof(struct search_item_sel));
+
+ sel_mem_info->type = type;
+
+ if ((title) && (strlen(title) > 0)) {
+ char* markup_text_1line = elm_entry_utf8_to_markup(title);
+
+ 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);
+ }
+
+ 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);
+ }
+
+ 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 - 1, "%s", audio_id);
+
+ strncpy(sel_mem_info->path, pathname, MAX_LENGTH_PER_PATH);
+
+ 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;
+ }
+ }
+
+ /* Set more title to genlist (under 'search all') */
+ if (loop_cnt == limit) {
+ ad->cate_info[type].next_point = offset + loop_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);
+ }
+
+out_func:
+
+ audio_svc_search_item_free(handle);
+
+ SEARCH_FUNC_END;
+
+ return ret;
+}
+
+ail_cb_ret_e __search_sql_menu_search_result_cb(
+ 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;
+
+ int type = SEARCH_TYPE_PHONE_MENU;
+
+ 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++;
+ return AIL_CB_RET_CONTINUE;
+ }
+
+ if(ad->cate_info[type].next_point <
+ ad->cate_info[type].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;
+
+ /********** START : set search result to sel_mem_info buf ************/
+
+ char *name = NULL;
+ char *package = NULL;
+
+ 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++;
+ SEARCH_FREE(sel_mem_info);
+ return AIL_CB_RET_CONTINUE;
+ }
+
+ strncpy(sel_mem_info->path, package, MAX_LENGTH_PER_PATH - 1);
+ }
+
+ 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),
+ 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) {
+ /* 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);
+ }
+
+ /********** END : set search result to sel_mem_info buf *************/
+
+ elm_genlist_item_append(ad->search_gl,
+ (ad->itc_pslist_1line),
+ 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++;
+
+ ret = AIL_CB_RET_CONTINUE;
+
+ } else if (ad->cate_info[type].next_point ==
+ ad->cate_info[type].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) {
+
+ char *package = NULL;
+
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+ if ((package) && (strlen(package) > 0) && (strcmp(package, SEARCHPKG) == 0)) {
+ 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;
+
+ 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);
+
+ ret = AIL_CB_RET_CANCEL;
+ } else {
+ SEARCH_DEBUG_WARNING
+ ("__search_sql_memo_search_result_cb wrong index : %d",
+ ad->cate_info[type].next_point);
+
+ ret = AIL_CB_RET_CANCEL;
+ }
+
+ SEARCH_FUNC_END;
+
+ return ret;
+}
+
+int search_sql_menu_search_result_by_api(int type, int offset, int limit,
+ char *keyword, void *data)
+{
+ SEARCH_FUNC_START;
+
+ struct appdata *ad = (struct appdata *)data;
+
+ int cnt = 0;
+ int ret = 0;
+
+ ail_filter_h filter;
+ ail_error_e rc;
+
+ 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);
+ if (rc != AIL_ERROR_OK) {
+ SEARCH_DEBUG_WARNING("menu search - ail_filter_add_str error : %d", rc);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
+
+ rc = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
+ if (rc != AIL_ERROR_OK) {
+ SEARCH_DEBUG_WARNING("menu search - ail_filter_add_bool error : %d", rc);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
+
+ rc = ail_filter_count_appinfo(filter, &cnt);
+ if( rc != AIL_ERROR_OK) {
+ SEARCH_DEBUG_WARNING("menu search - ail_filter_count_appinfo error : %d", rc);
+ ret = SEARCH_RET_SEARCH_FAIL;
+ goto out_func;
+ }
+
+ ad->cate_info[type].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);
+ 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) {
+ ret = SEARCH_RET_SEARCH_NONE;
+ } else {
+ ret = SEARCH_RET_SEARCH_SUCCESS;
+ }
+ } else {
+ ret = SEARCH_RET_SEARCH_NONE;
+ }
+
+out_func:
+ ail_filter_destroy(filter);
+
+ SEARCH_FUNC_END;
+
+ return ret;
+}
+
+int search_sql_msg_search_result_by_api(int type, int offset, int limit,
+ void *data)
+{
+ SEARCH_FUNC_START;
+
+ struct appdata *ad = (struct appdata *)data;
+
+ int loop_cnt = 0;
+ int ret = 0;
+
+ struct search_item_sel *sel_mem = NULL;
+ Elm_Object_Item *git = NULL;
+
+ struct search_item_sel *sel_mem_info = NULL;
+ bool is_word_in_str;
+
+ Evas_Object *glist;
+
+ 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_SEARCH_CONDITION_S searchCon = {0,};
+
+ searchCon.msgType = MSG_TYPE_INVALID;
+ searchCon.folderId = MSG_ALLBOX_ID;
+ searchCon.pSearchVal = ad->search_word;
+
+ err = msg_search_message(ad->msg_handle, &searchCon, offset, limit, &msgList);
+
+ if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
+ SEARCH_DEBUG_WARNING("msg_search_message is failed : %d", err);
+ return SEARCH_RET_SEARCH_FAIL;
+ }
+
+ if (msgList.nCount <= 0) {
+ SEARCH_DEBUG_WARNING("no msg search result");
+ ret = SEARCH_RET_SEARCH_NONE;
+ } 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 search result to genlist */
+
+ if(msgList.nCount < limit) {
+ loop_cnt = msgList.nCount;
+ is_more_btn = false;
+ } else {
+ loop_cnt = limit-1;
+ is_more_btn = true;
+ }
+
+ /********** START : set search result to sel_mem_info buf ************/
+
+ for (i = 0; i < loop_cnt; i++) {
+ const char *text_1line = NULL;
+ const char *text_2line = NULL;
+ const char *msg_address = NULL;
+ const char *markup_keyword = NULL;
+
+ sel_mem_info = (struct search_item_sel *)
+ calloc(1,sizeof(struct search_item_sel));
+ sel_mem_info->type = type;
+
+ snprintf(sel_mem_info->main_id, MAX_LENGTH_PER_ID - 1, "%d", msg_get_message_id(msgList.msgInfo[i]));
+
+ /* 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,
+ &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,
+ &is_word_in_title);
+ }
+
+ 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,
+ &is_word_in_title);
+
+ 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);
+ }
+
+ /* Set 2nd line string */
+ address_cnt = msg_get_address_count(msgList.msgInfo[i]);
+
+ for(j = 0; j < address_cnt; j++) {
+
+ 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 ((text_2line) && (strlen(text_2line) > 0)) {
+ char* markup_text_2line = NULL;
+
+ 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 ((is_word_in_title) || (is_word_in_str)) {
+ break;
+ }
+ }
+
+ elm_genlist_item_append(glist,
+ (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;
+ }
+
+ msg_release_message_list(&msgList);
+
+ /* Set more title to genlist (under 'search all') */
+ if (is_more_btn) {
+ ad->cate_info[type].next_point = offset + limit - 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);
+ }
+
+ ret = SEARCH_RET_SEARCH_SUCCESS;
+ }
+
+ SEARCH_FUNC_END;
+ return ret;
+}
+