~ubuntu-dev/ubuntu/lucid/mutt/lucid-201002110857

« back to all changes in this revision

Viewing changes to postpone.c

  • Committer: Bazaar Package Importer
  • Author(s): أحمد المحمودي (Ahmed El-Mahmoudy)
  • Date: 2009-06-17 17:17:28 UTC
  • mfrom: (1.1.11 upstream) (16.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090617171728-lj10l5x2m2vg6cag
Tags: 1.5.20-1ubuntu1
* Merge from debian unstable (LP: #388515)
* Build-depend on elinks-lite
  + elinks-lite doesn't provide links anymore.
  + elinks-lite is now in main, and pulls less dependencies than the
    full-fledged elinks.
* debian/control: Recommend default-mta instead of exim4. (LP: #386308)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
3
3
 * Copyright (C) 1999-2002,2004 Thomas Roessler <roessler@does-not-exist.org>
4
 
 * 
 
4
 *
5
5
 *     This program is free software; you can redistribute it and/or modify
6
6
 *     it under the terms of the GNU General Public License as published by
7
7
 *     the Free Software Foundation; either version 2 of the License, or
8
8
 *     (at your option) any later version.
9
 
 * 
 
9
 *
10
10
 *     This program is distributed in the hope that it will be useful,
11
11
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
13
 *     GNU General Public License for more details.
14
 
 * 
 
14
 *
15
15
 *     You should have received a copy of the GNU General Public License
16
16
 *     along with this program; if not, write to the Free Software
17
17
 *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
 
 */ 
 
18
 */
19
19
 
20
20
#if HAVE_CONFIG_H
21
21
# include "config.h"
42
42
  { N_("Del"),   OP_DELETE },
43
43
  { N_("Undel"), OP_UNDELETE },
44
44
  { N_("Help"),  OP_HELP },
45
 
  { NULL }
 
45
  { NULL,        0 }
46
46
};
47
47
 
48
48
 
69
69
    force = 1;
70
70
  }
71
71
 
72
 
  if (Postponed != OldPostponed)
 
72
  if (mutt_strcmp (Postponed, OldPostponed))
73
73
  {
74
 
    OldPostponed = Postponed;
 
74
    OldPostponed = safe_strdup (Postponed);
75
75
    LastModify = 0;
76
76
    force = 1;
77
77
  }
170
170
   * disabled while the postpone menu is being displayed. */
171
171
  orig_sort = Sort;
172
172
  Sort = SORT_ORDER;
173
 
  
 
173
 
174
174
  while (!done)
175
175
  {
176
176
    switch (i = mutt_menuLoop (menu))
244
244
    mutt_error _("No postponed messages.");
245
245
    return (-1);
246
246
  }
247
 
  
 
247
 
248
248
  if (! PostContext->msgcount)
249
249
  {
250
250
    PostCount = 0;
340
340
      hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1,
341
341
                                            APPLICATION_PGP);
342
342
      hdr->security |= APPLICATION_PGP;
343
 
       
 
343
 
344
344
      /* remove the pgp field */
345
345
      next = tmp->next;
346
346
      if (last)
357
357
      hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1,
358
358
                                            APPLICATION_SMIME);
359
359
      hdr->security |= APPLICATION_SMIME;
360
 
       
 
360
 
361
361
      /* remove the smime field */
362
362
      next = tmp->next;
363
363
      if (last)
