2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <glib/gprintf.h>
22 #include <appcore-common.h>
28 #include "email-composer.h"
29 #include "email-composer-recipient.h"
30 #include "email-composer-util.h"
31 #include "email-composer-predictive-search.h"
32 #include "email-composer-attachment.h"
33 #include "email-composer-callback.h"
34 #include "email-composer-js.h"
35 #include "email-composer-contents.h"
37 #include "email-engine.h"
38 #include "email-utils.h"
40 #define DIV_TAG_START_ORIGIN_INFO "<div id=\"origin_info\"><p>"
41 #define DIV_TAG_START_ORIGIN_CONTENT "<div id=\"origin_content\"><p>"
42 #define DIV_TAG_END "</div>"
44 #define DIVIDE_LEFT_LINE_FOR_HTML "<br><br><b>--------------- "
45 #define DIVIDE_RIGHT_LINE_FOR_HTML " ---------------</b><br>\n"
46 #define ADDED_TEXT "<b>%s:</b> %s<br>\n"
47 #define BODY_TAG_START "<body>\n"
48 #define BODY_TAG_END "</body>\n"
49 #define HTML_TAG_START "<html>\n"
50 #define HTML_TAG_END "</html>\n"
52 #define DIVIDE_LINE "\n\n-----------------------------------\n"
54 #define DEFAULT_SIGNATURE _("IDS_EMAIL_BODY_SENT_USING_TIZEN_MOBILE")
56 #define HTML_META_INFORMATION \
57 "<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"
60 static void _composer_save_draft_response_cb(void *data, Evas_Object *obj, void *event_info);
61 static void _composer_save_draft_fail_response_cb(void *data, Evas_Object *obj, void *event_info);
62 static void _composer_attachment_popup_response_cb(void *data, Evas_Object *obj, void *event_info);
63 static void _composer_dn_prog_popup_response_cb(void *data, Evas_Object *obj, void *event_info);
65 extern void _composer_free_initial_email_content(EmailComposerUGD *ugd);
67 void _composer_make_html_body(EmailComposerUGD *ugd);
69 extern char *icu_locale;
70 extern enum appcore_time_format icu_timeformat;
72 const gchar *email_composer_get_html_tag(const gchar char_val)
74 const gchar *tag = NULL;
94 gchar *email_composer_get_parse_string(const gchar *text, gint size)
97 RETURN_VAL_IF_FAIL(STR_VALID(text), NULL);
103 guint old_offset = 0, offset = 0;
105 for (i = 0; i < size; ++i) {
107 const gchar *tag = email_composer_get_html_tag(text[i]);
109 /* If need, convert text to html format. */
113 if (i > old_offset) {
114 offset = i - old_offset;
115 buff = g_strndup(&text[old_offset], offset);
117 html = g_strconcat(temp, buff, tag, NULL);
119 html = g_strconcat(buff, tag, NULL);
128 html = g_strconcat(temp, tag, NULL);
130 html = g_strconcat(tag, NULL);
143 /* If not terminated. */
144 if (old_offset < size) {
147 buff = g_strndup(&text[old_offset], size - old_offset);
148 html = g_strconcat(temp, buff, NULL);
156 return html ? html : g_strndup(text, size);
160 The following API splits a given filepath string into 'directory path' or 'filename'
162 char *email_composer_parse_filepath(const char *path, Eina_Bool directorypathORfilename)
165 RETURN_VAL_IF_FAIL(STR_VALID(path), NULL);
167 char *file_path = NULL;
169 int size = STR_LEN((char *)path);
171 for (i = (size - 1); i >= 0; --i) {
172 if (path[i] == '/') {
173 if (directorypathORfilename) {
174 file_path = g_strndup(path, i + 1); /* directory path is copied. */
176 file_path = g_strndup(path + i + 1, size - i + 1); /* filename is copied. */
184 char *email_composer_parse_get_filepath_from_path(const char *path)
186 RETURN_VAL_IF_FAIL(STR_VALID(path), NULL);
188 char *file_path = NULL;
190 int size = STR_LEN((char *)path);
192 for (i = (size - 1); i >= 0; --i) {
193 if (path[i] == '/') {
194 file_path = g_strndup(path, i + 1);
201 char *_composer_get_file_ext(const char *a_pszfile_name)
203 if (a_pszfile_name != NULL) {
204 int nlen = strlen(a_pszfile_name);
205 char *psztemp = (char *)a_pszfile_name + nlen;
209 if (*psztemp == '.') {
220 int _composer_copy_temp_file(const char *src_file_path, char *dst_file_path, int size_dst_file_path)
223 const char *filename = NULL;
224 char temp_file_path[MAX_PATH_LEN] = { 0, };
227 if (ecore_file_exists(src_file_path) == EINA_FALSE) {
231 filename = ecore_file_file_get(src_file_path);
232 debug_log("filename:%s", filename);
235 snprintf(temp_file_path, sizeof(temp_file_path) - 1, "%s/%s", EMAIL_TMP_FOLDER, filename);
237 while (ecore_file_exists(temp_file_path)) {
238 bzero(temp_file_path, sizeof(temp_file_path));
239 snprintf(temp_file_path, sizeof(temp_file_path) - 1, "%s/%d_%s", EMAIL_TMP_FOLDER, i, filename);
246 if (ecore_file_cp(src_file_path, temp_file_path) == EINA_FALSE) {
247 debug_log("temp_file_path = %s", temp_file_path);
251 strncpy(dst_file_path, temp_file_path, size_dst_file_path);
252 debug_log("copy file from %s to %s", src_file_path, dst_file_path);
262 * Changes inline images path from absolute to relative, in a given html content.
264 * @param [in] src_html_content string buffer contains html file content
265 * @param [out] dest_buffer string buffer to hold the processed html content
267 * @return true or false
270 Eina_Bool email_composer_change_image_paths_to_relative(char *src_html_content, char **dest_buffer)
274 if (src_html_content == NULL || dest_buffer == NULL) {
275 debug_log("NULL arguments passed");
281 char *src_str = src_html_content;
282 char *buffer = (char *)calloc(1, strlen(src_str) + 1);
283 if (buffer == NULL) {
284 debug_log("Memory allocation(calloc) failed.");
291 Eina_Bool success_flag = EINA_TRUE;
293 /* Ex. <img src="/opt/media/Images/image5.jpg" width=342 height="192" id="/opt/media/Images/image5.jpg"> */
294 while ((point1 = strstr(src_str, "<img")) || (point1 = strstr(src_str, "<IMG"))) {
296 if (!(temp = strstr(point1, "src=")) && !(temp = strstr(point1, "SRC="))) {
297 debug_log("1. No src=");
298 success_flag = EINA_FALSE;
303 if (point1 == NULL) {
304 debug_log("2. No file path");
305 success_flag = EINA_FALSE;
309 strncat(buffer, src_str, point1 - src_str);
311 debug_log("point1[0] = %c", point1[0]);
313 if (point1[0] == '/') {
315 point2 = strstr(point1, "\"");
316 if (point2 == NULL) {
317 debug_log("3. No end quotation");
318 success_flag = EINA_FALSE;
321 char *image_path = g_strndup(point1, point2 - point1);
322 debug_log("image_path : %s", image_path);
323 char *file_path = email_composer_parse_filepath(image_path, EINA_FALSE);
326 debug_log("file_path : %s", file_path);
327 if (file_path == NULL) {
328 debug_log("4. Could not parse inline image path");
329 success_flag = EINA_FALSE;
332 strncat(buffer, file_path, strlen(file_path));
339 if (success_flag == EINA_FALSE) {
345 strncat(buffer, src_str, strlen(src_str));
346 *dest_buffer = buffer;
351 Eina_Bool email_composer_save_file(const gchar *path, const gchar *buf, gsize len)
353 debug_log("path (%s)", path);
355 Eina_Bool success_flag = EINA_TRUE;
357 if (STR_LEN((gchar *)buf) > 0 && len > 0) {
358 int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
360 ssize_t nwrite = write(fd, (const void *)buf, (size_t) len);
361 debug_log("nwrite(%d)", nwrite);
363 debug_log("fail to write");
364 success_flag = EINA_FALSE;
369 debug_log("fail to open");
370 success_flag = EINA_FALSE;
373 debug_log("check the buf!!");
374 success_flag = EINA_FALSE;
380 static void _composer_ug_script_executed(Evas_Object *o, const char *result, void *data)
385 Eina_List *email_composer_change_str_to_EinaList(EmailComposerUGD *ugd, const char *str, char *token)
389 Eina_List *list = NULL;
391 char tmp_file_path[MAX_PATH_LEN + 1] = { 0, };
392 char *file_ext = NULL;
394 debug_log("str = %s", str);
395 debug_log("token = %s", token);
397 p = strtok((char *)str, token);
400 debug_log("p = %s", p);
404 if (ecore_file_exists(p)) {
405 if (email_drm_file_forward_lock_check(p)) {
406 if (ugd->composer_noti) {
407 evas_object_del(ugd->composer_noti);
408 ugd->composer_noti = NULL;
410 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
411 _("IDS_EMAIL_POP_UNABLE_TO_FORWARD_DRM_CONTENTS"), 0, NULL, NULL, 2.0, _composer_noti_response_cb);
413 file_ext = _composer_get_file_ext(p);
414 debug_log("file_ext:%s", file_ext);
416 if (strcasecmp(file_ext, "vcf") == 0 || strcasecmp(file_ext, "vcs") == 0) {
417 if (_composer_copy_temp_file(p, tmp_file_path, MAX_PATH_LEN))
418 list = eina_list_append(list, tmp_file_path);
420 list = eina_list_append(list, p);
422 list = eina_list_append(list, p);
425 debug_log("ecore_file_exists failed");
426 if (g_str_has_prefix(p, "http://")) {
427 if (EINA_TRUE == ugd->has_body_html) {
428 if (ugd->selected_entry != ugd->body_ewkview) {
429 if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_SET_FOCUS, _composer_ug_script_executed, 0) == EINA_FALSE) {
430 debug_log("COMPOSER_JS_SET_FOCUS is failed!");
432 debug_log("body_ewkview focussed");
434 if (ugd->body_ewkview) {
435 ewk_view_command_execute(ugd->body_ewkview, "InsertText", p);
436 ewk_view_command_execute(ugd->body_ewkview, "InsertText", "\n");
442 p = strtok(NULL, token);
444 debug_log("p = %s", p);
448 list = eina_list_append(list, str);
454 Eina_List *email_composer_change_GList_to_EinaList(GList * l)
458 Eina_List *list = NULL;
461 int count = g_list_length(l);
464 for (i = 0; i < count; i++) {
465 char *string = g_list_nth_data(l, i);
466 debug_log("%d = %s", i, string);
469 list = eina_list_append(list, string);
474 debug_log("count is 0!!");
479 int _composer_add_mailbox_folder(EmailComposerUGD *ugd, email_mailbox_type_e mailbox_type, Eina_Bool b_save_to_draft)
483 int nResult = EMAIL_ERROR_NONE;
485 nResult = email_get_mailbox_by_mailbox_type(ugd->account_info->account_id, mailbox_type, &ugd->mailbox_info->mail_box);
486 if (nResult != EMAIL_ERROR_NONE) {
487 debug_log("email_get_mailbox_by_mailbox_type failed! %d", nResult);
491 debug_log("mailbox = %s", ugd->mailbox_info->mail_box->mailbox_name);
492 debug_log("mailbox_id = %d", ugd->mailbox_info->mail_box->mailbox_id);
494 nResult = _composer_make_mail(ugd, b_save_to_draft);
495 if (nResult < COMPOSER_ERROR_NONE) {
496 debug_log("error in _composer_make_mail(%d)", nResult);
500 debug_log("ugd->new_mail_info->mail_data->account_id = %d, ugd->new_mail_info->mail_data->server_mailbox_name = %s",
501 ugd->new_mail_info->mail_data->account_id, ugd->new_mail_info->mail_data->server_mailbox_name);
503 debug_log("attachment_list = %x, attachment_count = %d",
504 ugd->new_mail_info->attachment_list, ugd->new_mail_info->mail_data->attachment_count);
508 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);
510 debug_log("result of email_add_mail: %d", nResult);
511 if (nResult != EMAIL_ERROR_NONE) {
512 debug_warning("email_add_mail failed! %d", nResult);
516 if (email_check_file_exist(ugd->saved_html_path)) {
517 if (-1 == remove(ugd->saved_html_path)) {
518 debug_warning("Failed to remove file");
519 return COMPOSER_ERROR_FAIL;
523 return COMPOSER_ERROR_NONE;
526 int _composer_move_mailbox_folder(EmailComposerUGD *ugd, email_mailbox_type_e mailbox_type, Eina_Bool b_save_to_draft)
530 int nResult = EMAIL_ERROR_NONE;
532 int mail_ids[1] = { 0, };
533 mail_ids[0] = ugd->nExistingMailID;
535 debug_log("id = %d", mail_ids[0]);
537 nResult = email_get_mailbox_by_mailbox_type(ugd->account_info->account_id, mailbox_type, &ugd->mailbox_info->mail_box);
538 if (nResult != EMAIL_ERROR_NONE) {
539 debug_log("email_get_mailbox_by_mailbox_type failed! %d", nResult);
543 nResult = _composer_make_mail(ugd, b_save_to_draft);
544 if (nResult < COMPOSER_ERROR_NONE) {
545 debug_log("error in _composer_make_mail(%d)", nResult);
549 nResult = email_move_mail_to_mailbox(mail_ids, 1, ugd->mailbox_info->mail_box->mailbox_id);
550 if (nResult != EMAIL_ERROR_NONE) {
551 debug_log("email_move_mail_to_mailbox failed! %d", nResult);
555 if (email_check_file_exist(ugd->saved_html_path)) {
556 if (-1 == remove(ugd->saved_html_path)) {
557 debug_log("Failed to remove file");
558 return COMPOSER_ERROR_FAIL;
562 return COMPOSER_ERROR_NONE;
565 static void _composer_make_draft_html_content(EmailComposerUGD *ugd, char **html_content, Eina_Bool b_save_to_draft)
569 *html_content = g_strdup(ugd->latest_body_html_content);
572 int _composer_make_mail(EmailComposerUGD *ugd, Eina_Bool b_save_to_draft)
576 email_account_t *account = NULL;
577 if (!email_engine_get_account_full_data(ugd->account_info->account_id, &account)) {
578 debug_log("Failed to Get account full data");
579 email_free_account(&account, 1);
580 return COMPOSER_ERROR_GET_DATA_FAIL;
583 if (account == NULL) {
584 debug_log("account is NULL!");
585 return COMPOSER_ERROR_GET_DATA_FAIL;
588 debug_log("acc id = %d", ugd->account_info->account_id);
589 debug_log("priority = %d", (*ugd->account_info->account).options.priority);
590 debug_log("mailbox = %s", ugd->mailbox_info->mail_box->mailbox_name);
591 ugd->new_mail_info->mail_data->account_id = ugd->account_info->account_id;
593 ugd->new_mail_info->mail_data->report_status = EMAIL_MAIL_REPORT_NONE;
595 if (ugd->tracking_option[0] == 1) {
596 ugd->new_mail_info->mail_data->report_status |= EMAIL_MAIL_REQUEST_MDN;
598 if (ugd->tracking_option[1] == 1) {
599 ugd->new_mail_info->mail_data->report_status |= EMAIL_MAIL_REQUEST_DSN;
601 debug_log("ugd->new_mail_info->mail_data->report_status = %d", ugd->new_mail_info->mail_data->report_status);
603 ugd->new_mail_info->mail_data->priority = ugd->priority_option;
605 ugd->new_mail_info->mail_data->server_mailbox_name = strdup(ugd->mailbox_info->mail_box->mailbox_name);
606 ugd->new_mail_info->mail_data->mailbox_id = ugd->mailbox_info->mail_box->mailbox_id;
608 debug_log("user_name = %s, %s", ugd->account_info->account->user_display_name, account->user_display_name);
609 debug_log("email_addr = %s, %s", ugd->account_info->account->user_email_address, account->user_email_address);
611 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
612 ugd->new_mail_info->mail_data->body_download_status = 1;
613 ugd->new_mail_info->mail_data->mail_id = ugd->existing_mail_info->mail_data->mail_id;
616 char uc[MAX_STR_LEN];
617 snprintf(uc, sizeof(uc), "\"%s\"<%s>", account->user_display_name, account->user_email_address);
618 ugd->new_mail_info->mail_data->full_address_from = g_strdup(uc);
619 debug_log("from = %s", uc);
622 debug_log("email_free_account is called");
623 email_free_account(&account, 1);
627 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->to_mbe)) != NULL) {
629 if (_composer_make_recipient_char_to_list(ugd, ugd->to_mbe, &(ugd->new_mail_info->mail_data->full_address_to)) < COMPOSER_ERROR_NONE)
630 return COMPOSER_ERROR_GET_DATA_FAIL;
633 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->cc_mbe)) != NULL) {
635 if (_composer_make_recipient_char_to_list(ugd, ugd->cc_mbe, &(ugd->new_mail_info->mail_data->full_address_cc)) < COMPOSER_ERROR_NONE)
636 return COMPOSER_ERROR_GET_DATA_FAIL;
639 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->bcc_mbe)) != NULL) {
640 debug_log("bcc mbe");
641 if (_composer_make_recipient_char_to_list(ugd, ugd->bcc_mbe, &(ugd->new_mail_info->mail_data->full_address_bcc)) < COMPOSER_ERROR_NONE)
642 return COMPOSER_ERROR_GET_DATA_FAIL;
645 ugd->new_mail_info->mail_data->subject = elm_entry_markup_to_utf8(elm_entry_entry_get(ugd->subject_entry));
647 if (EINA_TRUE == ugd->has_body_html) {
649 if (TRUE == email_check_file_exist(ugd->saved_html_path)) {
650 if (-1 == remove(ugd->saved_html_path)) {
651 debug_log("Failed to remove temp html file");
652 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
656 if (TRUE == email_check_file_exist(SAVE_URI)) {
657 if (-1 == remove(SAVE_URI)) {
658 debug_log("Failed to remove temp text file");
659 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
663 char *html_content = NULL;
664 char *html_content_processed = NULL;
665 char *plain_text_content = NULL;
667 _composer_make_draft_html_content(ugd, &html_content, b_save_to_draft);
669 if (html_content == NULL) {
670 debug_log("html_content is NULL.");
671 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
674 debug_log("\nhtml_content:\n%s", html_content);
676 if (ugd->attachment_inline_item_list == NULL) {
677 debug_log("No images found or ERROR");
678 html_content_processed = html_content;
680 if (!email_composer_change_image_paths_to_relative(html_content, &html_content_processed)) {
681 debug_log("email_composer_change_image_paths_to_relative Failed");
682 g_free(html_content);
684 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
686 debug_log("\nhtml_source_processed:\n%s", html_content_processed);
688 g_free(html_content);
692 if (EINA_FALSE == email_composer_save_file(ugd->saved_html_path, html_content_processed, strlen(html_content_processed))) {
693 debug_log("Write to html file failed");
694 g_free(html_content_processed);
695 html_content_processed = NULL;
696 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
699 g_free(html_content_processed);
700 html_content_processed = NULL;
702 if (ugd->plain_content != NULL && strlen(ugd->plain_content) == 0) {
703 plain_text_content = g_strdup("\n");
705 plain_text_content = g_strdup(ugd->plain_content);
708 if (NULL == plain_text_content) {
709 debug_log("ugd->plain_content is NULL");
710 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
713 if (EINA_FALSE == email_composer_save_file(SAVE_URI, plain_text_content, strlen(plain_text_content))) {
714 debug_log("Write to %s file failed", SAVE_URI);
715 g_free(plain_text_content);
716 plain_text_content = NULL;
717 return COMPOSER_ERROR_MAKE_MAIL_FAIL;
719 g_free(plain_text_content);
720 plain_text_content = NULL;
722 ugd->new_mail_info->mail_data->file_path_html = COMPOSER_STRDUP(ugd->saved_html_path);
723 ugd->new_mail_info->mail_data->file_path_plain = COMPOSER_STRDUP(SAVE_URI);
726 int nAttachmentObjListCount = eina_list_count(ugd->attachment_item_obj_list) + ugd->inline_cnt;
727 debug_log("nAttachmentObjListCount : %d", nAttachmentObjListCount);
729 if ((nAttachmentObjListCount > 0) || (ugd->inline_cnt > 0)) {
731 if (ugd->new_mail_info->attachment_list) {
732 email_free_attachment_data(&ugd->new_mail_info->attachment_list, ugd->new_mail_info->mail_data->attachment_count);
733 ugd->new_mail_info->attachment_list = NULL;
734 ugd->new_mail_info->mail_data->attachment_count = 0;
737 ugd->new_mail_info->mail_data->attachment_count = nAttachmentObjListCount;
739 debug_log("ugd->save_drafts : %d, ugd->new_mail_info->attachment_count : %d", ugd->save_drafts, ugd->new_mail_info->mail_data->attachment_count);
741 ugd->new_mail_info->attachment_list = (email_attachment_data_t *)calloc(nAttachmentObjListCount, sizeof(email_attachment_data_t));
744 Eina_Iterator *it = NULL;
745 Evas_Object *attachment_obj = NULL;
746 email_attachment_data_t *attachment_data;
748 it = eina_list_iterator_new(ugd->attachment_item_obj_list);
750 while (eina_iterator_next(it, (void **)&attachment_obj)) {
752 attachment_data = evas_object_data_get(attachment_obj, "attachment_data");
754 if (attachment_data) {
755 if (attachment_data->save_status == 1) {
756 ugd->new_mail_info->attachment_list[nCount].inline_content_status = attachment_data->inline_content_status;
757 ugd->new_mail_info->attachment_list[nCount].attachment_id = attachment_data->attachment_id;
758 ugd->new_mail_info->attachment_list[nCount].attachment_size = attachment_data->attachment_size;
759 ugd->new_mail_info->attachment_list[nCount].save_status = attachment_data->save_status;
760 ugd->new_mail_info->attachment_list[nCount].attachment_name = COMPOSER_STRDUP(attachment_data->attachment_name);
761 ugd->new_mail_info->attachment_list[nCount].attachment_path = COMPOSER_STRDUP(attachment_data->attachment_path);
763 debug_log("attachment_name : %s", ugd->new_mail_info->attachment_list[nCount].attachment_name);
764 debug_log("attachment_path : %s", ugd->new_mail_info->attachment_list[nCount].attachment_path);
765 debug_log("attachment_id : %d", ugd->new_mail_info->attachment_list[nCount].attachment_id);
766 debug_log("attachment_size : %d", ugd->new_mail_info->attachment_list[nCount].attachment_size);
767 debug_log("save_status : %d", ugd->new_mail_info->attachment_list[nCount].save_status);
768 debug_log("inline_content_status : %d", ugd->new_mail_info->attachment_list[nCount].inline_content_status);
775 it = eina_list_iterator_new(ugd->attachment_inline_item_list);
777 while (eina_iterator_next(it, (void **)&attachment_data)) {
778 if (attachment_data) {
779 if (attachment_data->save_status == 1) {
780 ugd->new_mail_info->attachment_list[nCount].inline_content_status = attachment_data->inline_content_status;
781 ugd->new_mail_info->attachment_list[nCount].attachment_id = attachment_data->attachment_id;
782 ugd->new_mail_info->attachment_list[nCount].attachment_size = attachment_data->attachment_size;
783 ugd->new_mail_info->attachment_list[nCount].save_status = attachment_data->save_status;
784 ugd->new_mail_info->attachment_list[nCount].attachment_name = COMPOSER_STRDUP(attachment_data->attachment_name);
785 ugd->new_mail_info->attachment_list[nCount].attachment_path = COMPOSER_STRDUP(attachment_data->attachment_path);
787 debug_log("attachment_name : %s", ugd->new_mail_info->attachment_list[nCount].attachment_name);
788 debug_log("attachment_path : %s", ugd->new_mail_info->attachment_list[nCount].attachment_path);
789 debug_log("attachment_id : %d", ugd->new_mail_info->attachment_list[nCount].attachment_id);
790 debug_log("attachment_size : %d", ugd->new_mail_info->attachment_list[nCount].attachment_size);
791 debug_log("save_status : %d", ugd->new_mail_info->attachment_list[nCount].save_status);
792 debug_log("inline_content_status : %d", ugd->new_mail_info->attachment_list[nCount].inline_content_status);
800 ugd->new_mail_info->mail_data->flags_draft_field = 1;
802 return COMPOSER_ERROR_NONE;
805 EmailRecpInfo *_composer_separate_save_recipient_char(EmailComposerUGD *ugd, char *recipient)
808 if (!ugd || !recipient) {
809 debug_log("Function arguments NULL");
812 debug_log("separate recipient char = %s", recipient);
816 if (recipient[0] == ' ') {
817 temp = g_strdup(recipient++);
818 debug_log("temp = %s", temp);
820 temp = g_strdup(recipient);
821 debug_log("temp = %s", temp);
828 gchar **vector = NULL;
830 vector = g_strsplit_set(temp, "\"<>", -1);
832 if (vector == NULL) {
833 debug_log("vector == NULL");
838 EmailRecpInfo *ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
841 debug_log("Memory allocation failed.");
847 gint tok_cnt = g_strv_length(vector);
849 debug_log("tok_cnt = %d", tok_cnt);
850 debug_log("temp = %s", temp);
854 ri->display_name = g_strdup(vector[0]);
855 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", vector[0]);
862 } else if (tok_cnt == 3) {
864 ri->display_name = g_strdup(vector[1]);
865 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", vector[1]);
872 } else if (tok_cnt == 5) {
873 if (vector[1] && vector[3]) {
874 ri->display_name = g_strdup(vector[1]);
875 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", vector[3]);
889 ri->selected_email_idx = 0;
891 ri->is_contact_info = false;
892 ri->is_always_bcc = false;
893 ri->is_from_addr = false;
901 void _composer_convert_ps_to_br(char *input)
903 const char *char_ps = "<ps>";
908 while ((ptr = strstr(input, char_ps))) {
916 int _composer_send_mail(EmailComposerUGD *ugd)
920 if (!ugd->account_info->account) {
921 debug_log("account is NULL");
922 return COMPOSER_ERROR_SEND_FAIL;
925 debug_log("priority = %d", (*ugd->account_info->account).options.priority);
926 debug_log("request read report = %d", (*ugd->account_info->account).options.req_read_receipt);
928 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
929 /* 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.
930 This is because only mailbox name is updated to Outbox using move mail.
932 Correct process will be as below -
934 1) Add new edited email to Outbox.
935 2) Delete the old email from Drafts / Outbox */
937 if (0 < ugd->mailbox_info->mailbox_id) {
938 int ret = _composer_add_mailbox_folder(ugd, EMAIL_MAILBOX_TYPE_OUTBOX, EINA_FALSE);
940 if (ret < COMPOSER_ERROR_NONE) {
941 debug_log("error in _composer_add_mailbox_folder(%d)", ret);
945 int sync = EMAIL_DELETE_LOCAL_AND_SERVER;
947 /* Retrieve mailbox type from email-service and store it to identify Outbox */
949 debug_log("mailbox type [%d]", ugd->existing_mail_info->mail_data->mailbox_type);
950 if (EMAIL_MAILBOX_TYPE_OUTBOX == ugd->existing_mail_info->mail_data->mailbox_type)
951 sync = EMAIL_DELETE_LOCALLY;
953 debug_log("Account id [%d] mailbox id [%d] mail id [%d]", ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID);
955 if (!email_engine_delete_mail(ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID, sync)) {
956 debug_log("Deleting email is failed.");
957 return COMPOSER_ERROR_SEND_FAIL;
961 debug_critical("mailbox name is null");
962 return COMPOSER_ERROR_SEND_FAIL;
966 int ret = _composer_add_mailbox_folder(ugd, EMAIL_MAILBOX_TYPE_OUTBOX, EINA_FALSE);
968 if (ret < COMPOSER_ERROR_NONE) {
969 debug_log("error in _composer_add_mailbox_folder(%d)", ret);
977 if ((err = email_send_mail(ugd->new_mail_info->mail_data->mail_id, &handle)) != EMAIL_ERROR_NONE) {
978 debug_log(" fail sending [%d]", err);
979 return COMPOSER_ERROR_SEND_FAIL;
981 debug_log(" finish sending");
982 /* Support sync engine */
983 if (ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL) {
984 debug_log("existing mail id = %d, %d", ugd->nExistingMailID, ugd->existing_mail_info->mail_data->mail_id);
985 email_set_flags_field(ugd->account_info->account->account_id, &ugd->nExistingMailID, 1, EMAIL_FLAGS_ANSWERED_FIELD, 1, 1);
986 } else if (ugd->composer_type == RUN_COMPOSER_FORWARD) {
987 debug_log("existing mail id = %d, %d", ugd->nExistingMailID, ugd->existing_mail_info->mail_data->mail_id);
988 email_set_flags_field(ugd->account_info->account->account_id, &ugd->nExistingMailID, 1, EMAIL_FLAGS_FORWARDED_FIELD, 1, 1);
992 return COMPOSER_ERROR_NONE;
995 int _composer_make_recipient_char_to_list(EmailComposerUGD *ugd, Evas_Object *obj, char **dest)
999 char result[MAX_RECIPIENT_ADDRESSES_LEN] = { 0, };
1001 debug_log("obj = %p", obj);
1003 Elm_Object_Item *mbe_item;
1004 mbe_item = elm_multibuttonentry_first_item_get(obj);
1005 debug_log("mbe_item = %p", mbe_item);
1011 ri = (EmailRecpInfo *) elm_object_item_data_get(mbe_item);
1013 return COMPOSER_ERROR_GET_DATA_FAIL;
1015 index = ri->selected_email_idx;
1017 debug_log("display name = %s", ri->display_name);
1018 debug_log("email_addr = %s", ri->email_list[index].email_addr);
1020 if (g_strcmp0(result, "") == 0) {
1021 if (ri->display_name)
1022 snprintf(result, sizeof(result), "\"%s\" <%s>", ri->display_name, ri->email_list[index].email_addr);
1024 snprintf(result, sizeof(result), "<%s>", ri->email_list[index].email_addr);
1026 if (ri->display_name)
1027 snprintf(result + strlen(result), sizeof(result) - strlen(result), ";\"%s\" <%s>", ri->display_name, ri->email_list[index].email_addr);
1029 snprintf(result + strlen(result), sizeof(result) - strlen(result), ";<%s>", ri->email_list[index].email_addr);
1032 mbe_item = elm_multibuttonentry_item_next_get(mbe_item);
1035 debug_log("result = %s", result);
1037 *dest = g_strdup(result);
1039 return COMPOSER_ERROR_NONE;
1042 Eina_Bool _composer_save_draft_mail(void *data)
1044 EmailComposerUGD *ugd = data;
1048 debug_log("ugd is NULL");
1049 return ECORE_CALLBACK_CANCEL;
1052 if (ugd->send_timer) {
1053 debug_log("delete send_timer");
1054 ecore_timer_del(ugd->send_timer);
1055 ugd->send_timer = NULL;
1058 int ret = _composer_add_mailbox_folder(ugd, EMAIL_MAILBOX_TYPE_DRAFT, EINA_TRUE);
1060 if (ret < COMPOSER_ERROR_NONE) {
1061 debug_log("Failed save in Drafts(%d)", ret);
1063 if (ugd->popup_list) {
1064 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1065 debug_log("composer_noti: %p", ugd->composer_noti);
1067 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1070 evas_object_del(ugd->composer_noti);
1071 ugd->composer_noti = NULL;
1073 ugd->idler_save_draft = ecore_idler_add(_composer_show_fail_to_save, ugd);
1075 debug_log("Succeed in saving in Drafts");
1076 debug_log("Account id [%d] mailbox id [%d] mail id [%d]", ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID);
1078 if (ugd->popup_list) {
1079 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1080 debug_log("composer_noti: %p", ugd->composer_noti);
1082 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1085 evas_object_del(ugd->composer_noti);
1086 ugd->composer_noti = NULL;
1088 if (ugd->save_drafts == 0) {
1089 ugd->idler_save_draft = ecore_idler_add(_composer_show_success_to_save, ugd);
1091 char str[128] = { 0, };
1092 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_SAVED_IN_DRAFTS"));
1093 ret = status_message_post(str);
1095 debug_log("status_message_post failed: %d", ret);
1097 ug_destroy_me(ugd->ug_main);
1101 return ECORE_CALLBACK_CANCEL;
1104 void _composer_save_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
1108 debug_log("data is NULL");
1112 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1114 char *pszBtnText = (char *)elm_object_text_get(obj);
1115 debug_log("selected button text = %s", pszBtnText);
1117 if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_YES")) == 0) {
1118 if (ugd->need_download == EINA_TRUE) {
1119 if (ugd->popup_list) {
1120 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1121 debug_log("composer_noti: %p", ugd->composer_noti);
1123 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1126 evas_object_del(ugd->composer_noti);
1127 ugd->composer_noti = NULL;
1129 _composer_download_attachment(ugd);
1131 _composer_save_draft_mail(ugd);
1133 } else if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_NO")) == 0) {
1134 ugd->idler_save_draft = ecore_idler_add(_composer_idler_destroy, ugd);
1135 } else if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_CANCEL")) == 0) {
1136 if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_BODY_ENABLE_EDITABLE, _composer_focus_script_executed_cb, NULL) == EINA_FALSE)
1137 debug_log("COMPOSER_JS_BODY_ENABLE_EDITABLE failed.");
1138 _composer_noti_response_cb(data, obj, event_info);
1142 Eina_Bool _composer_show_fail_to_save(void *data)
1144 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1146 if (ugd->idler_save_draft) {
1147 debug_log("delete idler_save_draft");
1148 ecore_idler_del(ugd->idler_save_draft);
1149 ugd->idler_save_draft = NULL;
1153 ugd->b_sending = false;
1155 if (ugd->composer_noti) {
1156 evas_object_del(ugd->composer_noti);
1157 ugd->composer_noti = NULL;
1159 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
1160 _("IDS_EMAIL_POP_UNABLE_TO_SAVE_IN_DRAFTS"), 0, NULL, NULL, 1.5, _composer_save_draft_fail_response_cb);
1165 Eina_Bool _composer_show_success_to_save(void *data)
1167 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1169 if (ugd->idler_save_draft) {
1170 debug_log("delete idler_save_draft");
1171 ecore_idler_del(ugd->idler_save_draft);
1172 ugd->idler_save_draft = NULL;
1176 ugd->b_sending = false;
1178 if (ugd->composer_noti) {
1179 evas_object_del(ugd->composer_noti);
1180 ugd->composer_noti = NULL;
1182 ugd->composer_noti = _composer_create_noti(ugd, false, NULL,
1183 _("IDS_EMAIL_POP_SAVED_IN_DRAFTS"), 0, NULL, NULL, 1.5, _composer_save_draft_response_cb);
1188 static void _composer_save_draft_response_cb(void *data, Evas_Object *obj, void *event_info)
1192 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1194 ugd->idler_save_draft = ecore_idler_add(_composer_idler_destroy, ugd);
1197 static void _composer_save_draft_fail_response_cb(void *data, Evas_Object *obj, void *event_info)
1201 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1203 ugd->idler_save_draft = ecore_idler_add(_composer_idler_return, ugd);
1206 Eina_Bool _composer_popup_end_cb(void *data)
1210 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1211 _composer_popup_end(ugd, COMPOSER_ERROR_NONE);
1216 void _composer_popup_end(EmailComposerUGD *ugd, int close_sg)
1220 if (ugd->send_timer) {
1221 debug_log("delete send_timer");
1222 ecore_timer_del(ugd->send_timer);
1223 ugd->send_timer = NULL;
1226 if (ugd->composer_noti) {
1227 evas_object_del(ugd->composer_noti);
1228 ugd->composer_noti = NULL;
1231 if (close_sg == COMPOSER_ERROR_NONE) {
1232 if (elm_multibuttonentry_first_item_get(ugd->to_mbe))
1233 elm_multibuttonentry_clear(ugd->to_mbe);
1234 if (elm_multibuttonentry_first_item_get(ugd->cc_mbe))
1235 elm_multibuttonentry_clear(ugd->cc_mbe);
1236 if (elm_multibuttonentry_first_item_get(ugd->bcc_mbe))
1237 elm_multibuttonentry_clear(ugd->bcc_mbe);
1239 ug_destroy_me(ugd->ug_main);
1241 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
1242 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
1244 ugd->bSendBtnDisabled = false;
1248 void _composer_make_default_thumbnail(Evas_Object *eo, char *pszImgPath, int nItemType)
1252 char thumb_path[MAX_ATTACHMENT_FILE_LEN + 1] = { 0, };
1254 if (eo == NULL || pszImgPath == NULL)
1257 debug_log("Image path = %s", pszImgPath);
1259 Evas_Object *icon = eo;
1261 if (nItemType == COMPOSER_ATTACHMENT_ITEM_IMAGE) {
1262 debug_log("Thumbnail type - image");
1264 int err = _composer_attachment_make_ethumb(pszImgPath, thumb_path);
1266 if (err != COMPOSER_ERROR_NONE)
1267 elm_image_file_set(icon, ATTACHMENT_IMAGE_FILE_PATH, NULL);
1269 debug_log("Thumbnail path = %s", thumb_path);
1271 elm_image_file_set(icon, thumb_path, NULL);
1275 else if (nItemType == COMPOSER_ATTACHMENT_ITEM_SOUND)
1276 elm_image_file_set(icon, ATTACHMENT_AUDIO_FILE_PATH, NULL);
1277 else if (nItemType == COMPOSER_ATTACHMENT_ITEM_VIDEO)
1278 elm_image_file_set(icon, ATTACHMENT_VIDEO_FILE_PATH, NULL);
1280 gchar **vector = NULL;
1281 gint tok_cnt = g_strv_length(vector);
1283 vector = g_strsplit_set(pszImgPath, ".", -1);
1284 tok_cnt = g_strv_length(vector);
1285 debug_log("tok_cnt: [%d], file(%s, %s)", tok_cnt, vector[tok_cnt - 2], vector[tok_cnt - 1]);
1286 if (vector[tok_cnt - 1]) {
1287 if (g_strcmp0(vector[tok_cnt - 1], ATTACHMENT_MEDIA_VCARD) == 0) {
1288 elm_image_file_set(icon, ATTACHMENT_VCARD_FILE_PATH, NULL);
1289 } else if (g_strcmp0(vector[tok_cnt - 1], ATTACHMENT_MEDIA_VCALENDAR) == 0) {
1290 elm_image_file_set(icon, ATTACHMENT_VCALENDAR_FILE_PATH, NULL);
1292 elm_image_file_set(icon, ATTACHMENT_ETC_FILE_PATH, NULL);
1295 elm_image_file_set(icon, ATTACHMENT_ETC_FILE_PATH, NULL);
1301 Evas_Object *_composer_load_edj(Evas_Object *parent, const char *file, const char *group)
1307 eo = elm_layout_add(parent);
1309 r = elm_layout_file_set(eo, file, group);
1311 evas_object_del(eo);
1315 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1321 Evas_Object *_composer_create_navigation_layout(EmailComposerUGD *ugd)
1324 Evas_Object *parent = ugd->main_layout;
1325 Evas_Object *navi_bar;
1327 navi_bar = elm_naviframe_add(parent);
1328 elm_object_part_content_set(parent, "elm.swallow.content", navi_bar);
1330 evas_object_show(navi_bar);
1335 Evas_Object *_composer_create_composer_layout(Evas_Object *parent)
1338 Evas_Object *layout;
1340 layout = elm_layout_add(parent);
1342 elm_layout_file_set(layout, COMPOSER_EDJ_NAME, "layout.composer");
1343 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1344 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1345 evas_object_show(layout);
1350 Evas_Object *_composer_create_outer_layout(Evas_Object *parent)
1353 Evas_Object *layout;
1355 layout = elm_layout_add(parent);
1357 elm_layout_theme_set(layout, "layout", "application", "noindicator");
1358 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1359 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1360 evas_object_show(layout);
1365 Evas_Object *_composer_create_main_scroller(Evas_Object *parent)
1368 Evas_Object *scroller;
1370 scroller = elm_scroller_add(parent);
1372 elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE);
1373 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
1374 evas_object_show(scroller);
1379 Evas_Object *_composer_create_box(Evas_Object *parent)
1383 Evas_Object *box = elm_box_add(parent);
1384 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1385 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
1386 evas_object_show(box);
1388 elm_object_focus_allow_set(box, EINA_FALSE);
1393 void _composer_set_mail_info(EmailComposerUGD *ugd)
1397 _composer_add_to_address(ugd);
1398 _composer_add_cc_address(ugd);
1399 _composer_add_bcc_address(ugd);
1401 _composer_add_subject(ugd);
1402 _composer_add_body(ugd);
1404 if (ugd->composer_type != RUN_COMPOSER_EDIT) {
1405 _composer_add_origin_msg(ugd);
1408 if (ugd->composer_type == RUN_COMPOSER_FORWARD && ugd->account_info->account->options.forward_with_files) {
1410 email_mail_data_t *mail_data = ugd->existing_mail_info->mail_data;
1411 debug_log("attachment_count:%d, inline_content_count:%d", mail_data->attachment_count, mail_data->inline_content_count);
1413 if (mail_data->attachment_count > 0) {
1415 for (i = 0; i < mail_data->attachment_count; i++) {
1416 email_attachment_data_t *attachment_list = ugd->existing_mail_info->attachment_list;
1417 debug_log("save_status:%d, inline_content_status:%d", attachment_list[i].save_status, attachment_list[i].inline_content_status);
1418 if (attachment_list[i].save_status == FALSE && attachment_list[i].inline_content_status == FALSE) {
1419 ugd->need_download = EINA_TRUE;
1422 ugd->fw_attach_cnt++;
1424 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);
1428 _composer_add_attachment(ugd);
1430 char *plain_charset = NULL;
1431 char *charset = NULL;
1432 if ((EINA_TRUE == ugd->has_body_html) &&
1433 (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)) {
1434 email_mail_data_t *mail_data = ugd->existing_mail_info->mail_data;
1435 _composer_add_softlink_to_inline_images(ugd);
1437 if (mail_data && mail_data->file_path_plain) {
1438 plain_charset = email_parse_get_filename_from_path(mail_data->file_path_plain);
1439 debug_log("plain_charset : %s", plain_charset);
1440 if (plain_charset) {
1441 Ewk_Settings *ewkSetting = ewk_view_settings_get(ugd->body_ewkview);
1443 if (ewkSetting == NULL)
1444 debug_log("ewkSetting is NULL.");
1446 ewk_settings_default_encoding_set(ewkSetting, plain_charset);
1449 if (mail_data && mail_data->file_path_html) {
1450 charset = email_parse_get_filename_from_path(mail_data->file_path_html);
1451 debug_log("body html filename charset:%s", charset);
1453 Ewk_Settings *ewkSetting = ewk_view_settings_get(ugd->body_ewkview);
1455 if (ewkSetting == NULL)
1456 debug_log("ewkSetting is NULL.");
1458 ewk_settings_default_encoding_set(ewkSetting, charset);
1464 if (EINA_TRUE == ugd->has_body_html) {
1467 char file_path[MAX_PATH_LEN] = { 0, };
1468 snprintf(file_path, sizeof(file_path), "file://%s", ugd->saved_html_path);
1469 debug_log("file_path: (%s)", file_path);
1471 ewk_view_url_set(ugd->body_ewkview, file_path);
1473 g_free(plain_charset);
1479 void _composer_show_download_attachment_popup(EmailComposerUGD *ugd)
1483 char msg[MAX_STR_LEN] = { 0, };
1484 if (ugd->fw_dn_cnt > 1)
1485 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_DOWNLOAD_ATTACHMENTS_Q"));
1487 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_DOWNLOAD_ATTACHMENT_Q"));
1489 if (ugd->dn_noti_popup) {
1490 evas_object_del(ugd->dn_noti_popup);
1491 ugd->dn_noti_popup = NULL;
1493 ugd->dn_noti_popup = _composer_create_noti(ugd, false, NULL, msg, 2,
1494 dgettext("sys_string", "IDS_COM_SK_OK"), dgettext("sys_string", "IDS_COM_SK_CANCEL"), 0.0, _composer_attachment_popup_response_cb);
1497 static void _composer_attachment_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
1502 debug_log("data is NULL");
1506 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1508 char *pszBtnText = (char *)elm_object_text_get(obj);
1509 debug_log("selected button text = %s", pszBtnText);
1511 if (ugd->popup_list) {
1512 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1513 debug_log("obj: %p", obj);
1514 debug_log("dn_noti_popup: %p", ugd->dn_noti_popup);
1516 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->dn_noti_popup/*obj*/);
1519 evas_object_del(ugd->dn_noti_popup);
1520 ugd->dn_noti_popup = NULL;
1522 if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_OK")) == 0) {
1523 _composer_download_attachment(ugd);
1525 } else if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_CANCEL")) == 0) {
1526 ugd->selected_entry = ugd->to_mbe_entry;
1527 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
1532 Eina_Bool _composer_show_progress_popup(void *data)
1534 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1536 Evas_Object *progressbar;
1539 if (ugd->idler_show_progress) {
1540 debug_log("delete idler_show_progress");
1541 ecore_idler_del(ugd->idler_show_progress);
1542 ugd->idler_show_progress = NULL;
1546 ugd->fw_dn_total_cnt = ugd->fw_dn_cnt;
1548 char buf[128] = { 0, };
1550 snprintf(buf, sizeof(buf), "%s [0/%d]", _("IDS_EMAIL_POP_DOWNLOADING_ATTACHMENT_ING"), ugd->fw_dn_cnt);
1552 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1553 debug_log("dn_noti_popup: %p", ugd->dn_noti_popup);
1555 evas_object_del(ugd->dn_noti_popup);
1556 ugd->dn_noti_popup = NULL;
1558 if (ugd->dn_prog_popup) {
1559 evas_object_del(ugd->dn_prog_popup);
1560 ugd->dn_prog_popup = NULL;
1562 popup = _composer_create_noti(ugd, false, NULL, buf, 1,
1563 dgettext("sys_string", "IDS_COM_SK_CANCEL"), NULL, 0.0, _composer_dn_prog_popup_response_cb);
1565 ugd->dn_prog_popup = popup;
1566 elm_object_focus_set(popup, EINA_TRUE);
1568 Evas_Object *label = elm_label_add(popup);
1569 elm_object_text_set(label, buf);
1570 evas_object_show(label);
1571 ugd->fw_dn_label = label;
1573 Evas_Object *box = elm_box_add(popup);
1575 progressbar = elm_progressbar_add(popup);
1577 elm_object_style_set(progressbar, "list_progress");
1579 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
1580 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1581 elm_progressbar_value_set(progressbar, 0.0);
1582 evas_object_show(progressbar);
1583 ugd->fw_dn_progress = progressbar;
1584 evas_object_show(box);
1586 elm_box_pack_end(box, label);
1587 elm_box_pack_end(box, progressbar);
1589 elm_object_content_set(popup, box);
1594 static void _composer_dn_prog_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
1598 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1600 char *pszBtnText = (char *)elm_object_text_get(obj);
1601 debug_log("selected button text = %s", pszBtnText);
1603 if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_CANCEL")) == 0) {
1604 if (ugd->popup_list) {
1605 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1606 debug_log("obj: %p", obj);
1607 debug_log("dn_prog_popup: %p", ugd->dn_prog_popup);
1609 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->dn_prog_popup/*obj*/);
1612 if (ugd->dn_prog_popup) {
1613 evas_object_del(ugd->dn_prog_popup);
1614 ugd->dn_prog_popup = NULL;
1617 _composer_webkit_set_body_script(data);
1618 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
1619 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
1620 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
1622 _composer_cancel_download_attachment(ugd);
1624 ugd->selected_entry = ugd->to_mbe_entry;
1625 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
1629 static Eina_Bool _composer_save_attachment(EmailComposerUGD *ugd, int index)
1633 if (ugd->fw_attachment_list == NULL) {
1637 EMAIL_ATTACHMENT_INFO_S *info = (EMAIL_ATTACHMENT_INFO_S *) g_list_nth_data(ugd->fw_attachment_list, index);
1640 debug_log("EMAIL_ATTACHMENT_INFO_S *info is NULL");
1644 if (!info->downloaded) {
1646 gboolean res = FALSE;
1648 debug_log("Need attachment download");
1650 res = email_engine_attachment_download(ugd->existing_mail_info->mail_data->account_id, info->mail_id, info->index, &handle);
1653 ugd->fw_dn_handle[index] = handle;
1654 ugd->idler_show_progress = ecore_idler_add(_composer_show_progress_popup, ugd);
1656 info->downloaded = false;
1657 _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
1658 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
1659 dgettext("sys_string", "IDS_COM_SK_OK"), NULL,
1660 0, _composer_popup_response_cb);
1663 return (res ? EINA_TRUE : EINA_FALSE);
1669 void _composer_download_attachment(EmailComposerUGD *ugd)
1674 debug_log("ugd->fw_attach_cnt = %d", ugd->fw_attach_cnt);
1676 if (ugd->fw_attach_cnt > 0) {
1677 for ( i = 0 ; i < ugd->fw_attach_cnt ; i++ ) {
1678 if (_composer_save_attachment(ugd, i) == EINA_TRUE) {
1680 service_h service = NULL;
1682 ret = service_create(&service);
1683 debug_log("service_create: %d", ret);
1685 debug_log("service create failed");
1689 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_UPDATE, EMAIL_BUNDLE_KEY_UPDATE);
1690 debug_log("service_add_extra_data: %d", ret);
1692 ret = ug_send_result(ugd->ug_main, service);
1693 debug_log("ug_send_result: %d", ret);
1695 ret = service_destroy(service);
1696 debug_log("service_destroy: %d", ret);
1700 ugd->need_download = EINA_FALSE;
1701 ugd->bSendBtnDisabled = true;
1702 ugd->send_timer = ecore_timer_add(0.5, _composer_send_mail_cb, ugd);
1706 void _composer_attachment_cancel_download(EmailComposerUGD *ugd)
1710 int att_cnt = g_list_length(ugd->fw_attachment_list);
1713 debug_log("att_cnt = %d", att_cnt);
1714 for (i = 0; i < att_cnt; i++) {
1715 debug_log("handle index = %d", i);
1716 debug_log("handle = %d", ugd->fw_dn_handle[i]);
1717 email_engine_stop_working(ugd->account_info->account_id, ugd->fw_dn_handle[i]);
1721 void _composer_cancel_download_attachment(EmailComposerUGD *ugd)
1726 service_h service = NULL;
1728 _composer_attachment_cancel_download(ugd);
1730 ret = service_create(&service);
1731 debug_log("service_create: %d", ret);
1733 debug_log("service create failed");
1737 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CANCEL_ALL, "CANCEL_ALL");
1738 debug_log("service_add_extra_data: %d", ret);
1740 ug_send_result(ugd->ug_main, service);
1742 ret = service_destroy(service);
1743 debug_log("service_destroy: %d", ret);
1746 void _composer_update_attachment_info(EmailComposerUGD *ugd, int index)
1750 int nAttachmentObjListCount = eina_list_count(ugd->attachment_item_obj_list);
1751 debug_log("nAttachmentObjListCount : %d", nAttachmentObjListCount);
1753 if (nAttachmentObjListCount > 0) {
1755 Eina_Iterator *it = NULL;
1756 Evas_Object *attachment_obj = NULL;
1757 email_attachment_data_t *attachment_data;
1759 it = eina_list_iterator_new(ugd->attachment_item_obj_list);
1761 while (eina_iterator_next(it, (void **)&attachment_obj)) {
1763 EMAIL_ATTACHMENT_INFO_S *info = (EMAIL_ATTACHMENT_INFO_S *) g_list_nth_data(ugd->fw_attachment_list, nCount);
1764 debug_log("info : %x", info);
1766 debug_log("info->path : %s", info->path);
1767 debug_log("info->downloaded : %d", info->downloaded);
1768 debug_log("info->attach_id : %d", info->attach_id);
1769 if (info->index == index) {
1770 info->downloaded = true;
1771 path = email_engine_get_attachment_path(info->attach_id);
1773 debug_log("info->downloaded : %d", info->downloaded);
1774 debug_log("path : %s", path);
1776 attachment_data = evas_object_data_get(attachment_obj, "attachment_data");
1778 if (attachment_data && path && STR_VALID(path)) {
1780 char newpath[MAX_PATH_LEN] = { 0, };
1781 debug_log("path[%s]", path);
1782 ret = email_attachments_save_file(path, newpath, NULL);
1783 if (ret == EMAIL_EXT_SAVE_ERR_NONE) {
1784 char str[128] = { 0, };
1785 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
1786 ret = status_message_post(str);
1788 debug_log("status_message_post failed: %d", ret);
1791 attachment_data->attachment_path = g_strdup(path);
1792 attachment_data->save_status = info->downloaded;
1793 debug_log("attachment_name : %s", attachment_data->attachment_name);
1794 debug_log("attachment_path : %s", attachment_data->attachment_path);
1795 debug_log("attachment_id : %d", attachment_data->attachment_id);
1796 debug_log("attachment_size : %d", attachment_data->attachment_size);
1797 debug_log("save_status : %d", attachment_data->save_status);
1798 debug_log("inline_content_status : %d", attachment_data->inline_content_status);
1812 const char *_composer_get_sent_time(EmailComposerMail *mail_info)
1817 time = mail_info->mail_data->date_time;
1819 char *formatted_date = NULL;
1821 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1822 formatted_date = email_get_date_text(icu_locale, "yMMMEEEdhms", &time);
1824 formatted_date = email_get_date_text(icu_locale, "yMMMEEEdHms", &time);
1826 debug_log("date&time: %d [%s]", time, formatted_date);
1828 return formatted_date;
1831 char *_composer_get_wday(int tm_wday)
1836 wday = (char *)g_malloc0(10 * sizeof(char));
1840 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_SUN"));
1843 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_MON"));
1846 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_TUE"));
1849 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_WED"));
1852 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_THU"));
1855 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_FRI"));
1858 snprintf(wday, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_SAT"));
1867 char *_composer_get_month(int tm_mon)
1872 mon = (char *)g_malloc0(10 * sizeof(char));
1876 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_JAN"));
1879 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_FEB"));
1882 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_MAR"));
1885 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_APR"));
1888 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_MAY"));
1891 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_JUN"));
1894 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_JUL"));
1897 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_AUG"));
1900 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_SEP"));
1903 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_OCT"));
1906 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_NOV"));
1909 snprintf(mon, 10, "%s", dgettext("sys_string", "IDS_COM_BODY_DEC"));
1918 bool _composer_is_valid_email(const char *addr)
1920 char *token1 = NULL;
1921 char *token2 = NULL;
1923 debug_log("addr = %s", addr);
1925 if (addr[0] == '\0') {
1929 token1 = strchr(addr, '@');
1931 debug_log("there is no @");
1935 if (strchr(&token1[1], '@')) {
1936 debug_log("there is too many @");
1940 token2 = strchr(token1, '.');
1942 debug_log("there is no .");
1946 if ((token2 == token1 + 1) || (*(token2 + 1) == '\0')) {
1947 debug_log("Should be xxx.xxx");
1954 bool _composer_check_recipient_is_duplicated(EmailComposerUGD *ugd, Evas_Object *obj, EmailRecpInfo * ri)
1958 bool isDuplicated = false;
1960 Elm_Object_Item *mbe_item;
1961 EmailRecpInfo *iter_ri = NULL;
1963 mbe_item = elm_multibuttonentry_first_item_get(obj);
1966 iter_ri = elm_object_item_data_get(mbe_item);
1968 if (iter_ri != ri) {
1969 if (!g_strcmp0(iter_ri->email_list[iter_ri->selected_email_idx].email_addr, ri->email_list[0].email_addr)) {
1970 isDuplicated = true;
1975 mbe_item = elm_multibuttonentry_item_next_get(mbe_item);
1978 return isDuplicated;
1981 Eina_Bool _composer_idler_destroy(void *data)
1984 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1986 char str[128] = { 0, };
1987 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MESSAGE_DELETED"));
1988 int ret = status_message_post(str);
1990 debug_log("status_message_post failed: %d", ret);
1992 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_FALSE); // block the focus not to open IME.
1994 if (ugd->idler_save_draft) {
1995 debug_log("delete idler_save_draft");
1996 ecore_idler_del(ugd->idler_save_draft);
1997 ugd->idler_save_draft = NULL;
2000 if (ugd->popup_list) {
2001 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
2002 debug_log("composer_noti: %p", ugd->composer_noti);
2004 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
2007 evas_object_del(ugd->composer_noti);
2008 ugd->composer_noti = NULL;
2010 ug_destroy_me(ugd->ug_main);
2015 Eina_Bool _composer_idler_return(void *data)
2018 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2020 if (ugd->idler_save_draft) {
2021 debug_log("delete idler_save_draft");
2022 ecore_idler_del(ugd->idler_save_draft);
2023 ugd->idler_save_draft = NULL;
2026 if (ugd->popup_list) {
2027 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
2028 debug_log("composer_noti: %p", ugd->composer_noti);
2030 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
2033 evas_object_del(ugd->composer_noti);
2034 ugd->composer_noti = NULL;
2039 void _composer_entry_filter_remove_markup(void *data, Evas_Object *entry, char **text)
2042 if (text == NULL || *text == NULL) {
2043 debug_log("New Text is NULL");
2047 char *preedit_str = NULL;
2048 char *utf8_text = NULL;
2049 char *convert_text = NULL;
2051 /* Check preeditting text and return if it exist */
2052 preedit_str = strstr(*text, "<preedit_sel>");
2056 /* Convert from markup text to utf8 text from entry */
2057 utf8_text = elm_entry_markup_to_utf8(*text);
2060 /* If the string contains "Carrage return ('\n'), it should be changed "<br>" to show properly */
2061 convert_text = elm_entry_utf8_to_markup(utf8_text);
2064 *text = strdup(convert_text);
2071 void _composer_add_to_address(EmailComposerUGD *ugd)
2075 Eina_Bool overflow_flag = TRUE;
2076 Eina_Bool invalid_address_flag = FALSE;
2078 char *from_addr = NULL;
2080 if (ugd->existing_mail_info->mail_data != NULL && ugd->existing_mail_info->mail_data->full_address_from != NULL &&
2081 (ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL)) {
2084 char *from_temp = g_strdup(ugd->existing_mail_info->mail_data->full_address_from);
2086 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, from_temp);
2089 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2091 if (!_composer_check_recipient_is_duplicated(ugd, ugd->to_mbe, ri)) {
2092 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
2095 if (ugd->composer_noti) {
2096 evas_object_del(ugd->composer_noti);
2097 ugd->composer_noti = NULL;
2099 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2100 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2104 if (ri && !ri_used) {
2105 if (ri->display_name) {
2106 free(ri->display_name);
2107 ri->display_name = NULL;
2116 if ((ugd->existing_mail_info->mail_data != NULL && ugd->existing_mail_info->mail_data->full_address_to != NULL &&
2117 (ugd->composer_type == RUN_COMPOSER_REPLY_ALL || ugd->composer_type == RUN_COMPOSER_EDIT)) ||
2118 (ugd->new_mail_info->mail_data != NULL && ugd->new_mail_info->mail_data->full_address_to != NULL && ugd->composer_type == RUN_COMPOSER_EXTERNAL)) {
2121 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2123 email_address_info_t *addrs_info = NULL;
2125 int duplicate_cnt = 0;
2127 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_to) {
2128 temp = g_strdup(ugd->existing_mail_info->mail_data->full_address_to);
2129 debug_log("to = %s", ugd->existing_mail_info->mail_data->full_address_to);
2130 } else if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_to) {
2131 temp = g_strdup(ugd->new_mail_info->mail_data->full_address_to);
2132 debug_log("to = %s", ugd->new_mail_info->mail_data->full_address_to);
2135 token = strtok(temp, ";");
2136 debug_log("to = %s\ntoken = %s", temp, token);
2140 while (token != NULL && (overflow_flag = (i < (MAX_RECIPIENT_COUNT)))) {
2141 temp_name[i] = g_strdup(token);
2143 token = strtok(NULL, ";");
2146 if (!overflow_flag) {
2147 char msg[MAX_STR_LEN] = { 0, };
2148 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
2150 if (ugd->composer_noti) {
2151 evas_object_del(ugd->composer_noti);
2152 ugd->composer_noti = NULL;
2154 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2155 msg, 0, NULL, NULL, 2.0, _composer_noti_response_cb);
2160 if (max >= MAX_RECIPIENT_COUNT)
2161 max = MAX_RECIPIENT_COUNT - 1;
2163 debug_log("To recipients count(%d)", max);
2164 for (i = 0; i < max; i++) {
2165 temp_name[i] = g_strstrip(temp_name[i]);
2166 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2170 debug_critical("_composer_separate_save_recipient_char returned NULL");
2175 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2177 debug_log("email_addr = %s", ri->email_list[0].email_addr);
2178 debug_log("account.email_addr = %s", ugd->account_info->account->user_email_address);
2179 debug_log("from_addr = %s", from_addr);
2181 if (g_strcmp0(ri->email_list[0].email_addr, ugd->account_info->account->user_email_address) != 0 || ugd->composer_type != RUN_COMPOSER_REPLY_ALL) {
2182 if (!_composer_check_recipient_is_duplicated(ugd, ugd->to_mbe, ri)) {
2184 if (!_composer_is_valid_email(ri->email_list[0].email_addr)) {
2185 invalid_address_flag = TRUE;
2186 debug_log("invalid_address_flag is SET");
2189 addrs_info = (email_address_info_t *) g_list_nth_data(ugd->to_list, i);
2191 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
2192 elm_multibuttonentry_item_append(ugd->to_mbe, addrs_info->display_name, NULL, ri);
2194 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
2196 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
2203 if (ri && !ri_used) {
2204 if (ri->display_name) {
2205 free(ri->display_name);
2206 ri->display_name = NULL;
2216 if (duplicate_cnt) {
2217 if (ugd->composer_noti) {
2218 evas_object_del(ugd->composer_noti);
2219 ugd->composer_noti = NULL;
2221 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2222 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2225 if (invalid_address_flag) {
2226 if (ugd->composer_noti) {
2227 evas_object_del(ugd->composer_noti);
2228 ugd->composer_noti = NULL;
2230 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2231 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 0, NULL, NULL, 2.0, _composer_noti_response_cb);
2239 elm_multibuttonentry_expanded_set(ugd->to_mbe, FALSE);
2242 void _composer_add_cc_address(EmailComposerUGD *ugd)
2246 Eina_Bool overflow_flag = TRUE;
2248 if (ugd->composer_type == RUN_COMPOSER_EDIT || ugd->composer_type == RUN_COMPOSER_REPLY_ALL
2249 || ugd->composer_type == RUN_COMPOSER_NEW || ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2251 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)
2252 || (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)) {
2254 if (ugd->cc_mbe == NULL) {
2255 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2256 email_composer_create_cc_field(ugd);
2257 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2258 email_composer_create_bcc_field(ugd);
2259 ugd->b_cc_bcc = false;
2264 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2266 email_address_info_t *addrs_info = NULL;
2268 int duplicate_cnt = 0;
2270 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_cc) {
2271 temp = COMPOSER_STRDUP(ugd->existing_mail_info->mail_data->full_address_cc);
2272 debug_log("cc = %s", ugd->existing_mail_info->mail_data->full_address_cc);
2273 } else if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_cc) {
2274 temp = COMPOSER_STRDUP(ugd->new_mail_info->mail_data->full_address_cc);
2275 debug_log("cc = %s", ugd->new_mail_info->mail_data->full_address_cc);
2278 token = strtok(temp, ";");
2279 debug_log("cc = %s\ntoken = %s", temp, token);
2283 while (token != NULL && (overflow_flag = (i < (MAX_RECIPIENT_COUNT)))) {
2284 temp_name[i] = g_strdup(token);
2286 token = strtok(NULL, ";");
2289 if (!overflow_flag) {
2290 char msg[MAX_STR_LEN] = { 0, };
2291 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
2293 if (ugd->composer_noti) {
2294 evas_object_del(ugd->composer_noti);
2295 ugd->composer_noti = NULL;
2297 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2298 msg, 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2303 debug_log("Cc recipients count(%d)", max);
2304 for (i = 0; i < max; i++) {
2305 temp_name[i] = g_strstrip(temp_name[i]);
2306 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2310 debug_critical("_composer_separate_save_recipient_char returned NULL");
2313 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2315 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) {
2316 ri->is_always_bcc = true;
2319 if (!_composer_check_recipient_is_duplicated(ugd, ugd->cc_mbe, ri)) {
2321 addrs_info = (email_address_info_t *) g_list_nth_data(ugd->cc_list, i);
2323 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
2324 elm_multibuttonentry_item_append(ugd->cc_mbe, addrs_info->display_name, NULL, (void *)ri);
2326 elm_multibuttonentry_item_append(ugd->cc_mbe, ri->display_name, NULL, (void *)ri);
2328 elm_multibuttonentry_item_append(ugd->cc_mbe, ri->display_name, NULL, (void *)ri);
2332 if (ri->display_name) {
2333 free(ri->display_name);
2334 ri->display_name = NULL;
2343 if (duplicate_cnt) {
2344 if (ugd->composer_noti) {
2345 evas_object_del(ugd->composer_noti);
2346 ugd->composer_noti = NULL;
2348 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2349 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2356 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) {
2358 if (ugd->cc_mbe == NULL) {
2360 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2361 email_composer_create_cc_field(ugd);
2362 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2363 email_composer_create_bcc_field(ugd);
2364 ugd->b_cc_bcc = false;
2368 elm_multibuttonentry_expanded_set(ugd->cc_mbe, FALSE);
2371 void _composer_add_bcc_address(EmailComposerUGD *ugd)
2375 Eina_Bool overflow_flag = TRUE;
2377 if (ugd->composer_type == RUN_COMPOSER_EDIT || ugd->composer_type == RUN_COMPOSER_REPLY_ALL
2378 || ugd->composer_type == RUN_COMPOSER_NEW || ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2380 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)
2381 || (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)) {
2383 if (ugd->bcc_mbe == NULL) {
2384 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2385 email_composer_create_bcc_field(ugd);
2386 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2387 email_composer_create_cc_field(ugd);
2388 ugd->b_cc_bcc = false;
2393 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2395 email_address_info_t *addrs_info = NULL;
2397 int duplicate_cnt = 0;
2399 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->full_address_bcc) {
2400 temp = COMPOSER_STRDUP(ugd->existing_mail_info->mail_data->full_address_bcc);
2401 debug_log("bcc = %s", ugd->existing_mail_info->mail_data->full_address_bcc);
2402 } else if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->full_address_bcc) {
2403 temp = COMPOSER_STRDUP(ugd->new_mail_info->mail_data->full_address_bcc);
2404 debug_log("bcc = %s", ugd->new_mail_info->mail_data->full_address_bcc);
2407 token = strtok(temp, ";");
2408 debug_log("bcc = %s\ntoken = %s", temp, token);
2412 while (token != NULL && (overflow_flag = (i < (MAX_RECIPIENT_COUNT)))) {
2413 temp_name[i] = g_strdup(token);
2415 token = strtok(NULL, ";");
2418 if (!overflow_flag) {
2419 char msg[MAX_STR_LEN] = { 0, };
2420 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
2422 if (ugd->composer_noti) {
2423 evas_object_del(ugd->composer_noti);
2424 ugd->composer_noti = NULL;
2426 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2427 msg, 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2432 debug_log("Bcc recipients count(%d)", max);
2433 for (i = 0; i < max; i++) {
2434 temp_name[i] = g_strstrip(temp_name[i]);
2435 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2439 debug_critical("_composer_separate_save_recipient_char returned NULL");
2442 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2444 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) {
2445 ri->is_always_bcc = true;
2448 if (!_composer_check_recipient_is_duplicated(ugd, ugd->bcc_mbe, ri)) {
2449 if (ugd->bcc_list) {
2450 addrs_info = (email_address_info_t *) g_list_nth_data(ugd->bcc_list, i);
2452 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
2453 elm_multibuttonentry_item_append(ugd->bcc_mbe, addrs_info->display_name, NULL, (void *)ri);
2455 elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->display_name, NULL, (void *)ri);
2457 elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->display_name, NULL, (void *)ri);
2461 if (ri->display_name) {
2462 free(ri->display_name);
2463 ri->display_name = NULL;
2472 if (duplicate_cnt) {
2473 if (ugd->composer_noti) {
2474 evas_object_del(ugd->composer_noti);
2475 ugd->composer_noti = NULL;
2477 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2478 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0, NULL, NULL, 1.0, _composer_noti_response_cb);
2485 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) {
2487 if (ugd->bcc_mbe == NULL) {
2489 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2490 email_composer_create_bcc_field(ugd);
2491 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2492 email_composer_create_cc_field(ugd);
2493 ugd->b_cc_bcc = false;
2497 elm_multibuttonentry_expanded_set(ugd->bcc_mbe, FALSE);
2500 void _composer_add_from_address(EmailComposerUGD *ugd)
2504 EmailRecpInfo *ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
2506 ri->selected_email_idx = 0;
2507 ri->display_name = ugd->account_info->account->user_display_name;
2508 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", ugd->account_info->account->user_email_address);
2510 ri->is_contact_info = false;
2511 ri->is_always_bcc = false;
2512 ri->is_from_addr = true;
2514 debug_log("display_name : %s", ri->display_name);
2515 debug_log("email_addr : %s", ri->email_list[0].email_addr);
2517 elm_multibuttonentry_item_append(ugd->from_mbe, ri->display_name, NULL, ri);
2520 void _composer_add_subject(EmailComposerUGD *ugd)
2525 if (ugd->existing_mail_info->mail_data) {
2527 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
2528 if (ugd->existing_mail_info->mail_data->subject)
2529 temp = elm_entry_utf8_to_markup(ugd->existing_mail_info->mail_data->subject);
2531 temp = elm_entry_utf8_to_markup("");
2533 elm_entry_entry_set(ugd->subject_entry, temp);
2534 } else if (ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL || ugd->composer_type == RUN_COMPOSER_FORWARD) {
2535 char subject_temp[MAX_SUBJECT_LEN];
2538 if (ugd->composer_type == RUN_COMPOSER_FORWARD) {
2539 if (ugd->existing_mail_info->mail_data->subject)
2540 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: %s", _("IDS_EMAIL_BODY_FWD_T_EMAIL_PREFIX_ABB"), ugd->existing_mail_info->mail_data->subject);
2542 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: ", _("IDS_EMAIL_BODY_FWD_T_EMAIL_PREFIX_ABB"));
2544 if (ugd->existing_mail_info->mail_data->subject) {
2545 p = strchr(ugd->existing_mail_info->mail_data->subject, ':');
2547 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) {
2548 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s%s", _("IDS_EMAIL_BODY_RE"), p);
2550 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: %s", _("IDS_EMAIL_BODY_RE"), ugd->existing_mail_info->mail_data->subject);
2552 snprintf(subject_temp, MAX_SUBJECT_LEN, "%s: ", _("IDS_EMAIL_BODY_RE"));
2556 temp = elm_entry_utf8_to_markup(subject_temp);
2557 elm_entry_entry_set(ugd->subject_entry, temp);
2559 } else if (ugd->new_mail_info->mail_data) {
2561 if (ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2563 if (ugd->new_mail_info->mail_data->subject)
2564 temp = elm_entry_utf8_to_markup(ugd->new_mail_info->mail_data->subject);
2566 temp = elm_entry_utf8_to_markup("");
2568 elm_entry_entry_set(ugd->subject_entry, temp);
2572 if (elm_entry_is_empty(ugd->subject_entry))
2573 elm_object_signal_emit(ugd->subject_editfield, "elm,state,guidetext,show", "elm");
2575 elm_object_signal_emit(ugd->subject_editfield, "elm,state,guidetext,hide", "elm");
2577 debug_log("Freed subject :%s", temp);
2584 void _composer_add_body(EmailComposerUGD *ugd)
2587 char *full_text = NULL;
2589 if (ugd->existing_mail_info->mail_data && ugd->existing_mail_info->mail_data->body_download_status) {
2590 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
2591 if (ugd->has_body_html) {
2592 debug_log("html composer_type: EDIT");
2594 char *html_text_for_body = NULL;
2595 if (ugd->existing_mail_info->mail_data->file_path_html) {
2596 html_text_for_body = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_html, 0);
2597 } else if (ugd->existing_mail_info->mail_data->file_path_plain) {
2598 /*A plain-text draft mail converted to html mail*/
2599 char *temp_body_plain = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_plain, 0);
2600 html_text_for_body = (char *)email_composer_get_parse_string(temp_body_plain, STR_LEN(temp_body_plain));
2601 debug_log("\nHTML-TEXT:\n%s", html_text_for_body);
2602 free(temp_body_plain);
2605 char szMetaViewportInfo[TEMP_BUFFER_SIZE + 1] = { 0x00, };
2606 strncpy(szMetaViewportInfo, HTML_META_INFORMATION, TEMP_BUFFER_SIZE);
2608 if (html_text_for_body) {
2609 debug_log("html_text_for_body: %s", html_text_for_body);
2610 full_text = g_strconcat(szMetaViewportInfo, html_text_for_body, NULL);
2611 email_composer_save_file(ugd->saved_html_path, full_text, STR_LEN(full_text));
2612 g_free(html_text_for_body);
2614 html_text_for_body = (char *)email_get_buff_from_file(DATADIR"/_email_default.html", 0);
2615 debug_log("html_text_for_body: %s", html_text_for_body);
2616 full_text = g_strconcat(szMetaViewportInfo, html_text_for_body, NULL);
2617 email_composer_save_file(ugd->saved_html_path, full_text, STR_LEN(full_text));
2618 g_free(html_text_for_body);
2621 debug_log("full text:\n%s", full_text);
2626 debug_log("full_text :%s", full_text);
2633 static char* _composer_get_recipients_list_for_original_body_info(EmailComposerUGD *ugd)
2639 char *temp_name[MAX_RECIPIENT_ADDRESS_LEN];
2640 char *recipients_list = NULL;
2642 if (ugd->existing_mail_info->mail_data->full_address_to) {
2643 temp = COMPOSER_STRDUP(ugd->existing_mail_info->mail_data->full_address_to);
2644 token = strtok(temp, ";");
2645 debug_log("to = %s\ntoken = %s", temp, token);
2649 while (token != NULL) {
2650 temp_name[i] = g_strdup(token);
2651 debug_log("temp_name[%d] = %s, token = %s", i, temp_name[i], token);
2653 token = strtok(NULL, ";");
2654 debug_log(">> temp_name[%d] = %s, token = %s", i, temp_name[i], token);
2656 if (i == MAX_RECIPIENT_COUNT)
2663 debug_log("To recipients count(%d)", max);
2664 for (i = 0; i < max; i++) {
2665 EmailRecpInfo *ri = _composer_separate_save_recipient_char(ugd, temp_name[i]);
2668 debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr);
2669 if (ri->display_name == NULL) {
2670 debug_log("ri->display_name is NULL!");
2675 recipients_list = g_strconcat((recipients_list ? "; " : ""), ri->display_name, NULL);
2676 debug_log("recipients_list = %s", recipients_list);
2677 debug_log("ugd->existing_mail_info->mail_data->full_address_to = %s", ugd->existing_mail_info->mail_data->full_address_to);
2679 if (ri->display_name) {
2680 free(ri->display_name);
2681 ri->display_name = NULL;
2690 return recipients_list ? g_strdup(recipients_list) : NULL;
2693 static char* __composer_make_original_email_info(EmailComposerUGD *ugd)
2697 char *recipients_list = NULL;
2698 char *text_for_original_info = NULL;
2699 const char *sent_time = NULL;
2701 char text_for_from[MAX_STR_LEN] = { 0, };
2702 char text_for_sent[MAX_STR_LEN] = { 0, };
2703 char text_for_to[MAX_STR_LEN] = { 0, };
2704 char text_for_subject[MAX_STR_LEN] = { 0, };
2706 if (ugd->existing_mail_info && ugd->existing_mail_info->mail_data) {
2707 if (ugd->existing_mail_info->mail_data->full_address_from) {
2709 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));
2710 snprintf(text_for_from, sizeof(text_for_from), "<b>%s</b> %s<br>\n", _("IDS_EMAIL_BODY_FROM_M_SENDER"), from);
2714 sent_time = _composer_get_sent_time(ugd->existing_mail_info);
2716 snprintf(text_for_sent, sizeof(text_for_sent), "<b>%s</b> %s<br>\n", _("IDS_EMAIL_BODY_SENT_C"), sent_time);
2719 recipients_list = _composer_get_recipients_list_for_original_body_info(ugd);
2721 if (recipients_list != NULL) {
2722 snprintf(text_for_to, sizeof(text_for_to), ADDED_TEXT, dgettext("sys_string", "IDS_COM_BODY_TO"), recipients_list);
2724 debug_log("recipients_list is NULL");
2727 if (ugd->existing_mail_info->mail_data->subject) {
2728 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);
2731 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);
2733 //debug_log("text_for_original_info: %s", text_for_original_info);
2736 free((char *)sent_time);
2739 if (recipients_list) {
2740 free(recipients_list);
2741 recipients_list = NULL;
2745 return text_for_original_info ? g_strdup(text_for_original_info) : NULL;
2748 static void _composer_get_original_body_info(EmailComposerUGD *ugd, char **text_for_original_info, char *signature_text)
2752 char *encoded_text = NULL;
2753 char *tmp_info_text = __composer_make_original_email_info(ugd);
2755 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) {
2756 if (tmp_info_text != NULL){
2757 char *html_charset = email_parse_get_filename_from_path(ugd->existing_mail_info->mail_data->file_path_html);
2758 debug_log("html_charset : %s", html_charset);
2761 if ((g_strcmp0(html_charset, "ks_c_5601-1987") == 0) ||
2762 (g_strcmp0(html_charset, "KS_C_5601-1987") == 0) ||
2763 (g_strcmp0(html_charset, "EUCKR") == 0) ||
2764 (g_strcmp0(html_charset, "EUC-KR") == 0) ||
2765 (g_strcmp0(html_charset, "euckr") == 0) ||
2766 (g_strcmp0(html_charset, "euc-kr") == 0)) {
2768 encoded_text = eina_str_convert("UTF-8", "EUC-KR", tmp_info_text);
2770 if (NULL != encoded_text) {
2771 free(tmp_info_text);
2772 tmp_info_text = g_strdup(encoded_text);
2775 encoded_text = NULL;
2778 g_free(html_charset);
2781 debug_log("text_for_original_info is NULL");
2782 tmp_info_text = g_strdup("\n");
2785 free(tmp_info_text);
2786 tmp_info_text = g_strdup("\n");
2789 if (signature_text == NULL) {
2790 *text_for_original_info = g_strconcat(DIV_TAG_START_ORIGIN_INFO, tmp_info_text, DIV_TAG_END, NULL);
2792 *text_for_original_info = g_strconcat(DIV_TAG_START_ORIGIN_INFO, signature_text, tmp_info_text, DIV_TAG_END, NULL);
2794 debug_log("text_for_original_info: \n%s", *text_for_original_info);
2796 if (tmp_info_text) {
2797 g_free(tmp_info_text);
2798 tmp_info_text = NULL;
2802 static void _composer_get_html_text_for_body(EmailComposerUGD *ugd, char **html_text_for_body)
2806 char *tmp_html_text = NULL;
2808 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) {
2809 if (ugd->existing_mail_info->mail_data->file_path_html) {
2810 tmp_html_text = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_html, 0);
2811 } else if (ugd->existing_mail_info->mail_data->file_path_plain) {
2812 char *temp_body_plain = (char *)email_get_buff_from_file(ugd->existing_mail_info->mail_data->file_path_plain, 0);
2814 /*Convert plain-text to html content*/
2815 tmp_html_text = (char *)email_composer_get_parse_string(temp_body_plain, STR_LEN(temp_body_plain));
2816 debug_log("\nHTML-TEXT:\n%s", tmp_html_text);
2817 free(temp_body_plain);
2819 tmp_html_text = g_strdup("\n");
2821 } else if (ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2822 if (ugd->new_mail_info->mail_data && ugd->new_mail_info->mail_data->file_path_plain) { /*For Text memo*/
2823 debug_log("file_path_plain(%s)", ugd->new_mail_info->mail_data->file_path_plain);
2824 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));
2826 debug_log("Empty html body");
2827 tmp_html_text = g_strdup("\n");
2830 debug_log("Empty html body"); /*For RUN_COMPOSER_NEW*/
2831 tmp_html_text = g_strdup("\n");
2834 *html_text_for_body = g_strconcat(DIV_TAG_START_ORIGIN_CONTENT, tmp_html_text, DIV_TAG_END, NULL);
2835 debug_log("html_text_for_body: \n%s", *html_text_for_body);
2837 if (tmp_html_text) {
2838 g_free(tmp_html_text);
2839 tmp_html_text = NULL;
2843 char *_composer_make_text_with_div_tag(char *origin_text, int div_tag)
2847 if (origin_text == NULL) {
2852 return g_strconcat(DIV_TAG_START_ORIGIN_INFO, origin_text, DIV_TAG_END, NULL);
2854 return g_strconcat(DIV_TAG_START_ORIGIN_CONTENT, origin_text, DIV_TAG_END, NULL);
2858 void _composer_make_html_body(EmailComposerUGD *ugd)
2862 char *full_text = NULL;
2863 char *text_for_original_info = NULL;
2864 char *html_text_for_body = NULL;
2865 char szMetaViewportInfo[TEMP_BUFFER_SIZE + 1] = { 0x00, };
2867 _composer_get_html_text_for_body(ugd, &html_text_for_body);
2869 strncpy(szMetaViewportInfo, HTML_META_INFORMATION, TEMP_BUFFER_SIZE);
2871 if ((ugd->account_info->account->options).add_signature) {
2872 char signature_text[128] = { 0, };
2874 if ((ugd->account_info->account->options).signature) {
2875 snprintf(signature_text, sizeof(signature_text), "<br><br><br>%s<br><br>", (ugd->account_info->account->options).signature);
2878 _composer_get_original_body_info(ugd, &text_for_original_info, signature_text);
2880 debug_log("composer_type:%d", ugd->composer_type);
2881 if (ugd->composer_type == RUN_COMPOSER_NEW || ugd->composer_type == RUN_COMPOSER_REPLY
2882 || ugd->composer_type == RUN_COMPOSER_REPLY_ALL || ugd->composer_type == RUN_COMPOSER_FORWARD) {
2884 full_text = g_strconcat(szMetaViewportInfo, BODY_TAG_START, text_for_original_info, html_text_for_body, BODY_TAG_END, HTML_TAG_END, NULL);
2885 } else if (ugd->composer_type == RUN_COMPOSER_EXTERNAL) {
2887 full_text = g_strconcat(szMetaViewportInfo, BODY_TAG_START, html_text_for_body, text_for_original_info, BODY_TAG_END, HTML_TAG_END, NULL);
2890 //ugd->original_info_content = g_strconcat(DIV_TAG_START_ORIGIN_INFO, text_for_original_info, DIV_TAG_END, NULL);
2891 _composer_get_original_body_info(ugd, &text_for_original_info, NULL);
2892 full_text = g_strconcat(szMetaViewportInfo, BODY_TAG_START, text_for_original_info, html_text_for_body, BODY_TAG_END, HTML_TAG_END, NULL);
2895 debug_log("full text:\n%s", full_text);
2896 email_composer_save_file(ugd->saved_html_path, full_text, STR_LEN(full_text));
2898 free(text_for_original_info);
2899 free(html_text_for_body);
2903 void _composer_add_origin_msg(EmailComposerUGD *ugd)
2907 _composer_make_html_body(ugd);
2910 /* Creates symbolic links to all the inline images */
2911 void _composer_add_softlink_to_inline_images(EmailComposerUGD *ugd)
2916 char *inline_image_name = NULL;
2917 char *softlink_path = NULL;
2918 char *temp_save_name = NULL;
2920 if (ugd->existing_mail_info->mail_data == NULL)
2923 if (ugd->existing_mail_info->mail_data->body_download_status && ugd->existing_mail_info->mail_data->attachment_count > 0) {
2925 for (i = 0; i < ugd->existing_mail_info->mail_data->attachment_count; i++) {
2926 if (ugd->existing_mail_info->attachment_list[i].inline_content_status && ugd->existing_mail_info->attachment_list[i].attachment_path)
2927 /* To do: Must check attachment_temp_list->downloaded condition also.
2928 Though inline content is downloaded, in db 'downloaded' flag set to 0. */
2930 debug_log("attachment_data_list[%d].attachment_path :%s", i, ugd->existing_mail_info->attachment_list[i].attachment_path);
2931 temp_save_name = g_strdup(ugd->existing_mail_info->attachment_list[i].attachment_path);
2932 inline_image_name = email_composer_parse_filepath(temp_save_name, EINA_FALSE);
2933 softlink_path = g_strconcat(EMAIL_TMP_FOLDER, "/", inline_image_name, NULL);
2934 g_free(inline_image_name);
2937 debug_log("softlink_path :%s", softlink_path);
2939 int result = symlink(ugd->existing_mail_info->attachment_list[i].attachment_path, softlink_path);
2940 debug_log("result:%d", result);
2941 free(softlink_path);
2942 free(temp_save_name);
2948 void _composer_add_attachment(EmailComposerUGD *ugd)
2952 if ((ugd->composer_type == RUN_COMPOSER_FORWARD && (ugd->account_info->account->options).forward_with_files != 0) || ugd->composer_type == RUN_COMPOSER_EDIT) {
2953 if (ugd->existing_mail_info->mail_data->body_download_status && ugd->existing_mail_info->mail_data->attachment_count > 0) {
2955 email_attachment_data_t *fwd_attachment_data_list = ugd->existing_mail_info->attachment_list;
2958 int nTotalAttachmentSize = 0;
2961 if (ugd->attachment_item_box == NULL) {
2962 Evas_Object *attachment_item_box;
2963 attachment_item_box = _composer_create_box(ugd->main_layout);
2964 elm_object_part_content_set(ugd->c_layout, "_attachment_field", attachment_item_box);
2965 ugd->attachment_item_box = attachment_item_box;
2967 _composer_attachment_expand_items(ugd);
2970 for (i = 0; i < ugd->existing_mail_info->mail_data->attachment_count; i++) {
2973 if (i >= MAX_ATTACHMENT_ITEM)
2976 EMAIL_ATTACHMENT_INFO_S *attachment_info = (EMAIL_ATTACHMENT_INFO_S *)calloc(1, sizeof(EMAIL_ATTACHMENT_INFO_S));
2978 if (attachment_info) {
2979 attachment_info->mail_id = ugd->nExistingMailID;
2980 attachment_info->attach_id = fwd_attachment_data_list[i].attachment_id;
2981 attachment_info->index = index;
2982 attachment_info->size = fwd_attachment_data_list[i].attachment_size;
2983 attachment_info->downloaded = fwd_attachment_data_list[i].save_status;
2984 attachment_info->drm = fwd_attachment_data_list[i].drm_status;
2985 attachment_info->inline_content = fwd_attachment_data_list[i].inline_content_status;
2986 attachment_info->name = g_strdup(fwd_attachment_data_list[i].attachment_name);
2987 attachment_info->path = g_strdup(fwd_attachment_data_list[i].attachment_path);
2989 debug_log("mail id (%d)", attachment_info->mail_id);
2990 debug_log("attachments index (%d)", attachment_info->index);
2991 debug_log("attachments attach_id (%d)", attachment_info->attach_id);
2992 debug_log("attachments name (%s)", attachment_info->name ? attachment_info->name : "@niL");
2993 debug_log("attachments path (%s)", attachment_info->path ? attachment_info->path : "@niL");
2994 debug_log("attachments size (%d)", attachment_info->size);
2995 debug_log("attachments download (%d)", attachment_info->downloaded);
2996 debug_log("attachments drm (%d)", attachment_info->drm);
2997 debug_log("attachments inline? (%d)", attachment_info->inline_content);
2999 nTotalAttachmentSize = nTotalAttachmentSize + attachment_info->size;
3001 debug_log("fwd_attachment_data_list[%d] = %x", i, &fwd_attachment_data_list[i]);
3002 debug_log("downloaded attachment = %s", fwd_attachment_data_list[i].attachment_path);
3004 if (ugd->existing_mail_info->mail_data->file_path_html) {
3005 nTotalAttachmentSize += (int)email_get_file_size(ugd->existing_mail_info->mail_data->file_path_html);
3006 debug_log("Total attachments size (including original html body): %d byte", nTotalAttachmentSize);
3009 if (nTotalAttachmentSize / 1024 > MAX_ATTACHMENT_SIZE) {
3010 char msg[MAX_STR_LEN] = { 0, };
3011 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_UNABLE_TO_ATTACH_MAXIMUM_SIZE_OF_FILES_IS_PD_KB"), MAX_ATTACHMENT_SIZE);
3013 if (ugd->composer_noti) {
3014 evas_object_del(ugd->composer_noti);
3015 ugd->composer_noti = NULL;
3017 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
3018 msg, 0, NULL, NULL, 2.0, _composer_noti_response_cb);
3020 if (attachment_info->name) {
3021 free(attachment_info->name);
3022 attachment_info->name = NULL;
3025 if (attachment_info->path) {
3026 free(attachment_info->path);
3027 attachment_info->path = NULL;
3030 if (attachment_info) {
3031 free(attachment_info);
3032 attachment_info = NULL;
3037 ugd->fw_attachment_list = g_list_append(ugd->fw_attachment_list, attachment_info);
3039 if (attachment_info->inline_content == EINA_FALSE) {
3040 email_attachment_data_t *attachment_data = (email_attachment_data_t *)calloc(1, sizeof(email_attachment_data_t));
3042 attachment_data->attachment_id = attachment_info->attach_id;
3043 attachment_data->attachment_name = COMPOSER_STRDUP(attachment_info->name);
3044 attachment_data->attachment_path = COMPOSER_STRDUP(attachment_info->path);
3045 attachment_data->save_status = attachment_info->downloaded;
3046 attachment_data->attachment_size = attachment_info->size;
3047 attachment_data->mail_id = attachment_info->mail_id;
3048 attachment_data->inline_content_status = attachment_info->inline_content;
3050 _composer_attachment_create_list_box(ugd, attachment_data);
3058 Evas_Object *_composer_popup_create(Evas_Object *parent, EmailComposerUGD *ugd)
3062 Evas_Object *popup, *window;
3064 window = _composer_create_sub_window(parent);
3065 ugd->popup_win = window;
3070 Evas_Object * bg = evas_object_rectangle_add(evas_object_evas_get(window));
3071 elm_win_resize_object_add(window, bg);
3072 evas_object_color_set(bg, 0, 0, 0, 0);
3073 evas_object_render_op_set(bg, EVAS_RENDER_COPY);
3074 evas_object_show(bg);
3076 popup = elm_popup_add(window);
3077 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3078 evas_object_data_set(popup, "window", window);
3080 evas_object_show(popup);
3081 evas_object_show(window);
3086 void _composer_popup_delete(Evas_Object *popup)
3092 Evas_Object *window = evas_object_data_del(popup, "window");
3095 debug_log("Window Delete");
3096 evas_object_del(window);
3098 debug_log("PopUp Delete");
3099 evas_object_del(popup);
3104 * This API gets the latest recipients list from mbe and checks for change from the initial list
3106 * @param [in] mbe multibuttonentry(to,cc or bcc)
3107 * @param [in] initial_recipients_list contains the list of recipients when composer launched
3109 * @return true if recipients modified or false
3111 bool _composer_check_recipients_modified(Evas_Object *mbe, Eina_List **initial_recipients_list)
3115 if (!mbe || !initial_recipients_list)
3118 const Eina_List *current_list = NULL;
3119 Eina_List *mbe_initial_list = *initial_recipients_list;
3120 bool is_modified = false;
3122 current_list = elm_multibuttonentry_items_get(mbe);
3124 if ((!mbe_initial_list && current_list) || (mbe_initial_list && !current_list)) {
3126 } else if (mbe_initial_list && current_list) {
3127 if (current_list->accounting->count != mbe_initial_list->accounting->count) {
3130 Eina_List *l1 = mbe_initial_list;
3131 const Eina_List *l2 = current_list;
3134 for (index = 0; index < current_list->accounting->count; index++) {
3135 if (eina_list_data_get(l1) != eina_list_data_get(l2)) {
3139 l1 = eina_list_next(l1);
3140 l2 = eina_list_next(l2);
3149 * This API checks whether email content has been modified from the original content
3151 * @param [in] data EmailComposerUGD data
3153 * @return true if mail is modified or false
3155 bool _composer_check_mail_is_modified(void *data)
3161 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3163 bool is_modified = false;
3165 if ((ugd->composer_type == RUN_COMPOSER_EXTERNAL)
3166 || (ugd->to_mbe && _composer_check_recipients_modified(ugd->to_mbe, &ugd->to_mbe_initial_list))
3167 || (ugd->cc_mbe && _composer_check_recipients_modified(ugd->cc_mbe, &ugd->cc_mbe_initial_list))
3168 || (ugd->bcc_mbe && _composer_check_recipients_modified(ugd->bcc_mbe, &ugd->bcc_mbe_initial_list))
3169 || (g_strcmp0(elm_entry_entry_get(ugd->subject_entry), ugd->saved_subject) != 0)) {
3175 bool is_attach_modified = false;
3177 if ((ugd->attach_initial_list && !ugd->attachment_item_obj_list) || (!ugd->attach_initial_list && ugd->attachment_item_obj_list)) {
3178 is_attach_modified = true;
3179 } else if (ugd->attach_initial_list && ugd->attachment_item_obj_list) {
3180 int nInitialListCount = eina_list_count(ugd->attach_initial_list);
3181 int nAttachmentCount = eina_list_count(ugd->attachment_item_obj_list);
3183 if (nInitialListCount != nAttachmentCount) {
3184 is_attach_modified = true;
3187 int nInitialListCount = eina_list_count(ugd->attach_initial_list);
3189 for (i = 0; i < nInitialListCount; i++) {
3190 if (eina_list_nth(ugd->attach_initial_list, i) != eina_list_nth(ugd->attachment_item_obj_list, i)) {
3191 is_attach_modified = true;
3198 if (is_attach_modified) {
3203 if (EINA_TRUE == ugd->has_body_html) {
3204 if (ugd->latest_body_html_content == NULL) {
3205 debug_log("ugd->latest_body_html_content is NULL");
3206 is_modified = false;
3210 if (ugd->latest_body_html_content && ugd->original_body_html_content) {
3211 debug_log("original_body_html_content:\n%s", ugd->original_body_html_content);
3212 debug_log("latest_body_html_content:\n%s", ugd->latest_body_html_content);
3213 if (g_strcmp0(ugd->original_body_html_content, ugd->latest_body_html_content) != 0) {
3214 debug_log("diff => %d", g_strcmp0(ugd->original_body_html_content, ugd->latest_body_html_content));
3219 is_modified = false; /*if latest_html_content and/or saved_html_content is NULL,
3220 is_modified set to false; on return false, destroy composer is called*/
3227 _composer_free_initial_email_content(ugd);
3233 bool _composer_check_recipient_is_empty(void *data)
3239 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3241 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->to_mbe)) != NULL) {
3244 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->cc_mbe)) != NULL) {
3247 if (elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->bcc_mbe)) != NULL) {
3254 Evas_Object *_composer_create_sub_window(Evas_Object *parent)
3260 unsigned char *prop_data = NULL;
3264 Eina_Bool accepts_focus;
3265 Ecore_X_Window_State_Hint initial_state;
3266 Ecore_X_Pixmap icon_pixmap;
3267 Ecore_X_Pixmap icon_mask;
3268 Ecore_X_Window icon_window;
3269 Ecore_X_Window window_group;
3270 Eina_Bool is_urgent;
3273 eo = elm_win_add(parent, "composer_sub_win", ELM_WIN_DIALOG_BASIC);
3275 elm_win_alpha_set(eo, EINA_TRUE);
3276 elm_win_title_set(eo, "composer_sub_win");
3278 ecore_x_window_geometry_get(ecore_x_window_root_get(ecore_x_window_focus_get()), &x, &y, &w, &h);
3280 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);
3282 if (ret && prop_data)
3283 memcpy(&rotation, prop_data, sizeof(int));
3286 evas_object_resize(eo, w, h);
3287 evas_object_move(eo, x, y);
3290 elm_win_rotation_with_resize_set(eo, rotation);
3292 ecore_x_icccm_hints_get(elm_win_xwindow_get(eo), &accepts_focus, &initial_state, &icon_pixmap, &icon_mask, &icon_window, &window_group, &is_urgent);
3293 ecore_x_icccm_hints_set(elm_win_xwindow_get(eo), EINA_FALSE, initial_state, icon_pixmap, icon_mask, icon_window, window_group, is_urgent);
3295 evas_object_show(eo);
3297 debug_log("Fail to make SubWindow");
3302 void _composer_unfocus_and_save(void *data)
3306 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3308 if (ugd->to_mbe_entry && elm_object_focus_get(ugd->to_mbe_entry)) {
3309 debug_log("to mbe unfocused");
3310 elm_multibuttonentry_expanded_set(ugd->to_mbe, FALSE);
3311 } else if (ugd->cc_mbe_entry && elm_object_focus_get(ugd->cc_mbe_entry)) {
3312 debug_log("cc mbe unfocused");
3313 elm_object_focus_set(ugd->cc_mbe, EINA_FALSE);
3314 elm_multibuttonentry_expanded_set(ugd->cc_mbe, FALSE);
3315 } else if (ugd->bcc_mbe_entry && elm_object_focus_get(ugd->bcc_mbe_entry)) {
3316 debug_log("bcc mbe unfocused");
3317 elm_object_focus_set(ugd->bcc_mbe, EINA_FALSE);
3318 elm_multibuttonentry_expanded_set(ugd->bcc_mbe, FALSE);
3319 } else if (ugd->subject_entry && elm_object_focus_get(ugd->subject_entry)) {
3320 debug_log("subject unfocused");
3321 elm_object_focus_set(ugd->subject_entry, EINA_FALSE);
3326 void _composer_change_text_to_textblock(char *input, char **output, char *matched_word, char *prefix, char *postfix)
3330 char *found = (char *)strcasestr(input, matched_word);
3336 int idx = found - input;
3337 int buf_len = strlen(input) + strlen(prefix) + strlen(postfix) + 1;
3339 temp = (char *)malloc(buf_len * sizeof(char));
3345 memset(temp, 0x00, buf_len);
3347 strncpy(temp, input, buf_len - 1);
3348 strncpy(temp + idx, prefix, buf_len - strlen(temp) - 1);
3349 strncpy(temp + idx + strlen(prefix), matched_word, buf_len - strlen(temp) - 1);
3350 strncpy(temp + idx + strlen(prefix) + strlen(matched_word), postfix, buf_len - strlen(temp) - 1);
3351 strncpy(temp + idx + strlen(prefix) + strlen(matched_word) + strlen(postfix), input + idx + strlen(matched_word), buf_len - strlen(temp) - 1);
3352 temp[buf_len - 1] = '\0';
3359 static void _composer_popup_waiting_response_cb(void *data, Evas_Object *obj, void *event_info)
3363 debug_log("data is NULL");
3367 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3369 if (ugd->timeout_noti) {
3370 evas_object_del(ugd->timeout_noti);
3371 ugd->timeout_noti = NULL;
3375 void _composer_create_waiting_popup(EmailComposerUGD *ugd, const char *title_text, const char *style)
3378 if (title_text == NULL) {
3379 debug_log("popup text is null");
3383 Evas_Object *popup = elm_popup_add(ugd->win_main);
3384 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3385 elm_object_part_text_set(popup, "title,text", title_text);
3387 Evas_Object *progress = elm_progressbar_add(popup);
3388 elm_object_style_set(progress, style);
3389 elm_progressbar_pulse_set(progress, EINA_TRUE);
3390 elm_progressbar_pulse(progress, EINA_TRUE);
3391 evas_object_show(progress);
3393 elm_object_content_set(popup, progress);
3395 Evas_Object *btn1 = elm_button_add(popup);
3396 elm_object_style_set(btn1, "popup_button/default");
3397 elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
3398 elm_object_part_content_set(popup, "button1", btn1);
3399 evas_object_smart_callback_add(btn1, "clicked", _composer_popup_waiting_response_cb, ugd);
3401 ugd->timeout_noti = popup;
3403 evas_object_show(popup);
3406 Evas_Object *_composer_create_noti_with_list(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);
3433 #ifdef _POPUP_WITH_LIST
3434 elm_object_style_set(notify, "min_menustyle");
3436 elm_object_style_set(notify, "menustyle");
3440 Evas_Object *peoBtn1 = NULL;
3441 peoBtn1 = elm_button_add(notify);
3442 debug_log("peoBtn1: %p", peoBtn1);
3443 elm_object_style_set(peoBtn1, "popup_button/default");
3444 elm_object_text_set(peoBtn1, btn1_lb);
3445 elm_object_part_content_set(notify, "button1", peoBtn1);
3446 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3447 } else if (btn_num == 2) {
3448 Evas_Object *peoBtn1 = NULL;
3449 peoBtn1 = elm_button_add(notify);
3450 debug_log("peoBtn1: %p", peoBtn1);
3451 elm_object_style_set(peoBtn1, "popup_button/default");
3452 elm_object_text_set(peoBtn1, btn1_lb);
3453 elm_object_part_content_set(notify, "button1", peoBtn1);
3454 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3456 Evas_Object *peoBtn2 = NULL;
3457 peoBtn2 = elm_button_add(notify);
3458 debug_log("peoBtn2: %p", peoBtn2);
3459 elm_object_style_set(peoBtn2, "popup_button/default");
3460 elm_object_text_set(peoBtn2, btn2_lb);
3461 elm_object_part_content_set(notify, "button2", peoBtn2);
3462 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3465 if (timeout > 0.0) {
3466 elm_popup_timeout_set(notify, timeout);
3467 evas_object_smart_callback_add(notify, "timeout", response_cb, ugd);
3468 evas_object_smart_callback_add(notify, "block,clicked", response_cb, ugd);
3471 evas_object_show(notify);
3473 ugd->popup_list = eina_list_append(ugd->popup_list, notify);
3475 debug_log("notify = %x, %p", notify, notify);
3479 Evas_Object *_composer_create_noti(EmailComposerUGD *ugd, bool use_win, char *title, char *content,
3480 int btn_num, char *btn1_lb, char *btn2_lb,
3481 double timeout, void (*response_cb) (void *data, Evas_Object *obj, void *event_info))
3484 Evas_Object *notify;
3487 notify = _composer_popup_create(ugd->win_main, ugd);
3489 notify = elm_popup_add(ugd->win_main);
3491 debug_log("notify: %p", notify);
3493 debug_log("elm_popup_add returns NULL");
3496 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3499 elm_object_part_text_set(notify, "title,text", title);
3503 elm_object_text_set(notify, content);
3507 Evas_Object *peoBtn1 = NULL;
3508 peoBtn1 = elm_button_add(notify);
3509 debug_log("peoBtn1: %p", peoBtn1);
3510 elm_object_style_set(peoBtn1, "popup_button/default");
3511 elm_object_text_set(peoBtn1, btn1_lb);
3512 elm_object_part_content_set(notify, "button1", peoBtn1);
3513 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3514 } else if (btn_num == 2) {
3515 Evas_Object *peoBtn1 = NULL;
3516 peoBtn1 = elm_button_add(notify);
3517 debug_log("peoBtn1: %p", peoBtn1);
3518 elm_object_style_set(peoBtn1, "popup_button/default");
3519 elm_object_text_set(peoBtn1, btn1_lb);
3520 elm_object_part_content_set(notify, "button1", peoBtn1);
3521 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3523 Evas_Object *peoBtn2 = NULL;
3524 peoBtn2 = elm_button_add(notify);
3525 debug_log("peoBtn2: %p", peoBtn2);
3526 elm_object_style_set(peoBtn2, "popup_button/default");
3527 elm_object_text_set(peoBtn2, btn2_lb);
3528 elm_object_part_content_set(notify, "button2", peoBtn2);
3529 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3532 if (timeout > 0.0) {
3533 elm_popup_timeout_set(notify, timeout);
3534 evas_object_smart_callback_add(notify, "timeout", response_cb, ugd);
3535 evas_object_smart_callback_add(notify, "block,clicked", response_cb, ugd);
3538 evas_object_show(notify);
3540 ugd->popup_list = eina_list_append(ugd->popup_list, notify);
3542 debug_log("notify = %x, %p", notify, notify);
3546 Evas_Object *_composer_create_popup(EmailComposerUGD *ugd, bool use_win, char *title, char *content,
3547 int btn_num, char *btn1_lb, char *btn2_lb, char *btn3_lb,
3548 double timeout, void (*response_cb) (void *data, Evas_Object *obj, void *event_info))
3551 Evas_Object *notify;
3554 notify = _composer_popup_create(ugd->win_main, ugd);
3556 notify = elm_popup_add(ugd->win_main);
3558 debug_log("notify: %p", notify);
3560 debug_log("elm_popup_add returns NULL");
3563 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3566 elm_object_part_text_set(notify, "title,text", title);
3570 elm_object_text_set(notify, content);
3574 Evas_Object *peoBtn1 = NULL;
3575 peoBtn1 = elm_button_add(notify);
3576 debug_log("peoBtn1: %p", peoBtn1);
3577 elm_object_style_set(peoBtn1, "popup_button/default");
3578 elm_object_text_set(peoBtn1, btn1_lb);
3579 elm_object_part_content_set(notify, "button1", peoBtn1);
3580 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3581 } else if (btn_num == 2) {
3582 Evas_Object *peoBtn1 = NULL;
3583 peoBtn1 = elm_button_add(notify);
3584 debug_log("peoBtn1: %p", peoBtn1);
3585 elm_object_style_set(peoBtn1, "popup_button/default");
3586 elm_object_text_set(peoBtn1, btn1_lb);
3587 elm_object_part_content_set(notify, "button1", peoBtn1);
3588 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3590 Evas_Object *peoBtn2 = NULL;
3591 peoBtn2 = elm_button_add(notify);
3592 debug_log("peoBtn2: %p", peoBtn2);
3593 elm_object_style_set(peoBtn2, "popup_button/default");
3594 elm_object_text_set(peoBtn2, btn2_lb);
3595 elm_object_part_content_set(notify, "button2", peoBtn2);
3596 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3597 } else if (btn_num == 3) {
3598 Evas_Object *peoBtn1 = NULL;
3599 peoBtn1 = elm_button_add(notify);
3600 debug_log("peoBtn1: %p", peoBtn1);
3601 elm_object_style_set(peoBtn1, "popup_button/default");
3602 elm_object_text_set(peoBtn1, btn1_lb);
3603 elm_object_part_content_set(notify, "button1", peoBtn1);
3604 evas_object_smart_callback_add(peoBtn1, "clicked", response_cb, ugd);
3606 Evas_Object *peoBtn2 = NULL;
3607 peoBtn2 = elm_button_add(notify);
3608 debug_log("peoBtn2: %p", peoBtn2);
3609 elm_object_style_set(peoBtn2, "popup_button/default");
3610 elm_object_text_set(peoBtn2, btn2_lb);
3611 elm_object_part_content_set(notify, "button2", peoBtn2);
3612 evas_object_smart_callback_add(peoBtn2, "clicked", response_cb, ugd);
3614 Evas_Object *peoBtn3 = NULL;
3615 peoBtn3 = elm_button_add(notify);
3616 debug_log("peoBtn3: %p", peoBtn3);
3617 elm_object_style_set(peoBtn3, "popup_button/default");
3618 elm_object_text_set(peoBtn3, btn3_lb);
3619 elm_object_part_content_set(notify, "button3", peoBtn3);
3620 evas_object_smart_callback_add(peoBtn3, "clicked", response_cb, ugd);
3623 if (timeout > 0.0) {
3624 elm_popup_timeout_set(notify, timeout);
3625 evas_object_smart_callback_add(notify, "timeout", response_cb, ugd);
3626 evas_object_smart_callback_add(notify, "block,clicked", response_cb, ugd);
3629 evas_object_show(notify);
3631 ugd->popup_list = eina_list_append(ugd->popup_list, notify);
3633 debug_log("notify = %x, %p", notify, notify);
3637 void _composer_noti_response_cb(void *data, Evas_Object *obj, void *event_info)
3641 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3643 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
3644 ugd->focus_status = COMPOSER_FOCUS_STATUS_NONE;
3646 Evas_Object *mbe = NULL;
3648 if (ugd->selected_entry == ugd->to_mbe_entry) {
3650 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
3652 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
3656 if (ugd->popup_list) {
3657 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
3658 debug_log("obj: %p", obj);
3659 debug_log("composer_noti: %p", ugd->composer_noti);
3661 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
3663 debug_log("@@@ b_sending = %d", ugd->b_sending);
3665 if (!_composer_check_popup_exist(ugd))
3666 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
3670 ugd->b_sending = false;
3672 evas_object_del(ugd->composer_noti);
3673 ugd->composer_noti = NULL;
3676 void _composer_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
3680 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3682 Evas_Object *mbe = NULL;
3684 if (ugd->selected_entry == ugd->to_mbe_entry) {
3686 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
3688 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
3693 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
3694 elm_multibuttonentry_item_selected_set(item, EINA_FALSE);
3697 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE);
3699 if (ugd->popup_list) {
3700 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
3701 debug_log("obj: %p", obj);
3702 debug_log("composer_noti: %p", ugd->composer_popup);
3704 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_popup/*obj*/);
3706 debug_log("@@@ b_sending = %d", ugd->b_sending);
3708 if (!_composer_check_popup_exist(ugd))
3709 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
3713 ugd->b_sending = false;
3715 evas_object_del(ugd->composer_popup);
3716 ugd->composer_popup = NULL;
3717 ugd->is_mbe_selected = false;
3718 ugd->selected_mbe_item = NULL;
3721 Eina_Bool _composer_check_popup_exist(EmailComposerUGD *ugd)
3725 if (!ugd) return EINA_FALSE;
3727 debug_log("popup list count = %d", eina_list_count(ugd->popup_list));
3728 if (eina_list_count(ugd->popup_list) > 0)
3734 int _composer_get_account_list(EmailComposerUGD *ugd)
3738 int err = email_get_account_list(&ugd->account_info->account_list, &ugd->account_info->account_count);
3740 if (err != EMAIL_ERROR_NONE) {
3741 debug_log("[email-composer] email_account_get_list error");
3742 return COMPOSER_ERROR_NO_ACCOUNT_LIST;
3746 for (i = 0; i < ugd->account_info->account_count; i++) {
3747 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);
3750 debug_log("[email-composer] account count = %d", ugd->account_info->account_count);
3752 return COMPOSER_ERROR_NONE;
3755 char *_composer_get_email_addr_from_account_id(EmailComposerUGD *ugd, int account_id)
3760 for (i = 0; i < ugd->account_info->account_count; i++) {
3761 if (ugd->account_info->account_list[i].account_id == account_id)
3762 return g_strdup(ugd->account_info->account_list[i].user_email_address);
3768 char *_composer_get_service_fail_type(int type)
3773 char str[MAX_STR_LEN] = { 0, };
3776 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("IP full"));
3777 return g_strdup(str);
3778 } else if (type == -176) {
3779 ret = _("IDS_EMAIL_POP_NO_SERVICE");
3780 return g_strdup(ret);
3781 } else if (type == -181) {
3782 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("Transport Error"));
3783 return g_strdup(str);
3784 } else if (type == EMAIL_ERROR_NETWORK_TOO_BUSY) {
3785 ret = _("IDS_EMAIL_POP_NETWORK_BUSY");
3786 return g_strdup(ret);
3787 } else if (type == EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS) {
3788 snprintf(str, sizeof(str), _("IDS_EMAIL_POP_YOU_CAN_ONLY_LOG_IN_ONCE_EVERY_PD_MINUTES"), 15);
3789 return g_strdup(str);
3790 } else if (type == EMAIL_ERROR_CONNECTION_FAILURE) {
3791 ret = dgettext("sys_string", "IDS_COM_POP_CONNECTION_FAILED");
3792 return g_strdup(ret);
3793 } else if (type == EMAIL_ERROR_LOGIN_FAILURE) {
3794 ret = _("IDS_EMAIL_POP_LOG_IN_FAILED");
3795 return g_strdup(ret);
3796 } else if (type == EMAIL_ERROR_AUTHENTICATE) {
3797 ret = _("IDS_EMAIL_POP_AUTHENTICATION_FAILED");
3798 return g_strdup(ret);
3799 } else if (type == EMAIL_ERROR_CANCELLED) {
3800 ret = _("IDS_EMAIL_POP_SENDING_CANCELLED");
3801 return g_strdup(ret);
3802 } else if (type == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) {
3803 ret = _("IDS_EMAIL_POP_EMAIL_DELETED_FROM_SERVER");
3804 return g_strdup(ret);
3805 } else if (type == EMAIL_ERROR_NO_SUCH_HOST) {
3806 ret = _("IDS_EMAIL_POP_HOST_NOT_FOUND");
3807 return g_strdup(ret);
3808 } else if (type == EMAIL_ERROR_INVALID_SERVER) {
3809 ret = _("IDS_EMAIL_POP_SERVER_NOT_AVAILABLE");
3810 return g_strdup(ret);
3811 } else if (type == EMAIL_ERROR_MAIL_MEMORY_FULL) {
3812 ret = _("IDS_EMAIL_POP_DEVICE_STORAGE_FULL");
3813 return g_strdup(ret);
3814 } else if (type == EMAIL_ERROR_FAILED_BY_SECURITY_POLICY) {
3815 ret = _("IDS_EMAIL_POP_DOWNLOADING_ATTACHMENTS_ON_THE_MOBILE_DEVICE_IS_NOT_ALLOWED_BY_EXCHANGE_SERVER_POLICY");
3816 return g_strdup(ret);
3817 } else if (type == EMAIL_ERROR_ATTACHMENT_SIZE_EXCEED_POLICY_LIMIT) {
3818 ret = _("IDS_EMAIL_BODY_ATTACHMENT_EXCEEDS_THE_MAXIMUM_SIZE_ALLOWED_BY_THIS_EXCHANGE_SERVER_POLICY_ABB");
3819 return g_strdup(ret);
3820 } else if (type == EMAIL_ERROR_NETWORK_NOT_AVAILABLE) {
3821 ret = N_("Network not available");
3822 return g_strdup(ret);
3823 } else if (type == EMAIL_ERROR_FLIGHT_MODE) {
3824 ret = N_("Flight mode enabled");
3825 return g_strdup(ret);
3826 } else if (type == EMAIL_ERROR_NO_RESPONSE) {
3827 ret = N_("No server response");
3828 return g_strdup(ret);
3829 } else if (type == EMAIL_ERROR_DISCONNECTED) {
3830 ret = N_("Disconnected");
3831 return g_strdup(ret);
3832 } else if (type == EMAIL_ERROR_CONNECTION_BROKEN) {
3833 ret = N_("Connection broken");
3834 return g_strdup(ret);
3836 snprintf(str, sizeof(str), "%s (%d)", dgettext("sys_string", "IDS_COM_POP_UNKNOWN_ERROR_OCCURRED"), type);
3837 return g_strdup(str);
3841 Eina_Bool _composer_mbe_set_focus(void *data)
3845 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3847 debug_log("selected_entry = %x, to_mbe_entry = %x, cc_mbe_entry = %x, bcc_mbe_entry = %x, subject_entry = %x, body_ewkview = %x",
3848 ugd->selected_entry, ugd->to_mbe_entry, ugd->cc_mbe_entry, ugd->bcc_mbe_entry, ugd->subject_entry, ugd->body_ewkview);
3850 if (ugd->focus_status != COMPOSER_FOCUS_STATUS_NONE) {
3851 ugd->focus_status = COMPOSER_FOCUS_STATUS_NONE;
3853 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
3855 if ((ugd->selected_entry == ugd->to_mbe_entry) || (ugd->selected_entry == NULL)) {
3856 debug_log("TO MBE ENTRY FOCUS!!!");
3857 elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
3858 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
3859 debug_log("CC MBE ENTRY FOCUS!!!");
3860 elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
3861 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
3862 debug_log("BCC MBE ENTRY FOCUS!!!");
3863 elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
3864 } else if (ugd->selected_entry == ugd->subject_entry) {
3865 debug_log("SUBJECT ENTRY FOCUS!!!");
3866 elm_object_focus_set(ugd->subject_editfield, EINA_TRUE);
3867 } else if (ugd->selected_entry == ugd->body_ewkview) {
3868 debug_log("BODY WEBKIT FOCUS!!!");
3869 evas_object_focus_set(ugd->body_ewkview, EINA_TRUE);
3870 } else if (ugd->selected_entry == ugd->attachment_contracted_item) {
3871 debug_log("Attachments FOCUS!!!");
3872 elm_object_focus_set(ugd->attachment_contracted_item, EINA_TRUE);
3874 debug_log("NO ENTRY!!! TO MBE ENTRY will get the focus.");
3875 elm_object_focus_set(ugd->to_mbe_entry, EINA_TRUE);
3879 ugd->b_cc_bcc = false;
3881 if (ugd->clipboard_on)
3882 ugd->clipboard_on = false;
3884 if (ugd->idler_set_focus) {
3885 ecore_idler_del(ugd->idler_set_focus);
3886 ugd->idler_set_focus = NULL;
3892 void _composer_resize_body_webview(EmailComposerUGD *ugd, int ime_height)
3894 Evas_Coord nWidth = 0, nHeight = 0;
3896 ecore_x_window_size_get(ecore_x_window_root_first_get(), &nWidth, &nHeight);
3898 if (ugd->isHorizontal == false) {
3899 evas_object_size_hint_min_set(ugd->webkit_ly, 0, nHeight - COMPOSER_NAVI_HEIGHT - COMPOSER_INDI_HEIGHT - ime_height);
3902 evas_object_size_hint_min_set(ugd->webkit_ly, 0, nWidth - COMPOSER_NAVI_HEIGHT - ime_height);
3905 if ((ugd->from_mbe != NULL) && (ugd->b_launch_finished == false)) {
3906 ugd->b_launch_finished = true;
3907 ugd->bringin_timer = ecore_timer_add(0.5f, _composer_bringin_cb, ugd);
3911 void _composer_input_panel_resize_cb(void *data, Ecore_IMF_Context *ctx, int value)
3915 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3917 bool ime_state = true; // true: open, false: close
3918 Evas_Coord x = 0, y = 0, w = 0, h = 0;
3919 Evas_Coord cx = 0, cy = 0, cw = 0, ch = 0;
3921 evas_object_geometry_get(ugd->win_main, &x, &y, &w, &h);
3922 ecore_imf_context_input_panel_geometry_get(ctx, &cx, &cy, &cw, &ch);
3924 debug_log("main ==> (x:%d,y:%d,w:%d,h:%d)", x, y, w, h);
3925 debug_log("rect ==> (x:%d,y:%d,w:%d,h:%d)", cx, cy, cw, ch);
3931 _composer_resize_body_webview(ugd, ch);
3934 _composer_resize_body_webview(ugd, 0);
3938 void _composer_input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value)
3943 void _composer_display_position(void *data)
3945 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
3946 Evas_Coord x = 0, y = 0, w = 0, h = 0;
3948 elm_scroller_region_get(ugd->main_scroller, &x, &y, &w, &h);
3949 debug_log("scroller = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3953 evas_object_geometry_get(ugd->from_ly, &x, &y, &w, &h);
3954 debug_log("from = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3958 evas_object_geometry_get(ugd->to_ly, &x, &y, &w, &h);
3959 debug_log("to = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3963 evas_object_geometry_get(ugd->cc_ly, &x, &y, &w, &h);
3964 debug_log("cc = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3969 evas_object_geometry_get(ugd->bcc_ly, &x, &y, &w, &h);
3970 debug_log("bcc = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3974 evas_object_geometry_get(ugd->subject_ly, &x, &y, &w, &h);
3975 debug_log("subject = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3978 evas_object_geometry_get(ugd->webkit_ly, &x, &y, &w, &h);
3979 debug_log("webview = [x:%d, y:%d, w:%d, h:%d]", x, y, w, h);
3983 static Eina_Bool _composer_print_hit_test_result_hash_fn(const Eina_Hash *hash, const void *key, void *data, void *fdata)
3985 // fdata is the third parameter
3986 debug_log("Func data: %s, Hash entry: %s / %s\n", fdata, (const char *)key, data);
3990 void _composer_print_hit_test_result(Ewk_Hit_Test *hit_test)
3992 Eina_Hash *attr_hash = NULL;
3993 debug_log("context: %d", ewk_hit_test_result_context_get(hit_test));
3994 debug_log("linkURI: %s", ewk_hit_test_link_uri_get(hit_test));
3995 debug_log("linkTitle: %s", ewk_hit_test_link_title_get(hit_test));
3996 debug_log("linkLabel: %s", ewk_hit_test_link_label_get(hit_test));
3997 debug_log("imageURI: %s", ewk_hit_test_image_uri_get(hit_test));
3998 debug_log("mediaURI: %s", ewk_hit_test_media_uri_get(hit_test));
3999 debug_log("nodeData.tagName: %s", ewk_hit_test_tag_name_get(hit_test));
4000 debug_log("nodeData.nodeValue: %s", ewk_hit_test_node_value_get(hit_test));
4001 debug_log("imageData.length: %d", ewk_hit_test_image_buffer_length_get(hit_test));
4002 debug_log("imageData.fileNameExtension: %s", ewk_hit_test_image_file_name_extension_get(hit_test));
4004 attr_hash = ewk_hit_test_attribute_hash_get(hit_test);
4006 eina_hash_foreach(attr_hash, _composer_print_hit_test_result_hash_fn, NULL);
4009 void _composer_coords_ewk_to_evas(Evas_Object *view, int ewkX, int ewkY, int *evasX, int *evasY)
4011 int scrollX, scrollY, viewX, viewY;
4012 ewk_view_scroll_pos_get(view, &scrollX, &scrollY);
4013 evas_object_geometry_get(view, &viewX, &viewY, NULL, NULL);
4015 *evasX = ewkX - scrollX + viewX;
4016 *evasY = ewkY - scrollY + viewY;
4019 void _composer_coords_evas_to_ewk(Evas_Object *view, int evasX, int evasY, int *ewkX, int *ewkY)
4021 debug_log("evasX:%d, evasY:%d", evasX, evasY);
4022 int scrollX, scrollY, viewX, viewY;
4023 ewk_view_scroll_pos_get(view, &scrollX, &scrollY);
4024 evas_object_geometry_get(view, &viewX, &viewY, NULL, NULL);
4025 debug_log("scrollX:%d, scrollY:%d, viewX:%d, viewY:%d", scrollX, scrollY, viewX, viewY);
4027 *ewkX = evasX + scrollX - viewX;
4028 *ewkY = evasY + scrollY - viewY;