2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "email-composer.h"
21 #include "email-composer-util.h"
22 #include "email-composer-recipient.h"
23 #include "email-composer-attachment.h"
24 #include "email-composer-callback.h"
25 #include "email-composer-predictive-search.h"
26 #include "email-composer-js.h"
27 #include "email-composer-contents.h"
29 #define ACCOUNT_ICON_OTHERS IMGDIR"/icon_email.png"
31 static EmailComposerUGD *g_ugd = NULL;
33 bool edit_mode = false;
34 bool edit_mode_bs = false;
38 EmailList email_list[MAX_RECIPIENT_COUNT];
40 static Elm_Genlist_Item_Class itc;
41 static Elm_Genlist_Item_Class from_itc;
42 static Elm_Genlist_Item_Class myemail_itc;
43 static Elm_Genlist_Item_Class priority_itc;
44 static Elm_Genlist_Item_Class tracking_itc;
46 static void _composer_mbe_popup_change_addr_selected_cb(void *data, Evas_Object *obj, void *event_info);
47 static void _composer_from_change_response_cb(void *data, Evas_Object *obj, void *event_info);
48 static void _composer_from_close_response_cb(EmailComposerUGD *ugd);
49 static void _composer_from_radio_cb(void *data, Evas_Object *obj, void *event_info);
50 static void _composer_from_gl_sel(void *data, Evas_Object *obj, void *event_info);
52 static void _composer_myemail_change_response_cb(void *data, Evas_Object *obj, void *event_info);
53 static void _composer_myemail_close_response_cb(EmailComposerUGD *ugd);
54 static void _composer_myemail_radio_cb(void *data, Evas_Object *obj, void *event_info);
55 static void _composer_myemail_gl_sel(void *data, Evas_Object *obj, void *event_info);
57 static Eina_Bool _composer_cc_mbe_set_focus(void *data);
58 Eina_Bool _composer_get_html_content_for_draft_cb(void *data);
59 static void _composer_plain_text_get_cb(Evas_Object *o, const char *plain_text, void *user_data);
60 static void _composer_get_latest_info_content_cb(Evas_Object *o, const char *result, void *data);
61 static void _composer_get_latest_html_content_cb(Evas_Object *o, const char *result, void *data);
63 void _composer_edit_field_changed_cb(void *data, Evas_Object *obj, void *event_info)
67 if (data == NULL || obj == NULL) {
71 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
73 if (obj == ugd->subject_entry) {
74 _composer_check_entry_max(ugd, ugd->subject_entry, MAX_SUBJECT_LEN + 1);
76 if (_composer_check_recipient_is_empty(ugd)) {
77 if (!ugd->bSendBtnDisabled) {
78 elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
79 elm_object_disabled_set(ugd->send_btm_btn, EINA_TRUE);
80 ugd->bSendBtnDisabled = true;
83 if (ugd->bSendBtnDisabled) {
84 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
85 elm_object_disabled_set(ugd->send_btm_btn, EINA_FALSE);
86 ugd->bSendBtnDisabled = false;
89 } else if (obj == ugd->body_ewkview) {
90 if (_composer_check_recipient_is_empty(ugd)) {
91 if (!ugd->bSendBtnDisabled) {
92 elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
93 elm_object_disabled_set(ugd->send_btm_btn, EINA_TRUE);
94 ugd->bSendBtnDisabled = true;
97 if (ugd->bSendBtnDisabled) {
98 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
99 elm_object_disabled_set(ugd->send_btm_btn, EINA_FALSE);
100 ugd->bSendBtnDisabled = false;
106 static void _composer_move_ctxpopup_more(EmailComposerUGD *ugd, Evas_Object *btn)
108 Evas_Coord x, y, w , h;
109 evas_object_geometry_get(btn, &x, &y, &w, &h);
110 debug_log("is_ime_hided:%d, x(%d), y(%d), w(%d), h(%d)", ugd->is_ime_hided, x, y, w, h);
111 if (ugd->is_ime_hided == FALSE)
112 evas_object_move(ugd->context_popup, x + (w / 2), y + h);
114 evas_object_move(ugd->context_popup, x + (w / 2), y);
117 static void _composer_ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
119 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
121 ugd->focus_status = COMPOSER_FOCUS_STATUS_NONE;
123 evas_object_del(ugd->context_popup);
124 ugd->context_popup = NULL;
127 void _composer_more_toolbar_button_cb(void *data, Evas_Object *obj, void *event_info)
131 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
133 Evas_Object* icon = NULL;
135 if(ugd->context_popup) {
136 evas_object_del(ugd->context_popup);
137 ugd->context_popup = NULL;
140 ugd->context_popup = elm_ctxpopup_add(ugd->main_layout);
141 elm_ctxpopup_direction_priority_set(ugd->context_popup, ELM_CTXPOPUP_DIRECTION_DOWN,
142 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
143 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
144 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
145 elm_object_style_set(ugd->context_popup, "more_button");
146 evas_object_smart_callback_add(ugd->context_popup, "dismissed", _composer_ctxpopup_dismissed_cb, ugd);
148 elm_object_focus_set(ugd->context_popup, EINA_TRUE);
149 ugd->focus_status = COMPOSER_FOCUS_STATUS_SELECTED; // more button is clicked!!
151 icon = elm_icon_add(ugd->context_popup);
152 elm_image_file_set(icon, IMGDIR "/M02_icon_popup_send_email.png", NULL);
153 elm_ctxpopup_item_append(ugd->context_popup, _("IDS_EMAIL_OPT_SEND_EMAIL_TO_MYSELF_ABB"), icon, _composer_cbar_send_myself_clicked, ugd);
156 icon = elm_icon_add(ugd->context_popup);
157 elm_image_file_set(icon, IMGDIR "/M02_icon_popup_add cc.png", NULL);
159 elm_ctxpopup_item_append(ugd->context_popup, N_("Remove Cc/Bcc"), icon, _composer_cbar_cc_clicked, ugd);
161 elm_ctxpopup_item_append(ugd->context_popup, _("IDS_EMAIL_OPT_ADD_CC_BCC"), icon, _composer_cbar_cc_clicked, ugd);
165 icon = elm_icon_add(ugd->context_popup);
166 elm_image_file_set(icon, IMGDIR "/M02_icon_popup_save.png", NULL);
167 elm_ctxpopup_item_append(ugd->context_popup, dgettext("sys_string", "IDS_COM_POP_SAVE_IN_DRAFTS"), icon, _composer_cbar_save_as_draft_clicked, ugd);
170 icon = elm_icon_add(ugd->context_popup);
171 elm_image_file_set(icon, IMGDIR "/M02_icon_popup_priority.png", NULL);
172 elm_ctxpopup_item_append(ugd->context_popup, _("IDS_EMAIL_BODY_PRIORITY"), icon, _composer_cbar_priority_clicked, ugd);
175 icon = elm_icon_add(ugd->context_popup);
176 elm_image_file_set(icon, IMGDIR "/M02_icon_popup_tracking.png", NULL);
177 elm_ctxpopup_item_append(ugd->context_popup, _("IDS_EMAIL_OPT_TRACKING"), icon, _composer_cbar_tracking_clicked, ugd);
180 _composer_move_ctxpopup_more(ugd, obj);
182 evas_object_show(ugd->context_popup);
185 void _composer_back_button_cb(void *data, Evas_Object *obj, void *event_info)
189 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
191 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_FALSE); // block the focus not to open IME.
193 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_INFO_CONTENT, _composer_get_latest_info_content_cb, (void *)ugd))
194 debug_log("COMPOSER_JS_GET_LATEST_INFO_CONTENT failed.");
196 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_HTML_CONTENT, _composer_get_latest_html_content_cb, (void *)ugd))
197 debug_log("COMPOSER_JS_GET_LATEST_HTML_CONTENT failed.");
199 ugd->bringin_timer = ecore_timer_add(0.5, _composer_get_html_content_for_draft_cb, ugd);
201 debug_log("Cancel Button Clicked: %p, %p", ugd->cancel_btn, ugd->cancel_btm_btn);
204 void _composer_mbe_changed_cb(void *data, Evas_Object *obj, void *event_info)
208 if (data == NULL || obj == NULL) {
212 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
214 if (ugd->clipboard_on) {
215 debug_log("MBE Lost Focus");
216 _composer_mbe_set_focus(ugd);
219 if (obj == ugd->to_mbe_entry) {
221 _composer_check_email_address(ugd, ugd->to_mbe_entry);
222 } else if (obj == ugd->cc_mbe_entry) {
224 _composer_check_email_address(ugd, ugd->cc_mbe_entry);
225 } else if (obj == ugd->bcc_mbe_entry) {
227 _composer_check_email_address(ugd, ugd->bcc_mbe_entry);
231 void _composer_mbe_longpressed_cb(void *data, Evas_Object *obj, void *event_info)
235 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
237 ugd->clipboard_on = true;
240 void _composer_mbe_added_cb(void *data, Evas_Object *obj, void *event_info)
244 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
246 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
248 EmailRecpInfo *ri = NULL;
250 bool is_contact_info = false;
251 bool is_always_bcc = false;
252 bool is_from_addr = false;
254 char *addr = elm_entry_markup_to_utf8((char *)elm_object_item_text_get(item));
255 debug_log("utf8 address : %s", addr);
258 debug_log("Added - Address is NULL");
263 char temp_addr[MAX_RECIPIENT_ADDRESSES_LEN + 1] = { 0, };
265 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
268 is_contact_info = ri->is_contact_info;
269 is_always_bcc = ri->is_always_bcc;
270 is_from_addr = ri->is_from_addr;
272 strncpy(temp_addr, ri->email_list[ri->selected_email_idx].email_addr, MAX_RECIPIENT_ADDRESSES_LEN - 1);
273 temp_addr[MAX_RECIPIENT_ADDRESSES_LEN] = '\0';
275 debug_log("is_contact_info = %d", is_contact_info);
276 debug_log("is_always_bcc = %d", is_always_bcc);
277 debug_log("is_from_addr = %d", is_from_addr);
279 strncpy(temp_addr, addr, MAX_RECIPIENT_ADDRESSES_LEN - 1);
280 temp_addr[MAX_RECIPIENT_ADDRESSES_LEN] = '\0';
285 debug_log("email_addr = %s", temp_addr);
287 if (!is_contact_info && !is_always_bcc && !is_from_addr) {
288 if (ugd->to_recipients_cnt > MAX_RECIPIENT_COUNT) {
289 char msg[MAX_STR_LEN] = { 0, };
290 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
292 if (ugd->composer_noti) {
293 evas_object_del(ugd->composer_noti);
294 ugd->composer_noti = NULL;
296 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
297 msg, 0, NULL, NULL, 1.0, _composer_noti_response_cb);
299 elm_object_item_del(item);
302 } else if (!_composer_is_valid_email(temp_addr)) {
303 if (ugd->composer_noti) {
304 evas_object_del(ugd->composer_noti);
305 ugd->composer_noti = NULL;
307 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
308 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 0, NULL, NULL, 1.5, _composer_noti_response_cb);
310 elm_object_item_del(item);
315 EmailRecpInfo *new_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
316 snprintf(new_ri->email_list[0].email_addr, sizeof(new_ri->email_list[0].email_addr), "%s", temp_addr);
317 debug_log("email_addr = %s", new_ri->email_list[0].email_addr);
318 new_ri->selected_email_idx = 0;
319 new_ri->display_name = NULL;
320 new_ri->email_cnt = 1;
321 new_ri->is_contact_info = false;
322 new_ri->is_from_addr = false;
323 new_ri->is_always_bcc = false;
325 if ((ugd->me_added == false) && (obj == ugd->to_mbe)) {
326 debug_log("display_name = %s", ugd->account_info->account->user_display_name);
327 EmailRecpInfo *from_ri = NULL;
328 Elm_Object_Item *from_item = NULL;
329 from_item = elm_multibuttonentry_first_item_get(ugd->from_mbe);
331 from_ri = elm_object_item_data_get(from_item);
332 debug_log("from_ri = %s", from_ri->email_list[0].email_addr);
333 if (g_strcmp0(new_ri->email_list[0].email_addr, from_ri->email_list[0].email_addr) == 0) {
334 new_ri->display_name = ugd->account_info->account->user_display_name;
335 new_ri->is_from_addr = true;
336 elm_object_text_set(ugd->add_me_btn, N_("Remove me"));
337 ugd->me_added = true;
340 debug_log("account name = %s", ugd->account_info->account_name);
341 if (g_strcmp0(new_ri->email_list[0].email_addr, ugd->account_info->account_name) == 0) {
342 new_ri->display_name = ugd->account_info->account->user_display_name;
343 new_ri->is_from_addr = true;
344 elm_object_text_set(ugd->add_me_btn, N_("Remove me"));
345 ugd->me_added = true;
349 elm_object_item_data_set(item, new_ri);
352 if (obj == ugd->to_mbe) {
353 ugd->to_recipients_cnt++;
354 } else if (obj == ugd->cc_mbe) {
355 ugd->cc_recipients_cnt++;
356 } else if (obj == ugd->bcc_mbe) {
357 ugd->bcc_recipients_cnt++;
360 if ((obj == ugd->to_mbe) || (obj == ugd->cc_mbe) || (obj == ugd->bcc_mbe)) {
361 if (ugd->bSendBtnDisabled && !_composer_check_recipient_is_empty(ugd)) {
362 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
363 elm_object_disabled_set(ugd->send_btm_btn, EINA_FALSE);
364 ugd->bSendBtnDisabled = false;
369 void _composer_mbe_deleted_cb(void *data, Evas_Object *obj, void *event_info)
373 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
374 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
376 if (obj == ugd->to_mbe) {
378 char *addr = elm_entry_markup_to_utf8((char *)elm_object_item_text_get(item));
379 debug_log("utf8 address : %s", addr);
381 EmailRecpInfo *from_ri = NULL;
382 Elm_Object_Item *from_item = NULL;
383 from_item = elm_multibuttonentry_first_item_get(ugd->from_mbe);
386 from_ri = elm_object_item_data_get(from_item);
388 debug_log("from_ri = %s", from_ri->email_list[0].email_addr);
391 debug_log("ugd->me_added = %d", ugd->me_added);
392 if (ugd->me_added == true) {
393 debug_log("account name = %s", ugd->account_info->account_name);
395 if (g_strcmp0(addr, from_ri->email_list[0].email_addr) == 0) {
396 ugd->me_added = false;
397 elm_object_text_set(ugd->add_me_btn, N_("Add me"));
400 if (g_strcmp0(addr, ugd->account_info->account_name) == 0) {
401 ugd->me_added = false;
402 elm_object_text_set(ugd->add_me_btn, N_("Add me"));
407 if (ugd->to_recipients_cnt > 0)
408 ugd->to_recipients_cnt--;
414 } else if (obj == ugd->cc_mbe) {
417 if (ugd->cc_recipients_cnt > 0)
418 ugd->cc_recipients_cnt--;
419 } else if (obj == ugd->bcc_mbe) {
420 debug_log("bcc_mbe");
422 if (ugd->bcc_recipients_cnt > 0)
423 ugd->bcc_recipients_cnt--;
426 if ((obj == ugd->to_mbe) || (obj == ugd->cc_mbe) || (obj == ugd->bcc_mbe)) {
427 if (!ugd->bSendBtnDisabled && _composer_check_recipient_is_empty(ugd)) {
428 elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
429 elm_object_disabled_set(ugd->send_btm_btn, EINA_TRUE);
430 ugd->bSendBtnDisabled = true;
435 Eina_Bool _composer_unfocus_selected_mbe(void *data)
439 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
441 debug_log("selected_entry = %x, to_mbe_entry = %x, cc_mbe_entry = %x, bcc_mbe_entry = %x",
442 ugd->selected_entry, ugd->to_mbe_entry, ugd->cc_mbe_entry, ugd->bcc_mbe_entry);
444 if (ugd->selected_entry == ugd->to_mbe_entry) {
446 elm_object_focus_set(ugd->to_mbe, EINA_FALSE);
447 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
449 elm_object_focus_set(ugd->cc_mbe, EINA_FALSE);
450 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
451 debug_log("bcc_mbe");
452 elm_object_focus_set(ugd->bcc_mbe, EINA_FALSE);
455 if (ugd->mbe_unfocus_timer) {
456 ecore_timer_del(ugd->mbe_unfocus_timer);
457 ugd->mbe_unfocus_timer = NULL;
463 void _composer_mbe_selected_cb(void *data, Evas_Object *obj, void *event_info)
467 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
470 EmailRecpInfo *ri = NULL;
472 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
474 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
476 debug_log("is_contact_info = %d", ri->is_contact_info);
477 debug_log("is_always_bcc = %d", ri->is_always_bcc);
478 debug_log("is_from_addr = %d", ri->is_from_addr);
480 if (obj == ugd->from_mbe) {
481 debug_log("from selected");
483 _composer_from_show_popup(ugd);
487 ugd->is_mbe_selected = true;
489 index = ri->selected_email_idx;
491 Evas_Object *pu_list;
493 if (ugd->composer_popup) {
494 evas_object_del(ugd->composer_popup);
495 ugd->composer_popup = NULL;
498 Evas_Object * popup = elm_popup_add(ugd->win_main);
499 elm_object_style_set(popup, "min_menustyle");
500 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
501 ugd->popup_list = eina_list_append(ugd->popup_list, popup);
503 debug_log("display_name:%s, index:%d", ri->display_name, index);
504 if (ri->display_name) {
505 char *email_str = g_strconcat(ri->display_name, " <", ri->email_list[index].email_addr, ">", NULL);
506 char *contact_str = elm_entry_utf8_to_markup(email_str);
507 debug_log("email_str:%s", email_str);
508 debug_log("contact_str:%s", contact_str);
509 elm_object_part_text_set(popup, "title,text", contact_str);
512 elm_object_part_text_set(popup, "title,text", ri->email_list[index].email_addr);
515 Evas_Object *btn_close = elm_button_add(popup);
516 elm_object_style_set(btn_close, "popup_button/default");
517 elm_object_text_set(btn_close, dgettext("sys_string", "IDS_COM_POP_CLOSE"));
518 elm_object_part_content_set(popup, "button1", btn_close);
519 evas_object_smart_callback_add(btn_close, "clicked", _composer_popup_response_cb, ugd);
521 pu_list = elm_list_add(popup);
522 elm_list_mode_set(pu_list, ELM_LIST_EXPAND);
524 elm_list_item_append(pu_list, dgettext("sys_string", "IDS_COM_SK_DELETE"), NULL, NULL, _composer_mbe_popup_delete_cb, ugd);
525 elm_list_item_append(pu_list, dgettext("sys_string", "IDS_COM_SK_EDIT"), NULL, NULL, _composer_mbe_popup_edit_cb, ugd);
527 if (obj != ugd->to_mbe)
528 elm_list_item_append(pu_list, _("IDS_EMAIL_BODY_MOVE_TO_TO"), NULL, NULL, _composer_mbe_popup_move_to_to_cb, ugd);
529 if (obj != ugd->cc_mbe)
530 elm_list_item_append(pu_list, _("IDS_EMAIL_OPT_MOVE_TO_CC"), NULL, NULL, _composer_mbe_popup_move_to_cc_cb, ugd);
531 if (obj != ugd->bcc_mbe)
532 elm_list_item_append(pu_list, _("IDS_EMAIL_OPT_MOVE_TO_BCC"), NULL, NULL, _composer_mbe_popup_move_to_bcc_cb, ugd);
534 debug_log("email_cnt = %d", ri->email_cnt);
535 if (ri->is_contact_info == true) {
536 if (ri->email_cnt > 1) {
537 elm_list_item_append(pu_list, _("IDS_EMAIL_OPT_CHANGE_EMAIL_ADDRESS_ABB"), NULL, NULL, _composer_mbe_popup_change_addr_cb, ugd);
541 elm_list_go(pu_list);
542 elm_object_content_set(popup, pu_list);
543 evas_object_show(popup);
544 elm_object_focus_set(popup, EINA_TRUE);
546 ugd->composer_popup = popup;
547 debug_log("composer_popup = %x, is_mbe_selected = %d", ugd->composer_popup, ugd->is_mbe_selected);
551 void _composer_mbe_focused_cb(void *data, Evas_Object *obj, void *event_info)
555 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
557 debug_log("focus_status: %d", ugd->focus_status);
559 if (COMPOSER_FOCUS_STATUS_NONE == ugd->focus_status) {
560 if (obj == ugd->to_mbe) {
561 edje_object_signal_emit(_EDJ(ugd->to_ly), "show.button", "*");
563 else if (obj == ugd->cc_mbe) {
564 edje_object_signal_emit(_EDJ(ugd->cc_ly), "show.button", "*");
566 else if (obj == ugd->bcc_mbe) {
567 edje_object_signal_emit(_EDJ(ugd->bcc_ly), "show.button", "*");
570 _composer_attachment_contract_items(ugd);
571 elm_multibuttonentry_expanded_set(obj, TRUE);
573 ugd->selected_entry = elm_multibuttonentry_entry_get(obj);
574 debug_log("MBE editable:%d", elm_multibuttonentry_editable_get(obj));
575 elm_layout_sizing_eval(ugd->c_layout);
577 if (ugd->selected_entry == ugd->body_ewkview) {
578 if (EINA_TRUE == elm_object_focus_get(ugd->to_mbe))
579 elm_object_focus_set(ugd->to_mbe, EINA_FALSE);
580 else if (EINA_TRUE == elm_object_focus_get(ugd->cc_mbe))
581 elm_object_focus_set(ugd->cc_mbe, EINA_FALSE);
582 else if (EINA_TRUE == elm_object_focus_get(ugd->bcc_mbe))
583 elm_object_focus_set(ugd->bcc_mbe, EINA_FALSE);
588 void _composer_mbe_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
592 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
594 debug_log("composer_popup = %x, is_mbe_selected = %d", ugd->composer_popup, ugd->is_mbe_selected);
596 _composer_ps_stop(ugd);
597 ugd->sc_timer = ecore_timer_add(0.5, _composer_ps_scroll_pop, ugd);
598 if (ugd->is_mbe_selected)
602 if (ugd->focus_status == COMPOSER_FOCUS_STATUS_SELECTED) {
603 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_FALSE); // block the focus not to open IME.
604 ugd->focus_status = COMPOSER_FOCUS_STATUS_NONE;
608 debug_log("obj = %x, to_mbe = %x, cc_mbe = %x, bcc_mbe = %x", obj, ugd->to_mbe, ugd->cc_mbe, ugd->bcc_mbe);
609 if (obj == ugd->to_mbe) {
610 edje_object_signal_emit(_EDJ(ugd->to_ly), "hide.button", "*");
612 else if (obj == ugd->cc_mbe) {
613 edje_object_signal_emit(_EDJ(ugd->cc_ly), "hide.button", "*");
615 else if (obj == ugd->bcc_mbe) {
616 edje_object_signal_emit(_EDJ(ugd->bcc_ly), "hide.button", "*");
619 elm_multibuttonentry_expanded_set(obj, FALSE);
622 Eina_Bool _composer_mbe_verified_item_cb(Evas_Object *obj, const char *item_label, void *item_data, void *data)
626 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
629 debug_log("Item_label is NULL");
634 debug_log("Normally Added");
638 debug_log("item_label = %s", item_label);
640 debug_log("is_recipient_duplicated:%d", ugd->is_recipient_duplicated);
641 if (ugd->is_recipient_duplicated == TRUE) {
642 ugd->is_recipient_duplicated = FALSE;
646 if (_composer_is_valid_email(item_label)) {
647 EmailRecpInfo *ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
648 ri->selected_email_idx = 0;
649 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", item_label);
650 ri->display_name = NULL;
652 ri->is_contact_info = false;
653 ri->is_always_bcc = false;
654 ri->is_from_addr = false;
656 if (_composer_check_recipient_is_duplicated(ugd, obj, ri)) {
657 if (ugd->composer_noti) {
658 evas_object_del(ugd->composer_noti);
659 ugd->composer_noti = NULL;
661 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"),
662 0, NULL, NULL, 1.5, _composer_noti_response_cb);
668 char msg[MAX_STR_LEN] = { 0, };
669 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
671 if (obj == ugd->to_mbe) {
672 if (ugd->to_recipients_cnt >= MAX_RECIPIENT_COUNT) {
673 if (ugd->composer_noti) {
674 evas_object_del(ugd->composer_noti);
675 ugd->composer_noti = NULL;
677 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), msg,
678 0, NULL, NULL, 1.0, _composer_noti_response_cb);
683 } else if (obj == ugd->cc_mbe) {
684 if (ugd->cc_recipients_cnt >= MAX_RECIPIENT_COUNT) {
685 if (ugd->composer_noti) {
686 evas_object_del(ugd->composer_noti);
687 ugd->composer_noti = NULL;
689 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), msg,
690 0, NULL, NULL, 1.0, _composer_noti_response_cb);
695 } else if (obj == ugd->bcc_mbe) {
696 if (ugd->bcc_recipients_cnt >= MAX_RECIPIENT_COUNT) {
697 if (ugd->composer_noti) {
698 evas_object_del(ugd->composer_noti);
699 ugd->composer_noti = NULL;
701 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), msg,
702 0, NULL, NULL, 1.0, _composer_noti_response_cb);
710 debug_log("Invalid Address");
712 if (ugd->composer_noti) {
713 evas_object_del(ugd->composer_noti);
714 ugd->composer_noti = NULL;
716 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
717 0, NULL, NULL, 1.0, _composer_noti_response_cb);
725 debug_log("err-return");
727 elm_entry_cursor_end_set(elm_multibuttonentry_entry_get(obj));
729 if (_composer_check_popup_exist(ugd))
730 elm_object_focus_set(ugd->composer_noti, EINA_TRUE);
735 void _composer_mbe_popup_delete_cb(void *data, Evas_Object *obj, void *event_info)
739 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
741 Evas_Object *mbe = NULL;
743 if (ugd->selected_entry == ugd->to_mbe_entry) {
744 debug_log("@@@ to MBE @@@");
746 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
747 debug_log("@@@ cc MBE @@@");
749 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
750 debug_log("@@@ bcc MBE @@@");
754 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
756 if (item && mbe == ugd->bcc_mbe) {
757 elm_object_item_data_get(item);
760 elm_object_item_del(item);
763 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
764 if (ugd->composer_noti) {
765 evas_object_del(ugd->composer_noti);
766 ugd->composer_noti = NULL;
768 if (ugd->composer_popup) {
769 evas_object_del(ugd->composer_popup);
770 ugd->composer_popup = NULL;
772 ugd->is_mbe_selected = false;
775 void _composer_mbe_popup_edit_cb(void *data, Evas_Object *obj, void *event_info)
779 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
781 EmailRecpInfo *ri = NULL;
783 Evas_Object *mbe = NULL;
785 if (ugd->selected_entry == ugd->to_mbe_entry) {
787 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
789 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
793 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
794 debug_log("item:%p", item);
798 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
801 index = ri->selected_email_idx;
803 debug_log("ri is NULL");
807 elm_object_item_del(item);
809 debug_log("email_addr = %s", ri->email_list[index].email_addr);
810 elm_entry_entry_set(ugd->selected_entry, ri->email_list[index].email_addr);
811 elm_entry_cursor_end_set(ugd->selected_entry);
817 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
818 if (ugd->composer_noti) {
819 evas_object_del(ugd->composer_noti);
820 ugd->composer_noti = NULL;
822 if (ugd->composer_popup) {
823 evas_object_del(ugd->composer_popup);
824 ugd->composer_popup = NULL;
826 ugd->is_mbe_selected = false;
831 void _composer_mbe_popup_move_to_to_cb(void *data, Evas_Object *obj, void *event_info)
835 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
836 Evas_Object *mbe = NULL;
837 EmailRecpInfo *ri = NULL;
839 if (ugd->selected_entry == ugd->to_mbe_entry) {
841 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
843 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
847 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
849 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
851 elm_object_item_del(item);
852 if (ri->display_name)
853 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
855 elm_multibuttonentry_item_append(ugd->to_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri);
858 debug_log("ri is NULL");
862 elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
865 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
867 if (ugd->composer_noti) {
868 evas_object_del(ugd->composer_noti);
869 ugd->composer_noti = NULL;
872 if (ugd->composer_popup) {
873 evas_object_del(ugd->composer_popup);
874 ugd->composer_popup = NULL;
876 ugd->is_mbe_selected = false;
879 void _composer_mbe_popup_move_to_cc_cb(void *data, Evas_Object *obj, void *event_info)
883 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
884 Evas_Object *mbe = NULL;
885 EmailRecpInfo *ri = NULL;
887 if (ugd->selected_entry == ugd->to_mbe_entry) {
889 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
891 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
895 if (!ugd->cc_added) {
896 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
897 email_composer_create_cc_field(ugd);
898 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
899 email_composer_create_bcc_field(ugd);
900 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
901 ugd->b_cc_bcc = false;
904 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
906 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
908 elm_object_item_del(item);
909 if (ri->display_name)
910 elm_multibuttonentry_item_append(ugd->cc_mbe, ri->display_name, NULL, ri);
912 elm_multibuttonentry_item_append(ugd->cc_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri);
915 debug_log("ri is NULL");
919 elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
922 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
924 if (ugd->composer_noti) {
925 evas_object_del(ugd->composer_noti);
926 ugd->composer_noti = NULL;
929 if (ugd->composer_popup) {
930 evas_object_del(ugd->composer_popup);
931 ugd->composer_popup = NULL;
933 ugd->is_mbe_selected = false;
936 void _composer_mbe_popup_move_to_bcc_cb(void *data, Evas_Object *obj, void *event_info)
940 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
941 Evas_Object *mbe = NULL;
942 EmailRecpInfo *ri = NULL;
944 if (ugd->selected_entry == ugd->to_mbe_entry) {
946 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
948 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
952 if (!ugd->bcc_added) {
953 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
954 email_composer_create_bcc_field(ugd);
955 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
956 email_composer_create_cc_field(ugd);
957 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
958 ugd->b_cc_bcc = false;
961 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
963 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
965 elm_object_item_del(item);
966 if (ri->display_name)
967 elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->display_name, NULL, ri);
969 elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri);
972 debug_log("ri is NULL");
976 elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
979 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
981 if (ugd->composer_noti) {
982 evas_object_del(ugd->composer_noti);
983 ugd->composer_noti = NULL;
986 if (ugd->composer_popup) {
987 evas_object_del(ugd->composer_popup);
988 ugd->composer_popup = NULL;
990 ugd->is_mbe_selected = false;
993 void _composer_mbe_popup_change_addr_cb(void *data, Evas_Object *obj, void *event_info)
997 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
999 EmailRecpInfo *ri = NULL;
1001 Evas_Object *mbe = NULL;
1005 if (ugd->selected_entry == ugd->to_mbe_entry) {
1007 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
1009 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
1013 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
1014 ugd->selected_item = item;
1015 debug_log("@@@ Elm_Object_Item = %p @@@", item);
1016 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
1018 for (i = 0; i < ri->email_cnt; i++) {
1019 snprintf(email_list[i].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ri->email_list[i].email_addr);
1020 email_list[i].email_type = ri->email_list[i].email_type;
1023 email_cnt = ri->email_cnt;
1025 _composer_mbe_create_change_addr_list(ugd);
1027 if (ugd->popup_list)
1028 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
1030 if (ugd->composer_noti) {
1031 evas_object_del(ugd->composer_noti);
1032 ugd->composer_noti = NULL;
1035 if (ugd->composer_popup) {
1036 evas_object_del(ugd->composer_popup);
1037 ugd->composer_popup = NULL;
1039 ugd->is_mbe_selected = false;
1042 static void _composer_mbe_popup_change_addr_selected_cb(void *data, Evas_Object *obj, void *event_info)
1052 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1054 int selected_idx = 0;
1055 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1058 selected_idx = (int)elm_object_item_data_get(item);
1059 debug_log("selected_idx = %d", selected_idx);
1060 debug_log("email_addr:%s", email_list[selected_idx].email_addr);
1062 EmailRecpInfo *ri = NULL;
1063 Evas_Object *mbe = NULL;
1065 if (ugd->selected_entry == ugd->to_mbe_entry) {
1067 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
1069 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
1073 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
1074 ugd->selected_item = item;
1075 debug_log("@@@ Elm_Object_Item = %p @@@", item);
1076 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
1078 ri->selected_email_idx = selected_idx;
1081 if (ugd->popup_list)
1082 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->change_addr_noti);
1084 if (ugd->change_addr_noti) {
1086 evas_object_del(ugd->change_addr_noti);
1087 ugd->change_addr_noti = NULL;
1091 char *_composer_change_addr_gl_text_get(void *data, Evas_Object *obj, const char *part)
1093 int index = (int)data;
1094 const char *email_str = NULL;
1096 debug_log("label index = %d, email_type = %d", index, email_list[index].email_type);
1098 if (!g_strcmp0(part, "elm.text")) {
1099 if (email_list[index].email_type == 0)
1100 email_str = g_strconcat(_("IDS_EMAIL_OPT_OTHER"), ": ", email_list[index].email_addr, NULL);
1101 else if (email_list[index].email_type == 2)
1102 email_str = g_strconcat(dgettext("sys_string", "IDS_COM_BODY_HOME"), ": ", email_list[index].email_addr, NULL);
1103 else if (email_list[index].email_type == 4)
1104 email_str = g_strconcat(dgettext("sys_string", "IDS_COM_BODY_WORK"), ": ", email_list[index].email_addr, NULL);
1106 email_str = g_strconcat(_("IDS_EMAIL_OPT_OTHER"), ": ", email_list[index].email_addr, NULL);
1108 debug_log("email_type(%d), email_str(%s)", email_list[index].email_type, email_str);
1109 return g_strdup(email_str);
1115 void _composer_mbe_change_addr_response_cb(void *data, Evas_Object *obj, void *event_info)
1119 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1121 Evas_Object *mbe = NULL;
1123 if (ugd->selected_entry == ugd->to_mbe_entry) {
1125 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
1127 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
1131 elm_object_item_data_get(ugd->selected_item);
1133 char *pszBtnText = (char *)elm_object_text_get(obj);
1134 debug_log("selected button text = %s", pszBtnText);
1136 if (ugd->popup_list) {
1137 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1138 debug_log("obj: %p", obj);
1139 debug_log("change_addr_noti: %p", ugd->change_addr_noti);
1141 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->change_addr_noti/*obj*/);
1144 if (ugd->change_addr_noti) {
1145 evas_object_del(ugd->change_addr_noti);
1146 ugd->change_addr_noti = NULL;
1150 void _composer_cancel_send_mail_cb(void *data, Evas_Object *obj, void *event_info)
1154 debug_log("data is NULL");
1158 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1160 int err = email_cancel_sending_mail(ugd->new_mail_info->mail_data->mail_id);
1162 _composer_webkit_set_body_script(data);
1163 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
1164 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
1165 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
1166 elm_object_disabled_set(ugd->send_btm_btn, EINA_FALSE);
1167 elm_object_disabled_set(ugd->cancel_btm_btn, EINA_FALSE);
1169 if (err != EMAIL_ERROR_NONE) {
1170 debug_warning("email_engine_cancel_send_mail failed - err(%d)", err);
1172 if (ugd->composer_noti) {
1173 evas_object_del(ugd->composer_noti);
1174 ugd->composer_noti = NULL;
1177 ugd->send_result = COMPOSER_ERROR_SEND_FAIL;
1178 debug_log("Cancelled to send email");
1182 Eina_Bool _composer_send_mail_cb(void *data)
1186 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1188 if (ugd->send_timer) {
1189 debug_log("delete send_timer");
1190 ecore_timer_del(ugd->send_timer);
1191 ugd->send_timer = NULL;
1194 ugd->send_result = _composer_send_mail(ugd);
1196 if (ugd->selected_entry == ugd->body_ewkview) {
1197 evas_object_focus_set(ugd->body_ewkview, EINA_FALSE);
1199 Ecore_IMF_Context *imf_context = NULL;
1200 imf_context = elm_entry_imf_context_get(ugd->selected_entry);
1202 ecore_imf_context_input_panel_hide(imf_context);
1205 if (ugd->composer_noti) {
1206 evas_object_del(ugd->composer_noti);
1207 ugd->composer_noti = NULL;
1210 ugd->composer_noti = elm_popup_add(ugd->main_layout);
1211 debug_log("composer_noti: %p", ugd->composer_noti);
1212 if (!ugd->composer_noti) {
1213 debug_log("elm_popup_add returns NULL");
1217 evas_object_size_hint_weight_set(ugd->composer_noti, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1219 if (ugd->send_result == COMPOSER_ERROR_NONE) {
1220 char temp_text[128];
1221 snprintf(temp_text, sizeof(temp_text), "%s", dgettext("sys_string", "IDS_COM_POP_SENDING"));
1222 elm_object_part_text_set(ugd->composer_noti, "title,text", temp_text);
1224 Evas_Object *progressbar = elm_progressbar_add(ugd->composer_noti);
1225 elm_object_style_set(progressbar, "list_process");//"pending_list"//"list_progress"
1226 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
1227 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
1228 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1229 evas_object_show(progressbar);
1230 elm_progressbar_pulse(progressbar, EINA_TRUE);
1231 elm_object_content_set(ugd->composer_noti, progressbar);
1233 Evas_Object *btn1 = elm_button_add(ugd->composer_noti);
1234 elm_object_style_set(btn1, "popup_button/default");
1235 elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
1236 elm_object_part_content_set(ugd->composer_noti, "button1", btn1);
1237 evas_object_smart_callback_add(btn1, "clicked", _composer_cancel_send_mail_cb, ugd);
1240 After sending, not to focus mbe.
1242 if (!ugd->b_sending)
1243 ugd->b_sending = true;
1245 evas_object_show(ugd->composer_noti);
1246 ugd->send_timer = ecore_timer_add(2.0, _composer_send_popup_finish_cb, ugd);
1247 } else if (ugd->send_result == COMPOSER_ERROR_SEND_FAIL) {
1248 if (ugd->composer_noti) {
1249 evas_object_del(ugd->composer_noti);
1250 ugd->composer_noti = NULL;
1252 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
1253 _("IDS_EMAIL_POP_UNABLE_TO_SEND_EMAIL"), 0, NULL, NULL, 1.5, _composer_fail_to_send_popup_cb);
1259 Eina_Bool _composer_region_show_cb(void *data)
1261 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1263 Evas_Coord sc_width = 0, sc_height = 0;
1264 elm_scroller_region_get(ugd->main_scroller, 0, 0, &sc_width, &sc_height);
1266 Evas_Coord from_height = 0;
1268 evas_object_geometry_get(ugd->from_ly, NULL, NULL, NULL, &from_height);
1270 Evas_Coord to_height = 0;
1271 evas_object_geometry_get(ugd->to_ly, NULL, NULL, NULL, &to_height);
1273 Evas_Coord cc_height = 0;
1275 evas_object_geometry_get(ugd->cc_ly, NULL, NULL, NULL, &cc_height);
1277 Evas_Coord bcc_height = 0;
1279 evas_object_geometry_get(ugd->bcc_ly, NULL, NULL, NULL, &bcc_height);
1281 Evas_Coord sub_height = 0;
1282 evas_object_geometry_get(ugd->subject_ly, NULL, NULL, NULL, &sub_height);
1284 Evas_Coord att_height = 0;
1285 if (ugd->attachment_contracted_item)
1286 evas_object_geometry_get(ugd->attachment_contracted_item, NULL, NULL, NULL, &att_height);
1288 debug_log("scroller = w:%d, h:%d", sc_width, sc_height);
1289 debug_log("from_height = %d", from_height);
1290 debug_log(" to_height = %d", to_height);
1291 debug_log(" cc_height = %d", cc_height);
1292 debug_log(" bcc_height = %d", bcc_height);
1293 debug_log(" sub_height = %d", sub_height);
1294 debug_log(" att_height = %d", att_height);
1296 // 10 means "top_line" size. it should be modified. it should get from edc part.
1297 if (ugd->selected_entry == ugd->to_mbe_entry) {
1298 debug_log("selected_entry = to_mbe_entry");
1299 elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height, sc_width, sc_height);
1300 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
1301 debug_log("selected_entry = cc_mbe_entry");
1302 elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height, sc_width, sc_height);
1303 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
1304 debug_log("selected_entry = bcc_mbe_entry");
1305 elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height, sc_width, sc_height);
1306 } else if (ugd->selected_entry == ugd->subject_entry) {
1307 debug_log("selected_entry = subject_entry");
1308 elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height, sc_width, sc_height);
1309 } else if (ugd->selected_entry == ugd->attachment_contracted_item) {
1310 debug_log("selected_entry = attachment_contracted_item");
1311 elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height + sub_height, sc_width, sc_height);
1312 } else if (ugd->selected_entry == ugd->body_ewkview) {
1313 debug_log("selected_entry = body_ewkview");
1314 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);
1317 return ECORE_CALLBACK_CANCEL;
1320 Eina_Bool _composer_bringin_cb(void *data)
1322 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1324 Evas_Coord sc_width = 0, sc_height = 0;
1325 elm_scroller_region_get(ugd->main_scroller, 0, 0, &sc_width, &sc_height);
1327 Evas_Coord from_height = 0;
1329 evas_object_geometry_get(ugd->from_ly, NULL, NULL, NULL, &from_height);
1331 Evas_Coord to_height = 0;
1332 evas_object_geometry_get(ugd->to_ly, NULL, NULL, NULL, &to_height);
1334 Evas_Coord cc_height = 0;
1336 evas_object_geometry_get(ugd->cc_ly, NULL, NULL, NULL, &cc_height);
1338 Evas_Coord bcc_height = 0;
1340 evas_object_geometry_get(ugd->bcc_ly, NULL, NULL, NULL, &bcc_height);
1342 Evas_Coord sub_height = 0;
1343 evas_object_geometry_get(ugd->subject_ly, NULL, NULL, NULL, &sub_height);
1345 Evas_Coord att_height = 0;
1346 if (ugd->attachment_contracted_item)
1347 evas_object_geometry_get(ugd->attachment_contracted_item, NULL, NULL, NULL, &att_height);
1349 debug_log("scroller = w:%d, h:%d", sc_width, sc_height);
1350 debug_log("from_height = %d", from_height);
1351 debug_log(" to_height = %d", to_height);
1352 debug_log(" cc_height = %d", cc_height);
1353 debug_log(" bcc_height = %d", bcc_height);
1354 debug_log(" sub_height = %d", sub_height);
1355 debug_log(" att_height = %d", att_height);
1357 // 10 means "top_line" size. it should be modified. it should get from edc part.
1358 if (ugd->selected_entry == ugd->to_mbe_entry) {
1359 debug_log("selected_entry = to_mbe_entry");
1360 elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height, sc_width, sc_height);
1361 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
1362 debug_log("selected_entry = cc_mbe_entry");
1363 elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height, sc_width, sc_height);
1364 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
1365 debug_log("selected_entry = bcc_mbe_entry");
1366 elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height, sc_width, sc_height);
1367 } else if (ugd->selected_entry == ugd->subject_entry) {
1368 debug_log("selected_entry = subject_entry");
1369 elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height, sc_width, sc_height);
1370 } else if (ugd->selected_entry == ugd->attachment_contracted_item) {
1371 debug_log("selected_entry = attachment_contracted_item");
1372 elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height + sub_height, sc_width, sc_height);
1373 } else if (ugd->selected_entry == ugd->body_ewkview) {
1374 debug_log("selected_entry = body_ewkview");
1375 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);
1378 if (ugd->bringin_timer) {
1379 ecore_timer_del(ugd->bringin_timer);
1380 ugd->bringin_timer = NULL;
1383 return ECORE_CALLBACK_CANCEL;
1386 Eina_Bool _composer_mbe_popup_del(void *data)
1389 Evas_Object *obj = (Evas_Object *)data;
1391 evas_object_del(obj);
1397 Eina_Bool _composer_mbe_create_change_addr_list(EmailComposerUGD *ugd)
1401 if (ugd->change_addr_noti) {
1402 evas_object_del(ugd->change_addr_noti);
1403 ugd->change_addr_noti = NULL;
1405 ugd->change_addr_noti = _composer_create_noti_with_list(ugd, false, _("IDS_EMAIL_HEADER_SELECT_EMAIL_ADDRESS"), NULL, 1,
1406 dgettext("sys_string", "IDS_COM_SK_CANCEL"), NULL, 0.0, _composer_mbe_change_addr_response_cb);
1409 Elm_Object_Item *gen_item;
1410 Evas_Object *genlist;
1413 itc.item_style = "1text";
1414 itc.func.text_get = _composer_change_addr_gl_text_get;
1415 itc.func.content_get = NULL;
1416 itc.func.state_get = NULL;
1417 itc.func.del = NULL;
1419 genlist = elm_genlist_add(ugd->change_addr_noti);
1421 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1422 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1424 debug_log("ri->email_cnt = %d", email_cnt);
1426 for (index = 0; index < email_cnt; index++) {
1427 gen_item = elm_genlist_item_append(genlist, &itc, (void *)index, NULL, ELM_GENLIST_ITEM_NONE, _composer_mbe_popup_change_addr_selected_cb, ugd);
1429 elm_object_item_data_set(gen_item, (void *)index);
1430 elm_genlist_item_update(gen_item);
1433 elm_genlist_tree_effect_enabled_set(genlist, EINA_FALSE);
1435 #ifdef _POPUP_WITH_LIST
1436 debug_log("index:%d", index);
1439 Evas_Object *box = elm_box_add(ugd->change_addr_noti);
1440 evas_object_size_hint_min_set(box, 610 * elm_config_scale_get(), 113 * index * elm_config_scale_get());
1441 evas_object_show(genlist);
1442 elm_box_pack_end(box, genlist);
1443 elm_object_content_set(ugd->change_addr_noti, box);
1445 elm_object_content_set(ugd->change_addr_noti, genlist);
1451 Eina_Bool _composer_send_popup_finish_cb(void *data)
1454 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1456 _composer_popup_end(ugd, ugd->send_result);
1460 void _composer_fail_to_send_popup_cb(void *data, Evas_Object *obj, void *event_info)
1463 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1465 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE);
1467 if (ugd->popup_list) {
1468 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1469 debug_log("obj: %p", obj);
1470 debug_log("composer_noti: %p", ugd->composer_noti);
1472 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1475 if (ugd->composer_noti) {
1476 evas_object_del(ugd->composer_noti);
1477 ugd->composer_noti = NULL;
1480 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
1481 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
1482 elm_object_disabled_set(ugd->send_btm_btn, EINA_FALSE);
1483 elm_object_disabled_set(ugd->cancel_btm_btn, EINA_FALSE);
1485 ugd->bSendBtnDisabled = false;
1488 void _composer_check_email_address(EmailComposerUGD *ugd, Evas_Object *entry)
1492 char *temp = elm_entry_markup_to_utf8(elm_entry_entry_get(entry));
1497 debug_log("temp = %s, edit_mode = %d", temp, edit_mode);
1499 if (edit_mode == true) {
1505 if (strlen(temp) == 0) {
1507 _composer_ps_stop(ugd);
1508 ugd->sc_timer = ecore_timer_add(0.5, _composer_ps_scroll_pop, ugd);
1510 } else if (strlen(temp)) {
1511 debug_log("temp = %s", temp);
1513 memset(ugd->ps_keyword, 0x00, sizeof(ugd->ps_keyword));
1514 strncpy(ugd->ps_keyword, temp, sizeof(ugd->ps_keyword) - 1);
1516 _composer_ps_add_timer(ugd);
1522 void _composer_check_entry_max(EmailComposerUGD *ugd, Evas_Object *entry, int max_len)
1525 const char *temp = elm_entry_entry_get(entry);
1527 debug_log("subject len = %d", strlen(temp));
1528 if (strlen(temp) >= max_len) {
1529 debug_log("Subject length is Over");
1531 char subject[MAX_SUBJECT_LEN] = { 0, };
1532 strncpy(subject, temp, sizeof(subject) - 1);
1534 elm_entry_entry_set(entry, subject);
1535 elm_entry_cursor_end_set(entry);
1537 if (ugd->composer_noti) {
1538 evas_object_del(ugd->composer_noti);
1539 ugd->composer_noti = NULL;
1541 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);
1545 void _composer_from_show_popup(EmailComposerUGD *ugd)
1553 if (ugd->composer_noti) {
1554 evas_object_del(ugd->composer_noti);
1555 ugd->composer_noti = NULL;
1557 ugd->composer_noti = _composer_create_noti_with_list(ugd, false, _("IDS_EMAIL_BODY_FROM"), NULL, 1, dgettext("sys_string", "IDS_COM_SK_OK"), NULL, 0.0, _composer_from_change_response_cb);
1559 from_itc.item_style = "email.2text.3icon.3";
1560 from_itc.func.text_get = _composer_from_gl_text_get;
1561 from_itc.func.content_get = _composer_from_gl_content_get;
1562 from_itc.func.state_get = NULL;
1563 from_itc.func.del = NULL;
1565 elm_genlist_clear(ugd->account_gen_list);
1566 ugd->account_gen_list = elm_genlist_add(ugd->composer_noti);
1567 elm_object_theme_set(ugd->account_gen_list, ugd->th);
1569 evas_object_size_hint_weight_set(ugd->account_gen_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1570 evas_object_size_hint_align_set(ugd->account_gen_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1572 for (acc_index = 0; acc_index < ugd->account_info->account_count; acc_index++) {
1573 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);
1576 elm_genlist_tree_effect_enabled_set(ugd->account_gen_list, EINA_FALSE);
1578 #ifdef _POPUP_WITH_LIST
1579 debug_log("acc_index:%d", acc_index);
1582 Evas_Object *box = elm_box_add(ugd->composer_noti);
1583 evas_object_size_hint_min_set(box, 610 * elm_config_scale_get(), 120 * acc_index * elm_config_scale_get());
1584 evas_object_show(ugd->account_gen_list);
1585 elm_box_pack_end(box, ugd->account_gen_list);
1586 elm_object_content_set(ugd->composer_noti, box);
1588 elm_object_content_set(ugd->composer_noti, ugd->account_gen_list);
1592 char *_composer_from_gl_text_get(void *data, Evas_Object *obj, const char *part)
1594 int index = (int)data;
1596 debug_log("label index = %d", index);
1598 if (!strncmp(part, "elm.text.1", 10)) {
1599 debug_log("email_addr = %s", g_ugd->account_info->account_list[index].account_name);
1600 return g_strdup(g_ugd->account_info->account_list[index].account_name);
1601 } else if (!strncmp(part, "elm.text.2", 10)) {
1602 debug_log("email_addr = %s", g_ugd->account_info->account_list[index].user_email_address);
1603 return g_strdup(g_ugd->account_info->account_list[index].user_email_address);
1605 debug_log("part is invalid");
1611 Evas_Object *_composer_from_gl_content_get(void *data, Evas_Object *obj, const char *part)
1613 int count = (int)data;
1615 debug_log("count = %d", count);
1616 debug_log("account_id = %d", g_ugd->account_info->account_list[count].account_id);
1617 debug_log("default account_id = %d", g_ugd->account_info->account_id);
1619 if (!strncmp(part, "elm.icon.1", 10)) {
1620 g_ugd->account_info->account_rd[count] = elm_radio_add(obj);
1621 elm_radio_state_value_set(g_ugd->account_info->account_rd[count], count);
1624 g_ugd->account_info->account_rdg = g_ugd->account_info->account_rd[count];
1626 elm_radio_group_add(g_ugd->account_info->account_rd[count], g_ugd->account_info->account_rdg);
1628 if (g_ugd->account_info->account_list[count].account_id == g_ugd->account_info->account_id)
1629 elm_radio_value_set(g_ugd->account_info->account_rdg, count);
1631 evas_object_smart_callback_add(g_ugd->account_info->account_rd[count], "changed", _composer_from_radio_cb, g_ugd);
1633 return g_ugd->account_info->account_rd[count];
1634 } else if (!strncmp(part, "elm.icon.2", 10)) {
1635 Evas_Object *icon = elm_icon_add(obj);
1637 debug_log("logo_icon_path:%s", g_ugd->account_info->account_list[count].logo_icon_path);
1638 if (g_ugd->account_info->account_list[count].logo_icon_path)
1639 elm_image_file_set(icon, g_ugd->account_info->account_list[count].logo_icon_path, NULL);
1641 elm_image_file_set(icon, ACCOUNT_ICON_OTHERS, NULL);
1642 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1645 } else if (!strncmp(part, "elm.swallow.colorbar", 20)) {
1646 account_user_data_t *ud = (account_user_data_t *)g_ugd->account_info->account_list[count].user_data;
1647 unsigned int val = ud->index_color;
1648 int r = (val & 0xff000000) >> 24;
1649 int g = (val & 0x00ff0000) >> 16;
1650 int b = (val & 0x0000ff00) >> 8;
1651 int a = val & 0x000000ff;
1653 Evas_Object *color_bar = evas_object_rectangle_add(evas_object_evas_get(obj));
1654 evas_object_size_hint_fill_set(color_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
1655 evas_object_color_set(color_bar, r, g, b, a);
1659 debug_log("part is invalid");
1665 static void _composer_from_gl_sel(void *data, Evas_Object *obj, void *event_info)
1667 debug_log("index:%d", (int)data);
1669 int index = (int)data;
1671 elm_radio_value_set(g_ugd->account_info->account_rdg, index);
1673 _composer_from_close_response_cb(g_ugd);
1676 static void _composer_from_change_response_cb(void *data, Evas_Object *obj, void *event_info)
1678 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1680 debug_log("composer_noti : %p", ugd->composer_noti);
1682 char *pszBtnText = (char *)elm_object_text_get(obj);
1683 debug_log("selected button text = %s", pszBtnText);
1685 _composer_from_close_response_cb(ugd);
1688 static void _composer_from_close_response_cb(EmailComposerUGD *ugd)
1690 debug_log("composer_noti : %p", ugd->composer_noti);
1692 int set_val = elm_radio_value_get(ugd->account_info->account_rdg);
1694 debug_log("set_val = %d", set_val);
1696 ugd->account_info->account_id = ugd->account_info->account_list[set_val].account_id;
1698 if (ugd->account_info->account_name) {
1699 g_free(ugd->account_info->account_name);
1700 ugd->account_info->account_name = NULL;
1703 ugd->account_info->account_name = g_strdup(ugd->account_info->account_list[set_val].user_email_address);
1705 debug_log("account_id = %d", ugd->account_info->account_id);
1707 debug_log("priority = %d, %d", (*ugd->account_info->account).options.priority, ugd->account_info->account_list[set_val].options.priority);
1709 Elm_Object_Item *from_item = NULL;
1710 from_item = elm_multibuttonentry_first_item_get(ugd->from_mbe);
1712 EmailRecpInfo *from_ri = NULL;
1715 from_ri = elm_object_item_data_get(from_item);
1717 debug_log("from_ri = %s", from_ri->email_list[0].email_addr);
1720 debug_log("add_my_address_to_bcc = %d, %d", ugd->account_info->account->options.add_my_address_to_bcc, ugd->account_info->account_list[set_val].options.add_my_address_to_bcc);
1722 debug_log("remove bcc myself if it is");
1723 Elm_Object_Item *bcc_item = NULL;
1724 bcc_item = elm_multibuttonentry_first_item_get(ugd->bcc_mbe);
1727 EmailRecpInfo *bcc_ri = NULL;
1730 bcc_ri = (EmailRecpInfo *) elm_object_item_data_get(bcc_item);
1732 index = bcc_ri->selected_email_idx;
1734 debug_log("bcc_ri email_addr = %s, from_ri email_addr = %s, is_always_bcc = %d", bcc_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr, bcc_ri->is_always_bcc);
1736 if ((g_strcmp0(bcc_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr) == 0) && (bcc_ri->is_always_bcc == true)) {
1737 elm_object_item_del(bcc_item);
1741 bcc_item = elm_multibuttonentry_item_next_get(bcc_item);
1744 debug_log("remove cc myself if it is");
1745 Elm_Object_Item *cc_item = NULL;
1746 cc_item = elm_multibuttonentry_first_item_get(ugd->cc_mbe);
1749 EmailRecpInfo *cc_ri = NULL;
1752 cc_ri = (EmailRecpInfo *) elm_object_item_data_get(cc_item);
1754 index = cc_ri->selected_email_idx;
1756 debug_log("cc_ri email_addr = %s, from_ri email_addr = %s, is_always_bcc = %d", cc_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr, cc_ri->is_always_bcc);
1758 if ((g_strcmp0(cc_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr) == 0) && (cc_ri->is_always_bcc == true)) {
1759 elm_object_item_del(cc_item);
1763 cc_item = elm_multibuttonentry_item_next_get(cc_item);
1766 if (ugd->account_info->account_list[set_val].options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_BCC) {
1767 debug_log("always bcc on");
1768 EmailRecpInfo *new_bcc_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
1770 new_bcc_ri->selected_email_idx = 0;
1771 new_bcc_ri->display_name = ugd->account_info->account_list[set_val].user_display_name;
1772 snprintf(new_bcc_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account_list[set_val].user_email_address);
1773 new_bcc_ri->email_cnt = 1;
1774 new_bcc_ri->is_contact_info = false;
1775 new_bcc_ri->is_always_bcc = true;
1776 new_bcc_ri->is_from_addr = false;
1778 bcc_item = elm_multibuttonentry_first_item_get(ugd->bcc_mbe);
1779 elm_multibuttonentry_item_insert_before(ugd->bcc_mbe, bcc_item, g_strdup(new_bcc_ri->display_name), NULL, new_bcc_ri);
1780 } else if (ugd->account_info->account_list[set_val].options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_CC) {
1781 debug_log("always cc on");
1782 EmailRecpInfo *new_cc_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
1784 new_cc_ri->selected_email_idx = 0;
1785 new_cc_ri->display_name = ugd->account_info->account_list[set_val].user_display_name;
1786 snprintf(new_cc_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account_list[set_val].user_email_address);
1787 new_cc_ri->email_cnt = 1;
1788 new_cc_ri->is_contact_info = false;
1789 new_cc_ri->is_always_bcc = true;
1790 new_cc_ri->is_from_addr = false;
1792 cc_item = elm_multibuttonentry_first_item_get(ugd->cc_mbe);
1793 elm_multibuttonentry_item_insert_before(ugd->cc_mbe, cc_item, g_strdup(new_cc_ri->display_name), NULL, new_cc_ri);
1795 debug_log("always bcc/cc off");
1798 EmailRecpInfo *new_from_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
1800 new_from_ri->selected_email_idx = 0;
1801 new_from_ri->display_name = ugd->account_info->account_list[set_val].user_display_name;
1802 snprintf(new_from_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account_list[set_val].user_email_address);
1803 new_from_ri->email_cnt = 1;
1804 new_from_ri->is_contact_info = false;
1805 new_from_ri->is_always_bcc = false;
1806 new_from_ri->is_from_addr = true;
1808 elm_object_item_del(from_item);
1810 elm_multibuttonentry_item_append(ugd->from_mbe, g_strdup(new_from_ri->display_name), NULL, new_from_ri);
1812 if (ugd->selected_entry == ugd->to_mbe_entry) {
1813 elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
1814 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
1815 elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
1816 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
1817 elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
1820 if (ugd->account_gen_list) {
1821 elm_genlist_clear(ugd->account_gen_list);
1823 evas_object_del(ugd->account_gen_list);
1824 ugd->account_gen_list = NULL;
1827 if (ugd->popup_list) {
1828 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1829 debug_log("composer_noti: %p", ugd->composer_noti);
1831 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
1834 if (ugd->composer_noti) {
1835 debug_log("@@@ ELM_POPUP_RESPONSE_CLOSE @@@");
1836 _composer_popup_delete(ugd->composer_noti);
1837 ugd->composer_noti = NULL;
1841 static void _composer_from_radio_cb(void *data, Evas_Object *obj, void *event_info)
1845 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1848 for (i = 0; i < ugd->account_info->account_count; i++) {
1849 if (obj == ugd->account_info->account_rd[i]) {
1850 debug_log("account_id = %d", ugd->account_info->account_list[i].account_id);
1851 elm_radio_value_set(ugd->account_info->account_rdg, i);
1856 void _composer_select_myemail_popup(EmailComposerUGD *ugd)
1864 if (ugd->composer_noti) {
1865 evas_object_del(ugd->composer_noti);
1866 ugd->composer_noti = NULL;
1868 ugd->composer_noti = _composer_create_noti_with_list(ugd, false, _("IDS_EMAIL_HEADER_SELECT_EMAIL_ADDRESS"), NULL, 1, dgettext("sys_string", "IDS_COM_SK_OK"), NULL, 0.0, _composer_myemail_change_response_cb);
1869 elm_object_focus_set(ugd->composer_noti, EINA_TRUE);
1871 myemail_itc.item_style = "email.2text.3icon.3";
1872 myemail_itc.func.text_get = _composer_myemail_gl_text_get;
1873 myemail_itc.func.content_get = _composer_myemail_gl_content_get;
1874 myemail_itc.func.state_get = NULL;
1875 myemail_itc.func.del = NULL;
1877 elm_genlist_clear(ugd->account_gen_list);
1878 ugd->account_gen_list = elm_genlist_add(ugd->composer_noti);
1879 elm_object_theme_set(ugd->account_gen_list, ugd->th);
1881 evas_object_size_hint_weight_set(ugd->account_gen_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1882 evas_object_size_hint_align_set(ugd->account_gen_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1884 for (acc_index = 0; acc_index < ugd->account_info->account_count; acc_index++) {
1885 elm_genlist_item_append(ugd->account_gen_list, &myemail_itc, (void *)acc_index, NULL, ELM_GENLIST_ITEM_NONE, _composer_myemail_gl_sel, (void *)acc_index);
1888 #ifdef _POPUP_WITH_LIST
1889 debug_log("acc_index:%d", acc_index);
1892 Evas_Object *box = elm_box_add(ugd->composer_noti);
1893 evas_object_size_hint_min_set(box, 610 * elm_config_scale_get(), 120 * acc_index * elm_config_scale_get());
1894 evas_object_show(ugd->account_gen_list);
1895 elm_box_pack_end(box, ugd->account_gen_list);
1896 elm_object_content_set(ugd->composer_noti, box);
1898 elm_object_content_set(ugd->composer_noti, ugd->account_gen_list);
1902 char *_composer_myemail_gl_text_get(void *data, Evas_Object *obj, const char *part)
1904 int index = (int)data;
1906 debug_log("label index = %d", index);
1908 if (!strncmp(part, "elm.text.1", 10)) {
1909 debug_log("email_addr = %s", g_ugd->account_info->account_list[index].account_name);
1910 return g_strdup(g_ugd->account_info->account_list[index].account_name);
1911 } else if (!strncmp(part, "elm.text.2", 10)) {
1912 debug_log("email_addr = %s", g_ugd->account_info->account_list[index].user_email_address);
1913 return g_strdup(g_ugd->account_info->account_list[index].user_email_address);
1915 debug_log("part is invalid");
1921 Evas_Object *_composer_myemail_gl_content_get(void *data, Evas_Object *obj, const char *part)
1923 int count = (int)data;
1925 debug_log("count = %d", count);
1926 debug_log("account_id = %d", g_ugd->account_info->account_list[count].account_id);
1927 debug_log("default account_id = %d", g_ugd->account_info->account_id);
1929 if (!strncmp(part, "elm.icon.1", 10)) {
1930 g_ugd->account_info->account_rd[count] = elm_radio_add(obj);
1931 elm_radio_state_value_set(g_ugd->account_info->account_rd[count], count);
1934 g_ugd->account_info->account_rdg = g_ugd->account_info->account_rd[count];
1936 elm_radio_group_add(g_ugd->account_info->account_rd[count], g_ugd->account_info->account_rdg);
1938 if (g_ugd->account_info->account_list[count].account_id == g_ugd->account_info->account_id)
1939 elm_radio_value_set(g_ugd->account_info->account_rdg, count);
1941 evas_object_smart_callback_add(g_ugd->account_info->account_rd[count], "changed", _composer_myemail_radio_cb, g_ugd);
1943 return g_ugd->account_info->account_rd[count];
1944 } else if (!strncmp(part, "elm.icon.2", 10)) {
1945 Evas_Object *icon = elm_icon_add(obj);
1947 debug_log("logo_icon_path:%s", g_ugd->account_info->account_list[count].logo_icon_path);
1948 if (g_ugd->account_info->account_list[count].logo_icon_path)
1949 elm_image_file_set(icon, g_ugd->account_info->account_list[count].logo_icon_path, NULL);
1951 elm_image_file_set(icon, ACCOUNT_ICON_OTHERS, NULL);
1952 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1955 } else if (!strncmp(part, "elm.swallow.colorbar", 20)) {
1956 account_user_data_t *ud = (account_user_data_t *)g_ugd->account_info->account_list[count].user_data;
1957 unsigned int val = ud->index_color;
1958 int r = (val & 0xff000000) >> 24;
1959 int g = (val & 0x00ff0000) >> 16;
1960 int b = (val & 0x0000ff00) >> 8;
1961 int a = val & 0x000000ff;
1963 Evas_Object *color_bar = evas_object_rectangle_add(evas_object_evas_get(obj));
1964 evas_object_size_hint_fill_set(color_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
1965 evas_object_color_set(color_bar, r, g, b, a);
1969 debug_log("part is invalid");
1975 static void _composer_myemail_gl_sel(void *data, Evas_Object *obj, void *event_info)
1977 debug_log("index:%d", (int)data);
1979 int index = (int)data;
1981 elm_radio_value_set(g_ugd->account_info->account_rdg, index);
1983 _composer_myemail_close_response_cb(g_ugd);
1986 static void _composer_myemail_change_response_cb(void *data, Evas_Object *obj, void *event_info)
1988 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1990 debug_log("composer_noti : %p", ugd->composer_noti);
1992 char *pszBtnText = (char *)elm_object_text_get(obj);
1993 debug_log("selected button text = %s", pszBtnText);
1995 _composer_myemail_close_response_cb(ugd);
1998 static void _composer_myemail_close_response_cb(EmailComposerUGD *ugd)
2000 debug_log("composer_noti : %p", ugd->composer_noti);
2002 int set_val = elm_radio_value_get(ugd->account_info->account_rdg);
2004 debug_log("set_val = %d", set_val);
2005 debug_log("account_id = %d", ugd->account_info->account_list[set_val].account_id);
2007 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
2009 EmailRecpInfo *new_to_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
2011 new_to_ri->selected_email_idx = 0;
2012 new_to_ri->display_name = ugd->account_info->account_list[set_val].user_display_name;
2013 snprintf(new_to_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account_list[set_val].user_email_address);
2014 new_to_ri->email_cnt = 1;
2015 new_to_ri->is_contact_info = false;
2016 new_to_ri->is_always_bcc = false;
2017 new_to_ri->is_from_addr = true;
2018 debug_log("my email_addr = %s, display_name = %s", new_to_ri->email_list[0].email_addr, new_to_ri->display_name);
2020 elm_multibuttonentry_item_append(ugd->to_mbe, g_strdup(new_to_ri->display_name), NULL, new_to_ri);
2022 if (ugd->selected_entry == ugd->to_mbe_entry) {
2023 elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
2024 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
2025 elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
2026 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
2027 elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
2030 if (ugd->account_gen_list) {
2031 elm_genlist_clear(ugd->account_gen_list);
2033 evas_object_del(ugd->account_gen_list);
2034 ugd->account_gen_list = NULL;
2037 if (ugd->popup_list) {
2038 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
2039 debug_log("composer_noti: %p", ugd->composer_noti);
2041 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
2044 if (ugd->composer_noti) {
2045 debug_log("@@@ ELM_POPUP_RESPONSE_CLOSE @@@");
2046 _composer_popup_delete(ugd->composer_noti);
2047 ugd->composer_noti = NULL;
2051 static void _composer_myemail_radio_cb(void *data, Evas_Object *obj, void *event_info)
2055 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2058 for (i = 0; i < ugd->account_info->account_count; i++) {
2059 if (obj == ugd->account_info->account_rd[i]) {
2060 debug_log("account_id = %d", ugd->account_info->account_list[i].account_id);
2061 elm_radio_value_set(ugd->account_info->account_rdg, i);
2066 void _composer_cbar_cc_clicked(void *data, Evas_Object *obj, void *event_info)
2070 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2072 if(ugd->context_popup) {
2073 evas_object_del(ugd->context_popup);
2074 ugd->context_popup = NULL;
2077 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
2079 if (ugd->cc_added) {
2080 if (ugd->b_cc_bcc) {
2081 debug_log("b_cc_bcc is ON");
2085 edje_object_signal_emit(_EDJ(ugd->c_layout), "hide.cc", "*");
2086 email_composer_delete_cc_field(ugd);
2087 edje_object_signal_emit(_EDJ(ugd->c_layout), "hide.bcc", "*");
2088 email_composer_delete_bcc_field(ugd);
2089 elm_object_text_set(ugd->cc_btn, _("IDS_EMAIL_OPT_ADD_CC_BCC"));
2091 if (ugd->b_cc_ps_open == true) {
2092 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
2093 ugd->b_cc_ps_open = false;
2096 ugd->b_cc_bcc = false;
2098 elm_layout_sizing_eval(ugd->c_layout);
2100 if (!_composer_check_popup_exist(ugd)) {
2101 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
2104 if (ugd->b_cc_bcc) {
2105 debug_log("b_cc_bcc is ON");
2109 if (ugd->clipboard_on) {
2110 ugd->clipboard_on = false;
2113 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2114 email_composer_create_cc_field(ugd);
2115 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2116 email_composer_create_bcc_field(ugd);
2117 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
2119 elm_layout_sizing_eval(ugd->c_layout);
2121 ugd->idler_set_focus = ecore_idler_add(_composer_cc_mbe_set_focus, ugd);
2125 void _composer_cbar_send_myself_clicked(void *data, Evas_Object *obj, void *event_info)
2128 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2130 if(ugd->context_popup) {
2131 evas_object_del(ugd->context_popup);
2132 ugd->context_popup = NULL;
2135 _composer_select_myemail_popup(ugd);
2138 static void _composer_cbar_save_as_draft_cb(Evas_Object *o, const char *result, void *data)
2141 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2143 if (NULL != ugd->latest_html_content) {
2144 g_free(ugd->latest_html_content);
2145 ugd->latest_html_content = NULL;
2148 if (result != NULL) {
2149 ugd->latest_html_content = g_strdup(result);
2150 debug_log("ugd->latest_html_content => %s", ugd->latest_html_content);
2153 if (ugd->timeout_noti) {
2154 debug_log("delete timeout_noti");
2155 evas_object_del(ugd->timeout_noti);
2156 ugd->timeout_noti = NULL;
2159 if (ugd->composer_noti) {
2160 debug_log("delete composer_noti");
2161 evas_object_del(ugd->composer_noti);
2162 ugd->composer_noti = NULL;
2166 debug_log("ps stop");
2167 _composer_ps_stop(ugd);
2168 ugd->sc_timer = ecore_timer_add(0.5, _composer_ps_scroll_pop, ugd);
2171 if (ugd->selected_entry == ugd->body_ewkview) {
2172 evas_object_focus_set(ugd->body_ewkview, EINA_FALSE);
2174 Ecore_IMF_Context *imf_context = NULL;
2175 imf_context = elm_entry_imf_context_get(ugd->selected_entry);
2177 ecore_imf_context_input_panel_hide(imf_context);
2180 if (_composer_check_mail_is_modified(ugd)) {
2181 debug_log("mail is changed.");
2182 ugd->save_drafts = 1;
2184 debug_log("mail is NOT changed.");
2185 ugd->save_drafts = 0;
2187 char str[128] = { 0, };
2188 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_OPT_COMPOSE_EMAIL"));
2189 int ret = status_message_post(str);
2191 debug_log("status_message_post failed: %d", ret);
2193 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME.
2194 _composer_webkit_set_body_script(ugd);
2195 if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_ENABLE_EDITABLE, _composer_script_executed_cb, ugd) == EINA_FALSE)
2196 debug_log("COMPOSER_JS_ENABLE_EDITABLE failed.");
2200 if (ugd->need_download == EINA_TRUE) {
2201 _composer_download_attachment(ugd);
2203 _composer_save_draft_mail(ugd);
2207 void _composer_cbar_save_as_draft_clicked(void *data, Evas_Object *obj, void *event_info)
2212 debug_log("data is NULL");
2216 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2218 if(ugd->context_popup) {
2219 evas_object_del(ugd->context_popup);
2220 ugd->context_popup = NULL;
2223 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_INFO_CONTENT, _composer_get_latest_info_content_cb, (void *)ugd))
2224 debug_log("COMPOSER_JS_GET_ORIGINAL_INFO_CONTENT failed.");
2226 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_HTML_CONTENT, _composer_get_latest_html_content_cb, (void *)ugd))
2227 debug_log("COMPOSER_JS_GET_ORIGINAL_HTML_CONTENT failed.");
2229 if (EINA_FALSE == ewk_view_plain_text_get(ugd->body_ewkview, _composer_plain_text_get_cb, (void *)ugd))
2230 debug_log("ewk_view_plain_text_get Failed");
2232 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_IMAGE_LIST, _composer_get_image_list_cb, (void *)ugd))
2233 debug_log("COMPOSER_JS_GET_IMAGE_LIST error.");
2235 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_HTML_CONTENT, _composer_cbar_save_as_draft_cb, (void *)ugd))
2236 debug_log("COMPOSER_JS_GET_HTML_CONTENT failed.");
2239 static void _composer_priority_radio_cb(void *data, Evas_Object *obj, void *event_info)
2243 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2246 for (i = 0; i < 3; i++) {
2247 if (obj == ugd->priority_rd[i]) {
2248 elm_radio_value_set(ugd->priority_rdg, i);
2253 static char *_composer_priority_gl_text_get(void *data, Evas_Object *obj, const char *part)
2255 int index = (int)data;
2257 debug_log("\n text index = %d", index);
2259 if (!g_strcmp0(part, "elm.text")) {
2261 return strdup(_("IDS_EMAIL_BODY_HIGH_M_PRIORITY"));
2262 else if (index == 1)
2263 return strdup(_("IDS_EMAIL_BODY_NORMAL_M_EMAILPRIORITY"));
2264 else if (index == 2)
2265 return strdup(_("IDS_EMAIL_BODY_LOW_M_EMAILPRIORITY"));
2270 static Evas_Object *_composer_priority_gl_content_get(void *data, Evas_Object *obj, const char *part)
2272 int index = (int)data;
2274 debug_log("\n content index = %d", index);
2276 if (!strcmp(part, "elm.icon") || !strcmp(part, "elm.swallow.icon")) {
2277 g_ugd->priority_rd[index] = elm_radio_add(obj);
2278 elm_radio_state_value_set(g_ugd->priority_rd[index], index);
2281 g_ugd->priority_rdg = g_ugd->priority_rd[index];
2283 elm_radio_group_add(g_ugd->priority_rd[index], g_ugd->priority_rdg);
2286 if (g_ugd->priority_option == EMAIL_MAIL_PRIORITY_HIGH) {
2287 elm_radio_value_set(g_ugd->priority_rdg, 0);
2288 } else if ( g_ugd->priority_option == EMAIL_MAIL_PRIORITY_NORMAL) {
2289 elm_radio_value_set(g_ugd->priority_rdg, 1);
2290 } else if ( g_ugd->priority_option == EMAIL_MAIL_PRIORITY_LOW) {
2291 elm_radio_value_set(g_ugd->priority_rdg, 2);
2293 debug_log("\n g_ugd->priority_option4 = %d", g_ugd->priority_option);
2296 evas_object_smart_callback_add(g_ugd->priority_rd[index], "changed", _composer_priority_radio_cb, g_ugd);
2298 return g_ugd->priority_rd[index];
2304 static Eina_Bool _composer_priority_gl_state_get(void *data, Evas_Object *obj, const char *part)
2310 static void _composer_priority_gl_del(void *data, Evas_Object *obj)
2316 static void _composer_priority_gl_sel(void *data, Evas_Object *obj, void *event_info)
2318 int index = (int)data;
2320 elm_radio_value_set(g_ugd->priority_rdg, index);
2323 g_ugd->priority_option = EMAIL_MAIL_PRIORITY_HIGH;
2324 } else if (index == 1) {
2325 g_ugd->priority_option = EMAIL_MAIL_PRIORITY_NORMAL;
2326 } else if (index == 2) {
2327 g_ugd->priority_option = EMAIL_MAIL_PRIORITY_LOW;
2329 debug_log("\n g_ugd->priority_option = %d", g_ugd->priority_option);
2331 debug_log("\n _composer_priority_gl_sel : priority_option = %d", g_ugd->priority_option);
2333 if (g_ugd->composer_noti) {
2334 evas_object_del(g_ugd->composer_noti);
2335 g_ugd->composer_noti = NULL;
2339 void _composer_cbar_priority_clicked(void *data, Evas_Object *obj, void *event_info)
2343 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2344 Elm_Object_Item *gen_item[3];
2347 if(ugd->context_popup) {
2348 evas_object_del(ugd->context_popup);
2349 ugd->context_popup = NULL;
2356 if (ugd->composer_noti) {
2357 evas_object_del(ugd->composer_noti);
2358 ugd->composer_noti = NULL;
2360 popup = _composer_create_noti_with_list(ugd, false, _("IDS_EMAIL_BODY_PRIORITY"), NULL, 1,
2361 dgettext("sys_string", "IDS_COM_POP_CLOSE"), NULL, 0.0, _composer_noti_response_cb);
2363 ugd->composer_noti = popup;
2364 elm_object_focus_set(popup, EINA_TRUE);
2366 if (ugd->clipboard_on) {
2367 ugd->clipboard_on = false;
2370 if (ugd->cc_added) {
2371 if (ugd->b_cc_ps_open == true) {
2372 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
2373 ugd->b_cc_ps_open = false;
2377 if (ugd->b_bcc_ps_open == true) {
2378 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
2380 if (ugd->cc_added) {
2381 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2384 ugd->b_bcc_ps_open = false;
2387 priority_itc.item_style = "1text.1icon.2";
2388 priority_itc.func.text_get = _composer_priority_gl_text_get;
2389 priority_itc.func.content_get = _composer_priority_gl_content_get;
2390 priority_itc.func.state_get = _composer_priority_gl_state_get;
2391 priority_itc.func.del = _composer_priority_gl_del;
2393 Evas_Object *priority_genlist;
2394 priority_genlist = elm_genlist_add(ugd->composer_noti);
2396 evas_object_size_hint_weight_set(priority_genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2397 evas_object_size_hint_align_set(priority_genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
2399 for (index = 0; index < 3; index++) {
2400 gen_item[index] = elm_genlist_item_append(priority_genlist, &priority_itc, (void *)index, NULL, ELM_GENLIST_ITEM_NONE, _composer_priority_gl_sel, (void *)index);
2403 #ifdef _POPUP_WITH_LIST
2404 Evas_Object *box = elm_box_add(ugd->composer_noti);
2405 evas_object_size_hint_min_set(box, 610 * elm_config_scale_get(), 113 * index * elm_config_scale_get());
2406 evas_object_show(priority_genlist);
2407 elm_box_pack_end(box, priority_genlist);
2408 elm_object_content_set(ugd->composer_noti, box);
2410 elm_object_content_set(ugd->composer_noti, priority_genlist);
2415 static char *_composer_tracking_gl_text_get(void *data, Evas_Object *obj, const char *part)
2417 int index = (int)data;
2419 debug_log("\n text index = %d", index);
2421 if (!g_strcmp0(part, "elm.text")) {
2423 return strdup(N_("Read report"));
2424 else if (index == 1)
2425 return strdup(N_("Delivery report"));
2430 static Evas_Object *_composer_tracking_gl_content_get(void *data, Evas_Object *obj, const char *part)
2432 int index = (int)data;
2434 debug_log("\n content index = %d", index);
2436 if (!strcmp(part, "elm.icon") || !strcmp(part, "elm.swallow.icon")) {
2437 Evas_Object *check = elm_check_add(obj);
2439 if (index == 0 && g_ugd->tracking_option[0] == 1) {
2440 debug_log("Read report");
2441 elm_check_state_set(check, EINA_TRUE);
2442 } else if (index == 1 && g_ugd->tracking_option[1] == 1) {
2443 debug_log("Delivery report");
2444 elm_check_state_set(check, EINA_TRUE);
2447 elm_check_state_set(check, EINA_FALSE);
2450 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2451 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
2459 static Eina_Bool _composer_tracking_gl_state_get(void *data, Evas_Object *obj, const char *part)
2465 static void _composer_tracking_gl_del(void *data, Evas_Object *obj)
2471 static void _composer_tracking_gl_sel(void *data, Evas_Object *obj, void *event_info)
2474 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
2476 debug_log("\nsel index = %d", (int)data);
2479 index = (int)elm_object_item_data_get(item);
2480 elm_genlist_item_selected_set(item, EINA_FALSE);
2482 debug_log("tracking_option[%d]:%d, !tracking_option[%d]:%d", index, g_ugd->tracking_option[index], index, !g_ugd->tracking_option[index]);
2483 g_ugd->tracking_option[index] = !g_ugd->tracking_option[index];
2485 elm_genlist_item_update(item);
2489 void _composer_cbar_tracking_clicked(void *data, Evas_Object *obj, void *event_info)
2493 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2494 Elm_Object_Item *gen_item[2];
2497 if(ugd->context_popup) {
2498 evas_object_del(ugd->context_popup);
2499 ugd->context_popup = NULL;
2506 if (ugd->composer_noti) {
2507 evas_object_del(ugd->composer_noti);
2508 ugd->composer_noti = NULL;
2510 popup = _composer_create_noti_with_list(ugd, false, _("IDS_EMAIL_OPT_TRACKING"), NULL, 1,
2511 dgettext("sys_string", "IDS_COM_POP_CLOSE"), NULL, 0.0, _composer_noti_response_cb);
2513 ugd->composer_noti = popup;
2514 elm_object_focus_set(popup, EINA_TRUE);
2516 if (ugd->clipboard_on) {
2517 ugd->clipboard_on = false;
2520 if (ugd->cc_added) {
2521 if (ugd->b_cc_ps_open == true) {
2522 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
2523 ugd->b_cc_ps_open = false;
2527 if (ugd->b_bcc_ps_open == true) {
2528 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
2530 if (ugd->cc_added) {
2531 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2534 ugd->b_bcc_ps_open = false;
2537 tracking_itc.item_style = "1text.1icon.2";
2538 tracking_itc.func.text_get = _composer_tracking_gl_text_get;
2539 tracking_itc.func.content_get = _composer_tracking_gl_content_get;
2540 tracking_itc.func.state_get = _composer_tracking_gl_state_get;
2541 tracking_itc.func.del = _composer_tracking_gl_del;
2543 Evas_Object *tracking_genlist;
2544 tracking_genlist = elm_genlist_add(ugd->composer_noti);
2546 evas_object_size_hint_weight_set(tracking_genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2547 evas_object_size_hint_align_set(tracking_genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
2549 for (index = 0; index < 2; index++) {
2550 gen_item[index] = elm_genlist_item_append(tracking_genlist, &tracking_itc, (void *)index, NULL, ELM_GENLIST_ITEM_NONE, _composer_tracking_gl_sel, (void *)index);
2553 #ifdef _POPUP_WITH_LIST
2554 Evas_Object *box = elm_box_add(ugd->composer_noti);
2555 evas_object_size_hint_min_set(box, 610 * elm_config_scale_get(), 113 * index * elm_config_scale_get());
2556 evas_object_show(tracking_genlist);
2557 elm_box_pack_end(box, tracking_genlist);
2558 elm_object_content_set(ugd->composer_noti, box);
2560 elm_object_content_set(ugd->composer_noti, tracking_genlist);
2564 void _composer_cbar_send_clicked(void *data, Evas_Object *obj, void *event_info)
2568 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2570 if(ugd->context_popup) {
2571 evas_object_del(ugd->context_popup);
2572 ugd->context_popup = NULL;
2575 if (_composer_check_recipient_is_empty(ugd)) {
2576 if (ugd->composer_noti) {
2577 evas_object_del(ugd->composer_noti);
2578 ugd->composer_noti = NULL;
2580 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
2581 _("IDS_EMAIL_POP_NO_RECIPIENTS_ADDED_ENTER_RECIPIENTS"), 0, NULL, NULL, 1.5, _composer_fail_to_send_popup_cb);
2586 debug_log("Send Button Clicked");
2587 elm_object_tree_focus_allow_set(ugd->c_layout, EINA_FALSE); // block the focus not to open IME.
2589 if (ugd->fw_attach_cnt > 0) {
2590 if (ugd->fw_attach_cnt != g_list_length(ugd->fw_attachment_list)) {
2591 if (ugd->account_info->account_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
2592 ugd->need_download = EINA_TRUE;
2595 if (ugd->account_info->account_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
2596 ugd->need_download = EINA_FALSE;
2601 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_INFO_CONTENT, _composer_get_latest_info_content_cb, (void *)ugd))
2602 debug_log("COMPOSER_JS_GET_ORIGINAL_INFO_CONTENT failed.");
2604 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_LATEST_HTML_CONTENT, _composer_get_latest_html_content_cb, (void *)ugd))
2605 debug_log("COMPOSER_JS_GET_ORIGINAL_HTML_CONTENT failed.");
2607 if (EINA_FALSE == ewk_view_plain_text_get(ugd->body_ewkview, _composer_plain_text_get_cb, (void *)ugd))
2608 debug_log("ewk_view_plain_text_get Failed");
2610 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_IMAGE_LIST, _composer_get_image_list_cb, (void *)ugd))
2611 debug_log("COMPOSER_JS_GET_IMAGE_LIST error.");
2613 debug_log("selected_entry = %x, to_mbe_entry = %x, cc_mbe_entry = %x, bcc_mbe_entry = %x, subject_entry = %x, body_ewkview = %x",
2614 ugd->selected_entry, ugd->to_mbe_entry, ugd->cc_mbe_entry, ugd->bcc_mbe_entry, ugd->subject_entry, ugd->body_ewkview);
2616 elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
2617 elm_object_disabled_set(ugd->cancel_btn, EINA_TRUE);
2618 elm_object_disabled_set(ugd->send_btm_btn, EINA_TRUE);
2619 elm_object_disabled_set(ugd->cancel_btm_btn, EINA_TRUE);
2621 if (!ugd->b_sending)
2622 ugd->b_sending = true;
2624 if (ugd->need_download == EINA_TRUE) {
2625 _composer_download_attachment(ugd);
2627 ugd->bSendBtnDisabled = true;
2628 ugd->send_timer = ecore_timer_add(0.5, _composer_send_mail_cb, ugd);
2632 static Eina_Bool _composer_cc_mbe_set_focus(void *data)
2636 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2638 if (ugd->idler_set_focus) {
2639 ecore_idler_del(ugd->idler_set_focus);
2640 ugd->idler_set_focus = NULL;
2643 elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
2645 ugd->b_cc_bcc = false;
2650 void _composer_script_executed_cb(Evas_Object *o, const char *result, void *data)
2653 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2656 _composer_mbe_set_focus(ugd);
2660 void _composer_focus_script_executed_cb(Evas_Object *o, const char *result, void *data)
2665 Eina_Bool _composer_get_html_content_for_draft_cb(void *data)
2669 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2671 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE); // It prevents clicking the cancel button several times
2672 elm_object_disabled_set(ugd->cancel_btm_btn, EINA_FALSE);
2673 if (EINA_FALSE == ewk_view_plain_text_get(ugd->body_ewkview, _composer_plain_text_get_cb, (void *)ugd)) {
2674 debug_log("ewk_view_plain_text_get Failed");
2677 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_IMAGE_LIST, _composer_get_image_list_cb, (void *)ugd)) {
2678 debug_log("COMPOSER_JS_GET_IMAGE_LIST error.");
2681 if (ugd->timeout_noti) {
2682 debug_log("delete timeout_noti");
2683 evas_object_del(ugd->timeout_noti);
2684 ugd->timeout_noti = NULL;
2687 if (ugd->composer_noti) {
2688 debug_log("delete composer_noti");
2689 evas_object_del(ugd->composer_noti);
2690 ugd->composer_noti = NULL;
2694 debug_log("ps stop");
2695 _composer_ps_stop(ugd);
2696 ugd->sc_timer = ecore_timer_add(0.5, _composer_ps_scroll_pop, ugd);
2699 if (ugd->selected_entry == ugd->body_ewkview) {
2700 evas_object_focus_set(ugd->body_ewkview, EINA_FALSE);
2702 Ecore_IMF_Context *imf_context = NULL;
2703 imf_context = elm_entry_imf_context_get(ugd->selected_entry);
2705 ecore_imf_context_input_panel_hide(imf_context);
2708 if (_composer_check_mail_is_modified(ugd)) {
2709 debug_log("mail is changed.");
2710 ugd->save_drafts = 1;
2712 debug_log("mail is NOT changed.");
2713 ugd->save_drafts = 0;
2716 if (ugd->save_drafts) {
2717 ugd->composer_noti = _composer_create_popup(ugd, false, NULL, dgettext("sys_string", "IDS_COM_POP_SAVE_TO_DRAFTS_Q"), 3,
2718 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);
2720 if (elm_multibuttonentry_first_item_get(ugd->to_mbe))
2721 elm_multibuttonentry_clear(ugd->to_mbe);
2722 if (elm_multibuttonentry_first_item_get(ugd->cc_mbe))
2723 elm_multibuttonentry_clear(ugd->cc_mbe);
2724 if (elm_multibuttonentry_first_item_get(ugd->bcc_mbe))
2725 elm_multibuttonentry_clear(ugd->bcc_mbe);
2727 ug_destroy_me(ugd->ug_main);
2730 if (ugd->bringin_timer) {
2731 ecore_timer_del(ugd->bringin_timer);
2732 ugd->bringin_timer = NULL;
2735 return ECORE_CALLBACK_CANCEL;
2738 void _composer_get_latest_info_content_cb(Evas_Object *o, const char *result, void *data)
2741 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2742 debug_log("result: \n%s", result);
2744 if (NULL != ugd->latest_info_content) {
2745 g_free(ugd->latest_info_content);
2746 ugd->latest_info_content = NULL;
2749 if (result != NULL) {
2750 ugd->latest_info_content = g_strdup(result);
2751 debug_log("ugd->latest_info_content : \n%s", ugd->latest_info_content);
2755 static void _composer_get_latest_html_content_cb(Evas_Object *o, const char *result, void *data)
2758 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2759 debug_log("result: \n%s", result);
2761 if (NULL != ugd->latest_html_content) {
2762 g_free(ugd->latest_html_content);
2763 ugd->latest_html_content = NULL;
2766 if (result != NULL) {
2767 ugd->latest_html_content = g_strdup(result);
2768 debug_log("ugd->latest_html_content : \n%s", ugd->latest_html_content);
2772 static void _composer_plain_text_get_cb(Evas_Object *o, const char *plain_text, void *user_data)
2776 EmailComposerUGD *ugd = (EmailComposerUGD *) user_data;
2778 if (NULL != ugd->plain_content) {
2779 g_free(ugd->plain_content);
2780 ugd->plain_content = NULL;
2783 ugd->plain_content = g_strdup(plain_text);
2784 debug_log("ugd->plain_content => %s", ugd->plain_content);
2787 void _composer_get_image_list_cb(Evas_Object *o, const char *result, void *data)
2792 EmailComposerUGD *ugd = (EmailComposerUGD *) data;
2794 if (ugd->attachment_inline_item_list) {
2795 eina_list_free(ugd->attachment_inline_item_list);
2796 ugd->attachment_inline_item_list = NULL;
2799 if (result != NULL) {
2800 debug_log("attachment_inline_item_list => %s", result);
2801 list = g_strdup(result);
2802 char *url = strtok(list, ",");
2803 while (url != NULL) {
2805 if (strncmp(url, "file://", 7) == 0) { /* add only local images(file://), not web images(http://) */
2808 struct stat file_info;
2809 debug_log("image = %s", url + 7);
2811 if ((return_stat = stat(url + 7, &file_info)) == -1) {
2812 debug_error("stat Error(%d): %s", return_stat, strerror(return_stat));
2816 tokens = g_strsplit(url + 7, "/", -1);
2818 email_attachment_data_t *attachment_data = (email_attachment_data_t *)calloc(1, sizeof(email_attachment_data_t));
2819 attachment_data->account_id = ugd->account_info->account_id;
2820 attachment_data->attachment_id = 0;
2821 attachment_data->attachment_name = COMPOSER_STRDUP(tokens[g_strv_length(tokens) - 1]);
2822 attachment_data->attachment_path = COMPOSER_STRDUP(url + 7);
2823 attachment_data->attachment_size = file_info.st_size;
2824 attachment_data->drm_status = 0;
2825 attachment_data->inline_content_status = 1;
2826 attachment_data->mailbox_id = NULL;
2827 attachment_data->mail_id = 0;
2828 attachment_data->save_status = 1;
2829 attachment_data->attachment_mime_type = NULL;
2830 debug_log("attachment_name = %s, attachment_path = %s", attachment_data->attachment_name, attachment_data->attachment_path);
2831 ugd->attachment_inline_item_list = eina_list_append(ugd->attachment_inline_item_list, attachment_data);
2834 url = strtok(NULL, ",");
2839 ugd->inline_cnt = eina_list_count(ugd->attachment_inline_item_list);
2840 debug_log("ugd->inline_cnt : %d", ugd->inline_cnt);