From 3167e58ff9ef331c52dc068ac4804eb694abded3 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli <thomas@roundcube.net> Date: Wed, 03 Jun 2015 04:29:49 -0400 Subject: [PATCH] Pass encrypted draft and reply messages to Mailvelope editor; add toolbar icon for encryption mode toggeling --- program/js/app.js | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 40 insertions(+), 4 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 36694b2..09baeab 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3396,8 +3396,7 @@ type: 'GET', url: this.url('get', { '_mbox': this.env.mailbox, '_uid': this.env.uid, '_part': this.env.pgp_mime_part }), error: function(o, status, err) { - ref.hide_message(msgkey); - ref.http_error(o, status, err, lock); + ref.http_error(o, status, err, msgid); }, success: function(data) { ref.mailvelope_display_container(selector, data, keyring, msgid); @@ -3406,11 +3405,31 @@ } } else if (action == 'compose' && window.mailvelope) { - this.enable_command('compose-encrypted', true); + if (this.env.pgp_mime_message) { + // fetch PGP/Mime part and open load into Mailvelope editor + var lock = this.set_busy(true, this.get_label('loadingdata')); + $.ajax({ + type: 'GET', + url: this.url('get', this.env.pgp_mime_message), + error: function(o, status, err) { + ref.http_error(o, status, err, lock); + ref.enable_command('compose-encrypted', true); + }, + success: function(data) { + ref.set_busy(false, null, lock); + ref.compose_encrypted({ quotedMail: data }); + ref.enable_command('compose-encrypted', true); + } + }); + } + else { + // enable encrypted compose toggle + this.enable_command('compose-encrypted', true); + } } }; - // handler for the 'compose-encrypt' command + // handler for the 'compose-encrypted' command this.compose_encrypted = function(props) { var container = $('#' + this.env.composebody).parent(); @@ -3429,6 +3448,14 @@ // embed Mailvelope editor container else { var options = { predefinedText: $('#' + this.env.composebody).val() }; + if (props.quotedMail) { + options = { quotedMail: props.quotedMail, quotedMailIndent: false }; + } + if (this.env.compose_mode == 'reply') { + options.quotedMailIndent = true; + options.quotedMailHeader = this.env.compose_reply_header; + } + mailvelope.createEditorContainer('#' + container.attr('id'), ref.mailvelope_keyring, options).then(function(editor) { ref.mailvelope_editor = editor; ref.compose_skip_unsavedcheck = true; @@ -3436,6 +3463,15 @@ container.addClass('mailvelope'); $('#' + ref.env.composebody).hide(); + + // notify user about loosing attachments + if (ref.env.attachments && !$.isEmptyObject(ref.env.attachments)) { + alert(ref.get_label('encryptnoattachments')); + + $.each(ref.env.attachments, function(name, attach) { + ref.remove_from_attachment_list(name); + }); + } }).catch(function(err) { console.error(err); }); -- Gitblit v1.9.1