From 98d96529fbf26fa8f3f2f8840a02ae779b04fd19 Mon Sep 17 00:00:00 2001 From: "jc47.park" Date: Fri, 4 Jan 2013 11:31:27 +0900 Subject: [PATCH] Merged the latest code --- composer/include/email-composer.h | 3 +- composer/src/email-composer-attachment.c | 31 +++++++------- composer/src/email-composer-callback.c | 57 ++++++++++++++++++++----- composer/src/email-composer-contents.c | 3 ++ composer/src/email-composer-util.c | 71 ++++++++++++++++++-------------- composer/src/email-composer.c | 10 +++-- 6 files changed, 113 insertions(+), 62 deletions(-) diff --git a/composer/include/email-composer.h b/composer/include/email-composer.h index 4abd15e..9015fc7 100755 --- a/composer/include/email-composer.h +++ b/composer/include/email-composer.h @@ -232,7 +232,8 @@ struct ug_data { COMPOSER_ERROR_TYPE_E eComposerErrorType; - Eina_List *listOfImageUrls; + int inline_cnt; + Eina_List *attachment_inline_item_list; Eina_Bool b_load_finished; Eina_Bool need_download; diff --git a/composer/src/email-composer-attachment.c b/composer/src/email-composer-attachment.c index 221e20b..d5b4206 100755 --- a/composer/src/email-composer-attachment.c +++ b/composer/src/email-composer-attachment.c @@ -154,19 +154,21 @@ int _composer_get_inline_images_size(EmailComposerUGD *ugd) int total_size = 0; if (EINA_TRUE == ugd->has_body_html) { - debug_log("listOfImageUrls count : %d", eina_list_count(ugd->listOfImageUrls)); - if (eina_list_count(ugd->listOfImageUrls) > 0) { + debug_log("attachment_inline_item_list count : %d", eina_list_count(ugd->attachment_inline_item_list)); + if (eina_list_count(ugd->attachment_inline_item_list) > 0) { - Eina_List *list = ugd->listOfImageUrls; + Eina_List *list = ugd->attachment_inline_item_list; Eina_List *l = NULL; - char *recv = NULL; - + email_attachment_data_t *attachment_data = NULL; + Eina_List *inline_list = NULL; - - EINA_LIST_FOREACH(list, l, recv) { - if (strncmp(recv, "file://", 7) == 0) { - debug_log("Inline image : %s", recv + 7); - inline_list = eina_list_append(inline_list, recv + 7); + + EINA_LIST_FOREACH(list, l, attachment_data) { + if (attachment_data != NULL) { + if (attachment_data->attachment_path != NULL) { + debug_log("Inline image : %s", attachment_data->attachment_path); + inline_list = eina_list_append(inline_list, attachment_data->attachment_path); + } } } if (eina_list_count(inline_list) > 0 && (inline_list != NULL)) { @@ -748,7 +750,7 @@ int _composer_attachment_make_ethumb(const char *source, char *target) { debug_log(""); - debug_log("file path: %s", source); +/* debug_log("file path: %s", source); efreet_mime_init(); char *type = (char *)efreet_mime_type_get(ecore_file_file_get(source)); char *mime_type = g_strdup(type); @@ -758,7 +760,8 @@ int _composer_attachment_make_ethumb(const char *source, char *target) if (mime_type) { if (strncmp(mime_type, "image", 5) == 0) { strncpy(target, source, MAX_ATTACHMENT_FILE_LEN); - } else if (strncmp(mime_type, "video", 5) == 0) { +#endif + } else if (strncmp(mime_type, "video", 5) == 0) {*/ metadata_extractor_h metadata = NULL; int ret = METADATA_EXTRACTOR_ERROR_NONE; char *video_width = NULL; @@ -824,11 +827,11 @@ int _composer_attachment_make_ethumb(const char *source, char *target) ret = metadata_extractor_destroy(metadata); debug_log("metadata_extractor_destroy: %d", ret); - } +/* } } g_free(mime_type); - +*/ return COMPOSER_ERROR_NONE; } diff --git a/composer/src/email-composer-callback.c b/composer/src/email-composer-callback.c index 7611aad..0629599 100755 --- a/composer/src/email-composer-callback.c +++ b/composer/src/email-composer-callback.c @@ -71,7 +71,7 @@ void _composer_edit_field_changed_cb(void *data, Evas_Object *obj, void *event_i EmailComposerUGD *ugd = (EmailComposerUGD *)data; if (obj == ugd->subject_entry) { - _composer_check_entry_max(ugd, ugd->subject_entry, MAX_SUBJECT_LEN); + _composer_check_entry_max(ugd, ugd->subject_entry, MAX_SUBJECT_LEN + 1); if (_composer_check_recipient_is_empty(ugd)) { if (!ugd->bSendBtnDisabled) { @@ -2791,21 +2791,56 @@ void _composer_get_image_list_cb(Evas_Object *o, const char *result, void *data) char *list = NULL; EmailComposerUGD *ugd = (EmailComposerUGD *) data; - if (ugd->listOfImageUrls) { - eina_list_free(ugd->listOfImageUrls); - ugd->listOfImageUrls = NULL; + if (ugd->attachment_inline_item_list) { + eina_list_free(ugd->attachment_inline_item_list); + ugd->attachment_inline_item_list = NULL; } if (result != NULL) { - debug_log("listOFImageUrls => %s", result); + debug_log("attachment_inline_item_list => %s", result); list = g_strdup(result); - - char *token = strtok(list, ","); - while (token != NULL) { - if (token) { - ugd->listOfImageUrls = eina_list_append(ugd->listOfImageUrls, token); - token = strtok(NULL, ","); + char *url = strtok(list, ","); + while (url != NULL) { + if (url) { + if (strncmp(url, "file://", 7) == 0) { /* add only local images(file://), not web images(http://) */ + int return_stat; + gchar **tokens; + struct stat file_info; + debug_log("image = %s", url + 7); + + if ((return_stat = stat(url + 7, &file_info)) == -1) { + debug_error("stat Error(%d): %s", return_stat, strerror(return_stat)); + break; + } + + tokens = g_strsplit(url + 7, "/", -1); + + email_attachment_data_t *attachment_data = (email_attachment_data_t *)calloc(1, sizeof(email_attachment_data_t)); + attachment_data->account_id = ugd->account_info->account_id; + attachment_data->attachment_id = 0; + attachment_data->attachment_name = COMPOSER_STRDUP(tokens[g_strv_length(tokens) - 1]); + attachment_data->attachment_path = COMPOSER_STRDUP(url + 7); + attachment_data->attachment_size = file_info.st_size; + attachment_data->drm_status = 0; + attachment_data->inline_content_status = 1; + attachment_data->mailbox_id = NULL; + attachment_data->mail_id = 0; + attachment_data->save_status = 1; + attachment_data->attachment_mime_type = NULL; + debug_log("attachment_name = %s, attachment_path = %s", attachment_data->attachment_name, attachment_data->attachment_path); + ugd->attachment_inline_item_list = eina_list_append(ugd->attachment_inline_item_list, attachment_data); + g_strfreev(tokens); + } + url = strtok(NULL, ","); } } } + + ugd->inline_cnt = eina_list_count(ugd->attachment_inline_item_list); + debug_log("ugd->inline_cnt : %d", ugd->inline_cnt); + + if (list) { + free(list); + list = NULL; + } } diff --git a/composer/src/email-composer-contents.c b/composer/src/email-composer-contents.c index 0b37e23..10ab971 100755 --- a/composer/src/email-composer-contents.c +++ b/composer/src/email-composer-contents.c @@ -299,6 +299,9 @@ static void _composer_webkit_script_executed_cb(Evas_Object *o, const char *resu debug_log("COMPOSER_JS_GET_ORIGINAL_HTML_CONTENT failed."); if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_INFO_CONTENT, _composer_set_original_info_content_cb, (void *)ugd) == EINA_FALSE) debug_log("COMPOSER_JS_GET_ORIGINAL_INFO_CONTENT failed."); + if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_IMAGE_LIST, _composer_get_image_list_cb, (void *)ugd)) { + debug_log("COMPOSER_JS_GET_IMAGE_LIST error."); + } } void _composer_webkit_loadFinished_cb(void *data, Evas_Object *obj, void *event_info) diff --git a/composer/src/email-composer-util.c b/composer/src/email-composer-util.c index 2a31f25..6743015 100755 --- a/composer/src/email-composer-util.c +++ b/composer/src/email-composer-util.c @@ -669,39 +669,20 @@ int _composer_make_mail(EmailComposerUGD *ugd, Eina_Bool b_save_to_draft) debug_log("\nhtml_content:\n%s", html_content); - - if (ugd->listOfImageUrls == NULL) { + if (ugd->attachment_inline_item_list == NULL) { debug_log("No images found or ERROR"); html_content_processed = html_content; } else { - - Eina_List *l = NULL; - char *recv = NULL; - Eina_List *inline_list = NULL; - - EINA_LIST_FOREACH(ugd->listOfImageUrls, l, recv) { - debug_log("images_list: %s", recv); - if (strncmp(recv, "file://", 7) == 0) { /* add only local images(file://), not web images(http://) */ - debug_log("image = %s", recv + 7); - inline_list = eina_list_append(inline_list, recv + 7); - } - } - if (inline_list != NULL) { - if (!email_composer_change_image_paths_to_relative(html_content, &html_content_processed)) { - debug_log("email_composer_change_image_paths_to_relative Failed"); - g_free(html_content); - html_content = NULL; - return COMPOSER_ERROR_MAKE_MAIL_FAIL; - } - debug_log("\nhtml_source_processed:\n%s", html_content_processed); - - _composer_attachment_create_list(ugd, inline_list, EINA_TRUE); - + if (!email_composer_change_image_paths_to_relative(html_content, &html_content_processed)) { + debug_log("email_composer_change_image_paths_to_relative Failed"); g_free(html_content); html_content = NULL; - } else { - html_content_processed = html_content; + return COMPOSER_ERROR_MAKE_MAIL_FAIL; } + debug_log("\nhtml_source_processed:\n%s", html_content_processed); + + g_free(html_content); + html_content = NULL; } if (EINA_FALSE == email_composer_save_file(ugd->saved_html_path, html_content_processed, strlen(html_content_processed))) { @@ -737,7 +718,7 @@ int _composer_make_mail(EmailComposerUGD *ugd, Eina_Bool b_save_to_draft) int nAttachmentObjListCount = eina_list_count(ugd->attachment_item_obj_list); debug_log("nAttachmentObjListCount : %d", nAttachmentObjListCount); - if (nAttachmentObjListCount > 0) { + if ((nAttachmentObjListCount > 0) || (ugd->inline_cnt > 0)) { if (ugd->new_mail_info->attachment_list) { email_free_attachment_data(&ugd->new_mail_info->attachment_list, ugd->new_mail_info->mail_data->attachment_count); @@ -782,6 +763,32 @@ int _composer_make_mail(EmailComposerUGD *ugd, Eina_Bool b_save_to_draft) } } } + + it = eina_list_iterator_new(ugd->attachment_inline_item_list); + + ugd->new_mail_info->mail_data->attachment_count += ugd->inline_cnt; + + while (eina_iterator_next(it, (void **)&attachment_data)) { + if (attachment_data) { + if (attachment_data->save_status == 1) { + ugd->new_mail_info->attachment_list[nCount].inline_content_status = attachment_data->inline_content_status; + ugd->new_mail_info->attachment_list[nCount].attachment_id = attachment_data->attachment_id; + ugd->new_mail_info->attachment_list[nCount].attachment_size = attachment_data->attachment_size; + ugd->new_mail_info->attachment_list[nCount].save_status = attachment_data->save_status; + ugd->new_mail_info->attachment_list[nCount].attachment_name = COMPOSER_STRDUP(attachment_data->attachment_name); + ugd->new_mail_info->attachment_list[nCount].attachment_path = COMPOSER_STRDUP(attachment_data->attachment_path); + + debug_log("attachment_name : %s", ugd->new_mail_info->attachment_list[nCount].attachment_name); + debug_log("attachment_path : %s", ugd->new_mail_info->attachment_list[nCount].attachment_path); + debug_log("attachment_id : %d", ugd->new_mail_info->attachment_list[nCount].attachment_id); + debug_log("attachment_size : %d", ugd->new_mail_info->attachment_list[nCount].attachment_size); + debug_log("save_status : %d", ugd->new_mail_info->attachment_list[nCount].save_status); + debug_log("inline_content_status : %d", ugd->new_mail_info->attachment_list[nCount].inline_content_status); + + nCount++; + } + } + } } ugd->new_mail_info->mail_data->flags_draft_field = 1; @@ -2939,7 +2946,7 @@ void _composer_add_attachment(EmailComposerUGD *ugd) if (i >= MAX_ATTACHMENT_ITEM) break; - EMAIL_ATTACHMENT_INFO_S *attachment_info = (EMAIL_ATTACHMENT_INFO_S *) calloc(1, sizeof(EMAIL_ATTACHMENT_INFO_S)); + EMAIL_ATTACHMENT_INFO_S *attachment_info = (EMAIL_ATTACHMENT_INFO_S *)calloc(1, sizeof(EMAIL_ATTACHMENT_INFO_S)); email_attachment_data_t *attachment_data = (email_attachment_data_t *)calloc(1, sizeof(email_attachment_data_t)); if (attachment_info) { @@ -2975,7 +2982,7 @@ void _composer_add_attachment(EmailComposerUGD *ugd) nTotalAttachmentSize = nTotalAttachmentSize + attachment_data->attachment_size; } - if (fwd_attachment_data_list[i].save_status && fwd_attachment_data_list[i].inline_content_status == EINA_FALSE) + if (fwd_attachment_data_list[i].inline_content_status == EINA_FALSE) /* No need to add Inline images. They are added in _composer_attachment_create_list API. Line no:160. */ { debug_log("fwd_attachment_data_list[%d] = %x", i, &fwd_attachment_data_list[i]); @@ -2997,11 +3004,11 @@ void _composer_add_attachment(EmailComposerUGD *ugd) } else { attachment_data->attachment_name = COMPOSER_STRDUP(fwd_attachment_data_list[i].attachment_name); attachment_data->attachment_path = COMPOSER_STRDUP(fwd_attachment_data_list[i].attachment_path); - attachment_data->save_status = 1; + attachment_data->save_status = fwd_attachment_data_list[i].save_status; attachment_data->attachment_size = fwd_attachment_data_list[i].attachment_size; } + _composer_attachment_create_list_box(ugd, attachment_data); } - _composer_attachment_create_list_box(ugd, attachment_data); } if (ugd->existing_mail_info->mail_data->file_path_html) { diff --git a/composer/src/email-composer.c b/composer/src/email-composer.c index 10673d4..8a0b1d4 100755 --- a/composer/src/email-composer.c +++ b/composer/src/email-composer.c @@ -723,9 +723,9 @@ void _composer_free_initial_email_content(EmailComposerUGD *ugd) g_free(ugd->saved_subject); ugd->saved_subject = NULL; } - if (ugd->listOfImageUrls) { - eina_list_free(ugd->listOfImageUrls); - ugd->listOfImageUrls = NULL; + if (ugd->attachment_inline_item_list) { + eina_list_free(ugd->attachment_inline_item_list); + ugd->attachment_inline_item_list = NULL; } } @@ -934,7 +934,8 @@ static void _composer_init_data(void *data) ugd->is_webview_scrolling = false; ugd->focus_status = COMPOSER_FOCUS_STATUS_NONE; - ugd->listOfImageUrls = NULL; + ugd->inline_cnt = 0; + ugd->attachment_inline_item_list = NULL; ugd->b_load_finished = EINA_FALSE; ugd->need_download = EINA_FALSE; @@ -1540,6 +1541,7 @@ static int _composer_pre_parse_bundle(EmailComposerUGD *ugd, service_h data) } return COMPOSER_ERROR_NONE; + } else { if (operation == NULL) { /* ug called by ug_create */ debug_log("ug called by ug_create"); -- 2.7.4