#include "email-composer.h"
-#define COMPOSER_JS_ENABLE_EDITABLE "document.body.contentEditable='true'; void 0"
-#define COMPOSER_JS_DISABLE_EDITABLE "document.body.contentEditable='false'; void 0"
+#define COMPOSER_JS_BODY_ENABLE_EDITABLE "document.body.contentEditable='true'; void 0"
+#define COMPOSER_JS_BODY_DISABLE_EDITABLE "document.body.contentEditable='false'; void 0"
#define COMPOSER_JS_SET_FOCUS "document.body.focus(); void 0"
#define COMPOSER_JS_SET_UNFOCUS "document.body.blur(); void 0"
-#define COMPOSER_JS_GET_HTML_CONTENT \
- "function getHtmlContent() { " \
+#define COMPOSER_JS_GET_BODY_HTML_CONTENT \
+ "function getHtmlBodyContent() { " \
"console.log(\"Here\");" \
"var elements = document.getElementsByTagName(\"body\");" \
"console.log(\"elements[0].outerHTML : \" + elements[0].outerHTML);" \
"return elements[0].outerHTML;" \
"};" \
- "getHtmlContent();"
+ "getHtmlBodyContent();"
#define COMPOSER_JS_GET_LATEST_HTML_CONTENT \
"function getHtmlOriginalContent() { " \
char *latest_info_content;
char *latest_html_content;
char *plain_content;
- char *original_info_content;
- char *original_html_content;
+
+ char *latest_body_html_content;
+ char *original_body_html_content;
int to_recipients_cnt;
int cc_recipients_cnt;
static Eina_Bool _composer_cc_mbe_set_focus(void *data);
Eina_Bool _composer_get_html_content_for_draft_cb(void *data);
static void _composer_plain_text_get_cb(Evas_Object *o, const char *plain_text, void *user_data);
-static void _composer_get_latest_info_content_cb(Evas_Object *o, const char *result, void *data);
-static void _composer_get_latest_html_content_cb(Evas_Object *o, const char *result, void *data);
+static void _composer_get_latest_body_html_content_cb(Evas_Object *o, const char *result, void *data);
void _composer_edit_field_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
debug_log("");
EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+ if (EINA_FALSE == ewk_view_plain_text_get(ugd->body_ewkview, _composer_plain_text_get_cb, (void *)ugd)) {
+ debug_log("ewk_view_plain_text_get Failed");
+ }
- if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_INFO_CONTENT, _composer_get_latest_info_content_cb, (void *)ugd))
- debug_log("COMPOSER_JS_GET_LATEST_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.");
+ }
- if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_HTML_CONTENT, _composer_get_latest_html_content_cb, (void *)ugd))
- debug_log("COMPOSER_JS_GET_LATEST_HTML_CONTENT failed.");
+ if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_BODY_HTML_CONTENT, _composer_get_latest_body_html_content_cb, (void *)ugd))
+ debug_log("COMPOSER_JS_GET_BODY_HTML_CONTENT failed.");
ugd->bringin_timer = ecore_timer_add(1.0, _composer_get_html_content_for_draft_cb, ugd);
ugd->composer_noti = NULL;
}
+ _composer_webkit_set_body_script(data);
+
elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
_composer_webkit_set_body_script(ugd);
- if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_ENABLE_EDITABLE, _composer_focus_script_executed_cb, ugd) == EINA_FALSE)
+ if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_BODY_ENABLE_EDITABLE, _composer_focus_script_executed_cb, ugd) == EINA_FALSE)
debug_log("COMPOSER_JS_ENABLE_EDITABLE failed.");
return;
}
ugd->context_popup = NULL;
}
- if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_INFO_CONTENT, _composer_get_latest_info_content_cb, (void *)ugd))
- debug_log("COMPOSER_JS_GET_LATEST_INFO_CONTENT failed.");
-
- if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_HTML_CONTENT, _composer_get_latest_html_content_cb, (void *)ugd))
- debug_log("COMPOSER_JS_GET_LATEST_HTML_CONTENT failed.");
+ if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_BODY_HTML_CONTENT, _composer_get_latest_body_html_content_cb, (void *)ugd))
+ debug_log("COMPOSER_JS_GET_BODY_HTML_CONTENT failed.");
if (EINA_FALSE == ewk_view_plain_text_get(ugd->body_ewkview, _composer_plain_text_get_cb, (void *)ugd))
debug_log("ewk_view_plain_text_get 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.");
- if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_HTML_CONTENT, _composer_cbar_save_as_draft_cb, (void *)ugd))
- debug_log("COMPOSER_JS_GET_LATEST_HTML_CONTENT failed.");
+ if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_BODY_DISABLE_EDITABLE, _composer_cbar_save_as_draft_cb, (void*)ugd))
+ debug_log("COMPOSER_JS_BODY_DISABLE_EDITABLE failed.");
}
static void _composer_priority_radio_cb(void *data, Evas_Object *obj, void *event_info)
}
}
- if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_INFO_CONTENT, _composer_get_latest_info_content_cb, (void *)ugd))
- debug_log("COMPOSER_JS_GET_LATEST_INFO_CONTENT failed.");
+ if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_BODY_DISABLE_EDITABLE, NULL, NULL) == EINA_FALSE)
+ debug_log("COMPOSER_JS_BODY_ENABLE_EDITABLE failed.");
- if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_HTML_CONTENT, _composer_get_latest_html_content_cb, (void *)ugd))
- debug_log("COMPOSER_JS_GET_LATEST_HTML_CONTENT failed.");
+ if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_BODY_HTML_CONTENT, _composer_get_latest_body_html_content_cb, (void *)ugd))
+ debug_log("COMPOSER_JS_GET_BODY_HTML_CONTENT failed.");
if (EINA_FALSE == ewk_view_plain_text_get(ugd->body_ewkview, _composer_plain_text_get_cb, (void *)ugd))
debug_log("ewk_view_plain_text_get Failed");
return ECORE_CALLBACK_CANCEL;
}
-void _composer_get_latest_info_content_cb(Evas_Object *o, const char *result, void *data)
-{
- debug_log("");
- EmailComposerUGD *ugd = (EmailComposerUGD *)data;
- debug_log("result: \n%s", result);
-
- if (NULL != ugd->latest_info_content) {
- g_free(ugd->latest_info_content);
- ugd->latest_info_content = NULL;
- }
-
- if (result != NULL) {
- ugd->latest_info_content = g_strdup(result);
- debug_log("ugd->latest_info_content : \n%s", ugd->latest_info_content);
- }
-}
-
-static void _composer_get_latest_html_content_cb(Evas_Object *o, const char *result, void *data)
+static void _composer_get_latest_body_html_content_cb(Evas_Object *o, const char *result, void *data)
{
debug_log("");
EmailComposerUGD *ugd = (EmailComposerUGD *)data;
debug_log("result: \n%s", result);
- if (NULL != ugd->latest_html_content) {
- g_free(ugd->latest_html_content);
- ugd->latest_html_content = NULL;
+ if (NULL != ugd->latest_body_html_content) {
+ g_free(ugd->latest_body_html_content);
+ ugd->latest_body_html_content = NULL;
}
if (result != NULL) {
- ugd->latest_html_content = g_strdup(result);
- debug_log("ugd->latest_html_content : \n%s", ugd->latest_html_content);
+ ugd->latest_body_html_content = g_strdup(result);
+ debug_log("ugd->latest_body_html_content : \n%s", ugd->latest_body_html_content);
}
}
void _composer_webkit_loadFinished_cb(void *data, Evas_Object *obj, void *event_info);
+static void _composer_set_original_body_html_content_cb(Evas_Object *o, const char *result, void *data);
static void _composer_webkit_script_executed_cb(Evas_Object *o, const char *result, void *data);
static void _composer_webkit_focused_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _composer_webkit_unfocused_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _composer_set_original_html_content_cb(Evas_Object *o, const char *result, void *data);
-static void _composer_set_original_info_content_cb(Evas_Object *o, const char *result, void *data);
static void _composer_webkit_scroll_up_cb(void *data, Evas_Object *obj, void *event_info);
static void _composer_webkit_scroll_down_cb(void *data, Evas_Object *obj, void *event_info);
evas_object_size_hint_align_set(ugd->body_ewkview, EVAS_HINT_FILL, EVAS_HINT_FILL);
ewk_view_vertical_panning_hold_set(ugd->body_ewkview, EINA_TRUE);
+ if (NULL == ugd->body_ewkview)
+ debug_log("ugd->body_ewkview is NULL.");
+
elm_object_part_content_set(ly, "webkit.swallow", ugd->body_ewkview);
evas_object_smart_callback_add(ugd->body_ewkview, "edge,top", _composer_webview_reach_top_cb, ugd);
EmailComposerUGD *ugd = (EmailComposerUGD *)data;
- if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_HTML_CONTENT, _composer_set_original_html_content_cb, (void *)ugd) == EINA_FALSE)
- debug_log("COMPOSER_JS_GET_LATEST_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_LATEST_INFO_CONTENT failed.");
+ if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_BODY_HTML_CONTENT, _composer_set_original_body_html_content_cb, (void *)ugd) == EINA_FALSE)
+ debug_log("COMPOSER_JS_GET_BODY_HTML_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.");
}
+
+ if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_BODY_ENABLE_EDITABLE, _composer_focus_script_executed_cb, (void *)ugd) == EINA_FALSE)
+ debug_log("COMPOSER_JS_BODY_ENABLE_EDITABLE failed.");
}
void _composer_webkit_loadFinished_cb(void *data, Evas_Object *obj, void *event_info)
}
}
-static void _composer_set_original_html_content_cb(Evas_Object *o, const char *result, void *data)
-{
- debug_log("");
-
- EmailComposerUGD *ugd = (EmailComposerUGD *)data;
-
- if (result != NULL) {
- ugd->original_html_content = g_strdup(result);
- debug_log("ugd->original_html_content => \n%s", ugd->original_html_content);
- }
-
- if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_ENABLE_EDITABLE, _composer_focus_script_executed_cb, NULL) == EINA_FALSE)
- debug_log("COMPOSER_JS_ENABLE_EDITABLE failed.");
-}
-
-static void _composer_set_original_info_content_cb(Evas_Object *o, const char *result, void *data)
+static void _composer_set_original_body_html_content_cb(Evas_Object *o, const char *result, void *data)
{
debug_log("");
EmailComposerUGD *ugd = (EmailComposerUGD *)data;
if (result != NULL) {
- if (ugd->original_info_content) {
- g_free(ugd->original_info_content);
- ugd->original_info_content = NULL;
- }
- ugd->original_info_content = g_strdup(result);
- debug_log("ugd->original_info_content => \n%s", ugd->original_info_content);
+ ugd->original_body_html_content = g_strdup(result);
+ debug_log("ugd->original_body_html_content => \n%s", ugd->original_body_html_content);
}
}
ugd->new_mail_info->attachment_list, ugd->new_mail_info->mail_data->attachment_count);
- if (ugd->composer_type == RUN_COMPOSER_EDIT) {
- nResult = email_update_mail(ugd->new_mail_info->mail_data, ugd->new_mail_info->attachment_list, ugd->new_mail_info->mail_data->attachment_count, NULL, 0);
- } else {
- 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);
- }
+
+ 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);
debug_log("result of email_add_mail: %d", nResult);
if (nResult != EMAIL_ERROR_NONE) {
{
debug_log("");
- char *latest_info_content = _composer_make_text_with_div_tag(ugd->latest_info_content, 0);
- char *latest_html_content = _composer_make_text_with_div_tag(ugd->latest_html_content, 1);
-
- if (b_save_to_draft == EINA_TRUE) {
- *html_content = g_strconcat(HTML_TAG_START, BODY_TAG_START, latest_info_content, latest_html_content, BODY_TAG_END, HTML_TAG_END, NULL);
- } else {
- *html_content = g_strconcat(HTML_TAG_START, BODY_TAG_START, ugd->latest_info_content, ugd->latest_html_content, BODY_TAG_END, HTML_TAG_END, NULL);
- }
-
- if (latest_info_content) {
- g_free(latest_info_content);
- latest_info_content = NULL;
- }
- if (latest_html_content) {
- g_free(latest_html_content);
- latest_html_content = NULL;
- }
+ *html_content = g_strdup(ugd->latest_body_html_content);
}
int _composer_make_mail(EmailComposerUGD *ugd, Eina_Bool b_save_to_draft)
g_free(html_content_processed);
html_content_processed = NULL;
-
- plain_text_content = g_strdup(ugd->plain_content);
+ if (ugd->plain_content != NULL && strlen(ugd->plain_content) == 0) {
+ plain_text_content = g_strdup("\n");
+ } else {
+ plain_text_content = g_strdup(ugd->plain_content);
+ }
if (NULL == plain_text_content) {
debug_log("ugd->plain_content is NULL");
return COMPOSER_ERROR_MAKE_MAIL_FAIL;
}
+
if (EINA_FALSE == email_composer_save_file(SAVE_URI, plain_text_content, strlen(plain_text_content))) {
debug_log("Write to %s file failed", SAVE_URI);
g_free(plain_text_content);
debug_log("Succeed in saving in Drafts");
debug_log("Account id [%d] mailbox id [%d] mail id [%d]", ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID);
- if (ugd->save_drafts == 0) {
- if (ugd->popup_list) {
- debug_log("popup count = %d", eina_list_count(ugd->popup_list));
- debug_log("composer_noti: %p", ugd->composer_noti);
-
- ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
- }
+ if (ugd->popup_list) {
+ debug_log("popup count = %d", eina_list_count(ugd->popup_list));
+ debug_log("composer_noti: %p", ugd->composer_noti);
+
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
+ }
- evas_object_del(ugd->composer_noti);
- ugd->composer_noti = NULL;
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ if (ugd->save_drafts == 0) {
ugd->idler_save_draft = ecore_idler_add(_composer_show_success_to_save, ugd);
} else {
char str[128] = { 0, };
} else if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_NO")) == 0) {
ugd->idler_save_draft = ecore_idler_add(_composer_idler_destroy, ugd);
} else if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_CANCEL")) == 0) {
- if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_ENABLE_EDITABLE, _composer_focus_script_executed_cb, NULL) == EINA_FALSE)
- debug_log("COMPOSER_JS_ENABLE_EDITABLE failed.");
+ if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_BODY_ENABLE_EDITABLE, _composer_focus_script_executed_cb, NULL) == EINA_FALSE)
+ debug_log("COMPOSER_JS_BODY_ENABLE_EDITABLE failed.");
_composer_noti_response_cb(data, obj, event_info);
}
}
tmp_info_text = g_strdup("\n");
}
- *text_for_original_info = g_strconcat(DIV_TAG_START_ORIGIN_INFO, signature_text, tmp_info_text, DIV_TAG_END, NULL);
+ if (signature_text == NULL) {
+ *text_for_original_info = g_strconcat(DIV_TAG_START_ORIGIN_INFO, tmp_info_text, DIV_TAG_END, NULL);
+ } else {
+ *text_for_original_info = g_strconcat(DIV_TAG_START_ORIGIN_INFO, signature_text, tmp_info_text, DIV_TAG_END, NULL);
+ }
debug_log("text_for_original_info: \n%s", *text_for_original_info);
if (tmp_info_text) {
}
if (EINA_TRUE == ugd->has_body_html) {
- if (ugd->latest_info_content == NULL) {
- debug_log("ugd->latest_info_content is NULL");
+ if (ugd->latest_body_html_content == NULL) {
+ debug_log("ugd->latest_body_html_content is NULL");
is_modified = false;
goto FINISH_OFF;
}
- if (ugd->latest_html_content == NULL) {
- debug_log("ugd->latest_html_content is NULL");
- is_modified = false;
- goto FINISH_OFF;
- }
-
- if (ugd->latest_info_content && ugd->original_info_content) {
- debug_log("original_info_content:\n%s", ugd->original_info_content);
- debug_log("latest_info_content:\n%s", ugd->latest_info_content);
- if (g_strcmp0(ugd->original_info_content, ugd->latest_info_content) != 0) {
- debug_log("diff => %d", g_strcmp0(ugd->original_info_content, ugd->latest_info_content));
+ if (ugd->latest_body_html_content && ugd->original_body_html_content) {
+ debug_log("original_body_html_content:\n%s", ugd->original_body_html_content);
+ debug_log("latest_body_html_content:\n%s", ugd->latest_body_html_content);
+ if (g_strcmp0(ugd->original_body_html_content, ugd->latest_body_html_content) != 0) {
+ debug_log("diff => %d", g_strcmp0(ugd->original_body_html_content, ugd->latest_body_html_content));
is_modified = true;
goto FINISH_OFF;
}
is_modified = false; /*if latest_html_content and/or saved_html_content is NULL,
is_modified set to false; on return false, destroy composer is called*/
}
-
- if (ugd->latest_html_content && ugd->original_html_content) {
- debug_log("original_html_content:\n%s", ugd->original_html_content);
- debug_log("latest_html_content:\n%s", ugd->latest_html_content);
- if (g_strcmp0(ugd->original_html_content, ugd->latest_html_content) != 0) {
- is_modified = true;
- }
- } else {
- is_modified = false; /*if latest_html_content and/or saved_html_content is NULL,
- is_modified set to false; on return false, destroy composer is called*/
- }
}
FINISH_OFF:
g_free(ugd->saved_html_path);
ugd->saved_html_path = NULL;
}
- if (ugd->latest_info_content) {
- g_free(ugd->latest_info_content);
- ugd->latest_info_content = NULL;
- }
- if (ugd->latest_html_content) {
- g_free(ugd->latest_html_content);
- ugd->latest_html_content = NULL;
- }
if (ugd->plain_content) {
g_free(ugd->plain_content);
ugd->plain_content = NULL;
}
- if (ugd->original_info_content) {
- g_free(ugd->original_info_content);
- ugd->original_info_content = NULL;
+ if (ugd->latest_body_html_content) {
+ g_free(ugd->latest_body_html_content);
+ ugd->latest_body_html_content = NULL;
}
- if (ugd->original_html_content) {
- g_free(ugd->original_html_content);
- ugd->original_html_content = NULL;
+ if (ugd->original_body_html_content) {
+ g_free(ugd->original_body_html_content);
+ ugd->original_body_html_content = NULL;
}
}
ugd->body_ewkview = NULL;
ugd->has_body_html = EINA_FALSE;
ugd->saved_html_path = NULL;
- ugd->latest_info_content = NULL;
- ugd->latest_html_content = NULL;
ugd->plain_content = NULL;
- ugd->original_info_content = NULL;
- ugd->original_html_content = NULL;
+
+ ugd->latest_body_html_content = NULL;
+ ugd->original_body_html_content = NULL;
+
ugd->to_recipients_cnt = 0;
ugd->cc_recipients_cnt = 0;
ugd->bcc_recipients_cnt = 0;
g_free(ugd->saved_html_path);
ugd->saved_html_path = NULL;
}
- if (ugd->latest_info_content) {
- g_free(ugd->latest_info_content);
- ugd->latest_info_content = NULL;
- }
- if (ugd->latest_html_content) {
- g_free(ugd->latest_html_content);
- ugd->latest_html_content = NULL;
- }
if (ugd->plain_content) {
g_free(ugd->plain_content);
ugd->plain_content = NULL;
}
- if (ugd->original_info_content) {
- g_free(ugd->original_info_content);
- ugd->original_info_content = NULL;
+ if (ugd->latest_body_html_content) {
+ g_free(ugd->latest_body_html_content);
+ ugd->latest_body_html_content = NULL;
}
- if (ugd->original_html_content) {
- g_free(ugd->original_html_content);
- ugd->original_html_content = NULL;
+ if (ugd->original_body_html_content) {
+ g_free(ugd->original_body_html_content);
+ ugd->original_body_html_content = NULL;
}
}