/* * Copyright 2012 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://floralicense.org/license/ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include #include "phone.h" #include "ph-front.h" #include "phone-dialer.h" #include "ph-dialer-view.h" #include "ph-dialer-utils.h" #include "ph-dialer-search.h" #define PH_DIALER_ENTRY_DEFAULT_STYLE "%s" #define PH_DIALER_ENTRY_EMPTY_STYLE "" #define PH_PAUSE_CHAR ';' #define PH_WAIT_CHAR ',' #define PH_DIALER_ENTRY_STYLE_END_TAG "" #define START_KEYPAD_RESET_TIMER 0.3 static dial_multiTouch_info* dialMultitouchInfo = NULL; static void dialer_entry_selection_changed(void *data, Evas_Object *entry, void *event_info) { ph_dialer_data *dial_d = (ph_dialer_data *)data; dial_d->selected_text = elm_entry_selection_get(entry); } static void dialer_entry_cursor_changed(void *data, Evas_Object *entry, void *event_info) { ph_dialer_data *dial_d = (ph_dialer_data *)data; dial_d->cursor_changed = true; } static void dialer_show_search_list_toggle(ph_dialer_data *dial_d, bool show) { PH_FN_CALL; if (show) { edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_list/show", "viewobject/search_list"); dial_d->count_button_status = COUNT_BUTTON_OPEN; edje_object_signal_emit(_EDJ(dial_d->count_layout), "count_button/closed", "count_button"); } else { edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_list/hide", "viewobject/search_list"); dial_d->count_button_status = COUNT_BUTTON_CLOSE; edje_object_signal_emit(_EDJ(dial_d->count_layout), "count_button/opened", "count_button"); } edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_list/index/hide", "viewobject/search_list/index"); } static void dialer_entry_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) { ph_dialer_data *dial_d = data; if (dial_d->list_mode == MODE_DIAL_NUMBER) { if (NULL == dial_d->search_list || eina_list_count(dial_d->search_list) < 2 || !dial_d->is_show_items) edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_result/count/hide", "viewobject/search_result/count"); else edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_result/count/show", "viewobject/search_result/count"); } else { if (NULL == dial_d->cc_list_sorted || eina_list_count(dial_d->cc_list_sorted) < 2 || !dial_d->is_show_items) edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_result/count/hide", "viewobject/search_result/count"); else edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_result/count/show", "viewobject/search_result/count"); } dialer_show_search_list_toggle(dial_d, false); } static void dialer_entry_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info) { ph_dialer_data *dial_d = data; if (dial_d->cursor_changed) { int pos = 0; dial_d->cursor_changed = false; pos = elm_entry_cursor_pos_get(dial_d->entry); dial_d->number_cursor = ph_dialer_util_get_node_by_index(data, pos); } dial_d->has_focus = true; } static void dialer_softkey_longpress(char *source, ph_dialer_data *dial_d) { int pos = 0; char dest[PH_TEXT_MAX_LEN] = {0}; if (strcmp(source, "star") == 0 || strcmp(source, "*") == 0) { if (ph_dialer_util_get_number_at_cursor(dial_d) == '*') { pos = ph_dialer_util_remove_node_at_cursor(dial_d); dialer_pw_popup(dial_d); ph_dialer_util_get_numstr_from_node(dial_d, dest); ph_dialer_entry_set_number(dial_d, dest, 0); } } else if (strcmp(source, "sharp") == 0 || strcmp(source, "#") == 0) { ph_dialer_util_get_numstr_from_node(dial_d, dest); if(strlen(dest) > 1) /* '#' longpress disable after number typed */ return; int value = 1; vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &value); if(!value) { vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, TRUE); phone_show_popup(dial_d->win, T_(PH_GET_TEXT_BASIC, PHTEXT_SOUND_ON), 2.0); } else { feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_HW_TAP); vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, FALSE); phone_show_popup(dial_d->win, T_(PH_GET_TEXT_BASIC, PHTEXT_SOUND_OFF), 2.0); } if(ph_dialer_util_get_number_at_cursor(dial_d) == '#') { pos = ph_dialer_util_remove_node_at_cursor(dial_d); ph_dialer_util_get_numstr_from_node(dial_d, dest); ph_dialer_entry_set_number(dial_d, dest, 0); ph_dialer_search_request(dial_d, FALSE); } } else if (strcmp(source, "input_del") == 0) { ph_dialer_util_entry_clear(dial_d); } } static Eina_Bool dialer_keypad_longpress(void *data) { PH_FN_CALL; ph_dialer_data *dial_d = data; int text_len = 0; int pos = 0; char dest[PH_TEXT_MAX_LEN] = {0}; char *source; p_retv_if(NULL == dial_d, -1); source = dial_d->longpress_source; text_len = ph_dialer_util_get_pure_numstr_with_plus(dial_d, dest); switch (source[0]) { case '0' ... '9': PH_DBG("number(len=%d):[%s]", text_len, dest); if (source[0] == '0') { pos = ph_dialer_util_remove_node_at_cursor(dial_d); edje_object_signal_emit(_EDJ(dial_d->layout), "pad_clicked", "+"); break; } /* speed dial: 2 ~ 9 */ if (0 < text_len && text_len <= 2) { if ('0' <= dest[0] && dest[0] <= '9' && atoi(dest) < 10) { ph_speeddial_info * speed_info = NULL; if ((speed_info = ph_dialer_util_get_speeddial_by_number(dial_d, atoi(dest))) != NULL) { ph_dialer_util_append_node_from_numstr_with_strip(dial_d, speed_info->ph_number); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, dest); ph_dialer_entry_set_number(dial_d, dest, CURSOR_END); ph_dialer_util_launch_call(dial_d); } else ph_dialer_util_show_speeddial_msg(dial_d, T_(PH_GET_TEXT_BASIC, PHTEXT_SPEED_DIAL_REQUEST)); } } break; default: dialer_softkey_longpress(source, dial_d); break; } if (dial_d->longpress_source) { free(dial_d->longpress_source); dial_d->longpress_source = NULL; } dial_d->longpress_timer = NULL; return ECORE_CALLBACK_CANCEL; } static void dialer_popup_del_cb(void *data, Evas_Object *obj, void *event_info) { ph_dialer_data *dial_d = data; p_retm_if(NULL == dial_d, "dial_d is null"); evas_object_del(dial_d->popup); dial_d->popup = NULL; } static void dialer_add_pause_cb(void *data, Evas_Object *obj, void *event_info) { ph_dialer_data *dial_d = data; p_retm_if(NULL == dial_d, "dial_d is null"); char dest[PH_TEXT_MAX_LEN] = {0}; dialer_show_search_list_toggle(dial_d, false); ph_dialer_util_strip_from_number_node(dial_d); ph_dialer_util_insert_number_at_cursor(dial_d, PH_PAUSE_CHAR); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, dest); ph_dialer_entry_set_number(dial_d, dest, 0); ph_dialer_search_request(dial_d, FALSE); dialer_popup_del_cb(dial_d, NULL, NULL); } static void dialer_add_wait_cb(void *data, Evas_Object *obj, void *event_info) { ph_dialer_data *dial_d = data; p_retm_if(NULL == dial_d, "dial_d is null"); char dest[PH_TEXT_MAX_LEN] = {0}; dialer_show_search_list_toggle(dial_d, false); ph_dialer_util_strip_from_number_node(dial_d); ph_dialer_util_insert_number_at_cursor(dial_d, PH_WAIT_CHAR); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, dest); ph_dialer_entry_set_number(dial_d, dest, 0); ph_dialer_search_request(dial_d, FALSE); dialer_popup_del_cb(dial_d, NULL, NULL); } void dialer_pw_popup(void *data) { PH_FN_CALL; char buf[PH_TEXT_SHORT_LEN] = {0}; ph_dialer_data *dial_d = (ph_dialer_data*)data; p_retm_if(NULL == dial_d, "dial_d is null"); if (dial_d->popup) evas_object_del(dial_d->popup); dial_d->popup = elm_ctxpopup_add(dial_d->navi); p_retm_if(NULL == dial_d->popup, "elm_ctxpopup_add() return NULL"); elm_ctxpopup_direction_priority_set(dial_d->popup, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_UP, -1, -1); ph_dialer_util_get_pure_numstr_with_plus(dial_d, buf); evas_object_smart_callback_add(dial_d->popup, "dismissed", dialer_popup_del_cb, dial_d); snprintf(buf, sizeof(buf), T_(PH_GET_TEXT_BASE_OP, PHTEXT_ADD_PAUSE), 2); elm_ctxpopup_item_append(dial_d->popup, buf, NULL, dialer_add_pause_cb, dial_d); elm_ctxpopup_item_append(dial_d->popup, T_(PH_GET_TEXT_BASE_OP, PHTEXT_ADD_WAIT), NULL, dialer_add_wait_cb, dial_d); int x, y, w, h; edje_object_part_geometry_get(_EDJ(dial_d->layout), "star_BG", &x, &y, &w, &h); evas_object_move(dial_d->popup, x+(w/2), (y+167)+(h/2)); evas_object_show(dial_d->popup); } static void dialer_keypad_down(void *data, Evas_Object *obj, const char *emission, const char *source) { PH_FN_CALL; char dest[PH_TEXT_MAX_LEN] = {0}; int snd_id = 0; ph_dialer_data *dial_d = data; p_retm_if(dial_d == NULL, "Invalid argument: ph_dialer_data *is NULL"); p_retm_if(source == NULL, "source is NULL"); if (dial_d->count_button_status == COUNT_BUTTON_OPEN) { dialer_show_search_list_toggle(dial_d, false); } if (dial_d->longpress_timer) { ecore_timer_del(dial_d->longpress_timer); dial_d->longpress_timer = NULL; } if (dial_d->dash_timer) { ecore_timer_del(dial_d->dash_timer); dial_d->dash_timer = NULL; } switch (source[0]) { case '0' ... '9': snd_id = FEEDBACK_PATTERN_KEY0 + (source[0] - '0'); break; default: if (0 == strcmp(source, "star")) { source = "*"; snd_id = FEEDBACK_PATTERN_KEY_STAR; } else if (0 == strcmp(source, "sharp")) { source = "#"; snd_id = FEEDBACK_PATTERN_KEY_SHARP; } else { snd_id = FEEDBACK_PATTERN_TOUCH_KEY; } break; } if (PH_DAILER_DURING_CALL != dial_d->run_mode) ph_dialer_util_svi_play(FEEDBACK_PATTERN_TOUCH_TAP , snd_id); ph_dialer_util_strip_from_number_node(dial_d); ph_dialer_util_insert_number_at_cursor(dial_d, source[0]); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, dest); ph_dialer_entry_set_number(dial_d, dest, 0); /* create new longpress timer */ if (dial_d->longpress_timer) { ecore_timer_del(dial_d->longpress_timer); dial_d->longpress_timer = NULL; } FREEandSTRDUP(dial_d->longpress_source, source); dial_d->longpress_timer = ecore_timer_add(elm_config_longpress_timeout_get(), dialer_keypad_longpress, dial_d); ph_dialer_search_request(dial_d, FALSE); } static Eina_Bool dialer_dash_add_timer(void *data) { char dest[PH_TEXT_MAX_LEN] = {0}; ph_dialer_data *dial_d = data; ph_dialer_util_strip_from_number_node(dial_d); ph_dialer_util_add_dashes(dial_d, DASH_PREVIEW); ph_dialer_util_get_numstr_from_node(dial_d, dest); ph_dialer_entry_set_number(dial_d, dest, 0); dial_d->dash_timer = NULL; return ECORE_CALLBACK_CANCEL; } static void dialer_keypad_up(void *data, Evas_Object *obj, const char *emission, const char *source) { ph_dialer_data *dial_d = data; p_retm_if(data == NULL, "Invalid argument: ph_dialer_data *is NULL"); PH_DBG("(source=%s)", source); if (dial_d->longpress_timer) { ecore_timer_del(dial_d->longpress_timer); dial_d->longpress_timer = NULL; } if (dial_d->dash_timer) { ecore_timer_del(dial_d->dash_timer); dial_d->dash_timer = NULL; } dial_d->dash_timer = ecore_timer_add(0.7, dialer_dash_add_timer, dial_d); } static void dialer_keypad_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) { PH_FN_CALL; ph_dialer_data *dial_d = data; char dest[PH_TEXT_MAX_LEN] = {0}; p_retm_if(NULL == source, "source is null"); p_retm_if(NULL == data, "Invalid argument: ph_dialer_data is NULL"); if (0 != strcmp(source, "+") && 0 != strcmp(source, "P") && 0 != strcmp(source, "W")) return; if (dial_d->dash_timer) { ecore_timer_del(dial_d->dash_timer); dial_d->dash_timer = NULL; } ph_dialer_util_strip_from_number_node(dial_d); ph_dialer_util_insert_number_at_cursor(dial_d, source[0]); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, dest); ph_dialer_entry_set_number(dial_d, dest, 0); ph_dialer_search_request(dial_d, FALSE); } static void dialer_softkey_down(void *data, Evas_Object *obj, const char *emission, const char *source) { PH_FN_CALL; char dest[PH_TEXT_MAX_LEN] = {0}; ph_dialer_data *dial_d = data; p_retm_if(data == NULL, "Invalid argument: ph_dialer_data *is NULL"); if (0 == strcmp(source, "back_btn") || 0 == strcmp(source, "option_btn")) return; ph_dialer_util_svi_play(FEEDBACK_PATTERN_TOUCH_TAP , FEEDBACK_PATTERN_TOUCH_TAP); if (0 != strcmp(source, "input_del")) return; if (dial_d->dash_timer) { ecore_timer_del(dial_d->dash_timer); dial_d->dash_timer = NULL; } char* entry_raw = strdup(elm_entry_entry_get(dial_d->entry)); char* tok = strstr(entry_raw, PH_DIALER_ENTRY_STYLE_END_TAG); if (tok) tok[0] = '\0'; if (dial_d->selected_text && strcmp(dial_d->selected_text, entry_raw) == 0) { ph_dialer_util_entry_clear(dial_d); free(entry_raw); return; } ph_dialer_util_strip_from_number_node(dial_d); ph_dialer_util_remove_node_at_cursor(dial_d); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, dest); ph_dialer_entry_set_number(dial_d, dest, 0); if (!*dest && dial_d->has_focus) { elm_object_focus_set(dial_d->entry, EINA_FALSE); dial_d->has_focus = false; } if (dial_d->longpress_timer) { ecore_timer_del(dial_d->longpress_timer); dial_d->longpress_timer = NULL; } FREEandSTRDUP(dial_d->longpress_source, source); dial_d->longpress_timer = ecore_timer_add(elm_config_longpress_timeout_get(), dialer_keypad_longpress, dial_d); ph_dialer_search_request(dial_d, FALSE); } static void dialer_softkey_up(void *data, Evas_Object *obj, const char *emission, const char *source) { PH_FN_CALL; ph_dialer_data *dial_d = data; p_retm_if(NULL == data, "Invalid argument: ph_dialer_data *is NULL"); if (0 != strcmp(source, "input_del")) return; if (dial_d->longpress_timer) { ecore_timer_del(dial_d->longpress_timer); dial_d->longpress_timer = NULL; } if (dial_d->dash_timer) { ecore_timer_del(dial_d->dash_timer); dial_d->dash_timer = NULL; } dial_d->dash_timer = ecore_timer_add(0.7, dialer_dash_add_timer, dial_d); } static void dialer_destroy_child_ug(void *data) { ph_dialer_data *dial_d = data; dial_d->child_ug = NULL; } static void dialer_cnt_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info) { PH_FN_CALL; ph_dialer_data *dial_d = (ph_dialer_data *)data; p_retm_if(dial_d == NULL, "Invalid argument: dial_d is NULL"); if (dial_d->count_button_status == COUNT_BUTTON_CLOSE) { if (dial_d->list_mode == MODE_DIAL_NUMBER) { p_retm_if((int)eina_list_count(dial_d->search_list) < 2, "lack of item to make drop down list (searched result: %d)", (int)eina_list_count(dial_d->search_list)); ph_dialer_search_fill_genlist_by_list(dial_d); } else { p_retm_if((int)eina_list_count(dial_d->cc_list_sorted) < 2, "lack of item to make drop down list (country code found: %d)", (int)eina_list_count(dial_d->cc_list_sorted)); ph_dialer_search_fill_genlist_by_cc_list(dial_d); } dialer_show_search_list_toggle(dial_d, true); } else { dialer_show_search_list_toggle(dial_d, false); } return; } static bool dialer_get_recent_log_number(char** get_str) { PH_FN_CALL; contacts_list_h cts_list = NULL; contacts_query_h query = NULL; contacts_error_e err = CONTACTS_ERROR_NONE; contacts_filter_h filter = NULL; do { if((err = contacts_query_create(_contacts_person_phone_log._uri, &query)) != CONTACTS_ERROR_NONE) break; if((err = contacts_filter_create( _contacts_person_phone_log._uri, &filter)) != CONTACTS_ERROR_NONE) break; if((err = contacts_filter_add_int(filter, _contacts_person_phone_log.log_type, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING )) != CONTACTS_ERROR_NONE) break; if((err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND)) != CONTACTS_ERROR_NONE) break; if((err = contacts_filter_add_int(filter, _contacts_person_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED )) != CONTACTS_ERROR_NONE) break; if((err = contacts_query_set_filter(query, filter)) != CONTACTS_ERROR_NONE) break; if((err = contacts_query_set_sort(query, _contacts_person_phone_log.log_time, false)) != CONTACTS_ERROR_NONE) break; if((err = contacts_db_get_records_with_query(query, 0, 1, &cts_list)) != CONTACTS_ERROR_NONE) break; unsigned int record_cnt = 0; contacts_list_get_count( cts_list, &record_cnt ); PH_DBG("get _contacts_person_phone_log table records(%d)", record_cnt); err = phone_cts_get_str_from_list(cts_list, _contacts_person_phone_log.address, get_str); PH_DBG("recent number : %s", *get_str); p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_str_from_list() Failed(%d)", err); contacts_list_destroy(cts_list, true); contacts_query_destroy(query); contacts_filter_destroy(filter); return true; } while(0); //error case ERR("contacts_db_query Failed(%d)", err); if(query != NULL) contacts_query_destroy(query); if(filter != NULL) contacts_filter_destroy(filter); return false; } static void dialer_softkey_call_clicked(void *data, int type) { PH_FN_CALL; ph_dialer_data *dial_d = data; char buf[PH_TEXT_MAX_LEN] = {0}; int len; p_retm_if(data == NULL, "Invalid argument: ph_dialer_data *is NULL"); len = ph_dialer_util_get_numstr_from_node(dial_d, buf); if (len == 0) { PH_DBG("text is NULL so input recent number "); char* get_str = NULL; if(dialer_get_recent_log_number(&get_str)) { if (get_str && strlen(get_str) > 0) { ph_dialer_util_append_node_from_numstr(dial_d, get_str); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, buf); ph_dialer_entry_set_number(dial_d, buf, CURSOR_END); ph_dialer_search_request(dial_d, FALSE); free(get_str); } } return; } if (0 == type) ph_dialer_util_launch_call(dial_d); } static void dialer_back_btn_cb(ph_dialer_data *dial_d) { dial_d->initialized = FALSE; ph_dialer_util_entry_clear(dial_d); } static void dialer_softkey_msg_clicked(void *data) { PH_FN_CALL; ph_dialer_data *dial_d = (ph_dialer_data *)data; p_retm_if(dial_d == NULL, "Invalid argument: ph_dialer_data *is NULL"); char num[PH_TEXT_SHORT_LEN] = {0}; ph_dialer_util_get_pure_numstr_with_plus(dial_d, num); dial_d->child_ug = phone_launch_msg_composer_ug(dial_d->ug, num, 0, dialer_destroy_child_ug, dial_d); dialer_popup_del_cb(dial_d, NULL, NULL); } static void dialer_ctx_message_cb(void *data, Evas_Object *obj, void *event_info) { ph_dialer_data *dial_d = data; char num[PH_TEXT_SHORT_LEN] = {0}; ph_dialer_util_get_pure_numstr_with_plus(dial_d, num); dial_d->child_ug = phone_launch_msg_composer_ug(dial_d->ug, num, 0, dialer_destroy_child_ug, dial_d); dialer_popup_del_cb(dial_d, NULL, NULL); } static void dialer_exit_cb(void *data, Evas_Object *obj, void *event_info) { ph_dialer_data *dial_d = data; p_retm_if(NULL == dial_d, "dial_d is null"); dialer_back_btn_cb(dial_d); phone_back_btn_clicked_cb(dial_d->win, NULL, NULL); dialer_popup_del_cb(dial_d, NULL, NULL); } static void dialer_contactsearch_btn_cb(void *data) { ph_dialer_data *dial_d = (ph_dialer_data *)data; ph_phoneui_data *phoneui_d = evas_object_data_get(dial_d->layout, "phoneui_d"); phone_front_view_show_sub_view(phoneui_d); //temp : need to fix as embedding contact search list into dialer layout. (kc.jun) return; } static void dialer_option_btn_cb(ph_dialer_data *dial_d) { PH_FN_CALL; char buf[PH_TEXT_SHORT_LEN] = {0}; if (dial_d->popup) evas_object_del(dial_d->popup); dial_d->popup = elm_ctxpopup_add(dial_d->navi); p_retm_if(NULL == dial_d->popup, "elm_ctxpopup_add() return NULL"); elm_ctxpopup_direction_priority_set(dial_d->popup, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_UP, -1, -1); ph_dialer_util_get_pure_numstr_with_plus(dial_d, buf); evas_object_smart_callback_add(dial_d->popup, "dismissed", dialer_popup_del_cb, dial_d); if (!dial_d->ug) elm_ctxpopup_item_append(dial_d->popup, S_(PH_SYS_BODY_MESSAGE), NULL, dialer_ctx_message_cb, dial_d); elm_ctxpopup_item_append(dial_d->popup, T_(PH_GET_TEXT_BASIC, PHTEXT_SPEEDDIAL), NULL, ph_dialer_util_speeddial_show_cb, dial_d); snprintf(buf, sizeof(buf), T_(PH_GET_TEXT_BASE_OP, PHTEXT_ADD_PAUSE), 2); elm_ctxpopup_item_append(dial_d->popup, buf, NULL, dialer_add_pause_cb, dial_d); elm_ctxpopup_item_append(dial_d->popup, T_(PH_GET_TEXT_BASE_OP, PHTEXT_ADD_WAIT), NULL, dialer_add_wait_cb, dial_d); if (!dial_d->ug) elm_ctxpopup_item_append(dial_d->popup, T_(PH_GET_TEXT_BASE_OP, PHTEXT_EXIT), NULL, dialer_exit_cb, dial_d); int x, y, w, h; edje_object_part_geometry_get(_EDJ(dial_d->layout), "option_btn", &x, &y, &w, &h); evas_object_move(dial_d->popup, x+(w/2), (y+167)+(h/2)); evas_object_show(dial_d->popup); } static void dialer_softkey_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) { PH_FN_CALL; ph_dialer_data *dial_d = data; char buf[PH_TEXT_MAX_LEN] = {0}; p_retm_if(data == NULL, "Invalid argument: ph_dialer_data *is NULL"); PH_DBG("source:[%s]", source); /* defense code for long-press */ /* remove longpress timer */ if (dial_d->longpress_timer) { ecore_timer_del(dial_d->longpress_timer); dial_d->longpress_timer=NULL; } if (strstr(source, "call") != NULL) /* normal/call, dc/call */ dialer_softkey_call_clicked(dial_d, 0); else if (strcmp(source, "normal/message") == 0) dialer_softkey_msg_clicked(dial_d); else if (0 == strcmp(source, "return_btn")) { if (dial_d->ug) phone_ug_destroy_me_cb(dial_d->ug, NULL, NULL); return; } else if (0 == strcmp(source, "option_btn")) { dialer_option_btn_cb(dial_d); return; } else if (0 == strcmp(source, "search/inputarea/image")) { dialer_contactsearch_btn_cb(dial_d); return; } ph_dialer_util_get_numstr_from_node(dial_d, buf); if (strcmp(source, "input_del") != 0) ph_dialer_entry_set_number(dial_d, buf, CURSOR_END); else ph_dialer_entry_set_number(dial_d, buf, 0); } static char* dialer_gl_cc_label_get(ph_dialer_data *dial_d, ph_cc_name_mcc_info *item, Evas_Object *obj, const char *part) { char buf[PH_TAG_TEXT_MAX_LEN] = {0}; char text[PH_TAG_TEXT_MAX_LEN] = {0}; int text_len; p_retvm_if(NULL == dial_d, NULL, "dial data is null"); if (0 == strcmp(part, "elm.text.left.name")) { return strdup(item->name); } else if (0 == strcmp(part, "elm.text.left.number")) { text_len = ph_dialer_util_get_pure_numstr(dial_d, text); ph_dialer_util_highlight_substring(buf, sizeof(buf), item->cc, text); return strdup(buf); } else return NULL; } Evas_Object* ph_dialer_gl_icon_get(void *data, Evas_Object *obj, const char *part) { p_retvm_if(NULL == data, NULL, "data is null"); ph_dialer_data *dial_d = evas_object_data_get(obj, KEY_DIALER_DATA); p_retvm_if(NULL == dial_d, NULL, "ph_dialer_data dial_d is null"); if (dial_d->list_mode == MODE_COUNTRY_CODE) return NULL; ph_dial_search_d *sd = data; Evas_Object *ic; if (0 == strcmp(part, "elm.icon.1")) { if (sd->img_path && *sd->img_path) { ic = elm_icon_add(obj); p_retvm_if(NULL == ic, NULL, "elm_icon_add is failed"); elm_icon_file_set(ic, sd->img_path, NULL); evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); return ic; } } return NULL; } char* ph_dialer_gl_label_get(void *data, Evas_Object *obj, const char *part) { p_retvm_if(NULL == data, NULL, "dialer data is null"); ph_dial_search_d *sd = data; ph_dialer_data *dial_d = evas_object_data_get(obj, KEY_DIALER_DATA); p_retvm_if(NULL == dial_d, NULL, "dialer data is null"); char buf[PH_TAG_TEXT_MAX_LEN] = {0}; char resultbuf[PH_TAG_TEXT_MAX_LEN] = {0}; if (dial_d->list_mode == MODE_COUNTRY_CODE) return dialer_gl_cc_label_get(dial_d, data, obj, part); if (0 == strcmp(part, "elm.text.left.name")) { if (sd->display && *sd->display) { if (sd->type == SEARCH_CONTACT_NAME_TYPE) { ph_dialer_util_highlight_substring_with_pos(buf, sizeof(buf), sd->display, sd->position, sd->len); return strdup(buf); } else return strdup(sd->display); } return NULL; } else if (0 == strcmp(part, "elm.text.left.number")) { if (sd->type == SEARCH_LOG_TYPE) { ph_dialer_util_highlight_substring(buf, sizeof(buf), sd->number, sd->find_number); return strdup(buf); } else { if (sd->number_type & CONTACTS_NUMBER_TYPE_CUSTOM && sd->numtype_label && sd->numtype_label[0]) snprintf(resultbuf, sizeof(resultbuf), "%s %s", sd->numtype_label, sd->number); else snprintf(resultbuf, sizeof(resultbuf), "%s %s", T_(CT_GET_TEXT_NUM_TYPE, phone_detail_log_get_phonenumber_type(sd->number_type)), sd->number); if (sd->type == SEARCH_CONTACT_NAME_TYPE) return strdup(resultbuf); else { ph_dialer_util_highlight_substring(buf, sizeof(buf), resultbuf, sd->find_number); return strdup(buf); } } } else return NULL; } static void dialer_fastscroll_level_up(void *data, Evas_Object *obj, void *event_info) { int level = elm_index_item_level_get(obj); const Elm_Object_Item *it; const Elm_Object_Item *index; ph_cc_name_mcc_info *item; char prev_ch[4] = {0}; char prev_ch_first[2] = {0}; p_retm_if(1 != level, "level is not 1"); index = elm_index_selected_item_get(obj, level - 1); elm_index_item_clear(obj); it= elm_object_item_data_get(index); p_retm_if(NULL == it, "elm_object_item_data_get(%p) returns NULL", index); item = elm_object_item_data_get(it); prev_ch_first[0]=item->name[0]; while (it) { item = elm_object_item_data_get(it); if (prev_ch_first[0] != item->name[0]) break; if (prev_ch[0] != item->name[1]) { prev_ch[0] = item->name[1]; elm_index_item_append(obj, prev_ch, NULL, it); } it = elm_genlist_item_next_get(it); } elm_index_level_go(obj, level); } static void dialer_fastscroll_level_down(void *data, Evas_Object *obj, void *event_info) { PH_FN_CALL; } static void dialer_fastscroll_index_changed(void *data, Evas_Object *obj, void *event_info) { PH_DBG("obj:%x, level:%d", (unsigned int)obj, elm_index_item_level_get(obj)); elm_genlist_item_bring_in(elm_object_item_data_get(event_info), ELM_GENLIST_ITEM_SCROLLTO_TOP); } static Evas_Object* dialer_create_genlist(ph_dialer_data *dial_d) { Evas_Object *genlist; Elm_Theme *th; genlist = elm_genlist_add(dial_d->layout); p_retvm_if(NULL == genlist, NULL, "elm_genlist_add is failed"); th = elm_theme_new(); elm_theme_ref_set(th, NULL); elm_theme_extension_add(th, DIALER_THEME_EDJ); dial_d->th = th; elm_object_theme_set(genlist, dial_d->th); evas_object_data_set(genlist, KEY_DIALER_DATA, dial_d); return genlist; } static void dialer_create_index(ph_dialer_data *dial_d) { dial_d->fast_index = elm_index_add(dial_d->layout); elm_object_part_content_set(dial_d->layout, "search_list/index", dial_d->fast_index); edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_list/index/hide", "viewobject/search_list/index"); evas_object_smart_callback_add(dial_d->fast_index, "level,up", dialer_fastscroll_level_up, NULL); evas_object_smart_callback_add(dial_d->fast_index, "level,down", dialer_fastscroll_level_down, NULL); evas_object_smart_callback_add(dial_d->fast_index, "delay,changed", dialer_fastscroll_index_changed, NULL); evas_object_smart_callback_add(dial_d->fast_index, "selected", dialer_fastscroll_index_changed, NULL); elm_index_level_go(dial_d->fast_index, 0); } void ph_dialer_update_cnt_btn(ph_dialer_data *dial_d, int count) { char buf[PH_TEXT_MAX_LEN] = {0}; if (count < 2) { elm_object_part_text_set(dial_d->count_layout, "btn_style/number", NULL); // elm_object_disabled_set(dial_d->count_button, EINA_TRUE); edje_object_signal_emit(_EDJ(dial_d->count_layout),"count_button/hide", "count_button"); } else { snprintf(buf, sizeof(buf), "%d", count); elm_object_part_text_set(dial_d->count_layout, "btn_style/number", buf); elm_object_disabled_set(dial_d->count_button, EINA_FALSE); edje_object_signal_emit(_EDJ(dial_d->count_layout),"count_button/opened", "count_button"); } } static void dialer_entry_set_number_noresize(ph_dialer_data *dial_d, char *text) { PH_FN_CALL; int size = MAX_DIAL_NUMBER_FONT_SIZE; char buf[PH_TEXT_MAX_LEN] = {0}; int pos; snprintf(buf, sizeof(buf), "DEFAULT='align=left font=Tizen:style=Thin text_class=tizen font_size=%d color=#FFFFFF'", size); elm_entry_text_style_user_push(dial_d->entry, buf); if (text && *text) snprintf(buf, sizeof(buf), PH_DIALER_ENTRY_DEFAULT_STYLE, size, text); else snprintf(buf, sizeof(buf), PH_DIALER_ENTRY_EMPTY_STYLE, size); elm_entry_entry_set(dial_d->entry, buf); pos = ph_dialer_util_get_cursor_pos(dial_d); elm_entry_cursor_pos_set(dial_d->entry, pos); } void ph_dialer_entry_set_number(ph_dialer_data *dial_d, char *orig, int cursor) { PH_FN_CALL; char text[PH_TEXT_MAX_LEN] = {0}; if (orig && *orig) { snprintf(text, sizeof(text), PH_DIALER_ENTRY_DEFAULT_STYLE, dial_d->entry_font_size, orig); if (dial_d->run_mode != PH_DAILER_EMERGENCY && strcmp("hide",edje_object_part_state_get(_EDJ(dial_d->layout), "textblock/textarea", NULL))) edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/entry/show", "viewobject/entry"); } else { snprintf(text, sizeof(text), PH_DIALER_ENTRY_EMPTY_STYLE, dial_d->entry_font_size); // if (dial_d->run_mode != PH_DAILER_EMERGENCY) // edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/entry/hide", "viewobject/entry");//temporalily HIDE for contact search implmentation (kc.jun) } elm_entry_entry_set(dial_d->entry, text); if (cursor == CURSOR_END) cursor = STRLEN(orig); else if (cursor == CURSOR_BEGIN) cursor = 0; else if (cursor == 0) cursor = ph_dialer_util_get_cursor_pos(dial_d); dial_d->number_cursor = ph_dialer_util_get_node_by_index(dial_d, cursor); elm_entry_cursor_pos_set(dial_d->entry, cursor); PH_FN_END; } static void dialer_clear_thread(ph_dialer_data *dial_d) { dial_d->t_info->alive = false; if (dial_d->t_info->epipe) { ecore_pipe_write_close(dial_d->t_info->epipe); ecore_pipe_read_close(dial_d->t_info->epipe); ecore_pipe_del(dial_d->t_info->epipe); dial_d->t_info->epipe = NULL; } pthread_join(dial_d->t_info->thread, NULL); free(dial_d->t_info); dial_d->t_info = NULL; } Eina_Bool ph_dialer_reload_data(void *data) { PH_FN_CALL; int count = 0; ph_dialer_data *dial_d = data; p_retvm_if(NULL == data, ECORE_CALLBACK_CANCEL, "data is null"); p_retvm_if(!dial_d->data_dirty_flag, ECORE_CALLBACK_CANCEL, "data is not changed"); if (dial_d->data_dirty_flag & CONTACT_DATA_CHAGNED) { phone_free_speeddial_data(dial_d->speeddial_list); dial_d->speeddial_list = phone_load_speeddial_data(&count); if (dial_d->t_info) dialer_clear_thread(dial_d); dial_d->loading = false; if (dial_d->contact_list) { phone_free_contacts(dial_d->contact_list); dial_d->contact_list = NULL; } } else if (dial_d->data_dirty_flag & SPEEDDIAL_DATA_CHAGNED) { phone_free_speeddial_data(dial_d->speeddial_list); dial_d->speeddial_list = phone_load_speeddial_data(&count); } dial_d->data_dirty_flag = 0; ph_dialer_search_request(dial_d, TRUE); dial_d->update_timer = NULL; return ECORE_CALLBACK_CANCEL; } static void dialer_contact_data_changed_cb(const char* view_uri, void* data) { PH_FN_CALL; ph_dialer_data *dial_d = data; p_retm_if(NULL == data, "data is null"); if (dial_d->update_timer) { ecore_timer_del(dial_d->update_timer); dial_d->update_timer = NULL; } if (dial_d->is_background) { dial_d->data_dirty_flag |= CONTACT_DATA_CHAGNED; dial_d->update_timer = ecore_timer_add(3.0, ph_dialer_reload_data, dial_d); } else { int count = 0; phone_free_speeddial_data(dial_d->speeddial_list); dial_d->speeddial_list = phone_load_speeddial_data(&count); if (dial_d->t_info) dialer_clear_thread(dial_d); dial_d->loading = false; if (dial_d->contact_list) { phone_free_contacts(dial_d->contact_list); dial_d->contact_list = NULL; } ph_dialer_search_request(dial_d, TRUE); } PH_FN_END; } static void dialer_speeddial_data_changed_cb(const char* view_uri, void* data) { PH_FN_CALL; ph_dialer_data *dial_d = data; p_retm_if(NULL == data, "data is null"); if (dial_d->update_timer) { ecore_timer_del(dial_d->update_timer); dial_d->update_timer = NULL; } if (dial_d->is_background) { dial_d->data_dirty_flag |= SPEEDDIAL_DATA_CHAGNED; dial_d->update_timer = ecore_timer_add(3.0, ph_dialer_reload_data, dial_d); } else { int count = 0; phone_free_speeddial_data(dial_d->speeddial_list); dial_d->speeddial_list = phone_load_speeddial_data(&count); ph_dialer_search_request(dial_d, TRUE); } } static void dialer_log_data_changed_cb(const char* view_uri, void* data) { PH_FN_CALL; ph_dialer_data *dial_d = (ph_dialer_data *)data; p_retm_if(NULL == dial_d, "dial_d is null"); if (dial_d->update_timer) { ecore_timer_del(dial_d->update_timer); dial_d->update_timer = NULL; } if (dial_d->is_background) { dial_d->data_dirty_flag |= LOG_DATA_CHAGNED; dial_d->update_timer = ecore_timer_add(3.0, ph_dialer_reload_data, dial_d); } else ph_dialer_search_request(dial_d, TRUE); } static void dialer_view_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { PH_FN_CALL; ph_dialer_data *dial_d = (ph_dialer_data *)data; p_retm_if(NULL == dial_d, "dial_d is null"); contacts_error_e err = CONTACTS_ERROR_NONE; err = contacts_db_remove_changed_cb(_contacts_person._uri, dialer_contact_data_changed_cb, dial_d); p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); err = contacts_db_remove_changed_cb(_contacts_phone_log._uri, dialer_log_data_changed_cb, dial_d); p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); err = contacts_db_remove_changed_cb(_contacts_speeddial._uri, dialer_speeddial_data_changed_cb, dial_d); p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); ph_dialer_util_del_all_number(dial_d); if (dial_d->t_info) dialer_clear_thread(dial_d); if (dial_d->search_idler) ecore_idler_del(dial_d->search_idler); if (dial_d->popup) evas_object_del(dial_d->popup); if (dial_d->job) ecore_job_del(dial_d->job); if (dial_d->search_timer) ecore_timer_del(dial_d->search_timer); if (dial_d->dash_timer) ecore_timer_del(dial_d->dash_timer); if (dial_d->longpress_timer) ecore_timer_del(dial_d->longpress_timer); if (dial_d->update_timer) ecore_timer_del(dial_d->update_timer); if (dial_d->slide_timer) ecore_timer_del(dial_d->slide_timer); if(dialMultitouchInfo && dialMultitouchInfo->keypad_reset_timer) ecore_timer_del(dialMultitouchInfo->keypad_reset_timer); if (dial_d->key_press) ecore_event_handler_del(dial_d->key_press); if (dial_d->key_release) ecore_event_handler_del(dial_d->key_release); feedback_deinitialize(); if (dial_d->th) { elm_theme_extension_del(dial_d->th, DIALER_THEME_EDJ); elm_theme_free(dial_d->th); } phone_free_speeddial_data(dial_d->speeddial_list); phone_free_contacts(dial_d->contact_list); free(dial_d->longpress_source); free(dial_d->searched_text); free(dial_d); } static void dialer_entry_font_check(Evas_Object *entry, ph_dialer_data *dial_d, char *text, int pos) { PH_FN_CALL; static int status = 0; Ecore_X_Window win; int size; int win_width; int max_width; int entry_width; char buf[PH_TEXT_MAX_LEN] = {0}; int size_interval = 3; win = ecore_x_window_root_get(ecore_x_window_focus_get()); ecore_x_window_size_get(win, &win_width, NULL); evas_object_size_hint_min_get(entry, &entry_width, NULL); max_width = win_width-142; size = dial_d->entry_font_size; // PH_DBG("BEFORE: fontsize : %d, max_width : %d, entry_width : %d", size, max_width, entry_width); if (max_width < entry_width) { if (MIN_DIAL_NUMBER_FONT_SIZE < size) { size-=size_interval; snprintf(buf, sizeof(buf), PH_DIALER_ENTRY_DEFAULT_STYLE, size, text); status = -1; dial_d->entry_font_size = size; elm_entry_entry_set(dial_d->entry, buf); // PH_DBG("####### elm_entry_entry_set, %s", buf); elm_entry_cursor_pos_set(dial_d->entry, pos); } } else if (entry_width < max_width) { if (status == -1) { status = 0; return; } if (size < MAX_DIAL_NUMBER_FONT_SIZE) { size+=size_interval; snprintf(buf, sizeof(buf), PH_DIALER_ENTRY_DEFAULT_STYLE, size, text); status = 1; dial_d->entry_font_size = size; elm_entry_entry_set(dial_d->entry, buf); elm_entry_cursor_pos_set(dial_d->entry, pos); } } else status = 0; // evas_object_size_hint_min_get(entry, &entry_width, NULL); // PH_DBG("AFTER: fontsize : %d, max_width : %d, entry_width : %d", size, max_width, entry_width); } static int dialer_include_zero_space(char *text) { int len; int i; p_retv_if(NULL == text, -1); len = strlen(text); for (i = 0;ientry); cursor = dialer_trim_dash_from_numstr(text, entry_text, sizeof(entry_text), pos); differ = strcmp(node_text, entry_text); if (0 <= dialer_include_zero_space(text) && strlen(text) == 3 && 0 == differ) { free(text); return; } const char* endtag = strstr(org, PH_DIALER_ENTRY_STYLE_END_TAG); if (0 != differ || (endtag && endtag[3] != '\0')) { PH_DBG("update entry"); ph_dialer_util_append_node_from_numstr(dial_d, entry_text); dial_d->number_cursor = ph_dialer_util_get_node_by_index(dial_d, cursor); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, node_text); ph_dialer_entry_set_number(dial_d, node_text, 0); ph_dialer_search_request(dial_d, FALSE); free(text); return; } #ifdef _ADJUST_FONTSIZE if (NULL == strstr(org, "font_size")) { if (MAX_DIAL_NUMBER_FONT_SIZE == dial_d->entry_font_size) dial_d->entry_font_size--; else if (MIN_DIAL_NUMBER_FONT_SIZE == dial_d->entry_font_size) dial_d->entry_font_size++; } PH_DBG("dial_d->entry_font_size : %d", dial_d->entry_font_size); dialer_entry_font_check(obj, dial_d, text, pos); #endif free(text); PH_FN_END; return; } static void dialer_create_entry(ph_dialer_data *dial_d) { Evas_Object *scroller; Evas_Object *entry; scroller = elm_scroller_add(dial_d->layout); elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE); elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); elm_scroller_content_min_limit(scroller, EINA_FALSE, EINA_TRUE); elm_object_part_content_set(dial_d->layout, "textblock/textarea", scroller); entry = elm_entry_add(dial_d->layout); elm_entry_single_line_set(entry, EINA_TRUE); elm_entry_editable_set(entry, EINA_TRUE); elm_entry_magnifier_disabled_set(entry, EINA_TRUE); elm_entry_input_panel_enabled_set(entry, EINA_FALSE); evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_content_set(scroller, entry); dial_d->entry = entry; evas_object_smart_callback_add(entry, "selection,changed", dialer_entry_selection_changed, dial_d); evas_object_smart_callback_add(entry, "cursor,changed", dialer_entry_cursor_changed, dial_d); evas_object_smart_callback_add(entry, "changed", dialer_entry_text_changed, dial_d); evas_object_event_callback_add(entry, EVAS_CALLBACK_MOUSE_DOWN, dialer_entry_mouse_down, dial_d); evas_object_event_callback_add(entry, EVAS_CALLBACK_MOUSE_UP, dialer_entry_mouse_up, dial_d); } static void dialer_entry_number_init(void *data) { PH_FN_CALL; int ret; char *buf; int value; char num[PH_TEXT_MAX_LEN] = {0}; ph_dialer_data *dial_d = data; p_retm_if(PH_DAILER_EMERGENCY == dial_d->run_mode, "It is Emergency mode"); value = FALSE; ret = vconf_get_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, &value); if(dial_d->searched_text) { ph_dialer_util_append_node_from_numstr_with_strip(dial_d, dial_d->searched_text); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, num); ph_dialer_entry_set_number(dial_d, num, CURSOR_END); ph_dialer_search_request(dial_d, TRUE); } else if (value == TRUE) { ret = vconf_get_int(VCONFKEY_CISSAPPL_PREFIX_DIAL_VALUE_INT, &value); PH_DBG("prefix dial index: %d", value); buf = NULL; switch (value) { case 0: buf = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM1_STR); break; case 1: buf = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM2_STR); break; case 2: buf = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM3_STR); break; case 3: buf = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM4_STR); break; case 4: buf = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM5_STR); break; default: PH_DBG("wrong prefix index(%d)", value); break; } if (buf && *buf) { ph_dialer_util_append_node_from_numstr_with_strip(dial_d, buf); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, num); ph_dialer_entry_set_number(dial_d, num, CURSOR_END); ph_dialer_search_request(dial_d, FALSE); free(buf); } } else dialer_entry_set_number_noresize(dial_d, ""); dial_d->initialized = TRUE; } static void __keypad_bg_handler(ph_dialer_data *dial_d, int x, int y, char* signal) { PH_FN_CALL; int i; for(i=0;idial_btn[i]; if( x >= rect->x && y >= rect->y && x <= rect->x + rect->w && y <= rect->y+rect->h) { PH_DBG("%s, %s", signal, dialMultitouchInfo->dial_btn_name[i]); edje_object_signal_emit(_EDJ(dial_d->layout), signal, dialMultitouchInfo->dial_btn_name[i]); break; } } } static void __keypad_reset_timer_cb(ph_dialer_data *dial_d) { p_retm_if(NULL == dial_d, "dialer data is null"); p_retm_if(NULL == dialMultitouchInfo, "dialMultitouchInfo data is null"); int i; for(i=0;idial_btn[i]; edje_object_signal_emit(_EDJ(dial_d->layout), "mouse,up,1", dialMultitouchInfo->dial_btn_name[i]); } dialMultitouchInfo->keypad_reset_timer = NULL; } static void dialer_keypad_bg_up(void *data, Evas *e, Evas_Object *o, void *event_info) { PH_FN_CALL; Evas_Event_Mouse_Up *ev = event_info; ph_dialer_data *dial_d = data; //PH_DBG("dialer_keypad_bg_up : x %d y %d", ev->output.x, ev->output.y); // Multi-key pressed sceanario should reset all dial key if(dialMultitouchInfo->lastMultiDown == TRUE) { if(dialMultitouchInfo->keypad_reset_timer) { ecore_timer_del(dialMultitouchInfo->keypad_reset_timer); dialMultitouchInfo->keypad_reset_timer = NULL; } dialMultitouchInfo->keypad_reset_timer = ecore_timer_add(START_KEYPAD_RESET_TIMER, __keypad_reset_timer_cb, dial_d); } // normal scenario for touch & drag + release else if(dialMultitouchInfo->lastDown == TRUE && (dialMultitouchInfo->lastDownX != ev->output.x || dialMultitouchInfo->lastDownY != ev->output.y)) { __keypad_bg_handler(dial_d, dialMultitouchInfo->lastDownX, dialMultitouchInfo->lastDownY, "mouse,up,1"); } dialMultitouchInfo->lastDown = FALSE; dialMultitouchInfo->lastMultiDown = FALSE; __keypad_bg_handler(dial_d, ev->output.x , ev->output.y, "mouse,up,1"); } static void dialer_keypad_bg_down(void *data, Evas *e, Evas_Object *o, void *event_info) { PH_FN_CALL; Evas_Event_Mouse_Down *ev = event_info; ph_dialer_data *dial_d = data; //PH_DBG("dialer_keypad_bg_down : x %d y %d", ev->output.x, ev->output.y); dialMultitouchInfo->lastDownX = ev->output.x; dialMultitouchInfo->lastDownY = ev->output.y; dialMultitouchInfo->lastDown = TRUE; __keypad_bg_handler(dial_d, ev->output.x , ev->output.y, "mouse,down,1"); } static void dialer_keypad_bg_multi_up(void *data, Evas *e, Evas_Object *o, void *event_info) { PH_FN_CALL; Evas_Event_Multi_Up *ev = event_info; ph_dialer_data *dial_d = data; PH_DBG("dialer_keypad_bg_multi_up : x %d y %d", ev->output.x, ev->output.y); __keypad_bg_handler(dial_d, ev->output.x , ev->output.y, "mouse,up,1"); } static void dialer_keypad_bg_multi_down(void *data, Evas *e, Evas_Object *o, void *event_info) { PH_FN_CALL; Evas_Event_Multi_Down *ev = event_info; ph_dialer_data *dial_d = data; PH_DBG("dialer_keypad_bg_multi_down : x %d y %d", ev->output.x, ev->output.y); dialMultitouchInfo->lastMultiDown = TRUE; if(dialMultitouchInfo->lastDown == TRUE) { __keypad_bg_handler(dial_d, dialMultitouchInfo->lastDownX, dialMultitouchInfo->lastDownY, "mouse,up,1"); dialMultitouchInfo->lastDownX = ev->output.x; dialMultitouchInfo->lastDownY = ev->output.y; dialMultitouchInfo->lastDown = TRUE; } __keypad_bg_handler(dial_d, ev->output.x , ev->output.y, "mouse,down,1"); } static void dialer_multi_touch_init (ph_dialer_data *dial_d) { PH_FN_CALL; Evas_Coord h, w, x, y; Evas_Coord_Rectangle* rect = NULL; int i; Evas_Object *evasKpdArea, *evasKeyArea, *kpdArea; Evas* evas; const char* btn_name[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "star", "sharp" }; p_retm_if(NULL != dialMultitouchInfo, "dialer_multi_touch_init aleady done!"); dialMultitouchInfo = calloc(1, sizeof(dial_multiTouch_info)); for(i=0;idial_btn[i]; dialMultitouchInfo->dial_btn_name[i] = btn_name[i]; evasKeyArea = (Evas_Object *)edje_object_part_object_get(_EDJ(dial_d->layout), btn_name[i]); evas_object_geometry_get(evasKeyArea, &rect->x,&rect->y,&rect->w,&rect->h); PH_DBG("edje_object_part_geometry_get : [%s]x %d y %d w %d h %d", btn_name[i], rect->x, rect->y, rect->w, rect->h); } rect = &dialMultitouchInfo->background; evasKpdArea = (Evas_Object *)edje_object_part_object_get(_EDJ(dial_d->layout), "keypad/swallow"); evas_object_geometry_get(evasKpdArea, &rect->x,&rect->y,&rect->w,&rect->h); PH_DBG("edje_object_part_geometry_get : x %d y %d w %d h %d", rect->x, rect->y, rect->w, rect->h); // remove bottom line btn area from layout geometry value rect->h-= dialMultitouchInfo->dial_btn[0].h; evas = evas_object_evas_get(dial_d->layout); kpdArea = evas_object_rectangle_add(evas); // Temporary patch for UG slide effect problem evas_output_viewport_get(evas, &x, &y, &w, &h); #define DIALER_PADDING_SIZE 3 if(dialMultitouchInfo->background.x >= w-DIALER_PADDING_SIZE) { PH_DBG("evas_output_viewport_get : x %d y %d w %d h %d", x, y, w, h); w-=DIALER_PADDING_SIZE; dialMultitouchInfo->background.x-=w; for(i=0;idial_btn[i]; rect->x-=w; } } //////////////////////////////////////////// evas_object_color_set(kpdArea, 0, 0, 0, 0); elm_object_part_content_set(dial_d->layout, "keypad/swallow", kpdArea); evas_object_show(kpdArea); evas_object_event_callback_add(kpdArea, EVAS_CALLBACK_MOUSE_DOWN, dialer_keypad_bg_down, dial_d); evas_object_event_callback_add(kpdArea, EVAS_CALLBACK_MOUSE_UP, dialer_keypad_bg_up, dial_d); evas_object_event_callback_add(kpdArea, EVAS_CALLBACK_MULTI_DOWN, dialer_keypad_bg_multi_down, dial_d); evas_object_event_callback_add(kpdArea, EVAS_CALLBACK_MULTI_UP, dialer_keypad_bg_multi_up, dial_d); } static void dialer_lazy_init(void *data) { PH_FN_CALL; ph_dialer_data *dial_d = data; Evas_Object *genlist; int count; dialer_create_index(dial_d); dialer_create_entry(dial_d); dial_d->entry_font_size = MAX_DIAL_NUMBER_FONT_SIZE; dial_d->number_cursor = &(dial_d->number_head); feedback_initialize(); edje_object_signal_callback_add(_EDJ(dial_d->layout), "pad_clicked", "*", dialer_keypad_clicked, dial_d); edje_object_signal_callback_add(_EDJ(dial_d->layout), "pad_down", "*", dialer_keypad_down, dial_d); edje_object_signal_callback_add(_EDJ(dial_d->layout), "pad_up", "*", dialer_keypad_up, dial_d); edje_object_signal_callback_add(_EDJ(dial_d->layout), "softkey_clicked", "*", dialer_softkey_clicked, dial_d); edje_object_signal_callback_add(_EDJ(dial_d->layout), "softkey_up", "*", dialer_softkey_up, dial_d); edje_object_signal_callback_add(_EDJ(dial_d->layout), "softkey_down", "*", dialer_softkey_down, dial_d); dialer_multi_touch_init(dial_d); count = 0; dial_d->speeddial_list = phone_load_speeddial_data(&count); dial_d->job = ecore_job_add(dialer_entry_number_init, dial_d); } static void dialer_layout_flush_post_cb(void *data, Evas *e, void *event_info) { ph_dialer_data *dial_d = data; evas_event_callback_del(evas_object_evas_get(dial_d->layout), EVAS_CALLBACK_RENDER_FLUSH_POST, dialer_layout_flush_post_cb); dial_d->job = ecore_job_add(dialer_lazy_init, dial_d); } static void dialer_mousedown(void *data, Evas *evas, Evas_Object *obj, void *event_info) { Evas_Event_Mouse_Up *ev = event_info; ph_dialer_data *dial_d = data; dial_d->touch_x = ev->canvas.x; dial_d->touch_y = ev->canvas.y; } static Eina_Bool _key_release_cb(void *data, int type, void *event) { ph_dialer_data *dial_d = data; p_retvm_if(dial_d == NULL, false, "dial_d is NULL"); p_retvm_if(dial_d->is_background == TRUE, false, "Dialer is not on top"); p_retvm_if(dial_d->child_ug != NULL, false, "child UG is exist."); p_retvm_if(elm_object_focus_get(dial_d->entry)== TRUE, false, "Focus already has been set on entry."); Evas_Event_Key_Up *ev = event; if (!ev) { PH_DBG("Invalid event object"); return ECORE_CALLBACK_RENEW; } PH_DBG("%d type / %s released.", type, ev->keyname); if (dial_d->longpress_timer) { ecore_timer_del(dial_d->longpress_timer); dial_d->longpress_timer = NULL; } return ECORE_CALLBACK_RENEW; } static Eina_Bool _key_press_cb(void* data, int type, void* event) { ph_dialer_data *dial_d = data; p_retvm_if(dial_d == NULL, false, "dial_d is NULL"); p_retvm_if(dial_d->is_background == TRUE, false, "Dialer is not on top"); p_retvm_if(dial_d->child_ug != NULL, false, "child UG is exist."); p_retvm_if(elm_object_focus_get(dial_d->entry)== TRUE, false, "Focus already has been set on entry."); Evas_Event_Key_Down *ev = event; if (!ev) { PH_DBG("Invalid event object"); return ECORE_CALLBACK_RENEW; } PH_DBG("%d type / %s pressed", type, ev->keyname); if (!strcmp(ev->keyname, "Return") || !strcmp(ev->keyname, "Phone")) { edje_object_signal_emit(_EDJ(dial_d->layout), "softkey_clicked", "call"); } else if (!strcmp(ev->keyname, "BackSpace")) { edje_object_signal_emit(_EDJ(dial_d->layout), "softkey_down", "input_del"); } else if (ev->keyname[0] >= '0' && ev->keyname[0] <= '9') { const Evas_Modifier *mods = evas_key_modifier_get(evas_object_evas_get(dial_d->layout)); if (evas_key_modifier_is_set(mods, "Shift")) { if (ev->keyname[0] == '3') edje_object_signal_emit(_EDJ(dial_d->layout), "pad_down", "#"); else if (ev->keyname[0] == '8') edje_object_signal_emit(_EDJ(dial_d->layout), "pad_down", "*"); } else edje_object_signal_emit(_EDJ(dial_d->layout), "pad_down", ev->keyname); } return ECORE_CALLBACK_RENEW; } int ph_dialer_create_content(ph_dialer_data *dial_d) { PH_FN_CALL; dial_d->layout = elm_layout_add(dial_d->navi); p_retvm_if(NULL == dial_d->layout, 0, "elm_layout_add() Failed"); elm_layout_file_set(dial_d->layout, DIALER_EDJ, "dialer/main"); evas_object_size_hint_weight_set(dial_d->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_event_callback_add(dial_d->layout, EVAS_CALLBACK_MOUSE_DOWN, dialer_mousedown, dial_d); if (dial_d->is_emergency) dial_d->run_mode = PH_DAILER_EMERGENCY; else dial_d->run_mode = PH_DAILER_NORMAL; ph_dialer_util_setup_run_mode(dial_d); edje_object_signal_emit(_EDJ(dial_d->layout), "main/default", "main"); evas_object_data_set(dial_d->layout, KEY_DIALER_DATA, dial_d); PH_DBG("run_mode(before emit):%d", dial_d->run_mode); if (PH_DAILER_NORMAL != dial_d->run_mode) { if (PH_DAILER_EMERGENCY == dial_d->run_mode) { edje_object_part_text_set(_EDJ(dial_d->layout), "return_btn/text", T_(PH_GET_TEXT_BASIC, PHTEXT_PREVIOUS_SCREEN_ABB)); edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/entry/show", "viewobject/entry"); } else if (PH_DAILER_DURING_CALL == dial_d->run_mode) { edje_object_part_text_set(_EDJ(dial_d->layout), "return_btn/text", T_(PH_GET_TEXT_BASIC, PHTEXT_BACK_TO_CALL)); edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/entry/show", "viewobject/entry");//temporalily HIDE for contact search implmentation (kc.jun) } edje_object_signal_emit(_EDJ(dial_d->layout), "return_btn/default", "return_btn"); } else { edje_object_signal_emit(_EDJ(dial_d->layout), "return_btn/hide", "return_btn"); edje_object_signal_emit(_EDJ(dial_d->layout), "softkey/normal", "softkey"); edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/entry/show", "viewobject/entry");//temporalily HIDE for contact search implmentation (kc.jun) } evas_object_event_callback_add(dial_d->layout, EVAS_CALLBACK_DEL, dialer_view_delete_cb, dial_d); contacts_error_e err = CONTACTS_ERROR_NONE; err = contacts_db_add_changed_cb(_contacts_person._uri, dialer_contact_data_changed_cb, dial_d); p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); err = contacts_db_add_changed_cb(_contacts_phone_log._uri, dialer_log_data_changed_cb, dial_d); p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); err = contacts_db_add_changed_cb(_contacts_speeddial._uri, dialer_speeddial_data_changed_cb, dial_d); p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); evas_event_callback_add(evas_object_evas_get(dial_d->layout), EVAS_CALLBACK_RENDER_FLUSH_POST, dialer_layout_flush_post_cb, dial_d); dial_d->key_press = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, dial_d); if (!dial_d->key_press) PH_DBG("Failed to register a key down event handler"); dial_d->key_release = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, dial_d); if (!dial_d->key_release) PH_DBG("Failed to register a key up event handler"); return 1; } API void phone_dialer_set_navi(Evas_Object *layout) { PH_FN_CALL; ph_dialer_data *dial_d; Elm_Object_Item *navi_it; dial_d = evas_object_data_get(layout, KEY_DIALER_DATA); p_retm_if(NULL == dial_d, "dialer data is null"); navi_it = elm_naviframe_bottom_item_get(dial_d->navi); phone_navi_item_clear(navi_it); elm_object_item_part_content_set(navi_it, "prev_btn", NULL); } API void phone_dialer_view_reset(Evas_Object *layout) { PH_FN_CALL; ph_dialer_data *dial_d; Elm_Object_Item *item; dial_d = evas_object_data_get(layout, KEY_DIALER_DATA); p_retm_if(NULL == dial_d, "dialer data is null"); if (dial_d->child_ug) { ug_destroy(dial_d->child_ug); dial_d->child_ug = NULL; } item = elm_naviframe_bottom_item_get(dial_d->navi); if (elm_naviframe_top_item_get(dial_d->navi) != item) elm_naviframe_item_pop_to(item); } API void phone_dialer_view_language_changed(Evas_Object *layout) { // TODO: Fixme } API void phone_dialer_check_focus(Evas_Object *layout) { PH_FN_CALL; ph_dialer_data *dial_d; char *text; dial_d = evas_object_data_get(layout, KEY_DIALER_DATA); p_retm_if(NULL == dial_d, "dialer data is null"); text = elm_entry_markup_to_utf8(elm_entry_entry_get(dial_d->entry)); if (dial_d->has_focus && text && dialer_include_zero_space(text) == -1) elm_object_focus_set(dial_d->entry, EINA_TRUE); else { elm_object_focus_set(dial_d->entry, EINA_FALSE); dial_d->has_focus = false; } free(text); } API void phone_dialer_view_resume(Evas_Object *layout) { PH_FN_CALL; ph_dialer_data *dial_d; dial_d = evas_object_data_get(layout, KEY_DIALER_DATA); p_retm_if(NULL == dial_d, "dialer data is null"); if (!dial_d->initialized) dialer_entry_number_init(dial_d); } API void phone_dialer_view_set_num(Evas_Object *layout, char *number) { PH_FN_CALL; ph_dialer_data *dial_d; char dest[PH_TEXT_MAX_LEN] = {0}; dial_d = evas_object_data_get(layout, KEY_DIALER_DATA); p_retm_if(NULL == dial_d, "dialer data is null"); if (number != NULL) { if(dial_d->entry) { ph_dialer_util_append_node_from_numstr_with_strip(dial_d, number); ph_dialer_util_add_dashes(dial_d, DASH_REAL); ph_dialer_util_get_numstr_from_node(dial_d, dest); ph_dialer_entry_set_number(dial_d, dest, CURSOR_END); ph_dialer_search_request(dial_d, FALSE); } else dial_d->searched_text = SAFE_STRDUP(number); } else ph_dialer_util_entry_clear(dial_d); } API void phone_dialer_view_send_key(Evas_Object *layout) { PH_FN_CALL; ph_dialer_data *dial_d; dial_d = evas_object_data_get(layout, KEY_DIALER_DATA); p_retm_if(NULL == dial_d, "dialer data is null"); dialer_softkey_call_clicked(dial_d, 0); } API void phone_dialer_set_background(Evas_Object *obj, bool is_background) { PH_FN_CALL; ph_dialer_data *dial_d; dial_d = evas_object_data_get(obj, KEY_DIALER_DATA); p_retm_if(NULL == dial_d, "log data is null"); dial_d->is_background = is_background; if (dial_d->update_timer) { ecore_timer_del(dial_d->update_timer); dial_d->update_timer = NULL; ph_dialer_reload_data(dial_d); } }