Add toolbar button to switch to Mailvelope encryption editor

pull/297/head
Thomas Bruederli 9 years ago
parent 1cd3762b0d
commit 7b8a0af1c8

@ -279,7 +279,7 @@ function rcube_webmail()
this.env.address_group_stack = []; this.env.address_group_stack = [];
this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'cancel', this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'cancel',
'toggle-editor', 'list-adresses', 'pushgroup', 'search', 'reset-search', 'extwin', 'toggle-editor', 'list-adresses', 'pushgroup', 'search', 'reset-search', 'extwin',
'insert-response', 'save-response', 'menu-open', 'menu-close']; 'insert-response', 'save-response', 'menu-open', 'menu-close', 'compose-encrypted'];
if (this.env.drafts_mailbox) if (this.env.drafts_mailbox)
this.env.compose_commands.push('savedraft') this.env.compose_commands.push('savedraft')
@ -3366,13 +3366,13 @@ function rcube_webmail()
mailvelope.getKeyring(keyring).then(function(kr) { mailvelope.getKeyring(keyring).then(function(kr) {
ref.mailvelope_keyring = kr; ref.mailvelope_keyring = kr;
}, function(err) { }).catch(function(err) {
// attempt to create a new keyring for this app/user // attempt to create a new keyring for this app/user
mailvelope.createKeyring(keyring).then(function(kr) { mailvelope.createKeyring(keyring).then(function(kr) {
ref.mailvelope_keyring = kr; ref.mailvelope_keyring = kr;
keyring = keyring.identifier; keyring = keyring.identifier;
}, function(err) { }).catch(function(err) {
console.error(err) console.error(err);
}); });
}); });
@ -3409,11 +3409,27 @@ function rcube_webmail()
this.compose_encrypted = function(props) this.compose_encrypted = function(props)
{ {
var container = $('#' + this.env.composebody).parent(); var container = $('#' + this.env.composebody).parent();
mailvelope.createEditorContainer('#' + container.attr('id'), keyring).then(function(editor) {
ref.mailvelope_editor = editor; // remove Mailvelope editor if active
container.addClass('mailvelope'); if (ref.mailvelope_editor) {
$('#' + ref.env.composebody).hide(); ref.mailvelope_editor = null;
}); ref.set_button('compose-encrypted', 'act');
container.removeClass('mailvelope')
.find('iframe:not([aria-hidden=true])').remove();
$('#' + ref.env.composebody).show();
}
// embed Mailvelope editor container
else {
var options = { predefinedText: $('#' + this.env.composebody).val() };
mailvelope.createEditorContainer('#' + container.attr('id'), ref.mailvelope_keyring.identifier, options).then(function(editor) {
ref.mailvelope_editor = editor;
ref.set_button('compose-encrypted', 'sel');
container.addClass('mailvelope');
$('#' + ref.env.composebody).hide();
}).catch(function(err) {
console.error(err);
});
}
}; };
// callback to replace the message body with the full armored // callback to replace the message body with the full armored
@ -3427,7 +3443,6 @@ function rcube_webmail()
rcpt = RegExp.$2 rcpt = RegExp.$2
recipients.push(rcpt); recipients.push(rcpt);
val = val.substr(val.indexOf(rcpt) + rcpt.length + 1).replace(/^\s*,\s*/, ''); val = val.substr(val.indexOf(rcpt) + rcpt.length + 1).replace(/^\s*,\s*/, '');
console.log('*', val)
} }
}); });
@ -3435,29 +3450,32 @@ function rcube_webmail()
var isvalid = recipients.length > 0; var isvalid = recipients.length > 0;
ref.mailvelope_keyring.validKeyForAddress(recipients).then(function(status) { ref.mailvelope_keyring.validKeyForAddress(recipients).then(function(status) {
$.each(status, function(k,v) { $.each(status, function(k,v) {
console.log('validate', k, v) if (v === false) {
if (!v) {
isvalid = false; isvalid = false;
alert("No key found for "+k) alert(ref.get_label('nopubkeyfor').replace('$email', k));
} }
}); });
if (!isvalid) { if (!isvalid) {
if (!recipients.length) if (!recipients.length) {
alert(ref.get_label('norecipientwarning')); alert(ref.get_label('norecipientwarning'));
$("[name='_to']").focus();
}
return false; return false;
} }
ref.mailvelope_editor.encrypt(recipients).then(function(armored) { ref.mailvelope_editor.encrypt(recipients).then(function(armored) {
console.log('encrypted message', armored); console.log('encrypted message', armored);
var form = this.gui_objects.messageform; var form = ref.gui_objects.messageform;
// all checks passed, send message // all checks passed, send message
// var msgid = ref.set_busy(true, draft || saveonly ? 'savingmessage' : 'sendingmessage') // var msgid = ref.set_busy(true, draft || saveonly ? 'savingmessage' : 'sendingmessage')
}, function(err) { }).catch(function(err) {
console.log(err) console.log(err);
}); });
}).catch(function(err) {
console.error(err);
}); });
return false; return false;
@ -3466,12 +3484,12 @@ function rcube_webmail()
// wrapper for the mailvelope.createDisplayContainer API call // wrapper for the mailvelope.createDisplayContainer API call
this.mailvelope_display_container = function(selector, data, keyring, msgid) this.mailvelope_display_container = function(selector, data, keyring, msgid)
{ {
mailvelope.createDisplayContainer(selector, data, keyring, {}).then(function() { mailvelope.createDisplayContainer(selector, data, keyring, { showExternalContent: this.env.safemode }).then(function() {
$(selector).addClass('mailvelope').find('.message-part, .part-notice').hide(); $(selector).addClass('mailvelope').find('.message-part, .part-notice').hide();
ref.hide_message(msgid); ref.hide_message(msgid);
setTimeout(function() { $(window).resize(); }, 10); setTimeout(function() { $(window).resize(); }, 10);
}, function(err) { }).catch(function(err) {
console.error(err) console.error(err);
ref.hide_message(msgid); ref.hide_message(msgid);
ref.display_message('Message decryption failed: ' + err.message, 'error') ref.display_message('Message decryption failed: ' + err.message, 'error')
}); });

@ -247,6 +247,8 @@ $labels['selectimage'] = 'Select image';
$labels['addimage'] = 'Add image'; $labels['addimage'] = 'Add image';
$labels['selectmedia'] = 'Select movie'; $labels['selectmedia'] = 'Select movie';
$labels['addmedia'] = 'Add movie'; $labels['addmedia'] = 'Add movie';
$labels['encrypt'] = 'Encrypt';
$labels['encryptmessage'] = 'Encrypt message';
$labels['editidents'] = 'Edit identities'; $labels['editidents'] = 'Edit identities';
$labels['spellcheck'] = 'Spell'; $labels['spellcheck'] = 'Spell';

@ -57,6 +57,7 @@ $messages['contactnameexists'] = 'A contact with the same name already exists.';
$messages['blockedimages'] = 'To protect your privacy, remote images are blocked in this message.'; $messages['blockedimages'] = 'To protect your privacy, remote images are blocked in this message.';
$messages['encryptedmessage'] = 'This is an encrypted message and can not be displayed. Sorry!'; $messages['encryptedmessage'] = 'This is an encrypted message and can not be displayed. Sorry!';
$messages['externalmessagedecryption'] = 'This is an encrypted message and can be decrypted with your browser extension.'; $messages['externalmessagedecryption'] = 'This is an encrypted message and can be decrypted with your browser extension.';
$messages['nopubkeyfor'] = 'No valid public key found for $email';
$messages['nocontactsfound'] = 'No contacts found.'; $messages['nocontactsfound'] = 'No contacts found.';
$messages['contactnotfound'] = 'The requested contact was not found.'; $messages['contactnotfound'] = 'The requested contact was not found.';
$messages['contactsearchonly'] = 'Enter some search terms to find contacts'; $messages['contactsearchonly'] = 'Enter some search terms to find contacts';

@ -83,7 +83,7 @@ $OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubj
'messagesaved', 'converting', 'editorwarning', 'searching', 'uploading', 'uploadingmany', 'messagesaved', 'converting', 'editorwarning', 'searching', 'uploading', 'uploadingmany',
'fileuploaderror', 'sendmessage', 'newresponse', 'responsename', 'responsetext', 'save', 'fileuploaderror', 'sendmessage', 'newresponse', 'responsename', 'responsetext', 'save',
'savingresponse', 'restoresavedcomposedata', 'restoremessage', 'delete', 'restore', 'ignore', 'savingresponse', 'restoresavedcomposedata', 'restoremessage', 'delete', 'restore', 'ignore',
'selectimportfile', 'messageissent'); 'selectimportfile', 'messageissent', 'nopubkeyfor');
$OUTPUT->set_pagetitle($RCMAIL->gettext('compose')); $OUTPUT->set_pagetitle($RCMAIL->gettext('compose'));

