summaryrefslogtreecommitdiff
path: root/widgets/aerc.go
diff options
context:
space:
mode:
authorRay Ganardi <ray@ganardi.xyz>2020-05-19 13:06:47 +0200
committerDrew DeVault <sir@cmpwn.com>2020-05-25 09:30:20 -0400
commitc32ab765a7cfecab7a30b2c6a50d43ba69036850 (patch)
treee827cf0e08282957d508ee55946cd53c1e9cb1cd /widgets/aerc.go
parent58db517c8d79c7fd8897d8ab5d5cf9c2de67a071 (diff)
downloadaerc-c32ab765a7cfecab7a30b2c6a50d43ba69036850.zip
feat(pgp): Add <ESC> to cancel password prompt
Previously there was no way to cancel the password prompt.
Diffstat (limited to 'widgets/aerc.go')
-rw-r--r--widgets/aerc.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 23b8901..273777b 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -537,11 +537,11 @@ func (aerc *Aerc) CloseBackends() error {
return returnErr
}
-func (aerc *Aerc) GetPassword(title string, prompt string, cb func(string)) {
- aerc.getpasswd = NewGetPasswd(title, prompt, func(pw string) {
+func (aerc *Aerc) GetPassword(title string, prompt string, cb func(string, error)) {
+ aerc.getpasswd = NewGetPasswd(title, prompt, func(pw string, err error) {
aerc.getpasswd = nil
aerc.Invalidate()
- cb(pw)
+ cb(pw, err)
})
aerc.getpasswd.OnInvalidate(func(_ ui.Drawable) {
aerc.Invalidate()
@@ -553,7 +553,7 @@ func (aerc *Aerc) Initialize(ui *ui.UI) {
aerc.ui = ui
}
-func (aerc *Aerc) DecryptKeys(keys []openpgp.Key, symmetric bool) ([]byte, error) {
+func (aerc *Aerc) DecryptKeys(keys []openpgp.Key, symmetric bool) (b []byte, err error) {
// HACK HACK HACK
for _, key := range keys {
var ident *openpgp.Identity
@@ -561,14 +561,18 @@ func (aerc *Aerc) DecryptKeys(keys []openpgp.Key, symmetric bool) ([]byte, error
break
}
aerc.GetPassword("Decrypt PGP private key",
- fmt.Sprintf("Enter password for %s (%8X)",
+ fmt.Sprintf("Enter password for %s (%8X)\nPress <ESC> to cancel",
ident.Name, key.PublicKey.KeyId),
- func(pass string) {
+ func(pass string, e error) {
+ if e != nil {
+ err = e
+ return
+ }
key.PrivateKey.Decrypt([]byte(pass))
})
for aerc.getpasswd != nil {
aerc.ui.Tick()
}
}
- return nil, nil
+ return nil, err
}