about summary refs log tree commit diff stats
path: root/widgets
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-03-03 19:02:27 -0500
committerDrew DeVault <sir@cmpwn.com>2020-03-03 19:04:05 -0500
commitf79813ada358249cbd6451752809d39b01f12f7a (patch)
treec2072a08ba12587d951ca828c767f8914f70301c /widgets
parent403b6af37916aad984fb340147a499f61daf1132 (diff)
downloadaerc-f79813ada358249cbd6451752809d39b01f12f7a.tar.gz
Simplify PGP messaging
Diffstat (limited to 'widgets')
-rw-r--r--widgets/pgpinfo.go31
1 files changed, 11 insertions, 20 deletions
diff --git a/widgets/pgpinfo.go b/widgets/pgpinfo.go
index b6a7a16..292f1d1 100644
--- a/widgets/pgpinfo.go
+++ b/widgets/pgpinfo.go
@@ -19,29 +19,22 @@ func NewPGPInfo(details *openpgp.MessageDetails) *PGPInfo {
 	return &PGPInfo{details: details}
 }
 
-func (p *PGPInfo) DrawSignature(ctx *ui.Context, offs bool) {
+func (p *PGPInfo) DrawSignature(ctx *ui.Context) {
 	errorStyle := tcell.StyleDefault.Background(tcell.ColorRed).
 		Foreground(tcell.ColorWhite).Bold(true)
-	softErrorStyle := tcell.StyleDefault.Foreground(tcell.ColorYellow).
-		Reverse(true).Bold(true)
+	softErrorStyle := tcell.StyleDefault.Foreground(tcell.ColorYellow).Bold(true)
 	validStyle := tcell.StyleDefault.Foreground(tcell.ColorGreen).Bold(true)
-	header := "Signature "
-	if offs {
-		header += " "
-	}
 
 	// 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, tcell.StyleDefault.Bold(true), "%s", header)
-		x += ctx.Printf(x, 0, softErrorStyle, " Unknown ")
+		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, tcell.StyleDefault.Bold(true), "%s", header)
-		x += ctx.Printf(x, 0, errorStyle, " ✗ Invalid! ")
+		x := ctx.Printf(0, 0, errorStyle, "Invalid signature!")
 		x += ctx.Printf(x, 0, tcell.StyleDefault.
 			Foreground(tcell.ColorRed).Bold(true),
 			" This message may have been tampered with! (%s)",
@@ -53,11 +46,10 @@ func (p *PGPInfo) DrawSignature(ctx *ui.Context, offs bool) {
 		for _, ident = range entity.Identities {
 			break
 		}
-		ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', validStyle)
-		x := ctx.Printf(0, 0, tcell.StyleDefault.Bold(true), "%s", header)
-		x += ctx.Printf(x, 0, validStyle, "✓ Signed ")
+		x := ctx.Printf(0, 0, validStyle, "✓ ")
 		x += ctx.Printf(x, 0, tcell.StyleDefault,
-			"by %s (%8X)", ident.Name, p.details.SignedByKeyId)
+			"Authentic signature from %s (%8X)",
+			ident.Name, p.details.SignedByKeyId)
 	}
 }
 
@@ -70,19 +62,18 @@ func (p *PGPInfo) DrawEncryption(ctx *ui.Context, y int) {
 		break
 	}
 
-	x := ctx.Printf(0, y, tcell.StyleDefault.Bold(true), "Encryption ")
-	x += ctx.Printf(x, y, validStyle, "✓ Encrypted ")
+	x := ctx.Printf(0, y, validStyle, "✓ ")
 	x += ctx.Printf(x, y, tcell.StyleDefault,
-		"for %s (%8X) ", ident.Name, p.details.DecryptedWith.PublicKey.KeyId)
+		"Encrypted for %s (%8X) ", ident.Name, p.details.DecryptedWith.PublicKey.KeyId)
 }
 
 func (p *PGPInfo) Draw(ctx *ui.Context) {
 	ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
 	if p.details.IsSigned && p.details.IsEncrypted {
-		p.DrawSignature(ctx, true)
+		p.DrawSignature(ctx)
 		p.DrawEncryption(ctx, 1)
 	} else if p.details.IsSigned {
-		p.DrawSignature(ctx, false)
+		p.DrawSignature(ctx)
 	} else if p.details.IsEncrypted {
 		p.DrawEncryption(ctx, 0)
 	}