diff options
Diffstat (limited to 'src/ps_makeupviews.cpp')
-rwxr-xr-x | src/ps_makeupviews.cpp | 587 |
1 files changed, 587 insertions, 0 deletions
diff --git a/src/ps_makeupviews.cpp b/src/ps_makeupviews.cpp new file mode 100755 index 0000000..a46413d --- /dev/null +++ b/src/ps_makeupviews.cpp @@ -0,0 +1,587 @@ +/* + * 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 "ps_searcher.h" +#include "ps_app_interface.h" + +static char *__search_get_phone_category_name(int type) +{ + SEARCH_FUNC_START; + + char* name = NULL; + + switch(type) { + + case SEARCH_TYPE_PHONE_CONTACTS: + { + name = dgettext("sys_string", "IDS_COM_BODY_CONTACTS"); + } + break; + case SEARCH_TYPE_PHONE_MSG: + { + name = dgettext("sys_string", "IDS_COM_BODY_MESSAGES"); + } + break; + case SEARCH_TYPE_PHONE_EMAIL: + { + name = dgettext("sys_string", "IDS_COM_BODY_EMAIL"); + } + break; + case SEARCH_TYPE_PHONE_IMAGES: + { + name = dgettext("sys_string", "IDS_COM_BODY_IMAGES"); + } + break; + case SEARCH_TYPE_PHONE_MUSIC: + { + name = dgettext("sys_string", "IDS_COM_BODY_MUSIC"); + } + break; + case SEARCH_TYPE_PHONE_VIDEO: + { + name = dgettext("sys_string", "IDS_COM_BODY_VIDEOS"); + } + break; + case SEARCH_TYPE_PHONE_CALENDAR: + { + name = dgettext("sys_string", "IDS_COM_BODY_CALENDAR"); + } + break; + case SEARCH_TYPE_PHONE_MEMO: + { + name = dgettext("sys_string", "IDS_COM_BODY_MEMO"); + } + break; + case SEARCH_TYPE_PHONE_MENU: + { + name = dgettext("sys_string", "IDS_COM_BODY_APPLICATIONS"); + } + break; + } + + return name; +} + + +static Eina_Bool __search_gl_state_get(void *data, Evas_Object * obj, + const char *part) +{ + return EINA_FALSE; +} + +static char *__search_gl_label_get(void *data, Evas_Object * obj, + const char *part) +{ + if (data == NULL) { + return g_strdup(""); + } + + char *buf; + struct search_item_sel *sel_mem_info = (struct search_item_sel *)data; + + if (!SEARCH_STRCMP(part, "elm.text") || !SEARCH_STRCMP(part, "elm.text.1")) { + buf = g_strdup(sel_mem_info->main_buf); + } else if (!SEARCH_STRCMP(part, "elm.text.sub") || !SEARCH_STRCMP(part, "elm.text.2")) { + buf = g_strdup(sel_mem_info->sub_buf); + } else { + buf = NULL; + } + + return buf; +} + +static char *__search_gl_label_get_title(void *data, Evas_Object * obj, + const char *part) +{ + SEARCH_FUNC_START; + + char* category_name = NULL; + + struct search_item_sel *sel_mem = (struct search_item_sel *)data; + + category_name = __search_get_phone_category_name(sel_mem->type); + + if(category_name) + return strdup(category_name); + else + return strdup(""); +} + +static char *__search_gl_label_get_more(void *data, Evas_Object * obj, + const char *part) +{ + return strdup(gettext("IDS_SSEARCH_BODY_MORE_RESULTS")); +} + +static void __search_gl_del(void *data, Evas_Object * obj) +{ + SEARCH_FUNC_START; + + struct search_item_sel *sel_mem_info = (struct search_item_sel *)data; + + SEARCH_FREE(sel_mem_info); + + return; +} + +void search_gl_phone_result_sel(void *data, Evas_Object * obj, void *event_info) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + struct search_item_sel *cur_category_mem; + Elm_Object_Item *it = (Elm_Object_Item *) event_info; + int ret = 0; + + cur_category_mem = + (struct search_item_sel *)elm_object_item_data_get(it); + if (cur_category_mem == NULL) { + return; + } + + switch (cur_category_mem->type) { + + case SEARCH_TYPE_PHONE_CONTACTS: + search_launch_contact_view(ad, cur_category_mem); + break; + + case SEARCH_TYPE_PHONE_MSG: + search_launch_msg_view(ad, cur_category_mem); + break; + + case SEARCH_TYPE_PHONE_EMAIL: + search_launch_email_view(ad, cur_category_mem); + break; + + case SEARCH_TYPE_PHONE_IMAGES: + search_launch_image_view(ad, cur_category_mem); + break; + + case SEARCH_TYPE_PHONE_VIDEO: + search_launch_video_view(ad, cur_category_mem); + break; + + case SEARCH_TYPE_PHONE_MUSIC: + search_launch_music_view(ad, cur_category_mem); + break; + + case SEARCH_TYPE_PHONE_CALENDAR: + search_launch_calendar_view(ad, cur_category_mem); + break; + + case SEARCH_TYPE_PHONE_MEMO: + search_launch_memo_view(ad, cur_category_mem); + break; + + case SEARCH_TYPE_PHONE_MENU: + search_launch_menu_view(ad, cur_category_mem); + break; + + default: + break; + } + + elm_genlist_item_selected_set(it, EINA_FALSE); + + SEARCH_FUNC_END; +} + +void search_result_gl_init(void *data) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + Evas_Object *genlist; + + + if (ad->itc_pslist_1line == NULL) { + ad->itc_pslist_1line = elm_genlist_item_class_new(); + ad->itc_pslist_1line->item_style = "1text.2"; + ad->itc_pslist_1line->func.text_get = __search_gl_label_get; + ad->itc_pslist_1line->func.content_get = NULL; + ad->itc_pslist_1line->func.state_get = __search_gl_state_get; + ad->itc_pslist_1line->func.del = __search_gl_del; + } + + + if (ad->itc_pslist_2line == NULL) { + ad->itc_pslist_2line = elm_genlist_item_class_new(); + ad->itc_pslist_2line->item_style = "2text.8"; + ad->itc_pslist_2line->func.text_get = __search_gl_label_get; + ad->itc_pslist_2line->func.content_get = NULL; + ad->itc_pslist_2line->func.state_get = __search_gl_state_get; + ad->itc_pslist_2line->func.del = __search_gl_del; + } + + if (ad->itc_grouptitle == NULL) { + ad->itc_grouptitle = elm_genlist_item_class_new(); + ad->itc_grouptitle->item_style = "grouptitle"; + ad->itc_grouptitle->func.text_get = __search_gl_label_get_title; + ad->itc_grouptitle->func.state_get = __search_gl_state_get; + ad->itc_grouptitle->func.del = __search_gl_del; + } + + if (ad->itc_listmore == NULL) { + ad->itc_listmore = elm_genlist_item_class_new(); + ad->itc_listmore->item_style = "1text.2"; + ad->itc_listmore->func.text_get = __search_gl_label_get_more; + ad->itc_listmore->func.state_get = __search_gl_state_get; + ad->itc_listmore->func.del = __search_gl_del; + } + + ad->search_gl = NULL; + + genlist = elm_genlist_add(ad->navi_bar); + + // To use multiline textblock/entry/editfield in genlist, set height_for_width mode + // then the item's height is calculated while the item's width fits to genlist width. + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + elm_genlist_tree_effect_enabled_set(genlist, EINA_TRUE); + + ad->search_gl = genlist; + + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, + EVAS_HINT_FILL); + SEARCH_FUNC_END; +} + +void search_result_gl_deinit(void *data) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + + if (ad->itc_pslist_1line != NULL) + elm_genlist_item_class_free(ad->itc_pslist_1line); + + if (ad->itc_pslist_2line != NULL) + elm_genlist_item_class_free(ad->itc_pslist_2line); + + if (ad->itc_grouptitle != NULL) + elm_genlist_item_class_free(ad->itc_grouptitle); + + if (ad->itc_listmore != NULL) + elm_genlist_item_class_free(ad->itc_listmore); + + SEARCH_FUNC_END; +} + +static int __search_gl_set_phone_search_result(int type, int offset, char *keyword, + void *data) +{ + SEARCH_FUNC_START; + + int rc = 0; + int category = 0; + int loop_cnt = 0; + + int ret = 0; + + int sel_cnt = SEARCH_CATEGORY_LIST_MORE_CNT + 1; + int func_ret = 1; + + struct appdata *ad = (struct appdata *)data; + Evas_Object *glist; + + ad->cate_info[type].offset = offset; + + if (offset == 0) { + ad->cate_info[type].next_point = 0; + } + + switch (type) { + + case SEARCH_TYPE_PHONE_CONTACTS: + { + func_ret = + search_sql_contact_search_result_by_api(type, + offset, + sel_cnt, + data); + } + break; + + case SEARCH_TYPE_PHONE_MSG: + { + if (ad->msg_handle != NULL) { + func_ret = + search_sql_msg_search_result_by_api(type, + offset, + sel_cnt, + data); + } + } + break; + + case SEARCH_TYPE_PHONE_EMAIL: + { + func_ret = + search_sql_email_search_result_by_api(type, + offset, + sel_cnt, + data); + } + break; + case SEARCH_TYPE_PHONE_IMAGES: + { + if (ad->media_handle != NULL ) { + func_ret = + search_sql_image_search_result_by_api(type, + offset, + sel_cnt, + data); + } + } + break; + case SEARCH_TYPE_PHONE_MUSIC: + { + if (ad->media_handle != NULL ) { + func_ret = + search_sql_music_search_result_by_api(type, + offset, + sel_cnt, + data); + } + } + break; + case SEARCH_TYPE_PHONE_VIDEO: + { + if (ad->media_handle != NULL ) { + func_ret = + search_sql_video_search_result_by_api(type, + offset, + sel_cnt, + data); + } + } + break; + + case SEARCH_TYPE_PHONE_CALENDAR: + { + func_ret = + search_sql_calendar_search_result_by_api(type, + offset, + sel_cnt, + data); + } + break; + + case SEARCH_TYPE_PHONE_MEMO: + { + func_ret = + search_sql_memo_search_result_by_api(type, + offset, + sel_cnt, + data); + } + break; + + case SEARCH_TYPE_PHONE_MENU: + { + func_ret = + search_sql_menu_search_result_by_api(type, + offset, + sel_cnt, + keyword, + data); + } + break; + } + + SEARCH_FUNC_END; + + return func_ret; +} + +void search_gl_result_more_item_append_cb(void *data, Evas_Object * obj, + void *event_info) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + Elm_Object_Item *it = (Elm_Object_Item *) event_info; + + int ret = 0; + + struct search_item_sel *sel_mem = + (search_item_sel *) elm_object_item_data_get(it); + struct search_item_sel *sel_mem_info = NULL; + struct search_item_sel *sel_mem_more = NULL; + + char* escape_added_keyword = NULL; + SEARCH_MALLOC(escape_added_keyword, strlen(ad->search_word)*2+5, char); + memset(escape_added_keyword, 0x0, strlen(ad->search_word)*2+5); + + int rc = 0, i = 0; + int type = sel_mem->type; + int offset = ad->cate_info[type].next_point; + + search_sql_make_keyword_bind_value(ad->search_word, escape_added_keyword, SEARCH_SQL_BIND_TYPE_DUPLEX); + + elm_object_item_del(it); + + __search_gl_set_phone_search_result(type, offset, escape_added_keyword, ad); + + SEARCH_FUNC_END; +} + +static int __search_set_phone_result_list(struct appdata *ad, bool is_input_keyword, const char* search_keyword) +{ + SEARCH_FUNC_START; + + int i = 0, is_search_result = 0, ret = 0; + + if (is_input_keyword == false) { + return SEARCH_RET_SEARCH_NONE; + } else { + + int offset = 0; + + while (i < PHONE_CATEGORY_LIST_CNT) { + ret = __search_gl_set_phone_search_result(i, + offset, + (char*)search_keyword, + ad); + if (ret == SEARCH_RET_SEARCH_SUCCESS) { + is_search_result = 1; + } + + i++; + } + + if(is_search_result == 0) { + return SEARCH_RET_SEARCH_NONE; + } else { + return SEARCH_RET_SEARCH_SUCCESS; + } + } +} + +Eina_Bool search_set_result_list(void *data) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + char *text; + int ret = 0; + bool is_input_keyword = false; + char* escape_added_keyword = NULL; + int bind_type = 0; + int search_ret = SEARCH_RET_SEARCH_NONE; + + SEARCH_ASSERT_IF(!ad); + + text = elm_entry_markup_to_utf8(elm_object_text_get(ad->search_entry)); + + SEARCH_FREE(ad->not_markup_search_word); + SEARCH_FREE(ad->search_word); + + if((text) && (strlen(text) > 0)) { + ad->not_markup_search_word = strdup(elm_object_text_get(ad->search_entry)); + ad->search_word = text; + + SEARCH_MALLOC(escape_added_keyword, strlen(ad->search_word)*2+5, char); + memset(escape_added_keyword, 0x0, strlen(ad->search_word)*2+5); + + bind_type = SEARCH_SQL_BIND_TYPE_DUPLEX; + + search_sql_make_keyword_bind_value(ad->search_word, escape_added_keyword, bind_type); + is_input_keyword = true; + + elm_genlist_clear(ad->search_gl); + + search_ret = __search_set_phone_result_list(ad, is_input_keyword, ad->search_word); + } + + if(search_ret == SEARCH_RET_SEARCH_SUCCESS) { + search_layout_set_search_list(ad); + } else { + search_layout_set_search_no_result(ad); + } + + SEARCH_FREE(escape_added_keyword); + + SEARCH_FUNC_END; + + return EINA_FALSE; +} + +void search_layout_set_search_list(void* data) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + + if (elm_object_part_content_get(ad->sb_layout,"list_noresult")) { + elm_object_part_content_unset(ad->sb_layout,"list_noresult"); + evas_object_hide(ad->noresult_view); + + elm_object_part_content_set(ad->sb_layout, "list", ad->search_gl); + evas_object_show(ad->search_gl); + } + + elm_genlist_item_show(elm_genlist_first_item_get(ad->search_gl), ELM_GENLIST_ITEM_SCROLLTO_TOP); + SEARCH_FUNC_END; + + return; +} + +void search_layout_set_search_no_result(void* data) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + + if (elm_object_part_content_get(ad->sb_layout,"list")) { + elm_object_part_content_unset(ad->sb_layout, "list"); + evas_object_hide(ad->search_gl); + + elm_object_part_content_set(ad->sb_layout,"list_noresult", ad->noresult_view); + evas_object_show(ad->noresult_view); + } + + SEARCH_FUNC_END; + + return; +} + +int search_layout_get_content_list_set_status(void* data) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + int ret; + + if (elm_object_part_content_get(ad->sb_layout,"list")) { + ret = SEARCH_RET_SUCCESS; + } else { + ret = SEARCH_RET_FAIL; + } + + SEARCH_FUNC_END; + + return ret; +} + + |