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

« back to all changes in this revision

Viewing changes to recvattach.c

  • Committer: Bazaar Package Importer
  • Author(s): Antonio Radici
  • Date: 2009-06-14 20:53:18 UTC
  • mfrom: (1.3.1 upstream)
  • mto: (2.1.3 squeeze)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20090614205318-wf0sqy1o3km636li
Tags: 1.5.20-1
* New upstream release, includes the following features:
  + Bounced messages contains From: headers (Closes: 93268)
  + Attachments displayed based on Content-Disposition (Closes: 199709)
  + fcc to a mailbox does not raise the 'new' flag (Closes: 209390)
  + '!' supported as suffix in gpg keys (Closes: 277945)
  + failed attachment saving shows an error message (Closes: 292350)
  + inline signed messages sent honouring $send_charset (Closes: 307819)
  + support for <clear-flag> and <set-flag> in the pager (Closes: 436007)
  + fcc_attach is a quad option (Closes: 478861)
  + Content-Description header not included in reply (Closes: 500766)
  + imap_sync_mailbox fix for a segfault (Closes: 516364)
  + better threading support with particular Message-ID's (Closes: 520735)
  + no crash on IMAP folder refresh (Closes: 528465)
  + undisclosed-recipients not passed in the envelope (Closes: 529090)
* debian/patches/series:
  + commented all references to upstream/*, they should be included in 1.5.20
  + removed debian-specific/529838-gnutls-autoconf.patch, ditto
  + removed misc/manpage-typos.patch, ditto 
  + modified misc/hyphen-as-minus.patch, a big part was integrated upstream
  + features/trash-folder: do not reupload messages to $trash if IMAP is used
    (Closes: #448241)
  + added misc/hg.pmdef.debugtime, see upstream #3263
* debian/control: added DM-Upload-Allowed: yes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
3
 
 * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
 
2
 * Copyright (C) 1996-2000,2002,2007 Michael R. Elkins <me@mutt.org>
 
3
 * Copyright (C) 1999-2006 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
30
30
#include "attach.h"
31
31
#include "mapping.h"
32
32
#include "mx.h"
33
 
#include "copy.h"
34
33
#include "mutt_crypt.h"
35
34
 
36
35
#include <ctype.h>
56
55
  { N_("Pipe"),  OP_PIPE },
57
56
  { N_("Print"), OP_PRINT },
58
57
  { N_("Help"),  OP_HELP },
59
 
  { NULL }
 
58
  { NULL,        0 }
60
59
};
61
60
 
62
61
void mutt_update_tree (ATTACHPTR **idx, short idxlen)
254
253
          char path[_POSIX_PATH_MAX];
255
254
          
256
255
          strfcpy (path, aptr->content->filename, sizeof (path));
257
 
          mutt_pretty_mailbox (path);
 
256
          mutt_pretty_mailbox (path, sizeof (path));
258
257
          mutt_format_s (dest, destlen, prefix, path);
259
258
        }
260
259
        else
363
362
  return (src);
364
363
}
365
364
 
366
 
void attach_entry (char *b, size_t blen, MUTTMENU *menu, int num)
 
365
static void attach_entry (char *b, size_t blen, MUTTMENU *menu, int num)
367
366
{
368
367
  mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt, (unsigned long) (((ATTACHPTR **)menu->data)[num]), M_FORMAT_ARROWCURSOR);
369
368
}
386
385
  return (ascii_strcasecmp (subtype, "rfc822") == 0 || ascii_strcasecmp (subtype, "news") == 0);
387
386
}
388
387
 
 
388
static void prepend_curdir (char *dst, size_t dstlen)
 
389
{
 
390
  size_t l;
 
391
 
 
392
  if (!dst || !*dst || *dst == '/' || dstlen < 3 ||
 
393
      /* XXX bad modularization, these are special to mutt_expand_path() */
 
394
      !strchr ("~=+@<>!-^", *dst))
 
395
    return;
 
396
 
 
397
  dstlen -= 3;
 
398
  l = strlen (dst) + 2;
 
399
  l = (l > dstlen ? dstlen : l);
 
400
  memmove (dst + 2, dst, l);
 
