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 _timezone_changed_cb(keynode_t *key, void *data);
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 *_create_partial_body_dn_btn(EmailViewerUGD *ug_data);
81 static Evas_Object *_create_bg(Evas_Object *win);
83 static void _create_down_progress(char *message, popup_cb resp_cb);
84 static void _create_down_progress_ex(int index, EMAIL_VIEWER_PROGRESSBAR_TYPE p_type);
85 static void _destroy_down_progress_ex(void *data, Evas_Object *obj, void *event_info);
86 static void _create_more_ctxpopup(EmailViewerUGD *ug_data, Evas_Object *obj);
87 static void _delete_evas_objects(EmailViewerUGD *ug_data);
89 /* callback functions */
90 static void _back_cb(void *data, Evas_Object *obj, void *event_info);
91 static void _reply_cb(void *data, Evas_Object *obj, void *event_info);
92 static void _reply_all_cb(void *data, Evas_Object *obj, void *event_info);
93 static void _reply_option_cb(void *data, Evas_Object *obj, void *event_info);
94 static void _forward_cb(void *data, Evas_Object *obj, void *event_info);
95 static void _resend_cb(void *data, Evas_Object *obj, void *event_info);
96 static void _cancel_send_cb(void *data, Evas_Object *obj, void *event_info);
97 static void _edit_email_cb(void *data, Evas_Object *obj, void *event_info);
98 static void _delete_cb(void *data, Evas_Object *obj, void *event_info);
99 static void _move_cb(void *data, Evas_Object *obj, void *event_info);
100 static void _more_cb(void *data, Evas_Object *obj, void *event_info);
101 static void _body_down_cb(void *data, Evas_Object *obj, void *event_info);
102 static void _subject_favorite_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
103 static void _subject_detail_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
104 static void _attachment_item_collapse_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
105 static void _attachment_save_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
106 static void _attachment_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
107 static void _attachment_save_all_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
108 static void _attachment_bg_set_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
109 static void _attachment_bg_unset_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
110 static void _mark_as_unread_cb(void *data, Evas_Object *obj, void *event_info);
111 static void _mark_as_read_cb(void *data, Evas_Object *obj, void *event_info);
112 static void _save_email_cb(void *data, Evas_Object *obj, void *event_info);
113 static Eina_Bool _save_email_prog_cb(void *data);
115 static void _ctxpopup_detail_contact_cb(void *data, Evas_Object *obj, void *event_info);
116 static void _ctxpopup_send_email_cb(void *data, Evas_Object *obj, void *event_info);
117 static void _ctxpopup_add_contact_cb(void *data, Evas_Object *obj, void *event_info);
118 static void _popup_waiting_response_cb(void *data, Evas_Object *obj, void *event_info);
119 static void _popup_response_cb(void *data, Evas_Object *obj, void *event_info);
120 static void _popup_response_delete_ok_cb(void *data, Evas_Object *obj, void *event_info);
121 static void _popup_response_move_to_trash_cb(void *data, Evas_Object *obj, void *event_info);
122 static void _popup_response_delete_permanent_cb(void *data, Evas_Object *obj, void *event_info);
123 static void _popup_response_to_destroy_cb(void *data, Evas_Object *obj, void *event_info);
125 static void _webview_policy_navigation_decide_cb(void *data, Evas_Object *obj, void *event_info);
127 static void _outter_scroller_bottom_hit_cb(void *data, Evas_Object *obj, void *event_info);
128 static void _outter_scroller_top_hit_cb(void *data, Evas_Object *obj, void *event_info);
129 static void _outter_scroller_scroll_cb(void *data, Evas_Object *obj, void *event_info);
131 static void _mbe_focused_cb(void *data, Evas_Object *obj, void *event_info);
132 static void _mbe_unfocused_cb(void *data, Evas_Object *obj, void *event_info);
133 static void _mbe_added_cb(void *data, Evas_Object *obj, void *event_info);
134 static void _mbe_selected_cb(void *data, Evas_Object *obj, void *event_info);
135 static void _destroy_down_progress_cb(void *data, Evas_Object *obj, void *event_info);
137 /* Logic Functions */
138 static int _viewer_create_temp_folder();
139 static void _viewer_remove_temp_folder();
140 static void _init_viewer_data(int account_id, int mail_id, char *srv_mail_id, EmailViewerUGD *ug_data);
141 static int _init_webview_data(EmailViewerUGD *ug_data);
142 static Eina_Bool _check_body_download(void *data);
143 static int _update_attachment_info(EmailViewerUGD *ug_data, int index);
144 static int _get_attachment_info_index(EmailViewerUGD *ug_data, int index);
145 static void _show_select_info(EmailViewerUGD *ug_data, char *str);
146 static void _save_attachment(EmailViewerUGD *ug_data, int index);
147 static void _show_attachment(EmailViewerUGD *ug_data, int index);
148 static void _save_attachment_all(EmailViewerUGD *ug_data);
149 static void _dbus_receiver_setup(EmailViewerUGD *ug_data);
150 static void _dbus_receiver_remove(EmailViewerUGD *ug_data);
151 static void _on_edbus_event_email_viewer_receive(void *local_data, DBusMessage *message);
153 static void _delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item);
154 static void *_contact_search_by_email(EmailViewerUGD *ug_data, const char *search_word);
155 static void _set_value_down_progress(double val);
156 static void _set_value_down_progress_by_index(double val, int index);
157 static void _cancel_download_attachment(EmailViewerUGD *ug_data);
160 static char *_get_service_fail_type(int type);
161 static Evas_Object *_load_edj(Evas_Object *parent, const char *file, const char *group);
164 static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part);
165 static void _gl_del(void *data, Evas_Object *obj);
166 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part);
167 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part);
168 static void _move_here_cb(void *data, Evas_Object *obj, void *event_info);
169 static void _move_back_cb(void *data, Evas_Object *obj, void *event_info);
172 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
176 EmailViewerUGD *ug_data;
181 ug_data = calloc(1, sizeof(EmailViewerUGD));
185 _g_ug_data = ug_data;
187 ops->create = on_create;
188 ops->start = on_start;
189 ops->pause = on_pause;
190 ops->resume = on_resume;
191 ops->destroy = on_destroy;
192 ops->message = on_message;
193 ops->event = on_event;
194 ops->key_event = on_key_event;
196 ops->opt = UG_OPT_INDICATOR_ENABLE;
201 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
204 EmailViewerUGD *ug_data;
216 static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h data, void *priv)
219 EmailViewerUGD *ug_data;
220 char *account_id = NULL;
221 char *mail_id = NULL;
222 char *mailbox_id = NULL;
223 char *binternal = NULL;
224 char *landscape = NULL;
233 debug_log("account_id and mail_id are required by arguments");
234 ug_data->b_direct_destroy = 1;
235 ug_destroy_me(ug_data->ug);
240 /* email engine initialize */
241 if (email_engine_initialize() == FALSE) {
242 debug_log("Failed to initialize email engine");
243 ug_data->b_direct_destroy = 1;
244 ug_destroy_me(ug_data->ug);
250 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_ACCOUNT_ID, (char **)&account_id);
251 debug_log("service_get_extra_data: %d", ret);
252 debug_log("account_id:%s", account_id);
253 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_MAIL_ID, (char **)&mail_id);
254 debug_log("service_get_extra_data: %d", ret);
255 debug_log("mail_id:%s", mail_id);
256 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_MAILBOX, (char **)&mailbox_id);
257 debug_log("service_get_extra_data: %d", ret);
258 debug_log("mailbox:%s", mailbox_id);
259 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_INTERNAL, (char **)&binternal);
260 debug_log("service_get_extra_data: %d", ret);
261 debug_log("binternal:%s", binternal);
262 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_FIRST_LANDSCAPE, (char **)&landscape);
263 debug_log("service_get_extra_data: %d", ret);
264 debug_log("landscape:%s", landscape);
267 ug_data->isRotate = atoi(landscape);
268 debug_log("@@@@ Landscape = %d @@@@", ug_data->isRotate);
273 ug_data->account_id = atoi(account_id);
274 ug_data->folder_list = email_engine_get_ca_mailbox_list_using_glist(ug_data->account_id);
279 ug_data->mail_id = atoi(mail_id);
284 g_free(ug_data->mailbox_name);
285 ug_data->mailbox_name = NULL;
286 ug_data->mailbox_id = atoi(mailbox_id);
290 email_mail_data_t *mail_data = NULL;
291 if ((err = email_get_mail_data(ug_data->mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
292 debug_log("fail to get mail - err (%d)", err);
295 if (mail_data == NULL) {
296 debug_log("mail_data is NULL");
297 ug_data->timeout_popup = elm_popup_add(ug_get_window());
298 evas_object_size_hint_weight_set(ug_data->timeout_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
299 elm_popup_timeout_set(ug_data->timeout_popup, 2);
300 elm_object_text_set(ug_data->timeout_popup, dgettext("sys_string", "IDS_COM_BODY_SELECTED_DATA_NOT_FOUND"));
301 elm_object_part_text_set(ug_data->timeout_popup, "title,text", _("IDS_EMAIL_POP_ALERT"));
302 evas_object_smart_callback_add(ug_data->timeout_popup, "block,clicked", _popup_response_to_destroy_cb, ug_data);
303 evas_object_smart_callback_add(ug_data->timeout_popup, "timeout", _popup_response_to_destroy_cb, ug_data);
304 evas_object_show(ug_data->timeout_popup);
306 return elm_layout_add(ug_get_window());
308 if (mail_data->server_mailbox_name)
309 ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name);
310 ug_data->mailbox_type = mail_data->mailbox_type;
311 debug_log("server_mailbox_name:%s", mail_data->server_mailbox_name);
312 debug_log("mailbox_name:%s", ug_data->mailbox_name);
313 debug_log("mailbox_type:%d", ug_data->mailbox_type);
316 debug_log("email_free_mail is called");
317 email_free_mail_data(&(mail_data), 1);
324 ug_data->b_internal = atoi(binternal);
325 if (ug_data->b_internal == 1)
326 debug_log("############Launched from email-mailbox###############");
330 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);
332 if (ug_data->account_id <= 0 || ug_data->mail_id <= 0 || ug_data->mailbox_id <= 0) {
333 debug_log("Required bundle parameters are missing!");
334 ug_data->timeout_popup = elm_popup_add(ug_get_window());
335 evas_object_size_hint_weight_set(ug_data->timeout_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
336 elm_popup_timeout_set(ug_data->timeout_popup, 2);
337 elm_object_text_set(ug_data->timeout_popup, _("IDS_EMAIL_POP_UNABLE_TO_OPEN_EMAIL_MESSAGE"));
338 elm_object_part_text_set(ug_data->timeout_popup, "title,text", _("IDS_EMAIL_POP_ALERT"));
339 evas_object_smart_callback_add(ug_data->timeout_popup, "block,clicked", _popup_response_to_destroy_cb, ug_data);
340 evas_object_smart_callback_add(ug_data->timeout_popup, "timeout", _popup_response_to_destroy_cb, ug_data);
341 evas_object_show(ug_data->timeout_popup);
343 return elm_layout_add(ug_get_window());
346 ug_data->win_main = ug_get_window();
348 char *proxy_address = vconf_get_str(VCONFKEY_NETWORK_PROXY);
349 debug_log("network proxy: %s", proxy_address);
350 if (proxy_address && (g_strcmp0(proxy_address, "") != 0)) {
351 ewk_context_proxy_uri_set(ewk_context_default_get(), proxy_address);
358 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
359 debug_log("WINDOW W[%d] H[%d]", w, h);
363 ug_data->scale_factor = elm_config_scale_get();
364 debug_log("ELM Scale[%f]", ug_data->scale_factor);
367 ug_data->webview_width = 710.0;
368 ug_data->webview_height = 949.0;
369 ug_data->webview_width_landscape = 710.0;
370 ug_data->webview_height_landscape = 568.0;
371 ug_data->webview_margin = 633;
372 ug_data->webview_margin_landscape = 379;
373 } else if (w == 720) {
374 ug_data->webview_width = 710.0;
375 ug_data->webview_height = 1122.0;
376 ug_data->webview_width_landscape = 710.0;
377 ug_data->webview_height_landscape = 558.0;
378 ug_data->webview_margin = 1029;
379 ug_data->webview_margin_landscape = 558;
381 ug_data->webview_width = 710.0;
382 ug_data->webview_height = 949.0;
383 ug_data->webview_width_landscape = 710.0;
384 ug_data->webview_height_landscape = 568.0;
385 ug_data->webview_margin = 633;
386 ug_data->webview_margin_landscape = 379;
389 ug_data->evas = evas_object_evas_get(ug_data->win_main);
391 /* Double_Scroller */
394 email_account_t *account = NULL;
395 if (email_engine_get_account_full_data(ug_data->account_id, &account)) {
396 debug_log("email_engine_get_account");
398 ug_data->account_type = account->incoming_server_type;
399 snprintf(ug_data->account_email_address, sizeof(ug_data->account_email_address), "%s", account->user_email_address);
401 account_user_data_t *ud = (account_user_data_t*)account->user_data;
403 debug_log("show_images is %d", ud->show_images);
404 ug_data->b_show_remote_images = ud->show_images;
410 email_free_account(&account, 1);
415 _dbus_receiver_setup(ug_data);
417 email_register_timezone_changed_callback(_timezone_changed_cb, ug_data);
419 _init_viewer_data(ug_data->account_id, ug_data->mail_id, NULL, ug_data);
420 _create_view(ug_data);
422 _check_body_download(ug_data);
424 ug_data->base = ug_data->layout_main;
426 ug_data->display_download_result = TRUE;
428 return ug_data->base;
431 static void on_start(ui_gadget_h ug, service_h data, void *priv)
436 static void on_pause(ui_gadget_h ug, service_h data, void *priv)
441 static void on_resume(ui_gadget_h ug, service_h data, void *priv)
446 static void on_destroy(ui_gadget_h ug, service_h data, void *pd)
449 EmailViewerUGD *ug_data;
458 if (ug_data->b_direct_destroy)
461 if (ug_data->email_data == NULL) {
462 debug_log("ug_data->email_data is NULL.");
466 EmailViewerPrivate *priv = ug_data->email_data;
470 if (ug_data->property) {
471 att_len = g_list_length(ug_data->property->attachments);
474 if (priv->email_handle != 0)
475 email_engine_stop_working(ug_data->account_id, priv->email_handle);
477 for (i = 0; i < att_len; i++) {
478 if (priv->download_all_email_handle[i] != 0)
479 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[i]);
482 _delete_evas_objects(ug_data);
484 debug_log("free webview_data");
485 if (ug_data->webview_data) {
486 free(ug_data->webview_data);
487 ug_data->webview_data = NULL;
490 if (ecore_file_exists(DIR_TMP_PREFIX"/mail.txt"))
491 ecore_file_remove(DIR_TMP_PREFIX"/mail.txt");
493 debug_log("free address info list");
494 email_free_address_info_list(&(priv->addrs_info_list));
495 ug_data->from_list = NULL;
496 ug_data->to_list = NULL;
497 ug_data->cc_list = NULL;
498 ug_data->bcc_list = NULL;
500 debug_log("free mail_info");
501 if (ug_data->email_data->mail_info) {
502 email_free_mail_data(&(ug_data->email_data->mail_info), 1);
503 ug_data->email_data->mail_info = NULL;
506 if (ug_data->email_data->attachment_info && ug_data->email_data->attachment_count > 0) {
507 email_free_attachment_data(&(ug_data->email_data->attachment_info), ug_data->email_data->attachment_count);
508 ug_data->email_data->attachment_info = NULL;
509 ug_data->email_data->attachment_count = 0;
512 debug_log("free email_data");
513 free(ug_data->email_data);
514 ug_data->email_data = NULL;
516 debug_log("free attachment");
517 if (ug_data->property) {
518 if (ug_data->property->attachments) {
520 LIST_ITER_START(i, ug_data->property->attachments) {
521 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, ug_data->property->attachments);
528 g_list_free(ug_data->property->attachments);
529 ug_data->property->attachments = NULL;
532 debug_log("free property");
533 if (ug_data->property) {
534 free(ug_data->property);
535 ug_data->property = NULL;
539 ug_data->base = NULL;
541 _viewer_remove_temp_folder();
542 email_deregister_timezone_changed_callback(_timezone_changed_cb);
544 _dbus_receiver_remove(NULL);
545 int ret = e_dbus_shutdown();
546 debug_log("ret: %d", ret);
548 email_engine_finalize();
553 static void on_message(ui_gadget_h ug, service_h msg, service_h data, void *priv)
560 debug_log("_g_ug_data - %p", _g_ug_data);
561 if (_g_ug_data != NULL) {
562 debug_log("Hide previous mail data");
563 _hide_view(_g_ug_data);
566 char *account_id = NULL;
567 char *mail_id = NULL;
568 char *mailbox_id = NULL;
569 char *binternal = NULL;
570 char *landscape = NULL;
572 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
573 _g_ug_data = ug_data;
577 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_ACCOUNT_ID, (char **)&account_id);
578 debug_log("service_get_extra_data: %d", ret);
579 debug_log("account_id:%s", account_id);
580 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_MAIL_ID, (char **)&mail_id);
581 debug_log("service_get_extra_data: %d", ret);
582 debug_log("mail_id:%s", mail_id);
583 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_MAILBOX, (char **)&mailbox_id);
584 debug_log("service_get_extra_data: %d", ret);
585 debug_log("mailbox:%s", mailbox_id);
586 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_INTERNAL, (char **)&binternal);
587 debug_log("service_get_extra_data: %d", ret);
588 debug_log("binternal:%s", binternal);
589 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_FIRST_LANDSCAPE, (char **)&landscape);
590 debug_log("service_get_extra_data: %d", ret);
591 debug_log("landscape:%s", landscape);
594 ug_data->isRotate = atoi(landscape);
595 debug_log("@@@@ Landscape = %d @@@@", ug_data->isRotate);
600 ug_data->account_id = atoi(account_id);
601 ug_data->folder_list = email_engine_get_ca_mailbox_list_using_glist(ug_data->account_id);
606 ug_data->mail_id = atoi(mail_id);
611 g_free(ug_data->mailbox_name);
612 ug_data->mailbox_name = NULL;
613 ug_data->mailbox_id = atoi(mailbox_id);
617 email_mail_data_t *mail_data = NULL;
618 if ((err = email_get_mail_data(ug_data->mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
619 debug_log("fail to get mail - err (%d)", err);
622 if (mail_data == NULL) {
623 debug_log("mail_data is NULL");
624 ug_data->timeout_popup = elm_popup_add(ug_get_window());
625 evas_object_size_hint_weight_set(ug_data->timeout_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
626 elm_popup_timeout_set(ug_data->timeout_popup, 2);
627 elm_object_text_set(ug_data->timeout_popup, dgettext("sys_string", "IDS_COM_BODY_SELECTED_DATA_NOT_FOUND"));
628 elm_object_part_text_set(ug_data->timeout_popup, "title,text", _("IDS_EMAIL_POP_ALERT"));
629 evas_object_smart_callback_add(ug_data->timeout_popup, "block,clicked", _popup_response_to_destroy_cb, ug_data);
630 evas_object_smart_callback_add(ug_data->timeout_popup, "timeout", _popup_response_to_destroy_cb, ug_data);
631 evas_object_show(ug_data->timeout_popup);
635 if (mail_data->server_mailbox_name)
636 ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name);
637 ug_data->mailbox_type = mail_data->mailbox_type;
638 debug_log("server_mailbox_name:%s", mail_data->server_mailbox_name);
639 debug_log("mailbox_name:%s", ug_data->mailbox_name);
640 debug_log("mailbox_type:%d", ug_data->mailbox_type);
643 debug_log("email_free_mail is called");
644 email_free_mail_data(&(mail_data), 1);
651 ug_data->b_internal = atoi(binternal);
652 if (ug_data->b_internal == 1)
653 debug_log("############Launched from email-mailbox###############");
657 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);
659 if (ug_data->account_id <= 0 || ug_data->mail_id <= 0 || ug_data->mailbox_id <= 0) {
660 debug_log("Required bundle parameters are missing!");
665 email_account_t *account = NULL;
666 if (email_engine_get_account_full_data(ug_data->account_id, &account)) {
667 debug_log("email_engine_get_account");
669 ug_data->account_type = account->incoming_server_type;
670 snprintf(ug_data->account_email_address, sizeof(ug_data->account_email_address), "%s", account->user_email_address);
672 account_user_data_t *ud = (account_user_data_t*)account->user_data;
674 debug_log("show_images is %d", ud->show_images);
675 ug_data->b_show_remote_images = ud->show_images;
679 Ewk_Settings *setting = ewk_view_settings_get(ug_data->webview);
681 debug_log("b_show_remote_images is %d", ug_data->b_show_remote_images);
682 if (ewk_settings_load_remote_images_set(setting, ug_data->b_show_remote_images) == EINA_FALSE) {
683 debug_log("SET remote images is FAILED!");
688 email_free_account(&account, 1);
692 _init_viewer_data(ug_data->account_id, ug_data->mail_id, NULL, ug_data);
694 evas_object_show(ug_data->layout_main);
695 evas_object_raise(ug_data->layout_main);
697 _reset_view(ug_data);
699 ug_data->display_download_result = TRUE;
702 static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *priv)
709 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
710 EmailViewerProp *prop = ug_data->property;
711 char date_time[MAX_STR_LEN] = { 0, };
712 char *formatted_date = NULL;
715 debug_log("rotate event = %d", event);
718 case UG_EVENT_LOW_MEMORY:
720 case UG_EVENT_LOW_BATTERY:
722 case UG_EVENT_LANG_CHANGE:
723 if (ug_data->reply_btn)
724 elm_object_text_set(ug_data->reply_btn, dgettext("sys_string", "IDS_COM_SK_REPLY"));
725 if (ug_data->delete_btn)
726 elm_object_text_set(ug_data->delete_btn, dgettext("sys_string", "IDS_COM_SK_DELETE"));
727 if (ug_data->resend_btn)
728 elm_object_text_set(ug_data->resend_btn, _("IDS_EMAIL_SK_RESEND"));
729 if (ug_data->cancel_btn)
730 elm_object_text_set(ug_data->cancel_btn, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
731 if (ug_data->move_btn)
732 elm_object_text_set(ug_data->move_btn, _("IDS_EMAIL_SK_MOVE"));
734 if (ug_data->dn_btn) {
735 elm_object_text_set(ug_data->dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_MESSAGE"));
738 if (ug_data->partial_dn_btn) {
739 elm_object_text_set(ug_data->partial_dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_FULL_MESSAGE"));
742 case UG_EVENT_ROTATE_PORTRAIT:
743 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
744 if (ug_data->b_internal && ug_data->isRotate == true) {
745 ewk_view_command_execute(ug_data->webview, "Unselect", NULL);
746 debug_log("In Full view - Showing navi bar");
748 if (ug_data->con_popup) {
749 evas_object_del(ug_data->con_popup);
750 ug_data->con_popup = NULL;
753 if (ug_data->navi_move_it1) {
755 Evas_Object *move_back_btn = elm_button_add(ug_data->navi_bar);
756 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
757 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb, ug_data);
758 elm_object_item_part_content_set(ug_data->navi_move_it1, "prev_btn", move_back_btn);
759 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_TRUE);
760 if (ug_data->move_cbar) {
761 elm_object_item_part_content_unset(ug_data->navi_move_it1, "controlbar");
762 evas_object_del(ug_data->move_cbar);
763 ug_data->move_cbar = NULL;
767 if (ug_data->b_btn) {
768 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
769 evas_object_del(ug_data->b_btn);
770 ug_data->b_btn = NULL;
773 ug_data->b_btn = elm_button_add(ug_data->navi_bar);
774 elm_object_style_set(ug_data->b_btn, "naviframe/back_btn/default");
775 evas_object_smart_callback_add(ug_data->b_btn, "clicked", _back_cb, ug_data);
776 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", ug_data->b_btn);
778 ug_data->isRotate = false;
783 case UG_EVENT_ROTATE_LANDSCAPE:
784 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
785 if (ug_data->b_internal && ug_data->isRotate == false) {
786 ewk_view_command_execute(ug_data->webview, "Unselect", NULL);
787 debug_log("In Split view - Hiding navi bar");
789 if (ug_data->con_popup) {
790 evas_object_del(ug_data->con_popup);
791 ug_data->con_popup = NULL;
794 if (ug_data->navi_move_it1) {
796 Evas_Object *move_back_btn = elm_button_add(ug_data->navi_bar);
797 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
798 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb, ug_data);
799 elm_object_item_part_content_set(ug_data->navi_move_it1, "prev_btn", move_back_btn);
800 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_FALSE);
801 if (ug_data->move_cbar) {
802 elm_object_item_part_content_unset(ug_data->navi_move_it1, "controlbar");
803 evas_object_del(ug_data->move_cbar);
804 ug_data->move_cbar = NULL;
808 if (ug_data->b_btn) {
809 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
810 evas_object_del(ug_data->b_btn);
811 ug_data->b_btn = NULL;
812 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
815 ug_data->isRotate = true;
820 case UG_EVENT_REGION_CHANGE:
821 appcore_get_timeformat(&icu_timeformat);
822 /* ICU API to set default locale */
823 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
824 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
826 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
827 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
829 free(formatted_date);
830 formatted_date = NULL;
832 edje_object_part_text_set(_EDJ(ug_data->ly_subject), "elm.text.sub", date_time);
833 evas_object_show(ug_data->ly_subject);
841 static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h data, void *priv)
848 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
849 EmailViewerPrivate *private = ug_data->email_data;
850 EmailViewerProp *prop = ug_data->property;
853 case UG_KEY_EVENT_END:
855 if (ug_data->notify != NULL || ug_data->pb_notify != NULL || ug_data->timeout_popup != NULL) {
856 if (ug_data->timeout_popup) {
857 evas_object_del(ug_data->timeout_popup);
858 ug_data->timeout_popup = NULL;
861 if (ug_data->notify) {
862 evas_object_del(ug_data->notify);
863 ug_data->notify = NULL;
866 if (ug_data->pb_notify) {
868 int att_len = g_list_length(prop->attachments);
870 evas_object_del(ug_data->pb_notify);
871 ug_data->pb_notify = NULL;
873 if (private->email_handle != 0)
874 email_engine_stop_working(ug_data->account_id, private->email_handle);
876 for (i = 0; i < att_len; i++) {
877 if (private->download_all_email_handle[i] != 0)
878 email_engine_stop_working(ug_data->account_id, private->download_all_email_handle[i]);
882 if (ug_data->pb_notify_lb) {
883 evas_object_del(ug_data->pb_notify_lb);
884 ug_data->pb_notify_lb = NULL;
887 if (ug_data->isRotate == false && ug_data->b_internal) {
888 /* Viewer to hide, so set left content (mailbox) size to full */
889 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
892 if (ug_data->b_internal)
895 ug_destroy_me(ug_data->ug);
899 service_h service = NULL;
901 ret = service_create(&service);
902 debug_log("service_create: %d", ret);
904 debug_log("service create failed");
908 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_END_KEY);
909 debug_log("service_add_extra_data: %d", ret);
911 ug_send_message(_g_mailbox_ug, service);
913 ret = service_destroy(service);
914 debug_log("service_destroy: %d", ret);
923 static void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
931 base = ug_get_layout(ug);
936 case UG_MODE_FULLVIEW:
937 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
938 evas_object_show(base);
945 static void result_cb(ui_gadget_h ug, service_h result, void *priv)
953 static void destroy_cb(ui_gadget_h ug, void *priv)
959 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
960 ug_data->display_download_result = TRUE;
962 if (ug == ug_data->ug_composer) {
963 ug_data->ug_composer = NULL;
969 static ui_gadget_h create_ug(char *ug_name, service_h bd, void *data)
973 struct ug_cbs cbs = { 0, };
975 cbs.layout_cb = layout_cb;
976 cbs.result_cb = result_cb;
977 cbs.destroy_cb = destroy_cb;
980 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
982 ug = ug_create(ug_data->ug, ug_name, UG_MODE_FULLVIEW, bd, &cbs);
987 static void _create_view(EmailViewerUGD *ug_data)
993 ug_data->bg = _create_bg(ug_data->win_main);
996 ug_data->layout_main = elm_layout_add(ug_data->win_main);
998 if (ug_data->b_internal)
999 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "noindicator");
1001 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "default");
1002 evas_object_size_hint_weight_set(ug_data->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1003 evas_object_show(ug_data->layout_main);
1005 elm_object_part_content_set(ug_data->layout_main, "elm.swallow.bg", ug_data->bg);
1008 elm_win_indicator_mode_set(ug_data->win_main, ELM_WIN_INDICATOR_SHOW);
1010 /* navigation Bar */
1011 _create_navigation_bar(ug_data);
1013 /* push navigation bar */
1014 ug_data->sub_ly = elm_layout_add(ug_data->navi_bar);
1015 elm_layout_theme_set(ug_data->sub_ly, "layout", "application", "noindicator");
1016 evas_object_size_hint_weight_set(ug_data->sub_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1017 evas_object_show(ug_data->sub_ly);
1020 b_btn = elm_button_add(ug_data->navi_bar);
1021 elm_object_style_set(b_btn, "naviframe/back_btn/default");
1022 evas_object_smart_callback_add(b_btn, "clicked", _back_cb, ug_data);
1023 ug_data->b_btn = b_btn;
1025 ug_data->navi_main_it = elm_naviframe_item_push(ug_data->navi_bar, NULL, b_btn, NULL, ug_data->sub_ly, NULL);
1026 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE);
1028 _create_tab_bar(ug_data);
1030 /* create scroller */
1031 ug_data->scroller = elm_scroller_add(ug_data->navi_bar);
1032 evas_object_propagate_events_set(ug_data->scroller, EINA_FALSE);
1033 elm_scroller_bounce_set(ug_data->scroller, EINA_FALSE, EINA_TRUE);
1034 elm_scroller_policy_set(ug_data->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
1035 evas_object_show(ug_data->scroller);
1036 evas_object_smart_callback_add(ug_data->scroller, "edge,bottom", _outter_scroller_bottom_hit_cb, ug_data);
1037 evas_object_smart_callback_add(ug_data->scroller, "edge,top", _outter_scroller_top_hit_cb, ug_data);
1038 evas_object_smart_callback_add(ug_data->scroller, "scroll,drag,start", _outter_scroller_scroll_cb, ug_data);
1040 elm_object_part_content_set(ug_data->sub_ly, "elm.swallow.content", ug_data->scroller);
1042 /* create main box */
1043 ug_data->main_bx = elm_box_add(ug_data->navi_bar);
1044 evas_object_size_hint_weight_set(ug_data->main_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1045 evas_object_size_hint_align_set(ug_data->main_bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1046 evas_object_show(ug_data->main_bx);
1047 elm_object_content_set(ug_data->scroller, ug_data->main_bx);
1049 if (ug_data->property->has_attachment)
1050 ug_data->got_att = 1;
1052 ug_data->got_att = 0;
1054 /* packing subject, addrs, attachment */
1055 _create_subject(ug_data);
1057 if (ug_data->got_att) {
1058 _create_attach(ug_data);
1061 if (ug_data->isRotate == true) {
1062 debug_log("In Split view - Hiding navi bar");
1064 if (ug_data->b_btn) {
1065 debug_log("hiding back button");
1067 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1068 evas_object_del(ug_data->b_btn);
1069 ug_data->b_btn = NULL;
1071 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
1076 static void _reset_view(EmailViewerUGD *ug_data)
1079 EmailViewerProp *prop = ug_data->property;
1081 char date_time[MAX_STR_LEN] = { 0, };
1083 debug_log("@@@@@@@@@@ isRotate = %d", ug_data->isRotate);
1084 if (ug_data->isRotate == true) {
1085 debug_log("In Split view - Hiding navi bar");
1087 if (ug_data->b_btn) {
1088 debug_log("hiding back button");
1090 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1091 evas_object_del(ug_data->b_btn);
1092 ug_data->b_btn = NULL;
1094 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
1097 /* Set scroller to start - height made 480 to consider viewer in split view */
1098 elm_scroller_region_show(ug_data->scroller, 0, 0, (int)((double)ug_data->main_h * 0.6), ug_data->main_w);
1100 debug_log("In Full view - Showing navi bar");
1102 if (ug_data->b_btn) {
1104 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1105 evas_object_del(ug_data->b_btn);
1106 ug_data->b_btn = NULL;
1109 debug_log("showing back button");
1111 ug_data->b_btn = elm_button_add(ug_data->navi_bar);
1112 elm_object_style_set(ug_data->b_btn, "naviframe/back_btn/default");
1113 evas_object_smart_callback_add(ug_data->b_btn, "clicked", _back_cb, ug_data);
1115 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", ug_data->b_btn);
1117 /* Set scroller to start */
1118 elm_scroller_region_show(ug_data->scroller, 0, 0, ug_data->main_w, ug_data->main_h);
1122 char *_subject = elm_entry_utf8_to_markup(prop->subject);
1123 if (!g_strcmp0(_subject, "")) {
1125 _subject = g_strdup(_("IDS_EMAIL_BODY_NO_SUBJECT"));
1127 char *_subject_concated = g_strconcat("<font_size=44><color=#000000FF>", _subject, "</color></font_size>", NULL);
1128 elm_object_text_set(ug_data->lb_subject, _subject_concated);
1129 elm_label_wrap_width_set(ug_data->lb_subject, ug_data->main_w - (int)(110 * ug_data->scale_factor));
1130 elm_label_line_wrap_set(ug_data->lb_subject, ELM_WRAP_WORD);
1132 g_free(_subject_concated);
1134 /* reset date & time */
1135 char *formatted_date = NULL;
1137 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1138 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
1140 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
1141 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
1143 free(formatted_date);
1144 formatted_date = NULL;
1146 elm_object_part_text_set(ug_data->ly_subject, "elm.text.sub", date_time);
1148 Evas_Object *favorite_icon = elm_icon_add(ug_data->ly_subject);
1149 switch(prop->favorite)
1151 case EMAIL_FLAG_NONE:
1152 elm_image_file_set(favorite_icon, IMGDIR "/M02_icon_favorite_off_74x74.png", NULL);
1154 case EMAIL_FLAG_FLAGED:
1155 elm_image_file_set(favorite_icon, IMGDIR "/M02_icon_favorite_on_74x74.png", NULL);
1157 case EMAIL_FLAG_TASK_STATUS_CLEAR:
1158 elm_image_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
1160 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
1161 elm_image_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
1163 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
1164 elm_image_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
1167 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1168 elm_image_resizable_set(favorite_icon, 1, 1);
1169 evas_object_del(elm_object_part_content_unset(ug_data->ly_subject, "elm.icon.favorite"));
1170 elm_object_part_content_set(ug_data->ly_subject, "elm.icon.favorite", favorite_icon);
1171 evas_object_show(favorite_icon);
1173 evas_object_show(ug_data->ly_subject);
1174 elm_box_pack_end(ug_data->main_bx, ug_data->ly_subject);
1176 Evas_Object *edje = elm_layout_edje_get(ug_data->ly_subject);
1178 if (!ug_data->to_list && !ug_data->cc_list && !ug_data->bcc_list) {
1179 edje_object_signal_emit(edje, "elm,state,arrow_hidden", "elm");
1181 edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _subject_detail_clicked_cb, ug_data->ly_subject);
1184 if (prop->has_attachment)
1185 ug_data->got_att = 1;
1187 ug_data->got_att = 0;
1189 /* pack attachment if it exist */
1190 if (ug_data->got_att) {
1191 _create_attach(ug_data);
1194 /* check body downloaded */
1195 _check_body_download(ug_data);
1198 void _hide_view(EmailViewerUGD *ug_data)
1201 EmailViewerProp *prop = ug_data->property;
1202 EmailViewerPrivate *priv = ug_data->email_data;
1204 debug_log("Cancelling all attachment downloads");
1205 _cancel_download_attachment(ug_data);
1207 ug_data->display_download_result = FALSE;
1210 if (elm_naviframe_top_item_get(ug_data->navi_bar) != ug_data->navi_main_it) {
1211 ug_data->navi_move_it1 = NULL;
1212 elm_naviframe_item_pop_to(ug_data->navi_main_it);
1215 evas_object_hide(ug_data->layout_main);
1216 elm_box_unpack_all(ug_data->main_bx);
1217 elm_object_scroll_freeze_pop(ug_data->scroller);
1219 evas_object_hide(ug_data->ly_subject);
1220 evas_object_hide(ug_data->lb_subject);
1221 evas_object_hide(ug_data->webview_bx);
1222 evas_object_hide(ug_data->webview);
1224 if (ug_data->partial_dn_btn) {
1225 evas_object_del(ug_data->partial_dn_btn);
1226 ug_data->partial_dn_btn = NULL;
1229 if (ug_data->partial_dn_btn_bx) {
1230 evas_object_del(ug_data->partial_dn_btn_bx);
1231 ug_data->partial_dn_btn_bx = NULL;
1234 if (ug_data->ctr_bar) {
1235 elm_object_item_part_content_unset(ug_data->navi_main_it, "controlbar");
1236 evas_object_del(ug_data->ctr_bar);
1237 ug_data->ctr_bar = NULL;
1240 if (ug_data->to_ly) {
1241 evas_object_del(ug_data->to_ly);
1242 ug_data->to_ly = NULL;
1245 if (ug_data->cc_ly) {
1246 evas_object_del(ug_data->cc_ly);
1247 ug_data->cc_ly = NULL;
1250 if (ug_data->bcc_ly) {
1251 evas_object_del(ug_data->bcc_ly);
1252 ug_data->bcc_ly = NULL;
1255 if (ug_data->got_att) {
1258 evas_object_del(ug_data->attach_hd_bk);
1259 ug_data->attach_hd_ly = NULL;
1260 ug_data->attach_hd_bk = NULL;
1262 if (prop->real_att_len > 1) {
1263 for (i = 0; i < prop->real_att_len; i++) {
1264 if (ug_data->attach_ex_ly != NULL) {
1265 if (ug_data->attach_ex_ly[i] != NULL) {
1266 debug_log("index %d", i);
1267 evas_object_del(ug_data->attach_ex_bk[i]);
1268 ug_data->attach_ex_ly[i] = NULL;
1269 ug_data->attach_ex_bk[i] = NULL;
1274 if (ug_data->attach_ex_ly != NULL) {
1275 free(ug_data->attach_ex_ly);
1276 ug_data->attach_ex_ly = NULL;
1277 ug_data->attach_ex_bk = NULL;
1281 for (i = 0; i <= prop->att_len; i++) {
1282 if (ug_data->progress_bar_ly[i] != NULL) {
1283 evas_object_del(ug_data->progress_bar_ly[i]);
1284 ug_data->progress_bar_ly[i] = NULL;
1285 ug_data->progress_bar[i] = NULL;
1290 if (ug_data->con_popup != NULL) {
1291 evas_object_del(ug_data->con_popup);
1292 ug_data->con_popup = NULL;
1295 if (ug_data->notify != NULL) {
1296 evas_object_del(ug_data->notify);
1297 ug_data->notify = NULL;
1300 edje_object_signal_emit(_EDJ(ug_data->ly_subject), "elm,state,contracted", "elm");
1301 edje_object_signal_callback_del(_EDJ(ug_data->ly_subject), "elm,action,expand,toggle", "elm", _subject_detail_clicked_cb);
1303 evas_object_hide(ug_data->noc_bx);
1304 evas_object_hide(ug_data->dn_btn);
1306 if (ecore_file_exists(EMAIL_TMP_FILE_PATH ".html"))
1307 ecore_file_remove(EMAIL_TMP_FILE_PATH ".html");
1309 if (ecore_file_exists(DIR_TMP_PREFIX"/mail.txt"))
1310 ecore_file_remove(DIR_TMP_PREFIX"/mail.txt");
1312 ewk_view_url_set(ug_data->webview, EMAIL_DEFAULT_HTML);
1314 _viewer_remove_temp_folder();
1316 debug_log("free address info list");
1317 email_free_address_info_list(&(priv->addrs_info_list));
1318 ug_data->from_list = NULL;
1319 ug_data->to_list = NULL;
1320 ug_data->cc_list = NULL;
1321 ug_data->bcc_list = NULL;
1323 ug_data->got_att = 0;
1324 ug_data->subject_onoff_flag = 0;
1325 ug_data->attach_onoff_flag = 0;
1326 ug_data->b_partial_body = 0;
1327 ug_data->b_internal = 0;
1328 ug_data->scroller_locked = 0;
1329 ug_data->m_is_multi_touch = 0;
1331 ug_data->navi_move_it1 = NULL;
1333 /* Double_Scroller */
1335 ug_data->b_load_finished = EINA_FALSE;
1336 ug_data->is_long_pressed = EINA_FALSE;
1337 ug_data->b_show_remote_images = EINA_FALSE;
1338 ug_data->is_webview_scrolling = EINA_FALSE;
1339 ug_data->is_main_scroller_scrolling = EINA_FALSE;
1342 static void _timezone_changed_cb(keynode_t *key, void *data)
1345 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
1346 EmailViewerProp *prop = ug_data->property;
1348 char date_time[MAX_STR_LEN] = { 0, };
1350 char *timezone_id = NULL;
1351 UChar utimezone_id[512] = { 0, };
1352 UErrorCode status = U_ZERO_ERROR;
1354 timezone_id = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
1359 u_uastrcpy(utimezone_id, timezone_id);
1361 ucal_setDefaultTimeZone(utimezone_id, &status);
1363 if (U_FAILURE(status))
1366 char *formatted_date = NULL;
1368 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1369 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
1371 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
1372 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
1373 free(formatted_date);
1374 formatted_date = NULL;
1376 elm_object_part_text_set(ug_data->ly_subject, "elm.text.sub", date_time);
1380 static Evas_Object *_create_navigation_bar(EmailViewerUGD *ug_data)
1383 Evas_Object *navi_bar;
1385 navi_bar = elm_naviframe_add(ug_data->layout_main);
1386 if (navi_bar == NULL) {
1387 debug_log("navi_bar == NULL");
1391 elm_object_part_content_set(ug_data->layout_main, "elm.swallow.content", navi_bar);
1392 evas_object_show(navi_bar);
1394 ug_data->navi_bar = navi_bar;
1398 static Evas_Object *_create_subject(EmailViewerUGD *ug_data)
1401 EmailViewerProp *prop = ug_data->property;
1403 char date_time[MAX_STR_LEN] = { 0, };
1405 /* append subject */
1406 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1407 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.detail_subject");
1408 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1410 Evas_Object *subject_label;
1411 subject_label = elm_label_add(di);
1412 elm_object_part_content_set(di, "elm.text", subject_label);
1413 char *subject = elm_entry_utf8_to_markup(prop->subject);
1414 if (!g_strcmp0(subject, "")) {
1416 subject = g_strdup(_("IDS_EMAIL_BODY_NO_SUBJECT"));
1418 char *subject_tagged = g_strconcat("<font_size=44><color=#000000FF>", subject, "</color></font_size>", NULL);
1419 elm_object_text_set(subject_label, subject_tagged);
1420 elm_label_wrap_width_set(subject_label, ug_data->main_w - (int)(110 * ug_data->scale_factor));
1421 elm_label_line_wrap_set(subject_label, ELM_WRAP_WORD);
1422 ug_data->lb_subject = subject_label;
1424 g_free(subject_tagged);
1426 char *formatted_date = NULL;
1428 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1429 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
1431 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
1432 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
1433 free(formatted_date);
1434 formatted_date = NULL;
1436 elm_object_part_text_set(di, "elm.text.sub", date_time);
1438 Evas_Object *favorite_icon = elm_icon_add(di);
1439 switch(prop->favorite)
1441 case EMAIL_FLAG_NONE:
1442 elm_image_file_set(favorite_icon, IMGDIR "/M02_icon_favorite_off_74x74.png", NULL);
1444 case EMAIL_FLAG_FLAGED:
1445 elm_image_file_set(favorite_icon, IMGDIR "/M02_icon_favorite_on_74x74.png", NULL);
1447 case EMAIL_FLAG_TASK_STATUS_CLEAR:
1448 elm_image_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
1450 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
1451 elm_image_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
1453 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
1454 elm_image_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
1457 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1458 elm_image_resizable_set(favorite_icon, 1, 1);
1459 elm_object_part_content_set(di, "elm.icon.favorite", favorite_icon);
1460 evas_object_show(favorite_icon);
1462 evas_object_show(di);
1463 elm_box_pack_end(ug_data->main_bx, di);
1464 ug_data->ly_subject = di;
1466 Evas_Object *edje = elm_layout_edje_get(di);
1468 if (ug_data->to_list || ug_data->cc_list || ug_data->bcc_list) {
1469 edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _subject_detail_clicked_cb, di);
1471 edje_object_signal_emit(edje, "elm,state,arrow_hidden", "elm");
1473 edje_object_signal_callback_add(edje, "elm,action,toggle", "elm", _subject_favorite_clicked_cb, di);
1478 static Evas_Object *_create_to_addrs(EmailViewerUGD *ug_data)
1481 email_address_info_t *addrs_info = NULL;
1482 Elm_Object_Item *mbe_item;
1484 if (ug_data->to_list == NULL) {
1485 debug_log("to_list is NULL");
1489 int n_to_list = g_list_length(ug_data->to_list);
1492 if (n_to_list <= 0) {
1493 debug_log("to_list count is 0");
1497 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1498 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1499 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1500 evas_object_show(di);
1501 ug_data->to_ly = di;
1502 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1504 Evas_Object *to_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1505 char desc[MAX_STR_LEN] = { 0, };
1506 snprintf(desc, MAX_STR_LEN, "%s:", dgettext("sys_string", "IDS_COM_BODY_TO"));
1507 char *to_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1508 elm_object_text_set(to_mbe, to_str);
1511 evas_object_smart_callback_add(to_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1512 evas_object_smart_callback_add(to_mbe, "item,added", _mbe_added_cb, ug_data);
1513 evas_object_smart_callback_add(to_mbe, "focused", _mbe_focused_cb, ug_data);
1514 evas_object_smart_callback_add(to_mbe, "unfocused", _mbe_unfocused_cb, ug_data);
1515 elm_object_part_content_set(di, "elm.icon", to_mbe);
1516 ug_data->to_mbe = to_mbe;
1518 Evas_Object *entry = elm_multibuttonentry_entry_get(to_mbe);
1520 elm_entry_editable_set(entry, EINA_FALSE);
1522 if (n_to_list > EMAIL_VIEW_MAX_TO_COUNT)
1523 n_to_list = EMAIL_VIEW_MAX_TO_COUNT;
1525 for (i = 0; i < n_to_list; i++) {
1526 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->to_list, i);
1527 debug_log("Address:%s", addrs_info->address);
1528 debug_log("Display Name:%s", addrs_info->display_name);
1529 debug_log("Storage Type:%d", addrs_info->storage_type);
1530 debug_log("Contact ID:%d", addrs_info->contact_id);
1532 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1533 mbe_item = elm_multibuttonentry_item_append(to_mbe, addrs_info->display_name, NULL, NULL);
1535 mbe_item = elm_multibuttonentry_item_append(to_mbe, addrs_info->address, NULL, NULL);
1536 elm_object_item_data_set(mbe_item, addrs_info);
1542 static Evas_Object *_create_cc_addrs(EmailViewerUGD *ug_data)
1545 email_address_info_t *addrs_info = NULL;
1546 Elm_Object_Item *mbe_item;
1548 if (ug_data->cc_list == NULL) {
1549 debug_log("cc_list is NULL");
1553 int n_cc_list = g_list_length(ug_data->cc_list);
1556 if (n_cc_list <= 0) {
1557 debug_log("cc_list count is 0");
1561 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1562 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1563 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1564 evas_object_show(di);
1565 ug_data->cc_ly = di;
1567 if (ug_data->to_ly) {
1568 elm_box_pack_after(ug_data->main_bx, di, ug_data->to_ly);
1570 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1573 Evas_Object *cc_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1574 char desc[MAX_STR_LEN] = { 0, };
1575 snprintf(desc, MAX_STR_LEN, "%s:", _("IDS_EMAIL_BODY_CC"));
1576 char *cc_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1577 elm_object_text_set(cc_mbe, cc_str);
1579 evas_object_smart_callback_add(cc_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1580 evas_object_smart_callback_add(cc_mbe, "item,added", _mbe_added_cb, ug_data);
1581 evas_object_smart_callback_add(cc_mbe, "focused", _mbe_focused_cb, ug_data);
1582 evas_object_smart_callback_add(cc_mbe, "unfocused", _mbe_unfocused_cb, ug_data);
1583 elm_object_part_content_set(di, "elm.icon", cc_mbe);
1584 ug_data->cc_mbe = cc_mbe;
1586 Evas_Object *entry = elm_multibuttonentry_entry_get(cc_mbe);
1588 elm_entry_editable_set(entry, EINA_FALSE);
1590 if (n_cc_list > EMAIL_VIEW_MAX_CC_COUNT)
1591 n_cc_list = EMAIL_VIEW_MAX_CC_COUNT;
1593 for (i = 0; i < n_cc_list; i++) {
1594 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->cc_list, i);
1596 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1597 mbe_item = elm_multibuttonentry_item_append(cc_mbe, addrs_info->display_name, NULL, NULL);
1599 mbe_item = elm_multibuttonentry_item_append(cc_mbe, addrs_info->address, NULL, NULL);
1600 elm_object_item_data_set(mbe_item, addrs_info);
1606 static Evas_Object *_create_bcc_addrs(EmailViewerUGD *ug_data)
1609 email_address_info_t *addrs_info = NULL;
1610 Elm_Object_Item *mbe_item;
1612 if (ug_data->bcc_list == NULL) {
1613 debug_log("bcc_list is NULL");
1617 int n_bcc_list = g_list_length(ug_data->bcc_list);
1620 if (n_bcc_list <= 0) {
1621 debug_log("bcc_list count is 0");
1625 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1626 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1627 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1628 evas_object_show(di);
1629 ug_data->bcc_ly = di;
1631 if (ug_data->cc_ly) {
1632 elm_box_pack_after(ug_data->main_bx, di, ug_data->cc_ly);
1634 if (ug_data->to_ly && ug_data->cc_ly == NULL) {
1635 elm_box_pack_after(ug_data->main_bx, di, ug_data->to_ly);
1637 if (ug_data->to_ly == NULL && ug_data->cc_ly == NULL) {
1638 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1641 Evas_Object *bcc_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1642 char desc[MAX_STR_LEN] = { 0, };
1643 snprintf(desc, MAX_STR_LEN, "%s:", _("IDS_EMAIL_BODY_BCC"));
1644 char *bcc_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1645 elm_object_text_set(bcc_mbe, bcc_str);
1647 evas_object_smart_callback_add(bcc_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1648 evas_object_smart_callback_add(bcc_mbe, "item,added", _mbe_added_cb, ug_data);
1649 evas_object_smart_callback_add(bcc_mbe, "focused", _mbe_focused_cb, ug_data);
1650 evas_object_smart_callback_add(bcc_mbe, "unfocused", _mbe_unfocused_cb, ug_data);
1651 elm_object_part_content_set(di, "elm.icon", bcc_mbe);
1652 ug_data->bcc_mbe = bcc_mbe;
1654 Evas_Object *entry = elm_multibuttonentry_entry_get(bcc_mbe);
1656 elm_entry_editable_set(entry, EINA_FALSE);
1658 if (n_bcc_list > EMAIL_VIEW_MAX_BCC_COUNT)
1659 n_bcc_list = EMAIL_VIEW_MAX_BCC_COUNT;
1661 for (i = 0; i < n_bcc_list; i++) {
1662 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->bcc_list, i);
1664 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1665 mbe_item = elm_multibuttonentry_item_append(bcc_mbe, addrs_info->display_name, NULL, NULL);
1667 mbe_item = elm_multibuttonentry_item_append(bcc_mbe, addrs_info->address, NULL, NULL);
1668 elm_object_item_data_set(mbe_item, addrs_info);
1674 static Evas_Object *_create_attach(EmailViewerUGD *ug_data)
1678 EmailViewerProp *prop = ug_data->property;
1679 char buff[MAX_STR_LEN];
1681 int att_len = prop->real_att_len;
1684 RETURN_VAL_IF_FAIL(prop->attachments != NULL, NULL);
1685 RETURN_VAL_IF_FAIL(att_len > 0, NULL);
1687 GList *attachment_list = prop->attachments;
1690 LIST_ITER_START(i, attachment_list) {
1691 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
1693 if (info && !info->inline_content) {
1694 if (info->size < 1024) {
1695 g_sprintf(buff, "%s (%d %s)", info->name, (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
1697 gdouble tmpsize = (gdouble) (info->size / 1024.);
1698 if (tmpsize < 1024) {
1699 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1702 if (tmpsize < 1024) {
1703 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1706 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1711 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1712 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_item");
1713 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1714 evas_object_show(di);
1715 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1717 Evas_Object *thumbnail = NULL;
1719 if (info->download_yn) {
1720 thumbnail = viewer_make_thumbnail(info->path, di);
1722 thumbnail = viewer_make_thumbnail(NULL, di);
1723 evas_object_size_hint_aspect_set(thumbnail, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1724 elm_image_resizable_set(thumbnail, 1, 1);
1725 elm_object_part_content_set(di, "elm.icon", thumbnail);
1726 evas_object_show(thumbnail);
1728 elm_object_part_text_set(di, "elm.text", buff);
1732 Evas_Object *edje = elm_layout_edje_get(di);
1733 edje_object_signal_callback_add(edje, "elm,action,download", "elm", _attachment_save_cb, (void *)att_index);
1734 edje_object_signal_callback_add(edje, "clicked", "*", _attachment_clicked_cb, (void *)att_index);
1736 Evas_Object *text_bg = NULL;
1737 text_bg = (Evas_Object *)edje_object_part_object_get(_EDJ(di), "elm.event.rect");
1740 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_DOWN, _attachment_bg_set_cb, (void *)att_index);
1741 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_UP, _attachment_bg_unset_cb, (void *)att_index);
1744 ug_data->attach_hd_ly = di;
1745 ug_data->attach_hd_bk = di;
1748 } else if (att_len > 1) {
1749 gint64 total_size = prop->total_att_size;
1751 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1752 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_head");
1753 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1754 snprintf(buff, sizeof(buff), "%d %s", att_len, _("IDS_EMAIL_BODY_ATTACHMENTS"));
1756 Evas_Object *att_head_label;
1757 att_head_label = elm_label_add(di);
1758 elm_object_part_content_set(di, "elm.text", att_head_label);
1760 char *buff_tagged = g_strconcat("<font_size=35><color=#000000FF>", buff, "<color></font_size>", NULL);
1761 elm_object_text_set(att_head_label, buff_tagged);
1762 g_free(buff_tagged);
1764 if (total_size < 1024) {
1765 g_sprintf(buff, "(%d %s)", (gint) total_size, dgettext("sys_string", "IDS_COM_BODY_B"));
1767 gdouble tmpsize = (gdouble) (total_size / 1024.);
1769 if (tmpsize < 1024) {
1770 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1774 if (tmpsize < 1024) {
1775 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1778 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1783 edje_object_part_text_set(_EDJ(di), "elm.text.sub", buff);
1785 Evas_Object *edje = elm_layout_edje_get(di);
1786 edje_object_signal_callback_add(edje, "att,icon,save,all", "", _attachment_save_all_cb, di);
1787 edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _attachment_item_collapse_cb, di);
1788 evas_object_show(di);
1789 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1790 ug_data->attach_hd_ly = di;
1791 ug_data->attach_hd_bk = di;
1793 _create_attach_ex(ug_data);
1795 for (i = 0; i < prop->real_att_len; i++) {
1796 if (ug_data->attach_ex_ly[i] != NULL) {
1797 debug_log("index %d", i);
1798 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[i]);
1799 evas_object_hide(ug_data->attach_ex_ly[i]);
1803 debug_log("Attachment doesn't exist");
1809 static Evas_Object *_create_attach_ex(EmailViewerUGD *ug_data)
1813 EmailViewerProp *prop = ug_data->property;
1814 char buff[MAX_STR_LEN];
1817 int att_len = prop->real_att_len;
1820 RETURN_VAL_IF_FAIL(prop->attachments != NULL, NULL);
1821 RETURN_VAL_IF_FAIL(att_len > 0, NULL);
1823 GList *attachment_list = prop->attachments;
1825 ug_data->attach_ex_ly = (Evas_Object **)calloc(att_len, sizeof(Evas_Object *));
1826 ug_data->attach_ex_bk = (Evas_Object **)calloc(att_len, sizeof(Evas_Object *));
1828 LIST_ITER_START(i, attachment_list) {
1829 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
1831 if (info && !info->inline_content) {
1832 if (info->size < 1024) {
1833 g_sprintf(buff, "%s (%d %s)", info->name, (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
1835 gdouble tmpsize = (gdouble) (info->size / 1024.);
1836 if (tmpsize < 1024) {
1837 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1840 if (tmpsize < 1024) {
1841 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1844 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1849 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1850 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_item");
1851 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1852 elm_box_pack_after(ug_data->main_bx, di, ug_data->attach_hd_ly);
1853 evas_object_show(di);
1855 Evas_Object *thumbnail = NULL;
1857 if (info->download_yn) {
1858 thumbnail = viewer_make_thumbnail(info->path, di);
1860 thumbnail = viewer_make_thumbnail(NULL, di);
1861 evas_object_size_hint_aspect_set(thumbnail, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1862 elm_image_resizable_set(thumbnail, 1, 1);
1863 elm_object_part_content_set(di, "elm.icon", thumbnail);
1864 evas_object_show(thumbnail);
1866 elm_object_part_text_set(di, "elm.text", buff);
1870 Evas_Object *edje = elm_layout_edje_get(di);
1871 edje_object_signal_callback_add(edje, "elm,action,download", "elm", _attachment_save_cb, (void *)att_index);
1872 edje_object_signal_callback_add(edje, "clicked", "*", _attachment_clicked_cb, (void *)att_index);
1874 Evas_Object *text_bg = NULL;
1875 text_bg = (Evas_Object *)edje_object_part_object_get(_EDJ(di), "elm.event.rect");
1878 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_DOWN, _attachment_bg_set_cb, (void *)att_index);
1879 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_UP, _attachment_bg_unset_cb, (void *)att_index);
1882 debug_log("attach ly %d, att_index %d", j, i);
1884 ug_data->attach_ex_ly[j] = di;
1885 ug_data->attach_ex_bk[j] = di;
1894 static Evas_Object *_create_body(EmailViewerUGD *ug_data)
1897 EmailViewerProp *prop = ug_data->property;
1898 EmailViewerPrivate *priv = ug_data->email_data;
1902 if (ug_data->noc_bx) {
1903 elm_box_unpack(ug_data->main_bx, ug_data->noc_bx);
1904 evas_object_hide(ug_data->noc_bx);
1907 if (ug_data->dn_btn) {
1908 evas_object_hide(ug_data->dn_btn);
1911 if (ug_data->webview_bx) {
1912 _init_webview_data(ug_data);
1914 ewk_view_scale_set(ug_data->webview, 1.0f, 0, 0);
1916 if (prop->has_html) {
1918 ug_data->webview_data->body_type_prev = BODY_TYPE_HTML;
1919 ug_data->webview_data->body_type = BODY_TYPE_HTML;
1920 ug_data->webview_data->uri = prop->body_uri;
1923 ug_data->webview_data->body_type_prev = BODY_TYPE_TEXT;
1924 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
1925 ug_data->webview_data->text_content = prop->body;
1928 viewer_set_webview_content(ug_data, 0);
1930 evas_object_show(ug_data->webview_bx);
1931 evas_object_show(ug_data->webview);
1932 elm_box_pack_end(ug_data->main_bx, ug_data->webview_bx);
1934 /* create webview layout */
1935 ug_data->webview_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.web_view");
1936 if (ug_data->webview_bx == NULL) {
1937 debug_log("Cannot load edj");
1941 evas_object_size_hint_align_set(ug_data->webview_bx, EVAS_HINT_FILL, 0.0);
1942 evas_object_show(ug_data->webview_bx);
1943 elm_box_pack_end(ug_data->main_bx, ug_data->webview_bx);
1945 /* create webview */
1946 if (NULL == ug_data->webview) {
1947 _init_webview_data(ug_data);
1948 viewer_get_webview(ug_data, prop->has_html);
1950 if (prop->has_html) {
1951 ug_data->webview_data->body_type_prev = BODY_TYPE_HTML;
1952 ug_data->webview_data->body_type = BODY_TYPE_HTML;
1953 ug_data->webview_data->uri = prop->body_uri;
1955 ug_data->webview_data->body_type_prev = BODY_TYPE_TEXT;
1956 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
1957 ug_data->webview_data->text_content = prop->body;
1959 viewer_set_webview_content(ug_data, 0);
1962 evas_object_show(ug_data->webview);
1963 elm_object_part_content_set(ug_data->webview_bx, "web_body", ug_data->webview);
1967 if (ug_data->isRotate) {
1968 resized_w = ug_data->webview_width_landscape * ug_data->scale_factor;
1969 resized_h = ug_data->webview_height_landscape * ug_data->scale_factor;
1971 resized_w = ug_data->webview_width * ug_data->scale_factor;
1972 resized_h = ug_data->webview_height * ug_data->scale_factor;
1974 debug_log("resized_w:%d, resized_h:%d", resized_w, resized_h);
1976 evas_object_size_hint_min_set(ug_data->webview, resized_w, resized_h);
1978 /* set touch callbacks */
1979 evas_object_smart_callback_add(ug_data->webview, "policy,navigation,decide", _webview_policy_navigation_decide_cb, ug_data);
1982 viewer_set_mail_seen(prop, priv->mail_info);
1984 if (ug_data->timer) {
1985 ecore_timer_del(ug_data->timer);
1986 ug_data->timer = NULL;
1989 debug_log("send message - list unlock");
1990 ug_data->timer = ecore_timer_add(0.0, viewer_send_message, ug_data);
1992 return ug_data->webview_bx;
1995 static Evas_Object *_create_toolbar_btn(Evas_Object *parent, const char *text, Evas_Smart_Cb func, void *data, const char *style)
1998 Evas_Object *btn = elm_button_add(parent);
1999 if (!btn) return NULL;
2001 elm_object_style_set(btn, style);
2003 elm_object_style_set(btn, "naviframe/toolbar/default");
2004 elm_object_text_set(btn, text);
2005 evas_object_smart_callback_add(btn, "clicked", func, data);
2009 static Evas_Object *_create_toolbar_more_btn(Evas_Object *parent, Evas_Smart_Cb func, void *data)
2012 Evas_Object *btn = elm_button_add(parent);
2013 if (!btn) return NULL;
2014 elm_object_style_set(btn, "naviframe/more/default");
2015 evas_object_smart_callback_add(btn, "clicked", func, data);
2019 static Evas_Object *_create_tab_bar(EmailViewerUGD *ug_data)
2021 debug_log("mailbox_type:%d", ug_data->mailbox_type);
2023 EmailViewerProp *prop = ug_data->property;
2024 Evas_Object *more_btn = NULL;
2026 more_btn = _create_toolbar_more_btn(ug_data->navi_bar, _more_cb, ug_data);
2027 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_more_btn", more_btn);
2029 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX ||
2030 ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX) {
2032 int n_to_list = g_list_length(ug_data->to_list);
2033 int n_cc_list = g_list_length(ug_data->cc_list);
2034 debug_log("to:%d, cc:%d", n_to_list, n_cc_list);
2035 if (n_to_list + n_cc_list >= 2) {
2036 ug_data->reply_btn = _create_toolbar_btn(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_SK_REPLY"), _reply_option_cb, ug_data, "naviframe/toolbar/left");
2038 ug_data->reply_btn = _create_toolbar_btn(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_SK_REPLY"), _reply_cb, ug_data, "naviframe/toolbar/left");
2040 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_button1", ug_data->reply_btn);
2041 ug_data->delete_btn = _create_toolbar_btn(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data, "naviframe/toolbar/right");
2042 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_button2", ug_data->delete_btn);
2043 } else if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_OUTBOX) {
2044 debug_log("save_status: %d", prop->status2);
2045 if (prop->status2 == EMAIL_MAIL_STATUS_SEND_WAIT || prop->status2 == EMAIL_MAIL_STATUS_SEND_FAILURE) {
2046 ug_data->cancel_btn = _create_toolbar_btn(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_SK_CANCEL"), _cancel_send_cb, ug_data, "naviframe/toolbar/left");
2047 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_button1", ug_data->cancel_btn);
2048 ug_data->delete_btn = _create_toolbar_btn(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data, "naviframe/toolbar/right");
2049 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_button2", ug_data->delete_btn);
2050 } else if (prop->status2 == EMAIL_MAIL_STATUS_SEND_CANCELED) {
2051 ug_data->resend_btn = _create_toolbar_btn(ug_data->navi_bar, _("IDS_EMAIL_SK_RESEND"), _resend_cb, ug_data, "naviframe/toolbar/left");
2052 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_button1", ug_data->resend_btn);
2053 ug_data->delete_btn = _create_toolbar_btn(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data, "naviframe/toolbar/right");
2054 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_button2", ug_data->delete_btn);
2056 ug_data->move_btn = _create_toolbar_btn(ug_data->navi_bar, _("IDS_EMAIL_SK_MOVE"), _move_cb, ug_data, "naviframe/toolbar/left");
2057 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_button1", ug_data->move_btn);
2058 ug_data->delete_btn = _create_toolbar_btn(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data, "naviframe/toolbar/right");
2059 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_button1", ug_data->delete_btn);
2062 ug_data->move_btn = _create_toolbar_btn(ug_data->navi_bar, _("IDS_EMAIL_SK_MOVE"), _move_cb, ug_data, "naviframe/toolbar/left");
2063 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_button1", ug_data->move_btn);
2064 ug_data->delete_btn = _create_toolbar_btn(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data, "naviframe/toolbar/right");
2065 elm_object_item_part_content_set(ug_data->navi_main_it, "toolbar_button2", ug_data->delete_btn);
2071 static Evas_Object *_create_partial_body_dn_btn(EmailViewerUGD *ug_data)
2075 ug_data->partial_dn_btn_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.partial_download_btn");
2076 if (ug_data->partial_dn_btn_bx == NULL) {
2077 debug_log("Cannot load edj");
2081 evas_object_size_hint_align_set(ug_data->partial_dn_btn_bx, EVAS_HINT_FILL, 0.0);
2082 evas_object_show(ug_data->partial_dn_btn_bx);
2083 elm_box_pack_before(ug_data->main_bx, ug_data->partial_dn_btn_bx, ug_data->webview_bx);
2085 Evas_Object *dn_btn = elm_button_add(ug_data->navi_bar);
2086 elm_object_text_set(dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_FULL_MESSAGE"));
2087 evas_object_smart_callback_add(dn_btn, "clicked", _body_down_cb, (void *)ug_data);
2088 elm_object_style_set(dn_btn, "text_only/style2");
2089 evas_object_show(dn_btn);
2090 ug_data->partial_dn_btn = dn_btn;
2092 elm_object_part_content_set(ug_data->partial_dn_btn_bx, "button", ug_data->partial_dn_btn);
2094 return ug_data->partial_dn_btn_bx;
2097 static Evas_Object *_create_bg(Evas_Object *win)
2101 Evas_Object *bg = elm_bg_add(win);
2102 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2103 evas_object_show(bg);
2108 static void _create_down_progress(char *message, popup_cb resp_cb)
2113 debug_log("data is NULL");
2117 EmailViewerUGD *ug_data = _g_ug_data;
2118 Evas_Object *notify, *pb;
2120 notify = elm_popup_add(ug_data->win_main);
2122 debug_log("elm_popup_add returns NULL");
2125 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2126 ug_data->pb_notify = notify;
2128 elm_object_part_text_set(notify, "title,text", message);
2130 pb = elm_progressbar_add(notify);
2132 elm_object_style_set(pb, "list_progress");
2134 elm_progressbar_horizontal_set(pb, EINA_TRUE);
2135 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, EVAS_HINT_FILL);
2136 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2137 evas_object_show(pb);
2138 elm_progressbar_value_set(pb, 0.0);
2139 elm_object_content_set(notify, pb);
2140 ug_data->pb_notify_lb = pb;
2142 Evas_Object *btn1 = elm_button_add(notify);
2143 elm_object_style_set(btn1, "popup_button/default");
2144 elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
2145 elm_object_part_content_set(notify, "button1", btn1);
2146 evas_object_smart_callback_add(btn1, "clicked", resp_cb, ug_data);
2147 debug_log("Cancel btn1 for downloading body: %p", btn1);
2149 evas_object_show(notify);
2152 static void _create_down_progress_ex(int index, EMAIL_VIEWER_PROGRESSBAR_TYPE p_type)
2157 debug_log("data is NULL");
2161 EmailViewerUGD *ug_data = _g_ug_data;
2162 EmailViewerProp *prop = ug_data->property;
2163 EmailViewerPrivate *priv = ug_data->email_data;
2165 if (!prop || !prop->attachments) {
2179 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
2180 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
2182 GList *attachment_list = prop->attachments;
2184 debug_log("index %d of attachment_count %d", index, prop->att_len);
2186 EmailAttachmentType *info = NULL;
2187 info = g_list_nth_data(attachment_list, index);
2189 debug_log("info is NULL");
2192 Evas_Object *pbar_ly = elm_layout_add(ug_data->navi_bar);
2193 elm_layout_file_set(pbar_ly, EV_THEME_PATH, "layout.email.attachment_downloading");
2194 evas_object_size_hint_align_set(pbar_ly, EVAS_HINT_FILL, 0.0);
2195 evas_object_show(pbar_ly);
2196 ug_data->progress_bar_ly[index + 1] = pbar_ly;
2199 char buff[MAX_STR_LEN] = { 0, };
2201 Evas_Object *downloading_label1;
2202 downloading_label1 = elm_label_add(pbar_ly);
2203 elm_object_part_content_set(pbar_ly, "elm.text.1", downloading_label1);
2204 char *text_tagged = g_strconcat("<font_size=32><align=left><color=#000000FF>", info->name, "</color></align></font_size>", NULL);
2205 elm_object_text_set(downloading_label1, text_tagged);
2206 elm_label_ellipsis_set(downloading_label1, EINA_TRUE);
2207 elm_label_wrap_width_set(downloading_label1, ug_data->main_w - 240);
2208 g_free(text_tagged);
2210 if (info->size < 1024) {
2211 g_sprintf(buff, "%d %s", (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
2213 gdouble tmpsize = (gdouble) (info->size / 1024.);
2215 if (tmpsize < 1024) {
2216 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
2220 if (tmpsize < 1024) {
2221 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
2224 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
2229 Evas_Object *downloading_label3;
2230 downloading_label3 = elm_label_add(pbar_ly);
2231 elm_object_part_content_set(pbar_ly, "elm.text.3", downloading_label3);
2232 text_tagged = g_strconcat("<font_size=26><align=right><color=#646464FF>", buff, "</color></align></font_size>", NULL);
2233 elm_object_text_set(downloading_label3, text_tagged);
2234 g_free(text_tagged);
2237 Evas_Object *progressbar = elm_progressbar_add(pbar_ly);
2238 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
2239 elm_object_style_set(progressbar, "list_progress");
2240 elm_object_part_content_set(pbar_ly, "elm.icon.2", progressbar);
2241 ug_data->progress_bar[index + 1] = progressbar;
2242 evas_object_show(progressbar);
2244 Evas_Object *cancel_btn = elm_button_add(pbar_ly);
2245 elm_object_style_set(cancel_btn, "text_only/style2");
2246 elm_object_text_set(cancel_btn, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
2248 elm_object_part_content_set(pbar_ly, "elm.icon.1", cancel_btn);
2249 evas_object_show(cancel_btn);
2250 evas_object_smart_callback_add(cancel_btn, "clicked", _destroy_down_progress_ex, (void *)index);
2251 debug_log("Cancel button for attachment downloading progress popup: %p", cancel_btn);
2253 /* packing progress layout */
2254 if (p_type == EMAIL_VIEWER_PROGRESSBAR_ATT && prop->real_att_len > 1) {
2255 for (i = 0; i < prop->att_len; i++) {
2256 info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2257 if (info && !info->inline_content) {
2259 if (ug_data->attach_ex_ly != NULL && ug_data->attach_ex_ly[j] != NULL) {
2261 elm_box_pack_after(ug_data->main_bx, pbar_ly, ug_data->attach_ex_ly[j]);
2262 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[j]);
2263 evas_object_hide(ug_data->attach_ex_ly[j]);
2264 ug_data->attach_ex_ly[j] = pbar_ly;
2271 if ((p_type == EMAIL_VIEWER_PROGRESSBAR_ATT && prop->real_att_len == 1) || (p_type == EMAIL_VIEWER_PROGRESSBAR_ATT_ALL)) {
2273 elm_box_pack_after(ug_data->main_bx, pbar_ly, ug_data->attach_hd_ly);
2274 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2275 evas_object_hide(ug_data->attach_hd_ly);
2276 ug_data->attach_hd_ly = pbar_ly;
2279 elm_object_focus_set(pbar_ly, EINA_TRUE);
2280 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
2283 static void _destroy_down_progress_ex(void *data, Evas_Object *obj, void *event_info)
2288 debug_log("data is NULL");
2292 EmailViewerUGD *ug_data = _g_ug_data;
2293 EmailViewerPrivate *priv = ug_data->email_data;
2294 EmailViewerProp *prop = ug_data->property;
2296 if (!prop || !prop->attachments) {
2310 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
2311 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
2313 GList *attachment_list = prop->attachments;
2314 int index = (int)data;
2317 /* Cancel the download in email-service */
2319 debug_log("index[%d] download_all_cnt[%d] email_handle[%d]", index, priv->download_all_cnt, priv->download_all_email_handle[index]);
2320 if (priv->download_all_email_handle[index] != 0) {
2321 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[index]);
2322 priv->download_all_email_handle[index] = 0;
2325 (priv->download_all_cnt)--;
2327 if (priv->download_all_cnt == 0)
2328 priv->b_all_att_save = FALSE;
2329 } else if (index == -1) {
2330 for (i = 0; i < prop->att_len; i++) {
2331 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2332 if (info && !info->inline_content) {
2333 debug_log("index[%d] download_all_cnt[%d] email_handle[%d]", i, priv->download_all_cnt, priv->download_all_email_handle[i]);
2334 if (priv->download_all_email_handle[i] != 0) {
2335 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[i]);
2338 priv->download_all_email_handle[i] = 0;
2340 priv->download_all_cnt = 0;
2341 priv->b_all_att_save = FALSE;
2344 /* upack and delete, pack again */
2346 debug_log("real_att_len:%d", prop->real_att_len);
2347 if (prop->real_att_len == 1) {
2348 debug_log("index[%d]", index);
2349 elm_box_pack_after(ug_data->main_bx, ug_data->attach_hd_bk, ug_data->attach_hd_ly);
2350 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2351 evas_object_del(ug_data->attach_hd_ly);
2352 ug_data->attach_hd_ly = ug_data->attach_hd_bk;
2353 evas_object_show(ug_data->attach_hd_ly);
2354 elm_object_focus_set(ug_data->attach_hd_ly, EINA_TRUE);
2355 ug_data->progress_bar[index + 1] = NULL;
2356 ug_data->progress_bar_ly[index + 1] = NULL;
2357 } else if (prop->real_att_len > 1) {
2358 for (i = 0; i < prop->att_len; i++) {
2359 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2360 if (info && !info->inline_content) {
2362 debug_log("index[%d]", i);
2363 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
2364 if (ug_data->attach_onoff_flag > 0) {
2365 elm_box_pack_after(ug_data->main_bx, ug_data->attach_ex_bk[j], ug_data->attach_ex_ly[j]);
2366 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[j]);
2367 evas_object_del(ug_data->attach_ex_ly[j]);
2368 ug_data->attach_ex_ly[j] = ug_data->attach_ex_bk[j];
2369 evas_object_show(ug_data->attach_ex_ly[j]);
2370 elm_object_focus_set(ug_data->attach_ex_ly[j], EINA_TRUE);
2371 ug_data->progress_bar[index + 1] = NULL;
2372 ug_data->progress_bar_ly[index + 1] = NULL;
2374 evas_object_del(ug_data->attach_ex_ly[j]);
2375 ug_data->attach_ex_ly[j] = ug_data->attach_ex_bk[j];
2376 ug_data->progress_bar[index + 1] = NULL;
2377 ug_data->progress_bar_ly[index + 1] = NULL;
2384 } else if (index == -1) {
2385 debug_log("index[%d]", index);
2386 elm_box_pack_after(ug_data->main_bx, ug_data->attach_hd_bk, ug_data->attach_hd_ly);
2387 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2388 evas_object_del(ug_data->attach_hd_ly);
2389 ug_data->attach_hd_ly = ug_data->attach_hd_bk;
2390 evas_object_show(ug_data->attach_hd_ly);
2391 elm_object_focus_set(ug_data->attach_hd_ly, EINA_TRUE);
2392 ug_data->progress_bar[index + 1] = NULL;
2393 ug_data->progress_bar_ly[index + 1] = NULL;
2396 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
2399 static void _move_ctxpopup(Evas_Object *ctxpopup, Evas_Object *win)
2401 Evas_Coord x, y, w, h;
2403 evas_object_geometry_get(win, &x, &y, &w, &h);
2404 evas_object_move(ctxpopup, x + (w / 2), y);
2407 static void _create_more_ctxpopup(EmailViewerUGD *ug_data, Evas_Object *obj)
2411 debug_log("ug_data is NULL");
2415 EmailViewerProp *prop = ug_data->property;
2416 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
2417 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, prop->sender);
2418 Evas_Object* icon = NULL;
2420 if (ug_data->con_popup) {
2421 evas_object_del(ug_data->con_popup);
2422 ug_data->con_popup = NULL;
2425 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
2426 if (ug_data->con_popup == NULL) {
2427 debug_log("cannot create context popup");
2431 debug_log("mailbox_type:%d", ug_data->mailbox_type);
2432 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_OUTBOX) {
2433 if (prop->status2 == EMAIL_MAIL_STATUS_SEND_CANCELED) {
2434 icon = elm_icon_add(ug_data->con_popup);
2435 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_edit.png", NULL);
2436 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_SK_EDIT"), icon, _edit_email_cb, ug_data);
2440 icon = elm_icon_add(ug_data->con_popup);
2441 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_mark_as_unread.png", NULL);
2442 if (email_engine_check_seen_mail(ug_data->account_id, ug_data->mail_id)) {
2443 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_UNREAD"), icon, _mark_as_unread_cb, ug_data);
2445 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_READ"), icon, _mark_as_read_cb, ug_data);
2449 icon = elm_icon_add(ug_data->con_popup);
2450 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_forward.png", NULL);
2451 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_BODY_FORWARD"), icon, _forward_cb, ug_data);
2454 icon = elm_icon_add(ug_data->con_popup);
2455 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_mark_as_unread.png", NULL);
2456 if (email_engine_check_seen_mail(ug_data->account_id, ug_data->mail_id)) {
2457 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_UNREAD"), icon, _mark_as_unread_cb, ug_data);
2459 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_READ"), icon, _mark_as_read_cb, ug_data);
2463 icon = elm_icon_add(ug_data->con_popup);
2464 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_move.png", NULL);
2465 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_BODY_MOVE"), icon, _move_cb, ug_data);
2468 icon = elm_icon_add(ug_data->con_popup);
2469 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_save_email.png", NULL);
2470 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SAVE_EMAIL_ABB"), icon, _save_email_cb, ug_data);
2473 if (contact_list_item) {
2474 debug_log("Contact Item Exist: index[%d]", contact_list_item->index);
2475 char index[10] = { 0, };
2476 snprintf(index, sizeof(index), "%d", contact_list_item->index);
2477 icon = elm_icon_add(ug_data->con_popup);
2478 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_view contact.png", NULL);
2479 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_VIEW_CONTACT"), icon, _ctxpopup_detail_contact_cb, g_strdup(index));
2481 _delete_contacts_list(contact_list_item);
2483 ug_data->create_contact_arg = CONTACTUI_REQ_ADD_EMAIL;
2484 icon = elm_icon_add(ug_data->con_popup);
2485 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_add_to_contacts.png", NULL);
2486 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_OPT_ADD_TO_CONTACTS"), icon, _ctxpopup_add_contact_cb, prop->sender);
2491 _move_ctxpopup(ug_data->con_popup, obj);
2492 evas_object_show(ug_data->con_popup);
2495 static void _create_reply_ctxpopup(EmailViewerUGD *ug_data)
2499 debug_log("ug_data is NULL");
2503 if (ug_data->con_popup) {
2504 evas_object_del(ug_data->con_popup);
2505 ug_data->con_popup = NULL;
2508 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
2509 if (ug_data->con_popup == NULL) {
2510 debug_log("cannot create context popup");
2514 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_TO_SENDER_ABB"), NULL, _reply_cb, ug_data);
2515 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_TO_ALL_ABB"), NULL, _reply_all_cb, ug_data);
2517 Evas_Coord x, y, w, h;
2518 evas_object_geometry_get(ug_data->reply_btn, &x, &y, &w, &h);
2519 evas_object_move(ug_data->con_popup, x + (w / 2), y);
2520 evas_object_show(ug_data->con_popup);
2523 static void _delete_evas_objects(EmailViewerUGD *ug_data)
2526 EmailViewerProp *prop = ug_data->property;
2528 if (ug_data->webview) {
2529 evas_object_del(ug_data->webview);
2530 ug_data->webview = NULL;
2533 if (ug_data->webview_bx) {
2534 evas_object_del(ug_data->webview_bx);
2535 ug_data->webview_bx = NULL;
2538 if (ug_data->scroller) {
2539 evas_object_del(ug_data->scroller);
2540 ug_data->scroller = NULL;
2543 if (ug_data->main_bx) {
2544 evas_object_del(ug_data->main_bx);
2545 ug_data->main_bx = NULL;
2548 if (ug_data->b_btn) {
2549 evas_object_del(ug_data->b_btn);
2550 ug_data->b_btn = NULL;
2553 if (ug_data->sub_ly) {
2554 evas_object_del(ug_data->sub_ly);
2555 ug_data->sub_ly = NULL;
2558 if (ug_data->navi_bar) {
2559 evas_object_del(ug_data->navi_bar);
2560 ug_data->navi_bar = NULL;
2563 if (ug_data->ctr_bar) {
2564 evas_object_del(ug_data->ctr_bar);
2565 ug_data->ctr_bar = NULL;
2568 if (ug_data->layout_main) {
2569 evas_object_del(ug_data->layout_main);
2570 ug_data->layout_main = NULL;
2573 if (ug_data->con_popup) {
2574 evas_object_del(ug_data->con_popup);
2575 ug_data->con_popup = NULL;
2578 if (ug_data->select_info) {
2579 evas_object_del(ug_data->select_info);
2580 ug_data->select_info = NULL;
2583 if (ug_data->selectioninfo_layout != NULL) {
2584 evas_object_del(ug_data->selectioninfo_layout);
2585 ug_data->selectioninfo_layout = NULL;
2588 if (ug_data->notify) {
2589 evas_object_del(ug_data->notify);
2590 ug_data->notify = NULL;
2593 if (ug_data->pb_notify) {
2594 evas_object_del(ug_data->pb_notify);
2595 ug_data->pb_notify = NULL;
2598 if (ug_data->pb_notify_lb) {
2599 evas_object_del(ug_data->pb_notify_lb);
2600 ug_data->pb_notify_lb = NULL;
2603 if (ug_data->partial_dn_btn) {
2604 evas_object_del(ug_data->partial_dn_btn);
2605 ug_data->partial_dn_btn = NULL;
2608 if (ug_data->partial_dn_btn_bx) {
2609 evas_object_del(ug_data->partial_dn_btn_bx);
2610 ug_data->partial_dn_btn_bx = NULL;
2613 if (ug_data->waiting_timer) {
2614 ecore_timer_del(ug_data->waiting_timer);
2615 ug_data->waiting_timer = NULL;
2618 if (ug_data->timer) {
2619 ecore_timer_del(ug_data->timer);
2620 ug_data->timer = NULL;
2623 if (ug_data->idler) {
2624 ecore_idler_del(ug_data->idler);
2625 ug_data->idler = NULL;
2628 if (ug_data->got_att) {
2631 evas_object_del(ug_data->attach_hd_bk);
2632 ug_data->attach_hd_ly = NULL;
2633 ug_data->attach_hd_bk = NULL;
2635 if (prop->real_att_len > 1) {
2636 for (i = 0; i < prop->real_att_len; i++) {
2637 if (ug_data->attach_ex_ly != NULL) {
2638 if (ug_data->attach_ex_ly[i] != NULL) {
2639 debug_log("index %d", i);
2640 evas_object_del(ug_data->attach_ex_bk[i]);
2641 ug_data->attach_ex_ly[i] = NULL;
2642 ug_data->attach_ex_bk[i] = NULL;
2647 if (ug_data->attach_ex_ly != NULL) {
2648 free(ug_data->attach_ex_ly);
2649 ug_data->attach_ex_ly = NULL;
2650 ug_data->attach_ex_bk = NULL;
2654 for (i = 0; i <= prop->att_len; i++) {
2655 if (ug_data->progress_bar_ly[i] != NULL) {
2656 evas_object_del(ug_data->progress_bar_ly[i]);
2657 ug_data->progress_bar_ly[i] = NULL;
2658 ug_data->progress_bar[i] = NULL;
2664 void _launch_composer(EmailViewerUGD *ug_data, int type)
2669 debug_log("ug_data is NULL");
2673 EmailViewerPrivate *priv = ug_data->email_data;
2677 service_h service = NULL;
2679 ret = service_create(&service);
2680 debug_log("service_create: %d", ret);
2682 debug_log("service create failed");
2686 char rtype[10] = { 0, };
2687 snprintf(rtype, sizeof(rtype), "%d", type);
2688 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
2689 debug_log("service_add_extra_data: %d", ret);
2691 memset(tmp, 0x0, sizeof(tmp));
2692 snprintf(tmp, sizeof(tmp), "%d", priv->account_id);
2693 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_ACCOUNT_ID, tmp);
2694 debug_log("service_add_extra_data: %d", ret);
2696 memset(tmp, 0x0, sizeof(tmp));
2697 snprintf(tmp, sizeof(tmp), "%d", priv->mailbox_id);
2698 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MAILBOX, tmp);
2699 debug_log("service_add_extra_data: %d", ret);
2701 memset(tmp, 0x0, sizeof(tmp));
2702 snprintf(tmp, sizeof(tmp), "%d", priv->mail_id);
2703 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MAIL_ID, tmp);
2704 debug_log("service_add_extra_data: %d", ret);
2706 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
2708 ret = service_destroy(service);
2709 debug_log("service_destroy: %d", ret);
2712 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
2716 if (_g_ug_data == NULL) {
2717 debug_log("_g_ug_data is NULL");
2722 debug_log("data is NULL");
2725 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2727 if (ug_data->con_popup != NULL) {
2728 evas_object_del(ug_data->con_popup);
2729 ug_data->con_popup = NULL;
2732 debug_log("isRoate = %d", ug_data->isRotate);
2733 if (ug_data->isRotate == false && ug_data->b_internal) {
2734 /* Viewer to hide, so set left content (mailbox) size to full */
2735 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
2738 if (ug_data->b_internal != 1) {
2739 debug_log("ug_destory_me");
2740 ug_destroy_me(ug_data->ug);
2742 _hide_view(ug_data);
2746 static void _reply_cb(void *data, Evas_Object *obj, void *event_info)
2750 debug_log("data is NULL");
2754 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2756 if (ug_data->con_popup) {
2757 evas_object_del(ug_data->con_popup);
2758 ug_data->con_popup = NULL;
2761 ug_data->display_download_result = FALSE;
2762 _launch_composer(ug_data, RUN_COMPOSER_REPLY);
2764 if (ug_data->notify) {
2765 evas_object_del(ug_data->notify);
2766 ug_data->notify = NULL;
2770 static void _reply_all_cb(void *data, Evas_Object *obj, void *event_info)
2774 debug_log("data is NULL");
2778 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2780 if (ug_data->con_popup) {
2781 evas_object_del(ug_data->con_popup);
2782 ug_data->con_popup = NULL;
2785 ug_data->display_download_result = FALSE;
2786 _launch_composer(ug_data, RUN_COMPOSER_REPLY_ALL);
2788 if (ug_data->notify) {
2789 evas_object_del(ug_data->notify);
2790 ug_data->notify = NULL;
2794 static void _reply_option_cb(void *data, Evas_Object *obj, void *event_info)
2798 debug_log("data is NULL");
2802 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2804 _create_reply_ctxpopup(ug_data);
2807 static void _forward_cb(void *data, Evas_Object *obj, void *event_info)
2811 debug_log("data is NULL");
2815 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2817 if (ug_data->con_popup) {
2818 evas_object_del(ug_data->con_popup);
2819 ug_data->con_popup = NULL;
2822 ug_data->display_download_result = FALSE;
2823 _launch_composer(ug_data, RUN_COMPOSER_FORWARD);
2826 static void _resend_cb(void *data, Evas_Object *obj, void *event_info)
2830 debug_log("data is NULL");
2834 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2837 /* Send email again */
2838 debug_log("ug_data->account_id(%d), priv->account_id(%d), mail_info->account_id(%d), prop->account_id(%d)", ug_data->account_id, ug_data->email_data->account_id, ug_data->email_data->mail_info->account_id, ug_data->property->account_id);
2839 debug_log("ug_data->mail_id(%d), priv->mail_id(%d), mail_info->mail_id(%d), prop->mail_id(%d)", ug_data->mail_id, ug_data->email_data->mail_id, ug_data->email_data->mail_info->mail_id, ug_data->property->mail_id);
2841 int err = email_send_mail(ug_data->mail_id, &handle);
2842 if (err != EMAIL_ERROR_NONE) {
2843 debug_warning("email_send_mail failed: handle(%d) - err(%d)", handle, err);
2845 debug_log("sending: handle(%d)", handle);
2848 if (ug_data->isRotate == false && ug_data->b_internal) {
2849 /* Viewer to hide, so set left content (mailbox) size to full */
2850 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
2854 if (ug_data->b_internal) {
2855 _hide_view(ug_data);
2857 debug_log("ug_destory_me");
2858 ug_destroy_me(ug_data->ug);
2862 static void _cancel_send_cb(void *data, Evas_Object *obj, void *event_info)
2866 debug_log("data is NULL");
2870 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2872 debug_log("ug_data->account_id(%d), priv->account_id(%d), mail_info->account_id(%d), prop->account_id(%d)", ug_data->account_id, ug_data->email_data->account_id, ug_data->email_data->mail_info->account_id, ug_data->property->account_id);
2873 debug_log("ug_data->mail_id(%d), priv->mail_id(%d), mail_info->mail_id(%d), prop->mail_id(%d)", ug_data->mail_id, ug_data->email_data->mail_id, ug_data->email_data->mail_info->mail_id, ug_data->property->mail_id);
2875 int err = email_cancel_sending_mail(ug_data->mail_id);
2876 if (err != EMAIL_ERROR_NONE) {
2877 debug_warning("email_engine_cancel_send_mail failed - err(%d)", err);
2881 static void _edit_email_cb(void *data, Evas_Object *obj, void *event_info)
2885 debug_log("data is NULL");
2889 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2891 if (ug_data->con_popup) {
2892 evas_object_del(ug_data->con_popup);
2893 ug_data->con_popup = NULL;
2897 service_h service = NULL;
2899 ret = service_create(&service);
2900 debug_log("service_create: %d", ret);
2902 debug_log("service create failed");
2906 char rtype[10] = { 0, };
2907 snprintf(rtype, sizeof(rtype), "%d", RUN_COMPOSER_EDIT);
2908 char acctid[10] = { 0, };
2909 snprintf(acctid, sizeof(acctid), "%d", ug_data->account_id);
2910 char mailboxid[10] = { 0, };
2911 snprintf(mailboxid, sizeof(mailboxid), "%d", ug_data->mailbox_id);
2912 char mailid[10] = { 0, };
2913 snprintf(mailid, sizeof(mailid), "%d", ug_data->mail_id);
2915 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
2916 debug_log("service_add_extra_data: %d", ret);
2917 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_ACCOUNT_ID, acctid);
2918 debug_log("service_add_extra_data: %d", ret);
2919 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MAILBOX, mailboxid);
2920 debug_log("service_add_extra_data: %d", ret);
2921 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MAIL_ID, mailid);
2922 debug_log("service_add_extra_data: %d", ret);
2924 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
2926 ret = service_destroy(service);
2927 debug_log("service_destroy: %d", ret);
2930 static void _delete_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 if (ug_data->mailbox_type != EMAIL_MAILBOX_TYPE_TRASH) {
2946 _create_notify_3btn(ug_data, NULL, dgettext("sys_string", "IDS_COM_POP_DELETE_Q"),
2947 3, N_("Move to Recycle bin"), _popup_response_move_to_trash_cb,
2948 N_("Delete permanently"), _popup_response_delete_permanent_cb,
2949 dgettext("sys_string", "IDS_COM_SK_CANCEL"), _popup_response_cb, NULL);
2951 _create_notify_3btn(ug_data, NULL, dgettext("sys_string", "IDS_COM_POP_DELETE_Q"),
2952 2, dgettext("sys_string", "IDS_COM_SK_DELETE"), _popup_response_delete_ok_cb,
2953 dgettext("sys_string", "IDS_COM_SK_CANCEL"), _popup_response_cb, NULL, NULL, NULL);
2957 static void _move_cb(void *data, Evas_Object *obj, void *event_info)
2961 debug_log("data is NULL");
2965 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2966 EmailViewerPrivate *priv = ug_data->email_data;
2968 if (ug_data->con_popup) {
2969 evas_object_del(ug_data->con_popup);
2970 ug_data->con_popup = NULL;
2973 Evas_Object *gl = elm_genlist_add(ug_data->navi_bar);
2974 evas_object_show(gl);
2976 ug_data->itc1.item_style = "1text.1icon.2";
2977 ug_data->itc1.func.text_get = _gl_text_get;
2978 ug_data->itc1.func.content_get = _gl_content_get;
2979 ug_data->itc1.func.state_get = _gl_state_get;
2980 ug_data->itc1.func.del = _gl_del;
2982 Elm_Object_Item *navi_it = NULL;
2983 navi_it = elm_naviframe_top_item_get(ug_data->navi_bar);
2984 navi_it = elm_naviframe_item_insert_after(ug_data->navi_bar, navi_it, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, NULL, gl, NULL);
2985 ug_data->navi_move_it1 = navi_it;
2986 if (ug_data->isRotate)
2987 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_FALSE);
2989 email_mailbox_t *mailbox_list = NULL;
2990 int mailbox_count = 0;
2993 email_get_mailbox_list(priv->account_id, -1, &mailbox_list, &mailbox_count);
2994 debug_log("folder count %d", mailbox_count);
2995 ug_data->move_mailbox_list = mailbox_list;
2996 ug_data->move_mailbox_count = mailbox_count;
2998 for (i = 0; i < mailbox_count; i++) {
2999 if (mailbox_list[i].mailbox_id != ug_data->mailbox_id &&
3000 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_OUTBOX &&
3001 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_SENTBOX &&
3002 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_DRAFT &&
3003 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_TRASH &&
3004 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_ALL_EMAILS &&
3005 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_SEARCH_RESULT) {
3006 if (g_strcmp0(mailbox_list[i].alias, "[Gmail]")) {
3007 elm_genlist_item_append(gl, &ug_data->itc1, (void *)&(mailbox_list[i]), NULL, ELM_GENLIST_ITEM_NONE, _move_here_cb, (void *)&(mailbox_list[i]));
3009 Elm_Object_Item *item = elm_genlist_item_append(gl, &ug_data->itc1, (void *)&(mailbox_list[i]), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
3010 elm_object_item_disabled_set(item, EINA_TRUE);
3013 Elm_Object_Item *item = elm_genlist_item_append(gl, &ug_data->itc1, (void *)&(mailbox_list[i]), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
3014 elm_object_item_disabled_set(item, EINA_TRUE);
3018 Evas_Object *move_back_btn = NULL;
3019 move_back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
3020 if (move_back_btn) {
3021 evas_object_del(move_back_btn);
3022 move_back_btn = elm_button_add(ug_data->navi_bar);
3023 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
3024 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb, ug_data);
3025 elm_object_item_part_content_set(navi_it, "prev_btn", move_back_btn);
3029 static void _more_cb(void *data, Evas_Object *obj, void *event_info)
3033 debug_log("data is NULL");
3037 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3039 _create_more_ctxpopup(ug_data, obj);
3042 static void _body_down_cb(void *data, Evas_Object *obj, void *event_info)
3046 debug_log("data is NULL");
3052 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3053 EmailViewerPrivate *priv = ug_data->email_data;
3055 /* check already downloaded */
3056 int body_download_status = ug_data->property->body_download;
3058 if (body_download_status == 0) { //EMAIL_BODY_DOWNLOAD_STATUS_NONE
3059 debug_log("only header downloaded -> need body download");
3060 } else if (body_download_status == 1) { //EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED
3061 debug_log("already downloaded fully, create body directly");
3064 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
3066 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
3069 if (ug_data->b_partial_body) {
3074 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
3075 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
3077 elm_box_unpack(ug_data->main_bx, ug_data->partial_dn_btn_bx);
3078 if (ug_data->partial_dn_btn) {
3079 evas_object_del(ug_data->partial_dn_btn);
3080 ug_data->partial_dn_btn = NULL;
3082 if (ug_data->partial_dn_btn_bx) {
3083 evas_object_del(ug_data->partial_dn_btn_bx);
3084 ug_data->partial_dn_btn_bx = NULL;
3087 if (ug_data->property->has_html) {
3088 ug_data->webview_data->body_type = BODY_TYPE_HTML;
3089 ug_data->webview_data->uri = ug_data->property->body_uri;
3091 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
3092 ug_data->webview_data->text_content = ug_data->property->body;
3095 viewer_set_webview_content(ug_data, 1);
3096 ug_data->b_partial_body = 0;
3098 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
3099 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
3101 if (ug_data->property->has_attachment)
3102 ug_data->got_att = 1;
3104 ug_data->got_att = 0;
3106 /* pack attachment if it exist */
3107 if (ug_data->got_att) {
3108 _create_attach(ug_data);
3111 _create_body(ug_data);
3115 } else if (body_download_status == 2) { //EMAILL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED
3116 debug_log("body downloaded partially -> need full body download");
3119 ret = email_engine_body_download(priv->account_id, priv->mail_id, &handle);
3122 priv->email_handle = handle;
3123 debug_log("succeed in email_engine_body_download(handle:%d)", priv->email_handle);
3124 _create_down_progress(dgettext("sys_string", "IDS_COM_POP_DOWNLOADING"), _destroy_down_progress_cb);
3126 /* If attachment download is in progress, first cancel to attachment download of the mail and then carry out body download */
3127 _cancel_download_attachment(ug_data);
3130 debug_log("unable to download mail body");
3131 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
3132 _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), 1,
3133 dgettext("sys_string", "IDS_COM_SK_OK"),
3134 _popup_response_cb, NULL, NULL, NULL);
3138 static void _subject_favorite_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3142 debug_log("data is NULL");
3146 EmailViewerUGD *ug_data = _g_ug_data;
3147 EmailViewerProp *prop = ug_data->property;
3148 int err = EMAIL_ERROR_NONE;
3150 if (ug_data->con_popup) {
3151 evas_object_del(ug_data->con_popup);
3152 ug_data->con_popup = NULL;
3155 debug_log("Before prop->favorite: %d", prop->favorite);
3156 switch(prop->favorite) {
3157 case EMAIL_FLAG_NONE:
3158 prop->favorite = EMAIL_FLAG_FLAGED;
3160 case EMAIL_FLAG_FLAGED:
3161 prop->favorite = EMAIL_FLAG_NONE;
3163 case EMAIL_FLAG_TASK_STATUS_CLEAR:
3164 prop->favorite = EMAIL_FLAG_TASK_STATUS_ACTIVE;
3166 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
3167 prop->favorite = EMAIL_FLAG_TASK_STATUS_COMPLETE;
3169 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
3170 prop->favorite = EMAIL_FLAG_TASK_STATUS_CLEAR;
3173 debug_log("Never here");
3175 debug_log("After prop->favorite: %d", prop->favorite);
3177 err = email_set_flags_field(ug_data->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_FLAGGED_FIELD, prop->favorite, 1);
3178 if (err != EMAIL_ERROR_NONE) {
3179 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3180 N_("Failed to set favourite"), 0,
3181 NULL, NULL, NULL, NULL, _popup_response_cb);
3185 evas_object_del(elm_object_part_content_unset(ug_data->ly_subject, "elm.icon.favorite"));
3186 Evas_Object *favorite_icon = elm_icon_add(ug_data->ly_subject);
3187 switch(prop->favorite)
3189 case EMAIL_FLAG_NONE:
3190 elm_image_file_set(favorite_icon, IMGDIR "/M02_icon_favorite_off_74x74.png", NULL);
3192 case EMAIL_FLAG_FLAGED:
3193 elm_image_file_set(favorite_icon, IMGDIR "/M02_icon_favorite_on_74x74.png", NULL);
3195 case EMAIL_FLAG_TASK_STATUS_CLEAR:
3196 elm_image_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
3198 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
3199 elm_image_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
3201 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
3202 elm_image_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
3205 debug_log("Never here");
3207 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
3208 elm_image_resizable_set(favorite_icon, 1, 1);
3209 elm_object_part_content_set(ug_data->ly_subject, "elm.icon.favorite", favorite_icon);
3210 evas_object_show(favorite_icon);
3213 static void _subject_detail_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3217 debug_log("data is NULL");
3221 Evas_Object *item = (Evas_Object *)data;
3222 EmailViewerUGD *ug_data = _g_ug_data;
3224 if (!(ug_data->subject_onoff_flag)) {
3225 edje_object_signal_emit(_EDJ(item), "elm,state,expanded", "elm");
3226 (ug_data->subject_onoff_flag)++;
3228 _create_to_addrs(ug_data);
3229 _create_cc_addrs(ug_data);
3230 _create_bcc_addrs(ug_data);
3232 edje_object_signal_emit(_EDJ(item), "elm,state,contracted", "elm");
3233 (ug_data->subject_onoff_flag)--;
3235 if (ug_data->to_ly) {
3236 elm_box_unpack(ug_data->main_bx, ug_data->to_ly);
3237 evas_object_del(ug_data->to_ly);
3238 ug_data->to_ly = NULL;
3240 if (ug_data->cc_ly) {
3241 elm_box_unpack(ug_data->main_bx, ug_data->cc_ly);
3242 evas_object_del(ug_data->cc_ly);
3243 ug_data->cc_ly = NULL;
3245 if (ug_data->bcc_ly) {
3246 elm_box_unpack(ug_data->main_bx, ug_data->bcc_ly);
3247 evas_object_del(ug_data->bcc_ly);
3248 ug_data->bcc_ly = NULL;
3251 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
3255 static void _attachment_item_collapse_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3258 if (!data || !_g_ug_data) {
3259 debug_log("data is NULL");
3263 Evas_Object *item = (Evas_Object *)data;
3264 EmailViewerUGD *ug_data = _g_ug_data;
3265 EmailViewerProp *prop = ug_data->property;
3268 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
3269 if (!(ug_data->attach_onoff_flag)) {
3270 debug_log("attachments expanded");
3271 edje_object_signal_emit(_EDJ(item), "elm,state,expanded", "elm");
3272 (ug_data->attach_onoff_flag)++;
3274 if (ug_data->attach_ex_ly == NULL)
3275 _create_attach_ex(ug_data);
3277 for (i = 0; i < prop->real_att_len; i++) {
3278 debug_log("index %d", i);
3279 elm_box_pack_after(ug_data->main_bx, ug_data->attach_ex_ly[i], ug_data->attach_hd_ly);
3280 evas_object_show(ug_data->attach_ex_ly[i]);
3284 debug_log("attachments contracted");
3285 edje_object_signal_emit(_EDJ(item), "elm,state,contracted", "elm");
3286 ug_data->attach_onoff_flag = 0;
3288 for (i = 0; i < prop->real_att_len; i++) {
3289 if (ug_data->attach_ex_ly[i] != NULL) {
3290 debug_log("index %d", i);
3291 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[i]);
3292 evas_object_hide(ug_data->attach_ex_ly[i]);
3298 static void _attachment_save_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3303 debug_log("ug_data is NULL");
3307 EmailViewerUGD *ug_data = _g_ug_data;
3308 int att_index = (int)data;
3310 ug_data->display_download_result = FALSE;
3312 debug_log("Selected item index = %d", att_index);
3313 _show_attachment(ug_data, att_index);
3316 static void _attachment_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3321 debug_log("ug_data is NULL");
3325 EmailViewerUGD *ug_data = _g_ug_data;
3326 int att_index = (int)data;
3328 debug_log("Selected item index = %d", att_index);
3329 ug_data->display_download_result = TRUE;
3330 _show_attachment(ug_data, att_index);
3333 static void _attachment_save_all_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3337 debug_log("ug_data is NULL");
3341 EmailViewerUGD *ug_data = _g_ug_data;
3343 _save_attachment_all(ug_data);
3346 static void _attachment_bg_set_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
3350 debug_log("ug_data is NULL");
3354 EmailViewerUGD *ug_data = _g_ug_data;
3355 EmailViewerProp *prop = ug_data->property;
3357 int att_index = (int)data;
3358 debug_log("att_index = %d, attachments count = %d", att_index, prop->real_att_len);
3360 if (prop->real_att_len > 1) {
3363 GList *attachment_list = prop->attachments;
3364 LIST_ITER_START(i, attachment_list) {
3365 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
3366 if (info && !info->inline_content) {
3372 edje_object_signal_emit(_EDJ(ug_data->attach_ex_ly[j]), "pressed", "elm.event.rect");
3375 edje_object_signal_emit(_EDJ(ug_data->attach_hd_ly), "pressed", "elm.event.rect");
3378 static void _attachment_bg_unset_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
3382 debug_log("ug_data is NULL");
3386 EmailViewerUGD *ug_data = _g_ug_data;
3387 EmailViewerProp *prop = ug_data->property;
3389 int att_index = (int)data;
3390 debug_log("att_index = %d, attachments count = %d", att_index, prop->real_att_len);
3392 if (prop->real_att_len > 1) {
3395 GList *attachment_list = prop->attachments;
3396 LIST_ITER_START(i, attachment_list) {
3397 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
3398 if (info && !info->inline_content) {
3404 edje_object_signal_emit(_EDJ(ug_data->attach_ex_ly[j]), "unpressed", "elm.event.rect");
3407 edje_object_signal_emit(_EDJ(ug_data->attach_hd_ly), "unpressed", "elm.event.rect");
3410 static void _mark_as_unread_cb(void *data, Evas_Object *obj, void *event_info)
3414 debug_log("data is NULL");
3418 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3420 if (ug_data->con_popup) {
3421 evas_object_del(ug_data->con_popup);
3422 ug_data->con_popup = NULL;
3426 debug_log("ug_data->mail_id(%d), priv->mail_id(%d), mail_info->mail_id(%d), prop->mail_id(%d)", ug_data->mail_id, ug_data->email_data->mail_id, ug_data->email_data->mail_info->mail_id, ug_data->property->mail_id);
3428 err = email_set_flags_field(ug_data->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_SEEN_FIELD, 0, 1);
3429 debug_log("email_set_flags_field - err(%d)", err);
3431 if (err != EMAIL_ERROR_NONE) {
3432 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3433 _("IDS_EMAIL_POP_FAILED_TO_MARK_AS_UNREAD"), 0,
3434 NULL, NULL, NULL, NULL, _popup_response_cb);
3436 char str[128] = { 0, };
3437 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MARKED_AS_UNREAD"));
3438 _show_select_info(ug_data, str);
3442 static void _mark_as_read_cb(void *data, Evas_Object *obj, void *event_info)
3446 debug_log("data is NULL");
3450 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3452 if (ug_data->con_popup) {
3453 evas_object_del(ug_data->con_popup);
3454 ug_data->con_popup = NULL;
3458 debug_log("ug_data->mail_id(%d), priv->mail_id(%d), mail_info->mail_id(%d), prop->mail_id(%d)", ug_data->mail_id, ug_data->email_data->mail_id, ug_data->email_data->mail_info->mail_id, ug_data->property->mail_id);
3460 err = email_set_flags_field(ug_data->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_SEEN_FIELD, 1, 1);
3461 debug_log("email_set_flags_field - err(%d)", err);
3463 if (err != EMAIL_ERROR_NONE) {
3464 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3465 _("IDS_EMAIL_POP_FAILED_TO_MARK_AS_READ"), 0,
3466 NULL, NULL, NULL, NULL, _popup_response_cb);
3468 char str[128] = { 0, };
3469 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MARKED_AS_READ"));
3470 _show_select_info(ug_data, str);
3474 static void _create_waiting_popup(EmailViewerUGD *ug_data, const char *title_text, const char *style)
3477 if (title_text == NULL) {
3478 debug_log("popup text is null");
3482 Evas_Object *popup = elm_popup_add(ug_data->win_main);
3483 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3484 elm_object_part_text_set(popup, "title,text", title_text);
3486 Evas_Object *progress = elm_progressbar_add(popup);
3487 elm_object_style_set(progress, style);
3488 elm_progressbar_pulse_set(progress, EINA_TRUE);
3489 elm_progressbar_pulse(progress, EINA_TRUE);
3490 evas_object_show(progress);
3492 elm_object_content_set(popup, progress);
3494 Evas_Object *btn1 = elm_button_add(popup);
3495 elm_object_style_set(btn1, "popup_button/default");
3496 elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
3497 elm_object_part_content_set(popup, "button1", btn1);
3498 evas_object_smart_callback_add(btn1, "clicked", _popup_waiting_response_cb, ug_data);
3500 ug_data->timeout_popup = popup;
3502 evas_object_show(popup);
3505 static void _save_email_cb(void *data, Evas_Object *obj, void *event_info)
3509 debug_log("data is NULL");
3513 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3515 if (ug_data->con_popup) {
3516 evas_object_del(ug_data->con_popup);
3517 ug_data->con_popup = NULL;
3520 if (ug_data->timeout_popup) {
3521 evas_object_del(ug_data->timeout_popup);
3522 ug_data->timeout_popup = NULL;
3524 _create_waiting_popup(ug_data, dgettext("sys_string", "IDS_COM_POP_SAVING_ING"), "pending_list"); //"list_process"
3526 if (ug_data->waiting_timer) {
3527 ecore_timer_del(ug_data->waiting_timer);
3528 ug_data->waiting_timer = NULL;
3530 ug_data->waiting_timer = ecore_timer_add(0.2, _save_email_prog_cb, ug_data);
3533 static Eina_Bool _save_email_prog_cb(void *data)
3537 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3540 debug_log("ug_data->mail_id(%d), priv->mail_id(%d), mail_info->mail_id(%d), prop->mail_id(%d)", ug_data->mail_id, ug_data->email_data->mail_id, ug_data->email_data->mail_info->mail_id, ug_data->property->mail_id);
3542 email_mail_data_t *mail_t = NULL;
3543 err = email_get_mail_data(ug_data->email_data->mail_id, &mail_t);
3544 debug_log("email_get_mail_data - err (%d)", err);
3546 if (mail_t == NULL) {
3547 debug_log("mail_t is NULL");
3551 email_attachment_data_t *attachment_t = NULL;
3552 int attachment_count = 0;
3553 err = email_get_attachment_data_list(ug_data->email_data->mail_id, &attachment_t, &attachment_count);
3554 debug_log("email_get_attachment_data_list - err (%d)", err);
3556 if (err == EMAIL_ERROR_NONE) {
3557 char file_name[MAX_PATH_LEN] = { 0, };
3558 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");
3559 char *output_file_path = g_strdup(file_name);
3560 debug_log("output_file_path(%s)", file_name, output_file_path);
3562 err = email_write_mime_file(mail_t, attachment_t, attachment_count, &output_file_path);
3563 debug_log("email_write_mime_file - err(%d)", err);
3565 g_free(output_file_path);
3569 email_free_mail_data(&(mail_t), 1);
3573 if (ug_data->timeout_popup) {
3574 evas_object_del(ug_data->timeout_popup);
3575 ug_data->timeout_popup = NULL;
3578 if (err != EMAIL_ERROR_NONE) {
3579 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3580 dgettext("sys_string", "IDS_COM_POP_UNABLE_TO_SAVE"), 0,
3581 NULL, NULL, NULL, NULL, _popup_response_cb);
3583 char str[128] = { 0, };
3584 snprintf(str, sizeof(str), "%s", N_("Saved in My files"));
3585 int ret = status_message_post(str);
3587 debug_log("status_message_post failed: %d", ret);
3591 email_free_attachment_data(&(attachment_t), attachment_count);
3592 attachment_t = NULL;
3593 attachment_count = 0;
3596 if (ug_data->waiting_timer) {
3597 ecore_timer_del(ug_data->waiting_timer);
3598 ug_data->waiting_timer = NULL;
3604 static void _ctxpopup_detail_contact_cb(void *data, Evas_Object *obj, void *event_info)
3607 if (data == NULL || _g_ug_data == NULL) {
3608 debug_log("data is NULL");
3612 EmailViewerUGD *ug_data = _g_ug_data;
3614 if (ug_data->con_popup) {
3615 evas_object_del(ug_data->con_popup);
3616 ug_data->con_popup = NULL;
3619 char *index = (char *)data;
3620 char type[10] = { 0, };
3622 service_h service = NULL;
3624 ret = service_create(&service);
3625 debug_log("service_create: %d", ret);
3627 debug_log("service create failed");
3631 snprintf(type, sizeof(type), "%d", CT_UG_REQUEST_DETAIL);
3633 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, type);
3634 debug_log("service_add_extra_data: %d", ret);
3635 ret = service_add_extra_data(service, CT_UG_BUNDLE_ID, index);
3636 debug_log("service_add_extra_data: %d", ret);
3638 create_ug(UG_CONTACTS_DETAILS, service, ug_data);
3640 ret = service_destroy(service);
3641 debug_log("service_destroy: %d", ret);
3643 debug_log("set flag for contact ug");
3644 ug_data->b_contact_ug_launched = TRUE;
3647 static void _ctxpopup_send_email_cb(void *data, Evas_Object *obj, void *event_info)
3650 if (!data || !_g_ug_data) {
3651 debug_log("data is NULL");
3655 EmailViewerUGD *ug_data = _g_ug_data;
3657 if (ug_data->con_popup == NULL) {
3658 debug_log("con_popup is NULL");
3662 if (ug_data->con_popup) {
3663 evas_object_del(ug_data->con_popup);
3664 ug_data->con_popup = NULL;
3667 debug_log("email: %s", (char *)data);
3670 service_h service = NULL;
3672 ret = service_create(&service);
3673 debug_log("service_create: %d", ret);
3675 debug_log("service create failed");
3679 char rtype[10] = { 0, };
3680 snprintf(rtype, sizeof(rtype), "%d", RUN_COMPOSER_EXTERNAL);
3682 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
3683 debug_log("service_add_extra_data: %d", ret);
3684 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_TO, (char *)data);
3685 debug_log("service_add_extra_data: %d", ret);
3686 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CC, NULL);
3687 debug_log("service_add_extra_data: %d", ret);
3688 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_BCC, NULL);
3689 debug_log("service_add_extra_data: %d", ret);
3690 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_SUBJECT, NULL);
3691 debug_log("service_add_extra_data: %d", ret);
3692 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_BODY, NULL);
3693 debug_log("service_add_extra_data: %d", ret);
3694 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_ATTACHMENT, NULL);
3695 debug_log("service_add_extra_data: %d", ret);
3697 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
3699 ret = service_destroy(service);
3700 debug_log("service_destroy: %d", ret);
3703 static void _ctxpopup_add_contact_cb(void *data, Evas_Object *obj, void *event_info)
3705 debug_log("data(%s)", data);
3706 if (!data || !_g_ug_data) {
3707 debug_log("data is NULL");
3711 char tmp[MAX_STR_LEN] = { 0, };
3712 EmailViewerUGD *ug_data = _g_ug_data;
3714 if (ug_data->con_popup == NULL) {
3715 debug_log("con_popup is NULL");
3719 if (ug_data->con_popup) {
3720 evas_object_del(ug_data->con_popup);
3721 ug_data->con_popup = NULL;
3725 service_h service = NULL;
3727 ret = service_create(&service);
3728 debug_log("service_create: %d", ret);
3730 debug_log("service create failed");
3734 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_PHONE_NUMBER) {
3735 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_NUM);
3736 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3737 debug_log("service_add_extra_data: %d", ret);
3738 ret = service_add_extra_data(service, CT_UG_BUNDLE_NUM, (char *)data);
3739 debug_log("service_add_extra_data: %d", ret);
3741 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_EMAIL) {
3742 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_EMAIL);
3743 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3744 debug_log("service_add_extra_data: %d", ret);
3745 ret = service_add_extra_data(service, CT_UG_BUNDLE_EMAIL, (char *)data);
3746 debug_log("service_add_extra_data: %d", ret);
3748 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_URL) {
3749 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_WEB);
3750 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3751 debug_log("service_add_extra_data: %d", ret);
3752 ret = service_add_extra_data(service, CT_UG_BUNDLE_WEB, (char *)data);
3753 debug_log("service_add_extra_data: %d", ret);
3756 create_ug(UG_CONTACTS_DETAILS, service, ug_data);
3758 ret = service_destroy(service);
3759 debug_log("service_destroy: %d", ret);
3762 static void _popup_waiting_response_cb(void *data, Evas_Object *obj, void *event_info)
3766 debug_log("data is NULL");
3770 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3772 if (ug_data->timeout_popup) {
3773 evas_object_del(ug_data->timeout_popup);
3774 ug_data->timeout_popup = NULL;
3778 static void _popup_response_cb(void *data, Evas_Object *obj, void *event_info)
3782 debug_log("_g_ug_data is NULL");
3787 debug_log("data is NULL");
3791 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3793 if (ug_data->notify) {
3794 evas_object_del(ug_data->notify);
3795 ug_data->notify = NULL;
3799 static void _popup_response_delete_ok_cb(void *data, Evas_Object *obj, void *event_info)
3803 debug_log("_g_ug_data is NULL");
3808 debug_log("data is NULL");
3812 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3815 if (ug_data->notify) {
3816 evas_object_del(ug_data->notify);
3817 ug_data->notify = NULL;
3820 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH)
3821 ret = _delete_email(ug_data);
3823 ret = _move_email(ug_data, _find_folder_id_using_folder_type(ug_data, EMAIL_MAILBOX_TYPE_TRASH), TRUE);
3826 if (ug_data->isRotate == false && ug_data->b_internal) {
3827 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
3831 if (ug_data->b_internal) {
3832 _hide_view(ug_data);
3834 /* send next or previous mail request to mailbox. */
3835 service_h service = NULL;
3837 ret = service_create(&service);
3838 debug_log("service_create: %d", ret);
3840 debug_log("service create failed");
3844 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
3845 debug_log("service_add_extra_data: %d", ret);
3846 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "1");
3847 debug_log("service_add_extra_data: %d", ret);
3849 ug_send_message(_g_mailbox_ug, service);
3851 ret = service_destroy(service);
3852 debug_log("service_destroy: %d", ret);
3854 ug_destroy_me(ug_data->ug);
3858 static void _popup_response_move_to_trash_cb(void *data, Evas_Object *obj, void *event_info)
3862 debug_log("_g_ug_data is NULL");
3867 debug_log("data is NULL");
3871 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3874 if (ug_data->notify) {
3875 evas_object_del(ug_data->notify);
3876 ug_data->notify = NULL;
3879 ret = _move_email(ug_data, _find_folder_id_using_folder_type(ug_data, EMAIL_MAILBOX_TYPE_TRASH), TRUE);
3882 if (ug_data->isRotate == false && ug_data->b_internal) {
3883 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
3887 if (ug_data->b_internal) {
3888 _hide_view(ug_data);
3890 /* send next or previous mail request to mailbox. */
3892 service_h service = NULL;
3894 ret = service_create(&service);
3895 debug_log("service_create: %d", ret);
3897 debug_log("service create failed");
3901 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
3902 debug_log("service_add_extra_data: %d", ret);
3903 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "1");
3904 debug_log("service_add_extra_data: %d", ret);
3906 ug_send_message(_g_mailbox_ug, service);
3908 ret = service_destroy(service);
3909 debug_log("service_destroy: %d", ret);
3911 ug_destroy_me(ug_data->ug);
3915 static void _popup_response_delete_permanent_cb(void *data, Evas_Object *obj, void *event_info)
3919 debug_log("_g_ug_data is NULL");
3924 debug_log("data is NULL");
3928 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3931 if (ug_data->notify) {
3932 evas_object_del(ug_data->notify);
3933 ug_data->notify = NULL;
3936 ret = _delete_email(ug_data);
3939 if (ug_data->isRotate == false && ug_data->b_internal) {
3940 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
3944 if (ug_data->b_internal) {
3945 _hide_view(ug_data);
3947 /* send next or previous mail request to mailbox. */
3948 service_h service = NULL;
3950 ret = service_create(&service);
3951 debug_log("service_create: %d", ret);
3953 debug_log("service create failed");
3957 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
3958 debug_log("service_add_extra_data: %d", ret);
3959 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "1");
3960 debug_log("service_add_extra_data: %d", ret);
3962 ug_send_message(_g_mailbox_ug, service);
3964 ret = service_destroy(service);
3965 debug_log("service_destroy: %d", ret);
3967 ug_destroy_me(ug_data->ug);
3971 static void _popup_response_to_destroy_cb(void *data, Evas_Object *obj, void *event_info)
3975 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3976 evas_object_del(obj);
3978 ug_data->b_direct_destroy = 1;
3979 ug_destroy_me(ug_data->ug);
3983 static void _webview_policy_navigation_decide_cb(void *data, Evas_Object *obj, void *event_info)
3987 debug_log("_g_ug_data is NULL");
3991 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3992 Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info;
3993 Ewk_Policy_Navigation_Type pd_type = ewk_policy_decision_navigation_type_get(policy_decision);
3994 debug_log("Ewk_Policy_Navigation_Type:%d", pd_type);
3996 const char *uri = NULL;
3997 uri = ewk_view_url_get(ug_data->webview);
3998 debug_log("ewk_view_url_get(%s)", uri);
4000 if (ug_data->b_load_finished == EINA_TRUE) {
4001 if (ug_data->is_long_pressed == EINA_TRUE) {
4002 debug_log("Long pressed!!!");
4003 ug_data->is_long_pressed = EINA_FALSE;
4004 ewk_policy_decision_ignore(policy_decision);
4008 ewk_policy_decision_ignore(policy_decision);
4010 debug_log("url:%s", ewk_policy_decision_url_get(policy_decision));
4011 debug_log("scheme:%s", ewk_policy_decision_scheme_get(policy_decision));
4012 debug_log("cookie:%s", ewk_policy_decision_cookie_get(policy_decision));
4013 debug_log("host:%s", ewk_policy_decision_host_get(policy_decision));
4014 debug_log("response_mime:%s", ewk_policy_decision_response_mime_get(policy_decision));
4016 char *url = (char *)ewk_policy_decision_url_get(policy_decision);
4018 if ((strncmp(url, "http://", 7) == 0) ||
4019 (strncmp(url, "https://", 8) == 0) ||
4020 (strncmp(url, "ftp://", 6) == 0) ||
4021 (strncmp(url, "mms://", 6) == 0) ||
4022 (strncmp(url, "file://", 7) == 0) ||
4023 (strncmp(url, "rtsp://", 7) == 0) ||
4024 (strncmp(url, "wap://", 6) == 0)) {
4026 service_h service = NULL;
4027 ret = service_create(&service);
4028 debug_log("service_create: %d", ret);
4030 debug_log("service create failed");
4033 ret = service_set_operation(service, SERVICE_OPERATION_VIEW);
4034 debug_log("service_set_operation: %d", ret);
4035 ret = service_set_uri(service, url);
4036 debug_log("service_set_uri: %d", ret);
4037 ret = service_send_launch_request(service, NULL, NULL);
4038 debug_log("service_send_launch_request: %d", ret);
4039 ret = service_destroy(service);
4040 debug_log("service_destroy: %d", ret);
4043 if (strncmp(url, "tel:", 4) == 0) {
4044 char refined_num[MAX_STR_LEN] = { 0, };
4047 while (url[i] != '\0') {
4048 if (url[i] >= '0' && url[i] <= '9')
4049 refined_num[j++] = url[i];
4053 char *number = refined_num;
4054 debug_log("number: %s", number);
4057 service_h service = NULL;
4058 char telnum[255] = { 0, };
4059 ret = service_create(&service);
4060 debug_log("service_create: %d", ret);
4062 debug_log("service create failed");
4065 ret = service_set_operation(service, SERVICE_OPERATION_CALL);
4066 debug_log("service_set_operation: %d", ret);
4067 snprintf(telnum, sizeof(telnum), "tel:%s", number); /* Number to make a call */
4068 ret = service_set_uri(service, telnum);
4069 debug_log("service_set_uri: %d", ret);
4070 ret = service_add_extra_data(service, "ctindex", "-1"); /* If you don't know ctindex, you don't have to add it. */
4071 debug_log("service_add_extra_data: %d", ret);
4072 ret = service_send_launch_request(service, NULL, NULL);
4073 debug_log("service_send_launch_request: %d", ret);
4074 ret = service_destroy(service);
4075 debug_log("service_destroy: %d", ret);
4078 if (strncmp(url, "mailto:", 7) == 0) {
4080 service_h service = NULL;
4081 ret = service_create(&service);
4082 debug_log("service_create: %d", ret);
4084 debug_log("service create failed");
4088 char rtype[10] = { 0, };
4089 snprintf(rtype, sizeof(rtype), "%d", RUN_COMPOSER_EXTERNAL);
4091 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
4092 debug_log("service_add_extra_data: %d", ret);
4093 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_TO, &url[7]);
4094 debug_log("service_add_extra_data: %d", ret);
4096 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
4098 ret = service_destroy(service);
4099 debug_log("service_destroy: %d", ret);
4102 debug_log("Loading...");
4103 if (ug_data->timeout_popup) {
4104 evas_object_del(ug_data->timeout_popup);
4105 ug_data->timeout_popup = NULL;
4107 _create_waiting_popup(ug_data, _("IDS_EMAIL_POP_LOADING_CONTENTS_ING"), "list_process");
4109 if (pd_type == EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED) {
4110 debug_log("Link click is ignored.");
4111 ewk_policy_decision_ignore(policy_decision);
4117 /* Double_Scroller */
4118 static void _outter_scroller_bottom_hit_cb(void *data, Evas_Object *obj, void *event_info)
4122 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4123 int res = email_engine_check_body_download(ug_data->email_data->mail_id);
4125 if (ug_data->is_main_scroller_scrolling && res != 0) {
4126 debug_log("Main scroller hold push");
4127 elm_object_scroll_freeze_push(ug_data->scroller); //stop
4128 ewk_view_vertical_panning_hold_set(ug_data->webview, EINA_FALSE); //restart
4129 ug_data->is_main_scroller_scrolling = EINA_FALSE;
4130 ug_data->is_webview_scrolling = EINA_TRUE;
4134 static void _outter_scroller_top_hit_cb(void *data, Evas_Object *obj, void *event_info)
4139 static void _outter_scroller_scroll_cb(void *data, Evas_Object *obj, void *event_info)
4142 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4144 ug_data->is_main_scroller_scrolling = EINA_TRUE;
4147 static void _mbe_focused_cb(void *data, Evas_Object *obj, void *event_info)
4150 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(obj);
4151 elm_multibuttonentry_item_selected_set(item, EINA_FALSE);
4154 static void _mbe_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
4159 static void _mbe_added_cb(void *data, Evas_Object *obj, void *event_info)
4164 static void _mbe_selected_cb(void *data, Evas_Object *obj, void *event_info)
4167 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4168 email_address_info_t *addrs_info = NULL;
4169 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
4170 debug_log("selected item:%s", elm_object_item_text_get(item));
4172 addrs_info = elm_object_item_data_get(item);
4175 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
4176 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, addrs_info->address);
4177 Evas_Object* icon = NULL;
4179 if (ug_data->con_popup != NULL) {
4180 evas_object_del(ug_data->con_popup);
4181 ug_data->con_popup = NULL;
4184 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
4185 if (ug_data->con_popup == NULL) {
4186 debug_log("cannot create context popup");
4190 if (contact_list_item) {
4191 debug_log("Contact Item Exist: index[%d]", contact_list_item->index);
4192 char index[10] = { 0, };
4193 snprintf(index, sizeof(index), "%d", contact_list_item->index);
4195 icon = elm_icon_add(ug_data->con_popup);
4196 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_view contact.png", NULL);
4197 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_VIEW_CONTACT"), icon, _ctxpopup_detail_contact_cb, g_strdup(index));
4199 _delete_contacts_list(contact_list_item);
4201 ug_data->create_contact_arg = CONTACTUI_REQ_ADD_EMAIL;
4202 icon = elm_icon_add(ug_data->con_popup);
4203 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_add_to_contacts.png", NULL);
4204 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_OPT_ADD_TO_CONTACTS"), icon, _ctxpopup_add_contact_cb, addrs_info->address);
4208 icon = elm_icon_add(ug_data->con_popup);
4209 elm_image_file_set(icon, IMGDIR "/M02_popup_icon_send email.png", NULL);
4210 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SEND_EMAIL"), icon, _ctxpopup_send_email_cb, addrs_info->address);
4213 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
4214 debug_log("canvas x:%d, y:%d", x, y);
4215 evas_object_move(ug_data->con_popup, x, y);
4216 evas_object_show(ug_data->con_popup);
4219 static void _destroy_down_progress_cb(void *data, Evas_Object *obj, void *event_info)
4224 debug_log("data is NULL");
4228 EmailViewerUGD *ug_data = _g_ug_data;
4229 EmailViewerPrivate *priv = ug_data->email_data;
4231 email_engine_stop_working(ug_data->account_id, priv->email_handle);
4233 if (ug_data->pb_notify) {
4234 evas_object_del(ug_data->pb_notify);
4235 ug_data->pb_notify = NULL;
4238 if (ug_data->pb_notify_lb) {
4239 evas_object_del(ug_data->pb_notify_lb);
4240 ug_data->pb_notify_lb = NULL;
4244 if (priv->att_file_id) {
4245 free(priv->att_file_id);
4246 priv->att_file_id = NULL;
4249 priv->file_size = 0;
4250 priv->attachment_id = -1;
4251 priv->multi_body = FALSE;
4255 static int _viewer_create_temp_folder()
4259 if (!email_check_dir_exist(EMAIL_VIEWER_TMP_FOLDER)) {
4261 nErr = mkdir(EMAIL_VIEWER_TMP_FOLDER, 0755);
4262 debug_log("errno: %d", nErr);
4264 debug_log("Email viewer temp folder creation failed");
4268 debug_log("Email viewer temp folder already exists.");
4272 static void _viewer_remove_temp_folder()
4276 struct dirent *dir_entry = NULL;
4280 dir = opendir(EMAIL_VIEWER_TMP_FOLDER);
4282 debug_log("Unable to open %s", EMAIL_VIEWER_TMP_FOLDER);
4285 while ((dir_entry = readdir(dir))) {
4286 debug_log("%s", dir_entry->d_name);
4287 if (g_strcmp0(".", dir_entry->d_name) == 0 || g_strcmp0("..", dir_entry->d_name) == 0)
4289 snprintf(buffer, 256, "%s/%s", EMAIL_VIEWER_TMP_FOLDER, dir_entry->d_name);
4290 if (-1 == remove(buffer)) {
4291 debug_log("Failed to remove buffer");
4295 rmdir(EMAIL_VIEWER_TMP_FOLDER);
4298 static void _init_viewer_data(int account_id, int mail_id, char *srv_mail_id, EmailViewerUGD *ug_data)
4301 EmailViewerPrivate *priv = NULL;
4302 EmailViewerProp *prop = NULL;
4303 email_address_info_list_t *addrs_info_list = NULL;
4305 /* Create Email Viewer Private Structure */
4306 if (ug_data->email_data) {
4307 if (ug_data->email_data->mail_info) {
4308 debug_log("mail_info freed");
4309 email_free_mail_data(&(ug_data->email_data->mail_info), 1);
4310 ug_data->email_data->mail_info = NULL;
4313 if (ug_data->email_data->attachment_info && ug_data->email_data->attachment_count > 0) {
4314 debug_log("attachment_info freed p[%p] n[%d]", ug_data->email_data->attachment_info, ug_data->email_data->attachment_count);
4315 email_free_attachment_data(&(ug_data->email_data->attachment_info), ug_data->email_data->attachment_count);
4316 ug_data->email_data->attachment_info = NULL;
4317 ug_data->email_data->attachment_count = 0;
4320 memset(ug_data->email_data, 0x0, sizeof(EmailViewerPrivate));
4321 priv = ug_data->email_data;
4323 priv = (EmailViewerPrivate *)malloc(sizeof(EmailViewerPrivate));
4324 memset(priv, 0x0, sizeof(EmailViewerPrivate));
4325 ug_data->email_data = priv;
4328 /* Create Email Viewer Property Structure */
4329 if (ug_data->property) {
4330 if (ug_data->property->attachments) {
4332 LIST_ITER_START(i, ug_data->property->attachments) {
4333 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, ug_data->property->attachments);
4340 g_list_free(ug_data->property->attachments);
4342 memset(ug_data->property, 0x0, sizeof(EmailViewerProp));
4343 prop = ug_data->property;
4345 prop = (EmailViewerProp *)malloc(sizeof(EmailViewerProp));
4346 memset(prop, 0x0, sizeof(EmailViewerProp));
4347 ug_data->property = prop;
4350 /* Set account ID */
4351 priv->account_id = account_id;
4352 prop->account_id = account_id;
4355 priv->mail_id = mail_id;
4356 prop->mail_id = mail_id;
4358 priv->mailbox_id = ug_data->mailbox_id;
4359 prop->src_box = ug_data->mailbox_name;
4360 debug_log("mailbox_name [%s]", ug_data->mailbox_name);
4362 /* Get mail_info from service, and fill property */
4363 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
4364 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
4367 email_get_address_info_list(priv->mail_id, &addrs_info_list);
4369 if (addrs_info_list) {
4370 ug_data->from_list = addrs_info_list->from;
4371 ug_data->to_list = addrs_info_list->to;
4372 ug_data->cc_list = addrs_info_list->cc;
4373 ug_data->bcc_list = addrs_info_list->bcc;
4374 priv->addrs_info_list = addrs_info_list;
4377 ug_data->option_header_opened = 0;
4379 if (_viewer_create_temp_folder() < 0)
4380 debug_log("creating email viewer temp folder is failed");
4383 static int _init_webview_data(EmailViewerUGD *ug_data)
4387 EmailViewerWebview *wvd;
4389 if (ug_data->webview_data == NULL) {
4390 wvd = (EmailViewerWebview *)malloc(sizeof(EmailViewerWebview));
4391 memset(wvd, 0x0, sizeof(EmailViewerWebview));
4392 ug_data->webview_data = wvd;
4395 if (STR_VALID(ug_data->property->charset)) {
4396 ug_data->webview_data->charset = g_strdup(ug_data->property->charset);
4397 debug_log("charset:%s", ug_data->webview_data->charset);
4399 ug_data->webview_data->charset = DEFAULT_CHARSET;
4400 debug_log("charset:%s", ug_data->webview_data->charset);
4406 static Eina_Bool _check_body_download(void *data)
4410 debug_log("data is NULL");
4411 return ECORE_CALLBACK_CANCEL;
4414 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4416 /* check mail body downloaded */
4417 int body_download_status = ug_data->property->body_download;
4419 if (body_download_status == 0) { //EMAIL_BODY_DOWNLOAD_STATUS_NONE
4420 debug_log("need body download");
4421 ug_data->b_noc = 1; /* Double_Scroller */
4423 if (ug_data->noc_bx) {
4424 debug_log("no content layout exist");
4425 evas_object_show(ug_data->noc_bx);
4426 elm_object_text_set(ug_data->dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_MESSAGE"));
4427 evas_object_show(ug_data->dn_btn);
4428 elm_box_pack_end(ug_data->main_bx, ug_data->noc_bx);
4430 /* add body download button */
4431 ug_data->noc_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.no_content");
4432 if (ug_data->noc_bx == NULL) {
4433 debug_log("Cannot load edj");
4434 return ECORE_CALLBACK_CANCEL;
4437 evas_object_size_hint_align_set(ug_data->noc_bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
4438 evas_object_size_hint_weight_set(ug_data->noc_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
4439 evas_object_show(ug_data->noc_bx);
4440 elm_box_pack_end(ug_data->main_bx, ug_data->noc_bx);
4442 Evas_Object *dn_btn = elm_button_add(ug_data->navi_bar);
4443 elm_object_style_set(dn_btn, "text_only/style2");
4444 elm_object_text_set(dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_MESSAGE"));
4445 evas_object_smart_callback_add(dn_btn, "clicked", _body_down_cb, (void *)ug_data);
4446 evas_object_show(dn_btn);
4447 ug_data->dn_btn = dn_btn;
4449 elm_object_part_content_set(ug_data->noc_bx, "btn", ug_data->dn_btn);
4450 debug_log("no content layout created");
4453 elm_object_focus_set(ug_data->noc_bx, EINA_TRUE);
4454 if (ug_data->timer) {
4455 ecore_timer_del(ug_data->timer);
4456 ug_data->timer = NULL;
4459 ug_data->timer = ecore_timer_add(0.0, viewer_send_message, ug_data);
4460 } else if (body_download_status == 1) { //EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED
4461 debug_log("check mail downloaded - ok");
4463 _create_body(ug_data);
4464 } else if (body_download_status == 2) { //EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED
4466 debug_log("Partial Body");
4467 ug_data->b_partial_body = 1;
4468 _create_body(ug_data);
4469 _create_partial_body_dn_btn(ug_data);
4472 return ECORE_CALLBACK_CANCEL;
4475 static int _update_attachment_info(EmailViewerUGD *ug_data, int index)
4478 EmailViewerProp *prop = ug_data->property;
4481 int attach_index = 0;
4483 /* update attachment information */
4484 LIST_ITER_START(i, prop->attachments) {
4485 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, prop->attachments);
4487 if (info && !info->inline_content) {
4488 debug_log("info->index[%d] index[%d]", info->index, index);
4490 if (info->index == index) {
4491 info->download_yn = TRUE;
4492 info->path = email_engine_get_attachment_path(info->attach_id);
4496 if (prop->real_att_len > 1) {
4497 Evas_Object *thumbnail = viewer_make_thumbnail(info->path, ug_data->attach_ex_bk[j]);
4498 Evas_Object *content = elm_object_part_content_unset(ug_data->attach_ex_bk[j], "elm.icon");
4499 evas_object_del(content);
4500 elm_object_part_content_set(ug_data->attach_ex_bk[j], "elm.icon", thumbnail);
4501 evas_object_show(thumbnail);
4503 Evas_Object *thumbnail = viewer_make_thumbnail(info->path, ug_data->attach_hd_bk);
4504 Evas_Object *content = elm_object_part_content_unset(ug_data->attach_hd_bk, "elm.icon");
4505 evas_object_del(content);
4506 elm_object_part_content_set(ug_data->attach_hd_bk, "elm.icon", thumbnail);
4507 evas_object_show(thumbnail);
4517 debug_log("return id[%d]", attach_index);
4519 return attach_index;
4522 static int _get_attachment_info_index(EmailViewerUGD *ug_data, int index)
4526 EmailViewerProp *prop = ug_data->property;
4528 int attach_index = 0;
4530 /* update attachment information */
4531 LIST_ITER_START(i, prop->attachments) {
4532 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, prop->attachments);
4534 debug_log("info->index[%d] index[%d]", info->index, index);
4535 if (info->index == index) {
4542 debug_log("return id[%d]", attach_index);
4544 return attach_index;
4547 static void _show_select_info(EmailViewerUGD *ug_data, char *str)
4551 if (ug_data->select_info != NULL) {
4552 evas_object_del(ug_data->select_info);
4553 ug_data->select_info = NULL;
4556 if (ug_data->selectioninfo_layout != NULL) {
4557 evas_object_del(ug_data->selectioninfo_layout);
4558 ug_data->selectioninfo_layout = NULL;
4561 ug_data->select_info = elm_notify_add(ug_data->win_main);
4562 elm_notify_align_set(ug_data->select_info, ELM_NOTIFY_ALIGN_FILL, 1.0);
4564 ug_data->selectioninfo_layout = elm_layout_add(ug_data->layout_main);
4565 elm_object_content_set(ug_data->select_info, ug_data->selectioninfo_layout);
4567 elm_layout_theme_set(ug_data->selectioninfo_layout, "standard", "selectioninfo", "center_text");
4569 edje_object_part_text_set(_EDJ(ug_data->selectioninfo_layout), "elm.text", str);
4570 elm_notify_timeout_set(ug_data->select_info, 3);
4571 evas_object_show(ug_data->select_info);
4574 static void _save_attachment(EmailViewerUGD *ug_data, int index)
4577 EmailViewerPrivate *priv = ug_data->email_data;
4578 EmailViewerProp *prop = ug_data->property;
4579 char newpath[MAX_PATH_LEN] = { 0, };
4581 RETURN_IF_FAIL(prop->attachments != NULL);
4582 EmailAttachmentType *info = g_list_nth_data(prop->attachments, index);
4585 debug_log("EmailAttachmentType *info is NULL");
4589 if (!info->download_yn) {
4591 gboolean res = FALSE;
4593 if (ug_data->progress_bar[index + 1] != NULL) {
4594 debug_log("Already getting downloaded...!");
4595 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4596 _("IDS_EMAIL_POP_ALREADY_DOWNLOADING_T_HEADER"), 1,
4597 dgettext("sys_string", "IDS_COM_SK_OK"),
4598 _popup_response_cb, NULL, NULL, NULL);
4602 debug_log("Need attachment download");
4603 /* download attachment */
4604 priv->b_att_save = TRUE;
4606 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4609 priv->download_all_cnt++;
4610 debug_log("Assigning Handle[%d] Index[%d] download_all_cnt[%d]", handle, index, priv->download_all_cnt);
4611 priv->download_all_email_handle[index] = handle;
4612 _create_down_progress_ex(index, EMAIL_VIEWER_PROGRESSBAR_ATT);
4613 ug_data->display_download_result = TRUE;
4615 priv->b_att_save = FALSE;
4616 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4617 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
4618 dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
4625 if (info && STR_VALID(info->path)) {
4627 debug_log("path[%s]", info->path);
4628 ret = email_attachments_save_file(info->path, newpath, NULL);
4629 if (ret == EMAIL_EXT_SAVE_ERR_NONE) {
4630 char str[128] = { 0, };
4631 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
4632 ret = status_message_post(str);
4634 debug_log("status_message_post failed: %d", ret);
4639 static void _show_attachment(EmailViewerUGD *ug_data, int index)
4642 EmailViewerPrivate *priv = ug_data->email_data;
4643 EmailViewerProp *prop = ug_data->property;
4644 EmailAttachmentType *info = g_list_nth_data(prop->attachments, index);
4645 char newpath[MAX_PATH_LEN] = { 0, };
4648 debug_log("EmailAttachmentType *info is NULL");
4652 debug_log("attach_id:%d, index:%d, name(%s), path(%s), size:%d, download_yn:%d, drm:%d, inline_content:%d",
4653 info->attach_id, info->index, info->name, info->path, (gint) info->size, info->download_yn, info->drm, info->inline_content);
4655 if (!info->download_yn) {
4657 gboolean res = FALSE;
4658 debug_log("Need attachment download");
4660 priv->b_att_open = TRUE;
4662 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4665 priv->download_all_email_handle[index] = handle;
4666 priv->download_all_cnt++;
4667 _create_down_progress_ex(index, EMAIL_VIEWER_PROGRESSBAR_ATT);
4669 priv->b_att_open = FALSE;
4670 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4671 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
4672 dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
4678 gboolean res = FALSE;
4679 res = email_attachments_save_file(info->path, newpath, NULL);
4680 debug_log("Result:%d, Saved Path:%s", res, newpath);
4682 if (res == EMAIL_EXT_SAVE_ERR_NONE) {
4683 char str[128] = { 0, };
4684 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
4685 int ret = status_message_post(str);
4687 debug_log("status_message_post failed: %d", ret);
4689 if (g_str_has_suffix(info->path, ".vcs")) {
4693 fp = fopen(newpath, "r");
4695 debug_error("fopen(%s) is failed.", newpath);
4696 calendar_disconnect();
4701 if (stat(newpath, &st) == -1) {
4702 debug_error("file(%s), stat Error(%d): %s", newpath, errno, strerror(errno));
4704 calendar_disconnect();
4708 int size = st.st_size;
4709 char *raw_data = calloc(size + 1, sizeof(char));
4711 debug_error("calloc is failed.");
4713 calendar_disconnect();
4718 if ((n = fread(raw_data, 1, size, fp)) != size) {
4719 debug_error("error in fread");
4722 calendar_disconnect();
4728 calendar_list_h list = NULL;
4730 ret = calendar_vcalendar_parse_to_calendar(raw_data, &list);
4732 if( list && ret == CALENDAR_ERROR_NONE) {
4733 calendar_db_insert_records(list, NULL, NULL);
4734 debug_log("vcalendar is registered to calendar");
4738 calendar_list_destroy(list, true);
4739 calendar_disconnect();
4741 media_file_register(newpath);
4742 } else if (res == EMAIL_EXT_SAVE_ERR_ALREADY_EXIST && !ug_data->display_download_result) {
4743 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
4744 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0,
4745 NULL, NULL, NULL, NULL, _popup_response_cb);
4748 debug_log("display_download_result:%d", ug_data->display_download_result);
4749 if (ug_data->display_download_result) {
4750 if (res == EMAIL_EXT_SAVE_ERR_NONE || res == EMAIL_EXT_SAVE_ERR_ALREADY_EXIST) {
4752 service_h service = NULL;
4753 ret = service_create(&service);
4754 debug_log("service_create: %d", ret);
4756 debug_log("service create failed");
4759 ret = service_set_operation(service, SERVICE_OPERATION_VIEW);
4760 debug_log("service_set_operation: %d", ret);
4761 ret = service_set_uri(service, newpath);
4762 debug_log("service_set_uri: %d", ret);
4763 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_VIDEO_PLAYER_LAUNCH_APP, "email");
4764 debug_log("service_add_extra_data: %d", ret);
4765 ret = service_send_launch_request(service, NULL, NULL);
4766 debug_log("service_send_launch_request: %d", ret);
4767 if (ret != SERVICE_ERROR_NONE) {
4768 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4769 _("IDS_EMAIL_POP_THIS_ATTACHMENT_CANNOT_BE_DISPLAYED"), 0,
4770 NULL, NULL, NULL, NULL, _popup_response_cb);
4772 ret = service_destroy(service);
4773 debug_log("service_destroy: %d", ret);
4775 debug_log("EMAIL_EXT_SAVE_ERR_UNKNOWN");
4780 static void _save_attachment_all(EmailViewerUGD *ug_data)
4783 EmailViewerPrivate *priv = ug_data->email_data;
4784 EmailViewerProp *prop = ug_data->property;
4785 EmailAttachmentType *info = NULL;
4788 int att_len = g_list_length(prop->attachments);
4790 if (priv->b_all_att_save)
4793 for (i = 0; i < att_len; i++) {
4794 info = g_list_nth_data(prop->attachments, i);
4796 if (info && !info->inline_content) {
4797 if (!info->download_yn) {
4798 if (ug_data->progress_bar_ly[i + 1] == NULL) {
4800 gboolean res = FALSE;
4801 debug_log("Need attachment [%d] download", i);
4803 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4806 priv->download_all_cnt++;
4807 priv->download_all_email_handle[i] = handle;
4808 priv->b_all_att_save = TRUE;
4810 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
4811 if (priv->b_all_att_save) {
4812 if (ug_data->attach_onoff_flag == 0) {
4813 _attachment_item_collapse_cb(ug_data->attach_hd_bk, NULL, NULL, NULL);
4817 _create_down_progress_ex(i, EMAIL_VIEWER_PROGRESSBAR_ATT);
4818 ug_data->display_download_result = TRUE;
4820 priv->download_all_fail_cnt++;
4827 debug_log("download [%d], failed [%d]", priv->download_all_cnt, priv->download_all_fail_cnt);
4830 static void _dbus_receiver_setup(EmailViewerUGD *ug_data)
4834 int ret = e_dbus_init();
4835 debug_log("ret: %d", ret);
4839 if (_g_viewer_dbus_conn == NULL) {
4841 dbus_error_init(&derror);
4842 _g_viewer_dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
4844 if (_g_viewer_dbus_conn == NULL) {
4845 debug_log("e_dbus_bus_get return NULL");
4849 if (e_dbus_request_name(_g_viewer_dbus_conn, "User.Email.StorageChange", 0, NULL, NULL) == NULL) {
4850 debug_critical("Failed to e_dbus_request_name()");
4854 if (_g_viewer_signal_handler_storage != NULL) {
4855 debug_log("_g_viewer_signal_handler_storage != NULL");
4858 _g_viewer_signal_handler_storage = e_dbus_signal_handler_add(_g_viewer_dbus_conn, NULL,
4859 "/User/Email/StorageChange",
4860 "User.Email.StorageChange",
4861 "email", _on_edbus_event_email_viewer_receive, ug_data);
4863 if (_g_viewer_signal_handler_storage == NULL) {
4864 debug_log("Failed to e_dbus_signal_handler_add()");
4869 if (e_dbus_request_name(_g_viewer_dbus_conn, "User.Email.NetworkStatus", 0, NULL, NULL) == NULL) {
4870 debug_log("Failed to e_dbus_request_name()");
4874 if (_g_viewer_signal_handler_network != NULL) {
4875 debug_log("_g_viewer_signal_handler_network != NULL");
4878 _g_viewer_signal_handler_network = e_dbus_signal_handler_add(_g_viewer_dbus_conn, NULL,
4879 "/User/Email/NetworkStatus",
4880 "User.Email.NetworkStatus",
4881 "email", _on_edbus_event_email_viewer_receive, ug_data);
4883 if (_g_viewer_signal_handler_network == NULL) {
4884 debug_log("Failed to e_dbus_signal_handler_add()");
4890 static void _dbus_receiver_remove(EmailViewerUGD *ug_data)
4894 if (_g_viewer_signal_handler_storage != NULL) {
4895 e_dbus_signal_handler_del(_g_viewer_dbus_conn, _g_viewer_signal_handler_storage);
4896 _g_viewer_signal_handler_storage = NULL;
4899 if (_g_viewer_signal_handler_network != NULL) {
4900 e_dbus_signal_handler_del(_g_viewer_dbus_conn, _g_viewer_signal_handler_network);
4901 _g_viewer_signal_handler_network = NULL;
4904 if (e_dbus_release_name(_g_viewer_dbus_conn, "User.Email.StorageChange", NULL, NULL) == NULL) {
4905 debug_critical("e_dbus_release_name to failed");
4908 if (e_dbus_release_name(_g_viewer_dbus_conn, "User.Email.NetworkStatus", NULL, NULL) == NULL) {
4909 debug_critical("e_dbus_release_name to failed");
4912 if (_g_viewer_dbus_conn != NULL) {
4913 _g_viewer_dbus_conn = NULL;
4917 static void _on_edbus_event_email_viewer_receive(void *data, DBusMessage *message)
4922 debug_log("data is NULL");
4926 EmailViewerUGD *ug_data = _g_ug_data;
4927 EmailViewerPrivate *priv = ug_data->email_data;
4928 char fail_msg[MAX_STR_LEN] = { 0, };
4931 if (dbus_message_is_signal(message, "User.Email.StorageChange", "email")) {
4932 debug_log("User.Email.StorageChange");
4939 dbus_error_init(&error);
4940 if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &subtype,
4941 DBUS_TYPE_INT32, &data1, DBUS_TYPE_INT32, &data2,
4942 DBUS_TYPE_STRING, &data3, DBUS_TYPE_INVALID)) {
4943 debug_log("STORE_ENABLE: subtype: %d, data1: %d, data2: %d, data3: %s", subtype, data1, data2, data3);
4946 case NOTI_ACCOUNT_ADD:
4947 if (get_app_paused()) {
4948 debug_log("account added during pause status");
4950 if (ug_data->isRotate == false && ug_data->b_internal) {
4951 /* Viewer to hide, so set left content (mailbox) size to full */
4952 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
4955 if (ug_data->b_internal != 1) {
4956 debug_log("ug_destory_me");
4957 ug_destroy_me(ug_data->ug);
4959 _hide_view(ug_data);
4964 case NOTI_ACCOUNT_DELETE:
4965 if (get_app_paused()) {
4966 debug_log("account deleted during pause status");
4969 if (ug_data->isRotate == false && ug_data->b_internal) {
4970 /* Viewer to hide, so set left content (mailbox) size to full */
4971 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
4974 if (email_engine_get_default_account(&account_id)) {
4975 if (ug_data->b_internal != 1) {
4976 debug_log("ug_destory_me");
4977 ug_destroy_me(ug_data->ug);
4979 _hide_view(ug_data);
4985 case NOTI_ACCOUNT_UPDATE:
4986 if (get_app_paused()) {
4987 debug_log("account updated during pause status");
4992 debug_warning("unknown type");
4996 debug_critical("receive data error: %s", error.message);
4997 dbus_error_free(&error);
4999 } else if (dbus_message_is_signal(message, "User.Email.NetworkStatus", "email")) {
5008 dbus_error_init(&error);
5010 if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &subtype,
5011 DBUS_TYPE_INT32, &data1, DBUS_TYPE_STRING, &data2,
5012 DBUS_TYPE_INT32, &data3, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID)) {
5013 debug_log("subtype: %d, data1: %d, data2: %s, data3: %d, data4: %d", subtype, data1, data2, data3, data4);
5016 case NOTI_DOWNLOAD_BODY_START:
5017 /* DATA1[mail_id] DATA2[file_id] DATA3[body_size] DATA4[received size] */
5018 debug_log("receive noti, DOWNLOAD_BODY");
5019 if (priv->mail_id == data1) {
5020 priv->file_id = g_strdup(data2);
5021 priv->file_size = data3;
5024 _set_value_down_progress(0.0);
5026 double per = (double)data4 / (double)data3;
5027 _set_value_down_progress(per);
5030 debug_log("mail_id is different");
5031 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5035 case NOTI_DOWNLOAD_MULTIPART_BODY:
5036 /* DATA1[mail_id] DATA2[file_id] DATA3[body_size] DATA4[received size] */
5037 debug_log("receive noti, DOWNLOAD_MULTIPART_BODY");
5038 if (priv->mail_id == data1) {
5039 priv->file_id = g_strdup(data2);
5040 priv->file_size = data3;
5041 priv->multi_body = TRUE;
5044 _set_value_down_progress(0.0);
5046 double per = (double)data4 / (double)data3;
5047 _set_value_down_progress(per);
5050 debug_log("mail_id is different");
5051 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5055 case NOTI_DOWNLOAD_BODY_FINISH:
5056 /* DATA1[mail_id] DATA2[NULL] DATA3[handle_id] */
5057 debug_log("receive noti, DOWNLOAD_BODY_FINISH");
5058 if (priv->email_handle == data3 && priv->mail_id == data1) {
5059 priv->email_handle = 0;
5061 ug_data->b_load_finished = EINA_FALSE;
5063 /* delete progress */
5064 if (ug_data->pb_notify) {
5065 _set_value_down_progress(1.0);
5066 _destroy_down_progress_cb(NULL, NULL, NULL);
5069 char str[128] = { 0, };
5070 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_BODY_DOWNLOADED"));
5071 int ret = status_message_post(str);
5073 debug_log("status_message_post failed: %d", ret);
5076 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
5077 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
5079 /* create att and body */
5080 if (ug_data->b_partial_body) {
5085 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
5086 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
5088 elm_box_unpack(ug_data->main_bx, ug_data->partial_dn_btn_bx);
5089 if (ug_data->partial_dn_btn) {
5090 evas_object_del(ug_data->partial_dn_btn);
5091 ug_data->partial_dn_btn = NULL;
5093 if (ug_data->partial_dn_btn_bx) {
5094 evas_object_del(ug_data->partial_dn_btn_bx);
5095 ug_data->partial_dn_btn_bx = NULL;
5098 if (ug_data->property->has_html) {
5099 ug_data->webview_data->body_type = BODY_TYPE_HTML;
5100 ug_data->webview_data->uri = ug_data->property->body_uri;
5102 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
5103 ug_data->webview_data->text_content = ug_data->property->body;
5106 viewer_set_webview_content(ug_data, 1);
5108 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
5109 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
5112 if (ug_data->property->has_attachment)
5113 ug_data->got_att = 1;
5115 ug_data->got_att = 0;
5117 /* pack attachment if it exist */
5118 if (ug_data->got_att) {
5119 _create_attach(ug_data);
5122 _create_body(ug_data);
5125 debug_log("email_handle or mail_id is different");
5126 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5127 debug_log("expected email_handle [%d], received email_handle [%d]", priv->email_handle, data3);
5131 case NOTI_DOWNLOAD_BODY_FAIL:
5132 /* DATA1[mail_id] DATA2[NULL] DATA3[handle_id] */
5133 debug_log("receive noti, DOWNLOAD_BODY_FAIL");
5134 if (priv->email_handle == data3 && priv->mail_id == data1) {
5135 priv->email_handle = 0;
5137 /* delete progress */
5138 if (ug_data->pb_notify) {
5139 _destroy_down_progress_cb(NULL, NULL, NULL);
5142 char *err_msg = _get_service_fail_type(data4);
5143 snprintf(fail_msg, sizeof(fail_msg), "%s<br>%s", _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), err_msg);
5144 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
5145 fail_msg, 1, dgettext("sys_string", "IDS_COM_SK_OK"),
5146 _popup_response_cb, NULL, NULL, NULL);
5149 debug_log("email_handle or mail_id is different");
5150 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5151 debug_log("expected email_handle [%d], received email_handle [%d]", priv->email_handle, data3);
5155 case NOTI_DOWNLOAD_ATTACH_START:
5156 /* DATA1[mail_id] DATA2[file_id] DATA3[attachment_id] DATA4[percentage] */
5157 debug_log("receive noti, DOWNLOAD_ATTACHMENT");
5158 if (priv->mail_id == data1) {
5159 priv->att_file_id = g_strdup(data2);
5160 priv->attachment_id = data3;
5163 /* Set the progressbar of particular attachment_id */
5164 _set_value_down_progress_by_index(0.0, priv->attachment_id);
5167 double per = (double)data4 / 100.0;
5168 /* Set the progressbar of particular attachment_id */
5169 _set_value_down_progress_by_index(per, priv->attachment_id);
5172 debug_log("mail_id is different");
5173 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5177 case NOTI_DOWNLOAD_ATTACH_FINISH:
5178 /* DATA1[mail_id] DATA2[NULL] DATA3[attachment_id] */
5179 debug_log("receive noti, DOWNLOAD_ATTACH_FINISH");
5181 if (priv->mail_id == data1) {
5182 int attach_index = 0;
5183 int attachment_id = (int)data3;
5184 debug_log("download_all_cnt [%d]", priv->download_all_cnt);
5186 if (priv->download_all_cnt > 0) {
5187 _set_value_down_progress_by_index(1.0, attachment_id);
5188 attach_index = _update_attachment_info(ug_data, attachment_id);
5189 if (priv->b_all_att_save) {
5190 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5191 _save_attachment(ug_data, attach_index);
5192 if (priv->download_all_cnt == 0) {
5193 priv->b_all_att_save = FALSE;
5196 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5197 _show_attachment(ug_data, attach_index);
5199 } else { // for updating attachments
5200 attach_index = _update_attachment_info(ug_data, attachment_id);
5201 debug_log("attach_index [%d]", attach_index);
5204 debug_log("mail_id or attachment_id is different");
5205 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5209 case NOTI_DOWNLOAD_ATTACH_FAIL:
5210 /* DATA1[mail_id] DATA2[NULL] DATA3[attachment_id] */
5211 debug_log("receive noti, DOWNLOAD_ATTACH_FAIL");
5212 if (priv->mail_id == data1) {
5213 int attach_index = _get_attachment_info_index(ug_data, data3);
5214 debug_log("download_all_cnt[%d]", priv->download_all_cnt);
5216 if (priv->download_all_cnt > 0) {
5217 if (ug_data->progress_bar[data3] != NULL && data4 != EMAIL_ERROR_CANCELLED)
5218 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5220 debug_log("Download already cancelled, No need to destroy again..!");
5222 if (data4 != EMAIL_ERROR_CANCELLED && ug_data->ug_composer == NULL) {
5223 char *err_msg = _get_service_fail_type(data4);
5224 snprintf(fail_msg, sizeof(fail_msg), "%s<br>%s", _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), err_msg);
5225 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"), fail_msg, 1,
5226 dgettext("sys_string", "IDS_COM_SK_OK"),
5227 _popup_response_cb, NULL, NULL, NULL);
5231 if (priv->b_all_att_save && priv->download_all_cnt == 0) {
5232 priv->b_all_att_save = FALSE;
5236 debug_log("mail_id is different");
5237 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5242 debug_log("unknown type");
5246 debug_log("receive data error: %s", error.message);
5247 dbus_error_free(&error);
5254 static void _delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item)
5258 if (contacts_list_item) {
5259 g_free(contacts_list_item->display);
5260 contacts_list_item->display = NULL;
5261 g_free(contacts_list_item->email_address);
5262 contacts_list_item->email_address = NULL;
5263 g_free(contacts_list_item);
5264 contacts_list_item = NULL;
5268 static void *_contact_search_by_email(EmailViewerUGD *ug_data, const char *search_word)
5271 if (!ug_data || !_g_ug_data) {
5272 debug_log("data is NULL");
5276 if (contacts_connect2() != CONTACTS_ERROR_NONE) {
5277 debug_log("Fail of contacts_connect2 !!!");
5281 int ct_ret = CONTACTS_ERROR_NONE;
5282 EMAIL_CONTACT_LIST_INFO_S *contacts_list_item = NULL;
5283 contacts_list_h list = NULL;
5285 ct_ret = email_get_contacts_list(CONTACTS_MATCH_EXACTLY, &list, search_word);
5286 debug_log("email_get_contacts_record:%d, list : %p", ct_ret, list);
5289 debug_log("list is NULL");
5290 contacts_list_destroy(list, true);
5291 contacts_disconnect2();
5295 contacts_list_item = (EMAIL_CONTACT_LIST_INFO_S *)calloc(1, sizeof(EMAIL_CONTACT_LIST_INFO_S));
5296 contacts_list_item->ugd = ug_data;
5298 ct_ret = email_get_contacts_list_info(list, contacts_list_item);
5299 if (ct_ret != CONTACTS_ERROR_NONE) {
5300 debug_log("email_get_contacts_list_info: ct_ret : %d", ct_ret);
5301 contacts_list_destroy(list, true);
5302 contacts_disconnect2();
5305 debug_log("email_get_contacts_list_info:%d, contacts_list_item : %p", ct_ret, contacts_list_item);
5307 contacts_list_destroy(list, true);
5308 contacts_disconnect2();
5310 return contacts_list_item;
5313 static void _set_value_down_progress(double val)
5318 debug_log("data is NULL");
5321 char buf[30] = { 0, };
5322 EmailViewerUGD *ug_data = _g_ug_data;
5324 sprintf(buf, "%s: %d", dgettext("sys_string", "IDS_COM_POP_DOWNLOADING"), (int)val);
5326 if (ug_data->pb_notify_lb) {
5327 elm_progressbar_value_set(ug_data->pb_notify_lb, val);
5328 elm_object_text_set(ug_data->pb_notify_lb, buf);
5332 static void _set_value_down_progress_by_index(double val, int index)
5337 debug_log("data is NULL");
5341 EmailViewerUGD *ug_data = _g_ug_data;
5342 EmailViewerProp *prop = ug_data->property;
5345 debug_log("val(%f) is MINUS", val);
5349 if (index < 0 || index >= ATTACH_MAX) {
5350 debug_log("index(%d) is overflowed", index);
5355 debug_log("prop is NULL");
5359 if (prop->attachments == NULL) {
5360 debug_log("attachments is NULL");
5364 int per = val * 100;
5365 int attach_index = _get_attachment_info_index(ug_data, index);
5366 EmailAttachmentType *info = g_list_nth_data(prop->attachments, attach_index);
5369 debug_log("info is NULL");
5372 if (ug_data->progress_bar[index] == NULL) {
5373 debug_log("obj is NULL");
5377 char *pszTemp = NULL;
5378 pszTemp = (char *)elm_object_style_get(ug_data->progress_bar[index]);
5380 if (STR_INVALID(pszTemp))
5383 if (g_strcmp0(pszTemp, "pending_list") == 0) {
5384 debug_log("pending_list so return");
5388 elm_progressbar_value_set(ug_data->progress_bar[index], val);
5390 if (ug_data->progress_bar_ly[index] != NULL) {
5391 char buf[30] = { 0, };
5392 snprintf(buf, sizeof(buf), "%d%%", per);
5394 Evas_Object *downloading_label2;
5395 downloading_label2 = elm_label_add(ug_data->progress_bar_ly[index]);
5396 elm_object_part_content_set(ug_data->progress_bar_ly[index], "elm.text.2", downloading_label2);
5397 char *buf_tagged = g_strconcat("<font_size=26><align=left><color=#646464FF>", buf, "</align></font_size>", NULL);
5398 elm_object_text_set(downloading_label2, buf_tagged);
5403 static void _cancel_download_attachment(EmailViewerUGD *ug_data)
5407 gboolean is_cancel = FALSE;
5410 debug_log("data is NULL");
5414 EmailViewerPrivate *priv = ug_data->email_data;
5415 EmailViewerProp *prop = ug_data->property;
5417 if (priv && priv->download_all_cnt <= 0) {
5418 debug_log("No attachment download to be cancelled!");
5422 for (i = 0; i <= prop->att_len; i++) {
5423 if (ug_data->progress_bar_ly[i]) {
5424 Evas_Object *btn = elm_object_part_content_get(ug_data->progress_bar_ly[i], "elm.icon.1");
5425 debug_log("Cancel btn for downloading attachment: %p", btn);
5427 evas_object_smart_callback_call(btn, "clicked", NULL);
5433 if (is_cancel == TRUE && ug_data->ug_composer == NULL) {
5434 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"), _("IDS_EMAIL_POP_CANCELLING_ATTACHMENT_DOWNLOAD_ING"),
5435 1, dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
5440 static char *_get_service_fail_type(int type)
5445 char str[MAX_STR_LEN] = { 0, };
5448 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("IP full"));
5449 return g_strdup(str);
5450 } else if (type == -176) {
5451 ret = _("IDS_EMAIL_POP_NO_SERVICE");
5452 return g_strdup(ret);
5453 } else if (type == -181) {
5454 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("Transport Error"));
5455 return g_strdup(str);
5456 } else if (type == EMAIL_ERROR_NETWORK_TOO_BUSY) {
5457 ret = _("IDS_EMAIL_POP_NETWORK_BUSY");
5458 return g_strdup(ret);
5459 } else if (type == EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS) {
5460 snprintf(str, sizeof(str), _("IDS_EMAIL_POP_YOU_CAN_ONLY_LOG_IN_ONCE_EVERY_PD_MINUTES"), 15);
5461 return g_strdup(str);
5462 } else if (type == EMAIL_ERROR_CONNECTION_FAILURE) {
5463 ret = dgettext("sys_string", "IDS_COM_POP_CONNECTION_FAILED");
5464 return g_strdup(ret);
5465 } else if (type == EMAIL_ERROR_LOGIN_FAILURE) {
5466 ret = _("IDS_EMAIL_POP_LOG_IN_FAILED");
5467 return g_strdup(ret);
5468 } else if (type == EMAIL_ERROR_AUTHENTICATE) {
5469 ret = _("IDS_EMAIL_POP_AUTHENTICATION_FAILED");
5470 return g_strdup(ret);
5471 } else if (type == EMAIL_ERROR_CANCELLED) {
5472 ret = _("IDS_EMAIL_POP_DOWNLOAD_CANCELLED");
5473 return g_strdup(ret);
5474 } else if (type == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) {
5475 ret = _("IDS_EMAIL_POP_EMAIL_DELETED_FROM_SERVER");
5476 return g_strdup(ret);
5477 } else if (type == EMAIL_ERROR_NO_SUCH_HOST) {
5478 ret = _("IDS_EMAIL_POP_HOST_NOT_FOUND");
5479 return g_strdup(ret);
5480 } else if (type == EMAIL_ERROR_INVALID_SERVER) {
5481 ret = _("IDS_EMAIL_POP_SERVER_NOT_AVAILABLE");
5482 return g_strdup(ret);
5483 } else if (type == EMAIL_ERROR_MAIL_MEMORY_FULL) {
5484 ret = _("IDS_EMAIL_POP_DEVICE_STORAGE_FULL");
5485 return g_strdup(ret);
5486 } else if (type == EMAIL_ERROR_FAILED_BY_SECURITY_POLICY) {
5487 ret = _("IDS_EMAIL_POP_DOWNLOADING_ATTACHMENTS_ON_THE_MOBILE_DEVICE_IS_NOT_ALLOWED_BY_EXCHANGE_SERVER_POLICY");
5488 return g_strdup(ret);
5489 } else if (type == EMAIL_ERROR_NETWORK_NOT_AVAILABLE) {
5490 ret = N_("Network not available");
5491 return g_strdup(ret);
5492 } else if (type == EMAIL_ERROR_FLIGHT_MODE) {
5493 ret = N_("Flight mode enabled");
5494 return g_strdup(ret);
5495 } else if (type == EMAIL_ERROR_NO_RESPONSE) {
5496 ret = N_("No server response");
5497 return g_strdup(ret);
5498 } else if (type == EMAIL_ERROR_DISCONNECTED) {
5499 ret = N_("Disconnected");
5500 return g_strdup(ret);
5501 } else if (type == EMAIL_ERROR_CONNECTION_BROKEN) {
5502 ret = N_("Connection broken");
5503 return g_strdup(ret);
5505 snprintf(str, sizeof(str), "%s (%d)", dgettext("sys_string", "IDS_COM_POP_UNKNOWN_ERROR_OCCURRED"), type);
5506 return g_strdup(str);
5510 static Evas_Object *_load_edj(Evas_Object *parent, const char *file, const char *group)
5516 eo = elm_layout_add(parent);
5518 r = elm_layout_file_set(eo, file, group);
5520 evas_object_del(eo);
5524 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5531 static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part)
5537 static void _gl_del(void *data, Evas_Object *obj)
5541 if (_g_ug_data == NULL) {
5542 debug_log("ug_data is NULL");
5546 EmailViewerUGD *ug_data = _g_ug_data;
5548 if (ug_data->move_mailbox_list) {
5549 email_free_mailbox(&ug_data->move_mailbox_list, ug_data->move_mailbox_count);
5550 ug_data->move_mailbox_list = NULL;
5551 ug_data->move_mailbox_count = 0;
5557 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part)
5560 email_mailbox_t *mailbox_list = NULL;
5561 mailbox_list = (email_mailbox_t *) data;
5563 if (g_strcmp0(part, "elm.text") == 0) {
5564 char buf[MAX_STR_LEN] = { 0, };
5565 if (mailbox_list && mailbox_list->alias) {
5566 snprintf(buf, sizeof(buf), "%s", mailbox_list->alias);
5567 return g_strdup(buf);
5574 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part)
5578 if (g_strcmp0(part, "elm.icon") == 0) {
5579 Evas_Object *icon = elm_icon_add(obj);
5580 elm_image_file_set(icon, IMGDIR "/U01_icon_folder.png", NULL);
5581 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
5589 static void _move_here_cb(void *data, Evas_Object *obj, void *event_info)
5593 if (data == NULL || _g_ug_data == NULL) {
5594 debug_log("data is NULL");
5598 email_mailbox_t *mailbox_list = NULL;
5599 mailbox_list = (email_mailbox_t *) data;
5601 EmailViewerUGD *ug_data = _g_ug_data;
5602 int folder_id = mailbox_list->mailbox_id;
5605 ret = _move_email(ug_data, folder_id, FALSE);
5608 ug_data->navi_move_it1 = NULL;
5609 elm_naviframe_item_pop_to(ug_data->navi_main_it);
5611 if (ug_data->isRotate == false && ug_data->b_internal) {
5612 /* Viewer to hide, so set left content (mailbox) size to full */
5613 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
5616 if (ug_data->b_internal) {
5617 _hide_view(ug_data);
5619 /* send next or previous mail request to mailbox. */
5620 service_h service = NULL;
5622 ret = service_create(&service);
5623 debug_log("service_create: %d", ret);
5625 debug_log("service create failed");
5629 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
5630 debug_log("service_add_extra_data: %d", ret);
5631 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "1");
5632 debug_log("service_add_extra_data: %d", ret);
5634 ug_send_message(_g_mailbox_ug, service);
5636 ret = service_destroy(service);
5637 debug_log("service_destroy: %d", ret);
5639 ug_destroy_me(ug_data->ug);
5644 static void _move_back_cb(void *data, Evas_Object *obj, void *event_info)
5648 if (data == NULL || _g_ug_data == NULL) {
5649 debug_log("data is NULL");
5653 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
5655 elm_object_item_del(ug_data->navi_move_it1);
5656 ug_data->navi_move_it1 = NULL;