374
374
    {
375
375
      char *t;
376
376
      mutt_free_list (&hdr->chain);
377
 
      
 
377
 
378
378
      t = strtok (tmp->data + 11, " \t\n");
379
379
      while (t)
380
380
      {
381
381
        hdr->chain = mutt_add_list (hdr->chain, t);
382
382
        t = strtok (NULL, " \t\n");
383
383
      }
384
 
      
 
384
 
385
385
      next = tmp->next;
386
 
      if (last) 
 
386
      if (last)
387
387
        last->next = tmp->next;
388
388
      else
389
389
        hdr->env->userhdrs = tmp->next;
412
412
 
413
413
  if (!WithCrypto)
414
414
    return 0;
415
 
   
 
415
 
416
416
  SKIPWS (p);
417
417
  for (; *p; p++)
418
 
  {    
419
 
     
 
418
  {
 
419
 
420
420
    switch (*p)
421
421
    {
422
422
      case 'e':
424
424
        flags |= ENCRYPT;
425
425
        break;
426
426
 
427
 
      case 's':    
 
427
      case 's':
428
428
      case 'S':
429
429
        flags |= SIGN;
430
430
        q = sign_as;
431
 
      
 
431
 
432
432
        if (*(p+1) == '<')
433
433
        {
434
 
          for (p += 2; 
 
434
          for (p += 2;
435
435
               *p && *p != '>' && q < sign_as + sizeof (sign_as) - 1;
436
436
               *q++ = *p++)
437
437
            ;
442
442
            return 0;
443
443
          }
444
444
        }
445
 
       
 
445
 
446
446
        *q = '\0';
447
447
        break;
448
448
 
449
449
      /* This used to be the micalg parameter.
450
 
       * 
 
450
       *
451
451
       * It's no longer needed, so we just skip the parameter in order
452
452
       * to be able to recall old messages.
453
453
       */
465
465
        }
466
466
 
467
467
        break;
468
 
          
469
 
          
 
468
 
 
469
 
470
470
      case 'c':
471
471
      case 'C':
472
472
        q = smime_cryptalg;
473
 
        
 
473
 
474
474
        if(*(p+1) == '<')
475
475
        {
476
476
          for(p += 2; *p && *p != '>' && q < smime_cryptalg + sizeof(smime_cryptalg) - 1;
477
477
              *q++ = *p++)
478
478
            ;
479
 
          
 
479
 
480
480
          if(*p != '>')
481
481
          {
482
482
            mutt_error _("Illegal S/MIME header");
496
496
        mutt_error _("Illegal crypto header");
497
497
        return 0;
498
498
    }
499
 
     
 
499
 
500
500
  }
501
501
 
502
502
  /* the cryptalg field must not be empty */
525
525
  char file[_POSIX_PATH_MAX];
526
526
  BODY *b;
527
527
  FILE *bfp;
528
 
  
 
528
 
529
529
  int rv = -1;
530
530
  STATE s;
531
 
  
 
531
 
532
532
  memset (&s, 0, sizeof (s));
533
 
  
 
533
 
534
534
  if (!fp && (msg = mx_open_message (ctx, hdr->msgno)) == NULL)
535
535
    return (-1);
536
536
 
560
560
      goto err;
561
561
 
562
562
    mutt_message _("Decrypting message...");
563
 
    if (((ccap & APPLICATION_PGP) && crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) 
564
 
        || ((ccap & APPLICATION_SMIME) && crypt_smime_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) 
 
563
    if (((ccap & APPLICATION_PGP) && crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1)
 
564
        || ((ccap & APPLICATION_SMIME) && crypt_smime_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1)
565
565
        || b == NULL)
566
566
    {
567
567
 err:
578
578
    mutt_clear_error ();
579
579
  }
580
580
 
581
 
  /* 
 
581
  /*
582
582
   * remove a potential multipart/signed layer - useful when
583
 
   * resending messages 
 
583
   * resending messages
584
584
   */
585
 
  
 
585
 
586
586
  if (WithCrypto && mutt_is_multipart_signed (newhdr->content))
587
587
  {
588
588
    newhdr->security |= SIGN;
591
591
      newhdr->security |= APPLICATION_PGP;
592
592
    else if ((WithCrypto & APPLICATION_SMIME))
593
593
      newhdr->security |= APPLICATION_SMIME;
594
 
    
 
594
 
595
595
    /* destroy the signature */
596
596
    mutt_free_body (&newhdr->content->parts->next);
597
597
    newhdr->content = mutt_remove_multipart (newhdr->content);
598
598
  }
599
599
 
600
600
 
601
 
  /* 
 
601
  /*
602
602
   * We don't need no primary multipart.
603
603
   * Note: We _do_ preserve messages!
604
 
   * 
605
 
   * XXX - we don't handle multipart/alternative in any 
 
604
   *
 
605
   * XXX - we don't handle multipart/alternative in any
606
606
   * smart way when sending messages.  However, one may
607
607
   * consider this a feature.
608
 
   * 
 
608
   *
609
609
   */
610
610
 
611
611
  if (newhdr->content->type == TYPEMULTIPART)
612
612
    newhdr->content = mutt_remove_multipart (newhdr->content);
613
613
 
614
614
  s.fpin = bfp;
615
 
  
 
615
 
616
616
  /* create temporary files for all attachments */
617
617
  for (b = newhdr->content; b; b = b->next)
618
618
  {
619
 
    
 
619
 
620
620
    /* what follows is roughly a receive-mode variant of
621
621
     * mutt_get_tmp_attachment () from muttlib.c
622
622
     */
654
654
    if ((s.fpout = safe_fopen (file, "w")) == NULL)
655
655
      goto bail;
656
656
 
657
 
    
658
 
    if ((WithCrypto & APPLICATION_PGP) 
 
657
 
 
658
    if ((WithCrypto & APPLICATION_PGP)
659
659
        && (mutt_is_application_pgp (b) & (ENCRYPT|SIGN)))
660
660
    {
661
 
      
 
661
 
662
662
      mutt_body_handler (b, &s);
663
663
 
664
664
      newhdr->security |= mutt_is_application_pgp (newhdr->content);
683
683
  }
684
684
 
685
685
  /* Fix encryption flags. */
686
 
  
 
686
 
687
687
  /* No inline if multipart. */
688
688
  if (WithCrypto && (newhdr->security & INLINE) && newhdr->content->next)
689
689
    newhdr->security &= ~INLINE;
690
 
  
 
690
 
691
691
  /* Do we even support multiple mechanisms? */
692
692
  newhdr->security &= WithCrypto | ~(APPLICATION_PGP|APPLICATION_SMIME);
693
 
  
 
693
 
694
694
  /* Theoretically, both could be set. Take the one the user wants to set by default. */
695
695
  if ((newhdr->security & APPLICATION_PGP) && (newhdr->security & APPLICATION_SMIME))
696
696
  {
701
701
  }
702
702
 
703
703
  rv = 0;
704
 
  
 
704
 
705
705
  bail:
706
 
  
 
706
 
707
707
  /* that's it. */
708
 
  if (bfp != fp) fclose (bfp);
 
708
  if (bfp != fp) safe_fclose (&bfp);
709
709
  if (msg) mx_close_message (&msg);
710
 
  
 
710
 
711
711
  if (rv == -1)
712
712
  {
713
713
    mutt_free_envelope (&newhdr->env);
714
714
    mutt_free_body (&newhdr->content);
715
715
  }
716
 
  
 
716
 
717
717
  return rv;
718
718
}