diff --git a/plugins/enigma/README b/plugins/enigma/README index 3026b8442..7aadbd0f6 100644 --- a/plugins/enigma/README +++ b/plugins/enigma/README @@ -6,26 +6,25 @@ WARNING: Don't use with gnupg-2.x! Plugin Status: -+ PGP: signed messages verification ++ PGP: signatures verification + PGP: messages decryption ++ PGP: Sending of encrypted/signed messages + PGP: keys management UI (keys import and delete) + Handling of PGP keys attached to incoming messages TODO (must have): - Fix issues with enabled messages_cache -- PGP: Sending of encrypted/signed messages -- Per-Identity settings (including keys/certs) -- Test/Make working with gnupg-2.x +- PGP: Handling of signed inside encrypted message +- Make working with gnupg-2.x - Keys export to file - Disable Reply/Forward options when viewing encrypted messages until they are decrypted successfully -- Handling of replying/forwarding of encrypted messages +- Handling of replying/forwarding of encrypted/signed messages - Add composer.json file - Performance improvements: - - cache decrypted message key id in cache so we can skip - decryption if we have no password in session - - cache sig verification status to not verify on every msg preview (optional) + - cache decrypted message key id so we can skip decryption if we have no password in session + - cache (last or successful only?) sig verification status to not verify on every msg preview (optional) TODO (later): @@ -45,6 +44,8 @@ TODO (later): - Mark keys as trusted/untrasted, display appropriate message in verify/decrypt status - User-preferences to disable signature verification, decrypting, encrypting or all enigma features - Change attachment icon on messages list for encrypted messages (like vcard_attachment plugin does) +- Support for multi-server installations (store keys in sql database?) +- Per-Identity settings (including keys/certs) - S/MIME: Certs generation - S/MIME: Certs management diff --git a/plugins/enigma/config.inc.php.dist b/plugins/enigma/config.inc.php.dist index 2adb4d9f6..b58ce8bad 100644 --- a/plugins/enigma/config.inc.php.dist +++ b/plugins/enigma/config.inc.php.dist @@ -12,3 +12,9 @@ $config['enigma_smime_driver'] = 'phpssl'; // Keys directory for all users. Default 'enigma/home'. // Must be writeable by PHP process $config['enigma_pgp_homedir'] = null; + +// Enable signing all messages by default +$config['enigma_sign_all'] = false; + +// Enable encrypting all messages by default +$config['enigma_encrypt_all'] = false; diff --git a/plugins/enigma/enigma.js b/plugins/enigma/enigma.js index a7bc43f93..4048d8d85 100644 --- a/plugins/enigma/enigma.js +++ b/plugins/enigma/enigma.js @@ -33,6 +33,9 @@ window.rcmail && rcmail.addEventListener('init', function(evt) { } else if (rcmail.env.task == 'mail') { if (rcmail.env.action == 'compose') { + rcmail.addEventListener('beforesend', function(props) { rcmail.enigma_beforesend_handler(props); }) + .addEventListener('beforesavedraft', function(props) { rcmail.enigma_beforesavedraft_handler(props); }); + $('input,label', $('#enigmamenu')).mouseup(function(e) { // don't close the menu on mouse click inside e.stopPropagation(); @@ -234,10 +237,46 @@ rcube_webmail.prototype.enigma_add_list_row = function(r) list.insert_row(row); } + /*********************************************************/ /********* Enigma Message methods *********/ /*********************************************************/ +// handle message send/save action +rcube_webmail.prototype.enigma_beforesend_handler = function(props) +{ + this.env.last_action = 'send'; + this.enigma_compose_handler(props); +} + +rcube_webmail.prototype.enigma_beforesavedraft_handler = function(props) +{ + this.env.last_action = 'savedraft'; + this.enigma_compose_handler(props); +} + +rcube_webmail.prototype.enigma_compose_handler = function(props) +{ + var form = this.gui_objects.messageform; + + // copy inputs from enigma menu to the form + $('#enigmamenu input').each(function() { + var id = this.id + '_cpy', input = $('#' + id); + + if (!input.length) { + input = $(this).clone(); + input.prop({id: id, type: 'hidden'}).appendTo(form); + } + + input.val(this.checked ? '1' : ''); + }); + + // disable signing when saving drafts + if (this.env.last_action == 'savedraft') { + $('input[name="_enigma_sign"]', form).val(0); + } +} + // Import attached keys/certs file rcube_webmail.prototype.enigma_import_attachment = function(mime_id) { @@ -249,6 +288,7 @@ rcube_webmail.prototype.enigma_import_attachment = function(mime_id) return false; } +// password request popup rcube_webmail.prototype.enigma_password_request = function(data) { if (!data || !data.keyid) { @@ -268,7 +308,8 @@ rcube_webmail.prototype.enigma_password_request = function(data) .appendTo(myprompt); data.key = data.keyid; - data.keyid = data.keyid.substr(0, 8); + if (data.keyid.length > 8) + data.keyid = data.keyid.substr(data.keyid.length - 8); $.each(['keyid', 'user'], function() { msg = msg.replace('$' + this, data[this]); @@ -310,8 +351,14 @@ rcube_webmail.prototype.enigma_password_request = function(data) } } +// submit entered password rcube_webmail.prototype.enigma_password_submit = function(keyid, password) { + if (this.env.action == 'compose') { + return this.enigma_password_compose_submit(keyid, password); + } + + // message preview var form = $('