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"
28 #define ACCOUNT_ICON_GMAIL IMGDIR"/M02_email_list_icon_gmail.png"
29 #define ACCOUNT_ICON_HOTMAIL IMGDIR"/M02_email_list_icon_hotmail.png"
30 #define ACCOUNT_ICON_YAHOO IMGDIR"/M02_email_list_icon_YahooMail.png"
31 #define ACCOUNT_ICON_AOL IMGDIR"/M02_email_list_icon_AOL.png"
32 #define ACCOUNT_ICON_OTHERS IMGDIR"/icon_email.png"
34 static EmailComposerUGD *g_ugd = NULL;
36 bool edit_mode = false;
37 bool edit_mode_bs = false;
41 EmailList email_list[MAX_RECIPIENT_COUNT];
43 static Elm_Genlist_Item_Class itc;
44 static Elm_Genlist_Item_Class from_itc;
45 static Elm_Genlist_Item_Class priority_itc;
46 static Elm_Genlist_Item_Class tracking_itc;
48 static void _composer_mbe_popup_change_addr_selected_cb(void *data, Evas_Object *obj, void *event_info);
49 static void _composer_from_change_response_cb(void *data, Evas_Object *obj, void *event_info);
50 static void _composer_from_close_response_cb(EmailComposerUGD *ugd);
51 static void _composer_from_radio_cb(void *data, Evas_Object *obj, void *event_info);
52 static void _composer_from_gl_sel(void *data, Evas_Object *obj, void *event_info);
54 static Eina_Bool _composer_cc_mbe_set_focus(void *data);
55 static void *_composer_contact_search_by_email(EmailComposerUGD *ugd, const char *search_word);
56 static void _composer_delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item);
57 static void _composer_get_html_content_for_draft_cb(Evas_Object *o, const char *result, void *data);
58 static void _composer_send_clicked_cb(Evas_Object *o, const char *result, void *data);
59 static void _composer_plain_text_get_cb(Evas_Object *o, const char *plain_text, void *user_data);
62 void _composer_edit_field_changed_cb(void *data, Evas_Object *obj, void *event_info)
66 if (data == NULL || obj == NULL) {
70 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
72 if (obj == ugd->subject_entry) {
73 _composer_check_entry_max(ugd, ugd->subject_entry, MAX_SUBJECT_LEN);
75 if (_composer_check_recipient_is_empty(ugd)) {
76 if (!ugd->bSendBtnDisabled) {
77 elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
78 ugd->bSendBtnDisabled = true;
81 if (ugd->bSendBtnDisabled) {
82 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
83 ugd->bSendBtnDisabled = false;
86 } else if (obj == ugd->body_ewkview) {
87 if (_composer_check_recipient_is_empty(ugd)) {
88 if (!ugd->bSendBtnDisabled) {
89 elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
90 ugd->bSendBtnDisabled = true;
93 if (ugd->bSendBtnDisabled) {
94 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
95 ugd->bSendBtnDisabled = false;
101 void _composer_more_button_cb(void *data, Evas_Object *obj, void *event_info)
105 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
107 debug_log("More Button Clicked");
109 if (ugd->option_header_opened) {
110 if (ugd->isRotated == true) {
111 _composer_resize_body_webview(ugd, 316);
113 _composer_resize_body_webview(ugd, ugd->ime_height);
115 elm_object_item_signal_emit(ugd->navi_item, "elm,state,optionheader,close", "");
117 if (ugd->isRotated == true) {
118 _composer_resize_body_webview(ugd, 316 + 122);
120 _composer_resize_body_webview(ugd, ugd->ime_height + 122);
122 elm_object_item_signal_emit(ugd->navi_item, "elm,state,optionheader,open", "");
124 ugd->option_header_opened = !ugd->option_header_opened;
126 elm_layout_sizing_eval(ugd->c_layout);
128 _composer_mbe_set_focus(ugd);
131 void _composer_back_button_cb(void *data, Evas_Object *obj, void *event_info)
135 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
137 elm_object_disabled_set(ugd->cancel_btn, EINA_TRUE); // It prevents clicking the cancel button several times
139 if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_HTML_CONTENT, _composer_get_html_content_for_draft_cb, (void *)ugd) == EINA_FALSE)
140 debug_log("COMPOSER_JS_GET_HTML_CONTENT failed.");
142 debug_log("Cancel Button Clicked: %p", ugd->cancel_btn);
145 void _composer_mbe_changed_cb(void *data, Evas_Object *obj, void *event_info)
149 if (data == NULL || obj == NULL) {
153 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
155 if (ugd->clipboard_on) {
156 debug_log("MBE Lost Focus");
157 _composer_mbe_set_focus(ugd);
160 if (obj == ugd->to_mbe_entry) {
162 _composer_check_email_address(ugd, ugd->to_mbe_entry);
163 } else if (obj == ugd->cc_mbe_entry) {
165 _composer_check_email_address(ugd, ugd->cc_mbe_entry);
166 } else if (obj == ugd->bcc_mbe_entry) {
168 _composer_check_email_address(ugd, ugd->bcc_mbe_entry);
172 void _composer_mbe_longpressed_cb(void *data, Evas_Object *obj, void *event_info)
176 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
178 ugd->clipboard_on = true;
181 void _composer_mbe_added_cb(void *data, Evas_Object *obj, void *event_info)
185 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
187 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
189 EmailRecpInfo *ri = NULL;
191 bool is_contact_info = false;
192 bool is_always_bcc = false;
193 bool is_from_addr = false;
195 char *addr = elm_entry_markup_to_utf8((char *)elm_object_item_text_get(item));
196 debug_log("utf8 address : %s", addr);
199 debug_log("Added - Address is NULL");
204 char temp_addr[MAX_RECIPIENT_ADDRESSES_LEN + 1] = { 0, };
206 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
209 is_contact_info = ri->is_contact_info;
210 is_always_bcc = ri->is_always_bcc;
211 is_from_addr = ri->is_from_addr;
213 strncpy(temp_addr, ri->email_list[ri->selected_email_idx].email_addr, MAX_RECIPIENT_ADDRESSES_LEN - 1);
214 temp_addr[MAX_RECIPIENT_ADDRESSES_LEN] = '\0';
216 debug_log("is_contact_info = %d", is_contact_info);
217 debug_log("is_always_bcc = %d", is_always_bcc);
218 debug_log("is_from_addr = %d", is_from_addr);
220 strncpy(temp_addr, addr, MAX_RECIPIENT_ADDRESSES_LEN - 1);
221 temp_addr[MAX_RECIPIENT_ADDRESSES_LEN] = '\0';
226 debug_log("email_addr = %s", temp_addr);
228 if (!is_contact_info && !is_always_bcc && !is_from_addr) {
229 if (ugd->to_recipients_cnt > MAX_RECIPIENT_COUNT) {
230 char msg[MAX_STR_LEN] = { 0, };
231 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
233 if (ugd->composer_noti) {
234 evas_object_del(ugd->composer_noti);
235 ugd->composer_noti = NULL;
237 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
238 msg, 0, NULL, NULL, 1.0, _composer_noti_response_cb);
240 elm_object_item_del(item);
243 } else if (!_composer_is_valid_email(temp_addr)) {
244 if (ugd->composer_noti) {
245 evas_object_del(ugd->composer_noti);
246 ugd->composer_noti = NULL;
248 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
249 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 0, NULL, NULL, 1.5, _composer_noti_response_cb);
251 elm_object_item_del(item);
256 EmailRecpInfo *new_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
257 snprintf(new_ri->email_list[0].email_addr, sizeof(new_ri->email_list[0].email_addr), "%s", temp_addr);
258 debug_log("email_addr = %s", new_ri->email_list[0].email_addr);
259 new_ri->selected_email_idx = 0;
260 new_ri->display_name = NULL;
261 new_ri->email_cnt = 1;
262 new_ri->is_contact_info = false;
263 new_ri->is_from_addr = false;
264 new_ri->is_always_bcc = false;
266 elm_object_item_data_set(item, new_ri);
269 if (obj == ugd->to_mbe) {
270 ugd->to_recipients_cnt++;
271 } else if (obj == ugd->cc_mbe) {
272 ugd->cc_recipients_cnt++;
273 } else if (obj == ugd->bcc_mbe) {
274 ugd->bcc_recipients_cnt++;
277 if ((obj == ugd->to_mbe) || (obj == ugd->cc_mbe) || (obj == ugd->bcc_mbe)) {
278 if (ugd->bSendBtnDisabled && !_composer_check_recipient_is_empty(ugd)) {
279 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
280 ugd->bSendBtnDisabled = false;
285 void _composer_mbe_deleted_cb(void *data, Evas_Object *obj, void *event_info)
289 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
291 if (obj == ugd->to_mbe) {
294 if (ugd->to_recipients_cnt > 0)
295 ugd->to_recipients_cnt--;
296 } else if (obj == ugd->cc_mbe) {
299 if (ugd->cc_recipients_cnt > 0)
300 ugd->cc_recipients_cnt--;
301 } else if (obj == ugd->bcc_mbe) {
302 debug_log("bcc_mbe");
304 if (ugd->bcc_recipients_cnt > 0)
305 ugd->bcc_recipients_cnt--;
308 if ((obj == ugd->to_mbe) || (obj == ugd->cc_mbe) || (obj == ugd->bcc_mbe)) {
309 if (!ugd->bSendBtnDisabled && _composer_check_recipient_is_empty(ugd)) {
310 elm_object_disabled_set(ugd->send_btn, EINA_TRUE);
311 ugd->bSendBtnDisabled = true;
316 Eina_Bool _composer_unfocus_selected_mbe(void *data)
320 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
322 debug_log("selected_entry = %x, to_mbe_entry = %x, cc_mbe_entry = %x, bcc_mbe_entry = %x",
323 ugd->selected_entry, ugd->to_mbe_entry, ugd->cc_mbe_entry, ugd->bcc_mbe_entry);
325 if (ugd->selected_entry == ugd->to_mbe_entry) {
327 elm_object_focus_set(ugd->to_mbe, EINA_FALSE);
328 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
330 elm_object_focus_set(ugd->cc_mbe, EINA_FALSE);
331 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
332 debug_log("bcc_mbe");
333 elm_object_focus_set(ugd->bcc_mbe, EINA_FALSE);
336 if (ugd->mbe_unfocus_timer) {
337 ecore_timer_del(ugd->mbe_unfocus_timer);
338 ugd->mbe_unfocus_timer = NULL;
344 void _composer_mbe_selected_cb(void *data, Evas_Object *obj, void *event_info)
348 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
351 EmailRecpInfo *ri = NULL;
353 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
355 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
357 debug_log("is_contact_info = %d", ri->is_contact_info);
358 debug_log("is_always_bcc = %d", ri->is_always_bcc);
359 debug_log("is_from_addr = %d", ri->is_from_addr);
361 /* 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)) {
364 ugd->bringin_timer = ecore_timer_add(0.5f, _composer_bringin_cb, ugd);
366 } else */if (obj == ugd->from_mbe) {
367 debug_log("from selected");
369 _composer_from_show_popup(ugd);
373 Ecore_IMF_Context *imf_context = NULL;
375 imf_context = elm_entry_imf_context_get(ugd->selected_entry);
378 ecore_imf_context_input_panel_hide(imf_context);
380 ugd->is_mbe_selected = true;
382 index = ri->selected_email_idx;
384 Evas_Object *pu_list;
386 if (ugd->composer_popup) {
387 evas_object_del(ugd->composer_popup);
388 ugd->composer_popup = NULL;
391 debug_log("display_name:%s, index:%d", ri->display_name, index);
392 if (ri->display_name) {
393 char *email_str = g_strconcat(ri->display_name, " <", ri->email_list[index].email_addr, ">", NULL);
394 char *contact_str = elm_entry_utf8_to_markup(email_str);
395 debug_log("email_str:%s", email_str);
396 debug_log("contact_str:%s", contact_str);
397 ugd->composer_popup = _composer_create_noti(ugd, false, contact_str, NULL, 1,
398 dgettext("sys_string", "IDS_COM_POP_CLOSE"), NULL, 0.0, _composer_popup_response_cb);
401 ugd->composer_popup = _composer_create_noti(ugd, false, ri->email_list[index].email_addr, NULL, 1,
402 dgettext("sys_string", "IDS_COM_POP_CLOSE"), NULL, 0.0, _composer_popup_response_cb);
405 #ifdef _POPUP_WITH_LIST
406 elm_object_style_set(ugd->composer_popup, "min_menustyle");
408 elm_object_style_set(ugd->composer_popup, "menustyle");
410 elm_object_focus_allow_set(ugd->composer_popup, EINA_TRUE);
412 pu_list = elm_list_add(ugd->composer_popup);
416 elm_list_item_append(pu_list, dgettext("sys_string", "IDS_COM_SK_DELETE"), NULL, NULL, _composer_mbe_popup_delete_cb, ugd);
417 elm_list_item_append(pu_list, dgettext("sys_string", "IDS_COM_SK_EDIT"), NULL, NULL, _composer_mbe_popup_edit_cb, ugd);
419 if (obj != ugd->to_mbe)
420 elm_list_item_append(pu_list, _("IDS_EMAIL_BODY_MOVE_TO_TO"), NULL, NULL, _composer_mbe_popup_move_to_to_cb, ugd);
421 if (obj != ugd->cc_mbe)
422 elm_list_item_append(pu_list, _("IDS_EMAIL_OPT_MOVE_TO_CC"), NULL, NULL, _composer_mbe_popup_move_to_cc_cb, ugd);
423 if (obj != ugd->bcc_mbe)
424 elm_list_item_append(pu_list, _("IDS_EMAIL_OPT_MOVE_TO_BCC"), NULL, NULL, _composer_mbe_popup_move_to_bcc_cb, ugd);
426 debug_log("email_cnt = %d", ri->email_cnt);
427 if (ri->is_contact_info == true) {
428 if (ri->email_cnt > 1) {
429 elm_list_item_append(pu_list, _("IDS_EMAIL_OPT_CHANGE_EMAIL_ADDRESS_ABB"), NULL, NULL, _composer_mbe_popup_change_addr_cb, ugd);
433 elm_list_go(pu_list);
435 #ifdef _POPUP_WITH_LIST
436 elm_list_mode_set(pu_list, ELM_LIST_EXPAND);
437 evas_object_size_hint_max_set(pu_list, -1, 114 * item_count * elm_scale_get());
439 elm_object_content_set(ugd->composer_popup, pu_list);
441 ugd->mbe_unfocus_timer = ecore_timer_add(0.1, _composer_unfocus_selected_mbe, ugd);
442 debug_log("composer_popup = %x, is_mbe_selected = %d", ugd->composer_popup, ugd->is_mbe_selected);
446 void _composer_mbe_focused_cb(void *data, Evas_Object *obj, void *event_info)
450 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
452 debug_log("focus_status: %d", ugd->focus_status);
454 if (COMPOSER_FOCUS_STATUS_NONE == ugd->focus_status) {
455 if (obj == ugd->to_mbe) {
456 edje_object_signal_emit(_EDJ(ugd->to_ly), "show.button", "*");
457 edje_object_signal_emit(_EDJ(ugd->to_ly), "contract.recp", "*");
459 else if (obj == ugd->cc_mbe) {
460 edje_object_signal_emit(_EDJ(ugd->cc_ly), "show.button", "*");
461 edje_object_signal_emit(_EDJ(ugd->cc_ly), "contract.recp", "*");
463 else if (obj == ugd->bcc_mbe) {
464 edje_object_signal_emit(_EDJ(ugd->bcc_ly), "show.button", "*");
465 edje_object_signal_emit(_EDJ(ugd->bcc_ly), "contract.recp", "*");
468 _composer_attachment_contract_items(ugd);
469 elm_multibuttonentry_expanded_set(obj, TRUE);
471 ugd->selected_entry = elm_multibuttonentry_entry_get(obj);
472 // ugd->bringin_timer = ecore_timer_add(0.5f, _composer_bringin_cb, ugd);
473 debug_log("MBE editable:%d", elm_multibuttonentry_editable_get(obj));
475 if (ugd->selected_entry == ugd->body_ewkview) {
476 if (EINA_TRUE == elm_object_focus_get(ugd->to_mbe))
477 elm_object_focus_set(ugd->to_mbe, EINA_FALSE);
478 else if (EINA_TRUE == elm_object_focus_get(ugd->cc_mbe))
479 elm_object_focus_set(ugd->cc_mbe, EINA_FALSE);
480 else if (EINA_TRUE == elm_object_focus_get(ugd->bcc_mbe))
481 elm_object_focus_set(ugd->bcc_mbe, EINA_FALSE);
486 void _composer_mbe_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
490 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
492 debug_log("composer_popup = %x, is_mbe_selected = %d", ugd->composer_popup, ugd->is_mbe_selected);
494 _composer_ps_stop(ugd);
495 ugd->sc_timer = ecore_timer_add(0.5, _composer_ps_scroll_pop, ugd);
496 if (ugd->is_mbe_selected)
500 debug_log("obj = %x, to_mbe = %x, cc_mbe = %x, bcc_mbe = %x", obj, ugd->to_mbe, ugd->cc_mbe, ugd->bcc_mbe);
501 if (obj == ugd->to_mbe) {
502 edje_object_signal_emit(_EDJ(ugd->to_ly), "hide.button", "*");
503 edje_object_signal_emit(_EDJ(ugd->to_ly), "extract.recp", "*");
505 else if (obj == ugd->cc_mbe) {
506 edje_object_signal_emit(_EDJ(ugd->cc_ly), "hide.button", "*");
507 edje_object_signal_emit(_EDJ(ugd->cc_ly), "extract.recp", "*");
509 else if (obj == ugd->bcc_mbe) {
510 edje_object_signal_emit(_EDJ(ugd->bcc_ly), "hide.button", "*");
511 edje_object_signal_emit(_EDJ(ugd->bcc_ly), "extract.recp", "*");
514 elm_multibuttonentry_expanded_set(obj, FALSE);
517 Eina_Bool _composer_mbe_verified_item_cb(Evas_Object *obj, const char *item_label, void *item_data, void *data)
521 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
524 debug_log("Item_label is NULL");
529 debug_log("Normally Added");
533 debug_log("item_label = %s", item_label);
535 debug_log("is_recipient_duplicated:%d", ugd->is_recipient_duplicated);
536 if (ugd->is_recipient_duplicated == TRUE) {
537 ugd->is_recipient_duplicated = FALSE;
541 if (_composer_is_valid_email(item_label)) {
542 EmailRecpInfo *ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
543 ri->selected_email_idx = 0;
544 snprintf(ri->email_list[0].email_addr, sizeof(ri->email_list[0].email_addr), "%s", item_label);
545 ri->display_name = NULL;
547 ri->is_contact_info = false;
548 ri->is_always_bcc = false;
549 ri->is_from_addr = false;
551 if (_composer_check_recipient_is_duplicated(ugd, obj, ri)) {
552 if (ugd->composer_noti) {
553 evas_object_del(ugd->composer_noti);
554 ugd->composer_noti = NULL;
556 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"),
557 0, NULL, NULL, 1.5, _composer_noti_response_cb);
563 char msg[MAX_STR_LEN] = { 0, };
564 snprintf(msg, sizeof(msg), _("IDS_EMAIL_POP_MAXIMUM_NUMBER_OF_RECIPIENTS_HPD_REACHED"), MAX_RECIPIENT_COUNT);
566 if (obj == ugd->to_mbe) {
567 if (ugd->to_recipients_cnt >= MAX_RECIPIENT_COUNT) {
568 if (ugd->composer_noti) {
569 evas_object_del(ugd->composer_noti);
570 ugd->composer_noti = NULL;
572 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), msg,
573 0, NULL, NULL, 1.0, _composer_noti_response_cb);
578 } else if (obj == ugd->cc_mbe) {
579 if (ugd->cc_recipients_cnt >= MAX_RECIPIENT_COUNT) {
580 if (ugd->composer_noti) {
581 evas_object_del(ugd->composer_noti);
582 ugd->composer_noti = NULL;
584 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), msg,
585 0, NULL, NULL, 1.0, _composer_noti_response_cb);
590 } else if (obj == ugd->bcc_mbe) {
591 if (ugd->bcc_recipients_cnt >= MAX_RECIPIENT_COUNT) {
592 if (ugd->composer_noti) {
593 evas_object_del(ugd->composer_noti);
594 ugd->composer_noti = NULL;
596 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), msg,
597 0, NULL, NULL, 1.0, _composer_noti_response_cb);
604 debug_log("Invalid Address");
606 if (ugd->composer_noti) {
607 evas_object_del(ugd->composer_noti);
608 ugd->composer_noti = NULL;
610 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"), _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
611 0, NULL, NULL, 1.0, _composer_noti_response_cb);
619 debug_log("err-return");
621 elm_entry_entry_set(elm_multibuttonentry_entry_get(obj), NULL);
622 elm_entry_cursor_end_set(elm_multibuttonentry_entry_get(obj));
624 if (_composer_check_popup_exist(ugd))
625 elm_object_focus_set(obj, EINA_FALSE);
630 void _composer_mbe_popup_delete_cb(void *data, Evas_Object *obj, void *event_info)
634 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
636 Evas_Object *mbe = NULL;
638 if (ugd->selected_entry == ugd->to_mbe_entry) {
639 debug_log("@@@ to MBE @@@");
641 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
642 debug_log("@@@ cc MBE @@@");
644 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
645 debug_log("@@@ bcc MBE @@@");
649 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
651 if (item && mbe == ugd->bcc_mbe) {
652 EmailRecpInfo *bcc_ri_info;
654 bcc_ri_info = (EmailRecpInfo *) elm_object_item_data_get(item);
657 elm_object_item_del(item);
660 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
661 if (ugd->composer_noti) {
662 evas_object_del(ugd->composer_noti);
663 ugd->composer_noti = NULL;
665 if (ugd->composer_popup) {
666 evas_object_del(ugd->composer_popup);
667 ugd->composer_popup = NULL;
669 ugd->is_mbe_selected = false;
672 void _composer_mbe_popup_edit_cb(void *data, Evas_Object *obj, void *event_info)
676 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
678 EmailRecpInfo *ri = NULL;
680 Evas_Object *mbe = NULL;
682 if (ugd->selected_entry == ugd->to_mbe_entry) {
684 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
686 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
690 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
691 debug_log("item:%p", item);
695 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
698 index = ri->selected_email_idx;
700 debug_log("ri is NULL");
704 elm_object_item_del(item);
706 debug_log("email_addr = %s", ri->email_list[index].email_addr);
707 elm_entry_entry_set(ugd->selected_entry, ri->email_list[index].email_addr);
708 elm_entry_cursor_end_set(ugd->selected_entry);
714 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
715 if (ugd->composer_noti) {
716 evas_object_del(ugd->composer_noti);
717 ugd->composer_noti = NULL;
719 if (ugd->composer_popup) {
720 evas_object_del(ugd->composer_popup);
721 ugd->composer_popup = NULL;
723 ugd->is_mbe_selected = false;
728 void _composer_mbe_popup_move_to_to_cb(void *data, Evas_Object *obj, void *event_info)
732 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
733 Evas_Object *mbe = NULL;
734 EmailRecpInfo *ri = NULL;
736 if (ugd->selected_entry == ugd->to_mbe_entry) {
738 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
740 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
744 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
746 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
748 elm_object_item_del(item);
749 if (ri->display_name)
750 elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri);
752 elm_multibuttonentry_item_append(ugd->to_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri);
755 debug_log("ri is NULL");
759 //ugd->selected_entry = ugd->to_mbe_entry;
760 elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
763 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
765 if (ugd->composer_noti) {
766 evas_object_del(ugd->composer_noti);
767 ugd->composer_noti = NULL;
770 if (ugd->composer_popup) {
771 evas_object_del(ugd->composer_popup);
772 ugd->composer_popup = NULL;
774 ugd->is_mbe_selected = false;
777 void _composer_mbe_popup_move_to_cc_cb(void *data, Evas_Object *obj, void *event_info)
781 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
782 Evas_Object *mbe = NULL;
783 EmailRecpInfo *ri = 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 if (!ugd->cc_added) {
794 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
795 email_composer_create_cc_field(ugd);
796 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
797 email_composer_create_bcc_field(ugd);
798 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
799 ugd->b_cc_bcc = false;
802 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
804 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
806 elm_object_item_del(item);
807 if (ri->display_name)
808 elm_multibuttonentry_item_append(ugd->cc_mbe, ri->display_name, NULL, ri);
810 elm_multibuttonentry_item_append(ugd->cc_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri);
813 debug_log("ri is NULL");
817 //ugd->selected_entry = ugd->cc_mbe_entry;
818 elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
821 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
823 if (ugd->composer_noti) {
824 evas_object_del(ugd->composer_noti);
825 ugd->composer_noti = NULL;
828 if (ugd->composer_popup) {
829 evas_object_del(ugd->composer_popup);
830 ugd->composer_popup = NULL;
832 ugd->is_mbe_selected = false;
835 void _composer_mbe_popup_move_to_bcc_cb(void *data, Evas_Object *obj, void *event_info)
839 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
840 Evas_Object *mbe = NULL;
841 EmailRecpInfo *ri = NULL;
843 if (ugd->selected_entry == ugd->to_mbe_entry) {
845 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
847 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
851 if (!ugd->bcc_added) {
852 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
853 email_composer_create_bcc_field(ugd);
854 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
855 email_composer_create_cc_field(ugd);
856 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
857 ugd->b_cc_bcc = false;
860 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
862 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
864 elm_object_item_del(item);
865 if (ri->display_name)
866 elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->display_name, NULL, ri);
868 elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri);
871 debug_log("ri is NULL");
875 //ugd->selected_entry = ugd->bcc_mbe_entry;
876 elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
879 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
881 if (ugd->composer_noti) {
882 evas_object_del(ugd->composer_noti);
883 ugd->composer_noti = NULL;
886 if (ugd->composer_popup) {
887 evas_object_del(ugd->composer_popup);
888 ugd->composer_popup = NULL;
890 ugd->is_mbe_selected = false;
893 void _composer_mbe_popup_change_addr_cb(void *data, Evas_Object *obj, void *event_info)
897 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
899 EmailRecpInfo *ri = NULL;
901 Evas_Object *mbe = NULL;
905 if (ugd->selected_entry == ugd->to_mbe_entry) {
907 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
909 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
913 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
914 ugd->selected_item = item;
915 debug_log("@@@ Elm_Object_Item = %p @@@", item);
916 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
918 for (i = 0; i < ri->email_cnt; i++) {
919 snprintf(email_list[i].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ri->email_list[i].email_addr);
920 email_list[i].email_type = ri->email_list[i].email_type;
923 email_cnt = ri->email_cnt;
925 _composer_mbe_create_change_addr_list(ugd);
928 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
930 if (ugd->composer_noti) {
931 evas_object_del(ugd->composer_noti);
932 ugd->composer_noti = NULL;
935 if (ugd->composer_popup) {
936 evas_object_del(ugd->composer_popup);
937 ugd->composer_popup = NULL;
939 ugd->is_mbe_selected = false;
942 static void _composer_mbe_popup_change_addr_selected_cb(void *data, Evas_Object *obj, void *event_info)
952 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
954 int selected_idx = 0;
955 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
958 selected_idx = (int)elm_object_item_data_get(item);
959 debug_log("selected_idx = %d", selected_idx);
960 debug_log("email_addr:%s", email_list[selected_idx].email_addr);
962 EmailRecpInfo *ri = NULL;
963 Evas_Object *mbe = NULL;
965 if (ugd->selected_entry == ugd->to_mbe_entry) {
967 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
969 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
973 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe);
974 ugd->selected_item = item;
975 debug_log("@@@ Elm_Object_Item = %p @@@", item);
976 ri = (EmailRecpInfo *) elm_object_item_data_get(item);
978 ri->selected_email_idx = selected_idx;
982 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->change_addr_noti);
984 if (ugd->change_addr_noti) {
986 evas_object_del(ugd->change_addr_noti);
987 ugd->change_addr_noti = NULL;
991 char *_composer_change_addr_gl_text_get(void *data, Evas_Object *obj, const char *part)
993 int index = (int)data;
994 const char *email_str = NULL;
996 debug_log("label index = %d, email_type = %d", index, email_list[index].email_type);
998 if (!g_strcmp0(part, "elm.text")) {
999 if (email_list[index].email_type == 0)
1000 email_str = g_strconcat(_("IDS_EMAIL_OPT_OTHER"), ": ", email_list[index].email_addr, NULL);
1001 else if (email_list[index].email_type == 2)
1002 email_str = g_strconcat(dgettext("sys_string", "IDS_COM_BODY_HOME"), ": ", email_list[index].email_addr, NULL);
1003 else if (email_list[index].email_type == 4)
1004 email_str = g_strconcat(dgettext("sys_string", "IDS_COM_BODY_WORK"), ": ", email_list[index].email_addr, NULL);
1006 email_str = g_strconcat(_("IDS_EMAIL_OPT_OTHER"), ": ", email_list[index].email_addr, NULL);
1008 debug_log("email_type(%d), email_str(%s)", email_list[index].email_type, email_str);
1009 return g_strdup(email_str);
1015 void _composer_mbe_change_addr_response_cb(void *data, Evas_Object *obj, void *event_info)
1019 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1021 EmailRecpInfo *ri = NULL;
1023 Evas_Object *mbe = NULL;
1025 if (ugd->selected_entry == ugd->to_mbe_entry) {
1027 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
1029 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
1033 ri = (EmailRecpInfo *) elm_object_item_data_get(ugd->selected_item);
1035 char *pszBtnText = (char *)elm_object_text_get(obj);
1036 debug_log("selected button text = %s", pszBtnText);
1038 if (ugd->popup_list) {
1039 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1040 debug_log("obj: %p", obj);
1041 debug_log("change_addr_noti: %p", ugd->change_addr_noti);
1043 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->change_addr_noti/*obj*/);
1046 if (ugd->change_addr_noti) {
1047 evas_object_del(ugd->change_addr_noti);
1048 ugd->change_addr_noti = NULL;
1052 Eina_Bool _composer_send_mail_cb(void *data)
1056 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1058 if (ugd->send_timer) {
1059 debug_log("delete send_timer");
1060 ecore_timer_del(ugd->send_timer);
1061 ugd->send_timer = NULL;
1064 ugd->send_result = _composer_send_mail(ugd);
1066 if (ugd->selected_entry == ugd->body_ewkview) {
1067 evas_object_focus_set(ugd->body_ewkview, EINA_FALSE);
1069 Ecore_IMF_Context *imf_context = NULL;
1070 imf_context = elm_entry_imf_context_get(ugd->selected_entry);
1072 ecore_imf_context_input_panel_hide(imf_context);
1075 if (ugd->composer_noti) {
1076 evas_object_del(ugd->composer_noti);
1077 ugd->composer_noti = NULL;
1080 ugd->composer_noti = elm_popup_add(ugd->main_layout);
1081 debug_log("composer_noti: %p", ugd->composer_noti);
1082 if (!ugd->composer_noti) {
1083 debug_log("elm_popup_add returns NULL");
1087 evas_object_size_hint_weight_set(ugd->composer_noti, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1089 if (ugd->send_result == COMPOSER_ERROR_NONE) {
1090 char temp_text[128];
1091 snprintf(temp_text, sizeof(temp_text), "%s", dgettext("sys_string", "IDS_COM_POP_SENDING"));
1092 elm_object_part_text_set(ugd->composer_noti, "title,text", temp_text);
1094 Evas_Object *progressbar = elm_progressbar_add(ugd->composer_noti);
1095 elm_object_style_set(progressbar, "list_process");//"pending_list"//"list_progress"
1096 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
1097 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
1098 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1099 evas_object_show(progressbar);
1100 elm_progressbar_pulse(progressbar, EINA_TRUE);
1101 elm_object_content_set(ugd->composer_noti, progressbar);
1104 After sending, not to focus mbe.
1106 if (!ugd->b_sending)
1107 ugd->b_sending = true;
1109 evas_object_show(ugd->composer_noti);
1110 ugd->send_timer = ecore_timer_add(2.0, _composer_send_popup_finish_cb, ugd);
1111 } else if (ugd->send_result == COMPOSER_ERROR_SEND_FAIL) {
1112 if (ugd->composer_noti) {
1113 evas_object_del(ugd->composer_noti);
1114 ugd->composer_noti = NULL;
1116 ugd->composer_noti = _composer_create_noti(ugd, false, dgettext("sys_string", "IDS_COM_POP_WARNING"),
1117 _("IDS_EMAIL_POP_UNABLE_TO_SEND_EMAIL"), 0, NULL, NULL, 1.5, _composer_fail_to_send_popup_cb);
1123 Eina_Bool _composer_region_show_cb(void *data)
1125 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1127 Evas_Coord sc_width = 0, sc_height = 0;
1128 elm_scroller_region_get(ugd->main_scroller, 0, 0, &sc_width, &sc_height);
1130 Evas_Coord from_height = 0;
1132 evas_object_geometry_get(ugd->from_ly, NULL, NULL, NULL, &from_height);
1134 Evas_Coord to_height = 0;
1135 evas_object_geometry_get(ugd->to_ly, NULL, NULL, NULL, &to_height);
1137 Evas_Coord cc_height = 0;
1139 evas_object_geometry_get(ugd->cc_ly, NULL, NULL, NULL, &cc_height);
1141 Evas_Coord bcc_height = 0;
1143 evas_object_geometry_get(ugd->bcc_ly, NULL, NULL, NULL, &bcc_height);
1145 Evas_Coord sub_height = 0;
1146 evas_object_geometry_get(ugd->subject_ly, NULL, NULL, NULL, &sub_height);
1148 Evas_Coord att_height = 0;
1149 if (ugd->attachment_contracted_item)
1150 evas_object_geometry_get(ugd->attachment_contracted_item, NULL, NULL, NULL, &att_height);
1152 debug_log("scroller = w:%d, h:%d", sc_width, sc_height);
1153 debug_log("from_height = %d", from_height);
1154 debug_log(" to_height = %d", to_height);
1155 debug_log(" cc_height = %d", cc_height);
1156 debug_log(" bcc_height = %d", bcc_height);
1157 debug_log(" sub_height = %d", sub_height);
1158 debug_log(" att_height = %d", att_height);
1160 // 10 means "top_line" size. it should be modified. it should get from edc part.
1161 if (ugd->selected_entry == ugd->to_mbe_entry) {
1162 debug_log("selected_entry = to_mbe_entry");
1163 elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height, sc_width, sc_height);
1164 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
1165 debug_log("selected_entry = cc_mbe_entry");
1166 elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height, sc_width, sc_height);
1167 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
1168 debug_log("selected_entry = bcc_mbe_entry");
1169 elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height, sc_width, sc_height);
1170 } else if (ugd->selected_entry == ugd->subject_entry) {
1171 debug_log("selected_entry = subject_entry");
1172 elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height, sc_width, sc_height);
1173 } else if (ugd->selected_entry == ugd->attachment_contracted_item) {
1174 debug_log("selected_entry = attachment_contracted_item");
1175 elm_scroller_region_show(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height + sub_height, sc_width, sc_height);
1176 } else if (ugd->selected_entry == ugd->body_ewkview) {
1177 debug_log("selected_entry = body_ewkview");
1178 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);
1181 return ECORE_CALLBACK_CANCEL;
1184 Eina_Bool _composer_bringin_cb(void *data)
1186 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1188 Evas_Coord sc_width = 0, sc_height = 0;
1189 elm_scroller_region_get(ugd->main_scroller, 0, 0, &sc_width, &sc_height);
1191 Evas_Coord from_height = 0;
1193 evas_object_geometry_get(ugd->from_ly, NULL, NULL, NULL, &from_height);
1195 Evas_Coord to_height = 0;
1196 evas_object_geometry_get(ugd->to_ly, NULL, NULL, NULL, &to_height);
1198 Evas_Coord cc_height = 0;
1200 evas_object_geometry_get(ugd->cc_ly, NULL, NULL, NULL, &cc_height);
1202 Evas_Coord bcc_height = 0;
1204 evas_object_geometry_get(ugd->bcc_ly, NULL, NULL, NULL, &bcc_height);
1206 Evas_Coord sub_height = 0;
1207 evas_object_geometry_get(ugd->subject_ly, NULL, NULL, NULL, &sub_height);
1209 Evas_Coord att_height = 0;
1210 if (ugd->attachment_contracted_item)
1211 evas_object_geometry_get(ugd->attachment_contracted_item, NULL, NULL, NULL, &att_height);
1213 debug_log("scroller = w:%d, h:%d", sc_width, sc_height);
1214 debug_log("from_height = %d", from_height);
1215 debug_log(" to_height = %d", to_height);
1216 debug_log(" cc_height = %d", cc_height);
1217 debug_log(" bcc_height = %d", bcc_height);
1218 debug_log(" sub_height = %d", sub_height);
1219 debug_log(" att_height = %d", att_height);
1221 // 10 means "top_line" size. it should be modified. it should get from edc part.
1222 if (ugd->selected_entry == ugd->to_mbe_entry) {
1223 debug_log("selected_entry = to_mbe_entry");
1224 elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height, sc_width, sc_height);
1225 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
1226 debug_log("selected_entry = cc_mbe_entry");
1227 elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height, sc_width, sc_height);
1228 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
1229 debug_log("selected_entry = bcc_mbe_entry");
1230 elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height, sc_width, sc_height);
1231 } else if (ugd->selected_entry == ugd->subject_entry) {
1232 debug_log("selected_entry = subject_entry");
1233 elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height, sc_width, sc_height);
1234 } else if (ugd->selected_entry == ugd->attachment_contracted_item) {
1235 debug_log("selected_entry = attachment_contracted_item");
1236 elm_scroller_region_bring_in(ugd->main_scroller, 0, 10 + from_height + to_height + cc_height + bcc_height + sub_height, sc_width, sc_height);
1237 } else if (ugd->selected_entry == ugd->body_ewkview) {
1238 debug_log("selected_entry = body_ewkview");
1239 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);
1242 if (ugd->bringin_timer) {
1243 ecore_timer_del(ugd->bringin_timer);
1244 ugd->bringin_timer = NULL;
1247 return ECORE_CALLBACK_CANCEL;
1250 Eina_Bool _composer_mbe_popup_del(void *data)
1253 Evas_Object *obj = (Evas_Object *)data;
1255 evas_object_del(obj);
1261 Eina_Bool _composer_mbe_create_change_addr_list(EmailComposerUGD *ugd)
1265 if (ugd->change_addr_noti) {
1266 evas_object_del(ugd->change_addr_noti);
1267 ugd->change_addr_noti = NULL;
1269 ugd->change_addr_noti = _composer_create_noti(ugd, false, _("IDS_EMAIL_HEADER_SELECT_EMAIL_ADDRESS"), NULL, 1,
1270 dgettext("sys_string", "IDS_COM_SK_CANCEL"), NULL, 0.0, _composer_mbe_change_addr_response_cb);
1272 #ifdef _POPUP_WITH_LIST
1273 elm_object_style_set(ugd->change_addr_noti, "min_menustyle");
1275 elm_object_style_set(ugd->change_addr_noti, "menustyle");
1277 elm_object_focus_allow_set(ugd->change_addr_noti, EINA_FALSE);
1279 Elm_Object_Item *gen_item;
1280 Evas_Object *genlist;
1283 itc.item_style = "1text";
1284 itc.func.text_get = _composer_change_addr_gl_text_get;
1285 itc.func.content_get = NULL;
1286 itc.func.state_get = NULL;
1287 itc.func.del = NULL;
1289 genlist = elm_genlist_add(ugd->change_addr_noti);
1291 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1292 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1294 debug_log("ri->email_cnt = %d", email_cnt);
1296 for (index = 0; index < email_cnt; index++) {
1297 gen_item = elm_genlist_item_append(genlist, &itc, (void *)index, NULL, ELM_GENLIST_ITEM_NONE, _composer_mbe_popup_change_addr_selected_cb, ugd);
1299 elm_object_item_data_set(gen_item, (void *)index);
1300 elm_genlist_item_update(gen_item);
1303 // elm_genlist_effect_set(genlist, EINA_FALSE);
1304 elm_genlist_tree_effect_enabled_set(genlist, EINA_FALSE);
1306 #ifdef _POPUP_WITH_LIST
1307 debug_log("index:%d", index);
1310 Evas_Object *box = elm_box_add(ugd->change_addr_noti);
1311 evas_object_size_hint_min_set(box, 610 * elm_scale_get(), 114 * index * elm_scale_get());
1312 evas_object_show(genlist);
1313 elm_box_pack_end(box, genlist);
1314 elm_object_content_set(ugd->change_addr_noti, box);
1316 elm_object_content_set(ugd->change_addr_noti, genlist);
1322 Eina_Bool _composer_send_popup_finish_cb(void *data)
1325 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1327 if (elm_multibuttonentry_first_item_get(ugd->to_mbe))
1328 elm_multibuttonentry_clear(ugd->to_mbe);
1329 if (elm_multibuttonentry_first_item_get(ugd->cc_mbe))
1330 elm_multibuttonentry_clear(ugd->cc_mbe);
1331 if (elm_multibuttonentry_first_item_get(ugd->bcc_mbe))
1332 elm_multibuttonentry_clear(ugd->bcc_mbe);
1334 _composer_popup_end(ugd, ugd->send_result);
1338 void _composer_fail_to_send_popup_cb(void *data, Evas_Object *obj, void *event_info)
1341 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1343 if (ugd->popup_list) {
1344 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1345 debug_log("obj: %p", obj);
1346 debug_log("composer_noti: %p", ugd->composer_noti);
1348 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1351 if (ugd->composer_noti) {
1352 evas_object_del(ugd->composer_noti);
1353 ugd->composer_noti = NULL;
1356 elm_object_disabled_set(ugd->send_btn, EINA_FALSE);
1357 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE);
1359 ugd->bSendBtnDisabled = false;
1362 static void *_composer_contact_search_by_email(EmailComposerUGD *ugd, const char *search_word)
1365 if (!ugd || !g_ugd) {
1366 debug_log("data is NULL");
1370 int ret = CTS_SUCCESS;
1371 CTSiter *iter = NULL;
1373 EMAIL_CONTACT_LIST_INFO_S *contacts_list_item = NULL;
1374 contacts_svc_connect();
1376 debug_log("search_word = %s", search_word);
1378 if (contacts_svc_get_list_with_str(CTS_LIST_EMAILINFOS_WITH_EMAIL, search_word, &iter) != CTS_SUCCESS) {
1382 ret = contacts_svc_iter_next(iter);
1384 if (CTS_SUCCESS == ret) {
1385 CTSvalue *row_info = NULL;
1387 row_info = contacts_svc_iter_get_info(iter);
1389 contacts_list_item = (EMAIL_CONTACT_LIST_INFO_S *)calloc(1, sizeof(EMAIL_CONTACT_LIST_INFO_S));
1391 int index = contacts_svc_value_get_int(row_info, CTS_LIST_EMAIL_CONTACT_ID_INT);
1393 contacts_list_item->index = index;
1394 contacts_list_item->first_name = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_FIRST_STR));
1395 contacts_list_item->last_name = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_LAST_STR));
1396 contacts_list_item->image_path = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_IMG_PATH_STR));
1397 contacts_list_item->email_address = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_ADDR_STR));
1399 char *first = contacts_list_item->first_name;
1400 char *last = contacts_list_item->last_name;
1401 char *display = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR));
1404 if (first != NULL && last != NULL) {
1405 if (CTS_ORDER_NAME_FIRSTLAST == contacts_svc_get_order(CTS_ORDER_OF_DISPLAY)) {
1406 display = g_strconcat(first, " ", last, NULL);
1408 display = g_strconcat(last, " ", first, NULL);
1410 } else if (first != NULL || last != NULL) {
1411 display = (first != NULL) ? g_strdup(first) : g_strdup(last);
1413 display = g_strdup(" ");
1417 snprintf(contacts_list_item->display_name, sizeof(contacts_list_item->display_name), "%s", display);
1420 /*contacts_list = eina_list_append(contacts_list, contacts_list_item);*/
1423 contacts_svc_value_free(row_info);
1426 /*ret = contacts_svc_iter_next(iter);*/
1427 contacts_svc_iter_remove(iter);
1430 contacts_svc_disconnect();
1432 return contacts_list_item;
1435 static void _composer_delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item)
1439 if (contacts_list_item) {
1440 g_free(contacts_list_item->first_name);
1441 contacts_list_item->first_name = NULL;
1442 g_free(contacts_list_item->last_name);
1443 contacts_list_item->last_name = NULL;
1444 g_free(contacts_list_item->email_address);
1445 contacts_list_item->email_address = NULL;
1446 g_free(contacts_list_item->image_path);
1447 contacts_list_item->image_path = NULL;
1448 g_free(contacts_list_item);
1449 contacts_list_item = NULL;
1453 void _composer_check_email_address(EmailComposerUGD *ugd, Evas_Object *entry)
1457 char *temp = elm_entry_markup_to_utf8(elm_entry_entry_get(entry));
1462 debug_log("temp = %s, edit_mode = %d", temp, edit_mode);
1464 if (edit_mode == true) {
1470 if (strlen(temp) == 0) {
1472 _composer_ps_stop(ugd);
1473 ugd->sc_timer = ecore_timer_add(0.5, _composer_ps_scroll_pop, ugd);
1475 } else if (strlen(temp)) {
1476 debug_log("temp = %s", temp);
1478 memset(ugd->ps_keyword, 0x00, sizeof(ugd->ps_keyword));
1479 strncpy(ugd->ps_keyword, temp, sizeof(ugd->ps_keyword) - 1);
1481 /*if (ugd->ps_bg_timer) {
1482 ecore_timer_del(ugd->ps_bg_timer);
1483 ugd->ps_bg_timer = NULL;
1485 _composer_ps_add_timer(ugd);
1491 void _composer_check_entry_max(EmailComposerUGD *ugd, Evas_Object *entry, int max_len)
1494 const char *temp = elm_entry_entry_get(entry);
1496 debug_log("subject len = %d", strlen(temp));
1497 if (strlen(temp) >= max_len) {
1498 debug_log("Subject length is Over");
1500 char subject[MAX_SUBJECT_LEN] = { 0, };
1501 strncpy(subject, temp, sizeof(subject) - 1);
1503 elm_entry_entry_set(entry, subject);
1504 elm_entry_cursor_end_set(entry);
1506 if (ugd->composer_noti) {
1507 evas_object_del(ugd->composer_noti);
1508 ugd->composer_noti = NULL;
1510 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);
1514 void _composer_from_show_popup(EmailComposerUGD *ugd)
1518 Elm_Object_Item *gen_item;
1523 if (ugd->composer_noti) {
1524 evas_object_del(ugd->composer_noti);
1525 ugd->composer_noti = NULL;
1527 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);
1529 #ifdef _POPUP_WITH_LIST
1530 elm_object_style_set(ugd->composer_noti, "min_menustyle");
1532 elm_object_style_set(ugd->composer_noti, "menustyle");
1534 elm_object_focus_allow_set(ugd->composer_noti, EINA_FALSE);
1536 from_itc.item_style = "email.2text.3icon.3";
1537 from_itc.func.text_get = _composer_from_gl_text_get;
1538 from_itc.func.content_get = _composer_from_gl_content_get;
1539 from_itc.func.state_get = NULL;
1540 from_itc.func.del = NULL;
1542 elm_genlist_clear(ugd->account_gen_list);
1543 ugd->account_gen_list = elm_genlist_add(ugd->composer_noti);
1544 elm_object_theme_set(ugd->account_gen_list, ugd->th);
1546 evas_object_size_hint_weight_set(ugd->account_gen_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1547 evas_object_size_hint_align_set(ugd->account_gen_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1549 for (acc_index = 0; acc_index < ugd->account_info->account_count; acc_index++) {
1550 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);
1553 // elm_genlist_effect_set(ugd->account_gen_list, EINA_FALSE);
1554 elm_genlist_tree_effect_enabled_set(ugd->account_gen_list, EINA_FALSE);
1556 #ifdef _POPUP_WITH_LIST
1557 debug_log("acc_index:%d", acc_index);
1560 Evas_Object *box = elm_box_add(ugd->composer_noti);
1561 evas_object_size_hint_min_set(box, 610 * elm_scale_get(), 122 * acc_index * elm_scale_get());
1562 evas_object_show(ugd->account_gen_list);
1563 elm_box_pack_end(box, ugd->account_gen_list);
1564 elm_object_content_set(ugd->composer_noti, box);
1566 elm_object_content_set(ugd->composer_noti, ugd->account_gen_list);
1570 char *_composer_from_gl_text_get(void *data, Evas_Object *obj, const char *part)
1572 int index = (int)data;
1574 debug_log("label index = %d", index);
1576 if (!strncmp(part, "elm.text.1", 10)) {
1577 debug_log("email_addr = %s", g_ugd->account_info->account_list[index].account_name);
1578 return g_strdup(g_ugd->account_info->account_list[index].account_name);
1579 } else if (!strncmp(part, "elm.text.2", 10)) {
1580 debug_log("email_addr = %s", g_ugd->account_info->account_list[index].user_email_address);
1581 return g_strdup(g_ugd->account_info->account_list[index].user_email_address);
1583 debug_log("part is invalid");
1589 Evas_Object *_composer_from_gl_content_get(void *data, Evas_Object *obj, const char *part)
1591 int count = (int)data;
1593 debug_log("count = %d", count);
1594 debug_log("account_id = %d", g_ugd->account_info->account_list[count].account_id);
1595 debug_log("default account_id = %d", g_ugd->account_info->account_id);
1597 if (!strncmp(part, "elm.icon.1", 10)) {
1598 g_ugd->account_info->account_rd[count] = elm_radio_add(obj);
1599 elm_radio_state_value_set(g_ugd->account_info->account_rd[count], count);
1602 g_ugd->account_info->account_rdg = g_ugd->account_info->account_rd[count];
1604 elm_radio_group_add(g_ugd->account_info->account_rd[count], g_ugd->account_info->account_rdg);
1606 if (g_ugd->account_info->account_list[count].account_id == g_ugd->account_info->account_id)
1607 elm_radio_value_set(g_ugd->account_info->account_rdg, count);
1609 evas_object_smart_callback_add(g_ugd->account_info->account_rd[count], "changed", _composer_from_radio_cb, g_ugd);
1611 return g_ugd->account_info->account_rd[count];
1612 } else if (!strncmp(part, "elm.icon.2", 10)) {
1613 Evas_Object *icon = elm_icon_add(obj);
1615 // setting/include/email-setting.h
1624 account_user_data_t *ud = (account_user_data_t *)g_ugd->account_info->account_list[count].user_data;
1625 debug_log("is_preset_account:%d", ud->is_preset_account);
1627 switch (ud->is_preset_account) {
1629 elm_icon_file_set(icon, ACCOUNT_ICON_GMAIL, NULL);
1632 elm_icon_file_set(icon, ACCOUNT_ICON_HOTMAIL, NULL);
1635 elm_icon_file_set(icon, ACCOUNT_ICON_YAHOO, NULL);
1638 elm_icon_file_set(icon, ACCOUNT_ICON_AOL, NULL);
1642 elm_icon_file_set(icon, ACCOUNT_ICON_OTHERS, NULL);
1645 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1648 } else if (!strncmp(part, "elm.swallow.colorbar", 20)) {
1649 account_user_data_t *ud = (account_user_data_t *)g_ugd->account_info->account_list[count].user_data;
1650 unsigned int val = ud->index_color;
1651 int r = (val & 0xff000000) >> 24;
1652 int g = (val & 0x00ff0000) >> 16;
1653 int b = (val & 0x0000ff00) >> 8;
1654 int a = val & 0x000000ff;
1656 Evas_Object *color_bar = evas_object_rectangle_add(evas_object_evas_get(obj));
1657 evas_object_size_hint_fill_set(color_bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
1658 evas_object_color_set(color_bar, r, g, b, a);
1662 debug_log("part is invalid");
1668 static void _composer_from_gl_sel(void *data, Evas_Object *obj, void *event_info)
1672 int index = (int)data;
1674 elm_radio_value_set(g_ugd->account_info->account_rdg, index);
1676 _composer_from_close_response_cb(g_ugd);
1679 static void _composer_from_change_response_cb(void *data, Evas_Object *obj, void *event_info)
1681 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
1683 debug_log("composer_noti : %p", ugd->composer_noti);
1685 char *pszBtnText = (char *)elm_object_text_get(obj);
1686 debug_log("selected button text = %s", pszBtnText);
1688 if (pszBtnText && strcmp(pszBtnText, dgettext("sys_string", "IDS_COM_SK_OK")) == 0) {
1689 int set_val = elm_radio_value_get(ugd->account_info->account_rdg);
1691 debug_log("set_val = %d", set_val);
1692 debug_log("account_type: %d", ugd->account_info->account_list[set_val].incoming_server_type);
1694 ugd->account_info->account_id = ugd->account_info->account_list[set_val].account_id;
1696 if (ugd->account_info->account_name) {
1697 g_free(ugd->account_info->account_name);
1698 ugd->account_info->account_name = NULL;
1701 ugd->account_info->account_name = g_strdup(ugd->account_info->account_list[set_val].user_email_address);
1703 debug_log("account_id = %d", ugd->account_info->account_id);
1705 debug_log("priority = %d", (*ugd->account_info->account).options.priority);
1707 Elm_Object_Item *from_item = NULL;
1708 from_item = elm_multibuttonentry_first_item_get(ugd->from_mbe);
1710 EmailRecpInfo *from_ri = NULL;
1713 from_ri = elm_object_item_data_get(from_item);
1715 debug_log("from_ri = %s", from_ri->email_list[0].email_addr);
1718 debug_log("add_my_address_to_bcc = %d", ugd->account_info->account->options.add_my_address_to_bcc);
1720 #ifdef _ALWAYS_CC_MYSELF
1721 debug_log("remove bcc myself if it is");
1722 Elm_Object_Item *bcc_item = NULL;
1723 bcc_item = elm_multibuttonentry_first_item_get(ugd->bcc_mbe);
1726 EmailRecpInfo *bcc_ri = NULL;
1729 bcc_ri = (EmailRecpInfo *) elm_object_item_data_get(bcc_item);
1731 index = bcc_ri->selected_email_idx;
1733 debug_log("bcc_ri email_addr = %s", bcc_ri->email_list[index].email_addr);
1735 if ((g_strcmp0(bcc_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr) == 0) && (bcc_ri->is_always_bcc == true)) {
1736 elm_object_item_del(bcc_item);
1740 bcc_item = elm_multibuttonentry_item_next_get(bcc_item);
1743 debug_log("remove cc myself if it is");
1744 Elm_Object_Item *cc_item = NULL;
1745 cc_item = elm_multibuttonentry_first_item_get(ugd->cc_mbe);
1748 EmailRecpInfo *cc_ri = NULL;
1751 cc_ri = (EmailRecpInfo *) elm_object_item_data_get(cc_item);
1753 index = cc_ri->selected_email_idx;
1755 debug_log("cc_ri email_addr = %s", cc_ri->email_list[index].email_addr);
1757 if ((g_strcmp0(cc_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr) == 0) && (cc_ri->is_always_bcc == true)) {
1758 elm_object_item_del(cc_item);
1762 cc_item = elm_multibuttonentry_item_next_get(cc_item);
1765 if (ugd->account_info->account->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_BCC) {
1766 debug_log("always bcc on");
1767 EmailRecpInfo *new_bcc_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
1769 new_bcc_ri->selected_email_idx = 0;
1770 new_bcc_ri->display_name = ugd->account_info->account->user_display_name;
1771 snprintf(new_bcc_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account->user_email_address);
1772 new_bcc_ri->email_cnt = 1;
1773 new_bcc_ri->is_contact_info = false;
1774 new_bcc_ri->is_always_bcc = true;
1775 new_bcc_ri->is_from_addr = false;
1777 bcc_item = elm_multibuttonentry_first_item_get(ugd->bcc_mbe);
1778 elm_multibuttonentry_item_insert_before(ugd->bcc_mbe, bcc_item, g_strdup(new_bcc_ri->display_name), NULL, new_bcc_ri);
1779 } else if (ugd->account_info->account->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_CC) {
1780 debug_log("always cc on");
1781 EmailRecpInfo *new_cc_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
1783 new_cc_ri->selected_email_idx = 0;
1784 new_cc_ri->display_name = ugd->account_info->account->user_display_name;
1785 snprintf(new_cc_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account->user_email_address);
1786 new_cc_ri->email_cnt = 1;
1787 new_cc_ri->is_contact_info = false;
1788 new_cc_ri->is_always_bcc = true;
1789 new_cc_ri->is_from_addr = false;
1791 cc_item = elm_multibuttonentry_first_item_get(ugd->cc_mbe);
1792 elm_multibuttonentry_item_insert_before(ugd->cc_mbe, cc_item, g_strdup(new_cc_ri->display_name), NULL, new_cc_ri);
1794 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("obj: %p", obj);
1830 debug_log("composer_noti: %p", ugd->composer_noti);
1832 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
1835 if (ugd->composer_noti) {
1836 debug_log("@@@ ELM_POPUP_RESPONSE_CLOSE @@@");
1837 _composer_popup_delete(ugd->composer_noti);
1838 ugd->composer_noti = NULL;
1843 static void _composer_from_close_response_cb(EmailComposerUGD *ugd)
1845 debug_log("composer_noti : %p", ugd->composer_noti);
1847 int set_val = elm_radio_value_get(ugd->account_info->account_rdg);
1849 debug_log("set_val = %d", set_val);
1851 ugd->account_info->account_id = ugd->account_info->account_list[set_val].account_id;
1853 if (ugd->account_info->account_name) {
1854 g_free(ugd->account_info->account_name);
1855 ugd->account_info->account_name = NULL;
1858 ugd->account_info->account_name = g_strdup(ugd->account_info->account_list[set_val].user_email_address);
1860 debug_log("account_id = %d", ugd->account_info->account_id);
1862 debug_log("priority = %d", (*ugd->account_info->account).options.priority);
1864 Elm_Object_Item *from_item = NULL;
1865 from_item = elm_multibuttonentry_first_item_get(ugd->from_mbe);
1867 EmailRecpInfo *from_ri = NULL;
1870 from_ri = elm_object_item_data_get(from_item);
1872 debug_log("from_ri = %s", from_ri->email_list[0].email_addr);
1875 debug_log("add_my_address_to_bcc = %d", ugd->account_info->account->options.add_my_address_to_bcc);
1877 #ifdef _ALWAYS_CC_MYSELF
1878 debug_log("remove bcc myself if it is");
1879 Elm_Object_Item *bcc_item = NULL;
1880 bcc_item = elm_multibuttonentry_first_item_get(ugd->bcc_mbe);
1883 EmailRecpInfo *bcc_ri = NULL;
1886 bcc_ri = (EmailRecpInfo *) elm_object_item_data_get(bcc_item);
1888 index = bcc_ri->selected_email_idx;
1890 debug_log("bcc_ri email_addr = %s", bcc_ri->email_list[index].email_addr);
1892 if ((g_strcmp0(bcc_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr) == 0) && (bcc_ri->is_always_bcc == true)) {
1893 elm_object_item_del(bcc_item);
1897 bcc_item = elm_multibuttonentry_item_next_get(bcc_item);
1900 debug_log("remove cc myself if it is");
1901 Elm_Object_Item *cc_item = NULL;
1902 cc_item = elm_multibuttonentry_first_item_get(ugd->cc_mbe);
1905 EmailRecpInfo *cc_ri = NULL;
1908 cc_ri = (EmailRecpInfo *) elm_object_item_data_get(cc_item);
1910 index = cc_ri->selected_email_idx;
1912 debug_log("cc_ri email_addr = %s", cc_ri->email_list[index].email_addr);
1914 if ((g_strcmp0(cc_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr) == 0) && (cc_ri->is_always_bcc == true)) {
1915 elm_object_item_del(cc_item);
1919 cc_item = elm_multibuttonentry_item_next_get(cc_item);
1922 if (ugd->account_info->account->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_BCC) {
1923 debug_log("always bcc on");
1924 EmailRecpInfo *new_bcc_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
1926 new_bcc_ri->selected_email_idx = 0;
1927 new_bcc_ri->display_name = ugd->account_info->account->user_display_name;
1928 snprintf(new_bcc_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account->user_email_address);
1929 new_bcc_ri->email_cnt = 1;
1930 new_bcc_ri->is_contact_info = false;
1931 new_bcc_ri->is_always_bcc = true;
1932 new_bcc_ri->is_from_addr = false;
1934 bcc_item = elm_multibuttonentry_first_item_get(ugd->bcc_mbe);
1935 elm_multibuttonentry_item_insert_before(ugd->bcc_mbe, bcc_item, g_strdup(new_bcc_ri->display_name), NULL, new_bcc_ri);
1936 } else if (ugd->account_info->account->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_CC) {
1937 debug_log("always cc on");
1938 EmailRecpInfo *new_cc_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
1940 new_cc_ri->selected_email_idx = 0;
1941 new_cc_ri->display_name = ugd->account_info->account->user_display_name;
1942 snprintf(new_cc_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account->user_email_address);
1943 new_cc_ri->email_cnt = 1;
1944 new_cc_ri->is_contact_info = false;
1945 new_cc_ri->is_always_bcc = true;
1946 new_cc_ri->is_from_addr = false;
1948 cc_item = elm_multibuttonentry_first_item_get(ugd->cc_mbe);
1949 elm_multibuttonentry_item_insert_before(ugd->cc_mbe, cc_item, g_strdup(new_cc_ri->display_name), NULL, new_cc_ri);
1951 debug_log("always bcc/cc off");
1955 EmailRecpInfo *new_from_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
1957 new_from_ri->selected_email_idx = 0;
1958 new_from_ri->display_name = ugd->account_info->account_list[set_val].user_display_name;
1959 snprintf(new_from_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account_list[set_val].user_email_address);
1960 new_from_ri->email_cnt = 1;
1961 new_from_ri->is_contact_info = false;
1962 new_from_ri->is_always_bcc = false;
1963 new_from_ri->is_from_addr = true;
1965 elm_object_item_del(from_item);
1967 elm_multibuttonentry_item_append(ugd->from_mbe, g_strdup(new_from_ri->display_name), NULL, new_from_ri);
1969 if (ugd->selected_entry == ugd->to_mbe_entry) {
1970 elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
1971 } else if (ugd->selected_entry == ugd->cc_mbe_entry) {
1972 elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
1973 } else if (ugd->selected_entry == ugd->bcc_mbe_entry) {
1974 elm_object_focus_set(ugd->bcc_mbe, EINA_TRUE);
1977 if (ugd->account_gen_list) {
1978 elm_genlist_clear(ugd->account_gen_list);
1980 evas_object_del(ugd->account_gen_list);
1981 ugd->account_gen_list = NULL;
1984 if (ugd->popup_list) {
1985 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
1986 debug_log("composer_noti: %p", ugd->composer_noti);
1988 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti);
1991 if (ugd->composer_noti) {
1992 debug_log("@@@ ELM_POPUP_RESPONSE_CLOSE @@@");
1993 _composer_popup_delete(ugd->composer_noti);
1994 ugd->composer_noti = NULL;
1998 static void _composer_from_radio_cb(void *data, Evas_Object *obj, void *event_info)
2002 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2005 for (i = 0; i < ugd->account_info->account_count; i++) {
2006 if (obj == ugd->account_info->account_rd[i]) {
2007 debug_log("account_id = %d", ugd->account_info->account_list[i].account_id);
2008 elm_radio_value_set(ugd->account_info->account_rdg, i);
2013 void _composer_cbar_cc_clicked(void *data, Evas_Object *obj, void *event_info)
2017 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2019 if (ugd->cc_added) {
2020 if (ugd->b_cc_bcc) {
2021 debug_log("b_cc_bcc is ON");
2025 edje_object_signal_emit(_EDJ(ugd->c_layout), "hide.cc", "*");
2026 email_composer_delete_cc_field(ugd);
2027 edje_object_signal_emit(_EDJ(ugd->c_layout), "hide.bcc", "*");
2028 email_composer_delete_bcc_field(ugd);
2029 elm_object_text_set(ugd->cc_btn, _("IDS_EMAIL_OPT_ADD_CC_BCC"));
2031 if (ugd->b_cc_ps_open == true) {
2032 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
2033 ugd->b_cc_ps_open = false;
2036 ugd->b_cc_bcc = false;
2038 elm_layout_sizing_eval(ugd->c_layout);
2040 if (!_composer_check_popup_exist(ugd)) {
2041 ugd->idler_set_focus = ecore_idler_add(_composer_mbe_set_focus, ugd);
2044 if (ugd->b_cc_bcc) {
2045 debug_log("b_cc_bcc is ON");
2049 if (ugd->clipboard_on) {
2050 ugd->clipboard_on = false;
2053 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2054 email_composer_create_cc_field(ugd);
2055 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.bcc", "*");
2056 email_composer_create_bcc_field(ugd);
2057 elm_object_text_set(ugd->cc_btn, N_("Remove Cc/Bcc"));
2059 elm_layout_sizing_eval(ugd->c_layout);
2061 ugd->idler_set_focus = ecore_idler_add(_composer_cc_mbe_set_focus, ugd);
2065 void _composer_cbar_add_me_clicked(void *data, Evas_Object *obj, void *event_info)
2068 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2070 if (ugd->me_added == false) {
2071 EmailRecpInfo *from_ri = NULL;
2072 Elm_Object_Item *from_item = NULL;
2073 from_item = elm_multibuttonentry_first_item_get(ugd->from_mbe);
2076 from_ri = elm_object_item_data_get(from_item);
2078 debug_log("from_ri = %s", from_ri->email_list[0].email_addr);
2081 Elm_Object_Item *to_item = NULL;
2082 to_item = elm_multibuttonentry_first_item_get(ugd->to_mbe);
2085 EmailRecpInfo *to_ri = NULL;
2088 to_ri = (EmailRecpInfo *) elm_object_item_data_get(to_item);
2090 index = to_ri->selected_email_idx;
2092 debug_log("to_ri email_addr = %s", to_ri->email_list[index].email_addr);
2094 debug_log("account name = %s", ugd->account_info->account_name);
2096 if (g_strcmp0(to_ri->email_list[index].email_addr, from_ri->email_list[0].email_addr) == 0) {
2097 elm_object_item_del(to_item);
2101 if (g_strcmp0(to_ri->email_list[index].email_addr, ugd->account_info->account_name) == 0) {
2102 elm_object_item_del(to_item);
2107 to_item = elm_multibuttonentry_item_next_get(to_item);
2110 EmailRecpInfo *new_to_ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo));
2112 new_to_ri->selected_email_idx = 0;
2113 new_to_ri->display_name = ugd->account_info->account->user_display_name;
2114 snprintf(new_to_ri->email_list[0].email_addr, MAX_RECIPIENT_ADDRESS_LEN, "%s", ugd->account_info->account->user_email_address);
2115 new_to_ri->email_cnt = 1;
2116 new_to_ri->is_contact_info = false;
2117 new_to_ri->is_always_bcc = false;
2118 new_to_ri->is_from_addr = true;
2120 to_item = elm_multibuttonentry_first_item_get(ugd->to_mbe);
2121 elm_multibuttonentry_item_insert_before(ugd->to_mbe, to_item, g_strdup(new_to_ri->display_name), NULL, new_to_ri);
2123 elm_object_text_set(ugd->add_me_btn, N_("Remove me"));
2125 ugd->me_added = true;
2127 Elm_Object_Item *to_item = NULL;
2128 to_item = elm_multibuttonentry_first_item_get(ugd->to_mbe);
2130 elm_object_item_del(to_item);
2131 ugd->me_added = false;
2132 elm_object_text_set(ugd->add_me_btn, N_("Add me"));
2136 if (ugd->selected_entry == ugd->to_mbe_entry) {
2137 elm_object_focus_set(ugd->to_mbe, EINA_TRUE);
2141 static void _composer_cbar_save_as_draft_cb(Evas_Object *o, const char *result, void *data)
2144 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2146 if (NULL != ugd->latest_html_content) {
2147 g_free(ugd->latest_html_content);
2148 ugd->latest_html_content = NULL;
2151 ugd->latest_html_content = g_strdup(result);
2152 debug_log("ugd->latest_html_content => %s", ugd->latest_html_content);
2154 if (EINA_FALSE == ewk_view_plain_text_get(ugd->body_ewkview, _composer_plain_text_get_cb, (void *)ugd)) {
2155 debug_log("ewk_view_plain_text_get Failed");
2158 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_IMAGE_LIST, _composer_get_image_list_cb, (void *)ugd)) {
2159 debug_log("COMPOSER_JS_GET_IMAGE_LIST error.");
2162 if (ugd->timeout_noti) {
2163 debug_log("delete timeout_noti");
2164 evas_object_del(ugd->timeout_noti);
2165 ugd->timeout_noti = NULL;
2168 if (ugd->composer_noti) {
2169 debug_log("delete composer_noti");
2170 evas_object_del(ugd->composer_noti);
2171 ugd->composer_noti = NULL;
2175 debug_log("ps stop");
2176 _composer_ps_stop(ugd);
2177 ugd->sc_timer = ecore_timer_add(0.5, _composer_ps_scroll_pop, ugd);
2180 if (ugd->selected_entry == ugd->body_ewkview) {
2181 evas_object_focus_set(ugd->body_ewkview, EINA_FALSE);
2183 Ecore_IMF_Context *imf_context = NULL;
2184 imf_context = elm_entry_imf_context_get(ugd->selected_entry);
2186 ecore_imf_context_input_panel_hide(imf_context);
2189 if (_composer_check_mail_is_modified(ugd)) {
2190 debug_log("mail is changed.");
2191 ugd->save_drafts = 1;
2193 debug_log("mail is NOT changed.");
2194 ugd->save_drafts = 0;
2196 char str[128] = { 0, };
2197 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_OPT_COMPOSE_EMAIL"));
2198 int ret = status_message_post(str);
2200 debug_log("status_message_post failed: %d", ret);
2202 _composer_mbe_set_focus(ugd);
2206 debug_log("account_type: %d", ugd->account_info->account_type);
2208 int ret = _composer_add_mailbox_folder(ugd, EMAIL_MAILBOX_TYPE_DRAFT);
2210 if (ret < COMPOSER_ERROR_NONE) {
2211 debug_log("Failed save in Drafts(%d)", ret);
2213 if (ugd->popup_list) {
2214 debug_log("popup count = %d", eina_list_count(ugd->popup_list));
2215 debug_log("obj: %p", o);
2216 debug_log("composer_noti: %p", ugd->composer_noti);
2218 ugd->popup_list = eina_list_remove(ugd->popup_list, ugd->composer_noti/*obj*/);
2221 evas_object_del(ugd->composer_noti);
2222 ugd->composer_noti = NULL;
2224 ugd->idler_save_draft = ecore_idler_add(_composer_show_fail_to_save, ugd);
2226 debug_log("Succeed in saving in Drafts");
2228 debug_log("composer_type:%d", ugd->composer_type);
2229 if (ugd->composer_type == RUN_COMPOSER_EDIT) {
2230 //After a new draft mail is added, the old draft mail is deleted and synced to server
2231 debug_log("Account id [%d] mailbox id [%d] mail id [%d]", ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID);
2233 if (!email_engine_delete_mail(ugd->account_info->account->account_id, ugd->mailbox_info->mailbox_id, ugd->nExistingMailID, EMAIL_DELETE_LOCAL_AND_SERVER)) {
2234 debug_log("Deleting email is failed.");
2238 char str[128] = { 0, };
2239 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_SAVED_IN_DRAFTS"));
2240 int ret = status_message_post(str);
2242 debug_log("status_message_post failed: %d", ret);
2244 ug_destroy_me(ugd->ug_main);
2248 void _composer_cbar_save_as_draft_clicked(void *data, Evas_Object *obj, void *event_info)
2253 debug_log("data is NULL");
2257 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2259 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_HTML_CONTENT, _composer_cbar_save_as_draft_cb, (void *)ugd))
2260 debug_log("COMPOSER_JS_GET_HTML_CONTENT failed.");
2263 static void _composer_priority_radio_cb(void *data, Evas_Object *obj, void *event_info)
2267 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2270 for (i = 0; i < 3; i++) {
2271 if (obj == ugd->priority_rd[i]) {
2272 elm_radio_value_set(ugd->priority_rdg, i);
2277 static char *_composer_priority_gl_text_get(void *data, Evas_Object *obj, const char *part)
2279 int index = (int)data;
2281 debug_log("\n text index = %d", index);
2283 if (!g_strcmp0(part, "elm.text")) {
2285 return strdup(_("IDS_EMAIL_BODY_HIGH_M_PRIORITY"));
2286 else if (index == 1)
2287 return strdup(_("IDS_EMAIL_BODY_NORMAL_M_EMAILPRIORITY"));
2288 else if (index == 2)
2289 return strdup(_("IDS_EMAIL_BODY_LOW_M_EMAILPRIORITY"));
2294 static Evas_Object *_composer_priority_gl_content_get(void *data, Evas_Object *obj, const char *part)
2296 int index = (int)data;
2298 debug_log("\n content index = %d", index);
2300 if (!strcmp(part, "elm.icon") || !strcmp(part, "elm.swallow.icon")) {
2301 g_ugd->priority_rd[index] = elm_radio_add(obj);
2302 elm_radio_state_value_set(g_ugd->priority_rd[index], index);
2305 g_ugd->priority_rdg = g_ugd->priority_rd[index];
2307 elm_radio_group_add(g_ugd->priority_rd[index], g_ugd->priority_rdg);
2310 if (g_ugd->priority_option == EMAIL_MAIL_PRIORITY_HIGH) {
2311 elm_radio_value_set(g_ugd->priority_rdg, 0);
2312 } else if ( g_ugd->priority_option == EMAIL_MAIL_PRIORITY_NORMAL) {
2313 elm_radio_value_set(g_ugd->priority_rdg, 1);
2314 } else if ( g_ugd->priority_option == EMAIL_MAIL_PRIORITY_LOW) {
2315 elm_radio_value_set(g_ugd->priority_rdg, 2);
2317 debug_log("\n g_ugd->priority_option4 = %d", g_ugd->priority_option);
2320 evas_object_smart_callback_add(g_ugd->priority_rd[index], "changed", _composer_priority_radio_cb, g_ugd);
2322 return g_ugd->priority_rd[index];
2328 static Eina_Bool _composer_priority_gl_state_get(void *data, Evas_Object *obj, const char *part)
2334 static void _composer_priority_gl_del(void *data, Evas_Object *obj)
2340 static void _composer_priority_gl_sel(void *data, Evas_Object *obj, void *event_info)
2342 int index = (int)data;
2344 elm_radio_value_set(g_ugd->priority_rdg, index);
2347 g_ugd->priority_option = EMAIL_MAIL_PRIORITY_HIGH;
2348 } else if (index == 1) {
2349 g_ugd->priority_option = EMAIL_MAIL_PRIORITY_NORMAL;
2350 } else if (index == 2) {
2351 g_ugd->priority_option = EMAIL_MAIL_PRIORITY_LOW;
2353 debug_log("\n g_ugd->priority_option = %d", g_ugd->priority_option);
2355 debug_log("\n _composer_priority_gl_sel : priority_option = %d", g_ugd->priority_option);
2357 if (g_ugd->composer_noti) {
2358 evas_object_del(g_ugd->composer_noti);
2359 g_ugd->composer_noti = NULL;
2363 void _composer_cbar_priority_clicked(void *data, Evas_Object *obj, void *event_info)
2367 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2368 Elm_Object_Item *gen_item[2];
2375 if (ugd->composer_noti) {
2376 evas_object_del(ugd->composer_noti);
2377 ugd->composer_noti = NULL;
2379 popup = _composer_create_noti(ugd, false, _("IDS_EMAIL_BODY_PRIORITY"), NULL, 1,
2380 dgettext("sys_string", "IDS_COM_POP_CLOSE"), NULL, 0.0, _composer_noti_response_cb);
2382 ugd->composer_noti = popup;
2384 if (ugd->clipboard_on) {
2385 ugd->clipboard_on = false;
2388 if (ugd->cc_added) {
2389 if (ugd->b_cc_ps_open == true) {
2390 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
2391 ugd->b_cc_ps_open = false;
2395 if (ugd->b_bcc_ps_open == true) {
2396 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
2398 if (ugd->cc_added) {
2399 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2402 ugd->b_bcc_ps_open = false;
2405 #ifdef _POPUP_WITH_LIST
2406 elm_object_style_set(ugd->composer_noti, "min_menustyle");
2408 elm_object_style_set(ugd->composer_noti, "menustyle");
2410 elm_object_focus_allow_set(ugd->composer_noti, EINA_FALSE);
2412 priority_itc.item_style = "1text.1icon.2";
2413 priority_itc.func.text_get = _composer_priority_gl_text_get;
2414 priority_itc.func.content_get = _composer_priority_gl_content_get;
2415 priority_itc.func.state_get = _composer_priority_gl_state_get;
2416 priority_itc.func.del = _composer_priority_gl_del;
2418 Evas_Object *priority_genlist;
2419 priority_genlist = elm_genlist_add(ugd->composer_noti);
2421 evas_object_size_hint_weight_set(priority_genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2422 evas_object_size_hint_align_set(priority_genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
2424 for (index = 0; index < 3; index++) {
2425 gen_item[index] = elm_genlist_item_append(priority_genlist, &priority_itc, (void *)index, NULL, ELM_GENLIST_ITEM_NONE, _composer_priority_gl_sel, (void *)index);
2428 // elm_genlist_effect_set(security_genlist, EINA_FALSE);
2429 elm_genlist_tree_effect_enabled_set(priority_genlist, EINA_FALSE);
2431 #ifdef _POPUP_WITH_LIST
2432 Evas_Object *box = elm_box_add(ugd->composer_noti);
2433 evas_object_size_hint_min_set(box, 610 * elm_scale_get(), 114 * index * elm_scale_get());
2434 evas_object_show(priority_genlist);
2435 elm_box_pack_end(box, priority_genlist);
2436 elm_object_content_set(ugd->composer_noti, box);
2438 elm_object_content_set(ugd->composer_noti, priority_genlist);
2443 static char *_composer_tracking_gl_text_get(void *data, Evas_Object *obj, const char *part)
2445 int index = (int)data;
2447 debug_log("\n text index = %d", index);
2449 if (!g_strcmp0(part, "elm.text")) {
2451 return strdup(N_("Read report"));
2452 else if (index == 1)
2453 return strdup(N_("Delivery report"));
2458 static Evas_Object *_composer_tracking_gl_content_get(void *data, Evas_Object *obj, const char *part)
2460 int index = (int)data;
2462 debug_log("\n content index = %d", index);
2464 if (!strcmp(part, "elm.icon") || !strcmp(part, "elm.swallow.icon")) {
2465 Evas_Object *check = elm_check_add(obj);
2467 if (index == 0 && g_ugd->tracking_option[0] == 1) {
2468 debug_log("Read report");
2469 elm_check_state_set(check, EINA_TRUE);
2470 } else if (index == 1 && g_ugd->tracking_option[1] == 1) {
2471 debug_log("Delivery report");
2472 elm_check_state_set(check, EINA_TRUE);
2475 elm_check_state_set(check, EINA_FALSE);
2478 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2479 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
2487 static Eina_Bool _composer_tracking_gl_state_get(void *data, Evas_Object *obj, const char *part)
2493 static void _composer_tracking_gl_del(void *data, Evas_Object *obj)
2499 static void _composer_tracking_gl_sel(void *data, Evas_Object *obj, void *event_info)
2502 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
2504 debug_log("\nsel index = %d", (int)data);
2507 index = (int)elm_object_item_data_get(item);
2508 elm_genlist_item_selected_set(item, EINA_FALSE);
2510 debug_log("tracking_option[%d]:%d, !tracking_option[%d]:%d", index, g_ugd->tracking_option[index], index, !g_ugd->tracking_option[index]);
2511 g_ugd->tracking_option[index] = !g_ugd->tracking_option[index];
2513 elm_genlist_item_update(item);
2517 void _composer_cbar_tracking_clicked(void *data, Evas_Object *obj, void *event_info)
2521 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2522 Elm_Object_Item *gen_item[2];
2529 if (ugd->composer_noti) {
2530 evas_object_del(ugd->composer_noti);
2531 ugd->composer_noti = NULL;
2533 popup = _composer_create_noti(ugd, false, N_("Tracking"), NULL, 1,
2534 dgettext("sys_string", "IDS_COM_POP_CLOSE"), NULL, 0.0, _composer_noti_response_cb);
2536 ugd->composer_noti = popup;
2538 if (ugd->clipboard_on) {
2539 ugd->clipboard_on = false;
2542 if (ugd->cc_added) {
2543 if (ugd->b_cc_ps_open == true) {
2544 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
2545 ugd->b_cc_ps_open = false;
2549 if (ugd->b_bcc_ps_open == true) {
2550 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.to", "*");
2552 if (ugd->cc_added) {
2553 edje_object_signal_emit(_EDJ(ugd->c_layout), "show.cc", "*");
2556 ugd->b_bcc_ps_open = false;
2559 #ifdef _POPUP_WITH_LIST
2560 elm_object_style_set(ugd->composer_noti, "min_menustyle");
2562 elm_object_style_set(ugd->composer_noti, "menustyle");
2564 elm_object_focus_allow_set(ugd->composer_noti, EINA_FALSE);
2566 tracking_itc.item_style = "1text.1icon.2";
2567 tracking_itc.func.text_get = _composer_tracking_gl_text_get;
2568 tracking_itc.func.content_get = _composer_tracking_gl_content_get;
2569 tracking_itc.func.state_get = _composer_tracking_gl_state_get;
2570 tracking_itc.func.del = _composer_tracking_gl_del;
2572 Evas_Object *tracking_genlist;
2573 tracking_genlist = elm_genlist_add(ugd->composer_noti);
2575 evas_object_size_hint_weight_set(tracking_genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2576 evas_object_size_hint_align_set(tracking_genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
2578 for (index = 0; index < 2; index++) {
2579 gen_item[index] = elm_genlist_item_append(tracking_genlist, &tracking_itc, (void *)index, NULL, ELM_GENLIST_ITEM_NONE, _composer_tracking_gl_sel, (void *)index);
2582 // elm_genlist_effect_set(security_genlist, EINA_FALSE);
2583 elm_genlist_tree_effect_enabled_set(tracking_genlist, EINA_FALSE);
2585 #ifdef _POPUP_WITH_LIST
2586 Evas_Object *box = elm_box_add(ugd->composer_noti);
2587 evas_object_size_hint_min_set(box, 610 * elm_scale_get(), 114 * index * elm_scale_get());
2588 evas_object_show(tracking_genlist);
2589 elm_box_pack_end(box, tracking_genlist);
2590 elm_object_content_set(ugd->composer_noti, box);
2592 elm_object_content_set(ugd->composer_noti, tracking_genlist);
2596 void _composer_cbar_send_clicked(void *data, Evas_Object *obj, void *event_info)
2600 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2602 debug_log("Send Button Clicked");
2604 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_DISABLE_EDITABLE, _composer_send_clicked_cb, (void *)ugd))
2605 debug_log("COMPOSER_JS_DISABLE_EDITABLE error");
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);
2619 ugd->bSendBtnDisabled = true;
2621 ugd->send_timer = ecore_timer_add(0.5, _composer_send_mail_cb, ugd);
2624 static Eina_Bool _composer_cc_mbe_set_focus(void *data)
2628 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2630 if (ugd->idler_set_focus) {
2631 ecore_idler_del(ugd->idler_set_focus);
2632 ugd->idler_set_focus = NULL;
2635 elm_object_focus_set(ugd->cc_mbe, EINA_TRUE);
2637 ugd->b_cc_bcc = false;
2642 void _composer_script_executed_cb(Evas_Object *o, const char *result, void *data)
2647 void _composer_focus_script_executed_cb(Evas_Object *o, const char *result, void *data)
2650 // EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2652 // ugd->bringin_timer = ecore_timer_add(0.7f, _composer_bringin_cb, ugd);
2655 static void _composer_get_html_content_for_draft_cb(Evas_Object *o, const char *result, void *data)
2659 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2661 elm_object_disabled_set(ugd->cancel_btn, EINA_FALSE); // It prevents clicking the cancel button several times
2663 if (NULL != ugd->latest_html_content) {
2664 g_free(ugd->latest_html_content);
2665 ugd->latest_html_content = NULL;
2668 if (result != NULL) {
2669 ugd->latest_html_content = g_strdup(result);
2670 debug_log("ugd->latest_html_content => %s", ugd->latest_html_content);
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);
2731 static void _composer_send_clicked_cb(Evas_Object *o, const char *result, void *data)
2734 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2736 if (EINA_FALSE == ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_GET_HTML_CONTENT, _composer_get_latest_html_content_cb, (void *)ugd))
2737 debug_log("COMPOSER_JS_GET_HTML_CONTENT failed.");
2740 void _composer_get_latest_html_content_cb(Evas_Object *o, const char *result, void *data)
2743 EmailComposerUGD *ugd = (EmailComposerUGD *)data;
2745 if (NULL != ugd->latest_html_content) {
2746 g_free(ugd->latest_html_content);
2747 ugd->latest_html_content = NULL;
2750 ugd->latest_html_content = g_strdup(result);
2751 debug_log("ugd->latest_html_content => %s", ugd->latest_html_content);
2754 static void _composer_plain_text_get_cb(Evas_Object *o, const char *plain_text, void *user_data)
2758 EmailComposerUGD *ugd = (EmailComposerUGD *) user_data;
2760 if (NULL != ugd->plain_content) {
2761 g_free(ugd->plain_content);
2762 ugd->plain_content = NULL;
2765 ugd->plain_content = g_strdup(plain_text);
2766 debug_log("ugd->plain_content => %s", ugd->plain_content);
2769 void _composer_get_image_list_cb(Evas_Object *o, const char *result, void *data)
2774 EmailComposerUGD *ugd = (EmailComposerUGD *) data;
2776 if (ugd->listOfImageUrls) {
2777 eina_list_free(ugd->listOfImageUrls);
2778 ugd->listOfImageUrls = NULL;
2781 if (result != NULL) {
2782 debug_log("listOFImageUrls => %s", result);
2783 list = g_strdup(result);
2785 char *token = strtok(list, ",");
2786 while (token != NULL) {
2788 ugd->listOfImageUrls = eina_list_append(ugd->listOfImageUrls, token);
2789 token = strtok(NULL, ",");