From 705b925c45567f2fc5a002fd3fd89d94e66bc2f6 Mon Sep 17 00:00:00 2001 From: Junghyun Kim Date: Tue, 21 Aug 2012 20:20:51 +0900 Subject: Update changed code --- CMakeLists.txt | 15 +- data/.goutputstream-A2OL5V | 18 - data/groups/search_result.edc | 2 +- data/images/B10_Phone.png | Bin 3054 -> 0 bytes data/images/B10_Phone_press.png | Bin 3054 -> 0 bytes data/images/B10_btn_icon_Phone.png | Bin 0 -> 2964 bytes data/images/B10_btn_icon_Phone_press.png | Bin 0 -> 2964 bytes data/images/B10_icon_list_favorite.png | Bin 0 -> 3631 bytes data/images/B10_icon_list_memorycard.png | Bin 0 -> 3393 bytes data/org.tizen.smartsearch.desktop.in | 29 - data/org.tizen.smartsearch.xml | 31 + data/smartsearch-color.edc | 6 +- debian/changelog | 8 + debian/control | 11 +- debian/rules | 2 + include/common_util.h | 6 +- include/ps_app_interface.h | 7 +- include/ps_debug_util.h | 8 +- include/ps_makeupviews.h | 16 +- include/ps_searcher.h | 60 +- include/search_bar.h | 8 +- include/smartsearch.h | 95 +- include/smartsearch_define.h | 102 +- packaging/org.tizen.smartsearch.spec | 24 +- po/CMakeLists.txt | 2 +- po/ar.po | 6 + po/bg.po | 6 + po/ca.po | 6 + po/cs.po | 6 + po/da.po | 6 + po/de.po | 27 - po/de_DE.po | 6 +- po/el.po | 27 - po/el_GR.po | 6 +- po/en.po | 6 +- po/en_US.po | 29 +- po/es.po | 27 - po/es_ES.po | 6 +- po/fi.po | 6 + po/fr.po | 27 - po/fr_FR.po | 6 +- po/he.po | 6 + po/hi.po | 6 + po/hr.po | 6 + po/hu.po | 6 + po/id.po | 6 + po/it.po | 27 - po/it_IT.po | 6 +- po/ja.po | 27 - po/ja_JP.po | 6 +- po/ko.po | 27 - po/ko_KR.po | 6 +- po/lt.po | 6 + po/lv.po | 6 + po/ms.po | 6 + po/nl.po | 27 - po/nl_NL.po | 6 +- po/no.po | 6 + po/pl.po | 6 + po/pt.po | 27 - po/pt_PT.po | 6 +- po/ro.po | 6 + po/ru.po | 27 - po/ru_RU.po | 6 +- po/sk.po | 6 + po/sl.po | 6 + po/sr.po | 6 + po/sv.po | 6 + po/th.po | 6 + po/tk.po | 27 - po/tr_TR.po | 6 +- po/uk.po | 6 + po/vi.po | 6 + po/zh_CN.po | 6 +- po/zh_HK.po | 6 +- po/zh_TW.po | 6 +- src/common_util.cpp | 30 +- src/ps_app_interface.cpp | 377 ++++-- src/ps_makeupviews.cpp | 1085 +++++++++++----- src/ps_searcher.cpp | 2015 +++++++++++++++++++----------- src/search_bar.cpp | 89 +- src/smartsearch.cpp | 564 +++++---- 82 files changed, 3241 insertions(+), 1929 deletions(-) delete mode 100755 data/.goutputstream-A2OL5V delete mode 100755 data/images/B10_Phone.png delete mode 100755 data/images/B10_Phone_press.png create mode 100755 data/images/B10_btn_icon_Phone.png create mode 100755 data/images/B10_btn_icon_Phone_press.png create mode 100755 data/images/B10_icon_list_favorite.png create mode 100755 data/images/B10_icon_list_memorycard.png delete mode 100755 data/org.tizen.smartsearch.desktop.in create mode 100755 data/org.tizen.smartsearch.xml create mode 100755 po/ar.po create mode 100755 po/bg.po create mode 100755 po/ca.po create mode 100755 po/cs.po create mode 100755 po/da.po delete mode 100755 po/de.po delete mode 100755 po/el.po delete mode 100755 po/es.po create mode 100755 po/fi.po delete mode 100755 po/fr.po create mode 100755 po/he.po create mode 100755 po/hi.po create mode 100755 po/hr.po create mode 100755 po/hu.po create mode 100755 po/id.po delete mode 100755 po/it.po delete mode 100755 po/ja.po delete mode 100755 po/ko.po create mode 100755 po/lt.po create mode 100755 po/lv.po create mode 100755 po/ms.po delete mode 100755 po/nl.po create mode 100755 po/no.po create mode 100755 po/pl.po delete mode 100755 po/pt.po create mode 100755 po/ro.po delete mode 100755 po/ru.po create mode 100755 po/sk.po create mode 100755 po/sl.po create mode 100755 po/sr.po create mode 100755 po/sv.po create mode 100755 po/th.po delete mode 100755 po/tk.po create mode 100755 po/uk.po create mode 100755 po/vi.po diff --git a/CMakeLists.txt b/CMakeLists.txt index 1806e34..896acbb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ pkg_check_modules(pkgs REQUIRED ecore-imf ecore-input ecore-x - ui-gadget + ui-gadget-1 utilX x11 contacts-service @@ -34,12 +34,15 @@ pkg_check_modules(pkgs REQUIRED memo icu-i18n email-service - libmedia-service - appsvc msg-service libsoup-2.4 json-glib-1.0 glib-2.0 + capi-appfw-application + capi-appfw-app-manager + capi-web-favorites + capi-content-media-content + libxml-2.0 ) @@ -53,7 +56,7 @@ SET(BINDIR "${PREFIX}/bin") SET(RESDIR "${PREFIX}/res") SET(DATADIR "${PREFIX}/data") SET(LOCALEDIR "${RESDIR}/locale") -SET(ICONDIR "${RESDIR}/icons/default/small") +SET(ICONDIR "/opt/share/icons/default/small") SET(EDJDIR "${RESDIR}/edje") ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") @@ -93,8 +96,8 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/images/ DESTINATION res/icons # install desktop file & icon SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -CONFIGURE_FILE(data/${SMARTSEARCH_PKG_NAME}.desktop.in ${SMARTSEARCH_PKG_NAME}.desktop) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/${SMARTSEARCH_PKG_NAME}.desktop DESTINATION /opt/share/applications/) +#CONFIGURE_FILE(data/${SMARTSEARCH_PKG_NAME}.desktop.in ${SMARTSEARCH_PKG_NAME}.desktop) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${SMARTSEARCH_PKG_NAME}.xml DESTINATION /opt/share/packages/) INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/images/${SMARTSEARCH_PKG_NAME}.png DESTINATION ${ICONDIR}) # install ini file diff --git a/data/.goutputstream-A2OL5V b/data/.goutputstream-A2OL5V deleted file mode 100755 index d5eabbd..0000000 --- a/data/.goutputstream-A2OL5V +++ /dev/null @@ -1,18 +0,0 @@ -Name=Smart search -Type=Application -Exec=${PREFIX}/bin/smartsearch -Icon=${SMARTSEARCH_PKG_NAME}.png -Comment=Smart search Application -X-SLP-BaseLayoutWidth=720 -X-SLP-BaseLayoutHeight=1280 -X-SLP-IsHorizontalScale=True -Visible=True -X-SLP-TaskManage=True -X-SLP-Multiple=False -X-SLP-Service=search_all -X-SLP-SVC= slp.appsvc.operation.SEARCH:NULL:NULL - -Name[en_US]=Smart search -Name[nl_NL]=Slim zoeken -Name[de_DE]=Smart Search -Name[zh_HK]= \ No newline at end of file diff --git a/data/groups/search_result.edc b/data/groups/search_result.edc index 83c294b..fe4a03d 100755 --- a/data/groups/search_result.edc +++ b/data/groups/search_result.edc @@ -105,7 +105,7 @@ group { description { state: "default" 0.0; visible: 1; - min: 16 0; + min: 0 0; fixed: 1 0; align: 0 0.5; rel1 { relative: 1.0 0.0; to: "searchbar_area_category";} diff --git a/data/images/B10_Phone.png b/data/images/B10_Phone.png deleted file mode 100755 index 156842c..0000000 Binary files a/data/images/B10_Phone.png and /dev/null differ diff --git a/data/images/B10_Phone_press.png b/data/images/B10_Phone_press.png deleted file mode 100755 index 156842c..0000000 Binary files a/data/images/B10_Phone_press.png and /dev/null differ diff --git a/data/images/B10_btn_icon_Phone.png b/data/images/B10_btn_icon_Phone.png new file mode 100755 index 0000000..34dc56e Binary files /dev/null and b/data/images/B10_btn_icon_Phone.png differ diff --git a/data/images/B10_btn_icon_Phone_press.png b/data/images/B10_btn_icon_Phone_press.png new file mode 100755 index 0000000..34dc56e Binary files /dev/null and b/data/images/B10_btn_icon_Phone_press.png differ diff --git a/data/images/B10_icon_list_favorite.png b/data/images/B10_icon_list_favorite.png new file mode 100755 index 0000000..6626b5b Binary files /dev/null and b/data/images/B10_icon_list_favorite.png differ diff --git a/data/images/B10_icon_list_memorycard.png b/data/images/B10_icon_list_memorycard.png new file mode 100755 index 0000000..836dfc1 Binary files /dev/null and b/data/images/B10_icon_list_memorycard.png differ diff --git a/data/org.tizen.smartsearch.desktop.in b/data/org.tizen.smartsearch.desktop.in deleted file mode 100755 index d125e52..0000000 --- a/data/org.tizen.smartsearch.desktop.in +++ /dev/null @@ -1,29 +0,0 @@ -Name=Search -Type=Application -Exec=${PREFIX}/bin/smartsearch -Icon=${SMARTSEARCH_PKG_NAME}.png -Comment=Search Application -nodisplay=False -Version=0.3.15 -X-TIZEN-TaskManage=True -X-TIZEN-Multiple=False -X-TIZEN-Service=search_all -X-TIZEN-SVC= http://tizen.org/appsvc/operation/search|NULL|NULL -X-TIZEN-Removable=false - -Name[en_US]=Search -Name[nl_NL]=Zoeken -Name[de_DE]=Smart Search -Name[zh_HK]=搜尋 -Name[zh_CN]=搜索 -Name[ru_RU]=Поиск -Name[ko_KR]=검색 -Name[zh_TW]=搜尋 -Name[ja_JP]=検索 -Name[es_ES]=Buscar -Name[el_GR]=Αναζήτηση -Name[it_IT]=Cerca -Name[tr_TR]=Akıllı Arama -Name[pt_PT]=Procurar -Name[fr_FR]=Rechercher - diff --git a/data/org.tizen.smartsearch.xml b/data/org.tizen.smartsearch.xml new file mode 100755 index 0000000..051377a --- /dev/null +++ b/data/org.tizen.smartsearch.xml @@ -0,0 +1,31 @@ + + + + Junghyun Kim + Search Application + + org.tizen.smartsearch.png + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/smartsearch-color.edc b/data/smartsearch-color.edc index b53f63f..56209fe 100755 --- a/data/smartsearch-color.edc +++ b/data/smartsearch-color.edc @@ -13,8 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - - - -#define SEARCHBAR_BACKGROUND_COLOR_DEFAULT 36 36 36 255 +#define SEARCHBAR_BACKGROUND_COLOR_DEFAULT 215 225 232 255 diff --git a/debian/changelog b/debian/changelog index ede405a..4f1eb61 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +smartsearch (0.3.16-1) unstable; urgency=low + + * Apply changed feature + * Git: magnolia/apps/home/smartsearch + * Tag: smartsearch_0.3.16-1 + + -- Junghyun Kim Sat, 11 Aug 2012 01:01:42 +0900 + smartsearch (0.3.15-1) unstable; urgency=low * Fix keyword bug diff --git a/debian/control b/debian/control index 5e4422a..7d2d81c 100755 --- a/debian/control +++ b/debian/control @@ -1,8 +1,8 @@ Source: smartsearch Section: main Priority: extra -Maintainer: Junghyun Kim , Hyungdeuk Kim , Hakjoo ko -Uploaders: Junghyun Kim , Hyungdeuk Kim , Hakjoo ko +Maintainer: Junghyun Kim , Myungho Ham +Uploaders: Junghyun Kim , Myungho Ham Build-Depends: debhelper (>= 5), libglib2.0-dev, libappcore-efl-dev, @@ -20,14 +20,15 @@ Build-Depends: debhelper (>= 5), libslp-memo-dev, libicu-dev, email-service-dev, - libmedia-service-dev, libail-0-dev, - libappsvc-dev, libslp-msg-service-dev, libsoup2.4-dev, libjson-glib-dev, libxml2-dev, - libappsvc-dev + capi-appfw-application-dev, + capi-appfw-app-manager, + capi-web-favorites-dev, + capi-content-media-content-dev, Standards-Version: 0.1.0 Package: org.tizen.smartsearch diff --git a/debian/rules b/debian/rules index 4290b8e..ce445ce 100755 --- a/debian/rules +++ b/debian/rules @@ -24,6 +24,8 @@ else CXXFLAGS += -O2 endif +CFLAGS += -Wall -fPIC +CXXFLAGS += -fPIC LDFLAGS += -pie -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed configure: configure-stamp diff --git a/include/common_util.h b/include/common_util.h index 6ccea16..f30bf95 100755 --- a/include/common_util.h +++ b/include/common_util.h @@ -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. diff --git a/include/ps_app_interface.h b/include/ps_app_interface.h index 2a1e044..b2029b3 100755 --- a/include/ps_app_interface.h +++ b/include/ps_app_interface.h @@ -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. @@ -33,5 +33,6 @@ void search_launch_document_view(void *data, void *record_info); void search_launch_calendar_view(void *data, void *record_info); void search_launch_memo_view(void *data, void *record_info); void search_launch_menu_view(void *data, void *record_info); +void search_launch_browser_view(void *data, void *record_info); void search_launch_popup_error(int error_type, void *data); #endif diff --git a/include/ps_debug_util.h b/include/ps_debug_util.h index eb6b800..bfdd5e3 100755 --- a/include/ps_debug_util.h +++ b/include/ps_debug_util.h @@ -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. @@ -162,7 +162,7 @@ return ret;\ }\ }while(0) - + #endif #else diff --git a/include/ps_makeupviews.h b/include/ps_makeupviews.h index ae8d64f..5d7d8fa 100755 --- a/include/ps_makeupviews.h +++ b/include/ps_makeupviews.h @@ -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. @@ -26,9 +26,15 @@ void search_result_gl_init(void *data); void search_result_gl_deinit(void *data); void search_gl_phone_result_sel(void *data, Evas_Object * obj, void *event_info); void search_gl_result_more_item_append_cb(void *data, Evas_Object * obj, void *event_info); -Eina_Bool search_set_result_list(void *data); +int search_app_connect(void *data); +int search_app_disconnect(void *data); +void search_set_result_list(void *data); +void search_stop_search(void *data); void search_layout_set_search_list(void* data); void search_layout_set_search_no_result(void* data); int search_layout_get_content_list_set_status(void* data); - +Ecore_Thread* search_make_result_thread(void *data); +struct search_genlist_item_info* search_add_genlist_item(int type, + struct search_content_object *obj, Elm_Genlist_Item_Class *itc_style, void *data, + Elm_Object_Item *parent); #endif // __DEF_PS_MAKEUPVIEWS_H__ diff --git a/include/ps_searcher.h b/include/ps_searcher.h index f190739..df3e55e 100755 --- a/include/ps_searcher.h +++ b/include/ps_searcher.h @@ -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. @@ -15,12 +15,10 @@ */ +#ifndef __SEARCHSEARCHER_HEADER_H__ +#define __SEARCHSEARCHER_HEADER_H__ - - - -#ifndef __SEARCHSERVER_HEADER_H__ -#define __SEARCHSERVER_HEADER_H__ +#include "smartsearch.h" int search_sql_stmt_init(sqlite3_stmt * sql_stmt); @@ -29,31 +27,41 @@ int search_sql_stmt_finalize(sqlite3_stmt * stmt); int search_sql_prepare_stmt(sqlite3 *db_handle, const char *query, sqlite3_stmt ** stmt_out); -int search_sql_contact_search_result_by_api(int type, int offset, int limit, - void *data); +int search_sql_bind_text(sqlite3 *db_handle, sqlite3_stmt *sql_stmt, int col, char *data); + +int search_sql_bind_int(sqlite3 *db_handle, sqlite3_stmt *sql_stmt, int col, int 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); + +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); + +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); + +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); -int search_sql_msg_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); -int search_sql_email_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); -int search_sql_calendar_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); -int search_sql_memo_search_result_by_api(int type, int offset, int limit, - void *data); +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); -int search_sql_image_search_result_by_api(int type, int offset, int limit, - 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); -int search_sql_video_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); -int search_sql_music_search_result_by_api(int type, int offset, int limit, - void *data); -int search_sql_menu_search_result_by_api(int type, int offset, int limit, - char *keyword, void *data); +void search_sql_update_result_object(struct search_content_object* result_obj, sqlite3* db_handle, sqlite3_stmt** db_sql); #endif // __SEARCHSERVER_HEADER_H__ diff --git a/include/search_bar.h b/include/search_bar.h index 035e9f5..de71d2d 100755 --- a/include/search_bar.h +++ b/include/search_bar.h @@ -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. @@ -29,6 +29,6 @@ void search_searchbar_cb(void *data, Evas_Object * obj, void *event_info); void search_searchbar_entry_changed_cb(void *data, Evas_Object * obj, void *event_info); -Evas_Object *search_searchbar_category_icon_add(int cate_type, int press_type, Evas_Object *parent); +Evas_Object *search_searchbar_category_icon_add(char *img, Evas_Object *parent); #endif /* __DEF_SEARCH_BAR_H__ */ diff --git a/include/smartsearch.h b/include/smartsearch.h index 1edd84e..5c80cbf 100755 --- a/include/smartsearch.h +++ b/include/smartsearch.h @@ -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. @@ -32,14 +32,8 @@ #include #include #include -extern "C" { -} #include -#include -#include -#include -#include -#include +#include #include "smartsearch_define.h" #include "ps_debug_util.h" @@ -50,26 +44,75 @@ extern "C" { #include "util-func.h" #define _EDJ(x) elm_layout_edje_get(x) - + struct search_more_result{ int next_point; int offset; int loop_cnt; int result_cnt; + struct appdata *ad; +}; + +struct search_content_object { + int order; + Eina_Bool visible; + char *name; + int string_type; + int contents_type; + int category_type; + char *def_pkg_name; + char *obj_icon_path; + Elm_Object_Item *gl_result_grp; + struct search_more_result mr_info; +}; + +struct search_category_info { + char *btn_icon_path; + char *btn_icon_press_path; + char *popup_icon_path; + char *popup_press_icon_path; +}; + +struct search_genlist_item_info { + int type; + struct search_content_object *obj; + Elm_Genlist_Item_Class *itc_style; + void *data; + Elm_Object_Item *parent; +}; + +struct search_genlist_info { + struct search_genlist_item_info *group; + GList *itemlist; + struct search_genlist_item_info *more; +}; + +struct search_pipe_data { + int cmd; + struct search_genlist_info *result_list; + int search_ret; + struct search_content_object *obj; }; struct search_item_sel { - unsigned char type; + int type; char path[MAX_LENGTH_PER_PATH]; - char main_id[MAX_LENGTH_PER_ID]; char main_buf[MAX_LENGTH_PER_LINE]; char sub_buf[MAX_LENGTH_PER_LINE]; + char main_id[MAX_LENGTH_PER_ID]; + char icon1_path[MAX_LENGTH_PER_PATH]; + char icon2_path[MAX_LENGTH_PER_PATH]; +}; + +struct search_item_more_sel { + struct search_content_object *obj; }; struct appdata { Evas_Object *win_main; Evas_Object *layout_main; Evas_Object *navi_bar; + Elm_Object_Item *navi_it; double scale_factor; @@ -87,33 +130,41 @@ struct appdata { Evas_Object *cate_btn; Ecore_Idler *idler_search; Ecore_Idler *idler_create_ui; - + Ecore_Timer *search_timer; + int touch_x; int touch_y; Elm_Genlist_Item_Class *itc_pslist_1line; - Elm_Genlist_Item_Class *itc_pslist_2line; + Elm_Genlist_Item_Class *itc_pslist_1line_1icon; + Elm_Genlist_Item_Class *itc_pslist_1line_2icon; + Elm_Genlist_Item_Class *itc_pslist_2line_1icon; + Elm_Genlist_Item_Class *itc_pslist_2line_2icon; Elm_Genlist_Item_Class *itc_grouptitle; + Elm_Genlist_Item_Class *itc_label; Elm_Genlist_Item_Class *itc_listmore; - search_more_result cate_info[SEARCH_TYPE_PHONE_MAX]; + Ecore_Pipe *pipe; + Ecore_Thread *search_thread; + Eina_Condition condition; + Eina_Lock mutex; char *search_word; char *not_markup_search_word; int back_btn_type; + int search_category; Evas_Object *effect_layout; - ui_gadget *detail_ug; - - Elm_Object_Item *gl_result_group_item[PHONE_CATEGORY_LIST_CNT]; + ui_gadget_h detail_ug; sqlite3 *search_db_hd; - sqlite3_stmt *search_db_sql_stmt[SEARCH_STMT_MAX]; + sqlite3_stmt *search_db_sql[SEARCH_STMT_MAX]; + struct search_content_object result_obj[SEARCH_CONT_MAX]; + struct search_category_info category_info[SEARCH_CATE_MAX]; /* Handle List */ - MSG_HANDLE_T msg_handle; - MediaSvcHandle *media_handle; + msg_handle_t msg_handle; }; #endif diff --git a/include/smartsearch_define.h b/include/smartsearch_define.h index 2cf2609..c6bf078 100755 --- a/include/smartsearch_define.h +++ b/include/smartsearch_define.h @@ -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. @@ -15,29 +15,41 @@ */ - - - - #ifndef __DEF_SMARTSEARCH_DEFINE_H__ #define __DEF_SMARTSEARCH_DEFINE_H__ enum { - SEARCH_TYPE_PHONE_CONTACTS = 0, - SEARCH_TYPE_PHONE_MSG, - SEARCH_TYPE_PHONE_EMAIL, - SEARCH_TYPE_PHONE_IMAGES, - SEARCH_TYPE_PHONE_MUSIC, - SEARCH_TYPE_PHONE_VIDEO, - SEARCH_TYPE_PHONE_CALENDAR, - SEARCH_TYPE_PHONE_MEMO, - SEARCH_TYPE_PHONE_MENU, - SEARCH_TYPE_PHONE_MAX + SEARCH_OBJ_PHONE_CONTENTS = 0, + SEARCH_OBJ_APPLICATION, + SEARCH_OBJ_TYPE_MAX +}; + +enum { + SEARCH_CONT_PHONE_MIN = 0, + SEARCH_CONT_PHONE_CONTACTS = SEARCH_CONT_PHONE_MIN, + SEARCH_CONT_PHONE_MSG, + SEARCH_CONT_PHONE_EMAIL, + SEARCH_CONT_PHONE_IMAGES, + SEARCH_CONT_PHONE_MUSIC, + SEARCH_CONT_PHONE_VIDEO, + SEARCH_CONT_PHONE_CALENDAR, + SEARCH_CONT_PHONE_MEMO, + SEARCH_CONT_PHONE_MENU, + SEARCH_CONT_PHONE_BROWSER, + SEARCH_CONT_PHONE_MAX = SEARCH_CONT_PHONE_BROWSER, + SEARCH_CONT_MAX +}; + +enum { + SEARCH_CATE_PHONE = 0, + SEARCH_CATE_MAX }; enum { - SEARCH_TYPE_PHONE = 0, + SEARCH_GENLIST_GROUP = 0, + SEARCH_GENLIST_ITEM, + SEARCH_GENLIST_MORE }; enum { @@ -52,12 +64,6 @@ enum { BACK_BTN_TYPE_CLOSE }; -enum { - SEARCH_CATE_BTN_IMG_TYPE_UNPRESSED, - SEARCH_CATE_BTN_IMG_TYPE_PRESSED, - SEARCH_CATE_BTN_IMG_TYPE_MAX -}; - enum { SEARCH_RET_SEARCH_FAIL = -1, SEARCH_RET_SEARCH_NONE, @@ -70,22 +76,40 @@ enum { }; enum { - SEARCH_STMT_GET_HISTORY_ALL = 0, - SEARCH_STMT_GET_HISTORY_WITH_KEYWORD, - SEARCH_STMT_INSERT_KEYWORD, + SEARCH_STMT_GET_CATEGORY_LIST_ALL = 0, + SEARCH_STMT_INSERT_OBJECT_INFO, + SEARCH_STMT_UPDATE_OBJECT_INFO, SEARCH_STMT_MAX }; enum { SEARCH_SQL_BIND_TYPE_SIMPLEX = 0, SEARCH_SQL_BIND_TYPE_DUPLEX -}; +}; + +enum { + SEARCH_PIPE_CMD_CLEAR_GENLIST = 0, + SEARCH_PIPE_CMD_ADD_GENLIST_PHONE, + SEARCH_PIPE_CMD_SET_LAYOUT, +}; + +enum { + SEARCH_STR_TYPE_APP_STRING = 0, + SEARCH_STR_TYPE_SYSTEM_STRING, +}; //============================================================================================================================== #define SEARCH_PACKAGE "smartsearch" #define SEARCH_ICON_PATH RESDIR"/icons/" #define SEARCH_EDJ EDJDIR"/smartsearch.edj" +#define SEARCH_DB_PATH "/opt/apps/org.tizen.smartsearch/data/.search.db" + +#define SEARCH_FAVORITE_ICON SEARCH_ICON_PATH"B10_icon_list_favorite.png" +#define SEARCH_SDCARD_ICON SEARCH_ICON_PATH"B10_icon_list_memorycard.png" + +#define SEARCH_THUMBNAIL_SIZE 96 +#define SEARCH_ICON_SIZE 64 #define DEF_BUF_LEN (512) #define MAX_LENGTH_PER_LINE (512) @@ -93,17 +117,27 @@ enum { #define MAX_LENGTH_PER_ID (10) #define MAX_SEARCH_WORD_SIZE (128) -#define SMARTSEARCH_KEY_KEYWORD "db/smartsearch/keyword" +#define SMARTSEARCH_KEY_KEYWORD "file/private/org.tizen.smartsearch/keyword" -#define PHONE_CATEGORY_LIST_CNT (SEARCH_TYPE_PHONE_MAX) +#define PHONE_CATEGORY_LIST_CNT (SEARCH_CONT_PHONE_MAX) #define DB_QUERY_LEN (512) #define NO_RESULT_BODY_LEN 7 -#define SEARCH_CATEGORY_LIST_MORE_CNT (20) +#define SEARCH_CATEGORY_LIST_MORE_CNT (100) #define DB_ESCAPE_CHAR "|" +#define SEARCH_DB_SQL_GET_CATEGORY_LIST_ALL "SELECT item_name, item_string, item_visible, item_order, item_contents_type, item_object_type, " \ + "def_pkg_name FROM search_category ORDER by item_order asc;" +#define SEARCH_DB_SQL_INSERT_OBJECT_IFNO "REPLACE INTO search_category" \ + "(item_name, item_string, item_visible, item_order, item_contents_type, item_object_type, def_pkg_name) " \ + "VALUES(?,?,?,?,?,?,?);" + +#define SEARCH_DB_SQL_UPDATE_OBJECT_INFO "UPDATE search_category SET " \ + "item_name = ?, item_string = ?, item_visible = ?, item_order = ?, item_contents_type = ?, item_object_type = ?, " \ + "def_pkg_name = ? WHERE item_contents_type = ?;" + //============================================================================================================================== @@ -126,15 +160,15 @@ enum { } else { \ assert(0); \ } \ - } while(0); + } while(0); /* Gives comparison result of two strings and returns -1 if any of two is NULL */ -#define SEARCH_STRCMP(str1, str2) ((str1 && str2) ? strcmp(str1, str2) : -1) +#define SEARCH_STRCMP(str1, str2) ((str1 && str2) ? strcmp(str1, str2) : -1) /* Returns string length of src and 0 if it is NULL */ #define SEARCH_STRLEN(src) ((src != NULL)? strlen(src): 0) -#define SEARCH_SCALABLED_SIZE(size, _scale_factor) (int)((size) * (_scale_factor)) +#define SEARCH_SCALABLED_SIZE(size, _scale_factor) (int)((size) * (_scale_factor)) #endif diff --git a/packaging/org.tizen.smartsearch.spec b/packaging/org.tizen.smartsearch.spec index 7e26a25..9f1da15 100755 --- a/packaging/org.tizen.smartsearch.spec +++ b/packaging/org.tizen.smartsearch.spec @@ -1,13 +1,12 @@ Name: org.tizen.smartsearch Summary: Smartsearch Application -Version: 0.3.15 +Version: 0.3.16 Release: 1 Group: main License: Flora Software License Source0: %{name}-%{version}.tar.gz Requires: elementary-bin BuildRequires: pkgconfig(appcore-efl) -BuildRequires: pkgconfig(appsvc) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(calendar) BuildRequires: pkgconfig(contacts-service) @@ -22,13 +21,16 @@ BuildRequires: pkgconfig(email-service) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(icu-i18n) BuildRequires: pkgconfig(json-glib-1.0) -BuildRequires: pkgconfig(libmedia-service) BuildRequires: pkgconfig(libsoup-2.4) BuildRequires: pkgconfig(memo) BuildRequires: pkgconfig(msg-service) -BuildRequires: pkgconfig(ui-gadget) +BuildRequires: pkgconfig(ui-gadget-1) BuildRequires: pkgconfig(utilX) BuildRequires: pkgconfig(x11) +BuildRequires: pkgconfig(capi-content-media-content) +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(capi-appfw-app-manager) +BuildRequires: pkgconfig(capi-web-favorites) BuildRequires: libug-contacts-devel BuildRequires: cmake @@ -61,8 +63,9 @@ SEARCHPKG="org.tizen.smartsearch" # create db if [ ! -s /opt/apps/$SEARCHPKG/data/.search.db ] then - sqlite3 /opt/apps/$SEARCHPKG/data/.search.db 'PRAGMA journal_mode = PERSIST; - CREATE TABLE IF NOT EXISTS search_history (category int, keyword text not null, date TEXT, UNIQUE(category, keyword));' + sqlite3 /opt/apps/org.tizen.smartsearch/data/.search.db 'PRAGMA journal_mode = PERSIST; + CREATE TABLE IF NOT EXISTS search_category (item_name text not null, item_string int, item_visible int, item_order int, item_contents_type int, item_object_type int, def_pkg_name text);' + fi # owner & permission @@ -73,16 +76,15 @@ chown -R 5000:5000 /opt/apps/$SEARCHPKG/data/.search.db-journal chmod 660 /opt/apps/$SEARCHPKG/data/.search.db chmod 660 /opt/apps/$SEARCHPKG/data/.search.db-journal -vconftool set -t int db/smartsearch/category 0 -u 5000 -g 5000 2> /dev/null -vconftool set -t string db/smartsearch/keyword '' -u 5000 -g 5000 2> /dev/null - - +vconftool set -t int file/private/org.tizen.smartsearch/category 0 -u 5000 -g 5000 2> /dev/null +vconftool set -t string file/private/org.tizen.smartsearch/keyword '' -u 5000 -g 5000 2> /dev/null %files +/opt/share/packages/* +/opt/share/icons/default/small/* /opt/apps/org.tizen.smartsearch/bin/* /opt/apps/org.tizen.smartsearch/res/* %attr(-,inhouse,inhouse) /opt/apps/org.tizen.smartsearch/data/ %config(noreplace,missingok) /opt/apps/org.tizen.smartsearch/data/.search.db %config(noreplace,missingok) /opt/apps/org.tizen.smartsearch/data/.search.db-journal -/opt/share/applications/* /opt/apps/org.tizen.smartsearch/share/process-info/smartsearch.ini diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index fe43d1f..504a85c 100755 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -1,6 +1,6 @@ # for i18n -SET(POFILES de_DE.po el_GR.po en.po es_ES.po fr_FR.po it_IT.po ja_JP.po ko_KR.po nl_NL.po pt_PT.po ru_RU.po tr_TR.po zh_CN.po zh_HK.po zh_TW.po) +SET(POFILES ar.po bg.po ca.po cs.po da.po de_DE.po el_GR.po en.po en_US.po es_ES.po fi.po fr_FR.po he.po hi.po hr.po hu.po id.po it_IT.po ja_JP.po ko_KR.po lt.po lv.po ms.po nl_NL.po no.po pl.po pt_PT.po ro.po ru_RU.po sk.po sl.po sr.po sv.po th.po tr_TR.po uk.po vi.po zh_CN.po zh_HK.po zh_TW.po) SET(MSGFMT "/usr/bin/msgfmt") diff --git a/po/ar.po b/po/ar.po new file mode 100755 index 0000000..202acf8 --- /dev/null +++ b/po/ar.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "البيانات المحددة غير موجودة" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "مزيد من النتائج" + diff --git a/po/bg.po b/po/bg.po new file mode 100755 index 0000000..76a6cd1 --- /dev/null +++ b/po/bg.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Избраните данни не съществуват" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Още резултати" + diff --git a/po/ca.po b/po/ca.po new file mode 100755 index 0000000..cdb3917 --- /dev/null +++ b/po/ca.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Les dades seleccionades no existeixen" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Més resultats" + diff --git a/po/cs.po b/po/cs.po new file mode 100755 index 0000000..13d6a09 --- /dev/null +++ b/po/cs.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Vybraná data neexistují" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Další výsledky" + diff --git a/po/da.po b/po/da.po new file mode 100755 index 0000000..c283c64 --- /dev/null +++ b/po/da.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Valgte data findes ikke" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Flere resultater" + diff --git a/po/de.po b/po/de.po deleted file mode 100755 index a4fe132..0000000 --- a/po/de.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "Favoriten" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "Internet" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "Dokument" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "Bilder" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "Kein Suchergebnis" - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "In Google suchen" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "Videos" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "Kategorien ändern" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "Abbrechen" - diff --git a/po/de_DE.po b/po/de_DE.po index 4a0cdf6..e9fe6e1 100755 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Ausgewählte Daten sind nicht vorhanden" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "Mehr Ergebnisse" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "Wörterbuch" - diff --git a/po/el.po b/po/el.po deleted file mode 100755 index 04fbdf8..0000000 --- a/po/el.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "Σελιδοδείκτες" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "Πλοηγός" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "Έγγραφο" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "Εικόνες" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "Δεν υπ.απ.αναζ." - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Αναζήτηση μέσω Google" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "Βίντεο" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "Αλλαγή κατηγοριών" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "Άκυρο" - diff --git a/po/el_GR.po b/po/el_GR.po index 6a863b8..4c79c1f 100755 --- a/po/el_GR.po +++ b/po/el_GR.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Τα επιλεγμένα δεδομένα δεν υπάρχουν" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "Περισσότερα αποτελέσματα" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "Λεξικό" - diff --git a/po/en.po b/po/en.po index 2a33305..6a444e9 100755 --- a/po/en.po +++ b/po/en.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Selected data does not exist" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "More results" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "Dictionary" - diff --git a/po/en_US.po b/po/en_US.po index e916646..6a444e9 100755 --- a/po/en_US.po +++ b/po/en_US.po @@ -1,27 +1,6 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "Bookmarks" +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Selected data does not exist" -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "Browser" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "Document" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "Images" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "No search result" - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Search by Google" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "Videos" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "Change categories" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "Cancel" +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "More results" diff --git a/po/es.po b/po/es.po deleted file mode 100755 index c27b7cf..0000000 --- a/po/es.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "Favoritos" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "Navegador" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "Documento" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "Imágenes" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "Sin resultados" - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Buscar con Google" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "Vídeos" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "Cambiar categorías" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "Cancelar" - diff --git a/po/es_ES.po b/po/es_ES.po index 8b19faa..4419dfb 100755 --- a/po/es_ES.po +++ b/po/es_ES.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Los datos seleccionados no existen" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "Más resultados" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "Diccionario" - diff --git a/po/fi.po b/po/fi.po new file mode 100755 index 0000000..3540992 --- /dev/null +++ b/po/fi.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Valittuja tietoja ei ole olemassa" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Lisää tuloksia" + diff --git a/po/fr.po b/po/fr.po deleted file mode 100755 index 1b92d0d..0000000 --- a/po/fr.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "Favoris" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "Navigateur" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "Document" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "Images" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "Aucun résultat" - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Rechercher avec Google" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "Vidéos" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "Modifier les catégories" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "Annuler" - diff --git a/po/fr_FR.po b/po/fr_FR.po index d0b62de..27a1b15 100755 --- a/po/fr_FR.po +++ b/po/fr_FR.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Les données sélectionnées n'existent pas" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "Plus de résultats" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "Dictionnaire" - diff --git a/po/he.po b/po/he.po new file mode 100755 index 0000000..9979e57 --- /dev/null +++ b/po/he.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "הנתונים שנבחרו לא קיימים" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "תוצאות נוספות" + diff --git a/po/hi.po b/po/hi.po new file mode 100755 index 0000000..e8fe4fd --- /dev/null +++ b/po/hi.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "चयनित डेटा मौजूद नहीं है" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "और परिणाम" + diff --git a/po/hr.po b/po/hr.po new file mode 100755 index 0000000..6b7a70c --- /dev/null +++ b/po/hr.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Nema odabranih podataka" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Više rezultata" + diff --git a/po/hu.po b/po/hu.po new file mode 100755 index 0000000..33bb497 --- /dev/null +++ b/po/hu.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "A kijelölt adatok nem léteznek" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "További eredmények" + diff --git a/po/id.po b/po/id.po new file mode 100755 index 0000000..33b9d00 --- /dev/null +++ b/po/id.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Data yang dipilih tidak ada" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Hasil lainnya" + diff --git a/po/it.po b/po/it.po deleted file mode 100755 index dba1ee8..0000000 --- a/po/it.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "Preferiti" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "Browser" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "Documento" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "Immagini" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "Nessun risultato ricerca" - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Cerca con Google" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "Video" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "Cambia categorie" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "Annulla" - diff --git a/po/it_IT.po b/po/it_IT.po index 0755121..5aebff9 100755 --- a/po/it_IT.po +++ b/po/it_IT.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "I dati selezionati non esistono" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "Altri risultati" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "Dizionario" - diff --git a/po/ja.po b/po/ja.po deleted file mode 100755 index 1944a9c..0000000 --- a/po/ja.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "ブックマーク" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "ブラウザ" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "ドキュメント" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "画像" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "検索​結果​が​ありません" - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Google​で​検索​" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "ムービー" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "カテゴリ​​を変更​" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "キャンセル" - diff --git a/po/ja_JP.po b/po/ja_JP.po index ea8c560..ae9f988 100755 --- a/po/ja_JP.po +++ b/po/ja_JP.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "選択した​データ​は​存在​しません" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "他の​結果" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "辞書" - diff --git a/po/ko.po b/po/ko.po deleted file mode 100755 index dd52094..0000000 --- a/po/ko.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "북마크" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "인터넷" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "문서" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "이미지" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "검색 결과가 없습니다" - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Google 검색" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "동영상" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "범주 편집" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "취소" - diff --git a/po/ko_KR.po b/po/ko_KR.po index 5419860..7f505c5 100755 --- a/po/ko_KR.po +++ b/po/ko_KR.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "존재하지 않는 데이터입니다" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "결과 더보기" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "사전" - diff --git a/po/lt.po b/po/lt.po new file mode 100755 index 0000000..e0abcc9 --- /dev/null +++ b/po/lt.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Pasirinktų duomenų nėra" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Daugiau rezultatų" + diff --git a/po/lv.po b/po/lv.po new file mode 100755 index 0000000..0c37451 --- /dev/null +++ b/po/lv.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Izvēlētie dati nepastāv" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Citi rezultāti" + diff --git a/po/ms.po b/po/ms.po new file mode 100755 index 0000000..5e07eaf --- /dev/null +++ b/po/ms.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Data pilihan tidak wujud" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Lebih hasil" + diff --git a/po/nl.po b/po/nl.po deleted file mode 100755 index 12b6cc6..0000000 --- a/po/nl.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "Favorieten" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "Browser" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "Document" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "Afbeeldingen" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "Geen zoekresultaten" - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Zoeken met Google" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "Video's" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "Categorieën wijzigen" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "Annul." - diff --git a/po/nl_NL.po b/po/nl_NL.po index 66cb642..b856a02 100755 --- a/po/nl_NL.po +++ b/po/nl_NL.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Geselecteerde gegevens bestaan niet" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "Meer resultaten" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "Woordenboek" - diff --git a/po/no.po b/po/no.po new file mode 100755 index 0000000..541b03a --- /dev/null +++ b/po/no.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Valgte data finnes ikke" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Flere resultater" + diff --git a/po/pl.po b/po/pl.po new file mode 100755 index 0000000..77a4a75 --- /dev/null +++ b/po/pl.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Wybrane dane nie istnieją" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Więcej wyników" + diff --git a/po/pt.po b/po/pt.po deleted file mode 100755 index e675c60..0000000 --- a/po/pt.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "Favoritos" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "Browser" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "Documento" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "Imagens" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "S/ resul. pesq." - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Procurar através do Google" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "Vídeos" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "Alterar categorias" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "Cancelar" - diff --git a/po/pt_PT.po b/po/pt_PT.po index 8b8baf8..2e3a8f9 100755 --- a/po/pt_PT.po +++ b/po/pt_PT.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Os dados seleccionados não existem" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "Mais resultados" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "Dicionário" - diff --git a/po/ro.po b/po/ro.po new file mode 100755 index 0000000..b33e160 --- /dev/null +++ b/po/ro.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Datele selectate nu există" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Mai multe rezultate" + diff --git a/po/ru.po b/po/ru.po deleted file mode 100755 index 8aa0aad..0000000 --- a/po/ru.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "Закладки" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "Интернет" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "Документ" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "Картинки" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "Нет результатов" - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Поиск в Google" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "Видео" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "Изменить категории" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "Отмена" - diff --git a/po/ru_RU.po b/po/ru_RU.po index 91767d1..f73d6c1 100755 --- a/po/ru_RU.po +++ b/po/ru_RU.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Выбранные данные не существуют" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "Другие результаты" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "Словарь" - diff --git a/po/sk.po b/po/sk.po new file mode 100755 index 0000000..5007187 --- /dev/null +++ b/po/sk.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Vybraté údaje neexistujú" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Ďalšie výsledky" + diff --git a/po/sl.po b/po/sl.po new file mode 100755 index 0000000..42e7000 --- /dev/null +++ b/po/sl.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Izbrani podatki ne obstajajo" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Več rezultatov" + diff --git a/po/sr.po b/po/sr.po new file mode 100755 index 0000000..6981754 --- /dev/null +++ b/po/sr.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Izabrani podaci ne postoje" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Još rezultata" + diff --git a/po/sv.po b/po/sv.po new file mode 100755 index 0000000..478e400 --- /dev/null +++ b/po/sv.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Valda data finns inte" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Fler resultat" + diff --git a/po/th.po b/po/th.po new file mode 100755 index 0000000..55d1b68 --- /dev/null +++ b/po/th.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "ไม่​มี​ข้อมูล​ที่​เลือก" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "ผลลัพธ์​เพิ่ม​เติม" + diff --git a/po/tk.po b/po/tk.po deleted file mode 100755 index 7dc1567..0000000 --- a/po/tk.po +++ /dev/null @@ -1,27 +0,0 @@ -msgid "IDS_SSEARCH_BODY_BOOKMARKS" -msgstr "Yer imleri" - -msgid "IDS_SSEARCH_BODY_BROWSER" -msgstr "İnternet" - -msgid "IDS_SSEARCH_BODY_DOCUMENT" -msgstr "Belge" - -msgid "IDS_SSEARCH_BODY_IMAGES" -msgstr "Resimler" - -msgid "IDS_SSEARCH_BODY_NO_SEARCH_RESULT" -msgstr "Arama sonucu yok" - -msgid "IDS_SSEARCH_BODY_SEARCH_BY_GOOGLE" -msgstr "Google ile ara" - -msgid "IDS_SSEARCH_BODY_VIDEOS" -msgstr "Videolar" - -msgid "IDS_SSEARCH_OPT_CHANGE_CATEGORIES" -msgstr "Kategorileri değiştir" - -msgid "IDS_SSEARCH_SK3_CANCEL" -msgstr "İptal" - diff --git a/po/tr_TR.po b/po/tr_TR.po index fe48994..bd7b58e 100755 --- a/po/tr_TR.po +++ b/po/tr_TR.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Seçilen veriler mevcut değil" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "Diğer sonuçlar" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "Sözlük" - diff --git a/po/uk.po b/po/uk.po new file mode 100755 index 0000000..ff76ff6 --- /dev/null +++ b/po/uk.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Вибрані дані не існують" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Інші результати" + diff --git a/po/vi.po b/po/vi.po new file mode 100755 index 0000000..db5dded --- /dev/null +++ b/po/vi.po @@ -0,0 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "Dữ liệu đã chọn không tồn tại" + +msgid "IDS_SSEARCH_BODY_MORE_RESULTS" +msgstr "Nhiều kết quả hơn" + diff --git a/po/zh_CN.po b/po/zh_CN.po index d3bf028..9e947d3 100755 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "选择的数据不存在" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "更多结果" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "字典" - diff --git a/po/zh_HK.po b/po/zh_HK.po index 091a25f..7861ca5 100755 --- a/po/zh_HK.po +++ b/po/zh_HK.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "已選資料不存在" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "更多結果" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "字典" - diff --git a/po/zh_TW.po b/po/zh_TW.po index 091a25f..7b469ee 100755 --- a/po/zh_TW.po +++ b/po/zh_TW.po @@ -1,6 +1,6 @@ +msgid "IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST" +msgstr "選定的數據不存在" + msgid "IDS_SSEARCH_BODY_MORE_RESULTS" msgstr "更多結果" -msgid "IDS_SSEARCH_OPT_DICTIONARY" -msgstr "字典" - diff --git a/src/common_util.cpp b/src/common_util.cpp index 02b4f51..396c6ba 100755 --- a/src/common_util.cpp +++ b/src/common_util.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. @@ -39,7 +39,6 @@ int search_util_date_time_format_init(void *data) UErrorCode status = U_ZERO_ERROR; UChar customSkeleton[64] = { '\0' }; char skeleton[128] = { 0, }; - int hr = 0; int32_t bestPatternCapacity, bestPatternLength; UChar bestPattern[64] = { 0, }; const char *locale; @@ -108,8 +107,6 @@ void search_util_date_time_format_deinit() { SEARCH_FUNC_START; - UErrorCode status = U_ZERO_ERROR; - if (search_pattern_generator) { udatpg_close(search_pattern_generator); search_pattern_generator = NULL; @@ -163,7 +160,7 @@ void search_sql_make_keyword_bind_value(char *src, char *dest, int type) if(type == SEARCH_SQL_BIND_TYPE_DUPLEX) { *dest = '%'; ++dest; - } + } for (tmp = src; *tmp; ++tmp, ++dest) { if ((*tmp == '%') || (*tmp == '_') || (*tmp == *DB_ESCAPE_CHAR)) { @@ -195,17 +192,18 @@ void search_get_date_string(char *date_string) const char *search_markup_keyword(const char *string, char *searchword, bool *result) { - SEARCH_FUNC_START; - char pstr[DEF_BUF_LEN + 1] = {0,}; char result_str[DEF_BUF_LEN + 1] = {0,}; - char start_str[DEF_BUF_LEN + 1] = {0,}; + char start_str[DEF_BUF_LEN + 1] = {0,}; static char return_string[DEF_BUF_LEN + 1] = { 0, }; int word_len = 0; int search_len = 0; int i = 0; bool found = false; + SEARCH_RET_IF_STR_INVALID(string, return_string); + SEARCH_RET_IF_STR_INVALID(searchword, return_string); + strncpy(pstr, string, DEF_BUF_LEN); word_len = strlen(pstr); @@ -240,8 +238,6 @@ const char *search_markup_keyword(const char *string, char *searchword, snprintf(return_string, 128, "%s", pstr); } - SEARCH_FUNC_END; - return return_string; } @@ -280,12 +276,12 @@ const char *search_markup_keyword(const char *string, char *searchword, *result = found; memset(return_string, 0x00, DEF_BUF_LEN); - if (found) { + if (found) { if (i == 0) { markup_text = g_markup_escape_text(&pstr[0], search_len); markup_text_end = g_markup_escape_text(&pstr[search_len], word_len-search_len); - snprintf(return_string, - DEF_BUF_LEN, + snprintf(return_string, + DEF_BUF_LEN, "%s%s", markup_text, (char*)markup_text_end); @@ -295,8 +291,8 @@ const char *search_markup_keyword(const char *string, char *searchword, markup_text_start = g_markup_escape_text(&pstr[0], i); markup_text = g_markup_escape_text(&pstr[i], search_len); markup_text_end = g_markup_escape_text(&pstr[i+search_len], word_len-(i+search_len)); - snprintf(return_string, - DEF_BUF_LEN, + snprintf(return_string, + DEF_BUF_LEN, "%s%s%s", (char*)markup_text_start, markup_text, diff --git a/src/ps_app_interface.cpp b/src/ps_app_interface.cpp index 56968f6..b4c277f 100755 --- a/src/ps_app_interface.cpp +++ b/src/ps_app_interface.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. @@ -25,7 +25,8 @@ #include #include #include -#include +#include +#include #include #define UG_NAME_LEN 50 @@ -82,13 +83,11 @@ static void __search_effect_layout_render_flush_post_cb(void *data, Evas * e, SEARCH_FUNC_END; } -static void __search_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, +static void __search_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv) { SEARCH_FUNC_START; - struct appdata *ad = (struct appdata *)priv; - Evas_Object *base = (Evas_Object *) ug_get_layout(ug); if (!base) @@ -100,7 +99,7 @@ static void __search_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, elm_object_part_content_set(ad->effect_layout, "elm.swallow.content", base); //B. Add the callback event for the EVAS_RENDER_FLUSH_POST - //B. This is one method to not skip the total effect time in creating the ug object. + //B. This is one method to not skip the total effect time in creating the ug object. evas_event_callback_add(evas_object_evas_get(ad->effect_layout), EVAS_CALLBACK_RENDER_FLUSH_POST, __search_effect_layout_render_flush_post_cb, @@ -112,12 +111,10 @@ static void __search_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, SEARCH_FUNC_END; } -static void __search_ug_closed_cb(struct ui_gadget *ug, void *priv) +static void __search_ug_closed_cb(ui_gadget_h ug, void *priv) { SEARCH_FUNC_START; - struct appdata *ad = (struct appdata *)priv; - #ifdef ENABLE_UG_EFFECT edje_object_signal_emit(elm_layout_edje_get(ad->effect_layout), "elm,state,hide", ""); @@ -171,27 +168,46 @@ void search_launch_contact_view(void *data, void *record_info) struct search_item_sel *cur_category_mem = (struct search_item_sel *)record_info; - bundle *kb; + service_h service = NULL; + int ret = 0; + bool err_popup_show = true; - struct ui_gadget *ug; + ui_gadget_h ug = NULL; struct ug_cbs cbs = { 0, }; char buf[10] = { 0, }; + if (!cur_category_mem || strlen(cur_category_mem->main_id) < 0 ) { + SEARCH_DEBUG_ERROR("Selected item does not have data!"); + goto out_func; + } else { if (ad->detail_ug) { - SEARCH_DEBUG_WARNING("prev ug is exist. destroy prev ug"); + SEARCH_DEBUG_WARNING("\n prev ug is exist. destroy prev ug"); __search_layout_ug_destroy(ad); - } + } - kb = bundle_create(); - if (!kb) { - SEARCH_DEBUG_ERROR("contact bundle_create"); - return; + ret = service_create(&service); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to create service handle!"); + goto out_func; } snprintf(buf, sizeof(buf), "%d", CT_UG_REQUEST_DETAIL); - bundle_add(kb, CT_UG_BUNDLE_TYPE, buf); - bundle_add(kb, CT_UG_BUNDLE_ID, cur_category_mem->main_id); + ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, buf); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to add service extra data : parameter 1!"); + goto out_func; + } + + ret = service_add_extra_data(service, CT_UG_BUNDLE_ID, + cur_category_mem->main_id); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to add service extra data : parameter 2!"); + goto out_func; + } #ifdef ENABLE_UG_EFFECT __search_create_effect_layout(ad->win_main, ad); @@ -200,17 +216,25 @@ void search_launch_contact_view(void *data, void *record_info) cbs.layout_cb = __search_ug_layout_cb; cbs.result_cb = NULL; cbs.destroy_cb = __search_ug_closed_cb; - cbs.priv = ad; + cbs.priv = ad; + + ug = ug_create(NULL, UG_CONTACTS_DETAILS, UG_MODE_FULLVIEW, service, &cbs); - ug = ug_create(NULL, UG_CONTACTS_DETAILS, UG_MODE_FULLVIEW, kb, &cbs); if (!ug) { SEARCH_DEBUG_ERROR(" ... ug_create: failed !!!"); - search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); + goto out_func; } else { ad->detail_ug = ug; - } + err_popup_show = false; + } + } + +out_func: + if (err_popup_show == true) + search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); - bundle_free(kb); + if (service != NULL) + service_destroy(service); SEARCH_FUNC_END; } @@ -231,16 +255,16 @@ void search_launch_msg_view(void *data, void *record_info) SEARCH_DEBUG_ERROR("search_launch_msg_view : bundle_create failed"); return; } - + bundle_add(b, "type", "msg_id"); bundle_add(b, "msgId", cur_category_mem->main_id); ret = aul_launch_app("org.tizen.message", b); - if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){ + if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){ SEARCH_DEBUG_ERROR("msg aul launch app error(%d)", ret); search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); } - bundle_free(b); + bundle_free(b); SEARCH_FUNC_END; } @@ -320,20 +344,21 @@ void search_launch_image_view(void *data, void *record_info) SEARCH_DEBUG_LOG("cur_category_mem->path : %s", cur_category_mem->path); - bundle* bd = NULL; - bd = bundle_create(); + service_h service; + ret = service_create(&service); - if (bd != NULL) { - appsvc_set_operation(bd, APPSVC_OPERATION_VIEW); - appsvc_set_uri(bd, cur_category_mem->path); - ret = appsvc_run_service(bd, 0, NULL, NULL); + if (ret == 0) { + service_set_operation(service, SERVICE_OPERATION_VIEW); + service_set_uri(service, cur_category_mem->path); + ret = service_send_launch_request(service, NULL, NULL); - if (ret < 0 ) + if (ret != 0) { + SEARCH_DEBUG_ERROR("image app service launching error(%d)", ret); search_launch_popup_error(LAUNCH_ERROR_APPSVC, - ad); - bundle_free(bd); + ad); } - + service_destroy(service); + } } SEARCH_FUNC_END; @@ -353,20 +378,24 @@ void search_launch_video_view(void *data, void *record_info) cur_category_mem->path); search_launch_popup_error(LAUNCH_ERROR_FILE_NOT_FOUND, ad); } else { - bundle* bd = NULL; - bd = bundle_create(); - - appsvc_set_operation(bd, APPSVC_OPERATION_VIEW); - appsvc_set_uri(bd, cur_category_mem->path); - ret = appsvc_run_service(bd, 0, NULL, NULL); - - if (ret < 0) { - SEARCH_DEBUG_ERROR("video app service error(%d) : %s", - ret, cur_category_mem->path); - search_launch_popup_error(LAUNCH_ERROR_APPSVC, ad); - } + SEARCH_DEBUG_LOG("cur_category_mem->path : %s", + cur_category_mem->path); + + service_h service; + ret = service_create(&service); - bundle_free(bd); + if (ret == 0) { + service_set_operation(service, SERVICE_OPERATION_VIEW); + service_set_uri(service, cur_category_mem->path); + ret = service_send_launch_request(service, NULL, NULL); + + if (ret != 0) { + SEARCH_DEBUG_ERROR("video app service launching error(%d)", ret); + search_launch_popup_error(LAUNCH_ERROR_APPSVC, + ad); + } + service_destroy(service); + } } SEARCH_FUNC_END; @@ -388,22 +417,21 @@ void search_launch_music_view(void *data, void *record_info) } else { SEARCH_DEBUG_LOG("cur_category_mem->path : %s", cur_category_mem->path); - - bundle* bd = NULL; - bd = bundle_create(); - - if (bd != NULL) { - appsvc_set_operation(bd, APPSVC_OPERATION_VIEW); - appsvc_set_uri(bd, cur_category_mem->path); - ret = appsvc_run_service(bd, 0, NULL, NULL); - - if (ret < 0) { - SEARCH_DEBUG_ERROR("music app service error(%d) : %s", - ret, cur_category_mem->path); + + service_h service; + ret = service_create(&service); + + if (ret == 0) { + service_set_operation(service, SERVICE_OPERATION_VIEW); + service_set_uri(service, cur_category_mem->path); + ret = service_send_launch_request(service, NULL, NULL); + + if (ret != 0) { + SEARCH_DEBUG_ERROR("music app service launching error(%d)", ret); search_launch_popup_error(LAUNCH_ERROR_APPSVC, ad); } - bundle_free(bd); + service_destroy(service); } } @@ -417,35 +445,56 @@ void search_launch_calendar_view(void *data, void *record_info) struct appdata *ad = (struct appdata *)data; struct search_item_sel *cur_category_mem = (struct search_item_sel *)record_info; - struct ui_gadget *ug; + ui_gadget_h ug = NULL; struct ug_cbs cbs = { 0, }; + int ret = 0; + bool err_popup_show = true; + service_h service = NULL; - bundle *b; - int ret; + if (!cur_category_mem && strlen(cur_category_mem->main_id) < 0) { + SEARCH_DEBUG_ERROR("Selected item does not have data!"); + goto out_func; + } else { + ret = service_create(&service); - if (ad->detail_ug) { - SEARCH_DEBUG_WARNING("prev ug is exist. destroy prev ug"); + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to create service handle!"); + goto out_func; + } - __search_layout_ug_destroy(ad); + ret = service_add_extra_data(service, "index", cur_category_mem->main_id); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to add service extra data : parameter 1!"); + goto out_func; } - b = bundle_create(); - if (!b) - return; +#ifdef ENABLE_UG_EFFECT + __search_create_effect_layout(ad->win_main, ad); +#endif + cbs.destroy_cb = __search_ug_closed_cb; + cbs.layout_cb = __search_ug_layout_cb; + cbs.result_cb = NULL; + cbs.priv = ad; + + ug = ug_create(NULL, "calendar-detail-efl", UG_MODE_FULLVIEW, service, &cbs); - bundle_add(b, AUL_K_SERVICE_NAME, "view_event"); - bundle_add(b, "index", cur_category_mem->main_id); + if (!ug) { + SEARCH_DEBUG_ERROR("... create_ug_calendar : failed !!!"); + goto out_func; + } - SEARCH_DEBUG_LOG("index : %s", cur_category_mem->main_id); + ad->detail_ug = ug; + err_popup_show = false; + } - ret = aul_launch_app("org.tizen.efl-calendar", b); - if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){ - SEARCH_DEBUG_ERROR("calendar aul launch app error(%d)", ret); +out_func: + if (err_popup_show == true) search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); - } - bundle_free(b); - + if (service != NULL) + service_destroy(service); + SEARCH_FUNC_END; } @@ -456,39 +505,62 @@ void search_launch_memo_view(void *data, void *record_info) struct appdata *ad = (struct appdata *)data; struct search_item_sel *cur_category_mem = (struct search_item_sel *)record_info; - struct ui_gadget *ug; + ui_gadget_h ug = NULL; struct ug_cbs cbs = { 0, }; - bundle *b; + int ret = 0; + bool err_popup_show = true; + + service_h service = NULL; + if (!cur_category_mem && strlen(cur_category_mem->main_id) < 0) { + SEARCH_DEBUG_ERROR("Selected item does not have data!"); + goto out_func; + } else { if (ad->detail_ug) { SEARCH_DEBUG_WARNING("prev ug is exist. destroy prev ug"); + __search_layout_ug_destroy(ad); + } - __search_layout_ug_destroy(ad); + ret = service_create(&service); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to create service handle!"); + goto out_func; } - b = bundle_create(); - if (!b) - return; + ret = service_add_extra_data(service, "index", cur_category_mem->main_id); - bundle_add(b, "index", cur_category_mem->main_id); + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to add service extra data : parameter 1!"); + goto out_func; + } +#ifdef ENABLE_UG_EFFECT __search_create_effect_layout(ad->win_main, ad); - +#endif cbs.layout_cb = __search_ug_layout_cb; cbs.result_cb = NULL; cbs.destroy_cb = __search_ug_closed_cb; cbs.priv = ad; - ug = ug_create(NULL, "memo-efl", UG_MODE_FULLVIEW, b, &cbs); + ug = ug_create(NULL, "memo-efl", UG_MODE_FULLVIEW, service, &cbs); + if (!ug) { SEARCH_DEBUG_ERROR("... create_ug_email : failed !!!"); - search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); + goto out_func; } ad->detail_ug = ug; + err_popup_show = false; + } - bundle_free(b); +out_func: + if (err_popup_show == true) + search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); + + if (service != NULL) + service_destroy(service); SEARCH_FUNC_END; } @@ -500,21 +572,114 @@ void search_launch_menu_view(void *data, void *record_info) struct appdata *ad = (struct appdata *)data; struct search_item_sel *cur_category_mem = (struct search_item_sel *)record_info; + char *pkg_name = cur_category_mem->path; + bool is_running = false; + app_context_h app_h; + + bool err_popup_show = true; int ret; + service_h service = NULL; - ret = aul_launch_app(cur_category_mem->path, NULL); + if (pkg_name != NULL && strlen(pkg_name)) { + ret = app_manager_is_running(pkg_name, &is_running); - SEARCH_DEBUG_WARNING("path : %s, ret : %d", cur_category_mem->path, ret); - - if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){ - SEARCH_DEBUG_ERROR("menu aul launch app error(%d) : %s", ret, - cur_category_mem->path); - search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); + if (ret != APP_MANAGER_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to get info : app_manager_is_running [%d]", ret); + goto out_func; + } + + if (is_running == true) { + ret = app_manager_get_app_context(pkg_name, &app_h); + if (ret != APP_MANAGER_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to get info : app_manager_get_app_context [%d]", ret); + goto out_func; + } + + ret = app_manager_resume_app(app_h); + + if (ret != APP_MANAGER_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to get info : app_manager_resume_app [%d]", ret); + goto out_func; + } + err_popup_show = false; + } else { + ret = service_create(&service); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to create service header : [%d]", ret); + goto out_func; + } + + ret = service_set_operation(service, SERVICE_OPERATION_DEFAULT); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to set operation : [%d]", ret); + goto out_func; + } + + ret = service_set_package(service, pkg_name); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to set package : [%d]", ret); + goto out_func; + } + + ret = service_send_launch_request(service, NULL, NULL); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to send launch request : [%d]", ret); + goto out_func; + } + err_popup_show = false; + } + } else { + SEARCH_DEBUG_ERROR("Pkg name is NULL!"); + } + +out_func: + if (err_popup_show == true) + search_launch_popup_error(LAUNCH_ERROR_APPSVC, ad); + + if (service != NULL) { + ret = service_destroy(service); + + if (ret != SERVICE_ERROR_NONE) + SEARCH_DEBUG_ERROR("Fail to destroy service header : [%d]", ret); } SEARCH_FUNC_END; } +void search_launch_browser_view(void *data, void *record_info) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + struct search_item_sel *cur_category_mem = + (struct search_item_sel *)record_info; + int ret; + + SEARCH_DEBUG_LOG("cur_category_mem->path : %s", + cur_category_mem->path); + + service_h service; + ret = service_create(&service); + + if (ret == 0 && strlen(cur_category_mem->path) > 0 ) { + service_set_operation(service, SERVICE_OPERATION_VIEW); + service_set_uri(service, cur_category_mem->path); + ret = service_send_launch_request(service, NULL, NULL); + + if (ret != 0) { + SEARCH_DEBUG_ERROR("browser app service launching error(%d)", ret); + search_launch_popup_error(LAUNCH_ERROR_APPSVC, + ad); + } + service_destroy(service); + } + +} + static void __search_launch_popup_error_response_cb(void *data, Evas_Object * obj, void *event_info) @@ -558,19 +723,19 @@ void search_launch_popup_error(int error_type, void *data) case LAUNCH_ERROR_AUL_LAUNCH: /* This Message String enable to be another string in the future */ elm_object_text_set(popup, - dgettext("sys_string", - "IDS_COM_POP_SERVICE_UNAVAILABLE")); + gettext("IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST")); break; case LAUNCH_ERROR_APPSVC: elm_object_text_set(popup, - dgettext("sys_string", - "IDS_COM_POP_SERVICE_UNAVAILABLE")); + gettext("IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST")); break; } btn1 = elm_button_add(popup); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, - dgettext("sys_string","IDS_COM_SK_OK")); + dgettext("sys_string","IDS_COM_POP_CLOSE")); evas_object_smart_callback_add(btn1, "clicked", __search_launch_popup_error_response_cb, ad); diff --git a/src/ps_makeupviews.cpp b/src/ps_makeupviews.cpp index a46413d..26eee50 100755 --- a/src/ps_makeupviews.cpp +++ b/src/ps_makeupviews.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. @@ -15,72 +15,155 @@ */ - - - - #include "smartsearch.h" #include "ps_searcher.h" #include "ps_app_interface.h" +#include +#include +#include +#include +#include +#include +#include + +struct search_thread_data { + struct appdata *ad; + char *keyword; + int is_search_result; +}; + +struct search_genlist_item_info* search_add_genlist_item(int type, + struct search_content_object *obj, Elm_Genlist_Item_Class *itc_style, void *data, + Elm_Object_Item *parent) +{ + struct search_genlist_item_info *item = (struct search_genlist_item_info *) + calloc(1, + sizeof(struct search_genlist_item_info)); + + if (item) { + item->type = type; + item->obj = obj; + item->itc_style = itc_style; + item->data = data; + item->parent = parent; + } -static char *__search_get_phone_category_name(int type) + return item; +} + +static void +ecore_exe_pipe_cb(void *data, void *buf, unsigned int size) { 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"); - } + struct appdata *ad = (struct appdata *)data; + struct search_pipe_data *pipe_data = *((struct search_pipe_data**)buf); + + struct search_content_object *obj = NULL; + struct search_genlist_item_info *item = NULL; + struct search_genlist_info *result_info = pipe_data->result_list; + + int cmd = pipe_data->cmd; + + SEARCH_DEBUG_LOG("Pipe Command : %d ret : %d", cmd, pipe_data->search_ret); + + switch (cmd) { + case SEARCH_PIPE_CMD_CLEAR_GENLIST: + elm_genlist_clear(ad->search_gl); break; - case SEARCH_TYPE_PHONE_EMAIL: - { - name = dgettext("sys_string", "IDS_COM_BODY_EMAIL"); - } + case SEARCH_PIPE_CMD_SET_LAYOUT: + if (pipe_data->search_ret == SEARCH_RET_SEARCH_SUCCESS) + search_layout_set_search_list(ad); + else + search_layout_set_search_no_result(ad); break; - case SEARCH_TYPE_PHONE_IMAGES: - { - name = dgettext("sys_string", "IDS_COM_BODY_IMAGES"); + case SEARCH_PIPE_CMD_ADD_GENLIST_PHONE: + if (result_info) { + if (result_info->group) { + item = result_info->group; + obj = item->obj; + + obj->gl_result_grp = elm_genlist_item_append(ad->search_gl, + item->itc_style, + item->data, + NULL, + ELM_GENLIST_ITEM_GROUP, + NULL, + NULL); + SEARCH_FREE(item); + } + + if (result_info->itemlist) { + GList *node = g_list_first(result_info->itemlist); + + while (node != NULL) { + item = (struct search_genlist_item_info *)node->data; + obj = item->obj; + if (item) { + elm_genlist_item_append(ad->search_gl, + item->itc_style, + item->data, + obj->gl_result_grp, + ELM_GENLIST_ITEM_NONE, + search_gl_phone_result_sel, + ad); + SEARCH_FREE(item); + } + node = g_list_next(node); + } + g_list_free(result_info->itemlist); + result_info->itemlist = NULL; + } + + if (result_info->more) { + item = result_info->more; + obj = item->obj; + elm_genlist_item_append(ad->search_gl, + item->itc_style, + item->data, + obj->gl_result_grp, + ELM_GENLIST_ITEM_NONE, + search_gl_result_more_item_append_cb, + ad); + SEARCH_FREE(item); + } + + SEARCH_FREE(result_info); } break; - case SEARCH_TYPE_PHONE_MUSIC: - { - name = dgettext("sys_string", "IDS_COM_BODY_MUSIC"); } - break; - case SEARCH_TYPE_PHONE_VIDEO: + + SEARCH_FREE(pipe_data); + SEARCH_FUNC_END; +} + +static Evas_Object *__search_gl_content_get_search_item_type(void *data, Evas_Object *obj, const char *part) { - name = dgettext("sys_string", "IDS_COM_BODY_VIDEOS"); + Evas_Object *icon = NULL; + int icon_size = 0; + + struct search_item_sel *sel_mem_info = (struct search_item_sel *)data; + + if (!SEARCH_STRCMP(part, "elm.icon") || !SEARCH_STRCMP(part, "elm.icon.1")) { + if (strlen(sel_mem_info->icon1_path) > 0 ) { + icon = elm_icon_add(obj); + icon_size = (int)(SEARCH_THUMBNAIL_SIZE * elm_scale_get()); + elm_icon_prescale_set(icon, icon_size); + elm_icon_file_set(icon, sel_mem_info->icon1_path, NULL); + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); } - break; - case SEARCH_TYPE_PHONE_CALENDAR: - { - name = dgettext("sys_string", "IDS_COM_BODY_CALENDAR"); + } else if(!strcmp(part, "elm.icon.2")) { + if (strlen(sel_mem_info->icon2_path) > 0 ) { + icon = elm_icon_add(obj); + icon_size = (int)(SEARCH_ICON_SIZE * elm_scale_get()); + elm_icon_prescale_set(icon, icon_size); + elm_icon_file_set(icon, sel_mem_info->icon2_path, NULL); + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); } - 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"); + return icon; } - break; - } - - return name; -} - static Eina_Bool __search_gl_state_get(void *data, Evas_Object * obj, const char *part) @@ -88,7 +171,7 @@ static Eina_Bool __search_gl_state_get(void *data, Evas_Object * obj, return EINA_FALSE; } -static char *__search_gl_label_get(void *data, Evas_Object * obj, +static char *__search_gl_label_get_search_item_type(void *data, Evas_Object * obj, const char *part) { if (data == NULL) { @@ -97,7 +180,7 @@ static char *__search_gl_label_get(void *data, Evas_Object * obj, 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")) { @@ -105,24 +188,32 @@ static char *__search_gl_label_get(void *data, Evas_Object * obj, } else { buf = NULL; } - + return buf; } -static char *__search_gl_label_get_title(void *data, Evas_Object * obj, +static char *__search_gl_label_get_normal_type(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; + char *title_string = (char*)data; + if(title_string) + return strdup(dgettext("sys_string", title_string)); + else + return strdup(""); +} - category_name = __search_get_phone_category_name(sel_mem->type); +static char *__search_gl_label_get_group(void *data, Evas_Object * obj, + const char *part) +{ + struct search_content_object *object = (struct search_content_object*)data; + SEARCH_DEBUG_WARNING("%s %d", object->name, object->string_type); + if (object) { + if (object->string_type == SEARCH_STR_TYPE_APP_STRING) + return strdup(gettext(object->name)); + else + return strdup(dgettext("sys_string", object->name)); + } - if(category_name) - return strdup(category_name); - else return strdup(""); } @@ -132,10 +223,16 @@ static char *__search_gl_label_get_more(void *data, Evas_Object * obj, return strdup(gettext("IDS_SSEARCH_BODY_MORE_RESULTS")); } -static void __search_gl_del(void *data, Evas_Object * obj) +static void __search_gl_del_grouptitle(void *data, Evas_Object * obj) { SEARCH_FUNC_START; + SEARCH_FUNC_END; + return; +} + +static void __search_gl_del(void *data, Evas_Object * obj) +{ struct search_item_sel *sel_mem_info = (struct search_item_sel *)data; SEARCH_FREE(sel_mem_info); @@ -143,6 +240,217 @@ static void __search_gl_del(void *data, Evas_Object * obj) return; } +static void __search_gl_del_more_button(void *data, Evas_Object * obj) +{ + struct search_item_more_sel *sel_mem_more = (struct search_item_more_sel *)data; + + SEARCH_FREE(sel_mem_more); + + return; +} + +int search_app_connect(void *data) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + + int rc = 0, conn_ret = 0; + int ret = SEARCH_RET_SUCCESS; + int i = 0; + + for (i = 0; i < SEARCH_CONT_MAX ; ++i) { + switch (ad->result_obj[i].contents_type) { + case SEARCH_CONT_PHONE_CONTACTS: + { + if (ad->result_obj[i].visible == EINA_TRUE) { + rc = contacts_svc_connect(); + if (rc != CTS_SUCCESS) { + SEARCH_DEBUG_WARNING("contacts svc connect fail : %d",rc); + } + } else { + rc = contacts_svc_disconnect(); + if (rc != CTS_SUCCESS) { + SEARCH_DEBUG_WARNING("contacts svc disconnect fail : %d",rc); + } + } + } + break; + + /* Contact-service should be conneted for display Message result. + Because We should display message with contact photo + if user have contact photo which have matched to tel-number of sender or receiver */ + case SEARCH_CONT_PHONE_MSG: + { + msg_error_t err = MSG_SUCCESS; + + if (ad->result_obj[i].visible == EINA_TRUE) { + + /* Connect Contact-service if contact category status is invisible */ + if (ad->result_obj[SEARCH_CONT_PHONE_CONTACTS].visible == EINA_FALSE) { + rc = contacts_svc_connect(); + if (rc != CTS_SUCCESS) { + /* If we fail to connect contact-service, display message-app icon */ + SEARCH_DEBUG_WARNING("contacts svc connect fail : %d",rc); + } + } + + /* Connect Message-Service */ + err = msg_open_msg_handle(&ad->msg_handle); + + if (err != MSG_SUCCESS) { + SEARCH_DEBUG_WARNING("msg_open_msg_handle error : %d", err); + ad->msg_handle = NULL; + } + } else { + /* Disconnect Contact-service if contact category status is invisible */ + if (ad->result_obj[SEARCH_CONT_PHONE_CONTACTS].visible == EINA_FALSE) { + rc = contacts_svc_disconnect(); + if (rc != CTS_SUCCESS) + SEARCH_DEBUG_WARNING("contacts svc connect fail : %d",rc); + } + + /* Disconnect Message-Service */ + if (ad->msg_handle != NULL ) { + err = msg_close_msg_handle(&ad->msg_handle); + + if (err != MSG_SUCCESS) + SEARCH_DEBUG_WARNING("msg_close_msg_handle error : %d", err); + ad->msg_handle = NULL; + } + } + } + break; + case SEARCH_CONT_PHONE_EMAIL: + break; + /* IMAGE, MUSIC, VIDEO use common handle */ + case SEARCH_CONT_PHONE_IMAGES: + case SEARCH_CONT_PHONE_MUSIC: + case SEARCH_CONT_PHONE_VIDEO: + { + if (ad->result_obj[SEARCH_CONT_PHONE_IMAGES].visible == EINA_TRUE + || ad->result_obj[SEARCH_CONT_PHONE_MUSIC].visible == EINA_TRUE + || ad->result_obj[SEARCH_CONT_PHONE_VIDEO].visible == EINA_TRUE ) { + conn_ret = media_content_connect(); + + if (conn_ret != 0) + SEARCH_DEBUG_WARNING("media_content_connect failed : %d\n", conn_ret); + } else { + conn_ret = media_content_disconnect(); + + if(conn_ret < 0) + SEARCH_DEBUG_WARNING("media_content_disconnect failed : %d\n", conn_ret); + } + } + break; + case SEARCH_CONT_PHONE_CALENDAR: + { + if (ad->result_obj[i].visible == EINA_TRUE) { + rc = calendar_svc_connect(); + if (rc != CAL_SUCCESS) { + SEARCH_DEBUG_WARNING + ("calendar svc connect fail : %d", + rc); + } + } else { + rc = calendar_svc_close(); + if (rc != CAL_SUCCESS) { + SEARCH_DEBUG_WARNING + ("calendar svc disconnect fail : %d", + rc); + } + } + } + break; + case SEARCH_CONT_PHONE_MEMO: + { + if (ad->result_obj[i].visible == EINA_TRUE) { + rc = memo_init(NULL); + if (rc == -1) { + SEARCH_DEBUG_WARNING + ("memo svc connect fail : %d", rc); + } + } else + memo_fini(); + } + break; + } + } + + SEARCH_FUNC_END; + + return ret; +} + +int search_app_disconnect(void *data) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + + int rc = 0, conn_ret = 0; + int i = 0; + + for (i = 0; i < SEARCH_CONT_MAX ; ++i) { + switch (ad->result_obj[i].contents_type) { + case SEARCH_CONT_PHONE_CONTACTS: + { + rc = contacts_svc_disconnect(); + if (rc != CTS_SUCCESS) { + SEARCH_DEBUG_WARNING + ("contacts svc disconnect fail : %d", + rc); + } + } + break; + case SEARCH_CONT_PHONE_MSG: + { + if (ad->msg_handle != NULL ) { + msg_error_t err = MSG_SUCCESS; + err = msg_close_msg_handle(&ad->msg_handle); + + if (err != MSG_SUCCESS) { + SEARCH_DEBUG_WARNING("msg_close_msg_handle error : %d", err); + } + + ad->msg_handle = NULL; + } + } + break; + case SEARCH_CONT_PHONE_EMAIL: + break; + case SEARCH_CONT_PHONE_IMAGES: + case SEARCH_CONT_PHONE_MUSIC: + case SEARCH_CONT_PHONE_VIDEO: + { + conn_ret = media_content_disconnect(); + if(conn_ret != 0) + SEARCH_DEBUG_WARNING("media_content_disconnect failed : %d\n", conn_ret); + } + break; + case SEARCH_CONT_PHONE_CALENDAR: + { + rc = calendar_svc_close(); + if (rc != CAL_SUCCESS) { + SEARCH_DEBUG_WARNING + ("calendar svc disconnect fail : %d", + rc); + } + } + break; + case SEARCH_CONT_PHONE_MEMO: + { + memo_fini(); + } + break; + } + } + + SEARCH_FUNC_END; + + return 0; +} + void search_gl_phone_result_sel(void *data, Evas_Object * obj, void *event_info) { SEARCH_FUNC_START; @@ -150,7 +458,6 @@ void search_gl_phone_result_sel(void *data, Evas_Object * obj, void *event_info) 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); @@ -158,44 +465,48 @@ void search_gl_phone_result_sel(void *data, Evas_Object * obj, void *event_info) return; } - switch (cur_category_mem->type) { + SEARCH_DEBUG_LOG("cur_category_mem->type : %d", cur_category_mem->type); - case SEARCH_TYPE_PHONE_CONTACTS: + switch (cur_category_mem->type) { + case SEARCH_CONT_PHONE_CONTACTS: search_launch_contact_view(ad, cur_category_mem); break; - case SEARCH_TYPE_PHONE_MSG: + case SEARCH_CONT_PHONE_MSG: search_launch_msg_view(ad, cur_category_mem); break; - case SEARCH_TYPE_PHONE_EMAIL: + case SEARCH_CONT_PHONE_EMAIL: search_launch_email_view(ad, cur_category_mem); break; - case SEARCH_TYPE_PHONE_IMAGES: + case SEARCH_CONT_PHONE_IMAGES: search_launch_image_view(ad, cur_category_mem); break; - case SEARCH_TYPE_PHONE_VIDEO: + case SEARCH_CONT_PHONE_VIDEO: search_launch_video_view(ad, cur_category_mem); break; - case SEARCH_TYPE_PHONE_MUSIC: + case SEARCH_CONT_PHONE_MUSIC: search_launch_music_view(ad, cur_category_mem); break; - - case SEARCH_TYPE_PHONE_CALENDAR: + + case SEARCH_CONT_PHONE_CALENDAR: search_launch_calendar_view(ad, cur_category_mem); break; - case SEARCH_TYPE_PHONE_MEMO: + case SEARCH_CONT_PHONE_MEMO: search_launch_memo_view(ad, cur_category_mem); break; - case SEARCH_TYPE_PHONE_MENU: + case SEARCH_CONT_PHONE_MENU: search_launch_menu_view(ad, cur_category_mem); break; + case SEARCH_CONT_PHONE_BROWSER: + search_launch_browser_view(ad, cur_category_mem); + default: break; } @@ -205,326 +516,521 @@ void search_gl_phone_result_sel(void *data, Evas_Object * obj, void *event_info) 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) +static int __search_gl_set_phone_search_result(struct search_content_object *obj, + int offset, + char *keyword, + void *data, + struct search_genlist_info *result_info) { 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; + obj->mr_info.offset = offset; - if (offset == 0) { - ad->cate_info[type].next_point = 0; + if (obj->mr_info.offset == 0) { + obj->mr_info.next_point = 0; } - switch (type) { - - case SEARCH_TYPE_PHONE_CONTACTS: + SEARCH_DEBUG_LOG("offset : %d, limit : %d keyword : %s", offset, sel_cnt, keyword); + + if (obj->visible == EINA_TRUE ) { + switch (obj->contents_type) { + case SEARCH_CONT_PHONE_CONTACTS: { func_ret = - search_sql_contact_search_result_by_api(type, + search_sql_contact_search_result_by_api(obj, offset, sel_cnt, - data); + keyword, + ad, + result_info); } break; - case SEARCH_TYPE_PHONE_MSG: + case SEARCH_CONT_PHONE_MSG: { if (ad->msg_handle != NULL) { func_ret = - search_sql_msg_search_result_by_api(type, + search_sql_msg_search_result_by_api(obj, offset, - sel_cnt, - data); + sel_cnt, + keyword, + ad, + result_info); } } break; - case SEARCH_TYPE_PHONE_EMAIL: + case SEARCH_CONT_PHONE_EMAIL: { func_ret = - search_sql_email_search_result_by_api(type, + search_sql_email_search_result_by_api(obj, offset, - sel_cnt, - data); + sel_cnt, + keyword, + ad, + result_info); } - break; - case SEARCH_TYPE_PHONE_IMAGES: + break; + case SEARCH_CONT_PHONE_IMAGES: { - if (ad->media_handle != NULL ) { func_ret = - search_sql_image_search_result_by_api(type, + search_sql_image_search_result_by_api(obj, offset, - sel_cnt, - data); + sel_cnt, + keyword, + ad, + result_info); } + break; + case SEARCH_CONT_PHONE_MUSIC: + { + func_ret = + search_sql_music_search_result_by_api(obj, + offset, + sel_cnt, + keyword, + ad, + result_info); } - break; - case SEARCH_TYPE_PHONE_MUSIC: + break; + case SEARCH_CONT_PHONE_VIDEO: { - if (ad->media_handle != NULL ) { func_ret = - search_sql_music_search_result_by_api(type, + search_sql_video_search_result_by_api(obj, offset, - sel_cnt, - data); - } + sel_cnt, + keyword, + ad, + result_info); } break; - case SEARCH_TYPE_PHONE_VIDEO: + case SEARCH_CONT_PHONE_CALENDAR: { - if (ad->media_handle != NULL ) { func_ret = - search_sql_video_search_result_by_api(type, + search_sql_calendar_search_result_by_api(obj, offset, - sel_cnt, - data); + sel_cnt, + keyword, + ad, + result_info); } - } - break; - - case SEARCH_TYPE_PHONE_CALENDAR: + break; + case SEARCH_CONT_PHONE_MEMO: { func_ret = - search_sql_calendar_search_result_by_api(type, + search_sql_memo_search_result_by_api(obj, offset, sel_cnt, - data); + keyword, + ad, + result_info); } break; - - case SEARCH_TYPE_PHONE_MEMO: + case SEARCH_CONT_PHONE_MENU: { func_ret = - search_sql_memo_search_result_by_api(type, + search_sql_menu_search_result_by_api(obj, offset, - sel_cnt, - data); + sel_cnt, + keyword, + ad, + result_info); } break; - - case SEARCH_TYPE_PHONE_MENU: + case SEARCH_CONT_PHONE_BROWSER: { func_ret = - search_sql_menu_search_result_by_api(type, + search_sql_browser_search_result_by_api(obj, offset, sel_cnt, keyword, - data); + ad, + result_info); } - break; + } } SEARCH_FUNC_END; - return func_ret; } -void search_gl_result_more_item_append_cb(void *data, Evas_Object * obj, - void *event_info) +static void __search_thread_heavy_cb(void *data, Ecore_Thread *th) { SEARCH_FUNC_START; - struct appdata *ad = (struct appdata *)data; - Elm_Object_Item *it = (Elm_Object_Item *) event_info; + struct search_thread_data *thread_data = (struct search_thread_data*)data; + struct appdata *ad = thread_data->ad; + struct search_content_object *obj = NULL; + struct search_genlist_info *result_info = NULL; 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; + int i = SEARCH_CONT_PHONE_MIN; + int category_type = 0; - 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); + SEARCH_DEBUG_LOG("Thread ID : %p Keyword : %s", th, thread_data->keyword); - int rc = 0, i = 0; - int type = sel_mem->type; - int offset = ad->cate_info[type].next_point; + thread_data->ad = ad; + thread_data->is_search_result = SEARCH_RET_SEARCH_NONE; - search_sql_make_keyword_bind_value(ad->search_word, escape_added_keyword, SEARCH_SQL_BIND_TYPE_DUPLEX); + while (i <= SEARCH_CONT_PHONE_MAX) { + int offset = 0; + obj = &ad->result_obj[i]; + category_type = obj->category_type; - elm_object_item_del(it); + if (category_type == SEARCH_OBJ_PHONE_CONTENTS) { + if (ecore_thread_check(th) != EINA_TRUE) { + result_info = (struct search_genlist_info *)calloc(1, sizeof(struct search_genlist_info)); + ret = __search_gl_set_phone_search_result(obj, + offset, + thread_data->keyword, + ad, + result_info); + + if (ret == SEARCH_RET_SEARCH_SUCCESS) { + SEARCH_DEBUG_LOG("Succes to Matched result : %s %d", obj->name, ret); + thread_data->is_search_result = SEARCH_RET_SEARCH_SUCCESS; + ecore_thread_feedback(th, result_info); + } else { + SEARCH_FREE(result_info); + } + } + } + i++; + } + SEARCH_FUNC_END; +} - __search_gl_set_phone_search_result(type, offset, escape_added_keyword, ad); + +static void __search_thread_feedback_cb(void *data, Ecore_Thread *th, void *msg_data) +{ + SEARCH_FUNC_START; + + struct search_thread_data *thread_data = (struct search_thread_data *)data; + struct appdata *ad = thread_data->ad; + struct search_genlist_info *result_list = (struct search_genlist_info *)msg_data; + struct search_pipe_data *pdata = NULL; + + pdata = (struct search_pipe_data *)calloc(1,sizeof(struct search_pipe_data)); + pdata->cmd = SEARCH_PIPE_CMD_ADD_GENLIST_PHONE; + pdata->obj = NULL; + pdata->result_list = result_list; + pdata->search_ret = thread_data->is_search_result; + + if (ecore_thread_check(th) == EINA_TRUE) + return; + + ecore_pipe_write(ad->pipe, &pdata, sizeof(struct search_pipe_data)); SEARCH_FUNC_END; } -static int __search_set_phone_result_list(struct appdata *ad, bool is_input_keyword, const char* search_keyword) +static void __search_thread_end_cb(void *data, Ecore_Thread *th) { SEARCH_FUNC_START; - int i = 0, is_search_result = 0, ret = 0; + struct search_thread_data *thread_data = (struct search_thread_data *)data; + struct appdata *ad = thread_data->ad; + struct search_pipe_data *pdata = NULL; - if (is_input_keyword == false) { - return SEARCH_RET_SEARCH_NONE; - } else { + pdata = (struct search_pipe_data *)calloc(1,sizeof(struct search_pipe_data)); + pdata->cmd = SEARCH_PIPE_CMD_SET_LAYOUT; + pdata->search_ret = thread_data->is_search_result; - int offset = 0; + if (ecore_thread_check(th) == EINA_TRUE) + return; - 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; - } + ecore_pipe_write(ad->pipe, &pdata, sizeof(struct search_pipe_data)); - i++; - } + SEARCH_FREE(thread_data->keyword); + SEARCH_FREE(thread_data); - if(is_search_result == 0) { - return SEARCH_RET_SEARCH_NONE; - } else { - return SEARCH_RET_SEARCH_SUCCESS; - } - } + SEARCH_FUNC_END; } -Eina_Bool search_set_result_list(void *data) +static void __search_thread_cancel_cb(void *data, Ecore_Thread *th) +{ + SEARCH_FUNC_START; + + struct search_thread_data *thread_data = (struct search_thread_data *)data; + + SEARCH_FREE(thread_data->keyword); + SEARCH_FREE(thread_data); + + SEARCH_FUNC_END; +} + +void search_stop_search(void *data) { SEARCH_FUNC_START; struct appdata *ad = (struct appdata *)data; - char *text; + + if (ad->search_thread) { + ecore_thread_cancel(ad->search_thread); + ad->search_thread = NULL; + } + + if (ad->search_timer) { + ecore_timer_del(ad->search_timer); + ad->search_timer = NULL; + } + + SEARCH_FUNC_END; +} + +Ecore_Thread* search_make_result_thread(void *data) +{ + SEARCH_FUNC_START; + int ret = 0; + Ecore_Thread *th = NULL; + struct appdata *ad = (struct appdata *)data; + struct search_thread_data *thread_data = NULL; + + /* set keyword to vconf for save last search histroy */ + ret = vconf_set_str(SMARTSEARCH_KEY_KEYWORD, ad->not_markup_search_word); + + if (ret < 0) + SEARCH_DEBUG_WARNING("Error : set keyword to vconf"); + + /* Create Thread for Phone Search */ + thread_data = (struct search_thread_data *)calloc(1, sizeof(struct search_thread_data)); + thread_data->ad = ad; + thread_data->is_search_result = SEARCH_RET_SEARCH_NONE; + thread_data->keyword = strdup(ad->search_word); + + th = ecore_thread_feedback_run(__search_thread_heavy_cb, + __search_thread_feedback_cb, + __search_thread_end_cb, + __search_thread_cancel_cb, + thread_data, + EINA_TRUE); + + SEARCH_FUNC_END; + return th; +} + + +void search_result_gl_init(void *data) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + + ad->pipe = ecore_pipe_add(ecore_exe_pipe_cb, ad); + eina_lock_new(&ad->mutex); + eina_condition_new(&ad->condition, &ad->mutex); + + 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_search_item_type; + ad->itc_pslist_1line->func.content_get = __search_gl_content_get_search_item_type; + ad->itc_pslist_1line->func.state_get = __search_gl_state_get; + ad->itc_pslist_1line->func.del = __search_gl_del; + } + + if (ad->itc_pslist_1line_1icon == NULL) { + ad->itc_pslist_1line_1icon = elm_genlist_item_class_new(); + ad->itc_pslist_1line_1icon->item_style = "1text.1icon.2.tb"; + ad->itc_pslist_1line_1icon->func.text_get = __search_gl_label_get_search_item_type; + ad->itc_pslist_1line_1icon->func.content_get = __search_gl_content_get_search_item_type; + ad->itc_pslist_1line_1icon->func.state_get = __search_gl_state_get; + ad->itc_pslist_1line_1icon->func.del = __search_gl_del; + } + + if (ad->itc_pslist_1line_2icon == NULL) { + ad->itc_pslist_1line_2icon = elm_genlist_item_class_new(); + ad->itc_pslist_1line_2icon->item_style = "1text.2icon.6.tb"; + ad->itc_pslist_1line_2icon->func.text_get = __search_gl_label_get_search_item_type; + ad->itc_pslist_1line_2icon->func.content_get = __search_gl_content_get_search_item_type; + ad->itc_pslist_1line_2icon->func.state_get = __search_gl_state_get; + ad->itc_pslist_1line_2icon->func.del = __search_gl_del; + } + + if (ad->itc_pslist_2line_1icon == NULL) { + ad->itc_pslist_2line_1icon = elm_genlist_item_class_new(); + ad->itc_pslist_2line_1icon->item_style = "2text.1icon.4.tb"; + ad->itc_pslist_2line_1icon->func.text_get = __search_gl_label_get_search_item_type; + ad->itc_pslist_2line_1icon->func.content_get = __search_gl_content_get_search_item_type; + ad->itc_pslist_2line_1icon->func.state_get = __search_gl_state_get; + ad->itc_pslist_2line_1icon->func.del = __search_gl_del; + } + + if (ad->itc_pslist_2line_2icon == NULL) { + ad->itc_pslist_2line_2icon = elm_genlist_item_class_new(); + ad->itc_pslist_2line_2icon->item_style = "2text.2icon.4.tb"; + ad->itc_pslist_2line_2icon->func.text_get = __search_gl_label_get_search_item_type; + ad->itc_pslist_2line_2icon->func.content_get = __search_gl_content_get_search_item_type; + ad->itc_pslist_2line_2icon->func.state_get = __search_gl_state_get; + ad->itc_pslist_2line_2icon->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_group; + ad->itc_grouptitle->func.state_get = __search_gl_state_get; + ad->itc_grouptitle->func.del = __search_gl_del_grouptitle; + } + + if (ad->itc_label == NULL) { + ad->itc_label = elm_genlist_item_class_new(); + ad->itc_label->item_style = "grouptitle"; + ad->itc_label->func.text_get = __search_gl_label_get_normal_type; + ad->itc_label->func.state_get = __search_gl_state_get; + ad->itc_label->func.del = __search_gl_del_grouptitle; + } + + 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_more_button; + } + + 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; + + ecore_pipe_del(ad->pipe); + eina_condition_free(&ad->condition); + eina_lock_free(&ad->mutex); + + if (ad->itc_pslist_1line != NULL) + elm_genlist_item_class_free(ad->itc_pslist_1line); + + if (ad->itc_pslist_1line_1icon != NULL) + elm_genlist_item_class_free(ad->itc_pslist_1line_1icon); + + if (ad->itc_pslist_1line_2icon != NULL) + elm_genlist_item_class_free(ad->itc_pslist_2line_1icon); + + if (ad->itc_pslist_2line_1icon != NULL) + elm_genlist_item_class_free(ad->itc_pslist_2line_1icon); + + if (ad->itc_pslist_2line_2icon != NULL) + elm_genlist_item_class_free(ad->itc_pslist_2line_2icon); + + if (ad->itc_grouptitle != NULL) + elm_genlist_item_class_free(ad->itc_grouptitle); + + if (ad->itc_label != NULL) + elm_genlist_item_class_free(ad->itc_label); + + if (ad->itc_listmore != NULL) + elm_genlist_item_class_free(ad->itc_listmore); + + SEARCH_FUNC_END; +} + + +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; + struct search_pipe_data *pdata = NULL; + struct search_genlist_info *result_info = NULL; + struct search_item_more_sel *sel_more = + (search_item_more_sel *)elm_object_item_data_get(it); + + struct search_content_object *content_obj = sel_more->obj; + int offset = content_obj->mr_info.next_point; + int ret = SEARCH_RET_SEARCH_NONE; + + elm_object_item_del(it); + + result_info = (struct search_genlist_info *)calloc(1, sizeof(struct search_genlist_info)); + ret = __search_gl_set_phone_search_result(content_obj, + offset, + ad->search_word, + ad, + result_info); + + pdata = (struct search_pipe_data *)calloc(1,sizeof(struct search_pipe_data)); + pdata->cmd = SEARCH_PIPE_CMD_ADD_GENLIST_PHONE; + pdata->obj = NULL; + pdata->result_list = result_info; + pdata->search_ret = ret; + ecore_pipe_write(ad->pipe, &pdata, sizeof(struct search_pipe_data)); + + pdata = (struct search_pipe_data *)calloc(1,sizeof(struct search_pipe_data)); + pdata->cmd = SEARCH_PIPE_CMD_SET_LAYOUT; + pdata->search_ret = ret; + ecore_pipe_write(ad->pipe, &pdata, sizeof(struct search_pipe_data)); + + SEARCH_FUNC_END; +} + +void search_set_result_list(void *data) +{ + struct appdata *ad = (struct appdata *)data; + int category = ad->search_category; + bool is_input_keyword = false; - char* escape_added_keyword = NULL; - int bind_type = 0; - int search_ret = SEARCH_RET_SEARCH_NONE; + struct search_pipe_data *pipe_data = NULL; + char *text = NULL; - SEARCH_ASSERT_IF(!ad); + search_stop_search(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); + } else if ( category == SEARCH_CATE_PHONE) { + pipe_data = (struct search_pipe_data *)calloc(1, sizeof(struct search_pipe_data)); + pipe_data->cmd = SEARCH_PIPE_CMD_SET_LAYOUT; + pipe_data->search_ret = SEARCH_RET_SEARCH_NONE; + ecore_pipe_write(ad->pipe, &pipe_data, sizeof(struct search_pipe_data)); + return; } - 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; + /* If category is Phone, make a thread for search */ + pipe_data = (struct search_pipe_data *)calloc(1, sizeof(struct search_pipe_data)); + pipe_data->cmd = SEARCH_PIPE_CMD_CLEAR_GENLIST; + ecore_pipe_write(ad->pipe, &pipe_data, sizeof(struct search_pipe_data)); - return EINA_FALSE; + switch(category) { + case SEARCH_CATE_PHONE: + ad->search_thread = search_make_result_thread(ad); + break; + } } void search_layout_set_search_list(void* data) @@ -537,10 +1043,13 @@ void search_layout_set_search_list(void* data) elm_object_part_content_unset(ad->sb_layout,"list_noresult"); evas_object_hide(ad->noresult_view); + if (ad->search_gl) { elm_object_part_content_set(ad->sb_layout, "list", ad->search_gl); evas_object_show(ad->search_gl); } + } + if (ad->search_gl) elm_genlist_item_show(elm_genlist_first_item_get(ad->search_gl), ELM_GENLIST_ITEM_SCROLLTO_TOP); SEARCH_FUNC_END; @@ -555,6 +1064,8 @@ void search_layout_set_search_no_result(void* data) if (elm_object_part_content_get(ad->sb_layout,"list")) { elm_object_part_content_unset(ad->sb_layout, "list"); + + if (ad->search_gl) evas_object_hide(ad->search_gl); elm_object_part_content_set(ad->sb_layout,"list_noresult", ad->noresult_view); @@ -583,5 +1094,5 @@ int search_layout_get_content_list_set_status(void* data) return ret; } - + 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 #include -#include -#include +#include -#include -#include -#include -#include -#include +#include +#include -#include +#include +#include +#include -static GList *g_history_list; +#include +#include +#include +#include +#include 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;itype = 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; jnCount; 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; + +} diff --git a/src/search_bar.cpp b/src/search_bar.cpp index 9403621..bcb3978 100755 --- a/src/search_bar.cpp +++ b/src/search_bar.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. @@ -23,11 +23,17 @@ #include "smartsearch.h" #include "Elementary.h" -static const char* g_search_category_icon[SEARCH_CATE_BTN_IMG_TYPE_MAX] = +Eina_Bool __search_entry_timer_cb(void *data) { - "B10_Phone.png", - "B10_Phone_press.png", -}; + SEARCH_FUNC_START; + struct appdata *ad = (struct appdata *)data; + + search_set_result_list(ad); + ad->search_timer = NULL; + + SEARCH_FUNC_END; + return ECORE_CALLBACK_CANCEL; +} void __search_searchbar_entry_changed_cb(void *data, Evas_Object * obj, void *event_info) @@ -46,7 +52,7 @@ void __search_searchbar_entry_changed_cb(void *data, Evas_Object * obj, else elm_object_signal_emit(ad->search_bar, "elm,state,eraser,show", "elm"); } else { - if (elm_entry_is_empty(ad->search_entry)) + if (elm_entry_is_empty(ad->search_entry)) elm_object_signal_emit(ad->search_bar, "elm,state,guidetext,show", "elm"); else elm_object_signal_emit(ad->search_bar, "elm,state,guidetext,hide", "elm"); @@ -56,11 +62,11 @@ void __search_searchbar_entry_changed_cb(void *data, Evas_Object * obj, && (SEARCH_STRCMP(text, ad->search_word) == 0)) { SEARCH_DEBUG_LOG("text is same as prev text"); } else { - if(ad->idler_search) - ecore_idler_del(ad->idler_search); - - ad->idler_search = ecore_idler_add(search_set_result_list, ad); - } + /* Make timer for check user's input */ + search_stop_search(ad); + + ad->search_timer = ecore_timer_add(0.4, __search_entry_timer_cb, ad); + } SEARCH_FUNC_END; return; @@ -185,21 +191,21 @@ __search_searchbar_state_event_cb(void *data, Ecore_IMF_Context *imf_context, in { case ECORE_IMF_INPUT_PANEL_STATE_SHOW: evas_object_smart_callback_add( - ad->search_gl, - "scroll,drag,start", - __search_searchbar_gl_drag_scroll_start_cb, - data); + ad->search_gl, + "scroll,drag,start", + __search_searchbar_gl_drag_scroll_start_cb, + data); break; case ECORE_IMF_INPUT_PANEL_STATE_HIDE: - // ISE state has changed to ISE_STATE_HIDE status + /* ISE state has changed to ISE_STATE_HIDE status */ evas_object_smart_callback_del( - ad->search_gl, - "scroll,drag,start", + ad->search_gl, + "scroll,drag,start", __search_searchbar_gl_drag_scroll_start_cb); break; } - SEARCH_FUNC_END; + SEARCH_FUNC_END; } static void __search_searchbar_create(void *data) @@ -264,7 +270,7 @@ static void __search_searchbar_create(void *data) elm_object_part_content_set(ad->search_bar, "button_cancel", ad->search_cancel_btn); elm_object_style_set(ad->search_cancel_btn, "searchbar/default"); elm_object_text_set(ad->search_cancel_btn, dgettext("sys_string", "IDS_COM_SK_CANCEL")); - + ad->search_entry = elm_entry_add(ad->search_bar); elm_entry_scrollable_set(ad->search_entry, EINA_TRUE); elm_entry_single_line_set(ad->search_entry, EINA_TRUE); @@ -295,7 +301,7 @@ static void __search_searchbar_create(void *data) "elm", __search_searchbar_eraser_clicked_cb, ad); - + /* Set Search-Entry Callback */ evas_object_smart_callback_add( ad->search_entry, @@ -320,7 +326,7 @@ static void __search_searchbar_create(void *data) ad); evas_object_event_callback_add( ad->search_entry, - EVAS_CALLBACK_KEY_DOWN, + EVAS_CALLBACK_KEY_DOWN, __search_searchbar_key_down_cb, ad); @@ -353,21 +359,25 @@ static Evas_Object *__search_init_noresult_view(void *data) return noc; } -Evas_Object *search_searchbar_category_icon_add(int cate_type, int press_type, Evas_Object *parent) +Evas_Object *search_searchbar_category_icon_add(char* img, Evas_Object *parent) { SEARCH_FUNC_START; - Evas_Object* cate_icon; - char buf[128] = { 0, }; + char buf[MAX_LENGTH_PER_PATH] = { 0, }; + Evas_Object* cate_icon = NULL; + if( img != NULL ) { cate_icon = elm_icon_add(parent); - - snprintf(buf, sizeof(buf), SEARCH_ICON_PATH "%s", g_search_category_icon[press_type]); + + snprintf(buf, sizeof(buf), SEARCH_ICON_PATH "%s", img); + + SEARCH_DEBUG_LOG("buf : %s", buf); elm_icon_file_set(cate_icon, buf, NULL); evas_object_size_hint_aspect_set(cate_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - elm_icon_resizable_set(cate_icon, EINA_TRUE, EINA_TRUE); + elm_icon_resizable_set(cate_icon, EINA_FALSE, EINA_FALSE); + } SEARCH_FUNC_END; @@ -379,11 +389,11 @@ void search_searchbar_cb(void *data, Evas_Object * obj, void *event_info) SEARCH_FUNC_START; struct appdata *ad = (struct appdata *)data; - + Evas_Object *cate_btn; Evas_Object *cate_icon; int category = 0; - int err = 0; + char *imgpath = NULL; /* create layout */ @@ -392,20 +402,19 @@ void search_searchbar_cb(void *data, Evas_Object * obj, void *event_info) SEARCH_EDJ, "smartsearch/search_result"); - category = SEARCH_TYPE_PHONE; + category = SEARCH_CATE_PHONE; - cate_icon = search_searchbar_category_icon_add(category, - SEARCH_CATE_BTN_IMG_TYPE_UNPRESSED, - ad->sb_layout); + imgpath = ad->category_info[ad->search_category].btn_icon_path; + cate_icon = search_searchbar_category_icon_add(imgpath, ad->sb_layout); cate_btn = elm_button_add(ad->sb_layout); elm_object_content_set(ad->cate_btn, cate_icon); - + evas_object_show(cate_btn); ad->cate_btn = cate_btn; elm_object_part_content_set(ad->sb_layout, "searchbar_area_category", cate_btn); - + /* set search bar area */ __search_searchbar_create(ad); elm_object_part_content_set(ad->sb_layout, "searchbar_area_entry", ad->search_bar); @@ -413,12 +422,12 @@ void search_searchbar_cb(void *data, Evas_Object * obj, void *event_info) /* set search result area */ ad->noresult_view = __search_init_noresult_view(ad); - elm_object_part_content_set(ad->sb_layout, + elm_object_part_content_set(ad->sb_layout, "list_noresult", ad->noresult_view); evas_object_size_hint_weight_set( - ad->sb_layout, + ad->sb_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); diff --git a/src/smartsearch.cpp b/src/smartsearch.cpp index f37725e..b751625 100755 --- a/src/smartsearch.cpp +++ b/src/smartsearch.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. @@ -28,13 +28,50 @@ #include "ps_makeupviews.h" #include "ps_searcher.h" -#include -#include -#include -#include -#include - -static int __search_app_terminate(void *data); +#include +#include + +struct search_content_object_default { + int order; + int visible; + char name[DEF_BUF_LEN]; + int string_type; + int contents_type; + int category_type; + char def_pkg_name[DEF_BUF_LEN]; +}; + +struct search_category_info_default { + char btn_icon_path[MAX_LENGTH_PER_PATH]; + char btn_icon_press_path[MAX_LENGTH_PER_PATH]; +}; + +static struct search_content_object_default def_obj[SEARCH_CONT_MAX] = { + { 0, EINA_TRUE, "IDS_COM_BODY_CONTACTS", SEARCH_STR_TYPE_SYSTEM_STRING, + SEARCH_CONT_PHONE_CONTACTS, SEARCH_OBJ_PHONE_CONTENTS, "org.tizen.contacts" }, + { 1, EINA_TRUE, "IDS_COM_BODY_MESSAGES", SEARCH_STR_TYPE_SYSTEM_STRING, + SEARCH_CONT_PHONE_MSG, SEARCH_OBJ_PHONE_CONTENTS, "org.tizen.message" }, + { 2, EINA_TRUE, "IDS_COM_BODY_EMAIL", SEARCH_STR_TYPE_SYSTEM_STRING, + SEARCH_CONT_PHONE_EMAIL, SEARCH_OBJ_PHONE_CONTENTS, "org.tizen.email" }, + { 3, EINA_TRUE, "IDS_COM_BODY_IMAGES", SEARCH_STR_TYPE_SYSTEM_STRING, + SEARCH_CONT_PHONE_IMAGES, SEARCH_OBJ_PHONE_CONTENTS, "org.tizen.image-viewer"}, + { 4, EINA_TRUE, "IDS_COM_BODY_MUSIC", SEARCH_STR_TYPE_SYSTEM_STRING, + SEARCH_CONT_PHONE_MUSIC, SEARCH_OBJ_PHONE_CONTENTS, "org.tizen.music-player"}, + { 5, EINA_TRUE, "IDS_COM_BODY_VIDEOS", SEARCH_STR_TYPE_SYSTEM_STRING, + SEARCH_CONT_PHONE_VIDEO, SEARCH_OBJ_PHONE_CONTENTS, "org.tizen.video-player"}, + { 6, EINA_TRUE, "IDS_COM_BODY_CALENDAR", SEARCH_STR_TYPE_SYSTEM_STRING, + SEARCH_CONT_PHONE_CALENDAR, SEARCH_OBJ_PHONE_CONTENTS, "org.tizen.efl-calendar"}, + { 7, EINA_TRUE, "IDS_COM_BODY_MEMO", SEARCH_STR_TYPE_SYSTEM_STRING, + SEARCH_CONT_PHONE_MEMO, SEARCH_OBJ_PHONE_CONTENTS, "org.tizen.memo"}, + { 8, EINA_TRUE, "IDS_COM_BODY_APPLICATIONS", SEARCH_STR_TYPE_SYSTEM_STRING, + SEARCH_CONT_PHONE_MENU, SEARCH_OBJ_PHONE_CONTENTS, {0} }, + { 9, EINA_TRUE, "IDS_COM_BODY_INTERNET", SEARCH_STR_TYPE_SYSTEM_STRING, + SEARCH_CONT_PHONE_BROWSER, SEARCH_OBJ_PHONE_CONTENTS, "org.tizen.browser"}, +}; + +static struct search_category_info_default def_category[SEARCH_CATE_MAX] = { + { "B10_btn_icon_Phone.png", "B10_btn_icon_Phone_press.png" }, +}; static void __search_win_delete_cb(void *data, Evas_Object * obj, void *event_info) @@ -65,7 +102,7 @@ static Eina_Bool __search_keydown_event(void *data, int type, void *event) Ecore_Event_Key *ev = (Ecore_Event_Key *) event; - if (!SEARCH_STRCMP(ev->keyname, KEY_END)) { + if (!SEARCH_STRCMP(ev->keyname, KEY_END)) { //end key concept is close. elm_exit(); } @@ -99,9 +136,9 @@ static Evas_Object *__search_create_layout_main(Evas_Object * parent) evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(parent, bg); elm_object_part_content_set(layout, "elm.swallow.bg", bg); - + evas_object_show(bg); - + edje_object_signal_emit(_EDJ(layout), "elm,state,show,indicator","elm"); edje_object_signal_emit(_EDJ(layout), "elm,state,show,content", "elm"); evas_object_show(layout); @@ -133,9 +170,9 @@ static Evas_Object *__search_create_navigation_layout(Evas_Object * parent) static void __search_back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info) { SEARCH_FUNC_START; - + struct appdata *ad = (struct appdata *)data; - + elm_win_lower(ad->win_main); if(ad->back_btn_type == BACK_BTN_TYPE_CLOSE) @@ -148,22 +185,20 @@ static void __search_add_back_btn(struct appdata *ad) { SEARCH_FUNC_START; - Elm_Object_Item *navi_it; - /* add back key */ Evas_Object *btn = elm_button_add(ad->navi_bar); elm_object_style_set(btn, "naviframe/end_btn/default"); evas_object_smart_callback_add(btn, "clicked", __search_back_btn_clicked_cb, ad); #ifdef __ENABLE_TOP_BACK_BTN - navi_it = elm_naviframe_item_push(ad->navi_bar, + ad->navi_it = elm_naviframe_item_push(ad->navi_bar, dgettext("sys_string", "IDS_COM_BODY_SEARCH"), NULL, NULL, ad->sb_layout, NULL); elm_object_item_part_content_set(navi_it, "title_right_btn", btn); elm_object_item_signal_emit(navi_it, "elm,state,controlbar,close", ""); #else - elm_naviframe_item_push(ad->navi_bar, + ad->navi_it = elm_naviframe_item_push(ad->navi_bar, dgettext("sys_string", "IDS_COM_BODY_SEARCH"), btn, NULL, ad->sb_layout, NULL); #endif @@ -171,7 +206,7 @@ static void __search_add_back_btn(struct appdata *ad) ad->back_btn = btn; SEARCH_FUNC_END; -} +} static int __search_init_smartsearch(struct appdata *ad) { @@ -189,8 +224,7 @@ static int __search_init_smartsearch(struct appdata *ad) // Navigation Bar ad->navi_bar = __search_create_navigation_layout(ad->layout_main); - search_result_gl_init(ad); - + ad->search_category = SEARCH_CATE_PHONE; search_searchbar_cb(ad, NULL, NULL); __search_add_back_btn(ad); @@ -199,35 +233,133 @@ static int __search_init_smartsearch(struct appdata *ad) return 0; } -static int __search_deinit_smartsearch(struct appdata *ad) +static void __search_init_result_object(struct appdata *ad) { SEARCH_FUNC_START; - SEARCH_RETV_IF(ad == NULL, -1); + int i = 0; + int rc = 0; + int ret = SEARCH_RET_SEARCH_NONE; - search_result_gl_deinit(ad); + ail_appinfo_h handle = NULL; + ail_error_e ail_ret = AIL_ERROR_OK; + char *str = NULL; - SEARCH_FUNC_END; + sqlite3_stmt *sql_load = NULL; + sqlite3_stmt *sql_insert = NULL; - return 0; + /* Load DB data */ + sql_load = ad->search_db_sql[SEARCH_STMT_GET_CATEGORY_LIST_ALL]; + + rc = sqlite3_step(sql_load); + if (rc != SQLITE_ROW) { + if (rc == SQLITE_DONE) { + SEARCH_DEBUG_WARNING("SELECT STEP : SQLITE_DONE. No result"); + ret = SEARCH_RET_SEARCH_NONE; + } else { + SEARCH_DEBUG_ERROR("SELECT STEP FAIL : (%d)", rc); + ret = SEARCH_RET_SEARCH_FAIL; + } + } else { + SEARCH_DEBUG_LOG("SELECT STEP SUCCESS"); + ret = SEARCH_RET_SEARCH_SUCCESS; +} + + /* Initialize Category */ + for( i = 0 ; i < SEARCH_CATE_MAX; ++i ) { + ad->category_info[i].btn_icon_path = strdup(def_category[i].btn_icon_path); + ad->category_info[i].btn_icon_press_path = strdup(def_category[i].btn_icon_press_path); + } + + if( ret != SEARCH_RET_SEARCH_SUCCESS ) { + /* If db result is NULL, initialize to default setting and insert this data to DB */ + for( i = 0; i < SEARCH_CONT_MAX ; ++i ) { + sql_insert = ad->search_db_sql[SEARCH_STMT_INSERT_OBJECT_INFO]; + ad->result_obj[i].order = def_obj[i].order; + ad->result_obj[i].visible = def_obj[i].visible; + ad->result_obj[i].contents_type = def_obj[i].contents_type; + ad->result_obj[i].category_type = def_obj[i].category_type; + ad->result_obj[i].name = strdup(def_obj[i].name); + ad->result_obj[i].string_type = def_obj[i].string_type; + ad->result_obj[i].def_pkg_name = strdup(def_obj[i].def_pkg_name); + + ail_ret = ail_package_get_appinfo(def_obj[i].def_pkg_name, &handle); + + if (ail_ret == AIL_ERROR_OK) { + ret = ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &str); + + if (ail_ret == AIL_ERROR_OK) + ad->result_obj[i].obj_icon_path = strdup(str); } + /* Insert DB */ + search_sql_bind_text(ad->search_db_hd, sql_insert, 1, ad->result_obj[i].name); + search_sql_bind_int(ad->search_db_hd, sql_insert, 2, ad->result_obj[i].string_type); + search_sql_bind_int(ad->search_db_hd, sql_insert, 3, ad->result_obj[i].visible); + search_sql_bind_int(ad->search_db_hd, sql_insert, 4, ad->result_obj[i].order); + search_sql_bind_int(ad->search_db_hd, sql_insert, 5, ad->result_obj[i].contents_type); + search_sql_bind_int(ad->search_db_hd, sql_insert, 6, ad->result_obj[i].category_type); + search_sql_bind_text(ad->search_db_hd, sql_insert, 7, ad->result_obj[i].def_pkg_name); + + rc = sqlite3_step(sql_insert); + + if( sql_insert != NULL ) + search_sql_stmt_init(sql_insert); + } + } else { + /* Copy db data to structure */ + for(i = 0; i < SEARCH_CONT_MAX && rc == SQLITE_ROW; ++i) { + char *name = (char *)sqlite3_column_text(sql_load, 0); + int string_type = sqlite3_column_int(sql_load, 1); + int visible = sqlite3_column_int(sql_load, 2); + int order = sqlite3_column_int(sql_load, 3); + int contents_type = sqlite3_column_int(sql_load, 4); + int category_type = sqlite3_column_int(sql_load, 5); + char *def_pkg_name = (char *)sqlite3_column_text(sql_load, 6); + + ad->result_obj[i].order = order; + ad->result_obj[i].contents_type = contents_type; + ad->result_obj[i].string_type = string_type; + ad->result_obj[i].category_type = category_type; + ad->result_obj[i].name = ( name != NULL ) ? strdup(name): NULL; + ad->result_obj[i].visible = ( visible > 0 ) ? EINA_TRUE : EINA_FALSE; + ad->result_obj[i].def_pkg_name = ( def_pkg_name != NULL) ? + strdup(def_pkg_name) : NULL; + + if (def_pkg_name) { + ail_ret = ail_package_get_appinfo(def_pkg_name, &handle); + + if (ail_ret == AIL_ERROR_OK) { + ret = ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &str); + + if (ail_ret == AIL_ERROR_OK) + ad->result_obj[i].obj_icon_path = strdup(str); + } + } + + rc = sqlite3_step(sql_load); + } + } + + if( sql_load != NULL ) + search_sql_stmt_init(sql_load); + if( sql_insert != NULL ) + search_sql_stmt_init(sql_insert); + + SEARCH_FUNC_END; + } + static Evas_Object *__search_create_win(const char *name) -{ + { SEARCH_FUNC_START; Evas_Object *eo; - int w, h; eo = elm_win_add(NULL, name, ELM_WIN_BASIC); if (eo) { elm_win_title_set(eo, name); - elm_win_borderless_set(eo, EINA_TRUE); evas_object_smart_callback_add(eo, "delete,request", __search_win_delete_cb, NULL); - ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, - &h); - evas_object_resize(eo, w, h); } SEARCH_FUNC_END; @@ -235,149 +367,69 @@ static Evas_Object *__search_create_win(const char *name) return eo; } -static int __search_init_app_connect(struct appdata *ad) +static int __search_init_db_connect(struct appdata *ad) { SEARCH_FUNC_START; - int rc = 0, conn_ret = 0, type = 0; - char sql_query[DB_QUERY_LEN] = { 0, }; - int ret = SEARCH_RET_SUCCESS; - - for (type = 0; type < PHONE_CATEGORY_LIST_CNT; type++) { + int rc = 0; + int ret = SEARCH_RET_FAIL; + + rc = db_util_open(SEARCH_DB_PATH, + &(ad->search_db_hd), + 0); + if (rc != SQLITE_OK) { + SEARCH_DEBUG_ERROR + ("db_util_open error : %d (%s)\n", + rc, SEARCH_DB_PATH); + ret = SEARCH_RET_FAIL; + } else { + int i = 0; + const char *query_list[SEARCH_STMT_MAX] = { SEARCH_DB_SQL_GET_CATEGORY_LIST_ALL, + SEARCH_DB_SQL_INSERT_OBJECT_IFNO, + SEARCH_DB_SQL_UPDATE_OBJECT_INFO + }; - switch(type) { + for (i = SEARCH_STMT_GET_CATEGORY_LIST_ALL; i < SEARCH_STMT_MAX ; ++i ) { + SEARCH_DEBUG_LOG("query : %s\n", query_list[i]); - case SEARCH_TYPE_PHONE_CONTACTS: - { - rc = contacts_svc_connect(); - if (rc != CTS_SUCCESS) { - SEARCH_DEBUG_WARNING - ("contacts svc connect fail : %d", - rc); + ret = search_sql_prepare_stmt(ad->search_db_hd, query_list[i], + &(ad->search_db_sql[i])); } } - break; - case SEARCH_TYPE_PHONE_MSG: - { - MSG_ERROR_T err = MSG_SUCCESS; - err = msg_open_msg_handle(&ad->msg_handle); - - if (err != MSG_SUCCESS) { - SEARCH_DEBUG_WARNING("msg_open_msg_handle error : %d", err); - ad->msg_handle = NULL; - } - } - break; - case SEARCH_TYPE_PHONE_EMAIL: - break; - - /* IMAGE, MUSIC, VIDEO use common handle */ - case SEARCH_TYPE_PHONE_IMAGES: - case SEARCH_TYPE_PHONE_MUSIC: - case SEARCH_TYPE_PHONE_VIDEO: - if( ad->media_handle == NULL ) { - conn_ret = media_svc_connect(&ad->media_handle); - if(conn_ret < 0) { - SEARCH_DEBUG_WARNING("media_svc_connect failed : %d\n", conn_ret); - ad->media_handle = NULL; - } - } - break; - case SEARCH_TYPE_PHONE_CALENDAR: - { - rc = calendar_svc_connect(); - if (rc != CAL_SUCCESS) { - SEARCH_DEBUG_WARNING - ("calendar svc connect fail : %d", - rc); - } - } - break; - case SEARCH_TYPE_PHONE_MEMO: - { - rc = memo_init(NULL); - if (rc == -1) { - SEARCH_DEBUG_WARNING - ("memo svc connect fail : %d", rc); - } - } - break; - } - } + return ret; SEARCH_FUNC_END; + } - return ret; -} - -static int __search_deinit_app_disconnect(void *data) -{ +static void __search_deinit_db_connect(struct appdata *ad) + { SEARCH_FUNC_START; - struct appdata *ad = (struct appdata *)data; - - int rc = 0, conn_ret = 0, type = 0; + int i = 0, rc = 0; - for (type = 0; type < PHONE_CATEGORY_LIST_CNT; type++) { - switch (type) { - - case SEARCH_TYPE_PHONE_CONTACTS: - { - rc = contacts_svc_disconnect(); - if (rc != CTS_SUCCESS) { - SEARCH_DEBUG_WARNING - ("contacts svc disconnect fail : %d", - rc); + for (i = SEARCH_STMT_GET_CATEGORY_LIST_ALL; i < SEARCH_STMT_MAX ; ++i ) { + if (ad->search_db_sql[i]) { + search_sql_stmt_finalize(ad->search_db_sql[i]); + ad->search_db_sql[i] = NULL; } } - break; - case SEARCH_TYPE_PHONE_MSG: - { - MSG_ERROR_T err = MSG_SUCCESS; - err = msg_close_msg_handle(&ad->msg_handle); - - if (err != MSG_SUCCESS) { - SEARCH_DEBUG_WARNING("msg_close_msg_handle error : %d", err); - } - ad->msg_handle = NULL; - } - break; - case SEARCH_TYPE_PHONE_EMAIL: - break; - case SEARCH_TYPE_PHONE_IMAGES: - case SEARCH_TYPE_PHONE_MUSIC: - case SEARCH_TYPE_PHONE_VIDEO: - { - conn_ret = media_svc_disconnect(ad->media_handle); - if(conn_ret < 0) { - SEARCH_DEBUG_WARNING("media_svc_disconnect failed : %d\n", conn_ret); - } - ad->media_handle = NULL; - } - break; - case SEARCH_TYPE_PHONE_CALENDAR: - { - rc = calendar_svc_close(); - if (rc != CAL_SUCCESS) { + if (ad->search_db_hd) { + rc = db_util_close(ad->search_db_hd); + if (rc != SQLITE_OK) { SEARCH_DEBUG_WARNING - ("calendar svc disconnect fail : %d", - rc); - } - } - break; - case SEARCH_TYPE_PHONE_MEMO: - { - memo_fini(); - } - break; + ("db_util_close error : %d / %s", + rc, SEARCH_DB_PATH); + } else { + SEARCH_DEBUG_LOG("db_util_close success"); } + ad->search_db_hd = NULL; + } else { + SEARCH_DEBUG_WARNING("db_handle(%s) is null", SEARCH_DB_PATH); } SEARCH_FUNC_END; - - return 0; } static Eina_Bool __search_init_after_ui_create(gpointer data) @@ -386,17 +438,17 @@ static Eina_Bool __search_init_after_ui_create(gpointer data) struct appdata *ad = (struct appdata *)data; - ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, + ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, __search_keydown_event, ad); - ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, + ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, __search_mousedown_event, ad); /* add system event callback */ appcore_set_event_callback(APPCORE_EVENT_REGION_CHANGE, - search_util_date_time_format_init, + search_util_date_time_format_init, NULL); UG_INIT_EFL(ad->win_main, UG_OPT_INDICATOR_ENABLE); @@ -406,7 +458,44 @@ static Eina_Bool __search_init_after_ui_create(gpointer data) return ECORE_CALLBACK_CANCEL; } -static int __search_app_create(void *data) + +static void __search_update_lang(void *data) +{ + SEARCH_FUNC_START; + struct appdata *ad = (struct appdata *)data; + int i = 0; + + /* Update Text for match to current language */ + if (ad->navi_it) + elm_object_item_text_set(ad->navi_it, + dgettext("sys_string", "IDS_COM_BODY_SEARCH")); + + if (ad->search_bar) + elm_object_part_text_set(ad->search_bar, + "elm.guidetext", + dgettext("sys_string", "IDS_COM_BODY_SEARCH")); + if (ad->noresult_view) + elm_object_part_text_set(ad->noresult_view, + "elm.text", + dgettext("sys_string", "IDS_COM_BODY_NO_SEARCH_RESULTS")); + + if (ad->search_cancel_btn) + elm_object_text_set(ad->search_cancel_btn, + dgettext("sys_string", + "IDS_COM_SK_CANCEL")); + + for (i = 0; i < SEARCH_CONT_MAX; i++) { + Elm_Object_Item *it = ad->result_obj[i].gl_result_grp; + const char *item_name = ad->result_obj[i].name; + + if (it && item_name) + elm_genlist_item_fields_update(it, "elm.text", ELM_GENLIST_ITEM_FIELD_TEXT); + } + + SEARCH_FUNC_END; +} + +static bool __search_app_create(void *data) { SEARCH_FUNC_START; @@ -423,23 +512,26 @@ static int __search_app_create(void *data) ad->scale_factor = elm_config_scale_get(); __search_init_smartsearch(ad); - + search_result_gl_init(ad); search_util_date_time_format_init(NULL); - __search_init_app_connect(ad); + __search_init_db_connect(ad); + __search_init_result_object(ad); + search_app_connect(ad); ad->idler_create_ui = ecore_idler_add(__search_init_after_ui_create, ad); SEARCH_FUNC_END; - return 0; + return true; } -static int __search_app_terminate(void *data) +static void __search_app_terminate(void *data) { SEARCH_FUNC_START; struct appdata *ad = (struct appdata *)data; + int i = 0; if (ad->layout_main) { evas_object_del(ad->layout_main); @@ -453,34 +545,42 @@ static int __search_app_terminate(void *data) if(ad->idler_create_ui) ecore_idler_del(ad->idler_create_ui); - + if(ad->idler_search) ecore_idler_del(ad->idler_search); - - __search_deinit_smartsearch(ad); - __search_deinit_app_disconnect(ad); + search_result_gl_deinit(ad); + + search_app_disconnect(ad); + __search_deinit_db_connect(ad); search_util_date_time_format_deinit(); + for ( i = 0 ; i < SEARCH_CONT_MAX ; ++i ) { + SEARCH_FREE(ad->result_obj[i].name); + SEARCH_FREE(ad->result_obj[i].obj_icon_path); + SEARCH_FREE(ad->result_obj[i].def_pkg_name); + } + + for ( i = 0 ; i < SEARCH_CATE_MAX ; ++i ) { + SEARCH_FREE(ad->category_info[i].btn_icon_path); + SEARCH_FREE(ad->category_info[i].btn_icon_press_path); + } + SEARCH_FREE(ad->search_word); SEARCH_FREE(ad->not_markup_search_word); - - SEARCH_FUNC_END; - return 0; + SEARCH_FUNC_END; } -static int __search_app_pause(void *data) +static void __search_app_pause(void *data) { SEARCH_FUNC_START; SEARCH_FUNC_END; - - return 0; } -static int __search_app_resume(void *data) +static void __search_app_resume(void *data) { SEARCH_FUNC_START; @@ -490,69 +590,76 @@ static int __search_app_resume(void *data) elm_object_focus_set(ad->back_btn, EINA_FALSE); } SEARCH_FUNC_END; - - return 0; } -static int __search_app_reset(bundle * b, void *data) +static void __search_app_service(service_h service, void *data) { SEARCH_FUNC_START; struct appdata *ad = (struct appdata *)data; - const char *query = NULL; - const char *svcname = NULL; - const char *category = NULL; - char* keyword = NULL; + + char *query = NULL; + char *keyword = NULL; + char *operation = NULL; Evas_Object *cate_icon; - int ret; + int ret = 0; ad->back_btn_type = BACK_BTN_TYPE_LOWER; + ret = service_get_operation(service, &operation); - if (b == NULL) { - keyword = vconf_get_str(SMARTSEARCH_KEY_KEYWORD); - } else { - svcname = appsvc_get_operation(b); - if(svcname) { - if(SEARCH_STRCMP(svcname, APPSVC_OPERATION_SEARCH) == 0) { - query = appsvc_get_data(b, APPSVC_DATA_KEYWORD); - } else { - SEARCH_DEBUG_WARNING("wrong app service name : %s", svcname); + if (ret != 0) { + SEARCH_DEBUG_WARNING("Cannot get operation!"); + return; + } + + if(operation == NULL ) { + SEARCH_DEBUG_WARNING("Operation is NULL!"); + return; } - ad->back_btn_type = BACK_BTN_TYPE_CLOSE; - } else { - svcname = bundle_get_val(b, AUL_K_SERVICE_NAME); + SEARCH_DEBUG_LOG("SERVICE OPERATION TYPE : %s", operation); + if (SEARCH_STRCMP(operation, SERVICE_OPERATION_SEARCH) == 0) { + ret = service_get_extra_data(service, "http://tizen.org/appsvc/data/keyword", &query); - if(svcname) { - if(SEARCH_STRCMP(svcname, SEARCH_SVC) == 0) { - query = bundle_get_val(b, "query"); - } else { - SEARCH_DEBUG_WARNING("wrong aul service name : %s", svcname); - } + if(ret != 0) { + SEARCH_DEBUG_WARNING("Fail to Get Keyword data!"); + query = NULL; } - } - - cate_icon = search_searchbar_category_icon_add(SEARCH_TYPE_PHONE, SEARCH_CATE_BTN_IMG_TYPE_UNPRESSED, ad->sb_layout); - elm_object_content_set(ad->cate_btn, cate_icon); - - /* - * keyword input param is only enabled for phone search - * if there is no keyword input param, set latest search keyword for phone search - */ + if( (query) && (strlen(query) > 0) ) { keyword = (char*)malloc(strlen(query)+1); memset(keyword, 0x00, strlen(query)+1); strncpy(keyword, query, strlen(query)); - } else { - keyword = vconf_get_str(SMARTSEARCH_KEY_KEYWORD); } + ad->search_category = SEARCH_CATE_PHONE; + ad->back_btn_type = BACK_BTN_TYPE_CLOSE; + + } else { + /* If Operation type is not SEARCH, Initializae valute to default */ + keyword = vconf_get_str(SMARTSEARCH_KEY_KEYWORD); + + if (keyword == NULL) + SEARCH_DEBUG_WARNING("Error(%d) : get current key from vconf", ret); + + ad->search_category = SEARCH_CATE_PHONE; } + SEARCH_DEBUG_LOG("current category : %d", ad->search_category); + + cate_icon = search_searchbar_category_icon_add(ad->category_info[ad->search_category].btn_icon_path, + ad->sb_layout); + elm_object_content_set(ad->cate_btn, cate_icon); + + /* set current category to vconf */ + ad->search_category = SEARCH_CATE_PHONE; + if ((keyword) && (strlen(keyword) > 0)) { elm_object_text_set(ad->search_entry, keyword); } else { + SEARCH_DEBUG_LOG("keyword is NULL"); + elm_object_text_set(ad->search_entry, ""); elm_object_signal_emit(ad->search_bar, "cancel,hide", ""); @@ -565,6 +672,8 @@ static int __search_app_reset(bundle * b, void *data) } SEARCH_FREE(keyword); + SEARCH_FREE(operation); + SEARCH_FREE(query); elm_entry_cursor_end_set(ad->search_entry); @@ -572,8 +681,16 @@ static int __search_app_reset(bundle * b, void *data) elm_win_activate(ad->win_main); SEARCH_FUNC_END; +} - return 0; +static void __search_app_lang_change(void *data) +{ + SEARCH_FUNC_START; + struct appdata *ad = (struct appdata *)data; + + __search_update_lang(ad); + + SEARCH_FUNC_END; } int main(int argc, char *argv[]) @@ -581,25 +698,28 @@ int main(int argc, char *argv[]) SEARCH_FUNC_START; struct appdata ad; - struct appcore_ops ops; - int ret = 0; + int i = 0; - ops.create = &__search_app_create; - ops.terminate = &__search_app_terminate; - ops.pause = &__search_app_pause; - ops.resume = &__search_app_resume; - ops.reset = &__search_app_reset; + app_event_callback_s event_callback; + + event_callback.create = __search_app_create; + event_callback.terminate = __search_app_terminate; + event_callback.pause = __search_app_pause; + event_callback.resume = __search_app_resume; + event_callback.service = __search_app_service; + event_callback.low_memory = NULL; + event_callback.low_battery = NULL; + event_callback.device_orientation = NULL; + event_callback.language_changed = __search_app_lang_change; + event_callback.region_format_changed = NULL; memset(&ad, 0x0, sizeof(struct appdata)); - ops.data = &ad; for (i = 0; i < argc; i++) SEARCH_DEBUG_LOG("argv[%d] = [%s]\n", i, argv[i]); - ret = appcore_efl_main(SEARCH_PACKAGE, &argc, &argv, &ops); - SEARCH_FUNC_END; - return ret; + return app_efl_main(&argc, &argv, &event_callback, &ad); } -- cgit v1.2.3