From bde19f6f6c40f1b21865902d51629be2430a3f0f Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 1 Sep 2017 16:20:57 +0200 Subject: [PATCH] S/MIME: - Preset smime_sign and smime_encrypt toolbar actions if the original mail is smime. - Fix smime alignment of smime icons in mail preview --- mail/inc/class.mail_compose.inc.php | 11 +++++++-- mail/inc/class.mail_ui.inc.php | 3 ++- mail/js/app.js | 22 +++++++++++++----- mail/templates/default/app.css | 2 +- mail/templates/default/display.xet | 4 ++-- mail/templates/default/index.xet | 4 ++-- .../default/smimeCertAddToContact.xet | 2 +- mail/templates/mobile/app.css | 2 +- mail/templates/pixelegg/app.css | 2 +- ...{smimeEncryption.png => smime_encrypt.png} | Bin ...{smimeEncryption.svg => smime_encrypt.svg} | 0 .../{smimeSignature.png => smime_sign.png} | Bin .../{smimeSignature.svg => smime_sign.svg} | 0 13 files changed, 35 insertions(+), 17 deletions(-) rename mail/templates/pixelegg/images/{smimeEncryption.png => smime_encrypt.png} (100%) rename mail/templates/pixelegg/images/{smimeEncryption.svg => smime_encrypt.svg} (100%) rename mail/templates/pixelegg/images/{smimeSignature.png => smime_sign.png} (100%) rename mail/templates/pixelegg/images/{smimeSignature.svg => smime_sign.svg} (100%) diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 3dc5016ce6..7130cb9467 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -220,7 +220,7 @@ class mail_compose $actions = array_merge($actions, array( 'smime_sign' => array ( 'caption' => 'SMIME Sign', - 'icon' => 'smimeSignature', + 'icon' => 'smime_sign', 'group' => ++$group, 'onExecute' => 'javaScript:app.mail.compose_setToggle', 'checkbox' => true, @@ -228,7 +228,7 @@ class mail_compose ), 'smime_encrypt' => array ( 'caption' => 'SMIME Encryption', - 'icon' => 'smimeEncryption', + 'icon' => 'smime_encrypt', 'group' => ++$group, 'onExecute' => 'javaScript:app.mail.compose_setToggle', 'checkbox' => true, @@ -324,6 +324,13 @@ class mail_compose // Additionally may be changed $_focusElement, $suppressSigOnTop, $isReply )); + if (isset($_GET['smime_type'])) $smime_type = $_GET['smime_type']; + // pre set smime_sign and smime_encrypt actions if the original + // message is smime. + $_content['smime_sign'] = $smime_type == (Mail\Smime::TYPE_SIGN || + $smime_type == Mail\Smime::TYPE_SIGN_ENCRYPT) ? 'on' : 'off'; + $_content['smime_encrypt'] = ($smime_type == Mail\Smime::TYPE_ENCRYPT) ? 'on' : 'off'; + $actionToProcess = $_GET['from']; unset($_GET['from']); unset($_GET['reply_id']); diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 3b67bc8594..867286932b 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -1835,7 +1835,8 @@ $filter['before']= date("d-M-Y", $cutoffdate2); { if (Mail\Smime::isSmime($attch['mimeType'])) { - $data['smime'] = Mail\Smime::isSmimeSignatureOnly($attch['mimeType']) ? 'smimeSignature' : 'smimeEncryption'; + $data['smime'] = Mail\Smime::isSmimeSignatureOnly($attch['mimeType'])? + Mail\Smime::TYPE_SIGN : Mail\Smime::TYPE_ENCRYPT; } } } diff --git a/mail/js/app.js b/mail/js/app.js index 0db411d335..dd52317e84 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -227,9 +227,9 @@ app.classes.mail = AppJS.extend( // removed once the issue is solved. var password = this.et2.getWidgetById('password'); if (password) password.set_value(''); - - if (this.et2.getWidgetById('composeToolbar')._actionManager.getActionById('pgp') && - this.et2.getWidgetById('composeToolbar')._actionManager.getActionById('pgp').checked || + var composeToolbar = this.et2.getWidgetById('composeToolbar'); + if (composeToolbar._actionManager.getActionById('pgp') && + composeToolbar._actionManager.getActionById('pgp').checked || this.et2.getArrayMgr('content').data.mail_plaintext && this.et2.getArrayMgr('content').data.mail_plaintext.indexOf(this.begin_pgp_message) != -1) { @@ -313,6 +313,15 @@ app.classes.mail = AppJS.extend( { jQuery('input',to.node).focus(); } + var smime_sign = this.et2.getWidgetById('smime_sign'); + var smime_encrypt = this.et2.getWidgetById('smime_encrypt'); + + if (composeToolbar._actionManager.getActionById('smime_sign') && + composeToolbar._actionManager.getActionById('smime_encrypt')) + { + if (smime_sign.getValue() == 'on') composeToolbar.checkbox('smime_sign', true); + if (smime_encrypt.getValue() == 'on') composeToolbar.checkbox('smime_encrypt', true); + } break; case 'mail.subscribe': if (this.subscription_treeLastState != "") @@ -594,7 +603,8 @@ app.classes.mail = AppJS.extend( // We only handle one for everything but forward settings.id = (typeof _elems == 'undefined'?'':_elems[0].id); - + var content = egw.dataGetUIDdata(settings.id); + if (content) settings.smime_type = content.data['smime']; switch(_action.id) { case 'compose': @@ -994,10 +1004,10 @@ app.classes.mail = AppJS.extend( switch (smime_widgets[i]) { case 'smime_signature': - widget.set_disabled(!(dataElem.data.smime == 'smimeSignature')); + widget.set_disabled(!(dataElem.data.smime == 'smime_sign')); break; case 'smime_encryption': - widget.set_disabled(!(dataElem.data.smime == 'smimeEncryption')); + widget.set_disabled(!(dataElem.data.smime == 'smime_encrypt')); break; default: widget.set_disabled(true); diff --git a/mail/templates/default/app.css b/mail/templates/default/app.css index 678ba58f0f..5c3ed6925f 100644 --- a/mail/templates/default/app.css +++ b/mail/templates/default/app.css @@ -938,4 +938,4 @@ img.smime_cert_notvalid { img.smime_cert_unknownemail { background: #a28cff; } -.smimeIcons {position: absolute;right: 0;} \ No newline at end of file +.smimeIcons {position: absolute;right: 10px;} \ No newline at end of file diff --git a/mail/templates/default/display.xet b/mail/templates/default/display.xet index e9421f0009..8b7156b440 100644 --- a/mail/templates/default/display.xet +++ b/mail/templates/default/display.xet @@ -47,8 +47,8 @@ - - + + diff --git a/mail/templates/default/index.xet b/mail/templates/default/index.xet index 7d3fec1611..6674d9681e 100644 --- a/mail/templates/default/index.xet +++ b/mail/templates/default/index.xet @@ -36,8 +36,8 @@ - - + + diff --git a/mail/templates/default/smimeCertAddToContact.xet b/mail/templates/default/smimeCertAddToContact.xet index 58595e677b..b6be64c9a6 100644 --- a/mail/templates/default/smimeCertAddToContact.xet +++ b/mail/templates/default/smimeCertAddToContact.xet @@ -12,7 +12,7 @@ - + diff --git a/mail/templates/mobile/app.css b/mail/templates/mobile/app.css index ad045096b2..8ad33a527b 100644 --- a/mail/templates/mobile/app.css +++ b/mail/templates/mobile/app.css @@ -927,7 +927,7 @@ img.smime_cert_unknownemail { } .smimeIcons { position: absolute; - right: 0; + right: 10px; } #popupMainDiv { padding: 5px; diff --git a/mail/templates/pixelegg/app.css b/mail/templates/pixelegg/app.css index e516c6dbec..89e216ccf7 100755 --- a/mail/templates/pixelegg/app.css +++ b/mail/templates/pixelegg/app.css @@ -915,7 +915,7 @@ img.smime_cert_unknownemail { } .smimeIcons { position: absolute; - right: 0; + right: 10px; } #popupMainDiv { padding: 5px; diff --git a/mail/templates/pixelegg/images/smimeEncryption.png b/mail/templates/pixelegg/images/smime_encrypt.png similarity index 100% rename from mail/templates/pixelegg/images/smimeEncryption.png rename to mail/templates/pixelegg/images/smime_encrypt.png diff --git a/mail/templates/pixelegg/images/smimeEncryption.svg b/mail/templates/pixelegg/images/smime_encrypt.svg similarity index 100% rename from mail/templates/pixelegg/images/smimeEncryption.svg rename to mail/templates/pixelegg/images/smime_encrypt.svg diff --git a/mail/templates/pixelegg/images/smimeSignature.png b/mail/templates/pixelegg/images/smime_sign.png similarity index 100% rename from mail/templates/pixelegg/images/smimeSignature.png rename to mail/templates/pixelegg/images/smime_sign.png diff --git a/mail/templates/pixelegg/images/smimeSignature.svg b/mail/templates/pixelegg/images/smime_sign.svg similarity index 100% rename from mail/templates/pixelegg/images/smimeSignature.svg rename to mail/templates/pixelegg/images/smime_sign.svg