/* * 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://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 "msg-ui-thread-main.h" static void __msg_ui_thread_insert_and_select_gen_item(PMSG_THREAD_LIST_DATA pListData); static void __msg_ui_thread_add_navi_select_all_ly(PMSG_THREAD_LIST_DATA pListData); static void __msg_ui_thread_sel_all_ly_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info); static void __msg_ui_thread_multi_action_finish(PMSG_THREAD_LIST_DATA pListData); static Eina_Bool __msg_ui_thread_searchbar_entry_timer_cb(void *data); static void __msg_ui_thread_ctxpopup_clicked_cb(void *data, Evas_Object *obj, void *event_info); static void __msg_ui_thread_ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info); void msg_ui_thread_storage_change_cb(msg_handle_t handle, msg_storage_change_type_t type, msg_id_list_s *pMsgIdList, void *user_param) { MSG_UI_ENTER(); int list_idx = 0; bool multiple_action = false; if (!user_param || !pMsgIdList) return; PMSG_THREAD_DATA pData = user_param; PMSG_THREAD_LIST_DATA pListData = NULL; if (msg_ui_thread_get_app_state(pData) == MSG_UI_STATE_DESTROY) return; MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "type is %d", type); for (list_idx = MSG_THREAD_LIST_MAX_COUNT-1; list_idx >= 0; list_idx--) { if (pData->list_data[list_idx] != NULL) { pListData = pData->list_data[list_idx]; if (pListData->multi_action_thread != NULL || multiple_action == true) { multiple_action = true; break; //finish multi action, reload msg list } if (type == MSG_STORAGE_CHANGE_CONTACT) { if (pListData->app_data_type == THREAD_LIST_APP_DATA_THREAD) msg_ui_thread_list_update(pListData); else msg_ui_thread_list_msg_list_update(pListData); } else if (type == MSG_STORAGE_CHANGE_INSERT) { if (pListData->view_mode == THREAD_EDIT_VIEW) { pData->isIncomingMsg = true; D_MSG("Current mode is EDIT."); return; } __msg_ui_thread_insert_and_select_gen_item(pListData); } else if (type == MSG_STORAGE_CHANGE_DELETE) { if (pListData->app_data_type == THREAD_LIST_APP_DATA_MSG) { int idx = 0; for (idx = 0; idx < pMsgIdList->nCount; idx++) { msg_ui_thread_list_msg_item_delete(pListData, pMsgIdList->msgIdList[idx]); } } else { Elm_Object_Item *gen_item = NULL; PMSG_APP_THREAD_DATA_S item_data = NULL; msg_struct_t threadInfo = msg_create_struct(MSG_STRUCT_THREAD_INFO); int smsCnt = 0; int mmsCnt = 0; msg_error_t err = MSG_SUCCESS; gen_item = elm_genlist_first_item_get(pListData->genlist); while (gen_item) { if (elm_genlist_item_parent_get(gen_item) == NULL) { gen_item = elm_genlist_item_next_get(gen_item); continue; } item_data = (PMSG_APP_THREAD_DATA_S) elm_object_item_data_get(gen_item); err = msg_get_thread(msg_ui_thread_get_data_handle(), item_data->thread_id, threadInfo); if (err != MSG_SUCCESS) { MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_get_thread() is failed : err = %d", err); msg_ui_thread_list_item_delete(pListData, item_data->thread_id); break; } msg_get_int_value(threadInfo, MSG_THREAD_MMS_COUNT_INT, &mmsCnt); msg_get_int_value(threadInfo, MSG_THREAD_SMS_COUNT_INT, &smsCnt); if (smsCnt+mmsCnt == 0) msg_ui_thread_list_item_delete(pListData, item_data->thread_id); else if ((item_data->sms_cnt + item_data->mms_cnt) != (smsCnt+mmsCnt)) msg_ui_thread_list_item_update(pListData, item_data->thread_id); gen_item = elm_genlist_item_next_get(gen_item); } msg_release_struct(&threadInfo); } } else if (type == MSG_STORAGE_CHANGE_UPDATE) { int idx = 0; for (idx = 0; idx < pMsgIdList->nCount; idx++) { if (pListData->app_data_type == THREAD_LIST_APP_DATA_THREAD) { msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); msg_error_t err = MSG_SUCCESS; int thread_id = 0; err = msg_get_message(pData->msgHandle, pMsgIdList->msgIdList[idx], msgInfo, sendOpt); if (err != MSG_SUCCESS) { msg_release_struct(&msgInfo); msg_release_struct(&sendOpt); MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "error : msg_id : %d, error : %d", pMsgIdList->msgIdList[idx], err); return; } msg_get_int_value(msgInfo, MSG_MESSAGE_THREAD_ID_INT, &thread_id); msg_release_struct(&msgInfo); msg_release_struct(&sendOpt); if (msg_ui_thread_list_item_update(pListData, thread_id) == EINA_FALSE) __msg_ui_thread_insert_and_select_gen_item(pListData); } else { if (msg_ui_thread_list_msg_item_update(pListData, pMsgIdList->msgIdList[idx]) == EINA_FALSE) __msg_ui_thread_insert_and_select_gen_item(pListData); } } } } } MSG_UI_LEAVE(); } static void __msg_ui_thread_insert_and_select_gen_item(PMSG_THREAD_LIST_DATA pListData) { MSG_UI_ENTER(); int sel_thread_id = 0, sel_msg_id = 0; if (pListData->sel_gen_item) { sel_thread_id = pListData->sel_thread_id; sel_msg_id = pListData->sel_msg_id; } if (pListData->app_data_type == THREAD_LIST_APP_DATA_MSG) { if (pListData->search_mode == THREAD_SEARCH_ON) msg_ui_thread_search_msg_list_load(pListData); else msg_ui_thread_msg_list_load(pListData, pListData->list_type); msg_ui_thread_select_item_by_msg_id(pListData, sel_msg_id); } else { msg_ui_thread_list_load(pListData, FALSE); msg_ui_thread_select_item_by_thread_id(pListData, sel_thread_id); } if (pListData->sel_gen_item) elm_genlist_item_selected_set(pListData->sel_gen_item, true); MSG_UI_LEAVE(); } void msg_ui_thread_ctlbar_multi_action_cb(void *data, Evas_Object *obj, void *event_info) { D_ENTER; MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data || !obj); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; MSG_UI_RET_IF(MSG_UI_LEVEL_DEBUG, pListData->multi_action_thread); if (pListData->popup) { evas_object_del(pListData->popup); pListData->popup = NULL; } if (obj == pListData->toolbar_btn[CONTROLBAR_ITEM_1]) { pListData->action_type = THREAD_ACTION_DELETE; msg_ui_thread_show_action_popup(pListData, THREAD_ACTION_DELETE, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_DELETE_Q")); } else if (obj == pListData->toolbar_btn[CONTROLBAR_ITEM_2]) { if (pListData->list_type == THREAD_SPAM_LIST_TYPE) { pListData->action_type = THREAD_ACTION_RESTORE; msg_ui_thread_show_action_popup(pListData, THREAD_ACTION_RESTORE, dgettext(MESSAGE_PKGNAME, "IDS_MSG_BODY_MESSAGE_WILL_BE_RESTORED")); } else if (pListData->list_type == THREAD_SIM_LIST_TYPE) { pListData->action_type = THREAD_ACTION_COPY_TO_PHONE; } } if (pListData->popup == NULL) { pListData->popup = msg_ui_thread_show_notify_with_progressbar(pListData, pListData->check_cnt); pListData->multi_action_thread = ecore_thread_feedback_run(msg_ui_thread_multi_action_thread_fn, msg_ui_thread_multi_action_thread_feedback_fn, NULL, NULL, (void *)pListData, EINA_TRUE); } } void msg_ui_thread_multi_action_thread_feedback_fn(void *data, Ecore_Thread *thread, void *msg_data) { D_ENTER; MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !thread || !data || !msg_data); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; int *ret = msg_data; if (*ret == MSG_SUCCESS) { if (pListData->progressbar) elm_progressbar_value_set(pListData->progressbar, (double)(pListData->sel_index+1)/pListData->check_cnt); } else { MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "fail action. %d", *ret); /** __msg_ui_thread_multi_action_finish function contains evas_object_del(thread_data->popup), */ /** so, call __msg_ui_thread_multi_action_finish() first, after that make "unable to delete" popup */ __msg_ui_thread_multi_action_finish(pListData); if (pListData->action_type == THREAD_ACTION_DELETE) msg_ui_thread_show_notify(pListData, dgettext("sys_string", "IDS_COM_POP_UNABLE_TO_DELETE")); else if (pListData->action_type == THREAD_ACTION_COPY_TO_PHONE) msg_ui_thread_show_notify(pListData, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_UNABLE_TO_COPY")); else if (pListData->action_type == THREAD_ACTION_RESTORE) msg_ui_thread_show_notify(pListData, dgettext("sys_string", "IDS_COM_POP_MOVING_FAILED")); pListData->action_type = THREAD_ACTION_NONE; pListData->include_protected_msg = false; if (ret) free(ret); return; } if (pListData->sel_index + 1 == pListData->check_cnt) __msg_ui_thread_multi_action_finish(pListData); else pListData->sel_index++; if (ret) free(ret); } void msg_ui_thread_multi_action_thread_fn(void *data, Ecore_Thread *thread) { D_ENTER; MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; Eina_List *list; void* item_data = NULL; EINA_LIST_FOREACH(pListData->chk_list, list, item_data) { int *ret = calloc(1, sizeof(int)); if (item_data) { if (pListData->action_type == THREAD_ACTION_DELETE) { if (pListData->list_type == THREAD_NORMAL_LIST_TYPE) { PMSG_APP_THREAD_DATA_S data = (PMSG_APP_THREAD_DATA_S)item_data; *ret = msg_delete_thread_message_list(msg_ui_thread_get_data_handle(), data->thread_id, pListData->include_protected_msg); MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "pListData->include_protected_msg = %d", pListData->include_protected_msg); } else { PMSG_APP_THREAD_MSG_DATA_S data = (PMSG_APP_THREAD_MSG_DATA_S)item_data; if (pListData->include_protected_msg == false) { msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); bool bProtect = false; msg_error_t err = MSG_SUCCESS; err = msg_get_message(msg_ui_thread_get_data_handle(), (msg_message_id_t)data->msg_id, msgInfo, sendOpt); if (err != MSG_SUCCESS) { MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_get_message() is failed : err = %d", err); msg_release_struct(&msgInfo); msg_release_struct(&sendOpt); goto MSG_FAIL; } msg_get_bool_value(msgInfo, MSG_MESSAGE_PROTECTED_BOOL, &bProtect); if (bProtect == true) { msg_release_struct(&msgInfo); msg_release_struct(&sendOpt); *ret = MSG_SUCCESS; ecore_thread_feedback(thread, (void *)ret); continue; } *ret = msg_delete_message(msg_ui_thread_get_data_handle(), data->msg_id); msg_release_struct(&msgInfo); msg_release_struct(&sendOpt); } else { *ret = msg_delete_message(msg_ui_thread_get_data_handle(), data->msg_id); } } } else if (pListData->action_type == THREAD_ACTION_RESTORE) { PMSG_APP_THREAD_MSG_DATA_S data = (PMSG_APP_THREAD_MSG_DATA_S)item_data; *ret = msg_move_msg_to_folder(msg_ui_thread_get_data_handle(), data->msg_id, MSG_INBOX_ID); } else if (pListData->action_type == THREAD_ACTION_COPY_TO_PHONE) { PMSG_APP_THREAD_MSG_DATA_S data = (PMSG_APP_THREAD_MSG_DATA_S)item_data; int msg_id = 0; msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); *ret = msg_get_message(msg_ui_thread_get_data_handle(), (msg_message_id_t)data->msg_id, msgInfo, sendOpt); if (*ret != MSG_SUCCESS) { MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_get_message() is failed : err = %d, msgid = %d", *ret, data->msg_id); msg_release_struct(&msgInfo); msg_release_struct(&sendOpt); goto MSG_FAIL; } msg_set_int_value(msgInfo, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_PHONE); msg_id = msg_add_message(msg_ui_thread_get_data_handle(), msgInfo, sendOpt); msg_release_struct(&msgInfo); msg_release_struct(&sendOpt); } MSG_FAIL: ecore_thread_feedback(thread, (void *)ret); if (*ret != MSG_SUCCESS) return; } else { *ret = MSG_ERR_NULL_POINTER; ecore_thread_feedback(thread, (void *)ret); return; } } } static void __msg_ui_thread_multi_action_finish(PMSG_THREAD_LIST_DATA pListData) { D_ENTER; if (pListData->popup) { evas_object_del(pListData->popup); pListData->popup = NULL; } msg_ui_thread_show_action_finish_info(pListData, pListData->action_type, NULL); pListData->multi_action_thread = NULL; pListData->action_type = THREAD_ACTION_NONE; pListData->include_protected_msg = false; msg_ui_thread_show_normal_mode(pListData); if (pListData->list_type == THREAD_NORMAL_LIST_TYPE) { msg_ui_thread_list_load(pListData, FALSE); } else { PMSG_THREAD_LIST_DATA pDefaultListData = msg_ui_thread_get_default_list(); msg_ui_thread_msg_list_load(pListData, pListData->list_type); if (pDefaultListData) msg_ui_thread_list_load(pDefaultListData, FALSE); //might be changed } } void msg_ui_thread_ctlbar_checkbox_cb(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data || !obj); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; Elm_Object_Item* it_sweep = NULL; char buf[DEF_BUF_LEN_S] = {0}; pListData->view_mode = THREAD_EDIT_VIEW; pListData->check_cnt = 0; pListData->sel_index = 0; if (pListData->popup) { evas_object_del(pListData->popup); pListData->popup = NULL; } it_sweep = (Elm_Object_Item *)elm_genlist_decorated_item_get(pListData->genlist); if (it_sweep) { elm_genlist_item_decorate_mode_set(it_sweep, "slide", EINA_FALSE); elm_genlist_item_select_mode_set(it_sweep, ELM_OBJECT_SELECT_MODE_DEFAULT); elm_genlist_item_update(it_sweep); } elm_genlist_decorate_mode_set(pListData->genlist, EINA_TRUE); elm_genlist_select_mode_set(pListData->genlist, ELM_OBJECT_SELECT_MODE_ALWAYS); if (pListData->list_type == THREAD_SIM_LIST_TYPE || pListData->list_type == THREAD_SPAM_LIST_TYPE) snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_SK_EDIT")); else snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_SK_DELETE")); elm_object_item_text_set(pListData->nf_it, buf); __msg_ui_thread_add_navi_select_all_ly(pListData); msg_ui_thread_set_navi_toolbar_item(pListData); evas_object_hide(pListData->search_btn); elm_object_item_part_content_unset(pListData->nf_it, "title_right_btn"); MSG_UI_LEAVE(); } static void __msg_ui_thread_add_navi_select_all_ly(PMSG_THREAD_LIST_DATA pListData) { if (!pListData) { MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT,"[ASSERT] pListData is NULL"); return; } if (!pListData->sel_all_ly) { pListData->sel_all_ly = elm_layout_add(pListData->content_ly); elm_layout_theme_set(pListData->sel_all_ly, "genlist", "item", "select_all/default"); evas_object_size_hint_weight_set(pListData->sel_all_ly, EVAS_HINT_EXPAND, EVAS_HINT_FILL); evas_object_size_hint_align_set(pListData->sel_all_ly, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_event_callback_add(pListData->sel_all_ly, EVAS_CALLBACK_MOUSE_DOWN, __msg_ui_thread_sel_all_ly_mouse_down_cb, pListData); pListData->sel_all_box = elm_check_add(pListData->sel_all_ly); elm_check_state_pointer_set(pListData->sel_all_box, &pListData->sel_all_checked); evas_object_propagate_events_set(pListData->sel_all_box, EINA_FALSE); evas_object_smart_callback_add(pListData->sel_all_box, "changed", msg_ui_thread_sel_all_clicked_cb, pListData); evas_object_show(pListData->sel_all_box); elm_object_part_content_set(pListData->sel_all_ly, "elm.icon", pListData->sel_all_box); elm_object_part_text_set(pListData->sel_all_ly, "elm.text", dgettext("sys_string", "IDS_COM_BODY_SELECT_ALL")); } if (msg_ui_thread_rotation_get() == true) { elm_object_part_content_unset(pListData->content_ly, "sel_all"); evas_object_hide(pListData->searchbar); } else { edje_object_signal_emit(_EDJ(pListData->content_ly), "show_searchbar", "sel_all"); } evas_object_show(pListData->sel_all_ly); elm_object_part_content_set(pListData->content_ly, "sel_all", pListData->sel_all_ly); } static void __msg_ui_thread_sel_all_ly_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; pListData->sel_all_checked = !pListData->sel_all_checked; elm_check_state_pointer_set(pListData->sel_all_box, &pListData->sel_all_checked); msg_ui_thread_sel_all_clicked_cb(pListData, NULL, NULL); MSG_UI_LEAVE(); } void msg_ui_thread_ctlbar_spam_setting_cb(void *data, Evas_Object *obj, void *event_info) { PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; Elm_Object_Item* it_sweep = NULL; it_sweep = (Elm_Object_Item *)elm_genlist_decorated_item_get(pListData->genlist); if (it_sweep) { elm_genlist_item_decorate_mode_set(it_sweep, "slide", EINA_FALSE); elm_genlist_item_select_mode_set(it_sweep, ELM_OBJECT_SELECT_MODE_DEFAULT); } msg_ui_thread_launch_spam_setting(pListData); } void msg_ui_thread_ctlbar_compose_cb(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data || !obj); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; Elm_Object_Item* it_sweep = NULL; service_h svc_handle = NULL; if (service_create(&svc_handle) < 0 || svc_handle == NULL) { D_EMSG("service_create() is failed !!"); return; } it_sweep = (Elm_Object_Item *)elm_genlist_decorated_item_get(pListData->genlist); if (it_sweep) { elm_genlist_item_decorate_mode_set(it_sweep, "slide", EINA_FALSE); elm_genlist_item_select_mode_set(it_sweep, ELM_OBJECT_SELECT_MODE_DEFAULT); } if (msg_ui_load_composer_ug(svc_handle, MSG_COMPOSER_UG_TYPE_COMPOSER) == MSG_UI_RET_ERR) D_MSG("Failed to load composer ug"); service_destroy(svc_handle); MSG_UI_LEAVE(); } void msg_ui_thread_ctlbar_message_box_cb(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data || !obj); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; PMSG_THREAD_DATA pData = msg_ui_thread_get_data(); Elm_Object_Item* it_sweep = NULL; if (pListData->popup) { evas_object_del(pListData->popup); pListData->popup = NULL; } it_sweep = (Elm_Object_Item *)elm_genlist_decorated_item_get(pListData->genlist); if (it_sweep) { elm_genlist_item_decorate_mode_set(it_sweep, "slide", EINA_FALSE); elm_genlist_item_select_mode_set(it_sweep, ELM_OBJECT_SELECT_MODE_DEFAULT); } // Create pop-up ( Spam / SIM (it will be extended) ) Evas_Object *ctx_popup = NULL; ctx_popup = elm_ctxpopup_add(pData->navi_frame); evas_object_smart_callback_add(ctx_popup, "dismissed", __msg_ui_thread_ctxpopup_dismissed_cb, pListData); if (pListData->item_cnt > 0) elm_ctxpopup_item_append(ctx_popup, dgettext("sys_string", "IDS_COM_SK_DELETE"), NULL, msg_ui_thread_ctlbar_checkbox_cb, pListData); elm_ctxpopup_item_append(ctx_popup, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_CB_MESSAGES"), NULL, __msg_ui_thread_ctxpopup_clicked_cb, pListData); elm_ctxpopup_item_append(ctx_popup, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_SIM_CARD_MESSAGES"), NULL, __msg_ui_thread_ctxpopup_clicked_cb, pListData); elm_ctxpopup_item_append(ctx_popup, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_SPAM_MESSAGES"), NULL, __msg_ui_thread_ctxpopup_clicked_cb, pListData); // move ctx popup Evas_Coord x, y, w, h; evas_object_geometry_get(obj, &x, &y, &w, &h); evas_object_move(ctx_popup, x , y); evas_object_show(ctx_popup); pListData->popup = ctx_popup; MSG_UI_LEAVE(); } static void __msg_ui_thread_ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; if (pListData->popup) { evas_object_del(pListData->popup); pListData->popup = NULL; } MSG_UI_LEAVE(); } static void __msg_ui_thread_ctxpopup_clicked_cb(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); ThreadMsgListType list_type = THREAD_NORMAL_LIST_TYPE; PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; const char *label = elm_object_item_text_get((Elm_Object_Item *)event_info); if (strcmp(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_SPAM_MESSAGES")) == 0) { list_type = THREAD_SPAM_LIST_TYPE; } else if (strcmp(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_SIM_CARD_MESSAGES")) == 0) { list_type = THREAD_SIM_LIST_TYPE; } else if (strcmp(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_CB_MESSAGES")) == 0) { list_type = THREAD_CBMSG_LIST_TYPE; } else { MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[ERROR] invalid list type"); return; } if (pListData->popup) { evas_object_del(pListData->popup); pListData->popup = NULL; } msg_ui_thread_load_message_box(list_type); MSG_UI_LEAVE(); } void msg_ui_thread_sel_all_clicked_cb(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; Elm_Object_Item *it; void* item_data = NULL; if (pListData->sel_all_checked) { pListData->check_cnt = pListData->item_cnt; } else { pListData->check_cnt = 0; pListData->chk_list = eina_list_free(pListData->chk_list); } it = elm_genlist_first_item_get(pListData->genlist); while (it) { if (elm_genlist_item_parent_get(it) == NULL) { it = elm_genlist_item_next_get(it); continue; } item_data = elm_object_item_data_get(it); if (item_data) { if (pListData->app_data_type == THREAD_LIST_APP_DATA_THREAD) { PMSG_APP_THREAD_DATA_S data = (PMSG_APP_THREAD_DATA_S)item_data; data->is_check = pListData->sel_all_checked; } else { PMSG_APP_THREAD_MSG_DATA_S data = (PMSG_APP_THREAD_MSG_DATA_S)item_data; data->is_check = pListData->sel_all_checked; } } if (pListData->sel_all_checked && !eina_list_data_find(pListData->chk_list, item_data)) pListData->chk_list = eina_list_append(pListData->chk_list, item_data); it = elm_genlist_item_next_get(it); } elm_genlist_realized_items_update(pListData->genlist); msg_ui_thread_show_select_info(pListData); MSG_UI_LEAVE(); } void msg_ui_thread_list_checked_cb(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; void* item_data = NULL; Eina_Bool is_check = EINA_FALSE; item_data = evas_object_data_get(obj, "item_data"); if (pListData->app_data_type == THREAD_LIST_APP_DATA_THREAD) { PMSG_APP_THREAD_DATA_S data = (PMSG_APP_THREAD_DATA_S)item_data; is_check = data->is_check; } else { PMSG_APP_THREAD_MSG_DATA_S data = (PMSG_APP_THREAD_MSG_DATA_S)item_data; is_check = data->is_check; } if (is_check) { pListData->check_cnt++; if (!eina_list_data_find(pListData->chk_list, item_data)) pListData->chk_list = eina_list_append(pListData->chk_list, item_data); } else { pListData->check_cnt--; pListData->chk_list = eina_list_remove(pListData->chk_list, item_data); } if (pListData->item_cnt == pListData->check_cnt) elm_check_state_set(pListData->sel_all_box, EINA_TRUE); else elm_check_state_set(pListData->sel_all_box, EINA_FALSE); msg_ui_thread_show_select_info(pListData); MSG_UI_LEAVE(); } void msg_ui_thread_back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); if (!data) return; PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; PMSG_THREAD_DATA pData = msg_ui_thread_get_data(); if (pData->detail_layout) { if (pData->isRotate == true) elm_naviframe_item_pop(pData->split_data->navi_frame); else elm_naviframe_item_pop(pData->navi_frame); pData->detail_layout = NULL; if (pListData->sel_msg_id) { msg_ui_thread_list_msg_item_update(pListData, pListData->sel_msg_id); pListData->sel_gen_item = NULL; pListData->sel_msg_id = 0; } if (pData->isRotate == false) return; } if (pListData->search_mode == THREAD_SEARCH_ON) { msg_ui_thread_cancel_search_mode(pListData); return; } if (pListData->view_mode == THREAD_EDIT_VIEW) { if (pData->isIncomingMsg == true) { if (pListData->app_data_type == THREAD_LIST_APP_DATA_MSG) msg_ui_thread_msg_list_load(pListData, pListData->list_type); else msg_ui_thread_list_load(pListData, FALSE); pData->isIncomingMsg = false; } msg_ui_thread_show_normal_mode(pListData); } else { if (pListData->list_type == THREAD_NORMAL_LIST_TYPE) { elm_win_lower(pData->win_main); } else { PMSG_THREAD_LIST_DATA pPrevList = msg_ui_thread_get_prev_list(pListData); msg_ui_thread_set_navi_toolbar_item(pPrevList); elm_naviframe_item_pop(pData->navi_frame); elm_genlist_clear(pListData->genlist); msg_ui_thread_destroy_thread_list_data(pListData); if (pData->isRotate == true) { msg_ui_thread_destroy_split_data(pData->split_data); msg_ui_thread_split_view_show(pData); } } } MSG_UI_LEAVE(); } void msg_ui_thread_search_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); if (!data) return; PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; Evas_Object *entry = NULL; if (pListData->item_cnt <= 0) return; edje_object_signal_emit(_EDJ(pListData->content_ly), "show_searchbar", "sel_all"); elm_object_part_content_set(pListData->content_ly, "sel_all", pListData->searchbar); entry = elm_object_part_content_get(pListData->searchbar, "elm.swallow.content"); elm_object_focus_set(entry, EINA_TRUE); evas_object_hide(pListData->search_btn); elm_object_item_part_content_unset(pListData->nf_it, "title_right_btn"); msg_ui_thread_set_navi_toolbar_item(pListData); MSG_UI_LEAVE(); } void msg_ui_thread_searchbar_entry_focus_cb(void *data, Evas_Object *obj, void *event_info) { D_ENTER; MSG_UI_RETM_IF(MSG_UI_LEVEL_ASSERT, !data, "[ASSERT] data is NULL"); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; Elm_Object_Item* it_sweep = NULL; pListData->search_mode = THREAD_SEARCH_ON; elm_genlist_mode_set(pListData->genlist, ELM_LIST_COMPRESS); it_sweep = (Elm_Object_Item *)elm_genlist_decorated_item_get(pListData->genlist); if (it_sweep) { elm_genlist_item_decorate_mode_set(it_sweep, "slide", EINA_FALSE); elm_genlist_item_select_mode_set(it_sweep, ELM_OBJECT_SELECT_MODE_DEFAULT); } if (!elm_entry_is_empty(obj)) elm_object_signal_emit(pListData->searchbar, "elm,state,eraser,show", "elm"); elm_object_signal_emit(pListData->searchbar, "elm,state,guidetext,hide", "elm"); elm_object_signal_emit(pListData->searchbar, "cancel,in", ""); evas_object_smart_callback_add(obj, "changed", msg_ui_thread_searchbar_entry_change_cb, pListData); evas_object_smart_callback_add(obj, "preedit,changed", msg_ui_thread_searchbar_entry_change_cb, pListData); D_LEAVE; } void msg_ui_thread_searchbar_entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info) { D_ENTER; evas_object_smart_callback_del(obj, "changed", msg_ui_thread_searchbar_entry_change_cb); if (!data) return; PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; elm_object_signal_emit(pListData->searchbar, "elm,state,eraser,hide", "elm"); msg_ui_thread_set_navi_toolbar_item(pListData); if (elm_entry_is_empty(obj)) { elm_object_signal_emit(pListData->searchbar, "elm,state,guidetext,show", "elm"); elm_genlist_mode_set(pListData->genlist, ELM_LIST_SCROLL); } D_LEAVE; } void msg_ui_thread_searchbar_entry_change_cb(void *data, Evas_Object *obj, void *event_info) { D_ENTER; if (!data) return; PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; /* Make timer for check user's input */ if (pListData->search_timer) { ecore_timer_del(pListData->search_timer); pListData->search_timer = NULL; } pListData->search_timer = ecore_timer_add(0.2, __msg_ui_thread_searchbar_entry_timer_cb, pListData); if (elm_object_focus_get(obj)) { if (elm_entry_is_empty(obj)) elm_object_signal_emit(pListData->searchbar, "elm,state,eraser,hide", "elm"); else elm_object_signal_emit(pListData->searchbar, "elm,state,eraser,show", "elm"); } D_LEAVE; } static Eina_Bool __msg_ui_thread_searchbar_entry_timer_cb(void *data) { PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; msg_ui_thread_search_msg_list_load(pListData); if (pListData->search_timer) { ecore_timer_del(pListData->search_timer); pListData->search_timer = NULL; } return ECORE_CALLBACK_CANCEL; } void msg_ui_thread_searchbar_cancel_click_cb(void *data, Evas_Object *obj, void *event_info) { D_ENTER; if (!data) return; PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; Evas_Object *entry = NULL; if (pListData->search_timer) { ecore_timer_del(pListData->search_timer); pListData->search_timer = NULL; } evas_object_hide(obj); msg_ui_thread_cancel_search_mode(pListData); D_LEAVE; } void msg_ui_thread_searchbar_eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source) { D_ENTER; if (!data) return; PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; Evas_Object *entry = NULL; if (pListData->search_timer) { ecore_timer_del(pListData->search_timer); pListData->search_timer = NULL; } entry = elm_object_part_content_get(pListData->searchbar, "elm.swallow.content"); elm_object_text_set(entry, ""); elm_object_signal_emit(pListData->searchbar, "elm,state,eraser,hide", "elm"); D_LEAVE; } void msg_ui_thread_sweep_btn_cb(void *data, Evas_Object *obj, void *event_info) { MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !obj || !data); PMSG_THREAD_LIST_DATA pListData = data; char address[DEF_THREAD_ADDR_LEN+1] = {0,}; Elm_Object_Item *it = NULL; const char *label = elm_object_text_get(obj); it = (Elm_Object_Item *)elm_genlist_decorated_item_get(pListData->genlist); if (g_strcmp0(label, dgettext("sys_string", "IDS_COM_SK_DELETE")) == 0) { msg_ui_thread_show_action_popup(pListData, THREAD_ACTION_DELETE, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_DELETE_Q")); return; } else if (g_strcmp0(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_SK_RESTORE")) == 0) { msg_ui_thread_show_action_popup(pListData, THREAD_ACTION_RESTORE, dgettext(MESSAGE_PKGNAME, "IDS_MSG_BODY_MESSAGE_WILL_BE_RESTORED")); return; } if (pListData->app_data_type == THREAD_LIST_APP_DATA_THREAD) { PMSG_APP_THREAD_DATA_S sel_peer_item = NULL; sel_peer_item = (PMSG_APP_THREAD_DATA_S)evas_object_data_get(obj, "sel_peer_data"); msg_struct_list_s addrList; memset(&addrList, 0x00, sizeof(msg_struct_list_s)); msg_get_address_list(msg_ui_thread_get_data_handle(), sel_peer_item->thread_id, &addrList); if (addrList.nCount == 1) { char strNumber[DEF_THREAD_ADDR_LEN + 1] = {0,}; msg_get_str_value(addrList.msg_struct_info[0], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, DEF_THREAD_ADDR_LEN); strncpy(address, strNumber, DEF_THREAD_ADDR_LEN); if (g_strcmp0(label, dgettext("sys_string", "IDS_COM_BODY_CALL")) == 0) msg_ui_thread_launch_voice_call(address); else if (g_strcmp0(label, dgettext("sys_string", "IDS_COM_BODY_VIDEO_CALL")) == 0) msg_ui_thread_launch_video_call(address); else if (g_strcmp0(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_BLOCK")) == 0) { char *szbuf = dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_BLOCK_PS_Q"); char *text = g_strdup_printf(szbuf, strNumber); msg_ui_thread_show_action_popup(pListData, THREAD_ACTION_BLOCK, text); free(text); return; } else if (g_strcmp0(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_UNBLOCK")) == 0) { if(msg_common_delete_block_number(msg_ui_thread_get_data_handle(), address) == MSG_SUCCESS) msg_ui_thread_show_action_finish_info(pListData, THREAD_ACTION_UNBLOCK, address); } } else if (addrList.nCount > 1) { msg_ui_thread_addr_select_popup(pListData, label, &addrList); } msg_release_list_struct(&addrList); } else { PMSG_APP_THREAD_MSG_DATA_S sel_peer_item = NULL; sel_peer_item = (PMSG_APP_THREAD_MSG_DATA_S)evas_object_data_get(obj, "sel_peer_data"); msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); msg_error_t err = MSG_SUCCESS; err = msg_get_message(msg_ui_thread_get_data_handle(), (msg_message_id_t)sel_peer_item->msg_id, msgInfo, sendOpt); if (err != MSG_SUCCESS) { MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_get_message() is failed : err = %d, msgid = %d", err, sel_peer_item->msg_id); msg_release_struct(&msgInfo); msg_release_struct(&sendOpt); return; } if (g_strcmp0(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_COPY_TO_PHONE")) == 0) { int msg_id = 0; msg_set_int_value(msgInfo, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_PHONE); msg_id = msg_add_message(msg_ui_thread_get_data_handle(), msgInfo, sendOpt); if (msg_id >= 0) msg_ui_thread_show_action_finish_info(pListData, THREAD_ACTION_COPY_TO_PHONE, NULL); } else { char strNumber[DEF_THREAD_ADDR_LEN + 1] = {0,}; msg_struct_list_s *addr_list = NULL; msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list); msg_get_str_value(addr_list->msg_struct_info[0], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, DEF_THREAD_ADDR_LEN); strncpy(address, strNumber, DEF_THREAD_ADDR_LEN); if (sel_peer_item->addr_cnt == 1) { if (g_strcmp0(label, dgettext("sys_string", "IDS_COM_BODY_CALL")) == 0) msg_ui_thread_launch_voice_call(address); else if (g_strcmp0(label, dgettext("sys_string", "IDS_COM_BODY_VIDEO_CALL")) == 0) msg_ui_thread_launch_video_call(address); else if (g_strcmp0(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_BLOCK")) == 0) { char *szbuf = dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_BLOCK_PS_Q"); char *text = g_strdup_printf(szbuf, strNumber); msg_ui_thread_show_action_popup(pListData, THREAD_ACTION_BLOCK, text); free(text); msg_release_struct(&msgInfo); msg_release_struct(&sendOpt); return; } else if (g_strcmp0(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_UNBLOCK")) == 0) { if (msg_common_delete_block_number(msg_ui_thread_get_data_handle(), address) == MSG_SUCCESS) msg_ui_thread_show_action_finish_info(pListData, THREAD_ACTION_UNBLOCK, address); } } else { msg_ui_thread_addr_select_popup(pListData, label, addr_list); } } msg_release_struct(&msgInfo); msg_release_struct(&sendOpt); } if (it) { elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE); elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT); } } void msg_ui_thread_timezone_change_cb(keynode_t *key, void *data) { D_ENTER; PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)data; PMSG_THREAD_LIST_DATA pListData = NULL; char *timezone_id = NULL; UChar utimezone_id[DEF_BUF_LEN] = {0,}; UErrorCode status = U_ZERO_ERROR; int i = 0; timezone_id = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID); if (!timezone_id) return; u_uastrcpy(utimezone_id, timezone_id); ucal_setDefaultTimeZone(utimezone_id, &status); if (U_FAILURE(status)) return; msg_ui_thread_get_locale(pData); msg_ui_thread_get_time_format(pData); if (pData->date_ptn_default) { free(pData->date_ptn_default); pData->date_ptn_default = NULL; } if (pData->date_ptn_year) { free(pData->date_ptn_year); pData->date_ptn_year = NULL; } if (pData->time_12h_ptn) { free(pData->time_12h_ptn); pData->time_12h_ptn = NULL; } if (pData->time_24h_ptn) { free(pData->time_24h_ptn); pData->time_24h_ptn = NULL; } pData->time_12h_ptn = msg_common_get_date_best_pattern(pData->locale, MSG_UI_TIME_PATTERN_12H); pData->time_24h_ptn = msg_common_get_date_best_pattern(pData->locale, MSG_UI_TIME_PATTERN_24H); pData->date_ptn_default = msg_common_get_date_best_pattern(pData->locale, MSG_UI_DATE_PATTERN_DEFAULT); pData->date_ptn_year = msg_common_get_date_best_pattern(pData->locale, MSG_UI_DATE_PATTERN_YEAR); for (i = 0; i < MSG_THREAD_LIST_MAX_COUNT; i++) { if (pData->list_data[i] != NULL) { pListData = pData->list_data[i]; elm_genlist_realized_items_update(pListData->genlist); } } D_LEAVE; } void msg_ui_thread_gl_mode_right(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); MSG_UI_RET_IF(MSG_UI_LEVEL_DEBUG, !data || !event_info); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; MSG_UI_RET_IF(MSG_UI_LEVEL_DEBUG, pListData->view_mode != THREAD_NORMAL_VIEW); Elm_Object_Item *it = (Elm_Object_Item *)elm_genlist_decorated_item_get(obj); if (it) { if (it == event_info) return; elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE); elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT); } if (pListData->search_mode == THREAD_SEARCH_OFF) { elm_genlist_item_decorate_mode_set(event_info, "slide", EINA_TRUE); elm_genlist_item_select_mode_set(event_info, ELM_OBJECT_SELECT_MODE_NONE); } MSG_UI_LEAVE(); } void msg_ui_thread_gl_mode_left(void *data, Evas_Object *obj, void *event_info) { MSG_UI_ENTER(); MSG_UI_RET_IF(MSG_UI_LEVEL_DEBUG, !data || !event_info); PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data; MSG_UI_RET_IF(MSG_UI_LEVEL_DEBUG, pListData->view_mode != THREAD_NORMAL_VIEW); if (pListData->search_mode == THREAD_SEARCH_OFF) { elm_genlist_item_decorate_mode_set(event_info, "slide", EINA_FALSE); elm_genlist_item_select_mode_set(event_info, ELM_OBJECT_SELECT_MODE_DEFAULT); } MSG_UI_LEAVE(); }