X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/14c29200cb58d3c4a0830265f2433849781858d0..2a21a8d0e236c24d3b12a57730e867c958f9d38c:/postpone.c?ds=sidebyside diff --git a/postpone.c b/postpone.c index bcb8607..fa3ec64 100644 --- a/postpone.c +++ b/postpone.c @@ -1,21 +1,21 @@ /* * Copyright (C) 1996-2002 Michael R. Elkins - * Copyright (C) 1999-2000 Thomas Roessler - * + * Copyright (C) 1999-2002,2004 Thomas Roessler + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ + */ #if HAVE_CONFIG_H # include "config.h" @@ -23,13 +23,11 @@ #include "mutt.h" #include "mutt_menu.h" -#include "rfc1524.h" #include "mime.h" #include "mailbox.h" #include "mapping.h" #include "sort.h" #ifdef USE_IMAP -#include "mx.h" #include "imap.h" #endif #include "mutt_crypt.h" @@ -44,7 +42,7 @@ static struct mapping_t PostponeHelp[] = { { N_("Del"), OP_DELETE }, { N_("Undel"), OP_UNDELETE }, { N_("Help"), OP_HELP }, - { NULL } + { NULL, 0 } }; @@ -71,9 +69,10 @@ int mutt_num_postponed (int force) force = 1; } - if (Postponed != OldPostponed) + if (mutt_strcmp (Postponed, OldPostponed)) { - OldPostponed = Postponed; + FREE (&OldPostponed); + OldPostponed = safe_strdup (Postponed); LastModify = 0; force = 1; } @@ -93,10 +92,10 @@ int mutt_num_postponed (int force) if (newpc >= 0) { PostCount = newpc; - dprint (2, (debugfile, "mutt_num_postponed: %d postponed IMAP messages found.\n", PostCount)); + dprint (3, (debugfile, "mutt_num_postponed: %d postponed IMAP messages found.\n", PostCount)); } else - dprint (2, (debugfile, "mutt_num_postponed: using old IMAP postponed count.\n")); + dprint (3, (debugfile, "mutt_num_postponed: using old IMAP postponed count.\n")); } return PostCount; } @@ -160,9 +159,8 @@ static HEADER *select_msg (void) char helpstr[LONG_STRING]; short orig_sort; - menu = mutt_new_menu (); + menu = mutt_new_menu (MENU_POST); menu->make_entry = post_entry; - menu->menu = MENU_POST; menu->max = PostContext->msgcount; menu->title = _("Postponed Messages"); menu->data = PostContext; @@ -173,7 +171,7 @@ static HEADER *select_msg (void) * disabled while the postpone menu is being displayed. */ orig_sort = Sort; Sort = SORT_ORDER; - + while (!done) { switch (i = mutt_menuLoop (menu)) @@ -247,7 +245,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size mutt_error _("No postponed messages."); return (-1); } - + if (! PostContext->msgcount) { PostCount = 0; @@ -322,7 +320,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size p = tmp->data + 11; SKIPWS (p); strfcpy (fcc, p, fcclen); - mutt_pretty_mailbox (fcc); + mutt_pretty_mailbox (fcc, fcclen); /* remove the X-Mutt-Fcc: header field */ next = tmp->next; @@ -343,7 +341,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1, APPLICATION_PGP); hdr->security |= APPLICATION_PGP; - + /* remove the pgp field */ next = tmp->next; if (last) @@ -360,7 +358,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1, APPLICATION_SMIME); hdr->security |= APPLICATION_SMIME; - + /* remove the smime field */ next = tmp->next; if (last) @@ -377,16 +375,16 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size { char *t; mutt_free_list (&hdr->chain); - + t = strtok (tmp->data + 11, " \t\n"); while (t) { hdr->chain = mutt_add_list (hdr->chain, t); t = strtok (NULL, " \t\n"); } - + next = tmp->next; - if (last) + if (last) last->next = tmp->next; else hdr->env->userhdrs = tmp->next; @@ -415,11 +413,11 @@ int mutt_parse_crypt_hdr (char *p, int set_signas, int crypt_app) if (!WithCrypto) return 0; - + SKIPWS (p); for (; *p; p++) - { - + { + switch (*p) { case 'e': @@ -427,14 +425,14 @@ int mutt_parse_crypt_hdr (char *p, int set_signas, int crypt_app) flags |= ENCRYPT; break; - case 's': + case 's': case 'S': flags |= SIGN; q = sign_as; - + if (*(p+1) == '<') { - for (p += 2; + for (p += 2; *p && *p != '>' && q < sign_as + sizeof (sign_as) - 1; *q++ = *p++) ; @@ -445,12 +443,12 @@ int mutt_parse_crypt_hdr (char *p, int set_signas, int crypt_app) return 0; } } - + *q = '\0'; break; /* This used to be the micalg parameter. - * + * * It's no longer needed, so we just skip the parameter in order * to be able to recall old messages. */ @@ -468,18 +466,18 @@ int mutt_parse_crypt_hdr (char *p, int set_signas, int crypt_app) } break; - - + + case 'c': case 'C': q = smime_cryptalg; - + if(*(p+1) == '<') { for(p += 2; *p && *p != '>' && q < smime_cryptalg + sizeof(smime_cryptalg) - 1; *q++ = *p++) ; - + if(*p != '>') { mutt_error _("Illegal S/MIME header"); @@ -499,7 +497,7 @@ int mutt_parse_crypt_hdr (char *p, int set_signas, int crypt_app) mutt_error _("Illegal crypto header"); return 0; } - + } /* the cryptalg field must not be empty */ @@ -528,12 +526,12 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, char file[_POSIX_PATH_MAX]; BODY *b; FILE *bfp; - + int rv = -1; STATE s; - + memset (&s, 0, sizeof (s)); - + if (!fp && (msg = mx_open_message (ctx, hdr->msgno)) == NULL) return (-1); @@ -563,8 +561,8 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, goto err; mutt_message _("Decrypting message..."); - if (((ccap & APPLICATION_PGP) && crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) - || ((ccap & APPLICATION_SMIME) && crypt_smime_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) + if (((ccap & APPLICATION_PGP) && crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) + || ((ccap & APPLICATION_SMIME) && crypt_smime_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) || b == NULL) { err: @@ -581,11 +579,11 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, mutt_clear_error (); } - /* + /* * remove a potential multipart/signed layer - useful when - * resending messages + * resending messages */ - + if (WithCrypto && mutt_is_multipart_signed (newhdr->content)) { newhdr->security |= SIGN; @@ -594,32 +592,32 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, newhdr->security |= APPLICATION_PGP; else if ((WithCrypto & APPLICATION_SMIME)) newhdr->security |= APPLICATION_SMIME; - + /* destroy the signature */ mutt_free_body (&newhdr->content->parts->next); newhdr->content = mutt_remove_multipart (newhdr->content); } - /* + /* * We don't need no primary multipart. * Note: We _do_ preserve messages! - * - * XXX - we don't handle multipart/alternative in any + * + * XXX - we don't handle multipart/alternative in any * smart way when sending messages. However, one may * consider this a feature. - * + * */ if (newhdr->content->type == TYPEMULTIPART) newhdr->content = mutt_remove_multipart (newhdr->content); s.fpin = bfp; - + /* create temporary files for all attachments */ for (b = newhdr->content; b; b = b->next) { - + /* what follows is roughly a receive-mode variant of * mutt_get_tmp_attachment () from muttlib.c */ @@ -657,11 +655,11 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, if ((s.fpout = safe_fopen (file, "w")) == NULL) goto bail; - - if ((WithCrypto & APPLICATION_PGP) + + if ((WithCrypto & APPLICATION_PGP) && (mutt_is_application_pgp (b) & (ENCRYPT|SIGN))) { - + mutt_body_handler (b, &s); newhdr->security |= mutt_is_application_pgp (newhdr->content); @@ -686,14 +684,14 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, } /* Fix encryption flags. */ - + /* No inline if multipart. */ if (WithCrypto && (newhdr->security & INLINE) && newhdr->content->next) newhdr->security &= ~INLINE; - + /* Do we even support multiple mechanisms? */ newhdr->security &= WithCrypto | ~(APPLICATION_PGP|APPLICATION_SMIME); - + /* Theoretically, both could be set. Take the one the user wants to set by default. */ if ((newhdr->security & APPLICATION_PGP) && (newhdr->security & APPLICATION_SMIME)) { @@ -704,18 +702,18 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, } rv = 0; - + bail: - + /* that's it. */ - if (bfp != fp) fclose (bfp); + if (bfp != fp) safe_fclose (&bfp); if (msg) mx_close_message (&msg); - + if (rv == -1) { mutt_free_envelope (&newhdr->env); mutt_free_body (&newhdr->content); } - + return rv; }