2 * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "msg-ui-composer-body.h"
19 #include "msg-ui-composer-body-page.h"
20 #include "msg-ui-composer-body-callback.h"
21 #include "msg-ui-composer-common.h"
22 #include "msg-ui-composer-popup.h"
23 #include "msg-ui-composer-message.h"
24 #include "msg-ui-composer-util.h"
25 #include "msg-ui-composer-recipient.h"
26 #include "msg-ui-composer-attachment.h"
27 #include "msg-ui-composer-external.h"
28 #include "msg-ui-content-utility.h"
29 #include "msg-file-util.h"
33 /*==================================================================================================
35 ==================================================================================================*/
37 static void msg_ui_composer_mms_attach_sound_remove(MSG_COMPOSER_BODY_PAGE_S *page_data, Evas_Object *remove_item);
38 static void msg_ui_composer_mms_attach_image_remove(MSG_COMPOSER_BODY_PAGE_S *page_data, Evas_Object *remove_item);
40 COMPOSER_RETURN_TYPE_E msg_ui_composer_body_read_sms_body(MSG_COMPOSER_VIEW_DATA_S *cd)
45 D_EMSG("composer view data is NULL ");
46 return COMPOSER_RETURN_FAIL;
49 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
50 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
52 Evas_Object *entry = NULL;
54 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(body_data->page_list, 0);
56 D_EMSG("page data is not exist");
57 return COMPOSER_RETURN_FAIL;
60 entry = page_data->entry;
62 D_EMSG("sms entry is NULL");
63 return COMPOSER_RETURN_FAIL;
66 char *entry_text = g_strdup(elm_entry_entry_get(entry));
67 char *sms_text = NULL;
71 convert_ps_to_br(entry_text);
72 sms_text = elm_entry_markup_to_utf8(entry_text);
73 if (sms_text == NULL) {
74 D_EMSG("sms_text is NULL");
76 return COMPOSER_RETURN_FAIL;
79 sms_length = strlen(sms_text);
82 msg_ui_composer_message_set_sms_body(sms_text);
84 D_WMSG("sms_length is %d", sms_length);
92 D_WMSG("entry_text is NULL");
96 return COMPOSER_RETURN_SUCCESS;
99 COMPOSER_RETURN_TYPE_E msg_ui_composer_body_read_mms_body(MSG_COMPOSER_VIEW_DATA_S *cd)
104 D_EMSG("composer data is NULL");
105 return COMPOSER_RETURN_NULL_POINTER;
108 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
109 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
110 Eina_List *page_list = body_data->page_list;
111 int page_count = body_data->page_count;
113 msg_ui_composer_message_set_page_count(page_count);
115 if (body_data->region_order == COMPOSER_REGION_ORDER_IMAGE_TOP)
116 msg_ui_composer_message_set_is_text_top(false);
118 msg_ui_composer_message_set_is_text_top(true);
121 for (i = 0; i < page_count; i++) {
122 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, i);
125 D_MSG("page duration = %d", page_data->page_duration);
127 msg_ui_composer_message_mms_set_page_duration(i, page_data->page_duration);
129 if (page_data->entry) {
130 D_MSG("read TEXT region data");
131 char *entry_text = g_strdup(elm_entry_entry_get(page_data->entry));
132 convert_ps_to_br(entry_text);
134 body_text = elm_entry_markup_to_utf8(entry_text);
136 if (body_text && strlen(body_text) > 0) {
137 msg_ui_composer_message_mms_set_text(body_text, i);
139 D_MSG("no text [%d]", i + 1);
147 D_MSG("no page entry @ page [%d]", i + 1);
150 if (page_data->is_image_item) {
151 if (page_data->isVideo) {
152 D_MSG("read video region data");
153 msg_ui_composer_message_mms_set_media(page_data->image_file_path, COMPOSER_MEDIA_TYPE_VIDEO, i);
155 D_MSG("read image region data");
156 msg_ui_composer_message_mms_set_media(page_data->image_file_path, COMPOSER_MEDIA_TYPE_IMAGE, i);
159 D_MSG("No [Image] region data");
162 if (page_data->is_sound_item) {
163 D_MSG("read SOUND region data");
165 msg_ui_composer_message_mms_set_media(page_data->sound_file_path, COMPOSER_MEDIA_TYPE_AUDIO, i);
167 D_MSG("No [Sound] region data");
173 return COMPOSER_RETURN_SUCCESS;
176 COMPOSER_RETURN_TYPE_E msg_ui_composer_update_char_count(MSG_COMPOSER_VIEW_DATA_S *cd, Evas_Object* entry)
179 D_EMSG("NULL parameter passed.");
180 return COMPOSER_RETURN_FAIL;
184 int char_encode = COMPOSER_CHAR_ENCODE_MAX;
186 char *body_text = elm_entry_markup_to_utf8(elm_entry_entry_get(entry));
188 if (body_text == NULL) {
189 D_EMSG("no text on there");
190 return COMPOSER_RETURN_FAIL;
193 /* update text count */
194 int text_len = strlen(body_text);
195 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
197 page_data = evas_object_data_get(entry, "page_data");
198 if (page_data == NULL) {
199 D_EMSG("page_data is NULL");
201 return COMPOSER_RETURN_FAIL;
205 COMPOSER_CHAR_ENCODE_E encode = COMPOSER_CHAR_ENCODE_GSM7;
207 page_data->text_info.char_count = 0;
209 switch (cd->encode_mode) {
210 case MSG_ENCODE_GSM7BIT:
211 case MSG_ENCODE_AUTO:
212 encode = COMPOSER_CHAR_ENCODE_GSM7;
214 case MSG_ENCODE_UCS2:
215 encode = COMPOSER_CHAR_ENCODE_UNICODE;
218 page_data->text_info.encode = encode;
220 if (cd->encode_mode == MSG_ENCODE_UCS2)
221 page_data->text_info.page_size = (COMPOSER_SMS_UNICODE_MAX_LEN * 2);
223 page_data->text_info.page_size = COMPOSER_SMS_GSM7_MAX_LEN;
225 int encode_mode = cd->encode_mode;
227 COMPOSER_TEXT_EXCEPTION_CHAR_E is_exception_char = COMPOSER_TEXT_HAS_NO_EXCEPTION_CHAR;
229 is_exception_char = msg_composer_check_exception_char_from_utf8(cd->encode_mode, (const unsigned char *)body_text);
231 /* When Emot Icons Entered. it should not be converted to MMS, So disable the check for Emot Icons*/
232 #ifdef _CONVERT_SMS_TO_MMS_IF_EMOTICON_PRESENT
233 if (is_exception_char == COMPOSER_TEXT_HAS_EMOTICON) {
234 /*there is emoticon, it should be changed to MMS;*/
235 cd->has_emoticon = true;
237 return COMPOSER_RETURN_SUCCESS;
240 if (cd->encode_mode == MSG_ENCODE_GSM7BIT) {
241 if (is_exception_char == COMPOSER_TEXT_HAS_KOREAN) {
242 D_MSG("there is korean,Encoding mode has to be changed");
243 encode_mode = MSG_ENCODE_AUTO;
244 cd->changed_encode_mode = MSG_ENCODE_AUTO;
247 char_encode = msg_ui_composer_body_entry_char_count(cd, (const char *)body_text, encode_mode, &char_count, &page_size);
249 page_data->text_info.encode = char_encode;
250 page_data->text_info.char_count = char_count;
251 page_data->text_info.page_size = page_size;
256 return COMPOSER_RETURN_SUCCESS;
259 int msg_ui_composer_body_entry_char_count(void *data, const char *text, int encode_type, int *char_count, int *page_size)
261 D_MSG_RETVM_IF(data == NULL, -1, "param is NULL");
262 D_MSG_RETVM_IF(text == NULL, -1, "param is NULL");
263 D_MSG_RETVM_IF(char_count == NULL, -1, "param is NULL");
264 D_MSG_RETVM_IF(page_size == NULL, -1, "param is NULL");
265 unsigned int text_size = 0;
266 unsigned int segment_size = 0;
267 int encoded_mode = 0;
268 int encode_mode_in = encode_type;
269 int ret = MSG_SUCCESS;
270 COMPOSER_CHAR_ENCODE_E encode = COMPOSER_CHAR_ENCODE_MAX;
272 ret = msg_util_calculate_text_length(text, encode_mode_in, &text_size, &segment_size, (msg_encode_type_t *)&encoded_mode);
273 D_MSG("encode_mode_in = %d, text_size = %d, segment_size = %d encoded_mode = %d", encode_mode_in, text_size, segment_size, encoded_mode);
275 if (ret != MSG_SUCCESS) {
276 D_EMSG("msg_calculate_text_length is failed ret = %d", ret);
278 switch (encode_mode_in) {
279 case MSG_ENCODE_GSM7BIT:
280 *char_count = (int)text_size;
281 *page_size = (int)segment_size;
283 if (encoded_mode == MSG_ENCODE_GSM7BIT_ABNORMAL)
284 encode = COMPOSER_CHAR_ENCODE_GSM7_ABNORMAL;
286 encode = COMPOSER_CHAR_ENCODE_GSM7;
290 case MSG_ENCODE_UCS2:
291 *char_count = (int)text_size;
292 *page_size = (int)segment_size;
293 encode = COMPOSER_CHAR_ENCODE_UNICODE;
297 case MSG_ENCODE_AUTO:
298 *char_count = (int)text_size;
299 *page_size = (int)segment_size;
301 if (encoded_mode == MSG_ENCODE_GSM7BIT)
302 encode = COMPOSER_CHAR_ENCODE_GSM7;
304 encode = COMPOSER_CHAR_ENCODE_UNICODE;
309 D_EMSG("unsupported encode mode %d", encode_mode_in);
316 Eina_Bool msg_ui_composer_body_keypad_show_idler(void *data)
318 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
319 D_MSG_RETVM_IF(cd == NULL, ECORE_CALLBACK_CANCEL, "composer data is NULL");
321 D_MSG("show_keypad_on_launch : %d", cd->show_keypad_on_launch);
323 if (cd->show_keypad_on_launch) {
324 msg_ui_composer_entry_input_panel_show(cd->last_focus_entry);
325 cd->show_keypad_on_launch = false;
328 int preferred_subscription = MSG_SIM_PREFERENCE_SIM_COUNT_LESS_THAN_TWO;
329 preferred_subscription = cd->voice_preferred_sim;
331 bool bMax_recipient_over = false;
333 int recipient_cnt = msg_ui_composer_common_recipient_count_get(cd);
334 if (recipient_cnt > cd->recipient_max_count) {
335 bMax_recipient_over = true;
338 if (cd->active_sims != 2) {
339 if (msg_ui_composer_common_is_send_possible(cd) && bMax_recipient_over == false) {
340 msg_ui_composer_send_btn_disabled_set(cd, EINA_FALSE);
341 msg_ui_composer_body_update_send_btn_icon(cd, false);
343 msg_ui_composer_send_btn_disabled_set(cd, EINA_TRUE);
344 msg_ui_composer_body_update_send_btn_icon(cd, true);
348 cd->keypad_show_idler = NULL;
351 return ECORE_CALLBACK_CANCEL;
354 void msg_ui_composer_body_info_area_update(MSG_COMPOSER_VIEW_DATA_S *cd)
356 D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
357 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
358 char count_str[DEF_BUF_LEN] = {0,};
360 if (cd->msg_type == COMPOSER_MSG_TYPE_SMS) {
361 MSG_COMPOSER_BODY_PAGE_S *page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(body_data->page_list, 0);
362 if (page_data == NULL) {
363 D_EMSG("page_data is NULL");
367 int char_encode = page_data->text_info.encode;
368 int char_count = page_data->text_info.char_count;
369 int page_size = page_data->text_info.page_size;
372 int remaining_count = 0;
374 if (char_encode == COMPOSER_CHAR_ENCODE_UNICODE ||
375 char_encode == COMPOSER_CHAR_ENCODE_GSM7 ||
376 char_encode == COMPOSER_CHAR_ENCODE_GSM7_ABNORMAL) {
377 if (char_count > page_size) {
378 cms_page = char_count / page_size;
380 if (!(char_count % page_size))
383 if ((cms_page+1) >= cd->cms_max_page)
384 max_count = page_size * cd->cms_max_page;
386 max_count = page_size * (cms_page+1);
389 max_count = page_size;
393 D_EMSG("Unknown character encode");
397 remaining_count = max_count - char_count;
399 if (char_encode == COMPOSER_CHAR_ENCODE_UNICODE)
400 remaining_count /= 2;
402 if (cd->cms_max_page == 1)
403 snprintf(count_str, sizeof(count_str), "%d", remaining_count);
405 snprintf(count_str, sizeof(count_str), "%d/%d", remaining_count, cms_page+1);
407 edje_object_part_text_set(_EDJ(cd->input_field_layout), "text.char_count", count_str); /*Add Char count*/
409 if (char_count == 0) {
410 msg_ui_composer_entry_set_guide_text(page_data->entry, "IDS_MSGF_BODY_TEXT_MESSAGES");
413 MSG_ECORE_IDLER_DEL(cd->keypad_show_idler);
414 cd->keypad_show_idler = ecore_idler_add(msg_ui_composer_body_keypad_show_idler, cd);
415 } else if (cd->msg_type == COMPOSER_MSG_TYPE_MMS) {
420 if (msg_ui_composer_get_message_size(cd, &msg_size) == COMPOSER_RETURN_SUCCESS) {
421 cd->mms_remained_size = cd->mms_max_size - (int)msg_size;
422 D_MSG("cd->mms_remained_byte = %d", cd->mms_remained_size);
423 if (cd->mms_remained_size < 0)
424 cd->mms_remained_size = 0;
426 if (msg_size < MSGC_1KB) {
427 snprintf(count_str, sizeof(count_str), "1%s", dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_MSGSIZE_KB"));
429 sizeKB = (int64)msg_size / MSGC_1KB;
430 sizeB = (int64)msg_size % MSGC_1KB;
433 if (sizeKB < cd->mms_max_size)
436 snprintf(count_str, sizeof(count_str), "%d%s", sizeKB, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_MSGSIZE_KB"));
438 edje_object_part_text_set(_EDJ(cd->input_field_layout), "text.char_count", count_str);
441 /* update body guide text */
443 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
444 page_data = eina_list_nth(body_data->page_list, 0);
446 page_count = eina_list_count(body_data->page_list);
447 if (page_count == 1) {
448 /* if there is inserted content */
449 if (page_data->is_image_item || page_data->is_sound_item) {
450 msg_ui_composer_entry_set_guide_text(page_data->entry, "");
452 msg_ui_composer_entry_set_guide_text(page_data->entry, "IDS_MSGF_BODY_TEXT_MESSAGES");
454 } else if (page_count > 1) {
455 msg_ui_composer_entry_set_guide_text(page_data->entry, "");
457 D_EMSG("Invalid page count = %d", page_count);
461 MSG_ECORE_IDLER_DEL(cd->keypad_show_idler);
462 cd->keypad_show_idler = ecore_idler_add(msg_ui_composer_body_keypad_show_idler, cd);
466 static Evas_Object *__msg_ui_composer_body_create_page_divider(MSG_COMPOSER_VIEW_DATA_S *cd, Evas_Object *parent)
469 D_MSG_RETVM_IF(cd == NULL, NULL, "composer data is NULL");
470 D_MSG_RETVM_IF(parent == NULL, NULL, "parent is NULL");
471 Evas_Object *layout = NULL;
472 Evas_Load_Error err = EVAS_LOAD_ERROR_NONE;
474 layout = elm_layout_add(parent);
476 D_EMSG("elm_layout_add error !!");
479 elm_layout_file_set(layout, msg_ui_composer_edj_get(cd), "composer/body/page_divider");
480 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
481 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
482 evas_object_show(layout);
484 Evas *evas = evas_object_evas_get(cd->main_window);
485 Evas_Object *img = evas_object_image_add(evas);
486 evas_object_image_file_set(img, MSGC_DOTTED_LINE_ICON, NULL);
488 err = evas_object_image_load_error_get(img);
489 if (err != EVAS_LOAD_ERROR_NONE)
490 D_EMSG("image loading is failed = %d", err);
492 evas_object_image_fill_set(img, 0, 0, 8, 1); /* this is image resource size (8*1) */
493 elm_object_part_content_set(layout, "swl.divider_line", img);
499 static Evas_Object *__msg_ui_composer_body_page_create(MSG_COMPOSER_VIEW_DATA_S *cd, Evas_Object *parent, MSG_COMPOSER_BODY_PAGE_S *page_data)
502 D_MSG_RETVM_IF(cd == NULL, NULL, "composer data is NULL");
503 D_MSG_RETVM_IF(parent == NULL, NULL, "parent is NULL");
504 D_MSG_RETVM_IF(page_data == NULL, NULL, "page_data is NULL");
505 Evas_Object *layout = NULL;
506 Evas_Object *page_box = NULL;
507 Evas_Object *entry = NULL;
508 Elm_Entry_Filter_Limit_Size limit_filter;
510 layout = elm_layout_add(parent);
512 D_EMSG("elm_layout_add error !!");
516 elm_layout_file_set(layout, msg_ui_composer_edj_get(cd), MSGC_EDJ_GRP_BODY_PAGE);
517 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
518 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
519 evas_object_show(layout);
521 page_box = elm_box_add(layout);
523 D_EMSG("elm_box_add error !!");
527 evas_object_size_hint_weight_set(page_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
528 evas_object_size_hint_align_set(page_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
529 evas_object_show(page_box);
531 entry = elm_entry_add(page_box);
533 D_EMSG("elm_box_add error !!");
537 D_MSG("### body entry : %p", entry);
539 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
540 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
542 elm_entry_markup_filter_append(entry, msg_composer_entry_filter_check_boundary, cd);
543 elm_entry_markup_filter_append(entry, msg_composer_entry_filter_addimage, cd);
544 /* add filter for removing markup */
545 elm_entry_markup_filter_append(entry, msg_composer_entry_filter_remove_markup, cd);
547 /* set entry max character count*/
548 #ifdef _MSG_FEATURE_MMS_DISABLE
549 int max_char_count = COMPOSER_SMS_GSM7_MAX_LEN;
551 if (cd->cms_max_page > 1)
552 max_char_count = COMPOSER_CMS_GSM7_MAX_LEN * cd->cms_max_page;
554 limit_filter.max_char_count = max_char_count;
556 limit_filter.max_char_count = COMPOSER_MMS_TEXT_MAX_CHAR;
559 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter);
561 #ifdef _MSG_FEATURE_MMS_DISABLE
562 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
565 elm_entry_prediction_allow_set(entry, EINA_TRUE);
566 elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_SENTENCE);
567 elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT);
570 if (cd->msg_type == COMPOSER_MSG_TYPE_SMS && cd->encode_mode == MSG_ENCODE_GSM7BIT) {
571 len = strlen("type=gsm_alphabet&action=enable_emoticons");
572 elm_entry_input_panel_imdata_set(entry, "type=gsm_alphabet&action=enable_emoticons", len);
574 len = strlen("action=enable_emoticons");
575 elm_entry_input_panel_imdata_set(entry, "action=enable_emoticons", len);
578 Ecore_IMF_Context *entry_ctx = elm_entry_imf_context_get(entry);
579 ecore_imf_context_input_panel_event_callback_add((Ecore_IMF_Context *)entry_ctx, ECORE_IMF_INPUT_PANEL_STATE_EVENT, msg_ui_composer_entry_imf_state_cb, cd);
581 /* We should not connect the resize callback on the keypad and try to resize the scroller in the callback.
582 * This is creating the flickering issue in bubble composer when candidate window comes and goes.
583 * ecore_imf_context_input_panel_event_callback_add((Ecore_IMF_Context *)entry_ctx, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, msg_ui_composer_entry_imf_resize_cb, cd); */
585 evas_object_show(entry);
586 evas_object_data_set(entry, "page_data", page_data);
588 evas_object_smart_callback_add(entry, "cursor,changed", msg_ui_composer_body_entry_cursor_changed_cb, cd);
589 evas_object_smart_callback_add(entry, "focused", msg_ui_composer_body_entry_focused_cb, cd);
590 evas_object_smart_callback_add(entry, "unfocused", msg_ui_composer_body_entry_unfocused_cb, cd);
591 evas_object_smart_callback_add(entry, "changed", msg_ui_composer_body_entry_changed_cb, cd);
592 evas_object_smart_callback_add(entry, "preedit,changed", msg_ui_composer_body_entry_changed_cb, cd);
593 evas_object_smart_callback_add(entry, "press", msg_ui_composer_body_entry_press_cb, cd);
594 evas_object_smart_callback_add(entry, "clicked", msg_ui_composer_body_entry_clicked_cb, cd);
595 #ifndef _MSG_FEATURE_MMS_DISABLE
596 evas_object_smart_callback_add(entry, "maxlength,reached", msg_ui_composer_body_entry_maxlength_reached_cb, cd);
597 evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN, msg_ui_composer_key_down_cb, cd);
598 evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_UP, msg_ui_composer_key_up_cb, cd);
600 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
602 elm_box_pack_end(page_box, entry);
603 elm_object_part_content_set(layout, "swl.page", page_box);
605 page_data->upper_layout = layout;
606 page_data->entry = entry;
607 page_data->page_box = page_box;
609 /* keypad is manually controlled, so disabling the auto control of keypad */
610 elm_entry_input_panel_enabled_set(page_data->entry, EINA_FALSE);
612 /* Check appcontrol launching scenario because share text scenario. (eg. browser > share)
613 * Fix do not add signature firstly, and append signature later after setting loaded share text to entry. */
614 if (!cd->isAppControl) {
615 /* Signature is added only to first page
616 * Incase of bubble view, whether the composer mode is draft or not, will
617 * be decided while loading the data so we neglect that case here */
618 if ((cd->body_data.page_count == 0) && (cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER)) {
619 if (true == msg_ui_composer_common_is_signature_enabled(cd, false)) {
620 D_MSG("cd->signature_string = %s", cd->signature_string);
621 char *utf8_string = NULL;
622 utf8_string = elm_entry_utf8_to_markup(cd->signature_string);
623 if (NULL != utf8_string) {
624 elm_entry_entry_set(entry, utf8_string);
631 if (cd->page_duration > COMPOSER_PAGE_DEFAULT_DURATION)
632 page_data->page_duration = cd->page_duration;
634 page_data->page_duration = COMPOSER_PAGE_DEFAULT_DURATION;
640 static Evas_Object *__msg_ui_composer_body_page_main_create(MSG_COMPOSER_VIEW_DATA_S *cd, Evas_Object *parent)
643 D_MSG_RETVM_IF(cd == NULL, NULL, "composer data is NULL");
644 D_MSG_RETVM_IF(parent == NULL, NULL, "parent is NULL");
645 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
646 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
647 Evas_Object *layout = NULL;
648 Evas_Object *new_page = NULL;
649 Evas_Object *page_main_box = NULL;
650 Evas_Object *page_divider = NULL;
652 page_data = (MSG_COMPOSER_BODY_PAGE_S *)calloc(1, sizeof(MSG_COMPOSER_BODY_PAGE_S));
654 D_EMSG("page_data is NULL!! calloc error");
658 layout = elm_layout_add(parent);
660 D_EMSG(" elm_layout_add error !!");
665 elm_layout_file_set(layout, msg_ui_composer_edj_get(cd), MSGC_EDJ_GRP_BODY_PAGE_MAIN);
667 edje_object_signal_emit(_EDJ(layout), "show.normal.mode", "*");
669 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
670 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
671 evas_object_show(layout);
673 page_main_box = elm_box_add(layout);
674 if (!page_main_box) {
675 D_EMSG("elm_box_add error !!");
680 evas_object_size_hint_weight_set(page_main_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
681 evas_object_size_hint_align_set(page_main_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
682 evas_object_show(page_main_box);
684 page_data->page_main_box = page_main_box;
685 page_data->layout = layout;
687 new_page = __msg_ui_composer_body_page_create(cd, page_main_box, page_data);
689 D_EMSG(" new_page error !!");
694 elm_box_pack_end(page_main_box, new_page);
696 if (body_data->page_count > 0) {
697 page_divider = __msg_ui_composer_body_create_page_divider(cd, page_main_box);
699 page_data->page_divider = page_divider;
700 elm_box_pack_start(page_main_box, page_divider);
704 elm_object_part_content_set(layout, "swl.page.main", page_main_box);
706 evas_object_data_set(_EDJ(layout), "private_data", cd);
707 edje_object_signal_callback_add(_EDJ(layout), "page_layout,clicked", "", msg_ui_composer_page_main_layout_clicked_cb, (void *)page_data);
709 body_data->page_list = eina_list_append(body_data->page_list, (void *)page_data);
710 body_data->page_count++;
713 page_count = eina_list_count(body_data->page_list);
715 if (page_count == 1) {
717 } else if (page_count == 2) {
719 char page_str[DEF_BUF_LEN_D + 1] = {0,};
720 snprintf(page_str, sizeof(page_str), "%d/%d", page_count - 1, page_count);
721 edje_object_part_text_set(_EDJ(page_divider), "text.page_info", page_str);
723 } else if (page_count > 2) {
724 msg_ui_composer_body_update_page_divider(cd);
731 COMPOSER_RETURN_TYPE_E msg_ui_composer_body_add_page(MSG_COMPOSER_VIEW_DATA_S *cd)
734 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "composer data is NULL");
735 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
736 Evas_Object *main_box = cd->pages_box;
737 Evas_Object *new_page = NULL;
739 if (body_data->page_count >= COMPOSER_MMS_MAX_PAGE) {
740 char buf[DEF_BUF_LEN] = { 0, };
741 char *text = dgettext(MESSAGE_PKGNAME, "IDS_MSG_TPOP_UNABLE_TO_ADD_ATTACHMENT_MAXIMUM_NUMBER_OF_ATTACHMENTS_HPD_REACHED");
742 snprintf(buf, sizeof(buf), text, COMPOSER_MMS_MAX_PAGE);
743 msg_ui_composer_create_text_btn_popup(cd, buf, 0, MESSAGE_PKGNAME, "IDS_MSG_BUTTON_OK_ABB");
744 return COMPOSER_RETURN_MAX_PAGE;
748 D_EMSG("composer body box is NULL");
749 return COMPOSER_RETURN_FAIL;
752 if (body_data->page_count == 0) {
753 cd->page_duration = COMPOSER_PAGE_DEFAULT_DURATION;
756 new_page = __msg_ui_composer_body_page_main_create(cd, main_box);
758 D_EMSG("page create error");
759 return COMPOSER_RETURN_FAIL;
762 elm_box_pack_end(main_box, new_page);
766 return COMPOSER_RETURN_SUCCESS;
769 COMPOSER_RETURN_TYPE_E msg_ui_composer_mms_insert_item_remove(MSG_COMPOSER_VIEW_DATA_S *cd, Evas_Object *remove_item)
772 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_NULL_POINTER, "cd is NULL");
773 D_MSG_RETVM_IF(remove_item == NULL, COMPOSER_RETURN_NULL_POINTER, "remove_item is NULL");
774 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
775 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
776 Eina_List *page_list = body_data->page_list;
777 int page_count = body_data->page_count;
780 for (i = 0; i < page_count; i++) {
781 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, i);
783 if (page_data->image_item == remove_item) {
784 D_MSG("remove image region media item !!");
785 page_data->is_image_item = false;
786 page_data->image_item = NULL;
787 page_data->isVideo = false;
788 page_data->is_image_focus = false;
789 /* remove temp file */
790 msg_composer_remove_file(page_data->image_file_path);
791 memset(page_data->image_file_path, 0x00, sizeof(page_data->image_file_path));
792 evas_object_del(remove_item);
794 } else if (page_data->sound_item == remove_item) {
795 D_MSG("remove sound media item !!");
796 page_data->is_sound_item = false;
797 page_data->sound_item = NULL;
798 page_data->is_sound_focus = false;
799 /* remove temp file */
800 msg_composer_remove_file(page_data->sound_file_path);
801 memset(page_data->sound_file_path, 0x00, sizeof(page_data->sound_file_path));
802 evas_object_del(remove_item);
806 D_WMSG("page_data is NULL");
809 if (cd->is_replace == false) {
810 msg_ui_composer_message_type_check_and_change(cd);
813 msg_ui_composer_body_info_area_update(cd);
816 return COMPOSER_RETURN_SUCCESS;
819 static void __msgc_body_remove_page(MSG_COMPOSER_VIEW_DATA_S *cd, MSG_COMPOSER_BODY_PAGE_S *page_data, Evas_Object *remove_page)
821 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
822 D_MSG_RETM_IF(page_data == NULL, "remove_page is NULL");
823 D_MSG_RETM_IF(remove_page == NULL, "remove_page is NULL");
824 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
826 elm_box_unpack(cd->pages_box, remove_page);
828 if (page_data->is_image_item)
829 msg_ui_composer_mms_insert_item_remove(cd, page_data->image_item);
831 if (page_data->is_sound_item)
832 msg_ui_composer_mms_insert_item_remove(cd, page_data->sound_item);
834 /* page count should be decresed before delete page layout */
835 body_data->page_list = eina_list_remove(body_data->page_list, page_data);
836 body_data->page_count--;
838 if (page_data->page_main_box) {
839 if (page_data->page_divider) {
840 evas_object_del(page_data->page_divider);
843 if (page_data->page_box) {
844 if (page_data->image_item) {
845 evas_object_del(page_data->image_item);
848 if (page_data->sound_item) {
849 evas_object_del(page_data->sound_item);
852 if (page_data->entry) {
853 evas_object_del(page_data->entry);
856 evas_object_del(page_data->page_box);
859 if (page_data->upper_layout) {
860 evas_object_del(page_data->upper_layout);
863 evas_object_del(page_data->page_main_box);
866 evas_object_del(page_data->layout);
870 COMPOSER_RETURN_TYPE_E msg_ui_composer_mms_body_remove_page(MSG_COMPOSER_VIEW_DATA_S *cd, Evas_Object *remove_page, bool clear_body)
873 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_NULL_POINTER, "cd is NULL");
874 D_MSG_RETVM_IF(remove_page == NULL, COMPOSER_RETURN_NULL_POINTER, "remove_page is NULL");
875 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
876 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
877 Eina_List *page_list = body_data->page_list;
878 int page_count = body_data->page_count;
881 if (page_count == 1) { /* in case of only one page exist */
882 if (clear_body == true) {
884 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, 0);
886 if (page_data->is_image_item)
887 msg_ui_composer_mms_insert_item_remove(cd, page_data->image_item);
889 if (page_data->is_sound_item)
890 msg_ui_composer_mms_insert_item_remove(cd, page_data->sound_item);
892 elm_entry_entry_set(page_data->entry, "");
894 D_MSG("focus change to the first page");
895 /* focus change to the first page */
896 cd->current_edit_entry = 0;
898 Evas_Object *body_entry = msg_ui_composer_last_body_entry_get(cd);
899 Evas_Object *last_focused_entry = msg_ui_composer_last_focused_entry_get(cd);
900 /* last focus is body entry*/
901 if (body_entry && (body_entry == last_focused_entry))
902 msg_ui_composer_last_focused_entry_set(cd, page_data->entry);
904 page_data->page_duration = COMPOSER_PAGE_DEFAULT_DURATION;
907 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, 0);
908 __msgc_body_remove_page(cd, page_data, remove_page);
910 cd->current_edit_entry = 0;
913 for (i = 0; i < page_count; i++) {
914 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(body_data->page_list, i);
916 if (page_data->layout == remove_page) {
917 D_MSG("Remove MMS (%d)th page", i + 1);
918 Evas_Object *body_entry = msg_ui_composer_last_body_entry_get(cd);
919 Evas_Object *last_focused_entry = msg_ui_composer_last_focused_entry_get(cd);
920 int current_edit_entry = cd->current_edit_entry;
921 D_MSG("current_edit_entry = %d", cd->current_edit_entry);
923 /* When focus is with body page entry, click on recipient entry once and again click
924 * on body entry and then remove the page. Here since body entry is getting deleted
925 * and last focused entry was recipient, EFL is giving the focus temporarily to recipient entry
926 * Due to which the contents of recipient entry is going off. This is default behaviour of
927 * EFL that when a entry is deleted focus should be given to some other object.
928 * So prevent this temporarily giving the focus to send button. */
929 elm_object_focus_set(cd->send_button, EINA_TRUE);
932 __msgc_body_remove_page(cd, page_data, remove_page);
935 /* remove next page's page_divider */
936 MSG_COMPOSER_BODY_PAGE_S *next_page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(body_data->page_list, i);
937 if (next_page_data && next_page_data->page_divider) {
938 D_MSG("remove next page's page_divider");
939 elm_box_unpack(next_page_data->page_main_box, next_page_data->page_divider);
940 evas_object_del(next_page_data->page_divider);
941 next_page_data->page_divider = NULL;
944 /* update page separator */
945 msg_ui_composer_body_update_page_divider(cd);
947 D_MSG("before update current entry");
948 /* deleted page is current edit page */
949 if (current_edit_entry == i) {
950 D_MSG("update focus index");
951 /* update body focus index*/
952 if (i == 0) { /* if it is first page, update focus index to next page */
953 cd->current_edit_entry = 0;
954 } else { /* if it is not first page, update focus index to previous page */
955 cd->current_edit_entry = i - 1;
958 /* change focus when last focused entry is a body entry */
959 if (body_entry && (body_entry == last_focused_entry)) {
960 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(body_data->page_list, cd->current_edit_entry);
962 msg_ui_composer_last_focused_entry_set(cd, page_data->entry);
964 msg_ui_composer_last_focus_load(cd);
965 elm_entry_cursor_end_set(msg_ui_composer_last_focused_entry_get(cd));
968 D_EMSG("page_data is NULL");
971 } else if (cd->current_edit_entry > i) {
972 D_MSG("update focus index");
973 /* update body focus index*/
974 cd->current_edit_entry--;
976 if (cd->current_edit_entry <= 0)
977 cd->current_edit_entry = 0;
987 return COMPOSER_RETURN_SUCCESS;
990 static Evas_Object *__msg_ui_composer_body_media_layout_create(MSG_COMPOSER_VIEW_DATA_S *cd, const char *file_path, Evas_Object *parent, COMPOSER_MEDIA_TYPE_E media_type, COMPOSER_MEDIA_ORIENT_E orient_mode)
993 D_MSG_RETVM_IF(cd == NULL, NULL, "cd is NULL");
994 D_MSG_RETVM_IF(parent == NULL, NULL, "parent is NULL");
995 Evas_Object *layout = NULL;
996 Evas_Object *thumb_icon = NULL;
997 const char *filename = NULL;
998 int image_icon_w = (int) ELM_SCALE_SIZE(MSGC_IMAGE_THUMB_LANDSCAPE_W);
999 int image_icon_h = (int) ELM_SCALE_SIZE(MSGC_IMAGE_THUMB_LANDSCAPE_H);
1000 int sound_icon_w = (int) ELM_SCALE_SIZE(MSGC_SOUND_THUMB_WIDTH);
1001 int sound_icon_h = (int) ELM_SCALE_SIZE(MSGC_SOUND_THUMB_HEIGHT);
1003 layout = elm_layout_add(parent);
1005 D_EMSG("layout create error !!!!");
1009 if (media_type == COMPOSER_MEDIA_TYPE_AUDIO)
1010 elm_layout_file_set(layout, msg_ui_composer_edj_get(cd), MSGC_EDJ_GRP_BODY_MEDIA_SOUND);
1012 elm_layout_file_set(layout, msg_ui_composer_edj_get(cd), MSGC_EDJ_GRP_BODY_MEDIA_IMAGE);
1014 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1015 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1016 evas_object_show(layout);
1018 thumb_icon = elm_icon_add(layout);
1020 if (media_type != COMPOSER_MEDIA_TYPE_AUDIO) {
1021 D_MSG("orient_mode = %d", orient_mode);
1022 if (orient_mode == COMPOSER_MEDIA_PORTRAIT_MODE) {
1023 image_icon_w = (int)ELM_SCALE_SIZE(MSGC_IMAGE_THUMB_PORTRAIT_W);
1024 image_icon_h = (int)ELM_SCALE_SIZE(MSGC_IMAGE_THUMB_PORTRAIT_H);
1025 } else if (orient_mode == COMPOSER_MEDIA_LANDSCAPE_MODE) {
1026 image_icon_w = (int)ELM_SCALE_SIZE(MSGC_IMAGE_THUMB_LANDSCAPE_W);
1027 image_icon_h = (int)ELM_SCALE_SIZE(MSGC_IMAGE_THUMB_LANDSCAPE_H);
1028 } else if (orient_mode == COMPOSER_MEDIA_EQUAL_MODE) {
1029 image_icon_w = (int)ELM_SCALE_SIZE(MSGC_IMAGE_THUMB_EQUAL_W_H);
1030 image_icon_h = (int)ELM_SCALE_SIZE(MSGC_IMAGE_THUMB_EQUAL_W_H);
1034 if (media_type == COMPOSER_MEDIA_TYPE_IMAGE) {
1035 elm_image_file_set(thumb_icon, file_path, NULL);
1036 evas_object_size_hint_min_set(thumb_icon, image_icon_w, image_icon_h);
1037 elm_image_aspect_fixed_set(thumb_icon, EINA_FALSE);
1038 } else if (media_type == COMPOSER_MEDIA_TYPE_VIDEO) {
1039 if (strcmp(file_path, MSGC_IMG_INSERT_ETC_ICON)) {
1040 elm_image_file_set(thumb_icon, file_path, NULL);
1042 elm_image_file_set(thumb_icon, MSG_IMAGES_EDJ, MSGC_IMG_INSERT_ETC_ICON);
1044 evas_object_size_hint_min_set(thumb_icon, image_icon_w, image_icon_h);
1045 elm_image_aspect_fixed_set(thumb_icon, EINA_FALSE);
1047 elm_image_file_set(thumb_icon, MSG_IMAGES_EDJ, MSGC_IMG_INSERT_ETC_ICON);
1048 evas_object_size_hint_min_set(thumb_icon, sound_icon_w, sound_icon_h);
1050 if (media_type != COMPOSER_MEDIA_TYPE_AUDIO) {
1051 evas_object_show(thumb_icon);
1052 elm_object_part_content_set(layout, "swl.thumbnail", thumb_icon);
1055 if (media_type == COMPOSER_MEDIA_TYPE_AUDIO) {
1056 filename = msg_file_file_get(file_path);
1058 edje_object_part_text_set(_EDJ(layout), "text.filename", filename);
1059 } else if (media_type == COMPOSER_MEDIA_TYPE_VIDEO) {
1060 if (strcmp(file_path, MSGC_IMG_INSERT_ETC_ICON))
1061 edje_object_signal_emit(_EDJ(layout), "elm,state,icon,show", "");
1068 static Evas_Object *__msg_ui_composer_body_create_insert_media(MSG_COMPOSER_VIEW_DATA_S *cd, const char *file_path, Evas_Object *parent, COMPOSER_MEDIA_TYPE_E media_type)
1071 D_MSG_RETVM_IF(cd == NULL, NULL, "cd is NULL");
1072 D_MSG_RETVM_IF(file_path == NULL, NULL, "file_path is NULL");
1073 D_MSG_RETVM_IF(parent == NULL, NULL, "parent is NULL");
1074 Evas_Object *layout = NULL;
1075 Evas_Object *transparent_button = NULL;
1076 char *inserted_file_path = (char *)file_path;
1077 char thumbnail_path[COMPOSER_FILEPATH_LEN_MAX + 1] = {0, };
1078 COMPOSER_MEDIA_ORIENT_E media_orient = COMPOSER_MEDIA_NONE;
1080 Evas_Load_Error err = EVAS_LOAD_ERROR_NONE;
1082 layout = elm_layout_add(parent);
1084 D_EMSG("layout create error !!!!");
1088 elm_layout_file_set(layout, msg_ui_composer_edj_get(cd), MSGC_EDJ_GRP_BODY_MEDIA_MAIN);
1089 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1090 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1091 evas_object_show(layout);
1093 if (media_type != COMPOSER_MEDIA_TYPE_AUDIO) {
1094 bool is_portrait = false;
1095 bool is_landscape = false ;
1099 if (media_type == COMPOSER_MEDIA_TYPE_VIDEO) {
1100 if (msg_composer_common_get_thumbnail(cd, file_path, thumbnail_path, COMPOSER_FILEPATH_LEN_MAX) == COMPOSER_RETURN_SUCCESS) {
1101 inserted_file_path = thumbnail_path;
1103 D_EMSG("getting thumbnail from video is failed");
1104 inserted_file_path = MSGC_IMG_INSERT_ETC_ICON;
1108 D_SEC_MSG("inserted_file_path = (%s)", inserted_file_path);
1110 if (media_type == COMPOSER_MEDIA_TYPE_IMAGE || media_type == COMPOSER_MEDIA_TYPE_VIDEO) {
1111 /*get image's content size*/
1112 Evas *evas = evas_object_evas_get(cd->main_window);
1113 Evas_Object *img = evas_object_image_add(evas);
1114 evas_object_image_load_orientation_set(img, EINA_TRUE);
1115 evas_object_image_file_set(img, inserted_file_path, NULL);
1117 err = evas_object_image_load_error_get(img);
1118 if (err != EVAS_LOAD_ERROR_NONE) {
1119 D_EMSG("image loading is failed = %d", err);
1122 evas_object_image_size_get(img, &content_w, &content_h);
1123 evas_object_del(img);
1124 D_SEC_MSG("image_width = %d, image_height = %d", content_w, content_h);
1127 if (content_w && content_h) {
1128 if (content_w < content_h) {
1130 } else if (content_w > content_h) {
1131 is_landscape = true;
1136 D_MSG("change to image portrait layout");
1137 media_orient = COMPOSER_MEDIA_PORTRAIT_MODE;
1138 edje_object_signal_emit(_EDJ(layout), "media.image.portrait", "*");
1139 } else if (is_landscape) {
1140 D_MSG("change to image landscape layout");
1141 media_orient = COMPOSER_MEDIA_LANDSCAPE_MODE;
1142 edje_object_signal_emit(_EDJ(layout), "media.image.landscape", "*");
1144 D_MSG("change to image equal layout");
1145 media_orient = COMPOSER_MEDIA_EQUAL_MODE;
1146 edje_object_signal_emit(_EDJ(layout), "media.image.equal", "*");
1149 Evas_Object *rect = evas_object_rectangle_add(evas_object_evas_get(layout));
1150 evas_object_size_hint_align_set(rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
1151 evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1152 evas_object_color_set(rect, 0, 0, 0, 0);
1153 evas_object_size_hint_min_set(rect, 0, ELM_SCALE_SIZE(MSGC_IMAGE_THUMB_LANDSCAPE_ORIGIN_H));
1154 evas_object_show(rect);
1156 elm_object_part_content_set(layout, "swl.rect", rect);
1159 /* create transparent focus button so that insert media can have a focus and tts highlight*/
1160 transparent_button = elm_button_add(layout);
1162 elm_object_style_set(transparent_button, "focus");
1163 evas_object_size_hint_weight_set(transparent_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1164 evas_object_size_hint_align_set(transparent_button, EVAS_HINT_FILL, EVAS_HINT_FILL);
1165 evas_object_show(transparent_button);
1167 elm_object_part_content_set(layout, "swl.content", transparent_button);
1169 /* create media layout */
1170 Evas_Object *media_layout = __msg_ui_composer_body_media_layout_create(cd, inserted_file_path, transparent_button, media_type, media_orient);
1172 /* create gesture_layout */
1173 Evas_Object *gl = elm_gesture_layer_add(parent);
1175 if (elm_gesture_layer_attach(gl, media_layout) == EINA_TRUE) {
1176 elm_gesture_layer_cb_set(gl, ELM_GESTURE_N_LONG_TAPS, ELM_GESTURE_STATE_START, msg_ui_composer_body_media_longpress_s_cb, layout);
1177 elm_gesture_layer_cb_set(gl, ELM_GESTURE_N_LONG_TAPS, ELM_GESTURE_STATE_MOVE, msg_ui_composer_body_media_longpress_m_cb, layout);
1179 D_EMSG("gesture_layer_attach is failed");
1180 evas_object_del(gl);
1184 D_EMSG("gesture layer is NULL");
1187 evas_object_smart_callback_add(transparent_button, "clicked", msg_ui_composer_body_media_btn_clicked_cb, layout);
1188 evas_object_smart_callback_add(transparent_button, "pressed", msg_ui_composer_body_media_btn_pressed_cb, layout);
1189 evas_object_smart_callback_add(transparent_button, "focused", msg_ui_composer_body_media_btn_focused_cb, layout);
1190 evas_object_smart_callback_add(transparent_button, "unfocused", msg_ui_composer_body_media_btn_unfocused_cb, layout);
1191 evas_object_smart_callback_add(transparent_button, "unpressed", msg_ui_composer_body_media_btn_unpressed_cb, layout);
1193 elm_object_part_content_set(transparent_button, "elm.swallow.content", media_layout);
1194 evas_object_data_set(layout, "priv_data", cd);
1199 COMPOSER_RETURN_TYPE_E msg_ui_composer_body_insert_media(MSG_COMPOSER_VIEW_DATA_S *cd, const char *file_path, COMPOSER_MEDIA_TYPE_E media_type)
1202 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "cd is NULL");
1203 D_MSG_RETVM_IF(file_path == NULL, COMPOSER_RETURN_FAIL, "file_path is NULL");
1204 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
1205 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
1206 Eina_List *page_list = body_data->page_list;
1207 int page_count = eina_list_count(page_list);
1208 bool is_new_page_needed = false;
1210 COMPOSER_RETURN_TYPE_E ret;
1212 if (strlen(file_path) == 0) {
1213 D_EMSG("empty file path");
1214 return COMPOSER_RETURN_FAIL;
1217 if (page_count < 1) {
1218 D_EMSG("mms page count error");
1219 return COMPOSER_RETURN_FAIL;
1222 if (page_count <= cd->current_edit_entry) {
1223 D_EMSG("mms page count error case page_count <= cd->current_edit_entry");
1224 return COMPOSER_RETURN_INVALID_PAGE;
1227 /* Check whether the selected file has some valid size or not */
1228 struct stat stat_buf;
1229 if (stat(file_path, &stat_buf) != 0) {
1230 return COMPOSER_RETURN_FAIL;
1233 if (stat_buf.st_size <= 0) {
1234 D_MSG("file size is invalid");
1235 return COMPOSER_RETURN_FAIL;
1238 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, cd->current_edit_entry);
1240 if (media_type == COMPOSER_MEDIA_TYPE_IMAGE) {
1241 if (page_data->is_image_item)
1242 is_new_page_needed = true;
1243 } else if (media_type == COMPOSER_MEDIA_TYPE_VIDEO) {
1244 if (page_data->is_image_item || page_data->is_sound_item)
1245 is_new_page_needed = true;
1246 } else if (media_type == COMPOSER_MEDIA_TYPE_AUDIO) {
1247 if (page_data->is_sound_item || (page_data->is_image_item && page_data->isVideo))
1248 is_new_page_needed = true;
1250 D_EMSG("invalid media type [%d]", media_type);
1251 return COMPOSER_RETURN_INVALID_MEDIA_TYPE;
1253 if (cd->is_replace == false) {
1254 if (is_new_page_needed) {
1255 ret = msg_ui_composer_body_add_page(cd);
1256 if (ret != COMPOSER_RETURN_SUCCESS) {
1257 D_EMSG("Fail of new page created");
1260 D_MSG("new page created");
1261 /* if new page added, current edit entry is changed to a new page's entry */
1262 cd->current_edit_entry = page_count;
1265 if (page_data->is_image_focus) {
1266 msg_ui_composer_mms_insert_item_remove(cd, page_data->image_item);
1267 } else if (page_data->is_sound_focus) {
1268 msg_ui_composer_mms_insert_item_remove(cd, page_data->sound_item);
1273 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, cd->current_edit_entry);
1274 if (page_data != NULL) {
1275 if (media_type == COMPOSER_MEDIA_TYPE_AUDIO) {
1276 page_data->is_sound_item = true;
1277 length = strlen(file_path);
1278 strncpy(page_data->sound_file_path, file_path, length);
1279 page_data->sound_file_path[length] = '\0';
1281 int media_duration = 0;
1282 msg_composer_common_get_media_duration(file_path, &media_duration);
1283 D_MSG("audio file duration [%d]", media_duration);
1285 if (media_duration % 1000)
1286 media_duration = media_duration / 1000 + 1;
1288 media_duration = media_duration / 1000;
1290 if (media_duration > page_data->page_duration)
1291 page_data->page_duration = media_duration;
1293 page_data->sound_item = __msg_ui_composer_body_create_insert_media(cd, page_data->sound_file_path, page_data->layout, media_type);
1295 if (page_data->sound_item) {
1296 elm_box_pack_end(page_data->page_box, page_data->sound_item);
1298 D_EMSG("creating insert item layout error");
1299 return COMPOSER_RETURN_FAIL;
1302 page_data->is_image_item = true;
1303 page_data->isVideo = media_type == COMPOSER_MEDIA_TYPE_VIDEO ? true : false;
1304 length = strlen(file_path);
1305 strncpy(page_data->image_file_path, file_path, length);
1306 page_data->image_file_path[length] = '\0';
1308 if (page_data->isVideo) {
1309 int media_duration = 0;
1310 msg_composer_common_get_media_duration(file_path, &media_duration);
1311 D_MSG("video file duration [%d]", media_duration);
1313 if (media_duration % 1000)
1314 media_duration = media_duration / 1000 + 1;
1316 media_duration = media_duration / 1000;
1318 if (media_duration > page_data->page_duration)
1319 page_data->page_duration = media_duration;
1322 page_data->image_item = __msg_ui_composer_body_create_insert_media(cd, page_data->image_file_path, page_data->layout, media_type);
1324 if (page_data->image_item) {
1325 D_MSG("cd->body_data.region_order = %d", cd->body_data.region_order);
1326 if (cd->body_data.region_order == COMPOSER_REGION_ORDER_IMAGE_TOP)
1327 elm_box_pack_start(page_data->page_box, page_data->image_item);
1329 elm_box_pack_after(page_data->page_box, page_data->image_item, page_data->entry);
1331 msg_composer_remove_file(page_data->image_file_path);
1332 memset(page_data->image_file_path, 0x00, sizeof(page_data->image_file_path));
1333 page_data->is_image_item = false;
1334 D_EMSG("creating insert item layout error");
1335 return COMPOSER_RETURN_FAIL;
1340 msg_ui_composer_send_btn_disabled_set(cd, EINA_FALSE);
1341 if (cd->is_replace == false) {
1342 msg_ui_composer_message_type_check_and_change(cd);
1344 msg_ui_composer_body_info_area_update(cd);
1346 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
1347 msg_ui_composer_change_body_layout_mode(cd, cd->rotate);
1349 D_MSG("cd->attach_index = %d", cd->attach_index);
1351 if (msg_ui_composer_recipient_check_showing_popup_condition(cd) == true) {
1352 int media_count = eina_list_count(cd->attachlist);
1353 /* show invalid popup when last content is added */
1354 if (media_count == cd->attach_index) {
1355 if (msg_ui_composer_recipient_addr_type_get(cd->recipient) == COMPOSER_RECP_ADDR_INVALID) {
1356 msg_common_create_noti_toast_popup("IDS_MSG_TPOP_UNABLE_TO_ADD_RECIPIENT_NUMBER_NOT_VALID");
1358 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
1362 /* change last focused entry to a page that is added media recently*/
1363 const char *recipient = NULL;
1365 if (cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER) {
1366 if (cd->recipient) {
1367 RECIPIENT_S *rd = cd->recipient;
1368 D_MSG_RETVM_IF(rd == NULL, COMPOSER_RETURN_FAIL, "rd is NULL");
1369 recipient = msg_ui_composer_recipient_entry_text_get(cd->recipient);
1370 status = rd->was_entry_empty;
1373 if (recipient && recipient[0] != '\0' && false == status) {
1374 msg_ui_composer_last_focused_entry_set(cd, cd->recipient->entry);
1376 msg_ui_composer_recipient_hide_mbe_and_update_entry(cd->recipient);
1378 if (page_data != NULL) {
1379 msg_ui_composer_last_focused_entry_set(cd, page_data->entry);
1384 return COMPOSER_RETURN_SUCCESS;
1387 int msg_ui_composer_get_inserted_item_size(MSG_COMPOSER_VIEW_DATA_S *cd)
1389 D_MSG_RETVM_IF(cd == NULL, MSG_UI_RET_ERR, "cd is NULL");
1390 int page_count = cd->body_data.page_count;
1391 Eina_List *page_list = cd->body_data.page_list;
1395 for (i = 0; i < page_count; i++) {
1396 MSG_COMPOSER_BODY_PAGE_S *page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, i);
1397 int image_file_size = 0;
1398 int sound_file_size = 0;
1399 int body_text_size = 0;
1400 char *body_text = NULL;
1402 if (page_data->is_image_item) {
1403 image_file_size = msg_composer_get_file_size(page_data->image_file_path);
1405 if (page_data->is_sound_item) {
1406 sound_file_size = msg_composer_get_file_size(page_data->sound_file_path);
1409 if (page_data->entry) {
1410 body_text = elm_entry_markup_to_utf8(elm_entry_entry_get(page_data->entry));
1412 body_text_size = strlen(body_text);
1417 total_size = total_size + image_file_size + sound_file_size + body_text_size;
1423 bool should_body_keypad_be_shown(MSG_COMPOSER_VIEW_DATA_S *cd, int nPage)
1425 bool show_keypad = false;
1427 if (cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER) {
1430 if ((cd->bubble_data && true == cd->bubble_data->reply_mode) ||
1431 ((cd->loaded_aul == false) && (cd->state == COMPOSER_STATE_TYPE_PAUSE))) {
1432 if (cd->isclosed == false) {
1440 void msg_ui_composer_body_apply_font_size(MSG_COMPOSER_VIEW_DATA_S *cd, const char *font_sytle)
1443 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
1444 D_MSG_RETM_IF(font_sytle == NULL, "font_sytle is NULL");
1445 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
1446 int page_count = body_data->page_count;
1447 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
1450 D_MSG_RETM_IF(body_data->page_list == NULL, "page_list is NULL");
1452 for (i = 0; i < page_count; i++) {
1453 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(body_data->page_list, i);
1454 if (page_data && page_data->entry) {
1455 elm_entry_text_style_user_push(page_data->entry, font_sytle);
1462 void msg_ui_composer_body_focus_set(MSG_COMPOSER_VIEW_DATA_S *cd, int nPage)
1465 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
1466 D_MSG_RETM_IF(nPage < 0, "nPage < 0");
1467 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
1468 D_MSG_RETM_IF(body_data->page_list == NULL, "page_list is NULL");
1470 RECIPIENT_S *rd = cd->recipient;
1472 MSG_COMPOSER_BODY_PAGE_S *page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(body_data->page_list, nPage);
1475 bool is_recipient_entry_activated = false;
1477 is_recipient_entry_activated = rd->is_entry_activated;
1478 elm_object_focus_set(page_data->entry, EINA_TRUE);
1480 D_MSG("Focus to Page[%d]", nPage);
1481 if (should_body_keypad_be_shown(cd, nPage)) {
1482 /*Even If internal mode is true check if reply mode is false or not . if false only then launch keypad , otherwise launch it in idler.
1483 Because when we launch bubble composer from quickpanel , internal mode will be true.
1485 if (cd->isMsgInternal || !cd->isAppControl) {
1486 if ((cd->bubble_data) && (cd->bubble_data->reply_mode == true)) {
1487 D_MSG("MEssage INtyernal MOde is :%d ", cd->isMsgInternal);
1488 cd->show_keypad_on_launch = true;
1490 msg_ui_composer_entry_input_panel_show(page_data->entry);
1493 if ((cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER) && (is_recipient_entry_activated == true)) {
1494 msg_ui_composer_entry_input_panel_show(page_data->entry);
1496 D_MSG("MEssage INtyernal MOde is :%d ", cd->isMsgInternal);
1497 cd->show_keypad_on_launch = true;
1502 /* Make reply mode false here mode false here */
1503 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1504 if (cd->bubble_data) {
1505 if ((cd->bubble_data->reply_mode) || ((cd->loaded_aul == false) && (cd->state == COMPOSER_STATE_TYPE_PAUSE))) {
1506 cd->bubble_data->reply_mode = false;
1511 if ((nPage == 0) && (true == msg_ui_composer_common_is_signature_enabled(cd, false))) {
1512 char *body_text = elm_entry_markup_to_utf8(elm_entry_entry_get(page_data->entry));
1514 char *signature_start = g_strrstr(body_text, cd->signature_string);
1516 if (signature_start) {
1517 if (!strcmp(signature_start, cd->signature_string)) {
1518 glong full_str_cnt = g_utf8_strlen(body_text, -1);
1519 glong signature_str_cnt = g_utf8_strlen(cd->signature_string, -1);
1521 elm_entry_cursor_pos_set(page_data->entry, (full_str_cnt - signature_str_cnt));
1522 D_MSG("cursor = %d", (full_str_cnt - signature_str_cnt));
1525 D_EMSG("signature_start is NULL");
1530 D_EMSG("body_text is NULL");
1533 elm_entry_cursor_end_set(page_data->entry);
1536 D_MSG("There is not exist Page[%d]", nPage);
1542 Evas_Object *msg_ui_composer_body_get_page_entry(MSG_COMPOSER_VIEW_DATA_S *cd, int nPage)
1545 D_MSG_RETVM_IF(cd == NULL, NULL, "cd is NULL");
1546 D_MSG_RETVM_IF(nPage < 0, NULL, "nPage < 0");
1547 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
1548 MSG_COMPOSER_BODY_PAGE_S *page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(body_data->page_list, nPage);
1551 return page_data->entry;
1556 MSG_COMPOSER_BODY_PAGE_S *msg_ui_composer_body_get_page_by_content(MSG_COMPOSER_VIEW_DATA_S *cd, Evas_Object *obj)
1559 D_MSG_RETVM_IF(cd == NULL, NULL, "cd is NULL");
1560 D_MSG_RETVM_IF(obj == NULL, NULL, "obj is NULL");
1561 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
1562 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
1563 Eina_List *page_list = body_data->page_list;
1566 D_EMSG("page_list is NULL");
1570 int page_count = eina_list_count(page_list);
1573 for (i = 0; i < page_count; i++) {
1574 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, i);
1577 D_EMSG("page data is NULL !!!");
1581 if (page_data->sound_item == obj) {
1583 } else if (page_data->image_item == obj) {
1585 } else if (page_data->entry == obj) {
1595 bool msg_ui_composer_body_get_focused_page_index(MSG_COMPOSER_VIEW_DATA_S *cd, int *page_index)
1598 D_MSG_RETVM_IF(cd == NULL, false, "cd is NULL");
1599 D_MSG_RETVM_IF(page_index == NULL, false, "page_index is NULL");
1600 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
1601 Eina_List *page_list = cd->body_data.page_list;
1604 if (page_list == NULL) {
1605 D_EMSG("page_list is NULL");
1609 Eina_List *l = NULL;
1610 EINA_LIST_FOREACH(page_list, l, page_data) {
1611 if (page_data == NULL) {
1612 D_EMSG("page_data is NULL");
1616 if (page_data->is_image_focus || page_data->is_sound_focus) {
1617 *page_index = index;
1621 if (evas_object_focus_get(page_data->entry)) {
1622 *page_index = index;
1633 bool msg_ui_composer_body_get_page_index(MSG_COMPOSER_VIEW_DATA_S *cd, MSG_COMPOSER_BODY_PAGE_S *page, int *page_index)
1636 D_MSG_RETVM_IF(cd == NULL, false, "cd is NULL");
1637 D_MSG_RETVM_IF(page_index == NULL, false, "page_index is NULL");
1638 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
1639 Eina_List *page_list = cd->body_data.page_list;
1643 Eina_List *l = NULL;
1644 EINA_LIST_FOREACH(page_list, l, page_data) {
1645 if (page_data == page) {
1646 *page_index = index;
1653 D_EMSG("page_list is NULL");
1659 MSG_COMPOSER_BODY_PAGE_S *msg_ui_composer_body_get_page_by_index(MSG_COMPOSER_VIEW_DATA_S *cd, int page_index)
1661 D_MSG_RETVM_IF(cd == NULL, NULL, "cd is NULL");
1663 if (page_index > cd->body_data.page_count) {
1664 D_EMSG("invalid page_index = %d, page_count = %d", page_index, cd->body_data.page_count);
1668 MSG_COMPOSER_BODY_PAGE_S *page_data = eina_list_nth(cd->body_data.page_list, page_index);
1676 bool msg_ui_composer_body_is_page_data(MSG_COMPOSER_BODY_PAGE_S *page)
1678 D_MSG_RETVM_IF(page == NULL, false, "page is NULL");
1680 if (page->is_image_item)
1683 if (page->is_sound_item)
1687 const char *str = elm_entry_entry_get(page->entry);
1688 if (str && strlen(str)) {
1696 void msg_ui_composer_body_page_image_layout_focus_hide(MSG_COMPOSER_BODY_PAGE_S *page_data)
1699 D_MSG_RETM_IF(page_data == NULL, "page_data is NULL");
1700 Evas_Object *btn = elm_object_part_content_get(page_data->image_item, "swl.content");
1701 Evas_Object *media_layout = elm_object_part_content_get(btn, "elm.swallow.content");
1704 edje_object_signal_emit(_EDJ(media_layout), "unfocused", "*");
1706 page_data->is_image_focus = false;
1711 void msg_ui_composer_body_page_image_layout_focus_show(MSG_COMPOSER_BODY_PAGE_S *page_data)
1714 D_MSG_RETM_IF(page_data == NULL, "page_data is NULL");
1715 Evas_Object *btn = elm_object_part_content_get(page_data->image_item, "swl.content");
1716 Evas_Object *media_layout = elm_object_part_content_get(btn, "elm.swallow.content");
1719 edje_object_signal_emit(_EDJ(media_layout), "focused", "*");
1721 page_data->is_image_focus = true;
1726 void msg_ui_composer_body_page_sound_layout_focus_hide(MSG_COMPOSER_BODY_PAGE_S *page_data)
1729 D_MSG_RETM_IF(page_data == NULL, "page_data is NULL");
1730 Evas_Object *btn = elm_object_part_content_get(page_data->sound_item, "swl.content");
1731 Evas_Object *media_layout = elm_object_part_content_get(btn, "elm.swallow.content");
1734 edje_object_signal_emit(_EDJ(media_layout), "unfocused", "*");
1736 page_data->is_sound_focus = false;
1741 void msg_ui_composer_body_page_sound_layout_focus_show(MSG_COMPOSER_BODY_PAGE_S *page_data)
1744 D_MSG_RETM_IF(page_data == NULL, "page_data is NULL");
1745 Evas_Object *btn = elm_object_part_content_get(page_data->sound_item, "swl.content");
1746 Evas_Object *media_layout = elm_object_part_content_get(btn, "elm.swallow.content");
1749 edje_object_signal_emit(_EDJ(media_layout), "focused", "*");
1751 page_data->is_sound_focus = true;
1756 void msg_ui_composer_body_media_layout_focus_hide(MSG_COMPOSER_VIEW_DATA_S *cd, COMPOSER_MEDIA_HIDE_TYPE_E type, int page_index)
1759 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
1760 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
1761 Eina_List *page_list = cd->body_data.page_list;
1764 D_EMSG("page_list is NULL");
1768 int page_count = eina_list_count(page_list);
1771 for (i = 0; i < page_count; i++) {
1772 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(page_list, i);
1774 D_EMSG("page data is NULL !!!");
1778 if ((type != COMPOSER_MEDIA_HIDE_EXCEPT_IMAGE) || (i != page_index)) {
1779 if (page_data->is_image_item && page_data->is_image_focus)
1780 msg_ui_composer_body_page_image_layout_focus_hide(page_data);
1783 if ((type != COMPOSER_MEDIA_HIDE_EXCEPT_SOUND) || (i != page_index)) {
1784 if (page_data->is_sound_item && page_data->is_sound_focus)
1785 msg_ui_composer_body_page_sound_layout_focus_hide(page_data);
1790 void msg_ui_composer_body_update_page_divider(MSG_COMPOSER_VIEW_DATA_S *cd)
1793 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
1794 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
1795 Eina_List *l = NULL;
1796 Eina_List *page_list = cd->body_data.page_list;
1797 char page_str[DEF_BUF_LEN_D + 1] = {0,};
1801 D_EMSG("page_list is NULL");
1805 int total_page_count = eina_list_count(page_list);
1807 EINA_LIST_FOREACH(page_list, l, page_data) {
1809 D_IMSG("page data is NULL !!!");
1813 if (index > 0) { /*skip first page*/
1814 if (page_data->page_divider) {
1815 memset(page_str, 0, sizeof(page_str));
1816 snprintf(page_str, sizeof(page_str), "%d/%d", index, total_page_count);
1817 edje_object_part_text_set(_EDJ(page_data->page_divider), "text.page_info", page_str);
1824 void msg_ui_composer_body_backspace_image_layout_focus_show(MSG_COMPOSER_VIEW_DATA_S *cd, MSG_COMPOSER_BODY_PAGE_S *page_data)
1827 D_MSG_RETM_IF(page_data == NULL, "page_data is NULL");
1828 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
1830 /* layout is not focusible widget. So, in order to disappear cursor of entry unset focus of entry.
1831 And, manually use input_panel_show to keep keypad showing becase entry unfocused cb makes hiding keypad. */
1833 page_data->is_image_focus = true; /* removed from msg_ui_composer_body_page_image_layout_focus_show and put here so that in entry unfocused callback it can be tracked */
1834 elm_object_focus_set(page_data->entry, EINA_FALSE);
1835 msg_ui_composer_entry_input_panel_show(page_data->entry);
1837 /* Bellow elm_object_focus_set() code should be called so that input_field_key_down_cb is called after moving focus to image layout */
1838 elm_object_focus_set(elm_layout_edje_get(page_data->image_item), EINA_TRUE);
1840 msg_ui_composer_body_page_image_layout_focus_show(page_data);
1845 void msg_ui_composer_body_backspace_sound_layout_focus_show(MSG_COMPOSER_VIEW_DATA_S *cd, MSG_COMPOSER_BODY_PAGE_S *page_data)
1848 D_MSG_RETM_IF(page_data == NULL, "page_data is NULL");
1849 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
1851 /* layout is not focusible widget. So, in order to disappear cursor of entry unset focus of entry.
1852 And, manually use input_panel_show to keep keypad showing becase entry unfocused cb makes hiding keypad. */
1853 elm_object_focus_set(page_data->entry, EINA_FALSE);
1854 msg_ui_composer_entry_input_panel_show(page_data->entry);
1856 /* Bellow elm_object_focus_set() code should be called so that input_field_key_down_cb is called after moving focus to image layout */
1857 elm_object_focus_set(elm_layout_edje_get(page_data->sound_item), EINA_TRUE);
1859 msg_ui_composer_body_page_sound_layout_focus_show(page_data);
1864 void msg_ui_composer_body_remove_cur_page(void *data, MSG_COMPOSER_BODY_PAGE_S *page_data, int page_index)
1867 D_MSG_RETM_IF(data == NULL, "data is NULL");
1868 D_MSG_RETM_IF(page_data == NULL, "page_data is NULL");
1869 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1870 Evas_Object *remove_layout = NULL;
1872 remove_layout = page_data->layout;
1874 if (page_data->sound_item && page_data->is_sound_focus) {
1875 D_MSG("remove sound layout");
1876 msg_ui_composer_mms_attach_sound_remove(page_data, page_data->sound_item);
1877 } else if (page_data->image_item && page_data->is_image_focus) {
1878 D_MSG("remove image region layout");
1879 msg_ui_composer_mms_attach_image_remove(page_data, page_data->image_item);
1882 if (elm_entry_is_empty(page_data->entry)) {
1883 D_MSG("remove page if entry is empty");
1884 msg_ui_composer_mms_body_remove_page(cd, remove_layout, true);
1887 msg_ui_composer_message_type_check_and_change(cd);
1888 msg_ui_composer_body_info_area_update(cd);
1890 if (page_index >= 1) { /* if there is a previous page, check it */
1891 int prev_page_index = page_index - 1;
1892 MSG_COMPOSER_BODY_PAGE_S *prev_page_data = msg_ui_composer_body_get_page_by_index(cd, prev_page_index);
1893 if (prev_page_data) {
1894 if (prev_page_data->is_sound_item) {
1895 /* move cursor to sound layout */
1896 msg_ui_composer_body_backspace_sound_layout_focus_show(cd, prev_page_data);
1898 if (cd->body_data.region_order == COMPOSER_REGION_ORDER_TEXT_TOP) {
1899 /* set focus to image layout */
1900 if (prev_page_data->is_image_item) {
1901 msg_ui_composer_body_backspace_image_layout_focus_show(cd, prev_page_data);
1903 msg_ui_composer_entry_input_panel_show(prev_page_data->entry);
1906 /* move cursor at end of text of prev page */
1907 /* entry focused_cb of prev_page_data is called at later. So, keypad is not shown on focused_cb */
1908 msg_ui_composer_entry_input_panel_show(prev_page_data->entry);
1917 static void msg_ui_composer_mms_attach_sound_remove(MSG_COMPOSER_BODY_PAGE_S *page_data, Evas_Object *remove_item)
1920 D_MSG("remove sound media item !!");
1921 page_data->is_sound_item = false;
1922 page_data->sound_item = NULL;
1923 page_data->is_sound_focus = false;
1924 /* remove temp file */
1925 msg_composer_remove_file(page_data->sound_file_path);
1926 page_data->sound_file_path[0] = '\0';
1927 evas_object_del(remove_item);
1931 static void msg_ui_composer_mms_attach_image_remove(MSG_COMPOSER_BODY_PAGE_S *page_data, Evas_Object *remove_item)
1934 D_MSG("remove image region media item !!");
1935 page_data->is_image_item = false;
1936 page_data->image_item = NULL;
1937 page_data->isVideo = false;
1938 page_data->is_image_focus = false;
1939 /* remove temp file */
1940 msg_composer_remove_file(page_data->image_file_path);
1941 page_data->image_file_path[0] = '\0';
1942 evas_object_del(remove_item);
1946 void msg_ui_composer_back_space_remove_page(void *data, MSG_COMPOSER_BODY_PAGE_S *page_data)
1949 D_MSG_RETM_IF(data == NULL, "data is NULL");
1950 D_MSG_RETM_IF(page_data == NULL, "page_data is NULL");
1951 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1953 /* check prev page's data and current pags' data
1954 if (prev has data & current no data), then remove current page
1955 else if (prev no data & current has data), then remove prev page
1956 else if (prev no data & current no data), then remove prev page <= no concept,
1959 if (msg_ui_composer_body_get_page_index(cd, page_data, &page_index)) {
1960 int prev_page_index = 0;
1961 bool is_prev_page_data = false;
1962 bool is_cur_page_data = false;
1964 D_MSG("page_index = %d", page_index)
1965 if (page_index > 0) {
1966 prev_page_index = page_index - 1;
1967 MSG_COMPOSER_BODY_PAGE_S *prev_page_data = msg_ui_composer_body_get_page_by_index(cd, prev_page_index);
1968 if (prev_page_data) {
1969 Evas_Object *remove_layout = NULL;
1970 is_prev_page_data = msg_ui_composer_body_is_page_data(prev_page_data);
1971 is_cur_page_data = msg_ui_composer_body_is_page_data(page_data);
1972 D_MSG("is_prev_page_data = %d, is_cur_page_data = %d", is_prev_page_data, is_cur_page_data);
1974 if (is_prev_page_data && !is_cur_page_data) {
1975 msg_ui_composer_body_remove_cur_page(cd, page_data, page_index);
1976 } else if (!is_prev_page_data && is_cur_page_data) {
1977 /* remove prev page and keep cursor position(start) */
1978 D_MSG("remove prev page");
1979 remove_layout = prev_page_data->layout;
1980 msg_ui_composer_mms_body_remove_page(cd, remove_layout, true);
1981 msg_ui_composer_message_type_check_and_change(cd);
1982 msg_ui_composer_body_info_area_update(cd);
1983 } else if (!is_prev_page_data && !is_cur_page_data) {
1984 /* remove prev page and keep cursor position(start) */
1985 D_MSG("remove prev page");
1986 remove_layout = prev_page_data->layout;
1987 msg_ui_composer_mms_body_remove_page(cd, remove_layout, true);
1988 msg_ui_composer_message_type_check_and_change(cd);
1989 msg_ui_composer_body_info_area_update(cd);
1991 D_MSG("Do nothing. Both pages have data");
1994 D_EMSG("prev_page_data is NULL");
1998 D_IMSG("msg_ui_composer_body_get_page_index is failed");