From e1f4574b9acd83497ce7d19854593dbb703eafee Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 27 Nov 2015 16:17:59 +0000 Subject: [PATCH] W.I.P. of new approach for mail winmail.data attachment handling - Fix mail list is loading super slow if there are mails with winmail.data attachments - Performance improvement for reading mails in preview pane with winmail.data --- mail/inc/class.mail_ui.inc.php | 34 +++++++++++++++++++++++++++++++++- mail/js/app.js | 18 ++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index a4bfd1dae9..782613044b 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -3657,7 +3657,39 @@ class mail_ui $response->call('app.mail.mail_reloadNode',$refreshData); } - + + /** + * ResolveWinmail fetches the encoded attachments + * from winmail.data and will response expected structure back + * to client in order to display them. + * + * Note: this ajax function should only be called via + * nm mail selection as it does not support profile change + * and uses the current available ic_server connection. + * + * @param type $_rowid row id from nm + * + */ + function ajax_resolveWinmail ($_rowid) + { + $response = egw_json_response::get(); + + $idParts = self::splitRowID($_rowid); + $uid = $idParts['msgUID']; + $mbox = $idParts['folder']; + + $attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox); + if (is_array($attachments)) + { + $attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false); + $response->data($attachments); + } + else + { + $response->call('egw.message', lang('Can not resolve the winmail.data attachment!')); + } + } + /** * move folder * diff --git a/mail/js/app.js b/mail/js/app.js index c852a06ba8..61c92eab15 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -844,6 +844,24 @@ app.classes.mail = AppJS.extend( { var _id = this.mail_fetchCurrentlyFocussed(selected); dataElem = jQuery.extend(dataElem, egw.dataGetUIDdata(_id)); + + // Try to resolve winmail.data attachment + if (dataElem.data && dataElem.data.attachmentsBlock[0] + && dataElem.data.attachmentsBlock[0].winmailFlag) + { + attachmentArea.getDOMNode().classList.add('loading'); + this.egw.jsonq('mail.mail_ui.ajax_resolveWinmail',[_id], function(_data){ + attachmentArea.getDOMNode().classList.remove('loading'); + if (typeof _data == 'object') + { + attachmentArea.set_value({content:_data}); + } + else + { + console.log('Can not resolve the winmail.data!'); + } + }); + } } var $preview_iframe = jQuery('#mail-index_mailPreviewContainer');