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.
18 #define UG_MODULE_API __attribute__ ((visibility("default")))
22 #include <contacts-ug.h>
23 #include <calendar-svc-provider.h>
24 #include <media-util-register.h>
25 #include <app_service.h>
28 #include "email-viewer.h"
29 #include "email-viewer-webview.h"
30 #include "email-viewer-utils.h"
31 #include "email-engine.h"
32 #include "email-utils.h"
33 #include "email-common-types.h"
34 #include "email-debug.h"
36 #define EMAIL_VCONF_KEY_BLOCK_RULE_CHANGED "file/private/org.tizen.email/spam_rule_changed"
39 EmailViewerUGD *_g_ug_data = NULL;
40 E_DBus_Connection *_g_viewer_dbus_conn = NULL;
41 E_DBus_Signal_Handler *_g_viewer_signal_handler_network = NULL;
42 E_DBus_Signal_Handler *_g_viewer_signal_handler_storage = NULL;
44 extern ui_gadget_h _g_mailbox_ug;
45 extern char *icu_locale;
46 extern enum appcore_time_format icu_timeformat;
47 extern void _set_mail_flags(EmailViewerProp *prop, EmailViewerPrivate *email_data);
50 static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h data, void *priv);
51 static void on_start(ui_gadget_h ug, service_h data, void *priv);
52 static void on_pause(ui_gadget_h ug, service_h data, void *priv);
53 static void on_resume(ui_gadget_h ug, service_h data, void *priv);
54 static void on_destroy(ui_gadget_h ug, service_h data, void *pd);
55 static void on_message(ui_gadget_h ug, service_h msg, service_h data, void *priv);
56 static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *priv);
57 static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h data, void *priv);
60 static void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv);
61 static void result_cb(ui_gadget_h ug, service_h result, void *priv);
62 static void destroy_cb(ui_gadget_h ug, void *priv);
63 static ui_gadget_h create_ug(char *ug_name, service_h bd, void *data);
66 static void _create_view(EmailViewerUGD *ug_data);
67 static void _reset_view(EmailViewerUGD *ug_data);
69 static void _win_profile_changed_cb(void *data, Evas_Object *obj, void *event);
71 static Evas_Object *_create_navigation_bar(EmailViewerUGD *ug_data);
72 static Evas_Object *_create_subject(EmailViewerUGD *ug_data);
73 static Evas_Object *_create_to_addrs(EmailViewerUGD *ug_data);
74 static Evas_Object *_create_cc_addrs(EmailViewerUGD *ug_data);
75 static Evas_Object *_create_bcc_addrs(EmailViewerUGD *ug_data);
76 static Evas_Object *_create_attach(EmailViewerUGD *ug_data);
77 static Evas_Object *_create_attach_ex(EmailViewerUGD *ug_data);
78 static Evas_Object *_create_body(EmailViewerUGD *ug_data);
79 static Evas_Object *_create_tab_bar(EmailViewerUGD *ug_data);
80 static Evas_Object *_update_tab_bar(EmailViewerUGD *ug_data);
81 static Evas_Object *_create_partial_body_dn_btn(EmailViewerUGD *ug_data);
82 static Evas_Object *_create_bg(Evas_Object *win);
84 static void _create_down_progress(char *message, popup_cb resp_cb);
85 static void _create_down_progress_ex(int index, EMAIL_VIEWER_PROGRESSBAR_TYPE p_type);
86 static void _destroy_down_progress_ex(void *data, Evas_Object *obj, void *event_info);
87 static void _create_more_ctxpopup(EmailViewerUGD *ug_data);
88 static void _delete_evas_objects(EmailViewerUGD *ug_data);
90 static void _launch_vcs_editor(EmailViewerUGD *ug_data);
92 /* callback functions */
93 static void _back_cb(void *data, Evas_Object *obj, void *event_info);
94 static void _prev_mail_cb(void *data, Evas_Object *obj, void *event_info);
95 static void _next_mail_cb(void *data, Evas_Object *obj, void *event_info);
96 static void _reply_cb(void *data, Evas_Object *obj, void *event_info);
97 static void _reply_all_cb(void *data, Evas_Object *obj, void *event_info);
98 static void _reply_option_cb(void *data, Evas_Object *obj, void *event_info);
99 static void _forward_cb(void *data, Evas_Object *obj, void *event_info);
100 static void _add_to_calendar_cb(void *data, Evas_Object *obj, void *event_info);
101 static void _resend_cb(void *data, Evas_Object *obj, void *event_info);
102 static void _delete_cb(void *data, Evas_Object *obj, void *event_info);
103 static void _move_cb(void *data, Evas_Object *obj, void *event_info);
104 static void _more_cb(void *data, Evas_Object *obj, void *event_info);
105 static void _body_down_cb(void *data, Evas_Object *obj, void *event_info);
106 static void _subject_favorite_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
107 static void _subject_detail_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
108 static void _attachment_item_collapse_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
109 static void _attachment_save_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
110 static void _attachment_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
111 static void _attachment_save_all_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
112 static void _attachment_bg_set_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
113 static void _attachment_bg_unset_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
114 static void _mark_as_unread_cb(void *data, Evas_Object *obj, void *event_info);
115 static void _mark_as_read_cb(void *data, Evas_Object *obj, void *event_info);
116 static void _save_email_cb(void *data, Evas_Object *obj, void *event_info);
117 static Eina_Bool _save_email_prog_cb(void *data);
119 static void _ctxpopup_detail_contact_cb(void *data, Evas_Object *obj, void *event_info);
120 static void _ctxpopup_send_email_cb(void *data, Evas_Object *obj, void *event_info);
121 static void _ctxpopup_add_contact_cb(void *data, Evas_Object *obj, void *event_info);
122 static void _ctxpopup_cutlink_update_contact_cb(void *data, Evas_Object *obj, void *event_info);
123 static void _ctxpopup_select_contact_mode_email_cb(void *data, Evas_Object *obj, void *event_info);
124 static void _ctxpopup_add_block_rule_cb(void *data, Evas_Object *obj, void *event_info);
125 static void _popup_response_cb(void *data, Evas_Object *obj, void *event_info);
126 static void _popup_response_delete_ok_cb(void *data, Evas_Object *obj, void *event_info);
127 static void _popup_response_to_destroy_cb(void *data, Evas_Object *obj, void *event_info);
129 static void _webview_multi_up_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
130 static void _webview_multi_down_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
131 static void _webview_policy_navigation_decide_cb(void *data, Evas_Object *obj, void *event_info);
133 static void _outter_scroller_bottom_hit_cb(void *data, Evas_Object *obj, void *event_info);
134 static void _outter_scroller_top_hit_cb(void *data, Evas_Object *obj, void *event_info);
135 static void _outter_scroller_scroll_cb(void *data, Evas_Object *obj, void *event_info);
137 static void _mbe_focused_cb(void *data, Evas_Object *obj, void *event_info);
138 static void _mbe_unfocused_cb(void *data, Evas_Object *obj, void *event_info);
139 static void _mbe_added_cb(void *data, Evas_Object *obj, void *event_info);
140 static void _mbe_selected_cb(void *data, Evas_Object *obj, void *event_info);
141 static void _destroy_down_progress_cb(void *data, Evas_Object *obj, void *event_info);
143 /* Logic Functions */
144 static void _init_viewer_data(int account_id, int mail_id, char *srv_mail_id, EmailViewerUGD *ug_data);
145 static int _init_webview_data(EmailViewerUGD *ug_data);
146 static Eina_Bool _check_body_download(void *data);
147 static int _update_attachment_info(EmailViewerUGD *ug_data, int index);
148 static int _get_attachment_info_index(EmailViewerUGD *ug_data, int index);
149 static void _show_select_info(EmailViewerUGD *ug_data, char *str);
150 static void _save_attachment(EmailViewerUGD *ug_data, int index);
151 static void _show_attachment(EmailViewerUGD *ug_data, int index);
152 static void _save_attachment_all(EmailViewerUGD *ug_data);
153 static void _dbus_receiver_setup(EmailViewerUGD *ug_data);
154 static void _dbus_receiver_remove(EmailViewerUGD *ug_data);
155 static void _on_edbus_event_email_viewer_receive(void *local_data, DBusMessage *message);
157 static void _delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item);
158 static void *_contact_search_by_email(EmailViewerUGD *ug_data, const char *search_word);
159 static void _set_value_down_progress(double val);
160 static void _set_value_down_progress_by_index(double val, int index);
161 static void _cancel_download_attachment(EmailViewerUGD *ug_data);
164 static char *_get_service_fail_type(int type);
165 static Evas_Object *_load_edj(Evas_Object *parent, const char *file, const char *group);
168 static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part);
169 static void _gl_del(void *data, Evas_Object *obj);
170 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part);
171 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part);
172 static void _move_here_cb(void *data, Evas_Object *obj, void *event_info);
173 static void _move_back_cb(void *data, Evas_Object *obj, void *event_info);
176 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
180 EmailViewerUGD *ug_data;
185 ug_data = calloc(1, sizeof(EmailViewerUGD));
189 _g_ug_data = ug_data;
192 ops->create = on_create;
193 ops->start = on_start;
194 ops->pause = on_pause;
195 ops->resume = on_resume;
196 ops->destroy = on_destroy;
197 ops->message = on_message;
198 ops->event = on_event;
199 ops->key_event = on_key_event;
201 ops->opt = UG_OPT_INDICATOR_ENABLE;
206 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
209 EmailViewerUGD *ug_data;
221 static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h data, void *priv)
224 EmailViewerUGD *ug_data;
225 char *account_id = NULL;
226 char *mail_id = NULL;
227 char *mailbox_id = NULL;
228 char *binternal = NULL;
229 char *landscape = NULL;
238 debug_log("account_id and mail_id are required by arguments");
239 ug_data->b_direct_destroy = 1;
240 ug_destroy_me(ug_data->ug);
245 /* email engine initialize */
246 if (email_engine_initialize() == FALSE) {
247 debug_log("Failed to initialize email engine");
248 ug_data->b_direct_destroy = 1;
249 ug_destroy_me(ug_data->ug);
254 /* Elm_Theme *theme = elm_theme_new();
255 elm_theme_ref_set(theme, NULL);
256 ug_data->theme = theme;
257 elm_theme_extension_add(ug_data->theme, EV_THEME_PATH);*/
260 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_ACCOUNT_ID, (char **)&account_id);
261 debug_log("service_get_extra_data: %d", ret);
262 debug_log("account_id:%s", account_id);
263 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_MAIL_ID, (char **)&mail_id);
264 debug_log("service_get_extra_data: %d", ret);
265 debug_log("mail_id:%s", mail_id);
266 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_MAILBOX, (char **)&mailbox_id);
267 debug_log("service_get_extra_data: %d", ret);
268 debug_log("mailbox:%s", mailbox_id);
269 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_INTERNAL, (char **)&binternal);
270 debug_log("service_get_extra_data: %d", ret);
271 debug_log("binternal:%s", binternal);
272 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_FIRST_LANDSCAPE, (char **)&landscape);
273 debug_log("service_get_extra_data: %d", ret);
274 debug_log("landscape:%s", landscape);
277 ug_data->isRotate = atoi(landscape);
278 debug_log("@@@@ Landscape = %d @@@@", ug_data->isRotate);
283 ug_data->account_id = atoi(account_id);
284 ug_data->folder_list = email_engine_get_ca_mailbox_list_using_glist(ug_data->account_id);
289 ug_data->mail_id = atoi(mail_id);
294 g_free(ug_data->mailbox_name);
295 ug_data->mailbox_name = NULL;
296 ug_data->mailbox_id = atoi(mailbox_id);
300 email_mail_data_t *mail_data = NULL;
301 if ((err = email_get_mail_data(ug_data->mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
302 debug_log("fail to get mail - err (%d)", err);
305 if (mail_data == NULL) {
306 debug_log("mail_data is NULL");
309 ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name);
310 ug_data->mailbox_type = mail_data->mailbox_type;
311 debug_log("server_mailbox_name:%s", mail_data->server_mailbox_name);
312 debug_log("mailbox_name:%s", ug_data->mailbox_name);
313 debug_log("mailbox_type:%d", ug_data->mailbox_type);
316 debug_log("email_free_mail is called");
317 email_free_mail_data(&(mail_data), 1);
323 ug_data->b_internal = atoi(binternal);
324 if (ug_data->b_internal == 1)
325 debug_log("############Launched from email-mailbox###############");
329 debug_log("account_id [%d], mail_id [%d], mailbox_id [%d], mailbox name [%s]", ug_data->account_id, ug_data->mail_id, ug_data->mailbox_id, ug_data->mailbox_name);
331 if (ug_data->account_id <= 0 || ug_data->mail_id <= 0 || ug_data->mailbox_id <= 0) {
332 debug_log("Required bundle parameters are missing!");
333 ug_data->timeout_popup = elm_popup_add(ug_get_window());
334 evas_object_size_hint_weight_set(ug_data->timeout_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
335 elm_popup_timeout_set(ug_data->timeout_popup, 2);
336 elm_object_text_set(ug_data->timeout_popup, _("IDS_EMAIL_POP_UNABLE_TO_OPEN_EMAIL_MESSAGE"));
337 elm_object_part_text_set(ug_data->timeout_popup, "title,text", _("IDS_EMAIL_POP_ALERT"));
338 evas_object_smart_callback_add(ug_data->timeout_popup, "block,clicked", _popup_response_to_destroy_cb, ug_data);
339 evas_object_smart_callback_add(ug_data->timeout_popup, "timeout", _popup_response_to_destroy_cb, ug_data);
340 evas_object_show(ug_data->timeout_popup);
342 return elm_layout_add(ug_get_window());
345 ug_data->win_main = ug_get_window();
347 char *proxy_address = vconf_get_str(VCONFKEY_NETWORK_PROXY);
348 debug_log("network proxy: %s", proxy_address);
349 if (proxy_address && (g_strcmp0(proxy_address, "") != 0)) {
350 ewk_context_proxy_uri_set(ewk_context_default_get(), proxy_address);
357 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
358 debug_log("WINDOW W[%d] H[%d]", w, h);
362 ug_data->scale_factor = elm_scale_get();
363 debug_log("ELM Scale[%f]", ug_data->scale_factor);
366 ug_data->webview_width = 710.0;
367 ug_data->webview_height = 949.0;
368 ug_data->webview_width_landscape = 710.0;
369 ug_data->webview_height_landscape = 568.0;
370 ug_data->webview_margin = 633;
371 ug_data->webview_margin_landscape = 379;
372 } else if (w == 720) {
373 ug_data->webview_width = 710.0;
374 ug_data->webview_height = 1021.0;
375 ug_data->webview_width_landscape = 710.0;
376 ug_data->webview_height_landscape = 558.0;
377 ug_data->webview_margin = 1029;
378 ug_data->webview_margin_landscape = 558;
380 ug_data->webview_width = 710.0;
381 ug_data->webview_height = 949.0;
382 ug_data->webview_width_landscape = 710.0;
383 ug_data->webview_height_landscape = 568.0;
384 ug_data->webview_margin = 633;
385 ug_data->webview_margin_landscape = 379;
388 ug_data->evas = evas_object_evas_get(ug_data->win_main);
390 /* Double_Scroller */
393 email_account_t *account = NULL;
394 if (email_engine_get_account_full_data(ug_data->account_id, &account)) {
395 debug_log("email_engine_get_account");
397 ug_data->account_type = account->incoming_server_type;
398 snprintf(ug_data->account_email_address, sizeof(ug_data->account_email_address), "%s", account->user_email_address);
400 account_user_data_t *ud = (account_user_data_t*)account->user_data;
402 debug_log("show_images is %d", ud->show_images);
403 ug_data->b_show_remote_images = ud->show_images;
405 email_free_account(&account, 1);
411 _dbus_receiver_setup(ug_data);
413 _init_viewer_data(ug_data->account_id, ug_data->mail_id, NULL, ug_data);
414 _create_view(ug_data);
416 _check_body_download(ug_data);
418 ug_data->base = ug_data->layout_main;
420 ug_data->display_download_result = TRUE;
422 return ug_data->base;
425 static void on_start(ui_gadget_h ug, service_h data, void *priv)
430 static void on_pause(ui_gadget_h ug, service_h data, void *priv)
435 static void on_resume(ui_gadget_h ug, service_h data, void *priv)
440 static void on_destroy(ui_gadget_h ug, service_h data, void *pd)
443 EmailViewerUGD *ug_data;
452 if (ug_data->b_direct_destroy)
456 EmailViewerPrivate *priv = ug_data->email_data;
457 EmailViewerProp *prop = ug_data->property;
459 int att_len = g_list_length(prop->attachments);
461 if (priv->email_handle != 0)
462 email_engine_stop_working(ug_data->account_id, priv->email_handle);
464 for (i = 0; i < att_len; i++) {
465 if (priv->download_all_email_handle[i] != 0)
466 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[i]);
469 /* if (ug_data->theme) {
470 elm_theme_extension_del(ug_data->theme, EV_THEME_PATH);
471 elm_theme_free(ug_data->theme);
472 ug_data->theme = NULL;
475 _delete_evas_objects(ug_data);
477 debug_log("free webview_data");
478 if (ug_data->webview_data) {
479 free(ug_data->webview_data);
480 ug_data->webview_data = NULL;
483 debug_log("free address info list");
484 email_free_address_info_list(&(priv->addrs_info_list));
485 ug_data->from_list = NULL;
486 ug_data->to_list = NULL;
487 ug_data->cc_list = NULL;
488 ug_data->bcc_list = NULL;
490 debug_log("free mail_info");
491 if (ug_data->email_data->mail_info) {
492 email_free_mail_data(&(ug_data->email_data->mail_info), 1);
493 ug_data->email_data->mail_info = NULL;
496 if (ug_data->email_data->attachment_info && ug_data->email_data->attachment_count > 0) {
497 email_free_attachment_data(&(ug_data->email_data->attachment_info), ug_data->email_data->attachment_count);
498 ug_data->email_data->attachment_info = NULL;
499 ug_data->email_data->attachment_count = 0;
502 debug_log("free email_data");
503 if (ug_data->email_data) {
504 free(ug_data->email_data);
505 ug_data->email_data = NULL;
508 debug_log("free attachment");
509 if (ug_data->property->attachments) {
511 LIST_ITER_START(i, ug_data->property->attachments) {
512 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, ug_data->property->attachments);
519 g_list_free(ug_data->property->attachments);
520 ug_data->property->attachments = NULL;
523 debug_log("free property");
524 if (ug_data->property) {
525 free(ug_data->property);
526 ug_data->property = NULL;
529 email_engine_finalize();
531 _dbus_receiver_remove(NULL);
533 int ret = e_dbus_shutdown();
534 debug_log("ret: %d", ret);
537 ug_data->base = NULL;
540 static void on_message(ui_gadget_h ug, service_h msg, service_h data, void *priv)
547 debug_log("_g_ug_data - %p", _g_ug_data);
548 if (_g_ug_data != NULL) {
549 debug_log("Hide previous mail data");
550 _hide_view(_g_ug_data);
553 char *account_id = NULL;
554 char *mail_id = NULL;
555 char *mailbox_id = NULL;
556 char *binternal = NULL;
557 char *landscape = NULL;
559 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
560 _g_ug_data = ug_data;
564 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_ACCOUNT_ID, (char **)&account_id);
565 debug_log("service_get_extra_data: %d", ret);
566 debug_log("account_id:%s", account_id);
567 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_MAIL_ID, (char **)&mail_id);
568 debug_log("service_get_extra_data: %d", ret);
569 debug_log("mail_id:%s", mail_id);
570 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_MAILBOX, (char **)&mailbox_id);
571 debug_log("service_get_extra_data: %d", ret);
572 debug_log("mailbox:%s", mailbox_id);
573 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_INTERNAL, (char **)&binternal);
574 debug_log("service_get_extra_data: %d", ret);
575 debug_log("binternal:%s", binternal);
576 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_FIRST_LANDSCAPE, (char **)&landscape);
577 debug_log("service_get_extra_data: %d", ret);
578 debug_log("landscape:%s", landscape);
581 ug_data->isRotate = atoi(landscape);
582 debug_log("@@@@ Landscape = %d @@@@", ug_data->isRotate);
587 ug_data->account_id = atoi(account_id);
588 ug_data->folder_list = email_engine_get_ca_mailbox_list_using_glist(ug_data->account_id);
593 ug_data->mail_id = atoi(mail_id);
598 g_free(ug_data->mailbox_name);
599 ug_data->mailbox_name = NULL;
600 ug_data->mailbox_id = atoi(mailbox_id);
604 email_mail_data_t *mail_data = NULL;
605 if ((err = email_get_mail_data(ug_data->mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
606 debug_log("fail to get mail - err (%d)", err);
609 if (mail_data == NULL) {
610 debug_log("mail_data is NULL");
613 ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name);
614 ug_data->mailbox_type = mail_data->mailbox_type;
615 debug_log("server_mailbox_name:%s", mail_data->server_mailbox_name);
616 debug_log("mailbox_name:%s", ug_data->mailbox_name);
617 debug_log("mailbox_type:%d", ug_data->mailbox_type);
620 debug_log("email_free_mail is called");
621 email_free_mail_data(&(mail_data), 1);
627 ug_data->b_internal = atoi(binternal);
628 if (ug_data->b_internal == 1)
629 debug_log("############Launched from email-mailbox###############");
633 debug_log("account_id [%d], mail_id [%d], mailbox_id[%d], mailbox name [%s]", ug_data->account_id, ug_data->mail_id, ug_data->mailbox_id, ug_data->mailbox_name);
635 if (ug_data->account_id <= 0 || ug_data->mail_id <= 0 || ug_data->mailbox_id <= 0) {
636 debug_log("Required bundle parameters are missing!");
641 email_account_t *account = NULL;
642 if (email_engine_get_account_full_data(ug_data->account_id, &account)) {
643 debug_log("email_engine_get_account");
645 ug_data->account_type = account->incoming_server_type;
646 snprintf(ug_data->account_email_address, sizeof(ug_data->account_email_address), "%s", account->user_email_address);
648 account_user_data_t *ud = (account_user_data_t*)account->user_data;
650 debug_log("show_images is %d", ud->show_images);
651 ug_data->b_show_remote_images = ud->show_images;
653 email_free_account(&account, 1);
657 Ewk_Setting *setting = ewk_view_setting_get(ug_data->webview);
659 debug_log("b_show_remote_images is %d", ug_data->b_show_remote_images);
660 if (ewk_setting_load_remote_images_set(setting, ug_data->b_show_remote_images) == EINA_FALSE) {
661 debug_log("SET remote images is FAILED!");
665 _init_viewer_data(ug_data->account_id, ug_data->mail_id, NULL, ug_data);
667 evas_object_show(ug_data->layout_main);
668 evas_object_raise(ug_data->layout_main);
670 _reset_view(ug_data);
672 ug_data->display_download_result = TRUE;
675 static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *priv)
682 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
683 EmailViewerProp *prop = ug_data->property;
684 char date_time[MAX_STR_LEN] = { 0, };
685 char *formatted_date = NULL;
688 debug_log("rotate event = %d", event);
691 case UG_EVENT_LOW_MEMORY:
693 case UG_EVENT_LOW_BATTERY:
695 case UG_EVENT_LANG_CHANGE:
697 case UG_EVENT_ROTATE_PORTRAIT:
698 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
699 if (ug_data->b_internal && ug_data->isRotate == true) {
700 ewk_view_command_execute(ug_data->webview, "Unselect", NULL);
701 debug_log("In Full view - Showing navi bar");
702 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_TRUE);
704 if (ug_data->con_popup) {
705 evas_object_del(ug_data->con_popup);
706 ug_data->con_popup = NULL;
709 if (ug_data->navi_move_it1) {
711 Evas_Object *move_back_btn = elm_button_add(ug_data->navi_bar);
712 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
713 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb, ug_data);
714 elm_object_item_part_content_set(ug_data->navi_move_it1, "prev_btn", move_back_btn);
715 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_TRUE);
716 if (ug_data->move_cbar) {
717 elm_object_item_part_content_unset(ug_data->navi_move_it1, "controlbar");
718 evas_object_del(ug_data->move_cbar);
719 ug_data->move_cbar = NULL;
723 if (ug_data->b_btn) {
724 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
725 evas_object_del(ug_data->b_btn);
726 ug_data->b_btn = NULL;
729 ug_data->b_btn = elm_button_add(ug_data->navi_bar);
730 elm_object_style_set(ug_data->b_btn, "naviframe/back_btn/default");
731 evas_object_smart_callback_add(ug_data->b_btn, "clicked", _back_cb, ug_data);
732 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", ug_data->b_btn);
734 ug_data->isRotate = false;
739 case UG_EVENT_ROTATE_LANDSCAPE:
740 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
741 if (ug_data->b_internal && ug_data->isRotate == false) {
742 ewk_view_command_execute(ug_data->webview, "Unselect", NULL);
743 debug_log("In Split view - Hiding navi bar");
744 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE);
746 if (ug_data->con_popup) {
747 evas_object_del(ug_data->con_popup);
748 ug_data->con_popup = NULL;
751 if (ug_data->navi_move_it1) {
753 ug_data->move_cbar = elm_toolbar_add(ug_data->navi_bar);
754 elm_toolbar_shrink_mode_set(ug_data->move_cbar, ELM_TOOLBAR_SHRINK_EXPAND);
755 elm_object_style_set(ug_data->move_cbar, "naviframe");
756 evas_object_show(ug_data->move_cbar);
758 elm_object_item_disabled_set(elm_toolbar_item_append(ug_data->move_cbar, NULL, "", NULL, NULL), EINA_TRUE);
759 elm_toolbar_item_append(ug_data->move_cbar, NULL, dgettext("sys_string", "IDS_COM_SK_CANCEL"), _move_back_cb, ug_data);
760 elm_object_item_part_content_set(ug_data->navi_move_it1, "controlbar", ug_data->move_cbar);
762 Evas_Object *move_back_btn = elm_object_item_part_content_get(ug_data->navi_move_it1, "prev_btn");
764 evas_object_smart_callback_del(move_back_btn, "clicked", _move_back_cb);
765 evas_object_del(move_back_btn);
766 elm_object_item_part_content_set(ug_data->navi_move_it1, "prev_btn", NULL);
768 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_FALSE);
771 if (ug_data->b_btn) {
772 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
773 evas_object_del(ug_data->b_btn);
774 ug_data->b_btn = NULL;
775 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
778 ug_data->isRotate = true;
783 case UG_EVENT_REGION_CHANGE:
784 appcore_get_timeformat(&icu_timeformat);
785 /* ICU API to set default locale */
786 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
787 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
789 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
790 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
792 free(formatted_date);
793 formatted_date = NULL;
795 edje_object_part_text_set(_EDJ(ug_data->ly_subject), "elm.text.sub", date_time);
796 evas_object_show(ug_data->ly_subject);
804 static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h data, void *priv)
811 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
812 EmailViewerPrivate *private = ug_data->email_data;
813 EmailViewerProp *prop = ug_data->property;
816 case UG_KEY_EVENT_END:
818 if (ug_data->notify != NULL || ug_data->pb_notify != NULL || ug_data->timeout_popup != NULL) {
819 if (ug_data->timeout_popup) {
820 evas_object_del(ug_data->timeout_popup);
821 ug_data->timeout_popup = NULL;
824 if (ug_data->notify) {
825 evas_object_del(ug_data->notify);
826 ug_data->notify = NULL;
829 if (ug_data->pb_notify) {
831 int att_len = g_list_length(prop->attachments);
833 evas_object_del(ug_data->pb_notify);
834 ug_data->pb_notify = NULL;
836 if (private->email_handle != 0)
837 email_engine_stop_working(ug_data->account_id, private->email_handle);
839 for (i = 0; i < att_len; i++) {
840 if (private->download_all_email_handle[i] != 0)
841 email_engine_stop_working(ug_data->account_id, private->download_all_email_handle[i]);
845 if (ug_data->pb_notify_lb) {
846 evas_object_del(ug_data->pb_notify_lb);
847 ug_data->pb_notify_lb = NULL;
850 if (ug_data->isRotate == false && ug_data->b_internal) {
851 /* Viewer to hide, so set left content (mailbox) size to full */
852 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
855 if (ug_data->b_internal)
858 ug_destroy_me(ug_data->ug);
862 service_h service = NULL;
864 ret = service_create(&service);
865 debug_log("service_create: %d", ret);
867 debug_log("service create failed");
871 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_END_KEY);
872 debug_log("service_add_extra_data: %d", ret);
874 ug_send_message(_g_mailbox_ug, service);
876 ret = service_destroy(service);
877 debug_log("service_destroy: %d", ret);
886 static void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
889 Evas_Object *base, *win;
894 base = ug_get_layout(ug);
898 win = ug_get_window();
901 case UG_MODE_FULLVIEW:
902 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
903 elm_win_resize_object_add(win, base);
904 evas_object_show(base);
911 static void result_cb(ui_gadget_h ug, service_h result, void *priv)
918 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
919 EmailViewerProp *prop = ug_data->property;
920 EmailViewerPrivate *private = ug_data->email_data;
922 if (ug == ug_data->ug_composer) {
924 int ret = service_get_extra_data(result, EMAIL_BUNDLE_KEY_SAVE_ALL, (char **)&cmd);
925 debug_log("service_get_extra_data: %d", ret);
926 debug_log("return of bundle_get_val for save all(%s)", cmd);
928 debug_log("save all from composer(%s)", cmd);
930 if (prop->real_att_len == 1) {
931 private->b_all_att_save = TRUE;
932 _save_attachment(ug_data, 0);
933 } else if (prop->real_att_len > 1) {
934 _save_attachment_all(ug_data);
940 ret = service_get_extra_data(result, EMAIL_BUNDLE_KEY_CANCEL_ALL, (char **)&cmd);
941 debug_log("service_get_extra_data: %d", ret);
942 debug_log("return of bundle_get_val for cancel all(%s)", cmd);
944 debug_log("cancel all attachment from composer(%s)", cmd);
946 _cancel_download_attachment(ug_data);
953 static void destroy_cb(ui_gadget_h ug, void *priv)
959 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
960 EmailViewerProp *prop = ug_data->property;
961 ug_data->display_download_result = TRUE;
963 if (ug == ug_data->ug_composer) {
964 ug_data->ug_composer = NULL;
969 if (ug_data->b_contact_ug_launched) {
970 debug_log("change navibar title label");
971 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
972 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, prop->sender);
974 if (contact_list_item) {
975 elm_object_item_text_set(ug_data->navi_main_it, contact_list_item->display_name);
976 _delete_contacts_list(contact_list_item);
978 elm_object_item_text_set(ug_data->navi_main_it, prop->sender_display_name);
981 ug_data->b_contact_ug_launched = FALSE;
985 static ui_gadget_h create_ug(char *ug_name, service_h bd, void *data)
989 struct ug_cbs cbs = { 0, };
991 cbs.layout_cb = layout_cb;
992 cbs.result_cb = result_cb;
993 cbs.destroy_cb = destroy_cb;
996 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
998 ug = ug_create(ug_data->ug, ug_name, UG_MODE_FULLVIEW, bd, &cbs);
1003 static void _create_view(EmailViewerUGD *ug_data)
1008 Evas_Object *prev_btn;
1009 Evas_Object *next_btn;
1010 EmailViewerProp *prop = ug_data->property;
1012 ug_data->bg = _create_bg(ug_data->win_main);
1015 ug_data->layout_main = elm_layout_add(ug_data->win_main);
1017 if (ug_data->b_internal)
1018 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "noindicator");
1020 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "default");
1021 evas_object_size_hint_weight_set(ug_data->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1022 evas_object_show(ug_data->layout_main);
1024 elm_object_part_content_set(ug_data->layout_main, "elm.swallow.bg", ug_data->bg);
1027 elm_win_indicator_mode_set(ug_data->win_main, ELM_WIN_INDICATOR_SHOW);
1029 evas_object_smart_callback_add(ug_data->win_main, "profile,changed", _win_profile_changed_cb, ug_data);
1031 /* navigation Bar */
1032 _create_navigation_bar(ug_data);
1034 /* push navigation bar */
1035 ug_data->sub_ly = elm_layout_add(ug_data->navi_bar);
1036 elm_layout_theme_set(ug_data->sub_ly, "layout", "application", "noindicator");
1037 evas_object_size_hint_weight_set(ug_data->sub_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1038 evas_object_show(ug_data->sub_ly);
1041 b_btn = elm_button_add(ug_data->navi_bar);
1042 elm_object_style_set(b_btn, "naviframe/back_btn/default");
1043 evas_object_smart_callback_add(b_btn, "clicked", _back_cb, ug_data);
1044 ug_data->b_btn = b_btn;
1046 ug_data->navi_main_it = elm_naviframe_item_push(ug_data->navi_bar, prop->sender_display_name, b_btn, NULL, ug_data->sub_ly, NULL);
1048 if (ug_data->b_internal) {
1049 /* Left : previous button */
1050 prev_btn = elm_button_add(ug_data->navi_bar);
1051 Evas_Object *prev_ic = elm_icon_add(prev_btn);
1052 elm_icon_file_set(prev_ic, IMGDIR "/M02_icon_previous.png", NULL);
1053 elm_object_style_set(prev_btn, "naviframe/title/default");
1054 evas_object_size_hint_aspect_set(prev_ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1055 elm_icon_resizable_set(prev_ic, 0.8, 0.8);
1056 elm_object_part_content_set(prev_btn, "icon", prev_ic);
1057 elm_object_item_part_content_set(ug_data->navi_main_it, "title_left_btn", prev_btn);
1058 evas_object_smart_callback_add(prev_btn, "clicked", _prev_mail_cb, ug_data);
1059 ug_data->prev_btn = prev_btn;
1061 /* Right : next button */
1062 next_btn = elm_button_add(ug_data->navi_bar);
1063 Evas_Object *next_ic = elm_icon_add(next_btn);
1064 elm_icon_file_set(next_ic, IMGDIR "/M02_icon_next.png", NULL);
1065 elm_object_style_set(next_btn, "naviframe/title/default");
1066 evas_object_size_hint_aspect_set(next_ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1067 elm_icon_resizable_set(next_ic, 0.8, 0.8);
1068 elm_object_part_content_set(next_btn, "icon", next_ic);
1069 elm_object_item_part_content_set(ug_data->navi_main_it, "title_right_btn", next_btn);
1070 evas_object_smart_callback_add(next_btn, "clicked", _next_mail_cb, ug_data);
1071 ug_data->next_btn = next_btn;
1074 /* create scroller */
1075 ug_data->scroller = elm_scroller_add(ug_data->navi_bar);
1076 evas_object_propagate_events_set(ug_data->scroller, EINA_FALSE);
1077 elm_scroller_bounce_set(ug_data->scroller, EINA_FALSE, EINA_TRUE);
1078 elm_scroller_policy_set(ug_data->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
1079 evas_object_show(ug_data->scroller);
1080 evas_object_smart_callback_add(ug_data->scroller, "edge,bottom", _outter_scroller_bottom_hit_cb, ug_data);
1081 evas_object_smart_callback_add(ug_data->scroller, "edge,top", _outter_scroller_top_hit_cb, ug_data);
1082 evas_object_smart_callback_add(ug_data->scroller, "scroll,drag,start", _outter_scroller_scroll_cb, ug_data);
1084 /* create conformant */
1085 elm_win_conformant_set(ug_data->win_main, EINA_TRUE);
1086 ug_data->conformant = elm_conformant_add(ug_data->sub_ly);
1087 elm_object_style_set(ug_data->conformant, "internal_layout");
1088 evas_object_size_hint_weight_set(ug_data->conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1089 evas_object_size_hint_align_set(ug_data->conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
1090 elm_object_content_set(ug_data->conformant, ug_data->scroller);
1091 elm_object_part_content_set(ug_data->sub_ly, "elm.swallow.content", ug_data->conformant);
1092 evas_object_show(ug_data->conformant);
1094 if (ug_data->from_list != NULL) {
1095 email_address_info_t *addrs_info = NULL;
1096 int n_from_list = g_list_length(ug_data->from_list);
1097 debug_log("from list count [%d]", n_from_list);
1099 if (n_from_list > 0) {
1100 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->from_list, 0);
1101 debug_log("From Address:%s", addrs_info->address);
1102 debug_log("Display Name:%s", addrs_info->display_name);
1103 debug_log("Storage Type:%d", addrs_info->storage_type);
1104 debug_log("Contact ID:%d", addrs_info->contact_id);
1106 g_free(prop->sender_display_name);
1107 prop->sender_display_name = g_strdup(addrs_info->display_name);
1108 g_free(prop->sender);
1109 prop->sender = g_strdup(addrs_info->address);
1111 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1112 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->display_name);
1114 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->address);
1118 /* create main box */
1119 ug_data->main_bx = elm_box_add(ug_data->navi_bar);
1120 evas_object_size_hint_weight_set(ug_data->main_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1121 evas_object_size_hint_align_set(ug_data->main_bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1122 evas_object_show(ug_data->main_bx);
1123 elm_object_content_set(ug_data->scroller, ug_data->main_bx);
1125 if (ug_data->property->has_attachment)
1126 ug_data->got_att = 1;
1128 ug_data->got_att = 0;
1130 /* packing subject, addrs, attachment */
1131 _create_subject(ug_data);
1133 if (ug_data->got_att) {
1134 _create_attach(ug_data);
1137 if (ug_data->isRotate == true) {
1138 debug_log("In Split view - Hiding navi bar");
1139 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE);
1141 if (ug_data->b_btn) {
1143 debug_log("hiding back button");
1145 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1146 evas_object_del(ug_data->b_btn);
1147 ug_data->b_btn = NULL;
1149 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
1154 static void _reset_view(EmailViewerUGD *ug_data)
1157 EmailViewerProp *prop = ug_data->property;
1159 char date_time[MAX_STR_LEN] = { 0, };
1161 debug_log("@@@@@@@@@@ isRotate = %d", ug_data->isRotate);
1162 if (ug_data->isRotate == true) {
1163 debug_log("In Split view - Hiding navi bar");
1164 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE);
1166 if (ug_data->b_btn) {
1168 debug_log("hiding back button");
1170 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1171 evas_object_del(ug_data->b_btn);
1172 ug_data->b_btn = NULL;
1174 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
1177 /* Set scroller to start - height made 480 to consider viewer in split view */
1178 elm_scroller_region_show(ug_data->scroller, 0, 0, (int)((double)ug_data->main_h * 0.6), ug_data->main_w);
1180 debug_log("In Full view - Showing navi bar");
1181 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_TRUE);
1183 if (ug_data->b_btn) {
1185 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1186 evas_object_del(ug_data->b_btn);
1187 ug_data->b_btn = NULL;
1190 debug_log("showing back button");
1192 ug_data->b_btn = elm_button_add(ug_data->navi_bar);
1193 elm_object_style_set(ug_data->b_btn, "naviframe/back_btn/default");
1194 evas_object_smart_callback_add(ug_data->b_btn, "clicked", _back_cb, ug_data);
1196 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", ug_data->b_btn);
1198 /* Set scroller to start */
1199 elm_scroller_region_show(ug_data->scroller, 0, 0, ug_data->main_w, ug_data->main_h);
1202 if (ug_data->from_list != NULL) {
1203 email_address_info_t *addrs_info = NULL;
1204 int n_from_list = g_list_length(ug_data->from_list);
1205 debug_log("from list count [%d]", n_from_list);
1207 if (n_from_list > 0) {
1208 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->from_list, 0);
1210 debug_log("From Address:%s", addrs_info->address);
1211 debug_log("Display Name:%s", addrs_info->display_name);
1212 debug_log("Storage Type:%d", addrs_info->storage_type);
1213 debug_log("Contact ID:%d", addrs_info->contact_id);
1214 g_free(prop->sender_display_name);
1215 prop->sender_display_name = g_strdup(addrs_info->display_name);
1216 g_free(prop->sender);
1217 prop->sender = g_strdup(addrs_info->address);
1219 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1220 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->display_name);
1222 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->address);
1226 elm_object_item_text_set(ug_data->navi_main_it, prop->sender_display_name);
1230 char *_subject = elm_entry_utf8_to_markup(prop->subject);
1231 if (!g_strcmp0(_subject, "")) {
1233 _subject = g_strdup(_("IDS_EMAIL_BODY_NO_SUBJECT"));
1235 char *_subject_concated = g_strconcat("<font_size=44><color=#000000FF>", _subject, "</color></font_size>", NULL);
1236 elm_object_text_set(ug_data->lb_subject, _subject_concated);
1237 elm_label_wrap_width_set(ug_data->lb_subject, ug_data->main_w - (int)(110 * ug_data->scale_factor));
1238 elm_label_line_wrap_set(ug_data->lb_subject, ELM_WRAP_WORD);
1240 g_free(_subject_concated);
1242 /* reset date & time */
1243 char *formatted_date = NULL;
1245 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1246 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
1248 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
1249 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
1251 free(formatted_date);
1252 formatted_date = NULL;
1254 elm_object_part_text_set(ug_data->ly_subject, "elm.text.sub", date_time);
1256 Evas_Object *favorite_icon = elm_icon_add(ug_data->ly_subject);
1257 switch(prop->favorite)
1259 case EMAIL_FLAG_NONE:
1260 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_off.png", NULL);
1262 case EMAIL_FLAG_FLAGED:
1263 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_on.png", NULL);
1265 case EMAIL_FLAG_TASK_STATUS_CLEAR:
1266 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
1268 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
1269 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
1271 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
1272 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
1275 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1276 elm_icon_resizable_set(favorite_icon, 1, 1);
1277 evas_object_del(elm_object_part_content_unset(ug_data->ly_subject, "elm.icon.favorite"));
1278 elm_object_part_content_set(ug_data->ly_subject, "elm.icon.favorite", favorite_icon);
1279 evas_object_show(favorite_icon);
1281 evas_object_show(ug_data->ly_subject);
1282 elm_box_pack_end(ug_data->main_bx, ug_data->ly_subject);
1284 Evas_Object *edje = elm_layout_edje_get(ug_data->ly_subject);
1286 if (!ug_data->to_list && !ug_data->cc_list && !ug_data->bcc_list) {
1287 edje_object_signal_emit(edje, "elm,state,arrow_hidden", "elm");
1290 if (prop->has_attachment)
1291 ug_data->got_att = 1;
1293 ug_data->got_att = 0;
1295 /* pack attachment if it exist */
1296 if (ug_data->got_att) {
1297 _create_attach(ug_data);
1300 /* check body downloaded */
1301 _check_body_download(ug_data);
1304 void _hide_view(EmailViewerUGD *ug_data)
1307 EmailViewerProp *prop = ug_data->property;
1308 EmailViewerPrivate *priv = ug_data->email_data;
1310 debug_log("Cancelling all attachment downloads");
1311 _cancel_download_attachment(ug_data);
1313 ug_data->display_download_result = FALSE;
1316 if (elm_naviframe_top_item_get(ug_data->navi_bar) != ug_data->navi_main_it) {
1317 ug_data->navi_move_it1 = NULL;
1318 elm_naviframe_item_pop_to(ug_data->navi_main_it);
1321 evas_object_hide(ug_data->layout_main);
1322 elm_box_unpack_all(ug_data->main_bx);
1323 elm_object_scroll_freeze_pop(ug_data->scroller);
1325 evas_object_hide(ug_data->ly_subject);
1326 evas_object_hide(ug_data->lb_subject);
1327 evas_object_hide(ug_data->webview_bx);
1328 evas_object_hide(ug_data->webview);
1330 if (ug_data->partial_dn_btn) {
1331 evas_object_del(ug_data->partial_dn_btn);
1332 ug_data->partial_dn_btn = NULL;
1335 if (ug_data->partial_dn_btn_bx) {
1336 evas_object_del(ug_data->partial_dn_btn_bx);
1337 ug_data->partial_dn_btn_bx = NULL;
1340 if (ug_data->ctr_bar) {
1341 elm_object_item_part_content_unset(ug_data->navi_main_it, "controlbar");
1342 evas_object_del(ug_data->ctr_bar);
1343 ug_data->ctr_bar = NULL;
1345 ug_data->reply_ctr_it = NULL;
1346 ug_data->replyall_ctr_it = NULL;
1347 ug_data->forward_ctr_it = NULL;
1348 ug_data->calendar_ctr_it = NULL;
1349 ug_data->resend_ctr_it = NULL;
1350 ug_data->move_ctr_it = NULL;
1351 ug_data->del_ctr_it = NULL;
1354 if (ug_data->to_ly) {
1355 evas_object_del(ug_data->to_ly);
1356 ug_data->to_ly = NULL;
1359 if (ug_data->cc_ly) {
1360 evas_object_del(ug_data->cc_ly);
1361 ug_data->cc_ly = NULL;
1364 if (ug_data->bcc_ly) {
1365 evas_object_del(ug_data->bcc_ly);
1366 ug_data->bcc_ly = NULL;
1369 if (ug_data->got_att) {
1372 evas_object_del(ug_data->attach_hd_bk);
1373 ug_data->attach_hd_ly = NULL;
1374 ug_data->attach_hd_bk = NULL;
1376 if (prop->real_att_len > 1) {
1377 for (i = 0; i < prop->real_att_len; i++) {
1378 if (ug_data->attach_ex_ly != NULL) {
1379 if (ug_data->attach_ex_ly[i] != NULL) {
1380 debug_log("index %d", i);
1381 evas_object_del(ug_data->attach_ex_bk[i]);
1382 ug_data->attach_ex_ly[i] = NULL;
1383 ug_data->attach_ex_bk[i] = NULL;
1388 if (ug_data->attach_ex_ly != NULL) {
1389 free(ug_data->attach_ex_ly);
1390 ug_data->attach_ex_ly = NULL;
1391 ug_data->attach_ex_bk = NULL;
1395 for (i = 0; i <= prop->att_len; i++) {
1396 if (ug_data->progress_bar_ly[i] != NULL) {
1397 evas_object_del(ug_data->progress_bar_ly[i]);
1398 ug_data->progress_bar_ly[i] = NULL;
1399 ug_data->progress_bar[i] = NULL;
1404 if (ug_data->con_popup != NULL) {
1405 evas_object_del(ug_data->con_popup);
1406 ug_data->con_popup = NULL;
1409 if (ug_data->notify != NULL) {
1410 evas_object_del(ug_data->notify);
1411 ug_data->notify = NULL;
1414 edje_object_signal_emit(_EDJ(ug_data->ly_subject), "elm,state,contracted", "elm");
1416 evas_object_hide(ug_data->noc_bx);
1417 evas_object_hide(ug_data->dn_btn);
1419 ewk_view_uri_set(ug_data->webview, EMAIL_DEFAULT_HTML);
1421 debug_log("free address info list");
1422 email_free_address_info_list(&(priv->addrs_info_list));
1423 ug_data->from_list = NULL;
1424 ug_data->to_list = NULL;
1425 ug_data->cc_list = NULL;
1426 ug_data->bcc_list = NULL;
1428 ug_data->got_att = 0;
1429 ug_data->subject_onoff_flag = 0;
1430 ug_data->attach_onoff_flag = 0;
1431 ug_data->b_partial_body = 0;
1432 ug_data->b_internal = 0;
1433 ug_data->scroller_locked = 0;
1434 ug_data->m_is_multi_touch = 0;
1436 ug_data->navi_move_it1 = NULL;
1438 /* Double_Scroller */
1440 ug_data->b_load_finished = EINA_FALSE;
1441 ug_data->b_show_remote_images = EINA_FALSE;
1442 ug_data->is_webview_scrolling = EINA_FALSE;
1443 ug_data->is_main_scroller_scrolling = EINA_FALSE;
1446 static void _win_profile_changed_cb(void *data, Evas_Object *obj, void *event)
1450 debug_log("data is NULL");
1454 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
1456 const char *profile = elm_config_profile_get();
1457 if (!g_strcmp0(profile, "desktop"))
1458 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "noindicator");
1460 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "default");
1462 evas_object_size_hint_weight_set(ug_data->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1463 elm_win_resize_object_add(ug_data->win_main, ug_data->layout_main);
1464 evas_object_show(ug_data->layout_main);
1467 static Evas_Object *_create_navigation_bar(EmailViewerUGD *ug_data)
1470 Evas_Object *navi_bar;
1472 navi_bar = elm_naviframe_add(ug_data->layout_main);
1473 if (navi_bar == NULL) {
1474 debug_log("navi_bar == NULL");
1478 elm_object_part_content_set(ug_data->layout_main, "elm.swallow.content", navi_bar);
1479 evas_object_show(navi_bar);
1481 ug_data->navi_bar = navi_bar;
1485 static Evas_Object *_create_subject(EmailViewerUGD *ug_data)
1488 EmailViewerProp *prop = ug_data->property;
1490 char date_time[MAX_STR_LEN] = { 0, };
1492 /* append subject */
1493 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1494 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.detail_subject");
1495 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1497 Evas_Object *subject_label;
1498 subject_label = elm_label_add(di);
1499 elm_object_part_content_set(di, "elm.text", subject_label);
1500 char *subject = elm_entry_utf8_to_markup(prop->subject);
1501 if (!g_strcmp0(subject, "")) {
1503 subject = g_strdup(_("IDS_EMAIL_BODY_NO_SUBJECT"));
1505 char *subject_tagged = g_strconcat("<font_size=44><color=#000000FF>", subject, "</color></font_size>", NULL);
1506 elm_object_text_set(subject_label, subject_tagged);
1507 elm_label_wrap_width_set(subject_label, ug_data->main_w - (int)(110 * ug_data->scale_factor));
1508 elm_label_line_wrap_set(subject_label, ELM_WRAP_WORD);
1509 ug_data->lb_subject = subject_label;
1511 g_free(subject_tagged);
1513 char *formatted_date = NULL;
1515 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1516 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
1518 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
1519 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
1520 free(formatted_date);
1521 formatted_date = NULL;
1523 elm_object_part_text_set(di, "elm.text.sub", date_time);
1525 Evas_Object *favorite_icon = elm_icon_add(di);
1526 switch(prop->favorite)
1528 case EMAIL_FLAG_NONE:
1529 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_off.png", NULL);
1531 case EMAIL_FLAG_FLAGED:
1532 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_on.png", NULL);
1534 case EMAIL_FLAG_TASK_STATUS_CLEAR:
1535 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
1537 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
1538 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
1540 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
1541 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
1544 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1545 elm_icon_resizable_set(favorite_icon, 1, 1);
1546 elm_object_part_content_set(di, "elm.icon.favorite", favorite_icon);
1547 evas_object_show(favorite_icon);
1549 evas_object_show(di);
1550 elm_box_pack_end(ug_data->main_bx, di);
1551 ug_data->ly_subject = di;
1553 Evas_Object *edje = elm_layout_edje_get(di);
1555 if (ug_data->to_list || ug_data->cc_list || ug_data->bcc_list) {
1556 edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _subject_detail_clicked_cb, di);
1558 edje_object_signal_emit(edje, "elm,state,arrow_hidden", "elm");
1560 edje_object_signal_callback_add(edje, "elm,action,toggle", "elm", _subject_favorite_clicked_cb, di);
1565 static Evas_Object *_create_to_addrs(EmailViewerUGD *ug_data)
1568 email_address_info_t *addrs_info = NULL;
1569 Elm_Object_Item *mbe_item;
1571 if (ug_data->to_list == NULL) {
1572 debug_log("to_list is NULL");
1576 int n_to_list = g_list_length(ug_data->to_list);
1579 if (n_to_list <= 0) {
1580 debug_log("to_list count is 0");
1584 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1585 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1586 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1587 evas_object_show(di);
1588 ug_data->to_ly = di;
1589 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1591 Evas_Object *to_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1592 char desc[MAX_STR_LEN] = { 0, };
1593 snprintf(desc, MAX_STR_LEN, "%s:", dgettext("sys_string", "IDS_COM_BODY_TO"));
1594 char *to_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1595 elm_object_text_set(to_mbe, to_str);
1598 evas_object_smart_callback_add(to_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1599 evas_object_smart_callback_add(to_mbe, "item,added", _mbe_added_cb, ug_data);
1600 evas_object_smart_callback_add(to_mbe, "focused", _mbe_focused_cb, ug_data);
1601 evas_object_smart_callback_add(to_mbe, "unfocused", _mbe_unfocused_cb, ug_data);
1602 elm_object_part_content_set(di, "elm.icon", to_mbe);
1603 ug_data->to_mbe = to_mbe;
1605 Evas_Object *entry = elm_multibuttonentry_entry_get(to_mbe);
1607 elm_entry_editable_set(entry, EINA_FALSE);
1609 if (n_to_list > EMAIL_VIEW_MAX_TO_COUNT)
1610 n_to_list = EMAIL_VIEW_MAX_TO_COUNT;
1612 for (i = 0; i < n_to_list; i++) {
1613 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->to_list, i);
1614 debug_log("Address:%s", addrs_info->address);
1615 debug_log("Display Name:%s", addrs_info->display_name);
1616 debug_log("Storage Type:%d", addrs_info->storage_type);
1617 debug_log("Contact ID:%d", addrs_info->contact_id);
1619 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1620 mbe_item = elm_multibuttonentry_item_append(to_mbe, addrs_info->display_name, NULL, NULL);
1622 mbe_item = elm_multibuttonentry_item_append(to_mbe, addrs_info->address, NULL, NULL);
1623 elm_object_item_data_set(mbe_item, addrs_info);
1629 static Evas_Object *_create_cc_addrs(EmailViewerUGD *ug_data)
1632 email_address_info_t *addrs_info = NULL;
1633 Elm_Object_Item *mbe_item;
1635 if (ug_data->cc_list == NULL) {
1636 debug_log("cc_list is NULL");
1640 int n_cc_list = g_list_length(ug_data->cc_list);
1643 if (n_cc_list <= 0) {
1644 debug_log("cc_list count is 0");
1648 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1649 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1650 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1651 evas_object_show(di);
1652 ug_data->cc_ly = di;
1654 if (ug_data->to_ly) {
1655 elm_box_pack_after(ug_data->main_bx, di, ug_data->to_ly);
1657 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1660 Evas_Object *cc_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1661 char desc[MAX_STR_LEN] = { 0, };
1662 snprintf(desc, MAX_STR_LEN, "%s:", _("IDS_EMAIL_BODY_CC"));
1663 char *cc_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1664 elm_object_text_set(cc_mbe, cc_str);
1666 evas_object_smart_callback_add(cc_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1667 evas_object_smart_callback_add(cc_mbe, "item,added", _mbe_added_cb, ug_data);
1668 evas_object_smart_callback_add(cc_mbe, "focused", _mbe_focused_cb, ug_data);
1669 evas_object_smart_callback_add(cc_mbe, "unfocused", _mbe_unfocused_cb, ug_data);
1670 elm_object_part_content_set(di, "elm.icon", cc_mbe);
1671 ug_data->cc_mbe = cc_mbe;
1673 Evas_Object *entry = elm_multibuttonentry_entry_get(cc_mbe);
1675 elm_entry_editable_set(entry, EINA_FALSE);
1677 if (n_cc_list > EMAIL_VIEW_MAX_CC_COUNT)
1678 n_cc_list = EMAIL_VIEW_MAX_CC_COUNT;
1680 for (i = 0; i < n_cc_list; i++) {
1681 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->cc_list, i);
1683 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1684 mbe_item = elm_multibuttonentry_item_append(cc_mbe, addrs_info->display_name, NULL, NULL);
1686 mbe_item = elm_multibuttonentry_item_append(cc_mbe, addrs_info->address, NULL, NULL);
1687 elm_object_item_data_set(mbe_item, addrs_info);
1693 static Evas_Object *_create_bcc_addrs(EmailViewerUGD *ug_data)
1696 email_address_info_t *addrs_info = NULL;
1697 Elm_Object_Item *mbe_item;
1699 if (ug_data->bcc_list == NULL) {
1700 debug_log("bcc_list is NULL");
1704 int n_bcc_list = g_list_length(ug_data->bcc_list);
1707 if (n_bcc_list <= 0) {
1708 debug_log("bcc_list count is 0");
1712 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1713 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1714 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1715 evas_object_show(di);
1716 ug_data->bcc_ly = di;
1718 if (ug_data->cc_ly) {
1719 elm_box_pack_after(ug_data->main_bx, di, ug_data->cc_ly);
1721 if (ug_data->to_ly && ug_data->cc_ly == NULL) {
1722 elm_box_pack_after(ug_data->main_bx, di, ug_data->to_ly);
1724 if (ug_data->to_ly == NULL && ug_data->cc_ly == NULL) {
1725 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1728 Evas_Object *bcc_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1729 char desc[MAX_STR_LEN] = { 0, };
1730 snprintf(desc, MAX_STR_LEN, "%s:", _("IDS_EMAIL_BODY_BCC"));
1731 char *bcc_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1732 elm_object_text_set(bcc_mbe, bcc_str);
1734 evas_object_smart_callback_add(bcc_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1735 evas_object_smart_callback_add(bcc_mbe, "item,added", _mbe_added_cb, ug_data);
1736 evas_object_smart_callback_add(bcc_mbe, "focused", _mbe_focused_cb, ug_data);
1737 evas_object_smart_callback_add(bcc_mbe, "unfocused", _mbe_unfocused_cb, ug_data);
1738 elm_object_part_content_set(di, "elm.icon", bcc_mbe);
1739 ug_data->bcc_mbe = bcc_mbe;
1741 Evas_Object *entry = elm_multibuttonentry_entry_get(bcc_mbe);
1743 elm_entry_editable_set(entry, EINA_FALSE);
1745 if (n_bcc_list > EMAIL_VIEW_MAX_BCC_COUNT)
1746 n_bcc_list = EMAIL_VIEW_MAX_BCC_COUNT;
1748 for (i = 0; i < n_bcc_list; i++) {
1749 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->bcc_list, i);
1751 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1752 mbe_item = elm_multibuttonentry_item_append(bcc_mbe, addrs_info->display_name, NULL, NULL);
1754 mbe_item = elm_multibuttonentry_item_append(bcc_mbe, addrs_info->address, NULL, NULL);
1755 elm_object_item_data_set(mbe_item, addrs_info);
1761 static Evas_Object *_create_attach(EmailViewerUGD *ug_data)
1765 EmailViewerProp *prop = ug_data->property;
1766 char buff[MAX_STR_LEN];
1768 int att_len = prop->real_att_len;
1771 RETURN_VAL_IF_FAIL(prop->attachments != NULL, NULL);
1772 RETURN_VAL_IF_FAIL(att_len > 0, NULL);
1774 GList *attachment_list = prop->attachments;
1777 LIST_ITER_START(i, attachment_list) {
1778 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
1780 if (info && !info->inline_content) {
1781 if (info->size < 1024) {
1782 g_sprintf(buff, "%s (%d %s)", info->name, (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
1784 gdouble tmpsize = (gdouble) (info->size / 1024.);
1785 if (tmpsize < 1024) {
1786 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1789 if (tmpsize < 1024) {
1790 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1793 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1798 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1799 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_item");
1800 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1801 evas_object_show(di);
1802 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1804 Evas_Object *thumbnail = NULL;
1806 if (info->download_yn) {
1807 thumbnail = viewer_make_thumbnail(info->path, di);
1809 thumbnail = viewer_make_thumbnail(NULL, di);
1810 evas_object_size_hint_aspect_set(thumbnail, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1811 elm_icon_resizable_set(thumbnail, 1, 1);
1812 elm_object_part_content_set(di, "elm.icon", thumbnail);
1813 evas_object_show(thumbnail);
1815 elm_object_part_text_set(di, "elm.text", buff);
1819 Evas_Object *edje = elm_layout_edje_get(di);
1820 edje_object_signal_callback_add(edje, "elm,action,download", "elm", _attachment_save_cb, (void *)att_index);
1821 edje_object_signal_callback_add(edje, "clicked", "*", _attachment_clicked_cb, (void *)att_index);
1823 Evas_Object *text_bg = NULL;
1824 text_bg = (Evas_Object *)edje_object_part_object_get(_EDJ(di), "elm.event.rect");
1827 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_DOWN, _attachment_bg_set_cb, (void *)att_index);
1828 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_UP, _attachment_bg_unset_cb, (void *)att_index);
1831 ug_data->attach_hd_ly = di;
1832 ug_data->attach_hd_bk = di;
1835 } else if (att_len > 1) {
1836 gint64 total_size = prop->total_att_size;
1838 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1839 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_head");
1840 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1841 snprintf(buff, sizeof(buff), "%d %s", att_len, _("IDS_EMAIL_BODY_ATTACHMENTS"));
1843 Evas_Object *att_head_label;
1844 att_head_label = elm_label_add(di);
1845 elm_object_part_content_set(di, "elm.text", att_head_label);
1847 char *buff_tagged = g_strconcat("<font_size=35><color=#000000FF>", buff, "<color></font_size>", NULL);
1848 elm_object_text_set(att_head_label, buff_tagged);
1849 g_free(buff_tagged);
1851 if (total_size < 1024) {
1852 g_sprintf(buff, "(%d %s)", (gint) total_size, dgettext("sys_string", "IDS_COM_BODY_B"));
1854 gdouble tmpsize = (gdouble) (total_size / 1024.);
1856 if (tmpsize < 1024) {
1857 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1861 if (tmpsize < 1024) {
1862 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1865 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1870 edje_object_part_text_set(_EDJ(di), "elm.text.sub", buff);
1872 Evas_Object *edje = elm_layout_edje_get(di);
1873 edje_object_signal_callback_add(edje, "att,icon,save,all", "", _attachment_save_all_cb, di);
1874 edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _attachment_item_collapse_cb, di);
1875 evas_object_show(di);
1876 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1877 ug_data->attach_hd_ly = di;
1878 ug_data->attach_hd_bk = di;
1880 debug_log("Attachment doesn't exist");
1886 static Evas_Object *_create_attach_ex(EmailViewerUGD *ug_data)
1890 EmailViewerProp *prop = ug_data->property;
1891 char buff[MAX_STR_LEN];
1894 int att_len = prop->real_att_len;
1897 RETURN_VAL_IF_FAIL(prop->attachments != NULL, NULL);
1898 RETURN_VAL_IF_FAIL(att_len > 0, NULL);
1900 GList *attachment_list = prop->attachments;
1902 ug_data->attach_ex_ly = (Evas_Object **)calloc(att_len, sizeof(Evas_Object *));
1903 ug_data->attach_ex_bk = (Evas_Object **)calloc(att_len, sizeof(Evas_Object *));
1905 LIST_ITER_START(i, attachment_list) {
1906 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
1908 if (info && !info->inline_content) {
1909 if (info->size < 1024) {
1910 g_sprintf(buff, "%s (%d %s)", info->name, (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
1912 gdouble tmpsize = (gdouble) (info->size / 1024.);
1913 if (tmpsize < 1024) {
1914 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1917 if (tmpsize < 1024) {
1918 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1921 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1926 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1927 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_item");
1928 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1929 elm_box_pack_after(ug_data->main_bx, di, ug_data->attach_hd_ly);
1930 evas_object_show(di);
1932 Evas_Object *thumbnail = NULL;
1934 if (info->download_yn) {
1935 thumbnail = viewer_make_thumbnail(info->path, di);
1937 thumbnail = viewer_make_thumbnail(NULL, di);
1938 evas_object_size_hint_aspect_set(thumbnail, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1939 elm_icon_resizable_set(thumbnail, 1, 1);
1940 elm_object_part_content_set(di, "elm.icon", thumbnail);
1941 evas_object_show(thumbnail);
1943 elm_object_part_text_set(di, "elm.text", buff);
1947 Evas_Object *edje = elm_layout_edje_get(di);
1948 edje_object_signal_callback_add(edje, "elm,action,download", "elm", _attachment_save_cb, (void *)att_index);
1949 edje_object_signal_callback_add(edje, "clicked", "*", _attachment_clicked_cb, (void *)att_index);
1951 Evas_Object *text_bg = NULL;
1952 text_bg = (Evas_Object *)edje_object_part_object_get(_EDJ(di), "elm.event.rect");
1955 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_DOWN, _attachment_bg_set_cb, (void *)att_index);
1956 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_UP, _attachment_bg_unset_cb, (void *)att_index);
1959 debug_log("attach ly %d, att_index %d", j, i);
1961 ug_data->attach_ex_ly[j] = di;
1962 ug_data->attach_ex_bk[j] = di;
1971 static Evas_Object *_create_body(EmailViewerUGD *ug_data)
1974 EmailViewerProp *prop = ug_data->property;
1975 EmailViewerPrivate *priv = ug_data->email_data;
1979 if (ug_data->noc_bx) {
1980 elm_box_unpack(ug_data->main_bx, ug_data->noc_bx);
1981 evas_object_hide(ug_data->noc_bx);
1984 if (ug_data->dn_btn) {
1985 evas_object_hide(ug_data->dn_btn);
1988 if (ug_data->webview_bx) {
1989 _init_webview_data(ug_data);
1991 ewk_view_scale_set(ug_data->webview, 1.0f, 0, 0);
1993 if (prop->has_html) {
1995 ug_data->webview_data->body_type_prev = BODY_TYPE_HTML;
1996 ug_data->webview_data->body_type = BODY_TYPE_HTML;
1997 ug_data->webview_data->uri = prop->body_uri;
2000 ug_data->webview_data->body_type_prev = BODY_TYPE_TEXT;
2001 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
2002 ug_data->webview_data->text_content = prop->body;
2005 viewer_set_webview_content(ug_data, 0);
2007 evas_object_show(ug_data->webview_bx);
2008 evas_object_show(ug_data->webview);
2009 elm_box_pack_end(ug_data->main_bx, ug_data->webview_bx);
2011 _update_tab_bar(ug_data);
2013 /* create webview layout */
2014 ug_data->webview_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.web_view");
2015 if (ug_data->webview_bx == NULL) {
2016 debug_log("Cannot load edj");
2020 evas_object_size_hint_align_set(ug_data->webview_bx, EVAS_HINT_FILL, 0.0);
2021 evas_object_show(ug_data->webview_bx);
2022 elm_box_pack_end(ug_data->main_bx, ug_data->webview_bx);
2024 /* create webview */
2025 if (NULL == ug_data->webview) {
2026 _init_webview_data(ug_data);
2027 viewer_get_webview(ug_data, prop->has_html);
2029 if (prop->has_html) {
2030 ug_data->webview_data->body_type_prev = BODY_TYPE_HTML;
2031 ug_data->webview_data->body_type = BODY_TYPE_HTML;
2032 ug_data->webview_data->uri = prop->body_uri;
2034 ug_data->webview_data->body_type_prev = BODY_TYPE_TEXT;
2035 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
2036 ug_data->webview_data->text_content = prop->body;
2038 viewer_set_webview_content(ug_data, 0);
2041 evas_object_show(ug_data->webview);
2042 elm_object_part_content_set(ug_data->webview_bx, "web_body", ug_data->webview);
2046 if (ug_data->isRotate) {
2047 resized_w = ug_data->webview_width_landscape * ug_data->scale_factor;
2048 resized_h = ug_data->webview_height_landscape * ug_data->scale_factor;
2050 resized_w = ug_data->webview_width * ug_data->scale_factor;
2051 resized_h = ug_data->webview_height * ug_data->scale_factor;
2053 debug_log("resized_w:%d, resized_h:%d", resized_w, resized_h);
2055 evas_object_size_hint_min_set(ug_data->webview, resized_w, resized_h);
2057 /* set touch callbacks */
2058 evas_object_smart_callback_add(ug_data->webview, "policy,navigation,decide", _webview_policy_navigation_decide_cb, ug_data);
2059 evas_object_event_callback_add(ug_data->webview, EVAS_CALLBACK_MULTI_DOWN, _webview_multi_down_cb, ug_data);
2060 evas_object_event_callback_add(ug_data->webview, EVAS_CALLBACK_MULTI_UP, _webview_multi_up_cb, ug_data);
2062 /* update control Bar */
2063 _update_tab_bar(ug_data);
2066 viewer_set_mail_seen(prop, priv->mail_info);
2068 if (ug_data->timer) {
2069 ecore_timer_del(ug_data->timer);
2070 ug_data->timer = NULL;
2073 debug_log("send message - list unlock");
2074 ug_data->timer = ecore_timer_add(0.0, viewer_send_message, ug_data);
2076 return ug_data->webview_bx;
2079 static Evas_Object *_create_tab_bar(EmailViewerUGD *ug_data)
2083 EmailViewerProp *prop = ug_data->property;
2085 obj = elm_toolbar_add(ug_data->navi_bar);
2086 elm_toolbar_shrink_mode_set(obj, ELM_TOOLBAR_SHRINK_EXPAND);
2087 elm_object_style_set(obj, "naviframe");
2089 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX ||
2090 ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX) {
2091 int n_to_list = g_list_length(ug_data->to_list);
2092 int n_cc_list = g_list_length(ug_data->cc_list);
2093 debug_log("to:%d, cc:%d", n_to_list, n_cc_list);
2094 if (n_to_list + n_cc_list >= 2)
2095 ug_data->reply_ctr_it = elm_toolbar_item_append(obj, ICON_REPLY, dgettext("sys_string", "IDS_COM_SK_REPLY"), _reply_option_cb, ug_data);
2097 ug_data->reply_ctr_it = elm_toolbar_item_append(obj, ICON_REPLY, dgettext("sys_string", "IDS_COM_SK_REPLY"), _reply_cb, ug_data);
2098 ug_data->forward_ctr_it = elm_toolbar_item_append(obj, ICON_FORWARD, dgettext("sys_string", "IDS_COM_BODY_FORWARD"), _forward_cb, ug_data);
2099 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2100 ug_data->more_ctr_it = elm_toolbar_item_append(obj, ICON_CONTROLBAR_MORE, dgettext("sys_string", "IDS_COM_SK_MORE"), _more_cb, ug_data);
2102 elm_object_item_disabled_set(ug_data->reply_ctr_it, EINA_TRUE);
2103 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_TRUE);
2104 } else if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_OUTBOX) {
2105 debug_log("save_status: %d", prop->status2);
2106 if (prop->status2 == EMAIL_MAIL_STATUS_SEND_FAILURE) {
2107 ug_data->resend_ctr_it = elm_toolbar_item_append(obj, ICON_RESEND, _("IDS_EMAIL_SK_RESEND"), _resend_cb, ug_data);
2108 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2110 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2113 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2114 ug_data->move_ctr_it = elm_toolbar_item_append(obj, ICON_MOVE, _("IDS_EMAIL_SK_MOVE"), _move_cb, ug_data);
2117 elm_object_item_part_content_set(ug_data->navi_main_it, "controlbar", obj);
2118 ug_data->ctr_bar = obj;
2123 static Evas_Object *_update_tab_bar(EmailViewerUGD *ug_data)
2127 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX ||
2128 ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX) {
2129 elm_object_item_disabled_set(ug_data->reply_ctr_it, EINA_FALSE);
2130 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_FALSE);
2136 static Evas_Object *_create_partial_body_dn_btn(EmailViewerUGD *ug_data)
2140 ug_data->partial_dn_btn_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.partial_download_btn");
2141 if (ug_data->partial_dn_btn_bx == NULL) {
2142 debug_log("Cannot load edj");
2146 evas_object_size_hint_align_set(ug_data->partial_dn_btn_bx, EVAS_HINT_FILL, 0.0);
2147 evas_object_show(ug_data->partial_dn_btn_bx);
2148 elm_box_pack_before(ug_data->main_bx, ug_data->partial_dn_btn_bx, ug_data->webview_bx);
2150 Evas_Object *dn_btn = elm_button_add(ug_data->navi_bar);
2151 elm_object_text_set(dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_FULL_MESSAGE"));
2152 evas_object_smart_callback_add(dn_btn, "clicked", _body_down_cb, (void *)ug_data);
2153 /*elm_object_theme_set(dn_btn, ug_data->theme);*/
2154 elm_object_style_set(dn_btn, "text_only/style2");
2155 evas_object_show(dn_btn);
2156 ug_data->partial_dn_btn = dn_btn;
2158 elm_object_part_content_set(ug_data->partial_dn_btn_bx, "button", ug_data->partial_dn_btn);
2160 return ug_data->partial_dn_btn_bx;
2163 static Evas_Object *_create_bg(Evas_Object *win)
2167 Evas_Object *bg = elm_bg_add(win);
2168 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2169 elm_win_resize_object_add(win, bg);
2170 evas_object_show(bg);
2175 static void _create_down_progress(char *message, popup_cb resp_cb)
2180 debug_log("data is NULL");
2184 EmailViewerUGD *ug_data = _g_ug_data;
2185 Evas_Object *notify, *pb;
2187 notify = elm_popup_add(ug_data->win_main);
2189 debug_log("elm_popup_add returns NULL");
2192 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2193 ug_data->pb_notify = notify;
2195 elm_object_part_text_set(notify, "title,text", message);
2197 pb = elm_progressbar_add(notify);
2199 elm_object_style_set(pb, "list_progress");
2201 elm_progressbar_horizontal_set(pb, EINA_TRUE);
2202 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, EVAS_HINT_FILL);
2203 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2204 evas_object_show(pb);
2205 elm_progressbar_value_set(pb, 0.0);
2206 elm_object_content_set(notify, pb);
2207 ug_data->pb_notify_lb = pb;
2209 Evas_Object *btn1 = elm_button_add(notify);
2210 elm_object_style_set(btn1, "popup_button/default");
2211 elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
2212 elm_object_part_content_set(notify, "button1", btn1);
2213 evas_object_smart_callback_add(btn1, "clicked", resp_cb, ug_data);
2214 debug_log("Cancel btn1 for downloading body: %p", btn1);
2216 evas_object_show(notify);
2219 static void _create_down_progress_ex(int index, EMAIL_VIEWER_PROGRESSBAR_TYPE p_type)
2224 debug_log("data is NULL");
2228 EmailViewerUGD *ug_data = _g_ug_data;
2229 EmailViewerProp *prop = ug_data->property;
2230 EmailViewerPrivate *priv = ug_data->email_data;
2232 if (!prop || !prop->attachments) {
2242 if (ug_data->forward_ctr_it)
2243 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_TRUE);
2249 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
2250 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
2252 GList *attachment_list = prop->attachments;
2254 debug_log("index %d of attachment_count %d", index, prop->att_len);
2256 EmailAttachmentType *info = NULL;
2257 info = g_list_nth_data(attachment_list, index);
2259 debug_log("info is NULL");
2262 Evas_Object *pbar_ly = elm_layout_add(ug_data->navi_bar);
2263 elm_layout_file_set(pbar_ly, EV_THEME_PATH, "layout.email.attachment_downloading");
2264 evas_object_size_hint_align_set(pbar_ly, EVAS_HINT_FILL, 0.0);
2265 evas_object_show(pbar_ly);
2266 ug_data->progress_bar_ly[index + 1] = pbar_ly;
2269 char buff[MAX_STR_LEN] = { 0, };
2271 Evas_Object *downloading_label1;
2272 downloading_label1 = elm_label_add(pbar_ly);
2273 elm_object_part_content_set(pbar_ly, "elm.text.1", downloading_label1);
2274 char *text_tagged = g_strconcat("<font_size=32><align=left><color=#000000FF>", info->name, "</color></align></font_size>", NULL);
2275 elm_object_text_set(downloading_label1, text_tagged);
2276 elm_label_ellipsis_set(downloading_label1, EINA_TRUE);
2277 elm_label_wrap_width_set(downloading_label1, ug_data->main_w - 240);
2278 g_free(text_tagged);
2280 if (info->size < 1024) {
2281 g_sprintf(buff, "%d %s", (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
2283 gdouble tmpsize = (gdouble) (info->size / 1024.);
2285 if (tmpsize < 1024) {
2286 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
2290 if (tmpsize < 1024) {
2291 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
2294 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
2299 Evas_Object *downloading_label3;
2300 downloading_label3 = elm_label_add(pbar_ly);
2301 elm_object_part_content_set(pbar_ly, "elm.text.3", downloading_label3);
2302 text_tagged = g_strconcat("<font_size=26><align=right><color=#646464FF>", buff, "</color></align></font_size>", NULL);
2303 elm_object_text_set(downloading_label3, text_tagged);
2304 g_free(text_tagged);
2307 Evas_Object *progressbar = elm_progressbar_add(pbar_ly);
2308 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
2309 elm_object_style_set(progressbar, "list_progress");
2310 elm_object_part_content_set(pbar_ly, "elm.icon.2", progressbar);
2311 ug_data->progress_bar[index + 1] = progressbar;
2312 evas_object_show(progressbar);
2314 Evas_Object *cancel_btn = elm_button_add(pbar_ly);
2315 /*elm_object_theme_set(cancel_btn, ug_data->theme);*/
2316 elm_object_style_set(cancel_btn, "text_only/style2");
2317 elm_object_text_set(cancel_btn, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
2319 elm_object_part_content_set(pbar_ly, "elm.icon.1", cancel_btn);
2320 evas_object_show(cancel_btn);
2321 evas_object_smart_callback_add(cancel_btn, "clicked", _destroy_down_progress_ex, (void *)index);
2322 debug_log("Cancel button for attachment downloading progress popup: %p", cancel_btn);
2324 /* packing progress layout */
2325 if (p_type == EMAIL_VIEWER_PROGRESSBAR_ATT && prop->real_att_len > 1) {
2326 for (i = 0; i < prop->att_len; i++) {
2327 info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2328 if (info && !info->inline_content) {
2330 if (ug_data->attach_ex_ly != NULL && ug_data->attach_ex_ly[j] != NULL) {
2332 elm_box_pack_after(ug_data->main_bx, pbar_ly, ug_data->attach_ex_ly[j]);
2333 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[j]);
2334 evas_object_hide(ug_data->attach_ex_ly[j]);
2335 ug_data->attach_ex_ly[j] = pbar_ly;
2342 if ((p_type == EMAIL_VIEWER_PROGRESSBAR_ATT && prop->real_att_len == 1) || (p_type == EMAIL_VIEWER_PROGRESSBAR_ATT_ALL)) {
2344 elm_box_pack_after(ug_data->main_bx, pbar_ly, ug_data->attach_hd_ly);
2345 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2346 evas_object_hide(ug_data->attach_hd_ly);
2347 ug_data->attach_hd_ly = pbar_ly;
2350 elm_object_focus_set(pbar_ly, EINA_TRUE);
2351 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
2354 static void _destroy_down_progress_ex(void *data, Evas_Object *obj, void *event_info)
2359 debug_log("data is NULL");
2363 EmailViewerUGD *ug_data = _g_ug_data;
2364 EmailViewerPrivate *priv = ug_data->email_data;
2365 EmailViewerProp *prop = ug_data->property;
2367 if (!prop || !prop->attachments) {
2381 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
2382 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
2384 GList *attachment_list = prop->attachments;
2385 int index = (int)data;
2388 /* Cancel the download in email-service */
2390 debug_log("index[%d] download_all_cnt[%d] email_handle[%d]", index, priv->download_all_cnt, priv->download_all_email_handle[index]);
2391 if (priv->download_all_email_handle[index] != 0) {
2392 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[index]);
2393 priv->download_all_email_handle[index] = 0;
2396 (priv->download_all_cnt)--;
2398 if (priv->download_all_cnt == 0)
2399 priv->b_all_att_save = FALSE;
2400 } else if (index == -1) {
2401 for (i = 0; i < prop->att_len; i++) {
2402 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2403 if (info && !info->inline_content) {
2404 debug_log("index[%d] download_all_cnt[%d] email_handle[%d]", i, priv->download_all_cnt, priv->download_all_email_handle[i]);
2405 if (priv->download_all_email_handle[i] != 0) {
2406 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[i]);
2409 priv->download_all_email_handle[i] = 0;
2411 priv->download_all_cnt = 0;
2412 priv->b_all_att_save = FALSE;
2415 /* upack and delete, pack again */
2417 debug_log("real_att_len:%d", prop->real_att_len);
2418 if (prop->real_att_len == 1) {
2419 debug_log("index[%d]", index);
2420 elm_box_pack_after(ug_data->main_bx, ug_data->attach_hd_bk, ug_data->attach_hd_ly);
2421 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2422 evas_object_del(ug_data->attach_hd_ly);
2423 ug_data->attach_hd_ly = ug_data->attach_hd_bk;
2424 evas_object_show(ug_data->attach_hd_ly);
2425 elm_object_focus_set(ug_data->attach_hd_ly, EINA_TRUE);
2426 ug_data->progress_bar[index + 1] = NULL;
2427 ug_data->progress_bar_ly[index + 1] = NULL;
2428 } else if (prop->real_att_len > 1) {
2429 for (i = 0; i < prop->att_len; i++) {
2430 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2431 if (info && !info->inline_content) {
2433 debug_log("index[%d]", i);
2434 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
2435 if (ug_data->attach_onoff_flag > 0) {
2436 elm_box_pack_after(ug_data->main_bx, ug_data->attach_ex_bk[j], ug_data->attach_ex_ly[j]);
2437 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[j]);
2438 evas_object_del(ug_data->attach_ex_ly[j]);
2439 ug_data->attach_ex_ly[j] = ug_data->attach_ex_bk[j];
2440 evas_object_show(ug_data->attach_ex_ly[j]);
2441 elm_object_focus_set(ug_data->attach_ex_ly[j], EINA_TRUE);
2442 ug_data->progress_bar[index + 1] = NULL;
2443 ug_data->progress_bar_ly[index + 1] = NULL;
2445 evas_object_del(ug_data->attach_ex_ly[j]);
2446 ug_data->attach_ex_ly[j] = ug_data->attach_ex_bk[j];
2447 ug_data->progress_bar[index + 1] = NULL;
2448 ug_data->progress_bar_ly[index + 1] = NULL;
2455 } else if (index == -1) {
2456 debug_log("index[%d]", index);
2457 elm_box_pack_after(ug_data->main_bx, ug_data->attach_hd_bk, ug_data->attach_hd_ly);
2458 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2459 evas_object_del(ug_data->attach_hd_ly);
2460 ug_data->attach_hd_ly = ug_data->attach_hd_bk;
2461 evas_object_show(ug_data->attach_hd_ly);
2462 elm_object_focus_set(ug_data->attach_hd_ly, EINA_TRUE);
2463 ug_data->progress_bar[index + 1] = NULL;
2464 ug_data->progress_bar_ly[index + 1] = NULL;
2467 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
2469 if (priv && priv->download_all_cnt <= 0) {
2470 if (ug_data->forward_ctr_it)
2471 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_FALSE);
2475 static void _create_more_ctxpopup(EmailViewerUGD *ug_data)
2479 debug_log("ug_data is NULL");
2483 EmailViewerProp *prop = ug_data->property;
2484 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
2485 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, prop->sender);
2487 if (ug_data->con_popup) {
2488 evas_object_del(ug_data->con_popup);
2489 ug_data->con_popup = NULL;
2492 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
2493 if (ug_data->con_popup == NULL) {
2494 debug_log("cannot create context popup");
2498 if (contact_list_item) {
2499 debug_log("Contact Item Exist: index[%d]", contact_list_item->index);
2500 char index[10] = { 0, };
2501 snprintf(index, sizeof(index), "%d", contact_list_item->index);
2503 if (email_engine_check_seen_mail(ug_data->account_id, ug_data->mail_id))
2504 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_UNREAD"), NULL, _mark_as_unread_cb, ug_data);
2506 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_READ"), NULL, _mark_as_read_cb, ug_data);
2508 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, _move_cb, ug_data);
2509 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SAVE_EMAIL_ABB"), NULL, _save_email_cb, ug_data);
2510 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_VIEW_CONTACT"), NULL, _ctxpopup_detail_contact_cb, g_strdup(index));
2511 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_ADD_TO_CALENDAR"), NULL, _add_to_calendar_cb, ug_data);
2512 ug_data->more_ctx_block_item = elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_BLOCK"), NULL, _ctxpopup_add_block_rule_cb, prop->sender);
2514 _delete_contacts_list(contact_list_item);
2516 if (email_engine_check_seen_mail(ug_data->account_id, ug_data->mail_id))
2517 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_UNREAD"), NULL, _mark_as_unread_cb, ug_data);
2519 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_READ"), NULL, _mark_as_read_cb, ug_data);
2521 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, _move_cb, ug_data);
2522 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SAVE_EMAIL_ABB"), NULL, _save_email_cb, ug_data);
2523 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_OPT_ADD_TO_CONTACTS"), NULL, _ctxpopup_select_contact_mode_email_cb, prop->sender);
2524 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_ADD_TO_CALENDAR"), NULL, _add_to_calendar_cb, ug_data);
2525 ug_data->more_ctx_block_item = elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_BLOCK"), NULL, _ctxpopup_add_block_rule_cb, prop->sender);
2529 email_rule_t *rule_list = NULL;
2531 /* get the rule list from service */
2532 if (email_get_rule_list(&rule_list, &count) < 0) {
2533 debug_log("email_get_rule_list failed");
2536 for (i = 0; i < count; i++) {
2537 if (rule_list[i].type == EMAIL_FILTER_FROM) {
2538 debug_log("block address %s", rule_list[i].value);
2540 if (g_strcmp0(rule_list[i].value, prop->sender) == 0) {
2541 debug_log("[%s] already blocked", rule_list[i].value);
2542 if (ug_data->more_ctx_block_item)
2543 elm_object_item_disabled_set(ug_data->more_ctx_block_item, EINA_TRUE);
2548 /* free email rule_list */
2549 email_free_rule(&rule_list, count);
2553 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
2554 evas_object_move(ug_data->con_popup, x, y - 20);
2555 evas_object_show(ug_data->con_popup);
2558 static void _create_reply_ctxpopup(EmailViewerUGD *ug_data)
2562 debug_log("ug_data is NULL");
2566 if (ug_data->con_popup) {
2567 evas_object_del(ug_data->con_popup);
2568 ug_data->con_popup = NULL;
2571 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
2572 if (ug_data->con_popup == NULL) {
2573 debug_log("cannot create context popup");
2577 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_TO_SENDER_ABB"), NULL, _reply_cb, ug_data);
2578 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_TO_ALL_ABB"), NULL, _reply_all_cb, ug_data);
2581 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
2582 evas_object_move(ug_data->con_popup, x, y - 20);
2583 evas_object_show(ug_data->con_popup);
2586 static void _delete_evas_objects(EmailViewerUGD *ug_data)
2589 EmailViewerProp *prop = ug_data->property;
2591 if (ug_data->webview) {
2592 evas_object_del(ug_data->webview);
2593 ug_data->webview = NULL;
2596 if (ug_data->webview_bx) {
2597 evas_object_del(ug_data->webview_bx);
2598 ug_data->webview_bx = NULL;
2601 if (ug_data->scroller) {
2602 evas_object_del(ug_data->scroller);
2603 ug_data->scroller = NULL;
2606 if (ug_data->main_bx) {
2607 evas_object_del(ug_data->main_bx);
2608 ug_data->main_bx = NULL;
2611 if (ug_data->b_btn) {
2612 evas_object_del(ug_data->b_btn);
2613 ug_data->b_btn = NULL;
2616 if (ug_data->sub_ly) {
2617 evas_object_del(ug_data->sub_ly);
2618 ug_data->sub_ly = NULL;
2621 if (ug_data->navi_bar) {
2622 evas_object_del(ug_data->navi_bar);
2623 ug_data->navi_bar = NULL;
2626 if (ug_data->ctr_bar) {
2627 evas_object_del(ug_data->ctr_bar);
2628 ug_data->ctr_bar = NULL;
2631 if (ug_data->layout_main) {
2632 evas_object_del(ug_data->layout_main);
2633 ug_data->layout_main = NULL;
2636 if (ug_data->con_popup) {
2637 evas_object_del(ug_data->con_popup);
2638 ug_data->con_popup = NULL;
2641 if (ug_data->select_info) {
2642 evas_object_del(ug_data->select_info);
2643 ug_data->select_info = NULL;
2646 if (ug_data->selectioninfo_layout != NULL) {
2647 evas_object_del(ug_data->selectioninfo_layout);
2648 ug_data->selectioninfo_layout = NULL;
2651 if (ug_data->notify) {
2652 evas_object_del(ug_data->notify);
2653 ug_data->notify = NULL;
2656 if (ug_data->pb_notify) {
2657 evas_object_del(ug_data->pb_notify);
2658 ug_data->pb_notify = NULL;
2661 if (ug_data->pb_notify_lb) {
2662 evas_object_del(ug_data->pb_notify_lb);
2663 ug_data->pb_notify_lb = NULL;
2666 if (ug_data->partial_dn_btn) {
2667 evas_object_del(ug_data->partial_dn_btn);
2668 ug_data->partial_dn_btn = NULL;
2671 if (ug_data->partial_dn_btn_bx) {
2672 evas_object_del(ug_data->partial_dn_btn_bx);
2673 ug_data->partial_dn_btn_bx = NULL;
2676 if (ug_data->waiting_timer) {
2677 ecore_timer_del(ug_data->waiting_timer);
2678 ug_data->waiting_timer = NULL;
2681 if (ug_data->timer) {
2682 ecore_timer_del(ug_data->timer);
2683 ug_data->timer = NULL;
2686 if (ug_data->idler) {
2687 ecore_idler_del(ug_data->idler);
2688 ug_data->idler = NULL;
2691 if (ug_data->got_att) {
2694 evas_object_del(ug_data->attach_hd_bk);
2695 ug_data->attach_hd_ly = NULL;
2696 ug_data->attach_hd_bk = NULL;
2698 if (prop->real_att_len > 1) {
2699 for (i = 0; i < prop->real_att_len; i++) {
2700 if (ug_data->attach_ex_ly != NULL) {
2701 if (ug_data->attach_ex_ly[i] != NULL) {
2702 debug_log("index %d", i);
2703 evas_object_del(ug_data->attach_ex_bk[i]);
2704 ug_data->attach_ex_ly[i] = NULL;
2705 ug_data->attach_ex_bk[i] = NULL;
2710 if (ug_data->attach_ex_ly != NULL) {
2711 free(ug_data->attach_ex_ly);
2712 ug_data->attach_ex_ly = NULL;
2713 ug_data->attach_ex_bk = NULL;
2717 for (i = 0; i <= prop->att_len; i++) {
2718 if (ug_data->progress_bar_ly[i] != NULL) {
2719 evas_object_del(ug_data->progress_bar_ly[i]);
2720 ug_data->progress_bar_ly[i] = NULL;
2721 ug_data->progress_bar[i] = NULL;
2727 void _launch_composer(EmailViewerUGD *ug_data, int type)
2732 debug_log("ug_data is NULL");
2736 EmailViewerPrivate *priv = ug_data->email_data;
2740 service_h service = NULL;
2742 ret = service_create(&service);
2743 debug_log("service_create: %d", ret);
2745 debug_log("service create failed");
2749 char rtype[10] = { 0, };
2750 snprintf(rtype, sizeof(rtype), "%d", type);
2751 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
2752 debug_log("service_add_extra_data: %d", ret);
2754 memset(tmp, 0x0, sizeof(tmp));
2755 snprintf(tmp, sizeof(tmp), "%d", priv->account_id);
2756 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_ACCOUNT_ID, tmp);
2757 debug_log("service_add_extra_data: %d", ret);
2759 memset(tmp, 0x0, sizeof(tmp));
2760 snprintf(tmp, sizeof(tmp), "%d", priv->mailbox_id);
2761 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MAILBOX, tmp);
2762 debug_log("service_add_extra_data: %d", ret);
2764 memset(tmp, 0x0, sizeof(tmp));
2765 snprintf(tmp, sizeof(tmp), "%d", priv->mail_id);
2766 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MAIL_ID, tmp);
2767 debug_log("service_add_extra_data: %d", ret);
2769 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
2771 ret = service_destroy(service);
2772 debug_log("service_destroy: %d", ret);
2775 static void _launch_vcs_editor(EmailViewerUGD *ug_data)
2780 debug_log("ug_data is NULL");
2784 char account_id[MAX_STR_LEN] = { 0, };
2785 char mail_id[MAX_STR_LEN] = { 0, };
2787 EmailViewerProp *prop = ug_data->property;
2790 service_h service = NULL;
2792 ret = service_create(&service);
2793 debug_log("service_create: %d", ret);
2795 debug_log("service create failed");
2799 snprintf(account_id, sizeof(account_id), "%d", prop->account_id);
2800 snprintf(mail_id, sizeof(mail_id), "%d", prop->mail_id);
2802 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_ACCOUNT_ID, account_id);
2803 debug_log("service_add_extra_data: %d", ret);
2804 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_MAIL_ID, mail_id);
2805 debug_log("service_add_extra_data: %d", ret);
2806 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_SRC_BOX, prop->src_box);
2807 debug_log("service_add_extra_data: %d", ret);
2808 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_INDEX, EMAIL_BUNDLE_VAL_CALENDAR_EDIT_INDEX);
2809 debug_log("service_add_extra_data: %d", ret);
2810 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_NOTE, prop->subject);
2811 debug_log("service_add_extra_data: %d", ret);
2813 ug_data->ug_calendar_edit = create_ug(UG_NAME_CALENDAR_EDIT, service, ug_data);
2815 ret = service_destroy(service);
2816 debug_log("service_destroy: %d", ret);
2819 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
2823 if (_g_ug_data == NULL) {
2824 debug_log("_g_ug_data is NULL");
2829 debug_log("data is NULL");
2832 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2834 if (ug_data->con_popup != NULL) {
2835 evas_object_del(ug_data->con_popup);
2836 ug_data->con_popup = NULL;
2839 debug_log("isRoate = %d", ug_data->isRotate);
2840 if (ug_data->isRotate == false && ug_data->b_internal) {
2841 /* Viewer to hide, so set left content (mailbox) size to full */
2842 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
2845 if (ug_data->b_internal != 1) {
2846 debug_log("ug_destory_me");
2847 ug_destroy_me(ug_data->ug);
2849 _hide_view(ug_data);
2853 static void _prev_mail_cb(void *data, Evas_Object *obj, void *event_info)
2857 debug_log("data is NULL");
2861 /* send next or previous mail request to mailbox. */
2863 service_h service = NULL;
2865 ret = service_create(&service);
2866 debug_log("service_create: %d", ret);
2868 debug_log("service create failed");
2872 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_PREV_MSG);
2873 debug_log("service_add_extra_data: %d", ret);
2874 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "0");
2875 debug_log("service_add_extra_data: %d", ret);
2877 ug_send_message(_g_mailbox_ug, service);
2879 ret = service_destroy(service);
2880 debug_log("service_destroy: %d", ret);
2883 static void _next_mail_cb(void *data, Evas_Object *obj, void *event_info)
2887 debug_log("data is NULL");
2891 /* send next or previous mail request to mailbox. */
2893 service_h service = NULL;
2895 ret = service_create(&service);
2896 debug_log("service_create: %d", ret);
2898 debug_log("service create failed");
2902 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
2903 debug_log("service_add_extra_data: %d", ret);
2904 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "0");
2905 debug_log("service_add_extra_data: %d", ret);
2907 ug_send_message(_g_mailbox_ug, service);
2909 ret = service_destroy(service);
2910 debug_log("service_destroy: %d", ret);
2913 static void _reply_cb(void *data, Evas_Object *obj, void *event_info)
2917 debug_log("data is NULL");
2921 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2923 if (ug_data->con_popup) {
2924 evas_object_del(ug_data->con_popup);
2925 ug_data->con_popup = NULL;
2928 ug_data->display_download_result = FALSE;
2930 _launch_composer(ug_data, RUN_COMPOSER_REPLY);
2932 if (ug_data->notify) {
2933 evas_object_del(ug_data->notify);
2934 ug_data->notify = NULL;
2938 static void _reply_all_cb(void *data, Evas_Object *obj, void *event_info)
2942 debug_log("data is NULL");
2946 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2948 if (ug_data->con_popup) {
2949 evas_object_del(ug_data->con_popup);
2950 ug_data->con_popup = NULL;
2953 ug_data->display_download_result = FALSE;
2955 _launch_composer(ug_data, RUN_COMPOSER_REPLY_ALL);
2957 if (ug_data->notify) {
2958 evas_object_del(ug_data->notify);
2959 ug_data->notify = NULL;
2963 static void _reply_option_cb(void *data, Evas_Object *obj, void *event_info)
2967 debug_log("data is NULL");
2971 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2973 _create_reply_ctxpopup(ug_data);
2976 static void _forward_cb(void *data, Evas_Object *obj, void *event_info)
2980 debug_log("data is NULL");
2984 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2986 ug_data->display_download_result = FALSE;
2988 _launch_composer(ug_data, RUN_COMPOSER_FORWARD);
2991 static void _add_to_calendar_cb(void *data, Evas_Object *obj, void *event_info)
2998 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3000 if (ug_data->con_popup) {
3001 evas_object_del(ug_data->con_popup);
3002 ug_data->con_popup = NULL;
3005 _launch_vcs_editor(ug_data);
3008 static void _resend_cb(void *data, Evas_Object *obj, void *event_info)
3013 static void _delete_cb(void *data, Evas_Object *obj, void *event_info)
3017 debug_log("data is NULL");
3021 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3023 if (ug_data->con_popup) {
3024 evas_object_del(ug_data->con_popup);
3025 ug_data->con_popup = NULL;
3028 _create_notify(ug_data, NULL, dgettext("sys_string", "IDS_COM_POP_DELETE_Q"),
3029 2, dgettext("sys_string", "IDS_COM_SK_DELETE"),
3030 _popup_response_delete_ok_cb, dgettext("sys_string", "IDS_COM_SK_CANCEL"),
3031 _popup_response_cb, NULL);
3034 static void _move_cb(void *data, Evas_Object *obj, void *event_info)
3038 debug_log("data is NULL");
3042 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3043 EmailViewerPrivate *priv = ug_data->email_data;
3045 if (ug_data->con_popup) {
3046 evas_object_del(ug_data->con_popup);
3047 ug_data->con_popup = NULL;
3050 Evas_Object *gl = elm_genlist_add(ug_data->navi_bar);
3051 evas_object_show(gl);
3053 ug_data->itc1.item_style = "1text.1icon.2";
3054 ug_data->itc1.func.text_get = _gl_text_get;
3055 ug_data->itc1.func.content_get = _gl_content_get;
3056 ug_data->itc1.func.state_get = _gl_state_get;
3057 ug_data->itc1.func.del = _gl_del;
3059 Elm_Object_Item *navi_it = NULL;
3060 navi_it = elm_naviframe_item_push(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, NULL, gl, NULL);
3061 ug_data->navi_move_it1 = navi_it;
3062 if (ug_data->isRotate)
3063 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_FALSE);
3065 email_mailbox_t *mailbox_list = NULL;
3066 int mailbox_count = 0;
3069 email_get_mailbox_list(priv->account_id, -1, &mailbox_list, &mailbox_count);
3070 debug_log("folder count %d", mailbox_count);
3071 ug_data->move_mailbox_list = mailbox_list;
3072 ug_data->move_mailbox_count = mailbox_count;
3074 for (i = 0; i < mailbox_count; i++) {
3075 if (g_strcmp0(ug_data->mailbox_name, mailbox_list[i].mailbox_name) != 0) {
3076 if (mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_OUTBOX &&
3077 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_SENTBOX &&
3078 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_DRAFT &&
3079 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_TRASH &&
3080 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_ALL_EMAILS &&
3081 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_SEARCH_RESULT)
3082 if (g_strcmp0(mailbox_list[i].alias, "[Gmail]")) {
3083 elm_genlist_item_append(gl, &ug_data->itc1, (void *)&(mailbox_list[i]), NULL, ELM_GENLIST_ITEM_NONE, _move_here_cb, (void *)&(mailbox_list[i]));
3088 /*if (ug_data->b_internal)
3089 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "noindicator");
3091 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "default");*/
3093 Evas_Object *move_back_btn = NULL;
3094 if (ug_data->isRotate) {
3095 ug_data->move_cbar = elm_toolbar_add(ug_data->navi_bar);
3096 elm_toolbar_shrink_mode_set(ug_data->move_cbar, ELM_TOOLBAR_SHRINK_EXPAND);
3097 elm_object_style_set(ug_data->move_cbar, "naviframe");
3098 evas_object_show(ug_data->move_cbar);
3100 elm_object_item_disabled_set(elm_toolbar_item_append(ug_data->move_cbar, NULL, "", NULL, NULL), EINA_TRUE);
3101 elm_toolbar_item_append(ug_data->move_cbar, NULL, dgettext("sys_string", "IDS_COM_SK_CANCEL"), _move_back_cb, ug_data);
3102 elm_object_item_part_content_set(navi_it, "controlbar", ug_data->move_cbar);
3104 move_back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
3105 if (move_back_btn) {
3106 evas_object_del(move_back_btn);
3107 elm_object_item_part_content_set(navi_it, "prev_btn", NULL);
3110 move_back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
3111 if (move_back_btn) {
3112 evas_object_del(move_back_btn);
3113 move_back_btn = elm_button_add(ug_data->navi_bar);
3114 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
3115 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb, ug_data);
3116 elm_object_item_part_content_set(navi_it, "prev_btn", move_back_btn);
3121 static void _more_cb(void *data, Evas_Object *obj, void *event_info)
3125 debug_log("data is NULL");
3129 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3131 _create_more_ctxpopup(ug_data);
3134 static void _body_down_cb(void *data, Evas_Object *obj, void *event_info)
3138 debug_log("data is NULL");
3144 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3145 EmailViewerPrivate *priv = ug_data->email_data;
3147 /* check already downloaded */
3148 int body_download_status = ug_data->property->body_download;
3150 if (body_download_status == 0) { //EMAIL_BODY_DOWNLOAD_STATUS_NONE
3151 debug_log("need body download");
3152 } else if (body_download_status == 1) { //EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED
3153 debug_log("already downloaded, create body directly");
3156 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
3158 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
3161 if (ug_data->b_partial_body) {
3166 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
3167 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
3169 elm_box_unpack(ug_data->main_bx, ug_data->partial_dn_btn_bx);
3170 if (ug_data->partial_dn_btn) {
3171 evas_object_del(ug_data->partial_dn_btn);
3172 ug_data->partial_dn_btn = NULL;
3174 if (ug_data->partial_dn_btn_bx) {
3175 evas_object_del(ug_data->partial_dn_btn_bx);
3176 ug_data->partial_dn_btn_bx = NULL;
3179 if (ug_data->property->has_html) {
3180 ug_data->webview_data->body_type = BODY_TYPE_HTML;
3181 ug_data->webview_data->uri = ug_data->property->body_uri;
3183 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
3184 ug_data->webview_data->text_content = ug_data->property->body;
3187 viewer_set_webview_content(ug_data, 1);
3188 ug_data->b_partial_body = 0;
3190 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
3191 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
3193 if (ug_data->property->has_attachment)
3194 ug_data->got_att = 1;
3196 ug_data->got_att = 0;
3198 /* pack attachment if it exist */
3199 if (ug_data->got_att) {
3200 _create_attach(ug_data);
3203 _create_body(ug_data);
3207 } else if (body_download_status == 2) { //EMAILL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED
3208 debug_log("need full body download");
3211 ret = email_engine_body_download(priv->account_id, priv->mail_id, &handle);
3214 priv->email_handle = handle;
3215 debug_log("succeed in email_engine_body_download");
3216 _create_down_progress(dgettext("sys_string", "IDS_COM_POP_DOWNLOADING"), _destroy_down_progress_cb);
3218 /* If attachment download is in progress, first cancel to attachment download of the mail and then carry out body download */
3219 _cancel_download_attachment(ug_data);
3222 debug_log("unable to download mail body");
3223 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
3224 _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), 1,
3225 dgettext("sys_string", "IDS_COM_SK_OK"),
3226 _popup_response_cb, NULL, NULL, NULL);
3230 static void _subject_favorite_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3234 debug_log("data is NULL");
3238 EmailViewerUGD *ug_data = _g_ug_data;
3239 EmailViewerProp *prop = ug_data->property;
3240 int err = EMAIL_ERROR_NONE;
3242 if (ug_data->con_popup) {
3243 evas_object_del(ug_data->con_popup);
3244 ug_data->con_popup = NULL;
3247 debug_log("Before prop->favorite: %d", prop->favorite);
3248 switch(prop->favorite) {
3249 case EMAIL_FLAG_NONE:
3250 prop->favorite = EMAIL_FLAG_FLAGED;
3252 case EMAIL_FLAG_FLAGED:
3253 prop->favorite = EMAIL_FLAG_NONE;
3255 case EMAIL_FLAG_TASK_STATUS_CLEAR:
3256 prop->favorite = EMAIL_FLAG_TASK_STATUS_ACTIVE;
3258 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
3259 prop->favorite = EMAIL_FLAG_TASK_STATUS_COMPLETE;
3261 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
3262 prop->favorite = EMAIL_FLAG_TASK_STATUS_CLEAR;
3265 debug_log("Never here");
3267 debug_log("After prop->favorite: %d", prop->favorite);
3269 err = email_set_flags_field(ug_data->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_FLAGGED_FIELD, prop->favorite, 1);
3270 if (err != EMAIL_ERROR_NONE) {
3271 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3272 N_("Failed to set favourite"), 0,
3273 NULL, NULL, NULL, NULL, _popup_response_cb);
3277 evas_object_del(elm_object_part_content_unset(ug_data->ly_subject, "elm.icon.favorite"));
3278 Evas_Object *favorite_icon = elm_icon_add(ug_data->ly_subject);
3279 switch(prop->favorite)
3281 case EMAIL_FLAG_NONE:
3282 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_off.png", NULL);
3284 case EMAIL_FLAG_FLAGED:
3285 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_on.png", NULL);
3287 case EMAIL_FLAG_TASK_STATUS_CLEAR:
3288 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
3290 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
3291 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
3293 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
3294 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
3297 debug_log("Never here");
3299 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
3300 elm_icon_resizable_set(favorite_icon, 1, 1);
3301 elm_object_part_content_set(ug_data->ly_subject, "elm.icon.favorite", favorite_icon);
3302 evas_object_show(favorite_icon);
3304 /* send unread request to mailbox. */
3306 service_h service = NULL;
3308 ret = service_create(&service);
3309 debug_log("service_create: %d", ret);
3311 debug_log("service create failed");
3315 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_READ);
3316 debug_log("service_add_extra_data: %d", ret);
3318 ug_send_message(_g_mailbox_ug, service);
3320 ret = service_destroy(service);
3321 debug_log("service_destroy: %d", ret);
3324 static void _subject_detail_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3328 debug_log("data is NULL");
3332 Evas_Object *item = (Evas_Object *)data;
3333 EmailViewerUGD *ug_data = _g_ug_data;
3335 if (!(ug_data->subject_onoff_flag)) {
3336 edje_object_signal_emit(_EDJ(item), "elm,state,expanded", "elm");
3337 (ug_data->subject_onoff_flag)++;
3339 _create_to_addrs(ug_data);
3340 _create_cc_addrs(ug_data);
3341 _create_bcc_addrs(ug_data);
3343 edje_object_signal_emit(_EDJ(item), "elm,state,contracted", "elm");
3344 (ug_data->subject_onoff_flag)--;
3346 if (ug_data->to_ly) {
3347 elm_box_unpack(ug_data->main_bx, ug_data->to_ly);
3348 evas_object_del(ug_data->to_ly);
3349 ug_data->to_ly = NULL;
3351 if (ug_data->cc_ly) {
3352 elm_box_unpack(ug_data->main_bx, ug_data->cc_ly);
3353 evas_object_del(ug_data->cc_ly);
3354 ug_data->cc_ly = NULL;
3356 if (ug_data->bcc_ly) {
3357 elm_box_unpack(ug_data->main_bx, ug_data->bcc_ly);
3358 evas_object_del(ug_data->bcc_ly);
3359 ug_data->bcc_ly = NULL;
3362 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
3366 static void _attachment_item_collapse_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3369 if (!data || !_g_ug_data) {
3370 debug_log("data is NULL");
3374 Evas_Object *item = (Evas_Object *)data;
3375 EmailViewerUGD *ug_data = _g_ug_data;
3376 EmailViewerProp *prop = ug_data->property;
3379 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
3380 if (!(ug_data->attach_onoff_flag)) {
3381 debug_log("attachments expanded");
3382 edje_object_signal_emit(_EDJ(item), "elm,state,expanded", "elm");
3383 (ug_data->attach_onoff_flag)++;
3385 if (ug_data->attach_ex_ly == NULL)
3386 _create_attach_ex(ug_data);
3388 for (i = 0; i < prop->real_att_len; i++) {
3389 debug_log("index %d", i);
3390 elm_box_pack_after(ug_data->main_bx, ug_data->attach_ex_ly[i], ug_data->attach_hd_ly);
3391 evas_object_show(ug_data->attach_ex_ly[i]);
3395 debug_log("attachments contracted");
3396 edje_object_signal_emit(_EDJ(item), "elm,state,contracted", "elm");
3397 ug_data->attach_onoff_flag = 0;
3399 for (i = 0; i < prop->real_att_len; i++) {
3400 if (ug_data->attach_ex_ly[i] != NULL) {
3401 debug_log("index %d", i);
3402 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[i]);
3403 evas_object_hide(ug_data->attach_ex_ly[i]);
3409 static void _attachment_save_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3414 debug_log("ug_data is NULL");
3418 EmailViewerUGD *ug_data = _g_ug_data;
3419 int att_index = (int)data;
3421 ug_data->display_download_result = FALSE;
3423 debug_log("Selected item index = %d", att_index);
3424 _show_attachment(ug_data, att_index);
3427 static void _attachment_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3432 debug_log("ug_data is NULL");
3436 EmailViewerUGD *ug_data = _g_ug_data;
3437 int att_index = (int)data;
3439 debug_log("Selected item index = %d", att_index);
3440 ug_data->display_download_result = TRUE;
3441 _show_attachment(ug_data, att_index);
3444 static void _attachment_save_all_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3448 debug_log("ug_data is NULL");
3452 EmailViewerUGD *ug_data = _g_ug_data;
3454 _save_attachment_all(ug_data);
3457 static void _attachment_bg_set_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
3461 debug_log("ug_data is NULL");
3465 EmailViewerUGD *ug_data = _g_ug_data;
3466 EmailViewerProp *prop = ug_data->property;
3468 int att_index = (int)data;
3469 debug_log("att_index = %d, attachments count = %d", att_index, prop->real_att_len);
3471 if (prop->real_att_len > 1) {
3474 GList *attachment_list = prop->attachments;
3475 LIST_ITER_START(i, attachment_list) {
3476 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
3477 if (info && !info->inline_content) {
3483 edje_object_signal_emit(_EDJ(ug_data->attach_ex_ly[j]), "pressed", "elm.event.rect");
3486 edje_object_signal_emit(_EDJ(ug_data->attach_hd_ly), "pressed", "elm.event.rect");
3489 static void _attachment_bg_unset_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
3493 debug_log("ug_data is NULL");
3497 EmailViewerUGD *ug_data = _g_ug_data;
3498 EmailViewerProp *prop = ug_data->property;
3500 int att_index = (int)data;
3501 debug_log("att_index = %d, attachments count = %d", att_index, prop->real_att_len);
3503 if (prop->real_att_len > 1) {
3506 GList *attachment_list = prop->attachments;
3507 LIST_ITER_START(i, attachment_list) {
3508 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
3509 if (info && !info->inline_content) {
3515 edje_object_signal_emit(_EDJ(ug_data->attach_ex_ly[j]), "unpressed", "elm.event.rect");
3518 edje_object_signal_emit(_EDJ(ug_data->attach_hd_ly), "unpressed", "elm.event.rect");
3521 static void _mark_as_unread_cb(void *data, Evas_Object *obj, void *event_info)
3525 debug_log("data is NULL");
3529 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3530 EmailViewerPrivate *priv = ug_data->email_data;
3532 if (ug_data->con_popup) {
3533 evas_object_del(ug_data->con_popup);
3534 ug_data->con_popup = NULL;
3538 debug_log("ug_data->mail_id(%d), priv->mail_id(%d), mail_info->mail_id(%d))", ug_data->mail_id, priv->mail_id, priv->mail_info->mail_id);
3540 err = email_set_flags_field(ug_data->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_SEEN_FIELD, 0, 1);
3541 debug_log("email_set_flags_field - err(%d)", err);
3543 if (err != EMAIL_ERROR_NONE) {
3544 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3545 _("IDS_EMAIL_POP_FAILED_TO_MARK_AS_UNREAD"), 0,
3546 NULL, NULL, NULL, NULL, _popup_response_cb);
3548 char str[128] = { 0, };
3549 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MARKED_AS_UNREAD"));
3550 _show_select_info(ug_data, str);
3552 /* send unread request to mailbox. */
3554 service_h service = NULL;
3556 ret = service_create(&service);
3557 debug_log("service_create: %d", ret);
3559 debug_log("service create failed");
3563 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_UNREAD);
3564 debug_log("service_add_extra_data: %d", ret);
3566 ug_send_message(_g_mailbox_ug, service);
3568 ret = service_destroy(service);
3569 debug_log("service_destroy: %d", ret);
3573 static void _mark_as_read_cb(void *data, Evas_Object *obj, void *event_info)
3577 debug_log("data is NULL");
3581 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3582 EmailViewerPrivate *priv = ug_data->email_data;
3584 if (ug_data->con_popup) {
3585 evas_object_del(ug_data->con_popup);
3586 ug_data->con_popup = NULL;
3590 debug_log("ug_data->mail_id(%d), priv->mail_id(%d), mail_info->mail_id(%d))", ug_data->mail_id, priv->mail_id, priv->mail_info->mail_id);
3592 err = email_set_flags_field(priv->mail_info->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_SEEN_FIELD, 1, 1);
3593 debug_log("email_set_flags_field - err(%d)", err);
3595 if (err != EMAIL_ERROR_NONE) {
3596 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3597 _("IDS_EMAIL_POP_FAILED_TO_MARK_AS_READ"), 0,
3598 NULL, NULL, NULL, NULL, _popup_response_cb);
3600 char str[128] = { 0, };
3601 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MARKED_AS_READ"));
3602 _show_select_info(ug_data, str);
3604 /* send unread request to mailbox. */
3606 service_h service = NULL;
3608 ret = service_create(&service);
3609 debug_log("service_create: %d", ret);
3611 debug_log("service create failed");
3615 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_READ);
3616 debug_log("service_add_extra_data: %d", ret);
3618 ug_send_message(_g_mailbox_ug, service);
3620 ret = service_destroy(service);
3621 debug_log("service_destroy: %d", ret);
3625 static void _create_waiting_popup(EmailViewerUGD *ug_data, const char *title_text, const char *style)
3629 Evas_Object *progress;
3631 if (title_text == NULL) {
3632 debug_log("popup text is null");
3636 popup = elm_popup_add(ug_data->win_main);
3637 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3638 elm_object_part_text_set(popup, "title,text", title_text);
3640 progress = elm_progressbar_add(popup);
3641 elm_object_style_set(progress, style);
3642 elm_progressbar_pulse_set(progress, EINA_TRUE);
3643 elm_progressbar_pulse(progress, EINA_TRUE);
3644 evas_object_show(progress);
3646 elm_object_content_set(popup, progress);
3648 ug_data->timeout_popup = popup;
3650 evas_object_show(popup);
3653 static void _save_email_cb(void *data, Evas_Object *obj, void *event_info)
3657 debug_log("data is NULL");
3661 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3663 if (ug_data->con_popup) {
3664 evas_object_del(ug_data->con_popup);
3665 ug_data->con_popup = NULL;
3668 _create_waiting_popup(ug_data, dgettext("sys_string", "IDS_COM_POP_SAVING_ING"), "pending_list"); //"list_process"
3670 if (ug_data->waiting_timer) {
3671 ecore_timer_del(ug_data->waiting_timer);
3672 ug_data->waiting_timer = NULL;
3674 ug_data->waiting_timer = ecore_timer_add(0.2, _save_email_prog_cb, ug_data);
3677 static Eina_Bool _save_email_prog_cb(void *data)
3681 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3684 debug_log("ug_data->mail_id(%d), priv->mail_id(%d), mail_info->mail_id(%d))", ug_data->mail_id, ug_data->email_data->mail_id, ug_data->email_data->mail_info->mail_id);
3686 email_mail_data_t *mail_t = NULL;
3687 err = email_get_mail_data(ug_data->email_data->mail_id, &mail_t);
3688 debug_log("email_get_mail_data - err (%d)", err);
3690 if (mail_t == NULL) {
3691 debug_log("mail_t is NULL");
3695 email_attachment_data_t *attachment_t = NULL;
3696 int attachment_count = 0;
3697 err = email_get_attachment_data_list(ug_data->email_data->mail_id, &attachment_t, &attachment_count);
3698 debug_log("email_get_attachment_data_list - err (%d)", err);
3700 char file_name[MAX_PATH_LEN] = { 0, };
3701 snprintf(file_name, sizeof(file_name), "%s_%d_%d.%s", DIR_DEFAULT_MEDIA_PHONE"/Downloads/Others/email", ug_data->account_id, ug_data->mail_id, "eml");
3702 char *output_file_path = g_strdup(file_name);
3703 debug_log("output_file_path(%s)", file_name, output_file_path);
3705 err = email_write_mime_file(mail_t, attachment_t, attachment_count, &output_file_path);
3706 debug_log("email_write_mime_file - err(%d)", err);
3708 g_free(output_file_path);
3711 email_free_mail_data(&(mail_t), 1);
3715 if (attachment_t && attachment_count > 0) {
3716 email_free_attachment_data(&(attachment_t), attachment_count);
3717 attachment_t = NULL;
3718 attachment_count = 0;
3721 if (ug_data->timeout_popup) {
3722 evas_object_del(ug_data->timeout_popup);
3723 ug_data->timeout_popup = NULL;
3726 if (err != EMAIL_ERROR_NONE) {
3727 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3728 dgettext("sys_string", "IDS_COM_POP_UNABLE_TO_SAVE"), 0,
3729 NULL, NULL, NULL, NULL, _popup_response_cb);
3732 char str[128] = { 0, };
3733 snprintf(str, sizeof(str), "%s", N_("Saved in My files"));
3734 int ret = status_message_post(str);
3736 debug_log("status_message_post failed: %d", ret);
3738 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_OPT_INFORMATION"),
3739 N_("Saved in My files"), 0,
3740 NULL, NULL, NULL, NULL, _popup_response_cb);
3744 if (ug_data->waiting_timer) {
3745 ecore_timer_del(ug_data->waiting_timer);
3746 ug_data->waiting_timer = NULL;
3752 static void _ctxpopup_detail_contact_cb(void *data, Evas_Object *obj, void *event_info)
3755 if (data == NULL || _g_ug_data == NULL) {
3756 debug_log("data is NULL");
3760 EmailViewerUGD *ug_data = _g_ug_data;
3762 if (ug_data->con_popup) {
3763 evas_object_del(ug_data->con_popup);
3764 ug_data->con_popup = NULL;
3767 char *index = (char *)data;
3768 char type[10] = { 0, };
3770 service_h service = NULL;
3772 ret = service_create(&service);
3773 debug_log("service_create: %d", ret);
3775 debug_log("service create failed");
3779 snprintf(type, sizeof(type), "%d", CT_UG_REQUEST_DETAIL);
3781 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, type);
3782 debug_log("service_add_extra_data: %d", ret);
3783 ret = service_add_extra_data(service, CT_UG_BUNDLE_ID, index);
3784 debug_log("service_add_extra_data: %d", ret);
3786 create_ug(UG_CONTACTS_DETAILS, service, ug_data);
3788 ret = service_destroy(service);
3789 debug_log("service_destroy: %d", ret);
3791 debug_log("set flag for contact ug");
3792 ug_data->b_contact_ug_launched = TRUE;
3795 static void _ctxpopup_send_email_cb(void *data, Evas_Object *obj, void *event_info)
3798 if (!data || !_g_ug_data) {
3799 debug_log("data is NULL");
3803 EmailViewerUGD *ug_data = _g_ug_data;
3805 if (ug_data->con_popup == NULL) {
3806 debug_log("con_popup is NULL");
3810 if (ug_data->con_popup) {
3811 evas_object_del(ug_data->con_popup);
3812 ug_data->con_popup = NULL;
3815 debug_log("email: %s", (char *)data);
3818 service_h service = NULL;
3820 ret = service_create(&service);
3821 debug_log("service_create: %d", ret);
3823 debug_log("service create failed");
3827 char rtype[10] = { 0, };
3828 snprintf(rtype, sizeof(rtype), "%d", RUN_COMPOSER_EXTERNAL);
3830 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
3831 debug_log("service_add_extra_data: %d", ret);
3832 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_TO, (char *)data);
3833 debug_log("service_add_extra_data: %d", ret);
3834 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CC, NULL);
3835 debug_log("service_add_extra_data: %d", ret);
3836 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_BCC, NULL);
3837 debug_log("service_add_extra_data: %d", ret);
3838 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_SUBJECT, NULL);
3839 debug_log("service_add_extra_data: %d", ret);
3840 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_BODY, NULL);
3841 debug_log("service_add_extra_data: %d", ret);
3842 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_ATTACHMENT, NULL);
3843 debug_log("service_add_extra_data: %d", ret);
3845 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
3847 ret = service_destroy(service);
3848 debug_log("service_destroy: %d", ret);
3851 static void _ctxpopup_add_contact_cb(void *data, Evas_Object *obj, void *event_info)
3854 if (!data || !_g_ug_data) {
3855 debug_log("data is NULL");
3859 char tmp[MAX_STR_LEN] = { 0, };
3860 EmailViewerUGD *ug_data = _g_ug_data;
3862 if (ug_data->con_popup == NULL) {
3863 debug_log("con_popup is NULL");
3867 if (ug_data->con_popup) {
3868 evas_object_del(ug_data->con_popup);
3869 ug_data->con_popup = NULL;
3873 service_h service = NULL;
3875 ret = service_create(&service);
3876 debug_log("service_create: %d", ret);
3878 debug_log("service create failed");
3882 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_PHONE_NUMBER) {
3883 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_NUM);
3884 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3885 debug_log("service_add_extra_data: %d", ret);
3886 ret = service_add_extra_data(service, CT_UG_BUNDLE_NUM, (char *)data);
3887 debug_log("service_add_extra_data: %d", ret);
3889 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_EMAIL) {
3890 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_EMAIL);
3891 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3892 debug_log("service_add_extra_data: %d", ret);
3893 ret = service_add_extra_data(service, CT_UG_BUNDLE_EMAIL, (char *)data);
3894 debug_log("service_add_extra_data: %d", ret);
3896 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_URL) {
3897 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_WEB);
3898 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3899 debug_log("service_add_extra_data: %d", ret);
3900 ret = service_add_extra_data(service, CT_UG_BUNDLE_WEB, (char *)data);
3901 debug_log("service_add_extra_data: %d", ret);
3904 create_ug(UG_CONTACTS_DETAILS, service, ug_data);
3906 ret = service_destroy(service);
3907 debug_log("service_destroy: %d", ret);
3910 static void _ctxpopup_cutlink_update_contact_cb(void *data, Evas_Object *obj, void *event_info)
3913 if (!data || !_g_ug_data) {
3914 debug_log("data is NULL");
3918 char tmp[MAX_STR_LEN] = { 0, };
3919 EmailViewerUGD *ug_data = _g_ug_data;
3921 if (ug_data->con_popup == NULL) {
3922 debug_log("con_popup is NULL");
3926 if (ug_data->con_popup) {
3927 evas_object_del(ug_data->con_popup);
3928 ug_data->con_popup = NULL;
3932 service_h service = NULL;
3934 ret = service_create(&service);
3935 debug_log("service_create: %d", ret);
3937 debug_log("service create failed");
3941 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_PHONE_NUMBER) {
3942 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_NUM);
3943 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3944 debug_log("service_add_extra_data: %d", ret);
3945 ret = service_add_extra_data(service, CT_UG_BUNDLE_NUM, (char *)data);
3946 debug_log("service_add_extra_data: %d", ret);
3948 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_EMAIL) {
3949 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_EMAIL);
3950 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3951 debug_log("service_add_extra_data: %d", ret);
3952 ret = service_add_extra_data(service, CT_UG_BUNDLE_EMAIL, (char *)data);
3953 debug_log("service_add_extra_data: %d", ret);
3955 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_URL) {
3956 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_WEB);
3957 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3958 debug_log("service_add_extra_data: %d", ret);
3959 ret = service_add_extra_data(service, CT_UG_BUNDLE_WEB, (char *)data);
3960 debug_log("service_add_extra_data: %d", ret);
3963 ug_data->ug_contacts_search = create_ug(UG_CONTACTS_LIST, service, ug_data);
3965 ret = service_destroy(service);
3966 debug_log("service_destroy: %d", ret);
3969 static void _ctxpopup_select_contact_mode_email_cb(void *data, Evas_Object *obj, void *event_info)
3972 if (!data || !_g_ug_data) {
3973 debug_log("data is NULL");
3977 EmailViewerUGD *ug_data = _g_ug_data;
3980 if (ug_data->con_popup) {
3981 evas_object_del(ug_data->con_popup);
3982 ug_data->con_popup = NULL;
3985 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
3986 if (ug_data->con_popup == NULL) {
3987 debug_log("cannot create context popup");
3991 ug_data->create_contact_arg = CONTACTUI_REQ_ADD_EMAIL;
3992 ug_data->update_contact_type = CONTACTUI_REQ_ADD_EMAIL;
3994 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_OPT_CREATE_CONTACT"), NULL, _ctxpopup_add_contact_cb, data);
3995 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_UPDATE_EXISTING"), NULL, _ctxpopup_cutlink_update_contact_cb, data);
3997 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
3998 evas_object_move(ug_data->con_popup, x, y);
3999 evas_object_show(ug_data->con_popup);
4002 static void _ctxpopup_add_block_rule_cb(void *data, Evas_Object *obj, void *event_info)
4006 if (!data || !_g_ug_data) {
4007 debug_log("data is NULL");
4011 EmailViewerUGD *ug_data = _g_ug_data;
4012 EmailViewerPrivate *priv = ug_data->email_data;
4013 char *addr = (char *)data;
4015 debug_log("Block address: %s", addr);
4017 if (ug_data->con_popup) {
4018 evas_object_del(ug_data->con_popup);
4019 ug_data->con_popup = NULL;
4023 email_rule_t *rule = NULL;
4025 /* add filtering rule */
4026 rule = malloc(sizeof(email_rule_t));
4027 rule->account_id = priv->account_id;
4028 rule->type = EMAIL_FILTER_FROM;
4029 rule->value = g_strdup(addr);
4030 rule->faction = EMAIL_FILTER_BLOCK;
4033 email_mailbox_t *mail_box = NULL;
4034 if ((err = email_get_mailbox_by_mailbox_type(ug_data->account_id, ug_data->mailbox_type, &mail_box)) != EMAIL_ERROR_NONE) {
4035 debug_log("email_get_mailbox_by_mailbox_type failed! - err (%d)", err);
4038 if (mail_box == NULL) {
4039 debug_log("mail_box is NULL");
4042 rule->target_mailbox_id = mail_box->mailbox_id;
4045 debug_log("email_free_mailbox is called");
4046 email_free_mailbox(&mail_box, 1);
4051 rule->flag2 = RULE_TYPE_INCLUDES;
4053 ret = email_add_rule(rule);
4055 debug_log("email_add_rule failed %d", ret);
4056 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
4057 _("IDS_EMAIL_POP_FAILED_TO_ADD_BLOCK_RULE"), 0,
4058 NULL, NULL, NULL, NULL, _popup_response_cb);
4061 vconf_ret = vconf_set_int(EMAIL_VCONF_KEY_BLOCK_RULE_CHANGED, 1);
4062 if (vconf_ret == -1) {
4063 debug_log("fail to set vconf int(spam_rule_changed)");
4064 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
4065 _("IDS_EMAIL_POP_FAILED_TO_ADD_BLOCK_RULE"), 0,
4066 NULL, NULL, NULL, NULL, _popup_response_cb);
4068 char str[128] = { 0, };
4069 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_BLOCKED"));
4070 ret = status_message_post(str);
4072 debug_log("status_message_post failed: %d", ret);
4076 email_free_rule(&rule, 1);
4079 static void _popup_response_cb(void *data, Evas_Object *obj, void *event_info)
4083 debug_log("_g_ug_data is NULL");
4088 debug_log("data is NULL");
4092 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4094 if (ug_data->notify) {
4095 evas_object_del(ug_data->notify);
4096 ug_data->notify = NULL;
4100 static void _popup_response_delete_ok_cb(void *data, Evas_Object *obj, void *event_info)
4104 debug_log("_g_ug_data is NULL");
4109 debug_log("data is NULL");
4113 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4115 if (ug_data->notify) {
4116 evas_object_del(ug_data->notify);
4117 ug_data->notify = NULL;
4120 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH)
4121 _delete_email(ug_data);
4123 _move_email(ug_data, _find_folder_id_using_folder_type(ug_data, EMAIL_MAILBOX_TYPE_TRASH), TRUE);
4125 if (ug_data->isRotate == false && ug_data->b_internal) {
4126 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
4130 if (ug_data->b_internal) {
4131 _hide_view(ug_data);
4133 /* send next or previous mail request to mailbox. */
4135 service_h service = NULL;
4137 ret = service_create(&service);
4138 debug_log("service_create: %d", ret);
4140 debug_log("service create failed");
4144 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
4145 debug_log("service_add_extra_data: %d", ret);
4146 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "1");
4147 debug_log("service_add_extra_data: %d", ret);
4149 ug_send_message(_g_mailbox_ug, service);
4151 ret = service_destroy(service);
4152 debug_log("service_destroy: %d", ret);
4154 ug_destroy_me(ug_data->ug);
4157 static void _popup_response_to_destroy_cb(void *data, Evas_Object *obj, void *event_info)
4161 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4162 evas_object_del(obj);
4164 ug_data->b_direct_destroy = 1;
4165 ug_destroy_me(ug_data->ug);
4169 static void _webview_multi_up_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
4172 if (_g_ug_data == NULL)
4176 debug_log("data is NULL");
4180 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4182 ug_data->m_is_multi_touch = FALSE;
4184 if (ug_data->scroller_locked) {
4185 ug_data->scroller_locked = FALSE;
4186 debug_log("<<unlock scroller>>");
4187 debug_log("<<lock webview>>");
4191 static void _webview_multi_down_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
4194 if (_g_ug_data == NULL)
4198 debug_log("data is NULL");
4202 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4204 ug_data->m_is_multi_touch = TRUE;
4205 if (ug_data->scroller_locked == FALSE) {
4206 ug_data->scroller_locked = TRUE;
4207 debug_log("<<lock scroller>>");
4208 debug_log("<<unlock webview>>");
4212 static void _webview_policy_navigation_decide_cb(void *data, Evas_Object *obj, void *event_info)
4216 debug_log("data is NULL");
4220 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4221 Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info;
4222 Ewk_Policy_Navigation_Type pd_type = ewk_policy_decision_navigation_type_get(policy_decision);
4223 debug_log("Ewk_Policy_Navigation_Type:%d", pd_type);
4225 const char *uri = NULL;
4226 uri = ewk_view_uri_get(ug_data->webview);
4227 debug_log("ewk_view_uri_get(%s)", uri);
4229 if (ug_data->b_load_finished == EINA_TRUE) {
4230 ewk_policy_decision_ignore(policy_decision);
4232 debug_log("url:%s", ewk_policy_decision_url_get(policy_decision));
4233 debug_log("scheme:%s", ewk_policy_decision_scheme_get(policy_decision));
4234 debug_log("cookie:%s", ewk_policy_decision_cookie_get(policy_decision));
4235 debug_log("host:%s", ewk_policy_decision_host_get(policy_decision));
4236 debug_log("response_mime:%s", ewk_policy_decision_response_mime_get(policy_decision));
4238 char *url = (char *)ewk_policy_decision_url_get(policy_decision);
4240 if ((strncmp(url, "http://", 7) == 0) ||
4241 (strncmp(url, "https://", 8) == 0) ||
4242 (strncmp(url, "ftp://", 6) == 0) ||
4243 (strncmp(url, "mms://", 6) == 0) ||
4244 (strncmp(url, "file://", 7) == 0) ||
4245 (strncmp(url, "rtsp://", 7) == 0) ||
4246 (strncmp(url, "wap://", 6) == 0)) {
4248 service_h service = NULL;
4249 ret = service_create(&service);
4250 debug_log("service_create: %d", ret);
4252 debug_log("service create failed");
4255 ret = service_set_operation(service, SERVICE_OPERATION_VIEW);
4256 debug_log("service_set_operation: %d", ret);
4257 ret = service_set_uri(service, url);
4258 debug_log("service_set_uri: %d", ret);
4259 ret = service_send_launch_request(service, NULL, NULL);
4260 debug_log("service_send_launch_request: %d", ret);
4261 ret = service_destroy(service);
4262 debug_log("service_destroy: %d", ret);
4265 if (strncmp(url, "tel:", 4) == 0) {
4266 char refined_num[MAX_STR_LEN] = { 0, };
4269 while (url[i] != '\0') {
4270 if (url[i] >= '0' && url[i] <= '9')
4271 refined_num[j++] = url[i];
4275 char *number = refined_num;
4276 debug_log("number: %s", number);
4279 service_h service = NULL;
4280 char telnum[255] = { 0, };
4281 ret = service_create(&service);
4282 debug_log("service_create: %d", ret);
4284 debug_log("service create failed");
4287 ret = service_set_operation(service, SERVICE_OPERATION_CALL);
4288 debug_log("service_set_operation: %d", ret);
4289 snprintf(telnum, sizeof(telnum), "tel:%s", number); /* Number to make a call */
4290 ret = service_set_uri(service, telnum);
4291 debug_log("service_set_uri: %d", ret);
4292 ret = service_add_extra_data(service, "ctindex", "-1"); /* If you don't know ctindex, you don't have to add it. */
4293 debug_log("service_add_extra_data: %d", ret);
4294 ret = service_send_launch_request(service, NULL, NULL);
4295 debug_log("service_send_launch_request: %d", ret);
4296 ret = service_destroy(service);
4297 debug_log("service_destroy: %d", ret);
4300 if (strncmp(url, "mailto:", 7) == 0) {
4302 service_h service = NULL;
4303 ret = service_create(&service);
4304 debug_log("service_create: %d", ret);
4306 debug_log("service create failed");
4310 char rtype[10] = { 0, };
4311 snprintf(rtype, sizeof(rtype), "%d", RUN_COMPOSER_EXTERNAL);
4313 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
4314 debug_log("service_add_extra_data: %d", ret);
4315 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_TO, &url[7]);
4316 debug_log("service_add_extra_data: %d", ret);
4318 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
4320 ret = service_destroy(service);
4321 debug_log("service_destroy: %d", ret);
4324 if (ug_data->timeout_popup) {
4325 evas_object_del(ug_data->timeout_popup);
4326 ug_data->timeout_popup = NULL;
4328 _create_waiting_popup(ug_data, _("IDS_EMAIL_POP_LOADING_CONTENTS_ING"), "list_process");
4330 if (pd_type == EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED) {
4331 debug_log("Link click is ignored.");
4332 ewk_policy_decision_ignore(policy_decision);
4338 /* Double_Scroller */
4339 static void _outter_scroller_bottom_hit_cb(void *data, Evas_Object *obj, void *event_info)
4343 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4344 int res = email_engine_check_body_download(ug_data->email_data->mail_id);
4346 if (ug_data->is_main_scroller_scrolling && res != 0) {
4347 debug_log("Main scroller hold push");
4348 elm_object_scroll_freeze_push(ug_data->scroller); //stop
4349 ewk_view_vertical_panning_hold_set(ug_data->webview, EINA_FALSE); //restart
4350 ug_data->is_main_scroller_scrolling = EINA_FALSE;
4351 ug_data->is_webview_scrolling = EINA_TRUE;
4355 static void _outter_scroller_top_hit_cb(void *data, Evas_Object *obj, void *event_info)
4360 static void _outter_scroller_scroll_cb(void *data, Evas_Object *obj, void *event_info)
4363 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4365 ug_data->is_main_scroller_scrolling = EINA_TRUE;
4368 static void _mbe_focused_cb(void *data, Evas_Object *obj, void *event_info)
4371 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(obj);
4372 elm_multibuttonentry_item_selected_set(item, EINA_FALSE);
4375 static void _mbe_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
4380 static void _mbe_added_cb(void *data, Evas_Object *obj, void *event_info)
4385 static void _mbe_selected_cb(void *data, Evas_Object *obj, void *event_info)
4388 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4389 email_address_info_t *addrs_info = NULL;
4390 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
4391 debug_log("selected item:%s", elm_object_item_text_get(item));
4393 addrs_info = elm_object_item_data_get(item);
4396 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
4397 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, addrs_info->address);
4399 if (ug_data->con_popup != NULL) {
4400 evas_object_del(ug_data->con_popup);
4401 ug_data->con_popup = NULL;
4404 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
4405 if (ug_data->con_popup == NULL) {
4406 debug_log("cannot create context popup");
4410 if (contact_list_item) {
4411 debug_log("Contact Item Exist: index[%d]", contact_list_item->index);
4412 char index[10] = { 0, };
4413 snprintf(index, sizeof(index), "%d", contact_list_item->index);
4415 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_VIEW_CONTACT"), NULL, _ctxpopup_detail_contact_cb, g_strdup(index));
4416 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SEND_EMAIL"), NULL, _ctxpopup_send_email_cb, addrs_info->address);
4417 ug_data->ctx_block_item = elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_BLOCK"), NULL, _ctxpopup_add_block_rule_cb, addrs_info->address);
4418 _delete_contacts_list(contact_list_item);
4420 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_OPT_ADD_TO_CONTACTS"), NULL, _ctxpopup_select_contact_mode_email_cb, addrs_info->address);
4421 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SEND_EMAIL"), NULL, _ctxpopup_send_email_cb, addrs_info->address);
4422 ug_data->ctx_block_item = elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_BLOCK"), NULL, _ctxpopup_add_block_rule_cb, addrs_info->address);
4426 email_rule_t *rule_list = NULL;
4428 /* get the rule list from service */
4429 if (email_get_rule_list(&rule_list, &count) < 0) {
4430 debug_log("email_get_rule_list failed");
4433 for (i = 0; i < count; i++) {
4434 if (rule_list[i].type == EMAIL_FILTER_FROM/*TYPE_BLOCK_ADDRESS*/) {
4435 debug_log("block address %s", rule_list[i].value);
4437 if (g_strcmp0(rule_list[i].value, addrs_info->address) == 0) {
4438 debug_log("[%s] already blocked", rule_list[i].value);
4439 if (ug_data->ctx_block_item)
4440 elm_object_item_disabled_set(ug_data->ctx_block_item, EINA_TRUE);
4445 /* free email rule_list */
4446 email_free_rule(&rule_list, count);
4449 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
4450 debug_log("canvas x:%d, y:%d", x, y);
4451 evas_object_move(ug_data->con_popup, x, y);
4452 evas_object_show(ug_data->con_popup);
4455 static void _destroy_down_progress_cb(void *data, Evas_Object *obj, void *event_info)
4460 debug_log("data is NULL");
4464 EmailViewerUGD *ug_data = _g_ug_data;
4465 EmailViewerPrivate *priv = ug_data->email_data;
4467 email_engine_stop_working(ug_data->account_id, priv->email_handle);
4469 if (ug_data->pb_notify) {
4470 evas_object_del(ug_data->pb_notify);
4471 ug_data->pb_notify = NULL;
4474 if (ug_data->pb_notify_lb) {
4475 evas_object_del(ug_data->pb_notify_lb);
4476 ug_data->pb_notify_lb = NULL;
4480 if (priv->att_file_id) {
4481 free(priv->att_file_id);
4482 priv->att_file_id = NULL;
4485 priv->file_size = 0;
4486 priv->attachment_id = -1;
4487 priv->multi_body = FALSE;
4491 static void _init_viewer_data(int account_id, int mail_id, char *srv_mail_id, EmailViewerUGD *ug_data)
4494 EmailViewerPrivate *priv = NULL;
4495 EmailViewerProp *prop = NULL;
4496 email_address_info_list_t *addrs_info_list = NULL;
4498 /* Create Email Viewer Private Structure */
4499 if (ug_data->email_data) {
4500 if (ug_data->email_data->mail_info) {
4501 debug_log("mail_info freed");
4502 email_free_mail_data(&(ug_data->email_data->mail_info), 1);
4503 ug_data->email_data->mail_info = NULL;
4506 if (ug_data->email_data->attachment_info && ug_data->email_data->attachment_count > 0) {
4507 debug_log("attachment_info freed p[%p] n[%d]", ug_data->email_data->attachment_info, ug_data->email_data->attachment_count);
4508 email_free_attachment_data(&(ug_data->email_data->attachment_info), ug_data->email_data->attachment_count);
4509 ug_data->email_data->attachment_info = NULL;
4510 ug_data->email_data->attachment_count = 0;
4513 memset(ug_data->email_data, 0x0, sizeof(EmailViewerPrivate));
4514 priv = ug_data->email_data;
4516 priv = (EmailViewerPrivate *)malloc(sizeof(EmailViewerPrivate));
4517 memset(priv, 0x0, sizeof(EmailViewerPrivate));
4518 ug_data->email_data = priv;
4521 /* Create Email Viewer Property Structure */
4522 if (ug_data->property) {
4523 if (ug_data->property->attachments) {
4525 LIST_ITER_START(i, ug_data->property->attachments) {
4526 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, ug_data->property->attachments);
4533 g_list_free(ug_data->property->attachments);
4535 memset(ug_data->property, 0x0, sizeof(EmailViewerProp));
4536 prop = ug_data->property;
4538 prop = (EmailViewerProp *)malloc(sizeof(EmailViewerProp));
4539 memset(prop, 0x0, sizeof(EmailViewerProp));
4540 ug_data->property = prop;
4543 /* Set account ID */
4544 priv->account_id = account_id;
4545 prop->account_id = account_id;
4548 priv->mail_id = mail_id;
4549 prop->mail_id = mail_id;
4551 priv->mailbox_id = ug_data->mailbox_id;
4552 prop->src_box = ug_data->mailbox_name;
4553 debug_log("mailbox_name [%s]", ug_data->mailbox_name);
4555 /* Get mail_info from service, and fill property */
4556 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
4557 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
4560 email_get_address_info_list(priv->mail_id, &addrs_info_list);
4562 if (addrs_info_list) {
4563 ug_data->from_list = addrs_info_list->from;
4564 ug_data->to_list = addrs_info_list->to;
4565 ug_data->cc_list = addrs_info_list->cc;
4566 ug_data->bcc_list = addrs_info_list->bcc;
4567 priv->addrs_info_list = addrs_info_list;
4570 ug_data->option_header_opened = 0;
4573 static int _init_webview_data(EmailViewerUGD *ug_data)
4577 EmailViewerWebview *wvd;
4579 if (ug_data->webview_data == NULL) {
4580 wvd = (EmailViewerWebview *)malloc(sizeof(EmailViewerWebview));
4581 memset(wvd, 0x0, sizeof(EmailViewerWebview));
4582 ug_data->webview_data = wvd;
4585 if (STR_VALID(ug_data->property->charset)) {
4586 ug_data->webview_data->charset = g_strdup(ug_data->property->charset);
4587 debug_log("charset:%s", ug_data->webview_data->charset);
4589 ug_data->webview_data->charset = DEFAULT_CHARSET;
4590 debug_log("charset:%s", ug_data->webview_data->charset);
4596 static Eina_Bool _check_body_download(void *data)
4600 debug_log("data is NULL");
4601 return ECORE_CALLBACK_CANCEL;
4604 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4606 _create_tab_bar(ug_data);
4608 /* check mail body downloaded */
4609 int body_download_status = ug_data->property->body_download;
4611 if (body_download_status == 0) { //EMAIL_BODY_DOWNLOAD_STATUS_NONE
4612 debug_log("need body download");
4613 ug_data->b_noc = 1; /* Double_Scroller */
4615 if (ug_data->noc_bx) {
4616 debug_log("no content layout exist");
4617 evas_object_show(ug_data->noc_bx);
4618 elm_object_text_set(ug_data->dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_MESSAGE"));
4619 evas_object_show(ug_data->dn_btn);
4620 elm_box_pack_end(ug_data->main_bx, ug_data->noc_bx);
4622 /* add body download button */
4623 ug_data->noc_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.no_content");
4624 if (ug_data->noc_bx == NULL) {
4625 debug_log("Cannot load edj");
4626 return ECORE_CALLBACK_CANCEL;
4629 evas_object_size_hint_align_set(ug_data->noc_bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
4630 evas_object_size_hint_weight_set(ug_data->noc_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
4631 evas_object_show(ug_data->noc_bx);
4632 elm_box_pack_end(ug_data->main_bx, ug_data->noc_bx);
4634 Evas_Object *dn_btn = elm_button_add(ug_data->navi_bar);
4635 /*elm_object_theme_set(dn_btn, ug_data->theme);*/
4636 elm_object_style_set(dn_btn, "text_only/style2");
4637 elm_object_text_set(dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_MESSAGE"));
4638 evas_object_smart_callback_add(dn_btn, "clicked", _body_down_cb, (void *)ug_data);
4639 evas_object_show(dn_btn);
4640 ug_data->dn_btn = dn_btn;
4642 elm_object_part_content_set(ug_data->noc_bx, "btn", ug_data->dn_btn);
4643 debug_log("no content layout created");
4646 elm_object_focus_set(ug_data->noc_bx, EINA_TRUE);
4647 if (ug_data->timer) {
4648 ecore_timer_del(ug_data->timer);
4649 ug_data->timer = NULL;
4652 ug_data->timer = ecore_timer_add(0.0, viewer_send_message, ug_data);
4653 } else if (body_download_status == 1) { //EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED
4654 debug_log("check mail downloaded - ok");
4656 _create_body(ug_data);
4657 } else if (body_download_status == 2) { //EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED
4659 debug_log("Partial Body");
4660 ug_data->b_partial_body = 1;
4661 _create_body(ug_data);
4662 _create_partial_body_dn_btn(ug_data);
4665 return ECORE_CALLBACK_CANCEL;
4668 static int _update_attachment_info(EmailViewerUGD *ug_data, int index)
4671 EmailViewerProp *prop = ug_data->property;
4674 int attach_index = 0;
4676 /* update attachment information */
4677 LIST_ITER_START(i, prop->attachments) {
4678 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, prop->attachments);
4680 if (info && !info->inline_content) {
4681 debug_log("info->index[%d] index[%d]", info->index, index);
4683 if (info->index == index) {
4684 info->download_yn = TRUE;
4685 info->path = email_engine_get_attachment_path(info->attach_id);
4689 if (prop->real_att_len > 1) {
4690 Evas_Object *thumbnail = viewer_make_thumbnail(info->path, ug_data->attach_ex_bk[j]);
4691 Evas_Object *content = elm_object_part_content_unset(ug_data->attach_ex_bk[j], "elm.icon");
4692 evas_object_del(content);
4693 elm_object_part_content_set(ug_data->attach_ex_bk[j], "elm.icon", thumbnail);
4694 evas_object_show(thumbnail);
4696 Evas_Object *thumbnail = viewer_make_thumbnail(info->path, ug_data->attach_hd_bk);
4697 Evas_Object *content = elm_object_part_content_unset(ug_data->attach_hd_bk, "elm.icon");
4698 evas_object_del(content);
4699 elm_object_part_content_set(ug_data->attach_hd_bk, "elm.icon", thumbnail);
4700 evas_object_show(thumbnail);
4710 debug_log("return id[%d]", attach_index);
4712 return attach_index;
4715 static int _get_attachment_info_index(EmailViewerUGD *ug_data, int index)
4719 EmailViewerProp *prop = ug_data->property;
4721 int attach_index = 0;
4723 /* update attachment information */
4724 LIST_ITER_START(i, prop->attachments) {
4725 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, prop->attachments);
4727 debug_log("info->index[%d] index[%d]", info->index, index);
4728 if (info->index == index) {
4735 debug_log("return id[%d]", attach_index);
4737 return attach_index;
4740 static void _show_select_info(EmailViewerUGD *ug_data, char *str)
4744 if (ug_data->select_info != NULL) {
4745 evas_object_del(ug_data->select_info);
4746 ug_data->select_info = NULL;
4749 if (ug_data->selectioninfo_layout != NULL) {
4750 evas_object_del(ug_data->selectioninfo_layout);
4751 ug_data->selectioninfo_layout = NULL;
4754 ug_data->select_info = elm_notify_add(ug_data->win_main);
4755 elm_notify_orient_set(ug_data->select_info, ELM_NOTIFY_ORIENT_BOTTOM);
4757 ug_data->selectioninfo_layout = elm_layout_add(ug_data->layout_main);
4758 elm_object_content_set(ug_data->select_info, ug_data->selectioninfo_layout);
4760 elm_layout_theme_set(ug_data->selectioninfo_layout, "standard", "selectioninfo", "vertical/bottom_64");
4762 edje_object_part_text_set(_EDJ(ug_data->selectioninfo_layout), "elm.text", str);
4763 elm_notify_timeout_set(ug_data->select_info, 3);
4764 evas_object_show(ug_data->select_info);
4767 static void _save_attachment(EmailViewerUGD *ug_data, int index)
4770 EmailViewerPrivate *priv = ug_data->email_data;
4771 EmailViewerProp *prop = ug_data->property;
4772 char newpath[MAX_STR_LEN] = { 0, };
4774 RETURN_IF_FAIL(prop->attachments != NULL);
4775 EmailAttachmentType *info = g_list_nth_data(prop->attachments, index);
4778 debug_log("EmailAttachmentType *info is NULL");
4782 if (!info->download_yn) {
4784 gboolean res = FALSE;
4786 if (ug_data->progress_bar[index + 1] != NULL) {
4787 debug_log("Already getting downloaded...!");
4788 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4789 _("IDS_EMAIL_POP_ALREADY_DOWNLOADING_T_HEADER"), 1,
4790 dgettext("sys_string", "IDS_COM_SK_OK"),
4791 _popup_response_cb, NULL, NULL, NULL);
4795 debug_log("Need attachment download");
4796 /* download attachment */
4797 priv->b_att_save = TRUE;
4799 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4802 priv->download_all_cnt++;
4803 debug_log("Assigning Handle[%d] Index[%d] download_all_cnt[%d]", handle, index, priv->download_all_cnt);
4804 priv->download_all_email_handle[index] = handle;
4805 _create_down_progress_ex(index, EMAIL_VIEWER_PROGRESSBAR_ATT);
4806 ug_data->display_download_result = TRUE;
4808 priv->b_att_save = FALSE;
4809 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4810 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
4811 dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
4818 if (info && STR_VALID(info->path)) {
4820 debug_log("path[%s]", info->path);
4821 ret = email_attachments_save_file(info->path, newpath, NULL);
4822 if (ret == EMAIL_EXT_SAVE_ERR_NONE) {
4823 char str[128] = { 0, };
4824 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
4825 ret = status_message_post(str);
4827 debug_log("status_message_post failed: %d", ret);
4832 static void _show_attachment(EmailViewerUGD *ug_data, int index)
4835 EmailViewerPrivate *priv = ug_data->email_data;
4836 EmailViewerProp *prop = ug_data->property;
4837 EmailAttachmentType *info = g_list_nth_data(prop->attachments, index);
4838 char newpath[MAX_STR_LEN] = { 0, };
4841 debug_log("EmailAttachmentType *info is NULL");
4845 debug_log("attach_id:%d, index:%d, name(%s), path(%s), size:%d, download_yn:%d, drm:%d, inline_content:%d",
4846 info->attach_id, info->index, info->name, info->path, (gint) info->size, info->download_yn, info->drm, info->inline_content);
4848 if (!info->download_yn) {
4850 gboolean res = FALSE;
4851 debug_log("Need attachment download");
4853 priv->b_att_open = TRUE;
4855 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4858 priv->download_all_email_handle[index] = handle;
4859 priv->download_all_cnt++;
4860 _create_down_progress_ex(index, EMAIL_VIEWER_PROGRESSBAR_ATT);
4862 priv->b_att_open = FALSE;
4863 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4864 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
4865 dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
4871 gboolean res = FALSE;
4872 res = email_attachments_save_file(info->path, newpath, NULL);
4873 debug_log("Result:%d, Saved Path:%s", res, newpath);
4875 if (res == EMAIL_EXT_SAVE_ERR_NONE) {
4876 char str[128] = { 0, };
4877 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
4878 int ret = status_message_post(str);
4880 debug_log("status_message_post failed: %d", ret);
4882 if (g_str_has_suffix(info->path, ".vcs")) {
4884 int calendar_id = 1;
4885 calendar_svc_connect();
4886 nResult = calendar_svc_calendar_import(newpath, calendar_id);
4888 debug_log("check return value of calendar_svc_util_register_vcs_file for %s - %d", newpath, nResult);
4889 if (nResult != CAL_SUCCESS) {
4890 debug_log("Failed to import path(%s) to id(%d)", newpath, calendar_id);
4893 calendar_svc_close();
4895 media_file_register(newpath);
4896 } else if (res == EMAIL_EXT_SAVE_ERR_ALREADY_EXIST && !ug_data->display_download_result) {
4897 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
4898 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0,
4899 NULL, NULL, NULL, NULL, _popup_response_cb);
4902 debug_log("display_download_result:%d", ug_data->display_download_result);
4903 if (ug_data->display_download_result) {
4904 if (res == EMAIL_EXT_SAVE_ERR_NONE || res == EMAIL_EXT_SAVE_ERR_ALREADY_EXIST) {
4906 service_h service = NULL;
4907 ret = service_create(&service);
4908 debug_log("service_create: %d", ret);
4910 debug_log("service create failed");
4913 ret = service_set_operation(service, SERVICE_OPERATION_VIEW);
4914 debug_log("service_set_operation: %d", ret);
4915 ret = service_set_uri(service, newpath);
4916 debug_log("service_set_uri: %d", ret);
4917 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_VIDEO_PLAYER_LAUNCH_APP, "email");
4918 debug_log("service_add_extra_data: %d", ret);
4919 ret = service_send_launch_request(service, NULL, NULL);
4920 debug_log("service_send_launch_request: %d", ret);
4921 if (ret != SERVICE_ERROR_NONE) {
4922 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4923 _("IDS_EMAIL_POP_THIS_ATTACHMENT_CANNOT_BE_DISPLAYED"), 0,
4924 NULL, NULL, NULL, NULL, _popup_response_cb);
4926 ret = service_destroy(service);
4927 debug_log("service_destroy: %d", ret);
4929 debug_log("EMAIL_EXT_SAVE_ERR_UNKNOWN");
4934 static void _save_attachment_all(EmailViewerUGD *ug_data)
4937 EmailViewerPrivate *priv = ug_data->email_data;
4938 EmailViewerProp *prop = ug_data->property;
4939 EmailAttachmentType *info = NULL;
4942 int att_len = g_list_length(prop->attachments);
4944 if (priv->b_all_att_save)
4948 if (ug_data->forward_ctr_it)
4949 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_TRUE);
4952 for (i = 0; i < att_len; i++) {
4953 info = g_list_nth_data(prop->attachments, i);
4955 if (info && !info->inline_content) {
4956 if (!info->download_yn) {
4957 if (ug_data->progress_bar_ly[i + 1] == NULL) {
4959 gboolean res = FALSE;
4960 debug_log("Need attachment [%d] download", i);
4962 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4965 priv->download_all_cnt++;
4966 priv->download_all_email_handle[i] = handle;
4967 priv->b_all_att_save = TRUE;
4969 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
4970 if (priv->b_all_att_save) {
4971 if (ug_data->attach_onoff_flag == 0) {
4972 _attachment_item_collapse_cb(ug_data->attach_hd_bk, NULL, NULL, NULL);
4976 _create_down_progress_ex(i, EMAIL_VIEWER_PROGRESSBAR_ATT);
4977 ug_data->display_download_result = TRUE;
4979 priv->download_all_fail_cnt++;
4986 debug_log("download [%d], failed [%d]", priv->download_all_cnt, priv->download_all_fail_cnt);
4989 static void _dbus_receiver_setup(EmailViewerUGD *ug_data)
4993 int ret = e_dbus_init();
4994 debug_log("ret: %d", ret);
4998 if (_g_viewer_dbus_conn == NULL) {
5000 dbus_error_init(&derror);
5001 _g_viewer_dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
5003 if (_g_viewer_dbus_conn == NULL) {
5004 debug_log("e_dbus_bus_get return NULL");
5008 if (e_dbus_request_name(_g_viewer_dbus_conn, "User.Email.StorageChange", 0, NULL, NULL) == NULL) {
5009 debug_critical("Failed to e_dbus_request_name()");
5013 if (_g_viewer_signal_handler_storage != NULL) {
5014 debug_log("_g_viewer_signal_handler_storage != NULL");
5017 _g_viewer_signal_handler_storage = e_dbus_signal_handler_add(_g_viewer_dbus_conn, NULL,
5018 "/User/Email/StorageChange",
5019 "User.Email.StorageChange",
5020 "email", _on_edbus_event_email_viewer_receive, ug_data);
5022 if (_g_viewer_signal_handler_storage == NULL) {
5023 debug_log("Failed to e_dbus_signal_handler_add()");
5028 if (e_dbus_request_name(_g_viewer_dbus_conn, "User.Email.NetworkStatus", 0, NULL, NULL) == NULL) {
5029 debug_log("Failed to e_dbus_request_name()");
5033 if (_g_viewer_signal_handler_network != NULL) {
5034 debug_log("_g_viewer_signal_handler_network != NULL");
5037 _g_viewer_signal_handler_network = e_dbus_signal_handler_add(_g_viewer_dbus_conn, NULL,
5038 "/User/Email/NetworkStatus",
5039 "User.Email.NetworkStatus",
5040 "email", _on_edbus_event_email_viewer_receive, ug_data);
5042 if (_g_viewer_signal_handler_network == NULL) {
5043 debug_log("Failed to e_dbus_signal_handler_add()");
5049 static void _dbus_receiver_remove(EmailViewerUGD *ug_data)
5053 if (_g_viewer_signal_handler_storage != NULL) {
5054 e_dbus_signal_handler_del(_g_viewer_dbus_conn, _g_viewer_signal_handler_storage);
5055 _g_viewer_signal_handler_storage = NULL;
5058 if (_g_viewer_signal_handler_network != NULL) {
5059 e_dbus_signal_handler_del(_g_viewer_dbus_conn, _g_viewer_signal_handler_network);
5060 _g_viewer_signal_handler_network = NULL;
5063 if (e_dbus_release_name(_g_viewer_dbus_conn, "User.Email.StorageChange", NULL, NULL) == NULL) {
5064 debug_critical("e_dbus_release_name to failed");
5067 if (e_dbus_release_name(_g_viewer_dbus_conn, "User.Email.NetworkStatus", NULL, NULL) == NULL) {
5068 debug_critical("e_dbus_release_name to failed");
5071 if (_g_viewer_dbus_conn != NULL) {
5072 /*e_dbus_connection_close(_g_viewer_dbus_conn);*/
5073 _g_viewer_dbus_conn = NULL;
5077 static void _on_edbus_event_email_viewer_receive(void *data, DBusMessage *message)
5082 debug_log("data is NULL");
5086 EmailViewerUGD *ug_data = _g_ug_data;
5087 EmailViewerPrivate *priv = ug_data->email_data;
5088 char fail_msg[MAX_STR_LEN] = { 0, };
5091 if (dbus_message_is_signal(message, "User.Email.StorageChange", "email")) {
5092 debug_log("User.Email.StorageChange");
5099 dbus_error_init(&error);
5100 if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &subtype,
5101 DBUS_TYPE_INT32, &data1, DBUS_TYPE_INT32, &data2,
5102 DBUS_TYPE_STRING, &data3, DBUS_TYPE_INVALID)) {
5103 debug_log("STORE_ENABLE: subtype: %d, data1: %d, data2: %d, data3: %s", subtype, data1, data2, data3);
5106 case NOTI_ACCOUNT_ADD:
5107 if (get_app_paused()) {
5108 debug_log("account added during pause status");
5110 if (ug_data->isRotate == false && ug_data->b_internal) {
5111 /* Viewer to hide, so set left content (mailbox) size to full */
5112 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
5115 if (ug_data->b_internal != 1) {
5116 debug_log("ug_destory_me");
5117 ug_destroy_me(ug_data->ug);
5119 _hide_view(ug_data);
5124 case NOTI_ACCOUNT_DELETE:
5125 if (get_app_paused()) {
5126 debug_log("account deleted during pause status");
5129 if (ug_data->isRotate == false && ug_data->b_internal) {
5130 /* Viewer to hide, so set left content (mailbox) size to full */
5131 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
5134 if (email_engine_get_default_account(&account_id)) {
5135 if (ug_data->b_internal != 1) {
5136 debug_log("ug_destory_me");
5137 ug_destroy_me(ug_data->ug);
5139 _hide_view(ug_data);
5145 case NOTI_ACCOUNT_UPDATE:
5146 if (get_app_paused()) {
5147 debug_log("account updated during pause status");
5152 debug_warning("unknown type");
5156 debug_critical("receive data error: %s", error.message);
5157 dbus_error_free(&error);
5159 } else if (dbus_message_is_signal(message, "User.Email.NetworkStatus", "email")) {
5168 dbus_error_init(&error);
5170 if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &subtype,
5171 DBUS_TYPE_INT32, &data1, DBUS_TYPE_STRING, &data2,
5172 DBUS_TYPE_INT32, &data3, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID)) {
5173 debug_log("subtype: %d, data1: %d, data2: %s, data3: %d, data4: %d", subtype, data1, data2, data3, data4);
5176 case NOTI_DOWNLOAD_BODY_START:
5177 /* DATA1[mail_id] DATA2[file_id] DATA3[body_size] DATA4[received size] */
5178 debug_log("receive noti, DOWNLOAD_BODY");
5179 if (priv->mail_id == data1) {
5180 priv->file_id = g_strdup(data2);
5181 priv->file_size = data3;
5184 _set_value_down_progress(0.0);
5186 double per = (double)data4 / (double)data3;
5187 _set_value_down_progress(per);
5190 debug_log("mail_id is different");
5191 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5195 case NOTI_DOWNLOAD_MULTIPART_BODY:
5196 /* DATA1[mail_id] DATA2[file_id] DATA3[body_size] DATA4[received size] */
5197 debug_log("receive noti, DOWNLOAD_MULTIPART_BODY");
5198 if (priv->mail_id == data1) {
5199 priv->file_id = g_strdup(data2);
5200 priv->file_size = data3;
5201 priv->multi_body = TRUE;
5204 _set_value_down_progress(0.0);
5206 double per = (double)data4 / (double)data3;
5207 _set_value_down_progress(per);
5210 debug_log("mail_id is different");
5211 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5215 case NOTI_DOWNLOAD_BODY_FINISH:
5216 /* DATA1[mail_id] DATA2[NULL] DATA3[handle_id] */
5217 debug_log("receive noti, DOWNLOAD_BODY_FINISH");
5218 if (priv->email_handle == data3 && priv->mail_id == data1) {
5219 priv->email_handle = 0;
5221 ug_data->b_load_finished = EINA_FALSE;
5223 /* delete progress */
5224 if (ug_data->pb_notify) {
5225 _set_value_down_progress(1.0);
5226 _destroy_down_progress_cb(NULL, NULL, NULL);
5229 char str[128] = { 0, };
5230 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_BODY_DOWNLOADED"));
5231 int ret = status_message_post(str);
5233 debug_log("status_message_post failed: %d", ret);
5236 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
5237 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
5239 /* create att and body */
5240 if (ug_data->b_partial_body) {
5245 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
5246 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
5248 elm_box_unpack(ug_data->main_bx, ug_data->partial_dn_btn_bx);
5249 if (ug_data->partial_dn_btn) {
5250 evas_object_del(ug_data->partial_dn_btn);
5251 ug_data->partial_dn_btn = NULL;
5253 if (ug_data->partial_dn_btn_bx) {
5254 evas_object_del(ug_data->partial_dn_btn_bx);
5255 ug_data->partial_dn_btn_bx = NULL;
5258 if (ug_data->property->has_html) {
5259 ug_data->webview_data->body_type = BODY_TYPE_HTML;
5260 ug_data->webview_data->uri = ug_data->property->body_uri;
5262 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
5263 ug_data->webview_data->text_content = ug_data->property->body;
5266 viewer_set_webview_content(ug_data, 1);
5268 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
5269 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
5272 if (ug_data->property->has_attachment)
5273 ug_data->got_att = 1;
5275 ug_data->got_att = 0;
5277 /* pack attachment if it exist */
5278 if (ug_data->got_att) {
5279 _create_attach(ug_data);
5282 _create_body(ug_data);
5285 debug_log("email_handle or mail_id is different");
5286 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5287 debug_log("expected email_handle [%d], received email_handle [%d]", priv->email_handle, data3);
5291 case NOTI_DOWNLOAD_BODY_FAIL:
5292 /* DATA1[mail_id] DATA2[NULL] DATA3[handle_id] */
5293 debug_log("receive noti, DOWNLOAD_BODY_FAIL");
5294 if (priv->email_handle == data3 && priv->mail_id == data1) {
5295 priv->email_handle = 0;
5297 /* delete progress */
5298 if (ug_data->pb_notify) {
5299 _destroy_down_progress_cb(NULL, NULL, NULL);
5302 char *err_msg = _get_service_fail_type(data4);
5303 snprintf(fail_msg, sizeof(fail_msg), "%s<br>%s", _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), err_msg);
5304 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
5305 fail_msg, 1, dgettext("sys_string", "IDS_COM_SK_OK"),
5306 _popup_response_cb, NULL, NULL, NULL);
5309 debug_log("email_handle or mail_id is different");
5310 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5311 debug_log("expected email_handle [%d], received email_handle [%d]", priv->email_handle, data3);
5315 case NOTI_DOWNLOAD_ATTACH_START:
5316 /* DATA1[mail_id] DATA2[file_id] DATA3[attachment_id] DATA4[percentage] */
5317 debug_log("receive noti, DOWNLOAD_ATTACHMENT");
5318 if (priv->mail_id == data1) {
5319 priv->att_file_id = g_strdup(data2);
5320 priv->attachment_id = data3;
5323 /* Set the progressbar of particular attachment_id */
5324 _set_value_down_progress_by_index(0.0, priv->attachment_id);
5327 double per = (double)data4 / 100.0;
5328 /* Set the progressbar of particular attachment_id */
5329 _set_value_down_progress_by_index(per, priv->attachment_id);
5332 debug_log("mail_id is different");
5333 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5337 case NOTI_DOWNLOAD_ATTACH_FINISH:
5338 /* DATA1[mail_id] DATA2[NULL] DATA3[attachment_id] */
5339 debug_log("receive noti, DOWNLOAD_ATTACH_FINISH");
5341 if (priv->mail_id == data1) {
5342 int attach_index = 0;
5343 int attachment_id = (int)data3;
5344 debug_log("download_all_cnt [%d]", priv->download_all_cnt);
5346 if (priv->download_all_cnt > 0) {
5347 _set_value_down_progress_by_index(1.0, attachment_id);
5348 attach_index = _update_attachment_info(ug_data, attachment_id);
5349 if (priv->b_all_att_save) {
5350 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5351 _save_attachment(ug_data, attach_index);
5352 if (priv->download_all_cnt == 0) {
5353 priv->b_all_att_save = FALSE;
5356 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5357 _show_attachment(ug_data, attach_index);
5361 debug_log("mail_id or attachment_id is different");
5362 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5366 case NOTI_DOWNLOAD_ATTACH_FAIL:
5367 /* DATA1[mail_id] DATA2[NULL] DATA3[attachment_id] */
5368 debug_log("receive noti, DOWNLOAD_ATTACH_FAIL");
5369 if (priv->mail_id == data1) {
5370 int attach_index = _get_attachment_info_index(ug_data, data3);
5371 debug_log("download_all_cnt[%d]", priv->download_all_cnt);
5373 if (priv->download_all_cnt > 0) {
5374 if (ug_data->progress_bar[data3] != NULL && data4 != EMAIL_ERROR_CANCELLED)
5375 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5377 debug_log("Download already cancelled, No need to destroy again..!");
5379 if (data4 != EMAIL_ERROR_CANCELLED && ug_data->ug_composer == NULL) {
5380 char *err_msg = _get_service_fail_type(data4);
5381 snprintf(fail_msg, sizeof(fail_msg), "%s<br>%s", _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), err_msg);
5382 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"), fail_msg, 1,
5383 dgettext("sys_string", "IDS_COM_SK_OK"),
5384 _popup_response_cb, NULL, NULL, NULL);
5388 if (priv->b_all_att_save && priv->download_all_cnt == 0) {
5389 priv->b_all_att_save = FALSE;
5393 debug_log("mail_id is different");
5394 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5399 debug_log("unknown type");
5403 debug_log("receive data error: %s", error.message);
5404 dbus_error_free(&error);
5406 /*return DBUS_HANDLER_RESULT_HANDLED;*/
5409 /*return DBUS_HANDLER_RESULT_HANDLED;*/
5413 static void _delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item)
5417 if (contacts_list_item) {
5418 #ifndef _NEW_CT_SVC_API
5419 g_free(contacts_list_item->first_name);
5420 contacts_list_item->first_name = NULL;
5421 g_free(contacts_list_item->last_name);
5422 contacts_list_item->last_name = NULL;
5424 g_free(contacts_list_item->display);
5425 contacts_list_item->display = NULL;
5427 g_free(contacts_list_item->email_address);
5428 contacts_list_item->email_address = NULL;
5429 g_free(contacts_list_item);
5430 contacts_list_item = NULL;
5434 static void *_contact_search_by_email(EmailViewerUGD *ug_data, const char *search_word)
5437 if (!ug_data || !_g_ug_data) {
5438 debug_log("data is NULL");
5442 int ret = CTS_SUCCESS;
5443 CTSiter *iter = NULL;
5445 EMAIL_CONTACT_LIST_INFO_S *contacts_list_item = NULL;
5446 contacts_svc_connect();
5448 debug_log("search_word = %s", search_word);
5450 if (contacts_svc_get_list_with_str(CTS_LIST_EMAILINFOS_WITH_EMAIL, search_word, &iter) != CTS_SUCCESS) {
5454 ret = contacts_svc_iter_next(iter);
5456 if (CTS_SUCCESS == ret) {
5457 CTSvalue *row_info = NULL;
5459 row_info = contacts_svc_iter_get_info(iter);
5461 contacts_list_item = (EMAIL_CONTACT_LIST_INFO_S *)calloc(1, sizeof(EMAIL_CONTACT_LIST_INFO_S));
5463 int index = contacts_svc_value_get_int(row_info, CTS_LIST_EMAIL_CONTACT_ID_INT);
5465 contacts_list_item->index = index;
5466 #ifndef _NEW_CT_SVC_API
5467 contacts_list_item->first_name = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_FIRST_STR));
5468 contacts_list_item->last_name = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_LAST_STR));
5470 contacts_list_item->display = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR));
5472 contacts_list_item->email_address = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_ADDR_STR));
5474 #ifndef _NEW_CT_SVC_API
5475 char *first = contacts_list_item->first_name;
5476 char *last = contacts_list_item->last_name;
5477 char *display = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR));
5480 if (first != NULL && last != NULL) {
5481 if (CTS_ORDER_NAME_FIRSTLAST == contacts_svc_get_order(CTS_ORDER_OF_DISPLAY)) {
5482 display = g_strconcat(first, " ", last, NULL);
5484 display = g_strconcat(last, " ", first, NULL);
5486 } else if (first != NULL || last != NULL) {
5487 display = (first != NULL) ? g_strdup(first) : g_strdup(last);
5489 display = g_strdup(" ");
5493 snprintf(contacts_list_item->display_name, sizeof(contacts_list_item->display_name), "%s", display);
5496 snprintf(contacts_list_item->display_name, sizeof(contacts_list_item->display_name), "%s", contacts_list_item->display);
5501 contacts_svc_value_free(row_info);
5504 contacts_svc_iter_remove(iter);
5507 contacts_svc_disconnect();
5509 return contacts_list_item;
5512 static void _set_value_down_progress(double val)
5517 debug_log("data is NULL");
5520 char buf[30] = { 0, };
5521 EmailViewerUGD *ug_data = _g_ug_data;
5523 sprintf(buf, "%s: %d", dgettext("sys_string", "IDS_COM_POP_DOWNLOADING"), (int)val);
5525 if (ug_data->pb_notify_lb) {
5526 elm_progressbar_value_set(ug_data->pb_notify_lb, val);
5527 elm_object_text_set(ug_data->pb_notify_lb, buf);
5531 static void _set_value_down_progress_by_index(double val, int index)
5536 debug_log("data is NULL");
5540 EmailViewerUGD *ug_data = _g_ug_data;
5541 EmailViewerProp *prop = ug_data->property;
5544 debug_log("val(%f) is MINUS", val);
5548 if (index < 0 || index >= ATTACH_MAX) {
5549 debug_log("index(%d) is overflowed", index);
5554 debug_log("prop is NULL");
5558 if (prop->attachments == NULL) {
5559 debug_log("attachments is NULL");
5563 int per = val * 100;
5564 int attach_index = _get_attachment_info_index(ug_data, index);
5565 EmailAttachmentType *info = g_list_nth_data(prop->attachments, attach_index);
5568 debug_log("info is NULL");
5571 if (ug_data->progress_bar[index] == NULL) {
5572 debug_log("obj is NULL");
5576 char *pszTemp = NULL;
5577 pszTemp = (char *)elm_object_style_get(ug_data->progress_bar[index]);
5579 if (STR_INVALID(pszTemp))
5582 if (g_strcmp0(pszTemp, "pending_list") == 0) {
5583 debug_log("pending_list so return");
5587 elm_progressbar_value_set(ug_data->progress_bar[index], val);
5589 if (ug_data->progress_bar_ly[index] != NULL) {
5590 char buf[30] = { 0, };
5591 snprintf(buf, sizeof(buf), "%d%%", per);
5593 Evas_Object *downloading_label2;
5594 downloading_label2 = elm_label_add(ug_data->progress_bar_ly[index]);
5595 elm_object_part_content_set(ug_data->progress_bar_ly[index], "elm.text.2", downloading_label2);
5596 char *buf_tagged = g_strconcat("<font_size=26><align=left><color=#646464FF>", buf, "</align></font_size>", NULL);
5597 elm_object_text_set(downloading_label2, buf_tagged);
5602 static void _cancel_download_attachment(EmailViewerUGD *ug_data)
5606 gboolean is_cancel = FALSE;
5609 debug_log("data is NULL");
5613 EmailViewerPrivate *priv = ug_data->email_data;
5614 EmailViewerProp *prop = ug_data->property;
5616 if (priv && priv->download_all_cnt <= 0) {
5617 debug_log("No attachment download to be cancelled!");
5621 for (i = 0; i <= prop->att_len; i++) {
5622 if (ug_data->progress_bar_ly[i]) {
5623 Evas_Object *btn = elm_object_part_content_get(ug_data->progress_bar_ly[i], "elm.icon.1");
5624 debug_log("Cancel btn for downloading attachment: %p", btn);
5626 evas_object_smart_callback_call(btn, "clicked", NULL);
5632 if (is_cancel == TRUE && ug_data->ug_composer == NULL) {
5633 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"), _("IDS_EMAIL_POP_CANCELLING_ATTACHMENT_DOWNLOAD_ING"),
5634 1, dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
5639 static char *_get_service_fail_type(int type)
5644 char str[MAX_STR_LEN] = { 0, };
5647 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("IP full"));
5648 return g_strdup(str);
5649 } else if (type == -176) {
5650 ret = _("IDS_EMAIL_POP_NO_SERVICE");
5651 return g_strdup(ret);
5652 } else if (type == -181) {
5653 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("Transport Error"));
5654 return g_strdup(str);
5655 } else if (type == EMAIL_ERROR_NETWORK_TOO_BUSY) {
5656 ret = _("IDS_EMAIL_POP_NETWORK_BUSY");
5657 return g_strdup(ret);
5658 } else if (type == EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS) {
5659 snprintf(str, sizeof(str), _("IDS_EMAIL_POP_YOU_CAN_ONLY_LOG_IN_ONCE_EVERY_PD_MINUTES"), 15);
5660 return g_strdup(str);
5661 } else if (type == EMAIL_ERROR_CONNECTION_FAILURE) {
5662 ret = dgettext("sys_string", "IDS_COM_POP_CONNECTION_FAILED");
5663 return g_strdup(ret);
5664 } else if (type == EMAIL_ERROR_LOGIN_FAILURE) {
5665 ret = _("IDS_EMAIL_POP_LOG_IN_FAILED");
5666 return g_strdup(ret);
5667 } else if (type == EMAIL_ERROR_AUTHENTICATE) {
5668 ret = _("IDS_EMAIL_POP_AUTHENTICATION_FAILED");
5669 return g_strdup(ret);
5670 } else if (type == EMAIL_ERROR_CANCELLED) {
5671 ret = _("IDS_EMAIL_POP_DOWNLOAD_CANCELLED");
5672 return g_strdup(ret);
5673 } else if (type == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) {
5674 ret = _("IDS_EMAIL_POP_EMAIL_DELETED_FROM_SERVER");
5675 return g_strdup(ret);
5676 } else if (type == EMAIL_ERROR_NO_SUCH_HOST) {
5677 ret = _("IDS_EMAIL_POP_HOST_NOT_FOUND");
5678 return g_strdup(ret);
5679 } else if (type == EMAIL_ERROR_INVALID_SERVER) {
5680 ret = _("IDS_EMAIL_POP_SERVER_NOT_AVAILABLE");
5681 return g_strdup(ret);
5682 } else if (type == EMAIL_ERROR_MAIL_MEMORY_FULL) {
5683 ret = _("IDS_EMAIL_POP_DEVICE_STORAGE_FULL");
5684 return g_strdup(ret);
5685 } else if (type == EMAIL_ERROR_FAILED_BY_SECURITY_POLICY) {
5686 ret = _("IDS_EMAIL_POP_DOWNLOADING_ATTACHMENTS_ON_THE_MOBILE_DEVICE_IS_NOT_ALLOWED_BY_EXCHANGE_SERVER_POLICY");
5687 return g_strdup(ret);
5689 snprintf(str, sizeof(str), "%s (%d)", dgettext("sys_string", "IDS_COM_POP_INTERNAL_ERROR"), type);
5690 return g_strdup(str);
5694 static Evas_Object *_load_edj(Evas_Object *parent, const char *file, const char *group)
5700 eo = elm_layout_add(parent);
5702 r = elm_layout_file_set(eo, file, group);
5704 evas_object_del(eo);
5708 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5715 static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part)
5721 static void _gl_del(void *data, Evas_Object *obj)
5725 if (_g_ug_data == NULL) {
5726 debug_log("ug_data is NULL");
5730 EmailViewerUGD *ug_data = _g_ug_data;
5732 if (ug_data->move_mailbox_list) {
5733 email_free_mailbox(&ug_data->move_mailbox_list, ug_data->move_mailbox_count);
5734 ug_data->move_mailbox_list = NULL;
5735 ug_data->move_mailbox_count = 0;
5741 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part)
5744 email_mailbox_t *mailbox_list = NULL;
5745 mailbox_list = (email_mailbox_t *) data;
5747 if (g_strcmp0(part, "elm.text") == 0) {
5748 char buf[MAX_STR_LEN] = { 0, };
5749 if (mailbox_list && mailbox_list->alias) {
5750 snprintf(buf, sizeof(buf), "%s", mailbox_list->alias);
5751 return g_strdup(buf);
5758 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part)
5762 if (g_strcmp0(part, "elm.icon") == 0) {
5763 Evas_Object *icon = elm_icon_add(obj);
5764 elm_icon_file_set(icon, IMGDIR "/U01_icon_folder.png", NULL);
5765 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
5773 static void _move_here_cb(void *data, Evas_Object *obj, void *event_info)
5777 if (data == NULL || _g_ug_data == NULL) {
5778 debug_log("data is NULL");
5782 email_mailbox_t *mailbox_list = NULL;
5783 mailbox_list = (email_mailbox_t *) data;
5785 EmailViewerUGD *ug_data = _g_ug_data;
5786 int folder_id = mailbox_list->mailbox_id;
5788 _move_email(ug_data, folder_id, FALSE);
5790 ug_data->navi_move_it1 = NULL;
5791 elm_naviframe_item_pop_to(ug_data->navi_main_it);
5793 if (ug_data->isRotate == false && ug_data->b_internal) {
5794 /* Viewer to hide, so set left content (mailbox) size to full */
5795 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
5798 if (ug_data->b_internal) {
5799 _hide_view(ug_data);
5801 /* send next or previous mail request to mailbox. */
5803 service_h service = NULL;
5805 ret = service_create(&service);
5806 debug_log("service_create: %d", ret);
5808 debug_log("service create failed");
5812 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
5813 debug_log("service_add_extra_data: %d", ret);
5814 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "1");
5815 debug_log("service_add_extra_data: %d", ret);
5817 ug_send_message(_g_mailbox_ug, service);
5819 ret = service_destroy(service);
5820 debug_log("service_destroy: %d", ret);
5822 ug_destroy_me(ug_data->ug);
5826 static void _move_back_cb(void *data, Evas_Object *obj, void *event_info)
5830 if (data == NULL || _g_ug_data == NULL) {
5831 debug_log("data is NULL");
5835 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
5837 elm_naviframe_item_pop(ug_data->navi_bar);
5838 ug_data->navi_move_it1 = NULL;
5840 /*if (ug_data->b_internal)
5841 elm_layout_theme_set(ug_data->layout_main, "layout", "controlbar", "default");
5843 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "controlbar");*/