Added options to Identity for PGP sign and encrypt #89

This commit is contained in:
the-djmaze 2024-02-11 21:16:38 +01:00
parent 4c84c6cdfc
commit c72c2dbaa4
6 changed files with 65 additions and 46 deletions

View file

@ -21,6 +21,9 @@ export class IdentityModel extends AbstractModel {
signature: '', signature: '',
signatureInsertBefore: false, signatureInsertBefore: false,
pgpSign: false,
pgpEncrypt: false,
askDelete: false askDelete: false
}); });
} }

View file

@ -346,7 +346,13 @@ export class ComposePopupView extends AbstractViewPopup {
sendSuccessButSaveError: value => !value && this.savedErrorDesc(''), 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 => { from: value => {
this.canPgpSign(false); 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) async getMessageRequestParams(sSaveFolder, draft)
{ {
let Text = this.oEditor.getData().trim(), let Text = this.oEditor.getData().trim(),

View file

@ -15,22 +15,10 @@ export class IdentityPopupView extends AbstractViewPopup {
super('Identity'); super('Identity');
addObservablesTo(this, { addObservablesTo(this, {
id: '', identity: null,
edit: false, edit: false,
label: '',
labelFocused: false, labelFocused: false,
email: '',
name: '',
nameFocused: false, nameFocused: false,
replyTo: '',
bcc: '',
signature: '',
signatureInsertBefore: false,
submitRequest: false, submitRequest: false,
submitError: '' submitError: ''
}); });
@ -43,11 +31,12 @@ export class IdentityPopupView extends AbstractViewPopup {
submitForm(form) { submitForm(form) {
if (!this.submitRequest() && form.reportValidity()) { if (!this.submitRequest() && form.reportValidity()) {
this.signature?.__fetchEditorValue?.(); let identity = this.identity();
identity.signature?.__fetchEditorValue?.();
this.submitRequest(true); this.submitRequest(true);
const data = new FormData(form); const data = new FormData(form);
data.set('Id', this.id()); data.set('Id', identity.id());
data.set('Signature', this.signature()); data.set('Signature', identity.signature());
Remote.request('IdentityUpdate', iError => { Remote.request('IdentityUpdate', iError => {
this.submitRequest(false); this.submitRequest(false);
if (iError) { if (iError) {
@ -67,7 +56,6 @@ export class IdentityPopupView extends AbstractViewPopup {
onShow(identity) { onShow(identity) {
this.submitRequest(false); this.submitRequest(false);
this.submitError(''); this.submitError('');
if (identity) { if (identity) {
this.edit(true); this.edit(true);
} else { } else {
@ -75,17 +63,10 @@ export class IdentityPopupView extends AbstractViewPopup {
identity = new IdentityModel; identity = new IdentityModel;
identity.id(Jua.randomId()); identity.id(Jua.randomId());
} }
this.id(identity.id() || ''); this.identity(identity);
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());
} }
afterShow() { afterShow() {
this.id() ? this.labelFocused(true) : this.nameFocused(true); this.identity().id() ? this.labelFocused(true) : this.nameFocused(true);
} }
} }

View file

@ -22,6 +22,9 @@ class Identity implements \JsonSerializable
private bool $bSignatureInsertBefore = false; private bool $bSignatureInsertBefore = false;
private bool $bPgpEncrypt = false;
private bool $bPgpSign = false;
function __construct(string $sId = '', string $sEmail = '') function __construct(string $sId = '', string $sEmail = '')
{ {
$this->sId = $sId; $this->sId = $sId;
@ -89,7 +92,8 @@ class Identity implements \JsonSerializable
$this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : ''; $this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : '';
$this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : ''; $this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : '';
$this->bSignatureInsertBefore = !empty($aData['SignatureInsertBefore']); $this->bSignatureInsertBefore = !empty($aData['SignatureInsertBefore']);
$this->bPgpEncrypt = !empty($aData['PgpEncrypt']);
$this->bPgpSign = !empty($aData['PgpSign']);
return true; return true;
} }
@ -107,7 +111,9 @@ class Identity implements \JsonSerializable
'ReplyTo' => $this->sReplyTo, 'ReplyTo' => $this->sReplyTo,
'Bcc' => $this->sBcc, 'Bcc' => $this->sBcc,
'Signature' => $this->sSignature, '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, 'replyTo' => $this->sReplyTo,
'bcc' => $this->sBcc, 'bcc' => $this->sBcc,
'signature' => $this->sSignature, 'signature' => $this->sSignature,
'signatureInsertBefore' => $this->bSignatureInsertBefore 'signatureInsertBefore' => $this->bSignatureInsertBefore,
'pgpEncrypt' => $this->bPgpEncrypt,
'pgpSign' => $this->bPgpSign
); );
} }

View file

@ -60,13 +60,13 @@
<span data-i18n="COMPOSE/BUTTON_MARK_AS_IMPORTANT"></span> <span data-i18n="COMPOSE/BUTTON_MARK_AS_IMPORTANT"></span>
</a> </a>
</li> </li>
<li data-bind="click: togglePgpSign, visible: canPgpSign"> <li data-bind="toggle: pgpSign, visible: canPgpSign">
<a> <a>
<i class="fontastic" data-bind="text: pgpSign() ? '☑' : '☐'"></i> <i class="fontastic" data-bind="text: pgpSign() ? '☑' : '☐'"></i>
<span data-icon="✍" data-i18n="OPENPGP/LABEL_SIGN"></span> <span data-icon="✍" data-i18n="OPENPGP/LABEL_SIGN"></span>
</a> </a>
</li> </li>
<li data-bind="click: togglePgpEncrypt, visible: canPgpEncrypt"> <li data-bind="toggle: pgpEncrypt, visible: canPgpEncrypt">
<a> <a>
<i class="fontastic" data-bind="text: pgpEncrypt() || 'mailvelope' == viewArea() ? '☑' : '☐'"></i> <i class="fontastic" data-bind="text: pgpEncrypt() || 'mailvelope' == viewArea() ? '☑' : '☐'"></i>
<span data-icon="🔒" data-i18n="OPENPGP/LABEL_ENCRYPT"></span> <span data-icon="🔒" data-i18n="OPENPGP/LABEL_ENCRYPT"></span>
@ -137,10 +137,10 @@
<div style="display:flex"> <div style="display:flex">
<div class="btn-group" style="flex-grow:1"></div> <div class="btn-group" style="flex-grow:1"></div>
<div class="btn-group"> <div class="btn-group">
<a class="btn fontastic" data-bind="click: togglePgpSign, visible: canPgpSign, css: {'btn-success': pgpSign()}" data-i18n="[title]OPENPGP/LABEL_SIGN"> <a class="btn fontastic" data-bind="toggle: pgpSign, visible: canPgpSign, css: {'btn-success': pgpSign()}" data-i18n="[title]OPENPGP/LABEL_SIGN">
</a> </a>
<a class="btn fontastic" data-bind="click: togglePgpEncrypt, visible: canPgpEncrypt, css: {'btn-success': pgpEncrypt() || 'mailvelope' == viewArea()}" data-i18n="[title]OPENPGP/LABEL_ENCRYPT"> <a class="btn fontastic" data-bind="toggle: pgpEncrypt, visible: canPgpEncrypt, css: {'btn-success': pgpEncrypt() || 'mailvelope' == viewArea()}" data-i18n="[title]OPENPGP/LABEL_ENCRYPT">
🔒 🔒
</a> </a>
</div> </div>

View file

@ -9,16 +9,16 @@
<span data-bind="text: submitError"></span> <span data-bind="text: submitError"></span>
</div> </div>
<div class="tabs"> <div class="tabs" data-bind="with: identity">
<input type="radio" name="identitytabs" id="tab-identity" checked> <input type="radio" name="identitytabs" id="tab-identity" checked>
<label data-i18n="SETTINGS_LABELS/GENERAL" for="tab-identity" role="tab" aria-selected="true" aria-controls="panel1" tabindex="0"></label> <label data-i18n="SETTINGS_LABELS/GENERAL" for="tab-identity" role="tab" aria-selected="true" aria-controls="panel1" tabindex="0"></label>
<div class="form-horizontal tab-content" role="tabpanel" aria-hidden="false"> <div class="form-horizontal tab-content" role="tabpanel" aria-hidden="false">
<div class="control-group"> <div class="control-group">
<label data-i18n="POPUPS_IDENTITY/LABEL"></label> <label data-i18n="POPUPS_IDENTITY/LABEL"></label>
<div> <div>
<input name="Label" type="text" class="input-xlarge" autofocus="" required="" <input name="Label" type="text" class="input-xlarge" autofocus=""
autocomplete="off" autocorrect="off" autocapitalize="off" autocomplete="off" autocorrect="off" autocapitalize="off"
data-bind="value: label, hasfocus: labelFocused"> data-bind="value: label, hasfocus: $root.labelFocused">
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -34,7 +34,7 @@
<label data-i18n="GLOBAL/NAME"></label> <label data-i18n="GLOBAL/NAME"></label>
<input name="Name" type="text" class="input-xlarge" <input name="Name" type="text" class="input-xlarge"
autocomplete="off" autocorrect="off" autocapitalize="off" autocomplete="off" autocorrect="off" autocapitalize="off"
data-bind="value: name, hasfocus: nameFocused"> data-bind="value: name, hasfocus: $root.nameFocused">
</div> </div>
</div> </div>
@ -67,6 +67,35 @@
autocomplete="off" autocorrect="off" autocapitalize="off" autocomplete="off" autocorrect="off" autocapitalize="off"
data-bind="value: bcc"> data-bind="value: bcc">
</div> </div>
<div class="legend" data-i18n="CONTACTS/TAB_CRYPTO"></div>
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'OPENPGP/LABEL_SIGN',
value: pgpSign,
name: 'PgpSign'
}
}"></div>
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'OPENPGP/LABEL_ENCRYPT',
value: pgpEncrypt,
name: 'PgpEncrypt'
}
}"></div>
<!--
<div class="control-group">
<label data-i18n="OPENPGP/LABEL_ENCRYPT"></label>
<select name="PgpEncrypt" data-bind="value: pgpEncrypt">
<option value="Ask" data-i18n="CONTACTS/ASK"></option>
<option value="Never" data-i18n="CONTACTS/NEVER"></option>
<option value="Always" data-i18n="CONTACTS/ALWAYS"></option>
<option value="IfPossible" data-i18n="CONTACTS/ALWAYS_IF_POSSIBLE"></option>
</select>
</div>
-->
</div> </div>
</div> </div>
</form> </form>