- int i;
- char tempfname[_POSIX_PATH_MAX], *mbox;
- address_t *tmp = NULL;
- FILE *fpout;
-
- fpout = m_tempfile(tempfname, sizeof(tempfname), NONULL(Tempdir), NULL);
- if (!fpout) {
- mutt_error(_("Could not create temporary file"));
- return;
- }
-
- set_option (OPTDONTHANDLEPGPKEYS);
-
- if (!h) {
- for (i = 0; i < Context->vcount; i++) {
- if (Context->hdrs[Context->v2r[i]]->tagged) {
- mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
- if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
- !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
- security)) {
- m_fclose(&fpout);
- break;
- }
-
- if (Context->hdrs[Context->v2r[i]]->security & APPLICATION_PGP) {
- mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
- M_CM_DECODE | M_CM_CHARCONV, 0);
- fflush (fpout);
-
- mutt_endwin (_("Trying to extract PGP keys...\n"));
- crypt_pgp_invoke_import (tempfname);
- }
-
- if (Context->hdrs[Context->v2r[i]]->security & APPLICATION_SMIME) {
- if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT)
- mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
- M_CM_NOHEADER | M_CM_DECODE_CRYPT
- | M_CM_DECODE_SMIME, 0);
- else
- mutt_copy_message (fpout, Context,
- Context->hdrs[Context->v2r[i]], 0, 0);
- fflush (fpout);
-
- if (Context->hdrs[Context->v2r[i]]->env->from)
- tmp = mutt_expand_aliases (h->env->from);
- else if (Context->hdrs[Context->v2r[i]]->env->sender)
- tmp = mutt_expand_aliases (Context->hdrs[Context->v2r[i]]
- ->env->sender);
- mbox = tmp ? tmp->mailbox : NULL;
- if (mbox) {
- mutt_endwin (_("Trying to extract S/MIME certificates...\n"));
- crypt_smime_invoke_import (tempfname, mbox);
- tmp = NULL;
- }
- }
-
- rewind (fpout);
- }
- }
- }
- else {