aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/pgpinfo.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/pgpinfo.go')
-rw-r--r--widgets/pgpinfo.go34
1 files changed, 16 insertions, 18 deletions
diff --git a/widgets/pgpinfo.go b/widgets/pgpinfo.go
index 94fb8772..5da91412 100644
--- a/widgets/pgpinfo.go
+++ b/widgets/pgpinfo.go
@@ -3,40 +3,40 @@ package widgets
import (
"errors"
- "git.sr.ht/~sircmpwn/aerc/config"
"git.sr.ht/~sircmpwn/aerc/lib/ui"
+ "github.com/gdamore/tcell"
"golang.org/x/crypto/openpgp"
pgperrors "golang.org/x/crypto/openpgp/errors"
)
type PGPInfo struct {
ui.Invalidatable
- details *openpgp.MessageDetails
- uiConfig config.UIConfig
+ details *openpgp.MessageDetails
}
-func NewPGPInfo(details *openpgp.MessageDetails, uiConfig config.UIConfig) *PGPInfo {
- return &PGPInfo{details: details, uiConfig: uiConfig}
+func NewPGPInfo(details *openpgp.MessageDetails) *PGPInfo {
+ return &PGPInfo{details: details}
}
func (p *PGPInfo) DrawSignature(ctx *ui.Context) {
- errorStyle := p.uiConfig.GetStyle(config.STYLE_ERROR)
- warningStyle := p.uiConfig.GetStyle(config.STYLE_WARNING)
- validStyle := p.uiConfig.GetStyle(config.STYLE_SUCCESS)
- defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT)
+ errorStyle := tcell.StyleDefault.Background(tcell.ColorRed).
+ Foreground(tcell.ColorWhite).Bold(true)
+ softErrorStyle := tcell.StyleDefault.Foreground(tcell.ColorYellow).Bold(true)
+ validStyle := tcell.StyleDefault.Foreground(tcell.ColorGreen).Bold(true)
// TODO: Nicer prompt for TOFU, fetch from keyserver, etc
if errors.Is(p.details.SignatureError, pgperrors.ErrUnknownIssuer) ||
p.details.SignedBy == nil {
- x := ctx.Printf(0, 0, warningStyle, "*")
- x += ctx.Printf(x, 0, defaultStyle,
+ x := ctx.Printf(0, 0, softErrorStyle, "*")
+ x += ctx.Printf(x, 0, tcell.StyleDefault,
" Signed with unknown key (%8X); authenticity unknown",
p.details.SignedByKeyId)
} else if p.details.SignatureError != nil {
x := ctx.Printf(0, 0, errorStyle, "Invalid signature!")
- x += ctx.Printf(x, 0, errorStyle,
+ x += ctx.Printf(x, 0, tcell.StyleDefault.
+ Foreground(tcell.ColorRed).Bold(true),
" This message may have been tampered with! (%s)",
p.details.SignatureError.Error())
} else {
@@ -44,26 +44,24 @@ func (p *PGPInfo) DrawSignature(ctx *ui.Context) {
ident := entity.PrimaryIdentity()
x := ctx.Printf(0, 0, validStyle, "✓ Authentic ")
- x += ctx.Printf(x, 0, defaultStyle,
+ x += ctx.Printf(x, 0, tcell.StyleDefault,
"Signature from %s (%8X)",
ident.Name, p.details.SignedByKeyId)
}
}
func (p *PGPInfo) DrawEncryption(ctx *ui.Context, y int) {
- validStyle := p.uiConfig.GetStyle(config.STYLE_SUCCESS)
- defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT)
+ validStyle := tcell.StyleDefault.Foreground(tcell.ColorGreen).Bold(true)
entity := p.details.DecryptedWith.Entity
ident := entity.PrimaryIdentity()
x := ctx.Printf(0, y, validStyle, "✓ Encrypted ")
- x += ctx.Printf(x, y, defaultStyle,
+ x += ctx.Printf(x, y, tcell.StyleDefault,
"To %s (%8X) ", ident.Name, p.details.DecryptedWith.PublicKey.KeyId)
}
func (p *PGPInfo) Draw(ctx *ui.Context) {
- defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT)
- ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', defaultStyle)
+ ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
if p.details.IsSigned && p.details.IsEncrypted {
p.DrawSignature(ctx)
p.DrawEncryption(ctx, 1)