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);
484 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
485 nResult = email_update_mail(ugd->new_mail_info->mail_data, ugd->new_mail_info->attachment_list, ugd->new_mail_info->mail_data->attachment_count, NULL, 0);
487 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);
490 debug_log("result of email_add_mail: %d", nResult);
491 if (nResult != EMAIL_ERROR_NONE) {
492 debug_warning("email_add_mail failed! %d", nResult);
496 if (email_check_file_exist(ugd->saved_html_path)) {
497 if (-1 == remove(ugd->saved_html_path)) {
498 debug_warning("Failed to remove file");
499 return COMPOSER_ERROR_FAIL;
503 return COMPOSER_ERROR_NONE;
506 int _composer_move_mailbox_folder(EmailComposerUGD *ugd, email_mailbox_type_e mailbox_type, Eina_Bool b_save_to_draft)
510 int nResult = EMAIL_ERROR_NONE;
512 int mail_ids[1] = { 0, };
513 mail_ids[0] = ugd->nExistingMailID;
515 debug_log("id = %d", mail_ids[0]);
517 nResult = email_get_mailbox_by_mailbox_type(ugd->account_info->account_id, mailbox_type, &ugd->mailbox_info->mail_box);
518 if (nResult != EMAIL_ERROR_NONE) {
519 debug_log("email_get_mailbox_by_mailbox_type failed! %d", nResult);
523 nResult = _composer_make_mail(ugd, b_save_to_draft);
524 if (nResult < COMPOSER_ERROR_NONE) {
525 debug_log("error in _composer_make_mail(%d)", nResult);
529 nResult = email_move_mail_to_mailbox(mail_ids, 1, ugd->mailbox_info->mail_box->mailbox_id);
530 if (nResult != EMAIL_ERROR_NONE) {
531 debug_log("email_move_mail_to_mailbox failed! %d", nResult);
535 if (email_check_file_exist(ugd->saved_html_path)) {
536 if (-1 == remove(ugd->saved_html_path)) {
537 debug_log("Failed to remove file");
538 return COMPOSER_ERROR_FAIL;
542 return COMPOSER_ERROR_NONE;
545 static void _composer_make_draft_html_content(EmailComposerUGD *ugd, char **html_content, Eina_Bool b_save_to_draft)
549 char *latest_info_content = _composer_make_text_with_div_tag(ugd->latest_info_content, 0);
550 char *latest_html_content = _composer_make_text_with_div_tag(ugd->latest_html_content, 1);
552 if (b_save_to_draft == EINA_TRUE) {
553 *html_content = g_strconcat(BODY_TAG_START, latest_info_content, latest_html_content, BODY_TAG_END, NULL);
555 *html_content = g_strconcat(BODY_TAG_START, ugd->latest_info_content, ugd->latest_html_content, BODY_TAG_END, HTML_TAG_END, NULL);
558 if (latest_info_content) {
559 g_free(latest_info_content);
560 latest_info_content = NULL;
562 if (latest_html_content) {
563 g_free(latest_html_content);
564 latest_html_content = NULL;
568 int _composer_make_mail(EmailComposerUGD *ugd, Eina_Bool b_save_to_draft)
572 email_account_t *account = NULL;
573 if (!email_engine_get_account_full_data(ugd->account_info->account_id, &account)) {
574 debug_log("Failed to Get account full data");
575 email_free_account(&account, 1);
576 return COMPOSER_ERROR_GET_DATA_FAIL;
579 if (account == NULL) {
580 debug_log("account is NULL!");
581 return COMPOSER_ERROR_GET_DATA_FAIL;
584 debug_log("acc id = %d", ugd->account_info->account_id);
585 debug_log("priority = %d", (*ugd->account_info->account).options.priority);
586 debug_log("mailbox = %s", ugd->mailbox_info->mail_box->mailbox_name);
587 ugd->new_mail_info->mail_data->account_id = ugd->account_info->account_id;
589 ugd->new_mail_info->mail_data->report_status = EMAIL_MAIL_REPORT_NONE;
591 if (ugd->tracking_option[0] == 1) {
592 ugd->new_mail_info->mail_data->report_status |= EMAIL_MAIL_REQUEST_MDN;
594 if (ugd->tracking_option[1] == 1) {
595 ugd->new_mail_info->mail_data->report_status |= EMAIL_MAIL_REQUEST_DSN;
597 debug_log("ugd->new_mail_info->mail_data->report_status = %d", ugd->new_mail_info->mail_data->report_status);
599 ugd->new_mail_info->mail_data->priority = ugd->priority_option;
601 ugd->new_mail_info->mail_data->server_mailbox_name = strdup(ugd->mailbox_info->mail_box->mailbox_name);
602 ugd->new_mail_info->mail_data->mailbox_id = ugd->mailbox_info->mail_box->mailbox_id;
604 debug_log("user_name = %s, %s", ugd->account_info->account->user_display_name, account->user_display_name);
605 debug_log("email_addr = %s, %s", ugd->account_info->account->user_email_address, account->user_email_address);
607 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
608 ugd->new_mail_info->mail_data->body_download_status = 1;
609 ugd->new_mail_info->mail_data->mail_id = ugd->existing_mail_info->mail_data->mail_id;
612 char uc[MAX_STR_LEN];
613 snprintf(uc, sizeof(uc), "\"%s\"<%s>", account->user_display_name, account->user_email_address);
614 ugd->new_mail_info->mail_data->full_address_from = g_strdup(uc);
615 debug_log("from = %s", uc);
618 debug_log("email_free_account is called");
619 email_free_account(&account, 1);
623 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->to_mbe)) != NULL) {
625 if (_composer_make_recipient_char_to_list(ugd, ugd->to_mbe, &(ugd->new_mail_info->mail_data->full_address_to)) < COMPOSER_ERROR_NONE)
626 return COMPOSER_ERROR_GET_DATA_FAIL;
629 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->cc_mbe)) != NULL) {
631 if (_composer_make_recipient_char_to_list(ugd, ugd->cc_mbe, &(ugd->new_mail_info->mail_data->full_address_cc)) < COMPOSER_ERROR_NONE)
632 return COMPOSER_ERROR_GET_DATA_FAIL;
635 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->bcc_mbe)) != NULL) {
636 debug_log("bcc mbe");
637 if (_composer_make_recipient_char_to_list(ugd, ugd->bcc_mbe, &(ugd->new_mail_info->mail_data->full_address_bcc)) < COMPOSER_ERROR_NONE)
638 return COMPOSER_ERROR_GET_DATA_FAIL;
641 ugd->new_mail_info->mail_data->subject = elm_entry_markup_to_utf8(elm_entry_entry_get(ugd->subject_entry));
643 if (EINA_TRUE == ugd->has_body_html) {
645 if (TRUE == email_check_file_exist(ugd->saved_html_path)) {
646 if (-1 == remove(ugd->saved_html_path)) {
647 debug_log("Failed to remove temp html file");
648 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
652 if (TRUE == email_check_file_exist(SAVE_URI)) {
653 if (-1 == remove(SAVE_URI)) {
654 debug_log("Failed to remove temp text file");
655 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
659 char *html_content = NULL;
660 char *html_content_processed = NULL;
661 char *plain_text_content = NULL;
663 _composer_make_draft_html_content(ugd, &html_content, b_save_to_draft);
665 if (html_content == NULL) {
666 debug_log("html_content is NULL.");
667 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
670 debug_log("\nhtml_content:\n%s", html_content);
673 if (ugd->listOfImageUrls == NULL) {
674 debug_log("No images found or ERROR");
675 html_content_processed = html_content;
680 Eina_List *inline_list = NULL;
682 EINA_LIST_FOREACH(ugd->listOfImageUrls, l, recv) {
683 debug_log("images_list: %s", recv);
684 if (strncmp(recv, "file://", 7) == 0) { /* add only local images(file://), not web images(http://) */
685 debug_log("image = %s", recv + 7);
686 inline_list = eina_list_append(inline_list, recv + 7);
689 if (inline_list != NULL) {
690 if (!email_composer_change_image_paths_to_relative(html_content, &html_content_processed)) {
691 debug_log("email_composer_change_image_paths_to_relative Failed");
692 g_free(html_content);
694 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
696 debug_log("\nhtml_source_processed:\n%s", html_content_processed);
698 _composer_attachment_create_list(ugd, inline_list, EINA_TRUE);
700 g_free(html_content);
703 html_content_processed = html_content;
707 if (EINA_FALSE == email_composer_save_file(ugd->saved_html_path, html_content_processed, strlen(html_content_processed))) {
708 debug_log("Write to html file failed");
709 g_free(html_content_processed);
710 html_content_processed = NULL;
711 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
714 g_free(html_content_processed);
715 html_content_processed = NULL;
718 plain_text_content = g_strdup(ugd->plain_content);
720 if (NULL == plain_text_content) {
721 debug_log("ugd->plain_content is NULL");
722 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
724 if (EINA_FALSE == email_composer_save_file(SAVE_URI, plain_text_content, strlen(plain_text_content))) {
725 debug_log("Write to %s file failed", SAVE_URI);
726 g_free(plain_text_content);
727 plain_text_content = NULL;
728 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
730 g_free(plain_text_content);
731 plain_text_content = NULL;
733 ugd->new_mail_info->mail_data->file_path_html = COMPOSER_STRDUP(ugd->saved_html_path);
734 ugd->new_mail_info->mail_data->file_path_plain = COMPOSER_STRDUP(SAVE_URI);
737 int nAttachmentObjListCount = eina_list_count(ugd->attachment_item_obj_list);
738 debug_log("nAttachmentObjListCount : %d", nAttachmentObjListCount);
740 if (nAttachmentObjListCount > 0) {
742 if (ugd->new_mail_info->attachment_list) {
743 email_free_attachment_data(&ugd->new_mail_info->attachment_list, ugd->new_mail_info->mail_data->attachment_count);
744 ugd->new_mail_info->attachment_list = NULL;
745 ugd->new_mail_info->mail_data->attachment_count = 0;
748 ugd->new_mail_info->mail_data->attachment_count = nAttachmentObjListCount;
750 debug_log("ugd->save_drafts : %d, ugd->new_mail_info->attachment_count : %d", ugd->save_drafts, ugd->new_mail_info->mail_data->attachment_count);
752 ugd->new_mail_info->attachment_list = (email_attachment_data_t *)calloc(nAttachmentObjListCount, sizeof(email_attachment_data_t));
755 Eina_Iterator *it = NULL;
756 Evas_Object *attachment_obj = NULL;
757 email_attachment_data_t *attachment_data;
759 it = eina_list_iterator_new(ugd->attachment_item_obj_list);
761 while (eina_iterator_next(it, (void **)&attachment_obj)) {
763 attachment_data = evas_object_data_get(attachment_obj, "attachment_data");
765 if (attachment_data) {
766 if (attachment_data->save_status == 1) {
767 ugd->new_mail_info->attachment_list[nCount].inline_content_status = attachment_data->inline_content_status;
768 ugd->new_mail_info->attachment_list[nCount].attachment_id = attachment_data->attachment_id;
769 ugd->new_mail_info->attachment_list[nCount].attachment_size = attachment_data->attachment_size;
770 ugd->new_mail_info->attachment_list[nCount].save_status = attachment_data->save_status;
771 ugd->new_mail_info->attachment_list[nCount].attachment_name = COMPOSER_STRDUP(attachment_data->attachment_name);
772 ugd->new_mail_info->attachment_list[nCount].attachment_path = COMPOSER_STRDUP(attachment_data->attachment_path);
774 debug_log("attachment_name : %s", ugd->new_mail_info->attachment_list[nCount].attachment_name);
775 debug_log("attachment_path : %s", ugd->new_mail_info->attachment_list[nCount].attachment_path);
776 debug_log("attachment_id : %d", ugd->new_mail_info->attachment_list[nCount].attachment_id);
777 debug_log("attachment_size : %d", ugd->new_mail_info->attachment_list[nCount].attachment_size);
778 debug_log("save_status : %d", ugd->new_mail_info->attachment_list[nCount].save_status);
779 debug_log("inline_content_status : %d", ugd->new_mail_info->attachment_list[nCount].inline_content_status);
787 ugd->new_mail_info->mail_data->flags_draft_field = 1;
789 return COMPOSER_ERROR_NONE;
792 EmailRecpInfo *_composer_separate_save_recipient_char(EmailComposerUGD *ugd, char *recipient)
795 if (!ugd || !recipient) {
796 debug_log("Function arguments NULL");
799 debug_log("separate recipient char = %s", recipient);
803 if (recipient[0] == ' ') {
804 temp = g_strdup(recipient++);
805 debug_log("temp = %s", temp);
807 temp = g_strdup(recipient);
808 debug_log("temp = %s", temp);
815 gchar **vector = NULL;
817 vector = g_strsplit_set(temp, "\"<>", -1);
819 if (vector == NULL) {
820 debug_log("vector == NULL");
825 EmailRecpInfo *ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
828 debug_log("Memory allocation failed.");
834 gint tok_cnt = g_strv_length(vector);
836 debug_log("tok_cnt = %d", tok_cnt);
837 debug_log("temp = %s", temp);
841 ri->display_name = g_strdup(vector[0]);
842 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", vector[0]);
849 } else if (tok_cnt == 3) {
851 ri->display_name = g_strdup(vector[1]);
852 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", vector[1]);
859 } else if (tok_cnt == 5) {
860 if (vector[1] && vector[3]) {
861 ri->display_name = g_strdup(vector[1]);
862 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", vector[3]);
876 ri->selected_email_idx = 0;
878 ri->is_contact_info = false;
879 ri->is_always_bcc = false;
880 ri->is_from_addr = false;
888 void _composer_convert_ps_to_br(char *input)
890 const char *char_ps = "<ps>";
895 while ((ptr = strstr(input, char_ps))) {
903 int _composer_send_mail(EmailComposerUGD *ugd)
907 if (!ugd->account_info->account) {
908 debug_log("account is NULL");
909 return COMPOSER_ERROR_SEND_FAIL;
912 debug_log("priority = %d", (*ugd->account_info->account).options.priority);
913 debug_log("request read report = %d", (*ugd->account_info->account).options.req_read_receipt);
915 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
916 /* 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.
917 This is because only mailbox name is updated to Outbox using move mail.
919 Correct process will be as below -
921 1) Add new edited email to Outbox.
922 2) Delete the old email from Drafts / Outbox */
924 if (0 < ugd->mailbox_info->mailbox_id) {
925 int ret = _composer_add_mailbox_folder(ugd, EMAIL_MAILBOX_TYPE_OUTBOX, EINA_FALSE);
927 if (ret < COMPOSER_ERROR_NONE) {
928 debug_log("error in _composer_add_mailbox_folder(%d)", ret);
929 return COMPOSER_ERROR_SEND_FAIL;
932 int sync = EMAIL_DELETE_LOCAL_AND_SERVER;
934 /* Retrieve mailbox type from email-service and store it to identify Outbox */
936 debug_log("mailbox type [%d]", ugd->existing_mail_info->mail_data->mailbox_type);
937 if (EMAIL_MAILBOX_TYPE_OUTBOX == ugd->existing_mail_info->mail_data->mailbox_type)
938 sync = EMAIL_DELETE_LOCALLY;
940 debug_log("Account id [%d] mailbox id [%d] mail id [%d]", ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID);
942 if (!email_engine_delete_mail(ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID, sync)) {
943 debug_log("Deleting email is failed.");
944 return COMPOSER_ERROR_SEND_FAIL;
948 debug_critical("mailbox name is null");
949 return COMPOSER_ERROR_SEND_FAIL;
953 int ret = _composer_add_mailbox_folder(ugd, EMAIL_MAILBOX_TYPE_OUTBOX, EINA_FALSE);
955 if (ret < COMPOSER_ERROR_NONE) {
956 debug_log("error in _composer_add_mailbox_folder(%d)", ret);
957 return COMPOSER_ERROR_SEND_FAIL;
964 if ((err = email_send_mail(ugd->new_mail_info->mail_data->mail_id, &handle)) != EMAIL_ERROR_NONE) {
965 debug_log(" fail sending [%d]", err);
966 return COMPOSER_ERROR_SEND_FAIL;
968 debug_log(" finish sending");
969 /* Support sync engine */
970 if (ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL) {
971 debug_log("existing mail id = %d, %d", ugd->nExistingMailID, ugd->existing_mail_info->mail_data->mail_id);
972 email_set_flags_field(ugd->account_info->account->account_id, &ugd->nExistingMailID, 1, EMAIL_FLAGS_ANSWERED_FIELD, 1, 1);
973 } else if (ugd->composer_type == RUN_COMPOSER_FORWARD) {
974 debug_log("existing mail id = %d, %d", ugd->nExistingMailID, ugd->existing_mail_info->mail_data->mail_id);
975 email_set_flags_field(ugd->account_info->account->account_id, &ugd->nExistingMailID, 1, EMAIL_FLAGS_FORWARDED_FIELD, 1, 1);
979 return COMPOSER_ERROR_NONE;
982 int _composer_make_recipient_char_to_list(EmailComposerUGD *ugd, Evas_Object *obj, char **dest)
986 char result[MAX_RECIPIENT_ADDRESSES_LEN] = { 0, };
988 debug_log("obj = %p", obj);
990 Elm_Object_Item *mbe_item;
991 mbe_item = elm_multibuttonentry_first_item_get(obj);
992 debug_log("mbe_item = %p", mbe_item);
998 ri = (EmailRecpInfo *) elm_object_item_data_get(mbe_item);
1000 return COMPOSER_ERROR_GET_DATA_FAIL;
1002 index = ri->selected_email_idx;
1004 debug_log("display name = %s", ri->display_name);
1005 debug_log("email_addr = %s", ri->email_list[index].email_addr);
1007 if (g_strcmp0(result, "") == 0) {
1008 if (ri->display_name)
1009 snprintf(result, sizeof(result), "\"%s\" <%s>", ri->display_name, ri->email_list[index].email_addr);
1011 snprintf(result, sizeof(result), "<%s>", ri->email_list[index].email_addr);
1013 if (ri->display_name)
1014 snprintf(result + strlen(result), sizeof(result) - strlen(result), ";\"%s\" <%s>", ri->display_name, ri->email_list[index].email_addr);
1016 snprintf(result + strlen(result), sizeof(result) - strlen(result), ";<%s>", ri->email_list[index].email_addr);
1019 mbe_item = elm_multibuttonentry_item_next_get(mbe_item);
1022 debug_log("result = %s", result);
1024 *dest = g_strdup(result);
1026 return COMPOSER_ERROR_NONE;
1029 void _composer_save_draft_mail(EmailComposerUGD * ugd)
1034 debug_log("ugd is NULL");
1038 if (ugd->send_timer) {
1039 debug_log("delete send_timer");
1040 ecore_timer_del(ugd->send_timer);
1041 ugd->send_timer = NULL;
1044 int ret = _composer_add_mailbox_folder(ugd, EMAIL_MAILBOX_TYPE_DRAFT, EINA_TRUE);
1046 if (ret < COMPOSER_ERROR_NONE) {
1047 debug_log("Failed save in Drafts(%d)", ret);
1049 if (ugd->popup_list) {
1050 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1051 debug_log("composer_noti: %p", ugd->composer_noti);
1053 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1056 evas_object_del(ugd->composer_noti);
1057 ugd->composer_noti = NULL;
1059 ugd->idler_save_draft = ecore_idler_add(_composer_show_fail_to_save, ugd);
1061 debug_log("Succeed in saving in Drafts");
1062 debug_log("Account id [%d] mailbox id [%d] mail id [%d]", ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID);
1064 if (ugd->popup_list) {
1065 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1066 debug_log("composer_noti: %p", ugd->composer_noti);
1068 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1071 evas_object_del(ugd->composer_noti);
1072 ugd->composer_noti = NULL;
1074 ugd->idler_save_draft = ecore_idler_add(_composer_show_success_to_save, ugd);
1078 void _composer_save_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
1082 debug_log("data is NULL");
1086 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1088 char *pszBtnText = (char *)elm_object_text_get(obj);
1089 debug_log("selected button text = %s", pszBtnText);
1091 if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_YES")) == 0) {
1092 if (ugd->need_download == EINA_TRUE) {
1093 if (ugd->popup_list) {
1094 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1095 debug_log("composer_noti: %p", ugd->composer_noti);
1097 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1100 evas_object_del(ugd->composer_noti);
1101 ugd->composer_noti = NULL;
1103 _composer_download_attachment(ugd);
1105 _composer_save_draft_mail(ugd);
1107 } else if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_NO")) == 0) {
1108 ugd->idler_save_draft = ecore_idler_add(_composer_idler_destroy, ugd);
1109 } else if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_CANCEL")) == 0) {
1110 if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_ENABLE_EDITABLE, _composer_script_executed_cb, NULL) == EINA_FALSE)
1111 debug_log("COMPOSER_JS_ENABLE_EDITABLE failed.");
1112 _composer_noti_response_cb(data, obj, event_info);
1116 Eina_Bool _composer_show_fail_to_save(void *data)
1118 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1120 if (ugd->idler_save_draft) {
1121 debug_log("delete idler_save_draft");
1122 ecore_idler_del(ugd->idler_save_draft);
1123 ugd->idler_save_draft = NULL;
1127 ugd->b_sending = false;
1129 if (ugd->composer_noti) {
1130 evas_object_del(ugd->composer_noti);
1131 ugd->composer_noti = NULL;
1133 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
1134 _("IDS_EMAIL_POP_UNABLE_TO_SAVE_IN_DRAFTS"), 0, NULL, NULL, 1.5, _composer_save_draft_fail_response_cb);
1139 Eina_Bool _composer_show_success_to_save(void *data)
1141 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1143 if (ugd->idler_save_draft) {
1144 debug_log("delete idler_save_draft");
1145 ecore_idler_del(ugd->idler_save_draft);
1146 ugd->idler_save_draft = NULL;
1150 ugd->b_sending = false;
1152 if (ugd->composer_noti) {
1153 evas_object_del(ugd->composer_noti);
1154 ugd->composer_noti = NULL;
1156 ugd->composer_noti = _composer_create_noti(ugd, false, NULL,
1157 _("IDS_EMAIL_POP_SAVED_IN_DRAFTS"), 0, NULL, NULL, 1.5, _composer_save_draft_response_cb);
1162 static void _composer_save_draft_response_cb(void *data, Evas_Object *obj, void *event_info)
1166 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1168 ugd->idler_save_draft = ecore_idler_add(_composer_idler_destroy, ugd);
1171 static void _composer_save_draft_fail_response_cb(void *data, Evas_Object *obj, void *event_info)
1175 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1177 ugd->idler_save_draft = ecore_idler_add(_composer_idler_return, ugd);
1180 Eina_Bool _composer_popup_end_cb(void *data)
1184 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1185 _composer_popup_end(ugd, COMPOSER_ERROR_NONE);
1190 void _composer_popup_end(EmailComposerUGD *ugd, int close_sg)
1194 if (ugd->send_timer) {
1195 debug_log("delete send_timer");
1196 ecore_timer_del(ugd->send_timer);
1197 ugd->send_timer = NULL;
1200 if (ugd->composer_noti) {
1201 evas_object_del(ugd->composer_noti);
1202 ugd->composer_noti = NULL;
1205 if (close_sg == COMPOSER_ERROR_NONE) {
1206 if (elm_multibuttonentry_first_item_get(ugd->to_mbe))
1207 elm_multibuttonentry_clear(ugd->to_mbe);
1208 if (elm_multibuttonentry_first_item_get(ugd->cc_mbe))
1209 elm_multibuttonentry_clear(ugd->cc_mbe);
1210 if (elm_multibuttonentry_first_item_get(ugd->bcc_mbe))
1211 elm_multibuttonentry_clear(ugd->bcc_mbe);
1213 ug_destroy_me(ugd->ug_main);
1215 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
1216 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
1217 elm_object_disabled_set(ugd->send_btm_btn, EINA_FALSE);
1218 elm_object_disabled_set(ugd->cancel_btm_btn, EINA_FALSE);
1220 ugd->bSendBtnDisabled = false;
1224 void _composer_make_default_thumbnail(Evas_Object *eo, char *pszImgPath, int nItemType)
1228 char thumb_path[MAX_ATTACHMENT_FILE_LEN + 1] = { 0, };
1230 if (eo == NULL || pszImgPath == NULL)
1233 debug_log("Image path = %s", pszImgPath);
1235 Evas_Object *icon = eo;
1237 if (nItemType == COMPOSER_ATTACHMENT_ITEM_IMAGE) {
1238 debug_log("Thumbnail type - image");
1240 int err = _composer_attachment_make_ethumb(pszImgPath, thumb_path);
1242 if (err != COMPOSER_ERROR_NONE)
1243 elm_image_file_set(icon, ATTACHMENT_IMAGE_FILE_PATH, NULL);
1245 debug_log("Thumbnail path = %s", thumb_path);
1247 elm_image_file_set(icon, thumb_path, NULL);
1251 else if (nItemType == COMPOSER_ATTACHMENT_ITEM_SOUND)
1252 elm_image_file_set(icon, ATTACHMENT_AUDIO_FILE_PATH, NULL);
1253 else if (nItemType == COMPOSER_ATTACHMENT_ITEM_VIDEO)
1254 elm_image_file_set(icon, ATTACHMENT_VIDEO_FILE_PATH, NULL);
1256 gchar **vector = NULL;
1257 gint tok_cnt = g_strv_length(vector);
1259 vector = g_strsplit_set(pszImgPath, ".", -1);
1260 tok_cnt = g_strv_length(vector);
1261 debug_log("tok_cnt: [%d], file(%s, %s)", tok_cnt, vector[tok_cnt - 2], vector[tok_cnt - 1]);
1262 if (vector[tok_cnt - 1]) {
1263 if (g_strcmp0(vector[tok_cnt - 1], ATTACHMENT_MEDIA_VCARD) == 0) {
1264 elm_image_file_set(icon, ATTACHMENT_VCARD_FILE_PATH, NULL);
1265 } else if (g_strcmp0(vector[tok_cnt - 1], ATTACHMENT_MEDIA_VCALENDAR) == 0) {
1266 elm_image_file_set(icon, ATTACHMENT_VCALENDAR_FILE_PATH, NULL);
1268 elm_image_file_set(icon, ATTACHMENT_ETC_FILE_PATH, NULL);
1271 elm_image_file_set(icon, ATTACHMENT_ETC_FILE_PATH, NULL);
1277 Evas_Object *_composer_load_edj(Evas_Object *parent, const char *file, const char *group)
1283 eo = elm_layout_add(parent);
1285 r = elm_layout_file_set(eo, file, group);
1287 evas_object_del(eo);
1291 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1297 Evas_Object *_composer_create_navigation_layout(EmailComposerUGD *ugd)
1300 Evas_Object *parent = ugd->main_layout;
1301 Evas_Object *navi_bar;
1303 navi_bar = elm_naviframe_add(parent);
1304 elm_object_part_content_set(parent, "elm.swallow.content", navi_bar);
1306 evas_object_show(navi_bar);
1311 Evas_Object *_composer_create_composer_layout(Evas_Object *parent)
1314 Evas_Object *layout;
1316 layout = elm_layout_add(parent);
1318 elm_layout_file_set(layout, COMPOSER_EDJ_NAME, "layout.composer");
1319 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1320 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1321 evas_object_show(layout);
1326 Evas_Object *_composer_create_outer_layout(Evas_Object *parent)
1329 Evas_Object *layout;
1331 layout = elm_layout_add(parent);
1333 elm_layout_theme_set(layout, "layout", "application", "noindicator");
1334 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1335 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1336 evas_object_show(layout);
1341 Evas_Object *_composer_create_main_scroller(Evas_Object *parent)
1344 Evas_Object *scroller;
1346 scroller = elm_scroller_add(parent);
1348 elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE);
1349 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
1350 evas_object_show(scroller);
1355 Evas_Object *_composer_create_box(Evas_Object *parent)
1359 Evas_Object *box = elm_box_add(parent);
1360 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1361 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
1362 evas_object_show(box);
1364 elm_object_focus_allow_set(box, EINA_FALSE);
1369 void _composer_set_mail_info(EmailComposerUGD *ugd)
1373 _composer_add_to_address(ugd);
1374 _composer_add_cc_address(ugd);
1375 _composer_add_bcc_address(ugd);
1377 _composer_add_subject(ugd);
1378 _composer_add_body(ugd);
1380 if (ugd->composer_type != RUN_COMPOSER_EDIT) {
1381 _composer_add_origin_msg(ugd);
1384 if (ugd->composer_type == RUN_COMPOSER_FORWARD && ugd->account_info->account->options.forward_with_files) {
1385 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);
1386 if (ugd->existing_mail_info->mail_data->attachment_count > 0) {
1388 for (i = 0; i < ugd->existing_mail_info->mail_data->attachment_count; i++) {
1389 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);
1390 if (ugd->existing_mail_info->attachment_list[i].save_status == FALSE && ugd->existing_mail_info->attachment_list[i].inline_content_status == FALSE) {
1391 ugd->need_download = EINA_TRUE;
1394 ugd->fw_attach_cnt++;
1396 debug_log("ugd->need_download:%d, fw_dn_cnt:%d, fw_attach_cnt:%d", ugd->need_download, ugd->fw_dn_cnt, ugd->fw_attach_cnt);
1400 _composer_add_attachment(ugd);
1402 char *plain_charset = NULL;
1403 char *charset = NULL;
1404 if ((EINA_TRUE == ugd->has_body_html) &&
1405 (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)) {
1406 _composer_add_softlink_to_inline_images(ugd);
1408 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->file_path_plain) {
1409 plain_charset = email_parse_get_filename_from_path(ugd->existing_mail_info->mail_data->file_path_plain);
1410 debug_log("plain_charset : %s", plain_charset);
1411 if (plain_charset) {
1412 Ewk_Settings *ewkSetting = ewk_view_settings_get(ugd->body_ewkview);
1414 if (ewkSetting == NULL)
1415 debug_log("ewkSetting is NULL.");
1417 ewk_settings_default_encoding_set(ewkSetting, plain_charset);
1420 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->file_path_html) {
1421 charset = email_parse_get_filename_from_path(ugd->existing_mail_info->mail_data->file_path_html);
1422 debug_log("body html filename charset:%s", charset);
1424 Ewk_Settings *ewkSetting = ewk_view_settings_get(ugd->body_ewkview);
1426 if (ewkSetting == NULL)
1427 debug_log("ewkSetting is NULL.");
1429 ewk_settings_default_encoding_set(ewkSetting, charset);
1435 if (EINA_TRUE == ugd->has_body_html) {
1438 char file_path[MAX_PATH_LEN] = { 0, };
1439 snprintf(file_path, sizeof(file_path), "file://%s", ugd->saved_html_path);
1440 debug_log("file_path: (%s)", file_path);
1442 ewk_view_url_set(ugd->body_ewkview, file_path);
1444 g_free(plain_charset);
1450 void _composer_show_download_attachment_popup(EmailComposerUGD *ugd)
1454 char msg[MAX_STR_LEN] = { 0, };
1455 if (ugd->fw_dn_cnt > 1)
1456 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_DOWNLOAD_ATTACHMENTS_Q"));
1458 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_DOWNLOAD_ATTACHMENT_Q"));
1460 if (ugd->dn_noti_popup) {
1461 evas_object_del(ugd->dn_noti_popup);
1462 ugd->dn_noti_popup = NULL;
1464 ugd->dn_noti_popup = _composer_create_noti(ugd, false, NULL, msg, 2,
1465 dgettext("sys_string", "IDS_COM_SK_OK"), dgettext("sys_string", "IDS_COM_SK_CANCEL"), 0.0, _composer_attachment_popup_response_cb);
1468 static void _composer_attachment_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
1473 debug_log("data is NULL");
1477 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1479 char *pszBtnText = (char *)elm_object_text_get(obj);
1480 debug_log("selected button text = %s", pszBtnText);
1482 if (ugd->popup_list) {
1483 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1484 debug_log("obj: %p", obj);
1485 debug_log("dn_noti_popup: %p", ugd->dn_noti_popup);
1487 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->dn_noti_popup/*obj*/);
1490 evas_object_del(ugd->dn_noti_popup);
1491 ugd->dn_noti_popup = NULL;
1493 if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_OK")) == 0) {
1494 _composer_download_attachment(ugd);
1496 } else if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_CANCEL")) == 0) {
1497 ugd->selected_entry = ugd->to_mbe_entry;
1498 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
1503 Eina_Bool _composer_show_progress_popup(void *data)
1505 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1507 Evas_Object *progressbar;
1510 if (ugd->idler_show_progress) {
1511 debug_log("delete idler_show_progress");
1512 ecore_idler_del(ugd->idler_show_progress);
1513 ugd->idler_show_progress = NULL;
1517 ugd->fw_dn_total_cnt = ugd->fw_dn_cnt;
1519 char buf[128] = { 0, };
1521 snprintf(buf, sizeof(buf), "%s [0/%d]", _("IDS_EMAIL_POP_DOWNLOADING_ATTACHMENT_ING"), ugd->fw_dn_cnt);
1523 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1524 debug_log("dn_noti_popup: %p", ugd->dn_noti_popup);
1526 evas_object_del(ugd->dn_noti_popup);
1527 ugd->dn_noti_popup = NULL;
1529 if (ugd->dn_prog_popup) {
1530 evas_object_del(ugd->dn_prog_popup);
1531 ugd->dn_prog_popup = NULL;
1533 popup = _composer_create_noti(ugd, false, NULL, buf, 1,
1534 dgettext("sys_string", "IDS_COM_SK_CANCEL"), NULL, 0.0, _composer_dn_prog_popup_response_cb);
1536 ugd->dn_prog_popup = popup;
1538 Evas_Object *label = elm_label_add(popup);
1539 elm_object_text_set(label, buf);
1540 evas_object_show(label);
1541 ugd->fw_dn_label = label;
1543 Evas_Object *box = elm_box_add(popup);
1545 progressbar = elm_progressbar_add(popup);
1547 elm_object_style_set(progressbar, "list_progress");
1549 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
1550 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1551 elm_progressbar_value_set(progressbar, 0.0);
1552 evas_object_show(progressbar);
1553 ugd->fw_dn_progress = progressbar;
1554 evas_object_show(box);
1556 elm_box_pack_end(box, label);
1557 elm_box_pack_end(box, progressbar);
1559 elm_object_content_set(popup, box);
1564 static void _composer_dn_prog_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
1568 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1570 char *pszBtnText = (char *)elm_object_text_get(obj);
1571 debug_log("selected button text = %s", pszBtnText);
1573 if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_CANCEL")) == 0) {
1574 if (ugd->popup_list) {
1575 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1576 debug_log("obj: %p", obj);
1577 debug_log("dn_prog_popup: %p", ugd->dn_prog_popup);
1579 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->dn_prog_popup/*obj*/);
1582 if (ugd->dn_prog_popup) {
1583 evas_object_del(ugd->dn_prog_popup);
1584 ugd->dn_prog_popup = NULL;
1587 _composer_webkit_set_body_script(data);
1588 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
1589 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
1590 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
1591 elm_object_disabled_set(ugd->send_btm_btn, EINA_FALSE);
1592 elm_object_disabled_set(ugd->cancel_btm_btn, EINA_FALSE);
1594 _composer_cancel_download_attachment(ugd);
1596 ugd->selected_entry = ugd->to_mbe_entry;
1597 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
1601 static Eina_Bool _composer_save_attachment(EmailComposerUGD *ugd, int index)
1605 if (ugd->fw_attachment_list == NULL) {
1609 EMAIL_ATTACHMENT_INFO_S *info = (EMAIL_ATTACHMENT_INFO_S *) g_list_nth_data(ugd->fw_attachment_list, index);
1612 debug_log("EMAIL_ATTACHMENT_INFO_S *info is NULL");
1616 if (!info->downloaded) {
1618 gboolean res = FALSE;
1620 debug_log("Need attachment download");
1622 res = email_engine_attachment_download(ugd->existing_mail_info->mail_data->account_id, info->mail_id, info->index, &handle);
1625 ugd->fw_dn_handle[index] = handle;
1626 ugd->idler_show_progress = ecore_idler_add(_composer_show_progress_popup, ugd);
1628 info->downloaded = false;
1629 _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
1630 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
1631 dgettext("sys_string", "IDS_COM_SK_OK"), NULL,
1632 0, _composer_popup_response_cb);
1635 return (res ? EINA_TRUE : EINA_FALSE);
1641 void _composer_download_attachment(EmailComposerUGD *ugd)
1646 debug_log("ugd->fw_attach_cnt = %d", ugd->fw_attach_cnt);
1648 if (ugd->fw_attach_cnt > 0) {
1649 for ( i = 0 ; i < ugd->fw_attach_cnt ; i++ ) {
1650 if (_composer_save_attachment(ugd, i) == EINA_TRUE) {
1652 service_h service = NULL;
1654 ret = service_create(&service);
1655 debug_log("service_create: %d", ret);
1657 debug_log("service create failed");
1661 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_UPDATE, EMAIL_BUNDLE_KEY_UPDATE);
1662 debug_log("service_add_extra_data: %d", ret);
1664 ret = ug_send_result(ugd->ug_main, service);
1665 debug_log("ug_send_result: %d", ret);
1667 ret = service_destroy(service);
1668 debug_log("service_destroy: %d", ret);
1672 ugd->need_download = EINA_FALSE;
1673 ugd->bSendBtnDisabled = true;
1674 ugd->send_timer = ecore_timer_add(0.5, _composer_send_mail_cb, ugd);
1678 void _composer_update_attachment_info(EmailComposerUGD *ugd, int index)
1682 int nAttachmentObjListCount = eina_list_count(ugd->attachment_item_obj_list);
1683 debug_log("nAttachmentObjListCount : %d", nAttachmentObjListCount);
1685 if (nAttachmentObjListCount > 0) {
1687 Eina_Iterator *it = NULL;
1688 Evas_Object *attachment_obj = NULL;
1689 email_attachment_data_t *attachment_data;
1691 it = eina_list_iterator_new(ugd->attachment_item_obj_list);
1693 while (eina_iterator_next(it, (void **)&attachment_obj)) {
1695 EMAIL_ATTACHMENT_INFO_S *info = (EMAIL_ATTACHMENT_INFO_S *) g_list_nth_data(ugd->fw_attachment_list, nCount);
1696 debug_log("info : %x", info);
1698 debug_log("info->path : %s", info->path);
1699 debug_log("info->downloaded : %d", info->downloaded);
1700 debug_log("info->attach_id : %d", info->attach_id);
1701 if (info->index == index) {
1702 char newpath[MAX_PATH_LEN] = { 0, };
1703 info->downloaded = true;
1704 path = email_engine_get_attachment_path(info->attach_id);
1706 debug_log("info->downloaded : %d", info->downloaded);
1707 debug_log("path : %s", path);
1709 attachment_data = evas_object_data_get(attachment_obj, "attachment_data");
1711 if (attachment_data && path && STR_VALID(path)) {
1713 debug_log("path[%s]", path);
1714 ret = email_attachments_save_file(path, newpath, NULL);
1715 if (ret == EMAIL_EXT_SAVE_ERR_NONE) {
1716 char str[128] = { 0, };
1717 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
1718 ret = status_message_post(str);
1720 debug_log("status_message_post failed: %d", ret);
1723 attachment_data->attachment_path = g_strdup(path);
1724 attachment_data->save_status = info->downloaded;
1725 debug_log("attachment_name : %s", attachment_data->attachment_name);
1726 debug_log("attachment_path : %s", attachment_data->attachment_path);
1727 debug_log("attachment_id : %d", attachment_data->attachment_id);
1728 debug_log("attachment_size : %d", attachment_data->attachment_size);
1729 debug_log("save_status : %d", attachment_data->save_status);
1730 debug_log("inline_content_status : %d", attachment_data->inline_content_status);
1744 void _composer_attachment_cancel_download(EmailComposerUGD *ugd)
1748 int att_cnt = g_list_length(ugd->fw_attachment_list);
1751 debug_log("att_cnt = %d", att_cnt);
1752 for (i = 0; i < att_cnt; i++) {
1753 debug_log("handle index = %d", i);
1754 debug_log("handle = %d", ugd->fw_dn_handle[i]);
1755 email_engine_stop_working(ugd->account_info->account_id, ugd->fw_dn_handle[i]);
1759 void _composer_cancel_download_attachment(EmailComposerUGD *ugd)
1764 service_h service = NULL;
1766 _composer_attachment_cancel_download(ugd);
1768 ret = service_create(&service);
1769 debug_log("service_create: %d", ret);
1771 debug_log("service create failed");
1775 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CANCEL_ALL, "CANCEL_ALL");
1776 debug_log("service_add_extra_data: %d", ret);
1778 ug_send_result(ugd->ug_main, service);
1780 ret = service_destroy(service);
1781 debug_log("service_destroy: %d", ret);
1784 const char *_composer_get_sent_time(EmailComposerMail *mail_info)
1789 time = mail_info->mail_data->date_time;
1791 char *formatted_date = NULL;
1793 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1794 formatted_date = email_get_date_text(icu_locale, "yMMMEEEdhms", &time);
1796 formatted_date = email_get_date_text(icu_locale, "yMMMEEEdHms", &time);
1798 debug_log("date&time: %d [%s]", time, formatted_date);
1800 return formatted_date;
1803 char *_composer_get_wday(int tm_wday)
1808 wday = (char *)g_malloc0(10 * sizeof(char));
1812 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_SUN"));
1815 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_MON"));
1818 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_TUE"));
1821 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_WED"));
1824 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_THU"));
1827 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_FRI"));
1830 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_SAT"));
1839 char *_composer_get_month(int tm_mon)
1844 mon = (char *)g_malloc0(10 * sizeof(char));
1848 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_JAN"));
1851 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_FEB"));
1854 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_MAR"));
1857 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_APR"));
1860 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_MAY"));
1863 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_JUN"));
1866 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_JUL"));
1869 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_AUG"));
1872 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_SEP"));
1875 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_OCT"));
1878 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_NOV"));
1881 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_DEC"));
1890 bool _composer_is_valid_email(const char *addr)
1892 char *token1 = NULL;
1893 char *token2 = NULL;
1895 debug_log("addr = %s", addr);
1897 if (addr[0] == '\0') {
1901 token1 = strchr(addr, '@');
1903 debug_log("there is no @");
1907 if (strchr(&token1[1], '@')) {
1908 debug_log("there is too many @");
1912 token2 = strchr(token1, '.');
1914 debug_log("there is no .");
1918 if ((token2 == token1 + 1) || (*(token2 + 1) == '\0')) {
1919 debug_log("Should be xxx.xxx");
1926 bool _composer_check_recipient_is_duplicated(EmailComposerUGD *ugd, Evas_Object *obj, EmailRecpInfo * ri)
1930 bool isDuplicated = false;
1932 Elm_Object_Item *mbe_item;
1933 EmailRecpInfo *iter_ri = NULL;
1935 mbe_item = elm_multibuttonentry_first_item_get(obj);
1938 iter_ri = elm_object_item_data_get(mbe_item);
1940 if (iter_ri != ri) {
1941 if (!g_strcmp0(iter_ri->email_list[iter_ri->selected_email_idx].email_addr, ri->email_list[0].email_addr)) {
1942 isDuplicated = true;
1947 mbe_item = elm_multibuttonentry_item_next_get(mbe_item);
1950 return isDuplicated;
1953 Eina_Bool _composer_idler_destroy(void *data)
1956 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1958 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_FALSE); // block the focus not to open IME.
1960 if (ugd->idler_save_draft) {
1961 debug_log("delete idler_save_draft");
1962 ecore_idler_del(ugd->idler_save_draft);
1963 ugd->idler_save_draft = NULL;
1966 if (ugd->popup_list) {
1967 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1968 debug_log("composer_noti: %p", ugd->composer_noti);
1970 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
1973 evas_object_del(ugd->composer_noti);
1974 ugd->composer_noti = NULL;
1976 ug_destroy_me(ugd->ug_main);
1981 Eina_Bool _composer_idler_return(void *data)
1984 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1986 if (ugd->idler_save_draft) {
1987 debug_log("delete idler_save_draft");
1988 ecore_idler_del(ugd->idler_save_draft);
1989 ugd->idler_save_draft = NULL;
1992 if (ugd->popup_list) {
1993 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1994 debug_log("composer_noti: %p", ugd->composer_noti);
1996 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
1999 evas_object_del(ugd->composer_noti);
2000 ugd->composer_noti = NULL;
2005 void _composer_entry_filter_remove_markup(void *data, Evas_Object *entry, char **text)
2008 if (text == NULL || *text == NULL) {
2009 debug_log("New Text is NULL");
2013 char *preedit_str = NULL;
2014 char *utf8_text = NULL;
2015 char *convert_text = NULL;
2017 /* Check preeditting text and return if it exist */
2018 preedit_str = strstr(*text, "<preedit_sel>");
2022 /* Convert from markup text to utf8 text from entry */
2023 utf8_text = elm_entry_markup_to_utf8(*text);
2026 /* If the string contains "Carrage return ('\n'), it should be changed "<br>" to show properly */
2027 convert_text = elm_entry_utf8_to_markup(utf8_text);
2030 *text = strdup(convert_text);
2037 void _composer_add_to_address(EmailComposerUGD *ugd)
2041 Eina_Bool overflow_flag = TRUE;
2042 Eina_Bool invalid_address_flag = FALSE;
2044 char *from_addr = NULL;
2046 if (ugd->existing_mail_info->mail_data != NULL && ugd->existing_mail_info->mail_data->full_address_from != NULL &&
2047 (ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL)) {
2050 char *from_temp = g_strdup(ugd->existing_mail_info->mail_data->full_address_from);
2052 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, from_temp);
2055 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2057 if (!_composer_check_recipient_is_duplicated(ugd, ugd->to_mbe, ri)) {
2058 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
2061 if (ugd->composer_noti) {
2062 evas_object_del(ugd->composer_noti);
2063 ugd->composer_noti = NULL;
2065 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2066 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2070 if (ri && !ri_used) {
2071 if (ri->display_name) {
2072 free(ri->display_name);
2073 ri->display_name = NULL;
2082 if ((ugd->existing_mail_info->mail_data != NULL && ugd->existing_mail_info->mail_data->full_address_to != NULL &&
2083 (ugd->composer_type == RUN_COMPOSER_REPLY_ALL || ugd->composer_type == RUN_COMPOSER_EDIT)) ||
2084 (ugd->new_mail_info->mail_data != NULL && ugd->new_mail_info->mail_data->full_address_to != NULL && ugd->composer_type == RUN_COMPOSER_EXTERNAL)) {
2087 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2089 email_address_info_t *addrs_info = NULL;
2091 int duplicate_cnt = 0;
2093 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_to) {
2094 temp = g_strdup(ugd->existing_mail_info->mail_data->full_address_to);
2095 debug_log("to = %s", ugd->existing_mail_info->mail_data->full_address_to);
2096 } else if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_to) {
2097 temp = g_strdup(ugd->new_mail_info->mail_data->full_address_to);
2098 debug_log("to = %s", ugd->new_mail_info->mail_data->full_address_to);
2101 token = strtok(temp, ";");
2102 debug_log("to = %s\ntoken = %s", temp, token);
2106 while (token != NULL && (overflow_flag = (i < (MAX_RECIPIENT_COUNT)))) {
2107 temp_name[i] = g_strdup(token);
2109 token = strtok(NULL, ";");
2112 if (!overflow_flag) {
2113 char msg[MAX_STR_LEN] = { 0, };
2114 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
2116 if (ugd->composer_noti) {
2117 evas_object_del(ugd->composer_noti);
2118 ugd->composer_noti = NULL;
2120 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2121 msg, 0, NULL, NULL, 2.0, _composer_noti_response_cb);
2126 if (max >= MAX_RECIPIENT_COUNT)
2127 max = MAX_RECIPIENT_COUNT - 1;
2129 debug_log("To recipients count(%d)", max);
2130 for (i = 0; i < max; i++) {
2131 temp_name[i] = g_strstrip(temp_name[i]);
2132 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2136 debug_critical("_composer_separate_save_recipient_char returned NULL");
2141 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2143 debug_log("email_addr = %s", ri->email_list[0].email_addr);
2144 debug_log("account.email_addr = %s", ugd->account_info->account->user_email_address);
2145 debug_log("from_addr = %s", from_addr);
2147 if (g_strcmp0(ri->email_list[0].email_addr, ugd->account_info->account->user_email_address) != 0 || ugd->composer_type != RUN_COMPOSER_REPLY_ALL) {
2148 if (!_composer_check_recipient_is_duplicated(ugd, ugd->to_mbe, ri)) {
2150 if (!_composer_is_valid_email(ri->email_list[0].email_addr)) {
2151 invalid_address_flag = TRUE;
2152 debug_log("invalid_address_flag is SET");
2155 addrs_info = (email_address_info_t *) g_list_nth_data(ugd->to_list, i);
2157 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
2158 elm_multibuttonentry_item_append(ugd->to_mbe, addrs_info->display_name, NULL, ri);
2160 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
2162 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
2169 if (ri && !ri_used) {
2170 if (ri->display_name) {
2171 free(ri->display_name);
2172 ri->display_name = NULL;
2182 if (duplicate_cnt) {
2183 if (ugd->composer_noti) {
2184 evas_object_del(ugd->composer_noti);
2185 ugd->composer_noti = NULL;
2187 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2188 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2191 if (invalid_address_flag) {
2192 if (ugd->composer_noti) {
2193 evas_object_del(ugd->composer_noti);
2194 ugd->composer_noti = NULL;
2196 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2197 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 0, NULL, NULL, 2.0, _composer_noti_response_cb);
2205 elm_multibuttonentry_expanded_set(ugd->to_mbe, FALSE);
2208 void _composer_add_cc_address(EmailComposerUGD *ugd)
2212 Eina_Bool overflow_flag = TRUE;
2214 if (ugd->composer_type == RUN_COMPOSER_EDIT || ugd->composer_type == RUN_COMPOSER_REPLY_ALL
2215 || ugd->composer_type == RUN_COMPOSER_NEW || ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2217 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)
2218 || (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)) {
2220 if (ugd->cc_mbe == NULL) {
2221 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2222 email_composer_create_cc_field(ugd);
2223 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2224 email_composer_create_bcc_field(ugd);
2225 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
2226 ugd->b_cc_bcc = false;
2231 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2233 email_address_info_t *addrs_info = NULL;
2235 int duplicate_cnt = 0;
2237 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_cc) {
2238 temp = COMPOSER_STRDUP(ugd->existing_mail_info->mail_data->full_address_cc);
2239 debug_log("cc = %s", ugd->existing_mail_info->mail_data->full_address_cc);
2240 } else if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_cc) {
2241 temp = COMPOSER_STRDUP(ugd->new_mail_info->mail_data->full_address_cc);
2242 debug_log("cc = %s", ugd->new_mail_info->mail_data->full_address_cc);
2245 token = strtok(temp, ";");
2246 debug_log("cc = %s\ntoken = %s", temp, token);
2250 while (token != NULL && (overflow_flag = (i < (MAX_RECIPIENT_COUNT)))) {
2251 temp_name[i] = g_strdup(token);
2253 token = strtok(NULL, ";");
2256 if (!overflow_flag) {
2257 char msg[MAX_STR_LEN] = { 0, };
2258 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
2260 if (ugd->composer_noti) {
2261 evas_object_del(ugd->composer_noti);
2262 ugd->composer_noti = NULL;
2264 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2265 msg, 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2270 debug_log("Cc recipients count(%d)", max);
2271 for (i = 0; i < max; i++) {
2272 temp_name[i] = g_strstrip(temp_name[i]);
2273 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2277 debug_critical("_composer_separate_save_recipient_char returned NULL");
2280 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2282 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) {
2283 ri->is_always_bcc = true;
2286 if (!_composer_check_recipient_is_duplicated(ugd, ugd->cc_mbe, ri)) {
2288 addrs_info = (email_address_info_t *) g_list_nth_data(ugd->cc_list, i);
2290 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
2291 elm_multibuttonentry_item_append(ugd->cc_mbe, addrs_info->display_name, NULL, (void *)ri);
2293 elm_multibuttonentry_item_append(ugd->cc_mbe, ri->display_name, NULL, (void *)ri);
2295 elm_multibuttonentry_item_append(ugd->cc_mbe, ri->display_name, NULL, (void *)ri);
2299 if (ri->display_name) {
2300 free(ri->display_name);
2301 ri->display_name = NULL;
2310 if (duplicate_cnt) {
2311 if (ugd->composer_noti) {
2312 evas_object_del(ugd->composer_noti);
2313 ugd->composer_noti = NULL;
2315 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2316 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2323 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) {
2325 if (ugd->cc_mbe == NULL) {
2327 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2328 email_composer_create_cc_field(ugd);
2329 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2330 email_composer_create_bcc_field(ugd);
2331 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
2332 ugd->b_cc_bcc = false;
2336 elm_multibuttonentry_expanded_set(ugd->cc_mbe, FALSE);
2339 void _composer_add_bcc_address(EmailComposerUGD *ugd)
2343 Eina_Bool overflow_flag = TRUE;
2345 if (ugd->composer_type == RUN_COMPOSER_EDIT || ugd->composer_type == RUN_COMPOSER_REPLY_ALL
2346 || ugd->composer_type == RUN_COMPOSER_NEW || ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2348 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)
2349 || (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)) {
2351 if (ugd->bcc_mbe == NULL) {
2352 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2353 email_composer_create_bcc_field(ugd);
2354 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2355 email_composer_create_cc_field(ugd);
2356 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
2357 ugd->b_cc_bcc = false;
2362 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2364 email_address_info_t *addrs_info = NULL;
2366 int duplicate_cnt = 0;
2368 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_bcc) {
2369 temp = COMPOSER_STRDUP(ugd->existing_mail_info->mail_data->full_address_bcc);
2370 debug_log("bcc = %s", ugd->existing_mail_info->mail_data->full_address_bcc);
2371 } else if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_bcc) {
2372 temp = COMPOSER_STRDUP(ugd->new_mail_info->mail_data->full_address_bcc);
2373 debug_log("bcc = %s", ugd->new_mail_info->mail_data->full_address_bcc);
2376 token = strtok(temp, ";");
2377 debug_log("bcc = %s\ntoken = %s", temp, token);
2381 while (token != NULL && (overflow_flag = (i < (MAX_RECIPIENT_COUNT)))) {
2382 temp_name[i] = g_strdup(token);
2384 token = strtok(NULL, ";");
2387 if (!overflow_flag) {
2388 char msg[MAX_STR_LEN] = { 0, };
2389 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
2391 if (ugd->composer_noti) {
2392 evas_object_del(ugd->composer_noti);
2393 ugd->composer_noti = NULL;
2395 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2396 msg, 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2401 debug_log("Bcc recipients count(%d)", max);
2402 for (i = 0; i < max; i++) {
2403 temp_name[i] = g_strstrip(temp_name[i]);
2404 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2408 debug_critical("_composer_separate_save_recipient_char returned NULL");
2411 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2413 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) {
2414 ri->is_always_bcc = true;
2417 if (!_composer_check_recipient_is_duplicated(ugd, ugd->bcc_mbe, ri)) {
2418 if (ugd->bcc_list) {
2419 addrs_info = (email_address_info_t *) g_list_nth_data(ugd->bcc_list, i);
2421 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
2422 elm_multibuttonentry_item_append(ugd->bcc_mbe, addrs_info->display_name, NULL, (void *)ri);
2424 elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->display_name, NULL, (void *)ri);
2426 elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->display_name, NULL, (void *)ri);
2430 if (ri->display_name) {
2431 free(ri->display_name);
2432 ri->display_name = NULL;
2441 if (duplicate_cnt) {
2442 if (ugd->composer_noti) {
2443 evas_object_del(ugd->composer_noti);
2444 ugd->composer_noti = NULL;
2446 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2447 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2454 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) {
2456 if (ugd->bcc_mbe == NULL) {
2458 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2459 email_composer_create_bcc_field(ugd);
2460 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2461 email_composer_create_cc_field(ugd);
2462 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
2463 ugd->b_cc_bcc = false;
2467 elm_multibuttonentry_expanded_set(ugd->bcc_mbe, FALSE);
2470 void _composer_add_from_address(EmailComposerUGD *ugd)
2474 EmailRecpInfo *ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
2476 ri->selected_email_idx = 0;
2477 ri->display_name = ugd->account_info->account->user_display_name;
2478 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", ugd->account_info->account->user_email_address);
2480 ri->is_contact_info = false;
2481 ri->is_always_bcc = false;
2482 ri->is_from_addr = true;
2484 debug_log("display_name : %s", ri->display_name);
2485 debug_log("email_addr : %s", ri->email_list[0].email_addr);
2487 elm_multibuttonentry_item_append(ugd->from_mbe, ri->display_name, NULL, ri);
2490 void _composer_add_subject(EmailComposerUGD *ugd)
2495 if (ugd->existing_mail_info->mail_data) {
2497 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
2498 if (ugd->existing_mail_info->mail_data->subject)
2499 temp = elm_entry_utf8_to_markup(ugd->existing_mail_info->mail_data->subject);
2501 temp = elm_entry_utf8_to_markup("");
2503 elm_entry_entry_set(ugd->subject_entry, temp);
2504 } else if (ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL || ugd->composer_type == RUN_COMPOSER_FORWARD) {
2505 char subject_temp[MAX_SUBJECT_LEN];
2508 if (ugd->composer_type == RUN_COMPOSER_FORWARD) {
2509 if (ugd->existing_mail_info->mail_data->subject)
2510 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: %s", _("IDS_EMAIL_BODY_FWD_T_EMAIL_PREFIX_ABB"), ugd->existing_mail_info->mail_data->subject);
2512 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: ", _("IDS_EMAIL_BODY_FWD_T_EMAIL_PREFIX_ABB"));
2514 if (ugd->existing_mail_info->mail_data->subject) {
2515 p = strchr(ugd->existing_mail_info->mail_data->subject, ':');
2517 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) {
2518 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s%s", _("IDS_EMAIL_BODY_RE"), p);
2520 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: %s", _("IDS_EMAIL_BODY_RE"), ugd->existing_mail_info->mail_data->subject);
2522 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: ", _("IDS_EMAIL_BODY_RE"));
2526 temp = elm_entry_utf8_to_markup(subject_temp);
2527 elm_entry_entry_set(ugd->subject_entry, temp);
2529 } else if (ugd->new_mail_info->mail_data) {
2531 if (ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2533 if (ugd->new_mail_info->mail_data->subject)
2534 temp = elm_entry_utf8_to_markup(ugd->new_mail_info->mail_data->subject);
2536 temp = elm_entry_utf8_to_markup("");
2538 elm_entry_entry_set(ugd->subject_entry, temp);
2542 if (elm_entry_is_empty(ugd->subject_entry))
2543 elm_object_signal_emit(ugd->subject_editfield, "elm,state,guidetext,show", "elm");
2545 elm_object_signal_emit(ugd->subject_editfield, "elm,state,guidetext,hide", "elm");
2547 debug_log("Freed subject :%s", temp);
2554 void _composer_add_body(EmailComposerUGD *ugd)
2557 char *full_text = NULL;
2559 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->body_download_status) {
2560 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
2561 if (ugd->has_body_html) {
2562 debug_log("html composer_type: EDIT");
2564 char *html_text_for_body = NULL;
2565 if (ugd->existing_mail_info->mail_data->file_path_html) {
2566 html_text_for_body = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_html, 0);
2567 } else if (ugd->existing_mail_info->mail_data->file_path_plain) {
2568 /*A plain-text draft mail converted to html mail*/
2569 char *temp_body_plain = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_plain, 0);
2570 html_text_for_body = (char *)email_composer_get_parse_string(temp_body_plain, STR_LEN(temp_body_plain));
2571 debug_log("\nHTML-TEXT:\n%s", html_text_for_body);
2572 free(temp_body_plain);
2575 char szMetaViewportInfo[TEMP_BUFFER_SIZE + 1] = { 0x00, };
2576 strncpy(szMetaViewportInfo, HTML_META_INFORMATION, TEMP_BUFFER_SIZE);
2578 if (html_text_for_body) {
2579 debug_log("html_text_for_body: %s", html_text_for_body);
2580 full_text = g_strconcat(szMetaViewportInfo, html_text_for_body, NULL);
2581 email_composer_save_file(ugd->saved_html_path, full_text, STR_LEN(full_text));
2582 g_free(html_text_for_body);
2584 html_text_for_body = (char *)email_get_buff_from_file(DATADIR"/_email_default.html", 0);
2585 debug_log("html_text_for_body: %s", html_text_for_body);
2586 full_text = g_strconcat(szMetaViewportInfo, html_text_for_body, NULL);
2587 email_composer_save_file(ugd->saved_html_path, full_text, STR_LEN(full_text));
2588 g_free(html_text_for_body);
2591 debug_log("full text:\n%s", full_text);
2596 debug_log("full_text :%s", full_text);
2603 static char* _composer_get_recipients_list_for_original_body_info(EmailComposerUGD *ugd)
2609 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2610 char *recipients_list = NULL;
2612 if (ugd->existing_mail_info->mail_data->full_address_to) {
2613 temp = COMPOSER_STRDUP(ugd->existing_mail_info->mail_data->full_address_to);
2614 token = strtok(temp, ";");
2615 debug_log("to = %s\ntoken = %s", temp, token);
2619 while (token != NULL) {
2620 temp_name[i] = g_strdup(token);
2621 debug_log("temp_name[%d] = %s, token = %s", i, temp_name[i], token);
2623 token = strtok(NULL, ";");
2624 debug_log(">> temp_name[%d] = %s, token = %s", i, temp_name[i], token);
2626 if (i == MAX_RECIPIENT_COUNT)
2633 debug_log("To recipients count(%d)", max);
2634 for (i = 0; i < max; i++) {
2635 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2638 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2639 if (ri->display_name == NULL) {
2640 debug_log("ri->display_name is NULL!");
2645 recipients_list = g_strconcat((recipients_list ? "; " : ""), ri->display_name, NULL);
2646 debug_log("recipients_list = %s", recipients_list);
2647 debug_log("ugd->existing_mail_info->mail_data->full_address_to = %s", ugd->existing_mail_info->mail_data->full_address_to);
2649 if (ri->display_name) {
2650 free(ri->display_name);
2651 ri->display_name = NULL;
2660 return recipients_list ? g_strdup(recipients_list) : NULL;
2663 static char* __composer_make_original_email_info(EmailComposerUGD *ugd)
2667 char *recipients_list = NULL;
2668 char *text_for_original_info = NULL;
2669 const char *sent_time = NULL;
2671 char text_for_from[MAX_STR_LEN] = { 0, };
2672 char text_for_sent[MAX_STR_LEN] = { 0, };
2673 char text_for_to[MAX_STR_LEN] = { 0, };
2674 char text_for_subject[MAX_STR_LEN] = { 0, };
2676 if (ugd->existing_mail_info && ugd->existing_mail_info->mail_data) {
2677 if (ugd->existing_mail_info->mail_data->full_address_from) {
2679 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));
2680 snprintf(text_for_from, sizeof(text_for_from), "<b>%s</b> %s<br>\n", _("IDS_EMAIL_BODY_FROM_M_SENDER"), from);
2684 sent_time = _composer_get_sent_time(ugd->existing_mail_info);
2686 snprintf(text_for_sent, sizeof(text_for_sent), "<b>%s</b> %s<br>\n", _("IDS_EMAIL_BODY_SENT_C"), sent_time);
2689 recipients_list = _composer_get_recipients_list_for_original_body_info(ugd);
2691 if (recipients_list != NULL) {
2692 snprintf(text_for_to, sizeof(text_for_to), ADDED_TEXT, dgettext("sys_string", "IDS_COM_BODY_TO"), recipients_list);
2694 debug_log("recipients_list is NULL");
2697 if (ugd->existing_mail_info->mail_data->subject) {
2698 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);
2701 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);
2703 //debug_log("text_for_original_info: %s", text_for_original_info);
2706 free((char *)sent_time);
2709 if (recipients_list) {
2710 free(recipients_list);
2711 recipients_list = NULL;
2715 return text_for_original_info ? g_strdup(text_for_original_info) : NULL;
2718 static void _composer_get_original_body_info(EmailComposerUGD *ugd, char **text_for_original_info, char *signature_text)
2722 char *encoded_text = NULL;
2723 char *tmp_info_text = __composer_make_original_email_info(ugd);
2725 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) {
2726 if (tmp_info_text != NULL){
2727 char *html_charset = email_parse_get_filename_from_path(ugd->existing_mail_info->mail_data->file_path_html);
2728 debug_log("html_charset : %s", html_charset);
2731 if ((g_strcmp0(html_charset, "ks_c_5601-1987") == 0) ||
2732 (g_strcmp0(html_charset, "KS_C_5601-1987") == 0) ||
2733 (g_strcmp0(html_charset, "EUCKR") == 0) ||
2734 (g_strcmp0(html_charset, "EUC-KR") == 0) ||
2735 (g_strcmp0(html_charset, "euckr") == 0) ||
2736 (g_strcmp0(html_charset, "euc-kr") == 0)) {
2738 encoded_text = eina_str_convert("UTF-8", "EUC-KR", tmp_info_text);
2740 if (NULL != encoded_text) {
2741 free(tmp_info_text);
2742 tmp_info_text = g_strdup(encoded_text);
2745 encoded_text = NULL;
2748 g_free(html_charset);
2751 debug_log("text_for_original_info is NULL");
2752 tmp_info_text = g_strdup("\n");
2755 free(tmp_info_text);
2756 tmp_info_text = g_strdup("\n");
2759 *text_for_original_info = g_strconcat(DIV_TAG_START_ORIGIN_INFO, signature_text, tmp_info_text, DIV_TAG_END, NULL);
2760 debug_log("text_for_original_info: \n%s", *text_for_original_info);
2762 if (tmp_info_text) {
2763 g_free(tmp_info_text);
2764 tmp_info_text = NULL;
2768 static void _composer_get_html_text_for_body(EmailComposerUGD *ugd, char **html_text_for_body)
2772 char *tmp_html_text = NULL;
2774 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) {
2775 if (ugd->existing_mail_info->mail_data->file_path_html) {
2776 tmp_html_text = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_html, 0);
2777 } else if (ugd->existing_mail_info->mail_data->file_path_plain) {
2778 char *temp_body_plain = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_plain, 0);
2780 /*Convert plain-text to html content*/
2781 tmp_html_text = (char *)email_composer_get_parse_string(temp_body_plain, STR_LEN(temp_body_plain));
2782 debug_log("\nHTML-TEXT:\n%s", tmp_html_text);
2783 free(temp_body_plain);
2785 tmp_html_text = g_strdup("\n");
2787 } else if (ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2788 if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->file_path_plain) { /*For Text memo*/
2789 debug_log("file_path_plain(%s)", ugd->new_mail_info->mail_data->file_path_plain);
2790 tmp_html_text = (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));
2792 debug_log("Empty html body");
2793 tmp_html_text = g_strdup("\n");
2796 debug_log("Empty html body"); /*For RUN_COMPOSER_NEW*/
2797 tmp_html_text = g_strdup("\n");
2800 *html_text_for_body = g_strconcat(DIV_TAG_START_ORIGIN_CONTENT, tmp_html_text, DIV_TAG_END, NULL);
2801 debug_log("html_text_for_body: \n%s", *html_text_for_body);
2803 if (tmp_html_text) {
2804 g_free(tmp_html_text);
2805 tmp_html_text = NULL;
2809 char *_composer_make_text_with_div_tag(char *origin_text, int div_tag)
2813 if (origin_text == NULL) {
2818 return g_strconcat(DIV_TAG_START_ORIGIN_INFO, origin_text, DIV_TAG_END, NULL);
2820 return g_strconcat(DIV_TAG_START_ORIGIN_CONTENT, origin_text, DIV_TAG_END, NULL);
2824 void _composer_make_html_body(EmailComposerUGD *ugd)
2828 char *full_text = NULL;
2829 char *text_for_original_info = NULL;
2830 char *html_text_for_body = NULL;
2831 char szMetaViewportInfo[TEMP_BUFFER_SIZE + 1] = { 0x00, };
2833 _composer_get_html_text_for_body(ugd, &html_text_for_body);
2835 strncpy(szMetaViewportInfo, HTML_META_INFORMATION, TEMP_BUFFER_SIZE);
2837 if ((ugd->account_info->account->options).add_signature) {
2838 char signature_text[128] = { 0, };
2840 if ((ugd->account_info->account->options).signature) {
2841 snprintf(signature_text, sizeof(signature_text), "<br><br><br>%s<br><br>", (ugd->account_info->account->options).signature);
2844 _composer_get_original_body_info(ugd, &text_for_original_info, signature_text);
2846 debug_log("composer_type:%d", ugd->composer_type);
2847 if (ugd->composer_type == RUN_COMPOSER_NEW || ugd->composer_type == RUN_COMPOSER_REPLY
2848 || ugd->composer_type == RUN_COMPOSER_REPLY_ALL || ugd->composer_type == RUN_COMPOSER_FORWARD) {
2850 full_text = g_strconcat(szMetaViewportInfo, BODY_TAG_START, text_for_original_info, html_text_for_body, BODY_TAG_END, HTML_TAG_END, NULL);
2851 } else if (ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2853 full_text = g_strconcat(szMetaViewportInfo, BODY_TAG_START, html_text_for_body, text_for_original_info, BODY_TAG_END, HTML_TAG_END, NULL);
2856 //ugd->original_info_content = g_strconcat(DIV_TAG_START_ORIGIN_INFO, text_for_original_info, DIV_TAG_END, NULL);
2857 _composer_get_original_body_info(ugd, &text_for_original_info, NULL);
2858 full_text = g_strconcat(szMetaViewportInfo, BODY_TAG_START, text_for_original_info, html_text_for_body, BODY_TAG_END, HTML_TAG_END, NULL);
2861 debug_log("full text:\n%s", full_text);
2862 email_composer_save_file(ugd->saved_html_path, full_text, STR_LEN(full_text));
2864 free(text_for_original_info);
2865 free(html_text_for_body);
2869 void _composer_add_origin_msg(EmailComposerUGD *ugd)
2873 _composer_make_html_body(ugd);
2876 /* Creates symbolic links to all the inline images */
2877 void _composer_add_softlink_to_inline_images(EmailComposerUGD *ugd)
2882 char *inline_image_name = NULL;
2883 char *softlink_path = NULL;
2884 char *temp_save_name = NULL;
2886 if (ugd->existing_mail_info->mail_data == NULL)
2889 if (ugd->existing_mail_info->mail_data->body_download_status && ugd->existing_mail_info->mail_data->attachment_count > 0) {
2891 for (i = 0; i < ugd->existing_mail_info->mail_data->attachment_count; i++) {
2892 if (ugd->existing_mail_info->attachment_list[i].inline_content_status && ugd->existing_mail_info->attachment_list[i].attachment_path)
2893 /* To do: Must check attachment_temp_list->downloaded condition also.
2894 Though inline content is downloaded, in db 'downloaded' flag set to 0. */
2896 debug_log("attachment_data_list[%d].attachment_path :%s", i, ugd->existing_mail_info->attachment_list[i].attachment_path);
2897 temp_save_name = g_strdup(ugd->existing_mail_info->attachment_list[i].attachment_path);
2898 inline_image_name = email_composer_parse_filepath(temp_save_name, EINA_FALSE);
2899 softlink_path = g_strconcat(EMAIL_TMP_FOLDER, "/", inline_image_name, NULL);
2900 g_free(inline_image_name);
2903 debug_log("softlink_path :%s", softlink_path);
2905 int result = symlink(ugd->existing_mail_info->attachment_list[i].attachment_path, softlink_path);
2906 debug_log("result:%d", result);
2907 free(softlink_path);
2908 free(temp_save_name);
2914 void _composer_add_attachment(EmailComposerUGD *ugd)
2918 if ((ugd->composer_type == RUN_COMPOSER_FORWARD && (ugd->account_info->account->options).forward_with_files != 0) || ugd->composer_type == RUN_COMPOSER_EDIT) {
2919 if (ugd->existing_mail_info->mail_data->body_download_status && ugd->existing_mail_info->mail_data->attachment_count > 0) {
2921 email_attachment_data_t *fwd_attachment_data_list = ugd->existing_mail_info->attachment_list;
2924 int nTotalAttachmentSize = 0;
2927 if (ugd->attachment_item_box == NULL) {
2928 Evas_Object *attachment_item_box;
2929 attachment_item_box = _composer_create_box(ugd->main_layout);
2930 elm_object_part_content_set(ugd->c_layout, "_attachment_field", attachment_item_box);
2931 ugd->attachment_item_box = attachment_item_box;
2933 _composer_attachment_expand_items(ugd);
2936 for (i = 0; i < ugd->existing_mail_info->mail_data->attachment_count; i++) {
2939 if (i >= MAX_ATTACHMENT_ITEM)
2942 EMAIL_ATTACHMENT_INFO_S *attachment_info = (EMAIL_ATTACHMENT_INFO_S *) calloc(1, sizeof(EMAIL_ATTACHMENT_INFO_S));
2943 email_attachment_data_t *attachment_data = (email_attachment_data_t *)calloc(1, sizeof(email_attachment_data_t));
2945 if (attachment_info) {
2946 attachment_info->mail_id = ugd->nExistingMailID;
2947 attachment_info->attach_id = fwd_attachment_data_list[i].attachment_id;
2948 attachment_info->index = index;
2949 attachment_info->size = fwd_attachment_data_list[i].attachment_size;
2950 attachment_info->downloaded = fwd_attachment_data_list[i].save_status;
2951 attachment_info->drm = fwd_attachment_data_list[i].drm_status;
2952 attachment_info->inline_content = fwd_attachment_data_list[i].inline_content_status;
2953 attachment_info->name = g_strdup(fwd_attachment_data_list[i].attachment_name);
2954 attachment_info->path = g_strdup(fwd_attachment_data_list[i].attachment_path);
2956 debug_log("mail id (%d)", attachment_info->mail_id);
2957 debug_log("attachments index (%d)", attachment_info->index);
2958 debug_log("attachments attach_id (%d)", attachment_info->attach_id);
2959 debug_log("attachments name (%s)", attachment_info->name ? attachment_info->name : "@niL");
2960 debug_log("attachments path (%s)", attachment_info->path ? attachment_info->path : "@niL");
2961 debug_log("attachments size (%d)", attachment_info->size);
2962 debug_log("attachments download (%d)", attachment_info->downloaded);
2963 debug_log("attachments drm (%d)", attachment_info->drm);
2964 debug_log("attachments inline? (%d)", attachment_info->inline_content);
2966 ugd->fw_attachment_list = g_list_append(ugd->fw_attachment_list, attachment_info);
2968 //email_attachment_data_t *attachment_data = (email_attachment_data_t *)calloc(1, sizeof(email_attachment_data_t));
2970 attachment_data->attachment_id = attachment_info->attach_id;
2971 attachment_data->attachment_name = COMPOSER_STRDUP(attachment_info->name);
2972 attachment_data->attachment_path = COMPOSER_STRDUP(attachment_info->path);
2973 attachment_data->save_status = 0;
2974 attachment_data->attachment_size = attachment_info->size;
2975 nTotalAttachmentSize = nTotalAttachmentSize + attachment_data->attachment_size;
2978 if (fwd_attachment_data_list[i].save_status && fwd_attachment_data_list[i].inline_content_status == EINA_FALSE)
2979 /* No need to add Inline images. They are added in _composer_attachment_create_list API. Line no:160. */
2981 debug_log("fwd_attachment_data_list[%d] = %x", i, &fwd_attachment_data_list[i]);
2982 debug_log("downloaded attachment = %s", fwd_attachment_data_list[i].attachment_path);
2983 nTotalAttachmentSize = nTotalAttachmentSize + fwd_attachment_data_list[i].attachment_size;
2985 if (nTotalAttachmentSize / 1024 > MAX_ATTACHMENT_SIZE) {
2987 char msg[MAX_STR_LEN] = { 0, };
2988 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_UNABLE_TO_ATTACH_MAXIMUM_SIZE_OF_FILES_IS_PD_KB"), MAX_ATTACHMENT_SIZE);
2990 if (ugd->composer_noti) {
2991 evas_object_del(ugd->composer_noti);
2992 ugd->composer_noti = NULL;
2994 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2995 msg, 0, NULL, NULL, 2.0, _composer_noti_response_cb);
2998 attachment_data->attachment_name = COMPOSER_STRDUP(fwd_attachment_data_list[i].attachment_name);
2999 attachment_data->attachment_path = COMPOSER_STRDUP(fwd_attachment_data_list[i].attachment_path);
3000 attachment_data->save_status = 1;
3001 attachment_data->attachment_size = fwd_attachment_data_list[i].attachment_size;
3004 _composer_attachment_create_list_box(ugd, attachment_data);
3007 if (ugd->existing_mail_info->mail_data->file_path_html) {
3008 nTotalAttachmentSize += (int)email_get_file_size(ugd->existing_mail_info->mail_data->file_path_html);
3009 debug_log("Total attachments size (including original html body): %d byte", nTotalAttachmentSize);
3015 Evas_Object *_composer_popup_create(Evas_Object *parent, EmailComposerUGD *ugd)
3019 Evas_Object *popup, *window;
3021 window = _composer_create_sub_window(parent);
3022 ugd->popup_win = window;
3027 Evas_Object * bg = evas_object_rectangle_add(evas_object_evas_get(window));
3028 elm_win_resize_object_add(window, bg);
3029 evas_object_color_set(bg, 0, 0, 0, 0);
3030 evas_object_render_op_set(bg, EVAS_RENDER_COPY);
3031 evas_object_show(bg);
3033 popup = elm_popup_add(window);
3034 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3035 evas_object_data_set(popup, "window", window);
3037 evas_object_show(popup);
3038 evas_object_show(window);
3043 void _composer_popup_delete(Evas_Object *popup)
3049 Evas_Object *window = evas_object_data_del(popup, "window");
3052 debug_log("Window Delete");
3053 evas_object_del(window);
3055 debug_log("PopUp Delete");
3056 evas_object_del(popup);
3061 * This API gets the latest recipients list from mbe and checks for change from the initial list
3063 * @param [in] mbe multibuttonentry(to,cc or bcc)
3064 * @param [in] initial_recipients_list contains the list of recipients when composer launched
3066 * @return true if recipients modified or false
3068 bool _composer_check_recipients_modified(Evas_Object *mbe, Eina_List **initial_recipients_list)
3072 if (!mbe || !initial_recipients_list)
3075 const Eina_List *current_list = NULL;
3076 Eina_List *mbe_initial_list = *initial_recipients_list;
3077 bool is_modified = false;
3079 current_list = elm_multibuttonentry_items_get(mbe);
3081 if ((!mbe_initial_list && current_list) || (mbe_initial_list && !current_list)) {
3083 } else if (mbe_initial_list && current_list) {
3084 if (current_list->accounting->count != mbe_initial_list->accounting->count) {
3087 Eina_List *l1 = mbe_initial_list;
3088 const Eina_List *l2 = current_list;
3091 for (index = 0; index < current_list->accounting->count; index++) {
3092 if (eina_list_data_get(l1) != eina_list_data_get(l2)) {
3096 l1 = eina_list_next(l1);
3097 l2 = eina_list_next(l2);
3106 * This API checks whether email content has been modified from the original content
3108 * @param [in] data EmailComposerUGD data
3110 * @return true if mail is modified or false
3112 bool _composer_check_mail_is_modified(void *data)
3118 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3120 bool is_modified = false;
3122 if ((ugd->composer_type == RUN_COMPOSER_EXTERNAL)
3123 || (ugd->to_mbe && _composer_check_recipients_modified(ugd->to_mbe, &ugd->to_mbe_initial_list))
3124 || (ugd->cc_mbe && _composer_check_recipients_modified(ugd->cc_mbe, &ugd->cc_mbe_initial_list))
3125 || (ugd->bcc_mbe && _composer_check_recipients_modified(ugd->bcc_mbe, &ugd->bcc_mbe_initial_list))
3126 || (g_strcmp0(elm_entry_entry_get(ugd->subject_entry), ugd->saved_subject) != 0)) {
3132 bool is_attach_modified = false;
3134 if ((ugd->attach_initial_list && !ugd->attachment_item_obj_list) || (!ugd->attach_initial_list && ugd->attachment_item_obj_list)) {
3135 is_attach_modified = true;
3136 } else if (ugd->attach_initial_list && ugd->attachment_item_obj_list) {
3137 int nInitialListCount = eina_list_count(ugd->attach_initial_list);
3138 int nAttachmentCount = eina_list_count(ugd->attachment_item_obj_list);
3140 if (nInitialListCount != nAttachmentCount) {
3141 is_attach_modified = true;
3144 int nInitialListCount = eina_list_count(ugd->attach_initial_list);
3146 for (i = 0; i < nInitialListCount; i++) {
3147 if (eina_list_nth(ugd->attach_initial_list, i) != eina_list_nth(ugd->attachment_item_obj_list, i)) {
3148 is_attach_modified = true;
3155 if (is_attach_modified) {
3160 if (EINA_TRUE == ugd->has_body_html) {
3161 if (ugd->latest_info_content == NULL) {
3162 debug_log("ugd->latest_info_content is NULL");
3163 is_modified = false;
3167 if (ugd->latest_html_content == NULL) {
3168 debug_log("ugd->latest_html_content is NULL");
3169 is_modified = false;
3173 if (ugd->latest_info_content && ugd->original_info_content) {
3174 debug_log("original_info_content:\n%s", ugd->original_info_content);
3175 debug_log("latest_info_content:\n%s", ugd->latest_info_content);
3176 if (g_strcmp0(ugd->original_info_content, ugd->latest_info_content) != 0) {
3177 debug_log("diff => %d", g_strcmp0(ugd->original_info_content, ugd->latest_info_content));
3182 is_modified = false; /*if latest_html_content and/or saved_html_content is NULL,
3183 is_modified set to false; on return false, destroy composer is called*/
3186 if (ugd->latest_html_content && ugd->original_html_content) {
3187 debug_log("original_html_content:\n%s", ugd->original_html_content);
3188 debug_log("latest_html_content:\n%s", ugd->latest_html_content);
3189 if (g_strcmp0(ugd->original_html_content, ugd->latest_html_content) != 0) {
3193 is_modified = false; /*if latest_html_content and/or saved_html_content is NULL,
3194 is_modified set to false; on return false, destroy composer is called*/
3201 _composer_free_initial_email_content(ugd);
3207 bool _composer_check_recipient_is_empty(void *data)
3213 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3215 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->to_mbe)) != NULL) {
3218 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->cc_mbe)) != NULL) {
3221 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->bcc_mbe)) != NULL) {
3228 Evas_Object *_composer_create_sub_window(Evas_Object *parent)
3234 unsigned char *prop_data = NULL;
3238 Eina_Bool accepts_focus;
3239 Ecore_X_Window_State_Hint initial_state;
3240 Ecore_X_Pixmap icon_pixmap;
3241 Ecore_X_Pixmap icon_mask;
3242 Ecore_X_Window icon_window;
3243 Ecore_X_Window window_group;
3244 Eina_Bool is_urgent;
3247 eo = elm_win_add(parent, "composer_sub_win", ELM_WIN_DIALOG_BASIC);
3249 elm_win_alpha_set(eo, EINA_TRUE);
3250 elm_win_title_set(eo, "composer_sub_win");
3252 ecore_x_window_geometry_get(ecore_x_window_root_get(ecore_x_window_focus_get()), &x, &y, &w, &h);
3254 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);
3256 if (ret && prop_data)
3257 memcpy(&rotation, prop_data, sizeof(int));
3260 evas_object_resize(eo, w, h);
3261 evas_object_move(eo, x, y);
3264 elm_win_rotation_with_resize_set(eo, rotation);
3266 ecore_x_icccm_hints_get(elm_win_xwindow_get(eo), &accepts_focus, &initial_state, &icon_pixmap, &icon_mask, &icon_window, &window_group, &is_urgent);
3267 ecore_x_icccm_hints_set(elm_win_xwindow_get(eo), EINA_FALSE, initial_state, icon_pixmap, icon_mask, icon_window, window_group, is_urgent);
3269 evas_object_show(eo);
3271 debug_log("Fail to make SubWindow");
3276 void _composer_unfocus_and_save(void *data)
3280 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3282 if (ugd->to_mbe_entry && elm_object_focus_get(ugd->to_mbe_entry)) {
3283 debug_log("to mbe unfocused");
3284 elm_multibuttonentry_expanded_set(ugd->to_mbe, FALSE);
3285 } else if (ugd->cc_mbe_entry && elm_object_focus_get(ugd->cc_mbe_entry)) {
3286 debug_log("cc mbe unfocused");
3287 elm_object_focus_set(ugd->cc_mbe, EINA_FALSE);
3288 elm_multibuttonentry_expanded_set(ugd->cc_mbe, FALSE);
3289 } else if (ugd->bcc_mbe_entry && elm_object_focus_get(ugd->bcc_mbe_entry)) {
3290 debug_log("bcc mbe unfocused");
3291 elm_object_focus_set(ugd->bcc_mbe, EINA_FALSE);
3292 elm_multibuttonentry_expanded_set(ugd->bcc_mbe, FALSE);
3293 } else if (ugd->subject_entry && elm_object_focus_get(ugd->subject_entry)) {
3294 debug_log("subject unfocused");
3295 elm_object_focus_set(ugd->subject_entry, EINA_FALSE);
3300 void _composer_change_text_to_textblock(char *input, char **output, char *matched_word, char *prefix, char *postfix)
3304 char *found = (char *)strcasestr(input, matched_word);
3310 int idx = found - input;
3311 int buf_len = strlen(input) + strlen(prefix) + strlen(postfix) + 1;
3313 temp = (char *)malloc(buf_len * sizeof(char));
3319 memset(temp, 0x00, buf_len);
3321 strncpy(temp, input, buf_len - 1);
3322 strncpy(temp + idx, prefix, buf_len - strlen(temp) - 1);
3323 strncpy(temp + idx + strlen(prefix), matched_word, buf_len - strlen(temp) - 1);
3324 strncpy(temp + idx + strlen(prefix) + strlen(matched_word), postfix, buf_len - strlen(temp) - 1);
3325 strncpy(temp + idx + strlen(prefix) + strlen(matched_word) + strlen(postfix), input + idx + strlen(matched_word), buf_len - strlen(temp) - 1);
3326 temp[buf_len - 1] = '\0';
3333 Evas_Object *_composer_create_noti_with_list(EmailComposerUGD *ugd, bool use_win, char *title, char *content,
3334 int btn_num, char *btn1_lb, char *btn2_lb,
3335 double timeout, void (*response_cb) (void *data, Evas_Object *obj, void *event_info))
3338 Evas_Object *notify;
3341 notify = _composer_popup_create(ugd->win_main, ugd);
3343 notify = elm_popup_add(ugd->win_main);
3345 debug_log("notify: %p", notify);
3347 debug_log("elm_popup_add returns NULL");
3350 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3353 elm_object_part_text_set(notify, "title,text", title);
3357 elm_object_text_set(notify, content);
3360 #ifdef _POPUP_WITH_LIST
3361 elm_object_style_set(notify, "min_menustyle");
3363 elm_object_style_set(notify, "menustyle");
3367 Evas_Object *peoBtn1 = NULL;
3368 peoBtn1 = elm_button_add(notify);
3369 debug_log("peoBtn1: %p", peoBtn1);
3370 elm_object_style_set(peoBtn1, "popup_button/default");
3371 elm_object_text_set(peoBtn1, btn1_lb);
3372 elm_object_part_content_set(notify, "button1", peoBtn1);
3373 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3374 } else if (btn_num == 2) {
3375 Evas_Object *peoBtn1 = NULL;
3376 peoBtn1 = elm_button_add(notify);
3377 debug_log("peoBtn1: %p", peoBtn1);
3378 elm_object_style_set(peoBtn1, "popup_button/default");
3379 elm_object_text_set(peoBtn1, btn1_lb);
3380 elm_object_part_content_set(notify, "button1", peoBtn1);
3381 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3383 Evas_Object *peoBtn2 = NULL;
3384 peoBtn2 = elm_button_add(notify);
3385 debug_log("peoBtn2: %p", peoBtn2);
3386 elm_object_style_set(peoBtn2, "popup_button/default");
3387 elm_object_text_set(peoBtn2, btn2_lb);
3388 elm_object_part_content_set(notify, "button2", peoBtn2);
3389 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3392 if (timeout > 0.0) {
3393 elm_popup_timeout_set(notify, timeout);
3394 evas_object_smart_callback_add(notify, "timeout", response_cb, ugd);
3395 evas_object_smart_callback_add(notify, "block,clicked", response_cb, ugd);
3398 evas_object_show(notify);
3400 ugd->popup_list = eina_list_append(ugd->popup_list, notify);
3402 debug_log("notify = %x, %p", notify, notify);
3406 Evas_Object *_composer_create_noti(EmailComposerUGD *ugd, bool use_win, char *title, char *content,
3407 int btn_num, char *btn1_lb, char *btn2_lb,
3408 double timeout, void (*response_cb) (void *data, Evas_Object *obj, void *event_info))
3411 Evas_Object *notify;
3414 notify = _composer_popup_create(ugd->win_main, ugd);
3416 notify = elm_popup_add(ugd->win_main);
3418 debug_log("notify: %p", notify);
3420 debug_log("elm_popup_add returns NULL");
3423 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3426 elm_object_part_text_set(notify, "title,text", title);
3430 elm_object_text_set(notify, content);
3434 Evas_Object *peoBtn1 = NULL;
3435 peoBtn1 = elm_button_add(notify);
3436 debug_log("peoBtn1: %p", peoBtn1);
3437 elm_object_style_set(peoBtn1, "popup_button/default");
3438 elm_object_text_set(peoBtn1, btn1_lb);
3439 elm_object_part_content_set(notify, "button1", peoBtn1);
3440 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3441 } else if (btn_num == 2) {
3442 Evas_Object *peoBtn1 = NULL;
3443 peoBtn1 = elm_button_add(notify);
3444 debug_log("peoBtn1: %p", peoBtn1);
3445 elm_object_style_set(peoBtn1, "popup_button/default");
3446 elm_object_text_set(peoBtn1, btn1_lb);
3447 elm_object_part_content_set(notify, "button1", peoBtn1);
3448 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3450 Evas_Object *peoBtn2 = NULL;
3451 peoBtn2 = elm_button_add(notify);
3452 debug_log("peoBtn2: %p", peoBtn2);
3453 elm_object_style_set(peoBtn2, "popup_button/default");
3454 elm_object_text_set(peoBtn2, btn2_lb);
3455 elm_object_part_content_set(notify, "button2", peoBtn2);
3456 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3459 if (timeout > 0.0) {
3460 elm_popup_timeout_set(notify, timeout);
3461 evas_object_smart_callback_add(notify, "timeout", response_cb, ugd);
3462 evas_object_smart_callback_add(notify, "block,clicked", response_cb, ugd);
3465 evas_object_show(notify);
3467 ugd->popup_list = eina_list_append(ugd->popup_list, notify);
3469 debug_log("notify = %x, %p", notify, notify);
3473 Evas_Object *_composer_create_popup(EmailComposerUGD *ugd, bool use_win, char *title, char *content,
3474 int btn_num, char *btn1_lb, char *btn2_lb, char *btn3_lb,
3475 double timeout, void (*response_cb) (void *data, Evas_Object *obj, void *event_info))
3478 Evas_Object *notify;
3481 notify = _composer_popup_create(ugd->win_main, ugd);
3483 notify = elm_popup_add(ugd->win_main);
3485 debug_log("notify: %p", notify);
3487 debug_log("elm_popup_add returns NULL");
3490 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3493 elm_object_part_text_set(notify, "title,text", title);
3497 elm_object_text_set(notify, content);
3501 Evas_Object *peoBtn1 = NULL;
3502 peoBtn1 = elm_button_add(notify);
3503 debug_log("peoBtn1: %p", peoBtn1);
3504 elm_object_style_set(peoBtn1, "popup_button/default");
3505 elm_object_text_set(peoBtn1, btn1_lb);
3506 elm_object_part_content_set(notify, "button1", peoBtn1);
3507 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3508 } else if (btn_num == 2) {
3509 Evas_Object *peoBtn1 = NULL;
3510 peoBtn1 = elm_button_add(notify);
3511 debug_log("peoBtn1: %p", peoBtn1);
3512 elm_object_style_set(peoBtn1, "popup_button/default");
3513 elm_object_text_set(peoBtn1, btn1_lb);
3514 elm_object_part_content_set(notify, "button1", peoBtn1);
3515 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3517 Evas_Object *peoBtn2 = NULL;
3518 peoBtn2 = elm_button_add(notify);
3519 debug_log("peoBtn2: %p", peoBtn2);
3520 elm_object_style_set(peoBtn2, "popup_button/default");
3521 elm_object_text_set(peoBtn2, btn2_lb);
3522 elm_object_part_content_set(notify, "button2", peoBtn2);
3523 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3524 } else if (btn_num == 3) {
3525 Evas_Object *peoBtn1 = NULL;
3526 peoBtn1 = elm_button_add(notify);
3527 debug_log("peoBtn1: %p", peoBtn1);
3528 elm_object_style_set(peoBtn1, "popup_button/default");
3529 elm_object_text_set(peoBtn1, btn1_lb);
3530 elm_object_part_content_set(notify, "button1", peoBtn1);
3531 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3533 Evas_Object *peoBtn2 = NULL;
3534 peoBtn2 = elm_button_add(notify);
3535 debug_log("peoBtn2: %p", peoBtn2);
3536 elm_object_style_set(peoBtn2, "popup_button/default");
3537 elm_object_text_set(peoBtn2, btn2_lb);
3538 elm_object_part_content_set(notify, "button2", peoBtn2);
3539 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3541 Evas_Object *peoBtn3 = NULL;
3542 peoBtn3 = elm_button_add(notify);
3543 debug_log("peoBtn3: %p", peoBtn3);
3544 elm_object_style_set(peoBtn3, "popup_button/default");
3545 elm_object_text_set(peoBtn3, btn3_lb);
3546 elm_object_part_content_set(notify, "button3", peoBtn3);
3547 evas_object_smart_callback_add(peoBtn3, "clicked", response_cb, ugd);
3550 if (timeout > 0.0) {
3551 elm_popup_timeout_set(notify, timeout);
3552 evas_object_smart_callback_add(notify, "timeout", response_cb, ugd);
3553 evas_object_smart_callback_add(notify, "block,clicked", response_cb, ugd);
3556 evas_object_show(notify);
3558 ugd->popup_list = eina_list_append(ugd->popup_list, notify);
3560 debug_log("notify = %x, %p", notify, notify);
3564 void _composer_noti_response_cb(void *data, Evas_Object *obj, void *event_info)
3568 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3570 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
3571 ugd->focus_status = COMPOSER_FOCUS_STATUS_NONE;
3573 Evas_Object *mbe = NULL;
3575 if (ugd->selected_entry == ugd->to_mbe_entry) {
3577 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
3579 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
3583 if (ugd->popup_list) {
3584 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
3585 debug_log("obj: %p", obj);
3586 debug_log("composer_noti: %p", ugd->composer_noti);
3588 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
3590 debug_log("@@@ b_sending = %d", ugd->b_sending);
3592 if (!_composer_check_popup_exist(ugd))
3593 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
3597 ugd->b_sending = false;
3599 evas_object_del(ugd->composer_noti);
3600 ugd->composer_noti = NULL;
3603 void _composer_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
3607 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3609 Evas_Object *mbe = NULL;
3611 if (ugd->selected_entry == ugd->to_mbe_entry) {
3613 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
3615 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
3620 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
3621 elm_multibuttonentry_item_selected_set(item, EINA_FALSE);
3624 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE);
3626 if (ugd->popup_list) {
3627 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
3628 debug_log("obj: %p", obj);
3629 debug_log("composer_noti: %p", ugd->composer_popup);
3631 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_popup/*obj*/);
3633 debug_log("@@@ b_sending = %d", ugd->b_sending);
3635 if (!_composer_check_popup_exist(ugd))
3636 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
3640 ugd->b_sending = false;
3642 evas_object_del(ugd->composer_popup);
3643 ugd->composer_popup = NULL;
3644 ugd->is_mbe_selected = false;
3647 Eina_Bool _composer_check_popup_exist(EmailComposerUGD *ugd)
3651 if (!ugd) return EINA_FALSE;
3653 debug_log("popup list count = %d", eina_list_count(ugd->popup_list));
3654 if (eina_list_count(ugd->popup_list) > 0)
3660 int _composer_get_account_list(EmailComposerUGD *ugd)
3664 int err = email_get_account_list(&ugd->account_info->account_list, &ugd->account_info->account_count);
3666 if (err != EMAIL_ERROR_NONE) {
3667 debug_log("[email-composer] email_account_get_list error");
3668 return COMPOSER_ERROR_NO_ACCOUNT_LIST;
3672 for (i = 0; i < ugd->account_info->account_count; i++) {
3673 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);
3676 debug_log("[email-composer] account count = %d", ugd->account_info->account_count);
3678 return COMPOSER_ERROR_NONE;
3681 char *_composer_get_email_addr_from_account_id(EmailComposerUGD *ugd, int account_id)
3686 for (i = 0; i < ugd->account_info->account_count; i++) {
3687 if (ugd->account_info->account_list[i].account_id == account_id)
3688 return g_strdup(ugd->account_info->account_list[i].user_email_address);
3694 char *_composer_get_service_fail_type(int type)
3699 char str[MAX_STR_LEN] = { 0, };
3702 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("IP full"));
3703 return g_strdup(str);
3704 } else if (type == -176) {
3705 ret = _("IDS_EMAIL_POP_NO_SERVICE");
3706 return g_strdup(ret);
3707 } else if (type == -181) {
3708 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("Transport Error"));
3709 return g_strdup(str);
3710 } else if (type == EMAIL_ERROR_NETWORK_TOO_BUSY) {
3711 ret = _("IDS_EMAIL_POP_NETWORK_BUSY");
3712 return g_strdup(ret);
3713 } else if (type == EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS) {
3714 snprintf(str, sizeof(str), _("IDS_EMAIL_POP_YOU_CAN_ONLY_LOG_IN_ONCE_EVERY_PD_MINUTES"), 15);
3715 return g_strdup(str);
3716 } else if (type == EMAIL_ERROR_CONNECTION_FAILURE) {
3717 ret = dgettext("sys_string", "IDS_COM_POP_CONNECTION_FAILED");
3718 return g_strdup(ret);
3719 } else if (type == EMAIL_ERROR_LOGIN_FAILURE) {
3720 ret = _("IDS_EMAIL_POP_LOG_IN_FAILED");
3721 return g_strdup(ret);
3722 } else if (type == EMAIL_ERROR_AUTHENTICATE) {
3723 ret = _("IDS_EMAIL_POP_AUTHENTICATION_FAILED");
3724 return g_strdup(ret);
3725 } else if (type == EMAIL_ERROR_CANCELLED) {
3726 ret = _("IDS_EMAIL_POP_SENDING_CANCELLED");
3727 return g_strdup(ret);
3728 } else if (type == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) {
3729 ret = _("IDS_EMAIL_POP_EMAIL_DELETED_FROM_SERVER");
3730 return g_strdup(ret);
3731 } else if (type == EMAIL_ERROR_NO_SUCH_HOST) {
3732 ret = _("IDS_EMAIL_POP_HOST_NOT_FOUND");
3733 return g_strdup(ret);
3734 } else if (type == EMAIL_ERROR_INVALID_SERVER) {
3735 ret = _("IDS_EMAIL_POP_SERVER_NOT_AVAILABLE");
3736 return g_strdup(ret);
3737 } else if (type == EMAIL_ERROR_MAIL_MEMORY_FULL) {
3738 ret = _("IDS_EMAIL_POP_DEVICE_STORAGE_FULL");
3739 return g_strdup(ret);
3740 } else if (type == EMAIL_ERROR_FAILED_BY_SECURITY_POLICY) {
3741 ret = _("IDS_EMAIL_POP_DOWNLOADING_ATTACHMENTS_ON_THE_MOBILE_DEVICE_IS_NOT_ALLOWED_BY_EXCHANGE_SERVER_POLICY");
3742 return g_strdup(ret);
3743 } else if (type == EMAIL_ERROR_NETWORK_NOT_AVAILABLE) {
3744 ret = N_("Network not available");
3745 return g_strdup(ret);
3746 } else if (type == EMAIL_ERROR_FLIGHT_MODE) {
3747 ret = N_("Flight mode enabled");
3748 return g_strdup(ret);
3749 } else if (type == EMAIL_ERROR_NO_RESPONSE) {
3750 ret = N_("No server response");
3751 return g_strdup(ret);
3752 } else if (type == EMAIL_ERROR_DISCONNECTED) {
3753 ret = N_("Disconnected");
3754 return g_strdup(ret);
3755 } else if (type == EMAIL_ERROR_CONNECTION_BROKEN) {
3756 ret = N_("Connection broken");
3757 return g_strdup(ret);
3759 snprintf(str, sizeof(str), "%s (%d)", dgettext("sys_string", "IDS_COM_POP_UNKNOWN_ERROR_OCCURRED"), type);
3760 return g_strdup(str);
3764 Eina_Bool _composer_mbe_set_focus(void *data)
3768 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3770 debug_log("selected_entry = %x, to_mbe_entry = %x, cc_mbe_entry = %x, bcc_mbe_entry = %x, subject_entry = %x, body_ewkview = %x",
3771 ugd->selected_entry, ugd->to_mbe_entry, ugd->cc_mbe_entry, ugd->bcc_mbe_entry, ugd->subject_entry, ugd->body_ewkview);
3773 if ((ugd->selected_entry == ugd->to_mbe_entry) || (ugd->selected_entry == NULL)) {
3774 debug_log("TO MBE ENTRY FOCUS!!!");
3775 elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
3776 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
3777 debug_log("CC MBE ENTRY FOCUS!!!");
3778 elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
3779 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
3780 debug_log("BCC MBE ENTRY FOCUS!!!");
3781 elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
3782 } else if (ugd->selected_entry == ugd->subject_entry) {
3783 debug_log("SUBJECT ENTRY FOCUS!!!");
3784 elm_object_focus_set(ugd->subject_editfield, EINA_TRUE);
3785 } else if (ugd->selected_entry == ugd->body_ewkview) {
3786 debug_log("BODY WEBKIT FOCUS!!!");
3787 evas_object_focus_set(ugd->body_ewkview, EINA_TRUE);
3788 } else if (ugd->selected_entry == ugd->attachment_contracted_item) {
3789 debug_log("Attachments FOCUS!!!");
3790 elm_object_focus_set(ugd->attachment_contracted_item, EINA_TRUE);
3792 debug_log("NO ENTRY!!! TO MBE ENTRY will get the focus.");
3793 elm_object_focus_set(ugd->to_mbe_entry, EINA_TRUE);
3797 ugd->b_cc_bcc = false;
3799 if (ugd->clipboard_on)
3800 ugd->clipboard_on = false;
3802 if (ugd->idler_set_focus) {
3803 ecore_idler_del(ugd->idler_set_focus);
3804 ugd->idler_set_focus = NULL;
3810 void _composer_resize_body_webview(EmailComposerUGD *ugd, int ime_height)
3812 int nWidth, nHeight;
3814 _composer_display_position(ugd);
3816 ecore_x_window_size_get(ecore_x_window_root_first_get(), &nWidth, &nHeight);
3818 Evas_Coord x, y, w, h;
3820 debug_log(" === ime_height %d", ime_height);
3822 evas_object_geometry_get(ugd->win_main, &x, &y, &w, &h);
3823 debug_log(" === win_main x:%d, y:%d, w:%d, h:%d", x, y, w, h);
3825 evas_object_geometry_get(ugd->body_ewkview, &x, &y, &w, &h);
3826 debug_log(" === body_ewkview x:%d, y:%d, w:%d, h:%d", x, y, w, h);
3828 evas_object_geometry_get(ugd->webkit_ly, &x, &y, &w, &h);
3829 debug_log(" === resize webkit_ly x:%d, y:%d, w:%d, h:%d", x, y, w, h);
3831 if (ugd->isHorizontal == false) {
3832 ugd->is_prediction = ((ime_height - COMPOSER_IME_HEIGHT_V) == 0) ? EINA_FALSE : EINA_TRUE;
3834 ugd->is_prediction = ((ime_height - COMPOSER_IME_HEIGHT_H) == 0) ? EINA_FALSE : EINA_TRUE;
3836 debug_log("ugd->is_prediction(%d) : %d", ugd->is_prediction, ime_height - COMPOSER_IME_HEIGHT_V);
3838 if (ugd->isHorizontal == false) {
3839 // Webkit should be resized after showing/hiding IME
3840 debug_log("nHeight:%d, COMPOSER_NAVI_HEIGHT:%d, indicator_height:%d", nHeight, COMPOSER_NAVI_HEIGHT, COMPOSER_INDI_HEIGHT);
3841 evas_object_size_hint_min_set(ugd->webkit_ly, 0, nHeight - COMPOSER_NAVI_HEIGHT - COMPOSER_INDI_HEIGHT - ime_height);
3843 debug_log("nHeight:%d, COMPOSER_NAVI_HEIGHT:%d, indicator_height:%d", nWidth, COMPOSER_NAVI_HEIGHT, COMPOSER_INDI_HEIGHT);
3844 evas_object_size_hint_min_set(ugd->webkit_ly, 0, nWidth - COMPOSER_NAVI_HEIGHT - ime_height);
3847 if ((ugd->from_mbe != NULL) && (ugd->b_launch_finished == false)) {
3848 ugd->b_launch_finished = true;
3849 ugd->bringin_timer = ecore_timer_add(0.5f, _composer_bringin_cb, ugd);
3853 void _composer_input_panel_resize_cb(void *data, Ecore_IMF_Context *ctx, int value)
3857 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3859 ecore_imf_context_input_panel_geometry_get (ctx, &x, &y, &w, &h);
3860 debug_log("imf = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3862 if (ugd->isHorizontal == false) {
3863 ugd->is_prediction = ((h - COMPOSER_IME_HEIGHT_V) == 0) ? EINA_FALSE : EINA_TRUE;
3865 ugd->is_prediction = ((h - COMPOSER_IME_HEIGHT_H) == 0) ? EINA_FALSE : EINA_TRUE;
3867 _composer_resize_body_webview(ugd, h);
3868 elm_layout_sizing_eval(ugd->c_layout);
3871 void _composer_input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value)
3875 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3877 debug_log("ugd->selected_entry : %d", ugd->selected_entry);
3879 if (ugd->selected_entry != ugd->body_ewkview) {
3882 ecore_imf_context_input_panel_geometry_get(ctx, &x, &y, &w, &h);
3883 debug_log("imf = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3885 debug_log("IME status changed to %d", value);
3888 case ECORE_IMF_INPUT_PANEL_STATE_HIDE: /* :1 */
3890 elm_object_item_signal_emit(ugd->navi_item, "elm,state,sip,hidden", "");
3891 ugd->is_ime_hided = TRUE;
3892 _composer_resize_body_webview(ugd, 0);
3895 case ECORE_IMF_INPUT_PANEL_STATE_SHOW: /* :0 */
3897 elm_object_item_signal_emit(ugd->navi_item, "elm,state,sip,shown", "");
3898 ugd->is_ime_hided = FALSE;
3899 _composer_resize_body_webview(ugd, h);
3902 default: /* ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW :2 */
3903 debug_log("Will show");
3904 elm_object_item_signal_emit(ugd->navi_item, "elm,state,sip,shown", "");
3905 ugd->is_ime_hided = FALSE;
3912 void _composer_display_position(void *data)
3914 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3915 Evas_Coord x = 0, y = 0, w = 0, h = 0;
3917 elm_scroller_region_get(ugd->main_scroller, &x, &y, &w, &h);
3918 debug_log("scroller = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3922 evas_object_geometry_get(ugd->from_ly, &x, &y, &w, &h);
3923 debug_log("from = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3927 evas_object_geometry_get(ugd->to_ly, &x, &y, &w, &h);
3928 debug_log("to = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3932 evas_object_geometry_get(ugd->cc_ly, &x, &y, &w, &h);
3933 debug_log("cc = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3938 evas_object_geometry_get(ugd->bcc_ly, &x, &y, &w, &h);
3939 debug_log("bcc = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3943 evas_object_geometry_get(ugd->subject_ly, &x, &y, &w, &h);
3944 debug_log("subject = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3947 evas_object_geometry_get(ugd->webkit_ly, &x, &y, &w, &h);
3948 debug_log("webview = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3952 static Eina_Bool _composer_print_hit_test_result_hash_fn(const Eina_Hash *hash, const void *key, void *data, void *fdata)
3954 // fdata is the third parameter
3955 debug_log("Func data: %s, Hash entry: %s / %s\n", fdata, (const char *)key, data);
3959 void _composer_print_hit_test_result(Ewk_Hit_Test *hit_test)
3961 Eina_Hash *attr_hash = NULL;
3962 debug_log("context: %d", ewk_hit_test_result_context_get(hit_test));
3963 debug_log("linkURI: %s", ewk_hit_test_link_uri_get(hit_test));
3964 debug_log("linkTitle: %s", ewk_hit_test_link_title_get(hit_test));
3965 debug_log("linkLabel: %s", ewk_hit_test_link_label_get(hit_test));
3966 debug_log("imageURI: %s", ewk_hit_test_image_uri_get(hit_test));
3967 debug_log("mediaURI: %s", ewk_hit_test_media_uri_get(hit_test));
3968 debug_log("nodeData.tagName: %s", ewk_hit_test_tag_name_get(hit_test));
3969 debug_log("nodeData.nodeValue: %s", ewk_hit_test_node_value_get(hit_test));
3970 debug_log("imageData.length: %d", ewk_hit_test_image_buffer_length_get(hit_test));
3971 debug_log("imageData.fileNameExtension: %s", ewk_hit_test_image_file_name_extension_get(hit_test));
3973 attr_hash = ewk_hit_test_attribute_hash_get(hit_test);
3975 eina_hash_foreach(attr_hash, _composer_print_hit_test_result_hash_fn, NULL);
3978 void _composer_coords_ewk_to_evas(Evas_Object *view, int ewkX, int ewkY, int *evasX, int *evasY)
3980 int scrollX, scrollY, viewX, viewY;
3981 ewk_view_scroll_pos_get(view, &scrollX, &scrollY);
3982 evas_object_geometry_get(view, &viewX, &viewY, NULL, NULL);
3984 *evasX = ewkX - scrollX + viewX;
3985 *evasY = ewkY - scrollY + viewY;
3988 void _composer_coords_evas_to_ewk(Evas_Object *view, int evasX, int evasY, int *ewkX, int *ewkY)
3990 debug_log("evasX:%d, evasY:%d", evasX, evasY);
3991 int scrollX, scrollY, viewX, viewY;
3992 ewk_view_scroll_pos_get(view, &scrollX, &scrollY);
3993 evas_object_geometry_get(view, &viewX, &viewY, NULL, NULL);
3994 debug_log("scrollX:%d, scrollY:%d, viewX:%d, viewY:%d", scrollX, scrollY, viewX, viewY);
3996 *ewkX = evasX + scrollX - viewX;
3997 *ewkY = evasY + scrollY - viewY;