mutt stable branch with some hacks
0
fork

Configure Feed

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

Add open_msg to struct mx_ops

Add the callback to open an existing message to struct mx_ops. For mbox,
mmdf, maildir, and mh, the code was implemented directly into
mx_open_message, so it is moved in their respective source files. For
imap and pop, there were already <mailbox>_fetch_message functions, but
their argument order has been changed to pass the context as a first
argument.

+63 -56
+1
imap/imap.c
··· 2074 2074 struct mx_ops mx_imap_ops = { 2075 2075 .open = imap_open_mailbox, 2076 2076 .close = imap_close_mailbox, 2077 + .open_msg = imap_fetch_message, 2077 2078 .open_new_msg = imap_open_new_message, 2078 2079 .check = imap_check_mailbox_reopen, 2079 2080 };
-1
imap/imap.h
··· 58 58 /* message.c */ 59 59 int imap_append_message (CONTEXT* ctx, MESSAGE* msg); 60 60 int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete); 61 - int imap_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno); 62 61 63 62 /* socket.c */ 64 63 void imap_logout_all (void);
+2
imap/imap_private.h
··· 268 268 int imap_cache_del (IMAP_DATA* idata, HEADER* h); 269 269 int imap_cache_clean (IMAP_DATA* idata); 270 270 271 + int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno); 272 + 271 273 /* util.c */ 272 274 #ifdef USE_HCACHE 273 275 header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path);
+1 -1
imap/message.c
··· 391 391 return retval; 392 392 } 393 393 394 - int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno) 394 + int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno) 395 395 { 396 396 IMAP_DATA* idata; 397 397 HEADER* h;
+9
mbox.c
··· 447 447 return 0; 448 448 } 449 449 450 + static int mbox_open_message (CONTEXT *ctx, MESSAGE *msg, int msgno) 451 + { 452 + msg->fp = ctx->fp; 453 + 454 + return 0; 455 + } 456 + 450 457 static int mbox_open_new_message (MESSAGE *msg, CONTEXT *dest, HEADER *hdr) 451 458 { 452 459 msg->fp = dest->fp; ··· 1274 1281 struct mx_ops mx_mbox_ops = { 1275 1282 .open = mbox_open_mailbox, 1276 1283 .close = mbox_close_mailbox, 1284 + .open_msg = mbox_open_message, 1277 1285 .open_new_msg = mbox_open_new_message, 1278 1286 .check = mbox_check_mailbox, 1279 1287 }; ··· 1281 1289 struct mx_ops mx_mmdf_ops = { 1282 1290 .open = mbox_open_mailbox, 1283 1291 .close = mbox_close_mailbox, 1292 + .open_msg = mbox_open_message, 1284 1293 .open_new_msg = mbox_open_new_message, 1285 1294 .check = mbox_check_mailbox, 1286 1295 };
+34
mh.c
··· 1336 1336 } 1337 1337 } 1338 1338 1339 + static int maildir_mh_open_message (CONTEXT *ctx, MESSAGE *msg, int msgno, 1340 + int is_maildir) 1341 + { 1342 + HEADER *cur = ctx->hdrs[msgno]; 1343 + char path[_POSIX_PATH_MAX]; 1344 + 1345 + snprintf (path, sizeof (path), "%s/%s", ctx->path, cur->path); 1346 + 1347 + msg->fp = fopen (path, "r"); 1348 + if (msg->fp == NULL && errno == ENOENT && is_maildir) 1349 + msg->fp = maildir_open_find_message (ctx->path, cur->path); 1350 + 1351 + if (!msg->fp) 1352 + { 1353 + mutt_perror (path); 1354 + dprint (1, (debugfile, "maildir_mh_open_message: fopen: %s: %s (errno %d).\n", 1355 + path, strerror (errno), errno)); 1356 + return -1; 1357 + } 1358 + 1359 + return 0; 1360 + } 1361 + 1362 + static int maildir_open_message (CONTEXT *ctx, MESSAGE *msg, int msgno) 1363 + { 1364 + return maildir_mh_open_message (ctx, msg, msgno, 1); 1365 + } 1366 + 1367 + static int mh_open_message (CONTEXT *ctx, MESSAGE *msg, int msgno) 1368 + { 1369 + return maildir_mh_open_message (ctx, msg, msgno, 0); 1370 + } 1339 1371 1340 1372 /* 1341 1373 * Open a new (temporary) message in a maildir folder. ··· 2412 2444 struct mx_ops mx_maildir_ops = { 2413 2445 .open = maildir_open_mailbox, 2414 2446 .close = mh_close_mailbox, 2447 + .open_msg = maildir_open_message, 2415 2448 .open_new_msg = maildir_open_new_message, 2416 2449 .check = maildir_check_mailbox, 2417 2450 }; ··· 2419 2452 struct mx_ops mx_mh_ops = { 2420 2453 .open = mh_open_mailbox, 2421 2454 .close = mh_close_mailbox, 2455 + .open_msg = mh_open_message, 2422 2456 .open_new_msg = mh_open_new_message, 2423 2457 .check = mh_check_mailbox, 2424 2458 };
+1
mutt.h
··· 894 894 int (*open)(struct _context *); 895 895 int (*close)(struct _context *); 896 896 int (*check) (struct _context *ctx, int *index_hint); 897 + int (*open_msg) (struct _context *, struct _message *, int msgno); 897 898 int (*open_new_msg) (struct _message *, struct _context *, HEADER *); 898 899 }; 899 900
+13 -52
mx.c
··· 1308 1308 /* return a stream pointer for a message */ 1309 1309 MESSAGE *mx_open_message (CONTEXT *ctx, int msgno) 1310 1310 { 1311 + struct mx_ops *ops = mx_get_ops (ctx->magic); 1311 1312 MESSAGE *msg; 1312 - 1313 - msg = safe_calloc (1, sizeof (MESSAGE)); 1314 - switch (msg->magic = ctx->magic) 1313 + int ret; 1314 + 1315 + if (!ops || !ops->open_msg) 1315 1316 { 1316 - case MUTT_MBOX: 1317 - case MUTT_MMDF: 1318 - msg->fp = ctx->fp; 1319 - break; 1317 + dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic)); 1318 + return NULL; 1319 + } 1320 1320 1321 - case MUTT_MH: 1322 - case MUTT_MAILDIR: 1323 - { 1324 - HEADER *cur = ctx->hdrs[msgno]; 1325 - char path[_POSIX_PATH_MAX]; 1326 - 1327 - snprintf (path, sizeof (path), "%s/%s", ctx->path, cur->path); 1328 - 1329 - if ((msg->fp = fopen (path, "r")) == NULL && errno == ENOENT && 1330 - ctx->magic == MUTT_MAILDIR) 1331 - msg->fp = maildir_open_find_message (ctx->path, cur->path); 1332 - 1333 - if (msg->fp == NULL) 1334 - { 1335 - mutt_perror (path); 1336 - dprint (1, (debugfile, "mx_open_message: fopen: %s: %s (errno %d).\n", 1337 - path, strerror (errno), errno)); 1338 - FREE (&msg); 1339 - } 1340 - } 1341 - break; 1342 - 1343 - #ifdef USE_IMAP 1344 - case MUTT_IMAP: 1345 - { 1346 - if (imap_fetch_message (msg, ctx, msgno) != 0) 1347 - FREE (&msg); 1348 - break; 1349 - } 1350 - #endif /* USE_IMAP */ 1321 + msg = safe_calloc (1, sizeof (MESSAGE)); 1322 + msg->magic = ctx->magic; 1323 + ret = ops->open_msg (ctx, msg, msgno); 1324 + if (ret) 1325 + FREE (&msg); 1351 1326 1352 - #ifdef USE_POP 1353 - case MUTT_POP: 1354 - { 1355 - if (pop_fetch_message (msg, ctx, msgno) != 0) 1356 - FREE (&msg); 1357 - break; 1358 - } 1359 - #endif /* USE_POP */ 1360 - 1361 - default: 1362 - dprint (1, (debugfile, "mx_open_message(): function not implemented for mailbox type %d.\n", ctx->magic)); 1363 - FREE (&msg); 1364 - break; 1365 - } 1366 - return (msg); 1327 + return msg; 1367 1328 } 1368 1329 1369 1330 /* commit a message to a folder */
+2 -1
pop.c
··· 512 512 } 513 513 514 514 /* fetch message from POP server */ 515 - int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno) 515 + static int pop_fetch_message (CONTEXT* ctx, MESSAGE* msg, int msgno) 516 516 { 517 517 int ret; 518 518 void *uidl; ··· 931 931 struct mx_ops mx_pop_ops = { 932 932 .open = pop_open_mailbox, 933 933 .close = pop_close_mailbox, 934 + .open_msg = pop_fetch_message, 934 935 .check = pop_check_mailbox, 935 936 };
-1
pop.h
··· 106 106 107 107 /* pop.c */ 108 108 int pop_sync_mailbox (CONTEXT *, int *); 109 - int pop_fetch_message (MESSAGE *, CONTEXT *, int); 110 109 int pop_close_mailbox (CONTEXT *); 111 110 void pop_fetch_mail (void); 112 111