NULL
};
-
-struct passphrase_cb_info_s {
- GpgmeCtx c;
- int did_it;
-};
-
/* stolen from rfc2015.c */
static int
gpg_name_cmp(const char *a, const char *b)
return *a != *b;
}
-static const char *
-passphrase_cb (void *opaque, const char *desc, void *r_hd)
-{
- struct passphrase_cb_info_s *info = opaque;
- GpgmeCtx ctx = info ? info->c : NULL;
- const char *pass;
-
- if (!desc) {
- /* FIXME: cleanup by looking at *r_hd */
- return NULL;
- }
-
- gpgmegtk_set_passphrase_grab (prefs_common.passphrase_grab);
- debug_print ("requesting passphrase for `%s': ", desc);
- pass = gpgmegtk_passphrase_mbox (desc);
- if (!pass) {
- debug_print ("cancel passphrase entry\n");
- gpgme_cancel (ctx);
- }
- else
- debug_print ("sending passphrase\n");
-
- return pass;
-}
-
static GpgmeData
pgptext_decrypt (MimeInfo *partinfo, FILE *fp)
{
if (!getenv("GPG_AGENT_INFO")) {
info.c = ctx;
- gpgme_set_passphrase_cb (ctx, passphrase_cb, &info);
+ gpgme_set_passphrase_cb (ctx, gpgmegtk_passphrase_cb, &info);
}
err = gpgme_op_decrypt (ctx, cipher, plain);
leave:
gpgme_data_release (cipher);
if (err) {
+ gpgmegtk_free_passphrase();
debug_print ("decryption failed: %s\n", gpgme_strerror (err));
gpgme_data_release (plain);
plain = NULL;