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.
18 #include <glib/gprintf.h>
21 #include <appcore-common.h>
27 #include "email-composer.h"
28 #include "email-composer-recipient.h"
29 #include "email-composer-util.h"
30 #include "email-composer-predictive-search.h"
31 #include "email-composer-attachment.h"
32 #include "email-composer-callback.h"
33 #include "email-composer-js.h"
34 #include "email-composer-contents.h"
36 #include "email-engine.h"
37 #include "email-utils.h"
39 #define DIV_TAG_START_ORIGIN_INFO "<div id=\"origin_info\">"
40 #define DIV_TAG_START_ORIGIN_CONTENT "<div id=\"origin_content\">"
41 #define DIV_TAG_END "</div>"
43 #define DIVIDE_LEFT_LINE_FOR_HTML "<br><br><b>--------------- "
44 #define DIVIDE_RIGHT_LINE_FOR_HTML " ---------------</b><br>\n"
45 #define ADDED_TEXT "<b>%s:</b> %s<br>\n"
46 #define BODY_TAG_START "<body>\n"
47 #define BODY_TAG_END "</body>\n"
48 #define HTML_TAG_END "</html>\n"
50 #define DIVIDE_LINE "\n\n-----------------------------------\n"
52 #define DEFAULT_SIGNATURE _("IDS_EMAIL_BODY_SENT_USING_TIZEN_MOBILE")
54 #define HTML_META_INFORMATION \
55 "<html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi\" /></head>\n"
58 static void _composer_save_draft_response_cb(void *data, Evas_Object *obj, void *event_info);
59 static void _composer_save_draft_fail_response_cb(void *data, Evas_Object *obj, void *event_info);
60 static void _composer_attachment_popup_response_cb(void *data, Evas_Object *obj, void *event_info);
61 static void _composer_dn_prog_popup_response_cb(void *data, Evas_Object *obj, void *event_info);
63 extern void _composer_free_initial_email_content(EmailComposerUGD *ugd);
65 void _composer_make_html_body(EmailComposerUGD *ugd);
67 extern char *icu_locale;
68 extern enum appcore_time_format icu_timeformat;
70 const gchar *email_composer_get_html_tag(const gchar char_val)
72 const gchar *tag = NULL;
92 gchar *email_composer_get_parse_string(const gchar *text, gint size)
95 RETURN_VAL_IF_FAIL(STR_VALID(text), NULL);
101 guint old_offset = 0, offset = 0;
103 for (i = 0; i < size; ++i) {
105 const gchar *tag = email_composer_get_html_tag(text[i]);
107 /* If need, convert text to html format. */
111 if (i > old_offset) {
112 offset = i - old_offset;
113 buff = g_strndup(&text[old_offset], offset);
115 html = g_strconcat(temp, buff, tag, NULL);
117 html = g_strconcat(buff, tag, NULL);
126 html = g_strconcat(temp, tag, NULL);
128 html = g_strconcat(tag, NULL);
141 /* If not terminated. */
142 if (old_offset < size) {
145 buff = g_strndup(&text[old_offset], size - old_offset);
146 html = g_strconcat(temp, buff, NULL);
154 return html ? html : g_strndup(text, size);
158 The following API splits a given filepath string into 'directory path' or 'filename'
160 char *email_composer_parse_filepath(const char *path, Eina_Bool directorypathORfilename)
163 RETURN_VAL_IF_FAIL(STR_VALID(path), NULL);
165 char *file_path = NULL;
167 int size = STR_LEN((char *)path);
169 for (i = (size - 1); i >= 0; --i) {
170 if (path[i] == '/') {
171 if (directorypathORfilename) {
172 file_path = g_strndup(path, i + 1); /* directory path is copied. */
174 file_path = g_strndup(path + i + 1, size - i + 1); /* filename is copied. */
182 char *email_composer_parse_get_filepath_from_path(const char *path)
184 RETURN_VAL_IF_FAIL(STR_VALID(path), NULL);
186 char *file_path = NULL;
188 int size = STR_LEN((char *)path);
190 for (i = (size - 1); i >= 0; --i) {
191 if (path[i] == '/') {
192 file_path = g_strndup(path, i + 1);
199 char *_composer_get_file_ext(const char *a_pszfile_name)
201 if (a_pszfile_name != NULL) {
202 int nlen = strlen(a_pszfile_name);
203 char *psztemp = (char *)a_pszfile_name + nlen;
207 if (*psztemp == '.') {
218 int _composer_copy_temp_file(const char *src_file_path, char *dst_file_path, int size_dst_file_path)
221 const char *filename = NULL;
222 char temp_file_path[MAX_PATH_LEN] = { 0, };
225 if (ecore_file_exists(src_file_path) == EINA_FALSE) {
229 filename = ecore_file_file_get(src_file_path);
230 debug_log("filename:%s", filename);
233 snprintf(temp_file_path, sizeof(temp_file_path) - 1, "%s/%s", EMAIL_TMP_FOLDER, filename);
235 while (ecore_file_exists(temp_file_path)) {
236 bzero(temp_file_path, sizeof(temp_file_path));
237 snprintf(temp_file_path, sizeof(temp_file_path) - 1, "%s/%d_%s", EMAIL_TMP_FOLDER, i, filename);
244 if (ecore_file_cp(src_file_path, temp_file_path) == EINA_FALSE) {
245 debug_log("temp_file_path = %s", temp_file_path);
249 strncpy(dst_file_path, temp_file_path, size_dst_file_path);
250 debug_log("copy file from %s to %s", src_file_path, dst_file_path);
260 * Changes inline images path from absolute to relative, in a given html content.
262 * @param [in] src_html_content string buffer contains html file content
263 * @param [out] dest_buffer string buffer to hold the processed html content
265 * @return true or false
268 Eina_Bool email_composer_change_image_paths_to_relative(char *src_html_content, char **dest_buffer)
272 if (src_html_content == NULL || dest_buffer == NULL) {
273 debug_log("NULL arguments passed");
279 char *src_str = src_html_content;
280 char *buffer = (char *)calloc(1, strlen(src_str) + 1);
281 if (buffer == NULL) {
282 debug_log("Memory allocation(calloc) failed.");
289 Eina_Bool success_flag = EINA_TRUE;
291 /* Ex. <img src="/opt/media/Images/image5.jpg" width=342 height="192" id="/opt/media/Images/image5.jpg"> */
292 while ((point1 = strstr(src_str, "<img")) || (point1 = strstr(src_str, "<IMG"))) {
294 if (!(temp = strstr(point1, "src=")) && !(temp = strstr(point1, "SRC="))) {
295 debug_log("1. No src=");
296 success_flag = EINA_FALSE;
301 if (point1 == NULL) {
302 debug_log("2. No file path");
303 success_flag = EINA_FALSE;
307 strncat(buffer, src_str, point1 - src_str);
309 debug_log("point1[0] = %c", point1[0]);
311 if (point1[0] == '/') {
313 point2 = strstr(point1, "\"");
314 if (point2 == NULL) {
315 debug_log("3. No end quotation");
316 success_flag = EINA_FALSE;
319 char *image_path = g_strndup(point1, point2 - point1);
320 debug_log("image_path : %s", image_path);
321 char *file_path = email_composer_parse_filepath(image_path, EINA_FALSE);
324 debug_log("file_path : %s", file_path);
325 if (file_path == NULL) {
326 debug_log("4. Could not parse inline image path");
327 success_flag = EINA_FALSE;
330 strncat(buffer, file_path, strlen(file_path));
337 if (success_flag == EINA_FALSE) {
343 strncat(buffer, src_str, strlen(src_str));
344 *dest_buffer = buffer;
349 Eina_Bool email_composer_save_file(const gchar *path, const gchar *buf, gsize len)
351 debug_log("path (%s)", path);
353 Eina_Bool success_flag = EINA_TRUE;
355 if (STR_LEN((gchar *)buf) > 0 && len > 0) {
356 int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
358 ssize_t nwrite = write(fd, (const void *)buf, (size_t) len);
359 debug_log("nwrite(%d)", nwrite);
361 debug_log("fail to write");
362 success_flag = EINA_FALSE;
367 debug_log("fail to open");
368 success_flag = EINA_FALSE;
371 debug_log("check the buf!!");
372 success_flag = EINA_FALSE;
378 Eina_List *email_composer_change_str_to_EinaList(EmailComposerUGD *ugd, const char *str, char *token)
382 Eina_List *list = NULL;
384 char tmp_file_path[MAX_PATH_LEN + 1] = { 0, };
385 char *file_ext = NULL;
387 debug_log("str = %s", str);
388 debug_log("token = %s", token);
390 p = strtok((char *)str, token);
393 debug_log("p = %s", p);
397 if (ecore_file_exists(p)) {
398 if (email_drm_file_forward_lock_check(p)) {
399 if (ugd->composer_noti) {
400 evas_object_del(ugd->composer_noti);
401 ugd->composer_noti = NULL;
403 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
404 _("IDS_EMAIL_POP_UNABLE_TO_FORWARD_DRM_CONTENTS"), 0, NULL, NULL, 2.0, _composer_noti_response_cb);
406 file_ext = _composer_get_file_ext(p);
407 debug_log("file_ext:%s", file_ext);
409 if (strcasecmp(file_ext, "vcf") == 0 || strcasecmp(file_ext, "vcs") == 0) {
410 if (_composer_copy_temp_file(p, tmp_file_path, MAX_PATH_LEN))
411 list = eina_list_append(list, tmp_file_path);
413 list = eina_list_append(list, p);
415 list = eina_list_append(list, p);
419 p = strtok(NULL, token);
421 debug_log("p = %s", p);
425 list = eina_list_append(list, str);
431 Eina_List *email_composer_change_GList_to_EinaList(GList * l)
435 Eina_List *list = NULL;
438 int count = g_list_length(l);
441 for (i = 0; i < count; i++) {
442 char *string = g_list_nth_data(l, i);
443 debug_log("%d = %s", i, string);
446 list = eina_list_append(list, string);
451 debug_log("count is 0!!");
456 int _composer_add_mailbox_folder(EmailComposerUGD *ugd, email_mailbox_type_e mailbox_type, Eina_Bool b_save_to_draft)
460 int nResult = EMAIL_ERROR_NONE;
462 nResult = email_get_mailbox_by_mailbox_type(ugd->account_info->account_id, mailbox_type, &ugd->mailbox_info->mail_box);
463 if (nResult != EMAIL_ERROR_NONE) {
464 debug_log("email_get_mailbox_by_mailbox_type failed! %d", nResult);
468 debug_log("mailbox = %s", ugd->mailbox_info->mail_box->mailbox_name);
469 debug_log("mailbox_id = %d", ugd->mailbox_info->mail_box->mailbox_id);
471 nResult = _composer_make_mail(ugd, b_save_to_draft);
472 if (nResult < COMPOSER_ERROR_NONE) {
473 debug_log("error in _composer_make_mail(%d)", nResult);
477 debug_log("ugd->new_mail_info->mail_data->account_id = %d, ugd->new_mail_info->mail_data->server_mailbox_name = %s",
478 ugd->new_mail_info->mail_data->account_id, ugd->new_mail_info->mail_data->server_mailbox_name);
480 debug_log("attachment_list = %x, attachment_count = %d",
481 ugd->new_mail_info->attachment_list, ugd->new_mail_info->mail_data->attachment_count);
483 nResult = email_add_mail(ugd->new_mail_info->mail_data, ugd->new_mail_info->attachment_list, ugd->new_mail_info->mail_data->attachment_count, NULL, 0);
484 debug_log("result of email_add_mail: %d", nResult);
485 if (nResult != EMAIL_ERROR_NONE) {
486 debug_warning("email_add_mail failed! %d", nResult);
490 if (email_check_file_exist(ugd->saved_html_path)) {
491 if (-1 == remove(ugd->saved_html_path)) {
492 debug_warning("Failed to remove file");
493 return COMPOSER_ERROR_FAIL;
497 return COMPOSER_ERROR_NONE;
500 int _composer_move_mailbox_folder(EmailComposerUGD *ugd, email_mailbox_type_e mailbox_type, Eina_Bool b_save_to_draft)
504 int nResult = EMAIL_ERROR_NONE;
506 int mail_ids[1] = { 0, };
507 mail_ids[0] = ugd->nExistingMailID;
509 debug_log("id = %d", mail_ids[0]);
511 nResult = email_get_mailbox_by_mailbox_type(ugd->account_info->account_id, mailbox_type, &ugd->mailbox_info->mail_box);
512 if (nResult != EMAIL_ERROR_NONE) {
513 debug_log("email_get_mailbox_by_mailbox_type failed! %d", nResult);
517 nResult = _composer_make_mail(ugd, b_save_to_draft);
518 if (nResult < COMPOSER_ERROR_NONE) {
519 debug_log("error in _composer_make_mail(%d)", nResult);
523 nResult = email_move_mail_to_mailbox(mail_ids, 1, ugd->mailbox_info->mail_box->mailbox_id);
524 if (nResult != EMAIL_ERROR_NONE) {
525 debug_log("email_move_mail_to_mailbox failed! %d", nResult);
529 if (email_check_file_exist(ugd->saved_html_path)) {
530 if (-1 == remove(ugd->saved_html_path)) {
531 debug_log("Failed to remove file");
532 return COMPOSER_ERROR_FAIL;
536 return COMPOSER_ERROR_NONE;
539 int _composer_make_mail(EmailComposerUGD *ugd, Eina_Bool b_save_to_draft)
543 email_account_t *account = NULL;
544 if (!email_engine_get_account_full_data(ugd->account_info->account_id, &account)) {
545 debug_log("Failed to Get account full data");
546 email_free_account(&account, 1);
547 return COMPOSER_ERROR_GET_DATA_FAIL;
550 if (account == NULL) {
551 debug_log("account is NULL!");
552 return COMPOSER_ERROR_GET_DATA_FAIL;
555 debug_log("acc id = %d", ugd->account_info->account_id);
556 debug_log("priority = %d", (*ugd->account_info->account).options.priority);
557 debug_log("mailbox = %s", ugd->mailbox_info->mail_box->mailbox_name);
558 ugd->new_mail_info->mail_data->account_id = ugd->account_info->account_id;
560 ugd->new_mail_info->mail_data->report_status = EMAIL_MAIL_REPORT_NONE;
562 if (ugd->tracking_option[0] == 1) {
563 ugd->new_mail_info->mail_data->report_status |= EMAIL_MAIL_REQUEST_MDN;
565 if (ugd->tracking_option[1] == 1) {
566 ugd->new_mail_info->mail_data->report_status |= EMAIL_MAIL_REQUEST_DSN;
568 debug_log("ugd->new_mail_info->mail_data->report_status = %d", ugd->new_mail_info->mail_data->report_status);
570 ugd->new_mail_info->mail_data->priority = ugd->priority_option;
572 ugd->new_mail_info->mail_data->server_mailbox_name = strdup(ugd->mailbox_info->mail_box->mailbox_name);
573 ugd->new_mail_info->mail_data->mailbox_id = ugd->mailbox_info->mail_box->mailbox_id;
575 debug_log("user_name = %s, %s", ugd->account_info->account->user_display_name, account->user_display_name);
576 debug_log("email_addr = %s, %s", ugd->account_info->account->user_email_address, account->user_email_address);
578 char uc[MAX_STR_LEN];
579 snprintf(uc, sizeof(uc), "\"%s\"<%s>", account->user_display_name, account->user_email_address);
580 ugd->new_mail_info->mail_data->full_address_from = g_strdup(uc);
581 debug_log("from = %s", uc);
584 debug_log("email_free_account is called");
585 email_free_account(&account, 1);
589 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->to_mbe)) != NULL) {
591 if (_composer_make_recipient_char_to_list(ugd, ugd->to_mbe, &(ugd->new_mail_info->mail_data->full_address_to)) < COMPOSER_ERROR_NONE)
592 return COMPOSER_ERROR_GET_DATA_FAIL;
595 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->cc_mbe)) != NULL) {
597 if (_composer_make_recipient_char_to_list(ugd, ugd->cc_mbe, &(ugd->new_mail_info->mail_data->full_address_cc)) < COMPOSER_ERROR_NONE)
598 return COMPOSER_ERROR_GET_DATA_FAIL;
601 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->bcc_mbe)) != NULL) {
602 debug_log("bcc mbe");
603 if (_composer_make_recipient_char_to_list(ugd, ugd->bcc_mbe, &(ugd->new_mail_info->mail_data->full_address_bcc)) < COMPOSER_ERROR_NONE)
604 return COMPOSER_ERROR_GET_DATA_FAIL;
607 ugd->new_mail_info->mail_data->subject = elm_entry_markup_to_utf8(elm_entry_entry_get(ugd->subject_entry));
609 if (EINA_TRUE == ugd->has_body_html) {
611 if (TRUE == email_check_file_exist(ugd->saved_html_path)) {
612 if (-1 == remove(ugd->saved_html_path)) {
613 debug_log("Failed to remove temp html file");
614 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
618 if (TRUE == email_check_file_exist(SAVE_URI)) {
619 if (-1 == remove(SAVE_URI)) {
620 debug_log("Failed to remove temp text file");
621 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
625 char *html_content = NULL;
626 char *html_content_processed = NULL;
627 char *plain_text_content = NULL;
629 html_content = g_strdup(ugd->latest_html_content);
631 if (html_content == NULL) {
632 debug_log("ugd->latest_html_content is null");
633 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
636 debug_log("\nhtml_content:\n%s", html_content);
639 if (ugd->listOfImageUrls == NULL) {
640 debug_log("No images found or ERROR");
641 html_content_processed = html_content;
646 Eina_List *inline_list = NULL;
648 EINA_LIST_FOREACH(ugd->listOfImageUrls, l, recv) {
649 debug_log("images_list: %s", recv);
650 if (strncmp(recv, "file://", 7) == 0) { /* add only local images(file://), not web images(http://) */
651 debug_log("image = %s", recv + 7);
652 inline_list = eina_list_append(inline_list, recv + 7);
655 if (inline_list != NULL) {
656 if (!email_composer_change_image_paths_to_relative(html_content, &html_content_processed)) {
657 debug_log("email_composer_change_image_paths_to_relative Failed");
658 g_free(html_content);
660 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
662 debug_log("\nhtml_source_processed:\n%s", html_content_processed);
664 _composer_attachment_create_list(ugd, inline_list, EINA_TRUE);
666 g_free(html_content);
669 html_content_processed = html_content;
673 if (EINA_FALSE == email_composer_save_file(ugd->saved_html_path, html_content_processed, strlen(html_content_processed))) {
674 debug_log("Write to html file failed");
675 g_free(html_content_processed);
676 html_content_processed = NULL;
677 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
680 g_free(html_content_processed);
681 html_content_processed = NULL;
684 plain_text_content = g_strdup(ugd->plain_content);
686 if (NULL == plain_text_content) {
687 debug_log("ugd->plain_content is NULL");
688 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
690 if (EINA_FALSE == email_composer_save_file(SAVE_URI, plain_text_content, strlen(plain_text_content))) {
691 debug_log("Write to %s file failed", SAVE_URI);
692 g_free(plain_text_content);
693 plain_text_content = NULL;
694 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
696 g_free(plain_text_content);
697 plain_text_content = NULL;
699 ugd->new_mail_info->mail_data->file_path_html = COMPOSER_STRDUP(ugd->saved_html_path);
700 ugd->new_mail_info->mail_data->file_path_plain = COMPOSER_STRDUP(SAVE_URI);
703 int nAttachmentObjListCount = eina_list_count(ugd->attachment_item_obj_list);
704 debug_log("nAttachmentObjListCount : %d", nAttachmentObjListCount);
706 if (nAttachmentObjListCount > 0) {
708 if (ugd->new_mail_info->attachment_list) {
709 email_free_attachment_data(&ugd->new_mail_info->attachment_list, ugd->new_mail_info->mail_data->attachment_count);
710 ugd->new_mail_info->attachment_list = NULL;
711 ugd->new_mail_info->mail_data->attachment_count = 0;
714 ugd->new_mail_info->mail_data->attachment_count = nAttachmentObjListCount;
716 debug_log("ugd->new_mail_info->attachment_count : %d", ugd->new_mail_info->mail_data->attachment_count);
718 ugd->new_mail_info->attachment_list = (email_attachment_data_t *)calloc(nAttachmentObjListCount, sizeof(email_attachment_data_t));
721 Eina_Iterator *it = NULL;
722 Evas_Object *attachment_obj = NULL;
723 email_attachment_data_t *attachment_data;
725 it = eina_list_iterator_new(ugd->attachment_item_obj_list);
727 while (eina_iterator_next(it, (void **)&attachment_obj)) {
729 attachment_data = evas_object_data_get(attachment_obj, "attachment_data");
731 if (attachment_data) {
732 ugd->new_mail_info->attachment_list[nCount].inline_content_status = attachment_data->inline_content_status;
733 ugd->new_mail_info->attachment_list[nCount].attachment_id = attachment_data->attachment_id;
734 ugd->new_mail_info->attachment_list[nCount].attachment_size = attachment_data->attachment_size;
735 ugd->new_mail_info->attachment_list[nCount].save_status = attachment_data->save_status;
736 ugd->new_mail_info->attachment_list[nCount].attachment_name = COMPOSER_STRDUP(attachment_data->attachment_name);
737 ugd->new_mail_info->attachment_list[nCount].attachment_path = COMPOSER_STRDUP(attachment_data->attachment_path);
739 debug_log("attachment_name : %s", ugd->new_mail_info->attachment_list[nCount].attachment_name);
740 debug_log("attachment_path : %s", ugd->new_mail_info->attachment_list[nCount].attachment_path);
741 debug_log("attachment_id : %d", ugd->new_mail_info->attachment_list[nCount].attachment_id);
742 debug_log("attachment_size : %d", ugd->new_mail_info->attachment_list[nCount].attachment_size);
743 debug_log("save_status : %d", ugd->new_mail_info->attachment_list[nCount].save_status);
744 debug_log("inline_content_status : %d", ugd->new_mail_info->attachment_list[nCount].inline_content_status);
751 ugd->new_mail_info->mail_data->flags_draft_field = 1;
753 return COMPOSER_ERROR_NONE;
756 EmailRecpInfo *_composer_separate_save_recipient_char(EmailComposerUGD *ugd, char *recipient)
759 if (!ugd || !recipient) {
760 debug_log("Function arguments NULL");
763 debug_log("separate recipient char = %s", recipient);
767 if (recipient[0] == ' ') {
768 temp = g_strdup(recipient++);
769 debug_log("temp = %s", temp);
771 temp = g_strdup(recipient);
772 debug_log("temp = %s", temp);
779 gchar **vector = NULL;
781 vector = g_strsplit_set(temp, "\"<>", -1);
783 if (vector == NULL) {
784 debug_log("vector == NULL");
789 EmailRecpInfo *ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
792 debug_log("Memory allocation failed.");
798 gint tok_cnt = g_strv_length(vector);
800 debug_log("tok_cnt = %d", tok_cnt);
801 debug_log("temp = %s", temp);
805 ri->display_name = g_strdup(vector[0]);
806 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", vector[0]);
813 } else if (tok_cnt == 3) {
815 ri->display_name = g_strdup(vector[1]);
816 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", vector[1]);
823 } else if (tok_cnt == 5) {
824 if (vector[1] && vector[3]) {
825 ri->display_name = g_strdup(vector[1]);
826 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", vector[3]);
840 ri->selected_email_idx = 0;
842 ri->is_contact_info = false;
843 ri->is_always_bcc = false;
844 ri->is_from_addr = false;
852 void _composer_convert_ps_to_br(char *input)
854 const char *char_ps = "<ps>";
859 while ((ptr = strstr(input, char_ps))) {
867 int _composer_send_mail(EmailComposerUGD *ugd)
871 if (!ugd->account_info->account) {
872 debug_log("account is NULL");
873 return COMPOSER_ERROR_SEND_FAIL;
876 debug_log("priority = %d", (*ugd->account_info->account).options.priority);
877 debug_log("request read report = %d", (*ugd->account_info->account).options.req_read_receipt);
879 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
880 /* Currently when a saved email is opened in drafts and edited before sending it then edited mail is not added to Outbox and edited email is not sent.
881 This is because only mailbox name is updated to Outbox using move mail.
883 Correct process will be as below -
885 1) Add new edited email to Outbox.
886 2) Delete the old email from Drafts / Outbox */
888 if (0 < ugd->mailbox_info->mailbox_id) {
889 int ret = _composer_add_mailbox_folder(ugd, EMAIL_MAILBOX_TYPE_OUTBOX, EINA_FALSE);
891 if (ret < COMPOSER_ERROR_NONE) {
892 debug_log("error in _composer_add_mailbox_folder(%d)", ret);
893 return COMPOSER_ERROR_SEND_FAIL;
896 int sync = EMAIL_DELETE_LOCAL_AND_SERVER;
898 /* Retrieve mailbox type from email-service and store it to identify Outbox */
900 debug_log("mailbox type [%d]", ugd->existing_mail_info->mail_data->mailbox_type);
901 if (EMAIL_MAILBOX_TYPE_OUTBOX == ugd->existing_mail_info->mail_data->mailbox_type)
902 sync = EMAIL_DELETE_LOCALLY;
904 debug_log("Account id [%d] mailbox id [%d] mail id [%d]", ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID);
906 if (!email_engine_delete_mail(ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID, sync)) {
907 debug_log("Deleting email is failed.");
908 return COMPOSER_ERROR_SEND_FAIL;
912 debug_critical("mailbox name is null");
913 return COMPOSER_ERROR_SEND_FAIL;
917 int ret = _composer_add_mailbox_folder(ugd, EMAIL_MAILBOX_TYPE_OUTBOX, EINA_FALSE);
919 if (ret < COMPOSER_ERROR_NONE) {
920 debug_log("error in _composer_add_mailbox_folder(%d)", ret);
921 return COMPOSER_ERROR_SEND_FAIL;
928 if ((err = email_send_mail(ugd->new_mail_info->mail_data->mail_id, &handle)) != EMAIL_ERROR_NONE) {
929 debug_log(" fail sending [%d]", err);
930 return COMPOSER_ERROR_SEND_FAIL;
932 debug_log(" finish sending");
933 /* Support sync engine */
934 if (ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL) {
935 debug_log("existing mail id = %d, %d", ugd->nExistingMailID, ugd->existing_mail_info->mail_data->mail_id);
936 email_set_flags_field(ugd->account_info->account->account_id, &ugd->nExistingMailID, 1, EMAIL_FLAGS_ANSWERED_FIELD, 1, 1);
937 } else if (ugd->composer_type == RUN_COMPOSER_FORWARD) {
938 debug_log("existing mail id = %d, %d", ugd->nExistingMailID, ugd->existing_mail_info->mail_data->mail_id);
939 email_set_flags_field(ugd->account_info->account->account_id, &ugd->nExistingMailID, 1, EMAIL_FLAGS_FORWARDED_FIELD, 1, 1);
943 return COMPOSER_ERROR_NONE;
946 int _composer_make_recipient_char_to_list(EmailComposerUGD *ugd, Evas_Object *obj, char **dest)
950 char result[MAX_RECIPIENT_ADDRESSES_LEN] = { 0, };
952 debug_log("obj = %p", obj);
954 Elm_Object_Item *mbe_item;
955 mbe_item = elm_multibuttonentry_first_item_get(obj);
956 debug_log("mbe_item = %p", mbe_item);
962 ri = (EmailRecpInfo *) elm_object_item_data_get(mbe_item);
964 return COMPOSER_ERROR_GET_DATA_FAIL;
966 index = ri->selected_email_idx;
968 debug_log("display name = %s", ri->display_name);
969 debug_log("email_addr = %s", ri->email_list[index].email_addr);
971 if (g_strcmp0(result, "") == 0) {
972 if (ri->display_name)
973 snprintf(result, sizeof(result), "\"%s\" <%s>", ri->display_name, ri->email_list[index].email_addr);
975 snprintf(result, sizeof(result), "<%s>", ri->email_list[index].email_addr);
977 if (ri->display_name)
978 snprintf(result + strlen(result), sizeof(result) - strlen(result), ";\"%s\" <%s>", ri->display_name, ri->email_list[index].email_addr);
980 snprintf(result + strlen(result), sizeof(result) - strlen(result), ";<%s>", ri->email_list[index].email_addr);
983 mbe_item = elm_multibuttonentry_item_next_get(mbe_item);
986 debug_log("result = %s", result);
988 *dest = g_strdup(result);
990 return COMPOSER_ERROR_NONE;
993 void _composer_save_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
997 debug_log("data is NULL");
1001 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1003 char *pszBtnText = (char *)elm_object_text_get(obj);
1004 debug_log("selected button text = %s", pszBtnText);
1006 if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_YES")) == 0) {
1007 int ret = _composer_add_mailbox_folder(ugd, EMAIL_MAILBOX_TYPE_DRAFT, EINA_TRUE);
1009 if (ret < COMPOSER_ERROR_NONE) {
1010 debug_log("Failed save in Drafts(%d)", ret);
1012 if (ugd->popup_list) {
1013 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1014 debug_log("obj: %p", obj);
1015 debug_log("composer_noti: %p", ugd->composer_noti);
1017 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1020 evas_object_del(ugd->composer_noti);
1021 ugd->composer_noti = NULL;
1023 ugd->idler_save_draft = ecore_idler_add(_composer_show_fail_to_save, ugd);
1025 debug_log("Succeed in saving in Drafts");
1027 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
1028 //After a new draft mail is added, the old draft mail is deleted and synced to server
1029 debug_log("Account id [%d] mailbox id [%d] mail id [%d]", ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID);
1031 if (!email_engine_delete_mail(ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID, EMAIL_DELETE_LOCAL_AND_SERVER)) {
1032 debug_log("Deleting email is failed.");
1036 if (ugd->popup_list) {
1037 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1038 debug_log("composer_noti: %p", ugd->composer_noti);
1040 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1043 evas_object_del(ugd->composer_noti);
1044 ugd->composer_noti = NULL;
1046 ugd->idler_save_draft = ecore_idler_add(_composer_show_success_to_save, ugd);
1048 } else if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_NO")) == 0) {
1049 ugd->idler_save_draft = ecore_idler_add(_composer_idler_destroy, ugd);
1051 _composer_noti_response_cb(data, obj, event_info);
1055 Eina_Bool _composer_show_fail_to_save(void *data)
1057 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1059 if (ugd->idler_save_draft) {
1060 debug_log("delete idler_save_draft");
1061 ecore_idler_del(ugd->idler_save_draft);
1062 ugd->idler_save_draft = NULL;
1066 ugd->b_sending = false;
1068 if (ugd->composer_noti) {
1069 evas_object_del(ugd->composer_noti);
1070 ugd->composer_noti = NULL;
1072 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
1073 _("IDS_EMAIL_POP_UNABLE_TO_SAVE_IN_DRAFTS"), 0, NULL, NULL, 1.5, _composer_save_draft_fail_response_cb);
1078 Eina_Bool _composer_show_success_to_save(void *data)
1080 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1082 if (ugd->idler_save_draft) {
1083 debug_log("delete idler_save_draft");
1084 ecore_idler_del(ugd->idler_save_draft);
1085 ugd->idler_save_draft = NULL;
1089 ugd->b_sending = false;
1091 if (ugd->composer_noti) {
1092 evas_object_del(ugd->composer_noti);
1093 ugd->composer_noti = NULL;
1095 ugd->composer_noti = _composer_create_noti(ugd, false, NULL,
1096 _("IDS_EMAIL_POP_SAVED_IN_DRAFTS"), 0, NULL, NULL, 1.5, _composer_save_draft_response_cb);
1101 static void _composer_save_draft_response_cb(void *data, Evas_Object *obj, void *event_info)
1105 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1107 ugd->idler_save_draft = ecore_idler_add(_composer_idler_destroy, ugd);
1110 static void _composer_save_draft_fail_response_cb(void *data, Evas_Object *obj, void *event_info)
1114 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1116 ugd->idler_save_draft = ecore_idler_add(_composer_idler_return, ugd);
1119 Eina_Bool _composer_popup_end_cb(void *data)
1123 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1124 _composer_popup_end(ugd, COMPOSER_ERROR_NONE);
1129 void _composer_popup_end(EmailComposerUGD *ugd, int close_sg)
1133 if (ugd->send_timer) {
1134 debug_log("delete send_timer");
1135 ecore_timer_del(ugd->send_timer);
1136 ugd->send_timer = NULL;
1139 if (ugd->composer_noti) {
1140 evas_object_del(ugd->composer_noti);
1141 ugd->composer_noti = NULL;
1144 if (close_sg == COMPOSER_ERROR_NONE) {
1145 if (elm_multibuttonentry_first_item_get(ugd->to_mbe))
1146 elm_multibuttonentry_clear(ugd->to_mbe);
1147 if (elm_multibuttonentry_first_item_get(ugd->cc_mbe))
1148 elm_multibuttonentry_clear(ugd->cc_mbe);
1149 if (elm_multibuttonentry_first_item_get(ugd->bcc_mbe))
1150 elm_multibuttonentry_clear(ugd->bcc_mbe);
1152 ug_destroy_me(ugd->ug_main);
1154 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
1155 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
1156 elm_object_disabled_set(ugd->send_btm_btn, EINA_FALSE);
1157 elm_object_disabled_set(ugd->cancel_btm_btn, EINA_FALSE);
1159 ugd->bSendBtnDisabled = false;
1163 void _composer_make_default_thumbnail(Evas_Object *eo, char *pszImgPath, int nItemType)
1167 char thumb_path[MAX_ATTACHMENT_FILE_LEN + 1] = { 0, };
1169 if (eo == NULL || pszImgPath == NULL)
1172 debug_log("Image path = %s", pszImgPath);
1174 Evas_Object *icon = eo;
1176 if (nItemType == COMPOSER_ATTACHMENT_ITEM_IMAGE) {
1177 debug_log("Thumbnail type - image");
1179 int err = _composer_attachment_make_ethumb(pszImgPath, thumb_path);
1181 if (err != COMPOSER_ERROR_NONE)
1182 elm_image_file_set(icon, ATTACHMENT_IMAGE_FILE_PATH, NULL);
1184 debug_log("Thumbnail path = %s", thumb_path);
1186 elm_image_file_set(icon, thumb_path, NULL);
1190 else if (nItemType == COMPOSER_ATTACHMENT_ITEM_SOUND)
1191 elm_image_file_set(icon, ATTACHMENT_AUDIO_FILE_PATH, NULL);
1192 else if (nItemType == COMPOSER_ATTACHMENT_ITEM_VIDEO)
1193 elm_image_file_set(icon, ATTACHMENT_VIDEO_FILE_PATH, NULL);
1195 gchar **vector = NULL;
1196 gint tok_cnt = g_strv_length(vector);
1198 vector = g_strsplit_set(pszImgPath, ".", -1);
1199 tok_cnt = g_strv_length(vector);
1200 debug_log("tok_cnt: [%d], file(%s, %s)", tok_cnt, vector[tok_cnt - 2], vector[tok_cnt - 1]);
1201 if (vector[tok_cnt - 1]) {
1202 if (g_strcmp0(vector[tok_cnt - 1], ATTACHMENT_MEDIA_VCARD) == 0) {
1203 elm_image_file_set(icon, ATTACHMENT_VCARD_FILE_PATH, NULL);
1204 } else if (g_strcmp0(vector[tok_cnt - 1], ATTACHMENT_MEDIA_VCALENDAR) == 0) {
1205 elm_image_file_set(icon, ATTACHMENT_VCALENDAR_FILE_PATH, NULL);
1207 elm_image_file_set(icon, ATTACHMENT_ETC_FILE_PATH, NULL);
1210 elm_image_file_set(icon, ATTACHMENT_ETC_FILE_PATH, NULL);
1216 Evas_Object *_composer_load_edj(Evas_Object *parent, const char *file, const char *group)
1222 eo = elm_layout_add(parent);
1224 r = elm_layout_file_set(eo, file, group);
1226 evas_object_del(eo);
1230 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1236 Evas_Object *_composer_create_navigation_layout(EmailComposerUGD *ugd)
1239 Evas_Object *parent = ugd->main_layout;
1240 Evas_Object *navi_bar;
1242 navi_bar = elm_naviframe_add(parent);
1243 elm_object_part_content_set(parent, "elm.swallow.content", navi_bar);
1245 evas_object_show(navi_bar);
1250 Evas_Object *_composer_create_composer_layout(Evas_Object *parent)
1253 Evas_Object *layout;
1255 layout = elm_layout_add(parent);
1257 elm_layout_file_set(layout, COMPOSER_EDJ_NAME, "layout.composer");
1258 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1259 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1260 evas_object_show(layout);
1265 Evas_Object *_composer_create_outer_layout(Evas_Object *parent)
1268 Evas_Object *layout;
1270 layout = elm_layout_add(parent);
1272 elm_layout_theme_set(layout, "layout", "application", "noindicator");
1273 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1274 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1275 evas_object_show(layout);
1280 Evas_Object *_composer_create_main_scroller(Evas_Object *parent)
1283 Evas_Object *scroller;
1285 scroller = elm_scroller_add(parent);
1287 elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE);
1288 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
1289 evas_object_show(scroller);
1294 Evas_Object *_composer_create_box(Evas_Object *parent)
1298 Evas_Object *box = elm_box_add(parent);
1299 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1300 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
1301 evas_object_show(box);
1303 elm_object_focus_allow_set(box, EINA_FALSE);
1308 void _composer_set_mail_info(EmailComposerUGD *ugd)
1312 _composer_add_to_address(ugd);
1313 _composer_add_cc_address(ugd);
1314 _composer_add_bcc_address(ugd);
1316 _composer_add_subject(ugd);
1317 _composer_add_body(ugd);
1319 if (ugd->composer_type != RUN_COMPOSER_EDIT) {
1320 _composer_add_origin_msg(ugd);
1323 if (ugd->composer_type == RUN_COMPOSER_FORWARD && ugd->account_info->account->options.forward_with_files) {
1324 debug_log("attachment_count:%d, inline_content_count:%d", ugd->existing_mail_info->mail_data->attachment_count, ugd->existing_mail_info->mail_data->inline_content_count);
1325 if (ugd->existing_mail_info->mail_data->attachment_count > 0) {
1327 for (i = 0; i < ugd->existing_mail_info->mail_data->attachment_count; i++) {
1328 debug_log("save_status:%d, inline_content_status:%d", ugd->existing_mail_info->attachment_list[i].save_status, ugd->existing_mail_info->attachment_list[i].inline_content_status);
1329 if (ugd->existing_mail_info->attachment_list[i].save_status == FALSE && ugd->existing_mail_info->attachment_list[i].inline_content_status == FALSE) {
1330 ugd->need_download = EINA_TRUE;
1334 debug_log("need_download:%d, fw_dn_cnt:%d", ugd->need_download, ugd->fw_dn_cnt);
1338 _composer_add_attachment(ugd);
1340 if ((EINA_TRUE == ugd->has_body_html) &&
1341 (ugd->composer_type == RUN_COMPOSER_EDIT || ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL || ugd->composer_type == RUN_COMPOSER_FORWARD)) {
1342 _composer_add_softlink_to_inline_images(ugd);
1344 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->file_path_plain) {
1345 char *plain_charset = email_parse_get_filename_from_path(ugd->existing_mail_info->mail_data->file_path_plain);
1346 debug_log("plain_charset : %s", plain_charset);
1347 if (plain_charset) {
1348 Ewk_Settings *ewkSetting = ewk_view_settings_get(ugd->body_ewkview);
1350 if (ewkSetting == NULL)
1351 debug_log("ewkSetting is NULL.");
1353 ewk_settings_default_encoding_set(ewkSetting, plain_charset);
1354 g_free(plain_charset);
1357 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->file_path_html) {
1358 char *charset = email_parse_get_filename_from_path(ugd->existing_mail_info->mail_data->file_path_html);
1359 debug_log("body html filename charset:%s", charset);
1361 Ewk_Settings *ewkSetting = ewk_view_settings_get(ugd->body_ewkview);
1363 if (ewkSetting == NULL)
1364 debug_log("ewkSetting is NULL.");
1366 ewk_settings_default_encoding_set(ewkSetting, charset);
1373 if (EINA_TRUE == ugd->has_body_html) {
1376 char file_path[MAX_PATH_LEN] = { 0, };
1377 snprintf(file_path, sizeof(file_path), "file://%s", ugd->saved_html_path);
1378 debug_log("file_path: (%s)", file_path);
1380 ewk_view_url_set(ugd->body_ewkview, file_path);
1384 void _composer_show_download_attachment_popup(EmailComposerUGD *ugd)
1388 char msg[MAX_STR_LEN] = { 0, };
1389 if (ugd->fw_dn_cnt > 1)
1390 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_DOWNLOAD_ATTACHMENTS_Q"));
1392 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_DOWNLOAD_ATTACHMENT_Q"));
1394 if (ugd->dn_noti_popup) {
1395 evas_object_del(ugd->dn_noti_popup);
1396 ugd->dn_noti_popup = NULL;
1398 ugd->dn_noti_popup = _composer_create_noti(ugd, false, NULL, msg, 2,
1399 dgettext("sys_string", "IDS_COM_SK_OK"), dgettext("sys_string", "IDS_COM_SK_CANCEL"), 0.0, _composer_attachment_popup_response_cb);
1402 static void _composer_attachment_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
1407 debug_log("data is NULL");
1411 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1413 char *pszBtnText = (char *)elm_object_text_get(obj);
1414 debug_log("selected button text = %s", pszBtnText);
1416 if (ugd->popup_list) {
1417 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1418 debug_log("obj: %p", obj);
1419 debug_log("dn_noti_popup: %p", ugd->dn_noti_popup);
1421 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->dn_noti_popup/*obj*/);
1424 evas_object_del(ugd->dn_noti_popup);
1425 ugd->dn_noti_popup = NULL;
1427 if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_OK")) == 0) {
1428 _composer_download_attachment(ugd);
1430 } else if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_CANCEL")) == 0) {
1431 ugd->selected_entry = ugd->to_mbe_entry;
1432 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
1437 Eina_Bool _composer_show_progress_popup(void *data)
1439 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1441 Evas_Object *progressbar;
1444 if (ugd->idler_show_progress) {
1445 debug_log("delete idler_show_progress");
1446 ecore_idler_del(ugd->idler_show_progress);
1447 ugd->idler_show_progress = NULL;
1451 ugd->fw_dn_total_cnt = ugd->fw_dn_cnt;
1453 char buf[128] = { 0, };
1455 snprintf(buf, sizeof(buf), "%s [0/%d]", _("IDS_EMAIL_POP_DOWNLOADING_ATTACHMENT_ING"), ugd->fw_dn_cnt);
1457 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1458 debug_log("dn_noti_popup: %p", ugd->dn_noti_popup);
1460 evas_object_del(ugd->dn_noti_popup);
1461 ugd->dn_noti_popup = NULL;
1463 if (ugd->dn_prog_popup) {
1464 evas_object_del(ugd->dn_prog_popup);
1465 ugd->dn_prog_popup = NULL;
1467 popup = _composer_create_noti(ugd, false, NULL, buf, 1,
1468 dgettext("sys_string", "IDS_COM_SK_CANCEL"), NULL, 0.0, _composer_dn_prog_popup_response_cb);
1470 ugd->dn_prog_popup = popup;
1472 Evas_Object *label = elm_label_add(popup);
1473 elm_object_text_set(label, buf);
1474 evas_object_show(label);
1475 ugd->fw_dn_label = label;
1477 Evas_Object *box = elm_box_add(popup);
1479 progressbar = elm_progressbar_add(popup);
1481 elm_object_style_set(progressbar, "list_progress");
1483 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
1484 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1485 elm_progressbar_value_set(progressbar, 0.0);
1486 evas_object_show(progressbar);
1487 ugd->fw_dn_progress = progressbar;
1488 evas_object_show(box);
1490 elm_box_pack_end(box, label);
1491 elm_box_pack_end(box, progressbar);
1493 elm_object_content_set(popup, box);
1498 static void _composer_dn_prog_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
1502 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1504 char *pszBtnText = (char *)elm_object_text_get(obj);
1505 debug_log("selected button text = %s", pszBtnText);
1507 if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_CANCEL")) == 0) {
1508 if (ugd->popup_list) {
1509 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1510 debug_log("obj: %p", obj);
1511 debug_log("dn_prog_popup: %p", ugd->dn_prog_popup);
1513 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->dn_prog_popup/*obj*/);
1516 if (ugd->dn_prog_popup) {
1517 evas_object_del(ugd->dn_prog_popup);
1518 ugd->dn_prog_popup = NULL;
1521 _composer_webkit_set_body_script(data);
1522 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
1523 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
1524 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
1525 elm_object_disabled_set(ugd->send_btm_btn, EINA_FALSE);
1526 elm_object_disabled_set(ugd->cancel_btm_btn, EINA_FALSE);
1528 _composer_cancel_download_attachment(ugd);
1530 ugd->selected_entry = ugd->to_mbe_entry;
1531 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
1535 static Eina_Bool _composer_save_attachment(EmailComposerUGD *ugd, int index)
1539 if (ugd->fw_attachment_list == NULL) {
1543 EMAIL_ATTACHMENT_INFO_S *info = (EMAIL_ATTACHMENT_INFO_S *) g_list_nth_data(ugd->fw_attachment_list, index);
1546 debug_log("EMAIL_ATTACHMENT_INFO_S *info is NULL");
1550 if (!info->downloaded) {
1552 gboolean res = FALSE;
1554 debug_log("Need attachment download");
1556 res = email_engine_attachment_download(ugd->existing_mail_info->mail_data->account_id, info->mail_id, info->index, &handle);
1559 ugd->fw_dn_handle[index] = handle;
1560 ugd->idler_show_progress = ecore_idler_add(_composer_show_progress_popup, ugd);
1562 info->downloaded = false;
1563 _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
1564 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
1565 dgettext("sys_string", "IDS_COM_SK_OK"), NULL,
1566 0, _composer_popup_response_cb);
1569 return (res ? EINA_TRUE : EINA_FALSE);
1575 void _composer_download_attachment(EmailComposerUGD *ugd)
1579 int att_cnt = g_list_length(ugd->fw_attachment_list);
1581 debug_log("att_cnt = %d", att_cnt);
1583 ugd->fw_dn_cnt = att_cnt;
1586 for ( i = 0 ; i < att_cnt ; i++ ) {
1587 if (_composer_save_attachment(ugd, i) == EINA_TRUE) {
1588 debug_log("_composer_save_attachment");
1592 ugd->need_download = EINA_FALSE;
1593 ugd->bSendBtnDisabled = true;
1594 ugd->send_timer = ecore_timer_add(0.5, _composer_send_mail_cb, ugd);
1598 void _composer_update_attachment_info(EmailComposerUGD *ugd, int index)
1602 int nAttachmentObjListCount = eina_list_count(ugd->attachment_item_obj_list);
1603 debug_log("nAttachmentObjListCount : %d", nAttachmentObjListCount);
1605 if (nAttachmentObjListCount > 0) {
1607 Eina_Iterator *it = NULL;
1608 Evas_Object *attachment_obj = NULL;
1609 email_attachment_data_t *attachment_data;
1611 it = eina_list_iterator_new(ugd->attachment_item_obj_list);
1613 while (eina_iterator_next(it, (void **)&attachment_obj)) {
1615 EMAIL_ATTACHMENT_INFO_S *info = (EMAIL_ATTACHMENT_INFO_S *) g_list_nth_data(ugd->fw_attachment_list, nCount);
1616 debug_log("info : %x", info);
1618 debug_log("info->path : %s", info->path);
1619 debug_log("info->downloaded : %d", info->downloaded);
1620 debug_log("info->attach_id : %d", info->attach_id);
1621 if (info->index == index) {
1622 char newpath[MAX_PATH_LEN] = { 0, };
1623 info->downloaded = true;
1624 path = email_engine_get_attachment_path(info->attach_id);
1626 debug_log("info->downloaded : %d", info->downloaded);
1627 debug_log("path : %s", path);
1629 attachment_data = evas_object_data_get(attachment_obj, "attachment_data");
1631 if (attachment_data && path && STR_VALID(path)) {
1633 debug_log("path[%s]", path);
1634 ret = email_attachments_save_file(path, newpath, NULL);
1635 if (ret == EMAIL_EXT_SAVE_ERR_NONE) {
1636 char str[128] = { 0, };
1637 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
1638 ret = status_message_post(str);
1640 debug_log("status_message_post failed: %d", ret);
1643 attachment_data->attachment_path = g_strdup(path);
1644 attachment_data->save_status = info->downloaded;
1645 debug_log("attachment_name : %s", attachment_data->attachment_name);
1646 debug_log("attachment_path : %s", attachment_data->attachment_path);
1647 debug_log("attachment_id : %d", attachment_data->attachment_id);
1648 debug_log("attachment_size : %d", attachment_data->attachment_size);
1649 debug_log("save_status : %d", attachment_data->save_status);
1650 debug_log("inline_content_status : %d", attachment_data->inline_content_status);
1664 void _composer_cancel_download_attachment(EmailComposerUGD *ugd)
1668 int att_cnt = g_list_length(ugd->fw_attachment_list);
1671 debug_log("att_cnt = %d", att_cnt);
1672 for (i = 0; i < att_cnt; i++) {
1673 debug_log("handle index = %d", i);
1674 debug_log("handle = %d", ugd->fw_dn_handle[i]);
1675 email_engine_stop_working(ugd->account_info->account_id, ugd->fw_dn_handle[i]);
1679 const char *_composer_get_sent_time(EmailComposerMail *mail_info)
1684 time = mail_info->mail_data->date_time;
1686 char *formatted_date = NULL;
1688 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1689 formatted_date = email_get_date_text(icu_locale, "yMMMEEEdhms", &time);
1691 formatted_date = email_get_date_text(icu_locale, "yMMMEEEdHms", &time);
1693 debug_log("date&time: %d [%s]", time, formatted_date);
1695 return formatted_date;
1698 char *_composer_get_wday(int tm_wday)
1703 wday = (char *)g_malloc0(10 * sizeof(char));
1707 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_SUN"));
1710 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_MON"));
1713 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_TUE"));
1716 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_WED"));
1719 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_THU"));
1722 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_FRI"));
1725 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_SAT"));
1734 char *_composer_get_month(int tm_mon)
1739 mon = (char *)g_malloc0(10 * sizeof(char));
1743 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_JAN"));
1746 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_FEB"));
1749 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_MAR"));
1752 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_APR"));
1755 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_MAY"));
1758 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_JUN"));
1761 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_JUL"));
1764 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_AUG"));
1767 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_SEP"));
1770 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_OCT"));
1773 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_NOV"));
1776 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_DEC"));
1785 bool _composer_is_valid_email(const char *addr)
1787 char *token1 = NULL;
1788 char *token2 = NULL;
1790 debug_log("addr = %s", addr);
1792 if (addr[0] == '\0') {
1796 token1 = strchr(addr, '@');
1798 debug_log("there is no @");
1802 if (strchr(&token1[1], '@')) {
1803 debug_log("there is too many @");
1807 token2 = strchr(token1, '.');
1809 debug_log("there is no .");
1813 if ((token2 == token1 + 1) || (*(token2 + 1) == '\0')) {
1814 debug_log("Should be xxx.xxx");
1821 bool _composer_check_recipient_is_duplicated(EmailComposerUGD *ugd, Evas_Object *obj, EmailRecpInfo * ri)
1825 bool isDuplicated = false;
1827 Elm_Object_Item *mbe_item;
1828 EmailRecpInfo *iter_ri = NULL;
1830 mbe_item = elm_multibuttonentry_first_item_get(obj);
1833 iter_ri = elm_object_item_data_get(mbe_item);
1835 if (iter_ri != ri) {
1836 if (!g_strcmp0(iter_ri->email_list[iter_ri->selected_email_idx].email_addr, ri->email_list[0].email_addr)) {
1837 isDuplicated = true;
1842 mbe_item = elm_multibuttonentry_item_next_get(mbe_item);
1845 return isDuplicated;
1848 Eina_Bool _composer_idler_destroy(void *data)
1851 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1853 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_FALSE); // block the focus not to open IME.
1855 if (ugd->idler_save_draft) {
1856 debug_log("delete idler_save_draft");
1857 ecore_idler_del(ugd->idler_save_draft);
1858 ugd->idler_save_draft = NULL;
1861 if (ugd->popup_list) {
1862 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1863 debug_log("composer_noti: %p", ugd->composer_noti);
1865 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
1868 evas_object_del(ugd->composer_noti);
1869 ugd->composer_noti = NULL;
1871 ug_destroy_me(ugd->ug_main);
1876 Eina_Bool _composer_idler_return(void *data)
1879 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1881 if (ugd->idler_save_draft) {
1882 debug_log("delete idler_save_draft");
1883 ecore_idler_del(ugd->idler_save_draft);
1884 ugd->idler_save_draft = NULL;
1887 if (ugd->popup_list) {
1888 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1889 debug_log("composer_noti: %p", ugd->composer_noti);
1891 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
1894 evas_object_del(ugd->composer_noti);
1895 ugd->composer_noti = NULL;
1900 void _composer_entry_filter_remove_markup(void *data, Evas_Object *entry, char **text)
1903 if (text == NULL || *text == NULL) {
1904 debug_log("New Text is NULL");
1908 char *preedit_str = NULL;
1909 char *utf8_text = NULL;
1910 char *convert_text = NULL;
1912 /* Check preeditting text and return if it exist */
1913 preedit_str = strstr(*text, "<preedit_sel>");
1917 /* Convert from markup text to utf8 text from entry */
1918 utf8_text = elm_entry_markup_to_utf8(*text);
1921 /* If the string contains "Carrage return ('\n'), it should be changed "<br>" to show properly */
1922 convert_text = elm_entry_utf8_to_markup(utf8_text);
1925 *text = strdup(convert_text);
1932 void _composer_add_to_address(EmailComposerUGD *ugd)
1936 Eina_Bool overflow_flag = TRUE;
1937 Eina_Bool invalid_address_flag = FALSE;
1939 char *from_addr = NULL;
1941 if (ugd->existing_mail_info->mail_data != NULL && ugd->existing_mail_info->mail_data->full_address_from != NULL &&
1942 (ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL)) {
1945 char *from_temp = g_strdup(ugd->existing_mail_info->mail_data->full_address_from);
1947 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, from_temp);
1950 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
1952 if (!_composer_check_recipient_is_duplicated(ugd, ugd->to_mbe, ri)) {
1953 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
1956 if (ugd->composer_noti) {
1957 evas_object_del(ugd->composer_noti);
1958 ugd->composer_noti = NULL;
1960 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
1961 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
1965 if (ri && !ri_used) {
1966 if (ri->display_name) {
1967 free(ri->display_name);
1968 ri->display_name = NULL;
1977 if ((ugd->existing_mail_info->mail_data != NULL && ugd->existing_mail_info->mail_data->full_address_to != NULL &&
1978 (ugd->composer_type == RUN_COMPOSER_REPLY_ALL || ugd->composer_type == RUN_COMPOSER_EDIT)) ||
1979 (ugd->new_mail_info->mail_data != NULL && ugd->new_mail_info->mail_data->full_address_to != NULL && ugd->composer_type == RUN_COMPOSER_EXTERNAL)) {
1982 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
1984 email_address_info_t *addrs_info = NULL;
1986 int duplicate_cnt = 0;
1988 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_to) {
1989 temp = g_strdup(ugd->existing_mail_info->mail_data->full_address_to);
1990 debug_log("to = %s", ugd->existing_mail_info->mail_data->full_address_to);
1991 } else if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_to) {
1992 temp = g_strdup(ugd->new_mail_info->mail_data->full_address_to);
1993 debug_log("to = %s", ugd->new_mail_info->mail_data->full_address_to);
1996 token = strtok(temp, ";");
1997 debug_log("to = %s\ntoken = %s", temp, token);
2001 while (token != NULL && (overflow_flag = (i < (MAX_RECIPIENT_COUNT)))) {
2002 temp_name[i] = g_strdup(token);
2004 token = strtok(NULL, ";");
2007 if (!overflow_flag) {
2008 char msg[MAX_STR_LEN] = { 0, };
2009 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
2011 if (ugd->composer_noti) {
2012 evas_object_del(ugd->composer_noti);
2013 ugd->composer_noti = NULL;
2015 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2016 msg, 0, NULL, NULL, 2.0, _composer_noti_response_cb);
2021 if (max >= MAX_RECIPIENT_COUNT)
2022 max = MAX_RECIPIENT_COUNT - 1;
2024 debug_log("To recipients count(%d)", max);
2025 for (i = 0; i < max; i++) {
2026 temp_name[i] = g_strstrip(temp_name[i]);
2027 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2031 debug_critical("_composer_separate_save_recipient_char returned NULL");
2036 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2038 debug_log("email_addr = %s", ri->email_list[0].email_addr);
2039 debug_log("account.email_addr = %s", ugd->account_info->account->user_email_address);
2040 debug_log("from_addr = %s", from_addr);
2042 if (g_strcmp0(ri->email_list[0].email_addr, ugd->account_info->account->user_email_address) != 0 || ugd->composer_type != RUN_COMPOSER_REPLY_ALL) {
2043 if (!_composer_check_recipient_is_duplicated(ugd, ugd->to_mbe, ri)) {
2045 if (!_composer_is_valid_email(ri->email_list[0].email_addr)) {
2046 invalid_address_flag = TRUE;
2047 debug_log("invalid_address_flag is SET");
2050 addrs_info = (email_address_info_t *) g_list_nth_data(ugd->to_list, i);
2052 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
2053 elm_multibuttonentry_item_append(ugd->to_mbe, addrs_info->display_name, NULL, ri);
2055 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
2057 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
2064 if (ri && !ri_used) {
2065 if (ri->display_name) {
2066 free(ri->display_name);
2067 ri->display_name = NULL;
2077 if (duplicate_cnt) {
2078 if (ugd->composer_noti) {
2079 evas_object_del(ugd->composer_noti);
2080 ugd->composer_noti = NULL;
2082 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2083 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2086 if (invalid_address_flag) {
2087 if (ugd->composer_noti) {
2088 evas_object_del(ugd->composer_noti);
2089 ugd->composer_noti = NULL;
2091 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2092 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 0, NULL, NULL, 2.0, _composer_noti_response_cb);
2100 elm_multibuttonentry_expanded_set(ugd->to_mbe, FALSE);
2103 void _composer_add_cc_address(EmailComposerUGD *ugd)
2107 Eina_Bool overflow_flag = TRUE;
2109 if (ugd->composer_type == RUN_COMPOSER_EDIT || ugd->composer_type == RUN_COMPOSER_REPLY_ALL
2110 || ugd->composer_type == RUN_COMPOSER_NEW || ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2112 if ((ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_cc && strlen(ugd->existing_mail_info->mail_data->full_address_cc) > 0)
2113 || (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_cc && strlen(ugd->new_mail_info->mail_data->full_address_cc) > 0)) {
2115 if (ugd->cc_mbe == NULL) {
2116 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2117 email_composer_create_cc_field(ugd);
2118 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2119 email_composer_create_bcc_field(ugd);
2120 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
2121 ugd->b_cc_bcc = false;
2126 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2128 email_address_info_t *addrs_info = NULL;
2130 int duplicate_cnt = 0;
2132 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_cc) {
2133 temp = COMPOSER_STRDUP(ugd->existing_mail_info->mail_data->full_address_cc);
2134 debug_log("cc = %s", ugd->existing_mail_info->mail_data->full_address_cc);
2135 } else if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_cc) {
2136 temp = COMPOSER_STRDUP(ugd->new_mail_info->mail_data->full_address_cc);
2137 debug_log("cc = %s", ugd->new_mail_info->mail_data->full_address_cc);
2140 token = strtok(temp, ";");
2141 debug_log("cc = %s\ntoken = %s", temp, token);
2145 while (token != NULL && (overflow_flag = (i < (MAX_RECIPIENT_COUNT)))) {
2146 temp_name[i] = g_strdup(token);
2148 token = strtok(NULL, ";");
2151 if (!overflow_flag) {
2152 char msg[MAX_STR_LEN] = { 0, };
2153 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
2155 if (ugd->composer_noti) {
2156 evas_object_del(ugd->composer_noti);
2157 ugd->composer_noti = NULL;
2159 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2160 msg, 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2165 debug_log("Cc recipients count(%d)", max);
2166 for (i = 0; i < max; i++) {
2167 temp_name[i] = g_strstrip(temp_name[i]);
2168 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2172 debug_critical("_composer_separate_save_recipient_char returned NULL");
2175 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2177 if (ugd->account_info->account->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_CC && g_strcmp0(ri->email_list[0].email_addr, ugd->account_info->account->user_email_address) == 0) {
2178 ri->is_always_bcc = true;
2181 if (!_composer_check_recipient_is_duplicated(ugd, ugd->cc_mbe, ri)) {
2183 addrs_info = (email_address_info_t *) g_list_nth_data(ugd->cc_list, i);
2185 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
2186 elm_multibuttonentry_item_append(ugd->cc_mbe, addrs_info->display_name, NULL, (void *)ri);
2188 elm_multibuttonentry_item_append(ugd->cc_mbe, ri->display_name, NULL, (void *)ri);
2190 elm_multibuttonentry_item_append(ugd->cc_mbe, ri->display_name, NULL, (void *)ri);
2194 if (ri->display_name) {
2195 free(ri->display_name);
2196 ri->display_name = NULL;
2205 if (duplicate_cnt) {
2206 if (ugd->composer_noti) {
2207 evas_object_del(ugd->composer_noti);
2208 ugd->composer_noti = NULL;
2210 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2211 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2218 if (ugd->account_info->account->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_CC && ugd->composer_type != RUN_COMPOSER_EDIT) {
2220 if (ugd->cc_mbe == NULL) {
2222 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2223 email_composer_create_cc_field(ugd);
2224 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2225 email_composer_create_bcc_field(ugd);
2226 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
2227 ugd->b_cc_bcc = false;
2231 elm_multibuttonentry_expanded_set(ugd->cc_mbe, FALSE);
2234 void _composer_add_bcc_address(EmailComposerUGD *ugd)
2238 Eina_Bool overflow_flag = TRUE;
2240 if (ugd->composer_type == RUN_COMPOSER_EDIT || ugd->composer_type == RUN_COMPOSER_REPLY_ALL
2241 || ugd->composer_type == RUN_COMPOSER_NEW || ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2243 if ((ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_bcc && strlen(ugd->existing_mail_info->mail_data->full_address_bcc) > 0)
2244 || (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_bcc && strlen(ugd->new_mail_info->mail_data->full_address_bcc) > 0)) {
2246 if (ugd->bcc_mbe == NULL) {
2247 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2248 email_composer_create_bcc_field(ugd);
2249 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2250 email_composer_create_cc_field(ugd);
2251 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
2252 ugd->b_cc_bcc = false;
2257 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2259 email_address_info_t *addrs_info = NULL;
2261 int duplicate_cnt = 0;
2263 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_bcc) {
2264 temp = COMPOSER_STRDUP(ugd->existing_mail_info->mail_data->full_address_bcc);
2265 debug_log("bcc = %s", ugd->existing_mail_info->mail_data->full_address_bcc);
2266 } else if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_bcc) {
2267 temp = COMPOSER_STRDUP(ugd->new_mail_info->mail_data->full_address_bcc);
2268 debug_log("bcc = %s", ugd->new_mail_info->mail_data->full_address_bcc);
2271 token = strtok(temp, ";");
2272 debug_log("bcc = %s\ntoken = %s", temp, token);
2276 while (token != NULL && (overflow_flag = (i < (MAX_RECIPIENT_COUNT)))) {
2277 temp_name[i] = g_strdup(token);
2279 token = strtok(NULL, ";");
2282 if (!overflow_flag) {
2283 char msg[MAX_STR_LEN] = { 0, };
2284 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
2286 if (ugd->composer_noti) {
2287 evas_object_del(ugd->composer_noti);
2288 ugd->composer_noti = NULL;
2290 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2291 msg, 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2296 debug_log("Bcc recipients count(%d)", max);
2297 for (i = 0; i < max; i++) {
2298 temp_name[i] = g_strstrip(temp_name[i]);
2299 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2303 debug_critical("_composer_separate_save_recipient_char returned NULL");
2306 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2308 if (ugd->account_info->account->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_BCC && g_strcmp0(ri->email_list[0].email_addr, ugd->account_info->account->user_email_address) == 0) {
2309 ri->is_always_bcc = true;
2312 if (!_composer_check_recipient_is_duplicated(ugd, ugd->bcc_mbe, ri)) {
2313 if (ugd->bcc_list) {
2314 addrs_info = (email_address_info_t *) g_list_nth_data(ugd->bcc_list, i);
2316 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
2317 elm_multibuttonentry_item_append(ugd->bcc_mbe, addrs_info->display_name, NULL, (void *)ri);
2319 elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->display_name, NULL, (void *)ri);
2321 elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->display_name, NULL, (void *)ri);
2325 if (ri->display_name) {
2326 free(ri->display_name);
2327 ri->display_name = NULL;
2336 if (duplicate_cnt) {
2337 if (ugd->composer_noti) {
2338 evas_object_del(ugd->composer_noti);
2339 ugd->composer_noti = NULL;
2341 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2342 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2349 if (ugd->account_info->account->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_BCC && ugd->composer_type != RUN_COMPOSER_EDIT) {
2351 if (ugd->bcc_mbe == NULL) {
2353 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2354 email_composer_create_bcc_field(ugd);
2355 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2356 email_composer_create_cc_field(ugd);
2357 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
2358 ugd->b_cc_bcc = false;
2362 elm_multibuttonentry_expanded_set(ugd->bcc_mbe, FALSE);
2365 void _composer_add_from_address(EmailComposerUGD *ugd)
2369 EmailRecpInfo *ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
2371 ri->selected_email_idx = 0;
2372 ri->display_name = ugd->account_info->account->user_display_name;
2373 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", ugd->account_info->account->user_email_address);
2375 ri->is_contact_info = false;
2376 ri->is_always_bcc = false;
2377 ri->is_from_addr = true;
2379 debug_log("display_name : %s", ri->display_name);
2380 debug_log("email_addr : %s", ri->email_list[0].email_addr);
2382 elm_multibuttonentry_item_append(ugd->from_mbe, ri->display_name, NULL, ri);
2385 void _composer_add_subject(EmailComposerUGD *ugd)
2390 if (ugd->existing_mail_info->mail_data) {
2392 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
2393 if (ugd->existing_mail_info->mail_data->subject)
2394 temp = elm_entry_utf8_to_markup(ugd->existing_mail_info->mail_data->subject);
2396 temp = elm_entry_utf8_to_markup("");
2398 elm_entry_entry_set(ugd->subject_entry, temp);
2399 } else if (ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL || ugd->composer_type == RUN_COMPOSER_FORWARD) {
2400 char subject_temp[MAX_SUBJECT_LEN];
2403 if (ugd->composer_type == RUN_COMPOSER_FORWARD) {
2404 if (ugd->existing_mail_info->mail_data->subject)
2405 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: %s", _("IDS_EMAIL_BODY_FWD_T_EMAIL_PREFIX_ABB"), ugd->existing_mail_info->mail_data->subject);
2407 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: ", _("IDS_EMAIL_BODY_FWD_T_EMAIL_PREFIX_ABB"));
2409 if (ugd->existing_mail_info->mail_data->subject) {
2410 p = strchr(ugd->existing_mail_info->mail_data->subject, ':');
2412 if (strncasecmp(ugd->existing_mail_info->mail_data->subject, "re:", 3) == 0 || strncasecmp(ugd->existing_mail_info->mail_data->subject, "fw:", 3) == 0 || strncasecmp(ugd->existing_mail_info->mail_data->subject, "fwd:", 4) == 0) {
2413 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s%s", _("IDS_EMAIL_BODY_RE"), p);
2415 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: %s", _("IDS_EMAIL_BODY_RE"), ugd->existing_mail_info->mail_data->subject);
2417 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: ", _("IDS_EMAIL_BODY_RE"));
2421 temp = elm_entry_utf8_to_markup(subject_temp);
2422 elm_entry_entry_set(ugd->subject_entry, temp);
2424 } else if (ugd->new_mail_info->mail_data) {
2426 if (ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2428 if (ugd->new_mail_info->mail_data->subject)
2429 temp = elm_entry_utf8_to_markup(ugd->new_mail_info->mail_data->subject);
2431 temp = elm_entry_utf8_to_markup("");
2433 elm_entry_entry_set(ugd->subject_entry, temp);
2437 if (elm_entry_is_empty(ugd->subject_entry))
2438 elm_object_signal_emit(ugd->subject_editfield, "elm,state,guidetext,show", "elm");
2440 elm_object_signal_emit(ugd->subject_editfield, "elm,state,guidetext,hide", "elm");
2442 debug_log("Freed subject :%s", temp);
2449 void _composer_add_body(EmailComposerUGD *ugd)
2452 char *full_text = NULL;
2454 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->body_download_status) {
2455 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
2456 if (ugd->has_body_html) {
2457 debug_log("html composer_type: EDIT");
2459 char *html_text_for_body = NULL;
2460 if (ugd->existing_mail_info->mail_data->file_path_html) {
2461 html_text_for_body = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_html, 0);
2462 } else if (ugd->existing_mail_info->mail_data->file_path_plain) {
2463 /*A plain-text draft mail converted to html mail*/
2464 char *temp_body_plain = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_plain, 0);
2465 html_text_for_body = (char *)email_composer_get_parse_string(temp_body_plain, STR_LEN(temp_body_plain));
2466 debug_log("\nHTML-TEXT:\n%s", html_text_for_body);
2467 free(temp_body_plain);
2470 char szMetaViewportInfo[TEMP_BUFFER_SIZE + 1] = { 0x00, };
2471 strncpy(szMetaViewportInfo, HTML_META_INFORMATION, TEMP_BUFFER_SIZE);
2473 if (html_text_for_body) {
2474 debug_log("html_text_for_body: %s", html_text_for_body);
2475 full_text = g_strconcat(szMetaViewportInfo, html_text_for_body, NULL);
2476 email_composer_save_file(ugd->saved_html_path, full_text, STR_LEN(full_text));
2477 g_free(html_text_for_body);
2479 html_text_for_body = (char *)email_get_buff_from_file(DATADIR"/_email_default.html", 0);
2480 debug_log("html_text_for_body: %s", html_text_for_body);
2481 full_text = g_strconcat(szMetaViewportInfo, html_text_for_body, NULL);
2482 email_composer_save_file(ugd->saved_html_path, full_text, STR_LEN(full_text));
2483 g_free(html_text_for_body);
2486 debug_log("full text:\n%s", full_text);
2491 debug_log("full_text :%s", full_text);
2498 void _composer_make_html_body(EmailComposerUGD *ugd)
2502 char *full_text = NULL;
2503 char *encoded_text = NULL;
2504 char *html_text_for_body = NULL;
2505 char *text_for_original_info = NULL;
2506 char *recipients_list = NULL;
2508 char text_for_from[MAX_STR_LEN] = { 0, };
2509 char text_for_sent[MAX_STR_LEN] = { 0, };
2510 char text_for_to[MAX_STR_LEN] = { 0, };
2511 char text_for_subject[MAX_STR_LEN] = { 0, };
2513 char szMetaViewportInfo[TEMP_BUFFER_SIZE + 1] = { 0x00, };
2515 const char *sent_time = NULL;
2517 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2521 if (((ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL) && ugd->account_info->account->options.reply_with_body) || ugd->composer_type == RUN_COMPOSER_FORWARD) {
2522 if (ugd->existing_mail_info->mail_data->full_address_to) {
2523 temp = COMPOSER_STRDUP(ugd->existing_mail_info->mail_data->full_address_to);
2524 token = strtok(temp, ";");
2525 debug_log("to = %s\ntoken = %s", temp, token);
2529 while (token != NULL) {
2530 temp_name[i] = g_strdup(token);
2531 debug_log("temp_name[%d] = %s, token = %s", i, temp_name[i], token);
2533 token = strtok(NULL, ";");
2534 debug_log(">> temp_name[%d] = %s, token = %s", i, temp_name[i], token);
2536 if (i == MAX_RECIPIENT_COUNT)
2548 debug_log("To recipients count(%d)", max);
2549 for (i = 0; i < max; i++) {
2550 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2553 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2554 if (ri->display_name == NULL) {
2555 debug_log("ri->display_name is NULL!");
2561 s_len = strlen(ri->display_name) + (!t ? 1 : strlen(t) + 3);
2562 debug_log("len = %d", s_len);
2565 s = realloc(t, s_len);
2567 s = (char *)malloc(s_len);
2570 debug_error("memory allocation failed");
2571 if (ri->display_name) {
2572 free(ri->display_name);
2573 ri->display_name = NULL;
2581 memset(s, 0x00, s_len);
2583 memset(s + strlen(s), 0x00, s_len - strlen(s));
2585 sprintf(s + strlen(s), "%s%s", (t ? "; " : ""), ri->display_name);
2589 recipients_list = t;
2591 debug_log("temp_name_list %d", strlen(recipients_list));
2592 debug_log("recipients_list = %s", recipients_list);
2593 debug_log("ugd->existing_mail_info->mail_data->full_address_to = %s", ugd->existing_mail_info->mail_data->full_address_to);
2595 if (ri->display_name) {
2596 free(ri->display_name);
2597 ri->display_name = NULL;
2608 if (ugd->existing_mail_info->mail_data->full_address_from) {
2610 from = email_composer_get_parse_string(ugd->existing_mail_info->mail_data->full_address_from, STR_LEN(ugd->existing_mail_info->mail_data->full_address_from));
2611 snprintf(text_for_from, sizeof(text_for_from), "<b>%s</b> %s<br>\n", _("IDS_EMAIL_BODY_FROM_M_SENDER"), from);
2615 sent_time = _composer_get_sent_time(ugd->existing_mail_info);
2617 snprintf(text_for_sent, sizeof(text_for_sent), "<b>%s</b> %s<br>\n", _("IDS_EMAIL_BODY_SENT_C"), sent_time);
2620 if (recipients_list) {
2621 snprintf(text_for_to, sizeof(text_for_to), ADDED_TEXT, dgettext("sys_string", "IDS_COM_BODY_TO"), recipients_list);
2624 if (ugd->existing_mail_info->mail_data->subject) {
2625 snprintf(text_for_subject, sizeof(text_for_subject), ADDED_TEXT"<br>", dgettext("sys_string", "IDS_COM_BODY_SUBJECT"), ugd->existing_mail_info->mail_data->subject);
2628 text_for_original_info = g_strconcat(DIVIDE_LEFT_LINE_FOR_HTML, _("IDS_EMAIL_BODY_ORIGINAL_MESSAGE"), DIVIDE_RIGHT_LINE_FOR_HTML, text_for_from, text_for_sent, text_for_to, text_for_subject, NULL);
2630 char *html_charset = email_parse_get_filename_from_path(ugd->existing_mail_info->mail_data->file_path_html);
2631 debug_log("html_charset : %s", html_charset);
2634 if ((g_strcmp0(html_charset, "ks_c_5601-1987") == 0) ||
2635 (g_strcmp0(html_charset, "KS_C_5601-1987") == 0) ||
2636 (g_strcmp0(html_charset, "EUCKR") == 0) ||
2637 (g_strcmp0(html_charset, "EUC-KR") == 0) ||
2638 (g_strcmp0(html_charset, "euckr") == 0) ||
2639 (g_strcmp0(html_charset, "euc-kr") == 0)) {
2641 encoded_text = eina_str_convert("UTF-8", "EUC-KR", text_for_original_info);
2643 if (NULL != encoded_text) {
2644 free(text_for_original_info);
2645 text_for_original_info = encoded_text;
2646 encoded_text = NULL;
2649 g_free(html_charset);
2652 if (ugd->existing_mail_info->mail_data->file_path_html) {
2653 html_text_for_body = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_html, 0);
2654 } else if (ugd->existing_mail_info->mail_data->file_path_plain) {
2655 char *temp_body_plain = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_plain, 0);
2657 /*Convert plain-text to html content*/
2658 html_text_for_body = (char *)email_composer_get_parse_string(temp_body_plain, STR_LEN(temp_body_plain));
2659 debug_log("\nHTML-TEXT:\n%s", html_text_for_body);
2660 free(temp_body_plain);
2662 html_text_for_body = g_strdup("\n");
2664 } else if (ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2665 if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->file_path_plain) { /*For Text memo*/
2666 debug_log("file_path_plain(%s)", ugd->new_mail_info->mail_data->file_path_plain);
2667 text_for_original_info = g_strdup("\n");
2668 html_text_for_body = (char *)email_composer_get_parse_string(ugd->new_mail_info->mail_data->file_path_plain, STR_LEN(ugd->new_mail_info->mail_data->file_path_plain));
2669 debug_log("html_text_for_body[%s]", html_text_for_body);
2671 debug_log("Empty html body");
2672 text_for_original_info = g_strdup("\n");
2673 html_text_for_body = g_strdup("\n");
2676 debug_log("Empty html body"); /*For RUN_COMPOSER_NEW*/
2677 text_for_original_info = g_strdup("\n");
2678 html_text_for_body = g_strdup("\n");
2681 strncpy(szMetaViewportInfo, HTML_META_INFORMATION, TEMP_BUFFER_SIZE);
2683 if ((ugd->account_info->account->options).add_signature) {
2684 char signature_text[128] = { 0, };
2686 debug_log("composer_type:%d", ugd->composer_type);
2687 if (ugd->composer_type == RUN_COMPOSER_NEW || ugd->composer_type == RUN_COMPOSER_REPLY
2688 || ugd->composer_type == RUN_COMPOSER_REPLY_ALL || ugd->composer_type == RUN_COMPOSER_FORWARD) {
2689 if ((ugd->account_info->account->options).signature) {
2690 snprintf(signature_text, sizeof(signature_text), "<br><br><br>%s<br><br>", (ugd->account_info->account->options).signature);
2693 full_text = g_strconcat(szMetaViewportInfo, BODY_TAG_START, DIV_TAG_START_ORIGIN_INFO, signature_text, text_for_original_info, DIV_TAG_END,
2694 DIV_TAG_START_ORIGIN_CONTENT, html_text_for_body, DIV_TAG_END, BODY_TAG_END, HTML_TAG_END, NULL);
2695 } else if (ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2696 if ((ugd->account_info->account->options).signature) {
2697 snprintf(signature_text, sizeof(signature_text), "<br><br><br>%s<br><br>", (ugd->account_info->account->options).signature);
2700 full_text = g_strconcat(szMetaViewportInfo, BODY_TAG_START, html_text_for_body, DIV_TAG_START_ORIGIN_INFO, signature_text, text_for_original_info, DIV_TAG_END,
2701 BODY_TAG_END, HTML_TAG_END, NULL);
2704 full_text = g_strconcat(szMetaViewportInfo, DIV_TAG_START_ORIGIN_INFO, text_for_original_info, DIV_TAG_END,
2705 DIV_TAG_START_ORIGIN_CONTENT, html_text_for_body, DIV_TAG_END, NULL);
2708 debug_log("text_for_original_info: %s", text_for_original_info);
2709 debug_log("html_text_for_body: %s", html_text_for_body);
2710 email_composer_save_file(ugd->saved_html_path, full_text, STR_LEN(full_text));
2712 debug_log("full text:\n%s", full_text);
2714 free(recipients_list);
2715 free((char *)sent_time);
2716 free(text_for_original_info);
2718 free(html_text_for_body);
2722 void _composer_add_origin_msg(EmailComposerUGD *ugd)
2726 _composer_make_html_body(ugd);
2729 /* Creates symbolic links to all the inline images */
2730 void _composer_add_softlink_to_inline_images(EmailComposerUGD *ugd)
2735 char *inline_image_name = NULL;
2736 char *softlink_path = NULL;
2737 char *temp_save_name = NULL;
2739 if (ugd->existing_mail_info->mail_data == NULL)
2742 if (ugd->existing_mail_info->mail_data->body_download_status && ugd->existing_mail_info->mail_data->attachment_count > 0) {
2744 for (i = 0; i < ugd->existing_mail_info->mail_data->attachment_count; i++) {
2745 if (ugd->existing_mail_info->attachment_list[i].inline_content_status && ugd->existing_mail_info->attachment_list[i].attachment_path)
2746 /* To do: Must check attachment_temp_list->downloaded condition also.
2747 Though inline content is downloaded, in db 'downloaded' flag set to 0. */
2749 debug_log("attachment_data_list[%d].attachment_path :%s", i, ugd->existing_mail_info->attachment_list[i].attachment_path);
2750 temp_save_name = g_strdup(ugd->existing_mail_info->attachment_list[i].attachment_path);
2751 inline_image_name = email_composer_parse_filepath(temp_save_name, EINA_FALSE);
2752 softlink_path = g_strconcat(EMAIL_TMP_FOLDER, "/", inline_image_name, NULL);
2753 g_free(inline_image_name);
2756 debug_log("softlink_path :%s", softlink_path);
2758 int result = symlink(ugd->existing_mail_info->attachment_list[i].attachment_path, softlink_path);
2759 debug_log("result:%d", result);
2760 free(softlink_path);
2761 free(temp_save_name);
2767 void _composer_add_attachment(EmailComposerUGD *ugd)
2771 if ((ugd->composer_type == RUN_COMPOSER_FORWARD && (ugd->account_info->account->options).forward_with_files != 0) || ugd->composer_type == RUN_COMPOSER_EDIT) {
2772 if (ugd->existing_mail_info->mail_data->body_download_status && ugd->existing_mail_info->mail_data->attachment_count > 0) {
2774 email_attachment_data_t *fwd_attachment_data_list = ugd->existing_mail_info->attachment_list;
2777 int nTotalAttachmentSize = 0;
2780 if (ugd->attachment_item_box == NULL) {
2781 Evas_Object *attachment_item_box;
2782 attachment_item_box = _composer_create_box(ugd->main_layout);
2783 elm_object_part_content_set(ugd->c_layout, "_attachment_field", attachment_item_box);
2784 ugd->attachment_item_box = attachment_item_box;
2786 _composer_attachment_expand_items(ugd);
2789 for (i = 0; i < ugd->existing_mail_info->mail_data->attachment_count; i++) {
2791 if (i >= MAX_ATTACHMENT_ITEM)
2794 if (fwd_attachment_data_list[i].save_status && fwd_attachment_data_list[i].inline_content_status == EINA_FALSE)
2795 /* No need to add Inline images. They are added in _composer_attachment_create_list API. Line no:160. */
2797 debug_log("fwd_attachment_data_list[%d] = %x", i, &fwd_attachment_data_list[i]);
2798 debug_log("downloaded attachment = %s", fwd_attachment_data_list[i].attachment_path);
2799 nTotalAttachmentSize = nTotalAttachmentSize + fwd_attachment_data_list[i].attachment_size;
2801 if (nTotalAttachmentSize / 1024 > MAX_ATTACHMENT_SIZE) {
2803 char msg[MAX_STR_LEN] = { 0, };
2804 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_UNABLE_TO_ATTACH_MAXIMUM_SIZE_OF_FILES_IS_PD_KB"), MAX_ATTACHMENT_SIZE);
2806 if (ugd->composer_noti) {
2807 evas_object_del(ugd->composer_noti);
2808 ugd->composer_noti = NULL;
2810 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2811 msg, 0, NULL, NULL, 2.0, _composer_noti_response_cb);
2814 email_attachment_data_t *attachment_data = (email_attachment_data_t *)calloc(1, sizeof(email_attachment_data_t));
2816 attachment_data->attachment_name = COMPOSER_STRDUP(fwd_attachment_data_list[i].attachment_name);
2817 attachment_data->attachment_path = COMPOSER_STRDUP(fwd_attachment_data_list[i].attachment_path);
2818 attachment_data->save_status = 1;
2819 attachment_data->attachment_size = fwd_attachment_data_list[i].attachment_size;
2821 _composer_attachment_create_list_box(ugd, attachment_data);
2823 } else if (fwd_attachment_data_list[i].save_status == FALSE) {
2824 EMAIL_ATTACHMENT_INFO_S *attachment_info = (EMAIL_ATTACHMENT_INFO_S *) calloc(1, sizeof(EMAIL_ATTACHMENT_INFO_S));
2826 if (attachment_info) {
2827 attachment_info->mail_id = ugd->nExistingMailID;
2828 attachment_info->attach_id = fwd_attachment_data_list[i].attachment_id;
2829 attachment_info->index = ++index;
2830 attachment_info->size = fwd_attachment_data_list[i].attachment_size;
2831 attachment_info->downloaded = fwd_attachment_data_list[i].save_status;
2832 attachment_info->drm = fwd_attachment_data_list[i].drm_status;
2833 attachment_info->inline_content = fwd_attachment_data_list[i].inline_content_status;
2834 attachment_info->name = g_strdup(fwd_attachment_data_list[i].attachment_name);
2835 attachment_info->path = g_strdup(fwd_attachment_data_list[i].attachment_path);
2837 debug_log("mail id (%d)", attachment_info->mail_id);
2838 debug_log("attachments index (%d)", attachment_info->index);
2839 debug_log("attachments attach_id (%d)", attachment_info->attach_id);
2840 debug_log("attachments name (%s)", attachment_info->name ? attachment_info->name : "@niL");
2841 debug_log("attachments path (%s)", attachment_info->path ? attachment_info->path : "@niL");
2842 debug_log("attachments size (%d)", attachment_info->size);
2843 debug_log("attachments download (%d)", attachment_info->downloaded);
2844 debug_log("attachments drm (%d)", attachment_info->drm);
2845 debug_log("attachments inline? (%d)", attachment_info->inline_content);
2847 ugd->fw_attachment_list = g_list_append(ugd->fw_attachment_list, attachment_info);
2849 email_attachment_data_t *attachment_data = (email_attachment_data_t *)calloc(1, sizeof(email_attachment_data_t));
2851 attachment_data->attachment_id = attachment_info->attach_id;
2852 attachment_data->attachment_name = COMPOSER_STRDUP(attachment_info->name);
2853 attachment_data->attachment_path = COMPOSER_STRDUP(attachment_info->path);
2854 attachment_data->save_status = 0;
2855 attachment_data->attachment_size = attachment_info->size;
2856 nTotalAttachmentSize = nTotalAttachmentSize + attachment_data->attachment_size;
2858 _composer_attachment_create_list_box(ugd, attachment_data);
2863 if (ugd->existing_mail_info->mail_data->file_path_html) {
2864 nTotalAttachmentSize += (int)email_get_file_size(ugd->existing_mail_info->mail_data->file_path_html);
2865 debug_log("Total attachments size (including original html body): %d byte", nTotalAttachmentSize);
2871 Evas_Object *_composer_popup_create(Evas_Object *parent, EmailComposerUGD *ugd)
2875 Evas_Object *popup, *window;
2877 window = _composer_create_sub_window(parent);
2878 ugd->popup_win = window;
2883 Evas_Object * bg = evas_object_rectangle_add(evas_object_evas_get(window));
2884 elm_win_resize_object_add(window, bg);
2885 evas_object_color_set(bg, 0, 0, 0, 0);
2886 evas_object_render_op_set(bg, EVAS_RENDER_COPY);
2887 evas_object_show(bg);
2889 popup = elm_popup_add(window);
2890 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2891 evas_object_data_set(popup, "window", window);
2893 evas_object_show(popup);
2894 evas_object_show(window);
2899 void _composer_popup_delete(Evas_Object *popup)
2905 Evas_Object *window = evas_object_data_del(popup, "window");
2908 debug_log("Window Delete");
2909 evas_object_del(window);
2911 debug_log("PopUp Delete");
2912 evas_object_del(popup);
2917 * This API gets the latest recipients list from mbe and checks for change from the initial list
2919 * @param [in] mbe multibuttonentry(to,cc or bcc)
2920 * @param [in] initial_recipients_list contains the list of recipients when composer launched
2922 * @return true if recipients modified or false
2924 bool _composer_check_recipients_modified(Evas_Object *mbe, Eina_List **initial_recipients_list)
2928 if (!mbe || !initial_recipients_list)
2931 const Eina_List *current_list = NULL;
2932 Eina_List *mbe_initial_list = *initial_recipients_list;
2933 bool is_modified = false;
2935 current_list = elm_multibuttonentry_items_get(mbe);
2937 if ((!mbe_initial_list && current_list) || (mbe_initial_list && !current_list)) {
2939 } else if (mbe_initial_list && current_list) {
2940 if (current_list->accounting->count != mbe_initial_list->accounting->count) {
2943 Eina_List *l1 = mbe_initial_list;
2944 const Eina_List *l2 = current_list;
2947 for (index = 0; index < current_list->accounting->count; index++) {
2948 if (eina_list_data_get(l1) != eina_list_data_get(l2)) {
2952 l1 = eina_list_next(l1);
2953 l2 = eina_list_next(l2);
2962 * This API checks whether email content has been modified from the original content
2964 * @param [in] data EmailComposerUGD data
2966 * @return true if mail is modified or false
2968 bool _composer_check_mail_is_modified(void *data)
2974 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2976 bool is_modified = false;
2978 if ((ugd->composer_type == RUN_COMPOSER_EXTERNAL)
2979 || (ugd->to_mbe && _composer_check_recipients_modified(ugd->to_mbe, &ugd->to_mbe_initial_list))
2980 || (ugd->cc_mbe && _composer_check_recipients_modified(ugd->cc_mbe, &ugd->cc_mbe_initial_list))
2981 || (ugd->bcc_mbe && _composer_check_recipients_modified(ugd->bcc_mbe, &ugd->bcc_mbe_initial_list))
2982 || (g_strcmp0(elm_entry_entry_get(ugd->subject_entry), ugd->saved_subject) != 0)) {
2988 bool is_attach_modified = false;
2990 if ((ugd->attach_initial_list && !ugd->attachment_item_obj_list) || (!ugd->attach_initial_list && ugd->attachment_item_obj_list)) {
2991 is_attach_modified = true;
2992 } else if (ugd->attach_initial_list && ugd->attachment_item_obj_list) {
2993 int nInitialListCount = eina_list_count(ugd->attach_initial_list);
2994 int nAttachmentCount = eina_list_count(ugd->attachment_item_obj_list);
2996 if (nInitialListCount != nAttachmentCount) {
2997 is_attach_modified = true;
3000 int nInitialListCount = eina_list_count(ugd->attach_initial_list);
3002 for (i = 0; i < nInitialListCount; i++) {
3003 if (eina_list_nth(ugd->attach_initial_list, i) != eina_list_nth(ugd->attachment_item_obj_list, i)) {
3004 is_attach_modified = true;
3011 if (is_attach_modified) {
3016 if (EINA_TRUE == ugd->has_body_html) {
3017 if (ugd->latest_html_content == NULL) {
3018 debug_log("ugd->latest_html_content is NULL");
3019 is_modified = false;
3023 if (ugd->latest_html_content && ugd->saved_html_content) {
3024 debug_log("saved_html_content:\n%s", ugd->saved_html_content);
3025 debug_log("latest_html_content:\n%s", ugd->latest_html_content);
3026 if (g_strcmp0(ugd->saved_html_content, ugd->latest_html_content) != 0) {
3030 is_modified = false; /*if latest_html_content and/or saved_html_content is NULL,
3031 is_modified set to false; on return false, destroy composer is called*/
3038 _composer_free_initial_email_content(ugd);
3044 bool _composer_check_recipient_is_empty(void *data)
3050 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3052 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->to_mbe)) != NULL) {
3055 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->cc_mbe)) != NULL) {
3058 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->bcc_mbe)) != NULL) {
3065 Evas_Object *_composer_create_sub_window(Evas_Object *parent)
3071 unsigned char *prop_data = NULL;
3075 Eina_Bool accepts_focus;
3076 Ecore_X_Window_State_Hint initial_state;
3077 Ecore_X_Pixmap icon_pixmap;
3078 Ecore_X_Pixmap icon_mask;
3079 Ecore_X_Window icon_window;
3080 Ecore_X_Window window_group;
3081 Eina_Bool is_urgent;
3084 eo = elm_win_add(parent, "composer_sub_win", ELM_WIN_DIALOG_BASIC);
3086 elm_win_alpha_set(eo, EINA_TRUE);
3087 elm_win_title_set(eo, "composer_sub_win");
3089 ecore_x_window_geometry_get(ecore_x_window_root_get(ecore_x_window_focus_get()), &x, &y, &w, &h);
3091 ret = ecore_x_window_prop_property_get(ecore_x_window_root_get(ecore_x_window_focus_get()), ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE, ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
3093 if (ret && prop_data)
3094 memcpy(&rotation, prop_data, sizeof(int));
3097 evas_object_resize(eo, w, h);
3098 evas_object_move(eo, x, y);
3101 elm_win_rotation_with_resize_set(eo, rotation);
3103 ecore_x_icccm_hints_get(elm_win_xwindow_get(eo), &accepts_focus, &initial_state, &icon_pixmap, &icon_mask, &icon_window, &window_group, &is_urgent);
3104 ecore_x_icccm_hints_set(elm_win_xwindow_get(eo), EINA_FALSE, initial_state, icon_pixmap, icon_mask, icon_window, window_group, is_urgent);
3106 evas_object_show(eo);
3108 debug_log("Fail to make SubWindow");
3113 void _composer_unfocus_and_save(void *data)
3117 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3119 if (ugd->to_mbe_entry && elm_object_focus_get(ugd->to_mbe_entry)) {
3120 debug_log("to mbe unfocused");
3121 elm_multibuttonentry_expanded_set(ugd->to_mbe, FALSE);
3122 } else if (ugd->cc_mbe_entry && elm_object_focus_get(ugd->cc_mbe_entry)) {
3123 debug_log("cc mbe unfocused");
3124 elm_object_focus_set(ugd->cc_mbe, EINA_FALSE);
3125 elm_multibuttonentry_expanded_set(ugd->cc_mbe, FALSE);
3126 } else if (ugd->bcc_mbe_entry && elm_object_focus_get(ugd->bcc_mbe_entry)) {
3127 debug_log("bcc mbe unfocused");
3128 elm_object_focus_set(ugd->bcc_mbe, EINA_FALSE);
3129 elm_multibuttonentry_expanded_set(ugd->bcc_mbe, FALSE);
3130 } else if (ugd->subject_entry && elm_object_focus_get(ugd->subject_entry)) {
3131 debug_log("subject unfocused");
3132 elm_object_focus_set(ugd->subject_entry, EINA_FALSE);
3137 void _composer_change_text_to_textblock(char *input, char **output, char *matched_word, char *prefix, char *postfix)
3141 char *found = (char *)strcasestr(input, matched_word);
3147 int idx = found - input;
3148 int buf_len = strlen(input) + strlen(prefix) + strlen(postfix) + 1;
3150 temp = (char *)malloc(buf_len * sizeof(char));
3156 memset(temp, 0x00, buf_len);
3158 strncpy(temp, input, buf_len - 1);
3159 strncpy(temp + idx, prefix, buf_len - strlen(temp) - 1);
3160 strncpy(temp + idx + strlen(prefix), matched_word, buf_len - strlen(temp) - 1);
3161 strncpy(temp + idx + strlen(prefix) + strlen(matched_word), postfix, buf_len - strlen(temp) - 1);
3162 strncpy(temp + idx + strlen(prefix) + strlen(matched_word) + strlen(postfix), input + idx + strlen(matched_word), buf_len - strlen(temp) - 1);
3163 temp[buf_len - 1] = '\0';
3170 Evas_Object *_composer_create_noti_with_list(EmailComposerUGD *ugd, bool use_win, char *title, char *content,
3171 int btn_num, char *btn1_lb, char *btn2_lb,
3172 double timeout, void (*response_cb) (void *data, Evas_Object *obj, void *event_info))
3175 Evas_Object *notify;
3178 notify = _composer_popup_create(ugd->win_main, ugd);
3180 notify = elm_popup_add(ugd->win_main);
3182 debug_log("notify: %p", notify);
3184 debug_log("elm_popup_add returns NULL");
3187 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3190 elm_object_part_text_set(notify, "title,text", title);
3194 elm_object_text_set(notify, content);
3197 #ifdef _POPUP_WITH_LIST
3198 elm_object_style_set(notify, "min_menustyle");
3200 elm_object_style_set(notify, "menustyle");
3204 Evas_Object *peoBtn1 = NULL;
3205 peoBtn1 = elm_button_add(notify);
3206 debug_log("peoBtn1: %p", peoBtn1);
3207 elm_object_style_set(peoBtn1, "popup_button/default");
3208 elm_object_text_set(peoBtn1, btn1_lb);
3209 elm_object_part_content_set(notify, "button1", peoBtn1);
3210 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3211 } else if (btn_num == 2) {
3212 Evas_Object *peoBtn1 = NULL;
3213 peoBtn1 = elm_button_add(notify);
3214 debug_log("peoBtn1: %p", peoBtn1);
3215 elm_object_style_set(peoBtn1, "popup_button/default");
3216 elm_object_text_set(peoBtn1, btn1_lb);
3217 elm_object_part_content_set(notify, "button1", peoBtn1);
3218 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3220 Evas_Object *peoBtn2 = NULL;
3221 peoBtn2 = elm_button_add(notify);
3222 debug_log("peoBtn2: %p", peoBtn2);
3223 elm_object_style_set(peoBtn2, "popup_button/default");
3224 elm_object_text_set(peoBtn2, btn2_lb);
3225 elm_object_part_content_set(notify, "button2", peoBtn2);
3226 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3229 if (timeout > 0.0) {
3230 elm_popup_timeout_set(notify, timeout);
3231 evas_object_smart_callback_add(notify, "timeout", response_cb, ugd);
3232 evas_object_smart_callback_add(notify, "block,clicked", response_cb, ugd);
3235 evas_object_show(notify);
3237 ugd->popup_list = eina_list_append(ugd->popup_list, notify);
3239 debug_log("notify = %x, %p", notify, notify);
3243 Evas_Object *_composer_create_noti(EmailComposerUGD *ugd, bool use_win, char *title, char *content,
3244 int btn_num, char *btn1_lb, char *btn2_lb,
3245 double timeout, void (*response_cb) (void *data, Evas_Object *obj, void *event_info))
3248 Evas_Object *notify;
3251 notify = _composer_popup_create(ugd->win_main, ugd);
3253 notify = elm_popup_add(ugd->win_main);
3255 debug_log("notify: %p", notify);
3257 debug_log("elm_popup_add returns NULL");
3260 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3263 elm_object_part_text_set(notify, "title,text", title);
3267 elm_object_text_set(notify, content);
3271 Evas_Object *peoBtn1 = NULL;
3272 peoBtn1 = elm_button_add(notify);
3273 debug_log("peoBtn1: %p", peoBtn1);
3274 elm_object_style_set(peoBtn1, "popup_button/default");
3275 elm_object_text_set(peoBtn1, btn1_lb);
3276 elm_object_part_content_set(notify, "button1", peoBtn1);
3277 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3278 } else if (btn_num == 2) {
3279 Evas_Object *peoBtn1 = NULL;
3280 peoBtn1 = elm_button_add(notify);
3281 debug_log("peoBtn1: %p", peoBtn1);
3282 elm_object_style_set(peoBtn1, "popup_button/default");
3283 elm_object_text_set(peoBtn1, btn1_lb);
3284 elm_object_part_content_set(notify, "button1", peoBtn1);
3285 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3287 Evas_Object *peoBtn2 = NULL;
3288 peoBtn2 = elm_button_add(notify);
3289 debug_log("peoBtn2: %p", peoBtn2);
3290 elm_object_style_set(peoBtn2, "popup_button/default");
3291 elm_object_text_set(peoBtn2, btn2_lb);
3292 elm_object_part_content_set(notify, "button2", peoBtn2);
3293 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3296 if (timeout > 0.0) {
3297 elm_popup_timeout_set(notify, timeout);
3298 evas_object_smart_callback_add(notify, "timeout", response_cb, ugd);
3299 evas_object_smart_callback_add(notify, "block,clicked", response_cb, ugd);
3302 evas_object_show(notify);
3304 ugd->popup_list = eina_list_append(ugd->popup_list, notify);
3306 debug_log("notify = %x, %p", notify, notify);
3310 Evas_Object *_composer_create_popup(EmailComposerUGD *ugd, bool use_win, char *title, char *content,
3311 int btn_num, char *btn1_lb, char *btn2_lb, char *btn3_lb,
3312 double timeout, void (*response_cb) (void *data, Evas_Object *obj, void *event_info))
3315 Evas_Object *notify;
3318 notify = _composer_popup_create(ugd->win_main, ugd);
3320 notify = elm_popup_add(ugd->win_main);
3322 debug_log("notify: %p", notify);
3324 debug_log("elm_popup_add returns NULL");
3327 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3330 elm_object_part_text_set(notify, "title,text", title);
3334 elm_object_text_set(notify, content);
3338 Evas_Object *peoBtn1 = NULL;
3339 peoBtn1 = elm_button_add(notify);
3340 debug_log("peoBtn1: %p", peoBtn1);
3341 elm_object_style_set(peoBtn1, "popup_button/default");
3342 elm_object_text_set(peoBtn1, btn1_lb);
3343 elm_object_part_content_set(notify, "button1", peoBtn1);
3344 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3345 } else if (btn_num == 2) {
3346 Evas_Object *peoBtn1 = NULL;
3347 peoBtn1 = elm_button_add(notify);
3348 debug_log("peoBtn1: %p", peoBtn1);
3349 elm_object_style_set(peoBtn1, "popup_button/default");
3350 elm_object_text_set(peoBtn1, btn1_lb);
3351 elm_object_part_content_set(notify, "button1", peoBtn1);
3352 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3354 Evas_Object *peoBtn2 = NULL;
3355 peoBtn2 = elm_button_add(notify);
3356 debug_log("peoBtn2: %p", peoBtn2);
3357 elm_object_style_set(peoBtn2, "popup_button/default");
3358 elm_object_text_set(peoBtn2, btn2_lb);
3359 elm_object_part_content_set(notify, "button2", peoBtn2);
3360 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3361 } else if (btn_num == 3) {
3362 Evas_Object *peoBtn1 = NULL;
3363 peoBtn1 = elm_button_add(notify);
3364 debug_log("peoBtn1: %p", peoBtn1);
3365 elm_object_style_set(peoBtn1, "popup_button/default");
3366 elm_object_text_set(peoBtn1, btn1_lb);
3367 elm_object_part_content_set(notify, "button1", peoBtn1);
3368 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3370 Evas_Object *peoBtn2 = NULL;
3371 peoBtn2 = elm_button_add(notify);
3372 debug_log("peoBtn2: %p", peoBtn2);
3373 elm_object_style_set(peoBtn2, "popup_button/default");
3374 elm_object_text_set(peoBtn2, btn2_lb);
3375 elm_object_part_content_set(notify, "button2", peoBtn2);
3376 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3378 Evas_Object *peoBtn3 = NULL;
3379 peoBtn3 = elm_button_add(notify);
3380 debug_log("peoBtn3: %p", peoBtn3);
3381 elm_object_style_set(peoBtn3, "popup_button/default");
3382 elm_object_text_set(peoBtn3, btn3_lb);
3383 elm_object_part_content_set(notify, "button3", peoBtn3);
3384 evas_object_smart_callback_add(peoBtn3, "clicked", response_cb, ugd);
3387 if (timeout > 0.0) {
3388 elm_popup_timeout_set(notify, timeout);
3389 evas_object_smart_callback_add(notify, "timeout", response_cb, ugd);
3390 evas_object_smart_callback_add(notify, "block,clicked", response_cb, ugd);
3393 evas_object_show(notify);
3395 ugd->popup_list = eina_list_append(ugd->popup_list, notify);
3397 debug_log("notify = %x, %p", notify, notify);
3401 void _composer_noti_response_cb(void *data, Evas_Object *obj, void *event_info)
3405 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3407 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
3408 ugd->focus_status = COMPOSER_FOCUS_STATUS_NONE;
3410 Evas_Object *mbe = NULL;
3412 if (ugd->selected_entry == ugd->to_mbe_entry) {
3414 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
3416 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
3420 if (ugd->popup_list) {
3421 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
3422 debug_log("obj: %p", obj);
3423 debug_log("composer_noti: %p", ugd->composer_noti);
3425 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
3427 debug_log("@@@ b_sending = %d", ugd->b_sending);
3429 if (!_composer_check_popup_exist(ugd))
3430 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
3434 ugd->b_sending = false;
3436 evas_object_del(ugd->composer_noti);
3437 ugd->composer_noti = NULL;
3440 void _composer_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
3444 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3446 Evas_Object *mbe = NULL;
3448 if (ugd->selected_entry == ugd->to_mbe_entry) {
3450 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
3452 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
3457 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
3458 elm_multibuttonentry_item_selected_set(item, EINA_FALSE);
3461 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE);
3463 if (ugd->popup_list) {
3464 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
3465 debug_log("obj: %p", obj);
3466 debug_log("composer_noti: %p", ugd->composer_popup);
3468 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_popup/*obj*/);
3470 debug_log("@@@ b_sending = %d", ugd->b_sending);
3472 if (!_composer_check_popup_exist(ugd))
3473 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
3477 ugd->b_sending = false;
3479 evas_object_del(ugd->composer_popup);
3480 ugd->composer_popup = NULL;
3481 ugd->is_mbe_selected = false;
3484 Eina_Bool _composer_check_popup_exist(EmailComposerUGD *ugd)
3488 if (!ugd) return EINA_FALSE;
3490 debug_log("popup list count = %d", eina_list_count(ugd->popup_list));
3491 if (eina_list_count(ugd->popup_list) > 0)
3497 int _composer_get_account_list(EmailComposerUGD *ugd)
3501 int err = email_get_account_list(&ugd->account_info->account_list, &ugd->account_info->account_count);
3503 if (err != EMAIL_ERROR_NONE) {
3504 debug_log("[email-composer] email_account_get_list error");
3505 return COMPOSER_ERROR_NO_ACCOUNT_LIST;
3509 for (i = 0; i < ugd->account_info->account_count; i++) {
3510 debug_log("cnt = %d, account_id = %d, email_addr = %s", i, ugd->account_info->account_list[i].account_id, ugd->account_info->account_list[i].user_email_address);
3513 debug_log("[email-composer] account count = %d", ugd->account_info->account_count);
3515 return COMPOSER_ERROR_NONE;
3518 char *_composer_get_email_addr_from_account_id(EmailComposerUGD *ugd, int account_id)
3523 for (i = 0; i < ugd->account_info->account_count; i++) {
3524 if (ugd->account_info->account_list[i].account_id == account_id)
3525 return g_strdup(ugd->account_info->account_list[i].user_email_address);
3531 char *_composer_get_service_fail_type(int type)
3536 char str[MAX_STR_LEN] = { 0, };
3539 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("IP full"));
3540 return g_strdup(str);
3541 } else if (type == -176) {
3542 ret = _("IDS_EMAIL_POP_NO_SERVICE");
3543 return g_strdup(ret);
3544 } else if (type == -181) {
3545 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("Transport Error"));
3546 return g_strdup(str);
3547 } else if (type == EMAIL_ERROR_NETWORK_TOO_BUSY) {
3548 ret = _("IDS_EMAIL_POP_NETWORK_BUSY");
3549 return g_strdup(ret);
3550 } else if (type == EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS) {
3551 snprintf(str, sizeof(str), _("IDS_EMAIL_POP_YOU_CAN_ONLY_LOG_IN_ONCE_EVERY_PD_MINUTES"), 15);
3552 return g_strdup(str);
3553 } else if (type == EMAIL_ERROR_CONNECTION_FAILURE) {
3554 ret = dgettext("sys_string", "IDS_COM_POP_CONNECTION_FAILED");
3555 return g_strdup(ret);
3556 } else if (type == EMAIL_ERROR_LOGIN_FAILURE) {
3557 ret = _("IDS_EMAIL_POP_LOG_IN_FAILED");
3558 return g_strdup(ret);
3559 } else if (type == EMAIL_ERROR_AUTHENTICATE) {
3560 ret = _("IDS_EMAIL_POP_AUTHENTICATION_FAILED");
3561 return g_strdup(ret);
3562 } else if (type == EMAIL_ERROR_CANCELLED) {
3563 ret = _("IDS_EMAIL_POP_SENDING_CANCELLED");
3564 return g_strdup(ret);
3565 } else if (type == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) {
3566 ret = _("IDS_EMAIL_POP_EMAIL_DELETED_FROM_SERVER");
3567 return g_strdup(ret);
3568 } else if (type == EMAIL_ERROR_NO_SUCH_HOST) {
3569 ret = _("IDS_EMAIL_POP_HOST_NOT_FOUND");
3570 return g_strdup(ret);
3571 } else if (type == EMAIL_ERROR_INVALID_SERVER) {
3572 ret = _("IDS_EMAIL_POP_SERVER_NOT_AVAILABLE");
3573 return g_strdup(ret);
3574 } else if (type == EMAIL_ERROR_MAIL_MEMORY_FULL) {
3575 ret = _("IDS_EMAIL_POP_DEVICE_STORAGE_FULL");
3576 return g_strdup(ret);
3577 } else if (type == EMAIL_ERROR_FAILED_BY_SECURITY_POLICY) {
3578 ret = _("IDS_EMAIL_POP_DOWNLOADING_ATTACHMENTS_ON_THE_MOBILE_DEVICE_IS_NOT_ALLOWED_BY_EXCHANGE_SERVER_POLICY");
3579 return g_strdup(ret);
3580 } else if (type == EMAIL_ERROR_NETWORK_NOT_AVAILABLE) {
3581 ret = N_("Network not available");
3582 return g_strdup(ret);
3583 } else if (type == EMAIL_ERROR_FLIGHT_MODE) {
3584 ret = N_("Flight mode enabled");
3585 return g_strdup(ret);
3586 } else if (type == EMAIL_ERROR_NO_RESPONSE) {
3587 ret = N_("No server response");
3588 return g_strdup(ret);
3589 } else if (type == EMAIL_ERROR_DISCONNECTED) {
3590 ret = N_("Disconnected");
3591 return g_strdup(ret);
3592 } else if (type == EMAIL_ERROR_CONNECTION_BROKEN) {
3593 ret = N_("Connection broken");
3594 return g_strdup(ret);
3596 snprintf(str, sizeof(str), "%s (%d)", dgettext("sys_string", "IDS_COM_POP_UNKNOWN_ERROR_OCCURRED"), type);
3597 return g_strdup(str);
3601 Eina_Bool _composer_mbe_set_focus(void *data)
3605 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3607 debug_log("selected_entry = %x, to_mbe_entry = %x, cc_mbe_entry = %x, bcc_mbe_entry = %x, subject_entry = %x, body_ewkview = %x",
3608 ugd->selected_entry, ugd->to_mbe_entry, ugd->cc_mbe_entry, ugd->bcc_mbe_entry, ugd->subject_entry, ugd->body_ewkview);
3610 if ((ugd->selected_entry == ugd->to_mbe_entry) || (ugd->selected_entry == NULL)) {
3611 debug_log("TO MBE ENTRY FOCUS!!!");
3612 elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
3613 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
3614 debug_log("CC MBE ENTRY FOCUS!!!");
3615 elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
3616 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
3617 debug_log("BCC MBE ENTRY FOCUS!!!");
3618 elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
3619 } else if (ugd->selected_entry == ugd->subject_entry) {
3620 debug_log("SUBJECT ENTRY FOCUS!!!");
3621 elm_object_focus_set(ugd->subject_editfield, EINA_TRUE);
3622 } else if (ugd->selected_entry == ugd->body_ewkview) {
3623 debug_log("BODY WEBKIT FOCUS!!!");
3624 evas_object_focus_set(ugd->body_ewkview, EINA_TRUE);
3625 } else if (ugd->selected_entry == ugd->attachment_contracted_item) {
3626 debug_log("Attachments FOCUS!!!");
3627 elm_object_focus_set(ugd->attachment_contracted_item, EINA_TRUE);
3629 debug_log("NO ENTRY!!! TO MBE ENTRY will get the focus.");
3630 elm_object_focus_set(ugd->to_mbe_entry, EINA_TRUE);
3634 ugd->b_cc_bcc = false;
3636 if (ugd->clipboard_on)
3637 ugd->clipboard_on = false;
3639 if (ugd->idler_set_focus) {
3640 ecore_idler_del(ugd->idler_set_focus);
3641 ugd->idler_set_focus = NULL;
3647 void _composer_resize_body_webview(EmailComposerUGD *ugd, int ime_height)
3649 int nWidth, nHeight;
3651 _composer_display_position(ugd);
3653 ecore_x_window_size_get(ecore_x_window_root_first_get(), &nWidth, &nHeight);
3655 Evas_Coord x, y, w, h;
3657 debug_log(" === ime_height %d", ime_height);
3659 evas_object_geometry_get(ugd->win_main, &x, &y, &w, &h);
3660 debug_log(" === win_main x:%d, y:%d, w:%d, h:%d", x, y, w, h);
3662 evas_object_geometry_get(ugd->body_ewkview, &x, &y, &w, &h);
3663 debug_log(" === body_ewkview x:%d, y:%d, w:%d, h:%d", x, y, w, h);
3665 evas_object_geometry_get(ugd->webkit_ly, &x, &y, &w, &h);
3666 debug_log(" === resize webkit_ly x:%d, y:%d, w:%d, h:%d", x, y, w, h);
3668 if (ugd->isHorizontal == false) {
3669 ugd->is_prediction = ((ime_height - COMPOSER_IME_HEIGHT_V) == 0) ? EINA_FALSE : EINA_TRUE;
3671 ugd->is_prediction = ((ime_height - COMPOSER_IME_HEIGHT_H) == 0) ? EINA_FALSE : EINA_TRUE;
3673 debug_log("ugd->is_prediction(%d) : %d", ugd->is_prediction, ime_height - COMPOSER_IME_HEIGHT_V);
3675 if (ugd->isHorizontal == false) {
3676 // Webkit should be resized after showing/hiding IME
3677 debug_log("nHeight:%d, COMPOSER_NAVI_HEIGHT:%d, indicator_height:%d", nHeight, COMPOSER_NAVI_HEIGHT, COMPOSER_INDI_HEIGHT);
3678 evas_object_size_hint_min_set(ugd->webkit_ly, 0, nHeight - COMPOSER_NAVI_HEIGHT - COMPOSER_INDI_HEIGHT - ime_height);
3680 debug_log("nHeight:%d, COMPOSER_NAVI_HEIGHT:%d, indicator_height:%d", nWidth, COMPOSER_NAVI_HEIGHT, COMPOSER_INDI_HEIGHT);
3681 evas_object_size_hint_min_set(ugd->webkit_ly, 0, nWidth - COMPOSER_NAVI_HEIGHT - ime_height);
3684 if ((ugd->from_mbe != NULL) && (ugd->b_launch_finished == false)) {
3685 ugd->b_launch_finished = true;
3686 ugd->bringin_timer = ecore_timer_add(0.5f, _composer_bringin_cb, ugd);
3690 void _composer_input_panel_resize_cb(void *data, Ecore_IMF_Context *ctx, int value)
3694 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3696 ecore_imf_context_input_panel_geometry_get (ctx, &x, &y, &w, &h);
3697 debug_log("imf = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3699 if (ugd->isHorizontal == false) {
3700 ugd->is_prediction = ((h - COMPOSER_IME_HEIGHT_V) == 0) ? EINA_FALSE : EINA_TRUE;
3702 ugd->is_prediction = ((h - COMPOSER_IME_HEIGHT_H) == 0) ? EINA_FALSE : EINA_TRUE;
3704 _composer_resize_body_webview(ugd, h);
3705 elm_layout_sizing_eval(ugd->c_layout);
3708 void _composer_input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value)
3712 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3714 debug_log("ugd->selected_entry : %d", ugd->selected_entry);
3716 if (ugd->selected_entry != ugd->body_ewkview) {
3719 ecore_imf_context_input_panel_geometry_get(ctx, &x, &y, &w, &h);
3720 debug_log("imf = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3722 debug_log("IME status changed to %d", value);
3725 case ECORE_IMF_INPUT_PANEL_STATE_HIDE: /* :1 */
3727 elm_object_item_signal_emit(ugd->navi_item, "elm,state,sip,hidden", "");
3728 ugd->is_ime_hided = TRUE;
3729 _composer_resize_body_webview(ugd, 0);
3732 case ECORE_IMF_INPUT_PANEL_STATE_SHOW: /* :0 */
3734 elm_object_item_signal_emit(ugd->navi_item, "elm,state,sip,shown", "");
3735 ugd->is_ime_hided = FALSE;
3736 _composer_resize_body_webview(ugd, h);
3739 default: /* ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW :2 */
3740 debug_log("Will show");
3741 elm_object_item_signal_emit(ugd->navi_item, "elm,state,sip,shown", "");
3742 ugd->is_ime_hided = FALSE;
3749 void _composer_display_position(void *data)
3751 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3752 Evas_Coord x = 0, y = 0, w = 0, h = 0;
3754 elm_scroller_region_get(ugd->main_scroller, &x, &y, &w, &h);
3755 debug_log("scroller = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3759 evas_object_geometry_get(ugd->from_ly, &x, &y, &w, &h);
3760 debug_log("from = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3764 evas_object_geometry_get(ugd->to_ly, &x, &y, &w, &h);
3765 debug_log("to = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3769 evas_object_geometry_get(ugd->cc_ly, &x, &y, &w, &h);
3770 debug_log("cc = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3775 evas_object_geometry_get(ugd->bcc_ly, &x, &y, &w, &h);
3776 debug_log("bcc = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3780 evas_object_geometry_get(ugd->subject_ly, &x, &y, &w, &h);
3781 debug_log("subject = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3784 evas_object_geometry_get(ugd->webkit_ly, &x, &y, &w, &h);
3785 debug_log("webview = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3789 static Eina_Bool _composer_print_hit_test_result_hash_fn(const Eina_Hash *hash, const void *key, void *data, void *fdata)
3791 // fdata is the third parameter
3792 debug_log("Func data: %s, Hash entry: %s / %s\n", fdata, (const char *)key, data);
3796 void _composer_print_hit_test_result(Ewk_Hit_Test *hit_test)
3798 Eina_Hash *attr_hash = NULL;
3799 debug_log("context: %d", ewk_hit_test_result_context_get(hit_test));
3800 debug_log("linkURI: %s", ewk_hit_test_link_uri_get(hit_test));
3801 debug_log("linkTitle: %s", ewk_hit_test_link_title_get(hit_test));
3802 debug_log("linkLabel: %s", ewk_hit_test_link_label_get(hit_test));
3803 debug_log("imageURI: %s", ewk_hit_test_image_uri_get(hit_test));
3804 debug_log("mediaURI: %s", ewk_hit_test_media_uri_get(hit_test));
3805 debug_log("nodeData.tagName: %s", ewk_hit_test_tag_name_get(hit_test));
3806 debug_log("nodeData.nodeValue: %s", ewk_hit_test_node_value_get(hit_test));
3807 debug_log("imageData.length: %d", ewk_hit_test_image_buffer_length_get(hit_test));
3808 debug_log("imageData.fileNameExtension: %s", ewk_hit_test_image_file_name_extension_get(hit_test));
3810 attr_hash = ewk_hit_test_attribute_hash_get(hit_test);
3812 eina_hash_foreach(attr_hash, _composer_print_hit_test_result_hash_fn, NULL);
3815 void _composer_coords_ewk_to_evas(Evas_Object *view, int ewkX, int ewkY, int *evasX, int *evasY)
3817 int scrollX, scrollY, viewX, viewY;
3818 ewk_view_scroll_pos_get(view, &scrollX, &scrollY);
3819 evas_object_geometry_get(view, &viewX, &viewY, NULL, NULL);
3821 *evasX = ewkX - scrollX + viewX;
3822 *evasY = ewkY - scrollY + viewY;
3825 void _composer_coords_evas_to_ewk(Evas_Object *view, int evasX, int evasY, int *ewkX, int *ewkY)
3827 debug_log("evasX:%d, evasY:%d", evasX, evasY);
3828 int scrollX, scrollY, viewX, viewY;
3829 ewk_view_scroll_pos_get(view, &scrollX, &scrollY);
3830 evas_object_geometry_get(view, &viewX, &viewY, NULL, NULL);
3831 debug_log("scrollX:%d, scrollY:%d, viewX:%d, viewY:%d", scrollX, scrollY, viewX, viewY);
3833 *ewkX = evasX + scrollX - viewX;
3834 *ewkY = evasY + scrollY - viewY;