summaryrefslogtreecommitdiff
path: root/src/smartsearch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/smartsearch.cpp')
-rwxr-xr-xsrc/smartsearch.cpp564
1 files changed, 342 insertions, 222 deletions
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 <contacts-svc.h>
-#include <calendar-svc-provider.h>
-#include <memo-db.h>
-#include <appsvc.h>
-#include <aul_service.h>
-
-static int __search_app_terminate(void *data);
+#include <app.h>
+#include <ail.h>
+
+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);
}