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 <app_service.h>
24 #include <calendar2.h>
25 #include <media-util-register.h>
26 #include <contacts-ug.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_waiting_response_cb(void *data, Evas_Object *obj, void *event_info);
126 static void _popup_response_cb(void *data, Evas_Object *obj, void *event_info);
127 static void _popup_response_delete_ok_cb(void *data, Evas_Object *obj, void *event_info);
128 static void _popup_response_to_destroy_cb(void *data, Evas_Object *obj, void *event_info);
130 static void _webview_multi_up_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
131 static void _webview_multi_down_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
132 static void _webview_policy_navigation_decide_cb(void *data, Evas_Object *obj, void *event_info);
134 static void _outter_scroller_bottom_hit_cb(void *data, Evas_Object *obj, void *event_info);
135 static void _outter_scroller_top_hit_cb(void *data, Evas_Object *obj, void *event_info);
136 static void _outter_scroller_scroll_cb(void *data, Evas_Object *obj, void *event_info);
138 static void _mbe_focused_cb(void *data, Evas_Object *obj, void *event_info);
139 static void _mbe_unfocused_cb(void *data, Evas_Object *obj, void *event_info);
140 static void _mbe_added_cb(void *data, Evas_Object *obj, void *event_info);
141 static void _mbe_selected_cb(void *data, Evas_Object *obj, void *event_info);
142 static void _destroy_down_progress_cb(void *data, Evas_Object *obj, void *event_info);
144 /* Logic Functions */
145 static void _init_viewer_data(int account_id, int mail_id, char *srv_mail_id, EmailViewerUGD *ug_data);
146 static int _init_webview_data(EmailViewerUGD *ug_data);
147 static Eina_Bool _check_body_download(void *data);
148 static int _update_attachment_info(EmailViewerUGD *ug_data, int index);
149 static int _get_attachment_info_index(EmailViewerUGD *ug_data, int index);
150 static void _show_select_info(EmailViewerUGD *ug_data, char *str);
151 static void _save_attachment(EmailViewerUGD *ug_data, int index);
152 static void _show_attachment(EmailViewerUGD *ug_data, int index);
153 static void _save_attachment_all(EmailViewerUGD *ug_data);
154 static void _dbus_receiver_setup(EmailViewerUGD *ug_data);
155 static void _dbus_receiver_remove(EmailViewerUGD *ug_data);
156 static void _on_edbus_event_email_viewer_receive(void *local_data, DBusMessage *message);
158 static void _delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item);
159 static void *_contact_search_by_email(EmailViewerUGD *ug_data, const char *search_word);
160 static void _set_value_down_progress(double val);
161 static void _set_value_down_progress_by_index(double val, int index);
162 static void _cancel_download_attachment(EmailViewerUGD *ug_data);
165 static char *_get_service_fail_type(int type);
166 static Evas_Object *_load_edj(Evas_Object *parent, const char *file, const char *group);
169 static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part);
170 static void _gl_del(void *data, Evas_Object *obj);
171 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part);
172 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part);
173 static void _move_here_cb(void *data, Evas_Object *obj, void *event_info);
174 static void _move_back_cb(void *data, Evas_Object *obj, void *event_info);
177 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
181 EmailViewerUGD *ug_data;
186 ug_data = calloc(1, sizeof(EmailViewerUGD));
190 _g_ug_data = ug_data;
193 ops->create = on_create;
194 ops->start = on_start;
195 ops->pause = on_pause;
196 ops->resume = on_resume;
197 ops->destroy = on_destroy;
198 ops->message = on_message;
199 ops->event = on_event;
200 ops->key_event = on_key_event;
202 ops->opt = UG_OPT_INDICATOR_ENABLE;
207 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
210 EmailViewerUGD *ug_data;
222 static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h data, void *priv)
225 EmailViewerUGD *ug_data;
226 char *account_id = NULL;
227 char *mail_id = NULL;
228 char *mailbox_id = NULL;
229 char *binternal = NULL;
230 char *landscape = NULL;
239 debug_log("account_id and mail_id are required by arguments");
240 ug_data->b_direct_destroy = 1;
241 ug_destroy_me(ug_data->ug);
246 /* email engine initialize */
247 if (email_engine_initialize() == FALSE) {
248 debug_log("Failed to initialize email engine");
249 ug_data->b_direct_destroy = 1;
250 ug_destroy_me(ug_data->ug);
255 /* Elm_Theme *theme = elm_theme_new();
256 elm_theme_ref_set(theme, NULL);
257 ug_data->theme = theme;
258 elm_theme_extension_add(ug_data->theme, EV_THEME_PATH);*/
261 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_ACCOUNT_ID, (char **)&account_id);
262 debug_log("service_get_extra_data: %d", ret);
263 debug_log("account_id:%s", account_id);
264 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_MAIL_ID, (char **)&mail_id);
265 debug_log("service_get_extra_data: %d", ret);
266 debug_log("mail_id:%s", mail_id);
267 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_MAILBOX, (char **)&mailbox_id);
268 debug_log("service_get_extra_data: %d", ret);
269 debug_log("mailbox:%s", mailbox_id);
270 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_INTERNAL, (char **)&binternal);
271 debug_log("service_get_extra_data: %d", ret);
272 debug_log("binternal:%s", binternal);
273 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_FIRST_LANDSCAPE, (char **)&landscape);
274 debug_log("service_get_extra_data: %d", ret);
275 debug_log("landscape:%s", landscape);
278 ug_data->isRotate = atoi(landscape);
279 debug_log("@@@@ Landscape = %d @@@@", ug_data->isRotate);
284 ug_data->account_id = atoi(account_id);
285 ug_data->folder_list = email_engine_get_ca_mailbox_list_using_glist(ug_data->account_id);
290 ug_data->mail_id = atoi(mail_id);
295 g_free(ug_data->mailbox_name);
296 ug_data->mailbox_name = NULL;
297 ug_data->mailbox_id = atoi(mailbox_id);
301 email_mail_data_t *mail_data = NULL;
302 if ((err = email_get_mail_data(ug_data->mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
303 debug_log("fail to get mail - err (%d)", err);
306 if (mail_data == NULL) {
307 debug_log("mail_data is NULL");
310 if (mail_data->server_mailbox_name)
311 ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name);
312 ug_data->mailbox_type = mail_data->mailbox_type;
313 debug_log("server_mailbox_name:%s", mail_data->server_mailbox_name);
314 debug_log("mailbox_name:%s", ug_data->mailbox_name);
315 debug_log("mailbox_type:%d", ug_data->mailbox_type);
318 debug_log("email_free_mail is called");
319 email_free_mail_data(&(mail_data), 1);
325 ug_data->b_internal = atoi(binternal);
326 if (ug_data->b_internal == 1)
327 debug_log("############Launched from email-mailbox###############");
331 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);
333 if (ug_data->account_id <= 0 || ug_data->mail_id <= 0 || ug_data->mailbox_id <= 0) {
334 debug_log("Required bundle parameters are missing!");
335 ug_data->timeout_popup = elm_popup_add(ug_get_window());
336 evas_object_size_hint_weight_set(ug_data->timeout_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
337 elm_popup_timeout_set(ug_data->timeout_popup, 2);
338 elm_object_text_set(ug_data->timeout_popup, _("IDS_EMAIL_POP_UNABLE_TO_OPEN_EMAIL_MESSAGE"));
339 elm_object_part_text_set(ug_data->timeout_popup, "title,text", _("IDS_EMAIL_POP_ALERT"));
340 evas_object_smart_callback_add(ug_data->timeout_popup, "block,clicked", _popup_response_to_destroy_cb, ug_data);
341 evas_object_smart_callback_add(ug_data->timeout_popup, "timeout", _popup_response_to_destroy_cb, ug_data);
342 evas_object_show(ug_data->timeout_popup);
344 return elm_layout_add(ug_get_window());
347 ug_data->win_main = ug_get_window();
349 char *proxy_address = vconf_get_str(VCONFKEY_NETWORK_PROXY);
350 debug_log("network proxy: %s", proxy_address);
351 if (proxy_address && (g_strcmp0(proxy_address, "") != 0)) {
352 ewk_context_proxy_uri_set(ewk_context_default_get(), proxy_address);
359 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
360 debug_log("WINDOW W[%d] H[%d]", w, h);
364 ug_data->scale_factor = elm_scale_get();
365 debug_log("ELM Scale[%f]", ug_data->scale_factor);
368 ug_data->webview_width = 710.0;
369 ug_data->webview_height = 949.0;
370 ug_data->webview_width_landscape = 710.0;
371 ug_data->webview_height_landscape = 568.0;
372 ug_data->webview_margin = 633;
373 ug_data->webview_margin_landscape = 379;
374 } else if (w == 720) {
375 ug_data->webview_width = 710.0;
376 ug_data->webview_height = 1021.0;
377 ug_data->webview_width_landscape = 710.0;
378 ug_data->webview_height_landscape = 558.0;
379 ug_data->webview_margin = 1029;
380 ug_data->webview_margin_landscape = 558;
382 ug_data->webview_width = 710.0;
383 ug_data->webview_height = 949.0;
384 ug_data->webview_width_landscape = 710.0;
385 ug_data->webview_height_landscape = 568.0;
386 ug_data->webview_margin = 633;
387 ug_data->webview_margin_landscape = 379;
390 ug_data->evas = evas_object_evas_get(ug_data->win_main);
392 /* Double_Scroller */
395 email_account_t *account = NULL;
396 if (email_engine_get_account_full_data(ug_data->account_id, &account)) {
397 debug_log("email_engine_get_account");
399 ug_data->account_type = account->incoming_server_type;
400 snprintf(ug_data->account_email_address, sizeof(ug_data->account_email_address), "%s", account->user_email_address);
402 account_user_data_t *ud = (account_user_data_t*)account->user_data;
404 debug_log("show_images is %d", ud->show_images);
405 ug_data->b_show_remote_images = ud->show_images;
407 email_free_account(&account, 1);
413 _dbus_receiver_setup(ug_data);
415 _init_viewer_data(ug_data->account_id, ug_data->mail_id, NULL, ug_data);
416 _create_view(ug_data);
418 _check_body_download(ug_data);
420 ug_data->base = ug_data->layout_main;
422 ug_data->display_download_result = TRUE;
424 return ug_data->base;
427 static void on_start(ui_gadget_h ug, service_h data, void *priv)
432 static void on_pause(ui_gadget_h ug, service_h data, void *priv)
437 static void on_resume(ui_gadget_h ug, service_h data, void *priv)
442 static void on_destroy(ui_gadget_h ug, service_h data, void *pd)
445 EmailViewerUGD *ug_data;
454 if (ug_data->b_direct_destroy)
458 EmailViewerPrivate *priv = ug_data->email_data;
459 EmailViewerProp *prop = ug_data->property;
461 int att_len = g_list_length(prop->attachments);
463 if (priv->email_handle != 0)
464 email_engine_stop_working(ug_data->account_id, priv->email_handle);
466 for (i = 0; i < att_len; i++) {
467 if (priv->download_all_email_handle[i] != 0)
468 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[i]);
471 /* if (ug_data->theme) {
472 elm_theme_extension_del(ug_data->theme, EV_THEME_PATH);
473 elm_theme_free(ug_data->theme);
474 ug_data->theme = NULL;
477 _delete_evas_objects(ug_data);
479 debug_log("free webview_data");
480 if (ug_data->webview_data) {
481 free(ug_data->webview_data);
482 ug_data->webview_data = NULL;
485 if (ecore_file_exists(DIR_TMP_PREFIX"/mail.txt"))
486 ecore_file_remove(DIR_TMP_PREFIX"/mail.txt");
488 debug_log("free address info list");
489 email_free_address_info_list(&(priv->addrs_info_list));
490 ug_data->from_list = NULL;
491 ug_data->to_list = NULL;
492 ug_data->cc_list = NULL;
493 ug_data->bcc_list = NULL;
495 debug_log("free mail_info");
496 if (ug_data->email_data->mail_info) {
497 email_free_mail_data(&(ug_data->email_data->mail_info), 1);
498 ug_data->email_data->mail_info = NULL;
501 if (ug_data->email_data->attachment_info && ug_data->email_data->attachment_count > 0) {
502 email_free_attachment_data(&(ug_data->email_data->attachment_info), ug_data->email_data->attachment_count);
503 ug_data->email_data->attachment_info = NULL;
504 ug_data->email_data->attachment_count = 0;
507 debug_log("free email_data");
508 if (ug_data->email_data) {
509 free(ug_data->email_data);
510 ug_data->email_data = NULL;
513 debug_log("free attachment");
514 if (ug_data->property->attachments) {
516 LIST_ITER_START(i, ug_data->property->attachments) {
517 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, ug_data->property->attachments);
524 g_list_free(ug_data->property->attachments);
525 ug_data->property->attachments = NULL;
528 debug_log("free property");
529 if (ug_data->property) {
530 free(ug_data->property);
531 ug_data->property = NULL;
534 ug_data->base = NULL;
536 _dbus_receiver_remove(NULL);
537 int ret = e_dbus_shutdown();
538 debug_log("ret: %d", ret);
540 email_engine_finalize();
546 static void on_message(ui_gadget_h ug, service_h msg, service_h data, void *priv)
553 debug_log("_g_ug_data - %p", _g_ug_data);
554 if (_g_ug_data != NULL) {
555 debug_log("Hide previous mail data");
556 _hide_view(_g_ug_data);
559 char *account_id = NULL;
560 char *mail_id = NULL;
561 char *mailbox_id = NULL;
562 char *binternal = NULL;
563 char *landscape = NULL;
565 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
566 _g_ug_data = ug_data;
570 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_ACCOUNT_ID, (char **)&account_id);
571 debug_log("service_get_extra_data: %d", ret);
572 debug_log("account_id:%s", account_id);
573 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_MAIL_ID, (char **)&mail_id);
574 debug_log("service_get_extra_data: %d", ret);
575 debug_log("mail_id:%s", mail_id);
576 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_MAILBOX, (char **)&mailbox_id);
577 debug_log("service_get_extra_data: %d", ret);
578 debug_log("mailbox:%s", mailbox_id);
579 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_INTERNAL, (char **)&binternal);
580 debug_log("service_get_extra_data: %d", ret);
581 debug_log("binternal:%s", binternal);
582 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_FIRST_LANDSCAPE, (char **)&landscape);
583 debug_log("service_get_extra_data: %d", ret);
584 debug_log("landscape:%s", landscape);
587 ug_data->isRotate = atoi(landscape);
588 debug_log("@@@@ Landscape = %d @@@@", ug_data->isRotate);
593 ug_data->account_id = atoi(account_id);
594 ug_data->folder_list = email_engine_get_ca_mailbox_list_using_glist(ug_data->account_id);
599 ug_data->mail_id = atoi(mail_id);
604 g_free(ug_data->mailbox_name);
605 ug_data->mailbox_name = NULL;
606 ug_data->mailbox_id = atoi(mailbox_id);
610 email_mail_data_t *mail_data = NULL;
611 if ((err = email_get_mail_data(ug_data->mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
612 debug_log("fail to get mail - err (%d)", err);
615 if (mail_data == NULL) {
616 debug_log("mail_data is NULL");
619 if (mail_data->server_mailbox_name)
620 ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name);
621 ug_data->mailbox_type = mail_data->mailbox_type;
622 debug_log("server_mailbox_name:%s", mail_data->server_mailbox_name);
623 debug_log("mailbox_name:%s", ug_data->mailbox_name);
624 debug_log("mailbox_type:%d", ug_data->mailbox_type);
627 debug_log("email_free_mail is called");
628 email_free_mail_data(&(mail_data), 1);
634 ug_data->b_internal = atoi(binternal);
635 if (ug_data->b_internal == 1)
636 debug_log("############Launched from email-mailbox###############");
640 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);
642 if (ug_data->account_id <= 0 || ug_data->mail_id <= 0 || ug_data->mailbox_id <= 0) {
643 debug_log("Required bundle parameters are missing!");
648 email_account_t *account = NULL;
649 if (email_engine_get_account_full_data(ug_data->account_id, &account)) {
650 debug_log("email_engine_get_account");
652 ug_data->account_type = account->incoming_server_type;
653 snprintf(ug_data->account_email_address, sizeof(ug_data->account_email_address), "%s", account->user_email_address);
655 account_user_data_t *ud = (account_user_data_t*)account->user_data;
657 debug_log("show_images is %d", ud->show_images);
658 ug_data->b_show_remote_images = ud->show_images;
660 email_free_account(&account, 1);
664 Ewk_Setting *setting = ewk_view_setting_get(ug_data->webview);
666 debug_log("b_show_remote_images is %d", ug_data->b_show_remote_images);
667 if (ewk_setting_load_remote_images_set(setting, ug_data->b_show_remote_images) == EINA_FALSE) {
668 debug_log("SET remote images is FAILED!");
672 _init_viewer_data(ug_data->account_id, ug_data->mail_id, NULL, ug_data);
674 evas_object_show(ug_data->layout_main);
675 evas_object_raise(ug_data->layout_main);
677 _reset_view(ug_data);
679 ug_data->display_download_result = TRUE;
682 static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *priv)
689 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
690 EmailViewerProp *prop = ug_data->property;
691 char date_time[MAX_STR_LEN] = { 0, };
692 char *formatted_date = NULL;
695 debug_log("rotate event = %d", event);
698 case UG_EVENT_LOW_MEMORY:
700 case UG_EVENT_LOW_BATTERY:
702 case UG_EVENT_LANG_CHANGE:
704 case UG_EVENT_ROTATE_PORTRAIT:
705 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
706 if (ug_data->b_internal && ug_data->isRotate == true) {
707 ewk_view_command_execute(ug_data->webview, "Unselect", NULL);
708 debug_log("In Full view - Showing navi bar");
709 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_TRUE);
711 if (ug_data->con_popup) {
712 evas_object_del(ug_data->con_popup);
713 ug_data->con_popup = NULL;
716 if (ug_data->navi_move_it1) {
718 Evas_Object *move_back_btn = elm_button_add(ug_data->navi_bar);
719 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
720 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb, ug_data);
721 elm_object_item_part_content_set(ug_data->navi_move_it1, "prev_btn", move_back_btn);
722 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_TRUE);
723 if (ug_data->move_cbar) {
724 elm_object_item_part_content_unset(ug_data->navi_move_it1, "controlbar");
725 evas_object_del(ug_data->move_cbar);
726 ug_data->move_cbar = NULL;
730 if (ug_data->b_btn) {
731 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
732 evas_object_del(ug_data->b_btn);
733 ug_data->b_btn = NULL;
736 ug_data->b_btn = elm_button_add(ug_data->navi_bar);
737 elm_object_style_set(ug_data->b_btn, "naviframe/back_btn/default");
738 evas_object_smart_callback_add(ug_data->b_btn, "clicked", _back_cb, ug_data);
739 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", ug_data->b_btn);
741 ug_data->isRotate = false;
746 case UG_EVENT_ROTATE_LANDSCAPE:
747 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
748 if (ug_data->b_internal && ug_data->isRotate == false) {
749 ewk_view_command_execute(ug_data->webview, "Unselect", NULL);
750 debug_log("In Split view - Hiding navi bar");
751 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE);
753 if (ug_data->con_popup) {
754 evas_object_del(ug_data->con_popup);
755 ug_data->con_popup = NULL;
758 if (ug_data->navi_move_it1) {
760 ug_data->move_cbar = elm_toolbar_add(ug_data->navi_bar);
761 elm_toolbar_shrink_mode_set(ug_data->move_cbar, ELM_TOOLBAR_SHRINK_EXPAND);
762 elm_object_style_set(ug_data->move_cbar, "naviframe");
763 evas_object_show(ug_data->move_cbar);
765 elm_object_item_disabled_set(elm_toolbar_item_append(ug_data->move_cbar, NULL, "", NULL, NULL), EINA_TRUE);
766 elm_toolbar_item_append(ug_data->move_cbar, NULL, dgettext("sys_string", "IDS_COM_SK_CANCEL"), _move_back_cb, ug_data);
767 elm_object_item_part_content_set(ug_data->navi_move_it1, "controlbar", ug_data->move_cbar);
769 Evas_Object *move_back_btn = elm_object_item_part_content_get(ug_data->navi_move_it1, "prev_btn");
771 evas_object_smart_callback_del(move_back_btn, "clicked", _move_back_cb);
772 evas_object_del(move_back_btn);
773 elm_object_item_part_content_set(ug_data->navi_move_it1, "prev_btn", NULL);
775 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_FALSE);
778 if (ug_data->b_btn) {
779 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
780 evas_object_del(ug_data->b_btn);
781 ug_data->b_btn = NULL;
782 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
785 ug_data->isRotate = true;
790 case UG_EVENT_REGION_CHANGE:
791 appcore_get_timeformat(&icu_timeformat);
792 /* ICU API to set default locale */
793 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
794 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
796 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
797 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
799 free(formatted_date);
800 formatted_date = NULL;
802 edje_object_part_text_set(_EDJ(ug_data->ly_subject), "elm.text.sub", date_time);
803 evas_object_show(ug_data->ly_subject);
811 static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h data, void *priv)
818 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
819 EmailViewerPrivate *private = ug_data->email_data;
820 EmailViewerProp *prop = ug_data->property;
823 case UG_KEY_EVENT_END:
825 if (ug_data->notify != NULL || ug_data->pb_notify != NULL || ug_data->timeout_popup != NULL) {
826 if (ug_data->timeout_popup) {
827 evas_object_del(ug_data->timeout_popup);
828 ug_data->timeout_popup = NULL;
831 if (ug_data->notify) {
832 evas_object_del(ug_data->notify);
833 ug_data->notify = NULL;
836 if (ug_data->pb_notify) {
838 int att_len = g_list_length(prop->attachments);
840 evas_object_del(ug_data->pb_notify);
841 ug_data->pb_notify = NULL;
843 if (private->email_handle != 0)
844 email_engine_stop_working(ug_data->account_id, private->email_handle);
846 for (i = 0; i < att_len; i++) {
847 if (private->download_all_email_handle[i] != 0)
848 email_engine_stop_working(ug_data->account_id, private->download_all_email_handle[i]);
852 if (ug_data->pb_notify_lb) {
853 evas_object_del(ug_data->pb_notify_lb);
854 ug_data->pb_notify_lb = NULL;
857 if (ug_data->isRotate == false && ug_data->b_internal) {
858 /* Viewer to hide, so set left content (mailbox) size to full */
859 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
862 if (ug_data->b_internal)
865 ug_destroy_me(ug_data->ug);
869 service_h service = NULL;
871 ret = service_create(&service);
872 debug_log("service_create: %d", ret);
874 debug_log("service create failed");
878 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_END_KEY);
879 debug_log("service_add_extra_data: %d", ret);
881 ug_send_message(_g_mailbox_ug, service);
883 ret = service_destroy(service);
884 debug_log("service_destroy: %d", ret);
893 static void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
896 Evas_Object *base, *win;
901 base = ug_get_layout(ug);
905 win = ug_get_window();
908 case UG_MODE_FULLVIEW:
909 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
910 elm_win_resize_object_add(win, base);
911 evas_object_show(base);
918 static void result_cb(ui_gadget_h ug, service_h result, void *priv)
925 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
926 EmailViewerProp *prop = ug_data->property;
927 EmailViewerPrivate *private = ug_data->email_data;
929 if (ug == ug_data->ug_composer) {
931 int ret = service_get_extra_data(result, EMAIL_BUNDLE_KEY_SAVE_ALL, (char **)&cmd);
932 debug_log("service_get_extra_data: %d", ret);
933 debug_log("return of bundle_get_val for save all(%s)", cmd);
935 debug_log("save all from composer(%s), real_att_len(%d), att_len(%d)", cmd, prop->real_att_len, prop->att_len);
937 if (prop->real_att_len == 1) {
938 private->b_all_att_save = TRUE;
939 _save_attachment(ug_data, 0);
940 } else if (prop->real_att_len > 1) {
941 _save_attachment_all(ug_data);
947 ret = service_get_extra_data(result, EMAIL_BUNDLE_KEY_CANCEL_ALL, (char **)&cmd);
948 debug_log("service_get_extra_data: %d", ret);
949 debug_log("return of bundle_get_val for cancel all(%s)", cmd);
951 debug_log("cancel all attachment from composer(%s)", cmd);
953 _cancel_download_attachment(ug_data);
960 static void destroy_cb(ui_gadget_h ug, void *priv)
966 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
967 EmailViewerProp *prop = ug_data->property;
968 ug_data->display_download_result = TRUE;
970 if (ug == ug_data->ug_composer) {
971 ug_data->ug_composer = NULL;
976 if (ug_data->b_contact_ug_launched) {
977 debug_log("change navibar title label");
978 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
979 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, prop->sender);
981 if (contact_list_item) {
982 elm_object_item_text_set(ug_data->navi_main_it, contact_list_item->display_name);
983 _delete_contacts_list(contact_list_item);
985 elm_object_item_text_set(ug_data->navi_main_it, prop->sender_display_name);
988 ug_data->b_contact_ug_launched = FALSE;
992 static ui_gadget_h create_ug(char *ug_name, service_h bd, void *data)
996 struct ug_cbs cbs = { 0, };
998 cbs.layout_cb = layout_cb;
999 cbs.result_cb = result_cb;
1000 cbs.destroy_cb = destroy_cb;
1003 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
1005 ug = ug_create(ug_data->ug, ug_name, UG_MODE_FULLVIEW, bd, &cbs);
1010 static void _create_view(EmailViewerUGD *ug_data)
1015 Evas_Object *prev_btn;
1016 Evas_Object *next_btn;
1017 EmailViewerProp *prop = ug_data->property;
1019 ug_data->bg = _create_bg(ug_data->win_main);
1022 ug_data->layout_main = elm_layout_add(ug_data->win_main);
1024 if (ug_data->b_internal)
1025 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "noindicator");
1027 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "default");
1028 evas_object_size_hint_weight_set(ug_data->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1029 evas_object_show(ug_data->layout_main);
1031 elm_object_part_content_set(ug_data->layout_main, "elm.swallow.bg", ug_data->bg);
1034 elm_win_indicator_mode_set(ug_data->win_main, ELM_WIN_INDICATOR_SHOW);
1036 evas_object_smart_callback_add(ug_data->win_main, "profile,changed", _win_profile_changed_cb, ug_data);
1038 /* navigation Bar */
1039 _create_navigation_bar(ug_data);
1041 /* push navigation bar */
1042 ug_data->sub_ly = elm_layout_add(ug_data->navi_bar);
1043 elm_layout_theme_set(ug_data->sub_ly, "layout", "application", "noindicator");
1044 evas_object_size_hint_weight_set(ug_data->sub_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1045 evas_object_show(ug_data->sub_ly);
1048 b_btn = elm_button_add(ug_data->navi_bar);
1049 elm_object_style_set(b_btn, "naviframe/back_btn/default");
1050 evas_object_smart_callback_add(b_btn, "clicked", _back_cb, ug_data);
1051 ug_data->b_btn = b_btn;
1053 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);
1055 if (ug_data->b_internal) {
1056 /* Left : previous button */
1057 prev_btn = elm_button_add(ug_data->navi_bar);
1058 Evas_Object *prev_ic = elm_icon_add(prev_btn);
1059 elm_icon_file_set(prev_ic, IMGDIR "/M02_icon_previous.png", NULL);
1060 elm_object_style_set(prev_btn, "naviframe/title/default");
1061 evas_object_size_hint_aspect_set(prev_ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1062 elm_icon_resizable_set(prev_ic, 0.8, 0.8);
1063 elm_object_part_content_set(prev_btn, "icon", prev_ic);
1064 elm_object_item_part_content_set(ug_data->navi_main_it, "title_left_btn", prev_btn);
1065 evas_object_smart_callback_add(prev_btn, "clicked", _prev_mail_cb, ug_data);
1066 ug_data->prev_btn = prev_btn;
1068 /* Right : next button */
1069 next_btn = elm_button_add(ug_data->navi_bar);
1070 Evas_Object *next_ic = elm_icon_add(next_btn);
1071 elm_icon_file_set(next_ic, IMGDIR "/M02_icon_next.png", NULL);
1072 elm_object_style_set(next_btn, "naviframe/title/default");
1073 evas_object_size_hint_aspect_set(next_ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1074 elm_icon_resizable_set(next_ic, 0.8, 0.8);
1075 elm_object_part_content_set(next_btn, "icon", next_ic);
1076 elm_object_item_part_content_set(ug_data->navi_main_it, "title_right_btn", next_btn);
1077 evas_object_smart_callback_add(next_btn, "clicked", _next_mail_cb, ug_data);
1078 ug_data->next_btn = next_btn;
1081 /* create scroller */
1082 ug_data->scroller = elm_scroller_add(ug_data->navi_bar);
1083 evas_object_propagate_events_set(ug_data->scroller, EINA_FALSE);
1084 elm_scroller_bounce_set(ug_data->scroller, EINA_FALSE, EINA_TRUE);
1085 elm_scroller_policy_set(ug_data->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
1086 evas_object_show(ug_data->scroller);
1087 evas_object_smart_callback_add(ug_data->scroller, "edge,bottom", _outter_scroller_bottom_hit_cb, ug_data);
1088 evas_object_smart_callback_add(ug_data->scroller, "edge,top", _outter_scroller_top_hit_cb, ug_data);
1089 evas_object_smart_callback_add(ug_data->scroller, "scroll,drag,start", _outter_scroller_scroll_cb, ug_data);
1091 /* create conformant */
1092 elm_win_conformant_set(ug_data->win_main, EINA_TRUE);
1093 ug_data->conformant = elm_conformant_add(ug_data->sub_ly);
1094 elm_object_style_set(ug_data->conformant, "internal_layout");
1095 evas_object_size_hint_weight_set(ug_data->conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1096 evas_object_size_hint_align_set(ug_data->conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
1097 elm_object_content_set(ug_data->conformant, ug_data->scroller);
1098 elm_object_part_content_set(ug_data->sub_ly, "elm.swallow.content", ug_data->conformant);
1099 evas_object_show(ug_data->conformant);
1101 if (ug_data->from_list != NULL) {
1102 email_address_info_t *addrs_info = NULL;
1103 int n_from_list = g_list_length(ug_data->from_list);
1104 debug_log("from list count [%d]", n_from_list);
1106 if (n_from_list > 0) {
1107 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->from_list, 0);
1108 debug_log("From Address:%s", addrs_info->address);
1109 debug_log("Display Name:%s", addrs_info->display_name);
1110 debug_log("Storage Type:%d", addrs_info->storage_type);
1111 debug_log("Contact ID:%d", addrs_info->contact_id);
1113 g_free(prop->sender_display_name);
1114 prop->sender_display_name = g_strdup(addrs_info->display_name);
1115 g_free(prop->sender);
1116 prop->sender = g_strdup(addrs_info->address);
1118 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1119 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->display_name);
1121 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->address);
1125 /* create main box */
1126 ug_data->main_bx = elm_box_add(ug_data->navi_bar);
1127 evas_object_size_hint_weight_set(ug_data->main_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1128 evas_object_size_hint_align_set(ug_data->main_bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1129 evas_object_show(ug_data->main_bx);
1130 elm_object_content_set(ug_data->scroller, ug_data->main_bx);
1132 if (ug_data->property->has_attachment)
1133 ug_data->got_att = 1;
1135 ug_data->got_att = 0;
1137 /* packing subject, addrs, attachment */
1138 _create_subject(ug_data);
1140 if (ug_data->got_att) {
1141 _create_attach(ug_data);
1144 if (ug_data->isRotate == true) {
1145 debug_log("In Split view - Hiding navi bar");
1146 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE);
1148 if (ug_data->b_btn) {
1149 debug_log("hiding back button");
1151 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1152 evas_object_del(ug_data->b_btn);
1153 ug_data->b_btn = NULL;
1155 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
1160 static void _reset_view(EmailViewerUGD *ug_data)
1163 EmailViewerProp *prop = ug_data->property;
1165 char date_time[MAX_STR_LEN] = { 0, };
1167 debug_log("@@@@@@@@@@ isRotate = %d", ug_data->isRotate);
1168 if (ug_data->isRotate == true) {
1169 debug_log("In Split view - Hiding navi bar");
1170 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE);
1172 if (ug_data->b_btn) {
1173 debug_log("hiding back button");
1175 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1176 evas_object_del(ug_data->b_btn);
1177 ug_data->b_btn = NULL;
1179 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
1182 /* Set scroller to start - height made 480 to consider viewer in split view */
1183 elm_scroller_region_show(ug_data->scroller, 0, 0, (int)((double)ug_data->main_h * 0.6), ug_data->main_w);
1185 debug_log("In Full view - Showing navi bar");
1186 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_TRUE);
1188 if (ug_data->b_btn) {
1190 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1191 evas_object_del(ug_data->b_btn);
1192 ug_data->b_btn = NULL;
1195 debug_log("showing back button");
1197 ug_data->b_btn = elm_button_add(ug_data->navi_bar);
1198 elm_object_style_set(ug_data->b_btn, "naviframe/back_btn/default");
1199 evas_object_smart_callback_add(ug_data->b_btn, "clicked", _back_cb, ug_data);
1201 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", ug_data->b_btn);
1203 /* Set scroller to start */
1204 elm_scroller_region_show(ug_data->scroller, 0, 0, ug_data->main_w, ug_data->main_h);
1207 if (ug_data->from_list != NULL) {
1208 email_address_info_t *addrs_info = NULL;
1209 int n_from_list = g_list_length(ug_data->from_list);
1210 debug_log("from list count [%d]", n_from_list);
1212 if (n_from_list > 0) {
1213 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->from_list, 0);
1215 debug_log("From Address:%s", addrs_info->address);
1216 debug_log("Display Name:%s", addrs_info->display_name);
1217 debug_log("Storage Type:%d", addrs_info->storage_type);
1218 debug_log("Contact ID:%d", addrs_info->contact_id);
1219 g_free(prop->sender_display_name);
1220 prop->sender_display_name = g_strdup(addrs_info->display_name);
1221 g_free(prop->sender);
1222 prop->sender = g_strdup(addrs_info->address);
1224 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1225 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->display_name);
1227 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->address);
1231 elm_object_item_text_set(ug_data->navi_main_it, prop->sender_display_name);
1235 char *_subject = elm_entry_utf8_to_markup(prop->subject);
1236 if (!g_strcmp0(_subject, "")) {
1238 _subject = g_strdup(_("IDS_EMAIL_BODY_NO_SUBJECT"));
1240 char *_subject_concated = g_strconcat("<font_size=44><color=#000000FF>", _subject, "</color></font_size>", NULL);
1241 elm_object_text_set(ug_data->lb_subject, _subject_concated);
1242 elm_label_wrap_width_set(ug_data->lb_subject, ug_data->main_w - (int)(110 * ug_data->scale_factor));
1243 elm_label_line_wrap_set(ug_data->lb_subject, ELM_WRAP_WORD);
1245 g_free(_subject_concated);
1247 /* reset date & time */
1248 char *formatted_date = NULL;
1250 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1251 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
1253 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
1254 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
1256 free(formatted_date);
1257 formatted_date = NULL;
1259 elm_object_part_text_set(ug_data->ly_subject, "elm.text.sub", date_time);
1261 Evas_Object *favorite_icon = elm_icon_add(ug_data->ly_subject);
1262 switch(prop->favorite)
1264 case EMAIL_FLAG_NONE:
1265 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_off.png", NULL);
1267 case EMAIL_FLAG_FLAGED:
1268 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_on.png", NULL);
1270 case EMAIL_FLAG_TASK_STATUS_CLEAR:
1271 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
1273 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
1274 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
1276 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
1277 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
1280 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1281 elm_icon_resizable_set(favorite_icon, 1, 1);
1282 evas_object_del(elm_object_part_content_unset(ug_data->ly_subject, "elm.icon.favorite"));
1283 elm_object_part_content_set(ug_data->ly_subject, "elm.icon.favorite", favorite_icon);
1284 evas_object_show(favorite_icon);
1286 evas_object_show(ug_data->ly_subject);
1287 elm_box_pack_end(ug_data->main_bx, ug_data->ly_subject);
1289 Evas_Object *edje = elm_layout_edje_get(ug_data->ly_subject);
1291 if (!ug_data->to_list && !ug_data->cc_list && !ug_data->bcc_list) {
1292 edje_object_signal_emit(edje, "elm,state,arrow_hidden", "elm");
1294 edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _subject_detail_clicked_cb, ug_data->ly_subject);
1297 if (prop->has_attachment)
1298 ug_data->got_att = 1;
1300 ug_data->got_att = 0;
1302 /* pack attachment if it exist */
1303 if (ug_data->got_att) {
1304 _create_attach(ug_data);
1307 /* check body downloaded */
1308 _check_body_download(ug_data);
1311 void _hide_view(EmailViewerUGD *ug_data)
1314 EmailViewerProp *prop = ug_data->property;
1315 EmailViewerPrivate *priv = ug_data->email_data;
1317 debug_log("Cancelling all attachment downloads");
1318 _cancel_download_attachment(ug_data);
1320 ug_data->display_download_result = FALSE;
1323 if (elm_naviframe_top_item_get(ug_data->navi_bar) != ug_data->navi_main_it) {
1324 ug_data->navi_move_it1 = NULL;
1325 elm_naviframe_item_pop_to(ug_data->navi_main_it);
1328 evas_object_hide(ug_data->layout_main);
1329 elm_box_unpack_all(ug_data->main_bx);
1330 elm_object_scroll_freeze_pop(ug_data->scroller);
1332 evas_object_hide(ug_data->ly_subject);
1333 evas_object_hide(ug_data->lb_subject);
1334 evas_object_hide(ug_data->webview_bx);
1335 evas_object_hide(ug_data->webview);
1337 if (ug_data->partial_dn_btn) {
1338 evas_object_del(ug_data->partial_dn_btn);
1339 ug_data->partial_dn_btn = NULL;
1342 if (ug_data->partial_dn_btn_bx) {
1343 evas_object_del(ug_data->partial_dn_btn_bx);
1344 ug_data->partial_dn_btn_bx = NULL;
1347 if (ug_data->ctr_bar) {
1348 elm_object_item_part_content_unset(ug_data->navi_main_it, "controlbar");
1349 evas_object_del(ug_data->ctr_bar);
1350 ug_data->ctr_bar = NULL;
1352 ug_data->reply_ctr_it = NULL;
1353 ug_data->replyall_ctr_it = NULL;
1354 ug_data->forward_ctr_it = NULL;
1355 ug_data->calendar_ctr_it = NULL;
1356 ug_data->resend_ctr_it = NULL;
1357 ug_data->move_ctr_it = NULL;
1358 ug_data->del_ctr_it = NULL;
1361 if (ug_data->to_ly) {
1362 evas_object_del(ug_data->to_ly);
1363 ug_data->to_ly = NULL;
1366 if (ug_data->cc_ly) {
1367 evas_object_del(ug_data->cc_ly);
1368 ug_data->cc_ly = NULL;
1371 if (ug_data->bcc_ly) {
1372 evas_object_del(ug_data->bcc_ly);
1373 ug_data->bcc_ly = NULL;
1376 if (ug_data->got_att) {
1379 evas_object_del(ug_data->attach_hd_bk);
1380 ug_data->attach_hd_ly = NULL;
1381 ug_data->attach_hd_bk = NULL;
1383 if (prop->real_att_len > 1) {
1384 for (i = 0; i < prop->real_att_len; i++) {
1385 if (ug_data->attach_ex_ly != NULL) {
1386 if (ug_data->attach_ex_ly[i] != NULL) {
1387 debug_log("index %d", i);
1388 evas_object_del(ug_data->attach_ex_bk[i]);
1389 ug_data->attach_ex_ly[i] = NULL;
1390 ug_data->attach_ex_bk[i] = NULL;
1395 if (ug_data->attach_ex_ly != NULL) {
1396 free(ug_data->attach_ex_ly);
1397 ug_data->attach_ex_ly = NULL;
1398 ug_data->attach_ex_bk = NULL;
1402 for (i = 0; i <= prop->att_len; i++) {
1403 if (ug_data->progress_bar_ly[i] != NULL) {
1404 evas_object_del(ug_data->progress_bar_ly[i]);
1405 ug_data->progress_bar_ly[i] = NULL;
1406 ug_data->progress_bar[i] = NULL;
1411 if (ug_data->con_popup != NULL) {
1412 evas_object_del(ug_data->con_popup);
1413 ug_data->con_popup = NULL;
1416 if (ug_data->notify != NULL) {
1417 evas_object_del(ug_data->notify);
1418 ug_data->notify = NULL;
1421 edje_object_signal_emit(_EDJ(ug_data->ly_subject), "elm,state,contracted", "elm");
1422 edje_object_signal_callback_del(_EDJ(ug_data->ly_subject), "elm,action,expand,toggle", "elm", _subject_detail_clicked_cb);
1424 evas_object_hide(ug_data->noc_bx);
1425 evas_object_hide(ug_data->dn_btn);
1427 if (ecore_file_exists(EMAIL_TMP_FILE_PATH ".html"))
1428 ecore_file_remove(EMAIL_TMP_FILE_PATH ".html");
1430 if (ecore_file_exists(DIR_TMP_PREFIX"/mail.txt"))
1431 ecore_file_remove(DIR_TMP_PREFIX"/mail.txt");
1433 ewk_view_uri_set(ug_data->webview, EMAIL_DEFAULT_HTML);
1435 debug_log("free address info list");
1436 email_free_address_info_list(&(priv->addrs_info_list));
1437 ug_data->from_list = NULL;
1438 ug_data->to_list = NULL;
1439 ug_data->cc_list = NULL;
1440 ug_data->bcc_list = NULL;
1442 ug_data->got_att = 0;
1443 ug_data->subject_onoff_flag = 0;
1444 ug_data->attach_onoff_flag = 0;
1445 ug_data->b_partial_body = 0;
1446 ug_data->b_internal = 0;
1447 ug_data->scroller_locked = 0;
1448 ug_data->m_is_multi_touch = 0;
1450 ug_data->navi_move_it1 = NULL;
1452 /* Double_Scroller */
1454 ug_data->b_load_finished = EINA_FALSE;
1455 ug_data->b_show_remote_images = EINA_FALSE;
1456 ug_data->is_webview_scrolling = EINA_FALSE;
1457 ug_data->is_main_scroller_scrolling = EINA_FALSE;
1460 static void _win_profile_changed_cb(void *data, Evas_Object *obj, void *event)
1464 debug_log("data is NULL");
1468 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
1470 const char *profile = elm_config_profile_get();
1471 if (!g_strcmp0(profile, "desktop"))
1472 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "noindicator");
1474 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "default");
1476 evas_object_size_hint_weight_set(ug_data->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1477 elm_win_resize_object_add(ug_data->win_main, ug_data->layout_main);
1478 evas_object_show(ug_data->layout_main);
1481 static Evas_Object *_create_navigation_bar(EmailViewerUGD *ug_data)
1484 Evas_Object *navi_bar;
1486 navi_bar = elm_naviframe_add(ug_data->layout_main);
1487 if (navi_bar == NULL) {
1488 debug_log("navi_bar == NULL");
1492 elm_object_part_content_set(ug_data->layout_main, "elm.swallow.content", navi_bar);
1493 evas_object_show(navi_bar);
1495 ug_data->navi_bar = navi_bar;
1499 static Evas_Object *_create_subject(EmailViewerUGD *ug_data)
1502 EmailViewerProp *prop = ug_data->property;
1504 char date_time[MAX_STR_LEN] = { 0, };
1506 /* append subject */
1507 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1508 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.detail_subject");
1509 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1511 Evas_Object *subject_label;
1512 subject_label = elm_label_add(di);
1513 elm_object_part_content_set(di, "elm.text", subject_label);
1514 char *subject = elm_entry_utf8_to_markup(prop->subject);
1515 if (!g_strcmp0(subject, "")) {
1517 subject = g_strdup(_("IDS_EMAIL_BODY_NO_SUBJECT"));
1519 char *subject_tagged = g_strconcat("<font_size=44><color=#000000FF>", subject, "</color></font_size>", NULL);
1520 elm_object_text_set(subject_label, subject_tagged);
1521 elm_label_wrap_width_set(subject_label, ug_data->main_w - (int)(110 * ug_data->scale_factor));
1522 elm_label_line_wrap_set(subject_label, ELM_WRAP_WORD);
1523 ug_data->lb_subject = subject_label;
1525 g_free(subject_tagged);
1527 char *formatted_date = NULL;
1529 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1530 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
1532 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
1533 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
1534 free(formatted_date);
1535 formatted_date = NULL;
1537 elm_object_part_text_set(di, "elm.text.sub", date_time);
1539 Evas_Object *favorite_icon = elm_icon_add(di);
1540 switch(prop->favorite)
1542 case EMAIL_FLAG_NONE:
1543 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_off.png", NULL);
1545 case EMAIL_FLAG_FLAGED:
1546 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_on.png", NULL);
1548 case EMAIL_FLAG_TASK_STATUS_CLEAR:
1549 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
1551 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
1552 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
1554 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
1555 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
1558 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1559 elm_icon_resizable_set(favorite_icon, 1, 1);
1560 elm_object_part_content_set(di, "elm.icon.favorite", favorite_icon);
1561 evas_object_show(favorite_icon);
1563 evas_object_show(di);
1564 elm_box_pack_end(ug_data->main_bx, di);
1565 ug_data->ly_subject = di;
1567 Evas_Object *edje = elm_layout_edje_get(di);
1569 if (ug_data->to_list || ug_data->cc_list || ug_data->bcc_list) {
1570 edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _subject_detail_clicked_cb, di);
1572 edje_object_signal_emit(edje, "elm,state,arrow_hidden", "elm");
1574 edje_object_signal_callback_add(edje, "elm,action,toggle", "elm", _subject_favorite_clicked_cb, di);
1579 static Evas_Object *_create_to_addrs(EmailViewerUGD *ug_data)
1582 email_address_info_t *addrs_info = NULL;
1583 Elm_Object_Item *mbe_item;
1585 if (ug_data->to_list == NULL) {
1586 debug_log("to_list is NULL");
1590 int n_to_list = g_list_length(ug_data->to_list);
1593 if (n_to_list <= 0) {
1594 debug_log("to_list count is 0");
1598 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1599 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1600 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1601 evas_object_show(di);
1602 ug_data->to_ly = di;
1603 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1605 Evas_Object *to_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1606 char desc[MAX_STR_LEN] = { 0, };
1607 snprintf(desc, MAX_STR_LEN, "%s:", dgettext("sys_string", "IDS_COM_BODY_TO"));
1608 char *to_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1609 elm_object_text_set(to_mbe, to_str);
1612 evas_object_smart_callback_add(to_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1613 evas_object_smart_callback_add(to_mbe, "item,added", _mbe_added_cb, ug_data);
1614 evas_object_smart_callback_add(to_mbe, "focused", _mbe_focused_cb, ug_data);
1615 evas_object_smart_callback_add(to_mbe, "unfocused", _mbe_unfocused_cb, ug_data);
1616 elm_object_part_content_set(di, "elm.icon", to_mbe);
1617 ug_data->to_mbe = to_mbe;
1619 Evas_Object *entry = elm_multibuttonentry_entry_get(to_mbe);
1621 elm_entry_editable_set(entry, EINA_FALSE);
1623 if (n_to_list > EMAIL_VIEW_MAX_TO_COUNT)
1624 n_to_list = EMAIL_VIEW_MAX_TO_COUNT;
1626 for (i = 0; i < n_to_list; i++) {
1627 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->to_list, i);
1628 debug_log("Address:%s", addrs_info->address);
1629 debug_log("Display Name:%s", addrs_info->display_name);
1630 debug_log("Storage Type:%d", addrs_info->storage_type);
1631 debug_log("Contact ID:%d", addrs_info->contact_id);
1633 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1634 mbe_item = elm_multibuttonentry_item_append(to_mbe, addrs_info->display_name, NULL, NULL);
1636 mbe_item = elm_multibuttonentry_item_append(to_mbe, addrs_info->address, NULL, NULL);
1637 elm_object_item_data_set(mbe_item, addrs_info);
1643 static Evas_Object *_create_cc_addrs(EmailViewerUGD *ug_data)
1646 email_address_info_t *addrs_info = NULL;
1647 Elm_Object_Item *mbe_item;
1649 if (ug_data->cc_list == NULL) {
1650 debug_log("cc_list is NULL");
1654 int n_cc_list = g_list_length(ug_data->cc_list);
1657 if (n_cc_list <= 0) {
1658 debug_log("cc_list count is 0");
1662 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1663 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1664 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1665 evas_object_show(di);
1666 ug_data->cc_ly = di;
1668 if (ug_data->to_ly) {
1669 elm_box_pack_after(ug_data->main_bx, di, ug_data->to_ly);
1671 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1674 Evas_Object *cc_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1675 char desc[MAX_STR_LEN] = { 0, };
1676 snprintf(desc, MAX_STR_LEN, "%s:", _("IDS_EMAIL_BODY_CC"));
1677 char *cc_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1678 elm_object_text_set(cc_mbe, cc_str);
1680 evas_object_smart_callback_add(cc_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1681 evas_object_smart_callback_add(cc_mbe, "item,added", _mbe_added_cb, ug_data);
1682 evas_object_smart_callback_add(cc_mbe, "focused", _mbe_focused_cb, ug_data);
1683 evas_object_smart_callback_add(cc_mbe, "unfocused", _mbe_unfocused_cb, ug_data);
1684 elm_object_part_content_set(di, "elm.icon", cc_mbe);
1685 ug_data->cc_mbe = cc_mbe;
1687 Evas_Object *entry = elm_multibuttonentry_entry_get(cc_mbe);
1689 elm_entry_editable_set(entry, EINA_FALSE);
1691 if (n_cc_list > EMAIL_VIEW_MAX_CC_COUNT)
1692 n_cc_list = EMAIL_VIEW_MAX_CC_COUNT;
1694 for (i = 0; i < n_cc_list; i++) {
1695 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->cc_list, i);
1697 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1698 mbe_item = elm_multibuttonentry_item_append(cc_mbe, addrs_info->display_name, NULL, NULL);
1700 mbe_item = elm_multibuttonentry_item_append(cc_mbe, addrs_info->address, NULL, NULL);
1701 elm_object_item_data_set(mbe_item, addrs_info);
1707 static Evas_Object *_create_bcc_addrs(EmailViewerUGD *ug_data)
1710 email_address_info_t *addrs_info = NULL;
1711 Elm_Object_Item *mbe_item;
1713 if (ug_data->bcc_list == NULL) {
1714 debug_log("bcc_list is NULL");
1718 int n_bcc_list = g_list_length(ug_data->bcc_list);
1721 if (n_bcc_list <= 0) {
1722 debug_log("bcc_list count is 0");
1726 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1727 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1728 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1729 evas_object_show(di);
1730 ug_data->bcc_ly = di;
1732 if (ug_data->cc_ly) {
1733 elm_box_pack_after(ug_data->main_bx, di, ug_data->cc_ly);
1735 if (ug_data->to_ly && ug_data->cc_ly == NULL) {
1736 elm_box_pack_after(ug_data->main_bx, di, ug_data->to_ly);
1738 if (ug_data->to_ly == NULL && ug_data->cc_ly == NULL) {
1739 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1742 Evas_Object *bcc_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1743 char desc[MAX_STR_LEN] = { 0, };
1744 snprintf(desc, MAX_STR_LEN, "%s:", _("IDS_EMAIL_BODY_BCC"));
1745 char *bcc_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1746 elm_object_text_set(bcc_mbe, bcc_str);
1748 evas_object_smart_callback_add(bcc_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1749 evas_object_smart_callback_add(bcc_mbe, "item,added", _mbe_added_cb, ug_data);
1750 evas_object_smart_callback_add(bcc_mbe, "focused", _mbe_focused_cb, ug_data);
1751 evas_object_smart_callback_add(bcc_mbe, "unfocused", _mbe_unfocused_cb, ug_data);
1752 elm_object_part_content_set(di, "elm.icon", bcc_mbe);
1753 ug_data->bcc_mbe = bcc_mbe;
1755 Evas_Object *entry = elm_multibuttonentry_entry_get(bcc_mbe);
1757 elm_entry_editable_set(entry, EINA_FALSE);
1759 if (n_bcc_list > EMAIL_VIEW_MAX_BCC_COUNT)
1760 n_bcc_list = EMAIL_VIEW_MAX_BCC_COUNT;
1762 for (i = 0; i < n_bcc_list; i++) {
1763 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->bcc_list, i);
1765 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1766 mbe_item = elm_multibuttonentry_item_append(bcc_mbe, addrs_info->display_name, NULL, NULL);
1768 mbe_item = elm_multibuttonentry_item_append(bcc_mbe, addrs_info->address, NULL, NULL);
1769 elm_object_item_data_set(mbe_item, addrs_info);
1775 static Evas_Object *_create_attach(EmailViewerUGD *ug_data)
1779 EmailViewerProp *prop = ug_data->property;
1780 char buff[MAX_STR_LEN];
1782 int att_len = prop->real_att_len;
1785 RETURN_VAL_IF_FAIL(prop->attachments != NULL, NULL);
1786 RETURN_VAL_IF_FAIL(att_len > 0, NULL);
1788 GList *attachment_list = prop->attachments;
1791 LIST_ITER_START(i, attachment_list) {
1792 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
1794 if (info && !info->inline_content) {
1795 if (info->size < 1024) {
1796 g_sprintf(buff, "%s (%d %s)", info->name, (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
1798 gdouble tmpsize = (gdouble) (info->size / 1024.);
1799 if (tmpsize < 1024) {
1800 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1803 if (tmpsize < 1024) {
1804 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1807 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1812 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1813 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_item");
1814 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1815 evas_object_show(di);
1816 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1818 Evas_Object *thumbnail = NULL;
1820 if (info->download_yn) {
1821 thumbnail = viewer_make_thumbnail(info->path, di);
1823 thumbnail = viewer_make_thumbnail(NULL, di);
1824 evas_object_size_hint_aspect_set(thumbnail, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1825 elm_icon_resizable_set(thumbnail, 1, 1);
1826 elm_object_part_content_set(di, "elm.icon", thumbnail);
1827 evas_object_show(thumbnail);
1829 elm_object_part_text_set(di, "elm.text", buff);
1833 Evas_Object *edje = elm_layout_edje_get(di);
1834 edje_object_signal_callback_add(edje, "elm,action,download", "elm", _attachment_save_cb, (void *)att_index);
1835 edje_object_signal_callback_add(edje, "clicked", "*", _attachment_clicked_cb, (void *)att_index);
1837 Evas_Object *text_bg = NULL;
1838 text_bg = (Evas_Object *)edje_object_part_object_get(_EDJ(di), "elm.event.rect");
1841 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_DOWN, _attachment_bg_set_cb, (void *)att_index);
1842 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_UP, _attachment_bg_unset_cb, (void *)att_index);
1845 ug_data->attach_hd_ly = di;
1846 ug_data->attach_hd_bk = di;
1849 } else if (att_len > 1) {
1850 gint64 total_size = prop->total_att_size;
1852 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1853 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_head");
1854 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1855 snprintf(buff, sizeof(buff), "%d %s", att_len, _("IDS_EMAIL_BODY_ATTACHMENTS"));
1857 Evas_Object *att_head_label;
1858 att_head_label = elm_label_add(di);
1859 elm_object_part_content_set(di, "elm.text", att_head_label);
1861 char *buff_tagged = g_strconcat("<font_size=35><color=#000000FF>", buff, "<color></font_size>", NULL);
1862 elm_object_text_set(att_head_label, buff_tagged);
1863 g_free(buff_tagged);
1865 if (total_size < 1024) {
1866 g_sprintf(buff, "(%d %s)", (gint) total_size, dgettext("sys_string", "IDS_COM_BODY_B"));
1868 gdouble tmpsize = (gdouble) (total_size / 1024.);
1870 if (tmpsize < 1024) {
1871 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1875 if (tmpsize < 1024) {
1876 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1879 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1884 edje_object_part_text_set(_EDJ(di), "elm.text.sub", buff);
1886 Evas_Object *edje = elm_layout_edje_get(di);
1887 edje_object_signal_callback_add(edje, "att,icon,save,all", "", _attachment_save_all_cb, di);
1888 edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _attachment_item_collapse_cb, di);
1889 evas_object_show(di);
1890 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1891 ug_data->attach_hd_ly = di;
1892 ug_data->attach_hd_bk = di;
1894 debug_log("Attachment doesn't exist");
1900 static Evas_Object *_create_attach_ex(EmailViewerUGD *ug_data)
1904 EmailViewerProp *prop = ug_data->property;
1905 char buff[MAX_STR_LEN];
1908 int att_len = prop->real_att_len;
1911 RETURN_VAL_IF_FAIL(prop->attachments != NULL, NULL);
1912 RETURN_VAL_IF_FAIL(att_len > 0, NULL);
1914 GList *attachment_list = prop->attachments;
1916 ug_data->attach_ex_ly = (Evas_Object **)calloc(att_len, sizeof(Evas_Object *));
1917 ug_data->attach_ex_bk = (Evas_Object **)calloc(att_len, sizeof(Evas_Object *));
1919 LIST_ITER_START(i, attachment_list) {
1920 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
1922 if (info && !info->inline_content) {
1923 if (info->size < 1024) {
1924 g_sprintf(buff, "%s (%d %s)", info->name, (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
1926 gdouble tmpsize = (gdouble) (info->size / 1024.);
1927 if (tmpsize < 1024) {
1928 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1931 if (tmpsize < 1024) {
1932 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1935 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1940 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1941 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_item");
1942 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1943 elm_box_pack_after(ug_data->main_bx, di, ug_data->attach_hd_ly);
1944 evas_object_show(di);
1946 Evas_Object *thumbnail = NULL;
1948 if (info->download_yn) {
1949 thumbnail = viewer_make_thumbnail(info->path, di);
1951 thumbnail = viewer_make_thumbnail(NULL, di);
1952 evas_object_size_hint_aspect_set(thumbnail, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1953 elm_icon_resizable_set(thumbnail, 1, 1);
1954 elm_object_part_content_set(di, "elm.icon", thumbnail);
1955 evas_object_show(thumbnail);
1957 elm_object_part_text_set(di, "elm.text", buff);
1961 Evas_Object *edje = elm_layout_edje_get(di);
1962 edje_object_signal_callback_add(edje, "elm,action,download", "elm", _attachment_save_cb, (void *)att_index);
1963 edje_object_signal_callback_add(edje, "clicked", "*", _attachment_clicked_cb, (void *)att_index);
1965 Evas_Object *text_bg = NULL;
1966 text_bg = (Evas_Object *)edje_object_part_object_get(_EDJ(di), "elm.event.rect");
1969 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_DOWN, _attachment_bg_set_cb, (void *)att_index);
1970 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_UP, _attachment_bg_unset_cb, (void *)att_index);
1973 debug_log("attach ly %d, att_index %d", j, i);
1975 ug_data->attach_ex_ly[j] = di;
1976 ug_data->attach_ex_bk[j] = di;
1985 static Evas_Object *_create_body(EmailViewerUGD *ug_data)
1988 EmailViewerProp *prop = ug_data->property;
1989 EmailViewerPrivate *priv = ug_data->email_data;
1993 if (ug_data->noc_bx) {
1994 elm_box_unpack(ug_data->main_bx, ug_data->noc_bx);
1995 evas_object_hide(ug_data->noc_bx);
1998 if (ug_data->dn_btn) {
1999 evas_object_hide(ug_data->dn_btn);
2002 if (ug_data->webview_bx) {
2003 _init_webview_data(ug_data);
2005 ewk_view_scale_set(ug_data->webview, 1.0f, 0, 0);
2007 if (prop->has_html) {
2009 ug_data->webview_data->body_type_prev = BODY_TYPE_HTML;
2010 ug_data->webview_data->body_type = BODY_TYPE_HTML;
2011 ug_data->webview_data->uri = prop->body_uri;
2014 ug_data->webview_data->body_type_prev = BODY_TYPE_TEXT;
2015 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
2016 ug_data->webview_data->text_content = prop->body;
2019 viewer_set_webview_content(ug_data, 0);
2021 evas_object_show(ug_data->webview_bx);
2022 evas_object_show(ug_data->webview);
2023 elm_box_pack_end(ug_data->main_bx, ug_data->webview_bx);
2025 _update_tab_bar(ug_data);
2027 /* create webview layout */
2028 ug_data->webview_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.web_view");
2029 if (ug_data->webview_bx == NULL) {
2030 debug_log("Cannot load edj");
2034 evas_object_size_hint_align_set(ug_data->webview_bx, EVAS_HINT_FILL, 0.0);
2035 evas_object_show(ug_data->webview_bx);
2036 elm_box_pack_end(ug_data->main_bx, ug_data->webview_bx);
2038 /* create webview */
2039 if (NULL == ug_data->webview) {
2040 _init_webview_data(ug_data);
2041 viewer_get_webview(ug_data, prop->has_html);
2043 if (prop->has_html) {
2044 ug_data->webview_data->body_type_prev = BODY_TYPE_HTML;
2045 ug_data->webview_data->body_type = BODY_TYPE_HTML;
2046 ug_data->webview_data->uri = prop->body_uri;
2048 ug_data->webview_data->body_type_prev = BODY_TYPE_TEXT;
2049 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
2050 ug_data->webview_data->text_content = prop->body;
2052 viewer_set_webview_content(ug_data, 0);
2055 evas_object_show(ug_data->webview);
2056 elm_object_part_content_set(ug_data->webview_bx, "web_body", ug_data->webview);
2060 if (ug_data->isRotate) {
2061 resized_w = ug_data->webview_width_landscape * ug_data->scale_factor;
2062 resized_h = ug_data->webview_height_landscape * ug_data->scale_factor;
2064 resized_w = ug_data->webview_width * ug_data->scale_factor;
2065 resized_h = ug_data->webview_height * ug_data->scale_factor;
2067 debug_log("resized_w:%d, resized_h:%d", resized_w, resized_h);
2069 evas_object_size_hint_min_set(ug_data->webview, resized_w, resized_h);
2071 /* set touch callbacks */
2072 evas_object_smart_callback_add(ug_data->webview, "policy,navigation,decide", _webview_policy_navigation_decide_cb, ug_data);
2073 evas_object_event_callback_add(ug_data->webview, EVAS_CALLBACK_MULTI_DOWN, _webview_multi_down_cb, ug_data);
2074 evas_object_event_callback_add(ug_data->webview, EVAS_CALLBACK_MULTI_UP, _webview_multi_up_cb, ug_data);
2076 /* update control Bar */
2077 _update_tab_bar(ug_data);
2080 viewer_set_mail_seen(prop, priv->mail_info);
2082 if (ug_data->timer) {
2083 ecore_timer_del(ug_data->timer);
2084 ug_data->timer = NULL;
2087 debug_log("send message - list unlock");
2088 ug_data->timer = ecore_timer_add(0.0, viewer_send_message, ug_data);
2090 return ug_data->webview_bx;
2093 static Evas_Object *_create_tab_bar(EmailViewerUGD *ug_data)
2097 EmailViewerProp *prop = ug_data->property;
2099 obj = elm_toolbar_add(ug_data->navi_bar);
2100 elm_toolbar_shrink_mode_set(obj, ELM_TOOLBAR_SHRINK_EXPAND);
2101 elm_object_style_set(obj, "naviframe");
2103 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX ||
2104 ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX) {
2105 int n_to_list = g_list_length(ug_data->to_list);
2106 int n_cc_list = g_list_length(ug_data->cc_list);
2107 debug_log("to:%d, cc:%d", n_to_list, n_cc_list);
2108 if (n_to_list + n_cc_list >= 2)
2109 ug_data->reply_ctr_it = elm_toolbar_item_append(obj, ICON_REPLY, dgettext("sys_string", "IDS_COM_SK_REPLY"), _reply_option_cb, ug_data);
2111 ug_data->reply_ctr_it = elm_toolbar_item_append(obj, ICON_REPLY, dgettext("sys_string", "IDS_COM_SK_REPLY"), _reply_cb, ug_data);
2112 ug_data->forward_ctr_it = elm_toolbar_item_append(obj, ICON_FORWARD, dgettext("sys_string", "IDS_COM_BODY_FORWARD"), _forward_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->more_ctr_it = elm_toolbar_item_append(obj, ICON_CONTROLBAR_MORE, dgettext("sys_string", "IDS_COM_SK_MORE"), _more_cb, ug_data);
2116 elm_object_item_disabled_set(ug_data->reply_ctr_it, EINA_TRUE);
2117 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_TRUE);
2118 } else if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_OUTBOX) {
2119 debug_log("save_status: %d", prop->status2);
2120 if (prop->status2 == EMAIL_MAIL_STATUS_SEND_FAILURE) {
2121 ug_data->resend_ctr_it = elm_toolbar_item_append(obj, ICON_RESEND, _("IDS_EMAIL_SK_RESEND"), _resend_cb, ug_data);
2122 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2124 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2127 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2128 ug_data->move_ctr_it = elm_toolbar_item_append(obj, ICON_MOVE, _("IDS_EMAIL_SK_MOVE"), _move_cb, ug_data);
2131 elm_object_item_part_content_set(ug_data->navi_main_it, "controlbar", obj);
2132 ug_data->ctr_bar = obj;
2137 static Evas_Object *_update_tab_bar(EmailViewerUGD *ug_data)
2141 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX ||
2142 ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX) {
2143 elm_object_item_disabled_set(ug_data->reply_ctr_it, EINA_FALSE);
2144 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_FALSE);
2150 static Evas_Object *_create_partial_body_dn_btn(EmailViewerUGD *ug_data)
2154 ug_data->partial_dn_btn_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.partial_download_btn");
2155 if (ug_data->partial_dn_btn_bx == NULL) {
2156 debug_log("Cannot load edj");
2160 evas_object_size_hint_align_set(ug_data->partial_dn_btn_bx, EVAS_HINT_FILL, 0.0);
2161 evas_object_show(ug_data->partial_dn_btn_bx);
2162 elm_box_pack_before(ug_data->main_bx, ug_data->partial_dn_btn_bx, ug_data->webview_bx);
2164 Evas_Object *dn_btn = elm_button_add(ug_data->navi_bar);
2165 elm_object_text_set(dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_FULL_MESSAGE"));
2166 evas_object_smart_callback_add(dn_btn, "clicked", _body_down_cb, (void *)ug_data);
2167 /*elm_object_theme_set(dn_btn, ug_data->theme);*/
2168 elm_object_style_set(dn_btn, "text_only/style2");
2169 evas_object_show(dn_btn);
2170 ug_data->partial_dn_btn = dn_btn;
2172 elm_object_part_content_set(ug_data->partial_dn_btn_bx, "button", ug_data->partial_dn_btn);
2174 return ug_data->partial_dn_btn_bx;
2177 static Evas_Object *_create_bg(Evas_Object *win)
2181 Evas_Object *bg = elm_bg_add(win);
2182 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2183 elm_win_resize_object_add(win, bg);
2184 evas_object_show(bg);
2189 static void _create_down_progress(char *message, popup_cb resp_cb)
2194 debug_log("data is NULL");
2198 EmailViewerUGD *ug_data = _g_ug_data;
2199 Evas_Object *notify, *pb;
2201 notify = elm_popup_add(ug_data->win_main);
2203 debug_log("elm_popup_add returns NULL");
2206 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2207 ug_data->pb_notify = notify;
2209 elm_object_part_text_set(notify, "title,text", message);
2211 pb = elm_progressbar_add(notify);
2213 elm_object_style_set(pb, "list_progress");
2215 elm_progressbar_horizontal_set(pb, EINA_TRUE);
2216 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, EVAS_HINT_FILL);
2217 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2218 evas_object_show(pb);
2219 elm_progressbar_value_set(pb, 0.0);
2220 elm_object_content_set(notify, pb);
2221 ug_data->pb_notify_lb = pb;
2223 Evas_Object *btn1 = elm_button_add(notify);
2224 elm_object_style_set(btn1, "popup_button/default");
2225 elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
2226 elm_object_part_content_set(notify, "button1", btn1);
2227 evas_object_smart_callback_add(btn1, "clicked", resp_cb, ug_data);
2228 debug_log("Cancel btn1 for downloading body: %p", btn1);
2230 evas_object_show(notify);
2233 static void _create_down_progress_ex(int index, EMAIL_VIEWER_PROGRESSBAR_TYPE p_type)
2238 debug_log("data is NULL");
2242 EmailViewerUGD *ug_data = _g_ug_data;
2243 EmailViewerProp *prop = ug_data->property;
2244 EmailViewerPrivate *priv = ug_data->email_data;
2246 if (!prop || !prop->attachments) {
2256 if (ug_data->forward_ctr_it)
2257 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_TRUE);
2263 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
2264 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
2266 GList *attachment_list = prop->attachments;
2268 debug_log("index %d of attachment_count %d", index, prop->att_len);
2270 EmailAttachmentType *info = NULL;
2271 info = g_list_nth_data(attachment_list, index);
2273 debug_log("info is NULL");
2276 Evas_Object *pbar_ly = elm_layout_add(ug_data->navi_bar);
2277 elm_layout_file_set(pbar_ly, EV_THEME_PATH, "layout.email.attachment_downloading");
2278 evas_object_size_hint_align_set(pbar_ly, EVAS_HINT_FILL, 0.0);
2279 evas_object_show(pbar_ly);
2280 ug_data->progress_bar_ly[index + 1] = pbar_ly;
2283 char buff[MAX_STR_LEN] = { 0, };
2285 Evas_Object *downloading_label1;
2286 downloading_label1 = elm_label_add(pbar_ly);
2287 elm_object_part_content_set(pbar_ly, "elm.text.1", downloading_label1);
2288 char *text_tagged = g_strconcat("<font_size=32><align=left><color=#000000FF>", info->name, "</color></align></font_size>", NULL);
2289 elm_object_text_set(downloading_label1, text_tagged);
2290 elm_label_ellipsis_set(downloading_label1, EINA_TRUE);
2291 elm_label_wrap_width_set(downloading_label1, ug_data->main_w - 240);
2292 g_free(text_tagged);
2294 if (info->size < 1024) {
2295 g_sprintf(buff, "%d %s", (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
2297 gdouble tmpsize = (gdouble) (info->size / 1024.);
2299 if (tmpsize < 1024) {
2300 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
2304 if (tmpsize < 1024) {
2305 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
2308 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
2313 Evas_Object *downloading_label3;
2314 downloading_label3 = elm_label_add(pbar_ly);
2315 elm_object_part_content_set(pbar_ly, "elm.text.3", downloading_label3);
2316 text_tagged = g_strconcat("<font_size=26><align=right><color=#646464FF>", buff, "</color></align></font_size>", NULL);
2317 elm_object_text_set(downloading_label3, text_tagged);
2318 g_free(text_tagged);
2321 Evas_Object *progressbar = elm_progressbar_add(pbar_ly);
2322 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
2323 elm_object_style_set(progressbar, "list_progress");
2324 elm_object_part_content_set(pbar_ly, "elm.icon.2", progressbar);
2325 ug_data->progress_bar[index + 1] = progressbar;
2326 evas_object_show(progressbar);
2328 Evas_Object *cancel_btn = elm_button_add(pbar_ly);
2329 /*elm_object_theme_set(cancel_btn, ug_data->theme);*/
2330 elm_object_style_set(cancel_btn, "text_only/style2");
2331 elm_object_text_set(cancel_btn, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
2333 elm_object_part_content_set(pbar_ly, "elm.icon.1", cancel_btn);
2334 evas_object_show(cancel_btn);
2335 evas_object_smart_callback_add(cancel_btn, "clicked", _destroy_down_progress_ex, (void *)index);
2336 debug_log("Cancel button for attachment downloading progress popup: %p", cancel_btn);
2338 /* packing progress layout */
2339 if (p_type == EMAIL_VIEWER_PROGRESSBAR_ATT && prop->real_att_len > 1) {
2340 for (i = 0; i < prop->att_len; i++) {
2341 info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2342 if (info && !info->inline_content) {
2344 if (ug_data->attach_ex_ly != NULL && ug_data->attach_ex_ly[j] != NULL) {
2346 elm_box_pack_after(ug_data->main_bx, pbar_ly, ug_data->attach_ex_ly[j]);
2347 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[j]);
2348 evas_object_hide(ug_data->attach_ex_ly[j]);
2349 ug_data->attach_ex_ly[j] = pbar_ly;
2356 if ((p_type == EMAIL_VIEWER_PROGRESSBAR_ATT && prop->real_att_len == 1) || (p_type == EMAIL_VIEWER_PROGRESSBAR_ATT_ALL)) {
2358 elm_box_pack_after(ug_data->main_bx, pbar_ly, ug_data->attach_hd_ly);
2359 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2360 evas_object_hide(ug_data->attach_hd_ly);
2361 ug_data->attach_hd_ly = pbar_ly;
2364 elm_object_focus_set(pbar_ly, EINA_TRUE);
2365 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
2368 static void _destroy_down_progress_ex(void *data, Evas_Object *obj, void *event_info)
2373 debug_log("data is NULL");
2377 EmailViewerUGD *ug_data = _g_ug_data;
2378 EmailViewerPrivate *priv = ug_data->email_data;
2379 EmailViewerProp *prop = ug_data->property;
2381 if (!prop || !prop->attachments) {
2395 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
2396 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
2398 GList *attachment_list = prop->attachments;
2399 int index = (int)data;
2402 /* Cancel the download in email-service */
2404 debug_log("index[%d] download_all_cnt[%d] email_handle[%d]", index, priv->download_all_cnt, priv->download_all_email_handle[index]);
2405 if (priv->download_all_email_handle[index] != 0) {
2406 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[index]);
2407 priv->download_all_email_handle[index] = 0;
2410 (priv->download_all_cnt)--;
2412 if (priv->download_all_cnt == 0)
2413 priv->b_all_att_save = FALSE;
2414 } else if (index == -1) {
2415 for (i = 0; i < prop->att_len; i++) {
2416 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2417 if (info && !info->inline_content) {
2418 debug_log("index[%d] download_all_cnt[%d] email_handle[%d]", i, priv->download_all_cnt, priv->download_all_email_handle[i]);
2419 if (priv->download_all_email_handle[i] != 0) {
2420 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[i]);
2423 priv->download_all_email_handle[i] = 0;
2425 priv->download_all_cnt = 0;
2426 priv->b_all_att_save = FALSE;
2429 /* upack and delete, pack again */
2431 debug_log("real_att_len:%d", prop->real_att_len);
2432 if (prop->real_att_len == 1) {
2433 debug_log("index[%d]", index);
2434 elm_box_pack_after(ug_data->main_bx, ug_data->attach_hd_bk, ug_data->attach_hd_ly);
2435 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2436 evas_object_del(ug_data->attach_hd_ly);
2437 ug_data->attach_hd_ly = ug_data->attach_hd_bk;
2438 evas_object_show(ug_data->attach_hd_ly);
2439 elm_object_focus_set(ug_data->attach_hd_ly, EINA_TRUE);
2440 ug_data->progress_bar[index + 1] = NULL;
2441 ug_data->progress_bar_ly[index + 1] = NULL;
2442 } else if (prop->real_att_len > 1) {
2443 for (i = 0; i < prop->att_len; i++) {
2444 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2445 if (info && !info->inline_content) {
2447 debug_log("index[%d]", i);
2448 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
2449 if (ug_data->attach_onoff_flag > 0) {
2450 elm_box_pack_after(ug_data->main_bx, ug_data->attach_ex_bk[j], ug_data->attach_ex_ly[j]);
2451 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[j]);
2452 evas_object_del(ug_data->attach_ex_ly[j]);
2453 ug_data->attach_ex_ly[j] = ug_data->attach_ex_bk[j];
2454 evas_object_show(ug_data->attach_ex_ly[j]);
2455 elm_object_focus_set(ug_data->attach_ex_ly[j], EINA_TRUE);
2456 ug_data->progress_bar[index + 1] = NULL;
2457 ug_data->progress_bar_ly[index + 1] = NULL;
2459 evas_object_del(ug_data->attach_ex_ly[j]);
2460 ug_data->attach_ex_ly[j] = ug_data->attach_ex_bk[j];
2461 ug_data->progress_bar[index + 1] = NULL;
2462 ug_data->progress_bar_ly[index + 1] = NULL;
2469 } else if (index == -1) {
2470 debug_log("index[%d]", index);
2471 elm_box_pack_after(ug_data->main_bx, ug_data->attach_hd_bk, ug_data->attach_hd_ly);
2472 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2473 evas_object_del(ug_data->attach_hd_ly);
2474 ug_data->attach_hd_ly = ug_data->attach_hd_bk;
2475 evas_object_show(ug_data->attach_hd_ly);
2476 elm_object_focus_set(ug_data->attach_hd_ly, EINA_TRUE);
2477 ug_data->progress_bar[index + 1] = NULL;
2478 ug_data->progress_bar_ly[index + 1] = NULL;
2481 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
2483 if (priv && priv->download_all_cnt <= 0) {
2484 if (ug_data->forward_ctr_it)
2485 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_FALSE);
2489 static void _create_more_ctxpopup(EmailViewerUGD *ug_data)
2493 debug_log("ug_data is NULL");
2497 EmailViewerProp *prop = ug_data->property;
2498 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
2499 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, prop->sender);
2501 if (ug_data->con_popup) {
2502 evas_object_del(ug_data->con_popup);
2503 ug_data->con_popup = NULL;
2506 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
2507 if (ug_data->con_popup == NULL) {
2508 debug_log("cannot create context popup");
2512 if (contact_list_item) {
2513 debug_log("Contact Item Exist: index[%d]", contact_list_item->index);
2514 char index[10] = { 0, };
2515 snprintf(index, sizeof(index), "%d", contact_list_item->index);
2517 if (email_engine_check_seen_mail(ug_data->account_id, ug_data->mail_id))
2518 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_UNREAD"), NULL, _mark_as_unread_cb, ug_data);
2520 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_READ"), NULL, _mark_as_read_cb, ug_data);
2522 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, _move_cb, ug_data);
2523 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SAVE_EMAIL_ABB"), NULL, _save_email_cb, ug_data);
2524 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_VIEW_CONTACT"), NULL, _ctxpopup_detail_contact_cb, g_strdup(index));
2525 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_ADD_TO_CALENDAR"), NULL, _add_to_calendar_cb, ug_data);
2526 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);
2528 _delete_contacts_list(contact_list_item);
2530 if (email_engine_check_seen_mail(ug_data->account_id, ug_data->mail_id))
2531 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_UNREAD"), NULL, _mark_as_unread_cb, ug_data);
2533 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_READ"), NULL, _mark_as_read_cb, ug_data);
2535 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, _move_cb, ug_data);
2536 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SAVE_EMAIL_ABB"), NULL, _save_email_cb, ug_data);
2537 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);
2538 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_ADD_TO_CALENDAR"), NULL, _add_to_calendar_cb, ug_data);
2539 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);
2543 email_rule_t *rule_list = NULL;
2545 /* get the rule list from service */
2546 if (email_get_rule_list(&rule_list, &count) < 0) {
2547 debug_log("email_get_rule_list failed");
2550 for (i = 0; i < count; i++) {
2551 if (rule_list[i].type == EMAIL_FILTER_FROM) {
2552 debug_log("block address %s", rule_list[i].value);
2554 if (g_strcmp0(rule_list[i].value, prop->sender) == 0) {
2555 debug_log("[%s] already blocked", rule_list[i].value);
2556 if (ug_data->more_ctx_block_item)
2557 elm_object_item_disabled_set(ug_data->more_ctx_block_item, EINA_TRUE);
2562 /* free email rule_list */
2563 email_free_rule(&rule_list, count);
2566 Evas_Coord x, y, w, h;
2567 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
2568 // evas_object_move(ug_data->con_popup, x, y - 20);
2569 evas_object_geometry_get(ug_data->ctr_bar, &x, &y, &w, &h);
2570 debug_log("x:%d, y:%d, w:%d, h:%d, mx:%d", x, y, w, h, ((w - x) * 6) / 7);
2571 evas_object_move(ug_data->con_popup, ((w - x) * 6) / 7 , y);
2572 evas_object_show(ug_data->con_popup);
2575 static void _create_reply_ctxpopup(EmailViewerUGD *ug_data)
2579 debug_log("ug_data is NULL");
2583 if (ug_data->con_popup) {
2584 evas_object_del(ug_data->con_popup);
2585 ug_data->con_popup = NULL;
2588 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
2589 if (ug_data->con_popup == NULL) {
2590 debug_log("cannot create context popup");
2594 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_TO_SENDER_ABB"), NULL, _reply_cb, ug_data);
2595 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_TO_ALL_ABB"), NULL, _reply_all_cb, ug_data);
2598 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
2599 evas_object_move(ug_data->con_popup, x, y - 20);
2600 evas_object_show(ug_data->con_popup);
2603 static void _delete_evas_objects(EmailViewerUGD *ug_data)
2606 EmailViewerProp *prop = ug_data->property;
2608 if (ug_data->webview) {
2609 evas_object_del(ug_data->webview);
2610 ug_data->webview = NULL;
2613 if (ug_data->webview_bx) {
2614 evas_object_del(ug_data->webview_bx);
2615 ug_data->webview_bx = NULL;
2618 if (ug_data->scroller) {
2619 evas_object_del(ug_data->scroller);
2620 ug_data->scroller = NULL;
2623 if (ug_data->main_bx) {
2624 evas_object_del(ug_data->main_bx);
2625 ug_data->main_bx = NULL;
2628 if (ug_data->b_btn) {
2629 evas_object_del(ug_data->b_btn);
2630 ug_data->b_btn = NULL;
2633 if (ug_data->sub_ly) {
2634 evas_object_del(ug_data->sub_ly);
2635 ug_data->sub_ly = NULL;
2638 if (ug_data->navi_bar) {
2639 evas_object_del(ug_data->navi_bar);
2640 ug_data->navi_bar = NULL;
2643 if (ug_data->ctr_bar) {
2644 evas_object_del(ug_data->ctr_bar);
2645 ug_data->ctr_bar = NULL;
2648 if (ug_data->layout_main) {
2649 evas_object_del(ug_data->layout_main);
2650 ug_data->layout_main = NULL;
2653 if (ug_data->con_popup) {
2654 evas_object_del(ug_data->con_popup);
2655 ug_data->con_popup = NULL;
2658 if (ug_data->select_info) {
2659 evas_object_del(ug_data->select_info);
2660 ug_data->select_info = NULL;
2663 if (ug_data->selectioninfo_layout != NULL) {
2664 evas_object_del(ug_data->selectioninfo_layout);
2665 ug_data->selectioninfo_layout = NULL;
2668 if (ug_data->notify) {
2669 evas_object_del(ug_data->notify);
2670 ug_data->notify = NULL;
2673 if (ug_data->pb_notify) {
2674 evas_object_del(ug_data->pb_notify);
2675 ug_data->pb_notify = NULL;
2678 if (ug_data->pb_notify_lb) {
2679 evas_object_del(ug_data->pb_notify_lb);
2680 ug_data->pb_notify_lb = NULL;
2683 if (ug_data->partial_dn_btn) {
2684 evas_object_del(ug_data->partial_dn_btn);
2685 ug_data->partial_dn_btn = NULL;
2688 if (ug_data->partial_dn_btn_bx) {
2689 evas_object_del(ug_data->partial_dn_btn_bx);
2690 ug_data->partial_dn_btn_bx = NULL;
2693 if (ug_data->waiting_timer) {
2694 ecore_timer_del(ug_data->waiting_timer);
2695 ug_data->waiting_timer = NULL;
2698 if (ug_data->timer) {
2699 ecore_timer_del(ug_data->timer);
2700 ug_data->timer = NULL;
2703 if (ug_data->idler) {
2704 ecore_idler_del(ug_data->idler);
2705 ug_data->idler = NULL;
2708 if (ug_data->got_att) {
2711 evas_object_del(ug_data->attach_hd_bk);
2712 ug_data->attach_hd_ly = NULL;
2713 ug_data->attach_hd_bk = NULL;
2715 if (prop->real_att_len > 1) {
2716 for (i = 0; i < prop->real_att_len; i++) {
2717 if (ug_data->attach_ex_ly != NULL) {
2718 if (ug_data->attach_ex_ly[i] != NULL) {
2719 debug_log("index %d", i);
2720 evas_object_del(ug_data->attach_ex_bk[i]);
2721 ug_data->attach_ex_ly[i] = NULL;
2722 ug_data->attach_ex_bk[i] = NULL;
2727 if (ug_data->attach_ex_ly != NULL) {
2728 free(ug_data->attach_ex_ly);
2729 ug_data->attach_ex_ly = NULL;
2730 ug_data->attach_ex_bk = NULL;
2734 for (i = 0; i <= prop->att_len; i++) {
2735 if (ug_data->progress_bar_ly[i] != NULL) {
2736 evas_object_del(ug_data->progress_bar_ly[i]);
2737 ug_data->progress_bar_ly[i] = NULL;
2738 ug_data->progress_bar[i] = NULL;
2744 void _launch_composer(EmailViewerUGD *ug_data, int type)
2749 debug_log("ug_data is NULL");
2753 EmailViewerPrivate *priv = ug_data->email_data;
2757 service_h service = NULL;
2759 ret = service_create(&service);
2760 debug_log("service_create: %d", ret);
2762 debug_log("service create failed");
2766 char rtype[10] = { 0, };
2767 snprintf(rtype, sizeof(rtype), "%d", type);
2768 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
2769 debug_log("service_add_extra_data: %d", ret);
2771 memset(tmp, 0x0, sizeof(tmp));
2772 snprintf(tmp, sizeof(tmp), "%d", priv->account_id);
2773 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_ACCOUNT_ID, tmp);
2774 debug_log("service_add_extra_data: %d", ret);
2776 memset(tmp, 0x0, sizeof(tmp));
2777 snprintf(tmp, sizeof(tmp), "%d", priv->mailbox_id);
2778 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MAILBOX, tmp);
2779 debug_log("service_add_extra_data: %d", ret);
2781 memset(tmp, 0x0, sizeof(tmp));
2782 snprintf(tmp, sizeof(tmp), "%d", priv->mail_id);
2783 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MAIL_ID, tmp);
2784 debug_log("service_add_extra_data: %d", ret);
2786 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
2788 ret = service_destroy(service);
2789 debug_log("service_destroy: %d", ret);
2792 static void _launch_vcs_editor(EmailViewerUGD *ug_data)
2797 debug_log("ug_data is NULL");
2801 char account_id[MAX_STR_LEN] = { 0, };
2802 char mail_id[MAX_STR_LEN] = { 0, };
2804 EmailViewerProp *prop = ug_data->property;
2807 service_h service = NULL;
2809 ret = service_create(&service);
2810 debug_log("service_create: %d", ret);
2812 debug_log("service create failed");
2816 snprintf(account_id, sizeof(account_id), "%d", prop->account_id);
2817 snprintf(mail_id, sizeof(mail_id), "%d", prop->mail_id);
2819 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_ACCOUNT_ID, account_id);
2820 debug_log("service_add_extra_data: %d", ret);
2821 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_MAIL_ID, mail_id);
2822 debug_log("service_add_extra_data: %d", ret);
2823 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_SRC_BOX, prop->src_box);
2824 debug_log("service_add_extra_data: %d", ret);
2825 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_INDEX, EMAIL_BUNDLE_VAL_CALENDAR_EDIT_INDEX);
2826 debug_log("service_add_extra_data: %d", ret);
2827 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_NOTE, prop->subject);
2828 debug_log("service_add_extra_data: %d", ret);
2830 ug_data->ug_calendar_edit = create_ug(UG_NAME_CALENDAR_EDIT, service, ug_data);
2832 ret = service_destroy(service);
2833 debug_log("service_destroy: %d", ret);
2836 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
2840 if (_g_ug_data == NULL) {
2841 debug_log("_g_ug_data is NULL");
2846 debug_log("data is NULL");
2849 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2851 if (ug_data->con_popup != NULL) {
2852 evas_object_del(ug_data->con_popup);
2853 ug_data->con_popup = NULL;
2856 debug_log("isRoate = %d", ug_data->isRotate);
2857 if (ug_data->isRotate == false && ug_data->b_internal) {
2858 /* Viewer to hide, so set left content (mailbox) size to full */
2859 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
2862 if (ug_data->b_internal != 1) {
2863 debug_log("ug_destory_me");
2864 ug_destroy_me(ug_data->ug);
2866 _hide_view(ug_data);
2870 static void _prev_mail_cb(void *data, Evas_Object *obj, void *event_info)
2874 debug_log("data is NULL");
2878 /* send next or previous mail request to mailbox. */
2880 service_h service = NULL;
2882 ret = service_create(&service);
2883 debug_log("service_create: %d", ret);
2885 debug_log("service create failed");
2889 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_PREV_MSG);
2890 debug_log("service_add_extra_data: %d", ret);
2891 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "0");
2892 debug_log("service_add_extra_data: %d", ret);
2894 ug_send_message(_g_mailbox_ug, service);
2896 ret = service_destroy(service);
2897 debug_log("service_destroy: %d", ret);
2900 static void _next_mail_cb(void *data, Evas_Object *obj, void *event_info)
2904 debug_log("data is NULL");
2908 /* send next or previous mail request to mailbox. */
2910 service_h service = NULL;
2912 ret = service_create(&service);
2913 debug_log("service_create: %d", ret);
2915 debug_log("service create failed");
2919 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
2920 debug_log("service_add_extra_data: %d", ret);
2921 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "0");
2922 debug_log("service_add_extra_data: %d", ret);
2924 ug_send_message(_g_mailbox_ug, service);
2926 ret = service_destroy(service);
2927 debug_log("service_destroy: %d", ret);
2930 static void _reply_cb(void *data, Evas_Object *obj, void *event_info)
2934 debug_log("data is NULL");
2938 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2940 if (ug_data->con_popup) {
2941 evas_object_del(ug_data->con_popup);
2942 ug_data->con_popup = NULL;
2945 ug_data->display_download_result = FALSE;
2947 _launch_composer(ug_data, RUN_COMPOSER_REPLY);
2949 if (ug_data->notify) {
2950 evas_object_del(ug_data->notify);
2951 ug_data->notify = NULL;
2955 static void _reply_all_cb(void *data, Evas_Object *obj, void *event_info)
2959 debug_log("data is NULL");
2963 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2965 if (ug_data->con_popup) {
2966 evas_object_del(ug_data->con_popup);
2967 ug_data->con_popup = NULL;
2970 ug_data->display_download_result = FALSE;
2972 _launch_composer(ug_data, RUN_COMPOSER_REPLY_ALL);
2974 if (ug_data->notify) {
2975 evas_object_del(ug_data->notify);
2976 ug_data->notify = NULL;
2980 static void _reply_option_cb(void *data, Evas_Object *obj, void *event_info)
2984 debug_log("data is NULL");
2988 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2990 _create_reply_ctxpopup(ug_data);
2993 static void _forward_cb(void *data, Evas_Object *obj, void *event_info)
2997 debug_log("data is NULL");
3001 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3003 ug_data->display_download_result = FALSE;
3005 _launch_composer(ug_data, RUN_COMPOSER_FORWARD);
3008 static void _add_to_calendar_cb(void *data, Evas_Object *obj, void *event_info)
3015 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3017 if (ug_data->con_popup) {
3018 evas_object_del(ug_data->con_popup);
3019 ug_data->con_popup = NULL;
3022 _launch_vcs_editor(ug_data);
3025 static void _resend_cb(void *data, Evas_Object *obj, void *event_info)
3030 static void _delete_cb(void *data, Evas_Object *obj, void *event_info)
3034 debug_log("data is NULL");
3038 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3040 if (ug_data->con_popup) {
3041 evas_object_del(ug_data->con_popup);
3042 ug_data->con_popup = NULL;
3045 _create_notify(ug_data, NULL, dgettext("sys_string", "IDS_COM_POP_DELETE_Q"),
3046 2, dgettext("sys_string", "IDS_COM_SK_DELETE"),
3047 _popup_response_delete_ok_cb, dgettext("sys_string", "IDS_COM_SK_CANCEL"),
3048 _popup_response_cb, NULL);
3051 static void _move_cb(void *data, Evas_Object *obj, void *event_info)
3055 debug_log("data is NULL");
3059 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3060 EmailViewerPrivate *priv = ug_data->email_data;
3062 if (ug_data->con_popup) {
3063 evas_object_del(ug_data->con_popup);
3064 ug_data->con_popup = NULL;
3067 Evas_Object *gl = elm_genlist_add(ug_data->navi_bar);
3068 evas_object_show(gl);
3070 ug_data->itc1.item_style = "1text.1icon.2";
3071 ug_data->itc1.func.text_get = _gl_text_get;
3072 ug_data->itc1.func.content_get = _gl_content_get;
3073 ug_data->itc1.func.state_get = _gl_state_get;
3074 ug_data->itc1.func.del = _gl_del;
3076 Elm_Object_Item *navi_it = NULL;
3077 navi_it = elm_naviframe_item_push(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, NULL, gl, NULL);
3078 ug_data->navi_move_it1 = navi_it;
3079 if (ug_data->isRotate)
3080 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_FALSE);
3082 email_mailbox_t *mailbox_list = NULL;
3083 int mailbox_count = 0;
3086 email_get_mailbox_list(priv->account_id, -1, &mailbox_list, &mailbox_count);
3087 debug_log("folder count %d", mailbox_count);
3088 ug_data->move_mailbox_list = mailbox_list;
3089 ug_data->move_mailbox_count = mailbox_count;
3091 for (i = 0; i < mailbox_count; i++) {
3092 if (g_strcmp0(ug_data->mailbox_name, mailbox_list[i].mailbox_name) != 0) {
3093 if (mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_OUTBOX &&
3094 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_SENTBOX &&
3095 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_DRAFT &&
3096 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_TRASH &&
3097 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_ALL_EMAILS &&
3098 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_SEARCH_RESULT)
3099 if (g_strcmp0(mailbox_list[i].alias, "[Gmail]")) {
3100 elm_genlist_item_append(gl, &ug_data->itc1, (void *)&(mailbox_list[i]), NULL, ELM_GENLIST_ITEM_NONE, _move_here_cb, (void *)&(mailbox_list[i]));
3105 /*if (ug_data->b_internal)
3106 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "noindicator");
3108 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "default");*/
3110 Evas_Object *move_back_btn = NULL;
3111 if (ug_data->isRotate) {
3112 ug_data->move_cbar = elm_toolbar_add(ug_data->navi_bar);
3113 elm_toolbar_shrink_mode_set(ug_data->move_cbar, ELM_TOOLBAR_SHRINK_EXPAND);
3114 elm_object_style_set(ug_data->move_cbar, "naviframe");
3115 evas_object_show(ug_data->move_cbar);
3117 elm_object_item_disabled_set(elm_toolbar_item_append(ug_data->move_cbar, NULL, "", NULL, NULL), EINA_TRUE);
3118 elm_toolbar_item_append(ug_data->move_cbar, NULL, dgettext("sys_string", "IDS_COM_SK_CANCEL"), _move_back_cb, ug_data);
3119 elm_object_item_part_content_set(navi_it, "controlbar", ug_data->move_cbar);
3121 move_back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
3122 if (move_back_btn) {
3123 evas_object_del(move_back_btn);
3124 elm_object_item_part_content_set(navi_it, "prev_btn", NULL);
3127 move_back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
3128 if (move_back_btn) {
3129 evas_object_del(move_back_btn);
3130 move_back_btn = elm_button_add(ug_data->navi_bar);
3131 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
3132 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb, ug_data);
3133 elm_object_item_part_content_set(navi_it, "prev_btn", move_back_btn);
3138 static void _more_cb(void *data, Evas_Object *obj, void *event_info)
3142 debug_log("data is NULL");
3146 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3148 _create_more_ctxpopup(ug_data);
3151 static void _body_down_cb(void *data, Evas_Object *obj, void *event_info)
3155 debug_log("data is NULL");
3161 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3162 EmailViewerPrivate *priv = ug_data->email_data;
3164 /* check already downloaded */
3165 int body_download_status = ug_data->property->body_download;
3167 if (body_download_status == 0) { //EMAIL_BODY_DOWNLOAD_STATUS_NONE
3168 debug_log("only header downloaded -> need body download");
3169 } else if (body_download_status == 1) { //EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED
3170 debug_log("already downloaded fully, create body directly");
3173 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
3175 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
3178 if (ug_data->b_partial_body) {
3183 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
3184 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
3186 elm_box_unpack(ug_data->main_bx, ug_data->partial_dn_btn_bx);
3187 if (ug_data->partial_dn_btn) {
3188 evas_object_del(ug_data->partial_dn_btn);
3189 ug_data->partial_dn_btn = NULL;
3191 if (ug_data->partial_dn_btn_bx) {
3192 evas_object_del(ug_data->partial_dn_btn_bx);
3193 ug_data->partial_dn_btn_bx = NULL;
3196 if (ug_data->property->has_html) {
3197 ug_data->webview_data->body_type = BODY_TYPE_HTML;
3198 ug_data->webview_data->uri = ug_data->property->body_uri;
3200 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
3201 ug_data->webview_data->text_content = ug_data->property->body;
3204 viewer_set_webview_content(ug_data, 1);
3205 ug_data->b_partial_body = 0;
3207 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
3208 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
3210 if (ug_data->property->has_attachment)
3211 ug_data->got_att = 1;
3213 ug_data->got_att = 0;
3215 /* pack attachment if it exist */
3216 if (ug_data->got_att) {
3217 _create_attach(ug_data);
3220 _create_body(ug_data);
3224 } else if (body_download_status == 2) { //EMAILL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED
3225 debug_log("body downloaded partially -> need full body download");
3228 ret = email_engine_body_download(priv->account_id, priv->mail_id, &handle);
3231 priv->email_handle = handle;
3232 debug_log("succeed in email_engine_body_download");
3233 _create_down_progress(dgettext("sys_string", "IDS_COM_POP_DOWNLOADING"), _destroy_down_progress_cb);
3235 /* If attachment download is in progress, first cancel to attachment download of the mail and then carry out body download */
3236 _cancel_download_attachment(ug_data);
3239 debug_log("unable to download mail body");
3240 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
3241 _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), 1,
3242 dgettext("sys_string", "IDS_COM_SK_OK"),
3243 _popup_response_cb, NULL, NULL, NULL);
3247 static void _subject_favorite_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3251 debug_log("data is NULL");
3255 EmailViewerUGD *ug_data = _g_ug_data;
3256 EmailViewerProp *prop = ug_data->property;
3257 int err = EMAIL_ERROR_NONE;
3259 if (ug_data->con_popup) {
3260 evas_object_del(ug_data->con_popup);
3261 ug_data->con_popup = NULL;
3264 debug_log("Before prop->favorite: %d", prop->favorite);
3265 switch(prop->favorite) {
3266 case EMAIL_FLAG_NONE:
3267 prop->favorite = EMAIL_FLAG_FLAGED;
3269 case EMAIL_FLAG_FLAGED:
3270 prop->favorite = EMAIL_FLAG_NONE;
3272 case EMAIL_FLAG_TASK_STATUS_CLEAR:
3273 prop->favorite = EMAIL_FLAG_TASK_STATUS_ACTIVE;
3275 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
3276 prop->favorite = EMAIL_FLAG_TASK_STATUS_COMPLETE;
3278 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
3279 prop->favorite = EMAIL_FLAG_TASK_STATUS_CLEAR;
3282 debug_log("Never here");
3284 debug_log("After prop->favorite: %d", prop->favorite);
3286 err = email_set_flags_field(ug_data->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_FLAGGED_FIELD, prop->favorite, 1);
3287 if (err != EMAIL_ERROR_NONE) {
3288 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3289 N_("Failed to set favourite"), 0,
3290 NULL, NULL, NULL, NULL, _popup_response_cb);
3294 evas_object_del(elm_object_part_content_unset(ug_data->ly_subject, "elm.icon.favorite"));
3295 Evas_Object *favorite_icon = elm_icon_add(ug_data->ly_subject);
3296 switch(prop->favorite)
3298 case EMAIL_FLAG_NONE:
3299 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_off.png", NULL);
3301 case EMAIL_FLAG_FLAGED:
3302 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_on.png", NULL);
3304 case EMAIL_FLAG_TASK_STATUS_CLEAR:
3305 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
3307 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
3308 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
3310 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
3311 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
3314 debug_log("Never here");
3316 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
3317 elm_icon_resizable_set(favorite_icon, 1, 1);
3318 elm_object_part_content_set(ug_data->ly_subject, "elm.icon.favorite", favorite_icon);
3319 evas_object_show(favorite_icon);
3322 static void _subject_detail_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3326 debug_log("data is NULL");
3330 Evas_Object *item = (Evas_Object *)data;
3331 EmailViewerUGD *ug_data = _g_ug_data;
3333 if (!(ug_data->subject_onoff_flag)) {
3334 edje_object_signal_emit(_EDJ(item), "elm,state,expanded", "elm");
3335 (ug_data->subject_onoff_flag)++;
3337 _create_to_addrs(ug_data);
3338 _create_cc_addrs(ug_data);
3339 _create_bcc_addrs(ug_data);
3341 edje_object_signal_emit(_EDJ(item), "elm,state,contracted", "elm");
3342 (ug_data->subject_onoff_flag)--;
3344 if (ug_data->to_ly) {
3345 elm_box_unpack(ug_data->main_bx, ug_data->to_ly);
3346 evas_object_del(ug_data->to_ly);
3347 ug_data->to_ly = NULL;
3349 if (ug_data->cc_ly) {
3350 elm_box_unpack(ug_data->main_bx, ug_data->cc_ly);
3351 evas_object_del(ug_data->cc_ly);
3352 ug_data->cc_ly = NULL;
3354 if (ug_data->bcc_ly) {
3355 elm_box_unpack(ug_data->main_bx, ug_data->bcc_ly);
3356 evas_object_del(ug_data->bcc_ly);
3357 ug_data->bcc_ly = NULL;
3360 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
3364 static void _attachment_item_collapse_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3367 if (!data || !_g_ug_data) {
3368 debug_log("data is NULL");
3372 Evas_Object *item = (Evas_Object *)data;
3373 EmailViewerUGD *ug_data = _g_ug_data;
3374 EmailViewerProp *prop = ug_data->property;
3377 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
3378 if (!(ug_data->attach_onoff_flag)) {
3379 debug_log("attachments expanded");
3380 edje_object_signal_emit(_EDJ(item), "elm,state,expanded", "elm");
3381 (ug_data->attach_onoff_flag)++;
3383 if (ug_data->attach_ex_ly == NULL)
3384 _create_attach_ex(ug_data);
3386 for (i = 0; i < prop->real_att_len; i++) {
3387 debug_log("index %d", i);
3388 elm_box_pack_after(ug_data->main_bx, ug_data->attach_ex_ly[i], ug_data->attach_hd_ly);
3389 evas_object_show(ug_data->attach_ex_ly[i]);
3393 debug_log("attachments contracted");
3394 edje_object_signal_emit(_EDJ(item), "elm,state,contracted", "elm");
3395 ug_data->attach_onoff_flag = 0;
3397 for (i = 0; i < prop->real_att_len; i++) {
3398 if (ug_data->attach_ex_ly[i] != NULL) {
3399 debug_log("index %d", i);
3400 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[i]);
3401 evas_object_hide(ug_data->attach_ex_ly[i]);
3407 static void _attachment_save_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3412 debug_log("ug_data is NULL");
3416 EmailViewerUGD *ug_data = _g_ug_data;
3417 int att_index = (int)data;
3419 ug_data->display_download_result = FALSE;
3421 debug_log("Selected item index = %d", att_index);
3422 _show_attachment(ug_data, att_index);
3425 static void _attachment_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3430 debug_log("ug_data is NULL");
3434 EmailViewerUGD *ug_data = _g_ug_data;
3435 int att_index = (int)data;
3437 debug_log("Selected item index = %d", att_index);
3438 ug_data->display_download_result = TRUE;
3439 _show_attachment(ug_data, att_index);
3442 static void _attachment_save_all_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3446 debug_log("ug_data is NULL");
3450 EmailViewerUGD *ug_data = _g_ug_data;
3452 _save_attachment_all(ug_data);
3455 static void _attachment_bg_set_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
3459 debug_log("ug_data is NULL");
3463 EmailViewerUGD *ug_data = _g_ug_data;
3464 EmailViewerProp *prop = ug_data->property;
3466 int att_index = (int)data;
3467 debug_log("att_index = %d, attachments count = %d", att_index, prop->real_att_len);
3469 if (prop->real_att_len > 1) {
3472 GList *attachment_list = prop->attachments;
3473 LIST_ITER_START(i, attachment_list) {
3474 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
3475 if (info && !info->inline_content) {
3481 edje_object_signal_emit(_EDJ(ug_data->attach_ex_ly[j]), "pressed", "elm.event.rect");
3484 edje_object_signal_emit(_EDJ(ug_data->attach_hd_ly), "pressed", "elm.event.rect");
3487 static void _attachment_bg_unset_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
3491 debug_log("ug_data is NULL");
3495 EmailViewerUGD *ug_data = _g_ug_data;
3496 EmailViewerProp *prop = ug_data->property;
3498 int att_index = (int)data;
3499 debug_log("att_index = %d, attachments count = %d", att_index, prop->real_att_len);
3501 if (prop->real_att_len > 1) {
3504 GList *attachment_list = prop->attachments;
3505 LIST_ITER_START(i, attachment_list) {
3506 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
3507 if (info && !info->inline_content) {
3513 edje_object_signal_emit(_EDJ(ug_data->attach_ex_ly[j]), "unpressed", "elm.event.rect");
3516 edje_object_signal_emit(_EDJ(ug_data->attach_hd_ly), "unpressed", "elm.event.rect");
3519 static void _mark_as_unread_cb(void *data, Evas_Object *obj, void *event_info)
3523 debug_log("data is NULL");
3527 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3528 EmailViewerPrivate *priv = ug_data->email_data;
3530 if (ug_data->con_popup) {
3531 evas_object_del(ug_data->con_popup);
3532 ug_data->con_popup = NULL;
3536 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);
3538 err = email_set_flags_field(ug_data->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_SEEN_FIELD, 0, 1);
3539 debug_log("email_set_flags_field - err(%d)", err);
3541 if (err != EMAIL_ERROR_NONE) {
3542 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3543 _("IDS_EMAIL_POP_FAILED_TO_MARK_AS_UNREAD"), 0,
3544 NULL, NULL, NULL, NULL, _popup_response_cb);
3546 char str[128] = { 0, };
3547 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MARKED_AS_UNREAD"));
3548 _show_select_info(ug_data, str);
3552 static void _mark_as_read_cb(void *data, Evas_Object *obj, void *event_info)
3556 debug_log("data is NULL");
3560 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3561 EmailViewerPrivate *priv = ug_data->email_data;
3563 if (ug_data->con_popup) {
3564 evas_object_del(ug_data->con_popup);
3565 ug_data->con_popup = NULL;
3569 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);
3571 err = email_set_flags_field(priv->mail_info->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_SEEN_FIELD, 1, 1);
3572 debug_log("email_set_flags_field - err(%d)", err);
3574 if (err != EMAIL_ERROR_NONE) {
3575 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3576 _("IDS_EMAIL_POP_FAILED_TO_MARK_AS_READ"), 0,
3577 NULL, NULL, NULL, NULL, _popup_response_cb);
3579 char str[128] = { 0, };
3580 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MARKED_AS_READ"));
3581 _show_select_info(ug_data, str);
3585 static void _create_waiting_popup(EmailViewerUGD *ug_data, const char *title_text, const char *style)
3588 if (title_text == NULL) {
3589 debug_log("popup text is null");
3593 Evas_Object *popup = elm_popup_add(ug_data->win_main);
3594 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3595 elm_object_part_text_set(popup, "title,text", title_text);
3597 Evas_Object *progress = elm_progressbar_add(popup);
3598 elm_object_style_set(progress, style);
3599 elm_progressbar_pulse_set(progress, EINA_TRUE);
3600 elm_progressbar_pulse(progress, EINA_TRUE);
3601 evas_object_show(progress);
3603 elm_object_content_set(popup, progress);
3605 Evas_Object *btn1 = elm_button_add(popup);
3606 elm_object_style_set(btn1, "popup_button/default");
3607 elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
3608 elm_object_part_content_set(popup, "button1", btn1);
3609 evas_object_smart_callback_add(btn1, "clicked", _popup_waiting_response_cb, ug_data);
3611 ug_data->timeout_popup = popup;
3613 evas_object_show(popup);
3616 static void _save_email_cb(void *data, Evas_Object *obj, void *event_info)
3620 debug_log("data is NULL");
3624 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3626 if (ug_data->con_popup) {
3627 evas_object_del(ug_data->con_popup);
3628 ug_data->con_popup = NULL;
3631 if (ug_data->timeout_popup) {
3632 evas_object_del(ug_data->timeout_popup);
3633 ug_data->timeout_popup = NULL;
3635 _create_waiting_popup(ug_data, dgettext("sys_string", "IDS_COM_POP_SAVING_ING"), "pending_list"); //"list_process"
3637 if (ug_data->waiting_timer) {
3638 ecore_timer_del(ug_data->waiting_timer);
3639 ug_data->waiting_timer = NULL;
3641 ug_data->waiting_timer = ecore_timer_add(0.2, _save_email_prog_cb, ug_data);
3644 static Eina_Bool _save_email_prog_cb(void *data)
3648 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3651 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);
3653 email_mail_data_t *mail_t = NULL;
3654 err = email_get_mail_data(ug_data->email_data->mail_id, &mail_t);
3655 debug_log("email_get_mail_data - err (%d)", err);
3657 if (mail_t == NULL) {
3658 debug_log("mail_t is NULL");
3662 email_attachment_data_t *attachment_t = NULL;
3663 int attachment_count = 0;
3664 err = email_get_attachment_data_list(ug_data->email_data->mail_id, &attachment_t, &attachment_count);
3665 debug_log("email_get_attachment_data_list - err (%d)", err);
3667 char file_name[MAX_PATH_LEN] = { 0, };
3668 snprintf(file_name, sizeof(file_name), "%s_%d_%d.%s", DIR_DEFAULT_MEDIA_PHONE"/Downloads/email", ug_data->account_id, ug_data->mail_id, "eml");
3669 char *output_file_path = g_strdup(file_name);
3670 debug_log("output_file_path(%s)", file_name, output_file_path);
3672 err = email_write_mime_file(mail_t, attachment_t, attachment_count, &output_file_path);
3673 debug_log("email_write_mime_file - err(%d)", err);
3675 g_free(output_file_path);
3678 email_free_mail_data(&(mail_t), 1);
3682 if (attachment_t && attachment_count > 0) {
3683 email_free_attachment_data(&(attachment_t), attachment_count);
3684 attachment_t = NULL;
3685 attachment_count = 0;
3688 if (ug_data->timeout_popup) {
3689 evas_object_del(ug_data->timeout_popup);
3690 ug_data->timeout_popup = NULL;
3693 if (err != EMAIL_ERROR_NONE) {
3694 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3695 dgettext("sys_string", "IDS_COM_POP_UNABLE_TO_SAVE"), 0,
3696 NULL, NULL, NULL, NULL, _popup_response_cb);
3699 char str[128] = { 0, };
3700 snprintf(str, sizeof(str), "%s", N_("Saved in My files"));
3701 int ret = status_message_post(str);
3703 debug_log("status_message_post failed: %d", ret);
3705 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_OPT_INFORMATION"),
3706 N_("Saved in My files"), 0,
3707 NULL, NULL, NULL, NULL, _popup_response_cb);
3711 if (ug_data->waiting_timer) {
3712 ecore_timer_del(ug_data->waiting_timer);
3713 ug_data->waiting_timer = NULL;
3719 static void _ctxpopup_detail_contact_cb(void *data, Evas_Object *obj, void *event_info)
3722 if (data == NULL || _g_ug_data == NULL) {
3723 debug_log("data is NULL");
3727 EmailViewerUGD *ug_data = _g_ug_data;
3729 if (ug_data->con_popup) {
3730 evas_object_del(ug_data->con_popup);
3731 ug_data->con_popup = NULL;
3734 char *index = (char *)data;
3735 char type[10] = { 0, };
3737 service_h service = NULL;
3739 ret = service_create(&service);
3740 debug_log("service_create: %d", ret);
3742 debug_log("service create failed");
3746 snprintf(type, sizeof(type), "%d", CT_UG_REQUEST_DETAIL);
3748 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, type);
3749 debug_log("service_add_extra_data: %d", ret);
3750 ret = service_add_extra_data(service, CT_UG_BUNDLE_ID, index);
3751 debug_log("service_add_extra_data: %d", ret);
3753 create_ug(UG_CONTACTS_DETAILS, service, ug_data);
3755 ret = service_destroy(service);
3756 debug_log("service_destroy: %d", ret);
3758 debug_log("set flag for contact ug");
3759 ug_data->b_contact_ug_launched = TRUE;
3762 static void _ctxpopup_send_email_cb(void *data, Evas_Object *obj, void *event_info)
3765 if (!data || !_g_ug_data) {
3766 debug_log("data is NULL");
3770 EmailViewerUGD *ug_data = _g_ug_data;
3772 if (ug_data->con_popup == NULL) {
3773 debug_log("con_popup is NULL");
3777 if (ug_data->con_popup) {
3778 evas_object_del(ug_data->con_popup);
3779 ug_data->con_popup = NULL;
3782 debug_log("email: %s", (char *)data);
3785 service_h service = NULL;
3787 ret = service_create(&service);
3788 debug_log("service_create: %d", ret);
3790 debug_log("service create failed");
3794 char rtype[10] = { 0, };
3795 snprintf(rtype, sizeof(rtype), "%d", RUN_COMPOSER_EXTERNAL);
3797 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
3798 debug_log("service_add_extra_data: %d", ret);
3799 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_TO, (char *)data);
3800 debug_log("service_add_extra_data: %d", ret);
3801 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CC, NULL);
3802 debug_log("service_add_extra_data: %d", ret);
3803 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_BCC, NULL);
3804 debug_log("service_add_extra_data: %d", ret);
3805 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_SUBJECT, NULL);
3806 debug_log("service_add_extra_data: %d", ret);
3807 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_BODY, NULL);
3808 debug_log("service_add_extra_data: %d", ret);
3809 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_ATTACHMENT, NULL);
3810 debug_log("service_add_extra_data: %d", ret);
3812 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
3814 ret = service_destroy(service);
3815 debug_log("service_destroy: %d", ret);
3818 static void _ctxpopup_add_contact_cb(void *data, Evas_Object *obj, void *event_info)
3821 if (!data || !_g_ug_data) {
3822 debug_log("data is NULL");
3826 char tmp[MAX_STR_LEN] = { 0, };
3827 EmailViewerUGD *ug_data = _g_ug_data;
3829 if (ug_data->con_popup == NULL) {
3830 debug_log("con_popup is NULL");
3834 if (ug_data->con_popup) {
3835 evas_object_del(ug_data->con_popup);
3836 ug_data->con_popup = NULL;
3840 service_h service = NULL;
3842 ret = service_create(&service);
3843 debug_log("service_create: %d", ret);
3845 debug_log("service create failed");
3849 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_PHONE_NUMBER) {
3850 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_NUM);
3851 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3852 debug_log("service_add_extra_data: %d", ret);
3853 ret = service_add_extra_data(service, CT_UG_BUNDLE_NUM, (char *)data);
3854 debug_log("service_add_extra_data: %d", ret);
3856 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_EMAIL) {
3857 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_EMAIL);
3858 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3859 debug_log("service_add_extra_data: %d", ret);
3860 ret = service_add_extra_data(service, CT_UG_BUNDLE_EMAIL, (char *)data);
3861 debug_log("service_add_extra_data: %d", ret);
3863 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_URL) {
3864 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_WEB);
3865 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3866 debug_log("service_add_extra_data: %d", ret);
3867 ret = service_add_extra_data(service, CT_UG_BUNDLE_WEB, (char *)data);
3868 debug_log("service_add_extra_data: %d", ret);
3871 create_ug(UG_CONTACTS_DETAILS, service, ug_data);
3873 ret = service_destroy(service);
3874 debug_log("service_destroy: %d", ret);
3877 static void _ctxpopup_cutlink_update_contact_cb(void *data, Evas_Object *obj, void *event_info)
3880 if (!data || !_g_ug_data) {
3881 debug_log("data is NULL");
3885 char tmp[MAX_STR_LEN] = { 0, };
3886 EmailViewerUGD *ug_data = _g_ug_data;
3888 if (ug_data->con_popup == NULL) {
3889 debug_log("con_popup is NULL");
3893 if (ug_data->con_popup) {
3894 evas_object_del(ug_data->con_popup);
3895 ug_data->con_popup = NULL;
3899 service_h service = NULL;
3901 ret = service_create(&service);
3902 debug_log("service_create: %d", ret);
3904 debug_log("service create failed");
3908 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_PHONE_NUMBER) {
3909 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_NUM);
3910 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3911 debug_log("service_add_extra_data: %d", ret);
3912 ret = service_add_extra_data(service, CT_UG_BUNDLE_NUM, (char *)data);
3913 debug_log("service_add_extra_data: %d", ret);
3915 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_EMAIL) {
3916 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_EMAIL);
3917 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3918 debug_log("service_add_extra_data: %d", ret);
3919 ret = service_add_extra_data(service, CT_UG_BUNDLE_EMAIL, (char *)data);
3920 debug_log("service_add_extra_data: %d", ret);
3922 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_URL) {
3923 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_WEB);
3924 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3925 debug_log("service_add_extra_data: %d", ret);
3926 ret = service_add_extra_data(service, CT_UG_BUNDLE_WEB, (char *)data);
3927 debug_log("service_add_extra_data: %d", ret);
3930 ug_data->ug_contacts_search = create_ug(UG_CONTACTS_LIST, service, ug_data);
3932 ret = service_destroy(service);
3933 debug_log("service_destroy: %d", ret);
3936 static void _ctxpopup_select_contact_mode_email_cb(void *data, Evas_Object *obj, void *event_info)
3939 if (!data || !_g_ug_data) {
3940 debug_log("data is NULL");
3944 EmailViewerUGD *ug_data = _g_ug_data;
3947 if (ug_data->con_popup) {
3948 evas_object_del(ug_data->con_popup);
3949 ug_data->con_popup = NULL;
3952 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
3953 if (ug_data->con_popup == NULL) {
3954 debug_log("cannot create context popup");
3958 ug_data->create_contact_arg = CONTACTUI_REQ_ADD_EMAIL;
3959 ug_data->update_contact_type = CONTACTUI_REQ_ADD_EMAIL;
3961 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_OPT_CREATE_CONTACT"), NULL, _ctxpopup_add_contact_cb, data);
3962 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_UPDATE_EXISTING"), NULL, _ctxpopup_cutlink_update_contact_cb, data);
3964 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
3965 evas_object_move(ug_data->con_popup, x, y);
3966 evas_object_show(ug_data->con_popup);
3969 static void _ctxpopup_add_block_rule_cb(void *data, Evas_Object *obj, void *event_info)
3973 if (!data || !_g_ug_data) {
3974 debug_log("data is NULL");
3978 EmailViewerUGD *ug_data = _g_ug_data;
3979 EmailViewerPrivate *priv = ug_data->email_data;
3980 char *addr = (char *)data;
3982 debug_log("Block address: %s", addr);
3984 if (ug_data->con_popup) {
3985 evas_object_del(ug_data->con_popup);
3986 ug_data->con_popup = NULL;
3990 email_rule_t *rule = NULL;
3992 /* add filtering rule */
3993 rule = malloc(sizeof(email_rule_t));
3994 rule->account_id = priv->account_id;
3995 rule->type = EMAIL_FILTER_FROM;
3996 rule->value = g_strdup(addr);
3997 rule->faction = EMAIL_FILTER_BLOCK;
4000 email_mailbox_t *mail_box = NULL;
4001 if ((err = email_get_mailbox_by_mailbox_type(ug_data->account_id, ug_data->mailbox_type, &mail_box)) != EMAIL_ERROR_NONE) {
4002 debug_log("email_get_mailbox_by_mailbox_type failed! - err (%d)", err);
4005 if (mail_box == NULL) {
4006 debug_log("mail_box is NULL");
4009 rule->target_mailbox_id = mail_box->mailbox_id;
4012 debug_log("email_free_mailbox is called");
4013 email_free_mailbox(&mail_box, 1);
4018 rule->flag2 = RULE_TYPE_INCLUDES;
4020 ret = email_add_rule(rule);
4022 debug_log("email_add_rule failed %d", ret);
4023 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
4024 _("IDS_EMAIL_POP_FAILED_TO_ADD_BLOCK_RULE"), 0,
4025 NULL, NULL, NULL, NULL, _popup_response_cb);
4028 vconf_ret = vconf_set_int(EMAIL_VCONF_KEY_BLOCK_RULE_CHANGED, 1);
4029 if (vconf_ret == -1) {
4030 debug_log("fail to set vconf int(spam_rule_changed)");
4031 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
4032 _("IDS_EMAIL_POP_FAILED_TO_ADD_BLOCK_RULE"), 0,
4033 NULL, NULL, NULL, NULL, _popup_response_cb);
4035 char str[128] = { 0, };
4036 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_BLOCKED"));
4037 ret = status_message_post(str);
4039 debug_log("status_message_post failed: %d", ret);
4043 email_free_rule(&rule, 1);
4046 static void _popup_waiting_response_cb(void *data, Evas_Object *obj, void *event_info)
4050 debug_log("_g_ug_data is NULL");
4055 debug_log("data is NULL");
4059 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4061 if (ug_data->timeout_popup) {
4062 evas_object_del(ug_data->timeout_popup);
4063 ug_data->timeout_popup = NULL;
4067 static void _popup_response_cb(void *data, Evas_Object *obj, void *event_info)
4071 debug_log("_g_ug_data is NULL");
4076 debug_log("data is NULL");
4080 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4082 if (ug_data->notify) {
4083 evas_object_del(ug_data->notify);
4084 ug_data->notify = NULL;
4088 static void _popup_response_delete_ok_cb(void *data, Evas_Object *obj, void *event_info)
4092 debug_log("_g_ug_data is NULL");
4097 debug_log("data is NULL");
4101 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4103 if (ug_data->notify) {
4104 evas_object_del(ug_data->notify);
4105 ug_data->notify = NULL;
4108 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH)
4109 _delete_email(ug_data);
4111 _move_email(ug_data, _find_folder_id_using_folder_type(ug_data, EMAIL_MAILBOX_TYPE_TRASH), TRUE);
4113 if (ug_data->isRotate == false && ug_data->b_internal) {
4114 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
4118 if (ug_data->b_internal) {
4119 _hide_view(ug_data);
4121 /* send next or previous mail request to mailbox. */
4123 service_h service = NULL;
4125 ret = service_create(&service);
4126 debug_log("service_create: %d", ret);
4128 debug_log("service create failed");
4132 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
4133 debug_log("service_add_extra_data: %d", ret);
4134 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "1");
4135 debug_log("service_add_extra_data: %d", ret);
4137 ug_send_message(_g_mailbox_ug, service);
4139 ret = service_destroy(service);
4140 debug_log("service_destroy: %d", ret);
4142 ug_destroy_me(ug_data->ug);
4145 static void _popup_response_to_destroy_cb(void *data, Evas_Object *obj, void *event_info)
4149 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4150 evas_object_del(obj);
4152 ug_data->b_direct_destroy = 1;
4153 ug_destroy_me(ug_data->ug);
4157 static void _webview_multi_up_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
4160 if (_g_ug_data == NULL)
4164 debug_log("data is NULL");
4168 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4170 ug_data->m_is_multi_touch = FALSE;
4172 if (ug_data->scroller_locked) {
4173 ug_data->scroller_locked = FALSE;
4174 debug_log("<<unlock scroller>>");
4175 debug_log("<<lock webview>>");
4179 static void _webview_multi_down_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
4182 if (_g_ug_data == NULL)
4186 debug_log("data is NULL");
4190 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4192 ug_data->m_is_multi_touch = TRUE;
4193 if (ug_data->scroller_locked == FALSE) {
4194 ug_data->scroller_locked = TRUE;
4195 debug_log("<<lock scroller>>");
4196 debug_log("<<unlock webview>>");
4200 static void _webview_policy_navigation_decide_cb(void *data, Evas_Object *obj, void *event_info)
4204 debug_log("data is NULL");
4208 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4209 Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info;
4210 Ewk_Policy_Navigation_Type pd_type = ewk_policy_decision_navigation_type_get(policy_decision);
4211 debug_log("Ewk_Policy_Navigation_Type:%d", pd_type);
4213 const char *uri = NULL;
4214 uri = ewk_view_uri_get(ug_data->webview);
4215 debug_log("ewk_view_uri_get(%s)", uri);
4217 if (ug_data->b_load_finished == EINA_TRUE) {
4218 ewk_policy_decision_ignore(policy_decision);
4220 debug_log("url:%s", ewk_policy_decision_url_get(policy_decision));
4221 debug_log("scheme:%s", ewk_policy_decision_scheme_get(policy_decision));
4222 debug_log("cookie:%s", ewk_policy_decision_cookie_get(policy_decision));
4223 debug_log("host:%s", ewk_policy_decision_host_get(policy_decision));
4224 debug_log("response_mime:%s", ewk_policy_decision_response_mime_get(policy_decision));
4226 char *url = (char *)ewk_policy_decision_url_get(policy_decision);
4228 if ((strncmp(url, "http://", 7) == 0) ||
4229 (strncmp(url, "https://", 8) == 0) ||
4230 (strncmp(url, "ftp://", 6) == 0) ||
4231 (strncmp(url, "mms://", 6) == 0) ||
4232 (strncmp(url, "file://", 7) == 0) ||
4233 (strncmp(url, "rtsp://", 7) == 0) ||
4234 (strncmp(url, "wap://", 6) == 0)) {
4236 service_h service = NULL;
4237 ret = service_create(&service);
4238 debug_log("service_create: %d", ret);
4240 debug_log("service create failed");
4243 ret = service_set_operation(service, SERVICE_OPERATION_VIEW);
4244 debug_log("service_set_operation: %d", ret);
4245 ret = service_set_uri(service, url);
4246 debug_log("service_set_uri: %d", ret);
4247 ret = service_send_launch_request(service, NULL, NULL);
4248 debug_log("service_send_launch_request: %d", ret);
4249 ret = service_destroy(service);
4250 debug_log("service_destroy: %d", ret);
4253 if (strncmp(url, "tel:", 4) == 0) {
4254 char refined_num[MAX_STR_LEN] = { 0, };
4257 while (url[i] != '\0') {
4258 if (url[i] >= '0' && url[i] <= '9')
4259 refined_num[j++] = url[i];
4263 char *number = refined_num;
4264 debug_log("number: %s", number);
4267 service_h service = NULL;
4268 char telnum[255] = { 0, };
4269 ret = service_create(&service);
4270 debug_log("service_create: %d", ret);
4272 debug_log("service create failed");
4275 ret = service_set_operation(service, SERVICE_OPERATION_CALL);
4276 debug_log("service_set_operation: %d", ret);
4277 snprintf(telnum, sizeof(telnum), "tel:%s", number); /* Number to make a call */
4278 ret = service_set_uri(service, telnum);
4279 debug_log("service_set_uri: %d", ret);
4280 ret = service_add_extra_data(service, "ctindex", "-1"); /* If you don't know ctindex, you don't have to add it. */
4281 debug_log("service_add_extra_data: %d", ret);
4282 ret = service_send_launch_request(service, NULL, NULL);
4283 debug_log("service_send_launch_request: %d", ret);
4284 ret = service_destroy(service);
4285 debug_log("service_destroy: %d", ret);
4288 if (strncmp(url, "mailto:", 7) == 0) {
4290 service_h service = NULL;
4291 ret = service_create(&service);
4292 debug_log("service_create: %d", ret);
4294 debug_log("service create failed");
4298 char rtype[10] = { 0, };
4299 snprintf(rtype, sizeof(rtype), "%d", RUN_COMPOSER_EXTERNAL);
4301 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
4302 debug_log("service_add_extra_data: %d", ret);
4303 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_TO, &url[7]);
4304 debug_log("service_add_extra_data: %d", ret);
4306 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
4308 ret = service_destroy(service);
4309 debug_log("service_destroy: %d", ret);
4312 if (ug_data->timeout_popup) {
4313 evas_object_del(ug_data->timeout_popup);
4314 ug_data->timeout_popup = NULL;
4316 _create_waiting_popup(ug_data, _("IDS_EMAIL_POP_LOADING_CONTENTS_ING"), "list_process");
4318 if (pd_type == EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED) {
4319 debug_log("Link click is ignored.");
4320 ewk_policy_decision_ignore(policy_decision);
4326 /* Double_Scroller */
4327 static void _outter_scroller_bottom_hit_cb(void *data, Evas_Object *obj, void *event_info)
4331 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4332 int res = email_engine_check_body_download(ug_data->email_data->mail_id);
4334 if (ug_data->is_main_scroller_scrolling && res != 0) {
4335 debug_log("Main scroller hold push");
4336 elm_object_scroll_freeze_push(ug_data->scroller); //stop
4337 ewk_view_vertical_panning_hold_set(ug_data->webview, EINA_FALSE); //restart
4338 ug_data->is_main_scroller_scrolling = EINA_FALSE;
4339 ug_data->is_webview_scrolling = EINA_TRUE;
4343 static void _outter_scroller_top_hit_cb(void *data, Evas_Object *obj, void *event_info)
4348 static void _outter_scroller_scroll_cb(void *data, Evas_Object *obj, void *event_info)
4351 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4353 ug_data->is_main_scroller_scrolling = EINA_TRUE;
4356 static void _mbe_focused_cb(void *data, Evas_Object *obj, void *event_info)
4359 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(obj);
4360 elm_multibuttonentry_item_selected_set(item, EINA_FALSE);
4363 static void _mbe_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
4368 static void _mbe_added_cb(void *data, Evas_Object *obj, void *event_info)
4373 static void _mbe_selected_cb(void *data, Evas_Object *obj, void *event_info)
4376 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4377 email_address_info_t *addrs_info = NULL;
4378 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
4379 debug_log("selected item:%s", elm_object_item_text_get(item));
4381 addrs_info = elm_object_item_data_get(item);
4384 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
4385 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, addrs_info->address);
4387 if (ug_data->con_popup != NULL) {
4388 evas_object_del(ug_data->con_popup);
4389 ug_data->con_popup = NULL;
4392 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
4393 if (ug_data->con_popup == NULL) {
4394 debug_log("cannot create context popup");
4398 if (contact_list_item) {
4399 debug_log("Contact Item Exist: index[%d]", contact_list_item->index);
4400 char index[10] = { 0, };
4401 snprintf(index, sizeof(index), "%d", contact_list_item->index);
4403 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_VIEW_CONTACT"), NULL, _ctxpopup_detail_contact_cb, g_strdup(index));
4404 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SEND_EMAIL"), NULL, _ctxpopup_send_email_cb, addrs_info->address);
4405 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);
4406 _delete_contacts_list(contact_list_item);
4408 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);
4409 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SEND_EMAIL"), NULL, _ctxpopup_send_email_cb, addrs_info->address);
4410 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);
4414 email_rule_t *rule_list = NULL;
4416 /* get the rule list from service */
4417 if (email_get_rule_list(&rule_list, &count) < 0) {
4418 debug_log("email_get_rule_list failed");
4421 for (i = 0; i < count; i++) {
4422 if (rule_list[i].type == EMAIL_FILTER_FROM/*TYPE_BLOCK_ADDRESS*/) {
4423 debug_log("block address %s", rule_list[i].value);
4425 if (g_strcmp0(rule_list[i].value, addrs_info->address) == 0) {
4426 debug_log("[%s] already blocked", rule_list[i].value);
4427 if (ug_data->ctx_block_item)
4428 elm_object_item_disabled_set(ug_data->ctx_block_item, EINA_TRUE);
4433 /* free email rule_list */
4434 email_free_rule(&rule_list, count);
4437 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
4438 debug_log("canvas x:%d, y:%d", x, y);
4439 evas_object_move(ug_data->con_popup, x, y);
4440 evas_object_show(ug_data->con_popup);
4443 static void _destroy_down_progress_cb(void *data, Evas_Object *obj, void *event_info)
4448 debug_log("data is NULL");
4452 EmailViewerUGD *ug_data = _g_ug_data;
4453 EmailViewerPrivate *priv = ug_data->email_data;
4455 email_engine_stop_working(ug_data->account_id, priv->email_handle);
4457 if (ug_data->pb_notify) {
4458 evas_object_del(ug_data->pb_notify);
4459 ug_data->pb_notify = NULL;
4462 if (ug_data->pb_notify_lb) {
4463 evas_object_del(ug_data->pb_notify_lb);
4464 ug_data->pb_notify_lb = NULL;
4468 if (priv->att_file_id) {
4469 free(priv->att_file_id);
4470 priv->att_file_id = NULL;
4473 priv->file_size = 0;
4474 priv->attachment_id = -1;
4475 priv->multi_body = FALSE;
4479 static void _init_viewer_data(int account_id, int mail_id, char *srv_mail_id, EmailViewerUGD *ug_data)
4482 EmailViewerPrivate *priv = NULL;
4483 EmailViewerProp *prop = NULL;
4484 email_address_info_list_t *addrs_info_list = NULL;
4486 /* Create Email Viewer Private Structure */
4487 if (ug_data->email_data) {
4488 if (ug_data->email_data->mail_info) {
4489 debug_log("mail_info freed");
4490 email_free_mail_data(&(ug_data->email_data->mail_info), 1);
4491 ug_data->email_data->mail_info = NULL;
4494 if (ug_data->email_data->attachment_info && ug_data->email_data->attachment_count > 0) {
4495 debug_log("attachment_info freed p[%p] n[%d]", ug_data->email_data->attachment_info, ug_data->email_data->attachment_count);
4496 email_free_attachment_data(&(ug_data->email_data->attachment_info), ug_data->email_data->attachment_count);
4497 ug_data->email_data->attachment_info = NULL;
4498 ug_data->email_data->attachment_count = 0;
4501 memset(ug_data->email_data, 0x0, sizeof(EmailViewerPrivate));
4502 priv = ug_data->email_data;
4504 priv = (EmailViewerPrivate *)malloc(sizeof(EmailViewerPrivate));
4505 memset(priv, 0x0, sizeof(EmailViewerPrivate));
4506 ug_data->email_data = priv;
4509 /* Create Email Viewer Property Structure */
4510 if (ug_data->property) {
4511 if (ug_data->property->attachments) {
4513 LIST_ITER_START(i, ug_data->property->attachments) {
4514 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, ug_data->property->attachments);
4521 g_list_free(ug_data->property->attachments);
4523 memset(ug_data->property, 0x0, sizeof(EmailViewerProp));
4524 prop = ug_data->property;
4526 prop = (EmailViewerProp *)malloc(sizeof(EmailViewerProp));
4527 memset(prop, 0x0, sizeof(EmailViewerProp));
4528 ug_data->property = prop;
4531 /* Set account ID */
4532 priv->account_id = account_id;
4533 prop->account_id = account_id;
4536 priv->mail_id = mail_id;
4537 prop->mail_id = mail_id;
4539 priv->mailbox_id = ug_data->mailbox_id;
4540 prop->src_box = ug_data->mailbox_name;
4541 debug_log("mailbox_name [%s]", ug_data->mailbox_name);
4543 /* Get mail_info from service, and fill property */
4544 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
4545 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
4548 email_get_address_info_list(priv->mail_id, &addrs_info_list);
4550 if (addrs_info_list) {
4551 ug_data->from_list = addrs_info_list->from;
4552 ug_data->to_list = addrs_info_list->to;
4553 ug_data->cc_list = addrs_info_list->cc;
4554 ug_data->bcc_list = addrs_info_list->bcc;
4555 priv->addrs_info_list = addrs_info_list;
4558 ug_data->option_header_opened = 0;
4561 static int _init_webview_data(EmailViewerUGD *ug_data)
4565 EmailViewerWebview *wvd;
4567 if (ug_data->webview_data == NULL) {
4568 wvd = (EmailViewerWebview *)malloc(sizeof(EmailViewerWebview));
4569 memset(wvd, 0x0, sizeof(EmailViewerWebview));
4570 ug_data->webview_data = wvd;
4573 if (STR_VALID(ug_data->property->charset)) {
4574 ug_data->webview_data->charset = g_strdup(ug_data->property->charset);
4575 debug_log("charset:%s", ug_data->webview_data->charset);
4577 ug_data->webview_data->charset = DEFAULT_CHARSET;
4578 debug_log("charset:%s", ug_data->webview_data->charset);
4584 static Eina_Bool _check_body_download(void *data)
4588 debug_log("data is NULL");
4589 return ECORE_CALLBACK_CANCEL;
4592 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4594 _create_tab_bar(ug_data);
4596 /* check mail body downloaded */
4597 int body_download_status = ug_data->property->body_download;
4599 if (body_download_status == 0) { //EMAIL_BODY_DOWNLOAD_STATUS_NONE
4600 debug_log("need body download");
4601 ug_data->b_noc = 1; /* Double_Scroller */
4603 if (ug_data->noc_bx) {
4604 debug_log("no content layout exist");
4605 evas_object_show(ug_data->noc_bx);
4606 elm_object_text_set(ug_data->dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_MESSAGE"));
4607 evas_object_show(ug_data->dn_btn);
4608 elm_box_pack_end(ug_data->main_bx, ug_data->noc_bx);
4610 /* add body download button */
4611 ug_data->noc_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.no_content");
4612 if (ug_data->noc_bx == NULL) {
4613 debug_log("Cannot load edj");
4614 return ECORE_CALLBACK_CANCEL;
4617 evas_object_size_hint_align_set(ug_data->noc_bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
4618 evas_object_size_hint_weight_set(ug_data->noc_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
4619 evas_object_show(ug_data->noc_bx);
4620 elm_box_pack_end(ug_data->main_bx, ug_data->noc_bx);
4622 Evas_Object *dn_btn = elm_button_add(ug_data->navi_bar);
4623 /*elm_object_theme_set(dn_btn, ug_data->theme);*/
4624 elm_object_style_set(dn_btn, "text_only/style2");
4625 elm_object_text_set(dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_MESSAGE"));
4626 evas_object_smart_callback_add(dn_btn, "clicked", _body_down_cb, (void *)ug_data);
4627 evas_object_show(dn_btn);
4628 ug_data->dn_btn = dn_btn;
4630 elm_object_part_content_set(ug_data->noc_bx, "btn", ug_data->dn_btn);
4631 debug_log("no content layout created");
4634 elm_object_focus_set(ug_data->noc_bx, EINA_TRUE);
4635 if (ug_data->timer) {
4636 ecore_timer_del(ug_data->timer);
4637 ug_data->timer = NULL;
4640 ug_data->timer = ecore_timer_add(0.0, viewer_send_message, ug_data);
4641 } else if (body_download_status == 1) { //EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED
4642 debug_log("check mail downloaded - ok");
4644 _create_body(ug_data);
4645 } else if (body_download_status == 2) { //EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED
4647 debug_log("Partial Body");
4648 ug_data->b_partial_body = 1;
4649 _create_body(ug_data);
4650 _create_partial_body_dn_btn(ug_data);
4653 return ECORE_CALLBACK_CANCEL;
4656 static int _update_attachment_info(EmailViewerUGD *ug_data, int index)
4659 EmailViewerProp *prop = ug_data->property;
4662 int attach_index = 0;
4664 /* update attachment information */
4665 LIST_ITER_START(i, prop->attachments) {
4666 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, prop->attachments);
4668 if (info && !info->inline_content) {
4669 debug_log("info->index[%d] index[%d]", info->index, index);
4671 if (info->index == index) {
4672 info->download_yn = TRUE;
4673 info->path = email_engine_get_attachment_path(info->attach_id);
4677 if (prop->real_att_len > 1) {
4678 Evas_Object *thumbnail = viewer_make_thumbnail(info->path, ug_data->attach_ex_bk[j]);
4679 Evas_Object *content = elm_object_part_content_unset(ug_data->attach_ex_bk[j], "elm.icon");
4680 evas_object_del(content);
4681 elm_object_part_content_set(ug_data->attach_ex_bk[j], "elm.icon", thumbnail);
4682 evas_object_show(thumbnail);
4684 Evas_Object *thumbnail = viewer_make_thumbnail(info->path, ug_data->attach_hd_bk);
4685 Evas_Object *content = elm_object_part_content_unset(ug_data->attach_hd_bk, "elm.icon");
4686 evas_object_del(content);
4687 elm_object_part_content_set(ug_data->attach_hd_bk, "elm.icon", thumbnail);
4688 evas_object_show(thumbnail);
4698 debug_log("return id[%d]", attach_index);
4700 return attach_index;
4703 static int _get_attachment_info_index(EmailViewerUGD *ug_data, int index)
4707 EmailViewerProp *prop = ug_data->property;
4709 int attach_index = 0;
4711 /* update attachment information */
4712 LIST_ITER_START(i, prop->attachments) {
4713 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, prop->attachments);
4715 debug_log("info->index[%d] index[%d]", info->index, index);
4716 if (info->index == index) {
4723 debug_log("return id[%d]", attach_index);
4725 return attach_index;
4728 static void _show_select_info(EmailViewerUGD *ug_data, char *str)
4732 if (ug_data->select_info != NULL) {
4733 evas_object_del(ug_data->select_info);
4734 ug_data->select_info = NULL;
4737 if (ug_data->selectioninfo_layout != NULL) {
4738 evas_object_del(ug_data->selectioninfo_layout);
4739 ug_data->selectioninfo_layout = NULL;
4742 ug_data->select_info = elm_notify_add(ug_data->win_main);
4743 elm_notify_orient_set(ug_data->select_info, ELM_NOTIFY_ORIENT_BOTTOM);
4745 ug_data->selectioninfo_layout = elm_layout_add(ug_data->layout_main);
4746 elm_object_content_set(ug_data->select_info, ug_data->selectioninfo_layout);
4748 elm_layout_theme_set(ug_data->selectioninfo_layout, "standard", "selectioninfo", "vertical/bottom_64");
4750 edje_object_part_text_set(_EDJ(ug_data->selectioninfo_layout), "elm.text", str);
4751 elm_notify_timeout_set(ug_data->select_info, 3);
4752 evas_object_show(ug_data->select_info);
4755 static void _save_attachment(EmailViewerUGD *ug_data, int index)
4758 EmailViewerPrivate *priv = ug_data->email_data;
4759 EmailViewerProp *prop = ug_data->property;
4760 char newpath[MAX_PATH_LEN] = { 0, };
4762 RETURN_IF_FAIL(prop->attachments != NULL);
4763 EmailAttachmentType *info = g_list_nth_data(prop->attachments, index);
4766 debug_log("EmailAttachmentType *info is NULL");
4770 if (!info->download_yn) {
4772 gboolean res = FALSE;
4774 if (ug_data->progress_bar[index + 1] != NULL) {
4775 debug_log("Already getting downloaded...!");
4776 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4777 _("IDS_EMAIL_POP_ALREADY_DOWNLOADING_T_HEADER"), 1,
4778 dgettext("sys_string", "IDS_COM_SK_OK"),
4779 _popup_response_cb, NULL, NULL, NULL);
4783 debug_log("Need attachment download");
4784 /* download attachment */
4785 priv->b_att_save = TRUE;
4787 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4790 priv->download_all_cnt++;
4791 debug_log("Assigning Handle[%d] Index[%d] download_all_cnt[%d]", handle, index, priv->download_all_cnt);
4792 priv->download_all_email_handle[index] = handle;
4793 _create_down_progress_ex(index, EMAIL_VIEWER_PROGRESSBAR_ATT);
4794 ug_data->display_download_result = TRUE;
4796 priv->b_att_save = FALSE;
4797 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4798 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
4799 dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
4806 if (info && STR_VALID(info->path)) {
4808 debug_log("path[%s]", info->path);
4809 ret = email_attachments_save_file(info->path, newpath, NULL);
4810 if (ret == EMAIL_EXT_SAVE_ERR_NONE) {
4811 char str[128] = { 0, };
4812 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
4813 ret = status_message_post(str);
4815 debug_log("status_message_post failed: %d", ret);
4820 static void _show_attachment(EmailViewerUGD *ug_data, int index)
4823 EmailViewerPrivate *priv = ug_data->email_data;
4824 EmailViewerProp *prop = ug_data->property;
4825 EmailAttachmentType *info = g_list_nth_data(prop->attachments, index);
4826 char newpath[MAX_PATH_LEN] = { 0, };
4829 debug_log("EmailAttachmentType *info is NULL");
4833 debug_log("attach_id:%d, index:%d, name(%s), path(%s), size:%d, download_yn:%d, drm:%d, inline_content:%d",
4834 info->attach_id, info->index, info->name, info->path, (gint) info->size, info->download_yn, info->drm, info->inline_content);
4836 if (!info->download_yn) {
4838 gboolean res = FALSE;
4839 debug_log("Need attachment download");
4841 priv->b_att_open = TRUE;
4843 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4846 priv->download_all_email_handle[index] = handle;
4847 priv->download_all_cnt++;
4848 _create_down_progress_ex(index, EMAIL_VIEWER_PROGRESSBAR_ATT);
4850 priv->b_att_open = FALSE;
4851 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4852 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
4853 dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
4859 gboolean res = FALSE;
4860 res = email_attachments_save_file(info->path, newpath, NULL);
4861 debug_log("Result:%d, Saved Path:%s", res, newpath);
4863 if (res == EMAIL_EXT_SAVE_ERR_NONE) {
4864 char str[128] = { 0, };
4865 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
4866 int ret = status_message_post(str);
4868 debug_log("status_message_post failed: %d", ret);
4870 if (g_str_has_suffix(info->path, ".vcs")) {
4874 fp = fopen(newpath, "r");
4876 debug_error("fopen(%s) is failed.", newpath);
4877 calendar_disconnect();
4882 if (stat(newpath, &st) == -1) {
4883 debug_error("file(%s), stat Error(%d): %s", newpath, errno, strerror(errno));
4885 calendar_disconnect();
4889 int size = st.st_size;
4890 char *raw_data = calloc(size + 1, sizeof(char));
4892 debug_error("calloc is failed.");
4894 calendar_disconnect();
4899 if ((n = fread(raw_data, 1, size, fp)) != size) {
4900 debug_error("error in fread");
4903 calendar_disconnect();
4909 calendar_list_h list = NULL;
4911 ret = calendar_vcalendar_parse_to_calendar(raw_data, &list);
4913 if( list && ret == CALENDAR_ERROR_NONE) {
4914 calendar_db_insert_records(list, NULL, NULL);
4915 debug_log("vcalendar is registered to calendar");
4919 calendar_disconnect();
4921 media_file_register(newpath);
4922 } else if (res == EMAIL_EXT_SAVE_ERR_ALREADY_EXIST && !ug_data->display_download_result) {
4923 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
4924 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0,
4925 NULL, NULL, NULL, NULL, _popup_response_cb);
4928 debug_log("display_download_result:%d", ug_data->display_download_result);
4929 if (ug_data->display_download_result) {
4930 if (res == EMAIL_EXT_SAVE_ERR_NONE || res == EMAIL_EXT_SAVE_ERR_ALREADY_EXIST) {
4932 service_h service = NULL;
4933 ret = service_create(&service);
4934 debug_log("service_create: %d", ret);
4936 debug_log("service create failed");
4939 ret = service_set_operation(service, SERVICE_OPERATION_VIEW);
4940 debug_log("service_set_operation: %d", ret);
4941 ret = service_set_uri(service, newpath);
4942 debug_log("service_set_uri: %d", ret);
4943 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_VIDEO_PLAYER_LAUNCH_APP, "email");
4944 debug_log("service_add_extra_data: %d", ret);
4945 ret = service_send_launch_request(service, NULL, NULL);
4946 debug_log("service_send_launch_request: %d", ret);
4947 if (ret != SERVICE_ERROR_NONE) {
4948 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4949 _("IDS_EMAIL_POP_THIS_ATTACHMENT_CANNOT_BE_DISPLAYED"), 0,
4950 NULL, NULL, NULL, NULL, _popup_response_cb);
4952 ret = service_destroy(service);
4953 debug_log("service_destroy: %d", ret);
4955 debug_log("EMAIL_EXT_SAVE_ERR_UNKNOWN");
4960 static void _save_attachment_all(EmailViewerUGD *ug_data)
4963 EmailViewerPrivate *priv = ug_data->email_data;
4964 EmailViewerProp *prop = ug_data->property;
4965 EmailAttachmentType *info = NULL;
4968 int att_len = g_list_length(prop->attachments);
4970 if (priv->b_all_att_save)
4974 if (ug_data->forward_ctr_it)
4975 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_TRUE);
4978 for (i = 0; i < att_len; i++) {
4979 info = g_list_nth_data(prop->attachments, i);
4981 if (info && !info->inline_content) {
4982 if (!info->download_yn) {
4983 if (ug_data->progress_bar_ly[i + 1] == NULL) {
4985 gboolean res = FALSE;
4986 debug_log("Need attachment [%d] download", i);
4988 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4991 priv->download_all_cnt++;
4992 priv->download_all_email_handle[i] = handle;
4993 priv->b_all_att_save = TRUE;
4995 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
4996 if (priv->b_all_att_save) {
4997 if (ug_data->attach_onoff_flag == 0) {
4998 _attachment_item_collapse_cb(ug_data->attach_hd_bk, NULL, NULL, NULL);
5002 _create_down_progress_ex(i, EMAIL_VIEWER_PROGRESSBAR_ATT);
5003 ug_data->display_download_result = TRUE;
5005 priv->download_all_fail_cnt++;
5012 debug_log("download [%d], failed [%d]", priv->download_all_cnt, priv->download_all_fail_cnt);
5015 static void _dbus_receiver_setup(EmailViewerUGD *ug_data)
5019 int ret = e_dbus_init();
5020 debug_log("ret: %d", ret);
5024 if (_g_viewer_dbus_conn == NULL) {
5026 dbus_error_init(&derror);
5027 _g_viewer_dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
5029 if (_g_viewer_dbus_conn == NULL) {
5030 debug_log("e_dbus_bus_get return NULL");
5034 if (e_dbus_request_name(_g_viewer_dbus_conn, "User.Email.StorageChange", 0, NULL, NULL) == NULL) {
5035 debug_critical("Failed to e_dbus_request_name()");
5039 if (_g_viewer_signal_handler_storage != NULL) {
5040 debug_log("_g_viewer_signal_handler_storage != NULL");
5043 _g_viewer_signal_handler_storage = e_dbus_signal_handler_add(_g_viewer_dbus_conn, NULL,
5044 "/User/Email/StorageChange",
5045 "User.Email.StorageChange",
5046 "email", _on_edbus_event_email_viewer_receive, ug_data);
5048 if (_g_viewer_signal_handler_storage == NULL) {
5049 debug_log("Failed to e_dbus_signal_handler_add()");
5054 if (e_dbus_request_name(_g_viewer_dbus_conn, "User.Email.NetworkStatus", 0, NULL, NULL) == NULL) {
5055 debug_log("Failed to e_dbus_request_name()");
5059 if (_g_viewer_signal_handler_network != NULL) {
5060 debug_log("_g_viewer_signal_handler_network != NULL");
5063 _g_viewer_signal_handler_network = e_dbus_signal_handler_add(_g_viewer_dbus_conn, NULL,
5064 "/User/Email/NetworkStatus",
5065 "User.Email.NetworkStatus",
5066 "email", _on_edbus_event_email_viewer_receive, ug_data);
5068 if (_g_viewer_signal_handler_network == NULL) {
5069 debug_log("Failed to e_dbus_signal_handler_add()");
5075 static void _dbus_receiver_remove(EmailViewerUGD *ug_data)
5079 if (_g_viewer_signal_handler_storage != NULL) {
5080 e_dbus_signal_handler_del(_g_viewer_dbus_conn, _g_viewer_signal_handler_storage);
5081 _g_viewer_signal_handler_storage = NULL;
5084 if (_g_viewer_signal_handler_network != NULL) {
5085 e_dbus_signal_handler_del(_g_viewer_dbus_conn, _g_viewer_signal_handler_network);
5086 _g_viewer_signal_handler_network = NULL;
5089 if (e_dbus_release_name(_g_viewer_dbus_conn, "User.Email.StorageChange", NULL, NULL) == NULL) {
5090 debug_critical("e_dbus_release_name to failed");
5093 if (e_dbus_release_name(_g_viewer_dbus_conn, "User.Email.NetworkStatus", NULL, NULL) == NULL) {
5094 debug_critical("e_dbus_release_name to failed");
5097 if (_g_viewer_dbus_conn != NULL) {
5098 /*e_dbus_connection_close(_g_viewer_dbus_conn);*/
5099 _g_viewer_dbus_conn = NULL;
5103 static void _on_edbus_event_email_viewer_receive(void *data, DBusMessage *message)
5108 debug_log("data is NULL");
5112 EmailViewerUGD *ug_data = _g_ug_data;
5113 EmailViewerPrivate *priv = ug_data->email_data;
5114 char fail_msg[MAX_STR_LEN] = { 0, };
5117 if (dbus_message_is_signal(message, "User.Email.StorageChange", "email")) {
5118 debug_log("User.Email.StorageChange");
5125 dbus_error_init(&error);
5126 if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &subtype,
5127 DBUS_TYPE_INT32, &data1, DBUS_TYPE_INT32, &data2,
5128 DBUS_TYPE_STRING, &data3, DBUS_TYPE_INVALID)) {
5129 debug_log("STORE_ENABLE: subtype: %d, data1: %d, data2: %d, data3: %s", subtype, data1, data2, data3);
5132 case NOTI_ACCOUNT_ADD:
5133 if (get_app_paused()) {
5134 debug_log("account added during pause status");
5136 if (ug_data->isRotate == false && ug_data->b_internal) {
5137 /* Viewer to hide, so set left content (mailbox) size to full */
5138 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
5141 if (ug_data->b_internal != 1) {
5142 debug_log("ug_destory_me");
5143 ug_destroy_me(ug_data->ug);
5145 _hide_view(ug_data);
5150 case NOTI_ACCOUNT_DELETE:
5151 if (get_app_paused()) {
5152 debug_log("account deleted during pause status");
5155 if (ug_data->isRotate == false && ug_data->b_internal) {
5156 /* Viewer to hide, so set left content (mailbox) size to full */
5157 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
5160 if (email_engine_get_default_account(&account_id)) {
5161 if (ug_data->b_internal != 1) {
5162 debug_log("ug_destory_me");
5163 ug_destroy_me(ug_data->ug);
5165 _hide_view(ug_data);
5171 case NOTI_ACCOUNT_UPDATE:
5172 if (get_app_paused()) {
5173 debug_log("account updated during pause status");
5178 debug_warning("unknown type");
5182 debug_critical("receive data error: %s", error.message);
5183 dbus_error_free(&error);
5185 } else if (dbus_message_is_signal(message, "User.Email.NetworkStatus", "email")) {
5194 dbus_error_init(&error);
5196 if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &subtype,
5197 DBUS_TYPE_INT32, &data1, DBUS_TYPE_STRING, &data2,
5198 DBUS_TYPE_INT32, &data3, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID)) {
5199 debug_log("subtype: %d, data1: %d, data2: %s, data3: %d, data4: %d", subtype, data1, data2, data3, data4);
5202 case NOTI_DOWNLOAD_BODY_START:
5203 /* DATA1[mail_id] DATA2[file_id] DATA3[body_size] DATA4[received size] */
5204 debug_log("receive noti, DOWNLOAD_BODY");
5205 if (priv->mail_id == data1) {
5206 priv->file_id = g_strdup(data2);
5207 priv->file_size = data3;
5210 _set_value_down_progress(0.0);
5212 double per = (double)data4 / (double)data3;
5213 _set_value_down_progress(per);
5216 debug_log("mail_id is different");
5217 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5221 case NOTI_DOWNLOAD_MULTIPART_BODY:
5222 /* DATA1[mail_id] DATA2[file_id] DATA3[body_size] DATA4[received size] */
5223 debug_log("receive noti, DOWNLOAD_MULTIPART_BODY");
5224 if (priv->mail_id == data1) {
5225 priv->file_id = g_strdup(data2);
5226 priv->file_size = data3;
5227 priv->multi_body = TRUE;
5230 _set_value_down_progress(0.0);
5232 double per = (double)data4 / (double)data3;
5233 _set_value_down_progress(per);
5236 debug_log("mail_id is different");
5237 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5241 case NOTI_DOWNLOAD_BODY_FINISH:
5242 /* DATA1[mail_id] DATA2[NULL] DATA3[handle_id] */
5243 debug_log("receive noti, DOWNLOAD_BODY_FINISH");
5244 if (priv->email_handle == data3 && priv->mail_id == data1) {
5245 priv->email_handle = 0;
5247 ug_data->b_load_finished = EINA_FALSE;
5249 /* delete progress */
5250 if (ug_data->pb_notify) {
5251 _set_value_down_progress(1.0);
5252 _destroy_down_progress_cb(NULL, NULL, NULL);
5255 char str[128] = { 0, };
5256 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_BODY_DOWNLOADED"));
5257 int ret = status_message_post(str);
5259 debug_log("status_message_post failed: %d", ret);
5262 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
5263 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
5265 /* create att and body */
5266 if (ug_data->b_partial_body) {
5271 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
5272 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
5274 elm_box_unpack(ug_data->main_bx, ug_data->partial_dn_btn_bx);
5275 if (ug_data->partial_dn_btn) {
5276 evas_object_del(ug_data->partial_dn_btn);
5277 ug_data->partial_dn_btn = NULL;
5279 if (ug_data->partial_dn_btn_bx) {
5280 evas_object_del(ug_data->partial_dn_btn_bx);
5281 ug_data->partial_dn_btn_bx = NULL;
5284 if (ug_data->property->has_html) {
5285 ug_data->webview_data->body_type = BODY_TYPE_HTML;
5286 ug_data->webview_data->uri = ug_data->property->body_uri;
5288 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
5289 ug_data->webview_data->text_content = ug_data->property->body;
5292 viewer_set_webview_content(ug_data, 1);
5294 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
5295 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
5298 if (ug_data->property->has_attachment)
5299 ug_data->got_att = 1;
5301 ug_data->got_att = 0;
5303 /* pack attachment if it exist */
5304 if (ug_data->got_att) {
5305 _create_attach(ug_data);
5308 _create_body(ug_data);
5311 debug_log("email_handle or mail_id is different");
5312 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5313 debug_log("expected email_handle [%d], received email_handle [%d]", priv->email_handle, data3);
5317 case NOTI_DOWNLOAD_BODY_FAIL:
5318 /* DATA1[mail_id] DATA2[NULL] DATA3[handle_id] */
5319 debug_log("receive noti, DOWNLOAD_BODY_FAIL");
5320 if (priv->email_handle == data3 && priv->mail_id == data1) {
5321 priv->email_handle = 0;
5323 /* delete progress */
5324 if (ug_data->pb_notify) {
5325 _destroy_down_progress_cb(NULL, NULL, NULL);
5328 char *err_msg = _get_service_fail_type(data4);
5329 snprintf(fail_msg, sizeof(fail_msg), "%s<br>%s", _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), err_msg);
5330 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
5331 fail_msg, 1, dgettext("sys_string", "IDS_COM_SK_OK"),
5332 _popup_response_cb, NULL, NULL, NULL);
5335 debug_log("email_handle or mail_id is different");
5336 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5337 debug_log("expected email_handle [%d], received email_handle [%d]", priv->email_handle, data3);
5341 case NOTI_DOWNLOAD_ATTACH_START:
5342 /* DATA1[mail_id] DATA2[file_id] DATA3[attachment_id] DATA4[percentage] */
5343 debug_log("receive noti, DOWNLOAD_ATTACHMENT");
5344 if (priv->mail_id == data1) {
5345 priv->att_file_id = g_strdup(data2);
5346 priv->attachment_id = data3;
5349 /* Set the progressbar of particular attachment_id */
5350 _set_value_down_progress_by_index(0.0, priv->attachment_id);
5353 double per = (double)data4 / 100.0;
5354 /* Set the progressbar of particular attachment_id */
5355 _set_value_down_progress_by_index(per, priv->attachment_id);
5358 debug_log("mail_id is different");
5359 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5363 case NOTI_DOWNLOAD_ATTACH_FINISH:
5364 /* DATA1[mail_id] DATA2[NULL] DATA3[attachment_id] */
5365 debug_log("receive noti, DOWNLOAD_ATTACH_FINISH");
5367 if (priv->mail_id == data1) {
5368 int attach_index = 0;
5369 int attachment_id = (int)data3;
5370 debug_log("download_all_cnt [%d]", priv->download_all_cnt);
5372 if (priv->download_all_cnt > 0) {
5373 _set_value_down_progress_by_index(1.0, attachment_id);
5374 attach_index = _update_attachment_info(ug_data, attachment_id);
5375 if (priv->b_all_att_save) {
5376 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5377 _save_attachment(ug_data, attach_index);
5378 if (priv->download_all_cnt == 0) {
5379 priv->b_all_att_save = FALSE;
5382 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5383 _show_attachment(ug_data, attach_index);
5387 debug_log("mail_id or attachment_id is different");
5388 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5392 case NOTI_DOWNLOAD_ATTACH_FAIL:
5393 /* DATA1[mail_id] DATA2[NULL] DATA3[attachment_id] */
5394 debug_log("receive noti, DOWNLOAD_ATTACH_FAIL");
5395 if (priv->mail_id == data1) {
5396 int attach_index = _get_attachment_info_index(ug_data, data3);
5397 debug_log("download_all_cnt[%d]", priv->download_all_cnt);
5399 if (priv->download_all_cnt > 0) {
5400 if (ug_data->progress_bar[data3] != NULL && data4 != EMAIL_ERROR_CANCELLED)
5401 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5403 debug_log("Download already cancelled, No need to destroy again..!");
5405 if (data4 != EMAIL_ERROR_CANCELLED && ug_data->ug_composer == NULL) {
5406 char *err_msg = _get_service_fail_type(data4);
5407 snprintf(fail_msg, sizeof(fail_msg), "%s<br>%s", _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), err_msg);
5408 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"), fail_msg, 1,
5409 dgettext("sys_string", "IDS_COM_SK_OK"),
5410 _popup_response_cb, NULL, NULL, NULL);
5414 if (priv->b_all_att_save && priv->download_all_cnt == 0) {
5415 priv->b_all_att_save = FALSE;
5419 debug_log("mail_id is different");
5420 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5425 debug_log("unknown type");
5429 debug_log("receive data error: %s", error.message);
5430 dbus_error_free(&error);
5432 /*return DBUS_HANDLER_RESULT_HANDLED;*/
5435 /*return DBUS_HANDLER_RESULT_HANDLED;*/
5439 static void _delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item)
5443 if (contacts_list_item) {
5444 g_free(contacts_list_item->display);
5445 contacts_list_item->display = NULL;
5446 g_free(contacts_list_item->email_address);
5447 contacts_list_item->email_address = NULL;
5448 g_free(contacts_list_item);
5449 contacts_list_item = NULL;
5453 static void *_contact_search_by_email(EmailViewerUGD *ug_data, const char *search_word)
5456 if (!ug_data || !_g_ug_data) {
5457 debug_log("data is NULL");
5461 int ret = CTS_SUCCESS;
5462 CTSiter *iter = NULL;
5464 EMAIL_CONTACT_LIST_INFO_S *contacts_list_item = NULL;
5465 contacts_svc_connect();
5467 debug_log("search_word = %s", search_word);
5469 if (contacts_svc_get_list_with_str(CTS_LIST_EMAILINFOS_WITH_EMAIL, search_word, &iter) != CTS_SUCCESS) {
5473 ret = contacts_svc_iter_next(iter);
5475 if (CTS_SUCCESS == ret) {
5476 CTSvalue *row_info = NULL;
5478 row_info = contacts_svc_iter_get_info(iter);
5480 contacts_list_item = (EMAIL_CONTACT_LIST_INFO_S *)calloc(1, sizeof(EMAIL_CONTACT_LIST_INFO_S));
5482 int index = contacts_svc_value_get_int(row_info, CTS_LIST_EMAIL_CONTACT_ID_INT);
5484 contacts_list_item->index = index;
5485 contacts_list_item->display = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR));
5486 contacts_list_item->email_address = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_ADDR_STR));
5488 snprintf(contacts_list_item->display_name, sizeof(contacts_list_item->display_name), "%s", contacts_list_item->display);
5491 contacts_svc_value_free(row_info);
5494 contacts_svc_iter_remove(iter);
5497 contacts_svc_disconnect();
5499 return contacts_list_item;
5502 static void _set_value_down_progress(double val)
5507 debug_log("data is NULL");
5510 char buf[30] = { 0, };
5511 EmailViewerUGD *ug_data = _g_ug_data;
5513 sprintf(buf, "%s: %d", dgettext("sys_string", "IDS_COM_POP_DOWNLOADING"), (int)val);
5515 if (ug_data->pb_notify_lb) {
5516 elm_progressbar_value_set(ug_data->pb_notify_lb, val);
5517 elm_object_text_set(ug_data->pb_notify_lb, buf);
5521 static void _set_value_down_progress_by_index(double val, int index)
5526 debug_log("data is NULL");
5530 EmailViewerUGD *ug_data = _g_ug_data;
5531 EmailViewerProp *prop = ug_data->property;
5534 debug_log("val(%f) is MINUS", val);
5538 if (index < 0 || index >= ATTACH_MAX) {
5539 debug_log("index(%d) is overflowed", index);
5544 debug_log("prop is NULL");
5548 if (prop->attachments == NULL) {
5549 debug_log("attachments is NULL");
5553 int per = val * 100;
5554 int attach_index = _get_attachment_info_index(ug_data, index);
5555 EmailAttachmentType *info = g_list_nth_data(prop->attachments, attach_index);
5558 debug_log("info is NULL");
5561 if (ug_data->progress_bar[index] == NULL) {
5562 debug_log("obj is NULL");
5566 char *pszTemp = NULL;
5567 pszTemp = (char *)elm_object_style_get(ug_data->progress_bar[index]);
5569 if (STR_INVALID(pszTemp))
5572 if (g_strcmp0(pszTemp, "pending_list") == 0) {
5573 debug_log("pending_list so return");
5577 elm_progressbar_value_set(ug_data->progress_bar[index], val);
5579 if (ug_data->progress_bar_ly[index] != NULL) {
5580 char buf[30] = { 0, };
5581 snprintf(buf, sizeof(buf), "%d%%", per);
5583 Evas_Object *downloading_label2;
5584 downloading_label2 = elm_label_add(ug_data->progress_bar_ly[index]);
5585 elm_object_part_content_set(ug_data->progress_bar_ly[index], "elm.text.2", downloading_label2);
5586 char *buf_tagged = g_strconcat("<font_size=26><align=left><color=#646464FF>", buf, "</align></font_size>", NULL);
5587 elm_object_text_set(downloading_label2, buf_tagged);
5592 static void _cancel_download_attachment(EmailViewerUGD *ug_data)
5596 gboolean is_cancel = FALSE;
5599 debug_log("data is NULL");
5603 EmailViewerPrivate *priv = ug_data->email_data;
5604 EmailViewerProp *prop = ug_data->property;
5606 if (priv && priv->download_all_cnt <= 0) {
5607 debug_log("No attachment download to be cancelled!");
5611 for (i = 0; i <= prop->att_len; i++) {
5612 if (ug_data->progress_bar_ly[i]) {
5613 Evas_Object *btn = elm_object_part_content_get(ug_data->progress_bar_ly[i], "elm.icon.1");
5614 debug_log("Cancel btn for downloading attachment: %p", btn);
5616 evas_object_smart_callback_call(btn, "clicked", NULL);
5622 if (is_cancel == TRUE && ug_data->ug_composer == NULL) {
5623 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"), _("IDS_EMAIL_POP_CANCELLING_ATTACHMENT_DOWNLOAD_ING"),
5624 1, dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
5629 static char *_get_service_fail_type(int type)
5634 char str[MAX_STR_LEN] = { 0, };
5637 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("IP full"));
5638 return g_strdup(str);
5639 } else if (type == -176) {
5640 ret = _("IDS_EMAIL_POP_NO_SERVICE");
5641 return g_strdup(ret);
5642 } else if (type == -181) {
5643 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("Transport Error"));
5644 return g_strdup(str);
5645 } else if (type == EMAIL_ERROR_NETWORK_TOO_BUSY) {
5646 ret = _("IDS_EMAIL_POP_NETWORK_BUSY");
5647 return g_strdup(ret);
5648 } else if (type == EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS) {
5649 snprintf(str, sizeof(str), _("IDS_EMAIL_POP_YOU_CAN_ONLY_LOG_IN_ONCE_EVERY_PD_MINUTES"), 15);
5650 return g_strdup(str);
5651 } else if (type == EMAIL_ERROR_CONNECTION_FAILURE) {
5652 ret = dgettext("sys_string", "IDS_COM_POP_CONNECTION_FAILED");
5653 return g_strdup(ret);
5654 } else if (type == EMAIL_ERROR_LOGIN_FAILURE) {
5655 ret = _("IDS_EMAIL_POP_LOG_IN_FAILED");
5656 return g_strdup(ret);
5657 } else if (type == EMAIL_ERROR_AUTHENTICATE) {
5658 ret = _("IDS_EMAIL_POP_AUTHENTICATION_FAILED");
5659 return g_strdup(ret);
5660 } else if (type == EMAIL_ERROR_CANCELLED) {
5661 ret = _("IDS_EMAIL_POP_DOWNLOAD_CANCELLED");
5662 return g_strdup(ret);
5663 } else if (type == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) {
5664 ret = _("IDS_EMAIL_POP_EMAIL_DELETED_FROM_SERVER");
5665 return g_strdup(ret);
5666 } else if (type == EMAIL_ERROR_NO_SUCH_HOST) {
5667 ret = _("IDS_EMAIL_POP_HOST_NOT_FOUND");
5668 return g_strdup(ret);
5669 } else if (type == EMAIL_ERROR_INVALID_SERVER) {
5670 ret = _("IDS_EMAIL_POP_SERVER_NOT_AVAILABLE");
5671 return g_strdup(ret);
5672 } else if (type == EMAIL_ERROR_MAIL_MEMORY_FULL) {
5673 ret = _("IDS_EMAIL_POP_DEVICE_STORAGE_FULL");
5674 return g_strdup(ret);
5675 } else if (type == EMAIL_ERROR_FAILED_BY_SECURITY_POLICY) {
5676 ret = _("IDS_EMAIL_POP_DOWNLOADING_ATTACHMENTS_ON_THE_MOBILE_DEVICE_IS_NOT_ALLOWED_BY_EXCHANGE_SERVER_POLICY");
5677 return g_strdup(ret);
5679 snprintf(str, sizeof(str), "%s (%d)", dgettext("sys_string", "IDS_COM_POP_INTERNAL_ERROR"), type);
5680 return g_strdup(str);
5684 static Evas_Object *_load_edj(Evas_Object *parent, const char *file, const char *group)
5690 eo = elm_layout_add(parent);
5692 r = elm_layout_file_set(eo, file, group);
5694 evas_object_del(eo);
5698 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5705 static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part)
5711 static void _gl_del(void *data, Evas_Object *obj)
5715 if (_g_ug_data == NULL) {
5716 debug_log("ug_data is NULL");
5720 EmailViewerUGD *ug_data = _g_ug_data;
5722 if (ug_data->move_mailbox_list) {
5723 email_free_mailbox(&ug_data->move_mailbox_list, ug_data->move_mailbox_count);
5724 ug_data->move_mailbox_list = NULL;
5725 ug_data->move_mailbox_count = 0;
5731 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part)
5734 email_mailbox_t *mailbox_list = NULL;
5735 mailbox_list = (email_mailbox_t *) data;
5737 if (g_strcmp0(part, "elm.text") == 0) {
5738 char buf[MAX_STR_LEN] = { 0, };
5739 if (mailbox_list && mailbox_list->alias) {
5740 snprintf(buf, sizeof(buf), "%s", mailbox_list->alias);
5741 return g_strdup(buf);
5748 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part)
5752 if (g_strcmp0(part, "elm.icon") == 0) {
5753 Evas_Object *icon = elm_icon_add(obj);
5754 elm_icon_file_set(icon, IMGDIR "/U01_icon_folder.png", NULL);
5755 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
5763 static void _move_here_cb(void *data, Evas_Object *obj, void *event_info)
5767 if (data == NULL || _g_ug_data == NULL) {
5768 debug_log("data is NULL");
5772 email_mailbox_t *mailbox_list = NULL;
5773 mailbox_list = (email_mailbox_t *) data;
5775 EmailViewerUGD *ug_data = _g_ug_data;
5776 int folder_id = mailbox_list->mailbox_id;
5778 _move_email(ug_data, folder_id, FALSE);
5780 ug_data->navi_move_it1 = NULL;
5781 elm_naviframe_item_pop_to(ug_data->navi_main_it);
5783 if (ug_data->isRotate == false && ug_data->b_internal) {
5784 /* Viewer to hide, so set left content (mailbox) size to full */
5785 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
5788 if (ug_data->b_internal) {
5789 _hide_view(ug_data);
5791 /* send next or previous mail request to mailbox. */
5793 service_h service = NULL;
5795 ret = service_create(&service);
5796 debug_log("service_create: %d", ret);
5798 debug_log("service create failed");
5802 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
5803 debug_log("service_add_extra_data: %d", ret);
5804 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "1");
5805 debug_log("service_add_extra_data: %d", ret);
5807 ug_send_message(_g_mailbox_ug, service);
5809 ret = service_destroy(service);
5810 debug_log("service_destroy: %d", ret);
5812 ug_destroy_me(ug_data->ug);
5816 static void _move_back_cb(void *data, Evas_Object *obj, void *event_info)
5820 if (data == NULL || _g_ug_data == NULL) {
5821 debug_log("data is NULL");
5825 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
5827 elm_naviframe_item_pop(ug_data->navi_bar);
5828 ug_data->navi_move_it1 = NULL;
5830 /*if (ug_data->b_internal)
5831 elm_layout_theme_set(ug_data->layout_main, "layout", "controlbar", "default");
5833 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "controlbar");*/