Add helpers and iterate over the actx->idx instead of the BODY structure.
/*
* Implementation of `pgp_check_traditional'.
*/
-static int pgp_check_traditional_one_body(FILE *fp, struct Body *b, int tagged_only)
+static int pgp_check_traditional_one_body(FILE *fp, struct Body *b)
{
char tempfile[_POSIX_PATH_MAX];
char buf[HUGE_STRING];
if (b->type != TYPETEXT)
return 0;
- if (tagged_only && !b->tagged)
- return 0;
-
mutt_mktemp(tempfile, sizeof(tempfile));
if (mutt_decode_save_attachment(fp, b, tempfile, 0, 0) != 0)
{
return 1;
}
-int pgp_gpgme_check_traditional(FILE *fp, struct Body *b, int tagged_only)
+int pgp_gpgme_check_traditional(FILE *fp, struct Body *b, int just_one)
{
int rv = 0;
int r;
for (; b; b = b->next)
{
- if (is_multipart(b))
- rv = (pgp_gpgme_check_traditional(fp, b->parts, tagged_only) || rv);
+ if (!just_one && is_multipart(b))
+ rv = (pgp_gpgme_check_traditional(fp, b->parts, 0) || rv);
else if (b->type == TYPETEXT)
{
if ((r = mutt_is_application_pgp(b)))
rv = (rv || r);
else
- rv = (pgp_check_traditional_one_body(fp, b, tagged_only) || rv);
+ rv = (pgp_check_traditional_one_body(fp, b) || rv);
}
+
+ if (just_one)
+ break;
}
return rv;
}
int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur);
int smime_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur);
-int pgp_gpgme_check_traditional(FILE *fp, struct Body *b, int tagged_only);
+int pgp_gpgme_check_traditional (FILE *fp, struct Body *b, int just_one);
void pgp_gpgme_invoke_import(const char *fname);
int pgp_gpgme_application_handler(struct Body *m, struct State *s);
typedef int (*crypt_func_encrypted_handler_t)(struct Body *m, struct State *s);
typedef void (*crypt_func_pgp_invoke_getkeys_t)(struct Address *addr);
-typedef int (*crypt_func_pgp_check_traditional_t)(FILE *fp, struct Body *b, int tagged_only);
+typedef int (*crypt_func_pgp_check_traditional_t) (FILE *fp, struct Body *b, int just_one);
typedef struct Body *(*crypt_func_pgp_traditional_encryptsign_t)(struct Body *a, int flags, char *keylist);
typedef struct Body *(*crypt_func_pgp_make_key_attachment_t)(char *tempf);
typedef char *(*crypt_func_findkeys_t)(struct Address *adrlist, int oppenc_mode);
return pgp_make_key_attachment(tempf);
}
-static int crypt_mod_pgp_check_traditional(FILE *fp, struct Body *b, int tagged_only)
+static int crypt_mod_pgp_check_traditional(FILE *fp, struct Body *b, int just_one)
{
- return pgp_check_traditional(fp, b, tagged_only);
+ return pgp_check_traditional(fp, b, just_one);
}
static struct Body *crypt_mod_pgp_traditional_encryptsign(struct Body *a,
return pgp_gpgme_encrypted_handler(m, s);
}
-static int crypt_mod_pgp_check_traditional(FILE *fp, struct Body *b, int tagged_only)
+static int crypt_mod_pgp_check_traditional(FILE *fp, struct Body *b, int just_one)
{
- return pgp_gpgme_check_traditional(fp, b, tagged_only);
+ return pgp_gpgme_check_traditional(fp, b, just_one);
}
static void crypt_mod_pgp_invoke_import(const char *fname)
/**
* crypt_pgp_check_traditional - Check for a traditional PGP message in body B
*/
-int crypt_pgp_check_traditional(FILE *fp, struct Body *b, int tagged_only)
+int crypt_pgp_check_traditional(FILE *fp, struct Body *b, int just_one)
{
if (CRYPT_MOD_CALL_CHECK(PGP, pgp_check_traditional))
- return (CRYPT_MOD_CALL(PGP, pgp_check_traditional))(fp, b, tagged_only);
+ return (CRYPT_MOD_CALL(PGP, pgp_check_traditional))(fp, b, just_one);
return 0;
}
int crypt_pgp_application_pgp_handler(struct Body *m, struct State *s);
int crypt_pgp_encrypted_handler(struct Body *a, struct State *s);
void crypt_pgp_invoke_getkeys(struct Address *addr);
-int crypt_pgp_check_traditional(FILE *fp, struct Body *b, int tagged_only);
+int crypt_pgp_check_traditional (FILE *fp, struct Body *b, int just_one);
struct Body *crypt_pgp_make_key_attachment(char *tempf);
int crypt_pgp_send_menu(struct Header *msg);
void crypt_pgp_extract_keys_from_attachment_list(FILE *fp, int tag, struct Body *top);
return rc;
}
-static int pgp_check_traditional_one_body(FILE *fp, struct Body *b, int tagged_only)
+static int pgp_check_traditional_one_body(FILE *fp, struct Body *b)
{
char tempfile[_POSIX_PATH_MAX];
char buf[HUGE_STRING];
if (b->type != TYPETEXT)
return 0;
- if (tagged_only && !b->tagged)
- return 0;
-
mutt_mktemp(tempfile, sizeof(tempfile));
if (mutt_decode_save_attachment(fp, b, tempfile, 0, 0) != 0)
{
return 1;
}
-int pgp_check_traditional(FILE *fp, struct Body *b, int tagged_only)
+int pgp_check_traditional(FILE *fp, struct Body *b, int just_one)
{
int rv = 0;
int r;
for (; b; b = b->next)
{
- if (is_multipart(b))
- rv = pgp_check_traditional(fp, b->parts, tagged_only) || rv;
+ if (!just_one && is_multipart(b))
+ rv = pgp_check_traditional(fp, b->parts, 0) || rv;
else if (b->type == TYPETEXT)
{
if ((r = mutt_is_application_pgp(b)))
rv = rv || r;
else
- rv = pgp_check_traditional_one_body(fp, b, tagged_only) || rv;
+ rv = pgp_check_traditional_one_body(fp, b) || rv;
}
+
+ if (just_one)
+ break;
}
return rv;
print_attachment_list(actx, fp, tag, top, &state);
}
+static void recvattach_extract_pgp_keys(struct AttachCtx *actx, struct Menu *menu)
+{
+ int i;
+
+ if (!menu->tagprefix)
+ crypt_pgp_extract_keys_from_attachment_list(CURATTACH->fp, 0, CURATTACH->content);
+ else
+ {
+ for (i = 0; i < actx->idxlen; i++)
+ if (actx->idx[i]->content->tagged)
+ crypt_pgp_extract_keys_from_attachment_list(actx->idx[i]->fp, 0,
+ actx->idx[i]->content);
+ }
+}
+
+static int recvattach_pgp_check_traditional(struct AttachCtx *actx, struct Menu *menu)
+{
+ int i, rv = 0;
+
+ if (!menu->tagprefix)
+ rv = crypt_pgp_check_traditional(CURATTACH->fp, CURATTACH->content, 1);
+ else
+ {
+ for (i = 0; i < actx->idxlen; i++)
+ if (actx->idx[i]->content->tagged)
+ rv = rv || crypt_pgp_check_traditional(actx->idx[i]->fp, actx->idx[i]->content, 1);
+ }
+
+ return rv;
+}
+
int mutt_attach_display_loop(struct Menu *menu, int op, struct Header *hdr,
struct AttachCtx *actx, int recv)
{
case OP_EXTRACT_KEYS:
if ((WithCrypto & APPLICATION_PGP))
{
- crypt_pgp_extract_keys_from_attachment_list(
- fp, menu->tagprefix, menu->tagprefix ? cur : CURATTACH->content);
+ recvattach_extract_pgp_keys(actx, menu);
menu->redraw = REDRAW_FULL;
}
break;
case OP_CHECK_TRADITIONAL:
- if ((WithCrypto & APPLICATION_PGP) &&
- crypt_pgp_check_traditional(fp, menu->tagprefix ? cur : CURATTACH->content,
- menu->tagprefix))
+ if ((WithCrypto & APPLICATION_PGP) && recvattach_pgp_check_traditional(actx, menu))
{
hdr->security = crypt_query(cur);
menu->redraw = REDRAW_FULL;