source: trunk/dports/mail/mutt-devel/files/patch-1.5.20.cd.trash_folder.diff @ 57238

Last change on this file since 57238 was 57238, checked in by macsforever2000@…, 8 years ago

Added trash variant. (#20412)

File size: 7.5 KB
  • commands.c

    diff -Nru mutt-1.5.20/commands.c mutt-1.5.20-trashfolder/commands.c
    old new  
    716716    if (option (OPTDELETEUNTAG))
    717717      mutt_set_flag (Context, h, M_TAG, 0);
    718718  }
     719  mutt_set_flag (Context, h, M_APPENDED, 1);
    719720 
    720721  return 0;
    721722}
  • mutt-1.5.

    diff -Nru mutt-1.5.20/flags.c mutt-1.5.20-trashfolder/flags.c
    old new  
    6565      {
    6666        h->deleted = 0;
    6767        update = 1;
    68         if (upd_ctx) ctx->deleted--;
     68        if (upd_ctx)
     69        {
     70          ctx->deleted--;
     71          if (h->appended)
     72            ctx->appended--;
     73        }
     74        h->appended = 0; /* when undeleting, also reset the appended flag */
    6975#ifdef USE_IMAP
    7076        /* see my comment above */
    7177        if (ctx->magic == M_IMAP)
     
    8793      }
    8894      break;
    8995
     96    case M_APPENDED:
     97      if (bf)
     98      {
     99        if (!h->appended)
     100        {
     101          h->appended = 1;
     102          if (upd_ctx) ctx->appended++;
     103        }
     104      }
     105      break;
     106
    90107    case M_NEW:
    91108
    92109      if (!mutt_bit_isset(ctx->rights,M_ACL_SEEN))
  • globals.h

    diff -Nru mutt-1.5.20/globals.h mutt-1.5.20-trashfolder/globals.h
    old new  
    139139WHERE char *Status;
    140140WHERE char *Tempdir;
    141141WHERE char *Tochars;
     142WHERE char *TrashPath;
    142143WHERE char *Username;
    143144WHERE char *Visual;
    144145
  • imap/message.c

    diff -Nru mutt-1.5.20/imap/message.c mutt-1.5.20-trashfolder/imap/message.c
    old new  
    867867        if (ctx->hdrs[n]->tagged)
    868868        {
    869869          mutt_set_flag (ctx, ctx->hdrs[n], M_DELETE, 1);
     870          mutt_set_flag (ctx, ctx->hdrs[n], M_APPENDED, 1);
    870871          if (option (OPTDELETEUNTAG))
    871872            mutt_set_flag (ctx, ctx->hdrs[n], M_TAG, 0);
    872873        }
     
    874875    else
    875876    {
    876877      mutt_set_flag (ctx, h, M_DELETE, 1);
     878      mutt_set_flag (ctx, h, M_APPENDED, 1);
    877879      if (option (OPTDELETEUNTAG))
    878880        mutt_set_flag (ctx, h, M_TAG, 0);
    879881    }
  • mutt-1.5.

    diff -Nru mutt-1.5.20/init.h mutt-1.5.20-trashfolder/init.h
    old new  
    31803180  ** by \fIyou\fP.  The sixth character is used to indicate when a mail
    31813181  ** was sent to a mailing-list you subscribe to.
    31823182  */
     3183  { "trash",             DT_PATH, R_NONE, UL &TrashPath, 0 },
     3184  /*
     3185  ** .pp
     3186  ** If set, this variable specifies the path of the trash folder where the
     3187  ** mails marked for deletion will be moved, instead of being irremediably
     3188  ** purged.
     3189  ** .pp
     3190  ** NOTE: When you delete a message in the trash folder, it is really
     3191  ** deleted, so that you have a way to clean the trash.
     3192  */
    31833193#ifdef USE_SOCKET
    31843194  { "tunnel",            DT_STR, R_NONE, UL &Tunnel, UL 0 },
    31853195  /*
  • mutt-1.5.

    diff -Nru mutt-1.5.20/mutt.h mutt-1.5.20-trashfolder/mutt.h
    old new  
    187187  M_DELETE,
    188188  M_UNDELETE,
    189189  M_DELETED,
     190  M_APPENDED,
    190191  M_FLAG,
    191192  M_TAG,
    192193  M_UNTAG,
     
    702703  unsigned int flagged : 1;             /* marked important? */
    703704  unsigned int tagged : 1;
    704705  unsigned int deleted : 1;
     706  unsigned int appended : 1;            /* has been saved */
    705707  unsigned int changed : 1;
    706708  unsigned int attach_del : 1;          /* has an attachment marked for deletion */
    707709  unsigned int old : 1;
     
    873875  int new;                      /* how many new messages? */
    874876  int unread;                   /* how many unread messages? */
    875877  int deleted;                  /* how many deleted messages */
     878  int appended;                 /* how many saved messages? */
    876879  int flagged;                  /* how many flagged messages */
    877880  int msgnotreadyet;            /* which msg "new" in pager, -1 if none */
    878881
  • muttlib.c

    diff -Nru mutt-1.5.20/muttlib.c mutt-1.5.20-trashfolder/muttlib.c
    old new  
    14601460
    14611461  if (magic > 0 && !mx_access (s, W_OK))
    14621462  {
    1463     if (option (OPTCONFIRMAPPEND))
     1463    if (option (OPTCONFIRMAPPEND) &&
     1464      (!TrashPath || (mutt_strcmp (s, TrashPath) != 0)))
     1465      /* if we're appending to the trash, there's no point in asking */
    14641466    {
    14651467      snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s);
    14661468      if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
  • mutt-1.5.

    diff -Nru mutt-1.5.20/mx.c mutt-1.5.20-trashfolder/mx.c
    old new  
    773773  return rc;
    774774}
    775775
     776/* move deleted mails to the trash folder */
     777static int trash_append (CONTEXT *ctx)
     778{
     779    CONTEXT *ctx_trash;
     780    int i = 0;
     781    struct stat st, stc;
     782
     783    if (!TrashPath || !ctx->deleted ||
     784        (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
     785      return 0;
     786
     787    for (;i < ctx->msgcount && (!ctx->hdrs[i]->deleted ||
     788                                ctx->hdrs[i]->appended); i++);
     789    if (i == ctx->msgcount)
     790      return 0; /* nothing to be done */
     791
     792    if (mutt_save_confirm (TrashPath, &st) != 0)
     793    {
     794      mutt_error _("message(s) not deleted");
     795      return -1;
     796    }
     797
     798    if (lstat (ctx->path, &stc) == 0 && stc.st_ino == st.st_ino
     799        && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
     800      return 0;  /* we are in the trash folder: simple sync */
     801
     802    if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL)
     803    {
     804      for (i = 0 ; i < ctx->msgcount ; i++)
     805        if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended
     806            && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1)
     807          {
     808            mx_close_mailbox (ctx_trash, NULL);
     809            return -1;
     810          }
     811
     812      mx_close_mailbox (ctx_trash, NULL);
     813    }
     814    else
     815    {
     816      mutt_error _("Can't open trash folder");
     817      return -1;
     818    }
     819
     820    return 0;
     821}
     822
    776823/* save changes and close mailbox */
    777824int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
    778825{
     
    909956          if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) == 0)
    910957          {
    911958            mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1);
     959            mutt_set_flag (ctx, ctx->hdrs[i], M_APPENDED, 1);
    912960          }
    913961          else
    914962          {
     
    931979    return 0;
    932980  }
    933981 
     982  /* copy mails to the trash before expunging */
     983  if (purge && ctx->deleted)
     984    if (trash_append (ctx) != 0)
     985    {
     986      ctx->closing = 0;
     987      return -1;
     988    }
     989
    934990#ifdef USE_IMAP
    935991  /* allow IMAP to preserve the deleted flag across sessions */
    936992  if (ctx->magic == M_IMAP)
     
    11301186  msgcount = ctx->msgcount;
    11311187  deleted = ctx->deleted;
    11321188
     1189  if (purge && ctx->deleted)
     1190  {
     1191    if (trash_append (ctx) == -1)
     1192      return -1;
     1193  }
     1194
    11331195#ifdef USE_IMAP
    11341196  if (ctx->magic == M_IMAP)
    11351197    rc = imap_sync_mailbox (ctx, purge, index_hint);
  • postpone.c

    diff -Nru mutt-1.5.20/postpone.c mutt-1.5.20-trashfolder/postpone.c
    old new  
    276276  /* finished with this message, so delete it. */
    277277  mutt_set_flag (PostContext, h, M_DELETE, 1);
    278278
     279  /* and consider it saved, so that it won't be moved to the trash folder */
     280  mutt_set_flag (PostContext, h, M_APPENDED, 1);
     281
    279282  /* update the count for the status display */
    280283  PostCount = PostContext->msgcount - PostContext->deleted;
    281284
Note: See TracBrowser for help on using the repository browser.