2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "msg-ui-composer-body.h"
20 #include "msg-ui-composer-recipient.h"
21 #include "msg-ui-composer-main.h"
22 #include "msg-ui-composer-body-page.h"
23 #include "msg-ui-composer-body-callback.h"
24 #include "msg-ui-composer-common.h"
25 #include "msg-ui-composer-attachment.h"
26 #include "msg-ui-composer-subject.h"
27 #include "msg-ui-composer-message.h"
28 #include "msg-ui-composer-popup.h"
29 #include "msg-ui-composer-util.h"
30 #include "msg-ui-composer-external.h"
31 #include "syspopup_caller.h"
32 #include <tapi_common.h>
33 #include <ITapiModem.h>
36 /*==================================================================================================
37 * FUNCTION IMPLEMENTATIONS
38 *==================================================================================================*/
39 static void __add_list_popup_clicked_cb(void *data, Evas_Object *obj, void *event_info)
43 if (!data || !event_info) {
44 D_EMSG("invalid argument, argument data is NULL");
48 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
50 if (cd->add_menu_clicked)
53 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
54 elm_list_item_selected_set(item, EINA_FALSE);
56 const char *label = elm_object_item_text_get(item);
58 D_EMSG("label is NULL !!");
62 cd->add_menu_clicked = true;
64 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "label = %s", label);
65 if (cd->isAppControl && cd->isEmulator) {
66 if (!g_strcmp0(label, MSGC_STR_SUBJECT)) {
67 msg_ui_composer_add_subject(cd);
69 D_EMSG("Unknown Menu List Item");
72 if (!g_strcmp0(label, MSGC_STR_SUBJECT)) {
73 msg_ui_composer_add_subject(cd);
74 } else if (!g_strcmp0(label, MSGC_STR_GALLERY)) {
75 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_GALLERY, NULL);
76 } else if (!g_strcmp0(label, MSGC_STR_MYFILE)) {
77 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_MYFILE, NULL);
78 } else if (!g_strcmp0(label, _MSGSTR("IDS_MSGC_BODY_TAKE_PICTURE"))) {
79 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_CAMERA, NULL);
80 } else if (!g_strcmp0(label, _MSGSTR("IDS_MSGC_BODY_CAPTURE_VIDEO"))) {
81 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_CAMCORDER, NULL);
82 } else if (!g_strcmp0(label, MSGC_STR_CONTACT)) {
83 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_NAMECARD, NULL);
84 } else if (!g_strcmp0(label, _SYSSTR("IDS_COM_BODY_CALENDAR"))) {
85 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_CALENDAR, NULL);
86 } else if (!g_strcmp0(label, _SYSSTR("IDS_COM_BODY_MEMO"))) {
87 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_MEMO, NULL);
89 D_EMSG("Unknown Menu List Item");
93 MSGC_EVAS_OBJECT_DEL(cd->add_popup);
94 cd->add_button_clicked = false;
95 cd->add_menu_clicked = false;
99 static void __add_list_popup_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
103 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
104 D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
105 MSGC_EVAS_OBJECT_DEL(cd->add_popup);
106 cd->add_button_clicked = false;
107 cd->add_menu_clicked = false;
112 static void __add_list_popup_show(void *data)
116 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
117 Evas_Object *popup = NULL;
118 Evas_Object *list = NULL;
120 int list_padding = 4;
123 list = elm_list_add(cd->main_window);
124 D_MSG_RETM_IF(list == NULL, "list is NULL");
125 elm_list_mode_set(list, ELM_LIST_EXPAND);
127 Elm_Object_Item *item = NULL;
129 if (cd->isAppControl && cd->isEmulator) {
130 item = elm_list_item_append(list, MSGC_STR_SUBJECT, NULL, NULL, __add_list_popup_clicked_cb, data);
134 elm_object_item_disabled_set(item, EINA_TRUE);
136 if (!cd->isSubject) {
137 elm_list_item_append(list, MSGC_STR_SUBJECT, NULL, NULL, __add_list_popup_clicked_cb, data);
141 elm_list_item_append(list, MSGC_STR_GALLERY, NULL, NULL, __add_list_popup_clicked_cb, data);
143 elm_list_item_append(list, _MSGSTR("IDS_MSGC_BODY_TAKE_PICTURE"), NULL, NULL, __add_list_popup_clicked_cb, data);
145 elm_list_item_append(list, _MSGSTR("IDS_MSGC_BODY_CAPTURE_VIDEO"), NULL, NULL, __add_list_popup_clicked_cb, data);
147 elm_list_item_append(list, MSGC_STR_MYFILE, NULL, NULL, __add_list_popup_clicked_cb, data);
149 elm_list_item_append(list, MSGC_STR_CONTACT, NULL, NULL, __add_list_popup_clicked_cb, data);
151 elm_list_item_append(list, _SYSSTR("IDS_COM_BODY_CALENDAR"), NULL, NULL, __add_list_popup_clicked_cb, data);
153 elm_list_item_append(list, _SYSSTR("IDS_COM_BODY_MEMO"), NULL, NULL, __add_list_popup_clicked_cb, data);
162 int popup_height = MSGC_POPUP_LIST_H * count + list_padding;
163 evas_object_size_hint_max_set(list, -1, popup_height * elm_config_scale_get());
166 popup = msg_ui_composer_list_popup_create(cd, _SYSSTR("IDS_COM_POP_ATTACH"), list, "min_menustyle");
168 Evas_Object *btn1 = elm_button_add(popup);
169 elm_object_style_set(btn1, "popup_button/default");
170 elm_object_text_set(btn1, MSGC_STR_BUTTON_CLOSE);
171 elm_object_part_content_set(popup, "button1", btn1);
172 evas_object_smart_callback_add(btn1, "clicked", __add_list_popup_btn_clicked_cb, cd);
174 cd->add_popup = popup;
179 static void __msgc_show_bubble_view(void *data, msg_thread_id_t tid)
182 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
183 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
185 /* show indicator area */
186 elm_layout_theme_set(cd->base, "layout", "application", "default");
188 elm_win_indicator_mode_set(cd->main_window, ELM_WIN_INDICATOR_SHOW);
190 msg_ui_composer_change_bubble_view(cd);
193 D_EMSG("Can not find tid = %d !!", tid);
194 msg_ui_composer_message_destroy();
195 ug_destroy_me(cd->ug);
200 msg_ui_composer_bubble_data_set(cd, tid);
201 msg_ui_bubble_start_view(cd->bubble_data);
202 msg_ui_composer_navi_title_set((void *)cd);
204 /* set recipient list for bubble composer */
205 msg_ui_composer_recipient_set_recipient_list(cd, tid);
210 static void __nosim_popup_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
214 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
215 D_MSG_RETM_IF(cd == NULL, "Composer data is NULL");
217 if (cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER || cd->composer_mode == MSG_COMPOSER_MODE_FORWARD) {
218 /* set saved msg flag */
219 cd->disable_auto_save_mode = true;
220 ug_destroy_me(cd->ug);
226 static void __unsupported_character_popup_yes_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
229 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
230 D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
232 MSGC_EVAS_OBJECT_DEL(cd->popup_end);
234 cd->send_check_exception_type |= SEND_CHECK_EXCEPTION_TYPE_ENCODING_MODE;
235 msg_ui_composer_body_make_and_send_message(cd, cd->send_check_exception_type);
240 static void __unsupported_character_popup_no_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
243 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
244 D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
246 MSGC_EVAS_OBJECT_DEL(cd->popup_end);
249 elm_object_disabled_set(cd->send_button, EINA_FALSE);
251 msg_ui_composer_last_focus_load(cd);
256 static void __msgc_flight_mode_tapi_cb(TapiHandle *handle, int result, void *data, void *user_data)
259 bool is_success = false;
262 case TAPI_POWER_FLIGHT_MODE_RESP_ON:
263 D_MSG("TAPI_POWER_FLIGHT_MODE_RESP_ON");
266 case TAPI_POWER_FLIGHT_MODE_RESP_OFF:
267 D_MSG("TAPI_POWER_FLIGHT_MODE_RESP_OFF");
271 case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
272 D_MSG("TAPI_POWER_FLIGHT_MODE_RESP_FAIL");
275 case TAPI_POWER_FLIGHT_MODE_RESP_MAX:
276 D_MSG("TAPI_POWER_FLIGHT_MODE_RESP_MAX");
280 D_MSG("result = %d", result);
281 if (result == NO_MODEM) {
282 D_MSG("there is no modem state");
283 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)user_data;
284 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
286 if (cd->flight_mode_timer) {
287 ecore_timer_del(cd->flight_mode_timer);
288 cd->flight_mode_timer = NULL;
290 MSGC_EVAS_OBJECT_DEL(cd->progress_popup);
292 msg_composer_set_flight_mode(false);
294 D_MSG("try to send message");
295 msg_ui_composer_body_make_and_send_message(cd, SEND_CHECK_EXCEPTION_TYPE_NONE);
301 D_EMSG("flight mode off is failed");
306 static Eina_Bool __msgc_flight_mode_enabled_check_timer_cb(void *data)
308 D_MSG_RETVM_IF(data == NULL, ECORE_CALLBACK_CANCEL, "data is NULL");
309 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
311 int network_status = -1;
312 static int count = 0;
315 if (count >= 100) { /* 0.5 sec * 100 = 50 sec */
316 D_EMSG("self time expiration");
317 MSGC_EVAS_OBJECT_DEL(cd->progress_popup);
323 /* check if call network is enabled - to send message l*/
324 ret = msg_composer_get_network_status(&network_status);
326 if (network_status == VCONFKEY_TELEPHONY_SVCTYPE_NONE ||
327 network_status == VCONFKEY_TELEPHONY_SVCTYPE_NOSVC ||
328 network_status == VCONFKEY_TELEPHONY_SVCTYPE_EMERGENCY ||
329 network_status == VCONFKEY_TELEPHONY_SVCTYPE_SEARCH) {
330 D_MSG("Cannot send message - check again");
331 return ECORE_CALLBACK_RENEW;
334 D_EMSG("msg_composer_get_network_status is failed");
335 return ECORE_CALLBACK_RENEW;
338 MSGC_EVAS_OBJECT_DEL(cd->progress_popup);
340 D_MSG("try to send message");
341 msg_ui_composer_body_make_and_send_message(cd, SEND_CHECK_EXCEPTION_TYPE_NONE);
346 cd->flight_mode_timer = NULL;
348 return ECORE_CALLBACK_CANCEL;
351 static void __flight_mode_popup_ok_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
354 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
355 D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
357 Evas_Object *check = (Evas_Object *)evas_object_data_get(cd->custom_popup, "check_box");
359 if (elm_check_state_get(check)) {
360 /* set flight mode off*/
361 if (msg_composer_set_flight_mode_by_api(cd->tapi_handle, TAPI_POWER_FLIGHT_MODE_LEAVE, __msgc_flight_mode_tapi_cb, cd) == false) {
362 D_EMSG("msg_composer_set_flight_mode_by_api is failed");
364 /* show progress popup */
365 MSGC_EVAS_OBJECT_DEL(cd->progress_popup);
366 cd->progress_popup = msg_ui_composer_progress_popup_show(cd, _MSGSTR("Disabling Flight mode"));
368 /* give focus to back btn to hide keypad */
369 elm_object_focus_set(cd->back_btn, EINA_TRUE);
371 if (cd->flight_mode_timer) {
372 ecore_timer_del(cd->flight_mode_timer);
373 cd->flight_mode_timer = NULL;
375 cd->flight_mode_timer = ecore_timer_add(0.5, __msgc_flight_mode_enabled_check_timer_cb, cd);
378 D_MSG("checkbox is not checked");
381 MSGC_EVAS_OBJECT_DEL(cd->custom_popup);
384 elm_object_disabled_set(cd->send_button, EINA_FALSE);
389 static void __flight_mode_popup_cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
392 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
393 D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
395 MSGC_EVAS_OBJECT_DEL(cd->custom_popup);
398 elm_object_disabled_set(cd->send_button, EINA_FALSE);
403 static COMPOSER_RETURN_TYPE_E __msgc_check_condition_to_send_msg(void *data, int check_exption_type)
406 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
407 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "composer data is NULL");
409 /* check flight mode */
411 if (msg_composer_get_flight_mode(&flight_mode) && flight_mode) {
413 if (!cd->tapi_handle)
414 cd->tapi_handle = (void *)tel_init(NULL);
416 if (!cd->tapi_handle) {
417 D_EMSG("tel_init is failed");
420 Evas_Object *popup = NULL;
421 Evas_Object *btn1 = NULL;
422 Evas_Object *btn2 = NULL;
423 char *popup_msg = _MSGSTR("IDS_MSGC_POP_UNABLE_TO_SEND_MESSAGES_WHILE_IN_FLIGHT_MODE_DISABLE_FLIGHT_MODE_AND_TRY_AGAIN");
424 char *checkbox_msg = _MSGSTR("IDS_MSGC_HEADER_DISABLE_FLIGHT_MODE_ABB");
426 MSGC_EVAS_OBJECT_DEL(cd->custom_popup);
428 popup = msg_ui_composer_checkbox_popup_create(cd, NULL, popup_msg, checkbox_msg);
430 btn1 = msg_ui_composer_popup_button_create(popup, _SYSSTR("IDS_COM_SK_OK"));
431 elm_object_part_content_set(popup, "button1", btn1);
432 evas_object_smart_callback_add(btn1, "clicked", __flight_mode_popup_ok_btn_clicked_cb, cd);
433 btn2 = msg_ui_composer_popup_button_create(popup, _SYSSTR("IDS_COM_SK_CANCEL"));
434 elm_object_part_content_set(popup, "button2", btn2);
435 evas_object_smart_callback_add(btn2, "clicked", __flight_mode_popup_cancel_btn_clicked_cb, cd);
437 cd->custom_popup = popup;
439 elm_object_focus_set(popup, EINA_TRUE);
442 return COMPOSER_RETURN_FAIL;
445 /*Check recipient available sending*/
446 RECIPIENT_S *rd = cd->recipient;
448 /*add recipient, if entry text exist*/
449 Evas_Object *entry = elm_multibuttonentry_entry_get(rd->mbe);
450 char *entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(entry));
452 if (strlen(entry_txt) > 0) {
453 if (NULL == elm_multibuttonentry_item_append(rd->mbe, entry_txt, NULL, NULL)) {
457 elm_object_disabled_set(cd->send_button, EINA_FALSE);
459 return COMPOSER_RETURN_FAIL;
465 /*check recipient count is zero*/
466 if (msg_ui_composer_recipient_count_get(rd) == 0) {
467 D_EMSG("there is no recipient");
468 //msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_NO_RECIPIENT);
470 /* change focus to recipient */
471 if (cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER)
472 msg_ui_composer_recipient_focus_set(cd->recipient);
475 elm_object_disabled_set(cd->send_button, EINA_FALSE);
477 return COMPOSER_RETURN_FAIL;
481 if (!(check_exption_type & SEND_CHECK_EXCEPTION_TYPE_ENCODING_MODE)) {
482 if (cd->msg_type == COMPOSER_MSG_TYPE_SMS) {
483 if (cd->body_data.page_list) {
484 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
485 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(cd->body_data.page_list, 0);
487 if (page_data && page_data->text_info.encode == COMPOSER_CHAR_ENCODE_GSM7_ABNORMAL) {
488 MSGC_EVAS_OBJECT_DEL(cd->popup_end);
489 Evas_Object *popup = msg_ui_composer_status_popup_show(cd->navi_bar, cd, _MSGSTR("Some characters may be lost. Continue?"), 0);
490 Evas_Object *btn1 = msg_ui_composer_popup_button_create(popup, _SYSSTR("IDS_COM_SK_YES"));
491 elm_object_part_content_set(popup, "button1", btn1);
492 evas_object_smart_callback_add(btn1, "clicked", __unsupported_character_popup_yes_btn_clicked_cb, cd);
493 Evas_Object *btn2 = msg_ui_composer_popup_button_create(popup, _SYSSTR("IDS_COM_SK_NO"));
494 elm_object_part_content_set(popup, "button2", btn2);
495 evas_object_smart_callback_add(btn2, "clicked", __unsupported_character_popup_no_btn_clicked_cb, cd);
496 elm_object_focus_allow_set(popup, EINA_TRUE);
497 elm_object_focus_set(popup, EINA_TRUE);
499 cd->popup_end = popup;
501 return COMPOSER_RETURN_FAIL;
508 return COMPOSER_RETURN_SUCCESS;
511 void msg_ui_composer_body_make_and_send_message(void *data, int check_exception_type)
514 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
515 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
516 msg_thread_id_t tid = 0;
518 if (__msgc_check_condition_to_send_msg(cd, check_exception_type) != COMPOSER_RETURN_SUCCESS) {
519 D_EMSG("__msgc_check_condition_to_send_msg is failed");
524 msg_ui_composer_message_init();
526 if (msg_ui_composer_recipient_read_data(cd) != COMPOSER_RETURN_SUCCESS) {
527 D_EMSG("Make recipient data Error");
531 if (__msg_ui_composer_body_read_data(cd) != COMPOSER_RETURN_SUCCESS) {
532 D_EMSG("Make body data Error");
537 COMPOSER_RETURN_TYPE_E ret = msg_ui_composer_message_make_and_send(cd->msg_handle, cd->msg_id, &tid);
539 /* reset region info */
540 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
541 body_data->region_order = COMPOSER_REGION_ORDER_UNDETERMINDED;
542 cd->send_check_exception_type = SEND_CHECK_EXCEPTION_TYPE_NONE;
544 if (ret == COMPOSER_RETURN_SUCCESS) {
545 D_MSG("Send Success");
547 if (cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER || cd->composer_mode == MSG_COMPOSER_MODE_FORWARD) {
548 /* set saved msg flag */
549 cd->disable_auto_save_mode = true;
550 ug_destroy_me(cd->ug);
551 } else if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER) {
552 __msgc_show_bubble_view(cd, tid);
553 msg_ui_composer_clear(cd);
555 service_h svc_handle;
556 if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
557 D_EMSG("service_create() is failed !!");
559 char buf[DEF_BUF_LEN_S] = {0,};
560 snprintf(buf, sizeof(buf), "%d", tid);
561 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, buf);
563 ug_send_result(cd->ug, svc_handle);
565 service_destroy(svc_handle);
568 msg_ui_composer_clear(cd);
571 cd->composer_mode = MSG_COMPOSER_MODE_NORMAL;
575 bool is_closed = false;
577 if (ret == COMPOSER_RETURN_NO_SIM) {
578 D_EMSG("Send Fail : NO SIM");
579 Evas_Object *popup = msg_ui_composer_status_popup_show(cd->main_window, cd, MSGC_STR_POP_NOSIM, 1);
580 elm_object_focus_set(cd->add_button, EINA_TRUE);
582 if (cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER || cd->composer_mode == MSG_COMPOSER_MODE_FORWARD) {
584 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, __nosim_popup_delete_cb, cd);
585 } else if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER) {
586 __msgc_show_bubble_view(cd, tid);
589 msg_ui_composer_clear(cd);
591 D_EMSG("Send Fail : Unable Send");
592 if ((cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER || cd->composer_mode == MSG_COMPOSER_MODE_FORWARD)) {
593 /* set saved msg flag */
594 cd->disable_auto_save_mode = true;
595 ug_destroy_me(cd->ug);
597 msg_ui_composer_status_popup_show(cd->main_window, cd, MSGC_STR_POP_UNABLE_SEND, COMPOSER_STATUS_POPUP_DEFAULT_TIME);
598 elm_object_focus_set(cd->add_button, EINA_TRUE);
603 cd->composer_mode = MSG_COMPOSER_MODE_NORMAL;
610 msg_ui_composer_set_body_keypad_layout(cd, ELM_INPUT_PANEL_LAYOUT_NORMAL);
611 msg_ui_composer_message_destroy();
616 msg_ui_composer_set_body_keypad_layout(cd, ELM_INPUT_PANEL_LAYOUT_NORMAL);
617 msg_ui_composer_message_destroy();
620 elm_object_disabled_set(cd->send_button, EINA_FALSE);
625 void msg_ui_composer_body_send_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
628 D_MSG_RETM_IF(data == NULL, "Composer Data is NULL");
630 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
633 elm_object_disabled_set(cd->send_button, EINA_TRUE);
635 cd->send_check_exception_type = SEND_CHECK_EXCEPTION_TYPE_NONE;
636 msg_ui_composer_body_make_and_send_message(cd, cd->send_check_exception_type);
642 void msg_ui_composer_body_add_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
647 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] error data is NULL");
651 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
653 if (cd->add_button_clicked)
656 cd->add_button_clicked = true;
657 __add_list_popup_show(cd);
662 void msg_ui_composer_body_entry_maxlength_reached_cb(void *data, Evas_Object *obj, void *event_info)
665 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
666 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
668 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_MAXLENGHT_CHAR);
673 void msg_ui_composer_body_entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
676 D_MSG_RETM_IF(data == NULL, "Composer Data is NULL");
677 D_MSG_RETM_IF(obj == NULL, "entry obj is NULL");
679 MSG_COMPOSER_VIEW_DATA_S *cd = data;
680 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
682 page_data = evas_object_data_get(obj, "page_data");
683 if (page_data == NULL)
686 char *body_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
687 if (body_text == NULL)
690 int text_len = strlen(body_text);
692 page_data->text_info.encode = COMPOSER_CHAR_ENCODE_UNICODE;
693 page_data->text_info.char_count = 0;
695 page_data->text_info.encode = msg_ui_composer_body_entry_char_count(cd, (const char *)body_text, &page_data->text_info.char_count, &page_data->text_info.page_size);
699 msg_ui_composer_message_type_check_and_change(cd);
701 msg_ui_composer_body_info_area_update(cd);
703 if (msg_ui_composer_common_is_send_possible(cd)) {
704 elm_object_disabled_set(cd->send_button, EINA_FALSE);
705 msg_ui_composer_body_update_send_btn_icon(cd, false);
707 elm_object_disabled_set(cd->send_button, EINA_TRUE);
708 msg_ui_composer_body_update_send_btn_icon(cd, true);
714 void msg_ui_composer_body_entry_press_cb(void *data, Evas_Object *obj, void *event_info)
717 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
718 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
720 if (msg_ui_composer_recipient_addr_type_get(cd->recipient) == COMPOSER_RECP_ADDR_INVALID) {
721 elm_entry_context_menu_disabled_set(obj, EINA_TRUE);
722 elm_entry_magnifier_disabled_set(obj, EINA_TRUE);
724 elm_entry_context_menu_disabled_set(obj, EINA_FALSE);
725 elm_entry_magnifier_disabled_set(obj, EINA_FALSE);
731 void msg_ui_composer_body_entry_clicked_cb(void *data, Evas_Object *obj, void *event_info)
734 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
735 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
737 int attach_count = msg_ui_composer_get_attach_count(cd);
739 if (attach_count > 1)
740 msg_ui_composer_contract_attach_list(cd);
745 void msg_ui_composer_body_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
749 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
750 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
752 if (cd->msg_type == COMPOSER_MSG_TYPE_MMS) {
753 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
755 int page_count = body_data->page_count;
757 if (page_count == 1) {
758 D_MSG("There is 1 page !!!");
760 MSG_COMPOSER_BODY_PAGE_S *page_data = evas_object_data_get(obj, "page_data");
761 if (page_data == NULL) {
762 D_EMSG("page_data is NULL");
764 /* hide delete button */
765 D_MSG("hide delete button");
766 edje_object_signal_emit(_EDJ(page_data->upper_layout), "hide.delete", "*");
774 void msg_ui_composer_body_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
778 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
779 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
781 if (msg_ui_composer_recipient_addr_type_get(cd->recipient) == COMPOSER_RECP_ADDR_INVALID) {
782 /* if focused_cb is called twice becuase of double click, move focus to popup */
783 if (msg_ui_composer_popup_exist(cd))
784 msg_ui_composer_popup_focus(cd);
789 if (cd->msg_type == COMPOSER_MSG_TYPE_MMS) {
790 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
792 Eina_List *page_list = body_data->page_list;
793 int page_count = body_data->page_count;
795 if (page_count == 1) {
796 D_MSG("page NO.1 focused !!!");
797 cd->current_edit_entry = 0;
799 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
802 for (i = 0; i < page_count; i++) {
803 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, i);
804 if (page_data->entry == obj) {
805 D_MSG("page NO.[%d]/[%d] focused !!!", i + 1, page_count);
806 cd->current_edit_entry = i;
810 page_data = evas_object_data_get(obj, "page_data");
811 if (page_data == NULL) {
812 D_EMSG("page_data is NULL");
814 /* show delete button */
815 D_MSG("show delete button");
816 edje_object_signal_emit(_EDJ(page_data->upper_layout), "show.delete", "*");
819 } else if (cd->msg_type == COMPOSER_MSG_TYPE_SMS) {
820 cd->current_edit_entry = 0;
822 D_MSG("message composer invalid message type");
825 msg_ui_composer_last_focused_entry_set(data, obj);
830 void msg_ui_composer_body_page_del_btn_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
833 D_MSG_RETM_IF(obj == NULL, "obj is NULL");
834 elm_image_file_set(obj, MSG_IMAGES_EDJ, MSGC_IMG_DEL_BTN_PRESS_ICON);
837 void msg_ui_composer_body_page_del_btn_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
840 D_MSG_RETM_IF(obj == NULL, "obj is NULL");
841 elm_image_file_set(obj, MSG_IMAGES_EDJ, MSGC_IMG_PAGE_DEL_ICON);
844 void msg_ui_composer_body_page_del_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
849 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] Callback data is NULL");
853 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
854 Evas_Object *layout = evas_object_data_get(obj, "layout");
856 msg_ui_composer_mms_body_remove_page(cd, layout);
858 msg_ui_composer_message_type_check_and_change(cd);
860 msg_ui_composer_body_info_area_update(cd);
862 /* in invalid recipient case, give focus to other widget to call verify_cb of recipient */
863 if (msg_ui_composer_last_focus_is_recipient(cd)) {
864 const char *recipient = msg_ui_composer_recipient_entry_text_get(cd->recipient);
866 if (recipient && recipient[0] != '\0') {
867 if (!msg_ui_composer_recipient_vaild_check(recipient))
868 elm_object_focus_set(cd->back_btn, EINA_TRUE);
874 static void __msg_ui_composer_body_launch_media_item(void *data, Evas_Object *obj)
877 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
878 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
879 D_MSG_RETM_IF(obj == NULL, "obj is NULL");
881 Evas_Object *layout = NULL;
882 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
883 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
884 Eina_List *page_list = body_data->page_list;
885 int page_count = body_data->page_count;
887 char file_path[COMPOSER_FILEPATH_LEN_MAX + 1] = {0, };
889 layout = evas_object_data_get(obj, "layout");
891 if (!layout || !page_list) {
892 D_EMSG("Invalid data layout = %x, page_list = %x", layout, page_list);
896 for (i = 0; i < page_count; i++) {
897 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, i);
900 D_EMSG("page data is NULL !!!");
904 if (page_data->sound_item == layout) {
905 strncpy(file_path, page_data->sound_file_path, COMPOSER_FILEPATH_LEN_MAX);
907 } else if (page_data->image_item == layout) {
908 strncpy(file_path, page_data->image_file_path, COMPOSER_FILEPATH_LEN_MAX);
913 if (file_path[0] != '\0') {
914 COMPOSER_EXT_TYPE_E type = COMPOSER_EXT_TYPE_COMMON;
915 COMPOSER_MEDIA_TYPE_E media_type = msg_composer_get_media_type(file_path);
917 if (media_type == COMPOSER_MEDIA_TYPE_IMAGE) {
918 type = COMPOSER_EXT_TYPE_IMAGE;
919 } else if (media_type == COMPOSER_MEDIA_TYPE_VIDEO) {
920 type = COMPOSER_EXT_TYPE_COMMON;
921 } else if (media_type == COMPOSER_MEDIA_TYPE_AUDIO) {
922 type = COMPOSER_EXT_TYPE_SOUND;
924 type = COMPOSER_EXT_TYPE_COMMON;
927 msg_ui_composer_external_call(cd, type, file_path);
933 void msg_ui_composer_body_media_layout_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
936 D_MSG_RETM_IF(data == NULL, "data is NULL");
937 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
939 __msg_ui_composer_body_launch_media_item(cd, obj);
944 void msg_ui_composer_body_media_thumb_icon_clicked_cb(void *data, Evas_Object *obj, void *event_info)
947 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
948 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
950 if (!cd->is_default_body_size)
951 __msg_ui_composer_body_launch_media_item(cd, obj);
956 void msg_ui_composer_body_media_del_btn_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
959 D_MSG_RETM_IF(obj == NULL, "obj is NULL");
962 media_type = (int)evas_object_data_get(obj, "media_type");
963 D_MSG("media_type = %d", media_type);
965 if (media_type == COMPOSER_MEDIA_TYPE_AUDIO)
966 elm_image_file_set(obj, MSG_IMAGES_EDJ, MSGC_IMG_DEL_BTN_PRESS_ICON);
968 elm_image_file_set(obj, MSG_IMAGES_EDJ, MSGC_IMG_INSERT_DEL_PRESS_ICON);
971 void msg_ui_composer_body_media_del_btn_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
974 D_MSG_RETM_IF(obj == NULL, "obj is NULL");
977 media_type = (int)evas_object_data_get(obj, "media_type");
979 if (media_type == COMPOSER_MEDIA_TYPE_AUDIO)
980 elm_image_file_set(obj, MSG_IMAGES_EDJ, MSGC_SOUND_INSERT_DEL_ICON);
982 elm_image_file_set(obj, MSG_IMAGES_EDJ, MSGC_IMG_INSERT_DEL_ICON);
985 void msg_ui_composer_body_media_del_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
990 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] NULL pointer error");
994 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
995 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
996 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
997 Eina_List *page_list = body_data->page_list;
998 int page_count = body_data->page_count;
1001 if (!cd->is_default_body_size) {
1002 Evas_Object *delete_layout = (Evas_Object *)evas_object_data_get(obj, "layout");
1006 for (i = 0; i < page_count; i++) {
1007 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, i);
1010 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] page data is NULL !!!");
1014 if (page_data->sound_item == delete_layout) {
1015 msg_ui_composer_mms_insert_item_remove(cd, delete_layout, COMPOSER_MEDIA_TYPE_AUDIO);
1017 char *body_text = elm_entry_markup_to_utf8(elm_entry_entry_get(page_data->entry));
1021 body_length = strlen(body_text);
1023 if (body_length == 0 && !page_data->is_image_item)
1024 msg_ui_composer_mms_body_remove_page(cd, page_data->layout);
1029 } else if (page_data->image_item == delete_layout) {
1031 char *body_text = elm_entry_markup_to_utf8(elm_entry_entry_get(page_data->entry));
1035 body_length = strlen(body_text);
1037 if (page_data->isVideo) {
1038 msg_ui_composer_mms_insert_item_remove(cd, delete_layout, COMPOSER_MEDIA_TYPE_VIDEO);
1040 msg_ui_composer_mms_insert_item_remove(cd, delete_layout, COMPOSER_MEDIA_TYPE_IMAGE);
1043 if (body_length == 0 && !page_data->is_sound_item)
1044 msg_ui_composer_mms_body_remove_page(cd, page_data->layout);
1051 msg_ui_composer_message_type_check_and_change(cd);
1054 /* in invalid recipient case, give focus to other widget to call verify_cb of recipient */
1055 if (msg_ui_composer_last_focus_is_recipient(cd)) {
1056 const char *recipient = msg_ui_composer_recipient_entry_text_get(cd->recipient);
1058 if (recipient && recipient[0] != '\0') {
1059 if (!msg_ui_composer_recipient_vaild_check(recipient))
1060 elm_object_focus_set(cd->back_btn, EINA_TRUE);
1067 void msg_ui_composer_body_body_layout_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
1071 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1072 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
1078 evas_object_geometry_get(obj, &x, &y, &w, &h);
1079 D_MSG("body layout height = %d", h);
1083 if (h >= COMPOSER_ENOUGH_TEXT_RENDERING_BODY_HEIGHT)
1084 msg_ui_composer_body_info_area_update(cd);
1086 edje_object_part_text_set(_EDJ(cd->ly_body), "text.char_count", "");
1091 void msg_ui_composer_body_body_layout_clicked_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
1094 D_MSG_RETM_IF(data == NULL, "data is NULL");
1095 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1097 msg_ui_composer_body_focus_set(cd, 0);
1099 evas_object_event_callback_del(cd->body_box, EVAS_CALLBACK_MOUSE_UP, msg_ui_composer_body_body_layout_clicked_cb);
1101 cd->is_default_body_size = false;