NeoMutt  2024-04-25-76-g20fe7b
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
postpone.c
Go to the documentation of this file.
1
32#include "config.h"
33#include <stdbool.h>
34#include <stdio.h>
35#include <string.h>
36#include <sys/stat.h>
37#include <time.h>
38#include <unistd.h>
39#include "mutt/lib.h"
40#include "address/lib.h"
41#include "config/lib.h"
42#include "email/lib.h"
43#include "core/lib.h"
44#include "mutt.h"
45#include "lib.h"
46#include "imap/lib.h"
47#include "ncrypt/lib.h"
48#include "send/lib.h"
49#include "globals.h"
50#include "handler.h"
51#include "mutt_logging.h"
52#include "mutt_thread.h"
53#include "muttlib.h"
54#include "mx.h"
55#include "protos.h"
56#include "rfc3676.h"
57
59short PostCount = 0;
61static bool UpdateNumPostponed = false;
62
71int mutt_num_postponed(struct Mailbox *m, bool force)
72{
73 struct stat st = { 0 };
74
75 static time_t LastModify = 0;
76 static char *OldPostponed = NULL;
77
79 {
80 UpdateNumPostponed = false;
81 force = true;
82 }
83
84 const char *const c_postponed = cs_subset_string(NeoMutt->sub, "postponed");
85 if (!mutt_str_equal(c_postponed, OldPostponed))
86 {
87 FREE(&OldPostponed);
88 OldPostponed = mutt_str_dup(c_postponed);
89 LastModify = 0;
90 force = true;
91 }
92
93 if (!c_postponed)
94 return 0;
95
96 // We currently are in the `$postponed` mailbox so just pick the current status
97 if (m && mutt_str_equal(c_postponed, m->realpath))
98 {
100 return PostCount;
101 }
102
103 /* LastModify is useless for IMAP */
104 if (imap_path_probe(c_postponed, NULL) == MUTT_IMAP)
105 {
106 if (force)
107 {
108 short newpc;
109
110 newpc = imap_path_status(c_postponed, false);
111 if (newpc >= 0)
112 {
113 PostCount = newpc;
114 mutt_debug(LL_DEBUG3, "%d postponed IMAP messages found\n", PostCount);
115 }
116 else
117 {
118 mutt_debug(LL_DEBUG3, "using old IMAP postponed count\n");
119 }
120 }
121 return PostCount;
122 }
123
124 if (stat(c_postponed, &st) == -1)
125 {
126 PostCount = 0;
127 LastModify = 0;
128 return 0;
129 }
130
131 if (S_ISDIR(st.st_mode))
132 {
133 /* if we have a maildir mailbox, we need to stat the "new" dir */
134 struct Buffer *buf = buf_pool_get();
135
136 buf_printf(buf, "%s/new", c_postponed);
137 if ((access(buf_string(buf), F_OK) == 0) && (stat(buf_string(buf), &st) == -1))
138 {
139 PostCount = 0;
140 LastModify = 0;
141 buf_pool_release(&buf);
142 return 0;
143 }
144 buf_pool_release(&buf);
145 }
146
147 if (LastModify < st.st_mtime)
148 {
149 int optnews = OptNews;
150 LastModify = st.st_mtime;
151
152 if (access(c_postponed, R_OK | F_OK) != 0)
153 return PostCount = 0;
154 if (optnews)
155 OptNews = false;
156 struct Mailbox *m_post = mx_path_resolve(c_postponed);
157 if (mx_mbox_open(m_post, MUTT_NOSORT | MUTT_QUIET))
158 {
159 PostCount = m_post->msg_count;
160 mx_fastclose_mailbox(m_post, false);
161 }
162 else
163 {
164 PostCount = 0;
165 }
166 mailbox_free(&m_post);
167
168 if (optnews)
169 OptNews = true;
170 }
171
172 return PostCount;
173}
174
179{
180 UpdateNumPostponed = true;
181}
182
187static void hardclose(struct Mailbox *m)
188{
189 /* messages might have been marked for deletion.
190 * try once more on reopen before giving up. */
191 enum MxStatus rc = mx_mbox_close(m);
192 if (rc != MX_STATUS_ERROR && rc != MX_STATUS_OK)
193 rc = mx_mbox_close(m);
194 if (rc != MX_STATUS_OK)
195 mx_fastclose_mailbox(m, false);
196}
197
205SecurityFlags mutt_parse_crypt_hdr(const char *p, bool set_empty_signas, SecurityFlags crypt_app)
206{
207 char smime_cryptalg[1024] = { 0 };
208 char sign_as[1024] = { 0 };
209 char *q = NULL;
211
212 if (!WithCrypto)
213 return SEC_NO_FLAGS;
214
216 for (; p[0] != '\0'; p++)
217 {
218 switch (p[0])
219 {
220 case 'c':
221 case 'C':
222 q = smime_cryptalg;
223
224 if (p[1] == '<')
225 {
226 for (p += 2; (p[0] != '\0') && (p[0] != '>') &&
227 (q < (smime_cryptalg + sizeof(smime_cryptalg) - 1));
228 *q++ = *p++)
229 {
230 }
231
232 if (p[0] != '>')
233 {
234 mutt_error(_("Illegal S/MIME header"));
235 return SEC_NO_FLAGS;
236 }
237 }
238
239 *q = '\0';
240 break;
241
242 case 'e':
243 case 'E':
244 flags |= SEC_ENCRYPT;
245 break;
246
247 case 'i':
248 case 'I':
249 flags |= SEC_INLINE;
250 break;
251
252 /* This used to be the micalg parameter.
253 *
254 * It's no longer needed, so we just skip the parameter in order
255 * to be able to recall old messages. */
256 case 'm':
257 case 'M':
258 if (p[1] != '<')
259 break;
260
261 for (p += 2; (p[0] != '\0') && (p[0] != '>'); p++)
262 ; // do nothing
263
264 if (p[0] != '>')
265 {
266 mutt_error(_("Illegal crypto header"));
267 return SEC_NO_FLAGS;
268 }
269 break;
270
271 case 'o':
272 case 'O':
273 flags |= SEC_OPPENCRYPT;
274 break;
275
276 case 'a':
277 case 'A':
278#ifdef USE_AUTOCRYPT
279 flags |= SEC_AUTOCRYPT;
280#endif
281 break;
282
283 case 'z':
284 case 'Z':
285#ifdef USE_AUTOCRYPT
286 flags |= SEC_AUTOCRYPT_OVERRIDE;
287#endif
288 break;
289
290 case 's':
291 case 'S':
292 flags |= SEC_SIGN;
293 q = sign_as;
294
295 if (p[1] == '<')
296 {
297 for (p += 2;
298 (p[0] != '\0') && (*p != '>') && (q < (sign_as + sizeof(sign_as) - 1));
299 *q++ = *p++)
300 {
301 }
302
303 if (p[0] != '>')
304 {
305 mutt_error(_("Illegal crypto header"));
306 return SEC_NO_FLAGS;
307 }
308 }
309
310 q[0] = '\0';
311 break;
312
313 default:
314 mutt_error(_("Illegal crypto header"));
315 return SEC_NO_FLAGS;
316 }
317 }
318
319 /* the cryptalg field must not be empty */
320 if (((WithCrypto & APPLICATION_SMIME) != 0) && *smime_cryptalg)
321 {
322 struct Buffer *errmsg = buf_pool_get();
323 int rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
324 smime_cryptalg, errmsg);
325
326 if ((CSR_RESULT(rc) != CSR_SUCCESS) && !buf_is_empty(errmsg))
327 mutt_error("%s", buf_string(errmsg));
328
329 buf_pool_release(&errmsg);
330 }
331
332 /* Set {Smime,Pgp}SignAs, if desired. */
333
334 if (((WithCrypto & APPLICATION_PGP) != 0) && (crypt_app == APPLICATION_PGP) &&
335 (flags & SEC_SIGN) && (set_empty_signas || *sign_as))
336 {
337 cs_subset_str_string_set(NeoMutt->sub, "pgp_sign_as", sign_as, NULL);
338 }
339
340 if (((WithCrypto & APPLICATION_SMIME) != 0) && (crypt_app == APPLICATION_SMIME) &&
341 (flags & SEC_SIGN) && (set_empty_signas || *sign_as))
342 {
343 cs_subset_str_string_set(NeoMutt->sub, "smime_sign_as", sign_as, NULL);
344 }
345
346 return flags;
347}
348
359static int create_tmp_files_for_attachments(FILE *fp_body, struct Buffer *file,
360 struct Email *e_new, struct Body *body,
361 struct Envelope *protected_headers)
362{
363 struct Body *b = NULL;
364 struct State state = { 0 };
365
366 state.fp_in = fp_body;
367
368 for (b = body; b; b = b->next)
369 {
370 if (b->type == TYPE_MULTIPART)
371 {
372 if (create_tmp_files_for_attachments(fp_body, file, e_new, b->parts, protected_headers) < 0)
373 {
374 return -1;
375 }
376 }
377 else
378 {
379 buf_reset(file);
380 if (b->filename)
381 {
382 buf_strcpy(file, b->filename);
384 }
385 else
386 {
387 /* avoid Content-Disposition: header with temporary filename */
388 b->use_disp = false;
389 }
390
391 /* set up state flags */
392
393 state.flags = 0;
394
395 if (b->type == TYPE_TEXT)
396 {
397 if (mutt_istr_equal("yes", mutt_param_get(&b->parameter, "x-mutt-noconv")))
398 {
399 b->noconv = true;
400 }
401 else
402 {
403 state.flags |= STATE_CHARCONV;
404 b->noconv = false;
405 }
406
407 mutt_param_delete(&b->parameter, "x-mutt-noconv");
408 }
409
410 mutt_adv_mktemp(file);
411 state.fp_out = mutt_file_fopen(buf_string(file), "w");
412 if (!state.fp_out)
413 return -1;
414
415 SecurityFlags sec_type = SEC_NO_FLAGS;
416 if (((WithCrypto & APPLICATION_PGP) != 0) && sec_type == SEC_NO_FLAGS)
417 sec_type = mutt_is_application_pgp(b);
418 if (((WithCrypto & APPLICATION_SMIME) != 0) && sec_type == SEC_NO_FLAGS)
419 sec_type = mutt_is_application_smime(b);
420 if (sec_type & (SEC_ENCRYPT | SEC_SIGN))
421 {
422 if (sec_type & SEC_ENCRYPT)
423 {
424 if (!crypt_valid_passphrase(sec_type))
425 return -1;
426 if (sec_type & APPLICATION_SMIME)
427 crypt_smime_getkeys(e_new->env);
428 mutt_message(_("Decrypting message..."));
429 }
430
431 if (mutt_body_handler(b, &state) < 0)
432 {
433 mutt_error(_("Decryption failed"));
434 return -1;
435 }
436
437 /* Is this the first body part? Then save the headers. */
438 if ((b == body) && !protected_headers)
439 {
440 protected_headers = b->mime_headers;
441 b->mime_headers = NULL;
442 }
443
444 e_new->security |= sec_type;
445 b->type = TYPE_TEXT;
446 mutt_str_replace(&b->subtype, "plain");
447 if (sec_type & APPLICATION_PGP)
448 mutt_param_delete(&b->parameter, "x-action");
449 }
450 else
451 {
452 mutt_decode_attachment(b, &state);
453 }
454
455 if (mutt_file_fclose(&state.fp_out) != 0)
456 return -1;
457
459 b->unlink = true;
460
462
464 if (b->email)
465 b->email->body = NULL; /* avoid dangling pointer */
466 }
467 }
468
469 return 0;
470}
471
484int mutt_prepare_template(FILE *fp, struct Mailbox *m, struct Email *e_new,
485 struct Email *e, bool resend)
486{
487 struct Message *msg = NULL;
488 struct Body *b = NULL;
489 FILE *fp_body = NULL;
490 int rc = -1;
491 struct Envelope *protected_headers = NULL;
492 struct Buffer *file = NULL;
493
494 if (!fp && !(msg = mx_msg_open(m, e)))
495 return -1;
496
497 if (!fp)
498 fp = msg->fp;
499
500 fp_body = fp;
501
502 /* parse the message header and MIME structure */
503
504 if (!mutt_file_seek(fp, e->offset, SEEK_SET))
505 {
506 return -1;
507 }
508 e_new->offset = e->offset;
509 /* enable header weeding for resent messages */
510 e_new->env = mutt_rfc822_read_header(fp, e_new, true, resend);
511 e_new->body->length = e->body->length;
512 mutt_parse_part(fp, e_new->body);
513
514 /* If resending a message, don't keep message_id or mail_followup_to.
515 * Otherwise, we are resuming a postponed message, and want to keep those
516 * headers if they exist. */
517 if (resend)
518 {
519 FREE(&e_new->env->message_id);
521 }
522
523 SecurityFlags sec_type = SEC_NO_FLAGS;
524 if (((WithCrypto & APPLICATION_PGP) != 0) && sec_type == SEC_NO_FLAGS)
525 sec_type = mutt_is_multipart_encrypted(e_new->body);
526 if (((WithCrypto & APPLICATION_SMIME) != 0) && sec_type == SEC_NO_FLAGS)
527 sec_type = mutt_is_application_smime(e_new->body);
528 if (sec_type != SEC_NO_FLAGS)
529 {
530 e_new->security |= sec_type;
531 if (!crypt_valid_passphrase(sec_type))
532 goto bail;
533
534 mutt_message(_("Decrypting message..."));
535 int ret = -1;
536 if (sec_type & APPLICATION_PGP)
537 ret = crypt_pgp_decrypt_mime(fp, &fp_body, e_new->body, &b);
538 else if (sec_type & APPLICATION_SMIME)
539 ret = crypt_smime_decrypt_mime(fp, &fp_body, e_new->body, &b);
540 if ((ret == -1) || !b)
541 {
542 mutt_error(_("Could not decrypt postponed message"));
543 goto bail;
544 }
545
546 /* throw away the outer layer and keep only the (now decrypted) inner part
547 * with its headers. */
548 mutt_body_free(&e_new->body);
549 e_new->body = b;
550
551 if (b->mime_headers)
552 {
553 protected_headers = b->mime_headers;
554 b->mime_headers = NULL;
555 }
556
558 }
559
560 /* remove a potential multipart/signed layer - useful when
561 * resending messages */
562 if ((WithCrypto != 0) && mutt_is_multipart_signed(e_new->body))
563 {
564 e_new->security |= SEC_SIGN;
565 if (((WithCrypto & APPLICATION_PGP) != 0) &&
566 mutt_istr_equal(mutt_param_get(&e_new->body->parameter, "protocol"), "application/pgp-signature"))
567 {
568 e_new->security |= APPLICATION_PGP;
569 }
570 else if (WithCrypto & APPLICATION_SMIME)
571 {
572 e_new->security |= APPLICATION_SMIME;
573 }
574
575 /* destroy the signature */
576 mutt_body_free(&e_new->body->parts->next);
577 e_new->body = mutt_remove_multipart(e_new->body);
578
579 if (e_new->body->mime_headers)
580 {
581 mutt_env_free(&protected_headers);
582 protected_headers = e_new->body->mime_headers;
583 e_new->body->mime_headers = NULL;
584 }
585 }
586
587 /* We don't need no primary multipart/mixed. */
588 if ((e_new->body->type == TYPE_MULTIPART) && mutt_istr_equal(e_new->body->subtype, "mixed"))
589 e_new->body = mutt_remove_multipart(e_new->body);
590
591 file = buf_pool_get();
592
593 /* create temporary files for all attachments */
594 if (create_tmp_files_for_attachments(fp_body, file, e_new, e_new->body, protected_headers) < 0)
595 {
596 goto bail;
597 }
598
599 const bool c_crypt_protected_headers_read = cs_subset_bool(NeoMutt->sub, "crypt_protected_headers_read");
600 if (c_crypt_protected_headers_read && protected_headers && protected_headers->subject &&
601 !mutt_str_equal(e_new->env->subject, protected_headers->subject))
602 {
603 mutt_env_set_subject(e_new->env, protected_headers->subject);
604 }
605 mutt_env_free(&protected_headers);
606
607 /* Fix encryption flags. */
608
609 /* No inline if multipart. */
610 if ((WithCrypto != 0) && (e_new->security & SEC_INLINE) && e_new->body->next)
611 e_new->security &= ~SEC_INLINE;
612
613 /* Do we even support multiple mechanisms? */
615
616 /* Theoretically, both could be set. Take the one the user wants to set by default. */
617 if ((e_new->security & APPLICATION_PGP) && (e_new->security & APPLICATION_SMIME))
618 {
619 const bool c_smime_is_default = cs_subset_bool(NeoMutt->sub, "smime_is_default");
620 if (c_smime_is_default)
621 e_new->security &= ~APPLICATION_PGP;
622 else
623 e_new->security &= ~APPLICATION_SMIME;
624 }
625
627
628 rc = 0;
629
630bail:
631
632 /* that's it. */
633 buf_pool_release(&file);
634 if (fp_body != fp)
635 mutt_file_fclose(&fp_body);
636 if (msg)
637 mx_msg_close(m, &msg);
638
639 if (rc == -1)
640 {
641 mutt_env_free(&e_new->env);
642 mutt_body_free(&e_new->body);
643 }
644
645 return rc;
646}
647
658int mutt_get_postponed(struct Mailbox *m_cur, struct Email *hdr,
659 struct Email **cur, struct Buffer *fcc)
660{
661 const char *const c_postponed = cs_subset_string(NeoMutt->sub, "postponed");
662 if (!c_postponed)
663 return -1;
664
665 struct Email *e = NULL;
666 int rc = SEND_POSTPONED;
667 const char *p = NULL;
668
669 struct Mailbox *m = mx_path_resolve(c_postponed);
670 if (m_cur != m)
671 {
672 if (!mx_mbox_open(m, MUTT_NOSORT))
673 {
674 PostCount = 0;
675 mutt_error(_("No postponed messages"));
676 mailbox_free(&m);
677 return -1;
678 }
679 }
680
681 mx_mbox_check(m);
682
683 if (m->msg_count == 0)
684 {
685 PostCount = 0;
686 mutt_error(_("No postponed messages"));
687 if (m_cur != m)
688 {
689 mx_fastclose_mailbox(m, false);
690 mailbox_free(&m);
691 }
692 return -1;
693 }
694
695 /* avoid the "purge deleted messages" prompt */
696 const enum QuadOption c_delete = cs_subset_quad(NeoMutt->sub, "delete");
697 cs_subset_str_native_set(NeoMutt->sub, "delete", MUTT_YES, NULL);
698
699 if (m->msg_count == 1)
700 {
701 /* only one message, so just use that one. */
702 e = m->emails[0];
703 }
704 else if (!(e = dlg_postponed(m)))
705 {
706 rc = -1;
707 goto cleanup;
708 }
709
710 if (mutt_prepare_template(NULL, m, hdr, e, false) < 0)
711 {
712 rc = -1;
713 goto cleanup;
714 }
715
716 /* finished with this message, so delete it. */
717 mutt_set_flag(m, e, MUTT_DELETE, true, true);
718 mutt_set_flag(m, e, MUTT_PURGE, true, true);
719
720 /* update the count for the status display */
722
723 struct ListNode *np = NULL, *tmp = NULL;
724 STAILQ_FOREACH_SAFE(np, &hdr->env->userhdrs, entries, tmp)
725 {
726 size_t plen = 0;
727 // Check for header names: most specific first
728 if ((plen = mutt_istr_startswith(np->data, "X-Mutt-References:")) ||
729 (plen = mutt_istr_startswith(np->data, "Mutt-References:")))
730 {
731 /* if a mailbox is currently open, look to see if the original message
732 * the user attempted to reply to is in this mailbox */
733 if (m_cur)
734 {
735 p = mutt_str_skip_email_wsp(np->data + plen);
736 if (!m_cur->id_hash)
737 m_cur->id_hash = mutt_make_id_hash(m_cur);
738 *cur = mutt_hash_find(m_cur->id_hash, p);
739
740 if (*cur)
741 rc |= SEND_REPLY;
742 }
743 }
744 // Check for header names: most specific first
745 else if ((plen = mutt_istr_startswith(np->data, "X-Mutt-Fcc:")) ||
746 (plen = mutt_istr_startswith(np->data, "Mutt-Fcc:")))
747 {
748 p = mutt_str_skip_email_wsp(np->data + plen);
749 buf_strcpy(fcc, p);
751
752 /* note that mutt-fcc was present. we do this because we want to add a
753 * default fcc if the header was missing, but preserve the request of the
754 * user to not make a copy if the header field is present, but empty. */
755 rc |= SEND_POSTPONED_FCC;
756 }
757 // Check for header names: most specific first
758 else if (((WithCrypto & APPLICATION_PGP) != 0) &&
759 ((plen = mutt_istr_startswith(np->data, "X-Mutt-PGP:")) ||
760 (plen = mutt_istr_startswith(np->data, "Mutt-PGP:")) ||
761 (plen = mutt_istr_startswith(np->data, "Pgp:"))))
762 {
763 hdr->security = mutt_parse_crypt_hdr(np->data + plen, true, APPLICATION_PGP);
765 }
766 // Check for header names: most specific first
767 else if (((WithCrypto & APPLICATION_SMIME) != 0) &&
768 ((plen = mutt_istr_startswith(np->data, "X-Mutt-SMIME:")) ||
769 (plen = mutt_istr_startswith(np->data, "Mutt-SMIME:"))))
770 {
771 hdr->security = mutt_parse_crypt_hdr(np->data + plen, true, APPLICATION_SMIME);
773 }
774#ifdef MIXMASTER
775 // Check for header names: most specific first
776 else if ((plen = mutt_istr_startswith(np->data, "X-Mutt-Mix:")) ||
777 (plen = mutt_istr_startswith(np->data, "Mutt-Mix:")))
778 {
779 mutt_list_free(&hdr->chain);
780
781 char *t = strtok(np->data + plen, " \t\n");
782 while (t)
783 {
785 t = strtok(NULL, " \t\n");
786 }
787 }
788#endif
789 else
790 {
791 // skip header removal
792 continue;
793 }
794
795 // remove the header
796 STAILQ_REMOVE(&hdr->env->userhdrs, np, ListNode, entries);
797 FREE(&np->data);
798 FREE(&np);
799 }
800
801 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(NeoMutt->sub, "crypt_opportunistic_encrypt");
802 if (c_crypt_opportunistic_encrypt)
804
805cleanup:
806 if (m_cur != m)
807 {
808 hardclose(m);
809 mailbox_free(&m);
810 }
811
812 cs_subset_str_native_set(NeoMutt->sub, "delete", c_delete, NULL);
813 return rc;
814}
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1460
Email Address Handling.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:76
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:291
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
enum QuadOption cs_subset_quad(const struct ConfigSubset *sub, const char *name)
Get a quad-value config item by name.
Definition: helpers.c:192
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
Convenience wrapper for the config headers.
#define CSR_RESULT(x)
Definition: set.h:52
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
Convenience wrapper for the core headers.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:89
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:50
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
Definition: crypt.c:1045
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:408
SecurityFlags mutt_is_application_smime(struct Body *b)
Does the message use S/MIME?
Definition: crypt.c:609
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:132
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:443
SecurityFlags mutt_is_application_pgp(const struct Body *b)
Does the message use PGP?
Definition: crypt.c:548
int crypt_pgp_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec)
Wrapper for CryptModuleSpecs::decrypt_mime()
Definition: cryptglue.c:210
void crypt_smime_getkeys(struct Envelope *env)
Wrapper for CryptModuleSpecs::smime_getkeys()
Definition: cryptglue.c:454
int crypt_smime_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec)
Wrapper for CryptModuleSpecs::decrypt_mime()
Definition: cryptglue.c:432
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:58
Structs that make up an email.
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition: parse.c:1817
struct Envelope * mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed)
Parses an RFC822 header.
Definition: parse.c:1200
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:126
void mutt_env_set_subject(struct Envelope *env, const char *subj)
Set both subject and real_subj to subj.
Definition: envelope.c:69
bool mutt_file_seek(FILE *fp, LOFF_T offset, int whence)
Wrapper for fseeko with error handling.
Definition: file.c:778
#define mutt_file_fclose(FP)
Definition: file.h:149
#define mutt_file_fopen(PATH, MODE)
Definition: file.h:148
void mutt_set_flag(struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool upd_mbox)
Set a flag on an email.
Definition: flags.c:57
bool OptNews
(pseudo) used to change reader mode
Definition: globals.c:70
struct Email * dlg_postponed(struct Mailbox *m)
Create a Menu to select a postponed message -.
Definition: dlg_postpone.c:208
#define mutt_error(...)
Definition: logging2.h:92
#define mutt_message(...)
Definition: logging2.h:91
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe() -.
Definition: imap.c:2345
int mutt_body_handler(struct Body *b, struct State *state)
Handler for the Body of an email.
Definition: handler.c:1631
void mutt_decode_attachment(const struct Body *b, struct State *state)
Decode an email's attachment.
Definition: handler.c:1905
Decide how to display email content.
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:362
IMAP network mailbox.
int imap_path_status(const char *path, bool queue)
Refresh the number of total and new messages.
Definition: imap.c:1172
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
@ LL_DEBUG3
Log at debug level 3.
Definition: logging2.h:45
#define FREE(x)
Definition: memory.h:45
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
@ TYPE_TEXT
Type: 'text/*'.
Definition: mime.h:38
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
Definition: multipart.c:126
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
#define STATE_CHARCONV
Do character set conversions.
Definition: state.h:37
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:672
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:253
char * mutt_str_skip_email_wsp(const char *s)
Skip over whitespace as defined by RFC5322.
Definition: string.c:608
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:242
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:280
Many unsorted constants and some structs.
@ MUTT_PURGE
Messages to be purged (bypass trash)
Definition: mutt.h:77
@ MUTT_DELETE
Messages to be deleted.
Definition: mutt.h:75
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
NeoMutt Logging.
struct HashTable * mutt_make_id_hash(struct Mailbox *m)
Create a Hash Table for message-ids.
Definition: mutt_thread.c:1702
Create/manipulate threading in emails.
void buf_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition: muttlib.c:554
void mutt_adv_mktemp(struct Buffer *buf)
Create a temporary file.
Definition: muttlib.c:84
Some miscellaneous functions.
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
Definition: mx.c:1180
void mx_fastclose_mailbox(struct Mailbox *m, bool keep_account)
Free up memory associated with the Mailbox.
Definition: mx.c:414
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition: mx.c:288
struct Message * mx_msg_open(struct Mailbox *m, struct Email *e)
Return a stream pointer for a message.
Definition: mx.c:1134
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
Definition: mx.c:1636
enum MxStatus mx_mbox_check(struct Mailbox *m)
Check for new mail - Wrapper for MxOps::mbox_check()
Definition: mx.c:1105
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
Definition: mx.c:598
API for mailboxes.
#define MUTT_QUIET
Do not print any messages.
Definition: mxapi.h:44
#define MUTT_NOSORT
Do not sort the mailbox after opening it.
Definition: mxapi.h:41
MxStatus
Return values from mbox_check(), mbox_check_stats(), mbox_sync(), and mbox_close()
Definition: mxapi.h:63
@ MX_STATUS_ERROR
An error occurred.
Definition: mxapi.h:64
@ MX_STATUS_OK
No changes.
Definition: mxapi.h:65
API for encryption/signing of emails.
#define SEC_INLINE
Email has an inline signature.
Definition: lib.h:85
#define SEC_AUTOCRYPT
(Autocrypt) Message will be, or was Autocrypt encrypt+signed
Definition: lib.h:87
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: lib.h:76
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition: lib.h:86
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:90
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:91
#define SEC_NO_FLAGS
No flags are set.
Definition: lib.h:77
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:78
#define WithCrypto
Definition: lib.h:116
#define SEC_AUTOCRYPT_OVERRIDE
(Autocrypt) Indicates manual set/unset of encryption
Definition: lib.h:88
#define SEC_SIGN
Email is signed.
Definition: lib.h:79
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:85
void mutt_param_delete(struct ParameterList *pl, const char *attribute)
Delete a matching Parameter.
Definition: parameter.c:143
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
SecurityFlags mutt_parse_crypt_hdr(const char *p, bool set_empty_signas, SecurityFlags crypt_app)
Parse a crypto header string.
Definition: postpone.c:205
int mutt_num_postponed(struct Mailbox *m, bool force)
Return the number of postponed messages.
Definition: postpone.c:71
void mutt_update_num_postponed(void)
Force the update of the number of postponed messages.
Definition: postpone.c:178
short PostCount
Number of postponed (draft) emails.
Definition: postpone.c:59
static bool UpdateNumPostponed
When true, force a recount of the postponed (draft) emails.
Definition: postpone.c:61
int mutt_get_postponed(struct Mailbox *m_cur, struct Email *hdr, struct Email **cur, struct Buffer *fcc)
Recall a postponed message.
Definition: postpone.c:658
int mutt_prepare_template(FILE *fp, struct Mailbox *m, struct Email *e_new, struct Email *e, bool resend)
Prepare a message template.
Definition: postpone.c:484
static void hardclose(struct Mailbox *m)
Try hard to close a mailbox.
Definition: postpone.c:187
static int create_tmp_files_for_attachments(FILE *fp_body, struct Buffer *file, struct Email *e_new, struct Body *body, struct Envelope *protected_headers)
Create temporary files for all attachments.
Definition: postpone.c:359
Prototypes for many functions.
QuadOption
Possible values for a quad-option.
Definition: quad.h:36
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:39
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:402
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:362
void mutt_rfc3676_space_unstuff(struct Email *e)
Remove RFC3676 space stuffing.
Definition: rfc3676.c:499
RFC3676 Format Flowed routines.
Convenience wrapper for the send headers.
#define SEND_POSTPONED_FCC
Used by mutt_get_postponed() to signal that the Mutt-Fcc header field was present.
Definition: send.h:50
#define SEND_POSTPONED
Recall a postponed email.
Definition: send.h:46
#define SEND_REPLY
Reply to sender.
Definition: send.h:42
void mutt_stamp_attachment(struct Body *b)
Timestamp an Attachment.
Definition: sendlib.c:410
Key value store.
The body of an email.
Definition: body.h:36
char * d_filename
filename to be used for the content-disposition header If NULL, filename is used instead.
Definition: body.h:56
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:72
bool noconv
Don't do character set conversion.
Definition: body.h:46
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
Definition: body.h:67
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:75
LOFF_T length
length (in bytes) of attachment
Definition: body.h:53
struct ParameterList parameter
Parameters of the content-type.
Definition: body.h:62
bool use_disp
Content-Disposition uses filename= ?
Definition: body.h:47
struct Email * email
header information for message/rfc822
Definition: body.h:73
struct Body * next
next attachment in the list
Definition: body.h:71
char * subtype
content-type subtype
Definition: body.h:60
unsigned int type
content-type primary type, ContentType
Definition: body.h:40
char * filename
When sending a message, this is the file to which this structure refers.
Definition: body.h:58
String manipulation buffer.
Definition: buffer.h:36
The envelope/body of an email.
Definition: email.h:39
struct Envelope * env
Envelope information.
Definition: email.h:68
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition: email.h:43
struct Body * body
List of MIME parts.
Definition: email.h:69
LOFF_T offset
Where in the stream does this message begin?
Definition: email.h:71
struct ListHead chain
Mixmaster chain.
Definition: email.h:93
The header of an Email.
Definition: envelope.h:57
struct ListHead userhdrs
user defined headers
Definition: envelope.h:85
char *const subject
Email's subject.
Definition: envelope.h:70
char * message_id
Message ID.
Definition: envelope.h:73
struct AddressList mail_followup_to
Email's 'mail-followup-to'.
Definition: envelope.h:65
A List node for strings.
Definition: list.h:36
char * data
String.
Definition: list.h:37
A mailbox.
Definition: mailbox.h:79
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:81
int msg_count
Total number of messages.
Definition: mailbox.h:88
struct Email ** emails
Array of Emails.
Definition: mailbox.h:96
struct HashTable * id_hash
Hash Table: "message-id" -> Email.
Definition: mailbox.h:123
int msg_deleted
Number of deleted messages.
Definition: mailbox.h:93
A local copy of an email.
Definition: message.h:34
FILE * fp
pointer to the message data
Definition: message.h:35
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
Keep track when processing files.
Definition: state.h:48
StateFlags flags
Flags, e.g. STATE_DISPLAY.
Definition: state.h:52
FILE * fp_out
File to write to.
Definition: state.h:50
FILE * fp_in
File to read from.
Definition: state.h:49
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition: subset.c:297
int cs_subset_str_string_set(const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
Definition: subset.c:386