Ticket #20412: patch-1.5.20.cd.trash_folder.diff
File patch-1.5.20.cd.trash_folder.diff, 7.5 KB (added by carter.tjoseph@…, 15 years ago) |
---|
-
commands.c
diff -Nru mutt-1.5.20/commands.c mutt-1.5.20-trashfolder/commands.c
old new 716 716 if (option (OPTDELETEUNTAG)) 717 717 mutt_set_flag (Context, h, M_TAG, 0); 718 718 } 719 mutt_set_flag (Context, h, M_APPENDED, 1); 719 720 720 721 return 0; 721 722 } -
mutt-1.5.
diff -Nru mutt-1.5.20/flags.c mutt-1.5.20-trashfolder/flags.c
old new 65 65 { 66 66 h->deleted = 0; 67 67 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 */ 69 75 #ifdef USE_IMAP 70 76 /* see my comment above */ 71 77 if (ctx->magic == M_IMAP) … … 87 93 } 88 94 break; 89 95 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 90 107 case M_NEW: 91 108 92 109 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 139 139 WHERE char *Status; 140 140 WHERE char *Tempdir; 141 141 WHERE char *Tochars; 142 WHERE char *TrashPath; 142 143 WHERE char *Username; 143 144 WHERE char *Visual; 144 145 -
imap/message.c
diff -Nru mutt-1.5.20/imap/message.c mutt-1.5.20-trashfolder/imap/message.c
old new 867 867 if (ctx->hdrs[n]->tagged) 868 868 { 869 869 mutt_set_flag (ctx, ctx->hdrs[n], M_DELETE, 1); 870 mutt_set_flag (ctx, ctx->hdrs[n], M_APPENDED, 1); 870 871 if (option (OPTDELETEUNTAG)) 871 872 mutt_set_flag (ctx, ctx->hdrs[n], M_TAG, 0); 872 873 } … … 874 875 else 875 876 { 876 877 mutt_set_flag (ctx, h, M_DELETE, 1); 878 mutt_set_flag (ctx, h, M_APPENDED, 1); 877 879 if (option (OPTDELETEUNTAG)) 878 880 mutt_set_flag (ctx, h, M_TAG, 0); 879 881 } -
mutt-1.5.
diff -Nru mutt-1.5.20/init.h mutt-1.5.20-trashfolder/init.h
old new 3180 3180 ** by \fIyou\fP. The sixth character is used to indicate when a mail 3181 3181 ** was sent to a mailing-list you subscribe to. 3182 3182 */ 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 */ 3183 3193 #ifdef USE_SOCKET 3184 3194 { "tunnel", DT_STR, R_NONE, UL &Tunnel, UL 0 }, 3185 3195 /* -
mutt-1.5.
diff -Nru mutt-1.5.20/mutt.h mutt-1.5.20-trashfolder/mutt.h
old new 187 187 M_DELETE, 188 188 M_UNDELETE, 189 189 M_DELETED, 190 M_APPENDED, 190 191 M_FLAG, 191 192 M_TAG, 192 193 M_UNTAG, … … 702 703 unsigned int flagged : 1; /* marked important? */ 703 704 unsigned int tagged : 1; 704 705 unsigned int deleted : 1; 706 unsigned int appended : 1; /* has been saved */ 705 707 unsigned int changed : 1; 706 708 unsigned int attach_del : 1; /* has an attachment marked for deletion */ 707 709 unsigned int old : 1; … … 873 875 int new; /* how many new messages? */ 874 876 int unread; /* how many unread messages? */ 875 877 int deleted; /* how many deleted messages */ 878 int appended; /* how many saved messages? */ 876 879 int flagged; /* how many flagged messages */ 877 880 int msgnotreadyet; /* which msg "new" in pager, -1 if none */ 878 881 -
muttlib.c
diff -Nru mutt-1.5.20/muttlib.c mutt-1.5.20-trashfolder/muttlib.c
old new 1460 1460 1461 1461 if (magic > 0 && !mx_access (s, W_OK)) 1462 1462 { 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 */ 1464 1466 { 1465 1467 snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s); 1466 1468 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 773 773 return rc; 774 774 } 775 775 776 /* move deleted mails to the trash folder */ 777 static 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 776 823 /* save changes and close mailbox */ 777 824 int mx_close_mailbox (CONTEXT *ctx, int *index_hint) 778 825 { … … 909 956 if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) == 0) 910 957 { 911 958 mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1); 959 mutt_set_flag (ctx, ctx->hdrs[i], M_APPENDED, 1); 912 960 } 913 961 else 914 962 { … … 931 979 return 0; 932 980 } 933 981 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 934 990 #ifdef USE_IMAP 935 991 /* allow IMAP to preserve the deleted flag across sessions */ 936 992 if (ctx->magic == M_IMAP) … … 1130 1186 msgcount = ctx->msgcount; 1131 1187 deleted = ctx->deleted; 1132 1188 1189 if (purge && ctx->deleted) 1190 { 1191 if (trash_append (ctx) == -1) 1192 return -1; 1193 } 1194 1133 1195 #ifdef USE_IMAP 1134 1196 if (ctx->magic == M_IMAP) 1135 1197 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 276 276 /* finished with this message, so delete it. */ 277 277 mutt_set_flag (PostContext, h, M_DELETE, 1); 278 278 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 279 282 /* update the count for the status display */ 280 283 PostCount = PostContext->msgcount - PostContext->deleted; 281 284