mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add check operation to struct mx_ops

In mx_check_mailbox switch case, we simply call
<mailbox>_check_mailbox, so this operation can be move into the mx_ops
structure pretty easily.

This commit adds a mandatory "check" operation to struct mx_ops and
change all mailboxes to use it. Check functions are made static as they
are only used in their respective source files now.

+26 -33
+2 -1
imap/imap.c
··· 1464 1464 return result; 1465 1465 } 1466 1466 1467 - int imap_check_mailbox_reopen (CONTEXT *ctx, int *index_hint) 1467 + static int imap_check_mailbox_reopen (CONTEXT *ctx, int *index_hint) 1468 1468 { 1469 1469 int rc; 1470 1470 ··· 2067 2067 .open = imap_open_mailbox, 2068 2068 .close = imap_close_mailbox, 2069 2069 .open_new_msg = imap_open_new_message, 2070 + .check = imap_check_mailbox_reopen, 2070 2071 };
-1
imap/imap.h
··· 34 34 /* imap.c */ 35 35 int imap_access (const char*, int); 36 36 int imap_check_mailbox (CONTEXT *ctx, int *index_hint, int force); 37 - int imap_check_mailbox_reopen (CONTEXT *ctx, int *index_hint); 38 37 int imap_delete_mailbox (CONTEXT* idata, IMAP_MBOX mx); 39 38 int imap_open_mailbox_append (CONTEXT *ctx); 40 39 int imap_sync_mailbox (CONTEXT *ctx, int expunge, int *index_hint);
+3 -1
mbox.c
··· 577 577 * 0 no change 578 578 * -1 error 579 579 */ 580 - int mbox_check_mailbox (CONTEXT *ctx, int *index_hint) 580 + static int mbox_check_mailbox (CONTEXT *ctx, int *index_hint) 581 581 { 582 582 struct stat st; 583 583 char buffer[LONG_STRING]; ··· 1273 1273 .open = mbox_open_mailbox, 1274 1274 .close = mbox_close_mailbox, 1275 1275 .open_new_msg = mbox_open_new_message, 1276 + .check = mbox_check_mailbox, 1276 1277 }; 1277 1278 1278 1279 struct mx_ops mx_mmdf_ops = { 1279 1280 .open = mbox_open_mailbox, 1280 1281 .close = mbox_close_mailbox, 1281 1282 .open_new_msg = mbox_open_new_message, 1283 + .check = mbox_check_mailbox, 1282 1284 };
+7 -2
mh.c
··· 58 58 59 59 #define INS_SORT_THRESHOLD 6 60 60 61 + static int maildir_check_mailbox (CONTEXT * ctx, int *index_hint); 62 + static int mh_check_mailbox (CONTEXT * ctx, int *index_hint); 63 + 61 64 struct maildir 62 65 { 63 66 HEADER *h; ··· 1905 1908 * either subdirectory differently, as mail could be copied directly into 1906 1909 * the cur directory from another agent. 1907 1910 */ 1908 - int maildir_check_mailbox (CONTEXT * ctx, int *index_hint) 1911 + static int maildir_check_mailbox (CONTEXT * ctx, int *index_hint) 1909 1912 { 1910 1913 struct stat st_new; /* status of the "new" subdirectory */ 1911 1914 struct stat st_cur; /* status of the "cur" subdirectory */ ··· 2051 2054 * 2052 2055 */ 2053 2056 2054 - int mh_check_mailbox (CONTEXT * ctx, int *index_hint) 2057 + static int mh_check_mailbox (CONTEXT * ctx, int *index_hint) 2055 2058 { 2056 2059 char buf[_POSIX_PATH_MAX]; 2057 2060 struct stat st, st_cur; ··· 2362 2365 .open = maildir_open_mailbox, 2363 2366 .close = mh_close_mailbox, 2364 2367 .open_new_msg = maildir_open_new_message, 2368 + .check = maildir_check_mailbox, 2365 2369 }; 2366 2370 2367 2371 struct mx_ops mx_mh_ops = { 2368 2372 .open = mh_open_mailbox, 2369 2373 .close = mh_close_mailbox, 2370 2374 .open_new_msg = mh_open_new_message, 2375 + .check = mh_check_mailbox, 2371 2376 };
+2
mutt.h
··· 876 876 * The following operations are mandatory: 877 877 * - open 878 878 * - close 879 + * - check 879 880 * 880 881 * Optional operations 881 882 * - open_new_msg ··· 884 885 { 885 886 int (*open)(struct _context *); 886 887 int (*close)(struct _context *); 888 + int (*check) (struct _context *ctx, int *index_hint); 887 889 int (*open_new_msg) (struct _message *, struct _context *, HEADER *); 888 890 }; 889 891
+10 -23
mx.c
··· 1264 1264 /* check for new mail */ 1265 1265 int mx_check_mailbox (CONTEXT *ctx, int *index_hint) 1266 1266 { 1267 - if (ctx) 1267 + struct mx_ops *ops; 1268 + 1269 + if (!ctx) 1268 1270 { 1269 - switch (ctx->magic) 1270 - { 1271 - case MUTT_MBOX: 1272 - case MUTT_MMDF: 1273 - return mbox_check_mailbox (ctx, index_hint); 1274 - case MUTT_MH: 1275 - return (mh_check_mailbox (ctx, index_hint)); 1276 - case MUTT_MAILDIR: 1277 - return (maildir_check_mailbox (ctx, index_hint)); 1271 + dprint (1, (debugfile, "mx_check_mailbox: null or invalid context.\n")); 1272 + return -1; 1273 + } 1278 1274 1279 - #ifdef USE_IMAP 1280 - case MUTT_IMAP: 1281 - return imap_check_mailbox_reopen (ctx, index_hint); 1282 - #endif /* USE_IMAP */ 1283 - 1284 - #ifdef USE_POP 1285 - case MUTT_POP: 1286 - return (pop_check_mailbox (ctx, index_hint)); 1287 - #endif /* USE_POP */ 1288 - } 1289 - } 1275 + ops = mx_get_ops (ctx->magic); 1276 + if (!ops) 1277 + return -1; 1290 1278 1291 - dprint (1, (debugfile, "mx_check_mailbox: null or invalid context.\n")); 1292 - return (-1); 1279 + return ops->check (ctx, index_hint); 1293 1280 } 1294 1281 1295 1282 /* return a stream pointer for a message */
-3
mx.h
··· 44 44 #define MAXLOCKATTEMPT 5 45 45 46 46 int mbox_sync_mailbox (CONTEXT *, int *); 47 - int mbox_check_mailbox (CONTEXT *, int *); 48 47 int mbox_lock_mailbox (CONTEXT *, int, int); 49 48 int mbox_parse_mailbox (CONTEXT *); 50 49 int mmdf_parse_mailbox (CONTEXT *); ··· 53 52 void mbox_reset_atime (CONTEXT *, struct stat *); 54 53 55 54 int mh_sync_mailbox (CONTEXT *, int *); 56 - int mh_check_mailbox (CONTEXT *, int *); 57 55 int mh_check_empty (const char *); 58 56 59 - int maildir_check_mailbox (CONTEXT *, int *); 60 57 int maildir_check_empty (const char *); 61 58 62 59 int maildir_commit_message (CONTEXT *, MESSAGE *, HEADER *);
+2 -1
pop.c
··· 735 735 } 736 736 737 737 /* Check for new messages and fetch headers */ 738 - int pop_check_mailbox (CONTEXT *ctx, int *index_hint) 738 + static int pop_check_mailbox (CONTEXT *ctx, int *index_hint) 739 739 { 740 740 int ret; 741 741 POP_DATA *pop_data = (POP_DATA *)ctx->data; ··· 931 931 struct mx_ops mx_pop_ops = { 932 932 .open = pop_open_mailbox, 933 933 .close = pop_close_mailbox, 934 + .check = pop_check_mailbox, 934 935 };
-1
pop.h
··· 105 105 void pop_error (POP_DATA *, char *); 106 106 107 107 /* pop.c */ 108 - int pop_check_mailbox (CONTEXT *, int *); 109 108 int pop_sync_mailbox (CONTEXT *, int *); 110 109 int pop_fetch_message (MESSAGE *, CONTEXT *, int); 111 110 int pop_close_mailbox (CONTEXT *);