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://www.tizenopensource.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.
20 #include "msg-ui-composer-main.h"
21 #include "msg-ui-composer-recipient.h"
22 #include "msg-ui-composer-popup.h"
23 #include "msg-ui-composer-predictsearch.h"
24 #include "msg-ui-composer-subject.h"
25 #include "msg-ui-composer-body.h"
26 #include "msg-ui-composer-pageduration.h"
27 #include "msg-ui-composer-message.h"
28 #include "msg-ui-composer-common.h"
29 #include "msg-ui-composer-external.h"
30 #include "msg-ui-composer-bubble.h"
32 #include "msg-ui-common-utility.h"
34 #define COMPOSER_BUNDLE_ATTACH_TOKEN "\n"
35 #define COMPOSER_BUNDLE_RECP_TOKEN ","
37 /*==================================================================================================
38 * FUNCTION IMPLEMENTATIONS
39 *==================================================================================================*/
40 static COMPOSER_EDIT_STATE_E __msg_ui_composer_edit_check(MSG_COMPOSER_VIEW_DATA_S *cd)
43 D_MSG_RETVM_IF(cd == NULL, COMPOSER_EDIT_NONE, "Composer Data == NULL");
45 bool isvalid_address = false;
46 bool iscontent_edited = false;
48 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
49 int recipient_count = msg_ui_composer_recipient_count_get(cd->recipient);
50 if (recipient_count > 0) {
51 isvalid_address = true;
54 const char *entry_str = msg_ui_composer_recipient_entry_text_get(cd->recipient);
55 if (entry_str && strlen(entry_str)) {
56 if (msg_ui_composer_recipient_vaild_check(entry_str) == EINA_TRUE)
57 isvalid_address = true;
59 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
60 isvalid_address = true;
63 /* valid address & there is body content */
64 if (msg_ui_composer_common_is_send_possible(cd) == true)
65 iscontent_edited = true;
67 if (isvalid_address && iscontent_edited)
68 return COMPOSER_EDIT_RECIPIENT_AND_BODY;
69 else if (isvalid_address)
70 return COMPOSER_EDIT_RECIPIENT;
71 else if (iscontent_edited)
72 return COMPOSER_EDIT_BODY;
74 return COMPOSER_EDIT_NONE;
77 static void __msgc_vconf_changed_cb(keynode_t *key, void *data)
81 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
82 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
83 D_MSG_RETM_IF(key == NULL, "key is NULL");
87 int converted_size = 0;
88 char *key_name = NULL;
90 key_name = vconf_keynode_get_name(key);
93 D_EMSG("key_name is NULL");
97 if (!strcmp(key_name, VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE)) {
102 * 3 : normal (default) : 44
105 index = vconf_keynode_get_int(key);
106 font_size = msg_ui_composer_get_font_size(index, (int)COMPOSER_SYSTEM_FONT_SIZE);
107 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
109 cd->font_size.last_updated_setting = COMPOSER_SYSTEM_FONT_SIZE;
110 cd->font_size.sys_font_size = converted_size;
111 } else if (!strcmp(key_name, VCONFKEY_MSG_APP_FONT_SIZE)) {
112 index = vconf_keynode_get_int(key);
113 font_size = msg_ui_composer_get_font_size(index, (int)COMPOSER_MSG_FONT_SIZE);
114 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
116 cd->font_size.last_updated_setting = COMPOSER_MSG_FONT_SIZE;
117 cd->font_size.msg_font_size = converted_size;
119 D_EMSG("key did not match.");
122 D_MSG("font size = %d", font_size);
123 D_MSG("converted font size = %d", converted_size);
128 static void __msgc_init_font_size(MSG_COMPOSER_VIEW_DATA_S *cd)
131 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
135 int converted_size = 0;
137 if (msg_common_get_font_size(&index, &font_size) != TRUE) {
138 D_EMSG("msg_common_get_font_size() is failed !!");
140 D_MSG("selected index = %d", index);
143 if (index == MSG_APP_FONT_SIZE_INDEX_SYSTEM_FONT) {
144 if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &index) < 0) {
145 D_EMSG("vconf_get_int(system font_size) is failed !!");
146 index = MSG_SYS_FONT_SIZE_INDEX_NORMAL;
149 font_size = msg_ui_composer_get_font_size(index, (int)COMPOSER_SYSTEM_FONT_SIZE);
150 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
152 cd->font_size.last_updated_setting = COMPOSER_SYSTEM_FONT_SIZE;
153 cd->font_size.sys_font_size = converted_size;
156 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
158 cd->font_size.last_updated_setting = COMPOSER_MSG_FONT_SIZE;
159 cd->font_size.msg_font_size = converted_size;
161 D_MSG("font size = %d", converted_size);
166 static void __msgc_parse_recipient_list(MSG_COMPOSER_VIEW_DATA_S *cd, const char *address)
169 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
170 D_MSG_RETM_IF(address == NULL, "address is NULL");
172 bool bMaxCount = false;
173 bool bInvalidNum = false;
176 Eina_List *recipient_list = make_tokenize_list(address, ",");
178 if (recipient_list) {
181 EINA_LIST_FOREACH(recipient_list, l, recipient) {
183 D_MSG("TO = %s", recipient);
184 if (msg_ui_composer_recipient_count_get(cd->recipient) >= COMPOSER_RECIPIENT_COUNT_MAX) {
190 if (msg_ui_composer_recipient_duplicate_check(cd->recipient, recipient) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
196 if (msg_ui_composer_recipient_vaild_check(recipient) == EINA_FALSE) {
199 msg_ui_composer_recipient_append(cd->recipient, recipient, 0);
206 D_MSG("bMaxCount = %d, bInvalidNum = %d, bDup = %d", bMaxCount, bInvalidNum, bDup);
208 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
209 } else if (bInvalidNum) {
210 msg_ui_composer_status_btn_popup_show(cd, MSGC_STR_NOTI_RECIPIENT_INVALID, 0, MSGC_STR_BUTTON_OK);
212 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_DUP_RECP);
219 static void __msgc_ui_parse_mmsto_uri(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, const char *uri)
222 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
223 D_MSG_RETM_IF(svc_handle == NULL, "svc_handle is NULL");
225 char *content = NULL;
226 char *recipient = NULL;
227 char *body_text = NULL;
228 char *subject = NULL;
229 char *attachment = NULL;
231 char *scheme = g_strdup(uri);
234 strtok_r(scheme, ":", &content);
237 if (g_ascii_isdigit(content[0]) || (content[0] == '+' && g_ascii_isdigit(content[1]))) {
238 recipient = strtok_r(NULL, "?", &content);
239 cc = strtok_r(NULL, "&", &content);
241 strtok_r(NULL, "=", &cc);
243 D_MSG("RECIPIENT = [%s]", recipient);
245 __msgc_parse_recipient_list(cd, (const char *)recipient);
250 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient) {
251 __msgc_parse_recipient_list(cd, (const char *)recipient);
255 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text) {
256 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
259 if ((service_get_extra_data(svc_handle, SERVICE_DATA_SUBJECT, &subject) == SERVICE_ERROR_NONE) && subject) {
260 msg_ui_composer_subject_set_loaded_data(cd, (const char *)subject);
263 if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, &attachment) == SERVICE_ERROR_NONE) && attachment) {
264 cd->attachlist = make_tokenize_list((const char *)attachment, COMPOSER_BUNDLE_ATTACH_TOKEN);
266 msg_ui_composer_body_items_add(cd);
272 static void __msgc_ui_parse_file_uri(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, const char *uri)
275 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
277 char *content = NULL;
278 char attachment[DEF_IMG_PATH_LEN + 1] = {0, };
281 char *scheme = g_strdup(uri);
284 strtok_r(scheme, ":", &content);
285 D_MSG("content = [%s]", content);
288 len = strlen(content) - 2;
290 D_EMSG("len is less than 0 !!");
295 /* Remove '//' from content string */
296 for (i = 0; i < len; i++) {
297 attachment[i] = content[i+2];
300 if (attachment[0] != '\0') {
301 D_MSG("APPSVC ATTACHMENT = [%s]", attachment);
302 cd->attachlist = make_tokenize_list((const char *)attachment, COMPOSER_BUNDLE_ATTACH_TOKEN);
304 msg_ui_composer_body_items_add(cd);
309 D_EMSG("scheme is NULL!!");
315 static void __msg_ui_parse_sms_uri(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, const char *uri)
318 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
320 char *content = NULL;
321 char *recipient = NULL;
322 char *body_text = NULL;
323 char *scheme = g_strdup(uri);
326 strtok_r(scheme, ":", &content);
329 if (g_ascii_isdigit(content[0]) || (content[0] == '+' && g_ascii_isdigit(content[1]))) {
330 recipient = strtok_r(NULL, "?", &content);
331 D_MSG("RECIPIENT = [%s]", recipient);
334 __msgc_parse_recipient_list(cd, (const char *)recipient);
339 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient) {
340 __msgc_parse_recipient_list(cd, (const char *)recipient);
344 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text) {
345 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
351 static void __msgc_get_service_app_svc_op(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, char *operation)
354 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
355 D_MSG_RETM_IF(svc_handle == NULL, "svc_handle is NULL");
356 D_MSG_RETM_IF(operation == NULL, "operation is NULL");
359 char *recipient = NULL;
360 char *body_text = NULL;
361 char *attachment = NULL;
362 char *subject = NULL;
364 if (g_strcmp0(operation, SERVICE_OPERATION_SEND) == 0) {
365 if (service_get_uri(svc_handle, &uri) == SERVICE_ERROR_NONE)
366 D_MSG("URI = [%s]", uri);
369 if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_MMSTO_URI)) { /* MMS URI : mmsto */
370 __msgc_ui_parse_mmsto_uri(cd, svc_handle, (const char *)uri);
371 } else if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_FILE_URI)) { /* URI : file */
372 __msgc_ui_parse_file_uri(cd, svc_handle, (const char *)uri);
374 D_MSG("Not supported mime type");
378 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient) {
379 __msgc_parse_recipient_list(cd, (const char *)recipient);
382 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text) {
383 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
386 if ((service_get_extra_data(svc_handle, SERVICE_DATA_SUBJECT, &subject) == SERVICE_ERROR_NONE) && subject) {
387 msg_ui_composer_subject_set_loaded_data(cd, (const char *)subject);
390 if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, &attachment) == SERVICE_ERROR_NONE) && attachment) {
391 cd->attachlist = make_tokenize_list((const char *)attachment, COMPOSER_BUNDLE_ATTACH_TOKEN);
393 msg_ui_composer_body_items_add(cd);
396 } else if (g_strcmp0(operation, SERVICE_OPERATION_SEND_TEXT) == 0) {
397 if (service_get_uri(svc_handle, &uri) == SERVICE_ERROR_NONE)
398 D_MSG("URI = [%s]", uri);
401 if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_SMS_URI)) { /* SMS URI : sms */
402 __msg_ui_parse_sms_uri(cd, svc_handle, (const char *)uri);
404 D_MSG("Not supported mime type");
408 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient) {
409 __msgc_parse_recipient_list(cd, (const char *)recipient);
412 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text) {
413 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
417 D_EMSG("Invalid operation type !!");
423 /* function definitions*/
424 static void __msg_ui_composer_bundle_data_process(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
427 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
428 D_MSG_RETM_IF(svc_handle == NULL, "Bundle Data is NULL");
430 char *bundle_txt = NULL;
432 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_FORWARD, &bundle_txt);
435 int msg_id = atoi(bundle_txt);
436 msg_ui_composer_message_init();
437 msg_ui_composer_message_load_message(cd->msg_handle, msg_id);
438 msg_ui_composer_message_set_loaded_data(cd);
439 msg_ui_composer_message_destroy();
441 char *operation = NULL;
442 if (service_get_operation(svc_handle, &operation) == SERVICE_ERROR_NONE && operation) { /* composer launching via service */
443 cd->isAppControl = true;
445 __msgc_get_service_app_svc_op(cd, svc_handle, operation);
447 } else { /* internal ug mode */
448 cd->isAppControl = false;
450 if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_TO, &bundle_txt) == SERVICE_ERROR_NONE) && bundle_txt) {
451 __msgc_parse_recipient_list(cd, bundle_txt);
453 if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_NUMBER_INDEX, &bundle_txt)== SERVICE_ERROR_NONE) && bundle_txt) {
459 char *copy_string = MSG_STRDUP(bundle_txt);
462 recipient = strtok_r(copy_string, "/", &save_p);
464 index = strtok_r(NULL, "/", &save_p);
466 D_MSG("NUMBER_INDEX = %s[%s]", recipient, index);
472 if (msg_ui_composer_recipient_count_get(cd->recipient) >= COMPOSER_RECIPIENT_COUNT_MAX) {
473 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
475 if (msg_ui_composer_recipient_duplicate_check(cd->recipient, recipient) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
476 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_DUP_RECP);
478 if (msg_ui_composer_recipient_vaild_check(recipient) == EINA_FALSE) {
479 msg_ui_composer_status_btn_popup_show(cd, MSGC_STR_NOTI_RECIPIENT_INVALID, 0, MSGC_STR_BUTTON_OK);
481 msg_ui_composer_recipient_append(cd->recipient, recipient, idx);
492 if (SERVICE_ERROR_NONE == service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_SUBJECT, &bundle_txt))
493 msg_ui_composer_subject_set_loaded_data(cd, bundle_txt);
495 if (SERVICE_ERROR_NONE == service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_BODY, &bundle_txt))
496 msg_ui_composer_body_set_loaded_text(cd, bundle_txt, 0);
498 if (SERVICE_ERROR_NONE == service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, &bundle_txt)) {
499 cd->attachlist = make_tokenize_list(bundle_txt, COMPOSER_BUNDLE_ATTACH_TOKEN);
501 msg_ui_composer_body_items_add(cd);
509 static void __msg_ui_composer_sent_status_cb(msg_handle_t Handle, msg_struct_t pStatus, void *pUserParam)
517 static void __end_popup_ok_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
520 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
521 D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
523 MSGC_EVAS_OBJECT_DEL(cd->popup_end);
525 ug_destroy_me(cd->ug);
528 static void __end_popup_cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
531 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
532 D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
534 MSGC_EVAS_OBJECT_DEL(cd->popup_end);
536 cd->isclosed = false;
538 msg_ui_composer_last_focus_load(cd);
542 static void __msg_ui_composer_end_popup(MSG_COMPOSER_VIEW_DATA_S *cd)
546 MSGC_EVAS_OBJECT_DEL(cd->popup_end);
548 Evas_Object *popup = msg_ui_composer_status_popup_show(cd, MSGC_STR_POP_DISCARD_Q, 0);
549 Evas_Object *btn1 = elm_button_add(popup);
550 elm_object_style_set(btn1, "popup_button/default");
551 elm_object_text_set(btn1, MSGC_STR_BUTTON_OK);
552 elm_object_part_content_set(popup, "button1", btn1);
553 evas_object_smart_callback_add(btn1, "clicked", __end_popup_ok_btn_clicked_cb, cd);
554 Evas_Object *btn2 = elm_button_add(popup);
555 elm_object_style_set(btn2, "popup_button/default");
556 elm_object_text_set(btn2, MSGC_STR_BUTTON_CANCEL);
557 elm_object_part_content_set(popup, "button2", btn2);
558 evas_object_smart_callback_add(btn2, "clicked", __end_popup_cancel_btn_clicked_cb, cd);
559 elm_object_focus_set(popup, EINA_TRUE);
560 evas_object_show(popup);
562 cd->popup_end = popup;
568 static void __naviframe_back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
571 D_MSG_RETM_IF(data == NULL, "Data == NULL");
572 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
574 COMPOSER_EDIT_STATE_E edit_state = __msg_ui_composer_edit_check(cd);
575 D_MSG("edit_state = %d", edit_state);
577 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
579 D_EMSG("back btn is already called");
583 /* isclosed is set to prevent showing invalid popup*/
586 if (edit_state == COMPOSER_EDIT_RECIPIENT || edit_state == COMPOSER_EDIT_BODY) {
587 __msg_ui_composer_end_popup(cd);
589 } else if (edit_state == COMPOSER_EDIT_RECIPIENT_AND_BODY) {
591 msg_ui_composer_message_init();
593 if (msg_ui_composer_get_message_data(cd) == COMPOSER_RETURN_SUCCESS) {
594 msg_ui_composer_save_message(cd->msg_handle);
596 /* show saved ticker popup */
597 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_AUTO_SAVED);
600 msg_ui_composer_message_destroy();
602 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
603 if (edit_state == COMPOSER_EDIT_RECIPIENT) {
605 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
607 if (bubble_data->bubble_count == 0) {
608 int err = MSG_SUCCESS;
610 if (bubble_data->isDraft == true)
611 err = msg_delete_thread_message_list(bubble_data->msgHandle, bubble_data->threadId);
613 if (err == MSG_SUCCESS) {
614 service_h svc_handle;
615 char buf[DEF_BUF_LEN_S] = {0,};
617 if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
618 D_EMSG("service_create() is failed !!");
620 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_RESULT, MSG_BUNDLE_VALUE_DEL_ALL);
621 snprintf(buf, sizeof(buf), "%d", bubble_data->threadId);
622 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, buf);
623 ug_send_result(cd->ug, svc_handle);
625 service_destroy(svc_handle);
628 D_MSG("msg_delete_thread_message_list failed");
631 /* delete draft message */
632 msg_struct_list_s msg_list;
634 if (msg_get_message_list(cd->msg_handle, MSG_DRAFT_ID, bubble_data->threadId, 0, 0, &msg_list) == MSG_SUCCESS) {
638 for (i= 0; i < msg_list.nCount; i++) {
639 msg_get_int_value(msg_list.msg_struct_info[i], MSG_MESSAGE_ID_INT, &msgid);
640 D_MSG("draft msg_id is %d", msgid);
641 if (msg_delete_message(cd->msg_handle, msgid) != COMPOSER_RETURN_SUCCESS)
642 D_EMSG("msg_ui_comp_core_delete_message is failed = %d", msgid);
645 msg_release_list_struct(&msg_list);
647 } else if (edit_state == COMPOSER_EDIT_RECIPIENT_AND_BODY) {
649 msg_ui_composer_message_init();
651 if (msg_ui_composer_get_message_data(cd) == COMPOSER_RETURN_SUCCESS) {
652 msg_ui_composer_save_message(cd->msg_handle);
653 /* show saved ticker popup */
654 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_AUTO_SAVED);
657 msg_ui_composer_message_destroy();
659 /* clear recipient_list of bubble composer */
660 msg_ui_composer_recipient_clear_recipient_list(cd);
664 ug_destroy_me(cd->ug);
669 static void __preview_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
672 MSG_COMPOSER_VIEW_DATA_S *cd = data;
673 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
674 D_MSG_RETM_IF(cd->navi_it == NULL, "Naviitem is NULL");
676 msg_struct_t msgInfo = NULL;
677 msg_ui_composer_message_init();
678 msg_ui_composer_read_preview_message(cd);
680 /* make preview message data */
681 msgInfo = msg_ui_composer_message_make_preview(cd->msg_handle);
684 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_MSGVIEWER, msgInfo);
686 msg_release_struct(&msgInfo);
687 msg_ui_composer_message_destroy();
689 elm_object_item_signal_emit(cd->navi_it, "elm,state,optionheader,close", "");
690 elm_object_signal_emit(cd->navi_title_layout, "elm,state,more,hide", "");
691 cd->navi_optionheader_opened = EINA_FALSE;
695 static void __pageduration_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
698 MSG_COMPOSER_VIEW_DATA_S *cd = data;
699 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
700 D_MSG_RETM_IF(cd->navi_it == NULL, "Naviitem is NULL");
702 msg_ui_composer_pageduration_popup_create(cd);
707 static Evas_Object *__toolbar_btn_create(Evas_Object *parent, char *text, char *style)
710 D_MSG_RETVM_IF(parent == NULL, NULL, "parent == NULL");
712 Evas_Object *button = elm_button_add(parent);
715 elm_object_style_set(button, style);
717 elm_object_style_set(button, "naviframe_control/default");
719 evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
720 evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
723 char *popup_msg = elm_entry_utf8_to_markup(text);
725 elm_object_text_set(button, popup_msg);
728 elm_object_text_set(button, text);
732 evas_object_show(button);
738 static Evas_Object *__toolbar_top_create(MSG_COMPOSER_VIEW_DATA_S *cd)
742 Evas_Object *toolbar = NULL;
744 toolbar = elm_toolbar_add(cd->navi_bar);
745 elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);
748 D_EMSG("toolbar is NULL");
752 elm_object_style_set(toolbar, "naviframe");
754 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
755 /* create delete button */
756 Evas_Object *delete_button = __toolbar_btn_create(toolbar, dgettext("sys_string", "IDS_COM_SK_DELETE"), NULL);
757 evas_object_smart_callback_add(delete_button, "clicked", msg_ui_bubble_option_header_delete_clicked_cb, cd);
759 cd->toolbar_btn[CONTROLBAR_ITEM_1] = delete_button;
760 cd->toolbar_item_top[CONTROLBAR_ITEM_1] = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, cd);
761 elm_object_item_part_content_set(cd->toolbar_item_top[CONTROLBAR_ITEM_1], "object", delete_button);
766 /* create preview button */
767 Evas_Object *preview_button = __toolbar_btn_create(toolbar, MSGC_STR_PREVIEW, NULL);
768 evas_object_smart_callback_add(preview_button, "clicked", __preview_btn_clicked_cb, cd);
769 cd->toolbar_btn[CONTROLBAR_ITEM_1+isBubble] = preview_button;
770 cd->toolbar_item_top[CONTROLBAR_ITEM_1+isBubble] = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, cd);
771 elm_object_item_part_content_set(cd->toolbar_item_top[CONTROLBAR_ITEM_1+isBubble], "object", preview_button);
773 /* create page duration button */
774 char buf[DEF_BUF_LEN_S + 1] = {0,};
775 int pageduration = msg_ui_composer_pageduration_value_get(cd);
776 snprintf(buf, sizeof(buf), _MSGSTR("IDS_MSGC_BUTTON2_DURATION_N_HPD_SECS"), pageduration);
778 Evas_Object *duration_button = __toolbar_btn_create(toolbar, buf, "naviframe_control/multiline");
779 evas_object_smart_callback_add(duration_button, "clicked", __pageduration_btn_clicked_cb, cd);
780 cd->toolbar_btn[CONTROLBAR_ITEM_2+isBubble] = duration_button;
781 cd->toolbar_item_top[CONTROLBAR_ITEM_2+isBubble] = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, cd);
782 elm_object_item_part_content_set(cd->toolbar_item_top[CONTROLBAR_ITEM_2+isBubble], "object", duration_button);
784 COMPOSER_MSG_TYPE_E checked_type = msg_ui_composer_check_message_type(cd);
785 if (checked_type == COMPOSER_MSG_TYPE_MMS) {
786 msg_ui_composer_toolbar_top_item_change(cd, false);
788 msg_ui_composer_toolbar_top_item_change(cd, true);
796 void msg_ui_composer_toolbar_top_update(MSG_COMPOSER_VIEW_DATA_S *cd)
799 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
801 /* update pageduration */
802 char buf[DEF_BUF_LEN_S + 1] = {0,};
803 int pageduration = 0;
805 char *markup_str = NULL;
807 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
810 pageduration = msg_ui_composer_pageduration_value_get(cd);
811 snprintf(buf, sizeof(buf), _MSGSTR("IDS_MSGC_BUTTON2_DURATION_N_HPD_SECS"), pageduration);
813 markup_str = elm_entry_utf8_to_markup(buf);
815 elm_object_text_set(cd->toolbar_btn[CONTROLBAR_ITEM_2+isBubble], markup_str);
818 elm_object_text_set(cd->toolbar_btn[CONTROLBAR_ITEM_2+isBubble], buf);
822 static void __naviframe_more_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
825 MSG_COMPOSER_VIEW_DATA_S *cd = data;
826 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
827 D_MSG_RETM_IF(cd->navi_it == NULL, "Navi item is NULL");
829 if (cd->navi_optionheader_opened) {
830 elm_object_item_signal_emit(cd->navi_it, "elm,state,optionheader,close", "");
831 elm_object_signal_emit(cd->navi_title_layout, "elm,state,more,hide", "");
833 Evas_Object *content = NULL;
835 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
836 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
838 if (bubble_data && bubble_data->title_optionheader_opened) {
839 elm_object_signal_emit(cd->navi_title_layout, "elm,state,title,hide", "");
840 if (bubble_data->title_genlist)
841 msg_ui_bubble_close_title_menu_genlist(bubble_data);
842 bubble_data->title_optionheader_opened = false;
846 content = elm_object_item_part_content_unset(cd->navi_it, "optionheader");
849 if (content != cd->toolbar_top) {
850 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
852 for (i = 0; i < MSG_BUBBLE_CONTROLBAR_ITEM_NUM; i++) {
853 if (bubble_data->toolbar_item[i]) {
854 elm_object_item_del(bubble_data->toolbar_item[i]);
855 bubble_data->toolbar_item[i] = NULL;
859 evas_object_del(content);
862 cd->toolbar_top = __toolbar_top_create(cd);
863 elm_object_item_part_content_set(cd->navi_it, "optionheader", cd->toolbar_top);
865 elm_object_item_signal_emit(cd->navi_it, "elm,state,optionheader,open", "");
866 elm_object_signal_emit(cd->navi_title_layout, "elm,state,more,show", "");
869 cd->navi_optionheader_opened = !cd->navi_optionheader_opened;
874 static Evas_Object *__naviframe_back_btn_create(Evas_Object *parent, void *data, bool title)
877 D_MSG_RETVM_IF(parent == NULL, NULL, "parent == NULL");
878 D_MSG_RETVM_IF(data == NULL, NULL, "data == NULL");
879 D_MSG("Title type = %d", title);
882 btn = elm_button_add(parent);
887 elm_object_style_set(btn, "naviframe/title/default");
888 elm_object_text_set(btn, MSGC_STR_BUTTON_CANCEL);
890 elm_object_style_set(btn, "naviframe/back_btn/default");
892 evas_object_smart_callback_add(btn, "clicked", __naviframe_back_btn_clicked_cb, data);
893 evas_object_show(btn);
898 static Evas_Object *__naviframe_more_btn_create(Evas_Object *parent, void *data)
901 D_MSG_RETVM_IF(parent == NULL, NULL, "parent == NULL");
902 D_MSG_RETVM_IF(data == NULL, NULL, "data == NULL");
904 Evas_Object *btn = elm_button_add(parent);
908 elm_object_style_set(btn, "naviframe/more/default");
909 elm_object_focus_allow_set(btn, EINA_FALSE);
911 evas_object_smart_callback_add(btn, "clicked", __naviframe_more_btn_clicked_cb, data);
912 evas_object_show(btn);
917 static char *__working_dir_create(void)
920 char *base_dir = "/tmp/message";
921 char working_path[DEF_PATH_MAX] = {0,};
925 if (ecore_file_exists(base_dir) == EINA_FALSE) {
926 if(ecore_file_mkdir(base_dir) == EINA_FALSE) {
934 bzero(working_path, DEF_PATH_MAX);
935 snprintf(working_path, sizeof(working_path)-1, "%s/composer_%d/", base_dir, i);
936 if (ecore_file_exists(working_path) == EINA_FALSE) {
937 if (ecore_file_mkdir(working_path) == EINA_FALSE) {
940 D_MSG("Success to create working path = %s", working_path);
941 return strdup(working_path);
951 void msg_ui_composer_reset_request(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
958 COMPOSER_EDIT_STATE_E edit_state = __msg_ui_composer_edit_check(cd);
959 D_MSG("edit_state = %d", edit_state);
961 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
962 if (edit_state == COMPOSER_EDIT_RECIPIENT_AND_BODY) {
964 msg_ui_composer_message_init();
966 if (msg_ui_composer_get_message_data(cd) == COMPOSER_RETURN_SUCCESS) {
967 msg_ui_composer_save_message(cd->msg_handle);
970 msg_ui_composer_message_destroy();
972 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
973 if (edit_state == COMPOSER_EDIT_RECIPIENT) {
974 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
976 if (bubble_data->bubble_count == 0) {
977 int err = MSG_SUCCESS;
979 if (bubble_data->isDraft == true)
980 err = msg_delete_thread_message_list(bubble_data->msgHandle, bubble_data->threadId);
982 if (err == MSG_SUCCESS) {
983 service_h svc_handle;
984 if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
985 D_EMSG("service_create() is failed !!");
987 char buf[DEF_BUF_LEN_S] = {0,};
988 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_RESULT, MSG_BUNDLE_VALUE_DEL_ALL);
989 snprintf(buf, sizeof(buf), "%d", bubble_data->threadId);
990 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, buf);
992 ug_send_result(cd->ug, svc_handle);
994 service_destroy(svc_handle);
997 D_MSG("msg_delete_thread_message_list failed");
1000 /* delete draft message */
1001 msg_struct_list_s msg_list;
1003 if (msg_get_message_list(cd->msg_handle, MSG_DRAFT_ID, bubble_data->threadId, 0, 0, &msg_list) == COMPOSER_RETURN_SUCCESS) {
1007 for (i= 0; i < msg_list.nCount; i++) {
1008 msg_get_int_value(msg_list.msg_struct_info[i], MSG_MESSAGE_ID_INT, &msgid);
1009 D_MSG("draft msg_id is %d", msgid);
1010 if (msg_delete_message(cd->msg_handle, msgid) != COMPOSER_RETURN_SUCCESS)
1011 D_EMSG("msg_ui_comp_core_delete_message is failed = %d", msgid);
1015 msg_release_list_struct(&msg_list);
1017 } else if (edit_state == COMPOSER_EDIT_RECIPIENT_AND_BODY) {
1019 msg_ui_composer_message_init();
1021 if (msg_ui_composer_get_message_data(cd) == COMPOSER_RETURN_SUCCESS) {
1022 msg_ui_composer_save_message(cd->msg_handle);
1025 msg_ui_composer_message_destroy();
1028 /* clear recipient_list of bubble composer */
1029 msg_ui_composer_recipient_clear_recipient_list(cd);
1033 msg_ui_composer_reset(cd, svc_handle);
1039 * 1. clear all composer editing obj
1040 * 2. make composer using bundle val
1042 COMPOSER_RETURN_TYPE_E msg_ui_composer_reset(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
1046 return COMPOSER_RETURN_FAIL;
1048 if (cd->working_path) {
1049 ecore_file_recursive_rm(cd->working_path);
1050 g_free(cd->working_path);
1053 cd->working_path = __working_dir_create();
1055 if (cd->working_path == NULL) {
1056 D_EMSG("[ASSERT] Fail of make working dir!!!");
1057 return COMPOSER_RETURN_FAIL;
1061 msg_ui_composer_clear(cd);
1062 /*Change to Bubble view*/
1063 char *thread_id = NULL;
1064 char *msg_id = NULL;
1065 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, &thread_id);
1066 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_MSG_ID, &msg_id);
1067 if (thread_id || msg_id) {
1068 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER) {
1069 D_MSG("chagne bubble view");
1070 msg_ui_composer_change_bubble_view(cd);
1071 msg_ui_bubble_parse_bubble_data(cd->bubble_data, svc_handle);
1072 msg_ui_bubble_start_view(cd->bubble_data);
1073 msg_ui_composer_navi_title_set((void *)cd);
1075 /* set recipient list for bubble composer */
1076 msg_ui_composer_recipient_set_recipient_list(cd, cd->bubble_data->threadId);
1078 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1079 D_MSG("reload bubble view");
1080 msg_ui_bubble_parse_bubble_data(cd->bubble_data, svc_handle);
1081 msg_ui_bubble_list_load(cd->bubble_data);
1082 msg_ui_composer_navi_title_set((void *)cd);
1084 /* set recipient list for bubble composer */
1085 msg_ui_composer_recipient_set_recipient_list(cd, cd->bubble_data->threadId);
1088 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1089 if (cd->bubble_data) {
1090 cd->bubble_data->ug_state = BUBBLE_UG_DESTROY;
1091 MSGC_EVAS_OBJECT_DEL(cd->bubble_data->toolbar);
1092 msg_ui_bubble_deinit_bubble_data(cd->bubble_data);
1093 cd->bubble_data = NULL;
1095 msg_ui_composer_change_composer_view(cd);
1097 __msg_ui_composer_bundle_data_process(cd, svc_handle);
1101 return COMPOSER_RETURN_SUCCESS;
1104 COMPOSER_RETURN_TYPE_E msg_ui_composer_start(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
1107 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer Data is NULL");
1109 COMPOSER_RETURN_TYPE_E ret;
1110 cd->state = COMPOSER_STATE_TYPE_RUNNING;
1112 /*bundle data parsing */
1114 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1116 __msg_ui_composer_bundle_data_process(cd, svc_handle);
1118 if (cd->attachlist == NULL)
1121 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1122 D_MSG("START BUBBLE COMPOSER");
1123 PMSG_BUBBLE_DATA bubble_data = (PMSG_BUBBLE_DATA)cd->bubble_data;
1124 msg_ui_bubble_parse_bubble_data(bubble_data, svc_handle);
1125 msg_ui_bubble_start_view(bubble_data);
1126 msg_ui_composer_navi_title_set((void *)cd);
1128 /* set recipient list for bubble composer */
1129 msg_ui_composer_recipient_set_recipient_list(cd, cd->bubble_data->threadId);
1134 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1135 if (!msg_ui_composer_popup_exist(cd)) {
1137 int recipient_count = msg_ui_composer_recipient_count_get(cd->recipient);
1139 if (recipient_count > 0)
1140 msg_ui_composer_body_focus_set(cd, 0);
1142 msg_ui_composer_recipient_focus_set(cd->recipient);
1150 COMPOSER_RETURN_TYPE_E msg_ui_composer_destroy(MSG_COMPOSER_VIEW_DATA_S *cd)
1154 COMPOSER_RETURN_TYPE_E ret = COMPOSER_RETURN_SUCCESS;
1156 return COMPOSER_RETURN_FAIL;
1158 D_PRINT("===== Composer UG Destroy Start =====");
1159 contacts_svc_disconnect();
1161 D_PRINT("----- Unregister vconf callback -----");
1162 if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, __msgc_vconf_changed_cb) < 0) {
1163 D_EMSG("Fail to unregister vconf CB with [%s]", VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE);
1165 if (vconf_ignore_key_changed(VCONFKEY_MSG_APP_FONT_SIZE, __msgc_vconf_changed_cb) < 0) {
1166 D_EMSG("Fail to unregister vconf CB with [%s]", VCONFKEY_MSG_APP_FONT_SIZE);
1169 if(cd->job_thread_end) {
1170 D_PRINT("----- Job Delete -----");
1171 ecore_job_del(cd->job_thread_end);
1172 cd->job_thread_end = NULL;
1175 if(cd->attach_thread) {
1176 D_PRINT("----- Thread Delete -----");
1177 ecore_thread_cancel(cd->attach_thread);
1178 cd->attach_thread = NULL;
1181 if (cd->last_focus_idler) {
1182 D_PRINT("----- idler Delete -----");
1183 ecore_idler_del(cd->last_focus_idler);
1184 cd->last_focus_idler = NULL;
1187 if (cd->popup_conform) {
1188 evas_object_del(cd->popup_conform);
1189 cd->popup_conform = NULL;
1192 if (cd->recipient) {
1193 D_PRINT("----- Recipient Delete -----");
1194 msg_ui_composer_recipient_delete(cd->recipient);
1195 cd->recipient = NULL;
1198 D_PRINT("----- Recipient list Clear -----");
1199 msg_ui_composer_recipient_clear_recipient_list(cd);
1201 D_PRINT("----- Predict Search Delete -----");
1202 msg_ui_composer_predictsearch_list_delete(cd);
1204 D_PRINT("----- Body Delete -----");
1205 msg_ui_composer_body_delete(cd);
1207 D_PRINT("----- Close Msg Handle -----");
1208 msg_close_msg_handle(&cd->msg_handle);
1210 D_PRINT("----- Delete Popup -----");
1211 msg_ui_composer_popup_delete_all(cd);
1213 if (cd->working_path) {
1214 ecore_file_recursive_rm(cd->working_path);
1215 g_free(cd->working_path);
1216 cd->working_path = NULL;
1220 elm_theme_extension_del(cd->th, MSG_CUSTOM_WINSET_EDJ);
1221 elm_theme_free(cd->th);
1224 msg_common_reset_font_size("entry");
1226 D_PRINT("===== Composer UG Destroy End =====");
1232 COMPOSER_RETURN_TYPE_E msg_ui_composer_rotate(MSG_COMPOSER_VIEW_DATA_S *cd, COMPOSER_ROTATE_TYPE_E rotate)
1235 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer Data == NULL");
1237 cd->rotate = rotate;
1238 D_MSG("rotate val [%d]", rotate);
1240 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1242 RECIPIENT_S *r = cd->recipient;
1243 if (!r) return COMPOSER_RETURN_FAIL;
1245 if (rotate == COMPOSER_ROTATE_PORTRAIT || rotate == COMPOSER_ROTATE_PORTRAIT_UPSIDEDOWN) {
1246 elm_layout_theme_set(cd->base, "layout", "application", "default");
1248 elm_box_horizontal_set(r->bx_main, EINA_FALSE);
1249 elm_scroller_content_min_limit(r->sc, EINA_FALSE, EINA_TRUE);
1250 evas_object_size_hint_max_set(r->sc, 9999, COMPOSER_RECIPIENT_PORTRAIT_HEIGHT_MAX);
1252 elm_layout_theme_set(cd->base, "layout", "application", "noindicator");/*hide indicator in Landscape*/
1254 elm_box_horizontal_set(r->bx_main, EINA_TRUE);
1255 elm_scroller_content_min_limit(r->sc, EINA_FALSE, EINA_FALSE);
1256 evas_object_size_hint_max_set(r->sc, 9999, -1);
1259 /* change body scroller size */
1260 msg_ui_composer_change_body_scroll_size(cd, 0);
1262 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1263 if (rotate == COMPOSER_ROTATE_PORTRAIT || rotate == COMPOSER_ROTATE_PORTRAIT_UPSIDEDOWN) {
1264 if (cd->bubble_data)
1265 cd->bubble_data->isRotate = false;
1267 if (cd->bubble_data)
1268 cd->bubble_data->isRotate = true;
1271 /* change body scroller size */
1272 msg_ui_composer_change_body_scroll_size(cd, 0);
1275 D_EMSG("Unknown Composer Mode");
1276 return COMPOSER_RETURN_FAIL;
1280 return COMPOSER_RETURN_SUCCESS;
1283 COMPOSER_RETURN_TYPE_E msg_ui_composer_init(MSG_COMPOSER_VIEW_DATA_S *cd)
1288 D_EMSG("[ASSERT] pcmop_data is NULL");
1289 return COMPOSER_RETURN_FAIL;
1292 /* create message handle */
1293 if (msg_open_msg_handle(&cd->msg_handle) != MSG_SUCCESS) {
1294 D_EMSG("[ASSERT] msg-server doesn't response !!!");
1295 return COMPOSER_RETURN_FAIL;
1298 /* set message sent status callback */
1299 if (msg_reg_sent_status_callback(cd->msg_handle, &__msg_ui_composer_sent_status_cb, cd) != MSG_SUCCESS) {
1300 D_EMSG("[ASSERT] sent status callback register error!!!");
1301 return COMPOSER_RETURN_FAIL;
1304 /* connect contacts svc*/
1305 if (contacts_svc_connect() != 0) {
1306 D_EMSG("[ASSERT] Fail of contacts_svc_connect !!!");
1307 return COMPOSER_RETURN_FAIL;
1310 cd->working_path = __working_dir_create();
1311 if (cd->working_path == NULL) {
1312 D_EMSG("[ASSERT] Fail of make working dir!!!");
1313 return COMPOSER_RETURN_FAIL;
1316 /* set default message type is SMS */
1317 cd->msg_type = COMPOSER_MSG_TYPE_SMS;
1319 if(cd->mms_max_size == 0) {
1320 msg_struct_t setting = msg_create_struct(MSG_STRUCT_SETTING_MSGSIZE_OPT);
1322 if (msg_get_msgsize_opt(cd->msg_handle, setting) != MSG_SUCCESS) {
1323 D_EMSG("Getting MMS MAX SIZE ERROR");
1326 msg_get_int_value(setting, MSG_MESSAGE_SIZE_INT, &cd->mms_max_size);
1328 D_MSG("[DEBUG] msg max size = [%d KB] !!!", cd->mms_max_size);
1330 cd->mms_max_size = cd->mms_max_size * 1024;
1332 msg_release_struct(&setting);
1335 /* set default font size*/
1336 __msgc_init_font_size(cd);
1338 /* register vconf callback function */
1339 if (vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, __msgc_vconf_changed_cb, cd) < 0) {
1340 D_EMSG("Fail to register vconf CB with [%s]", VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE);
1342 if (vconf_notify_key_changed(VCONFKEY_MSG_APP_FONT_SIZE, __msgc_vconf_changed_cb, cd) < 0) {
1343 D_EMSG("Fail to register vconf CB with [%s]", VCONFKEY_MSG_APP_FONT_SIZE);
1346 cd->th = elm_theme_new();
1347 elm_theme_ref_set(cd->th, NULL);
1348 elm_theme_extension_add(cd->th, MSG_CUSTOM_WINSET_EDJ);
1350 return COMPOSER_RETURN_SUCCESS;
1354 * Create Composer First View
1356 COMPOSER_RETURN_TYPE_E msg_ui_composer_create(MSG_COMPOSER_VIEW_DATA_S *cd)
1359 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1360 D_MSG_RETVM_IF(cd->main_window == NULL, COMPOSER_RETURN_FAIL, "main_window is NULL");
1361 D_MSG_RETVM_IF(cd->base == NULL, COMPOSER_RETURN_FAIL, "base layout is NULL");
1363 Evas_Object *navi_frame = NULL;
1364 Evas_Object *more_button = NULL;
1365 Evas_Object *content_layout = NULL;
1366 Elm_Object_Item *navi_it = NULL;
1367 Evas_Object *conform = NULL;
1368 Evas_Object *back_btn = NULL;
1371 cd->state = COMPOSER_STATE_TYPE_CREATE;
1373 /* Create naviframe */
1374 navi_frame = elm_naviframe_add(cd->base);
1376 D_EMSG("naviframe add fail");
1380 evas_object_show(navi_frame);
1381 cd->navi_bar = navi_frame;
1383 /* Create content layout */
1384 content_layout = elm_layout_add(navi_frame);
1385 if (!content_layout) {
1386 D_EMSG("layout add fail");
1390 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1391 elm_layout_file_set(content_layout, MSGC_UI_DEFAULT_EDJ, MSGC_EDJ_GRP_CONTENT_LAYOUT);
1392 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER){
1393 elm_layout_file_set(content_layout, MSGC_UI_DEFAULT_EDJ, MSGC_EDJ_GRP_CONTENT_LAYOUT);
1394 edje_object_signal_emit(_EDJ(content_layout), "change.bubble", "*");
1396 D_EMSG("UG mode Unknown");
1400 evas_object_size_hint_weight_set(content_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1401 evas_object_size_hint_align_set(content_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1402 edje_object_signal_emit(_EDJ(content_layout), "hide.predictsearch", "*");
1403 evas_object_show(content_layout);
1405 cd->content_layout = content_layout;
1407 /*Create conformant */
1408 conform = msg_ui_composer_conformant_create(cd->main_window, content_layout);
1410 D_EMSG("Fail to create conformant");
1414 cd->conform = conform;
1417 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1418 cd->recipient = msg_ui_composer_recipient_create(content_layout, 1, cd);
1419 if (cd->recipient == NULL)
1422 elm_object_part_content_set(content_layout, "swl.recipient", cd->recipient->bx_main);
1424 Evas_Object *predict_search_layout = msg_ui_composer_predictsearch_list_create(content_layout, cd);
1425 elm_object_part_content_set(content_layout, "swl.predictsearch", predict_search_layout);
1428 PMSG_BUBBLE_DATA bubble_data = msg_ui_bubble_init_bubble_data(cd->msg_handle, cd);
1433 cd->bubble_data = bubble_data;
1435 Evas_Object *bubble_layout = msg_ui_bubble_create_view(content_layout, cd->bubble_data);
1436 if (!bubble_layout) {
1439 elm_object_part_content_set(content_layout, "swl.bubble.content", bubble_layout);
1442 Evas_Object *body_layout = msg_ui_composer_body_create(cd, content_layout);
1447 elm_object_part_content_set(content_layout, "swl.composer.body", body_layout);
1449 cd->ly_body = body_layout;
1451 /*Push content to navi frame*/
1452 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1453 if (cd->isMsgInternal)
1454 back_btn = __naviframe_back_btn_create(navi_frame, (void *)cd, false);
1456 back_btn = __naviframe_back_btn_create(navi_frame, (void *)cd, true);
1458 back_btn = __naviframe_back_btn_create(navi_frame, (void *)cd, false);
1461 navi_it = elm_naviframe_item_push(navi_frame, NULL, NULL, NULL, conform, "empty");
1463 cd->navi_it = navi_it;
1464 cd->back_btn = back_btn;
1466 /* create navi title layout */
1467 cd->navi_title_layout = msg_ui_composer_create_navi_title_bar(cd);
1468 msg_ui_composer_navi_title_set(cd);
1469 elm_object_item_part_content_set(cd->navi_it, "title", cd->navi_title_layout);
1471 /*Create more button*/
1472 more_button = __naviframe_more_btn_create(navi_frame, cd);
1474 elm_object_part_content_set(cd->navi_title_layout, "more_btn", more_button);
1475 elm_object_part_content_set(cd->navi_title_layout, "prev_btn", back_btn);
1477 cd->more_btn = more_button;
1479 /* set navibar to main layout (base) */
1480 elm_object_part_content_set(cd->base, "elm.swallow.content", navi_frame);
1483 return COMPOSER_RETURN_SUCCESS;
1486 return COMPOSER_RETURN_FAIL;
1489 COMPOSER_RETURN_TYPE_E msg_ui_composer_bubble_data_set(MSG_COMPOSER_VIEW_DATA_S *cd, int thread_id)
1492 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1493 D_MSG_RETVM_IF(cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER, COMPOSER_RETURN_FAIL, "msg_ug_mode is NOT BUBBLE TYPE");
1494 D_MSG_RETVM_IF(thread_id <= 0, COMPOSER_RETURN_FAIL, "Composer mode is Not Full");
1495 D_MSG_RETVM_IF(cd->bubble_data == NULL, COMPOSER_RETURN_FAIL, "bubble data is NULL");
1497 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
1498 msg_struct_t threadInfo = NULL;
1501 /*Create bubble list*/
1502 bubble_data->threadId = thread_id;
1503 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "Thread ID = %d", bubble_data->threadId);
1505 msg_struct_list_s addrList;
1507 memset(&addrList, 0x00, sizeof(msg_struct_list_s));
1509 err = msg_get_address_list(bubble_data->msgHandle, bubble_data->threadId, &addrList);
1511 if (err == MSG_SUCCESS) {
1512 bubble_data->addr_list.addr_cnt = addrList.nCount;
1514 for (i = 0; i<addrList.nCount; i++) {
1516 msg_get_int_value(addrList.msg_struct_info[i], MSG_ADDRESS_INFO_CONTACT_ID_INT, &contact_id);
1518 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);
1520 /** contact ID & display name */
1521 if (contact_id > 0) {
1522 bubble_data->addr_list.addr_info[i].contact_id = contact_id;
1523 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);
1525 bubble_data->addr_list.addr_info[i].contact_id = 0;
1529 msg_release_list_struct(&addrList);
1531 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[ERROR] msg_get_address_list returns error [%d]", err);
1534 threadInfo = msg_create_struct(MSG_STRUCT_THREAD_INFO);
1535 err = msg_get_thread(bubble_data->msgHandle, bubble_data->threadId, threadInfo);
1537 if (err == MSG_SUCCESS)
1538 msg_get_str_value(threadInfo, MSG_THREAD_NAME_STR, bubble_data->threadName, DEF_THREAD_NAME_LEN);
1540 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[ERROR] msg_get_trhead returns error [%d", err);
1542 msg_release_struct(&threadInfo);
1544 return COMPOSER_RETURN_SUCCESS;
1547 COMPOSER_RETURN_TYPE_E msg_ui_composer_change_composer_view(MSG_COMPOSER_VIEW_DATA_S *cd)
1550 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1551 D_MSG_RETVM_IF(cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER, COMPOSER_RETURN_FAIL, "Composer mode is Not Full");
1554 cd->msg_ug_mode = MSG_UG_MODE_ONLY_COMPOSER;
1556 /*Change content layout to composer layout*/
1557 edje_object_signal_emit(_EDJ(cd->content_layout), "change.composer", "*");
1559 elm_scroller_content_min_limit(cd->body_scroll, 0, 0);
1561 cd->recipient = msg_ui_composer_recipient_create(cd->content_layout, 1, cd);
1562 elm_object_part_content_set(cd->content_layout, "swl.recipient", cd->recipient->bx_main);
1564 Evas_Object *predict_search_layout = msg_ui_composer_predictsearch_list_create(cd->content_layout, cd);
1565 elm_object_part_content_set(cd->content_layout, "swl.predictsearch", predict_search_layout);
1567 MSGC_EVAS_OBJECT_DEL(cd->back_btn);
1569 Evas_Object *back_btn = __naviframe_back_btn_create(cd->navi_bar, (void *)cd, true);
1570 elm_object_item_part_content_set(cd->navi_it, "title_right_btn", back_btn);
1571 cd->back_btn = back_btn;
1573 elm_object_item_text_set(cd->navi_it, MSGC_STR_NEW_MESSAGE);
1575 return COMPOSER_RETURN_SUCCESS;
1578 COMPOSER_RETURN_TYPE_E msg_ui_composer_change_bubble_view(MSG_COMPOSER_VIEW_DATA_S *cd)
1581 D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1582 D_MSG_RETVM_IF(cd->msg_ug_mode != MSG_UG_MODE_FULL_COMPOSER, COMPOSER_RETURN_FAIL, "Composer mode is Not Full");
1585 cd->msg_ug_mode = MSG_UG_MODE_BUBBLE_COMPOSER;
1587 /*Change content layout to bubble layout*/
1588 edje_object_signal_emit(_EDJ(cd->content_layout), "hide.predictsearch", "*");
1589 edje_object_signal_emit(_EDJ(cd->content_layout), "change.bubble", "*");
1591 elm_scroller_content_min_limit(cd->body_scroll, 0, 1);
1592 evas_object_size_hint_max_set(cd->body_scroll, 9999, 250);
1594 /*Init bubble data*/
1595 PMSG_BUBBLE_DATA bubble_data = msg_ui_bubble_init_bubble_data(cd->msg_handle, cd);
1597 return COMPOSER_RETURN_FAIL;
1599 cd->bubble_data = (void *)bubble_data;
1601 /*Change naviframe layout for bubble*/
1602 Evas_Object *cancel_btn = __naviframe_back_btn_create(cd->navi_bar, (void *)cd, false);
1603 elm_object_part_content_set(cd->navi_title_layout, "prev_btn", cancel_btn);
1604 cd->back_btn = cancel_btn;
1606 Evas_Object *layout = msg_ui_bubble_create_view(cd->content_layout, cd->bubble_data); // First parameter should be 'content_layout'.
1607 elm_object_part_content_set(cd->content_layout, "swl.bubble.content", layout);
1609 /*remove unused layout*/
1610 MSGC_EVAS_OBJECT_DEL(cd->ly_recipient);
1611 msg_ui_composer_recipient_delete(cd->recipient);
1612 cd->recipient = NULL;
1614 msg_ui_composer_predictsearch_list_delete(cd);
1616 return COMPOSER_RETURN_SUCCESS;
1620 * msg_ui_composer_editable_set
1621 * editable == FALSE : hide body content & disable more button & close option header
1622 * editable == TRUE : show body content layout
1624 void msg_ui_composer_editable_set(MSG_COMPOSER_VIEW_DATA_S *cd, Eina_Bool editable)
1627 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
1629 if (editable == EINA_FALSE){
1630 Evas_Object *body_layout = elm_object_part_content_unset(cd->content_layout, "swl.composer.body");
1631 evas_object_hide(body_layout);
1634 elm_object_disabled_set(cd->more_btn, EINA_TRUE);
1637 elm_object_item_signal_emit(cd->navi_it, "elm,state,optionheader,close", "");
1638 elm_object_signal_emit(cd->navi_title_layout, "elm,state,more,hide", "");
1639 elm_object_signal_emit(cd->navi_title_layout, "elm,state,title,hide", "");
1640 cd->navi_optionheader_opened = EINA_FALSE;
1644 elm_object_part_content_set(cd->content_layout, "swl.composer.body", cd->ly_body);
1645 evas_object_show(cd->ly_body);
1648 elm_object_disabled_set(cd->more_btn, EINA_FALSE);
1655 void msg_ui_composer_bubble_del_all(void *data, service_h svc_handle)
1659 MSG_COMPOSER_VIEW_DATA_S *cd = data;
1660 D_MSG_RETM_IF(cd == NULL, "Composer data is NULL");
1662 ug_send_result(cd->ug, svc_handle);
1665 void msg_ui_composer_toolbar_top_item_change(MSG_COMPOSER_VIEW_DATA_S *cd, bool smstype)
1668 D_MSG_RETM_IF(cd == NULL, "Composer data is NULL");
1672 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1675 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
1676 if (bubble_data->bubble_count <= 0) {
1677 elm_object_item_disabled_set(cd->toolbar_item_top[CONTROLBAR_ITEM_1], EINA_TRUE);
1678 elm_object_focus_allow_set(cd->toolbar_btn[CONTROLBAR_ITEM_1], EINA_FALSE);
1679 elm_object_disabled_set(cd->toolbar_btn[CONTROLBAR_ITEM_1], EINA_TRUE);
1683 if (smstype == true) {
1684 if (cd->toolbar_item_top[CONTROLBAR_ITEM_1]) {
1685 elm_object_item_disabled_set(cd->toolbar_item_top[CONTROLBAR_ITEM_1+isBubble], EINA_TRUE);
1686 elm_object_focus_allow_set(cd->toolbar_btn[CONTROLBAR_ITEM_1+isBubble], EINA_FALSE);
1687 elm_object_disabled_set(cd->toolbar_btn[CONTROLBAR_ITEM_1+isBubble], EINA_TRUE);
1689 elm_object_item_disabled_set(cd->toolbar_item_top[CONTROLBAR_ITEM_2+isBubble], EINA_TRUE);
1690 elm_object_focus_allow_set(cd->toolbar_btn[CONTROLBAR_ITEM_2+isBubble], EINA_FALSE);
1691 elm_object_disabled_set(cd->toolbar_btn[CONTROLBAR_ITEM_2+isBubble], EINA_TRUE);
1694 if (cd->toolbar_item_top[CONTROLBAR_ITEM_1]) {
1695 elm_object_item_disabled_set(cd->toolbar_item_top[CONTROLBAR_ITEM_1+isBubble], EINA_FALSE);
1696 elm_object_focus_allow_set(cd->toolbar_btn[CONTROLBAR_ITEM_1+isBubble], EINA_TRUE);
1697 elm_object_disabled_set(cd->toolbar_btn[CONTROLBAR_ITEM_1+isBubble], EINA_FALSE);
1699 elm_object_item_disabled_set(cd->toolbar_item_top[CONTROLBAR_ITEM_2+isBubble], EINA_FALSE);
1700 elm_object_focus_allow_set(cd->toolbar_btn[CONTROLBAR_ITEM_2+isBubble], EINA_TRUE);
1701 elm_object_disabled_set(cd->toolbar_btn[CONTROLBAR_ITEM_2+isBubble], EINA_FALSE);
1707 Evas_Object *msg_ui_composer_create_navi_title_bar(void *data)
1712 D_EMSG("[ERROR] data is NULL");
1716 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1718 Evas_Object *title_layout = elm_layout_add(cd->navi_bar);
1719 elm_layout_file_set(title_layout, MSG_COMMON_EDJ, "title");
1720 evas_object_size_hint_weight_set(title_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1721 evas_object_size_hint_align_set(title_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1722 evas_object_show(title_layout);
1724 return title_layout;
1727 void msg_ui_composer_navi_title_set(void *data)
1732 D_EMSG("data is NULL");
1736 MSG_COMPOSER_VIEW_DATA_S *cd = data;
1737 PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
1739 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1740 elm_object_part_text_set(cd->navi_title_layout, "title_text", MSGC_STR_NEW_MESSAGE);
1741 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER){
1742 Evas_Object *title_button = NULL;
1744 elm_object_part_text_set(cd->navi_title_layout, "title_text", ""); // text part clear first
1746 title_button = elm_button_add(cd->navi_bar);
1748 elm_object_theme_set(title_button, cd->th);
1749 elm_object_style_set(title_button, "title_button");
1751 evas_object_size_hint_weight_set(title_button, 0.0, 0.0);
1752 evas_object_size_hint_align_set(title_button, EVAS_HINT_FILL, EVAS_HINT_FILL);
1754 if (bubble_data->addr_list.addr_cnt == 1) {
1755 if (bubble_data->addr_list.addr_info[0].contact_id > 0 && bubble_data->addr_list.addr_info[0].name[0] != '\0')
1756 elm_object_text_set(title_button, bubble_data->addr_list.addr_info[0].name);
1758 elm_object_text_set(title_button, bubble_data->addr_list.addr_info[0].address);
1759 } else if (bubble_data->addr_list.addr_cnt > 1) {
1760 char title_text[DEF_BUF_LEN+1] = {0,};
1762 if (bubble_data->addr_list.addr_info[0].contact_id > 0 && bubble_data->addr_list.addr_info[0].name[0] != '\0')
1763 snprintf(title_text, sizeof(title_text), "%s +%d", bubble_data->addr_list.addr_info[0].name, bubble_data->addr_list.addr_cnt-1);
1765 snprintf(title_text, sizeof(title_text), "%s +%d", bubble_data->addr_list.addr_info[0].address, bubble_data->addr_list.addr_cnt-1);
1767 elm_object_text_set(title_button, title_text);
1769 elm_object_text_set(title_button, dgettext("sys_string", "IDS_COM_BODY_UNKNOWN"));
1772 evas_object_show(title_button);
1773 elm_object_part_content_set(cd->navi_title_layout, "title_btn", title_button);
1774 evas_object_smart_callback_add(title_button, "clicked", msg_ui_bubble_title_button_clicked_cb, cd);
1776 bubble_data->title_button = title_button;
1778 D_EMSG("Invalid msg_ui_mode [%d]", cd->msg_ug_mode);