From c72c2dbaa4b54d8442de940098de69f9b35349d1 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sun, 11 Feb 2024 21:16:38 +0100 Subject: [PATCH] Added options to Identity for PGP sign and encrypt #89 --- dev/Model/Identity.js | 3 ++ dev/View/Popup/Compose.js | 16 ++++---- dev/View/Popup/Identity.js | 33 ++++------------- .../app/libraries/RainLoop/Model/Identity.php | 14 +++++-- .../templates/Views/User/PopupsCompose.html | 8 ++-- .../templates/Views/User/PopupsIdentity.html | 37 +++++++++++++++++-- 6 files changed, 65 insertions(+), 46 deletions(-) diff --git a/dev/Model/Identity.js b/dev/Model/Identity.js index 4afa6f05e..592650e07 100644 --- a/dev/Model/Identity.js +++ b/dev/Model/Identity.js @@ -21,6 +21,9 @@ export class IdentityModel extends AbstractModel { signature: '', signatureInsertBefore: false, + pgpSign: false, + pgpEncrypt: false, + askDelete: false }); } diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index c90cbbc4d..da15f6f22 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -346,7 +346,13 @@ export class ComposePopupView extends AbstractViewPopup { sendSuccessButSaveError: value => !value && this.savedErrorDesc(''), - currentIdentity: value => value && this.from(value.formattedName()), + currentIdentity: value => { + if (value) { + this.from(value.formattedName()); + this.pgpEncrypt(value.pgpEncrypt/* || SettingsUserStore.pgpEncrypt()*/); + this.pgpSign(value.pgpSign/* || SettingsUserStore.pgpSign()*/); + } + }, from: value => { this.canPgpSign(false); @@ -1389,14 +1395,6 @@ export class ComposePopupView extends AbstractViewPopup { }); } - togglePgpSign() { - this.pgpSign(!this.pgpSign()/* && this.canPgpSign()*/); - } - - togglePgpEncrypt() { - this.pgpEncrypt(!this.pgpEncrypt()/* && this.canPgpEncrypt()*/); - } - async getMessageRequestParams(sSaveFolder, draft) { let Text = this.oEditor.getData().trim(), diff --git a/dev/View/Popup/Identity.js b/dev/View/Popup/Identity.js index 8db81772d..0857a78ab 100644 --- a/dev/View/Popup/Identity.js +++ b/dev/View/Popup/Identity.js @@ -15,22 +15,10 @@ export class IdentityPopupView extends AbstractViewPopup { super('Identity'); addObservablesTo(this, { - id: '', + identity: null, edit: false, - - label: '', labelFocused: false, - - email: '', - name: '', nameFocused: false, - - replyTo: '', - bcc: '', - - signature: '', - signatureInsertBefore: false, - submitRequest: false, submitError: '' }); @@ -43,11 +31,12 @@ export class IdentityPopupView extends AbstractViewPopup { submitForm(form) { if (!this.submitRequest() && form.reportValidity()) { - this.signature?.__fetchEditorValue?.(); + let identity = this.identity(); + identity.signature?.__fetchEditorValue?.(); this.submitRequest(true); const data = new FormData(form); - data.set('Id', this.id()); - data.set('Signature', this.signature()); + data.set('Id', identity.id()); + data.set('Signature', identity.signature()); Remote.request('IdentityUpdate', iError => { this.submitRequest(false); if (iError) { @@ -67,7 +56,6 @@ export class IdentityPopupView extends AbstractViewPopup { onShow(identity) { this.submitRequest(false); this.submitError(''); - if (identity) { this.edit(true); } else { @@ -75,17 +63,10 @@ export class IdentityPopupView extends AbstractViewPopup { identity = new IdentityModel; identity.id(Jua.randomId()); } - this.id(identity.id() || ''); - this.label(identity.label() || ''); - this.name(identity.name()); - this.email(identity.email()); - this.replyTo(identity.replyTo()); - this.bcc(identity.bcc()); - this.signature(identity.signature()); - this.signatureInsertBefore(identity.signatureInsertBefore()); + this.identity(identity); } afterShow() { - this.id() ? this.labelFocused(true) : this.nameFocused(true); + this.identity().id() ? this.labelFocused(true) : this.nameFocused(true); } } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Identity.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Identity.php index e9ba1d9f3..02ea3c1d7 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Identity.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Identity.php @@ -22,6 +22,9 @@ class Identity implements \JsonSerializable private bool $bSignatureInsertBefore = false; + private bool $bPgpEncrypt = false; + private bool $bPgpSign = false; + function __construct(string $sId = '', string $sEmail = '') { $this->sId = $sId; @@ -89,7 +92,8 @@ class Identity implements \JsonSerializable $this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : ''; $this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : ''; $this->bSignatureInsertBefore = !empty($aData['SignatureInsertBefore']); - + $this->bPgpEncrypt = !empty($aData['PgpEncrypt']); + $this->bPgpSign = !empty($aData['PgpSign']); return true; } @@ -107,7 +111,9 @@ class Identity implements \JsonSerializable 'ReplyTo' => $this->sReplyTo, 'Bcc' => $this->sBcc, 'Signature' => $this->sSignature, - 'SignatureInsertBefore' => $this->bSignatureInsertBefore + 'SignatureInsertBefore' => $this->bSignatureInsertBefore, + 'PgpEncrypt' => $this->bPgpEncrypt, + 'PgpSign' => $this->bPgpSign ); } @@ -123,7 +129,9 @@ class Identity implements \JsonSerializable 'replyTo' => $this->sReplyTo, 'bcc' => $this->sBcc, 'signature' => $this->sSignature, - 'signatureInsertBefore' => $this->bSignatureInsertBefore + 'signatureInsertBefore' => $this->bSignatureInsertBefore, + 'pgpEncrypt' => $this->bPgpEncrypt, + 'pgpSign' => $this->bPgpSign ); } diff --git a/snappymail/v/0.0.0/app/templates/Views/User/PopupsCompose.html b/snappymail/v/0.0.0/app/templates/Views/User/PopupsCompose.html index 2bef5ca32..4e943bb12 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/PopupsCompose.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/PopupsCompose.html @@ -60,13 +60,13 @@ -
  • +
  • -
  • +
  • @@ -137,10 +137,10 @@
    diff --git a/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html b/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html index f92f680b7..7cf85a3ab 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html @@ -9,16 +9,16 @@
    -
    +
    - + data-bind="value: label, hasfocus: $root.labelFocused">
    @@ -34,7 +34,7 @@ + data-bind="value: name, hasfocus: $root.nameFocused">
    @@ -67,6 +67,35 @@ autocomplete="off" autocorrect="off" autocapitalize="off" data-bind="value: bcc">
    + +
    +
    +
    +