2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <tapi_common.h>
20 #include <TapiUtility.h>
23 #include "msg-ui-composer-main.h"
24 #include "msg-ui-composer-recipient.h"
25 #include "msg-ui-composer-popup.h"
26 #include "msg-ui-composer-predictsearch.h"
27 #include "msg-ui-composer-subject.h"
28 #include "msg-ui-composer-body.h"
29 #include "msg-ui-composer-pageduration.h"
30 #include "msg-ui-composer-message.h"
31 #include "msg-ui-composer-common.h"
32 #include "msg-ui-composer-external.h"
33 #include "msg-ui-composer-bubble.h"
34 #include "msg-ui-composer-main.h" /*for page duration, it should be removed if more option concept is changed*/
36 #include "msg-ui-common-utility.h"
38 #define COMPOSER_BUNDLE_ATTACH_TOKEN "\n"
39 #define COMPOSER_BUNDLE_RECP_TOKEN ","
41 /*==================================================================================================
42 * FUNCTION IMPLEMENTATIONS
43 *==================================================================================================*/
44 static COMPOSER_EDIT_STATE_E __msg_ui_composer_edit_check(MSG_COMPOSER_VIEW_DATA_S *cd)
47 D_MSG_RETVM_IF(cd == NULL, COMPOSER_EDIT_NONE, "Composer Data == NULL");
49 bool isvalid_address = false;
50 bool iscontent_edited = false;
52 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
53 int recipient_count = msg_ui_composer_recipient_count_get(cd->recipient);
54 if (recipient_count > 0) {
55 isvalid_address = true;
58 const char *entry_str = msg_ui_composer_recipient_entry_text_get(cd->recipient);
59 if (entry_str && strlen(entry_str)) {
60 if (msg_ui_composer_recipient_vaild_check(entry_str) == EINA_TRUE)
61 isvalid_address = true;
63 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
64 isvalid_address = true;
67 /* valid address & there is body content */
68 if (msg_ui_composer_common_is_send_possible(cd) == true)
69 iscontent_edited = true;
71 if (isvalid_address && iscontent_edited)
72 return COMPOSER_EDIT_RECIPIENT_AND_BODY;
73 else if (isvalid_address)
74 return COMPOSER_EDIT_RECIPIENT;
75 else if (iscontent_edited)
76 return COMPOSER_EDIT_BODY;
78 return COMPOSER_EDIT_NONE;
81 static void __msgc_vconf_changed_cb(keynode_t *key, void *data)
85 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
86 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
87 D_MSG_RETM_IF(key == NULL, "key is NULL");
91 int converted_size = 0;
92 char *key_name = NULL;
94 key_name = vconf_keynode_get_name(key);
96 D_EMSG("key_name is NULL");
100 if (!strcmp(key_name, VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE)) {
101 index = vconf_keynode_get_int(key);
102 font_size = msg_common_get_font_size_from_index(index);
103 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
105 cd->font_size = converted_size;
107 /* sync current font size as accessibility font index */
108 if (msg_common_set_font_size(index) == FALSE)
109 D_EMSG("msg_common_set_font_size(index = %d) is failed !!", index);
111 /* sync msg accessibility font size with accessibility font index */
112 if (msg_common_set_access_font_size(index) == FALSE)
113 D_EMSG("vconf_set_int(VCONFKEY_MSG_APP_ACCESS_FONT_SIZE) is failed !!, [%d]", index);
114 } else if (!strcmp(key_name, VCONFKEY_MSG_APP_FONT_SIZE)) {
115 index = vconf_keynode_get_int(key);
116 font_size = msg_common_get_font_size_from_index(index);
117 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
119 cd->font_size = converted_size;
121 D_EMSG("key did not match.");
124 D_MSG("font size = %d", font_size);
125 D_MSG("converted font size = %d", converted_size);
130 static void __msgc_init_font_size(MSG_COMPOSER_VIEW_DATA_S *cd)
133 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
136 int access_font_index = 0;
137 int msg_access_font_index = 0;
139 int converted_size = 0;
141 /* get msg accessibility font index */
142 if (msg_common_get_access_font_size(&msg_access_font_index) == FALSE) {
143 D_EMSG("msg_common_get_access_font_size is failed !!");
144 msg_access_font_index = MSG_APP_FONT_SIZE_INDEX_NORMAL; /* 1 */
147 /* get accessibility font index */
148 if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &access_font_index) < 0) {
149 D_EMSG("vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE) is failed !!");
150 access_font_index = MSG_SYS_FONT_SIZE_INDEX_NORMAL; /* 1 */
153 if (msg_common_get_font_size(&index) == FALSE) {
154 D_EMSG("msg_common_get_font_size() is failed");
155 cd->font_size = MSGC_BODY_FONT_SIZE;
158 D_MSG("selected font_size index = %d", index);
161 D_MSG("VCONFKEY_MSG_APP_ACCESS_FONT_SIZE = %d", msg_access_font_index);
162 D_MSG("VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE = %d", access_font_index);
164 if (msg_access_font_index != access_font_index) {
165 font_size = msg_common_get_font_size_from_index(access_font_index);
167 /* sync current font size as accessibility font index */
168 if (msg_common_set_font_size(access_font_index) == FALSE)
169 D_EMSG("msg_common_set_font_size(index = %d) is failed !!", access_font_index);
171 /* sync msg accessibility font size with accessibility font index */
172 if (msg_common_set_access_font_size(access_font_index) == FALSE)
173 D_EMSG("vconf_set_int(VCONFKEY_MSG_APP_ACCESS_FONT_SIZE) is failed !!, [%d]", access_font_index);
175 font_size = msg_common_get_font_size_from_index(index);
178 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
180 cd->font_size = converted_size;
181 D_MSG("font size = %d, converted_size = %d", font_size, converted_size);
186 static void __msgc_parse_recipient_list(MSG_COMPOSER_VIEW_DATA_S *cd, const char *address)
189 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
190 D_MSG_RETM_IF(address == NULL, "address is NULL");
192 bool bMaxCount = false;
193 bool bInvalidNum = false;
196 Eina_List *recipient_list = make_tokenize_list(address, ",");
198 if (recipient_list) {
201 EINA_LIST_FOREACH(recipient_list, l, recipient) {
203 D_MSG("TO = %s", recipient);
204 if (msg_ui_composer_recipient_count_get(cd->recipient) >= COMPOSER_RECIPIENT_COUNT_MAX) {
210 if (msg_ui_composer_recipient_duplicate_check(cd->recipient, recipient) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
216 if (msg_ui_composer_recipient_vaild_check(recipient) == EINA_FALSE) {
219 msg_ui_composer_recipient_append(cd->recipient, recipient, 0);
226 D_MSG("bMaxCount = %d, bInvalidNum = %d, bDup = %d", bMaxCount, bInvalidNum, bDup);
228 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
229 } else if (bInvalidNum) {
230 msg_ui_composer_status_btn_popup_show(cd, MSGC_STR_NOTI_RECIPIENT_INVALID, 0, MSGC_STR_BUTTON_OK);
232 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_DUP_RECP);
239 static void __msgc_ui_parse_mmsto_uri(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, const char *uri)
242 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
243 D_MSG_RETM_IF(svc_handle == NULL, "svc_handle is NULL");
244 D_MSG_RETM_IF(uri == NULL, "uri is NULL");
246 char *content = NULL;
247 char *recipient = NULL;
248 char *body_text = NULL;
249 char *subject = NULL;
250 char *attachment = NULL;
252 char *scheme = g_strdup(uri);
255 strtok_r(scheme, ":", &content);
258 if (g_ascii_isdigit(content[0]) || (content[0] == '+' && g_ascii_isdigit(content[1]))) {
259 recipient = strtok_r(NULL, "?", &content);
260 cc = strtok_r(NULL, "&", &content);
262 strtok_r(NULL, "=", &cc);
264 D_MSG("RECIPIENT = [%s]", recipient);
266 __msgc_parse_recipient_list(cd, (const char *)recipient);
271 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient) {
272 __msgc_parse_recipient_list(cd, (const char *)recipient);
276 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text)
277 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
279 if ((service_get_extra_data(svc_handle, SERVICE_DATA_SUBJECT, &subject) == SERVICE_ERROR_NONE) && subject)
280 msg_ui_composer_subject_set_loaded_data(cd, (const char *)subject);
282 if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, &attachment) == SERVICE_ERROR_NONE) && attachment) {
283 cd->attachlist = make_tokenize_list((const char *)attachment, COMPOSER_BUNDLE_ATTACH_TOKEN);
285 msg_ui_composer_body_items_add(cd);
291 static void __msgc_ui_parse_file_uri(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, const char *uri)
294 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
295 D_MSG_RETM_IF(uri == NULL, "uri is NULL");
297 char *content = NULL;
298 char attachment[DEF_IMG_PATH_LEN + 1] = {0, };
301 char *scheme = g_strdup(uri);
304 strtok_r(scheme, ":", &content);
305 D_MSG("content = [%s]", content);
308 len = strlen(content) - 2;
310 D_EMSG("len is less than 0 !!");
315 /* Remove '//' from content string */
316 for (i = 0; i < len; i++) {
317 attachment[i] = content[i+2];
320 if (attachment[0] != '\0') {
321 D_MSG("APPSVC ATTACHMENT = [%s]", attachment);
322 cd->attachlist = make_tokenize_list((const char *)attachment, COMPOSER_BUNDLE_ATTACH_TOKEN);
324 msg_ui_composer_body_items_add(cd);
329 D_EMSG("scheme is NULL!!");
335 static void __msg_ui_parse_sms_uri(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, const char *uri)
338 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
339 D_MSG_RETM_IF(svc_handle == NULL, "svc_handle is NULL");
340 D_MSG_RETM_IF(uri == NULL, "uri is NULL");
342 char *content = NULL;
343 char *recipient = NULL;
344 char *body_text = NULL;
345 char *scheme = g_strdup(uri);
348 strtok_r(scheme, ":", &content);
351 if (g_ascii_isdigit(content[0]) || (content[0] == '+' && g_ascii_isdigit(content[1]))) {
352 recipient = strtok_r(NULL, "?", &content);
353 D_MSG("RECIPIENT = [%s]", recipient);
356 __msgc_parse_recipient_list(cd, (const char *)recipient);
361 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient)
362 __msgc_parse_recipient_list(cd, (const char *)recipient);
365 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text)
366 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
371 static void __msgc_get_service_app_svc_op(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, char *operation)
374 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
375 D_MSG_RETM_IF(svc_handle == NULL, "svc_handle is NULL");
376 D_MSG_RETM_IF(operation == NULL, "operation is NULL");
379 char *recipient = NULL;
380 char *body_text = NULL;
381 char *attachment = NULL;
382 char *subject = NULL;
384 if (g_strcmp0(operation, SERVICE_OPERATION_SEND) == 0) {
385 if (service_get_uri(svc_handle, &uri) == SERVICE_ERROR_NONE)
386 D_MSG("URI = [%s]", uri);
389 if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_MMSTO_URI)) { /* MMS URI : mmsto */
390 __msgc_ui_parse_mmsto_uri(cd, svc_handle, (const char *)uri);
391 } else if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_FILE_URI)) { /* URI : file */
392 __msgc_ui_parse_file_uri(cd, svc_handle, (const char *)uri);
393 } else if (g_str_has_prefix(uri, "/")) {
394 cd->attachlist = make_tokenize_list((const char *)uri, COMPOSER_BUNDLE_ATTACH_TOKEN);
396 msg_ui_composer_body_items_add(cd);
398 D_EMSG("Not supported URI type");
402 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient)
403 __msgc_parse_recipient_list(cd, (const char *)recipient);
405 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text)
406 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
408 if ((service_get_extra_data(svc_handle, SERVICE_DATA_SUBJECT, &subject) == SERVICE_ERROR_NONE) && subject)
409 msg_ui_composer_subject_set_loaded_data(cd, (const char *)subject);
411 if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, &attachment) == SERVICE_ERROR_NONE) && attachment) {
412 cd->attachlist = make_tokenize_list((const char *)attachment, COMPOSER_BUNDLE_ATTACH_TOKEN);
414 msg_ui_composer_body_items_add(cd);
417 } else if (g_strcmp0(operation, SERVICE_OPERATION_SEND_TEXT) == 0) {
418 if (service_get_uri(svc_handle, &uri) == SERVICE_ERROR_NONE)
419 D_MSG("URI = [%s]", uri);
422 if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_SMS_URI)) { /* SMS URI : sms */
423 __msg_ui_parse_sms_uri(cd, svc_handle, (const char *)uri);
425 D_EMSG("Not supported mime type");
429 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient)
430 __msgc_parse_recipient_list(cd, (const char *)recipient);
432 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text)
433 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
436 D_EMSG("Invalid operation type !!");
442 /* function definitions*/
443 static void __msg_ui_composer_bundle_data_process(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
446 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
447 D_MSG_RETM_IF(svc_handle == NULL, "Bundle Data is NULL");
449 char *bundle_txt = NULL;
451 if (cd->isAppControl) { /* composer launching from appcontrol */
452 char *operation = NULL;
454 service_get_operation(svc_handle, &operation);
455 __msgc_get_service_app_svc_op(cd, svc_handle, operation);
457 if (cd->composer_mode == MSG_COMPOSER_MODE_EDIT || cd->composer_mode == MSG_COMPOSER_MODE_FORWARD) {
458 if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_MSG_ID, &bundle_txt) == SERVICE_ERROR_NONE) && bundle_txt) {
459 bool set_recipient = false;
460 int msg_id = atoi(bundle_txt);
462 if (cd->composer_mode == MSG_COMPOSER_MODE_EDIT) {
464 set_recipient = true;
467 msg_ui_composer_message_init();
468 msg_ui_composer_message_load_message(cd->msg_handle, msg_id);
469 if (msg_ui_composer_message_set_loaded_data(cd, set_recipient) != COMPOSER_RETURN_CREATION_WARINING_MODE_FAIL)
470 msg_ui_composer_message_destroy();
473 D_EMSG("there is no msgid");
476 if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_TO, &bundle_txt) == SERVICE_ERROR_NONE) && bundle_txt) {
477 __msgc_parse_recipient_list(cd, bundle_txt);
479 if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_NUMBER_INDEX, &bundle_txt)== SERVICE_ERROR_NONE) && bundle_txt) {
480 char *recipient = NULL;
485 char *copy_string = MSG_STRDUP(bundle_txt);
488 recipient = strtok_r(copy_string, "/", &save_p);
490 index = strtok_r(NULL, "/", &save_p);
492 D_MSG("NUMBER_INDEX = %s[%s]", recipient, index);
498 if (msg_ui_composer_recipient_count_get(cd->recipient) >= COMPOSER_RECIPIENT_COUNT_MAX) {
499 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
501 if (msg_ui_composer_recipient_duplicate_check(cd->recipient, recipient) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
502 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_DUP_RECP);
504 if (msg_ui_composer_recipient_vaild_check(recipient) == EINA_FALSE) {
505 msg_ui_composer_status_btn_popup_show(cd, MSGC_STR_NOTI_RECIPIENT_INVALID, 0, MSGC_STR_BUTTON_OK);
507 msg_ui_composer_recipient_append(cd->recipient, recipient, idx);
518 if (SERVICE_ERROR_NONE == service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_SUBJECT, &bundle_txt))
519 msg_ui_composer_subject_set_loaded_data(cd, bundle_txt);
521 if (SERVICE_ERROR_NONE == service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_BODY, &bundle_txt))
522 msg_ui_composer_body_set_loaded_text(cd, bundle_txt, 0);
524 if (SERVICE_ERROR_NONE == service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, &bundle_txt)) {
525 cd->attachlist = make_tokenize_list(bundle_txt, COMPOSER_BUNDLE_ATTACH_TOKEN);
527 msg_ui_composer_body_items_add(cd);
535 static void __msg_ui_composer_sent_status_cb(msg_handle_t Handle, msg_struct_t pStatus, void *pUserParam)
543 static void __end_popup_ok_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
546 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
547 D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
549 MSGC_EVAS_OBJECT_DEL(cd->popup_end);
551 ug_destroy_me(cd->ug);
554 static void __end_popup_cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
557 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
558 D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
560 MSGC_EVAS_OBJECT_DEL(cd->popup_end);
562 cd->isclosed = false;
564 msg_ui_composer_last_focus_load(cd);
568 static void __msg_ui_composer_end_popup(MSG_COMPOSER_VIEW_DATA_S *cd)
572 MSGC_EVAS_OBJECT_DEL(cd->popup_end);
574 Evas_Object *popup = msg_ui_composer_status_popup_show(cd->main_window, cd, MSGC_STR_POP_DISCARD_Q, 0);
575 Evas_Object *btn1 = elm_button_add(popup);
576 elm_object_style_set(btn1, "popup_button/default");
577 elm_object_text_set(btn1, MSGC_STR_BUTTON_OK);
578 elm_object_part_content_set(popup, "button1", btn1);
579 evas_object_smart_callback_add(btn1, "clicked", __end_popup_ok_btn_clicked_cb, cd);
580 Evas_Object *btn2 = elm_button_add(popup);
581 elm_object_style_set(btn2, "popup_button/default");
582 elm_object_text_set(btn2, MSGC_STR_BUTTON_CANCEL);
583 elm_object_part_content_set(popup, "button2", btn2);
584 evas_object_smart_callback_add(btn2, "clicked", __end_popup_cancel_btn_clicked_cb, cd);
585 elm_object_focus_allow_set(popup, EINA_TRUE);
586 elm_object_focus_set(popup, EINA_TRUE);
587 evas_object_show(popup);
589 cd->popup_end = popup;
595 static void __naviframe_back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
598 D_MSG_RETM_IF(data == NULL, "Data == NULL");
599 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
601 COMPOSER_EDIT_STATE_E edit_state = __msg_ui_composer_edit_check(cd);
602 D_MSG("edit_state = %d", edit_state);
604 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
606 D_EMSG("back btn is already called");
610 /* isclosed is set to prevent showing invalid popup*/
613 if (edit_state == COMPOSER_EDIT_RECIPIENT || edit_state == COMPOSER_EDIT_BODY) {
614 __msg_ui_composer_end_popup(cd);
617 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
618 if (edit_state == COMPOSER_EDIT_RECIPIENT) {
620 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
622 if (bubble_data->title_menu_opened)
623 msg_ui_bubble_close_title_menu_genlist(bubble_data);
625 if (bubble_data->bubble_count == 0) {
626 int err = MSG_SUCCESS;
628 if (bubble_data->isDraft == true)
629 err = msg_delete_thread_message_list(bubble_data->msgHandle, bubble_data->threadId, false);
631 if (err == MSG_SUCCESS) {
632 service_h svc_handle;
633 char buf[DEF_BUF_LEN_S] = {0,};
635 if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
636 D_EMSG("service_create() is failed !!");
638 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_RESULT, MSG_BUNDLE_VALUE_DEL_ALL);
639 snprintf(buf, sizeof(buf), "%d", bubble_data->threadId);
640 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, buf);
641 ug_send_result(cd->ug, svc_handle);
643 service_destroy(svc_handle);
646 D_MSG("msg_delete_thread_message_list failed");
652 ug_destroy_me(cd->ug);
657 static void __preview_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
660 MSG_COMPOSER_VIEW_DATA_S *cd = data;
661 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
662 D_MSG_RETM_IF(cd->navi_it == NULL, "Naviitem is NULL");
664 msg_struct_t msgInfo = NULL;
665 msg_ui_composer_message_init();
666 msg_ui_composer_read_preview_message(cd);
668 /* make preview message data */
669 msgInfo = msg_ui_composer_message_make_preview(cd->msg_handle);
672 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_MSGVIEWER, msgInfo);
674 msg_ui_composer_message_destroy();
677 evas_object_del(cd->ctx_popup);
678 cd->ctx_popup = NULL;
684 static void __pageduration_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
687 MSG_COMPOSER_VIEW_DATA_S *cd = data;
688 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
689 D_MSG_RETM_IF(cd->navi_it == NULL, "Naviitem is NULL");
691 msg_ui_composer_pageduration_popup_create(cd);
694 evas_object_del(cd->ctx_popup);
695 cd->ctx_popup = NULL;
701 static void __msg_ui_composer_ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
704 MSG_COMPOSER_VIEW_DATA_S *cd = data;
707 evas_object_del(cd->ctx_popup);
708 cd->ctx_popup = NULL;
714 static void msg_composer_naviframe_more_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
717 MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data || !obj);
719 MSG_COMPOSER_VIEW_DATA_S *cd = data;
720 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
721 Evas_Object *ctx_popup = NULL;
724 evas_object_del(cd->popup_end);
725 cd->popup_end = NULL;
729 if (bubble_data->popup) {
730 evas_object_del(bubble_data->popup);
731 bubble_data->popup = NULL;
734 if (bubble_data->title_menu_opened)
735 msg_ui_bubble_close_title_menu_genlist(bubble_data);
738 /* fix ctx_popup flashing issue because of focus */
739 ctx_popup = elm_ctxpopup_add(cd->main_window);
740 elm_ctxpopup_direction_priority_set(ctx_popup, ELM_CTXPOPUP_DIRECTION_DOWN,
741 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
742 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
743 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
745 evas_object_smart_callback_add(ctx_popup, "dismissed", __msg_ui_composer_ctxpopup_dismissed_cb, cd);
747 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
748 elm_ctxpopup_item_append(ctx_popup, dgettext("sys_string", "IDS_COM_SK_DELETE"), NULL, msg_ui_bubble_more_delete_clicked_cb, cd);
750 if (cd->msg_type == COMPOSER_MSG_TYPE_MMS) {
752 if (msg_ui_composer_body_has_media(cd))
753 elm_ctxpopup_item_append(ctx_popup, MSGC_STR_PREVIEW, NULL, __preview_btn_clicked_cb, cd);
756 char buf[DEF_BUF_LEN_S + 1] = {0,};
757 char duration[DEF_BUF_LEN_D + 1] = {0,};
758 const char *str = _MSGSTR("IDS_MSGC_OPT2_DURATION_HPS_SEC_ABB");
759 int pageduration = msg_ui_composer_pageduration_value_get(cd);
761 snprintf(duration, sizeof(duration)-1, "%d", pageduration);
762 snprintf(buf, sizeof(buf)-1, str, duration);
763 elm_ctxpopup_item_append(ctx_popup, buf, NULL, __pageduration_btn_clicked_cb, cd);
766 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
767 elm_ctxpopup_item_append(ctx_popup, dgettext(MESSAGE_PKGNAME, "IDS_MSG_HEADER_BACKUP"), NULL, msg_ui_bubble_backup_clicked_cb, cd);
773 evas_object_geometry_get(cd->more_btn, &x, &y, &w, &h);
774 evas_object_move(ctx_popup, (x+(w/2)) , y+h);
775 evas_object_show(ctx_popup);
777 cd->ctx_popup = ctx_popup;
782 static void __naviframe_compose_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
785 MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data || !obj);
787 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
789 if (cd->bubble_data->popup) {
790 evas_object_del(cd->bubble_data->popup);
791 cd->bubble_data->popup = NULL;
794 service_h svc_handle;
796 if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
797 D_EMSG("service_create() is failed !!");
799 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_MODE, MSG_BUNDLE_VALUE_EDIT);
800 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_FROM, MSG_BUNDLE_VALUE_INTERNAL);
801 msg_ui_composer_launch_composer_create(cd, svc_handle);
802 service_destroy(svc_handle);
807 static Evas_Object *__naviframe_back_btn_create(Evas_Object *parent, void *data, bool title)
810 D_MSG_RETVM_IF(parent == NULL, NULL, "parent == NULL");
811 D_MSG_RETVM_IF(data == NULL, NULL, "data == NULL");
812 D_MSG("Title type = %d", title);
814 Evas_Object *btn = NULL;
815 btn = elm_button_add(parent);
820 elm_object_style_set(btn, "naviframe/back_btn/default");
822 elm_object_style_set(btn, "naviframe/back_btn/default");
824 evas_object_smart_callback_add(btn, "clicked", __naviframe_back_btn_clicked_cb, data);
825 evas_object_show(btn);
830 static Evas_Object *__naviframe_more_btn_create(Evas_Object *parent, void *data)
833 D_MSG_RETVM_IF(parent == NULL, NULL, "parent == NULL");
834 D_MSG_RETVM_IF(data == NULL, NULL, "data == NULL");
836 Evas_Object *btn = elm_button_add(parent);
840 elm_object_style_set(btn, "naviframe/more/default");
842 evas_object_smart_callback_add(btn, "clicked", msg_composer_naviframe_more_btn_clicked_cb, data);
843 evas_object_show(btn);
848 static Evas_Object *__naviframe_compose_btn_create(Evas_Object *parent, void *data)
851 D_MSG_RETVM_IF(parent == NULL, NULL, "parent == NULL");
852 D_MSG_RETVM_IF(data == NULL, NULL, "data == NULL");
854 Evas_Object *btn = elm_button_add(parent);
857 elm_object_style_set(btn, "naviframe/title_icon");
859 Evas_Object *icon = elm_icon_add(btn);
860 elm_image_file_set(icon, MSG_IMAGES_EDJ, MSG_UI_THREAD_LIST_TITLE_ICON_COMPOSE);
861 elm_image_resizable_set(icon, 1, 1);
862 evas_object_image_smooth_scale_set(icon, 0);
863 elm_object_content_set(btn, icon);
864 evas_object_smart_callback_add(btn, "clicked", __naviframe_compose_btn_clicked_cb, data);
870 void msg_ui_composer_reset_request(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
877 COMPOSER_EDIT_STATE_E edit_state = __msg_ui_composer_edit_check(cd);
878 D_MSG("edit_state = %d", edit_state);
879 D_MSG("composer mode = %d, msg_ug_mode = %d", cd->composer_mode, cd->msg_ug_mode);
881 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
882 if (edit_state == COMPOSER_EDIT_RECIPIENT_AND_BODY) {
884 msg_ui_composer_message_init();
886 if (msg_ui_composer_get_message_data(cd) == COMPOSER_RETURN_SUCCESS) {
887 /* delete draft message */
888 msg_thread_id_t tid = 0;
890 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
891 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
892 tid = bubble_data->threadId;
894 GSList *address_list = msg_ui_composer_message_get_address();
895 msg_ui_composer_get_thread_id_by_address(cd->msg_handle, address_list, &tid);
898 D_MSG("tid = %d", tid);
900 msg_ui_composer_delete_draft_message(cd->msg_handle, tid);
902 D_MSG("save draft message");
903 msg_ui_composer_save_message(cd->msg_handle, 0);
906 msg_ui_composer_message_destroy();
908 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
909 if (edit_state == COMPOSER_EDIT_RECIPIENT) {
910 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
912 if (bubble_data->title_menu_opened)
913 msg_ui_bubble_close_title_menu_genlist(bubble_data);
915 if (bubble_data->bubble_count == 0) {
916 int err = MSG_SUCCESS;
918 if (bubble_data->isDraft == true)
919 err = msg_delete_thread_message_list(bubble_data->msgHandle, bubble_data->threadId, false);
921 if (err == MSG_SUCCESS) {
922 service_h svc_handle;
923 if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
924 D_EMSG("service_create() is failed !!");
926 char buf[DEF_BUF_LEN_S] = {0,};
927 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_RESULT, MSG_BUNDLE_VALUE_DEL_ALL);
928 snprintf(buf, sizeof(buf), "%d", bubble_data->threadId);
929 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, buf);
931 ug_send_result(cd->ug, svc_handle);
933 service_destroy(svc_handle);
936 D_MSG("msg_delete_thread_message_list failed");
939 /* delete draft message */
940 msg_struct_list_s msg_list = {0,};
942 if (msg_get_message_list(cd->msg_handle, MSG_DRAFT_ID, bubble_data->threadId, 0, 0, &msg_list) == COMPOSER_RETURN_SUCCESS) {
946 for (i = 0; i < msg_list.nCount; i++) {
947 msg_get_int_value(msg_list.msg_struct_info[i], MSG_MESSAGE_ID_INT, &msgid);
948 D_MSG("draft msg_id is %d", msgid);
949 if (msg_delete_message(cd->msg_handle, msgid) != COMPOSER_RETURN_SUCCESS)
950 D_EMSG("msg_ui_comp_core_delete_message is failed = %d", msgid);
954 msg_release_list_struct(&msg_list);
956 } else if (edit_state == COMPOSER_EDIT_RECIPIENT_AND_BODY) {
958 msg_ui_composer_message_init();
960 if (msg_ui_composer_get_message_data(cd) == COMPOSER_RETURN_SUCCESS) {
961 /* delete draft message */
962 msg_thread_id_t tid = 0;
964 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
965 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
966 tid = bubble_data->threadId;
968 GSList *address_list = msg_ui_composer_message_get_address();
969 msg_ui_composer_get_thread_id_by_address(cd->msg_handle, address_list, &tid);
972 D_MSG("tid = %d", tid);
974 msg_ui_composer_delete_draft_message(cd->msg_handle, tid);
976 D_MSG("save draft message");
977 msg_ui_composer_save_message(cd->msg_handle, 0);
980 msg_ui_composer_message_destroy();
983 /* clear recipient_list of bubble composer */
984 msg_ui_composer_recipient_clear_recipient_list(cd);
988 msg_ui_composer_reset(cd, svc_handle);
994 * 1. clear all composer editing obj
995 * 2. make composer using bundle val
997 COMPOSER_RETURN_TYPE_E msg_ui_composer_reset(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
1001 return COMPOSER_RETURN_FAIL;
1003 if (cd->working_path) {
1004 ecore_file_recursive_rm(cd->working_path);
1005 g_free(cd->working_path);
1008 cd->working_path = msg_composer_create_working_dir();
1010 if (cd->working_path == NULL) {
1011 D_EMSG("Fail of make working dir!!!");
1012 return COMPOSER_RETURN_FAIL;
1016 msg_ui_composer_clear(cd);
1018 char *thread_id = NULL;
1019 char *msg_id = NULL;
1020 char *composer_mode = NULL;
1023 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, &thread_id);
1024 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_MSG_ID, &msg_id);
1025 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_MODE, &composer_mode);
1026 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_FROM, &from);
1028 if (composer_mode) {
1029 if (g_strcmp0(composer_mode, MSG_BUNDLE_VALUE_EDIT) == 0)
1030 cd->composer_mode = MSG_COMPOSER_MODE_EDIT;
1031 else if (g_strcmp0(composer_mode, MSG_BUNDLE_VALUE_FORWARD) == 0)
1032 cd->composer_mode = MSG_COMPOSER_MODE_FORWARD;
1034 cd->composer_mode = MSG_COMPOSER_MODE_NORMAL;
1036 cd->composer_mode = MSG_COMPOSER_MODE_NORMAL;
1039 if (from && g_strcmp0(from, MSG_BUNDLE_VALUE_INTERNAL) == 0)
1040 cd->isMsgInternal = true;
1042 cd->isMsgInternal = false;
1044 /*Change to Bubble view*/
1045 if ((thread_id || msg_id) && cd->composer_mode == MSG_COMPOSER_MODE_NORMAL) {
1046 D_MSG("bubble view composer mode = %d, msg_ug_mode = %d", cd->composer_mode, cd->msg_ug_mode);
1048 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER) {
1049 D_MSG("change bubble view");
1050 msg_ui_composer_change_bubble_view(cd);
1051 msg_ui_bubble_parse_bubble_data(cd->bubble_data, svc_handle);
1052 msg_ui_bubble_start_view(cd->bubble_data);
1053 msg_ui_composer_navi_title_set((void *)cd);
1055 /* set recipient list for bubble composer */
1056 msg_ui_composer_recipient_set_recipient_list(cd, cd->bubble_data->threadId);
1057 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1058 D_MSG("reload bubble view");
1059 msg_ui_bubble_parse_bubble_data(cd->bubble_data, svc_handle);
1060 msg_ui_bubble_list_load(cd->bubble_data, true);
1061 msg_ui_composer_navi_title_set((void *)cd);
1063 /* set recipient list for bubble composer */
1064 msg_ui_composer_recipient_set_recipient_list(cd, cd->bubble_data->threadId);
1066 D_EMSG("Invalid type");
1069 cd->msg_ug_mode = MSG_UG_MODE_BUBBLE_COMPOSER;
1071 D_MSG("normal composer composer mode = %d, msg_ug_mode = %d", cd->composer_mode, cd->msg_ug_mode);
1073 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1074 D_MSG("change composer view");
1075 if (cd->bubble_data) {
1076 cd->bubble_data->ug_state = BUBBLE_UG_DESTROY;
1077 msg_ui_bubble_deinit_bubble_data(cd->bubble_data);
1078 cd->bubble_data = NULL;
1081 msg_ui_composer_change_composer_view(cd);
1084 if (cd->isMsgInternal == true)
1085 cd->msg_ug_mode = MSG_UG_MODE_FULL_COMPOSER;
1087 cd->msg_ug_mode = MSG_UG_MODE_ONLY_COMPOSER;
1089 __msg_ui_composer_bundle_data_process(cd, svc_handle);
1094 return COMPOSER_RETURN_SUCCESS;
1097 COMPOSER_RETURN_TYPE_E msg_ui_composer_start(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
1100 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer Data is NULL");
1102 COMPOSER_RETURN_TYPE_E ret = COMPOSER_RETURN_SUCCESS;
1103 cd->state = COMPOSER_STATE_TYPE_RUNNING;
1105 /* bundle data parsing */
1107 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1109 __msg_ui_composer_bundle_data_process(cd, svc_handle);
1111 if (cd->attachlist == NULL)
1114 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1115 D_MSG("START BUBBLE COMPOSER");
1116 PMSG_BUBBLE_DATA bubble_data = (PMSG_BUBBLE_DATA)cd->bubble_data;
1117 msg_ui_bubble_parse_bubble_data(bubble_data, svc_handle);
1118 msg_ui_bubble_start_view(bubble_data);
1119 msg_ui_composer_navi_title_set((void *)cd);
1121 /* set recipient list for bubble composer */
1122 msg_ui_composer_recipient_set_recipient_list(cd, cd->bubble_data->threadId);
1126 /* set first focus*/
1127 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1128 if (!msg_ui_composer_popup_exist(cd)) {
1130 int recipient_count = msg_ui_composer_recipient_count_get(cd->recipient);
1132 if (recipient_count > 0) {
1133 msg_ui_composer_body_focus_set(cd, 0);
1134 msg_ui_composer_recipient_expanded_set(cd->recipient, EINA_FALSE);
1136 msg_ui_composer_recipient_focus_set(cd->recipient);
1145 static void __msg_composer_auto_save_and_delete_msg(MSG_COMPOSER_VIEW_DATA_S *cd)
1148 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
1150 /* save and delete msg */
1151 if (!cd->disable_auto_save_mode) {
1152 COMPOSER_EDIT_STATE_E edit_state = __msg_ui_composer_edit_check(cd);
1153 if (edit_state == COMPOSER_EDIT_RECIPIENT_AND_BODY) {
1155 /* auto save composer data */
1156 msg_ui_composer_message_init();
1157 if (msg_ui_composer_get_message_data(cd) == COMPOSER_RETURN_SUCCESS) {
1158 /* delete draft message */
1159 msg_thread_id_t tid = 0;
1161 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1162 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
1163 tid = bubble_data->threadId;
1165 GSList *address_list = msg_ui_composer_message_get_address();
1166 msg_ui_composer_get_thread_id_by_address(cd->msg_handle, address_list, &tid);
1169 D_MSG("tid = %d", tid);
1171 msg_ui_composer_delete_draft_message(cd->msg_handle, tid);
1173 D_MSG("save draft message");
1174 msg_ui_composer_save_message(cd->msg_handle, 0);
1175 /* show saved ticker popup */
1176 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_AUTO_SAVED);
1179 msg_ui_composer_message_destroy();
1180 } else if (edit_state == COMPOSER_EDIT_RECIPIENT) {
1181 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1182 /* delete draft message */
1183 MSG_BUBBLE_DATA *bubble_data = cd->bubble_data;
1186 msg_ui_composer_delete_draft_message(cd->msg_handle, bubble_data->threadId);
1195 COMPOSER_RETURN_TYPE_E msg_ui_composer_destroy(MSG_COMPOSER_VIEW_DATA_S *cd)
1198 COMPOSER_RETURN_TYPE_E ret = COMPOSER_RETURN_SUCCESS;
1200 msg_ui_composer_decrease_ref_count();
1203 return COMPOSER_RETURN_FAIL;
1205 D_PRINT("===== Composer UG Destroy Start =====");
1207 __msg_composer_auto_save_and_delete_msg(cd);
1209 /* discoonect volume key handler */
1210 msg_ui_composer_disconnect_handler(cd);
1212 contacts_disconnect2();
1214 D_PRINT("----- Unregister vconf callback -----");
1215 if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, __msgc_vconf_changed_cb) < 0) {
1216 D_EMSG("Fail to unregister vconf CB with [%s]", VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE);
1218 if (vconf_ignore_key_changed(VCONFKEY_MSG_APP_FONT_SIZE, __msgc_vconf_changed_cb) < 0) {
1219 D_EMSG("Fail to unregister vconf CB with [%s]", VCONFKEY_MSG_APP_FONT_SIZE);
1222 if (cd->tapi_handle) {
1223 if (tel_deinit(cd->tapi_handle) != TAPI_API_SUCCESS)
1224 D_EMSG("tel_deinit is failed");
1225 cd->tapi_handle = NULL;
1228 if(cd->job_thread_end) {
1229 D_PRINT("----- Job Delete -----");
1230 ecore_job_del(cd->job_thread_end);
1231 cd->job_thread_end = NULL;
1234 if(cd->attach_thread) {
1235 D_PRINT("----- Thread Delete -----");
1236 ecore_thread_cancel(cd->attach_thread);
1237 cd->attach_thread = NULL;
1240 if (cd->last_focus_idler) {
1241 D_PRINT("----- idler Delete -----");
1242 ecore_idler_del(cd->last_focus_idler);
1243 cd->last_focus_idler = NULL;
1246 if (cd->flight_mode_timer) {
1247 ecore_timer_del(cd->flight_mode_timer);
1248 cd->flight_mode_timer = NULL;
1251 if (cd->recipient) {
1252 D_PRINT("----- Recipient Delete -----");
1253 msg_ui_composer_recipient_delete(cd->recipient);
1254 cd->recipient = NULL;
1257 D_PRINT("----- Recipient list Clear -----");
1258 msg_ui_composer_recipient_clear_recipient_list(cd);
1260 D_PRINT("----- Predict Search Delete -----");
1261 msg_ui_composer_predictsearch_list_delete(cd);
1263 D_PRINT("----- Body Delete -----");
1264 msg_ui_composer_body_delete(cd);
1266 D_PRINT("----- Close Msg Handle -----");
1267 msg_close_msg_handle(&cd->msg_handle);
1269 D_PRINT("----- Delete Popup -----");
1270 msg_ui_composer_popup_delete_all(cd);
1272 if (cd->working_path) {
1273 ecore_file_recursive_rm(cd->working_path);
1274 g_free(cd->working_path);
1275 cd->working_path = NULL;
1279 elm_theme_extension_del(cd->th, MSG_CUSTOM_WINSET_EDJ);
1280 elm_theme_free(cd->th);
1284 /* rollback indicator mode to previous mode */
1285 if (msg_ui_composer_get_ref_count() <= 0)
1286 elm_win_indicator_mode_set(cd->main_window, cd->indicator_mode);
1288 D_PRINT("===== Composer UG Destroy End =====");
1294 void msg_ui_composer_change_language(MSG_COMPOSER_VIEW_DATA_S *cd)
1297 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
1299 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1301 msg_ui_composer_popup_delete_all(cd);
1303 if (cd->ctx_popup) {
1304 evas_object_del(cd->ctx_popup);
1305 cd->ctx_popup = NULL;
1309 msg_ui_composer_navi_title_set(cd);
1312 if (cd->recipient) {
1313 Evas_Object *mbe = cd->recipient->mbe;
1316 char label_txt[TO_FIELD_LABEL_SIZE_MAX] = { 0, };
1319 len = snprintf(label_txt, (gsize)sizeof(label_txt), "%s:", MSGC_STR_TO);
1321 D_EMSG("len = %d", len);
1322 } else if (len > 0) {
1323 label_txt[len] = '\0';
1324 elm_object_text_set(mbe, label_txt);
1326 D_EMSG("len = %d", len);
1329 /* set guide text */
1330 elm_object_part_text_set(mbe, "guide", MSGC_STR_ADD_RECIPIENT);
1334 if (cd->sub_data.entry)
1335 edje_object_part_text_set(_EDJ(cd->sub_data.layout), "subject.guidetxt", MSGC_STR_SUBJECT);
1338 if (cd->ly_attach_main) {
1339 char buf[DEF_BUF_LEN_S + 1] = {0,};
1340 const char *str = _MSGSTR("IDS_MSGC_BODY_PD_ATTACHMENTS");
1342 snprintf(buf, sizeof(buf), str, cd->attach_data.attachment_Cnt);
1343 edje_object_part_text_set(_EDJ(cd->ly_attach_main), "text.filename", buf);
1347 if (cd->msg_type == COMPOSER_MSG_TYPE_MMS)
1348 msg_ui_composer_body_info_area_update(cd);
1351 cd->isclosed = false;
1356 COMPOSER_RETURN_TYPE_E msg_ui_composer_rotate(MSG_COMPOSER_VIEW_DATA_S *cd, COMPOSER_ROTATE_TYPE_E rotate)
1359 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "cd is NULL");
1361 cd->rotate = rotate;
1362 D_MSG("rotate val [%d]", rotate);
1364 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1366 RECIPIENT_S *r = cd->recipient;
1367 if (!r) return COMPOSER_RETURN_FAIL;
1369 if (rotate == COMPOSER_ROTATE_PORTRAIT || rotate == COMPOSER_ROTATE_PORTRAIT_UPSIDEDOWN) {
1370 elm_layout_theme_set(cd->base, "layout", "application", "default");
1373 elm_win_indicator_mode_set(cd->main_window, ELM_WIN_INDICATOR_SHOW);
1375 elm_box_horizontal_set(r->bx_main, EINA_FALSE);
1376 elm_scroller_content_min_limit(r->sc, EINA_FALSE, EINA_TRUE);
1377 evas_object_size_hint_max_set(r->sc, 9999, COMPOSER_RECIPIENT_PORTRAIT_HEIGHT_MAX);
1378 } else if (rotate == COMPOSER_ROTATE_LANDSCAPE || rotate == COMPOSER_ROTATE_LANDSCAPE_UPSIDEDOWN) {
1379 elm_layout_theme_set(cd->base, "layout", "application", "noindicator");/*hide indicator in Landscape*/
1381 if (!cd->loaded_ug) {
1382 elm_win_indicator_mode_set(cd->main_window, ELM_WIN_INDICATOR_HIDE);
1383 D_MSG("hide indicator");
1386 elm_box_horizontal_set(r->bx_main, EINA_TRUE);
1387 elm_scroller_content_min_limit(r->sc, EINA_FALSE, EINA_FALSE);
1388 evas_object_size_hint_max_set(r->sc, 9999, -1);
1391 /* change body scroller size */
1392 msg_ui_composer_change_body_scroll_size(cd, 0);
1394 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1395 if (rotate == COMPOSER_ROTATE_PORTRAIT || rotate == COMPOSER_ROTATE_PORTRAIT_UPSIDEDOWN) {
1396 if (cd->bubble_data)
1397 cd->bubble_data->isRotate = false;
1399 if (cd->compose_btn) {
1400 evas_object_hide(cd->compose_btn);
1401 elm_object_part_content_unset(cd->navi_title_layout, "compose_btn");
1403 } else if (rotate == COMPOSER_ROTATE_LANDSCAPE || rotate == COMPOSER_ROTATE_LANDSCAPE_UPSIDEDOWN) {
1404 if (cd->bubble_data) {
1405 cd->bubble_data->isRotate = true;
1407 if (cd->compose_btn && cd->bubble_data->viewmode == BUBBLE_NORMAL_VIEW) {
1408 evas_object_show(cd->compose_btn);
1409 elm_object_part_content_set(cd->navi_title_layout, "compose_btn", cd->compose_btn);
1414 elm_win_indicator_mode_set(cd->main_window, ELM_WIN_INDICATOR_SHOW);
1416 /* change body scroller size */
1417 msg_ui_composer_change_body_scroll_size(cd, 0);
1420 D_EMSG("Unknown Composer Mode");
1421 return COMPOSER_RETURN_FAIL;
1425 return COMPOSER_RETURN_SUCCESS;
1428 COMPOSER_RETURN_TYPE_E msg_ui_composer_init(MSG_COMPOSER_VIEW_DATA_S *cd)
1433 D_EMSG("[ASSERT] pcmop_data is NULL");
1434 return COMPOSER_RETURN_FAIL;
1437 /* create message handle */
1438 if (msg_open_msg_handle(&cd->msg_handle) != MSG_SUCCESS) {
1439 D_EMSG("[ASSERT] msg-server doesn't response !!!");
1440 return COMPOSER_RETURN_FAIL;
1443 /* set message sent status callback */
1444 if (msg_reg_sent_status_callback(cd->msg_handle, &__msg_ui_composer_sent_status_cb, cd) != MSG_SUCCESS) {
1445 D_EMSG("[ASSERT] sent status callback register error!!!");
1446 return COMPOSER_RETURN_FAIL;
1449 /* connect contacts svc*/
1450 if (contacts_connect2() != 0) {
1451 D_EMSG("[ASSERT] Fail of contacts_connect2 !!!");
1452 return COMPOSER_RETURN_FAIL;
1455 cd->working_path = msg_composer_create_working_dir();
1456 if (cd->working_path == NULL) {
1457 D_EMSG("[ASSERT] Fail of make working dir!!!");
1458 return COMPOSER_RETURN_FAIL;
1461 /* set default message type is SMS */
1462 cd->msg_type = COMPOSER_MSG_TYPE_SMS;
1464 /* get sms setting */
1465 msg_struct_t sms_sent_opt = msg_create_struct(MSG_STRUCT_SETTING_SMS_SEND_OPT);
1467 if (msg_get_sms_send_opt(cd->msg_handle, sms_sent_opt) != MSG_SUCCESS) {
1468 D_EMSG("Getting SMS_SEND_OP ERROR");
1470 msg_get_int_value(sms_sent_opt, MSG_SMS_SENDOPT_ENCODE_TYPE_INT, &cd->encode_mode);
1471 D_MSG("SMS Encode mode is %d", cd->encode_mode);
1474 msg_release_struct(&sms_sent_opt);
1476 if (cd->cms_max_page == 0) {
1477 // TODO: get cms max page from msgfw when it is supported by msgfw.
1478 cd->cms_max_page = COMPOSER_CMS_MAX_PAGE;
1481 /* get mms max size */
1482 if (cd->mms_max_size == 0) {
1483 msg_struct_t setting = msg_create_struct(MSG_STRUCT_SETTING_MSGSIZE_OPT);
1485 if (msg_get_msgsize_opt(cd->msg_handle, setting) != MSG_SUCCESS) {
1486 D_EMSG("Getting MMS MAX SIZE ERROR");
1489 msg_get_int_value(setting, MSG_MESSAGE_SIZE_INT, &cd->mms_max_size);
1491 D_MSG("msg max size = [%d KB] !!!", cd->mms_max_size);
1492 cd->mms_max_size = cd->mms_max_size * 1024;
1494 msg_release_struct(&setting);
1497 /* set default font size*/
1498 __msgc_init_font_size(cd);
1500 /* coonect volume key handler */
1501 msg_ui_composer_connect_handler(cd);
1503 /* register vconf callback function */
1504 if (vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, __msgc_vconf_changed_cb, cd) < 0) {
1505 D_EMSG("Fail to register vconf CB with [%s]", VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE);
1507 if (vconf_notify_key_changed(VCONFKEY_MSG_APP_FONT_SIZE, __msgc_vconf_changed_cb, cd) < 0) {
1508 D_EMSG("Fail to register vconf CB with [%s]", VCONFKEY_MSG_APP_FONT_SIZE);
1511 cd->th = elm_theme_new();
1512 elm_theme_ref_set(cd->th, NULL);
1513 elm_theme_extension_add(cd->th, MSG_CUSTOM_WINSET_EDJ);
1515 return COMPOSER_RETURN_SUCCESS;
1519 * Create Composer First View
1521 COMPOSER_RETURN_TYPE_E msg_ui_composer_create(MSG_COMPOSER_VIEW_DATA_S *cd)
1524 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1525 D_MSG_RETVM_IF(cd->main_window == NULL, COMPOSER_RETURN_FAIL, "main_window is NULL");
1526 D_MSG_RETVM_IF(cd->base == NULL, COMPOSER_RETURN_FAIL, "base layout is NULL");
1528 Evas_Object *navi_frame = NULL;
1529 Evas_Object *more_button = NULL;
1530 Evas_Object *compose_button = NULL;
1531 Evas_Object *content_layout = NULL;
1532 Elm_Object_Item *navi_it = NULL;
1533 Evas_Object *back_btn = NULL;
1536 cd->state = COMPOSER_STATE_TYPE_CREATE;
1538 /* Create naviframe */
1539 navi_frame = elm_naviframe_add(cd->base);
1541 D_EMSG("naviframe add fail");
1545 evas_object_show(navi_frame);
1546 cd->navi_bar = navi_frame;
1548 /* Create content layout */
1549 content_layout = elm_layout_add(navi_frame);
1550 if (!content_layout) {
1551 D_EMSG("layout add fail");
1555 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1556 elm_layout_file_set(content_layout, MSGC_UI_DEFAULT_EDJ, MSGC_EDJ_GRP_CONTENT_LAYOUT);
1557 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER){
1558 elm_layout_file_set(content_layout, MSGC_UI_DEFAULT_EDJ, MSGC_EDJ_GRP_CONTENT_LAYOUT);
1559 edje_object_signal_emit(_EDJ(content_layout), "change.bubble", "*");
1561 D_EMSG("UG mode Unknown");
1565 evas_object_size_hint_weight_set(content_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1566 evas_object_size_hint_align_set(content_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1567 edje_object_signal_emit(_EDJ(content_layout), "hide.predictsearch", "*");
1568 evas_object_show(content_layout);
1570 cd->content_layout = content_layout;
1573 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1574 cd->recipient = msg_ui_composer_recipient_create(content_layout, 1, cd);
1575 if (cd->recipient == NULL)
1578 elm_object_part_content_set(content_layout, "swl.recipient", cd->recipient->bx_main);
1580 Evas_Object *predict_search_layout = msg_ui_composer_predictsearch_list_create(content_layout, cd);
1581 elm_object_part_content_set(content_layout, "swl.predictsearch", predict_search_layout);
1584 PMSG_BUBBLE_DATA bubble_data = msg_ui_bubble_init_bubble_data(cd->msg_handle, cd);
1589 cd->bubble_data = bubble_data;
1591 Evas_Object *bubble_layout = msg_ui_bubble_create_view(content_layout, cd->bubble_data);
1592 if (!bubble_layout) {
1595 elm_object_part_content_set(content_layout, "swl.bubble.content", bubble_layout);
1598 Evas_Object *body_layout = msg_ui_composer_body_create(cd, content_layout);
1603 elm_object_part_content_set(content_layout, "swl.composer.body", body_layout);
1605 cd->ly_body = body_layout;
1607 /*Push content to navi frame*/
1608 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1609 if (cd->isMsgInternal)
1610 back_btn = __naviframe_back_btn_create(navi_frame, (void *)cd, false);
1612 back_btn = __naviframe_back_btn_create(navi_frame, (void *)cd, true);
1614 back_btn = __naviframe_back_btn_create(navi_frame, (void *)cd, false);
1617 navi_it = elm_naviframe_item_push(navi_frame, NULL, NULL, NULL, content_layout, "empty");
1619 cd->navi_it = navi_it;
1620 cd->back_btn = back_btn;
1622 /* create navi title layout */
1623 cd->navi_title_layout = msg_ui_composer_create_navi_title_bar(cd);
1624 msg_ui_composer_navi_title_set(cd);
1625 elm_object_item_part_content_set(cd->navi_it, "title", cd->navi_title_layout);
1627 /*Create more button*/
1628 more_button = __naviframe_more_btn_create(navi_frame, cd);
1630 elm_object_part_content_set(cd->navi_title_layout, "more_btn", more_button);
1631 elm_object_part_content_set(cd->navi_title_layout, "prev_btn", back_btn);
1633 cd->more_btn = more_button;
1635 if (cd->msg_type == COMPOSER_MSG_TYPE_SMS && cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER)
1636 elm_object_disabled_set(cd->more_btn, EINA_TRUE);
1638 /*Create compose button*/
1639 compose_button = __naviframe_compose_btn_create(navi_frame, cd);
1641 if (cd->bubble_data != NULL && cd->bubble_data->isRotate == true) {
1642 evas_object_show(compose_button);
1643 elm_object_part_content_set(cd->navi_title_layout, "compose_btn", compose_button);
1645 evas_object_hide(compose_button);
1646 elm_object_part_content_unset(cd->navi_title_layout, "compose_btn");
1649 cd->compose_btn = compose_button;
1651 /* set navibar to main layout (base) */
1652 elm_object_part_content_set(cd->base, "elm.swallow.content", navi_frame);
1655 return COMPOSER_RETURN_SUCCESS;
1658 return COMPOSER_RETURN_FAIL;
1661 COMPOSER_RETURN_TYPE_E msg_ui_composer_bubble_data_set(MSG_COMPOSER_VIEW_DATA_S *cd, int thread_id)
1664 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1665 D_MSG_RETVM_IF(cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER, COMPOSER_RETURN_FAIL, "msg_ug_mode is NOT BUBBLE TYPE");
1666 D_MSG_RETVM_IF(thread_id <= 0, COMPOSER_RETURN_FAIL, "Composer mode is Not Full");
1667 D_MSG_RETVM_IF(cd->bubble_data == NULL, COMPOSER_RETURN_FAIL, "bubble data is NULL");
1669 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
1670 msg_struct_t threadInfo = NULL;
1673 /*Create bubble list*/
1674 bubble_data->threadId = thread_id;
1675 D_MSG("Thread ID = %d", bubble_data->threadId);
1677 msg_struct_list_s addrList;
1679 memset(&addrList, 0x00, sizeof(msg_struct_list_s));
1681 err = msg_get_address_list(bubble_data->msgHandle, bubble_data->threadId, &addrList);
1683 if (err == MSG_SUCCESS) {
1684 bubble_data->addr_list.addr_cnt = addrList.nCount;
1686 for (i = 0; i<addrList.nCount; i++) {
1688 msg_get_int_value(addrList.msg_struct_info[i], MSG_ADDRESS_INFO_CONTACT_ID_INT, &contact_id);
1690 msg_get_str_value(addrList.msg_struct_info[i], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, bubble_data->addr_list.addr_info[i].address, DEF_THREAD_ADDR_LEN);
1692 /** contact ID & display name */
1693 if (contact_id > 0) {
1694 bubble_data->addr_list.addr_info[i].contact_id = contact_id;
1695 msg_get_str_value(addrList.msg_struct_info[i], MSG_ADDRESS_INFO_DISPLAYNAME_STR, bubble_data->addr_list.addr_info[i].name, DEF_THREAD_NAME_LEN);
1697 bubble_data->addr_list.addr_info[i].contact_id = 0;
1701 msg_release_list_struct(&addrList);
1703 D_MSG("[ERROR] msg_get_address_list returns error [%d]", err);
1706 threadInfo = msg_create_struct(MSG_STRUCT_THREAD_INFO);
1707 err = msg_get_thread(bubble_data->msgHandle, bubble_data->threadId, threadInfo);
1709 if (err == MSG_SUCCESS)
1710 msg_get_str_value(threadInfo, MSG_THREAD_NAME_STR, bubble_data->threadName, DEF_THREAD_NAME_LEN);
1712 D_MSG("[ERROR] msg_get_trhead returns error [%d", err);
1714 msg_release_struct(&threadInfo);
1716 return COMPOSER_RETURN_SUCCESS;
1719 COMPOSER_RETURN_TYPE_E msg_ui_composer_change_composer_view(MSG_COMPOSER_VIEW_DATA_S *cd)
1722 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1723 D_MSG_RETVM_IF(cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER, COMPOSER_RETURN_FAIL, "Composer mode is Not Full");
1726 cd->msg_ug_mode = MSG_UG_MODE_ONLY_COMPOSER;
1728 /*Change content layout to composer layout*/
1729 edje_object_signal_emit(_EDJ(cd->content_layout), "change.composer", "*");
1731 elm_scroller_content_min_limit(cd->body_scroll, 0, 0);
1733 cd->recipient = msg_ui_composer_recipient_create(cd->content_layout, 1, cd);
1734 elm_object_part_content_set(cd->content_layout, "swl.recipient", cd->recipient->bx_main);
1736 Evas_Object *predict_search_layout = msg_ui_composer_predictsearch_list_create(cd->content_layout, cd);
1737 elm_object_part_content_set(cd->content_layout, "swl.predictsearch", predict_search_layout);
1739 MSGC_EVAS_OBJECT_DEL(cd->back_btn);
1740 Evas_Object *back_btn = __naviframe_back_btn_create(cd->navi_bar, (void *)cd, true);
1741 elm_object_part_content_set(cd->navi_title_layout, "prev_btn", back_btn);
1742 cd->back_btn = back_btn;
1744 msg_ui_composer_navi_title_set(cd);
1747 return COMPOSER_RETURN_SUCCESS;
1750 COMPOSER_RETURN_TYPE_E msg_ui_composer_change_bubble_view(MSG_COMPOSER_VIEW_DATA_S *cd)
1753 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1754 D_MSG_RETVM_IF(cd->msg_ug_mode != MSG_UG_MODE_FULL_COMPOSER, COMPOSER_RETURN_FAIL, "Composer mode is Not Full");
1757 cd->msg_ug_mode = MSG_UG_MODE_BUBBLE_COMPOSER;
1759 /*Change content layout to bubble layout*/
1760 edje_object_signal_emit(_EDJ(cd->content_layout), "hide.predictsearch", "*");
1761 edje_object_signal_emit(_EDJ(cd->content_layout), "change.bubble", "*");
1763 elm_scroller_content_min_limit(cd->body_scroll, 0, 1);
1764 evas_object_size_hint_max_set(cd->body_scroll, 9999, 250);
1766 /*Init bubble data*/
1767 PMSG_BUBBLE_DATA bubble_data = msg_ui_bubble_init_bubble_data(cd->msg_handle, cd);
1769 return COMPOSER_RETURN_FAIL;
1771 cd->bubble_data = (void *)bubble_data;
1773 /*Change naviframe layout for bubble*/
1774 Evas_Object *cancel_btn = __naviframe_back_btn_create(cd->navi_bar, (void *)cd, false);
1775 elm_object_part_content_set(cd->navi_title_layout, "prev_btn", cancel_btn);
1776 cd->back_btn = cancel_btn;
1778 Evas_Object *layout = msg_ui_bubble_create_view(cd->content_layout, cd->bubble_data); // First parameter should be 'content_layout'.
1779 elm_object_part_content_set(cd->content_layout, "swl.bubble.content", layout);
1781 /*remove unused layout*/
1782 MSGC_EVAS_OBJECT_DEL(cd->ly_recipient);
1783 msg_ui_composer_recipient_delete(cd->recipient);
1784 cd->recipient = NULL;
1786 msg_ui_composer_predictsearch_list_delete(cd);
1788 return COMPOSER_RETURN_SUCCESS;
1792 * msg_ui_composer_editable_set
1793 * editable == FALSE : hide body content & disable more button & close option header
1794 * editable == TRUE : show body content layout
1796 void msg_ui_composer_editable_set(MSG_COMPOSER_VIEW_DATA_S *cd, Eina_Bool editable)
1799 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
1801 if (editable == EINA_FALSE){
1802 Evas_Object *body_layout = elm_object_part_content_unset(cd->content_layout, "swl.composer.body");
1803 evas_object_hide(body_layout);
1806 elm_object_disabled_set(cd->more_btn, EINA_TRUE);
1808 elm_object_part_content_set(cd->content_layout, "swl.composer.body", cd->ly_body);
1809 evas_object_show(cd->ly_body);
1812 elm_object_disabled_set(cd->more_btn, EINA_FALSE);
1819 void msg_ui_composer_bubble_del_all(void *data, service_h svc_handle)
1823 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1824 D_MSG_RETM_IF(cd == NULL, "Composer data is NULL");
1826 ug_send_result(cd->ug, svc_handle);
1829 Evas_Object *msg_ui_composer_create_navi_title_bar(void *data)
1834 D_EMSG("[ERROR] data is NULL");
1838 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1840 Evas_Object *title_layout = elm_layout_add(cd->navi_bar);
1841 elm_layout_file_set(title_layout, MSG_COMMON_EDJ, "title");
1842 evas_object_size_hint_weight_set(title_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1843 evas_object_size_hint_align_set(title_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1844 evas_object_show(title_layout);
1846 return title_layout;
1849 void msg_ui_composer_navi_title_set(void *data)
1854 D_EMSG("data is NULL");
1858 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1859 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
1861 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1862 elm_object_part_text_set(cd->navi_title_layout, "title_text", MSGC_STR_NEW_MESSAGE);
1863 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1864 Evas_Object *title_button = NULL;
1866 elm_object_part_text_set(cd->navi_title_layout, "title_text", ""); // text part clear first
1868 title_button = elm_button_add(cd->navi_bar);
1870 elm_object_theme_set(title_button, cd->th);
1871 elm_object_style_set(title_button, "title_button");
1873 evas_object_size_hint_weight_set(title_button, 0.0, 0.0);
1874 evas_object_size_hint_align_set(title_button, EVAS_HINT_FILL, EVAS_HINT_FILL);
1876 if (bubble_data->addr_list.addr_cnt == 1) {
1877 if (bubble_data->addr_list.addr_info[0].contact_id > 0 && bubble_data->addr_list.addr_info[0].name[0] != '\0')
1878 elm_object_text_set(title_button, bubble_data->addr_list.addr_info[0].name);
1879 else if (bubble_data->addr_list.addr_info[0].address[0] != '\0')
1880 elm_object_text_set(title_button, bubble_data->addr_list.addr_info[0].address);
1882 elm_object_text_set(title_button, dgettext("sys_string", "IDS_COM_BODY_UNKNOWN"));
1883 } else if (bubble_data->addr_list.addr_cnt > 1) {
1884 char title_text[DEF_BUF_LEN+1] = {0,};
1886 if (bubble_data->addr_list.addr_info[0].contact_id > 0 && bubble_data->addr_list.addr_info[0].name[0] != '\0')
1887 snprintf(title_text, sizeof(title_text), "%s +%d", bubble_data->addr_list.addr_info[0].name, bubble_data->addr_list.addr_cnt-1);
1888 else if (bubble_data->addr_list.addr_info[0].address[0] != '\0')
1889 snprintf(title_text, sizeof(title_text), "%s +%d", bubble_data->addr_list.addr_info[0].address, bubble_data->addr_list.addr_cnt-1);
1891 snprintf(title_text, sizeof(title_text), "%s +%d", dgettext("sys_string", "IDS_COM_BODY_UNKNOWN"), bubble_data->addr_list.addr_cnt-1);
1893 elm_object_text_set(title_button, title_text);
1895 elm_object_text_set(title_button, dgettext("sys_string", "IDS_COM_BODY_UNKNOWN"));
1898 evas_object_show(title_button);
1899 elm_object_part_content_set(cd->navi_title_layout, "title_btn", title_button);
1900 evas_object_smart_callback_add(title_button, "clicked", msg_ui_bubble_title_button_clicked_cb, cd);
1902 bubble_data->title_button = title_button;
1904 D_EMSG("Invalid msg_ui_mode [%d]", cd->msg_ug_mode);
1909 static Eina_Bool __msgc_up_key_long_press_cb(void *data)
1912 D_MSG_RETVM_IF(data == NULL, EINA_FALSE, "cd is NULL");
1913 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1915 if (!msg_common_increase_font_size()) {
1916 cd->vol_up_key_longpress = NULL;
1920 /* apply font size */
1921 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
1922 msg_common_apply_font_size("bubble", cd->content_layout);
1924 msg_ui_composer_apply_font_size(cd, false);
1929 static Eina_Bool __msgc_down_key_long_press_cb(void *data)
1932 D_MSG_RETVM_IF(data == NULL, EINA_FALSE, "cd is NULL");
1933 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1935 if (!msg_common_decrease_font_size()) {
1936 cd->vol_down_key_longpress = NULL;
1940 /* apply font size */
1941 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
1942 msg_common_apply_font_size("bubble", cd->content_layout);
1944 msg_ui_composer_apply_font_size(cd, false);
1949 Eina_Bool msg_ui_composer_key_release_cb(void *data, int type, void *event)
1952 D_MSG_RETVM_IF(data == NULL, EINA_FALSE, "cd is NULL");
1953 D_MSG_RETVM_IF(event == NULL, EINA_FALSE, "event is NULL");
1954 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1955 Ecore_Event_Key *ev = (Ecore_Event_Key *)event;
1956 int use_volume_key = false;
1958 vconf_get_bool(VCONFKEY_MSG_APP_USE_VOLUME_KEY, &use_volume_key);
1960 if (use_volume_key) {
1961 if (!g_strcmp0(ev->keyname, KEY_VOLUMEUP)) { /* KEY_VOLUMEUP */
1962 D_MSG("KEY_VOLUMEUP is released");
1964 if (cd->vol_up_key_longpress) {
1965 ecore_timer_del(cd->vol_up_key_longpress);
1966 cd->vol_up_key_longpress = NULL;
1968 } else if (!g_strcmp0(ev->keyname, KEY_VOLUMEDOWN)) { /* KEY_VOLUMEDOWN */
1969 D_MSG("KEY_VOLUMEDOWN is released");
1971 if (cd->vol_down_key_longpress) {
1972 ecore_timer_del(cd->vol_down_key_longpress);
1973 cd->vol_down_key_longpress = NULL;
1976 D_MSG("key_name is not applicable!");
1979 D_MSG("Use volume key setting is not activated. Do volume key action");
1985 Eina_Bool msg_ui_composer_key_press_cb(void *data, int type, void *event)
1988 D_MSG_RETVM_IF(data == NULL, EINA_FALSE, "cd is NULL");
1989 D_MSG_RETVM_IF(event == NULL, EINA_FALSE, "event is NULL");
1990 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1991 Ecore_Event_Key *ev = (Ecore_Event_Key *)event;
1992 int use_volume_key = false;
1994 vconf_get_bool(VCONFKEY_MSG_APP_USE_VOLUME_KEY, &use_volume_key);
1996 if (use_volume_key) {
1997 if (!g_strcmp0(ev->keyname, KEY_VOLUMEUP)) { /* KEY_VOLUMEUP */
1998 D_MSG("KEY_VOLUMEUP is pressed");
2000 msg_common_increase_font_size();
2002 /* apply font size */
2003 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
2004 msg_common_apply_font_size("bubble", cd->content_layout);
2006 msg_ui_composer_apply_font_size(cd, false);
2008 cd->vol_up_key_longpress = ecore_timer_add(0.1, (Ecore_Task_Cb) __msgc_up_key_long_press_cb, (void *)cd);
2009 } else if (!g_strcmp0(ev->keyname, KEY_VOLUMEDOWN)) { /* KEY_VOLUMEDOWN */
2010 D_MSG("KEY_VOLUMEDOWN is pressed");
2012 msg_common_decrease_font_size();
2014 /* apply font size */
2015 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
2016 msg_common_apply_font_size("bubble", cd->content_layout);
2018 msg_ui_composer_apply_font_size(cd, false);
2020 cd->vol_down_key_longpress = ecore_timer_add(0.1, (Ecore_Task_Cb) __msgc_down_key_long_press_cb, (void *)cd);
2022 D_MSG("key_name is not applicable!");
2025 D_MSG("Use volume key setting is not activated. Do volume key action");
2031 void msg_ui_composer_connect_handler(MSG_COMPOSER_VIEW_DATA_S *cd)
2034 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
2036 int use_volume_key = 0;
2037 vconf_get_bool(VCONFKEY_MSG_APP_USE_VOLUME_KEY, &use_volume_key);
2039 if (use_volume_key) {
2040 msg_ui_composer_grab_key_setting(cd->xdisplay, cd->main_window);
2041 /* connect key handler for volume up/down */
2042 if (!cd->volkey_press_handler)
2043 cd->volkey_press_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, msg_ui_composer_key_press_cb, (void *)cd);
2045 if (!cd->volkey_release_handler)
2046 cd->volkey_release_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP, msg_ui_composer_key_release_cb, (void *)cd);
2048 D_MSG("use_volume_key = %d", use_volume_key);
2053 void msg_ui_composer_disconnect_handler(MSG_COMPOSER_VIEW_DATA_S *cd)
2056 D_MSG_RETM_IF(cd == NULL, "cd is NULL");
2058 if (cd->volkey_press_handler) {
2059 ecore_event_handler_del(cd->volkey_press_handler);
2060 cd->volkey_press_handler = NULL;
2063 if (cd->vol_down_key_longpress) {
2064 ecore_timer_del(cd->vol_down_key_longpress);
2065 cd->vol_down_key_longpress = NULL;
2068 if (cd->volkey_release_handler) {
2069 ecore_event_handler_del(cd->volkey_release_handler);
2070 cd->volkey_release_handler = NULL;
2073 if (cd->vol_up_key_longpress) {
2074 ecore_timer_del(cd->vol_up_key_longpress);
2075 cd->vol_up_key_longpress = NULL;
2078 msg_ui_composer_ungrab_key_setting(cd->xdisplay, cd->main_window);