summaryrefslogtreecommitdiff
path: root/composer/src/email-composer-callback.c
diff options
context:
space:
mode:
Diffstat (limited to 'composer/src/email-composer-callback.c')
-rwxr-xr-xcomposer/src/email-composer-callback.c2112
1 files changed, 2112 insertions, 0 deletions
diff --git a/composer/src/email-composer-callback.c b/composer/src/email-composer-callback.c
new file mode 100755
index 0000000..cb54ec5
--- /dev/null
+++ b/composer/src/email-composer-callback.c
@@ -0,0 +1,2112 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+
+#include "email-composer.h"
+#include "email-composer-util.h"
+#include "email-composer-recipient.h"
+#include "email-composer-attachment.h"
+#include "email-composer-callback.h"
+#include "email-composer-predictive-search.h"
+#include "email-composer-js.h"
+
+static EmailComposerUGD *g_ugd = NULL;
+
+bool edit_mode = false;
+bool edit_mode_bs = false;
+
+int email_cnt = 0;
+
+EmailList email_list[MAX_RECIPIENT_COUNT];
+
+static Elm_Genlist_Item_Class itc;
+static Elm_Genlist_Item_Class from_itc;
+
+static void _composer_mbe_popup_change_addr_selected_cb(void *data, Evas_Object *obj, void *event_info);
+static void _composer_from_change_response_cb(void *data, Evas_Object *obj, void *event_info);
+static void _composer_from_radio_cb(void *data, Evas_Object *obj, void *event_info);
+static void _composer_from_gl_sel(void *data, Evas_Object *obj, void *event_info);
+
+static Eina_Bool _composer_cc_mbe_set_focus(void *data);
+#ifndef _CC_BCC
+static Eina_Bool _composer_bcc_mbe_set_focus(void *data);
+#endif
+static void *_composer_contact_search_by_email(EmailComposerUGD *ugd, const char *search_word);
+static void _composer_delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item);
+static void _composer_get_html_content_for_draft_cb(Evas_Object *o, const char *result, void *data);
+static void _composer_send_clicked_cb(Evas_Object *o, const char *result, void *data);
+static void _composer_plain_text_get_cb(Evas_Object *o, const char *plain_text, void *user_data);
+
+
+void _composer_edit_field_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ if (data == NULL || obj == NULL) {
+ return;
+ }
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (obj == ugd->subject_entry) {
+ _composer_check_entry_max(ugd, ugd->subject_entry, MAX_SUBJECT_LEN);
+
+ if (_composer_check_recipient_is_empty(ugd)) {
+ if (!ugd->bSendBtnDisabled) {
+ elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
+ ugd->bSendBtnDisabled = true;
+ }
+ } else {
+ if (ugd->bSendBtnDisabled) {
+ elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
+ ugd->bSendBtnDisabled = false;
+ }
+ }
+ } else if (obj == ugd->body_ewkview) {
+ if (_composer_check_recipient_is_empty(ugd)) {
+ if (!ugd->bSendBtnDisabled) {
+ elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
+ ugd->bSendBtnDisabled = true;
+ }
+ } else {
+ if (ugd->bSendBtnDisabled) {
+ elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
+ ugd->bSendBtnDisabled = false;
+ }
+ }
+ }
+}
+
+void _composer_more_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("Enter");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ debug_log("More Button Clicked");
+
+ if (ugd->option_header_opened)
+ elm_object_item_signal_emit(ugd->navi_item, "elm,state,optionheader,close", "");
+ else
+ elm_object_item_signal_emit(ugd->navi_item, "elm,state,optionheader,open", "");
+
+ ugd->option_header_opened = !ugd->option_header_opened;
+
+ _composer_mbe_set_focus(ugd);
+}
+
+void _composer_back_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ elm_object_disabled_set(ugd->cancel_btn, EINA_TRUE); // It prevents clicking the cancel button several times
+
+ if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_HTML_CONTENT, _composer_get_html_content_for_draft_cb, (void *)ugd) == EINA_FALSE)
+ debug_log("COMPOSER_JS_GET_HTML_CONTENT failed.");
+
+ debug_log("Cancel Button Clicked: %p", ugd->cancel_btn);
+}
+
+void _composer_mbe_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ if (data == NULL || obj == NULL) {
+ return;
+ }
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (ugd->clipboard_on) {
+ debug_log("MBE Lost Focus");
+ _composer_mbe_set_focus(ugd);
+ }
+
+ if (obj == ugd->to_mbe_entry) {
+ debug_log("TO");
+ _composer_check_email_address(ugd, ugd->to_mbe_entry);
+ } else if (obj == ugd->cc_mbe_entry) {
+ debug_log("CC");
+ _composer_check_email_address(ugd, ugd->cc_mbe_entry);
+ } else if (obj == ugd->bcc_mbe_entry) {
+ debug_log("BCC");
+ _composer_check_email_address(ugd, ugd->bcc_mbe_entry);
+ }
+}
+
+void _composer_mbe_longpressed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ ugd->clipboard_on = true;
+}
+
+void _composer_mbe_added_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+
+ EmailRecpInfo *ri = NULL;
+
+ bool is_contact_info = false;
+ bool is_always_bcc = false;
+ bool is_from_addr = false;
+
+ char *addr = elm_entry_markup_to_utf8((char *)elm_object_item_text_get(item));
+ debug_log("utf8 address : %s", addr);
+
+ if (addr == NULL) {
+ debug_log("Added - Address is NULL");
+
+ return;
+ }
+
+ char temp_addr[MAX_RECIPIENT_ADDRESSES_LEN + 1] = { 0, };
+
+ ri = (EmailRecpInfo *) elm_object_item_data_get(item);
+
+ if (ri) {
+ is_contact_info = ri->is_contact_info;
+ is_always_bcc = ri->is_always_bcc;
+ is_from_addr = ri->is_from_addr;
+
+ strncpy(temp_addr, ri->email_list[ri->selected_email_idx].email_addr, MAX_RECIPIENT_ADDRESSES_LEN - 1);
+ temp_addr[MAX_RECIPIENT_ADDRESSES_LEN] = '\0';
+
+ debug_log("is_contact_info = %d", is_contact_info);
+ debug_log("is_always_bcc = %d", is_always_bcc);
+ debug_log("is_from_addr = %d", is_from_addr);
+ } else {
+ strncpy(temp_addr, addr, MAX_RECIPIENT_ADDRESSES_LEN - 1);
+ temp_addr[MAX_RECIPIENT_ADDRESSES_LEN] = '\0';
+ }
+
+ free(addr);
+
+ debug_log("email_addr = %s", temp_addr);
+
+ if (!is_contact_info && !is_always_bcc && !is_from_addr) {
+ if (ugd->to_recipients_cnt > MAX_RECIPIENT_COUNT) {
+ char msg[MAX_STR_LEN] = { 0, };
+ snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
+
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
+ msg, 0, NULL, NULL, 1.0, _composer_noti_response_cb);
+
+ elm_object_item_del(item);
+
+ return;
+ } else if (!_composer_is_valid_email(temp_addr)) {
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
+ _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 0, NULL, NULL, 1.5, _composer_noti_response_cb);
+
+ elm_object_item_del(item);
+
+ return;
+ }
+
+ EmailRecpInfo *new_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
+ snprintf(new_ri->email_list[0].email_addr, sizeof(new_ri->email_list[0].email_addr), "%s", temp_addr);
+ debug_log("email_addr = %s", new_ri->email_list[0].email_addr);
+ new_ri->selected_email_idx = 0;
+ new_ri->display_name = NULL;
+ new_ri->email_cnt = 1;
+ new_ri->is_contact_info = false;
+ new_ri->is_from_addr = false;
+ new_ri->is_always_bcc = false;
+
+ elm_object_item_data_set(item, new_ri);
+ }
+
+ if (obj == ugd->to_mbe) {
+ ugd->to_recipients_cnt++;
+ } else if (obj == ugd->cc_mbe) {
+ ugd->cc_recipients_cnt++;
+ } else if (obj == ugd->bcc_mbe) {
+ ugd->bcc_recipients_cnt++;
+ }
+
+ if ((obj == ugd->to_mbe) || (obj == ugd->cc_mbe) || (obj == ugd->bcc_mbe)) {
+ if (ugd->bSendBtnDisabled && !_composer_check_recipient_is_empty(ugd)) {
+ elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
+ ugd->bSendBtnDisabled = false;
+ }
+ }
+}
+
+void _composer_mbe_deleted_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (obj == ugd->to_mbe) {
+ debug_log("to_mbe");
+
+ if (ugd->to_recipients_cnt > 0)
+ ugd->to_recipients_cnt--;
+ } else if (obj == ugd->cc_mbe) {
+ debug_log("cc_mbe");
+
+ if (ugd->cc_recipients_cnt > 0)
+ ugd->cc_recipients_cnt--;
+ } else if (obj == ugd->bcc_mbe) {
+ debug_log("bcc_mbe");
+
+ if (ugd->bcc_recipients_cnt > 0)
+ ugd->bcc_recipients_cnt--;
+ }
+
+ if ((obj == ugd->to_mbe) || (obj == ugd->cc_mbe) || (obj == ugd->bcc_mbe)) {
+ if (!ugd->bSendBtnDisabled && _composer_check_recipient_is_empty(ugd)) {
+ elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
+ ugd->bSendBtnDisabled = true;
+ }
+ }
+}
+
+Eina_Bool _composer_unfocus_selected_mbe(void *data)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ debug_log("selected_entry = %x, to_mbe_entry = %x, cc_mbe_entry = %x, bcc_mbe_entry = %x",
+ ugd->selected_entry, ugd->to_mbe_entry, ugd->cc_mbe_entry, ugd->bcc_mbe_entry);
+
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ debug_log("to_mbe");
+ elm_object_focus_set(ugd->to_mbe, EINA_FALSE);
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ debug_log("cc_mbe");
+ elm_object_focus_set(ugd->cc_mbe, EINA_FALSE);
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ debug_log("bcc_mbe");
+ elm_object_focus_set(ugd->bcc_mbe, EINA_FALSE);
+ }
+
+ if (ugd->mbe_unfocus_timer) {
+ ecore_timer_del(ugd->mbe_unfocus_timer);
+ ugd->mbe_unfocus_timer = NULL;
+ }
+
+ return EINA_FALSE;
+}
+
+void _composer_mbe_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ int index = 0;
+ EmailRecpInfo *ri = NULL;
+
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+
+ ri = (EmailRecpInfo *) elm_object_item_data_get(item);
+
+ debug_log("is_contact_info = %d", ri->is_contact_info);
+ debug_log("is_always_bcc = %d", ri->is_always_bcc);
+ debug_log("is_from_addr = %d", ri->is_from_addr);
+
+/* if (obj == ugd->cc_mbe && elm_object_item_text_get(elm_multibuttonentry_first_item_get(ugd->bcc_mbe)) == NULL && (ri->is_always_bcc == true || ri->is_from_addr == true)) {
+ debug_log("");
+
+ ugd->bringin_timer = ecore_timer_add(0.5f, _composer_bringin_cb, ugd);
+
+ } else */if (obj == ugd->from_mbe) {
+ debug_log("from selected");
+
+ _composer_from_show_popup(ugd);
+ } else {
+ debug_log("");
+
+ Ecore_IMF_Context *imf_context = NULL;
+
+ imf_context = elm_entry_imf_context_get(ugd->selected_entry);
+
+ if (imf_context)
+ ecore_imf_context_input_panel_hide(imf_context);
+
+ ugd->is_mbe_selected = true;
+
+ index = ri->selected_email_idx;
+
+ Evas_Object *pu_list;
+
+ if (ugd->composer_popup) {
+ evas_object_del(ugd->composer_popup);
+ ugd->composer_popup = NULL;
+ }
+
+ debug_log("display_name:%s, index:%d", ri->display_name, index);
+ if (ri->display_name) {
+ char *email_str = g_strconcat(ri->display_name, " <", ri->email_list[index].email_addr, ">", NULL);
+ char *contact_str = elm_entry_utf8_to_markup(email_str);
+ debug_log("email_str:%s", email_str);
+ debug_log("contact_str:%s", contact_str);
+ ugd->composer_popup = _composer_create_noti(ugd, false, contact_str, NULL, 1,
+ dgettext("sys_string", "IDS_COM_POP_CLOSE"), NULL, 0.0, _composer_popup_response_cb);
+ g_free(contact_str);
+ } else {
+ ugd->composer_popup = _composer_create_noti(ugd, false, ri->email_list[index].email_addr, NULL, 1,
+ dgettext("sys_string", "IDS_COM_POP_CLOSE"), NULL, 0.0, _composer_popup_response_cb);
+ }
+
+#ifdef _POPUP_WITH_LIST
+ elm_object_style_set(ugd->composer_popup, "min_menustyle");
+#else
+ elm_object_style_set(ugd->composer_popup, "menustyle");
+#endif
+ elm_object_focus_allow_set(ugd->composer_popup, EINA_TRUE);
+
+ pu_list = elm_list_add(ugd->composer_popup);
+
+ int item_count = 5;
+
+ elm_list_item_append(pu_list, dgettext("sys_string", "IDS_COM_SK_DELETE"), NULL, NULL, _composer_mbe_popup_delete_cb, ugd);
+ elm_list_item_append(pu_list, dgettext("sys_string", "IDS_COM_SK_EDIT"), NULL, NULL, _composer_mbe_popup_edit_cb, ugd);
+
+ if (obj != ugd->to_mbe)
+ elm_list_item_append(pu_list, N_("Move to To"), NULL, NULL, _composer_mbe_popup_move_to_to_cb, ugd);
+ if (obj != ugd->cc_mbe)
+ elm_list_item_append(pu_list, _("IDS_EMAIL_OPT_MOVE_TO_CC"), NULL, NULL, _composer_mbe_popup_move_to_cc_cb, ugd);
+ if (obj != ugd->bcc_mbe)
+ elm_list_item_append(pu_list, _("IDS_EMAIL_OPT_MOVE_TO_BCC"), NULL, NULL, _composer_mbe_popup_move_to_bcc_cb, ugd);
+
+ debug_log("email_cnt = %d", ri->email_cnt);
+ if (ri->is_contact_info == true) {
+ if (ri->email_cnt > 1) {
+ elm_list_item_append(pu_list, _("IDS_EMAIL_OPT_CHANGE_EMAIL_ADDRESS_ABB"), NULL, NULL, _composer_mbe_popup_change_addr_cb, ugd);
+ }
+ }
+
+ elm_list_go(pu_list);
+
+#ifdef _POPUP_WITH_LIST
+ elm_list_mode_set(pu_list, ELM_LIST_EXPAND);
+ evas_object_size_hint_max_set(pu_list, -1, 113 * item_count * elm_scale_get());
+#endif
+ elm_object_content_set(ugd->composer_popup, pu_list);
+
+ ugd->mbe_unfocus_timer = ecore_timer_add(0.1, _composer_unfocus_selected_mbe, ugd);
+ debug_log("composer_popup = %x, is_mbe_selected = %d", ugd->composer_popup, ugd->is_mbe_selected);
+ }
+}
+
+void _composer_mbe_focused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ debug_log("focus_status: %d", ugd->focus_status);
+
+ if (COMPOSER_FOCUS_STATUS_NONE == ugd->focus_status) {
+ if (obj == ugd->to_mbe) {
+ edje_object_signal_emit(_EDJ(ugd->to_ly), "show.button", "*");
+ edje_object_signal_emit(_EDJ(ugd->to_ly), "contract.recp", "*");
+ }
+ else if (obj == ugd->cc_mbe) {
+ edje_object_signal_emit(_EDJ(ugd->cc_ly), "show.button", "*");
+ edje_object_signal_emit(_EDJ(ugd->cc_ly), "contract.recp", "*");
+ }
+ else if (obj == ugd->bcc_mbe) {
+ edje_object_signal_emit(_EDJ(ugd->bcc_ly), "show.button", "*");
+ edje_object_signal_emit(_EDJ(ugd->bcc_ly), "contract.recp", "*");
+ }
+
+ _composer_attachment_contract_items(ugd);
+ elm_multibuttonentry_expanded_set(obj, TRUE);
+
+ ugd->selected_entry = elm_multibuttonentry_entry_get(obj);
+// ugd->bringin_timer = ecore_timer_add(0.5f, _composer_bringin_cb, ugd);
+ debug_log("MBE edtable:%d", elm_multibuttonentry_editable_get(obj));
+ } else {
+ if (ugd->selected_entry == ugd->body_ewkview) {
+ if (EINA_TRUE == elm_object_focus_get(ugd->to_mbe))
+ elm_object_focus_set(ugd->to_mbe, EINA_FALSE);
+ else if (EINA_TRUE == elm_object_focus_get(ugd->cc_mbe))
+ elm_object_focus_set(ugd->cc_mbe, EINA_FALSE);
+ else if (EINA_TRUE == elm_object_focus_get(ugd->bcc_mbe))
+ elm_object_focus_set(ugd->bcc_mbe, EINA_FALSE);
+
+ evas_object_focus_set(ugd->body_ewkview, EINA_TRUE);
+ }
+ }
+}
+
+void _composer_mbe_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("Enter");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ debug_log("composer_popup = %x, is_mbe_selected = %d", ugd->composer_popup, ugd->is_mbe_selected);
+ if (ugd->ps_list) {
+ _composer_ps_stop(ugd);
+ ugd->sc_timer = ecore_timer_add(0.5, _composer_ps_scroll_pop, ugd);
+ if (ugd->is_mbe_selected)
+ return;
+ }
+
+ debug_log("obj = %x, to_mbe = %x, cc_mbe = %x, bcc_mbe = %x", obj, ugd->to_mbe, ugd->cc_mbe, ugd->bcc_mbe);
+ if (obj == ugd->to_mbe) {
+ edje_object_signal_emit(_EDJ(ugd->to_ly), "hide.button", "*");
+ edje_object_signal_emit(_EDJ(ugd->to_ly), "extract.recp", "*");
+ }
+ else if (obj == ugd->cc_mbe) {
+ edje_object_signal_emit(_EDJ(ugd->cc_ly), "hide.button", "*");
+ edje_object_signal_emit(_EDJ(ugd->cc_ly), "extract.recp", "*");
+ }
+ else if (obj == ugd->bcc_mbe) {
+ edje_object_signal_emit(_EDJ(ugd->bcc_ly), "hide.button", "*");
+ edje_object_signal_emit(_EDJ(ugd->bcc_ly), "extract.recp", "*");
+ }
+
+ elm_multibuttonentry_expanded_set(obj, FALSE);
+}
+
+Eina_Bool _composer_mbe_verified_item_cb(Evas_Object *obj, const char *item_label, void *item_data, void *data)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (!item_label) {
+ debug_log("Item_label is NULL");
+ return EINA_FALSE;
+ }
+
+ if (item_data) {
+ debug_log("Normally Added");
+
+ return EINA_TRUE;
+ }
+
+ debug_log("item_label = %s", item_label);
+
+ if (_composer_is_valid_email(item_label)) {
+ EmailRecpInfo *ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
+ ri->selected_email_idx = 0;
+ snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", item_label);
+ ri->display_name = NULL;
+ ri->email_cnt = 1;
+ ri->is_contact_info = false;
+ ri->is_always_bcc = false;
+ ri->is_from_addr = false;
+
+ if (_composer_check_recipient_is_duplicated(ugd, obj, ri)) {
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"),
+ 0, NULL, NULL, 1.5, _composer_noti_response_cb);
+
+ free(ri);
+ goto err_return;
+ }
+
+ char msg[MAX_STR_LEN] = { 0, };
+ snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
+
+ if (obj == ugd->to_mbe) {
+ if (ugd->to_recipients_cnt >= MAX_RECIPIENT_COUNT) {
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), msg,
+ 0, NULL, NULL, 1.0, _composer_noti_response_cb);
+
+ free(ri);
+ goto err_return;
+ }
+ } else if (obj == ugd->cc_mbe) {
+ if (ugd->cc_recipients_cnt >= MAX_RECIPIENT_COUNT) {
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), msg,
+ 0, NULL, NULL, 1.0, _composer_noti_response_cb);
+
+ free(ri);
+ goto err_return;
+ }
+ } else if (obj == ugd->bcc_mbe) {
+ if (ugd->bcc_recipients_cnt >= MAX_RECIPIENT_COUNT) {
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), msg,
+ 0, NULL, NULL, 1.0, _composer_noti_response_cb);
+
+ free(ri);
+ goto err_return;
+ }
+ }
+ } else {
+ debug_log("Invalid Address");
+
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
+ 0, NULL, NULL, 1.0, _composer_noti_response_cb);
+
+ goto err_return;
+ }
+
+ return EINA_TRUE;
+
+err_return:
+ debug_log("err-return");
+
+ elm_entry_entry_set(elm_multibuttonentry_entry_get(obj), NULL);
+ elm_entry_cursor_end_set(elm_multibuttonentry_entry_get(obj));
+
+ if (_composer_check_popup_exist(ugd))
+ elm_object_focus_set(obj, EINA_FALSE);
+
+ return EINA_FALSE;
+}
+
+void _composer_mbe_popup_delete_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ Evas_Object *mbe = NULL;
+
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ debug_log("@@@ to MBE @@@");
+ mbe = ugd->to_mbe;
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ debug_log("@@@ cc MBE @@@");
+ mbe = ugd->cc_mbe;
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ debug_log("@@@ bcc MBE @@@");
+ mbe = ugd->bcc_mbe;
+ }
+
+ Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
+
+ if (item && mbe == ugd->bcc_mbe) {
+ EmailRecpInfo *bcc_ri_info;
+
+ bcc_ri_info = (EmailRecpInfo *) elm_object_item_data_get(item);
+ }
+
+ elm_object_item_del(item);
+
+ if (ugd->popup_list)
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ if (ugd->composer_popup) {
+ evas_object_del(ugd->composer_popup);
+ ugd->composer_popup = NULL;
+ }
+ ugd->is_mbe_selected = false;
+}
+
+void _composer_mbe_popup_edit_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("In");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ EmailRecpInfo *ri = NULL;
+
+ Evas_Object *mbe = NULL;
+
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ mbe = ugd->to_mbe;
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ mbe = ugd->cc_mbe;
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ mbe = ugd->bcc_mbe;
+ }
+
+ Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
+ debug_log("item:%p", item);
+
+ int index = 0;
+
+ ri = (EmailRecpInfo *) elm_object_item_data_get(item);
+
+ if (ri)
+ index = ri->selected_email_idx;
+ else {
+ debug_log("ri is NULL");
+ return;
+ }
+
+ elm_object_item_del(item);
+
+ debug_log("email_addr = %s", ri->email_list[index].email_addr);
+ elm_entry_entry_set(ugd->selected_entry, ri->email_list[index].email_addr);
+ elm_entry_cursor_end_set(ugd->selected_entry);
+
+ edit_mode = true;
+ edit_mode_bs = true;
+
+ if (ugd->popup_list)
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ if (ugd->composer_popup) {
+ evas_object_del(ugd->composer_popup);
+ ugd->composer_popup = NULL;
+ }
+ ugd->is_mbe_selected = false;
+
+ debug_log("Out");
+}
+
+void _composer_mbe_popup_move_to_to_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+ Evas_Object *mbe = NULL;
+ EmailRecpInfo *ri = NULL;
+
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ mbe = ugd->to_mbe;
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ mbe = ugd->cc_mbe;
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ mbe = ugd->bcc_mbe;
+ }
+
+ Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
+ if (item)
+ {
+ ri = (EmailRecpInfo *) elm_object_item_data_get(item);
+ if (ri) {
+ elm_object_item_del(item);
+ elm_multibuttonentry_item_append(ugd->to_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri);
+ }
+ else {
+ debug_log("ri is NULL");
+ }
+ }
+
+ //ugd->selected_entry = ugd->to_mbe_entry;
+ elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
+
+ if (ugd->popup_list)
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
+
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+
+ if (ugd->composer_popup) {
+ evas_object_del(ugd->composer_popup);
+ ugd->composer_popup = NULL;
+ }
+ ugd->is_mbe_selected = false;
+}
+
+void _composer_mbe_popup_move_to_cc_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+ Evas_Object *mbe = NULL;
+ EmailRecpInfo *ri = NULL;
+
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ mbe = ugd->to_mbe;
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ mbe = ugd->cc_mbe;
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ mbe = ugd->bcc_mbe;
+ }
+
+ if (!ugd->cc_added) {
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
+ email_composer_create_cc_field(ugd);
+
+#ifdef _CC_BCC
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
+ email_composer_create_bcc_field(ugd);
+
+ elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
+#endif
+
+ ugd->b_cc_bcc = false;
+ }
+
+ Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
+ if (item)
+ {
+ ri = (EmailRecpInfo *) elm_object_item_data_get(item);
+ if (ri) {
+ elm_object_item_del(item);
+ elm_multibuttonentry_item_append(ugd->cc_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri);
+ }
+ else {
+ debug_log("ri is NULL");
+ }
+ }
+
+ //ugd->selected_entry = ugd->cc_mbe_entry;
+ elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
+
+ if (ugd->popup_list)
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
+
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+
+ if (ugd->composer_popup) {
+ evas_object_del(ugd->composer_popup);
+ ugd->composer_popup = NULL;
+ }
+ ugd->is_mbe_selected = false;
+}
+
+void _composer_mbe_popup_move_to_bcc_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+ Evas_Object *mbe = NULL;
+ EmailRecpInfo *ri = NULL;
+
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ mbe = ugd->to_mbe;
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ mbe = ugd->cc_mbe;
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ mbe = ugd->bcc_mbe;
+ }
+
+ if (!ugd->bcc_added) {
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
+ email_composer_create_bcc_field(ugd);
+
+#ifdef _CC_BCC
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
+ email_composer_create_cc_field(ugd);
+
+ elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
+#endif
+
+ ugd->b_cc_bcc = false;
+ }
+
+ Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
+ if (item)
+ {
+ ri = (EmailRecpInfo *) elm_object_item_data_get(item);
+ if (ri) {
+ elm_object_item_del(item);
+ elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri);
+ }
+ else {
+ debug_log("ri is NULL");
+ }
+ }
+
+ //ugd->selected_entry = ugd->bcc_mbe_entry;
+ elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
+
+ if (ugd->popup_list)
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
+
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+
+ if (ugd->composer_popup) {
+ evas_object_del(ugd->composer_popup);
+ ugd->composer_popup = NULL;
+ }
+ ugd->is_mbe_selected = false;
+}
+
+void _composer_mbe_popup_change_addr_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ EmailRecpInfo *ri = NULL;
+
+ Evas_Object *mbe = NULL;
+
+ int i;
+
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ mbe = ugd->to_mbe;
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ mbe = ugd->cc_mbe;
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ mbe = ugd->bcc_mbe;
+ }
+
+ Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
+ ugd->selected_item = item;
+ debug_log("@@@ Elm_Object_Item = %p @@@", item);
+ ri = (EmailRecpInfo *) elm_object_item_data_get(item);
+
+ for (i = 0; i < ri->email_cnt; i++) {
+ snprintf(email_list[i].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ri->email_list[i].email_addr);
+ email_list[i].email_type = ri->email_list[i].email_type;
+ }
+
+ email_cnt = ri->email_cnt;
+
+ _composer_mbe_create_change_addr_list(ugd);
+
+ if (ugd->popup_list)
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
+
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+
+ if (ugd->composer_popup) {
+ evas_object_del(ugd->composer_popup);
+ ugd->composer_popup = NULL;
+ }
+ ugd->is_mbe_selected = false;
+}
+
+static void _composer_mbe_popup_change_addr_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ if (data == NULL)
+ return;
+
+ if (obj == NULL)
+ return;
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ int selected_idx = 0;
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+
+ if (item != NULL) {
+ selected_idx = (int)elm_object_item_data_get(item);
+ debug_log("selected_idx = %d", selected_idx);
+ debug_log("email_addr:%s", email_list[selected_idx].email_addr);
+
+ EmailRecpInfo *ri = NULL;
+ Evas_Object *mbe = NULL;
+
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ mbe = ugd->to_mbe;
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ mbe = ugd->cc_mbe;
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ mbe = ugd->bcc_mbe;
+ }
+
+ Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
+ ugd->selected_item = item;
+ debug_log("@@@ Elm_Object_Item = %p @@@", item);
+ ri = (EmailRecpInfo *) elm_object_item_data_get(item);
+
+ ri->selected_email_idx = selected_idx;
+ }
+
+ if (ugd->popup_list)
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->change_addr_noti);
+
+ if (ugd->change_addr_noti) {
+ debug_log("");
+ evas_object_del(ugd->change_addr_noti);
+ ugd->change_addr_noti = NULL;
+ }
+}
+
+char *_composer_change_addr_gl_text_get(void *data, Evas_Object *obj, const char *part)
+{
+ int index = (int)data;
+ const char *email_str = NULL;
+
+ debug_log("label index = %d", index);
+
+ if (!g_strcmp0(part, "elm.text")) {
+ if (email_list[index].email_type == 0)
+ email_str = g_strconcat(_("IDS_EMAIL_OPT_OTHER"), ": ", email_list[index].email_addr, NULL);
+ else if (email_list[index].email_type == 1)
+ email_str = g_strconcat(dgettext("sys_string", "IDS_COM_BODY_HOME"), ": ", email_list[index].email_addr, NULL);
+ else if (email_list[index].email_type == 2)
+ email_str = g_strconcat(dgettext("sys_string", "IDS_COM_BODY_WORK"), ": ", email_list[index].email_addr, NULL);
+ else if (email_list[index].email_type == 3)
+ email_str = g_strconcat(_("IDS_EMAIL_OPT_OTHER"), ": ", email_list[index].email_addr, NULL);
+
+ debug_log("email_type(%d), email_str(%s)", email_list[index].email_type, email_str);
+ return g_strdup(email_str);
+ }
+
+ return NULL;
+}
+
+void _composer_mbe_change_addr_response_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ EmailRecpInfo *ri = NULL;
+
+ Evas_Object *mbe = NULL;
+
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ mbe = ugd->to_mbe;
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ mbe = ugd->cc_mbe;
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ mbe = ugd->bcc_mbe;
+ }
+
+ ri = (EmailRecpInfo *) elm_object_item_data_get(ugd->selected_item);
+
+ char *pszBtnText = (char *)elm_object_text_get(obj);
+ debug_log("selected button text = %s", pszBtnText);
+
+ if (ugd->popup_list) {
+ debug_log("popup count = %d", eina_list_count(ugd->popup_list));
+ debug_log("obj: %p", obj);
+ debug_log("change_addr_noti: %p", ugd->change_addr_noti);
+
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->change_addr_noti/*obj*/);
+ }
+
+ if (ugd->change_addr_noti) {
+ evas_object_del(ugd->change_addr_noti);
+ ugd->change_addr_noti = NULL;
+ }
+}
+
+Eina_Bool _composer_send_mail_cb(void *data)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (ugd->send_timer) {
+ debug_log("delete send_timer");
+ ecore_timer_del(ugd->send_timer);
+ ugd->send_timer = NULL;
+ }
+
+ ugd->send_result = _composer_send_mail(ugd);
+
+ if (ugd->selected_entry == ugd->body_ewkview) {
+ evas_object_focus_set(ugd->body_ewkview, EINA_FALSE);
+ } else {
+ Ecore_IMF_Context *imf_context = NULL;
+ imf_context = elm_entry_imf_context_get(ugd->selected_entry);
+ if (imf_context)
+ ecore_imf_context_input_panel_hide(imf_context);
+ }
+
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+
+ ugd->composer_noti = elm_popup_add(ugd->main_layout);
+ debug_log("composer_noti: %p", ugd->composer_noti);
+ if (!ugd->composer_noti) {
+ debug_log("elm_popup_add returns NULL");
+ return EINA_FALSE;
+ }
+
+ evas_object_size_hint_weight_set(ugd->composer_noti, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ if (ugd->send_result == COMPOSER_ERROR_NONE) {
+ char temp_text[128];
+ snprintf(temp_text, sizeof(temp_text), "%s", dgettext("sys_string", "IDS_COM_POP_SENDING"));
+ elm_object_part_text_set(ugd->composer_noti, "title,text", temp_text);
+
+ Evas_Object *progressbar = elm_progressbar_add(ugd->composer_noti);
+ elm_object_style_set(progressbar, "list_process");//"pending_list"//"list_progress"
+ elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
+ evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(progressbar);
+ elm_progressbar_pulse(progressbar, EINA_TRUE);
+ elm_object_content_set(ugd->composer_noti, progressbar);
+
+ if (elm_multibuttonentry_first_item_get(ugd->to_mbe))
+ elm_multibuttonentry_clear(ugd->to_mbe);
+ if (elm_multibuttonentry_first_item_get(ugd->cc_mbe))
+ elm_multibuttonentry_clear(ugd->cc_mbe);
+ if (elm_multibuttonentry_first_item_get(ugd->bcc_mbe))
+ elm_multibuttonentry_clear(ugd->bcc_mbe);
+
+ /*
+ After sending, not to focus mbe.
+ */
+ if (!ugd->b_sending)
+ ugd->b_sending = true;
+
+ evas_object_show(ugd->composer_noti);
+ ugd->send_timer = ecore_timer_add(2.0, _composer_send_popup_finish_cb, ugd);
+ } else if (ugd->send_result == COMPOSER_ERROR_SEND_FAIL) {
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
+ _("IDS_EMAIL_POP_UNABLE_TO_SEND_EMAIL"), 0, NULL, NULL, 1.5, _composer_fail_to_send_popup_cb);
+ }
+
+ return EINA_TRUE;
+}
+
+Eina_Bool _composer_region_show_cb(void *data)
+{
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ Evas_Coord sc_width = 0, sc_height = 0;
+ elm_scroller_region_get(ugd->main_scroller, 0, 0, &sc_width, &sc_height);
+
+ Evas_Coord from_height = 0;
+ if (ugd->from_ly)
+ evas_object_geometry_get(ugd->from_ly, NULL, NULL, NULL, &from_height);
+
+ Evas_Coord to_height = 0;
+ evas_object_geometry_get(ugd->to_ly, NULL, NULL, NULL, &to_height);
+
+ Evas_Coord cc_height = 0;
+ if (ugd->cc_ly)
+ evas_object_geometry_get(ugd->cc_ly, NULL, NULL, NULL, &cc_height);
+
+ Evas_Coord bcc_height = 0;
+ if (ugd->bcc_ly)
+ evas_object_geometry_get(ugd->bcc_ly, NULL, NULL, NULL, &bcc_height);
+
+ Evas_Coord sub_height = 0;
+ evas_object_geometry_get(ugd->subject_ly, NULL, NULL, NULL, &sub_height);
+
+ Evas_Coord att_height = 0;
+ if (ugd->attachment_contracted_item)
+ evas_object_geometry_get(ugd->attachment_contracted_item, NULL, NULL, NULL, &att_height);
+
+ debug_log("scroller = w:%d, h:%d", sc_width, sc_height);
+ debug_log("from_height = %d", from_height);
+ debug_log(" to_height = %d", to_height);
+ debug_log(" cc_height = %d", cc_height);
+ debug_log(" bcc_height = %d", bcc_height);
+ debug_log(" sub_height = %d", sub_height);
+ debug_log(" att_height = %d", att_height);
+
+ // 10 means "top_line" size. it should be modified. it should get from edc part.
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ debug_log("selected_entry = to_mbe_entry");
+ elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height, sc_width, sc_height);
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ debug_log("selected_entry = cc_mbe_entry");
+ elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height, sc_width, sc_height);
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ debug_log("selected_entry = bcc_mbe_entry");
+ elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height, sc_width, sc_height);
+ } else if (ugd->selected_entry == ugd->subject_entry) {
+ debug_log("selected_entry = subject_entry");
+ elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height, sc_width, sc_height);
+ } else if (ugd->selected_entry == ugd->attachment_contracted_item) {
+ debug_log("selected_entry = attachment_contracted_item");
+ elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height + sub_height, sc_width, sc_height);
+ } else if (ugd->selected_entry == ugd->body_ewkview) {
+ debug_log("selected_entry = body_ewkview");
+ elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height + sub_height + att_height, sc_width, sc_height);
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+Eina_Bool _composer_bringin_cb(void *data)
+{
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ Evas_Coord sc_width = 0, sc_height = 0;
+ elm_scroller_region_get(ugd->main_scroller, 0, 0, &sc_width, &sc_height);
+
+ Evas_Coord from_height = 0;
+ if (ugd->from_ly)
+ evas_object_geometry_get(ugd->from_ly, NULL, NULL, NULL, &from_height);
+
+ Evas_Coord to_height = 0;
+ evas_object_geometry_get(ugd->to_ly, NULL, NULL, NULL, &to_height);
+
+ Evas_Coord cc_height = 0;
+ if (ugd->cc_ly)
+ evas_object_geometry_get(ugd->cc_ly, NULL, NULL, NULL, &cc_height);
+
+ Evas_Coord bcc_height = 0;
+ if (ugd->bcc_ly)
+ evas_object_geometry_get(ugd->bcc_ly, NULL, NULL, NULL, &bcc_height);
+
+ Evas_Coord sub_height = 0;
+ evas_object_geometry_get(ugd->subject_ly, NULL, NULL, NULL, &sub_height);
+
+ Evas_Coord att_height = 0;
+ if (ugd->attachment_contracted_item)
+ evas_object_geometry_get(ugd->attachment_contracted_item, NULL, NULL, NULL, &att_height);
+
+ debug_log("scroller = w:%d, h:%d", sc_width, sc_height);
+ debug_log("from_height = %d", from_height);
+ debug_log(" to_height = %d", to_height);
+ debug_log(" cc_height = %d", cc_height);
+ debug_log(" bcc_height = %d", bcc_height);
+ debug_log(" sub_height = %d", sub_height);
+ debug_log(" att_height = %d", att_height);
+
+ // 10 means "top_line" size. it should be modified. it should get from edc part.
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ debug_log("selected_entry = to_mbe_entry");
+ elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height, sc_width, sc_height);
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ debug_log("selected_entry = cc_mbe_entry");
+ elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height, sc_width, sc_height);
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ debug_log("selected_entry = bcc_mbe_entry");
+ elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height, sc_width, sc_height);
+ } else if (ugd->selected_entry == ugd->subject_entry) {
+ debug_log("selected_entry = subject_entry");
+ elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height, sc_width, sc_height);
+ } else if (ugd->selected_entry == ugd->attachment_contracted_item) {
+ debug_log("selected_entry = attachment_contracted_item");
+ elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height + sub_height, sc_width, sc_height);
+ } else if (ugd->selected_entry == ugd->body_ewkview) {
+ debug_log("selected_entry = body_ewkview");
+ elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height + sub_height + att_height, sc_width, sc_height);
+ }
+
+ if (ugd->bringin_timer) {
+ ecore_timer_del(ugd->bringin_timer);
+ ugd->bringin_timer = NULL;
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+Eina_Bool _composer_mbe_popup_del(void *data)
+{
+ debug_log("");
+ Evas_Object *obj = (Evas_Object *)data;
+
+ evas_object_del(obj);
+ obj = NULL;
+
+ return EINA_FALSE;
+}
+
+Eina_Bool _composer_mbe_create_change_addr_list(void *data)
+{
+ debug_log("");
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (ugd->change_addr_noti) {
+ evas_object_del(ugd->change_addr_noti);
+ ugd->change_addr_noti = NULL;
+ }
+ ugd->change_addr_noti = _composer_create_noti(ugd, false, _("IDS_EMAIL_OPT_CHANGE_EMAIL_ADDRESS_ABB"), NULL, 1,
+ dgettext("sys_string", "IDS_COM_SK_CANCEL"), NULL, 0.0, _composer_mbe_change_addr_response_cb);
+
+ elm_object_focus_set(ugd->change_addr_noti, EINA_TRUE);
+
+#ifdef _POPUP_WITH_LIST
+ elm_object_style_set(ugd->change_addr_noti, "min_menustyle");
+#else
+ elm_object_style_set(ugd->change_addr_noti, "menustyle");
+#endif
+ elm_object_focus_allow_set(ugd->change_addr_noti, EINA_FALSE);
+
+ Elm_Object_Item *gen_item;
+ Evas_Object *genlist;
+ int index;
+
+ itc.item_style = "1text";
+ itc.func.text_get = _composer_change_addr_gl_text_get;
+ itc.func.content_get = NULL;
+ itc.func.state_get = NULL;
+ itc.func.del = NULL;
+
+ genlist = elm_genlist_add(ugd->change_addr_noti);
+
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ debug_log("ri->email_cnt = %d", email_cnt);
+
+ for (index = 0; index < email_cnt; index++) {
+ gen_item = elm_genlist_item_append(genlist, &itc, (void *)index, NULL, ELM_GENLIST_ITEM_NONE, _composer_mbe_popup_change_addr_selected_cb, ugd);
+
+ elm_object_item_data_set(gen_item, (void *)index);
+ elm_genlist_item_update(gen_item);
+ }
+
+// elm_genlist_effect_set(genlist, EINA_FALSE);
+ elm_genlist_tree_effect_enabled_set(genlist, EINA_FALSE);
+
+#ifdef _POPUP_WITH_LIST
+ debug_log("index:%d", index);
+ if (index > 5)
+ index = 5;
+ Evas_Object *box = elm_box_add(ugd->change_addr_noti);
+ evas_object_size_hint_min_set(box, 610 * elm_scale_get(), 113 * index * elm_scale_get());
+ evas_object_show(genlist);
+ elm_box_pack_end(box, genlist);
+ elm_object_content_set(ugd->change_addr_noti, box);
+#else
+ elm_object_content_set(ugd->change_addr_noti, genlist);
+#endif
+
+ return EINA_FALSE;
+}
+
+Eina_Bool _composer_send_popup_finish_cb(void *data)
+{
+ debug_log("");
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ _composer_popup_end(ugd, ugd->send_result);
+ return EINA_TRUE;
+}
+
+void _composer_fail_to_send_popup_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (ugd->popup_list) {
+ debug_log("popup count = %d", eina_list_count(ugd->popup_list));
+ debug_log("obj: %p", obj);
+ debug_log("composer_noti: %p", ugd->composer_noti);
+
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
+ }
+
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+
+ elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
+ elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
+
+ ugd->bSendBtnDisabled = false;
+}
+
+static void *_composer_contact_search_by_email(EmailComposerUGD *ugd, const char *search_word)
+{
+ debug_log("");
+ if (!ugd || !g_ugd) {
+ debug_log("data is NULL");
+ return NULL;
+ }
+
+ int ret = CTS_SUCCESS;
+ CTSiter *iter = NULL;
+
+ EMAIL_CONTACT_LIST_INFO_S *contacts_list_item = NULL;
+ contacts_svc_connect();
+
+ debug_log("search_word = %s", search_word);
+
+ if (contacts_svc_get_list_with_str(CTS_LIST_EMAILINFOS_WITH_EMAIL, search_word, &iter) != CTS_SUCCESS) {
+ return NULL;
+ }
+
+ ret = contacts_svc_iter_next(iter);
+
+ if (CTS_SUCCESS == ret) {
+ CTSvalue *row_info = NULL;
+
+ row_info = contacts_svc_iter_get_info(iter);
+ if (row_info) {
+ contacts_list_item = (EMAIL_CONTACT_LIST_INFO_S *)calloc(1, sizeof(EMAIL_CONTACT_LIST_INFO_S));
+
+ int index = contacts_svc_value_get_int(row_info, CTS_LIST_EMAIL_CONTACT_ID_INT);
+
+ contacts_list_item->index = index;
+ contacts_list_item->first_name = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_FIRST_STR));
+ contacts_list_item->last_name = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_LAST_STR));
+ contacts_list_item->image_path = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_IMG_PATH_STR));
+ contacts_list_item->email_address = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_ADDR_STR));
+
+ char *first = contacts_list_item->first_name;
+ char *last = contacts_list_item->last_name;
+ char *display = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR));
+
+ if (!display) {
+ if (first != NULL && last != NULL) {
+ if (CTS_ORDER_NAME_FIRSTLAST == contacts_svc_get_order(CTS_ORDER_OF_DISPLAY)) {
+ display = g_strconcat(first, " ", last, NULL);
+ } else {
+ display = g_strconcat(last, " ", first, NULL);
+ }
+ } else if (first != NULL || last != NULL) {
+ display = (first != NULL) ? g_strdup(first) : g_strdup(last);
+ } else {
+ display = g_strdup(" ");
+ }
+ }
+
+ snprintf(contacts_list_item->display_name, sizeof(contacts_list_item->display_name), "%s", display);
+ g_free(display);
+
+ /*contacts_list = eina_list_append(contacts_list, contacts_list_item);*/
+ }
+
+ contacts_svc_value_free(row_info);
+ row_info = NULL;
+
+ /*ret = contacts_svc_iter_next(iter);*/
+ contacts_svc_iter_remove(iter);
+ }
+
+ contacts_svc_disconnect();
+
+ return contacts_list_item;
+}
+
+static void _composer_delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item)
+{
+ debug_log("");
+
+ if (contacts_list_item) {
+ g_free(contacts_list_item->first_name);
+ contacts_list_item->first_name = NULL;
+ g_free(contacts_list_item->last_name);
+ contacts_list_item->last_name = NULL;
+ g_free(contacts_list_item->email_address);
+ contacts_list_item->email_address = NULL;
+ g_free(contacts_list_item->image_path);
+ contacts_list_item->image_path = NULL;
+ g_free(contacts_list_item);
+ contacts_list_item = NULL;
+ }
+}
+
+void _composer_check_email_address(EmailComposerUGD *ugd, Evas_Object *entry)
+{
+ debug_log("");
+
+ char *temp = elm_entry_markup_to_utf8(elm_entry_entry_get(entry));
+
+ if (!temp)
+ return;
+
+ debug_log("temp = %s, edit_mode = %d", temp, edit_mode);
+
+ if (edit_mode == true) {
+ edit_mode = false;
+ free(temp);
+ return;
+ }
+
+ if (strlen(temp) == 0) {
+ if (ugd->ps_on) {
+ _composer_ps_stop(ugd);
+ ugd->sc_timer = ecore_timer_add(0.5, _composer_ps_scroll_pop, ugd);
+ }
+ } else if (strlen(temp)) {
+ debug_log("temp = %s", temp);
+
+ memset(ugd->ps_keyword, 0x00, sizeof(ugd->ps_keyword));
+ strncpy(ugd->ps_keyword, temp, sizeof(ugd->ps_keyword) - 1);
+
+ /*if (ugd->ps_bg_timer) {
+ ecore_timer_del(ugd->ps_bg_timer);
+ ugd->ps_bg_timer = NULL;
+ }*/
+ _composer_ps_add_timer(ugd);
+ }
+
+ free(temp);
+}
+
+void _composer_check_entry_max(EmailComposerUGD *ugd, Evas_Object *entry, int max_len)
+{
+ debug_log("");
+ const char *temp = elm_entry_entry_get(entry);
+
+ debug_log("subject len = %d", strlen(temp));
+ if (strlen(temp) >= max_len) {
+ debug_log("Subject length is Over");
+
+ char subject[MAX_SUBJECT_LEN] = { 0, };
+ strncpy(subject, temp, sizeof(subject) - 1);
+
+ elm_entry_entry_set(entry, subject);
+ elm_entry_cursor_end_set(entry);
+
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), _("IDS_EMAIL_POP_UNABLE_TO_ENTER_TEXT"), 0, NULL, NULL, 1.5, _composer_noti_response_cb);
+ }
+}
+
+void _composer_from_show_popup(EmailComposerUGD *ugd)
+{
+ debug_log("");
+
+ Elm_Object_Item *gen_item;
+ int acc_index;
+
+ g_ugd = ugd;
+
+ if (ugd->composer_noti) {
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ ugd->composer_noti = _composer_create_noti(ugd, false, _("IDS_EMAIL_BODY_FROM"), NULL, 1, dgettext("sys_string", "IDS_COM_SK_OK"), NULL, 0.0, _composer_from_change_response_cb);
+
+#ifdef _POPUP_WITH_LIST
+ elm_object_style_set(ugd->composer_noti, "min_menustyle");
+#else
+ elm_object_style_set(ugd->composer_noti, "menustyle");
+#endif
+ elm_object_focus_allow_set(ugd->composer_noti, EINA_FALSE);
+
+ from_itc.item_style = "1text.1icon.2";
+ from_itc.func.text_get = _composer_from_gl_text_get;
+ from_itc.func.content_get = _composer_from_gl_content_get;
+ from_itc.func.state_get = NULL;
+ from_itc.func.del = NULL;
+
+ elm_genlist_clear(ugd->account_gen_list);
+ ugd->account_gen_list = elm_genlist_add(ugd->composer_noti);
+
+ evas_object_size_hint_weight_set(ugd->account_gen_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(ugd->account_gen_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ for (acc_index = 0; acc_index < ugd->account_info->account_count; acc_index++) {
+ gen_item = elm_genlist_item_append(ugd->account_gen_list, &from_itc, (void *)acc_index, NULL, ELM_GENLIST_ITEM_NONE, _composer_from_gl_sel, (void *)acc_index);
+ }
+
+// elm_genlist_effect_set(ugd->account_gen_list, EINA_FALSE);
+ elm_genlist_tree_effect_enabled_set(ugd->account_gen_list, EINA_FALSE);
+
+#ifdef _POPUP_WITH_LIST
+ debug_log("acc_index:%d", acc_index);
+ if (acc_index > 5)
+ acc_index = 5;
+ Evas_Object *box = elm_box_add(ugd->composer_noti);
+ evas_object_size_hint_min_set(box, 610 * elm_scale_get(), 113 * acc_index * elm_scale_get());
+ evas_object_show(ugd->account_gen_list);
+ elm_box_pack_end(box, ugd->account_gen_list);
+ elm_object_content_set(ugd->composer_noti, box);
+#else
+ elm_object_content_set(ugd->composer_noti, ugd->account_gen_list);
+#endif
+}
+
+char *_composer_from_gl_text_get(void *data, Evas_Object *obj, const char *part)
+{
+ int index = (int)data;
+
+ debug_log("label index = %d", index);
+ debug_log("email_addr = %s", g_ugd->account_info->account_list[index].user_email_address);
+
+ if (!g_strcmp0(part, "elm.text")) {
+ return g_strdup(g_ugd->account_info->account_list[index].user_email_address);
+ }
+
+ return NULL;
+}
+
+Evas_Object *_composer_from_gl_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ int count = (int)data;
+
+ debug_log("count = %d", count);
+ debug_log("account_id = %d", g_ugd->account_info->account_list[count].account_id);
+ debug_log("default account_id = %d", g_ugd->account_info->account_id);
+
+ if (!strncmp(part, "elm.icon", 8)) {
+ g_ugd->account_info->account_rd[count] = elm_radio_add(obj);
+ elm_radio_state_value_set(g_ugd->account_info->account_rd[count], count);
+
+ if (count == 0) {
+ g_ugd->account_info->account_rdg = g_ugd->account_info->account_rd[count];
+ } else
+ elm_radio_group_add(g_ugd->account_info->account_rd[count], g_ugd->account_info->account_rdg);
+
+ if (g_ugd->account_info->account_list[count].account_id == g_ugd->account_info->account_id)
+ elm_radio_value_set(g_ugd->account_info->account_rdg, count);
+
+ evas_object_smart_callback_add(g_ugd->account_info->account_rd[count], "changed", _composer_from_radio_cb, g_ugd);
+
+ return g_ugd->account_info->account_rd[count];
+ }
+
+ return NULL;
+}
+
+static void _composer_from_gl_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ int index = (int)data;
+
+ elm_radio_value_set(g_ugd->account_info->account_rdg, index);
+}
+
+static void _composer_from_change_response_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ debug_log("composer_noti : %p", ugd->composer_noti);
+
+ char *pszBtnText = (char *)elm_object_text_get(obj);
+ debug_log("selected button text = %s", pszBtnText);
+
+ if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_OK")) == 0) {
+ int set_val = elm_radio_value_get(ugd->account_info->account_rdg);
+
+ debug_log("set_val = %d", set_val);
+ debug_log("account_type: %d", ugd->account_info->account_list[set_val].incoming_server_type);
+
+ ugd->account_info->account_id = ugd->account_info->account_list[set_val].account_id;
+
+ if (ugd->account_info->account_name) {
+ g_free(ugd->account_info->account_name);
+ ugd->account_info->account_name = NULL;
+ }
+
+ ugd->account_info->account_name = g_strdup(ugd->account_info->account_list[set_val].user_email_address);
+
+ debug_log("account_id = %d", ugd->account_info->account_id);
+ if (!email_engine_get_account_full_data(ugd->account_info->account_id, &(ugd->account_info->account)))
+ debug_log("Failed to Get account full data");
+
+ debug_log("priority = %d", (*ugd->account_info->account).options.priority);
+
+ Elm_Object_Item *from_item = NULL;
+ from_item = elm_multibuttonentry_first_item_get(ugd->from_mbe);
+
+ EmailRecpInfo *from_ri = NULL;
+
+ if (from_item) {
+ from_ri = elm_object_item_data_get(from_item);
+
+ debug_log("from_ri = %s", from_ri->email_list[0].email_addr);
+ }
+
+ debug_log("add_my_address_to_bcc = %d", ugd->account_info->account->options.add_my_address_to_bcc);
+
+#ifdef _ALWAYS_CC_MYSELF
+ debug_log("remove bcc myself if it is");
+ Elm_Object_Item *bcc_item = NULL;
+ bcc_item = elm_multibuttonentry_first_item_get(ugd->bcc_mbe);
+
+ while (bcc_item) {
+ EmailRecpInfo *bcc_ri = NULL;
+ int index = 0;
+
+ bcc_ri = (EmailRecpInfo *) elm_object_item_data_get(bcc_item);
+
+ index = bcc_ri->selected_email_idx;
+
+ debug_log("bcc_ri email_addr = %s", bcc_ri->email_list[index].email_addr);
+
+ if ((g_strcmp0(bcc_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr) == 0) && (bcc_ri->is_always_bcc == true)) {
+ elm_object_item_del(bcc_item);
+ break;
+ }
+
+ bcc_item = elm_multibuttonentry_item_next_get(bcc_item);
+ }
+
+ debug_log("remove cc myself if it is");
+ Elm_Object_Item *cc_item = NULL;
+ cc_item = elm_multibuttonentry_first_item_get(ugd->cc_mbe);
+
+ while (cc_item) {
+ EmailRecpInfo *cc_ri = NULL;
+ int index = 0;
+
+ cc_ri = (EmailRecpInfo *) elm_object_item_data_get(cc_item);
+
+ index = cc_ri->selected_email_idx;
+
+ debug_log("cc_ri email_addr = %s", cc_ri->email_list[index].email_addr);
+
+ if ((g_strcmp0(cc_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr) == 0) && (cc_ri->is_always_bcc == true)) {
+ elm_object_item_del(cc_item);
+ break;
+ }
+
+ cc_item = elm_multibuttonentry_item_next_get(cc_item);
+ }
+
+ if (ugd->account_info->account->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_BCC) {
+ debug_log("always bcc on");
+ EmailRecpInfo *new_bcc_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
+
+ new_bcc_ri->selected_email_idx = 0;
+ new_bcc_ri->display_name = ugd->account_info->account->user_display_name;
+ snprintf(new_bcc_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account->user_email_address);
+ new_bcc_ri->email_cnt = 1;
+ new_bcc_ri->is_contact_info = false;
+ new_bcc_ri->is_always_bcc = true;
+ new_bcc_ri->is_from_addr = false;
+
+ bcc_item = elm_multibuttonentry_first_item_get(ugd->bcc_mbe);
+ elm_multibuttonentry_item_insert_before(ugd->bcc_mbe, bcc_item, g_strdup(new_bcc_ri->display_name), NULL, new_bcc_ri);
+ } else if (ugd->account_info->account->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_CC) {
+ debug_log("always cc on");
+ EmailRecpInfo *new_cc_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
+
+ new_cc_ri->selected_email_idx = 0;
+ new_cc_ri->display_name = ugd->account_info->account->user_display_name;
+ snprintf(new_cc_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account->user_email_address);
+ new_cc_ri->email_cnt = 1;
+ new_cc_ri->is_contact_info = false;
+ new_cc_ri->is_always_bcc = true;
+ new_cc_ri->is_from_addr = false;
+
+ cc_item = elm_multibuttonentry_first_item_get(ugd->cc_mbe);
+ elm_multibuttonentry_item_insert_before(ugd->cc_mbe, cc_item, g_strdup(new_cc_ri->display_name), NULL, new_cc_ri);
+ } else {
+ debug_log("always bcc/cc off");
+ }
+#endif
+
+ EmailRecpInfo *new_from_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
+
+ new_from_ri->selected_email_idx = 0;
+ new_from_ri->display_name = ugd->account_info->account->user_display_name;
+ snprintf(new_from_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account->user_email_address);
+ new_from_ri->email_cnt = 1;
+ new_from_ri->is_contact_info = false;
+ new_from_ri->is_always_bcc = false;
+ new_from_ri->is_from_addr = true;
+
+ elm_object_item_del(from_item);
+
+ elm_multibuttonentry_item_append(ugd->from_mbe, g_strdup(new_from_ri->display_name), NULL, new_from_ri);
+
+ if (ugd->selected_entry == ugd->to_mbe_entry) {
+ elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
+ } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
+ elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
+ } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
+ elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
+ }
+
+ if (ugd->account_gen_list) {
+ elm_genlist_clear(ugd->account_gen_list);
+
+ evas_object_del(ugd->account_gen_list);
+ ugd->account_gen_list = NULL;
+ }
+
+ if (ugd->popup_list) {
+ debug_log("popup count = %d", eina_list_count(ugd->popup_list));
+ debug_log("obj: %p", obj);
+ debug_log("composer_noti: %p", ugd->composer_noti);
+
+ ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
+ }
+
+ if (ugd->composer_noti) {
+ debug_log("@@@ ELM_POPUP_RESPONSE_CLOSE @@@");
+ _composer_popup_delete(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+ }
+}
+
+static void _composer_from_radio_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+ int i;
+
+ for (i = 0; i < ugd->account_info->account_count; i++) {
+ if (obj == ugd->account_info->account_rd[i]) {
+ debug_log("account_id = %d", ugd->account_info->account_list[i].account_id);
+ elm_radio_value_set(ugd->account_info->account_rdg, i);
+ }
+ }
+}
+
+void _composer_cbar_cc_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (ugd->cc_added) {
+ if (ugd->b_cc_bcc) {
+ debug_log("b_cc_bcc is ON");
+ return;
+ }
+
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "hide.cc", "*");
+ email_composer_delete_cc_field(ugd);
+
+#ifdef _CC_BCC
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "hide.bcc", "*");
+ email_composer_delete_bcc_field(ugd);
+
+ elm_object_text_set(ugd->cc_btn, _("IDS_EMAIL_OPT_ADD_CC_BCC"));
+#endif
+
+ if (ugd->b_cc_ps_open == true) {
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
+ ugd->b_cc_ps_open = false;
+ }
+
+ ugd->b_cc_bcc = false;
+
+ if (!_composer_check_popup_exist(ugd)) {
+ ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
+ }
+ } else {
+ if (ugd->b_cc_bcc) {
+ debug_log("b_cc_bcc is ON");
+ return;
+ }
+
+ if (ugd->clipboard_on) {
+ ugd->clipboard_on = false;
+ }
+
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
+ email_composer_create_cc_field(ugd);
+
+#ifdef _CC_BCC
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
+ email_composer_create_bcc_field(ugd);
+
+ elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
+#endif
+
+ ugd->idler_set_focus = ecore_idler_add(_composer_cc_mbe_set_focus, ugd);
+ }
+
+ if (ugd->isRotated == true)
+ elm_object_item_signal_emit(ugd->navi_item, "elm,state,optionheader,close", "");
+
+}
+
+#ifndef _CC_BCC
+void _composer_cbar_bcc_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (ugd->bcc_added) {
+ if (ugd->b_cc_bcc) {
+ debug_log("b_cc_bcc is ON");
+ return;
+ }
+
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "hide.bcc", "*");
+ email_composer_delete_bcc_field(ugd);
+
+ if (ugd->b_bcc_ps_open == true) {
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
+
+ if (ugd->cc_added) {
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
+ }
+
+ ugd->b_bcc_ps_open = false;
+ }
+
+ ugd->b_cc_bcc = false;
+
+ if (!_composer_check_popup_exist(ugd)) {
+ ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
+ }
+ } else {
+ if (ugd->b_cc_bcc) {
+ debug_log("b_cc_bcc is ON");
+ return;
+ }
+
+ if (ugd->clipboard_on) {
+ ugd->clipboard_on = false;
+ }
+
+ edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
+ email_composer_create_bcc_field(ugd);
+
+ ugd->idler_set_focus = ecore_idler_add(_composer_bcc_mbe_set_focus, ugd);
+ }
+
+ if (ugd->isRotated == true)
+ elm_object_item_signal_emit(ugd->navi_item, "elm,state,optionheader,close", "");
+
+}
+#endif
+
+void _composer_cbar_send_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ debug_log("Send Button Clicked");
+
+ if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_DISABLE_EDITABLE, _composer_send_clicked_cb, (void *)ugd))
+ debug_log("COMPOSER_JS_DISABLE_EDITABLE error");
+
+ 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.");
+
+ debug_log("selected_entry = %x, to_mbe_entry = %x, cc_mbe_entry = %x, bcc_mbe_entry = %x, subject_entry = %x, body_ewkview = %x",
+ ugd->selected_entry, ugd->to_mbe_entry, ugd->cc_mbe_entry, ugd->bcc_mbe_entry, ugd->subject_entry, ugd->body_ewkview);
+
+ elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
+ elm_object_disabled_set(ugd->cancel_btn, EINA_TRUE);
+
+ ugd->bSendBtnDisabled = true;
+
+ ugd->send_timer = ecore_timer_add(0.5, _composer_send_mail_cb, ugd);
+}
+
+static Eina_Bool _composer_cc_mbe_set_focus(void *data)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (ugd->idler_set_focus) {
+ ecore_idler_del(ugd->idler_set_focus);
+ ugd->idler_set_focus = NULL;
+ }
+
+ elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
+
+ ugd->b_cc_bcc = false;
+
+ return EINA_FALSE;
+}
+
+#ifndef _CC_BCC
+static Eina_Bool _composer_bcc_mbe_set_focus(void *data)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (ugd->idler_set_focus) {
+ ecore_idler_del(ugd->idler_set_focus);
+ ugd->idler_set_focus = NULL;
+ }
+
+ elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
+
+ ugd->b_cc_bcc = false;
+
+ return EINA_FALSE;
+}
+#endif
+
+void _composer_script_executed_cb(Evas_Object *o, const char *result, void *data)
+{
+ debug_log("");
+}
+
+void _composer_focus_script_executed_cb(Evas_Object *o, const char *result, void *data)
+{
+ debug_log("");
+// EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+// ugd->bringin_timer = ecore_timer_add(0.7f, _composer_bringin_cb, ugd);
+}
+
+static void _composer_get_html_content_for_draft_cb(Evas_Object *o, const char *result, void *data)
+{
+ debug_log("Enter");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE); // It prevents clicking the cancel button several times
+
+ if (NULL != ugd->latest_html_content) {
+ g_free(ugd->latest_html_content);
+ ugd->latest_html_content = NULL;
+ }
+
+ ugd->latest_html_content = g_strdup(result);
+ debug_log("ugd->latest_html_content => %s", ugd->latest_html_content);
+
+ 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 (ugd->timeout_noti) {
+ debug_log("delete timeout_noti");
+ evas_object_del(ugd->timeout_noti);
+ ugd->timeout_noti = NULL;
+ }
+
+ if (ugd->composer_noti) {
+ debug_log("delete composer_noti");
+ evas_object_del(ugd->composer_noti);
+ ugd->composer_noti = NULL;
+ }
+
+ if (ugd->ps_list) {
+ debug_log("ps stop");
+ _composer_ps_stop(ugd);
+ ugd->sc_timer = ecore_timer_add(0.5, _composer_ps_scroll_pop, ugd);
+ }
+
+ if (ugd->selected_entry == ugd->body_ewkview) {
+ evas_object_focus_set(ugd->body_ewkview, EINA_FALSE);
+ } else {
+ Ecore_IMF_Context *imf_context = NULL;
+ imf_context = elm_entry_imf_context_get(ugd->selected_entry);
+ if (imf_context)
+ ecore_imf_context_input_panel_hide(imf_context);
+ }
+
+ if (_composer_check_mail_is_modified(ugd)) {
+ debug_log("mail is changed.");
+ ugd->save_drafts = 1;
+ } else {
+ debug_log("mail is NOT changed.");
+ ugd->save_drafts = 0;
+ }
+
+ if (ugd->save_drafts) {
+ ugd->composer_noti = _composer_create_popup(ugd, false, NULL, dgettext("sys_string", "IDS_COM_POP_SAVE_TO_DRAFTS_Q"), 3,
+ dgettext("sys_string", "IDS_COM_SK_YES"), dgettext("sys_string", "IDS_COM_SK_NO"), dgettext("sys_string", "IDS_COM_SK_CANCEL"), 0.0, _composer_save_popup_response_cb);
+ } else {
+ if (elm_multibuttonentry_first_item_get(ugd->to_mbe))
+ elm_multibuttonentry_clear(ugd->to_mbe);
+ if (elm_multibuttonentry_first_item_get(ugd->cc_mbe))
+ elm_multibuttonentry_clear(ugd->cc_mbe);
+ if (elm_multibuttonentry_first_item_get(ugd->bcc_mbe))
+ elm_multibuttonentry_clear(ugd->bcc_mbe);
+
+ ug_destroy_me(ugd->ug_main);
+ }
+}
+
+static void _composer_send_clicked_cb(Evas_Object *o, const char *result, void *data)
+{
+ debug_log("");
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_HTML_CONTENT, _composer_get_latest_html_content_cb, (void *)ugd))
+ debug_log("COMPOSER_JS_GET_HTML_CONTENT failed.");
+}
+
+void _composer_get_latest_html_content_cb(Evas_Object *o, const char *result, void *data)
+{
+ debug_log("");
+ EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+ if (NULL != ugd->latest_html_content) {
+ g_free(ugd->latest_html_content);
+ ugd->latest_html_content = NULL;
+ }
+
+ ugd->latest_html_content = g_strdup(result);
+ debug_log("ugd->latest_html_content => %s", ugd->latest_html_content);
+}
+
+static void _composer_plain_text_get_cb(Evas_Object *o, const char *plain_text, void *user_data)
+{
+ debug_log("");
+
+ EmailComposerUGD *ugd = (EmailComposerUGD *) user_data;
+
+ if (NULL != ugd->plain_content) {
+ g_free(ugd->plain_content);
+ ugd->plain_content = NULL;
+ }
+
+ ugd->plain_content = g_strdup(plain_text);
+ debug_log("ugd->plain_content => %s", ugd->plain_content);
+}
+
+void _composer_get_image_list_cb(Evas_Object *o, const char *result, void *data)
+{
+ debug_log("");
+
+ char *list = NULL;
+ EmailComposerUGD *ugd = (EmailComposerUGD *) data;
+
+ if (ugd->listOfImageUrls) {
+ eina_list_free(ugd->listOfImageUrls);
+ ugd->listOfImageUrls = NULL;
+ }
+ debug_log("listOFImageUrls => %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, ",");
+ }
+ }
+}