2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #define UG_MODULE_API __attribute__ ((visibility("default")))
22 #include <contacts-ug.h>
23 #include <calendar-svc-provider.h>
24 #include <media-util-register.h>
25 #include <media-util-err.h>
26 #include <app_service.h>
29 #include "email-viewer.h"
30 #include "email-viewer-webview.h"
31 #include "email-viewer-utils.h"
32 #include "email-engine.h"
33 #include "email-utils.h"
34 #include "email-common-types.h"
35 #include "email-debug.h"
37 #define EMAIL_VCONF_KEY_BLOCK_RULE_CHANGED "file/private/org.tizen.email/spam_rule_changed"
40 EmailViewerUGD *_g_ug_data = NULL;
41 E_DBus_Connection *_g_viewer_dbus_conn = NULL;
42 E_DBus_Signal_Handler *_g_viewer_signal_handler_network = NULL;
43 E_DBus_Signal_Handler *_g_viewer_signal_handler_storage = NULL;
45 extern ui_gadget_h _g_mailbox_ug;
46 extern char *icu_locale;
47 extern enum appcore_time_format icu_timeformat;
48 extern void _set_mail_flags(EmailViewerProp *prop, EmailViewerPrivate *email_data);
51 static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h data, void *priv);
52 static void on_start(ui_gadget_h ug, service_h data, void *priv);
53 static void on_pause(ui_gadget_h ug, service_h data, void *priv);
54 static void on_resume(ui_gadget_h ug, service_h data, void *priv);
55 static void on_destroy(ui_gadget_h ug, service_h data, void *pd);
56 static void on_message(ui_gadget_h ug, service_h msg, service_h data, void *priv);
57 static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *priv);
58 static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h data, void *priv);
61 static void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv);
62 static void result_cb(ui_gadget_h ug, service_h result, void *priv);
63 static void destroy_cb(ui_gadget_h ug, void *priv);
64 static ui_gadget_h create_ug(char *ug_name, service_h bd, void *data);
67 static void _create_view(EmailViewerUGD *ug_data);
68 static void _reset_view(EmailViewerUGD *ug_data);
70 static void _win_profile_changed_cb(void *data, Evas_Object *obj, void *event);
72 static Evas_Object *_create_navigation_bar(EmailViewerUGD *ug_data);
73 static Evas_Object *_create_subject(EmailViewerUGD *ug_data);
74 static Evas_Object *_create_to_addrs(EmailViewerUGD *ug_data);
75 static Evas_Object *_create_cc_addrs(EmailViewerUGD *ug_data);
76 static Evas_Object *_create_bcc_addrs(EmailViewerUGD *ug_data);
77 static Evas_Object *_create_attach(EmailViewerUGD *ug_data);
78 static Evas_Object *_create_attach_ex(EmailViewerUGD *ug_data);
79 static Evas_Object *_create_body(EmailViewerUGD *ug_data);
80 static Evas_Object *_create_tab_bar(EmailViewerUGD *ug_data);
81 static Evas_Object *_update_tab_bar(EmailViewerUGD *ug_data);
82 static Evas_Object *_create_partial_body_dn_btn(EmailViewerUGD *ug_data);
83 static Evas_Object *_create_bg(Evas_Object *win);
85 static void _create_down_progress(char *message, popup_cb resp_cb);
86 static void _create_down_progress_ex(int index, EMAIL_VIEWER_PROGRESSBAR_TYPE p_type);
87 static void _destroy_down_progress_ex(void *data, Evas_Object *obj, void *event_info);
88 static void _create_more_ctxpopup(EmailViewerUGD *ug_data);
89 static void _delete_evas_objects(EmailViewerUGD *ug_data);
91 static void _launch_vcs_editor(EmailViewerUGD *ug_data);
93 /* callback functions */
94 static void _back_cb(void *data, Evas_Object *obj, void *event_info);
95 static void _prev_mail_cb(void *data, Evas_Object *obj, void *event_info);
96 static void _next_mail_cb(void *data, Evas_Object *obj, void *event_info);
97 static void _reply_cb(void *data, Evas_Object *obj, void *event_info);
98 static void _reply_all_cb(void *data, Evas_Object *obj, void *event_info);
99 static void _reply_option_cb(void *data, Evas_Object *obj, void *event_info);
100 static void _forward_cb(void *data, Evas_Object *obj, void *event_info);
101 static void _add_to_calendar_cb(void *data, Evas_Object *obj, void *event_info);
102 static void _resend_cb(void *data, Evas_Object *obj, void *event_info);
103 static void _delete_cb(void *data, Evas_Object *obj, void *event_info);
104 static void _move_cb(void *data, Evas_Object *obj, void *event_info);
105 static void _more_cb(void *data, Evas_Object *obj, void *event_info);
106 static void _body_down_cb(void *data, Evas_Object *obj, void *event_info);
107 static void _subject_favorite_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
108 static void _subject_detail_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
109 static void _attachment_item_collapse_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
110 static void _attachment_save_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
111 static void _attachment_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
112 static void _attachment_save_all_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
113 static void _attachment_bg_set_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
114 static void _attachment_bg_unset_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
115 static void _mark_as_unread_cb(void *data, Evas_Object *obj, void *event_info);
116 static void _mark_as_read_cb(void *data, Evas_Object *obj, void *event_info);
118 static void _ctxpopup_detail_contact_cb(void *data, Evas_Object *obj, void *event_info);
119 static void _ctxpopup_send_email_cb(void *data, Evas_Object *obj, void *event_info);
120 static void _ctxpopup_add_contact_cb(void *data, Evas_Object *obj, void *event_info);
121 static void _ctxpopup_cutlink_update_contact_cb(void *data, Evas_Object *obj, void *event_info);
122 static void _ctxpopup_select_contact_mode_email_cb(void *data, Evas_Object *obj, void *event_info);
123 static void _ctxpopup_add_block_rule_cb(void *data, Evas_Object *obj, void *event_info);
124 static void _popup_response_cb(void *data, Evas_Object *obj, void *event_info);
125 static void _popup_response_delete_ok_cb(void *data, Evas_Object *obj, void *event_info);
126 static void _popup_response_to_destroy_cb(void *data, Evas_Object *obj, void *event_info);
128 static void _webview_multi_up_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
129 static void _webview_multi_down_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info);
130 static void _webview_policy_navigation_decide_cb(void *data, Evas_Object *obj, void *event_info);
132 static void _outter_scroller_bottom_hit_cb(void *data, Evas_Object *obj, void *event_info);
133 static void _outter_scroller_top_hit_cb(void *data, Evas_Object *obj, void *event_info);
134 static void _outter_scroller_scroll_cb(void *data, Evas_Object *obj, void *event_info);
136 static void _mbe_added_cb(void *data, Evas_Object *obj, void *event_info);
137 static void _mbe_selected_cb(void *data, Evas_Object *obj, void *event_info);
138 static void _destroy_down_progress_cb(void *data, Evas_Object *obj, void *event_info);
140 /* Logic Functions */
141 static void _init_viewer_data(int account_id, int mail_id, char *srv_mail_id, EmailViewerUGD *ug_data);
142 static int _init_webview_data(EmailViewerUGD *ug_data);
143 static Eina_Bool _check_body_download(void *data);
144 static int _update_attachment_info(EmailViewerUGD *ug_data, int index);
145 static int _get_attachment_info_index(EmailViewerUGD *ug_data, int index);
146 static void _show_select_info(EmailViewerUGD *ug_data, char *str);
147 static void _save_attachment(EmailViewerUGD *ug_data, int index);
148 static void _show_attachment(EmailViewerUGD *ug_data, int index);
149 static void _save_attachment_all(EmailViewerUGD *ug_data);
150 static void _dbus_receiver_setup(EmailViewerUGD *ug_data);
151 static void _dbus_receiver_remove(EmailViewerUGD *ug_data);
152 static void _on_edbus_event_email_viewer_receive(void *local_data, DBusMessage *message);
154 static void _delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item);
155 static void *_contact_search_by_email(EmailViewerUGD *ug_data, const char *search_word);
156 static void _set_value_down_progress(double val);
157 static void _set_value_down_progress_by_index(double val, int index);
158 static void _cancel_download_attachment(EmailViewerUGD *ug_data);
161 static char *_get_service_fail_type(int type);
162 static Evas_Object *_load_edj(Evas_Object *parent, const char *file, const char *group);
165 static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part);
166 static void _gl_del(void *data, Evas_Object *obj);
167 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part);
168 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part);
169 static void _gl_sel(void *data, Evas_Object *obj, void *event_info);
170 static char *_gl_sub_upper_text_get(void *data, Evas_Object *obj, const char *part);
171 static Evas_Object *_gl_sub_upper_icon_get(void *data, Evas_Object *obj, const char *part);
172 static void _gl_sub_upper_sel(void *data, Evas_Object *obj, void *event_info);
173 static void _move_here_cb(void *data, Evas_Object *obj, void *event_info);
174 static void _move_back_cb(void *data, Evas_Object *obj, void *event_info);
175 static void _move_back_cb2(void *data, Evas_Object *obj, void *event_info);
178 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
182 EmailViewerUGD *ug_data;
187 ug_data = calloc(1, sizeof(EmailViewerUGD));
191 _g_ug_data = ug_data;
194 ops->create = on_create;
195 ops->start = on_start;
196 ops->pause = on_pause;
197 ops->resume = on_resume;
198 ops->destroy = on_destroy;
199 ops->message = on_message;
200 ops->event = on_event;
201 ops->key_event = on_key_event;
203 ops->opt = UG_OPT_INDICATOR_ENABLE;
208 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
211 EmailViewerUGD *ug_data;
223 static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h data, void *priv)
226 EmailViewerUGD *ug_data;
227 char *account_id = NULL;
228 char *mail_id = NULL;
229 char *mailbox_id = NULL;
230 char *binternal = NULL;
231 char *landscape = NULL;
240 debug_log("account_id and mail_id are required by arguments");
241 ug_data->b_direct_destroy = 1;
242 ug_destroy_me(ug_data->ug);
247 /* email engine initialize */
248 if (email_engine_initialize() == FALSE) {
249 debug_log("Failed to initialize email engine");
250 ug_data->b_direct_destroy = 1;
251 ug_destroy_me(ug_data->ug);
256 /* Elm_Theme *theme = elm_theme_new();
257 elm_theme_ref_set(theme, NULL);
258 ug_data->theme = theme;
259 elm_theme_extension_add(ug_data->theme, EV_THEME_PATH);*/
262 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_ACCOUNT_ID, (char **)&account_id);
263 debug_log("service_get_extra_data: %d", ret);
264 debug_log("account_id:%s", account_id);
265 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_MAIL_ID, (char **)&mail_id);
266 debug_log("service_get_extra_data: %d", ret);
267 debug_log("mail_id:%s", mail_id);
268 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_MAILBOX, (char **)&mailbox_id);
269 debug_log("service_get_extra_data: %d", ret);
270 debug_log("mailbox:%s", mailbox_id);
271 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_INTERNAL, (char **)&binternal);
272 debug_log("service_get_extra_data: %d", ret);
273 debug_log("binternal:%s", binternal);
274 ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_FIRST_LANDSCAPE, (char **)&landscape);
275 debug_log("service_get_extra_data: %d", ret);
276 debug_log("landscape:%s", landscape);
279 ug_data->isRotate = atoi(landscape);
280 debug_log("@@@@ Landscape = %d @@@@", ug_data->isRotate);
285 ug_data->account_id = atoi(account_id);
286 ug_data->folder_list = email_engine_get_ca_mailbox_list_using_glist(ug_data->account_id);
291 ug_data->mail_id = atoi(mail_id);
296 g_free(ug_data->mailbox_name);
297 ug_data->mailbox_name = NULL;
298 ug_data->mailbox_id = atoi(mailbox_id);
302 email_mail_data_t *mail_data = NULL;
303 if ((err = email_get_mail_data(ug_data->mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
304 debug_log("fail to get mail - err (%d)", err);
307 if (mail_data == NULL) {
308 debug_log("mail_data is NULL");
311 ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name);
312 ug_data->mailbox_type = mail_data->mailbox_type;
313 debug_log("server_mailbox_name:%s", mail_data->server_mailbox_name);
314 debug_log("mailbox_name:%s", ug_data->mailbox_name);
315 debug_log("mailbox_type:%d", ug_data->mailbox_type);
318 debug_log("email_free_mail is called");
319 email_free_mail_data(&(mail_data), 1);
325 ug_data->b_internal = atoi(binternal);
326 if (ug_data->b_internal == 1)
327 debug_log("############Launched from email-mailbox###############");
331 debug_log("account_id [%d], mail_id [%d], mailbox_id [%d], mailbox name [%s]", ug_data->account_id, ug_data->mail_id, ug_data->mailbox_id, ug_data->mailbox_name);
333 if (ug_data->account_id <= 0 || ug_data->mail_id <= 0 || ug_data->mailbox_id <= 0) {
334 debug_log("Required bundle parameters are missing!");
335 ug_data->timeout_popup = elm_popup_add(ug_get_window());
336 evas_object_size_hint_weight_set(ug_data->timeout_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
337 elm_popup_timeout_set(ug_data->timeout_popup, 2);
338 elm_object_text_set(ug_data->timeout_popup, _("IDS_EMAIL_POP_UNABLE_TO_OPEN_EMAIL_MESSAGE"));
339 elm_object_part_text_set(ug_data->timeout_popup, "title,text", _("IDS_EMAIL_POP_ALERT"));
340 evas_object_smart_callback_add(ug_data->timeout_popup, "block,clicked", _popup_response_to_destroy_cb, ug_data);
341 evas_object_smart_callback_add(ug_data->timeout_popup, "timeout", _popup_response_to_destroy_cb, ug_data);
342 evas_object_show(ug_data->timeout_popup);
344 return elm_layout_add(ug_get_window());
347 ug_data->win_main = ug_get_window();
349 char *proxy_address = vconf_get_str(VCONFKEY_NETWORK_PROXY);
350 debug_log("network proxy: %s", proxy_address);
351 if (proxy_address && (g_strcmp0(proxy_address, "") != 0)) {
352 ewk_context_proxy_uri_set(ewk_context_default_get(), proxy_address);
359 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
360 debug_log("WINDOW W[%d] H[%d]", w, h);
364 ug_data->scale_factor = elm_scale_get();
365 debug_log("ELM Scale[%f]", ug_data->scale_factor);
368 ug_data->webview_width = 710.0;
369 ug_data->webview_height = 949.0;
370 ug_data->webview_width_landscape = 710.0;
371 ug_data->webview_height_landscape = 568.0;
372 ug_data->webview_margin = 633;
373 ug_data->webview_margin_landscape = 379;
374 } else if (w == 720) {
375 ug_data->webview_width = 710.0;
376 ug_data->webview_height = 1009.0;
377 ug_data->webview_width_landscape = 710.0;
378 ug_data->webview_height_landscape = 558.0;
379 ug_data->webview_margin = 1029;
380 ug_data->webview_margin_landscape = 558;
382 ug_data->webview_width = 710.0;
383 ug_data->webview_height = 949.0;
384 ug_data->webview_width_landscape = 710.0;
385 ug_data->webview_height_landscape = 568.0;
386 ug_data->webview_margin = 633;
387 ug_data->webview_margin_landscape = 379;
390 ug_data->evas = evas_object_evas_get(ug_data->win_main);
392 /* Double_Scroller */
395 email_account_t *account = NULL;
396 if (email_engine_get_account_full_data(ug_data->account_id, &account)) {
397 debug_log("email_engine_get_account");
399 ug_data->account_type = account->incoming_server_type;
400 snprintf(ug_data->account_email_address, sizeof(ug_data->account_email_address), "%s", account->user_email_address);
402 account_user_data_t *ud = (account_user_data_t*)account->user_data;
404 debug_log("show_images is %d", ud->show_images);
405 ug_data->b_show_remote_images = ud->show_images;
407 email_free_account(&account, 1);
413 _dbus_receiver_setup(ug_data);
415 _init_viewer_data(ug_data->account_id, ug_data->mail_id, NULL, ug_data);
416 _create_view(ug_data);
418 _check_body_download(ug_data);
420 ug_data->base = ug_data->layout_main;
422 ug_data->display_download_result = TRUE;
424 return ug_data->base;
427 static void on_start(ui_gadget_h ug, service_h data, void *priv)
432 static void on_pause(ui_gadget_h ug, service_h data, void *priv)
437 static void on_resume(ui_gadget_h ug, service_h data, void *priv)
442 static void on_destroy(ui_gadget_h ug, service_h data, void *pd)
445 EmailViewerUGD *ug_data;
454 if (ug_data->b_direct_destroy)
458 EmailViewerPrivate *priv = ug_data->email_data;
459 EmailViewerProp *prop = ug_data->property;
461 int att_len = g_list_length(prop->attachments);
463 if (priv->email_handle != 0)
464 email_engine_stop_working(ug_data->account_id, priv->email_handle);
466 for (i = 0; i < att_len; i++) {
467 if (priv->download_all_email_handle[i] != 0)
468 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[i]);
471 /* if (ug_data->theme) {
472 elm_theme_extension_del(ug_data->theme, EV_THEME_PATH);
473 elm_theme_free(ug_data->theme);
474 ug_data->theme = NULL;
477 _delete_evas_objects(ug_data);
479 debug_log("free webview_data");
480 if (ug_data->webview_data) {
481 free(ug_data->webview_data);
482 ug_data->webview_data = NULL;
485 debug_log("free address info list");
486 email_free_address_info_list(&(priv->addrs_info_list));
487 ug_data->from_list = NULL;
488 ug_data->to_list = NULL;
489 ug_data->cc_list = NULL;
490 ug_data->bcc_list = NULL;
492 debug_log("free mail_info");
493 if (ug_data->email_data->mail_info) {
494 email_free_mail_data(&(ug_data->email_data->mail_info), 1);
495 ug_data->email_data->mail_info = NULL;
498 if (ug_data->email_data->attachment_info && ug_data->email_data->attachment_count > 0) {
499 email_free_attachment_data(&(ug_data->email_data->attachment_info), ug_data->email_data->attachment_count);
500 ug_data->email_data->attachment_info = NULL;
501 ug_data->email_data->attachment_count = 0;
504 debug_log("free email_data");
505 if (ug_data->email_data) {
506 free(ug_data->email_data);
507 ug_data->email_data = NULL;
510 debug_log("free attachment");
511 if (ug_data->property->attachments) {
513 LIST_ITER_START(i, ug_data->property->attachments) {
514 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, ug_data->property->attachments);
521 g_list_free(ug_data->property->attachments);
522 ug_data->property->attachments = NULL;
525 debug_log("free property");
526 if (ug_data->property) {
527 free(ug_data->property);
528 ug_data->property = NULL;
531 email_engine_finalize();
533 _dbus_receiver_remove(NULL);
535 int ret = e_dbus_shutdown();
536 debug_log("ret: %d", ret);
539 ug_data->base = NULL;
542 static void on_message(ui_gadget_h ug, service_h msg, service_h data, void *priv)
549 debug_log("_g_ug_data - %p", _g_ug_data);
550 if (_g_ug_data != NULL) {
551 debug_log("Hide previous mail data");
552 _hide_view(_g_ug_data);
555 char *account_id = NULL;
556 char *mail_id = NULL;
557 char *mailbox_id = NULL;
558 char *binternal = NULL;
559 char *landscape = NULL;
561 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
562 _g_ug_data = ug_data;
566 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_ACCOUNT_ID, (char **)&account_id);
567 debug_log("service_get_extra_data: %d", ret);
568 debug_log("account_id:%s", account_id);
569 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_MAIL_ID, (char **)&mail_id);
570 debug_log("service_get_extra_data: %d", ret);
571 debug_log("mail_id:%s", mail_id);
572 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_MAILBOX, (char **)&mailbox_id);
573 debug_log("service_get_extra_data: %d", ret);
574 debug_log("mailbox:%s", mailbox_id);
575 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_INTERNAL, (char **)&binternal);
576 debug_log("service_get_extra_data: %d", ret);
577 debug_log("binternal:%s", binternal);
578 ret = service_get_extra_data(msg, EMAIL_BUNDLE_KEY_FIRST_LANDSCAPE, (char **)&landscape);
579 debug_log("service_get_extra_data: %d", ret);
580 debug_log("landscape:%s", landscape);
583 ug_data->isRotate = atoi(landscape);
584 debug_log("@@@@ Landscape = %d @@@@", ug_data->isRotate);
589 ug_data->account_id = atoi(account_id);
590 ug_data->folder_list = email_engine_get_ca_mailbox_list_using_glist(ug_data->account_id);
595 ug_data->mail_id = atoi(mail_id);
600 g_free(ug_data->mailbox_name);
601 ug_data->mailbox_name = NULL;
602 ug_data->mailbox_id = atoi(mailbox_id);
606 email_mail_data_t *mail_data = NULL;
607 if ((err = email_get_mail_data(ug_data->mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
608 debug_log("fail to get mail - err (%d)", err);
611 if (mail_data == NULL) {
612 debug_log("mail_data is NULL");
615 ug_data->mailbox_name = g_strdup(mail_data->server_mailbox_name);
616 ug_data->mailbox_type = mail_data->mailbox_type;
617 debug_log("server_mailbox_name:%s", mail_data->server_mailbox_name);
618 debug_log("mailbox_name:%s", ug_data->mailbox_name);
619 debug_log("mailbox_type:%d", ug_data->mailbox_type);
622 debug_log("email_free_mail is called");
623 email_free_mail_data(&(mail_data), 1);
629 ug_data->b_internal = atoi(binternal);
630 if (ug_data->b_internal == 1)
631 debug_log("############Launched from email-mailbox###############");
635 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);
637 if (ug_data->account_id <= 0 || ug_data->mail_id <= 0 || ug_data->mailbox_id <= 0) {
638 debug_log("Required bundle parameters are missing!");
643 email_account_t *account = NULL;
644 if (email_engine_get_account_full_data(ug_data->account_id, &account)) {
645 debug_log("email_engine_get_account");
647 ug_data->account_type = account->incoming_server_type;
648 snprintf(ug_data->account_email_address, sizeof(ug_data->account_email_address), "%s", account->user_email_address);
650 account_user_data_t *ud = (account_user_data_t*)account->user_data;
652 debug_log("show_images is %d", ud->show_images);
653 ug_data->b_show_remote_images = ud->show_images;
655 email_free_account(&account, 1);
659 Ewk_Setting *setting = ewk_view_setting_get(ug_data->webview);
661 debug_log("b_show_remote_images is %d", ug_data->b_show_remote_images);
662 if (ewk_setting_load_remote_images_set(setting, ug_data->b_show_remote_images) == EINA_FALSE) {
663 debug_log("SET remote images is FAILED!");
667 _init_viewer_data(ug_data->account_id, ug_data->mail_id, NULL, ug_data);
669 evas_object_show(ug_data->layout_main);
670 evas_object_raise(ug_data->layout_main);
672 _reset_view(ug_data);
674 ug_data->display_download_result = TRUE;
677 static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *priv)
684 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
685 EmailViewerProp *prop = ug_data->property;
686 char date_time[MAX_STR_LEN] = { 0, };
687 char *formatted_date = NULL;
690 debug_log("rotate event = %d", event);
693 case UG_EVENT_LOW_MEMORY:
695 case UG_EVENT_LOW_BATTERY:
697 case UG_EVENT_LANG_CHANGE:
699 case UG_EVENT_ROTATE_PORTRAIT:
700 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
701 if (ug_data->b_internal && ug_data->isRotate == true) {
702 debug_log("In Full view - Showing navi bar");
703 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_TRUE);
705 if (ug_data->con_popup) {
706 evas_object_del(ug_data->con_popup);
707 ug_data->con_popup = NULL;
710 if (ug_data->navi_move_it1) {
712 Evas_Object *move_back_btn = elm_button_add(ug_data->navi_bar);
713 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
714 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb, ug_data);
715 elm_object_item_part_content_set(ug_data->navi_move_it1, "prev_btn", move_back_btn);
716 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_TRUE);
717 if (ug_data->move_cbar) {
718 elm_object_item_part_content_unset(ug_data->navi_move_it1, "controlbar");
719 evas_object_del(ug_data->move_cbar);
720 ug_data->move_cbar = NULL;
723 if (ug_data->navi_move_it2) {
725 Evas_Object *move_back_btn = elm_button_add(ug_data->navi_bar);
726 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
727 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb2, ug_data);
728 elm_object_item_part_content_set(ug_data->navi_move_it2, "prev_btn", move_back_btn);
729 elm_naviframe_item_title_visible_set(ug_data->navi_move_it2, EINA_TRUE);
732 if (ug_data->b_btn) {
733 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
734 evas_object_del(ug_data->b_btn);
735 ug_data->b_btn = NULL;
738 ug_data->b_btn = elm_button_add(ug_data->navi_bar);
739 elm_object_style_set(ug_data->b_btn, "naviframe/back_btn/default");
740 evas_object_smart_callback_add(ug_data->b_btn, "clicked", _back_cb, ug_data);
741 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", ug_data->b_btn);
743 int resized_w = ug_data->webview_width * ug_data->scale_factor;
744 int resized_h = ug_data->webview_height * ug_data->scale_factor;
745 evas_object_size_hint_min_set(ug_data->webview, resized_w, resized_h);
747 ug_data->isRotate = false;
752 case UG_EVENT_ROTATE_LANDSCAPE:
753 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
754 if (ug_data->b_internal && ug_data->isRotate == false) {
755 debug_log("In Split view - Hiding navi bar");
756 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE);
758 if (ug_data->con_popup) {
759 evas_object_del(ug_data->con_popup);
760 ug_data->con_popup = NULL;
763 if (ug_data->navi_move_it1) {
765 ug_data->move_cbar = elm_toolbar_add(ug_data->navi_bar);
766 elm_toolbar_shrink_mode_set(ug_data->move_cbar, ELM_TOOLBAR_SHRINK_EXPAND);
767 elm_object_style_set(ug_data->move_cbar, "naviframe");
768 evas_object_show(ug_data->move_cbar);
770 elm_object_item_disabled_set(elm_toolbar_item_append(ug_data->move_cbar, NULL, "", NULL, NULL), EINA_TRUE);
771 elm_toolbar_item_append(ug_data->move_cbar, NULL, dgettext("sys_string", "IDS_COM_SK_CANCEL"), _move_back_cb, ug_data);
772 elm_object_item_part_content_set(ug_data->navi_move_it1, "controlbar", ug_data->move_cbar);
774 Evas_Object *move_back_btn = elm_object_item_part_content_get(ug_data->navi_move_it1, "prev_btn");
776 evas_object_smart_callback_del(move_back_btn, "clicked", _move_back_cb);
777 evas_object_del(move_back_btn);
778 elm_object_item_part_content_set(ug_data->navi_move_it1, "prev_btn", NULL);
780 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_FALSE);
782 if (ug_data->navi_move_it2) {
784 Evas_Object *move_back_btn = elm_object_item_part_content_get(ug_data->navi_move_it2, "prev_btn");
786 evas_object_smart_callback_del(move_back_btn, "clicked", _move_back_cb2);
787 evas_object_del(move_back_btn);
788 elm_object_item_part_content_set(ug_data->navi_move_it2, "prev_btn", NULL);
790 elm_naviframe_item_title_visible_set(ug_data->navi_move_it2, EINA_FALSE);
793 if (ug_data->b_btn) {
794 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
795 evas_object_del(ug_data->b_btn);
796 ug_data->b_btn = NULL;
797 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
800 int resized_w = ug_data->webview_width_landscape * ug_data->scale_factor;
801 int resized_h = ug_data->webview_height_landscape * ug_data->scale_factor;
802 evas_object_size_hint_min_set(ug_data->webview, resized_w, resized_h);
804 ug_data->isRotate = true;
809 case UG_EVENT_REGION_CHANGE:
810 appcore_get_timeformat(&icu_timeformat);
811 /* ICU API to set default locale */
812 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
813 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
815 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
816 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
818 free(formatted_date);
819 formatted_date = NULL;
821 edje_object_part_text_set(_EDJ(ug_data->ly_subject), "elm.text.sub", date_time);
822 evas_object_show(ug_data->ly_subject);
830 static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h data, void *priv)
837 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
838 EmailViewerPrivate *private = ug_data->email_data;
839 EmailViewerProp *prop = ug_data->property;
842 case UG_KEY_EVENT_END:
844 if (ug_data->notify != NULL || ug_data->pb_notify != NULL || ug_data->timeout_popup != NULL) {
845 if (ug_data->timeout_popup) {
846 evas_object_del(ug_data->timeout_popup);
847 ug_data->timeout_popup = NULL;
850 if (ug_data->notify) {
851 evas_object_del(ug_data->notify);
852 ug_data->notify = NULL;
855 if (ug_data->pb_notify) {
857 int att_len = g_list_length(prop->attachments);
859 evas_object_del(ug_data->pb_notify);
860 ug_data->pb_notify = NULL;
862 if (private->email_handle != 0)
863 email_engine_stop_working(ug_data->account_id, private->email_handle);
865 for (i = 0; i < att_len; i++) {
866 if (private->download_all_email_handle[i] != 0)
867 email_engine_stop_working(ug_data->account_id, private->download_all_email_handle[i]);
871 if (ug_data->pb_notify_lb) {
872 evas_object_del(ug_data->pb_notify_lb);
873 ug_data->pb_notify_lb = NULL;
876 if (ug_data->isRotate == false && ug_data->b_internal) {
877 /* Viewer to hide, so set left content (mailbox) size to full */
878 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
881 if (ug_data->b_internal)
884 ug_destroy_me(ug_data->ug);
888 service_h service = NULL;
890 ret = service_create(&service);
891 debug_log("service_create: %d", ret);
893 debug_log("service create failed");
897 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_END_KEY);
898 debug_log("service_add_extra_data: %d", ret);
900 ug_send_message(_g_mailbox_ug, service);
902 ret = service_destroy(service);
903 debug_log("service_destroy: %d", ret);
912 static void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
915 Evas_Object *base, *win;
920 base = ug_get_layout(ug);
924 win = ug_get_window();
927 case UG_MODE_FULLVIEW:
928 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
929 elm_win_resize_object_add(win, base);
930 evas_object_show(base);
937 static void result_cb(ui_gadget_h ug, service_h result, void *priv)
944 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
945 EmailViewerProp *prop = ug_data->property;
946 EmailViewerPrivate *private = ug_data->email_data;
948 if (ug == ug_data->ug_composer) {
950 int ret = service_get_extra_data(result, EMAIL_BUNDLE_KEY_SAVE_ALL, (char **)&cmd);
951 debug_log("service_get_extra_data: %d", ret);
952 debug_log("return of bundle_get_val for save all(%s)", cmd);
954 debug_log("save all from composer(%s)", cmd);
956 if (prop->real_att_len == 1) {
957 private->b_all_att_save = TRUE;
958 _save_attachment(ug_data, 0);
959 } else if (prop->real_att_len > 1) {
960 _save_attachment_all(ug_data);
966 ret = service_get_extra_data(result, EMAIL_BUNDLE_KEY_CANCEL_ALL, (char **)&cmd);
967 debug_log("service_get_extra_data: %d", ret);
968 debug_log("return of bundle_get_val for cancel all(%s)", cmd);
970 debug_log("cancel all attachment from composer(%s)", cmd);
972 _cancel_download_attachment(ug_data);
979 static void destroy_cb(ui_gadget_h ug, void *priv)
985 EmailViewerUGD *ug_data = (EmailViewerUGD *)priv;
986 EmailViewerProp *prop = ug_data->property;
987 ug_data->display_download_result = TRUE;
989 if (ug == ug_data->ug_composer) {
990 ug_data->ug_composer = NULL;
995 if (ug_data->b_contact_ug_launched) {
996 debug_log("change navibar title label");
997 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
998 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, prop->sender);
1000 if (contact_list_item) {
1001 elm_object_item_text_set(ug_data->navi_main_it, contact_list_item->display_name);
1002 _delete_contacts_list(contact_list_item);
1004 elm_object_item_text_set(ug_data->navi_main_it, prop->sender_display_name);
1007 ug_data->b_contact_ug_launched = FALSE;
1011 static ui_gadget_h create_ug(char *ug_name, service_h bd, void *data)
1015 struct ug_cbs cbs = { 0, };
1017 cbs.layout_cb = layout_cb;
1018 cbs.result_cb = result_cb;
1019 cbs.destroy_cb = destroy_cb;
1022 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
1024 ug = ug_create(ug_data->ug, ug_name, UG_MODE_FULLVIEW, bd, &cbs);
1029 static void _create_view(EmailViewerUGD *ug_data)
1034 Evas_Object *prev_btn;
1035 Evas_Object *next_btn;
1036 EmailViewerProp *prop = ug_data->property;
1038 ug_data->bg = _create_bg(ug_data->win_main);
1041 ug_data->layout_main = elm_layout_add(ug_data->win_main);
1043 if (ug_data->b_internal)
1044 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "noindicator");
1046 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "default");
1047 evas_object_size_hint_weight_set(ug_data->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1048 evas_object_show(ug_data->layout_main);
1050 elm_object_part_content_set(ug_data->layout_main, "elm.swallow.bg", ug_data->bg);
1053 elm_win_indicator_mode_set(ug_data->win_main, ELM_WIN_INDICATOR_SHOW);
1055 evas_object_smart_callback_add(ug_data->win_main, "profile,changed", _win_profile_changed_cb, ug_data);
1057 /* navigation Bar */
1058 _create_navigation_bar(ug_data);
1060 /* push navigation bar */
1061 ug_data->sub_ly = elm_layout_add(ug_data->navi_bar);
1062 elm_layout_theme_set(ug_data->sub_ly, "layout", "application", "noindicator");
1063 evas_object_size_hint_weight_set(ug_data->sub_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1064 evas_object_show(ug_data->sub_ly);
1067 b_btn = elm_button_add(ug_data->navi_bar);
1068 elm_object_style_set(b_btn, "naviframe/back_btn/default");
1069 evas_object_smart_callback_add(b_btn, "clicked", _back_cb, ug_data);
1070 ug_data->b_btn = b_btn;
1072 ug_data->navi_main_it = elm_naviframe_item_push(ug_data->navi_bar, prop->sender_display_name, b_btn, NULL, ug_data->sub_ly, NULL);
1074 if (ug_data->b_internal) {
1075 /* Left : previous button */
1076 prev_btn = elm_button_add(ug_data->navi_bar);
1077 Evas_Object *prev_ic = elm_icon_add(prev_btn);
1078 elm_icon_file_set(prev_ic, IMGDIR "/M02_icon_previous.png", NULL);
1079 elm_object_style_set(prev_btn, "naviframe/title/default");
1080 evas_object_size_hint_aspect_set(prev_ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1081 elm_icon_resizable_set(prev_ic, 0.8, 0.8);
1082 elm_object_part_content_set(prev_btn, "icon", prev_ic);
1083 elm_object_item_part_content_set(ug_data->navi_main_it, "title_left_btn", prev_btn);
1084 evas_object_smart_callback_add(prev_btn, "clicked", _prev_mail_cb, ug_data);
1085 ug_data->prev_btn = prev_btn;
1087 /* Right : next button */
1088 next_btn = elm_button_add(ug_data->navi_bar);
1089 Evas_Object *next_ic = elm_icon_add(next_btn);
1090 elm_icon_file_set(next_ic, IMGDIR "/M02_icon_next.png", NULL);
1091 elm_object_style_set(next_btn, "naviframe/title/default");
1092 evas_object_size_hint_aspect_set(next_ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1093 elm_icon_resizable_set(next_ic, 0.8, 0.8);
1094 elm_object_part_content_set(next_btn, "icon", next_ic);
1095 elm_object_item_part_content_set(ug_data->navi_main_it, "title_right_btn", next_btn);
1096 evas_object_smart_callback_add(next_btn, "clicked", _next_mail_cb, ug_data);
1097 ug_data->next_btn = next_btn;
1100 /* create scroller */
1101 ug_data->scroller = elm_scroller_add(ug_data->navi_bar);
1102 evas_object_propagate_events_set(ug_data->scroller, EINA_FALSE);
1103 elm_scroller_bounce_set(ug_data->scroller, EINA_FALSE, EINA_TRUE);
1104 elm_scroller_policy_set(ug_data->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
1105 evas_object_show(ug_data->scroller);
1106 evas_object_smart_callback_add(ug_data->scroller, "edge,bottom", _outter_scroller_bottom_hit_cb, ug_data);
1107 evas_object_smart_callback_add(ug_data->scroller, "edge,top", _outter_scroller_top_hit_cb, ug_data);
1108 evas_object_smart_callback_add(ug_data->scroller, "scroll,drag,start", _outter_scroller_scroll_cb, ug_data);
1110 /* create conformant */
1111 elm_win_conformant_set(ug_data->win_main, EINA_TRUE);
1112 ug_data->conformant = elm_conformant_add(ug_data->sub_ly);
1113 elm_object_style_set(ug_data->conformant, "internal_layout");
1114 evas_object_size_hint_weight_set(ug_data->conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1115 evas_object_size_hint_align_set(ug_data->conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
1116 elm_object_content_set(ug_data->conformant, ug_data->scroller);
1117 elm_object_part_content_set(ug_data->sub_ly, "elm.swallow.content", ug_data->conformant);
1118 evas_object_show(ug_data->conformant);
1120 if (ug_data->from_list != NULL) {
1121 email_address_info_t *addrs_info = NULL;
1122 int n_from_list = g_list_length(ug_data->from_list);
1123 debug_log("from list count [%d]", n_from_list);
1125 if (n_from_list > 0) {
1126 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->from_list, 0);
1127 debug_log("From Address:%s", addrs_info->address);
1128 debug_log("Display Name:%s", addrs_info->display_name);
1129 debug_log("Storage Type:%d", addrs_info->storage_type);
1130 debug_log("Contact ID:%d", addrs_info->contact_id);
1132 g_free(prop->sender_display_name);
1133 prop->sender_display_name = g_strdup(addrs_info->display_name);
1134 g_free(prop->sender);
1135 prop->sender = g_strdup(addrs_info->address);
1137 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1138 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->display_name);
1140 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->address);
1144 /* create main box */
1145 ug_data->main_bx = elm_box_add(ug_data->navi_bar);
1146 evas_object_size_hint_weight_set(ug_data->main_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1147 evas_object_size_hint_align_set(ug_data->main_bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1148 evas_object_show(ug_data->main_bx);
1149 elm_object_content_set(ug_data->scroller, ug_data->main_bx);
1151 if (ug_data->property->has_attachment)
1152 ug_data->got_att = 1;
1154 ug_data->got_att = 0;
1156 /* packing subject, addrs, attachment */
1157 _create_subject(ug_data);
1159 if (ug_data->got_att) {
1160 _create_attach(ug_data);
1163 if (ug_data->isRotate == true) {
1164 debug_log("In Split view - Hiding navi bar");
1165 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE);
1167 if (ug_data->b_btn) {
1169 debug_log("hiding back button");
1171 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1172 evas_object_del(ug_data->b_btn);
1173 ug_data->b_btn = NULL;
1175 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
1180 static void _reset_view(EmailViewerUGD *ug_data)
1183 EmailViewerProp *prop = ug_data->property;
1185 char date_time[MAX_STR_LEN] = { 0, };
1187 debug_log("@@@@@@@@@@ isRotate = %d", ug_data->isRotate);
1188 if (ug_data->isRotate == true) {
1189 debug_log("In Split view - Hiding navi bar");
1190 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_FALSE);
1192 if (ug_data->b_btn) {
1194 debug_log("hiding back button");
1196 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1197 evas_object_del(ug_data->b_btn);
1198 ug_data->b_btn = NULL;
1200 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", NULL);
1203 /* Set scroller to start - height made 480 to consider viewer in split view */
1204 elm_scroller_region_show(ug_data->scroller, 0, 0, (int)((double)ug_data->main_h * 0.6), ug_data->main_w);
1206 debug_log("In Full view - Showing navi bar");
1207 elm_naviframe_item_title_visible_set(ug_data->navi_main_it, EINA_TRUE);
1209 if (ug_data->b_btn) {
1211 evas_object_smart_callback_del(ug_data->b_btn, "clicked", _back_cb);
1212 evas_object_del(ug_data->b_btn);
1213 ug_data->b_btn = NULL;
1216 debug_log("showing back button");
1218 ug_data->b_btn = elm_button_add(ug_data->navi_bar);
1219 elm_object_style_set(ug_data->b_btn, "naviframe/back_btn/default");
1220 evas_object_smart_callback_add(ug_data->b_btn, "clicked", _back_cb, ug_data);
1222 elm_object_item_part_content_set(ug_data->navi_main_it, "prev_btn", ug_data->b_btn);
1224 /* Set scroller to start */
1225 elm_scroller_region_show(ug_data->scroller, 0, 0, ug_data->main_w, ug_data->main_h);
1228 if (ug_data->from_list != NULL) {
1229 email_address_info_t *addrs_info = NULL;
1230 int n_from_list = g_list_length(ug_data->from_list);
1231 debug_log("from list count [%d]", n_from_list);
1233 if (n_from_list > 0) {
1234 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->from_list, 0);
1236 debug_log("From Address:%s", addrs_info->address);
1237 debug_log("Display Name:%s", addrs_info->display_name);
1238 debug_log("Storage Type:%d", addrs_info->storage_type);
1239 debug_log("Contact ID:%d", addrs_info->contact_id);
1240 g_free(prop->sender_display_name);
1241 prop->sender_display_name = g_strdup(addrs_info->display_name);
1242 g_free(prop->sender);
1243 prop->sender = g_strdup(addrs_info->address);
1245 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1246 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->display_name);
1248 elm_object_item_text_set(ug_data->navi_main_it, addrs_info->address);
1252 elm_object_item_text_set(ug_data->navi_main_it, prop->sender_display_name);
1256 char *_subject = elm_entry_utf8_to_markup(prop->subject);
1257 char *_subject_concated = g_strconcat("<font_size=44><color=#000000FF>", _subject, "</color></font_size>", NULL);
1258 elm_object_text_set(ug_data->lb_subject, _subject_concated);
1259 elm_label_wrap_width_set(ug_data->lb_subject, ug_data->main_w - (int)(110 * ug_data->scale_factor));
1260 elm_label_line_wrap_set(ug_data->lb_subject, ELM_WRAP_WORD);
1262 g_free(_subject_concated);
1264 /* reset date & time */
1265 char *formatted_date = NULL;
1267 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1268 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
1270 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
1271 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
1273 free(formatted_date);
1274 formatted_date = NULL;
1276 elm_object_part_text_set(ug_data->ly_subject, "elm.text.sub", date_time);
1278 Evas_Object *favorite_icon = elm_icon_add(ug_data->ly_subject);
1279 switch(prop->favorite)
1281 case EMAIL_FLAG_NONE:
1282 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_off.png", NULL);
1284 case EMAIL_FLAG_FLAGED:
1285 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_on.png", NULL);
1287 case EMAIL_FLAG_TASK_STATUS_CLEAR:
1288 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
1290 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
1291 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
1293 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
1294 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
1297 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1298 elm_icon_resizable_set(favorite_icon, 1, 1);
1299 evas_object_del(elm_object_part_content_unset(ug_data->ly_subject, "elm.icon.favorite"));
1300 elm_object_part_content_set(ug_data->ly_subject, "elm.icon.favorite", favorite_icon);
1301 evas_object_show(favorite_icon);
1303 evas_object_show(ug_data->ly_subject);
1304 elm_box_pack_end(ug_data->main_bx, ug_data->ly_subject);
1306 if (prop->has_attachment)
1307 ug_data->got_att = 1;
1309 ug_data->got_att = 0;
1311 /* pack attachment if it exist */
1312 if (ug_data->got_att) {
1313 _create_attach(ug_data);
1316 /* check body downloaded */
1317 _check_body_download(ug_data);
1320 void _hide_view(EmailViewerUGD *ug_data)
1323 EmailViewerProp *prop = ug_data->property;
1324 EmailViewerPrivate *priv = ug_data->email_data;
1326 debug_log("Cancelling all attachment downloads");
1327 _cancel_download_attachment(ug_data);
1329 ug_data->display_download_result = FALSE;
1332 if (elm_naviframe_top_item_get(ug_data->navi_bar) != ug_data->navi_main_it) {
1333 ug_data->navi_move_it1 = NULL;
1334 ug_data->navi_move_it2 = NULL;
1335 elm_naviframe_item_pop_to(ug_data->navi_main_it);
1338 evas_object_hide(ug_data->layout_main);
1339 elm_box_unpack_all(ug_data->main_bx);
1340 elm_object_scroll_freeze_pop(ug_data->scroller);
1342 evas_object_hide(ug_data->ly_subject);
1343 evas_object_hide(ug_data->lb_subject);
1344 evas_object_hide(ug_data->webview_bx);
1345 evas_object_hide(ug_data->webview);
1347 if (ug_data->partial_dn_btn) {
1348 evas_object_del(ug_data->partial_dn_btn);
1349 ug_data->partial_dn_btn = NULL;
1352 if (ug_data->partial_dn_btn_bx) {
1353 evas_object_del(ug_data->partial_dn_btn_bx);
1354 ug_data->partial_dn_btn_bx = NULL;
1357 if (ug_data->ctr_bar) {
1358 elm_object_item_part_content_unset(ug_data->navi_main_it, "controlbar");
1359 evas_object_del(ug_data->ctr_bar);
1360 ug_data->ctr_bar = NULL;
1362 ug_data->reply_ctr_it = NULL;
1363 ug_data->replyall_ctr_it = NULL;
1364 ug_data->forward_ctr_it = NULL;
1365 ug_data->calendar_ctr_it = NULL;
1366 ug_data->resend_ctr_it = NULL;
1367 ug_data->move_ctr_it = NULL;
1368 ug_data->del_ctr_it = NULL;
1371 if (ug_data->to_ly) {
1372 evas_object_del(ug_data->to_ly);
1373 ug_data->to_ly = NULL;
1376 if (ug_data->cc_ly) {
1377 evas_object_del(ug_data->cc_ly);
1378 ug_data->cc_ly = NULL;
1381 if (ug_data->bcc_ly) {
1382 evas_object_del(ug_data->bcc_ly);
1383 ug_data->bcc_ly = NULL;
1386 if (ug_data->got_att) {
1389 evas_object_del(ug_data->attach_hd_bk);
1390 ug_data->attach_hd_ly = NULL;
1391 ug_data->attach_hd_bk = NULL;
1393 if (prop->real_att_len > 1) {
1394 for (i = 0; i < prop->real_att_len; i++) {
1395 if (ug_data->attach_ex_ly != NULL) {
1396 if (ug_data->attach_ex_ly[i] != NULL) {
1397 debug_log("index %d", i);
1398 evas_object_del(ug_data->attach_ex_bk[i]);
1399 ug_data->attach_ex_ly[i] = NULL;
1400 ug_data->attach_ex_bk[i] = NULL;
1405 if (ug_data->attach_ex_ly != NULL) {
1406 free(ug_data->attach_ex_ly);
1407 ug_data->attach_ex_ly = NULL;
1408 ug_data->attach_ex_bk = NULL;
1412 for (i = 0; i <= prop->att_len; i++) {
1413 if (ug_data->progress_bar_ly[i] != NULL) {
1414 evas_object_del(ug_data->progress_bar_ly[i]);
1415 ug_data->progress_bar_ly[i] = NULL;
1416 ug_data->progress_bar[i] = NULL;
1421 if (ug_data->con_popup != NULL) {
1422 evas_object_del(ug_data->con_popup);
1423 ug_data->con_popup = NULL;
1426 if (ug_data->notify != NULL) {
1427 evas_object_del(ug_data->notify);
1428 ug_data->notify = NULL;
1431 edje_object_signal_emit(_EDJ(ug_data->ly_subject), "elm,state,contracted", "elm");
1433 evas_object_hide(ug_data->noc_bx);
1434 evas_object_hide(ug_data->dn_btn);
1436 ewk_view_uri_set(ug_data->webview, EMAIL_DEFAULT_HTML);
1438 debug_log("free address info list");
1439 email_free_address_info_list(&(priv->addrs_info_list));
1440 ug_data->from_list = NULL;
1441 ug_data->to_list = NULL;
1442 ug_data->cc_list = NULL;
1443 ug_data->bcc_list = NULL;
1445 ug_data->got_att = 0;
1446 ug_data->subject_onoff_flag = 0;
1447 ug_data->attach_onoff_flag = 0;
1448 ug_data->b_partial_body = 0;
1449 ug_data->b_internal = 0;
1450 ug_data->scroller_locked = 0;
1451 ug_data->m_is_multi_touch = 0;
1453 ug_data->navi_move_it1 = NULL;
1454 ug_data->navi_move_it2 = NULL;
1456 /* Double_Scroller */
1458 ug_data->b_load_finished = EINA_FALSE;
1459 ug_data->b_show_remote_images = EINA_FALSE;
1460 ug_data->is_webview_scrolling = EINA_FALSE;
1461 ug_data->is_main_scroller_scrolling = EINA_FALSE;
1464 static void _win_profile_changed_cb(void *data, Evas_Object *obj, void *event)
1468 debug_log("data is NULL");
1472 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
1474 const char *profile = elm_config_profile_get();
1475 if (!g_strcmp0(profile, "desktop"))
1476 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "noindicator");
1478 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "default");
1480 evas_object_size_hint_weight_set(ug_data->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1481 elm_win_resize_object_add(ug_data->win_main, ug_data->layout_main);
1482 evas_object_show(ug_data->layout_main);
1485 static Evas_Object *_create_navigation_bar(EmailViewerUGD *ug_data)
1488 Evas_Object *navi_bar;
1490 navi_bar = elm_naviframe_add(ug_data->layout_main);
1491 if (navi_bar == NULL) {
1492 debug_log("navi_bar == NULL");
1496 elm_object_part_content_set(ug_data->layout_main, "elm.swallow.content", navi_bar);
1497 evas_object_show(navi_bar);
1499 ug_data->navi_bar = navi_bar;
1503 static Evas_Object *_create_subject(EmailViewerUGD *ug_data)
1506 EmailViewerProp *prop = ug_data->property;
1508 char date_time[MAX_STR_LEN] = { 0, };
1510 /* append subject */
1511 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1512 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.detail_subject");
1513 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1515 Evas_Object *subject_label;
1516 subject_label = elm_label_add(di);
1517 elm_object_part_content_set(di, "elm.text", subject_label);
1518 char *subject = elm_entry_utf8_to_markup(prop->subject);
1519 char *subject_tagged = g_strconcat("<font_size=44><color=#000000FF>", subject, "</color></font_size>", NULL);
1520 elm_object_text_set(subject_label, subject_tagged);
1521 elm_label_wrap_width_set(subject_label, ug_data->main_w - (int)(110 * ug_data->scale_factor));
1522 elm_label_line_wrap_set(subject_label, ELM_WRAP_WORD);
1523 ug_data->lb_subject = subject_label;
1525 g_free(subject_tagged);
1527 char *formatted_date = NULL;
1529 if (icu_timeformat == APPCORE_TIME_FORMAT_12)
1530 formatted_date = email_get_date_text(icu_locale, "yMdhms", &(prop->mktime));
1532 formatted_date = email_get_date_text(icu_locale, "yMdHms", &(prop->mktime));
1533 ret = snprintf(date_time, MAX_STR_LEN, "%s", formatted_date);
1534 free(formatted_date);
1535 formatted_date = NULL;
1537 elm_object_part_text_set(di, "elm.text.sub", date_time);
1539 Evas_Object *favorite_icon = elm_icon_add(di);
1540 switch(prop->favorite)
1542 case EMAIL_FLAG_NONE:
1543 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_off.png", NULL);
1545 case EMAIL_FLAG_FLAGED:
1546 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_on.png", NULL);
1548 case EMAIL_FLAG_TASK_STATUS_CLEAR:
1549 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
1551 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
1552 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
1554 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
1555 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
1558 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1559 elm_icon_resizable_set(favorite_icon, 1, 1);
1560 elm_object_part_content_set(di, "elm.icon.favorite", favorite_icon);
1561 evas_object_show(favorite_icon);
1563 evas_object_show(di);
1564 elm_box_pack_end(ug_data->main_bx, di);
1565 ug_data->ly_subject = di;
1567 Evas_Object *edje = elm_layout_edje_get(di);
1569 if (ug_data->to_list || ug_data->cc_list || ug_data->bcc_list) {
1570 edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _subject_detail_clicked_cb, di);
1571 edje_object_signal_callback_add(edje, "elm,action,toggle", "elm", _subject_favorite_clicked_cb, di);
1573 edje_object_signal_emit(edje, "elm,state,arrow_hidden", "elm");
1579 static Evas_Object *_create_to_addrs(EmailViewerUGD *ug_data)
1582 email_address_info_t *addrs_info = NULL;
1583 Elm_Object_Item *mbe_item;
1585 if (ug_data->to_list == NULL) {
1586 debug_log("to_list is NULL");
1590 int n_to_list = g_list_length(ug_data->to_list);
1593 if (n_to_list <= 0) {
1594 debug_log("to_list count is 0");
1598 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1599 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1600 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1601 evas_object_show(di);
1602 ug_data->to_ly = di;
1603 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1605 Evas_Object *to_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1606 char desc[MAX_STR_LEN] = { 0, };
1607 snprintf(desc, MAX_STR_LEN, "%s:", dgettext("sys_string", "IDS_COM_BODY_TO"));
1608 char *to_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1609 elm_object_text_set(to_mbe, to_str);
1612 evas_object_smart_callback_add(to_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1613 evas_object_smart_callback_add(to_mbe, "item,added", _mbe_added_cb, ug_data);
1614 elm_object_part_content_set(di, "elm.icon", to_mbe);
1615 ug_data->to_mbe = to_mbe;
1617 Evas_Object *entry = elm_multibuttonentry_entry_get(to_mbe);
1619 elm_entry_editable_set(entry, EINA_FALSE);
1621 if (n_to_list > EMAIL_VIEW_MAX_TO_COUNT)
1622 n_to_list = EMAIL_VIEW_MAX_TO_COUNT;
1624 for (i = 0; i < n_to_list; i++) {
1625 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->to_list, i);
1626 debug_log("Address:%s", addrs_info->address);
1627 debug_log("Display Name:%s", addrs_info->display_name);
1628 debug_log("Storage Type:%d", addrs_info->storage_type);
1629 debug_log("Contact ID:%d", addrs_info->contact_id);
1631 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1632 mbe_item = elm_multibuttonentry_item_append(to_mbe, addrs_info->display_name, NULL, NULL);
1634 mbe_item = elm_multibuttonentry_item_append(to_mbe, addrs_info->address, NULL, NULL);
1635 elm_object_item_data_set(mbe_item, addrs_info);
1641 static Evas_Object *_create_cc_addrs(EmailViewerUGD *ug_data)
1644 email_address_info_t *addrs_info = NULL;
1645 Elm_Object_Item *mbe_item;
1647 if (ug_data->cc_list == NULL) {
1648 debug_log("cc_list is NULL");
1652 int n_cc_list = g_list_length(ug_data->cc_list);
1655 if (n_cc_list <= 0) {
1656 debug_log("cc_list count is 0");
1660 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1661 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1662 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1663 evas_object_show(di);
1664 ug_data->cc_ly = di;
1666 if (ug_data->to_ly) {
1667 elm_box_pack_after(ug_data->main_bx, di, ug_data->to_ly);
1669 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1672 Evas_Object *cc_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1673 char desc[MAX_STR_LEN] = { 0, };
1674 snprintf(desc, MAX_STR_LEN, "%s:", _("IDS_EMAIL_BODY_CC"));
1675 char *cc_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1676 elm_object_text_set(cc_mbe, cc_str);
1678 evas_object_smart_callback_add(cc_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1679 evas_object_smart_callback_add(cc_mbe, "item,added", _mbe_added_cb, ug_data);
1680 elm_object_part_content_set(di, "elm.icon", cc_mbe);
1681 ug_data->cc_mbe = cc_mbe;
1683 Evas_Object *entry = elm_multibuttonentry_entry_get(cc_mbe);
1685 elm_entry_editable_set(entry, EINA_FALSE);
1687 if (n_cc_list > EMAIL_VIEW_MAX_CC_COUNT)
1688 n_cc_list = EMAIL_VIEW_MAX_CC_COUNT;
1690 for (i = 0; i < n_cc_list; i++) {
1691 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->cc_list, i);
1693 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1694 mbe_item = elm_multibuttonentry_item_append(cc_mbe, addrs_info->display_name, NULL, NULL);
1696 mbe_item = elm_multibuttonentry_item_append(cc_mbe, addrs_info->address, NULL, NULL);
1697 elm_object_item_data_set(mbe_item, addrs_info);
1703 static Evas_Object *_create_bcc_addrs(EmailViewerUGD *ug_data)
1706 email_address_info_t *addrs_info = NULL;
1707 Elm_Object_Item *mbe_item;
1709 if (ug_data->bcc_list == NULL) {
1710 debug_log("bcc_list is NULL");
1714 int n_bcc_list = g_list_length(ug_data->bcc_list);
1717 if (n_bcc_list <= 0) {
1718 debug_log("bcc_list count is 0");
1722 Evas_Object *di = elm_layout_add(ug_data->main_bx);
1723 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.to_cc");
1724 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1725 evas_object_show(di);
1726 ug_data->bcc_ly = di;
1728 if (ug_data->cc_ly) {
1729 elm_box_pack_after(ug_data->main_bx, di, ug_data->cc_ly);
1731 if (ug_data->to_ly && ug_data->cc_ly == NULL) {
1732 elm_box_pack_after(ug_data->main_bx, di, ug_data->to_ly);
1734 if (ug_data->to_ly == NULL && ug_data->cc_ly == NULL) {
1735 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1738 Evas_Object *bcc_mbe = elm_multibuttonentry_add(ug_data->main_bx);
1739 char desc[MAX_STR_LEN] = { 0, };
1740 snprintf(desc, MAX_STR_LEN, "%s:", _("IDS_EMAIL_BODY_BCC"));
1741 char *bcc_str = g_strconcat("<font_size=36><color=#000000FF>", desc, "</color></font_size>", NULL);
1742 elm_object_text_set(bcc_mbe, bcc_str);
1744 evas_object_smart_callback_add(bcc_mbe, "item,clicked", _mbe_selected_cb, ug_data);
1745 evas_object_smart_callback_add(bcc_mbe, "item,added", _mbe_added_cb, ug_data);
1746 elm_object_part_content_set(di, "elm.icon", bcc_mbe);
1747 ug_data->bcc_mbe = bcc_mbe;
1749 Evas_Object *entry = elm_multibuttonentry_entry_get(bcc_mbe);
1751 elm_entry_editable_set(entry, EINA_FALSE);
1753 if (n_bcc_list > EMAIL_VIEW_MAX_BCC_COUNT)
1754 n_bcc_list = EMAIL_VIEW_MAX_BCC_COUNT;
1756 for (i = 0; i < n_bcc_list; i++) {
1757 addrs_info = (email_address_info_t *) g_list_nth_data(ug_data->bcc_list, i);
1759 if (addrs_info->display_name && strlen(addrs_info->display_name) > 0)
1760 mbe_item = elm_multibuttonentry_item_append(bcc_mbe, addrs_info->display_name, NULL, NULL);
1762 mbe_item = elm_multibuttonentry_item_append(bcc_mbe, addrs_info->address, NULL, NULL);
1763 elm_object_item_data_set(mbe_item, addrs_info);
1769 static Evas_Object *_create_attach(EmailViewerUGD *ug_data)
1773 EmailViewerProp *prop = ug_data->property;
1774 char buff[MAX_STR_LEN];
1776 int att_len = prop->real_att_len;
1779 RETURN_VAL_IF_FAIL(prop->attachments != NULL, NULL);
1780 RETURN_VAL_IF_FAIL(att_len > 0, NULL);
1782 GList *attachment_list = prop->attachments;
1785 LIST_ITER_START(i, attachment_list) {
1786 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
1788 if (info && !info->inline_content) {
1789 if (info->size < 1024) {
1790 g_sprintf(buff, "%s (%d %s)", info->name, (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
1792 gdouble tmpsize = (gdouble) (info->size / 1024.);
1793 if (tmpsize < 1024) {
1794 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1797 if (tmpsize < 1024) {
1798 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1801 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1806 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1807 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_item");
1808 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1809 evas_object_show(di);
1810 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1812 Evas_Object *thumbnail = NULL;
1814 if (info->download_yn) {
1815 thumbnail = viewer_make_thumbnail(info->path, di);
1817 thumbnail = viewer_make_thumbnail(NULL, di);
1818 evas_object_size_hint_aspect_set(thumbnail, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1819 elm_icon_resizable_set(thumbnail, 1, 1);
1820 elm_object_part_content_set(di, "elm.icon", thumbnail);
1821 evas_object_show(thumbnail);
1823 elm_object_part_text_set(di, "elm.text", buff);
1827 Evas_Object *edje = elm_layout_edje_get(di);
1828 edje_object_signal_callback_add(edje, "elm,action,download", "elm", _attachment_save_cb, (void *)att_index);
1829 edje_object_signal_callback_add(edje, "clicked", "*", _attachment_clicked_cb, (void *)att_index);
1831 Evas_Object *text_bg = NULL;
1832 text_bg = (Evas_Object *)edje_object_part_object_get(_EDJ(di), "elm.event.rect");
1835 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_DOWN, _attachment_bg_set_cb, (void *)att_index);
1836 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_UP, _attachment_bg_unset_cb, (void *)att_index);
1839 ug_data->attach_hd_ly = di;
1840 ug_data->attach_hd_bk = di;
1843 } else if (att_len > 1) {
1844 gint64 total_size = prop->total_att_size;
1846 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1847 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_head");
1848 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1849 snprintf(buff, sizeof(buff), "%d %s", att_len, _("IDS_EMAIL_BODY_ATTACHMENTS"));
1851 Evas_Object *att_head_label;
1852 att_head_label = elm_label_add(di);
1853 elm_object_part_content_set(di, "elm.text", att_head_label);
1855 char *buff_tagged = g_strconcat("<font_size=35><color=#000000FF>", buff, "<color></font_size>", NULL);
1856 elm_object_text_set(att_head_label, buff_tagged);
1857 g_free(buff_tagged);
1859 if (total_size < 1024) {
1860 g_sprintf(buff, "(%d %s)", (gint) total_size, dgettext("sys_string", "IDS_COM_BODY_B"));
1862 gdouble tmpsize = (gdouble) (total_size / 1024.);
1864 if (tmpsize < 1024) {
1865 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1869 if (tmpsize < 1024) {
1870 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1873 g_sprintf(buff, "(%.2f %s)", tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1878 edje_object_part_text_set(_EDJ(di), "elm.text.sub", buff);
1880 Evas_Object *edje = elm_layout_edje_get(di);
1881 edje_object_signal_callback_add(edje, "att,icon,save,all", "", _attachment_save_all_cb, di);
1882 edje_object_signal_callback_add(edje, "elm,action,expand,toggle", "elm", _attachment_item_collapse_cb, di);
1883 evas_object_show(di);
1884 elm_box_pack_after(ug_data->main_bx, di, ug_data->ly_subject);
1885 ug_data->attach_hd_ly = di;
1886 ug_data->attach_hd_bk = di;
1888 debug_log("Attachment doesn't exist");
1894 static Evas_Object *_create_attach_ex(EmailViewerUGD *ug_data)
1898 EmailViewerProp *prop = ug_data->property;
1899 char buff[MAX_STR_LEN];
1902 int att_len = prop->real_att_len;
1905 RETURN_VAL_IF_FAIL(prop->attachments != NULL, NULL);
1906 RETURN_VAL_IF_FAIL(att_len > 0, NULL);
1908 GList *attachment_list = prop->attachments;
1910 ug_data->attach_ex_ly = (Evas_Object **)calloc(att_len, sizeof(Evas_Object *));
1911 ug_data->attach_ex_bk = (Evas_Object **)calloc(att_len, sizeof(Evas_Object *));
1913 LIST_ITER_START(i, attachment_list) {
1914 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
1916 if (info && !info->inline_content) {
1917 if (info->size < 1024) {
1918 g_sprintf(buff, "%s (%d %s)", info->name, (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
1920 gdouble tmpsize = (gdouble) (info->size / 1024.);
1921 if (tmpsize < 1024) {
1922 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
1925 if (tmpsize < 1024) {
1926 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
1929 g_sprintf(buff, "%s (%.2f %s)", info->name, tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
1934 Evas_Object *di = elm_layout_add(ug_data->navi_bar);
1935 elm_layout_file_set(di, EV_THEME_PATH, "layout.email.attachment_item");
1936 evas_object_size_hint_align_set(di, EVAS_HINT_FILL, 0.0);
1937 elm_box_pack_after(ug_data->main_bx, di, ug_data->attach_hd_ly);
1938 evas_object_show(di);
1940 Evas_Object *thumbnail = NULL;
1942 if (info->download_yn) {
1943 thumbnail = viewer_make_thumbnail(info->path, di);
1945 thumbnail = viewer_make_thumbnail(NULL, di);
1946 evas_object_size_hint_aspect_set(thumbnail, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1947 elm_icon_resizable_set(thumbnail, 1, 1);
1948 elm_object_part_content_set(di, "elm.icon", thumbnail);
1949 evas_object_show(thumbnail);
1951 elm_object_part_text_set(di, "elm.text", buff);
1955 Evas_Object *edje = elm_layout_edje_get(di);
1956 edje_object_signal_callback_add(edje, "elm,action,download", "elm", _attachment_save_cb, (void *)att_index);
1957 edje_object_signal_callback_add(edje, "clicked", "*", _attachment_clicked_cb, (void *)att_index);
1959 Evas_Object *text_bg = NULL;
1960 text_bg = (Evas_Object *)edje_object_part_object_get(_EDJ(di), "elm.event.rect");
1963 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_DOWN, _attachment_bg_set_cb, (void *)att_index);
1964 evas_object_event_callback_add(text_bg, EVAS_CALLBACK_MOUSE_UP, _attachment_bg_unset_cb, (void *)att_index);
1967 debug_log("attach ly %d, att_index %d", j, i);
1969 ug_data->attach_ex_ly[j] = di;
1970 ug_data->attach_ex_bk[j] = di;
1979 static Evas_Object *_create_body(EmailViewerUGD *ug_data)
1982 EmailViewerProp *prop = ug_data->property;
1983 EmailViewerPrivate *priv = ug_data->email_data;
1987 if (ug_data->noc_bx) {
1988 elm_box_unpack(ug_data->main_bx, ug_data->noc_bx);
1989 evas_object_hide(ug_data->noc_bx);
1992 if (ug_data->dn_btn) {
1993 evas_object_hide(ug_data->dn_btn);
1996 if (ug_data->webview_bx) {
1997 _init_webview_data(ug_data);
1999 if (prop->has_html) {
2001 ug_data->webview_data->body_type_prev = BODY_TYPE_HTML;
2002 ug_data->webview_data->body_type = BODY_TYPE_HTML;
2003 ug_data->webview_data->uri = prop->body_uri;
2006 ug_data->webview_data->body_type_prev = BODY_TYPE_TEXT;
2007 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
2008 ug_data->webview_data->text_content = prop->body;
2011 viewer_set_webview_content(ug_data, 0);
2013 evas_object_show(ug_data->webview_bx);
2014 evas_object_show(ug_data->webview);
2015 elm_box_pack_end(ug_data->main_bx, ug_data->webview_bx);
2017 _update_tab_bar(ug_data);
2019 /* create webview layout */
2020 ug_data->webview_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.web_view");
2021 if (ug_data->webview_bx == NULL) {
2022 debug_log("Cannot load edj");
2026 evas_object_size_hint_align_set(ug_data->webview_bx, EVAS_HINT_FILL, 0.0);
2027 evas_object_show(ug_data->webview_bx);
2028 elm_box_pack_end(ug_data->main_bx, ug_data->webview_bx);
2030 /* create webview */
2031 if (NULL == ug_data->webview) {
2032 _init_webview_data(ug_data);
2033 viewer_get_webview(ug_data, prop->has_html);
2035 if (prop->has_html) {
2036 ug_data->webview_data->body_type_prev = BODY_TYPE_HTML;
2037 ug_data->webview_data->body_type = BODY_TYPE_HTML;
2038 ug_data->webview_data->uri = prop->body_uri;
2040 ug_data->webview_data->body_type_prev = BODY_TYPE_TEXT;
2041 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
2042 ug_data->webview_data->text_content = prop->body;
2044 viewer_set_webview_content(ug_data, 0);
2047 evas_object_show(ug_data->webview);
2048 elm_object_part_content_set(ug_data->webview_bx, "web_body", ug_data->webview);
2052 if (ug_data->isRotate) {
2053 resized_w = ug_data->webview_width_landscape * ug_data->scale_factor;
2054 resized_h = ug_data->webview_height_landscape * ug_data->scale_factor;
2056 resized_w = ug_data->webview_width * ug_data->scale_factor;
2057 resized_h = ug_data->webview_height * ug_data->scale_factor;
2060 evas_object_size_hint_min_set(ug_data->webview, resized_w, resized_h);
2062 /* set touch callbacks */
2063 evas_object_smart_callback_add(ug_data->webview, "policy,navigation,decide", _webview_policy_navigation_decide_cb, ug_data);
2064 evas_object_event_callback_add(ug_data->webview, EVAS_CALLBACK_MULTI_DOWN, _webview_multi_down_cb, ug_data);
2065 evas_object_event_callback_add(ug_data->webview, EVAS_CALLBACK_MULTI_UP, _webview_multi_up_cb, ug_data);
2067 /* update control Bar */
2068 _update_tab_bar(ug_data);
2071 viewer_set_mail_seen(prop, priv->mail_info);
2073 if (ug_data->timer) {
2074 ecore_timer_del(ug_data->timer);
2075 ug_data->timer = NULL;
2078 debug_log("send message - list unlock");
2079 ug_data->timer = ecore_timer_add(0.0, viewer_send_message, ug_data);
2081 return ug_data->webview_bx;
2084 static Evas_Object *_create_tab_bar(EmailViewerUGD *ug_data)
2088 EmailViewerProp *prop = ug_data->property;
2090 obj = elm_toolbar_add(ug_data->navi_bar);
2091 elm_toolbar_shrink_mode_set(obj, ELM_TOOLBAR_SHRINK_EXPAND);
2092 elm_object_style_set(obj, "naviframe");
2094 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX ||
2095 ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX) {
2096 int n_to_list = g_list_length(ug_data->to_list);
2097 int n_cc_list = g_list_length(ug_data->cc_list);
2098 debug_log("to:%d, cc:%d", n_to_list, n_cc_list);
2099 if (n_to_list + n_cc_list >= 2)
2100 ug_data->reply_ctr_it = elm_toolbar_item_append(obj, ICON_REPLY, dgettext("sys_string", "IDS_COM_SK_REPLY"), _reply_option_cb, ug_data);
2102 ug_data->reply_ctr_it = elm_toolbar_item_append(obj, ICON_REPLY, dgettext("sys_string", "IDS_COM_SK_REPLY"), _reply_cb, ug_data);
2103 ug_data->forward_ctr_it = elm_toolbar_item_append(obj, ICON_FORWARD, dgettext("sys_string", "IDS_COM_BODY_FORWARD"), _forward_cb, ug_data);
2104 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2105 ug_data->more_ctr_it = elm_toolbar_item_append(obj, ICON_CONTROLBAR_MORE, dgettext("sys_string", "IDS_COM_SK_MORE"), _more_cb, ug_data);
2107 elm_object_item_disabled_set(ug_data->reply_ctr_it, EINA_TRUE);
2108 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_TRUE);
2109 } else if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_OUTBOX) {
2110 debug_log("save_status: %d", prop->status2);
2111 if (prop->status2 == EMAIL_MAIL_STATUS_SEND_FAILURE) {
2112 ug_data->resend_ctr_it = elm_toolbar_item_append(obj, ICON_RESEND, _("IDS_EMAIL_SK_RESEND"), _resend_cb, ug_data);
2113 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2115 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2118 ug_data->del_ctr_it = elm_toolbar_item_append(obj, ICON_DELETE, dgettext("sys_string", "IDS_COM_SK_DELETE"), _delete_cb, ug_data);
2119 ug_data->move_ctr_it = elm_toolbar_item_append(obj, ICON_MOVE, _("IDS_EMAIL_SK_MOVE"), _move_cb, ug_data);
2122 elm_object_item_part_content_set(ug_data->navi_main_it, "controlbar", obj);
2123 ug_data->ctr_bar = obj;
2128 static Evas_Object *_update_tab_bar(EmailViewerUGD *ug_data)
2132 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX ||
2133 ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH || ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX) {
2134 elm_object_item_disabled_set(ug_data->reply_ctr_it, EINA_FALSE);
2135 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_FALSE);
2141 static Evas_Object *_create_partial_body_dn_btn(EmailViewerUGD *ug_data)
2145 ug_data->partial_dn_btn_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.partial_download_btn");
2146 if (ug_data->partial_dn_btn_bx == NULL) {
2147 debug_log("Cannot load edj");
2151 evas_object_size_hint_align_set(ug_data->partial_dn_btn_bx, EVAS_HINT_FILL, 0.0);
2152 evas_object_show(ug_data->partial_dn_btn_bx);
2153 elm_box_pack_before(ug_data->main_bx, ug_data->partial_dn_btn_bx, ug_data->webview_bx);
2155 Evas_Object *dn_btn = elm_button_add(ug_data->navi_bar);
2156 elm_object_text_set(dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_FULL_MESSAGE"));
2157 evas_object_smart_callback_add(dn_btn, "clicked", _body_down_cb, (void *)ug_data);
2158 /*elm_object_theme_set(dn_btn, ug_data->theme);*/
2159 elm_object_style_set(dn_btn, "text_only/style2");
2160 evas_object_show(dn_btn);
2161 ug_data->partial_dn_btn = dn_btn;
2163 elm_object_part_content_set(ug_data->partial_dn_btn_bx, "button", ug_data->partial_dn_btn);
2165 return ug_data->partial_dn_btn_bx;
2168 static Evas_Object *_create_bg(Evas_Object *win)
2172 Evas_Object *bg = elm_bg_add(win);
2173 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2174 elm_win_resize_object_add(win, bg);
2175 evas_object_show(bg);
2180 static void _create_down_progress(char *message, popup_cb resp_cb)
2185 debug_log("data is NULL");
2189 EmailViewerUGD *ug_data = _g_ug_data;
2190 Evas_Object *notify, *pb;
2192 notify = elm_popup_add(ug_data->win_main);
2194 debug_log("elm_popup_add returns NULL");
2197 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2198 ug_data->pb_notify = notify;
2200 elm_object_part_text_set(notify, "title,text", message);
2202 pb = elm_progressbar_add(notify);
2204 elm_object_style_set(pb, "list_progress");
2206 elm_progressbar_horizontal_set(pb, EINA_TRUE);
2207 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, EVAS_HINT_FILL);
2208 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2209 evas_object_show(pb);
2210 elm_progressbar_value_set(pb, 0.0);
2211 elm_object_content_set(notify, pb);
2212 ug_data->pb_notify_lb = pb;
2214 Evas_Object *btn1 = elm_button_add(notify);
2215 elm_object_style_set(btn1, "popup_button/default");
2216 elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
2217 elm_object_part_content_set(notify, "button1", btn1);
2218 evas_object_smart_callback_add(btn1, "clicked", resp_cb, ug_data);
2219 debug_log("Cancel btn1 for downloading body: %p", btn1);
2221 evas_object_show(notify);
2224 static void _create_down_progress_ex(int index, EMAIL_VIEWER_PROGRESSBAR_TYPE p_type)
2229 debug_log("data is NULL");
2233 EmailViewerUGD *ug_data = _g_ug_data;
2234 EmailViewerProp *prop = ug_data->property;
2235 EmailViewerPrivate *priv = ug_data->email_data;
2237 if (!prop || !prop->attachments) {
2247 if (ug_data->forward_ctr_it)
2248 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_TRUE);
2254 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
2255 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
2257 GList *attachment_list = prop->attachments;
2259 debug_log("index %d of attachment_count %d", index, prop->att_len);
2261 EmailAttachmentType *info = NULL;
2262 info = g_list_nth_data(attachment_list, index);
2264 debug_log("info is NULL");
2267 Evas_Object *pbar_ly = elm_layout_add(ug_data->navi_bar);
2268 elm_layout_file_set(pbar_ly, EV_THEME_PATH, "layout.email.attachment_downloading");
2269 evas_object_size_hint_align_set(pbar_ly, EVAS_HINT_FILL, 0.0);
2270 evas_object_show(pbar_ly);
2271 ug_data->progress_bar_ly[index + 1] = pbar_ly;
2274 char buff[MAX_STR_LEN] = { 0, };
2276 Evas_Object *downloading_label1;
2277 downloading_label1 = elm_label_add(pbar_ly);
2278 elm_object_part_content_set(pbar_ly, "elm.text.1", downloading_label1);
2279 char *text_tagged = g_strconcat("<font_size=32><align=left><color=#000000FF>", info->name, "</color></align></font_size>", NULL);
2280 elm_object_text_set(downloading_label1, text_tagged);
2281 elm_label_ellipsis_set(downloading_label1, EINA_TRUE);
2282 elm_label_wrap_width_set(downloading_label1, ug_data->main_w - 240);
2283 g_free(text_tagged);
2285 if (info->size < 1024) {
2286 g_sprintf(buff, "%d %s", (gint) info->size, dgettext("sys_string", "IDS_COM_BODY_B"));
2288 gdouble tmpsize = (gdouble) (info->size / 1024.);
2290 if (tmpsize < 1024) {
2291 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_KB"));
2295 if (tmpsize < 1024) {
2296 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_MB"));
2299 g_sprintf(buff, "%.2f %s", tmpsize, dgettext("sys_string", "IDS_COM_BODY_GB"));
2304 Evas_Object *downloading_label3;
2305 downloading_label3 = elm_label_add(pbar_ly);
2306 elm_object_part_content_set(pbar_ly, "elm.text.3", downloading_label3);
2307 text_tagged = g_strconcat("<font_size=26><align=right><color=#646464FF>", buff, "</color></align></font_size>", NULL);
2308 elm_object_text_set(downloading_label3, text_tagged);
2309 g_free(text_tagged);
2312 Evas_Object *progressbar = elm_progressbar_add(pbar_ly);
2313 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
2314 elm_object_style_set(progressbar, "list_progress");
2315 elm_object_part_content_set(pbar_ly, "elm.icon.2", progressbar);
2316 ug_data->progress_bar[index + 1] = progressbar;
2317 evas_object_show(progressbar);
2319 Evas_Object *cancel_btn = elm_button_add(pbar_ly);
2320 /*elm_object_theme_set(cancel_btn, ug_data->theme);*/
2321 elm_object_style_set(cancel_btn, "text_only/style2");
2322 elm_object_text_set(cancel_btn, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
2324 elm_object_part_content_set(pbar_ly, "elm.icon.1", cancel_btn);
2325 evas_object_show(cancel_btn);
2326 evas_object_smart_callback_add(cancel_btn, "clicked", _destroy_down_progress_ex, (void *)index);
2327 debug_log("Cancel button for attachment downloading progress popup: %p", cancel_btn);
2329 /* packing progress layout */
2330 if (p_type == EMAIL_VIEWER_PROGRESSBAR_ATT && prop->real_att_len > 1) {
2331 for (i = 0; i < prop->att_len; i++) {
2332 info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2333 if (info && !info->inline_content) {
2335 if (ug_data->attach_ex_ly != NULL && ug_data->attach_ex_ly[j] != NULL) {
2337 elm_box_pack_after(ug_data->main_bx, pbar_ly, ug_data->attach_ex_ly[j]);
2338 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[j]);
2339 evas_object_hide(ug_data->attach_ex_ly[j]);
2340 ug_data->attach_ex_ly[j] = pbar_ly;
2347 if ((p_type == EMAIL_VIEWER_PROGRESSBAR_ATT && prop->real_att_len == 1) || (p_type == EMAIL_VIEWER_PROGRESSBAR_ATT_ALL)) {
2349 elm_box_pack_after(ug_data->main_bx, pbar_ly, ug_data->attach_hd_ly);
2350 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2351 evas_object_hide(ug_data->attach_hd_ly);
2352 ug_data->attach_hd_ly = pbar_ly;
2355 elm_object_focus_set(pbar_ly, EINA_TRUE);
2356 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
2359 static void _destroy_down_progress_ex(void *data, Evas_Object *obj, void *event_info)
2364 debug_log("data is NULL");
2368 EmailViewerUGD *ug_data = _g_ug_data;
2369 EmailViewerPrivate *priv = ug_data->email_data;
2370 EmailViewerProp *prop = ug_data->property;
2372 if (!prop || !prop->attachments) {
2386 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
2387 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
2389 GList *attachment_list = prop->attachments;
2390 int index = (int)data;
2393 /* Cancel the download in email-service */
2395 debug_log("index[%d] download_all_cnt[%d] email_handle[%d]", index, priv->download_all_cnt, priv->download_all_email_handle[index]);
2396 if (priv->download_all_email_handle[index] > 0) {
2397 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[index]);
2398 priv->download_all_email_handle[index] = 0;
2401 (priv->download_all_cnt)--;
2403 if (priv->download_all_cnt == 0)
2404 priv->b_all_att_save = FALSE;
2405 } else if (index == -1) {
2406 for (i = 0; i < prop->att_len; i++) {
2407 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2408 if (info && !info->inline_content) {
2409 debug_log("index[%d] download_all_cnt[%d] email_handle[%d]", i, priv->download_all_cnt, priv->download_all_email_handle[i]);
2410 if (priv->download_all_email_handle[i] > 0) {
2411 email_engine_stop_working(ug_data->account_id, priv->download_all_email_handle[i]);
2414 priv->download_all_email_handle[i] = 0;
2416 priv->download_all_cnt = 0;
2417 priv->b_all_att_save = FALSE;
2420 /* upack and delete, pack again */
2422 debug_log("real_att_len:%d", prop->real_att_len);
2423 if (prop->real_att_len == 1) {
2424 debug_log("index[%d]", index);
2425 elm_box_pack_after(ug_data->main_bx, ug_data->attach_hd_bk, ug_data->attach_hd_ly);
2426 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2427 evas_object_del(ug_data->attach_hd_ly);
2428 ug_data->attach_hd_ly = ug_data->attach_hd_bk;
2429 evas_object_show(ug_data->attach_hd_ly);
2430 elm_object_focus_set(ug_data->attach_hd_ly, EINA_TRUE);
2431 ug_data->progress_bar[index + 1] = NULL;
2432 ug_data->progress_bar_ly[index + 1] = NULL;
2433 } else if (prop->real_att_len > 1) {
2434 for (i = 0; i < prop->att_len; i++) {
2435 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
2436 if (info && !info->inline_content) {
2438 debug_log("index[%d]", i);
2439 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
2440 if (ug_data->attach_onoff_flag > 0) {
2441 elm_box_pack_after(ug_data->main_bx, ug_data->attach_ex_bk[j], ug_data->attach_ex_ly[j]);
2442 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[j]);
2443 evas_object_del(ug_data->attach_ex_ly[j]);
2444 ug_data->attach_ex_ly[j] = ug_data->attach_ex_bk[j];
2445 evas_object_show(ug_data->attach_ex_ly[j]);
2446 elm_object_focus_set(ug_data->attach_ex_ly[j], EINA_TRUE);
2447 ug_data->progress_bar[index + 1] = NULL;
2448 ug_data->progress_bar_ly[index + 1] = NULL;
2450 evas_object_del(ug_data->attach_ex_ly[j]);
2451 ug_data->attach_ex_ly[j] = ug_data->attach_ex_bk[j];
2452 ug_data->progress_bar[index + 1] = NULL;
2453 ug_data->progress_bar_ly[index + 1] = NULL;
2460 } else if (index == -1) {
2461 debug_log("index[%d]", index);
2462 elm_box_pack_after(ug_data->main_bx, ug_data->attach_hd_bk, ug_data->attach_hd_ly);
2463 elm_box_unpack(ug_data->main_bx, ug_data->attach_hd_ly);
2464 evas_object_del(ug_data->attach_hd_ly);
2465 ug_data->attach_hd_ly = ug_data->attach_hd_bk;
2466 evas_object_show(ug_data->attach_hd_ly);
2467 elm_object_focus_set(ug_data->attach_hd_ly, EINA_TRUE);
2468 ug_data->progress_bar[index + 1] = NULL;
2469 ug_data->progress_bar_ly[index + 1] = NULL;
2472 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
2474 if (priv && priv->download_all_cnt <= 0) {
2475 if (ug_data->forward_ctr_it)
2476 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_FALSE);
2480 static void _create_more_ctxpopup(EmailViewerUGD *ug_data)
2484 debug_log("ug_data is NULL");
2488 EmailViewerProp *prop = ug_data->property;
2489 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
2490 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, prop->sender);
2492 if (ug_data->con_popup) {
2493 evas_object_del(ug_data->con_popup);
2494 ug_data->con_popup = NULL;
2497 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
2498 if (ug_data->con_popup == NULL) {
2499 debug_log("cannot create context popup");
2503 if (contact_list_item) {
2504 debug_log("Contact Item Exist: index[%d]", contact_list_item->index);
2505 char index[10] = { 0, };
2506 snprintf(index, sizeof(index), "%d", contact_list_item->index);
2508 if (email_engine_check_seen_mail(ug_data->account_id, ug_data->mail_id))
2509 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_UNREAD"), NULL, _mark_as_unread_cb, ug_data);
2511 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_READ"), NULL, _mark_as_read_cb, ug_data);
2513 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, _move_cb, ug_data);
2514 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_VIEW_CONTACT"), NULL, _ctxpopup_detail_contact_cb, g_strdup(index));
2515 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_ADD_TO_CALENDAR"), NULL, _add_to_calendar_cb, ug_data);
2516 ug_data->more_ctx_block_item = elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_BLOCK"), NULL, _ctxpopup_add_block_rule_cb, prop->sender);
2518 _delete_contacts_list(contact_list_item);
2520 if (email_engine_check_seen_mail(ug_data->account_id, ug_data->mail_id))
2521 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_UNREAD"), NULL, _mark_as_unread_cb, ug_data);
2523 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_MARK_AS_READ"), NULL, _mark_as_read_cb, ug_data);
2525 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, _move_cb, ug_data);
2526 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_OPT_ADD_TO_CONTACTS"), NULL, _ctxpopup_select_contact_mode_email_cb, prop->sender);
2527 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_ADD_TO_CALENDAR"), NULL, _add_to_calendar_cb, ug_data);
2528 ug_data->more_ctx_block_item = elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_BLOCK"), NULL, _ctxpopup_add_block_rule_cb, prop->sender);
2532 email_rule_t *rule_list = NULL;
2534 /* get the rule list from service */
2535 if (email_get_rule_list(&rule_list, &count) < 0) {
2536 debug_log("email_get_rule_list failed");
2539 for (i = 0; i < count; i++) {
2540 if (rule_list[i].type == EMAIL_FILTER_FROM) {
2541 debug_log("block address %s", rule_list[i].value);
2543 if (g_strcmp0(rule_list[i].value, prop->sender) == 0) {
2544 debug_log("[%s] already blocked", rule_list[i].value);
2545 if (ug_data->more_ctx_block_item)
2546 elm_object_item_disabled_set(ug_data->more_ctx_block_item, EINA_TRUE);
2551 /* free email rule_list */
2552 email_free_rule(&rule_list, count);
2556 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
2557 evas_object_move(ug_data->con_popup, x, y - 20);
2558 evas_object_show(ug_data->con_popup);
2561 static void _create_reply_ctxpopup(EmailViewerUGD *ug_data)
2565 debug_log("ug_data is NULL");
2569 if (ug_data->con_popup) {
2570 evas_object_del(ug_data->con_popup);
2571 ug_data->con_popup = NULL;
2574 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
2575 if (ug_data->con_popup == NULL) {
2576 debug_log("cannot create context popup");
2580 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_TO_SENDER_ABB"), NULL, _reply_cb, ug_data);
2581 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_TO_ALL_ABB"), NULL, _reply_all_cb, ug_data);
2584 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
2585 evas_object_move(ug_data->con_popup, x, y - 20);
2586 evas_object_show(ug_data->con_popup);
2589 static void _delete_evas_objects(EmailViewerUGD *ug_data)
2592 EmailViewerProp *prop = ug_data->property;
2594 if (ug_data->webview) {
2595 evas_object_del(ug_data->webview);
2596 ug_data->webview = NULL;
2599 if (ug_data->webview_bx) {
2600 evas_object_del(ug_data->webview_bx);
2601 ug_data->webview_bx = NULL;
2604 if (ug_data->scroller) {
2605 evas_object_del(ug_data->scroller);
2606 ug_data->scroller = NULL;
2609 if (ug_data->main_bx) {
2610 evas_object_del(ug_data->main_bx);
2611 ug_data->main_bx = NULL;
2614 if (ug_data->b_btn) {
2615 evas_object_del(ug_data->b_btn);
2616 ug_data->b_btn = NULL;
2619 if (ug_data->sub_ly) {
2620 evas_object_del(ug_data->sub_ly);
2621 ug_data->sub_ly = NULL;
2624 if (ug_data->navi_bar) {
2625 evas_object_del(ug_data->navi_bar);
2626 ug_data->navi_bar = NULL;
2629 if (ug_data->ctr_bar) {
2630 evas_object_del(ug_data->ctr_bar);
2631 ug_data->ctr_bar = NULL;
2634 if (ug_data->layout_main) {
2635 evas_object_del(ug_data->layout_main);
2636 ug_data->layout_main = NULL;
2639 if (ug_data->con_popup) {
2640 evas_object_del(ug_data->con_popup);
2641 ug_data->con_popup = NULL;
2644 if (ug_data->select_info) {
2645 evas_object_del(ug_data->select_info);
2646 ug_data->select_info = NULL;
2649 if (ug_data->selectioninfo_layout != NULL) {
2650 evas_object_del(ug_data->selectioninfo_layout);
2651 ug_data->selectioninfo_layout = NULL;
2654 if (ug_data->notify) {
2655 evas_object_del(ug_data->notify);
2656 ug_data->notify = NULL;
2659 if (ug_data->pb_notify) {
2660 evas_object_del(ug_data->pb_notify);
2661 ug_data->pb_notify = NULL;
2664 if (ug_data->pb_notify_lb) {
2665 evas_object_del(ug_data->pb_notify_lb);
2666 ug_data->pb_notify_lb = NULL;
2669 if (ug_data->partial_dn_btn) {
2670 evas_object_del(ug_data->partial_dn_btn);
2671 ug_data->partial_dn_btn = NULL;
2674 if (ug_data->partial_dn_btn_bx) {
2675 evas_object_del(ug_data->partial_dn_btn_bx);
2676 ug_data->partial_dn_btn_bx = NULL;
2679 if (ug_data->cutlink_timer) {
2680 ecore_timer_del(ug_data->cutlink_timer);
2681 ug_data->cutlink_timer = NULL;
2684 if (ug_data->timer) {
2685 ecore_timer_del(ug_data->timer);
2686 ug_data->timer = NULL;
2689 if (ug_data->idler) {
2690 ecore_idler_del(ug_data->idler);
2691 ug_data->idler = NULL;
2694 if (ug_data->got_att) {
2697 evas_object_del(ug_data->attach_hd_bk);
2698 ug_data->attach_hd_ly = NULL;
2699 ug_data->attach_hd_bk = NULL;
2701 if (prop->real_att_len > 1) {
2702 for (i = 0; i < prop->real_att_len; i++) {
2703 if (ug_data->attach_ex_ly != NULL) {
2704 if (ug_data->attach_ex_ly[i] != NULL) {
2705 debug_log("index %d", i);
2706 evas_object_del(ug_data->attach_ex_bk[i]);
2707 ug_data->attach_ex_ly[i] = NULL;
2708 ug_data->attach_ex_bk[i] = NULL;
2713 if (ug_data->attach_ex_ly != NULL) {
2714 free(ug_data->attach_ex_ly);
2715 ug_data->attach_ex_ly = NULL;
2716 ug_data->attach_ex_bk = NULL;
2720 for (i = 0; i <= prop->att_len; i++) {
2721 if (ug_data->progress_bar_ly[i] != NULL) {
2722 evas_object_del(ug_data->progress_bar_ly[i]);
2723 ug_data->progress_bar_ly[i] = NULL;
2724 ug_data->progress_bar[i] = NULL;
2730 void _launch_composer(EmailViewerUGD *ug_data, int type)
2735 debug_log("ug_data is NULL");
2739 EmailViewerPrivate *priv = ug_data->email_data;
2743 service_h service = NULL;
2745 ret = service_create(&service);
2746 debug_log("service_create: %d", ret);
2748 debug_log("service create failed");
2752 char rtype[10] = { 0, };
2753 snprintf(rtype, sizeof(rtype), "%d", type);
2754 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
2755 debug_log("service_add_extra_data: %d", ret);
2757 memset(tmp, 0x0, sizeof(tmp));
2758 snprintf(tmp, sizeof(tmp), "%d", priv->account_id);
2759 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_ACCOUNT_ID, tmp);
2760 debug_log("service_add_extra_data: %d", ret);
2762 memset(tmp, 0x0, sizeof(tmp));
2763 snprintf(tmp, sizeof(tmp), "%d", priv->mailbox_id);
2764 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MAILBOX, tmp);
2765 debug_log("service_add_extra_data: %d", ret);
2767 memset(tmp, 0x0, sizeof(tmp));
2768 snprintf(tmp, sizeof(tmp), "%d", priv->mail_id);
2769 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MAIL_ID, tmp);
2770 debug_log("service_add_extra_data: %d", ret);
2772 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
2774 ret = service_destroy(service);
2775 debug_log("service_destroy: %d", ret);
2778 static void _launch_vcs_editor(EmailViewerUGD *ug_data)
2783 debug_log("ug_data is NULL");
2787 char account_id[MAX_STR_LEN] = { 0, };
2788 char mail_id[MAX_STR_LEN] = { 0, };
2790 EmailViewerProp *prop = ug_data->property;
2793 service_h service = NULL;
2795 ret = service_create(&service);
2796 debug_log("service_create: %d", ret);
2798 debug_log("service create failed");
2802 snprintf(account_id, sizeof(account_id), "%d", prop->account_id);
2803 snprintf(mail_id, sizeof(mail_id), "%d", prop->mail_id);
2805 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_ACCOUNT_ID, account_id);
2806 debug_log("service_add_extra_data: %d", ret);
2807 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_MAIL_ID, mail_id);
2808 debug_log("service_add_extra_data: %d", ret);
2809 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_SRC_BOX, prop->src_box);
2810 debug_log("service_add_extra_data: %d", ret);
2811 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_INDEX, EMAIL_BUNDLE_VAL_CALENDAR_EDIT_INDEX);
2812 debug_log("service_add_extra_data: %d", ret);
2813 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CALENDAR_EDIT_NOTE, prop->subject);
2814 debug_log("service_add_extra_data: %d", ret);
2816 ug_data->ug_calendar_edit = create_ug(UG_NAME_CALENDAR_EDIT, service, ug_data);
2818 ret = service_destroy(service);
2819 debug_log("service_destroy: %d", ret);
2822 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
2826 if (_g_ug_data == NULL) {
2827 debug_log("_g_ug_data is NULL");
2832 debug_log("data is NULL");
2835 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2837 if (ug_data->con_popup != NULL) {
2838 evas_object_del(ug_data->con_popup);
2839 ug_data->con_popup = NULL;
2842 debug_log("isRoate = %d", ug_data->isRotate);
2843 if (ug_data->isRotate == false && ug_data->b_internal) {
2844 /* Viewer to hide, so set left content (mailbox) size to full */
2845 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
2848 if (ug_data->b_internal != 1) {
2849 debug_log("ug_destory_me");
2850 ug_destroy_me(ug_data->ug);
2852 _hide_view(ug_data);
2856 static void _prev_mail_cb(void *data, Evas_Object *obj, void *event_info)
2860 debug_log("data is NULL");
2864 /* send next or previous mail request to mailbox. */
2866 service_h service = NULL;
2868 ret = service_create(&service);
2869 debug_log("service_create: %d", ret);
2871 debug_log("service create failed");
2875 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_PREV_MSG);
2876 debug_log("service_add_extra_data: %d", ret);
2877 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "0");
2878 debug_log("service_add_extra_data: %d", ret);
2880 ug_send_message(_g_mailbox_ug, service);
2882 ret = service_destroy(service);
2883 debug_log("service_destroy: %d", ret);
2886 static void _next_mail_cb(void *data, Evas_Object *obj, void *event_info)
2890 debug_log("data is NULL");
2894 /* send next or previous mail request to mailbox. */
2896 service_h service = NULL;
2898 ret = service_create(&service);
2899 debug_log("service_create: %d", ret);
2901 debug_log("service create failed");
2905 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
2906 debug_log("service_add_extra_data: %d", ret);
2907 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "0");
2908 debug_log("service_add_extra_data: %d", ret);
2910 ug_send_message(_g_mailbox_ug, service);
2912 ret = service_destroy(service);
2913 debug_log("service_destroy: %d", ret);
2916 static void _reply_cb(void *data, Evas_Object *obj, void *event_info)
2920 debug_log("data is NULL");
2924 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2926 if (ug_data->con_popup) {
2927 evas_object_del(ug_data->con_popup);
2928 ug_data->con_popup = NULL;
2931 ug_data->display_download_result = FALSE;
2933 _launch_composer(ug_data, RUN_COMPOSER_REPLY);
2935 if (ug_data->notify) {
2936 evas_object_del(ug_data->notify);
2937 ug_data->notify = NULL;
2941 static void _reply_all_cb(void *data, Evas_Object *obj, void *event_info)
2945 debug_log("data is NULL");
2949 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2951 if (ug_data->con_popup) {
2952 evas_object_del(ug_data->con_popup);
2953 ug_data->con_popup = NULL;
2956 ug_data->display_download_result = FALSE;
2958 _launch_composer(ug_data, RUN_COMPOSER_REPLY_ALL);
2960 if (ug_data->notify) {
2961 evas_object_del(ug_data->notify);
2962 ug_data->notify = NULL;
2966 static void _reply_option_cb(void *data, Evas_Object *obj, void *event_info)
2970 debug_log("data is NULL");
2974 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2976 _create_reply_ctxpopup(ug_data);
2979 static void _forward_cb(void *data, Evas_Object *obj, void *event_info)
2983 debug_log("data is NULL");
2987 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
2989 ug_data->display_download_result = FALSE;
2991 _launch_composer(ug_data, RUN_COMPOSER_FORWARD);
2994 static void _add_to_calendar_cb(void *data, Evas_Object *obj, void *event_info)
3001 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3003 if (ug_data->con_popup) {
3004 evas_object_del(ug_data->con_popup);
3005 ug_data->con_popup = NULL;
3008 _launch_vcs_editor(ug_data);
3011 static void _resend_cb(void *data, Evas_Object *obj, void *event_info)
3016 static void _delete_cb(void *data, Evas_Object *obj, void *event_info)
3020 debug_log("data is NULL");
3024 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3026 if (ug_data->con_popup) {
3027 evas_object_del(ug_data->con_popup);
3028 ug_data->con_popup = NULL;
3031 _create_notify(ug_data, NULL, dgettext("sys_string", "IDS_COM_POP_DELETE_Q"),
3032 2, dgettext("sys_string", "IDS_COM_SK_DELETE"),
3033 _popup_response_delete_ok_cb, dgettext("sys_string", "IDS_COM_SK_CANCEL"),
3034 _popup_response_cb, NULL);
3037 static void _move_cb(void *data, Evas_Object *obj, void *event_info)
3041 debug_log("data is NULL");
3045 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3046 EmailViewerPrivate *priv = ug_data->email_data;
3048 if (ug_data->con_popup) {
3049 evas_object_del(ug_data->con_popup);
3050 ug_data->con_popup = NULL;
3053 Elm_Object_Item *git = NULL;
3054 Evas_Object *gl = elm_genlist_add(ug_data->navi_bar);
3055 evas_object_show(gl);
3057 ug_data->itc1.item_style = "1text.1icon.2";
3058 ug_data->itc1.func.text_get = _gl_text_get;
3059 ug_data->itc1.func.content_get = _gl_content_get;
3060 ug_data->itc1.func.state_get = _gl_state_get;
3061 ug_data->itc1.func.del = _gl_del;
3063 ug_data->itc2.item_style = "1text.1icon.2";
3064 ug_data->itc2.func.text_get = _gl_sub_upper_text_get;
3065 ug_data->itc2.func.content_get = _gl_sub_upper_icon_get;
3066 ug_data->itc2.func.state_get = _gl_state_get;
3067 ug_data->itc2.func.del = NULL;
3069 ug_data->itc3.item_style = "grouptitle.dialogue.seperator";
3070 ug_data->itc3.func.text_get = NULL;
3071 ug_data->itc3.func.content_get = NULL;
3072 ug_data->itc3.func.state_get = _gl_state_get;
3073 ug_data->itc3.func.del = NULL;
3075 Elm_Object_Item *navi_it = NULL;
3076 navi_it = elm_naviframe_item_push(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, NULL, gl, NULL);
3077 ug_data->navi_move_it1 = navi_it;
3078 if (ug_data->isRotate)
3079 elm_naviframe_item_title_visible_set(ug_data->navi_move_it1, EINA_FALSE);
3081 email_mailbox_t *mailbox_list = NULL;
3082 int mailbox_count = 0;
3085 email_get_mailbox_list(priv->account_id, -1, &mailbox_list, &mailbox_count);
3086 debug_log("folder count %d", mailbox_count);
3087 ug_data->move_mailbox_list = mailbox_list;
3088 ug_data->move_mailbox_count = mailbox_count;
3090 git = elm_genlist_item_append(gl, &(ug_data->itc3), NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
3091 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
3093 for (i = 0; i < mailbox_count; i++) {
3094 if (g_strcmp0(ug_data->mailbox_name, mailbox_list[i].mailbox_name) != 0) {
3095 if (mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_OUTBOX &&
3096 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_SENTBOX &&
3097 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_DRAFT &&
3098 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_TRASH &&
3099 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_ALL_EMAILS &&
3100 mailbox_list[i].mailbox_type != EMAIL_MAILBOX_TYPE_SEARCH_RESULT)
3101 if (g_strcmp0(mailbox_list[i].alias, "[Gmail]")) {
3102 elm_genlist_item_append(gl, &ug_data->itc1, (void *)&(mailbox_list[i]), git, ELM_GENLIST_ITEM_NONE, _gl_sel, (void *)&(mailbox_list[i]));
3107 /*if (ug_data->b_internal)
3108 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "noindicator");
3110 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "default");*/
3112 Evas_Object *move_back_btn = NULL;
3113 if (ug_data->isRotate) {
3114 ug_data->move_cbar = elm_toolbar_add(ug_data->navi_bar);
3115 elm_toolbar_shrink_mode_set(ug_data->move_cbar, ELM_TOOLBAR_SHRINK_EXPAND);
3116 elm_object_style_set(ug_data->move_cbar, "naviframe");
3117 evas_object_show(ug_data->move_cbar);
3119 elm_object_item_disabled_set(elm_toolbar_item_append(ug_data->move_cbar, NULL, "", NULL, NULL), EINA_TRUE);
3120 elm_toolbar_item_append(ug_data->move_cbar, NULL, dgettext("sys_string", "IDS_COM_SK_CANCEL"), _move_back_cb, ug_data);
3121 elm_object_item_part_content_set(navi_it, "controlbar", ug_data->move_cbar);
3123 move_back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
3124 if (move_back_btn) {
3125 evas_object_del(move_back_btn);
3126 elm_object_item_part_content_set(navi_it, "prev_btn", NULL);
3129 move_back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
3130 if (move_back_btn) {
3131 evas_object_del(move_back_btn);
3132 move_back_btn = elm_button_add(ug_data->navi_bar);
3133 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
3134 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb, ug_data);
3135 elm_object_item_part_content_set(navi_it, "prev_btn", move_back_btn);
3140 static void _more_cb(void *data, Evas_Object *obj, void *event_info)
3144 debug_log("data is NULL");
3148 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3150 _create_more_ctxpopup(ug_data);
3153 static void _body_down_cb(void *data, Evas_Object *obj, void *event_info)
3157 debug_log("data is NULL");
3161 unsigned int handle;
3163 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3164 EmailViewerPrivate *priv = ug_data->email_data;
3166 /* check already downloaded */
3167 int body_download_status = ug_data->property->body_download;
3169 if (body_download_status == 0) { //EMAIL_BODY_DOWNLOAD_STATUS_NONE
3170 debug_log("need body download");
3171 } else if (body_download_status == 1) { //EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED
3172 debug_log("already downloaded, create body directly");
3175 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
3177 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
3180 if (ug_data->b_partial_body) {
3185 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
3186 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
3188 elm_box_unpack(ug_data->main_bx, ug_data->partial_dn_btn_bx);
3189 if (ug_data->partial_dn_btn) {
3190 evas_object_del(ug_data->partial_dn_btn);
3191 ug_data->partial_dn_btn = NULL;
3193 if (ug_data->partial_dn_btn_bx) {
3194 evas_object_del(ug_data->partial_dn_btn_bx);
3195 ug_data->partial_dn_btn_bx = NULL;
3198 if (ug_data->property->has_html) {
3199 ug_data->webview_data->body_type = BODY_TYPE_HTML;
3200 ug_data->webview_data->uri = ug_data->property->body_uri;
3202 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
3203 ug_data->webview_data->text_content = ug_data->property->body;
3206 viewer_set_webview_content(ug_data, 1);
3207 ug_data->b_partial_body = 0;
3209 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
3210 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
3212 if (ug_data->property->has_attachment)
3213 ug_data->got_att = 1;
3215 ug_data->got_att = 0;
3217 /* pack attachment if it exist */
3218 if (ug_data->got_att) {
3219 _create_attach(ug_data);
3222 _create_body(ug_data);
3226 } else if (body_download_status == 2) { //EMAILL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED
3227 debug_log("need full body download");
3230 ret = email_engine_body_download(priv->account_id, priv->mail_id, &handle);
3233 priv->email_handle = handle;
3234 debug_log("succeed in email_engine_body_download");
3235 _create_down_progress(dgettext("sys_string", "IDS_COM_POP_DOWNLOADING"), _destroy_down_progress_cb);
3237 /* If attachment download is in progress, first cancel to attachment download of the mail and then carry out body download */
3238 _cancel_download_attachment(ug_data);
3241 debug_log("unable to download mail body");
3242 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
3243 _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), 1,
3244 dgettext("sys_string", "IDS_COM_SK_OK"),
3245 _popup_response_cb, NULL, NULL, NULL);
3249 static void _subject_favorite_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3253 debug_log("data is NULL");
3257 EmailViewerUGD *ug_data = _g_ug_data;
3258 EmailViewerProp *prop = ug_data->property;
3259 int err = EMAIL_ERROR_NONE;
3261 if (ug_data->con_popup) {
3262 evas_object_del(ug_data->con_popup);
3263 ug_data->con_popup = NULL;
3266 debug_log("Before prop->favorite: %d", prop->favorite);
3267 switch(prop->favorite) {
3268 case EMAIL_FLAG_NONE:
3269 prop->favorite = EMAIL_FLAG_FLAGED;
3271 case EMAIL_FLAG_FLAGED:
3272 prop->favorite = EMAIL_FLAG_NONE;
3274 case EMAIL_FLAG_TASK_STATUS_CLEAR:
3275 prop->favorite = EMAIL_FLAG_TASK_STATUS_ACTIVE;
3277 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
3278 prop->favorite = EMAIL_FLAG_TASK_STATUS_COMPLETE;
3280 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
3281 prop->favorite = EMAIL_FLAG_TASK_STATUS_CLEAR;
3284 debug_log("Never here");
3286 debug_log("After prop->favorite: %d", prop->favorite);
3288 err = email_set_flags_field(ug_data->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_FLAGGED_FIELD, prop->favorite, 1);
3289 if (err != EMAIL_ERROR_NONE) {
3290 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3291 N_("Failed to set favourite"), 0,
3292 NULL, NULL, NULL, NULL, _popup_response_cb);
3296 evas_object_del(elm_object_part_content_unset(ug_data->ly_subject, "elm.icon.favorite"));
3297 Evas_Object *favorite_icon = elm_icon_add(ug_data->ly_subject);
3298 switch(prop->favorite)
3300 case EMAIL_FLAG_NONE:
3301 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_off.png", NULL);
3303 case EMAIL_FLAG_FLAGED:
3304 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_icon_favorite_on.png", NULL);
3306 case EMAIL_FLAG_TASK_STATUS_CLEAR:
3307 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Clear.png", NULL);
3309 case EMAIL_FLAG_TASK_STATUS_ACTIVE:
3310 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Active.png", NULL);
3312 case EMAIL_FLAG_TASK_STATUS_COMPLETE:
3313 elm_icon_file_set(favorite_icon, IMGDIR "/M02_email_Flag_Complete.png", NULL);
3316 debug_log("Never here");
3318 evas_object_size_hint_aspect_set(favorite_icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
3319 elm_icon_resizable_set(favorite_icon, 1, 1);
3320 elm_object_part_content_set(ug_data->ly_subject, "elm.icon.favorite", favorite_icon);
3321 evas_object_show(favorite_icon);
3323 /* send unread request to mailbox. */
3325 service_h service = NULL;
3327 ret = service_create(&service);
3328 debug_log("service_create: %d", ret);
3330 debug_log("service create failed");
3334 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_READ);
3335 debug_log("service_add_extra_data: %d", ret);
3337 ug_send_message(_g_mailbox_ug, service);
3339 ret = service_destroy(service);
3340 debug_log("service_destroy: %d", ret);
3343 static void _subject_detail_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3347 debug_log("data is NULL");
3351 Evas_Object *item = (Evas_Object *)data;
3352 EmailViewerUGD *ug_data = _g_ug_data;
3354 if (!(ug_data->subject_onoff_flag)) {
3355 edje_object_signal_emit(_EDJ(item), "elm,state,expanded", "elm");
3356 (ug_data->subject_onoff_flag)++;
3358 _create_to_addrs(_g_ug_data);
3359 _create_cc_addrs(_g_ug_data);
3360 _create_bcc_addrs(_g_ug_data);
3362 edje_object_signal_emit(_EDJ(item), "elm,state,contracted", "elm");
3363 (ug_data->subject_onoff_flag)--;
3365 if (ug_data->to_ly) {
3366 elm_box_unpack(ug_data->main_bx, ug_data->to_ly);
3367 evas_object_del(ug_data->to_ly);
3368 ug_data->to_ly = NULL;
3370 if (ug_data->cc_ly) {
3371 elm_box_unpack(ug_data->main_bx, ug_data->cc_ly);
3372 evas_object_del(ug_data->cc_ly);
3373 ug_data->cc_ly = NULL;
3375 if (ug_data->bcc_ly) {
3376 elm_box_unpack(ug_data->main_bx, ug_data->bcc_ly);
3377 evas_object_del(ug_data->bcc_ly);
3378 ug_data->bcc_ly = NULL;
3381 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
3385 static void _attachment_item_collapse_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3388 if (!data || !_g_ug_data) {
3389 debug_log("data is NULL");
3393 Evas_Object *item = (Evas_Object *)data;
3394 EmailViewerUGD *ug_data = _g_ug_data;
3395 EmailViewerProp *prop = ug_data->property;
3398 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
3399 if (!(ug_data->attach_onoff_flag)) {
3400 debug_log("attachments expanded");
3401 edje_object_signal_emit(_EDJ(item), "elm,state,expanded", "elm");
3402 (ug_data->attach_onoff_flag)++;
3404 if (ug_data->attach_ex_ly == NULL)
3405 _create_attach_ex(ug_data);
3407 for (i = 0; i < prop->real_att_len; i++) {
3408 debug_log("index %d", i);
3409 elm_box_pack_after(ug_data->main_bx, ug_data->attach_ex_ly[i], ug_data->attach_hd_ly);
3410 evas_object_show(ug_data->attach_ex_ly[i]);
3414 debug_log("attachments contracted");
3415 edje_object_signal_emit(_EDJ(item), "elm,state,contracted", "elm");
3416 ug_data->attach_onoff_flag = 0;
3418 for (i = 0; i < prop->real_att_len; i++) {
3419 if (ug_data->attach_ex_ly[i] != NULL) {
3420 debug_log("index %d", i);
3421 elm_box_unpack(ug_data->main_bx, ug_data->attach_ex_ly[i]);
3422 evas_object_hide(ug_data->attach_ex_ly[i]);
3428 static void _attachment_save_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3433 debug_log("ug_data is NULL");
3437 EmailViewerUGD *ug_data = _g_ug_data;
3438 int att_index = (int)data;
3440 ug_data->display_download_result = FALSE;
3442 debug_log("Selected item index = %d", att_index);
3443 _show_attachment(ug_data, att_index);
3446 static void _attachment_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3451 debug_log("ug_data is NULL");
3455 EmailViewerUGD *ug_data = _g_ug_data;
3456 int att_index = (int)data;
3458 debug_log("Selected item index = %d", att_index);
3459 ug_data->display_download_result = TRUE;
3460 _show_attachment(ug_data, att_index);
3463 static void _attachment_save_all_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
3467 debug_log("ug_data is NULL");
3471 EmailViewerUGD *ug_data = _g_ug_data;
3473 _save_attachment_all(ug_data);
3476 static void _attachment_bg_set_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
3480 debug_log("ug_data is NULL");
3484 EmailViewerUGD *ug_data = _g_ug_data;
3485 EmailViewerProp *prop = ug_data->property;
3487 int att_index = (int)data;
3488 debug_log("att_index = %d, attachments count = %d", att_index, prop->real_att_len);
3490 if (prop->real_att_len > 1) {
3493 GList *attachment_list = prop->attachments;
3494 LIST_ITER_START(i, attachment_list) {
3495 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
3496 if (info && !info->inline_content) {
3502 edje_object_signal_emit(_EDJ(ug_data->attach_ex_ly[j]), "pressed", "elm.event.rect");
3505 edje_object_signal_emit(_EDJ(ug_data->attach_hd_ly), "pressed", "elm.event.rect");
3508 static void _attachment_bg_unset_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
3512 debug_log("ug_data is NULL");
3516 EmailViewerUGD *ug_data = _g_ug_data;
3517 EmailViewerProp *prop = ug_data->property;
3519 int att_index = (int)data;
3520 debug_log("att_index = %d, attachments count = %d", att_index, prop->real_att_len);
3522 if (prop->real_att_len > 1) {
3525 GList *attachment_list = prop->attachments;
3526 LIST_ITER_START(i, attachment_list) {
3527 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, attachment_list);
3528 if (info && !info->inline_content) {
3534 edje_object_signal_emit(_EDJ(ug_data->attach_ex_ly[j]), "unpressed", "elm.event.rect");
3537 edje_object_signal_emit(_EDJ(ug_data->attach_hd_ly), "unpressed", "elm.event.rect");
3540 static void _mark_as_unread_cb(void *data, Evas_Object *obj, void *event_info)
3544 debug_log("data is NULL");
3548 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3549 EmailViewerPrivate *priv = ug_data->email_data;
3551 if (ug_data->con_popup) {
3552 evas_object_del(ug_data->con_popup);
3553 ug_data->con_popup = NULL;
3557 debug_log("ug_data->mail_id(%d), priv->mail_id(%d), mail_info->mail_id(%d))", ug_data->mail_id, priv->mail_id, priv->mail_info->mail_id);
3559 err = email_set_flags_field(ug_data->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_SEEN_FIELD, 0, 1);
3560 debug_log("email_set_flags_field - err(%d)", err);
3562 if (err != EMAIL_ERROR_NONE) {
3563 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3564 _("IDS_EMAIL_POP_FAILED_TO_MARK_AS_UNREAD"), 0,
3565 NULL, NULL, NULL, NULL, _popup_response_cb);
3567 char str[128] = { 0, };
3568 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MARKED_AS_UNREAD"));
3569 _show_select_info(ug_data, str);
3571 /* send unread request to mailbox. */
3573 service_h service = NULL;
3575 ret = service_create(&service);
3576 debug_log("service_create: %d", ret);
3578 debug_log("service create failed");
3582 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_UNREAD);
3583 debug_log("service_add_extra_data: %d", ret);
3585 ug_send_message(_g_mailbox_ug, service);
3587 ret = service_destroy(service);
3588 debug_log("service_destroy: %d", ret);
3592 static void _mark_as_read_cb(void *data, Evas_Object *obj, void *event_info)
3596 debug_log("data is NULL");
3600 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3601 EmailViewerPrivate *priv = ug_data->email_data;
3603 if (ug_data->con_popup) {
3604 evas_object_del(ug_data->con_popup);
3605 ug_data->con_popup = NULL;
3609 debug_log("ug_data->mail_id(%d), priv->mail_id(%d), mail_info->mail_id(%d))", ug_data->mail_id, priv->mail_id, priv->mail_info->mail_id);
3611 err = email_set_flags_field(priv->mail_info->account_id, &ug_data->mail_id, 1, EMAIL_FLAGS_SEEN_FIELD, 1, 1);
3612 debug_log("email_set_flags_field - err(%d)", err);
3614 if (err != EMAIL_ERROR_NONE) {
3615 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3616 _("IDS_EMAIL_POP_FAILED_TO_MARK_AS_READ"), 0,
3617 NULL, NULL, NULL, NULL, _popup_response_cb);
3619 char str[128] = { 0, };
3620 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_MARKED_AS_READ"));
3621 _show_select_info(ug_data, str);
3623 /* send unread request to mailbox. */
3625 service_h service = NULL;
3627 ret = service_create(&service);
3628 debug_log("service_create: %d", ret);
3630 debug_log("service create failed");
3634 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_READ);
3635 debug_log("service_add_extra_data: %d", ret);
3637 ug_send_message(_g_mailbox_ug, service);
3639 ret = service_destroy(service);
3640 debug_log("service_destroy: %d", ret);
3644 static void _ctxpopup_detail_contact_cb(void *data, Evas_Object *obj, void *event_info)
3647 if (data == NULL || _g_ug_data == NULL) {
3648 debug_log("data is NULL");
3652 EmailViewerUGD *ug_data = _g_ug_data;
3654 if (ug_data->con_popup) {
3655 evas_object_del(ug_data->con_popup);
3656 ug_data->con_popup = NULL;
3659 char *index = (char *)data;
3660 char type[10] = { 0, };
3662 service_h service = NULL;
3664 ret = service_create(&service);
3665 debug_log("service_create: %d", ret);
3667 debug_log("service create failed");
3671 snprintf(type, sizeof(type), "%d", CT_UG_REQUEST_DETAIL);
3673 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, type);
3674 debug_log("service_add_extra_data: %d", ret);
3675 ret = service_add_extra_data(service, CT_UG_BUNDLE_ID, index);
3676 debug_log("service_add_extra_data: %d", ret);
3678 create_ug(UG_CONTACTS_DETAILS, service, ug_data);
3680 ret = service_destroy(service);
3681 debug_log("service_destroy: %d", ret);
3683 debug_log("set flag for contact ug");
3684 ug_data->b_contact_ug_launched = TRUE;
3687 static void _ctxpopup_send_email_cb(void *data, Evas_Object *obj, void *event_info)
3690 if (!data || !_g_ug_data) {
3691 debug_log("data is NULL");
3695 EmailViewerUGD *ug_data = _g_ug_data;
3697 if (ug_data->con_popup == NULL) {
3698 debug_log("con_popup is NULL");
3702 if (ug_data->con_popup) {
3703 evas_object_del(ug_data->con_popup);
3704 ug_data->con_popup = NULL;
3707 debug_log("email: %s", (char *)data);
3710 service_h service = NULL;
3712 ret = service_create(&service);
3713 debug_log("service_create: %d", ret);
3715 debug_log("service create failed");
3719 char rtype[10] = { 0, };
3720 snprintf(rtype, sizeof(rtype), "%d", RUN_COMPOSER_EXTERNAL);
3722 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
3723 debug_log("service_add_extra_data: %d", ret);
3724 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_TO, (char *)data);
3725 debug_log("service_add_extra_data: %d", ret);
3726 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_CC, NULL);
3727 debug_log("service_add_extra_data: %d", ret);
3728 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_BCC, NULL);
3729 debug_log("service_add_extra_data: %d", ret);
3730 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_SUBJECT, NULL);
3731 debug_log("service_add_extra_data: %d", ret);
3732 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_BODY, NULL);
3733 debug_log("service_add_extra_data: %d", ret);
3734 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_ATTACHMENT, NULL);
3735 debug_log("service_add_extra_data: %d", ret);
3737 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
3739 ret = service_destroy(service);
3740 debug_log("service_destroy: %d", ret);
3743 static void _ctxpopup_add_contact_cb(void *data, Evas_Object *obj, void *event_info)
3746 if (!data || !_g_ug_data) {
3747 debug_log("data is NULL");
3751 char tmp[MAX_STR_LEN] = { 0, };
3752 EmailViewerUGD *ug_data = _g_ug_data;
3754 if (ug_data->con_popup == NULL) {
3755 debug_log("con_popup is NULL");
3759 if (ug_data->con_popup) {
3760 evas_object_del(ug_data->con_popup);
3761 ug_data->con_popup = NULL;
3765 service_h service = NULL;
3767 ret = service_create(&service);
3768 debug_log("service_create: %d", ret);
3770 debug_log("service create failed");
3774 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_PHONE_NUMBER) {
3775 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_NUM);
3776 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3777 debug_log("service_add_extra_data: %d", ret);
3778 ret = service_add_extra_data(service, CT_UG_BUNDLE_NUM, (char *)data);
3779 debug_log("service_add_extra_data: %d", ret);
3781 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_EMAIL) {
3782 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_EMAIL);
3783 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3784 debug_log("service_add_extra_data: %d", ret);
3785 ret = service_add_extra_data(service, CT_UG_BUNDLE_EMAIL, (char *)data);
3786 debug_log("service_add_extra_data: %d", ret);
3788 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_URL) {
3789 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_WEB);
3790 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3791 debug_log("service_add_extra_data: %d", ret);
3792 ret = service_add_extra_data(service, CT_UG_BUNDLE_WEB, (char *)data);
3793 debug_log("service_add_extra_data: %d", ret);
3796 create_ug(UG_CONTACTS_DETAILS, service, ug_data);
3798 ret = service_destroy(service);
3799 debug_log("service_destroy: %d", ret);
3802 static void _ctxpopup_cutlink_update_contact_cb(void *data, Evas_Object *obj, void *event_info)
3805 if (!data || !_g_ug_data) {
3806 debug_log("data is NULL");
3810 char tmp[MAX_STR_LEN] = { 0, };
3811 EmailViewerUGD *ug_data = _g_ug_data;
3813 if (ug_data->con_popup == NULL) {
3814 debug_log("con_popup is NULL");
3818 if (ug_data->con_popup) {
3819 evas_object_del(ug_data->con_popup);
3820 ug_data->con_popup = NULL;
3824 service_h service = NULL;
3826 ret = service_create(&service);
3827 debug_log("service_create: %d", ret);
3829 debug_log("service create failed");
3833 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_PHONE_NUMBER) {
3834 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_NUM);
3835 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3836 debug_log("service_add_extra_data: %d", ret);
3837 ret = service_add_extra_data(service, CT_UG_BUNDLE_NUM, (char *)data);
3838 debug_log("service_add_extra_data: %d", ret);
3840 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_EMAIL) {
3841 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_EMAIL);
3842 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3843 debug_log("service_add_extra_data: %d", ret);
3844 ret = service_add_extra_data(service, CT_UG_BUNDLE_EMAIL, (char *)data);
3845 debug_log("service_add_extra_data: %d", ret);
3847 if (ug_data->create_contact_arg == CONTACTUI_REQ_ADD_URL) {
3848 snprintf(tmp, sizeof(tmp), "%d", CT_UG_REQUEST_ADD_WITH_WEB);
3849 ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, tmp);
3850 debug_log("service_add_extra_data: %d", ret);
3851 ret = service_add_extra_data(service, CT_UG_BUNDLE_WEB, (char *)data);
3852 debug_log("service_add_extra_data: %d", ret);
3855 ug_data->ug_contacts_search = create_ug(UG_CONTACTS_LIST, service, ug_data);
3857 ret = service_destroy(service);
3858 debug_log("service_destroy: %d", ret);
3861 static void _ctxpopup_select_contact_mode_email_cb(void *data, Evas_Object *obj, void *event_info)
3864 if (!data || !_g_ug_data) {
3865 debug_log("data is NULL");
3869 EmailViewerUGD *ug_data = _g_ug_data;
3872 if (ug_data->con_popup) {
3873 evas_object_del(ug_data->con_popup);
3874 ug_data->con_popup = NULL;
3877 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
3878 if (ug_data->con_popup == NULL) {
3879 debug_log("cannot create context popup");
3883 ug_data->create_contact_arg = CONTACTUI_REQ_ADD_EMAIL;
3884 ug_data->update_contact_type = CONTACTUI_REQ_ADD_EMAIL;
3886 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_OPT_CREATE_CONTACT"), NULL, _ctxpopup_add_contact_cb, data);
3887 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_UPDATE_EXISTING"), NULL, _ctxpopup_cutlink_update_contact_cb, data);
3889 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
3890 evas_object_move(ug_data->con_popup, x, y);
3891 evas_object_show(ug_data->con_popup);
3894 static void _ctxpopup_add_block_rule_cb(void *data, Evas_Object *obj, void *event_info)
3898 if (!data || !_g_ug_data) {
3899 debug_log("data is NULL");
3903 EmailViewerUGD *ug_data = _g_ug_data;
3904 EmailViewerPrivate *priv = ug_data->email_data;
3905 char *addr = (char *)data;
3907 debug_log("Block address: %s", addr);
3909 if (ug_data->con_popup) {
3910 evas_object_del(ug_data->con_popup);
3911 ug_data->con_popup = NULL;
3915 email_rule_t *rule = NULL;
3917 /* add filtering rule */
3918 rule = malloc(sizeof(email_rule_t));
3919 rule->account_id = priv->account_id;
3920 rule->type = EMAIL_FILTER_FROM;
3921 rule->value = g_strdup(addr);
3922 rule->faction = EMAIL_FILTER_BLOCK;
3925 email_mailbox_t *mail_box = NULL;
3926 if ((err = email_get_mailbox_by_mailbox_type(ug_data->account_id, ug_data->mailbox_type, &mail_box)) != EMAIL_ERROR_NONE) {
3927 debug_log("email_get_mailbox_by_mailbox_type failed! - err (%d)", err);
3930 if (mail_box == NULL) {
3931 debug_log("mail_box is NULL");
3934 rule->target_mailbox_id = mail_box->mailbox_id;
3937 debug_log("email_free_mailbox is called");
3938 email_free_mailbox(&mail_box, 1);
3943 rule->flag2 = RULE_TYPE_INCLUDES;
3945 ret = email_add_rule(rule);
3947 debug_log("email_add_rule failed %d", ret);
3948 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3949 _("IDS_EMAIL_POP_FAILED_TO_ADD_BLOCK_RULE"), 0,
3950 NULL, NULL, NULL, NULL, _popup_response_cb);
3953 vconf_ret = vconf_set_int(EMAIL_VCONF_KEY_BLOCK_RULE_CHANGED, 1);
3954 if (vconf_ret == -1) {
3955 debug_log("fail to set vconf int(spam_rule_changed)");
3956 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
3957 _("IDS_EMAIL_POP_FAILED_TO_ADD_BLOCK_RULE"), 0,
3958 NULL, NULL, NULL, NULL, _popup_response_cb);
3960 char str[128] = { 0, };
3961 snprintf(str, sizeof(str), "%s", _("IDS_EMAIL_POP_BLOCKED"));
3962 ret = status_message_post(str);
3964 debug_log("status_message_post failed: %d", ret);
3968 email_free_rule(&rule, 1);
3971 static void _popup_response_cb(void *data, Evas_Object *obj, void *event_info)
3975 debug_log("_g_ug_data is NULL");
3980 debug_log("data is NULL");
3984 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
3986 if (ug_data->notify) {
3987 evas_object_del(ug_data->notify);
3988 ug_data->notify = NULL;
3992 static void _popup_response_delete_ok_cb(void *data, Evas_Object *obj, void *event_info)
3996 debug_log("_g_ug_data is NULL");
4001 debug_log("data is NULL");
4005 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4007 if (ug_data->notify) {
4008 evas_object_del(ug_data->notify);
4009 ug_data->notify = NULL;
4012 if (ug_data->mailbox_type == EMAIL_MAILBOX_TYPE_TRASH)
4013 _delete_email(ug_data);
4015 _move_email(ug_data, _find_folder_id_using_folder_type(ug_data, EMAIL_MAILBOX_TYPE_TRASH), TRUE);
4017 if (ug_data->isRotate == false && ug_data->b_internal) {
4018 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
4022 if (ug_data->b_internal) {
4023 _hide_view(ug_data);
4025 /* send next or previous mail request to mailbox. */
4027 service_h service = NULL;
4029 ret = service_create(&service);
4030 debug_log("service_create: %d", ret);
4032 debug_log("service create failed");
4036 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
4037 debug_log("service_add_extra_data: %d", ret);
4038 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "1");
4039 debug_log("service_add_extra_data: %d", ret);
4041 ug_send_message(_g_mailbox_ug, service);
4043 ret = service_destroy(service);
4044 debug_log("service_destroy: %d", ret);
4046 ug_destroy_me(ug_data->ug);
4049 static void _popup_response_to_destroy_cb(void *data, Evas_Object *obj, void *event_info)
4053 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4054 evas_object_del(obj);
4056 ug_data->b_direct_destroy = 1;
4057 ug_destroy_me(ug_data->ug);
4061 static void _webview_multi_up_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
4064 if (_g_ug_data == NULL)
4068 debug_log("data is NULL");
4072 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4074 ug_data->m_is_multi_touch = FALSE;
4076 if (ug_data->scroller_locked) {
4077 ug_data->scroller_locked = FALSE;
4078 debug_log("<<unlock scroller>>");
4079 debug_log("<<lock webview>>");
4083 static void _webview_multi_down_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info)
4086 if (_g_ug_data == NULL)
4090 debug_log("data is NULL");
4094 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4096 ug_data->m_is_multi_touch = TRUE;
4098 if (ug_data->scroller_locked == FALSE) {
4099 ug_data->scroller_locked = TRUE;
4100 debug_log("<<lock scroller>>");
4101 debug_log("<<unlock webview>>");
4105 static void _webview_policy_navigation_decide_cb(void *data, Evas_Object *obj, void *event_info)
4109 debug_log("data is NULL");
4113 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4115 if (ug_data->b_load_finished == EINA_TRUE) {
4116 Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info;
4117 ewk_policy_decision_ignore(policy_decision);
4119 debug_log("url:%s", ewk_policy_decision_url_get(policy_decision));
4120 debug_log("scheme:%s", ewk_policy_decision_scheme_get(policy_decision));
4121 debug_log("cookie:%s", ewk_policy_decision_cookie_get(policy_decision));
4122 debug_log("host:%s", ewk_policy_decision_host_get(policy_decision));
4123 debug_log("response_mime:%s", ewk_policy_decision_response_mime_get(policy_decision));
4125 char *url = (char *)ewk_policy_decision_url_get(policy_decision);
4127 if ((strncmp(url, "http://", 7) == 0) ||
4128 (strncmp(url, "https://", 8) == 0) ||
4129 (strncmp(url, "ftp://", 6) == 0) ||
4130 (strncmp(url, "mms://", 6) == 0) ||
4131 (strncmp(url, "file://", 7) == 0) ||
4132 (strncmp(url, "rtsp://", 7) == 0) ||
4133 (strncmp(url, "wap://", 6) == 0)) {
4135 service_h service = NULL;
4136 ret = service_create(&service);
4137 debug_log("service_create: %d", ret);
4139 debug_log("service create failed");
4142 ret = service_set_operation(service, SERVICE_OPERATION_VIEW);
4143 debug_log("service_set_operation: %d", ret);
4144 ret = service_set_uri(service, url);
4145 debug_log("service_set_uri: %d", ret);
4146 ret = service_send_launch_request(service, NULL, NULL);
4147 debug_log("service_send_launch_request: %d", ret);
4148 ret = service_destroy(service);
4149 debug_log("service_destroy: %d", ret);
4152 if (strncmp(url, "tel:", 4) == 0) {
4153 char refined_num[MAX_STR_LEN] = { 0, };
4156 while (url[i] != '\0') {
4157 if (url[i] >= '0' && url[i] <= '9')
4158 refined_num[j++] = url[i];
4162 char *number = refined_num;
4163 debug_log("number: %s", number);
4166 service_h service = NULL;
4167 char telnum[255] = { 0, };
4168 ret = service_create(&service);
4169 debug_log("service_create: %d", ret);
4171 debug_log("service create failed");
4174 ret = service_set_operation(service, SERVICE_OPERATION_CALL);
4175 debug_log("service_set_operation: %d", ret);
4176 snprintf(telnum, sizeof(telnum), "tel:%s", number); /* Number to make a call */
4177 ret = service_set_uri(service, telnum);
4178 debug_log("service_set_uri: %d", ret);
4179 ret = service_add_extra_data(service, "ctindex", "-1"); /* If you don't know ctindex, you don't have to add it. */
4180 debug_log("service_add_extra_data: %d", ret);
4181 ret = service_send_launch_request(service, NULL, NULL);
4182 debug_log("service_send_launch_request: %d", ret);
4183 ret = service_destroy(service);
4184 debug_log("service_destroy: %d", ret);
4187 if (strncmp(url, "mailto:", 7) == 0) {
4189 service_h service = NULL;
4190 ret = service_create(&service);
4191 debug_log("service_create: %d", ret);
4193 debug_log("service create failed");
4197 char rtype[10] = { 0, };
4198 snprintf(rtype, sizeof(rtype), "%d", RUN_COMPOSER_EXTERNAL);
4200 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_RUN_TYPE, rtype);
4201 debug_log("service_add_extra_data: %d", ret);
4202 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_TO, &url[7]);
4203 debug_log("service_add_extra_data: %d", ret);
4205 ug_data->ug_composer = create_ug(UG_NAME_EMAIL_COMPOSER, service, ug_data);
4207 ret = service_destroy(service);
4208 debug_log("service_destroy: %d", ret);
4213 /* Double_Scroller */
4214 static void _outter_scroller_bottom_hit_cb(void *data, Evas_Object *obj, void *event_info)
4218 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4219 int res = email_engine_check_body_download(ug_data->email_data->mail_id);
4221 if (ug_data->is_main_scroller_scrolling && res != 0) {
4222 debug_log("Main scroller hold push");
4223 elm_object_scroll_freeze_push(ug_data->scroller); //stop
4224 ewk_view_vertical_panning_hold_set(ug_data->webview, EINA_FALSE); //restart
4225 ug_data->is_main_scroller_scrolling = EINA_FALSE;
4226 ug_data->is_webview_scrolling = EINA_TRUE;
4230 static void _outter_scroller_top_hit_cb(void *data, Evas_Object *obj, void *event_info)
4235 static void _outter_scroller_scroll_cb(void *data, Evas_Object *obj, void *event_info)
4238 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4240 ug_data->is_main_scroller_scrolling = EINA_TRUE;
4243 static void _mbe_added_cb(void *data, Evas_Object *obj, void *event_info)
4248 static void _mbe_selected_cb(void *data, Evas_Object *obj, void *event_info)
4251 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4252 email_address_info_t *addrs_info = NULL;
4253 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
4254 debug_log("selected item:%s", elm_object_item_text_get(item));
4256 addrs_info = elm_object_item_data_get(item);
4259 EMAIL_CONTACT_LIST_INFO_S *contact_list_item = NULL;
4260 contact_list_item = (EMAIL_CONTACT_LIST_INFO_S *)_contact_search_by_email(ug_data, addrs_info->address);
4262 if (ug_data->con_popup != NULL) {
4263 evas_object_del(ug_data->con_popup);
4264 ug_data->con_popup = NULL;
4267 ug_data->con_popup = elm_ctxpopup_add(ug_data->navi_bar);
4268 if (ug_data->con_popup == NULL) {
4269 debug_log("cannot create context popup");
4273 if (contact_list_item) {
4274 debug_log("Contact Item Exist: index[%d]", contact_list_item->index);
4275 char index[10] = { 0, };
4276 snprintf(index, sizeof(index), "%d", contact_list_item->index);
4278 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_VIEW_CONTACT"), NULL, _ctxpopup_detail_contact_cb, g_strdup(index));
4279 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SEND_EMAIL"), NULL, _ctxpopup_send_email_cb, addrs_info->address);
4280 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_BLOCK"), NULL, _ctxpopup_add_block_rule_cb, addrs_info->address);
4281 _delete_contacts_list(contact_list_item);
4283 elm_ctxpopup_item_append(ug_data->con_popup, dgettext("sys_string", "IDS_COM_OPT_ADD_TO_CONTACTS"), NULL, _ctxpopup_select_contact_mode_email_cb, addrs_info->address);
4284 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_SEND_EMAIL"), NULL, _ctxpopup_send_email_cb, addrs_info->address);
4285 elm_ctxpopup_item_append(ug_data->con_popup, _("IDS_EMAIL_OPT_BLOCK"), NULL, _ctxpopup_add_block_rule_cb, addrs_info->address);
4288 evas_pointer_canvas_xy_get(ug_data->evas, &x, &y);
4289 evas_object_move(ug_data->con_popup, x, y);
4290 evas_object_show(ug_data->con_popup);
4293 static void _destroy_down_progress_cb(void *data, Evas_Object *obj, void *event_info)
4298 debug_log("data is NULL");
4302 EmailViewerUGD *ug_data = _g_ug_data;
4303 EmailViewerPrivate *priv = ug_data->email_data;
4305 email_engine_stop_working(ug_data->account_id, priv->email_handle);
4307 if (ug_data->pb_notify) {
4308 evas_object_del(ug_data->pb_notify);
4309 ug_data->pb_notify = NULL;
4312 if (ug_data->pb_notify_lb) {
4313 evas_object_del(ug_data->pb_notify_lb);
4314 ug_data->pb_notify_lb = NULL;
4318 if (priv->att_file_id) {
4319 free(priv->att_file_id);
4320 priv->att_file_id = NULL;
4323 priv->file_size = 0;
4324 priv->attachment_id = -1;
4325 priv->multi_body = FALSE;
4329 static void _init_viewer_data(int account_id, int mail_id, char *srv_mail_id, EmailViewerUGD *ug_data)
4332 EmailViewerPrivate *priv = NULL;
4333 EmailViewerProp *prop = NULL;
4334 email_address_info_list_t *addrs_info_list = NULL;
4336 /* Create Email Viewer Private Structure */
4337 if (ug_data->email_data) {
4338 if (ug_data->email_data->mail_info) {
4339 debug_log("mail_info freed");
4340 email_free_mail_data(&(ug_data->email_data->mail_info), 1);
4341 ug_data->email_data->mail_info = NULL;
4344 if (ug_data->email_data->attachment_info && ug_data->email_data->attachment_count > 0) {
4345 debug_log("attachment_info freed p[%p] n[%d]", ug_data->email_data->attachment_info, ug_data->email_data->attachment_count);
4346 email_free_attachment_data(&(ug_data->email_data->attachment_info), ug_data->email_data->attachment_count);
4347 ug_data->email_data->attachment_info = NULL;
4348 ug_data->email_data->attachment_count = 0;
4351 memset(ug_data->email_data, 0x0, sizeof(EmailViewerPrivate));
4352 priv = ug_data->email_data;
4354 priv = (EmailViewerPrivate *)malloc(sizeof(EmailViewerPrivate));
4355 memset(priv, 0x0, sizeof(EmailViewerPrivate));
4356 ug_data->email_data = priv;
4359 /* Create Email Viewer Property Structure */
4360 if (ug_data->property) {
4361 if (ug_data->property->attachments) {
4363 LIST_ITER_START(i, ug_data->property->attachments) {
4364 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, ug_data->property->attachments);
4371 g_list_free(ug_data->property->attachments);
4373 memset(ug_data->property, 0x0, sizeof(EmailViewerProp));
4374 prop = ug_data->property;
4376 prop = (EmailViewerProp *)malloc(sizeof(EmailViewerProp));
4377 memset(prop, 0x0, sizeof(EmailViewerProp));
4378 ug_data->property = prop;
4381 /* Set account ID */
4382 priv->account_id = account_id;
4383 prop->account_id = account_id;
4386 priv->mail_id = mail_id;
4387 prop->mail_id = mail_id;
4389 priv->mailbox_id = ug_data->mailbox_id;
4390 prop->src_box = ug_data->mailbox_name;
4391 debug_log("mailbox_name [%s]", ug_data->mailbox_name);
4393 /* Get mail_info from service, and fill property */
4394 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
4395 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
4398 email_get_address_info_list(priv->mail_id, &addrs_info_list);
4400 if (addrs_info_list) {
4401 ug_data->from_list = addrs_info_list->from;
4402 ug_data->to_list = addrs_info_list->to;
4403 ug_data->cc_list = addrs_info_list->cc;
4404 ug_data->bcc_list = addrs_info_list->bcc;
4405 priv->addrs_info_list = addrs_info_list;
4408 ug_data->option_header_opened = 0;
4411 static int _init_webview_data(EmailViewerUGD *ug_data)
4415 EmailViewerWebview *wvd;
4417 if (ug_data->webview_data == NULL) {
4418 wvd = (EmailViewerWebview *)malloc(sizeof(EmailViewerWebview));
4419 memset(wvd, 0x0, sizeof(EmailViewerWebview));
4420 ug_data->webview_data = wvd;
4423 if (STR_VALID(ug_data->property->charset)) {
4424 ug_data->webview_data->charset = g_strdup(ug_data->property->charset);
4425 debug_log("charset:%s", ug_data->webview_data->charset);
4427 ug_data->webview_data->charset = DEFAULT_CHARSET;
4428 debug_log("charset:%s", ug_data->webview_data->charset);
4434 static Eina_Bool _check_body_download(void *data)
4438 debug_log("data is NULL");
4439 return ECORE_CALLBACK_CANCEL;
4442 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
4444 _create_tab_bar(ug_data);
4446 /* check mail body downloaded */
4447 int body_download_status = ug_data->property->body_download;
4449 if (body_download_status == 0) { //EMAIL_BODY_DOWNLOAD_STATUS_NONE
4450 debug_log("need body download");
4451 ug_data->b_noc = 1; /* Double_Scroller */
4453 if (ug_data->noc_bx) {
4454 debug_log("no content layout exist");
4455 evas_object_show(ug_data->noc_bx);
4456 elm_object_text_set(ug_data->dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_MESSAGE"));
4457 evas_object_show(ug_data->dn_btn);
4458 elm_box_pack_end(ug_data->main_bx, ug_data->noc_bx);
4460 /* add body download button */
4461 ug_data->noc_bx = _load_edj(ug_data->navi_bar, EV_THEME_PATH, "layout.email.no_content");
4462 if (ug_data->noc_bx == NULL) {
4463 debug_log("Cannot load edj");
4464 return ECORE_CALLBACK_CANCEL;
4467 evas_object_size_hint_align_set(ug_data->noc_bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
4468 evas_object_size_hint_weight_set(ug_data->noc_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
4469 evas_object_show(ug_data->noc_bx);
4470 elm_box_pack_end(ug_data->main_bx, ug_data->noc_bx);
4472 Evas_Object *dn_btn = elm_button_add(ug_data->navi_bar);
4473 /*elm_object_theme_set(dn_btn, ug_data->theme);*/
4474 elm_object_style_set(dn_btn, "text_only/style2");
4475 elm_object_text_set(dn_btn, _("IDS_EMAIL_BODY_DOWNLOAD_MESSAGE"));
4476 evas_object_smart_callback_add(dn_btn, "clicked", _body_down_cb, (void *)ug_data);
4477 evas_object_show(dn_btn);
4478 ug_data->dn_btn = dn_btn;
4480 elm_object_part_content_set(ug_data->noc_bx, "btn", ug_data->dn_btn);
4481 debug_log("no content layout created");
4484 elm_object_focus_set(ug_data->noc_bx, EINA_TRUE);
4485 if (ug_data->timer) {
4486 ecore_timer_del(ug_data->timer);
4487 ug_data->timer = NULL;
4490 ug_data->timer = ecore_timer_add(0.0, viewer_send_message, ug_data);
4491 } else if (body_download_status == 1) { //EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED
4492 debug_log("check mail downloaded - ok");
4494 _create_body(ug_data);
4495 } else if (body_download_status == 2) { //EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED
4497 debug_log("Partial Body");
4498 ug_data->b_partial_body = 1;
4499 _create_body(ug_data);
4500 _create_partial_body_dn_btn(ug_data);
4503 return ECORE_CALLBACK_CANCEL;
4506 static int _update_attachment_info(EmailViewerUGD *ug_data, int index)
4509 EmailViewerProp *prop = ug_data->property;
4512 int attach_index = 0;
4514 /* update attachment information */
4515 LIST_ITER_START(i, prop->attachments) {
4516 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, prop->attachments);
4518 if (info && !info->inline_content) {
4519 debug_log("info->index[%d] index[%d]", info->index, index);
4521 if (info->index == index) {
4522 info->download_yn = TRUE;
4523 info->path = email_engine_get_attachment_path(info->attach_id);
4527 if (prop->real_att_len > 1) {
4528 Evas_Object *thumbnail = viewer_make_thumbnail(info->path, ug_data->attach_ex_bk[j]);
4529 Evas_Object *content = elm_object_part_content_unset(ug_data->attach_ex_bk[j], "elm.icon");
4530 evas_object_del(content);
4531 elm_object_part_content_set(ug_data->attach_ex_bk[j], "elm.icon", thumbnail);
4532 evas_object_show(thumbnail);
4534 Evas_Object *thumbnail = viewer_make_thumbnail(info->path, ug_data->attach_hd_bk);
4535 Evas_Object *content = elm_object_part_content_unset(ug_data->attach_hd_bk, "elm.icon");
4536 evas_object_del(content);
4537 elm_object_part_content_set(ug_data->attach_hd_bk, "elm.icon", thumbnail);
4538 evas_object_show(thumbnail);
4548 debug_log("return id[%d]", attach_index);
4550 return attach_index;
4553 static int _get_attachment_info_index(EmailViewerUGD *ug_data, int index)
4557 EmailViewerProp *prop = ug_data->property;
4559 int attach_index = 0;
4561 /* update attachment information */
4562 LIST_ITER_START(i, prop->attachments) {
4563 EmailAttachmentType *info = (EmailAttachmentType *)LIST_ITER_GET_DATA(i, prop->attachments);
4565 debug_log("info->index[%d] index[%d]", info->index, index);
4566 if (info->index == index) {
4573 debug_log("return id[%d]", attach_index);
4575 return attach_index;
4578 static void _show_select_info(EmailViewerUGD *ug_data, char *str)
4582 if (ug_data->select_info != NULL) {
4583 evas_object_del(ug_data->select_info);
4584 ug_data->select_info = NULL;
4587 if (ug_data->selectioninfo_layout != NULL) {
4588 evas_object_del(ug_data->selectioninfo_layout);
4589 ug_data->selectioninfo_layout = NULL;
4592 ug_data->select_info = elm_notify_add(ug_data->win_main);
4593 elm_notify_orient_set(ug_data->select_info, ELM_NOTIFY_ORIENT_BOTTOM);
4595 ug_data->selectioninfo_layout = elm_layout_add(ug_data->layout_main);
4596 elm_object_content_set(ug_data->select_info, ug_data->selectioninfo_layout);
4598 elm_layout_theme_set(ug_data->selectioninfo_layout, "standard", "selectioninfo", "vertical/bottom_64");
4600 edje_object_part_text_set(_EDJ(ug_data->selectioninfo_layout), "elm.text", str);
4601 elm_notify_timeout_set(ug_data->select_info, 3);
4602 evas_object_show(ug_data->select_info);
4605 static void _save_attachment(EmailViewerUGD *ug_data, int index)
4608 EmailViewerPrivate *priv = ug_data->email_data;
4609 EmailViewerProp *prop = ug_data->property;
4610 char newpath[MAX_STR_LEN] = { 0, };
4612 RETURN_IF_FAIL(prop->attachments != NULL);
4613 EmailAttachmentType *info = g_list_nth_data(prop->attachments, index);
4616 debug_log("EmailAttachmentType *info is NULL");
4620 if (!info->download_yn) {
4621 unsigned handle = 0;
4622 gboolean res = FALSE;
4624 if (ug_data->progress_bar[index + 1] != NULL) {
4625 debug_log("Already getting downloaded...!");
4626 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4627 _("IDS_EMAIL_POP_ALREADY_DOWNLOADING_T_HEADER"), 1,
4628 dgettext("sys_string", "IDS_COM_SK_OK"),
4629 _popup_response_cb, NULL, NULL, NULL);
4633 debug_log("Need attachment download");
4634 /* download attachment */
4635 priv->b_att_save = TRUE;
4637 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4640 priv->download_all_cnt++;
4641 debug_log("Assigning Handle[%d] Index[%d] download_all_cnt[%d]", handle, index, priv->download_all_cnt);
4642 priv->download_all_email_handle[index] = handle;
4643 _create_down_progress_ex(index, EMAIL_VIEWER_PROGRESSBAR_ATT);
4644 ug_data->display_download_result = TRUE;
4646 priv->b_att_save = FALSE;
4647 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4648 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
4649 dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
4656 if (info && STR_VALID(info->path)) {
4658 debug_log("path[%s]", info->path);
4659 ret = email_attachments_save_file(info->path, newpath, NULL);
4660 if (ret == EMAIL_EXT_SAVE_ERR_NONE) {
4661 char str[128] = { 0, };
4662 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
4663 /*_show_select_info(ug_data, str);*/
4664 ret = status_message_post(str);
4666 debug_log("status_message_post failed: %d", ret);
4671 static void _show_attachment(EmailViewerUGD *ug_data, int index)
4674 EmailViewerPrivate *priv = ug_data->email_data;
4675 EmailViewerProp *prop = ug_data->property;
4676 EmailAttachmentType *info = g_list_nth_data(prop->attachments, index);
4677 char newpath[MAX_STR_LEN] = { 0, };
4680 debug_log("EmailAttachmentType *info is NULL");
4684 debug_log("attach_id:%d, index:%d, name(%s), path(%s), size:%d, download_yn:%d, drm:%d, inline_content:%d",
4685 info->attach_id, info->index, info->name, info->path, (gint) info->size, info->download_yn, info->drm, info->inline_content);
4687 if (!info->download_yn) {
4688 unsigned handle = 0;
4689 gboolean res = FALSE;
4690 debug_log("Need attachment download");
4692 priv->b_att_open = TRUE;
4694 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4697 priv->download_all_email_handle[index] = handle;
4698 priv->download_all_cnt++;
4699 _create_down_progress_ex(index, EMAIL_VIEWER_PROGRESSBAR_ATT);
4701 priv->b_att_open = FALSE;
4702 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4703 _("IDS_EMAIL_POP_UNABLE_TO_OPEN_ATTACHMENT"), 1,
4704 dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
4710 gboolean res = FALSE;
4711 res = email_attachments_save_file(info->path, newpath, NULL);
4712 debug_log("Result:%d, Saved Path:%s", res, newpath);
4714 if (res == EMAIL_EXT_SAVE_ERR_NONE) {
4715 char str[128] = { 0, };
4716 snprintf(str, sizeof(str), "%s", dgettext("sys_string", "IDS_COM_POP_SAVED"));
4717 /*_show_select_info(ug_data, str);*/
4718 int ret = status_message_post(str);
4720 debug_log("status_message_post failed: %d", ret);
4722 if (g_str_has_suffix(info->path, ".vcs")) {
4724 int calendar_id = 1;
4725 calendar_svc_connect();
4726 nResult = calendar_svc_calendar_import(newpath, calendar_id);
4728 debug_log("check return value of calendar_svc_util_register_vcs_file for %s - %d", newpath, nResult);
4729 if (nResult != CAL_SUCCESS) {
4730 debug_log("Failed to import path(%s) to id(%d)", newpath, calendar_id);
4733 calendar_svc_close();
4735 media_file_register(newpath);
4736 } else if (res == EMAIL_EXT_SAVE_ERR_ALREADY_EXIST && !ug_data->display_download_result) {
4737 _create_notify(ug_data, _("IDS_EMAIL_POP_ALERT"),
4738 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 0,
4739 NULL, NULL, NULL, NULL, _popup_response_cb);
4742 debug_log("display_download_result:%d", ug_data->display_download_result);
4743 if (ug_data->display_download_result) {
4744 if (res == EMAIL_EXT_SAVE_ERR_NONE || res == EMAIL_EXT_SAVE_ERR_ALREADY_EXIST) {
4746 service_h service = NULL;
4747 ret = service_create(&service);
4748 debug_log("service_create: %d", ret);
4750 debug_log("service create failed");
4753 ret = service_set_operation(service, SERVICE_OPERATION_VIEW);
4754 debug_log("service_set_operation: %d", ret);
4755 ret = service_set_uri(service, newpath);
4756 debug_log("service_set_uri: %d", ret);
4757 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_VIDEO_PLAYER_LAUNCH_APP, "email");
4758 debug_log("service_add_extra_data: %d", ret);
4759 ret = service_send_launch_request(service, NULL, NULL);
4760 debug_log("service_send_launch_request: %d", ret);
4761 if (ret != SERVICE_ERROR_NONE) {
4762 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
4763 _("IDS_EMAIL_POP_THIS_ATTACHMENT_CANNOT_BE_DISPLAYED"), 0,
4764 NULL, NULL, NULL, NULL, _popup_response_cb);
4766 ret = service_destroy(service);
4767 debug_log("service_destroy: %d", ret);
4769 debug_log("EMAIL_EXT_SAVE_ERR_UNKNOWN");
4774 static void _save_attachment_all(EmailViewerUGD *ug_data)
4777 EmailViewerPrivate *priv = ug_data->email_data;
4778 EmailViewerProp *prop = ug_data->property;
4779 EmailAttachmentType *info = NULL;
4782 int att_len = g_list_length(prop->attachments);
4784 if (priv->b_all_att_save)
4788 if (ug_data->forward_ctr_it)
4789 elm_object_item_disabled_set(ug_data->forward_ctr_it, EINA_TRUE);
4792 for (i = 0; i < att_len; i++) {
4793 info = g_list_nth_data(prop->attachments, i);
4795 if (info && !info->inline_content) {
4796 if (!info->download_yn) {
4797 if (ug_data->progress_bar_ly[i + 1] == NULL) {
4798 unsigned handle = 0;
4799 gboolean res = FALSE;
4800 debug_log("Need attachment [%d] download", i);
4802 res = email_engine_attachment_download(priv->account_id, priv->mail_id, info->index, &handle);
4805 priv->download_all_cnt++;
4806 priv->download_all_email_handle[i] = handle;
4807 priv->b_all_att_save = TRUE;
4809 debug_log("attach_onoff_flag:%d", ug_data->attach_onoff_flag);
4810 if (priv->b_all_att_save) {
4811 if (ug_data->attach_onoff_flag == 0) {
4812 _attachment_item_collapse_cb(ug_data->attach_hd_bk, NULL, NULL, NULL);
4816 _create_down_progress_ex(i, EMAIL_VIEWER_PROGRESSBAR_ATT);
4817 ug_data->display_download_result = TRUE;
4819 priv->download_all_fail_cnt++;
4826 debug_log("download [%d], failed [%d]", priv->download_all_cnt, priv->download_all_fail_cnt);
4829 static void _dbus_receiver_setup(EmailViewerUGD *ug_data)
4833 int ret = e_dbus_init();
4834 debug_log("ret: %d", ret);
4838 if (_g_viewer_dbus_conn == NULL) {
4840 dbus_error_init(&derror);
4841 _g_viewer_dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
4843 if (_g_viewer_dbus_conn == NULL) {
4844 debug_log("e_dbus_bus_get return NULL");
4848 if (e_dbus_request_name(_g_viewer_dbus_conn, "User.Email.StorageChange", 0, NULL, NULL) == NULL) {
4849 debug_critical("Failed to e_dbus_request_name()");
4853 if (_g_viewer_signal_handler_storage != NULL) {
4854 debug_log("_g_viewer_signal_handler_storage != NULL");
4857 _g_viewer_signal_handler_storage = e_dbus_signal_handler_add(_g_viewer_dbus_conn, NULL,
4858 "/User/Email/StorageChange",
4859 "User.Email.StorageChange",
4860 "email", _on_edbus_event_email_viewer_receive, ug_data);
4862 if (_g_viewer_signal_handler_storage == NULL) {
4863 debug_log("Failed to e_dbus_signal_handler_add()");
4868 if (e_dbus_request_name(_g_viewer_dbus_conn, "User.Email.NetworkStatus", 0, NULL, NULL) == NULL) {
4869 debug_log("Failed to e_dbus_request_name()");
4873 if (_g_viewer_signal_handler_network != NULL) {
4874 debug_log("_g_viewer_signal_handler_network != NULL");
4877 _g_viewer_signal_handler_network = e_dbus_signal_handler_add(_g_viewer_dbus_conn, NULL,
4878 "/User/Email/NetworkStatus",
4879 "User.Email.NetworkStatus",
4880 "email", _on_edbus_event_email_viewer_receive, ug_data);
4882 if (_g_viewer_signal_handler_network == NULL) {
4883 debug_log("Failed to e_dbus_signal_handler_add()");
4889 static void _dbus_receiver_remove(EmailViewerUGD *ug_data)
4893 if (_g_viewer_signal_handler_storage != NULL) {
4894 e_dbus_signal_handler_del(_g_viewer_dbus_conn, _g_viewer_signal_handler_storage);
4895 _g_viewer_signal_handler_storage = NULL;
4898 if (_g_viewer_signal_handler_network != NULL) {
4899 e_dbus_signal_handler_del(_g_viewer_dbus_conn, _g_viewer_signal_handler_network);
4900 _g_viewer_signal_handler_network = NULL;
4903 if (e_dbus_release_name(_g_viewer_dbus_conn, "User.Email.StorageChange", NULL, NULL) == NULL) {
4904 debug_critical("e_dbus_release_name to failed");
4907 if (e_dbus_release_name(_g_viewer_dbus_conn, "User.Email.NetworkStatus", NULL, NULL) == NULL) {
4908 debug_critical("e_dbus_release_name to failed");
4911 if (_g_viewer_dbus_conn != NULL) {
4912 /*e_dbus_connection_close(_g_viewer_dbus_conn);*/
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 /*_show_select_info(ug_data, str);*/
5072 int ret = status_message_post(str);
5074 debug_log("status_message_post failed: %d", ret);
5077 if (viewer_get_internal_mail_info(ug_data->property, ug_data->email_data)) {
5078 viewer_make_internal_mail(ug_data->property, ug_data->email_data);
5080 /* create att and body */
5081 if (ug_data->b_partial_body) {
5086 elm_scroller_region_get(ug_data->scroller, &scr_x, &scr_y, &scr_w, &scr_h);
5087 debug_log("scroller region> x[%d] y[%d] w[%d] h[%d]", scr_x, scr_y, scr_w, scr_h);
5089 elm_box_unpack(ug_data->main_bx, ug_data->partial_dn_btn_bx);
5090 if (ug_data->partial_dn_btn) {
5091 evas_object_del(ug_data->partial_dn_btn);
5092 ug_data->partial_dn_btn = NULL;
5094 if (ug_data->partial_dn_btn_bx) {
5095 evas_object_del(ug_data->partial_dn_btn_bx);
5096 ug_data->partial_dn_btn_bx = NULL;
5099 if (ug_data->property->has_html) {
5100 ug_data->webview_data->body_type = BODY_TYPE_HTML;
5101 ug_data->webview_data->uri = ug_data->property->body_uri;
5103 ug_data->webview_data->body_type = BODY_TYPE_TEXT;
5104 ug_data->webview_data->text_content = ug_data->property->body;
5107 viewer_set_webview_content(ug_data, 1);
5109 elm_object_focus_set(ug_data->ly_subject, EINA_TRUE);
5110 elm_scroller_region_show(ug_data->scroller, scr_x, scr_y, scr_w, scr_h);
5113 if (ug_data->property->has_attachment)
5114 ug_data->got_att = 1;
5116 ug_data->got_att = 0;
5118 /* pack attachment if it exist */
5119 if (ug_data->got_att) {
5120 _create_attach(ug_data);
5123 _create_body(ug_data);
5126 debug_log("email_handle or mail_id is different");
5127 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5128 debug_log("expected email_handle [%d], received email_handle [%d]", priv->email_handle, data3);
5132 case NOTI_DOWNLOAD_BODY_FAIL:
5133 /* DATA1[mail_id] DATA2[NULL] DATA3[handle_id] */
5134 debug_log("receive noti, DOWNLOAD_BODY_FAIL");
5135 if (priv->email_handle == data3 && priv->mail_id == data1) {
5136 priv->email_handle = 0;
5138 /* delete progress */
5139 if (ug_data->pb_notify) {
5140 _destroy_down_progress_cb(NULL, NULL, NULL);
5143 char *err_msg = _get_service_fail_type(data4);
5144 snprintf(fail_msg, sizeof(fail_msg), "%s<br>%s", _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), err_msg);
5145 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"),
5146 fail_msg, 1, dgettext("sys_string", "IDS_COM_SK_OK"),
5147 _popup_response_cb, NULL, NULL, NULL);
5150 debug_log("email_handle or mail_id is different");
5151 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5152 debug_log("expected email_handle [%d], received email_handle [%d]", priv->email_handle, data3);
5156 case NOTI_DOWNLOAD_ATTACH_START:
5157 /* DATA1[mail_id] DATA2[file_id] DATA3[attachment_id] DATA4[percentage] */
5158 debug_log("receive noti, DOWNLOAD_ATTACHMENT");
5159 if (priv->mail_id == data1) {
5160 priv->att_file_id = g_strdup(data2);
5161 priv->attachment_id = data3;
5164 /* Set the progressbar of particular attachment_id */
5165 _set_value_down_progress_by_index(0.0, priv->attachment_id);
5168 double per = (double)data4 / 100.0;
5169 /* Set the progressbar of particular attachment_id */
5170 _set_value_down_progress_by_index(per, priv->attachment_id);
5173 debug_log("mail_id is different");
5174 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5178 case NOTI_DOWNLOAD_ATTACH_FINISH:
5179 /* DATA1[mail_id] DATA2[NULL] DATA3[attachment_id] */
5180 debug_log("receive noti, DOWNLOAD_ATTACH_FINISH");
5182 if (priv->mail_id == data1) {
5183 int attach_index = 0;
5184 int attachment_id = (int)data3;
5185 debug_log("download_all_cnt [%d]", priv->download_all_cnt);
5187 if (priv->download_all_cnt > 0) {
5188 _set_value_down_progress_by_index(1.0, attachment_id);
5189 attach_index = _update_attachment_info(ug_data, attachment_id);
5190 if (priv->b_all_att_save) {
5191 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5192 _save_attachment(ug_data, attach_index);
5193 if (priv->download_all_cnt == 0) {
5194 priv->b_all_att_save = FALSE;
5197 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5198 _show_attachment(ug_data, attach_index);
5202 debug_log("mail_id or attachment_id is different");
5203 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5207 case NOTI_DOWNLOAD_ATTACH_FAIL:
5208 /* DATA1[mail_id] DATA2[NULL] DATA3[attachment_id] */
5209 debug_log("receive noti, DOWNLOAD_ATTACH_FAIL");
5210 if (priv->mail_id == data1) {
5211 int attach_index = _get_attachment_info_index(ug_data, data3);
5212 debug_log("download_all_cnt[%d]", priv->download_all_cnt);
5214 if (priv->download_all_cnt > 0) {
5215 if (ug_data->progress_bar[data3] != NULL && data4 != EMAIL_ERROR_CANCELLED)
5216 _destroy_down_progress_ex((void *)attach_index, NULL, NULL);
5218 debug_log("Download already cancelled, No need to destroy again..!");
5220 if (data4 != EMAIL_ERROR_CANCELLED && ug_data->ug_composer == NULL) {
5221 char *err_msg = _get_service_fail_type(data4);
5222 snprintf(fail_msg, sizeof(fail_msg), "%s<br>%s", _("IDS_EMAIL_POP_UNABLE_TO_DOWNLOAD"), err_msg);
5223 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"), fail_msg, 1,
5224 dgettext("sys_string", "IDS_COM_SK_OK"),
5225 _popup_response_cb, NULL, NULL, NULL);
5229 if (priv->b_all_att_save && priv->download_all_cnt == 0) {
5230 priv->b_all_att_save = FALSE;
5234 debug_log("mail_id is different");
5235 debug_log("expected mail_id [%d], received mail_id [%d]", priv->mail_id, data1);
5240 debug_log("unknown type");
5244 debug_log("receive data error: %s", error.message);
5245 dbus_error_free(&error);
5247 /*return DBUS_HANDLER_RESULT_HANDLED;*/
5250 /*return DBUS_HANDLER_RESULT_HANDLED;*/
5254 static void _delete_contacts_list(EMAIL_CONTACT_LIST_INFO_S *contacts_list_item)
5258 if (contacts_list_item) {
5259 #ifndef _NEW_CT_SVC_API
5260 g_free(contacts_list_item->first_name);
5261 contacts_list_item->first_name = NULL;
5262 g_free(contacts_list_item->last_name);
5263 contacts_list_item->last_name = NULL;
5265 g_free(contacts_list_item->display);
5266 contacts_list_item->display = NULL;
5268 g_free(contacts_list_item->email_address);
5269 contacts_list_item->email_address = NULL;
5270 g_free(contacts_list_item);
5271 contacts_list_item = NULL;
5275 static void *_contact_search_by_email(EmailViewerUGD *ug_data, const char *search_word)
5278 if (!ug_data || !_g_ug_data) {
5279 debug_log("data is NULL");
5283 int ret = CTS_SUCCESS;
5284 CTSiter *iter = NULL;
5286 EMAIL_CONTACT_LIST_INFO_S *contacts_list_item = NULL;
5287 contacts_svc_connect();
5289 debug_log("search_word = %s", search_word);
5291 if (contacts_svc_get_list_with_str(CTS_LIST_EMAILINFOS_WITH_EMAIL, search_word, &iter) != CTS_SUCCESS) {
5295 ret = contacts_svc_iter_next(iter);
5297 if (CTS_SUCCESS == ret) {
5298 CTSvalue *row_info = NULL;
5300 row_info = contacts_svc_iter_get_info(iter);
5302 contacts_list_item = (EMAIL_CONTACT_LIST_INFO_S *)calloc(1, sizeof(EMAIL_CONTACT_LIST_INFO_S));
5304 int index = contacts_svc_value_get_int(row_info, CTS_LIST_EMAIL_CONTACT_ID_INT);
5306 contacts_list_item->index = index;
5307 #ifndef _NEW_CT_SVC_API
5308 contacts_list_item->first_name = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_FIRST_STR));
5309 contacts_list_item->last_name = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_LAST_STR));
5311 contacts_list_item->display = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR));
5313 contacts_list_item->email_address = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_ADDR_STR));
5315 #ifndef _NEW_CT_SVC_API
5316 char *first = contacts_list_item->first_name;
5317 char *last = contacts_list_item->last_name;
5318 char *display = g_strdup(contacts_svc_value_get_str(row_info, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR));
5321 if (first != NULL && last != NULL) {
5322 if (CTS_ORDER_NAME_FIRSTLAST == contacts_svc_get_order(CTS_ORDER_OF_DISPLAY)) {
5323 display = g_strconcat(first, " ", last, NULL);
5325 display = g_strconcat(last, " ", first, NULL);
5327 } else if (first != NULL || last != NULL) {
5328 display = (first != NULL) ? g_strdup(first) : g_strdup(last);
5330 display = g_strdup(" ");
5334 snprintf(contacts_list_item->display_name, sizeof(contacts_list_item->display_name), "%s", display);
5337 snprintf(contacts_list_item->display_name, sizeof(contacts_list_item->display_name), "%s", contacts_list_item->display);
5342 contacts_svc_value_free(row_info);
5345 contacts_svc_iter_remove(iter);
5348 contacts_svc_disconnect();
5350 return contacts_list_item;
5353 static void _set_value_down_progress(double val)
5358 debug_log("data is NULL");
5361 char buf[30] = { 0, };
5362 EmailViewerUGD *ug_data = _g_ug_data;
5364 sprintf(buf, "%s: %d", dgettext("sys_string", "IDS_COM_POP_DOWNLOADING"), (int)val);
5366 if (ug_data->pb_notify_lb) {
5367 elm_progressbar_value_set(ug_data->pb_notify_lb, val);
5368 elm_object_text_set(ug_data->pb_notify_lb, buf);
5372 static void _set_value_down_progress_by_index(double val, int index)
5377 debug_log("data is NULL");
5381 EmailViewerUGD *ug_data = _g_ug_data;
5382 EmailViewerProp *prop = ug_data->property;
5385 debug_log("val(%f) is MINUS");
5389 if (index < 0 || index >= ATTACH_MAX) {
5390 debug_log("index(%d) is overflowed");
5395 debug_log("prop is NULL");
5399 if (prop->attachments == NULL) {
5400 debug_log("attachments is NULL");
5404 int per = val * 100;
5405 int attach_index = _get_attachment_info_index(ug_data, index);
5406 EmailAttachmentType *info = g_list_nth_data(prop->attachments, attach_index);
5409 debug_log("info is NULL");
5412 if (ug_data->progress_bar[index] == NULL) {
5413 debug_log("obj is NULL");
5417 char *pszTemp = NULL;
5418 pszTemp = (char *)elm_object_style_get(ug_data->progress_bar[index]);
5420 if (STR_INVALID(pszTemp))
5423 if (g_strcmp0(pszTemp, "pending_list") == 0) {
5424 debug_log("pending_list so return");
5428 elm_progressbar_value_set(ug_data->progress_bar[index], val);
5430 if (ug_data->progress_bar_ly[index] != NULL) {
5431 char buf[30] = { 0, };
5432 snprintf(buf, sizeof(buf), "%d%%", per);
5434 Evas_Object *downloading_label2;
5435 downloading_label2 = elm_label_add(ug_data->progress_bar_ly[index]);
5436 elm_object_part_content_set(ug_data->progress_bar_ly[index], "elm.text.2", downloading_label2);
5437 char *buf_tagged = g_strconcat("<font_size=26><align=left><color=#646464FF>", buf, "</align></font_size>", NULL);
5438 elm_object_text_set(downloading_label2, buf_tagged);
5443 static void _cancel_download_attachment(EmailViewerUGD *ug_data)
5447 gboolean is_cancel = FALSE;
5450 debug_log("data is NULL");
5454 EmailViewerPrivate *priv = ug_data->email_data;
5455 EmailViewerProp *prop = ug_data->property;
5457 if (priv && priv->download_all_cnt <= 0) {
5458 debug_log("No attachment download to be cancelled!");
5462 for (i = 0; i <= prop->att_len; i++) {
5463 if (ug_data->progress_bar_ly[i]) {
5464 Evas_Object *btn = elm_object_part_content_get(ug_data->progress_bar_ly[i], "elm.icon.1");
5465 debug_log("Cancel btn for downloading attachment: %p", btn);
5467 evas_object_smart_callback_call(btn, "clicked", NULL);
5473 if (is_cancel == TRUE && ug_data->ug_composer == NULL) {
5474 _create_notify(ug_data, dgettext("sys_string", "IDS_COM_POP_WARNING"), _("IDS_EMAIL_POP_CANCELLING_ATTACHMENT_DOWNLOAD_ING"),
5475 1, dgettext("sys_string", "IDS_COM_SK_OK"), _popup_response_cb,
5480 static char *_get_service_fail_type(int type)
5485 char str[MAX_STR_LEN] = { 0, };
5488 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("IP full"));
5489 return g_strdup(str);
5490 } else if (type == -176) {
5491 ret = _("IDS_EMAIL_POP_NO_SERVICE");
5492 return g_strdup(ret);
5493 } else if (type == -181) {
5494 snprintf(str, sizeof(str), "%s: %s", _("IDS_EMAIL_POP_FAILED_TO_ACTIVATE_PDP"), N_("Transport Error"));
5495 return g_strdup(str);
5496 } else if (type == EMAIL_ERROR_NETWORK_TOO_BUSY) {
5497 ret = _("IDS_EMAIL_POP_NETWORK_BUSY");
5498 return g_strdup(ret);
5499 } else if (type == EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS) {
5500 snprintf(str, sizeof(str), _("IDS_EMAIL_POP_YOU_CAN_ONLY_LOG_IN_ONCE_EVERY_PD_MINUTES"), 15);
5501 return g_strdup(str);
5502 } else if (type == EMAIL_ERROR_CONNECTION_FAILURE) {
5503 ret = dgettext("sys_string", "IDS_COM_POP_CONNECTION_FAILED");
5504 return g_strdup(ret);
5505 } else if (type == EMAIL_ERROR_LOGIN_FAILURE) {
5506 ret = _("IDS_EMAIL_POP_LOG_IN_FAILED");
5507 return g_strdup(ret);
5508 } else if (type == EMAIL_ERROR_AUTHENTICATE) {
5509 ret = _("IDS_EMAIL_POP_AUTHENTICATION_FAILED");
5510 return g_strdup(ret);
5511 } else if (type == EMAIL_ERROR_CANCELLED) {
5512 ret = _("IDS_EMAIL_POP_DOWNLOAD_CANCELLED");
5513 return g_strdup(ret);
5514 } else if (type == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) {
5515 ret = _("IDS_EMAIL_POP_EMAIL_DELETED_FROM_SERVER");
5516 return g_strdup(ret);
5517 } else if (type == EMAIL_ERROR_NO_SUCH_HOST) {
5518 ret = _("IDS_EMAIL_POP_HOST_NOT_FOUND");
5519 return g_strdup(ret);
5520 } else if (type == EMAIL_ERROR_INVALID_SERVER) {
5521 ret = _("IDS_EMAIL_POP_SERVER_NOT_AVAILABLE");
5522 return g_strdup(ret);
5523 } else if (type == EMAIL_ERROR_MAIL_MEMORY_FULL) {
5524 ret = _("IDS_EMAIL_POP_DEVICE_STORAGE_FULL");
5525 return g_strdup(ret);
5526 } else if (type == EMAIL_ERROR_FAILED_BY_SECURITY_POLICY) {
5527 ret = _("IDS_EMAIL_POP_DOWNLOADING_ATTACHMENTS_ON_THE_MOBILE_DEVICE_IS_NOT_ALLOWED_BY_EXCHANGE_SERVER_POLICY");
5528 return g_strdup(ret);
5530 snprintf(str, sizeof(str), "%s (%d)", dgettext("sys_string", "IDS_COM_POP_INTERNAL_ERROR"), type);
5531 return g_strdup(str);
5535 static Evas_Object *_load_edj(Evas_Object *parent, const char *file, const char *group)
5541 eo = elm_layout_add(parent);
5543 r = elm_layout_file_set(eo, file, group);
5545 evas_object_del(eo);
5549 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5556 static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part)
5562 static void _gl_del(void *data, Evas_Object *obj)
5566 if (_g_ug_data == NULL) {
5567 debug_log("ug_data is NULL");
5571 EmailViewerUGD *ug_data = _g_ug_data;
5573 if (ug_data->move_mailbox_list) {
5574 email_free_mailbox(&ug_data->move_mailbox_list, ug_data->move_mailbox_count);
5575 ug_data->move_mailbox_list = NULL;
5576 ug_data->move_mailbox_count = 0;
5582 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part)
5585 email_mailbox_t *mailbox_list = NULL;
5586 mailbox_list = (email_mailbox_t *) data;
5588 if (g_strcmp0(part, "elm.text") == 0) {
5589 char buf[MAX_STR_LEN] = { 0, };
5590 if (mailbox_list && mailbox_list->alias) {
5591 snprintf(buf, sizeof(buf), "%s", mailbox_list->alias);
5592 return g_strdup(buf);
5599 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part)
5603 if (g_strcmp0(part, "elm.icon") == 0) {
5604 Evas_Object *icon = elm_icon_add(obj);
5605 elm_icon_file_set(icon, IMGDIR "/U01_icon_folder.png", NULL);
5606 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
5614 static void _gl_sel(void *data, Evas_Object *obj, void *event_info)
5618 EmailViewerUGD *ug_data = _g_ug_data;
5619 email_mailbox_t *mailbox_list = NULL;
5620 mailbox_list = (email_mailbox_t *) data;
5621 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
5622 elm_genlist_item_selected_set(item, EINA_FALSE);
5624 Elm_Object_Item *git = NULL;
5625 Evas_Object *gl = elm_genlist_add(ug_data->navi_bar);
5626 evas_object_show(gl);
5628 git = elm_genlist_item_append(gl, &(ug_data->itc3), NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
5629 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
5630 elm_genlist_item_append(gl, &ug_data->itc2, NULL, git, ELM_GENLIST_ITEM_NONE, _gl_sub_upper_sel, NULL);
5632 Evas_Object *cbar = elm_toolbar_add(ug_data->navi_bar);
5633 elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
5634 elm_object_style_set(cbar, "naviframe");
5635 evas_object_show(cbar);
5637 elm_toolbar_item_append(cbar, NULL, _("IDS_EMAIL_SK3_MOVE_HERE"), _move_here_cb, mailbox_list);
5638 elm_object_item_disabled_set(elm_toolbar_item_append(cbar, NULL, "", NULL, NULL), EINA_TRUE);
5640 Elm_Object_Item *navi_it = NULL;
5641 navi_it = elm_naviframe_item_push(ug_data->navi_bar, dgettext("sys_string", "IDS_COM_BODY_MOVE"), NULL, NULL, gl, NULL);
5642 elm_object_item_part_content_set(navi_it, "controlbar", cbar);
5643 ug_data->navi_move_it2 = navi_it;
5645 Evas_Object *move_back_btn = NULL;
5646 if (ug_data->isRotate) {
5647 elm_naviframe_item_title_visible_set(navi_it, EINA_FALSE);
5648 move_back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
5649 if (move_back_btn) {
5650 evas_object_del(move_back_btn);
5651 elm_object_item_part_content_set(navi_it, "prev_btn", NULL);
5654 move_back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
5655 if (move_back_btn) {
5656 evas_object_del(move_back_btn);
5657 move_back_btn = elm_button_add(ug_data->navi_bar);
5658 elm_object_style_set(move_back_btn, "naviframe/back_btn/default");
5659 evas_object_smart_callback_add(move_back_btn, "clicked", _move_back_cb2, ug_data);
5660 elm_object_item_part_content_set(navi_it, "prev_btn", move_back_btn);
5666 static char *_gl_sub_upper_text_get(void *data, Evas_Object *obj, const char *part)
5669 email_mailbox_t *mailbox_list = NULL;
5670 mailbox_list = (email_mailbox_t *) data;
5672 if (g_strcmp0(part, "elm.text") == 0) {
5673 char buf[MAX_STR_LEN] = { 0, };
5674 snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_MBODY_MAILBOX_LIST"));
5675 return g_strdup(buf);
5681 static Evas_Object *_gl_sub_upper_icon_get(void *data, Evas_Object *obj, const char *part)
5685 if (g_strcmp0(part, "elm.icon") == 0) {
5686 Evas_Object *icon = elm_icon_add(obj);
5687 elm_icon_file_set(icon, IMGDIR "/U01_icon_upper_folder_focus.png", NULL);
5688 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
5696 static void _gl_sub_upper_sel(void *data, Evas_Object *obj, void *event_info)
5700 EmailViewerUGD *ug_data = _g_ug_data;
5702 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
5703 elm_genlist_item_selected_set(item, EINA_FALSE);
5705 ug_data->navi_move_it2 = NULL;
5706 elm_naviframe_item_pop(ug_data->navi_bar);
5711 static void _move_here_cb(void *data, Evas_Object *obj, void *event_info)
5715 if (data == NULL || _g_ug_data == NULL) {
5716 debug_log("data is NULL");
5720 email_mailbox_t *mailbox_list = NULL;
5721 mailbox_list = (email_mailbox_t *) data;
5723 EmailViewerUGD *ug_data = _g_ug_data;
5724 int folder_id = mailbox_list->mailbox_id;
5726 _move_email(ug_data, folder_id, FALSE);
5728 ug_data->navi_move_it1 = NULL;
5729 ug_data->navi_move_it2 = NULL;
5730 elm_naviframe_item_pop_to(ug_data->navi_main_it);
5732 if (ug_data->isRotate == false && ug_data->b_internal) {
5733 /* Viewer to hide, so set left content (mailbox) size to full */
5734 _notify_mailbox_size(ug_data, "MAILBOX_RESIZE_FULL");
5737 if (ug_data->b_internal) {
5738 _hide_view(ug_data);
5740 /* send next or previous mail request to mailbox. */
5742 service_h service = NULL;
5744 ret = service_create(&service);
5745 debug_log("service_create: %d", ret);
5747 debug_log("service create failed");
5751 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_MSG, EMAIL_BUNDLE_VAL_NEXT_MSG);
5752 debug_log("service_add_extra_data: %d", ret);
5753 ret = service_add_extra_data(service, EMAIL_BUNDLE_KEY_DO_DELETE, "1");
5754 debug_log("service_add_extra_data: %d", ret);
5756 ug_send_message(_g_mailbox_ug, service);
5758 ret = service_destroy(service);
5759 debug_log("service_destroy: %d", ret);
5761 ug_destroy_me(ug_data->ug);
5765 static void _move_back_cb(void *data, Evas_Object *obj, void *event_info)
5769 if (data == NULL || _g_ug_data == NULL) {
5770 debug_log("data is NULL");
5774 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
5776 elm_naviframe_item_pop(ug_data->navi_bar);
5777 ug_data->navi_move_it1 = NULL;
5778 ug_data->navi_move_it2 = NULL;
5780 /*if (ug_data->b_internal)
5781 elm_layout_theme_set(ug_data->layout_main, "layout", "controlbar", "default");
5783 elm_layout_theme_set(ug_data->layout_main, "layout", "application", "controlbar");*/
5786 static void _move_back_cb2(void *data, Evas_Object *obj, void *event_info)
5790 if (data == NULL || _g_ug_data == NULL) {
5791 debug_log("data is NULL");
5795 EmailViewerUGD *ug_data = (EmailViewerUGD *)data;
5797 elm_naviframe_item_pop(ug_data->navi_bar);
5798 ug_data->navi_move_it2 = NULL;