pgp: add icon for unencrypted, unsigned messages if an icon is set
Signed-off-by: Moritz Poldrack <git@moritz.sh> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
parent
ecf47542cb
commit
b7d8918bbd
|
@ -254,7 +254,8 @@ These options are configured in the *[ui]* section of aerc.conf.
|
||||||
Have a look at *aerc-stylesets*(7) as to how a styleset looks like.
|
Have a look at *aerc-stylesets*(7) as to how a styleset looks like.
|
||||||
|
|
||||||
*icon-unencrypted*
|
*icon-unencrypted*
|
||||||
The icon to display for unencrypted mails.
|
The icon to display for unencrypted mails. The status indicator is only
|
||||||
|
displayed if an icon is set.
|
||||||
|
|
||||||
Default: ""
|
Default: ""
|
||||||
|
|
||||||
|
@ -271,9 +272,10 @@ These options are configured in the *[ui]* section of aerc.conf.
|
||||||
|
|
||||||
*icon-signed-encrypted*
|
*icon-signed-encrypted*
|
||||||
The icon to display for signed and encrypted mails where the signature
|
The icon to display for signed and encrypted mails where the signature
|
||||||
was successfully verified.
|
was successfully verified. The combined icon is only used if set,
|
||||||
|
otherwise the signed and encrypted icons are displayed separately.
|
||||||
|
|
||||||
Default: [s|e]
|
Default: ""
|
||||||
|
|
||||||
*icon-unknown*
|
*icon-unknown*
|
||||||
The icon to display for signed mails which could not be verified due to
|
The icon to display for signed mails which could not be verified due to
|
||||||
|
|
|
@ -93,9 +93,9 @@ func NewMessageViewer(acct *AccountView,
|
||||||
{Strategy: ui.SIZE_EXACT, Size: ui.Const(headerHeight)},
|
{Strategy: ui.SIZE_EXACT, Size: ui.Const(headerHeight)},
|
||||||
}
|
}
|
||||||
|
|
||||||
if msg.MessageDetails() != nil {
|
if msg.MessageDetails() != nil || conf.Ui.IconUnencrypted != "" {
|
||||||
height := 1
|
height := 1
|
||||||
if msg.MessageDetails().IsSigned && msg.MessageDetails().IsEncrypted {
|
if msg.MessageDetails() != nil && msg.MessageDetails().IsSigned && msg.MessageDetails().IsEncrypted {
|
||||||
height = 2
|
height = 2
|
||||||
}
|
}
|
||||||
rows = append(rows, ui.GridSpec{Strategy: ui.SIZE_EXACT, Size: ui.Const(height)})
|
rows = append(rows, ui.GridSpec{Strategy: ui.SIZE_EXACT, Size: ui.Const(height)})
|
||||||
|
@ -125,7 +125,7 @@ func NewMessageViewer(acct *AccountView,
|
||||||
borderChar := acct.UiConfig().BorderCharHorizontal
|
borderChar := acct.UiConfig().BorderCharHorizontal
|
||||||
|
|
||||||
grid.AddChild(header).At(0, 0)
|
grid.AddChild(header).At(0, 0)
|
||||||
if msg.MessageDetails() != nil {
|
if msg.MessageDetails() != nil || conf.Ui.IconUnencrypted != "" {
|
||||||
grid.AddChild(NewPGPInfo(msg.MessageDetails(), acct.UiConfig())).At(1, 0)
|
grid.AddChild(NewPGPInfo(msg.MessageDetails(), acct.UiConfig())).At(1, 0)
|
||||||
grid.AddChild(ui.NewFill(borderChar, borderStyle)).At(2, 0)
|
grid.AddChild(ui.NewFill(borderChar, borderStyle)).At(2, 0)
|
||||||
grid.AddChild(switcher).At(3, 0)
|
grid.AddChild(switcher).At(3, 0)
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (p *PGPInfo) DrawSignature(ctx *ui.Context) {
|
||||||
p.details.SignatureError)
|
p.details.SignatureError)
|
||||||
} else {
|
} else {
|
||||||
icon := p.uiConfig.IconSigned
|
icon := p.uiConfig.IconSigned
|
||||||
if p.details.IsEncrypted {
|
if p.details.IsEncrypted && p.uiConfig.IconSignedEncrypted != "" {
|
||||||
icon = p.uiConfig.IconSignedEncrypted
|
icon = p.uiConfig.IconSignedEncrypted
|
||||||
}
|
}
|
||||||
x := ctx.Printf(0, 0, validStyle, "%s Authentic ", icon)
|
x := ctx.Printf(0, 0, validStyle, "%s Authentic ", icon)
|
||||||
|
@ -55,29 +55,34 @@ func (p *PGPInfo) DrawEncryption(ctx *ui.Context, y int) {
|
||||||
validStyle := p.uiConfig.GetStyle(config.STYLE_SUCCESS)
|
validStyle := p.uiConfig.GetStyle(config.STYLE_SUCCESS)
|
||||||
defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT)
|
defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT)
|
||||||
|
|
||||||
|
// if a sign-encrypt combination icon is set, use that
|
||||||
icon := p.uiConfig.IconEncrypted
|
icon := p.uiConfig.IconEncrypted
|
||||||
if p.details.IsSigned && p.details.SignatureValidity == models.Valid {
|
if p.details.IsSigned && p.details.SignatureValidity == models.Valid && p.uiConfig.IconSignedEncrypted != "" {
|
||||||
icon = strings.Repeat(" ", utf8.RuneCountInString(p.uiConfig.IconSignedEncrypted))
|
icon = strings.Repeat(" ", utf8.RuneCountInString(p.uiConfig.IconSignedEncrypted))
|
||||||
}
|
}
|
||||||
|
|
||||||
x := ctx.Printf(0, y, validStyle, "%s Encrypted", icon)
|
x := ctx.Printf(0, y, validStyle, "%s Encrypted", icon)
|
||||||
x += ctx.Printf(x, y, defaultStyle,
|
x += ctx.Printf(x+1, y, defaultStyle, "To %s (%8X) ", p.details.DecryptedWith, p.details.DecryptedWithKeyId)
|
||||||
"To %s (%8X) ", p.details.DecryptedWith, p.details.DecryptedWithKeyId)
|
|
||||||
if !p.details.IsSigned {
|
if !p.details.IsSigned {
|
||||||
x += ctx.Printf(x, y, warningStyle,
|
x += ctx.Printf(x, y, warningStyle, "(message not signed!)")
|
||||||
"(message not signed!)")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PGPInfo) Draw(ctx *ui.Context) {
|
func (p *PGPInfo) Draw(ctx *ui.Context) {
|
||||||
|
warningStyle := p.uiConfig.GetStyle(config.STYLE_WARNING)
|
||||||
defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT)
|
defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT)
|
||||||
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', defaultStyle)
|
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', defaultStyle)
|
||||||
if p.details.IsSigned && p.details.IsEncrypted {
|
|
||||||
|
switch {
|
||||||
|
case p.details == nil && p.uiConfig.IconUnencrypted != "":
|
||||||
|
x := ctx.Printf(0, 0, warningStyle, "%s ", p.uiConfig.IconUnencrypted)
|
||||||
|
ctx.Printf(x, 0, defaultStyle, "message unencrypted and unsigned")
|
||||||
|
case p.details.IsSigned && p.details.IsEncrypted:
|
||||||
p.DrawSignature(ctx)
|
p.DrawSignature(ctx)
|
||||||
p.DrawEncryption(ctx, 1)
|
p.DrawEncryption(ctx, 1)
|
||||||
} else if p.details.IsSigned {
|
case p.details.IsSigned:
|
||||||
p.DrawSignature(ctx)
|
p.DrawSignature(ctx)
|
||||||
} else if p.details.IsEncrypted {
|
case p.details.IsEncrypted:
|
||||||
p.DrawEncryption(ctx, 0)
|
p.DrawEncryption(ctx, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue