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.
18 #include <Elementary.h>
21 #include <mmf/mm_error.h>
22 #include <metadata_extractor.h>
23 #include <image_util.h>
25 #include "msg-ui-composer-common.h"
26 #include "msg-ui-composer-subject.h"
27 #include "msg-ui-composer-body.h"
28 #include "msg-ui-composer-body-callback.h"
29 #include "msg-ui-composer-attachment.h"
30 #include "msg-ui-composer-recipient.h"
31 #include "msg-ui-composer-popup.h"
32 #include "msg-ui-composer-data.h"
33 #include "msg-ui-composer-bubble.h"
34 #include "msg-ui-composer-main.h"
38 const composer_mime_type_t composer_mime_table[] = {
40 {"aac", "audio/aac", COMPOSER_MEDIA_TYPE_AUDIO},
41 {"amr", "audio/amr", COMPOSER_MEDIA_TYPE_AUDIO},
42 {"amr", "audio/x-amr", COMPOSER_MEDIA_TYPE_AUDIO},
43 {"amr", "audio/amr-wb", COMPOSER_MEDIA_TYPE_AUDIO},
44 {"imy", "audio/imelody", COMPOSER_MEDIA_TYPE_AUDIO},
45 {"imy", "audio/imy", COMPOSER_MEDIA_TYPE_AUDIO},
46 {"imy", "audio/iMelody", COMPOSER_MEDIA_TYPE_AUDIO},
47 {"imy", "audio/melody", COMPOSER_MEDIA_TYPE_AUDIO},
48 {"imy", "audio/x-iMelody", COMPOSER_MEDIA_TYPE_AUDIO},
49 {"imy", "text/iMelody", COMPOSER_MEDIA_TYPE_AUDIO},
50 {"imy", "text/x-iMelody", COMPOSER_MEDIA_TYPE_AUDIO},
51 {"imy", "text/x-imelody", COMPOSER_MEDIA_TYPE_AUDIO},
52 {"mid", "audio/mid", COMPOSER_MEDIA_TYPE_AUDIO},
53 {"mid", "audio/midi", COMPOSER_MEDIA_TYPE_AUDIO},
54 {"mid", "audio/x-mid", COMPOSER_MEDIA_TYPE_AUDIO},
55 {"mid", "audio/x-midi", COMPOSER_MEDIA_TYPE_AUDIO},
56 {"midi", "audio/mid", COMPOSER_MEDIA_TYPE_AUDIO},
57 {"mmf", "application/vnd.smaf", COMPOSER_MEDIA_TYPE_AUDIO},
58 {"mmf", "application/x-smaf", COMPOSER_MEDIA_TYPE_AUDIO},
59 {"mmf", "audio/mmf", COMPOSER_MEDIA_TYPE_AUDIO},
60 {"mmf", "audio/smaf", COMPOSER_MEDIA_TYPE_AUDIO},
61 {"mmf", "audio/x-mmf", COMPOSER_MEDIA_TYPE_AUDIO},
62 {"mmf", "audio/x-smaf", COMPOSER_MEDIA_TYPE_AUDIO},
63 {"mp3", "audio/mpeg", COMPOSER_MEDIA_TYPE_AUDIO},
64 {"mp3", "audio/mp3", COMPOSER_MEDIA_TYPE_AUDIO},
65 {"mp3", "audio/mpg3", COMPOSER_MEDIA_TYPE_AUDIO},
66 {"mp3", "audio/mpeg3", COMPOSER_MEDIA_TYPE_AUDIO},
67 {"mp3", "audio/mpg", COMPOSER_MEDIA_TYPE_AUDIO},
68 {"mp3", "audio/x-mp3", COMPOSER_MEDIA_TYPE_AUDIO},
69 {"mp3", "audio/x-mpeg", COMPOSER_MEDIA_TYPE_AUDIO},
70 {"mp3", "audio/x-mpeg3", COMPOSER_MEDIA_TYPE_AUDIO},
71 {"mp3", "audio/x-mpegaudio", COMPOSER_MEDIA_TYPE_AUDIO},
72 {"mp3", "audio/x-mpg", COMPOSER_MEDIA_TYPE_AUDIO},
73 {"mpg", "audio/x-mpeg", COMPOSER_MEDIA_TYPE_AUDIO},
74 {"m4a", "audio/m4a", COMPOSER_MEDIA_TYPE_AUDIO},
75 {"ra", "audio/x-pn-realaudio", COMPOSER_MEDIA_TYPE_AUDIO},
76 {"rm", "audio/vnd.rn-realaudio", COMPOSER_MEDIA_TYPE_AUDIO},
77 {"rm", "audio/x-pn-multirate-realaudio", COMPOSER_MEDIA_TYPE_AUDIO},
78 {"rm", "audio/x-pn-multirate-realaudio-live", COMPOSER_MEDIA_TYPE_AUDIO},
79 {"spm", "audio/sp-midi", COMPOSER_MEDIA_TYPE_AUDIO},
80 {"wav", "audio/wav", COMPOSER_MEDIA_TYPE_AUDIO},
81 {"wav", "audio/wave", COMPOSER_MEDIA_TYPE_AUDIO},
82 {"wav", "audio/x-wav", COMPOSER_MEDIA_TYPE_AUDIO},
83 {"wav", "audio/x-wave", COMPOSER_MEDIA_TYPE_AUDIO},
84 {"wma", "audio/wma", COMPOSER_MEDIA_TYPE_AUDIO},
85 {"wma", "audio/x-ms-wma", COMPOSER_MEDIA_TYPE_AUDIO},
86 {"xmf", "audio/mobile-xmf", COMPOSER_MEDIA_TYPE_AUDIO},
87 {"xmf", "audio/xmf", COMPOSER_MEDIA_TYPE_AUDIO},
88 {"xmf", "audio/x-xmf", COMPOSER_MEDIA_TYPE_AUDIO},
89 {"3gp", "audio/3gpp", COMPOSER_MEDIA_TYPE_AUDIO},
90 {"mp4", "audio/mp4", COMPOSER_MEDIA_TYPE_AUDIO},
91 {"mp4", "audio/MP4A-LATM", COMPOSER_MEDIA_TYPE_AUDIO},
92 {"mp4", "audio/mpeg4", COMPOSER_MEDIA_TYPE_AUDIO},
94 {"bmp", "image/bmp", COMPOSER_MEDIA_TYPE_IMAGE},
95 {"bmp", "image/x-bmp", COMPOSER_MEDIA_TYPE_IMAGE},
96 {"gif", "image/gif", COMPOSER_MEDIA_TYPE_IMAGE},
97 {"GIF", "image/gif", COMPOSER_MEDIA_TYPE_IMAGE},
98 {"gif", "image/vnd.tmo.my5-gif", COMPOSER_MEDIA_TYPE_IMAGE},
99 {"jpg", "image/jpg", COMPOSER_MEDIA_TYPE_IMAGE},
100 {"jpg", "image/jpeg", COMPOSER_MEDIA_TYPE_IMAGE},
101 {"jpg", "image/vnd.tmo.my5-jpg", COMPOSER_MEDIA_TYPE_IMAGE},
102 {"jpeg", "image/jpeg", COMPOSER_MEDIA_TYPE_IMAGE},
103 {"JPG", "image/jpeg", COMPOSER_MEDIA_TYPE_IMAGE},
104 {"jpg", "image/pjpeg", COMPOSER_MEDIA_TYPE_IMAGE},
105 {"jpe", "image/jpeg", COMPOSER_MEDIA_TYPE_IMAGE},
106 {"png", "image/png", COMPOSER_MEDIA_TYPE_IMAGE},
107 {"wbmp", "image/vnd.wap.wbmp", COMPOSER_MEDIA_TYPE_IMAGE},
108 {"wbmp", "image/wbmp", COMPOSER_MEDIA_TYPE_IMAGE},
109 {"swf", "application/x-shockwave-flash", COMPOSER_MEDIA_TYPE_UNKNOWN},
110 {"tif", "image/tiff", COMPOSER_MEDIA_TYPE_IMAGE},
111 {"tif", "image/tif", COMPOSER_MEDIA_TYPE_IMAGE},
112 {"pmd", "audio/pmd", COMPOSER_MEDIA_TYPE_IMAGE},
114 {"3gp", "video/3gpp", COMPOSER_MEDIA_TYPE_VIDEO},
115 {"3gp", "video/3gp", COMPOSER_MEDIA_TYPE_VIDEO},
116 {"3gp", "video/h263", COMPOSER_MEDIA_TYPE_VIDEO},
117 {"3gp", "video/mp4v-es", COMPOSER_MEDIA_TYPE_VIDEO},
118 {"asf", "audio/x-ms-asf", COMPOSER_MEDIA_TYPE_VIDEO},
119 {"asf", "video/x-ms-asf", COMPOSER_MEDIA_TYPE_VIDEO},
120 {"asx", "video/x-ms-asf", COMPOSER_MEDIA_TYPE_VIDEO},
121 {"avi", "video/avi", COMPOSER_MEDIA_TYPE_VIDEO},
122 {"mp2", "video/mpeg", COMPOSER_MEDIA_TYPE_VIDEO},
123 {"mp4", "video/mp4", COMPOSER_MEDIA_TYPE_VIDEO},
124 {"mp4", "video/mpeg4", COMPOSER_MEDIA_TYPE_VIDEO},
125 {"mp4", "video/x-mp4", COMPOSER_MEDIA_TYPE_VIDEO},
126 {"mp4", "video/x-pv-mp4", COMPOSER_MEDIA_TYPE_VIDEO},
127 {"mpg", "video/mpeg", COMPOSER_MEDIA_TYPE_VIDEO},
128 {"mpeg", "video/mpeg", COMPOSER_MEDIA_TYPE_VIDEO},
129 {"rm", "video/x-pn-multirate-realvideo", COMPOSER_MEDIA_TYPE_VIDEO},
130 {"rm", "video/vnd.rn-realmedia", COMPOSER_MEDIA_TYPE_VIDEO},
131 {"rm", "video/vnd.rn-realvideo", COMPOSER_MEDIA_TYPE_VIDEO},
132 {"rv", "video/x-pn-realvideo", COMPOSER_MEDIA_TYPE_VIDEO},
133 {"sdp", "application/sdp", COMPOSER_MEDIA_TYPE_VIDEO},
134 {"sdp", "video/sdp", COMPOSER_MEDIA_TYPE_VIDEO},
135 {"wmv", "video/x-ms-wmv", COMPOSER_MEDIA_TYPE_VIDEO},
137 {"txt", "text/plain", COMPOSER_MEDIA_TYPE_TEXT},
138 {"text", "text/plain", COMPOSER_MEDIA_TYPE_TEXT},
139 {"html", "text/html", COMPOSER_MEDIA_TYPE_TEXT},
140 {"htm", "text/html", COMPOSER_MEDIA_TYPE_TEXT},
141 {"wml", "text/vnd.wap.wml", COMPOSER_MEDIA_TYPE_TEXT},
142 {"xml", "text/xml", COMPOSER_MEDIA_TYPE_TEXT},
144 {"vbm", "text/x-vbookmark", COMPOSER_MEDIA_TYPE_UNKNOWN},
145 {"vcf", "text/x-vcard", COMPOSER_MEDIA_TYPE_UNKNOWN},
146 {"vcs", "text/x-vCalendar", COMPOSER_MEDIA_TYPE_UNKNOWN},
147 {"vnt", "text/x-vnote", COMPOSER_MEDIA_TYPE_UNKNOWN},
149 {"dcf", "application/vnd.oma.drm.content", COMPOSER_MEDIA_TYPE_DRM},
150 {"dm", "application/vnd.oma.drm.message", COMPOSER_MEDIA_TYPE_DRM},
151 {"odf", "application/vnd.oma.drm.dcf", COMPOSER_MEDIA_TYPE_DRM},
152 {"oro", "application/vnd.oma.drm.ro+xml", COMPOSER_MEDIA_TYPE_DRM},
153 {"ro", "application/vnd.oma.drm.rights+xml", COMPOSER_MEDIA_TYPE_DRM},
154 {"ro", "application/vnd.oma.drm.rights+wbxml", COMPOSER_MEDIA_TYPE_DRM},
156 {"doc", "application/msword", COMPOSER_MEDIA_TYPE_UNKNOWN},
157 {"doc", "applcation/vnd.ms-word", COMPOSER_MEDIA_TYPE_UNKNOWN},
158 {"xls", "application/vnd.ms-excel", COMPOSER_MEDIA_TYPE_UNKNOWN},
159 {"xls", "application/x-msexcel", COMPOSER_MEDIA_TYPE_UNKNOWN},
160 {"ppt", "application/vnd.ms-powerpoint", COMPOSER_MEDIA_TYPE_UNKNOWN},
161 {"ppt", "application/x-mspowerpoint", COMPOSER_MEDIA_TYPE_UNKNOWN},
162 {"pdf", "application/pdf", COMPOSER_MEDIA_TYPE_UNKNOWN},
164 {"rm ", "application/vnd.rn-realmedia", COMPOSER_MEDIA_TYPE_UNKNOWN},
165 {"smi", "application/smil", COMPOSER_MEDIA_TYPE_UNKNOWN},
166 {"smil", "application/smil", COMPOSER_MEDIA_TYPE_UNKNOWN},
167 {"xml", "application/vnd.oma.drm.roap-pdu+xml", COMPOSER_MEDIA_TYPE_UNKNOWN},
168 {"xml", "application/vnd.oma.drm.roap-trigger+xml", COMPOSER_MEDIA_TYPE_UNKNOWN},
169 {"xxx", "application/octet-stream", COMPOSER_MEDIA_TYPE_UNKNOWN},
172 char *msg_ui_composer_edj_get(MSG_COMPOSER_VIEW_DATA_S *cd)
174 return MSGC_UI_DEFAULT_EDJ;
177 Evas_Object *msg_ui_composer_load_edj(Evas_Object *parent, const char *edj_file, const char *group)
180 layout = elm_layout_add(parent);
182 elm_layout_file_set(layout, edj_file, group);
186 Evas_Object *msg_ui_composer_layout_create(Evas_Object *parent, bool indicator)
189 D_MSG_RETVM_IF(parent == NULL, NULL, "parent object == NULL");
193 layout = elm_layout_add(parent);
194 if (layout == NULL) {
195 D_EMSG("[ASSERT] elm_layout_add failed!!");
199 if (indicator == true)
200 elm_layout_theme_set(layout, "layout", "application", "default");
202 elm_layout_theme_set(layout, "layout", "application", "noindicator");
204 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
205 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
206 evas_object_show(layout);
211 Evas_Object *msg_ui_composer_bg_create(Evas_Object *parent)
213 D_MSG_RETVM_IF(parent == NULL, NULL, "parent object == NULL");
214 Evas_Object *bg = elm_bg_add(parent);
215 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
216 evas_object_show(bg);
220 int64 msg_composer_get_file_size(const char *path)
222 return ecore_file_size(path);
225 char *msg_composer_get_file_ext(const char *a_pszfile_name)
227 if (a_pszfile_name != NULL) {
228 int nlen = strlen(a_pszfile_name);
229 char *psztemp = (char *)a_pszfile_name + nlen;
233 if (*psztemp == '.') {
244 COMPOSER_MEDIA_TRACK_TYPE_E msg_composer_get_media_track_type(const char *a_pszfile_name)
247 D_MSG_RETVM_IF(a_pszfile_name == NULL, COMPOSER_MEDIA_TRACK_TYPE_NONE, "file path is null");
249 int ret = METADATA_EXTRACTOR_ERROR_NONE;
250 metadata_extractor_h metadata = NULL;
252 ret = metadata_extractor_create(&metadata);
253 if(ret != METADATA_EXTRACTOR_ERROR_NONE) {
254 D_EMSG("Fail metadata_extractor_create [%d]", ret);
255 return COMPOSER_MEDIA_TRACK_TYPE_NONE;
258 ret = metadata_extractor_set_path(metadata, a_pszfile_name);
259 if(ret != METADATA_EXTRACTOR_ERROR_NONE) {
260 D_EMSG("Fail metadata_extractor_set_path [%d]", ret);
261 metadata_extractor_destroy(metadata);
262 return COMPOSER_MEDIA_TRACK_TYPE_NONE;
265 /* check video first */
266 char *video_track_cnt = NULL;
267 metadata_extractor_get_metadata(metadata, METADATA_HAS_VIDEO, &video_track_cnt);
268 if (video_track_cnt) {
269 D_MSG("video_track_cnt = [%s]", video_track_cnt);
270 if (atoi(video_track_cnt) > 0) {
271 metadata_extractor_destroy(metadata);
272 return COMPOSER_MEDIA_TRACK_TYPE_VIDEO;
276 /* if curren meta_info has no video track, check audio again */
277 char *audio_track_cnt = NULL;
278 metadata_extractor_get_metadata(metadata, METADATA_HAS_AUDIO, &audio_track_cnt);
279 if (audio_track_cnt) {
280 D_MSG("audio_track_cnt = [%s]", audio_track_cnt);
281 if (atoi(audio_track_cnt) > 0) {
282 metadata_extractor_destroy(metadata);
283 return COMPOSER_MEDIA_TRACK_TYPE_AUDIO;
287 metadata_extractor_destroy(metadata);
289 return COMPOSER_MEDIA_TRACK_TYPE_NONE;
292 COMPOSER_MEDIA_TYPE_E msg_composer_get_media_type(const char *a_pszfile_path)
295 unsigned int nmimeidx = 0;
296 unsigned int nmime_max = 0;
297 COMPOSER_MEDIA_TRACK_TYPE_E track_type = COMPOSER_MEDIA_TRACK_TYPE_NONE;
299 if (a_pszfile_path == NULL)
300 return COMPOSER_MEDIA_TYPE_UNKNOWN;
302 pext = msg_composer_get_file_ext(a_pszfile_path);
303 nmime_max = (sizeof(composer_mime_table) / sizeof(composer_mime_type_t));
304 track_type = msg_composer_get_media_track_type(a_pszfile_path);
306 for (; nmimeidx < nmime_max; nmimeidx++) {
307 int nlen = strlen(composer_mime_table[nmimeidx].m_szextend);
309 if (strncasecmp(composer_mime_table[nmimeidx].m_szextend, pext, nlen) == 0) {
310 if (track_type == COMPOSER_MEDIA_TRACK_TYPE_VIDEO) {
311 if (strstr(composer_mime_table[nmimeidx].m_szmime_type, "video") != NULL)
312 return composer_mime_table[nmimeidx].m_ncontent_type;
313 } else if (track_type == COMPOSER_MEDIA_TRACK_TYPE_AUDIO) {
314 if (strstr(composer_mime_table[nmimeidx].m_szmime_type, "audio") != NULL)
315 return composer_mime_table[nmimeidx].m_ncontent_type;
317 return composer_mime_table[nmimeidx].m_ncontent_type;
322 return COMPOSER_MEDIA_TYPE_UNKNOWN;
325 COMPOSER_RETURN_TYPE_E msg_composer_common_get_media_duration(const char *file_path, int *duration)
329 metadata_extractor_h metadata_h = NULL;
330 int ret = METADATA_EXTRACTOR_ERROR_NONE;
333 if (!file_path || !duration) {
334 D_EMSG("file_path or duration is not exist");
335 return COMPOSER_RETURN_FAIL;
338 ret = metadata_extractor_create(&metadata_h);
339 if (ret != METADATA_EXTRACTOR_ERROR_NONE) {
340 D_EMSG("metadata_extractor_create is failed ret = %d", ret);
341 return COMPOSER_RETURN_FAIL;
344 ret = metadata_extractor_set_path(metadata_h, file_path);
345 if (ret != METADATA_EXTRACTOR_ERROR_NONE) {
346 D_EMSG("metadata_extractor_set_path is failed ret = %d", ret);
347 metadata_extractor_destroy(metadata_h);
348 return COMPOSER_RETURN_FAIL;
351 ret = metadata_extractor_get_metadata(metadata_h, METADATA_DURATION, &value);
352 if (ret != METADATA_EXTRACTOR_ERROR_NONE) {
353 D_EMSG("metadata_extractor_get_metadata is failed ret = %d", ret);
354 metadata_extractor_destroy(metadata_h);
355 return COMPOSER_RETURN_FAIL;
359 *duration = atoi(value);
363 D_MSG("file : %s, duration : %d", file_path, *duration);
365 metadata_extractor_destroy(metadata_h);
369 return COMPOSER_RETURN_SUCCESS;
372 COMPOSER_RETURN_TYPE_E msg_composer_common_get_thumbnail(MSG_COMPOSER_VIEW_DATA_S *cd, const char *src_file_path, char *thumb_file_path, int size_thumb_file_path)
375 COMPOSER_MEDIA_TYPE_E media_type;
377 char temp_img_file[COMPOSER_FILEPATH_LEN_MAX] = {0,};
378 char *filename_without_ext = NULL;
379 const char *filename = NULL;
381 if (!src_file_path || !thumb_file_path) {
382 D_EMSG("file path or thumbnail path is NULL");
383 return COMPOSER_RETURN_NULL_POINTER;
386 if (!ecore_file_exists(src_file_path)) {
387 D_EMSG("file path is not exist");
388 return COMPOSER_RETURN_NULL_POINTER;
391 media_type = msg_composer_get_media_type(src_file_path);
392 if (media_type == COMPOSER_MEDIA_TYPE_VIDEO) {
394 filename = ecore_file_file_get(src_file_path);
396 filename_without_ext = ecore_file_strip_ext(filename);
398 if (filename_without_ext) {
399 snprintf(temp_img_file, sizeof(temp_img_file)-1, "%s/temp_image_%s.jpg", cd->working_path, filename_without_ext);
400 g_free(filename_without_ext);
402 return COMPOSER_RETURN_FAIL;
406 return COMPOSER_RETURN_FAIL;
409 /* get image of video*/
410 ret = msg_composer_common_get_image_in_video(src_file_path, temp_img_file);
411 if (ret == COMPOSER_RETURN_SUCCESS) {
412 strncpy(thumb_file_path, temp_img_file, size_thumb_file_path);
415 D_EMSG("media type is not video type media_type = %d !!", media_type);
416 return COMPOSER_RETURN_FAIL;
420 return COMPOSER_RETURN_SUCCESS;
423 void msg_ui_composer_clear(MSG_COMPOSER_VIEW_DATA_S *cd)
426 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
430 msg_ui_composer_recipient_clear(cd->recipient);
434 msg_ui_composer_subject_clear(cd);
435 cd->isSubject = false;
438 if (cd->attach_data.attachment_Cnt > 0) {
439 msg_ui_composer_attachment_clear(cd);
442 msg_ui_composer_body_clear(cd);
447 static void __msg_ui_composer_change_to_sms(MSG_COMPOSER_VIEW_DATA_S *cd)
452 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] composer data is NULL");
456 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
457 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
459 /* reset region info */
460 body_data->region_order = COMPOSER_REGION_ORDER_UNDETERMINDED;
462 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(cd->body_data.page_list, 0);
464 char *body_text = elm_entry_markup_to_utf8(elm_entry_entry_get(page_data->entry));
466 msg_ui_composer_body_info_area_update(cd);
473 static void __msg_ui_composer_change_to_mms(MSG_COMPOSER_VIEW_DATA_S *cd)
478 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] composer data is NULL");
482 msg_ui_composer_body_info_area_update(cd);
486 COMPOSER_RETURN_TYPE_E msg_ui_composer_change_message_type(MSG_COMPOSER_VIEW_DATA_S *cd, COMPOSER_MSG_TYPE_E msg_type)
490 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] composer data is NULL");
491 return COMPOSER_RETURN_FAIL;
494 if (cd->msg_type == msg_type) {
495 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] it doesn't need to change message type");
496 return COMPOSER_RETURN_SUCCESS;
500 case COMPOSER_MSG_TYPE_SMS:
501 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_CHANGED_SMS);
503 cd->msg_type = COMPOSER_MSG_TYPE_SMS;
504 __msg_ui_composer_change_to_sms(cd);
506 case COMPOSER_MSG_TYPE_MMS:
507 if (cd->loading_draft == false)
508 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_CHANGED_MMS);
510 cd->loading_draft = false;
512 cd->msg_type = COMPOSER_MSG_TYPE_MMS;
513 __msg_ui_composer_change_to_mms(cd);
516 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] invalid message type");
517 return COMPOSER_RETURN_FAIL;
520 bool ret = msg_ui_composer_common_is_send_possible(cd);
521 msg_ui_composer_body_update_send_btn_icon(cd, !ret);
524 return COMPOSER_RETURN_SUCCESS;
527 COMPOSER_MSG_TYPE_E msg_ui_composer_check_message_type(MSG_COMPOSER_VIEW_DATA_S *cd)
532 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSSERT] composer data in NULL");
533 return COMPOSER_MSG_TYPE_INVALID;
537 return COMPOSER_MSG_TYPE_MMS;
539 if (cd->attach_data.attachment_Cnt > 0)
540 return COMPOSER_MSG_TYPE_MMS;
542 if (msg_ui_composer_body_is_mms(cd) == EINA_TRUE)
543 return COMPOSER_MSG_TYPE_MMS;
545 if (msg_ui_composer_recipient_is_mms(cd) == EINA_TRUE)
546 return COMPOSER_MSG_TYPE_MMS;
548 return COMPOSER_MSG_TYPE_SMS;
551 void msg_ui_composer_message_type_check_and_change(MSG_COMPOSER_VIEW_DATA_S *cd)
555 COMPOSER_MSG_TYPE_E checked_type;
557 checked_type = msg_ui_composer_check_message_type(cd);
559 if (cd->msg_type == COMPOSER_MSG_TYPE_SMS && checked_type == COMPOSER_MSG_TYPE_MMS) {
560 D_MSG("### Message Type Change from [SMS] to [MMS] ###");
561 msg_ui_composer_change_message_type(cd, COMPOSER_MSG_TYPE_MMS);
562 } else if (cd->msg_type == COMPOSER_MSG_TYPE_MMS && checked_type == COMPOSER_MSG_TYPE_SMS) {
563 D_MSG("### Message Type Change from [MMS] to [SMS] ###");
564 msg_ui_composer_change_message_type(cd, COMPOSER_MSG_TYPE_SMS);
566 D_MSG("Now msg type is [%d] & checked msg type is [%d](0: INVAILD, 1: SMS, 2: MMS)", cd->msg_type, checked_type);
572 Eina_Bool msg_ui_composer_last_focus_load(void *data)
575 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
576 if(!cd) return EINA_FALSE;
578 if (cd->last_focus_entry == NULL) {
579 D_MSG("NO ENTRY FOCUS");
583 elm_object_focus_set(cd->last_focus_entry, EINA_TRUE);
584 D_MSG("### Focused Entry Load = %p",cd->last_focus_entry);
589 Eina_Bool msg_ui_composer_last_body_page_focus_load(void *data)
593 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
595 MSG_COMPOSER_BODY_PAGE_S *last_page_data = eina_list_nth(cd->body_data.page_list, cd->body_data.page_count-1);
597 if (last_page_data && last_page_data->entry) {
598 elm_object_focus_set(last_page_data->entry, EINA_TRUE);
599 D_MSG("### Last body page entry focused = %p",last_page_data->entry);
600 msg_ui_composer_last_focused_entry_set(cd, last_page_data->entry);
602 D_MSG("Failed to get last body page entry");
610 void msg_ui_composer_last_focused_entry_set(void *data, Evas_Object *entry)
612 MSG_COMPOSER_VIEW_DATA_S *cd;
613 cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
614 cd->last_focus_entry = entry;
617 Evas_Object *msg_ui_composer_last_focused_entry_get(void *data)
619 MSG_COMPOSER_VIEW_DATA_S *cd;
620 cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
621 if (!cd) return NULL;
623 return cd->last_focus_entry;
626 Evas_Object *msg_ui_composer_last_body_entry_get(void *data)
630 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
632 MSG_COMPOSER_BODY_PAGE_S *page_data = eina_list_nth(cd->body_data.page_list, cd->current_edit_entry);
633 D_MSG("cd->current_edit_entry = %d", cd->current_edit_entry);
635 if (page_data && page_data->entry) {
636 return page_data->entry;
638 D_MSG("No Entry Saved");
646 void msg_ui_composer_set_body_keypad_layout(void *data, int mode)
649 D_MSG_RETM_IF(data == NULL, "data is NULL");
650 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
651 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
653 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(cd->body_data.page_list, 0);
655 if (page_data && page_data->entry)
656 elm_entry_input_panel_layout_set(page_data->entry, mode);
658 D_EMSG("entry is not found");
663 bool msg_ui_composer_last_focus_is_recipient(void *data)
666 D_MSG_RETVM_IF(data == NULL, false, "data is NULL");
668 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
669 RECIPIENT_S *recipient = cd->recipient;
670 Evas_Object *last_focus = msg_ui_composer_last_focused_entry_get(cd);
672 if (last_focus && recipient) {
673 if (last_focus == recipient->mbe) {
682 void bundle_send_to_result(void *data, char *key, char *val)
685 D_MSG("key = %s, val = %s", key, val);
687 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
688 service_h svc_handle;
689 if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
690 D_EMSG("service_create() is failed !!");
692 service_add_extra_data(svc_handle, key, val);
693 ug_send_result(cd->ug, svc_handle);
694 service_destroy(svc_handle);
699 bool msg_ui_composer_common_is_send_possible(MSG_COMPOSER_VIEW_DATA_S *cd)
704 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] composer data is NULL");
708 MSG_COMPOSER_BODY_S *body_data = &cd->body_data;
709 MSG_COMPOSER_BODY_PAGE_S *page_data = NULL;
711 if (cd->msg_type == COMPOSER_MSG_TYPE_MMS) {
713 char *subject = elm_entry_markup_to_utf8(elm_entry_entry_get(cd->sub_data.entry));
714 if (subject && strlen(subject) > 0) {
722 if (cd->attach_data.attachment_Cnt > 0) {
727 for (i = 0; i < cd->body_data.page_count; i++) {
728 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(body_data->page_list, i);
730 if (page_data->is_image_item)
733 if (page_data->is_sound_item)
736 char *body_text = elm_entry_markup_to_utf8(elm_entry_entry_get(page_data->entry));
738 if (strlen(body_text) > 0) {
745 } else if (cd->msg_type == COMPOSER_MSG_TYPE_SMS) {
746 page_data = (MSG_COMPOSER_BODY_PAGE_S *)eina_list_nth(body_data->page_list, 0);
748 char *body_text = elm_entry_markup_to_utf8(elm_entry_entry_get(page_data->entry));
750 if (strlen(body_text) > 0) {
758 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] invalid message type");
766 COMPOSER_RETURN_TYPE_E msg_composer_common_get_image_in_video(const char *video_file_path, char *image_file_path)
770 COMPOSER_MEDIA_TYPE_E media_type;
771 metadata_extractor_h metadata_h = NULL;
772 int ret = METADATA_EXTRACTOR_ERROR_NONE;
776 void *thumbnail = NULL;
779 media_type = msg_composer_get_media_type(video_file_path);
780 if (media_type != COMPOSER_MEDIA_TYPE_VIDEO) {
781 D_EMSG("It is not video file %s", video_file_path);
782 return COMPOSER_RETURN_FAIL;
785 ret = metadata_extractor_create(&metadata_h);
786 if (ret != METADATA_EXTRACTOR_ERROR_NONE) {
787 D_EMSG("metadata_extractor_create is failed ret = %d", ret);
788 return COMPOSER_RETURN_FAIL;
791 ret = metadata_extractor_set_path(metadata_h, video_file_path);
792 if (ret != METADATA_EXTRACTOR_ERROR_NONE) {
793 D_EMSG("metadata_extractor_set_path is failed ret = %d", ret);
794 metadata_extractor_destroy(metadata_h);
795 return COMPOSER_RETURN_FAIL;
798 ret = metadata_extractor_get_metadata(metadata_h, METADATA_VIDEO_WIDTH, &value);
799 if (ret != METADATA_EXTRACTOR_ERROR_NONE) {
800 D_EMSG("metadata_extractor_get_metadata is failed ret = %d", ret);
801 metadata_extractor_destroy(metadata_h);
802 return COMPOSER_RETURN_FAIL;
806 video_w = atoi(value);
811 ret = metadata_extractor_get_metadata(metadata_h, METADATA_VIDEO_HEIGHT, &value);
812 if (ret != METADATA_EXTRACTOR_ERROR_NONE) {
813 D_EMSG("metadata_extractor_get_metadata is failed ret = %d", ret);
814 metadata_extractor_destroy(metadata_h);
815 return COMPOSER_RETURN_FAIL;
819 video_h = atoi(value);
824 ret = metadata_extractor_get_frame(metadata_h, &thumbnail, &thumbsize);
825 if (ret != METADATA_EXTRACTOR_ERROR_NONE) {
826 D_EMSG("metadata_extractor_get_frame is failed ret = %d", ret);
827 metadata_extractor_destroy(metadata_h);
828 return COMPOSER_RETURN_FAIL;
832 ret = image_util_encode_jpeg((unsigned char *)thumbnail, video_w, video_h, IMAGE_UTIL_COLORSPACE_RGB888, 100, image_file_path);
836 if (ret != IMAGE_UTIL_ERROR_NONE) {
837 D_EMSG("image_util_encode_jpeg is failed ret = %d", ret);
838 metadata_extractor_destroy(metadata_h);
839 return COMPOSER_RETURN_FAIL;
843 metadata_extractor_destroy(metadata_h);
846 return COMPOSER_RETURN_SUCCESS;
849 COMPOSER_RETURN_TYPE_E msg_ui_composer_common_get_file(MSG_COMPOSER_VIEW_DATA_S *cd, const char *src_file_path, char *dst_file_path, int size_dst_file_path)
852 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "cd is NULL");
853 D_MSG_RETVM_IF(src_file_path == NULL, COMPOSER_RETURN_FAIL, "src_file_path is NULL");
854 D_MSG_RETVM_IF(dst_file_path == NULL, COMPOSER_RETURN_FAIL, "dst_file_path is NULL");
856 const char *filename = NULL;
859 char temp_file_path[COMPOSER_FILEPATH_LEN_MAX + 1] = {0,};
860 char file_name_without_ext[COMPOSER_FILENAME_LEN_MAX + 1] = {0};
862 if (ecore_file_exists(src_file_path) == EINA_FALSE) {
863 D_EMSG("file is not existed");
864 return COMPOSER_RETURN_FAIL;
867 filename = ecore_file_file_get(src_file_path);
870 strncpy(file_name_without_ext, filename, COMPOSER_FILENAME_LEN_MAX);
871 ext = msg_composer_get_file_ext(filename);
874 file_name_without_ext[strlen(file_name_without_ext) - strlen(ext) - 1] = '\0';
876 /*make new filename*/
878 memset(temp_file_path, 0x00, sizeof(temp_file_path));
880 snprintf(temp_file_path, sizeof(temp_file_path), "%s%s", cd->working_path, filename);
882 if (ext && strlen(ext) > 0)
883 snprintf(temp_file_path, sizeof(temp_file_path), "%s%s_%02d.%s", cd->working_path, file_name_without_ext, i, ext);
885 snprintf(temp_file_path, sizeof(temp_file_path), "%s%s_%02d", cd->working_path, file_name_without_ext, i);
890 if (i > COMPOSER_MMS_MAX_MEDIA_COUNT) {
891 D_EMSG("maximum count is reached = %d", i);
892 return COMPOSER_RETURN_FAIL;
894 } while (ecore_file_exists(temp_file_path));
897 if (ecore_file_cp(src_file_path, temp_file_path) == EINA_FALSE) {
898 D_MSG("temp_file_path = %s", temp_file_path);
899 return COMPOSER_RETURN_FAIL;
902 strncpy(dst_file_path, temp_file_path, size_dst_file_path);
903 D_MSG("copy file from %s to %s", src_file_path, dst_file_path);
905 D_EMSG("filename is NULL");
906 return COMPOSER_RETURN_FAIL;
910 return COMPOSER_RETURN_SUCCESS;
913 static char *__get_item_tag(char *text)
915 char *fulltext = NULL;
916 char *tagStart = NULL;
918 int tagStrLength = 0;
924 D_MSG("text(%p)[%d] = %s", text, strlen(text), text);
926 tagStart = strstr(fulltext, "<item");
928 tagEnd = strchr(tagStart, '>');
930 tagStrLength = tagEnd - tagStart + 1;
931 return strndup(tagStart, tagStrLength);
938 static char *__remove_item_tag(char *text)
940 char *fulltext = NULL;
941 char *tagStart = NULL;
943 char *braceStart = NULL;
944 char *braceEnd = NULL;
945 char *postStr = NULL;
948 int postStrLength = 0;
949 bool isitemTag = false;
954 char *textBuf = strdup(text);
957 D_EMSG("strdup is failed");
962 strLength = strlen(textBuf);
963 D_MSG("text length = %d, text = [%s]", strLength, textBuf);
965 while ((tagStart = strstr(fulltext, "<item"))) {
966 braceEnd = strchr(tagStart, '>');
968 braceStart = strstr(braceEnd, "</item>");
970 tagEnd = (braceStart + strlen("</item>") - 1);
972 D_EMSG("There is no close item tag");
976 D_EMSG("There is no close tag");
981 postStrLength = strLength - (tagEnd - fulltext + 1);
982 postStr = strndup(tagEnd + 1, postStrLength);
984 D_EMSG("strndup is failed");
989 strncpy(tagStart, postStr, postStrLength);
990 *(tagStart + postStrLength) = '\0';
991 D_MSG("after textBuf = [%s]", textBuf);
1007 static char *__get_tag_value(const char *tag_str, const char *tag_name)
1011 if (!tag_name || !tag_str)
1014 if ((tag = strstr(tag_str, tag_name))) {
1015 if (tag[strlen(tag_name)] == '_')
1017 char *value = strchr(tag, '=');
1022 } while (!isalnum(*value) && *value != '#');
1025 char *spArray[spCnt];
1026 spArray[0] = strchr(value, '>');
1027 spArray[1] = strchr(value, '\"');
1028 spArray[2] = strchr(value, '\'');
1029 spArray[3] = strchr(value, '\t');
1030 spArray[4] = strchr(value, '\n');
1031 char *valueEnd = strchr(value, '\0');
1035 if (!strcmp(tag_str, "item") && !strcmp(tag_name, "href"))
1038 for (i = start; i < spCnt; i++) {
1039 if (spArray[i] && spArray[i] < valueEnd) {
1040 valueEnd = spArray[i];
1044 int valueLength = valueEnd - value;
1045 return strndup(value, valueLength);
1052 void msg_composer_entry_filter_addimage(void *data, Evas_Object *entry, char **text)
1056 char *item_val = NULL;
1057 char *item_tag = NULL;
1058 char *filepath = NULL;
1059 char *realpath = NULL;
1061 MSG_COMPOSER_VIEW_DATA_S *cd = data;
1063 D_MSG_RETM_IF(cd == NULL, "Composer Data is Invalid");
1064 D_MSG_RETM_IF(entry == NULL,"Parameter Entry is Invalid");
1065 D_MSG_RETM_IF((!text || !(*text)),"Parameter Text is Invalid");
1067 /*get <item xxx> tag at insert text*/
1068 item_tag = __get_item_tag(*text);
1072 D_MSG("item_tag = %s", item_tag);
1074 /*get value of href in the item tag*/
1075 item_val = __get_tag_value(item_tag, "href");
1077 D_MSG("item_href_val = %s", item_val);
1078 filepath = strstr(item_val, "file:");
1080 realpath = filepath + 5;
1082 realpath = filepath;
1086 if (ecore_file_exists(realpath) == EINA_TRUE) {
1087 char * list_item_data = g_strdup(realpath);
1088 if (list_item_data) {
1089 cd->attachlist= eina_list_append(cd->attachlist, list_item_data);
1090 msg_ui_composer_body_items_add(data);
1092 D_EMSG("Fail to g_strdup");
1095 D_EMSG("File is NOT exist %s", realpath);
1098 D_EMSG("File Path is NULL");
1106 /* remove item tag */
1107 char *removed_text = __remove_item_tag(*text);
1111 *text = removed_text;
1121 msg_composer_entry_filter_remove_markup(void *data, Evas_Object *entry, char **text)
1124 D_MSG_RETM_IF(text == NULL || *text == NULL, "New Text is NULL");
1126 char *preedit_tag_start = NULL;
1127 char *preedit_tag_end = NULL;
1128 char *utf8_text = NULL;
1129 char *convert_text = NULL;
1130 D_MSG("text [%s]", *text);
1132 /* Check preeditting text and return if it exist*/
1133 preedit_tag_start = strstr(*text, "<preedit");
1134 preedit_tag_end = strstr(*text, "</preedit");
1136 if (preedit_tag_start && preedit_tag_end)
1139 /* convert from markup text to utf8 text from entry */
1140 utf8_text = elm_entry_markup_to_utf8(*text);
1143 /* If the string contains "Carrage return ('\n'), it should be changed "<br>" to show properly*/
1144 convert_text = elm_entry_utf8_to_markup(utf8_text);
1147 *text = strdup(convert_text);
1156 void msg_ui_composer_common_tickernoti(MSG_COMPOSER_VIEW_DATA_S *cd, COMPOSER_TICKERNOTI_TYPE_E tickertype)
1158 char popup_msg[DEF_BUF_LEN_L] = {0,};
1160 D_MSG_RETM_IF(cd == NULL, "Composer Data is Invalid");
1162 if (tickertype == COMPOSER_TICKERNOTI_COUNT_MAX) {
1163 const char *str = MSGC_STR_NOTI_RECIPIENT_MAX;
1164 snprintf(popup_msg, sizeof(popup_msg), str, COMPOSER_RECIPIENT_COUNT_MAX);
1165 } else if (tickertype == COMPOSER_TICKERNOTI_DUP_RECP) {
1166 snprintf(popup_msg, sizeof(popup_msg), MSGC_STR_NOTI_RECIPIENT_DUP);
1167 } else if (tickertype == COMPOSER_TICKERNOTI_INVALID_RECP) {
1168 snprintf(popup_msg, sizeof(popup_msg), MSGC_STR_NOTI_RECIPIENT_INVALID);
1169 } else if (tickertype == COMPOSER_TICKERNOTI_CHANGED_SMS) {
1170 snprintf(popup_msg, sizeof(popup_msg), MSGC_STR_NOTI_CHANGE_SMS);
1171 } else if (tickertype == COMPOSER_TICKERNOTI_CHANGED_MMS) {
1172 snprintf(popup_msg, sizeof(popup_msg), MSGC_STR_NOTI_CHANGE_MMS);
1173 } else if (tickertype == COMPOSER_TICKERNOTI_AUTO_SAVED) {
1174 snprintf(popup_msg, sizeof(popup_msg), _MSGSTR("IDS_MSGC_POP_MESSAGE_SAVED_AS_DRAFT"));
1175 } else if (tickertype == COMPOSER_TICKERNOTI_NO_RECIPIENT) {
1176 snprintf(popup_msg, sizeof(popup_msg), _MSGSTR("IDS_MSGF_POP_NO_RECIPIENTS_ADDED_ENTER_RECIPIENTS"));
1177 } else if (tickertype == COMPOSER_TICKERNOTI_MAXLENGHT_CHAR) {
1178 snprintf(popup_msg, sizeof(popup_msg), _MSGSTR("IDS_MSGF_POP_MAXIMUM_CHARACTERS"));
1183 msg_ui_composer_status_noti_show(popup_msg);
1186 int msg_ui_composer_get_keypad_height(Evas_Object *entry)
1188 D_MSG_RETVM_IF(entry == NULL, 0, "param is NULL");
1194 Ecore_IMF_Context *entry_ctx = elm_entry_imf_context_get(entry);
1195 ecore_imf_context_input_panel_geometry_get(entry_ctx, &keypad_x, &keypad_y, &keypad_w, &keypad_h);
1200 void msg_ui_composer_change_body_scroll_size(MSG_COMPOSER_VIEW_DATA_S *cd, int keypad_height)
1203 D_MSG_RETM_IF(cd == NULL, "Composer Data is Invalid");
1205 int total_height = 0;
1206 int scroll_height = 0;
1212 elm_scroller_region_get(cd->body_scroll, &scroll_x, &scroll_y, &scroll_w, &scroll_h);
1213 D_MSG("scroll region x=%d, y=%d, w=%d, h=%d", scroll_x, scroll_y, scroll_w, scroll_h);
1215 if (cd->rotate == COMPOSER_ROTATE_PORTRAIT || cd->rotate == COMPOSER_ROTATE_PORTRAIT_UPSIDEDOWN)
1216 total_height = (cd->window_h > cd->window_w) ? cd->window_h : cd->window_w;
1218 total_height = (cd->window_h > cd->window_w) ? cd->window_w : cd->window_h;
1220 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1221 RECIPIENT_S *rd = cd->recipient;
1222 D_MSG_RETM_IF(rd == NULL, "recipient Data is NULL");
1223 int recipient_h = 0;
1225 recipient_h = rd->recipient_h;
1227 D_MSG("recipient_h = %d", recipient_h);
1228 if (cd->rotate == COMPOSER_ROTATE_PORTRAIT || cd->rotate == COMPOSER_ROTATE_PORTRAIT_UPSIDEDOWN)
1229 scroll_height = (total_height - keypad_height - recipient_h - MSGC_NAVIBAR_TITLE_H - MSGC_BODY_PADDING - MSGC_INDICATOR_H);
1231 scroll_height = (total_height - keypad_height - recipient_h - MSGC_NAVIBAR_TITLE_H - MSGC_BODY_PADDING);
1233 D_MSG("scroll_height = %d", scroll_height);
1235 if (scroll_height <= COMPOSER_FRAME_BODY_LANDSCAPE_HEIGHT_MIN)
1236 scroll_height = COMPOSER_FRAME_BODY_LANDSCAPE_HEIGHT_MIN;
1238 if (scroll_h != scroll_height) {
1239 evas_object_size_hint_max_set(cd->body_scroll, 9999, scroll_height);
1240 elm_scroller_content_min_limit(cd->body_scroll, EINA_FALSE, EINA_TRUE);
1241 D_MSG("scroll size updated w = %d, h = %d", scroll_w, scroll_height);
1243 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1244 scroll_height = (total_height - keypad_height - MSGC_NAVIBAR_TITLE_H - MSGC_INDICATOR_H - MSGC_BODY_PADDING);
1245 D_MSG("scroll_height = %d", scroll_height);
1247 if (scroll_height <= COMPOSER_FRAME_BODY_LANDSCAPE_HEIGHT_MIN)
1248 scroll_height = COMPOSER_FRAME_BODY_LANDSCAPE_HEIGHT_MIN;
1250 if (scroll_h != scroll_height) {
1251 evas_object_size_hint_max_set(cd->body_scroll, 9999, scroll_height);
1252 elm_scroller_content_min_limit(cd->body_scroll, EINA_FALSE, EINA_TRUE);
1253 D_MSG("scroll size updated w = %d, h = %d", scroll_w, scroll_height);
1256 D_EMSG("Unknown Composer Mode");
1262 void msg_ui_composer_make_default_body_size(MSG_COMPOSER_VIEW_DATA_S *cd)
1265 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
1267 int scroll_height = COMPOSER_FRAME_BODY_LANDSCAPE_HEIGHT_MIN;
1269 cd->is_default_body_size = true;
1271 msg_ui_composer_contract_attach_list(cd);
1273 evas_object_size_hint_max_set(cd->body_scroll, 9999, scroll_height);
1274 elm_scroller_content_min_limit(cd->body_scroll, EINA_FALSE, EINA_TRUE);
1275 /* move scroll to top */
1276 elm_scroller_region_show(cd->body_scroll, 0, 0, 0, 0);
1278 evas_object_event_callback_add(cd->body_box, EVAS_CALLBACK_MOUSE_UP, msg_ui_composer_body_body_layout_clicked_cb, cd);
1283 void msg_ui_composer_entry_imf_resize_cb(void * data, Ecore_IMF_Context *ctx, int value)
1286 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1287 D_MSG_RETM_IF(cd == NULL, "Composer Data is Invalid");
1288 D_MSG_RETM_IF(ctx == NULL, "Ecore_IMF_Context is Invalid");
1294 ecore_imf_context_input_panel_geometry_get(ctx, &keypad_x, &keypad_y, &keypad_w, &keypad_h);
1295 D_MSG("keypad x = %d, y = %d, w = %d, h = %d", keypad_x, keypad_y, keypad_w, keypad_h);
1296 D_MSG("cd->make_default_body_size = %d", cd->make_default_body_size);
1298 if (cd->make_default_body_size) {
1299 if (!cd->is_keypad_show)
1300 cd->make_default_body_size = false;
1302 if (keypad_w != 0 && keypad_h != 0)
1303 msg_ui_composer_change_body_scroll_size(cd, keypad_h);
1309 void msg_ui_composer_entry_imf_state_cb(void * data, Ecore_IMF_Context *ctx, int value)
1313 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1314 D_MSG_RETM_IF(cd == NULL, "Composer Data is Invalid");
1315 D_MSG_RETM_IF(ctx == NULL, "Ecore_IMF_Context is Invalid");
1317 if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
1323 D_MSG("Imf status SHOW");
1325 cd->is_keypad_show = true;
1327 ecore_imf_context_input_panel_geometry_get(ctx, &keypad_x, &keypad_y, &keypad_w, &keypad_h);
1328 D_MSG("keypad x = %d, y = %d, w = %d, h = %d", keypad_x, keypad_y, keypad_w, keypad_h);
1330 msg_ui_composer_change_body_scroll_size(cd, keypad_h);
1331 } else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1332 D_MSG("Imf status HIDE");
1334 cd->is_keypad_show = false;
1336 D_MSG("cd->make_default_body_size = %d", cd->make_default_body_size);
1338 if (cd->make_default_body_size) {
1339 cd->make_default_body_size = false;
1340 msg_ui_composer_make_default_body_size(cd);
1342 msg_ui_composer_change_body_scroll_size(cd, 0);
1345 D_EMSG("imf status INVALID");
1351 int msg_ui_composer_get_font_size(int type)
1356 int converted_size = -1;
1358 if (type == COMPOSER_TYPE_BODY) {
1361 if (msg_common_get_font_size(&index) == FALSE) {
1362 D_EMSG("msg_common_get_font_size() is failed !!");
1365 D_MSG("selected font_size index = %d", index);
1368 font_size = msg_common_get_font_size_from_index(index);
1370 if (font_size == -1) {
1371 D_EMSG("msg_common_get_font_size_from_index() is failed !!");
1375 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
1376 } else if (type == COMPOSER_TYPE_SUBJECT) {
1377 int access_font_index = 0;
1379 /* get accessibility font index */
1380 if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &access_font_index) < 0) {
1381 D_EMSG("vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE) is failed !!");
1382 access_font_index = MSG_SYS_FONT_SIZE_INDEX_NORMAL; /* 1 */
1385 font_size = msg_common_get_font_size_from_index(access_font_index);
1386 if (font_size == -1) {
1387 D_EMSG("msg_common_get_font_size_from_index() is failed !!");
1391 converted_size = (MSGC_SUBJECT_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
1393 D_EMSG("Invalid type");
1397 return converted_size;
1400 void msg_ui_composer_apply_font_size(MSG_COMPOSER_VIEW_DATA_S *cd, bool update_subject)
1403 D_MSG_RETM_IF(cd == NULL, "Composer Data is Invalid");
1407 int converted_size = cd->font_size;
1409 if (msg_common_get_font_size(&index) == FALSE) {
1410 D_EMSG("msg_common_get_font_size() is failed !!");
1413 D_MSG("selected font_size index = %d", index);
1416 font_size = msg_common_get_font_size_from_index(index);
1418 if (font_size == -1) {
1419 D_EMSG("msg_common_get_font_size_from_index() is failed !!");
1423 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
1425 /* apply font size */
1426 char font_style_str[DEF_BUF_LEN_S + 1] = {0,};
1427 snprintf(font_style_str, sizeof(font_style_str), "DEFAULT='font_size=%d'", converted_size);
1428 D_MSG("font_style_str = (%s)", font_style_str);
1430 msg_ui_composer_recipient_apply_font_size(cd, font_style_str);
1431 msg_ui_composer_body_apply_font_size(cd, font_style_str);
1433 if (update_subject) {
1434 int access_font_index = 0;
1435 /* get accessibility font index */
1436 if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &access_font_index) < 0) {
1437 D_EMSG("vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE) is failed !!");
1438 access_font_index = MSG_SYS_FONT_SIZE_INDEX_NORMAL; /* 1 */
1441 font_size = msg_common_get_font_size_from_index(access_font_index);
1442 if (font_size == -1) {
1443 D_EMSG("msg_common_get_font_size_from_index() is failed !!");
1447 converted_size = (MSGC_SUBJECT_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
1449 /* apply font size */
1450 memset(font_style_str, 0, sizeof(font_style_str));
1451 snprintf(font_style_str, sizeof(font_style_str), "DEFAULT='font_size=%d'", converted_size);
1452 D_MSG("subject font_style_str = (%s)", font_style_str);
1454 msg_ui_composer_subject_apply_font_size(cd, font_style_str);