@ -2008,6 +2008,14 @@ ul.proplist li {
opacity: 0.4; opacity: 0.4;
} }
.toolbar a.button.selected {
color: #1978a1;
}
.toolbar a.button.hidden {
display: none;
}
.dropbutton { .dropbutton {
display: inline-block; display: inline-block;
position: relative; position: relative;

@ -33,6 +33,7 @@
<roundcube:button name="addattachment" type="link" class="button attach" label="attach" title="addattachment" onclick="UI.show_uploadform(event);return false" aria-haspopup="true" aria-expanded="false"tabindex="2" /> <roundcube:button name="addattachment" type="link" class="button attach" label="attach" title="addattachment" onclick="UI.show_uploadform(event);return false" aria-haspopup="true" aria-expanded="false"tabindex="2" />
<roundcube:button command="insert-sig" type="link" class="button insertsig disabled" classAct="button insertsig" label="signature" title="insertsignature" tabindex="2" /> <roundcube:button command="insert-sig" type="link" class="button insertsig disabled" classAct="button insertsig" label="signature" title="insertsignature" tabindex="2" />
<a href="#responses" class="button responses" label="responses" title="<roundcube:label name='insertresponse' />" id="responsesmenulink" unselectable="on" onmousedown="return false" onclick="UI.toggle_popup('responsesmenu',event);return false" tabindex="2" aria-haspopup="true" aria-expanded="false" aria-owns="textresponsesmenu"><roundcube:label name="responses" /></a> <a href="#responses" class="button responses" label="responses" title="<roundcube:label name='insertresponse' />" id="responsesmenulink" unselectable="on" onmousedown="return false" onclick="UI.toggle_popup('responsesmenu',event);return false" tabindex="2" aria-haspopup="true" aria-expanded="false" aria-owns="textresponsesmenu"><roundcube:label name="responses" /></a>
<roundcube:button command="compose-encrypted" type="link" class="button encrypt hidden" classAct="button encrypt" classSel="button encrypt selected" label="encrypt" title="encryptmessage" tabindex="2" />
<roundcube:container name="toolbar" id="compose-toolbar" /> <roundcube:container name="toolbar" id="compose-toolbar" />
</div> </div>

Loading…
Cancel
Save