about summary refs log tree commit diff stats
path: root/src/pgp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-09-01 20:16:04 +0100
committerJames Booth <boothj5@gmail.com>2015-09-01 20:16:04 +0100
commit1f4fd0fcb3ee7e38bfab2ca8613683a0186738d4 (patch)
tree53cdd1c5908dcd7bb3d937abf92b4dbb006a3fb1 /src/pgp
parentdd346eefc4f633db2047694ce49ef91314e5a5b4 (diff)
downloadprofani-tty-1f4fd0fcb3ee7e38bfab2ca8613683a0186738d4.tar.gz
Added UI function to get PGP passphrase
Diffstat (limited to 'src/pgp')
-rw-r--r--src/pgp/gpg.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c
index aeb88e5a..96821f0f 100644
--- a/src/pgp/gpg.c
+++ b/src/pgp/gpg.c
@@ -79,17 +79,20 @@ _p_gpg_free_pubkeyid(ProfPGPPubKeyId *pubkeyid)
 static gpgme_error_t *
 _p_gpg_passphrase_cb(void *hook, const char *uid_hint, const char *passphrase_info, int prev_was_bad, int fd)
 {
-    cons_show("Passphrase callback");
-    if (uid_hint) {
-        cons_show("  uid_hind: %s", uid_hint);
-    }
-    if (passphrase_info) {
-        cons_show("  passphrase_info: %s", passphrase_info);
-    }
-    if (prev_was_bad) {
-        cons_show("  prev_was_bad");
+    GString *pass_term = g_string_new("");
+
+    char *password = ui_ask_pgp_passphrase(uid_hint, prev_was_bad);
+    if (password) {
+        g_string_append(pass_term, password);
+        free(password);
     }
-    gpgme_io_writen(fd, "password\n", strlen("password\n"));
+
+    g_string_append(pass_term, "\n");
+
+    gpgme_io_writen(fd, pass_term->str, pass_term->len);
+
+    g_string_free(pass_term, TRUE);
+
     return 0;
 }