401
  dst[0] = '.';
 
402
  dst[1] = '/';
 
403
  dst[l + 2] = 0;
 
404
}
 
405
 
389
406
static int mutt_query_save_attachment (FILE *fp, BODY *body, HEADER *hdr, char **directory)
390
407
{
391
408
  char *prompt;
409
426
  else
410
427
    buf[0] = 0;
411
428
 
 
429
  prepend_curdir (buf, sizeof (buf));
 
430
 
412
431
  prompt = _("Save to file: ");
413
432
  while (prompt)
414
433
  {
415
434
    if (mutt_get_field (prompt, buf, sizeof (buf), M_FILE | M_CLEAR) != 0
416
435
        || !buf[0])
 
436
    {
 
437
      mutt_clear_error ();
417
438
      return -1;
 
439
    }
418
440
    
419
441
    prompt = NULL;
420
442
    mutt_expand_path (buf, sizeof (buf));
486
508
          int append = 0;
487
509
 
488
510
          strfcpy (buf, mutt_basename (NONULL (top->filename)), sizeof (buf));
 
511
          prepend_curdir (buf, sizeof (buf));
489
512
 
490
513
          if (mutt_get_field (_("Save to file: "), buf, sizeof (buf),
491
514
                                    M_FILE | M_CLEAR) != 0 || !buf[0])
498
521
          if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL)
499
522
          {
500
523
            fprintf(fpout, "%s", AttachSep);
501
 
            fclose (fpout);
 
524
            safe_fclose (&fpout);
502
525
          }
503
526
        }
504
527
        else
507
530
          if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL)
508
531
          {
509
532
            fprintf(fpout, "%s", AttachSep);
510
 
            fclose (fpout);
 
533
            safe_fclose (&fpout);
511
534
          }
512
535
        }
513
536
      }
602
625
      return;
603
626
    }
604
627
    mutt_copy_stream (ifp, state->fpout);
605
 
    fclose (ifp);
 
628
    safe_fclose (&ifp);
606
629
    if (AttachSep)
607
630
      state_puts (AttachSep, state);
608
631
  }
651
674
    mutt_endwin (NULL);
652
675
    thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
653
676
    pipe_attachment_list (buf, fp, tag, top, filter, &state);
654
 
    fclose (state.fpout);
 
677
    safe_fclose (&state.fpout);
655
678
    if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
656
679
      mutt_any_key_to_continue (NULL);
657
680
  }
717
740
            if ((ifp = fopen (newfile, "r")) != NULL)
718
741
            {
719
742
              mutt_copy_stream (ifp, state->fpout);
720
 
              fclose (ifp);
 
743
              safe_fclose (&ifp);
721
744
              if (AttachSep)
722
745
                state_puts (AttachSep, state);
723
746
            }
751
774
    memset (&state, 0, sizeof (STATE));
752
775
    thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
753
776
    print_attachment_list (fp, tag, top, &state);
754
 
    fclose (state.fpout);
 
777
    safe_fclose (&state.fpout);
755
778
    if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
756
779
      mutt_any_key_to_continue (NULL);
757
780
  }
759
782
    print_attachment_list (fp, tag, top, &state);
760
783
}
761
784
 
762
 
void
 
785
static void
763
786
mutt_update_attach_index (BODY *cur, ATTACHPTR ***idxp,
764
787
                                      short *idxlen, short *idxmax,
765
788
                                      MUTTMENU *menu)
984
1007
    cur = hdr->content;
985
1008
  }
986
1009
 
987
 
  menu = mutt_new_menu ();
988
 
  menu->menu = MENU_ATTACH;
 
1010
  menu = mutt_new_menu (MENU_ATTACH);
989
1011
  menu->title = _("Attachments");
990
1012
  menu->make_entry = attach_entry;
991
1013
  menu->tag = mutt_tag_attach;
1223
1245
 
1224
1246
        if (WithCrypto && need_secured && secured)
1225
1247
        {
1226
 
          fclose (fp);
 
1248
          safe_fclose (&fp);
1227
1249
          mutt_free_body (&cur);
1228
1250
        }
1229
1251