NeoMutt  2024-04-25-89-g194907
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
pop.c
Go to the documentation of this file.
1
33#include "config.h"
34#include <errno.h>
35#include <limits.h>
36#include <stdbool.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40#include <unistd.h>
41#include "private.h"
42#include "mutt/lib.h"
43#include "config/lib.h"
44#include "email/lib.h"
45#include "core/lib.h"
46#include "conn/lib.h"
47#include "lib.h"
48#include "bcache/lib.h"
49#include "ncrypt/lib.h"
50#include "progress/lib.h"
51#include "question/lib.h"
52#include "adata.h"
53#include "edata.h"
54#include "hook.h"
55#include "mutt_account.h"
56#include "mutt_header.h"
57#include "mutt_logging.h"
58#include "mutt_socket.h"
59#include "mx.h"
60#ifdef ENABLE_NLS
61#include <libintl.h>
62#endif
63#ifdef USE_HCACHE
64#include "hcache/lib.h"
65#endif
66
67struct BodyCache;
68struct stat;
69
70#define HC_FNAME "neomutt" /* filename for hcache as POP lacks paths */
71#define HC_FEXT "hcache" /* extension for hcache as POP lacks paths */
72
82static const char *cache_id(const char *id)
83{
84 static char clean[128];
85 mutt_str_copy(clean, id, sizeof(clean));
86 mutt_file_sanitize_filename(clean, true);
87 return clean;
88}
89
99static int fetch_message(const char *line, void *data)
100{
101 FILE *fp = data;
102
103 fputs(line, fp);
104 if (fputc('\n', fp) == EOF)
105 return -1;
106
107 return 0;
108}
109
119static int pop_read_header(struct PopAccountData *adata, struct Email *e)
120{
121 FILE *fp = mutt_file_mkstemp();
122 if (!fp)
123 {
124 mutt_perror(_("Can't create temporary file"));
125 return -3;
126 }
127
128 int index = 0;
129 size_t length = 0;
130 char buf[1024] = { 0 };
131
132 struct PopEmailData *edata = pop_edata_get(e);
133
134 snprintf(buf, sizeof(buf), "LIST %d\r\n", edata->refno);
135 int rc = pop_query(adata, buf, sizeof(buf));
136 if (rc == 0)
137 {
138 sscanf(buf, "+OK %d %zu", &index, &length);
139
140 snprintf(buf, sizeof(buf), "TOP %d 0\r\n", edata->refno);
141 rc = pop_fetch_data(adata, buf, NULL, fetch_message, fp);
142
143 if (adata->cmd_top == 2)
144 {
145 if (rc == 0)
146 {
147 adata->cmd_top = 1;
148
149 mutt_debug(LL_DEBUG1, "set TOP capability\n");
150 }
151
152 if (rc == -2)
153 {
154 adata->cmd_top = 0;
155
156 mutt_debug(LL_DEBUG1, "unset TOP capability\n");
157 snprintf(adata->err_msg, sizeof(adata->err_msg), "%s",
158 _("Command TOP is not supported by server"));
159 }
160 }
161 }
162
163 switch (rc)
164 {
165 case 0:
166 {
167 rewind(fp);
168 e->env = mutt_rfc822_read_header(fp, e, false, false);
169 e->body->length = length - e->body->offset + 1;
170 rewind(fp);
171 while (!feof(fp))
172 {
173 e->body->length--;
174 if (!fgets(buf, sizeof(buf), fp))
175 break;
176 }
177 break;
178 }
179 case -2:
180 {
181 mutt_error("%s", adata->err_msg);
182 break;
183 }
184 case -3:
185 {
186 mutt_error(_("Can't write header to temporary file"));
187 break;
188 }
189 }
190
191 mutt_file_fclose(&fp);
192 return rc;
193}
194
202static int fetch_uidl(const char *line, void *data)
203{
204 struct Mailbox *m = data;
206 char *endp = NULL;
207
208 errno = 0;
209 int index = strtol(line, &endp, 10);
210 if (errno)
211 return -1;
212 while (*endp == ' ')
213 endp++;
214 line = endp;
215
216 /* uid must be at least be 1 byte */
217 if (strlen(line) == 0)
218 return -1;
219
220 int i;
221 for (i = 0; i < m->msg_count; i++)
222 {
223 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
224 if (mutt_str_equal(line, edata->uid))
225 break;
226 }
227
228 if (i == m->msg_count)
229 {
230 mutt_debug(LL_DEBUG1, "new header %d %s\n", index, line);
231
232 mx_alloc_memory(m, i);
233
234 m->msg_count++;
235 m->emails[i] = email_new();
236
237 m->emails[i]->edata = pop_edata_new(line);
239 }
240 else if (m->emails[i]->index != index - 1)
241 {
242 adata->clear_cache = true;
243 }
244
245 m->emails[i]->index = index - 1;
246
247 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
248 edata->refno = index;
249
250 return 0;
251}
252
256static int pop_bcache_delete(const char *id, struct BodyCache *bcache, void *data)
257{
258 struct Mailbox *m = data;
259 if (!m)
260 return -1;
261
263 if (!adata)
264 return -1;
265
266#ifdef USE_HCACHE
267 /* keep hcache file if hcache == bcache */
268 if (mutt_str_equal(HC_FNAME "." HC_FEXT, id))
269 return 0;
270#endif
271
272 for (int i = 0; i < m->msg_count; i++)
273 {
274 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
275 /* if the id we get is known for a header: done (i.e. keep in cache) */
276 if (edata->uid && mutt_str_equal(edata->uid, id))
277 return 0;
278 }
279
280 /* message not found in context -> remove it from cache
281 * return the result of bcache, so we stop upon its first error */
282 return mutt_bcache_del(bcache, cache_id(id));
283}
284
285#ifdef USE_HCACHE
289static void pop_hcache_namer(const char *path, struct Buffer *dest)
290{
291 buf_printf(dest, "%s." HC_FEXT, path);
292}
293
300static struct HeaderCache *pop_hcache_open(struct PopAccountData *adata, const char *path)
301{
302 const char *const c_header_cache = cs_subset_path(NeoMutt->sub, "header_cache");
303 if (!adata || !adata->conn)
304 return hcache_open(c_header_cache, path, NULL, true);
305
306 struct Url url = { 0 };
307 char p[1024] = { 0 };
308
309 mutt_account_tourl(&adata->conn->account, &url);
310 url.path = HC_FNAME;
311 url_tostring(&url, p, sizeof(p), U_PATH);
312 return hcache_open(c_header_cache, p, pop_hcache_namer, true);
313}
314#endif
315
324static int pop_fetch_headers(struct Mailbox *m)
325{
326 if (!m)
327 return -1;
328
330 struct Progress *progress = NULL;
331
332#ifdef USE_HCACHE
333 struct HeaderCache *hc = pop_hcache_open(adata, mailbox_path(m));
334#endif
335
336 adata->check_time = mutt_date_now();
337 adata->clear_cache = false;
338
339 for (int i = 0; i < m->msg_count; i++)
340 {
341 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
342 edata->refno = -1;
343 }
344
345 const int old_count = m->msg_count;
346 int rc = pop_fetch_data(adata, "UIDL\r\n", NULL, fetch_uidl, m);
347 const int new_count = m->msg_count;
348 m->msg_count = old_count;
349
350 if (adata->cmd_uidl == 2)
351 {
352 if (rc == 0)
353 {
354 adata->cmd_uidl = 1;
355
356 mutt_debug(LL_DEBUG1, "set UIDL capability\n");
357 }
358
359 if ((rc == -2) && (adata->cmd_uidl == 2))
360 {
361 adata->cmd_uidl = 0;
362
363 mutt_debug(LL_DEBUG1, "unset UIDL capability\n");
364 snprintf(adata->err_msg, sizeof(adata->err_msg), "%s",
365 _("Command UIDL is not supported by server"));
366 }
367 }
368
369 if (m->verbose)
370 {
371 progress = progress_new(MUTT_PROGRESS_READ, new_count - old_count);
372 progress_set_message(progress, _("Fetching message headers..."));
373 }
374
375 if (rc == 0)
376 {
377 int i, deleted;
378 for (i = 0, deleted = 0; i < old_count; i++)
379 {
380 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
381 if (edata->refno == -1)
382 {
383 m->emails[i]->deleted = true;
384 deleted++;
385 }
386 }
387 if (deleted > 0)
388 {
389 mutt_error(ngettext("%d message has been lost. Try reopening the mailbox.",
390 "%d messages have been lost. Try reopening the mailbox.", deleted),
391 deleted);
392 }
393
394 bool hcached = false;
395 for (i = old_count; i < new_count; i++)
396 {
397 progress_update(progress, i + 1 - old_count, -1);
398 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
399#ifdef USE_HCACHE
400 struct HCacheEntry hce = hcache_fetch_email(hc, edata->uid, strlen(edata->uid), 0);
401 if (hce.email)
402 {
403 /* Detach the private data */
404 m->emails[i]->edata = NULL;
405
406 int index = m->emails[i]->index;
407 /* - POP dynamically numbers headers and relies on e->refno
408 * to map messages; so restore header and overwrite restored
409 * refno with current refno, same for index
410 * - e->data needs to a separate pointer as it's driver-specific
411 * data freed separately elsewhere
412 * (the old e->data should point inside a malloc'd block from
413 * hcache so there shouldn't be a memleak here) */
414 email_free(&m->emails[i]);
415 m->emails[i] = hce.email;
416 m->emails[i]->index = index;
417
418 /* Reattach the private data */
419 m->emails[i]->edata = edata;
421 rc = 0;
422 hcached = true;
423 }
424 else
425#endif
426 if ((rc = pop_read_header(adata, m->emails[i])) < 0)
427 break;
428#ifdef USE_HCACHE
429 else
430 {
431 hcache_store_email(hc, edata->uid, strlen(edata->uid), m->emails[i], 0);
432 }
433#endif
434
435 /* faked support for flags works like this:
436 * - if 'hcached' is true, we have the message in our hcache:
437 * - if we also have a body: read
438 * - if we don't have a body: old
439 * (if $mark_old is set which is maybe wrong as
440 * $mark_old should be considered for syncing the
441 * folder and not when opening it XXX)
442 * - if 'hcached' is false, we don't have the message in our hcache:
443 * - if we also have a body: read
444 * - if we don't have a body: new */
445 const bool bcached = (mutt_bcache_exists(adata->bcache, cache_id(edata->uid)) == 0);
446 m->emails[i]->old = false;
447 m->emails[i]->read = false;
448 if (hcached)
449 {
450 const bool c_mark_old = cs_subset_bool(NeoMutt->sub, "mark_old");
451 if (bcached)
452 m->emails[i]->read = true;
453 else if (c_mark_old)
454 m->emails[i]->old = true;
455 }
456 else
457 {
458 if (bcached)
459 m->emails[i]->read = true;
460 }
461
462 m->msg_count++;
463 }
464 }
465 progress_free(&progress);
466
467#ifdef USE_HCACHE
468 hcache_close(&hc);
469#endif
470
471 if (rc < 0)
472 {
473 for (int i = m->msg_count; i < new_count; i++)
474 email_free(&m->emails[i]);
475 return rc;
476 }
477
478 /* after putting the result into our structures,
479 * clean up cache, i.e. wipe messages deleted outside
480 * the availability of our cache */
481 const bool c_message_cache_clean = cs_subset_bool(NeoMutt->sub, "message_cache_clean");
482 if (c_message_cache_clean)
484
486 return new_count - old_count;
487}
488
493static void pop_clear_cache(struct PopAccountData *adata)
494{
495 if (!adata->clear_cache)
496 return;
497
498 mutt_debug(LL_DEBUG1, "delete cached messages\n");
499
500 for (int i = 0; i < POP_CACHE_LEN; i++)
501 {
502 if (adata->cache[i].path)
503 {
504 unlink(adata->cache[i].path);
505 FREE(&adata->cache[i].path);
506 }
507 }
508}
509
514{
515 const char *const c_pop_host = cs_subset_string(NeoMutt->sub, "pop_host");
516 if (!c_pop_host)
517 {
518 mutt_error(_("POP host is not defined"));
519 return;
520 }
521
522 char buf[1024] = { 0 };
523 char msgbuf[128] = { 0 };
524 int last = 0, msgs = 0, bytes = 0, rset = 0, rc;
525 struct ConnAccount cac = { { 0 } };
526
527 char *p = mutt_mem_calloc(strlen(c_pop_host) + 7, sizeof(char));
528 char *url = p;
529 if (url_check_scheme(c_pop_host) == U_UNKNOWN)
530 {
531 strcpy(url, "pop://");
532 p = strchr(url, '\0');
533 }
534 strcpy(p, c_pop_host);
535
536 rc = pop_parse_path(url, &cac);
537 FREE(&url);
538 if (rc)
539 {
540 mutt_error(_("%s is an invalid POP path"), c_pop_host);
541 return;
542 }
543
544 struct Connection *conn = mutt_conn_find(&cac);
545 if (!conn)
546 return;
547
549 adata->conn = conn;
550
551 if (pop_open_connection(adata) < 0)
552 {
553 pop_adata_free((void **) &adata);
554 return;
555 }
556
557 mutt_message(_("Checking for new messages..."));
558
559 /* find out how many messages are in the mailbox. */
560 mutt_str_copy(buf, "STAT\r\n", sizeof(buf));
561 rc = pop_query(adata, buf, sizeof(buf));
562 if (rc == -1)
563 goto fail;
564 if (rc == -2)
565 {
566 mutt_error("%s", adata->err_msg);
567 goto finish;
568 }
569
570 sscanf(buf, "+OK %d %d", &msgs, &bytes);
571
572 /* only get unread messages */
573 const bool c_pop_last = cs_subset_bool(NeoMutt->sub, "pop_last");
574 if ((msgs > 0) && c_pop_last)
575 {
576 mutt_str_copy(buf, "LAST\r\n", sizeof(buf));
577 rc = pop_query(adata, buf, sizeof(buf));
578 if (rc == -1)
579 goto fail;
580 if (rc == 0)
581 sscanf(buf, "+OK %d", &last);
582 }
583
584 if (msgs <= last)
585 {
586 mutt_message(_("No new mail in POP mailbox"));
587 goto finish;
588 }
589
590 const char *const c_spool_file = cs_subset_string(NeoMutt->sub, "spool_file");
591 struct Mailbox *m_spool = mx_path_resolve(c_spool_file);
592
593 if (!mx_mbox_open(m_spool, MUTT_OPEN_NO_FLAGS))
594 {
595 mailbox_free(&m_spool);
596 goto finish;
597 }
598 bool old_append = m_spool->append;
599 m_spool->append = true;
600
601 enum QuadOption delanswer = query_quadoption(_("Delete messages from server?"),
602 NeoMutt->sub, "pop_delete");
603
604 snprintf(msgbuf, sizeof(msgbuf),
605 ngettext("Reading new messages (%d byte)...",
606 "Reading new messages (%d bytes)...", bytes),
607 bytes);
608 mutt_message("%s", msgbuf);
609
610 for (int i = last + 1; i <= msgs; i++)
611 {
612 struct Message *msg = mx_msg_open_new(m_spool, NULL, MUTT_ADD_FROM);
613 if (msg)
614 {
615 snprintf(buf, sizeof(buf), "RETR %d\r\n", i);
616 rc = pop_fetch_data(adata, buf, NULL, fetch_message, msg->fp);
617 if (rc == -3)
618 rset = 1;
619
620 if ((rc == 0) && (mx_msg_commit(m_spool, msg) != 0))
621 {
622 rset = 1;
623 rc = -3;
624 }
625
626 mx_msg_close(m_spool, &msg);
627 }
628 else
629 {
630 rc = -3;
631 }
632
633 if ((rc == 0) && (delanswer == MUTT_YES))
634 {
635 /* delete the message on the server */
636 snprintf(buf, sizeof(buf), "DELE %d\r\n", i);
637 rc = pop_query(adata, buf, sizeof(buf));
638 }
639
640 if (rc == -1)
641 {
642 m_spool->append = old_append;
643 mx_mbox_close(m_spool);
644 goto fail;
645 }
646 if (rc == -2)
647 {
648 mutt_error("%s", adata->err_msg);
649 break;
650 }
651 if (rc == -3)
652 {
653 mutt_error(_("Error while writing mailbox"));
654 break;
655 }
656
657 /* L10N: The plural is picked by the second numerical argument, i.e.
658 the %d right before 'messages', i.e. the total number of messages. */
659 mutt_message(ngettext("%s [%d of %d message read]",
660 "%s [%d of %d messages read]", msgs - last),
661 msgbuf, i - last, msgs - last);
662 }
663
664 m_spool->append = old_append;
665 mx_mbox_close(m_spool);
666
667 if (rset)
668 {
669 /* make sure no messages get deleted */
670 mutt_str_copy(buf, "RSET\r\n", sizeof(buf));
671 if (pop_query(adata, buf, sizeof(buf)) == -1)
672 goto fail;
673 }
674
675finish:
676 /* exit gracefully */
677 mutt_str_copy(buf, "QUIT\r\n", sizeof(buf));
678 if (pop_query(adata, buf, sizeof(buf)) == -1)
679 goto fail;
680 mutt_socket_close(conn);
681 pop_adata_free((void **) &adata);
682 return;
683
684fail:
685 mutt_error(_("Server closed connection"));
686 mutt_socket_close(conn);
687 pop_adata_free((void **) &adata);
688}
689
693static bool pop_ac_owns_path(struct Account *a, const char *path)
694{
695 struct Url *url = url_parse(path);
696 if (!url)
697 return false;
698
699 struct PopAccountData *adata = a->adata;
700 struct ConnAccount *cac = &adata->conn->account;
701
702 const bool rc = mutt_istr_equal(url->host, cac->host) &&
703 mutt_istr_equal(url->user, cac->user);
704 url_free(&url);
705 return rc;
706}
707
711static bool pop_ac_add(struct Account *a, struct Mailbox *m)
712{
713 if (a->adata)
714 return true;
715
716 struct ConnAccount cac = { { 0 } };
717 if (pop_parse_path(mailbox_path(m), &cac))
718 {
719 mutt_error(_("%s is an invalid POP path"), mailbox_path(m));
720 return false;
721 }
722
724 adata->conn = mutt_conn_new(&cac);
725 if (!adata->conn)
726 {
727 pop_adata_free((void **) &adata);
728 return false;
729 }
730 a->adata = adata;
732
733 return true;
734}
735
741static enum MxOpenReturns pop_mbox_open(struct Mailbox *m)
742{
743 if (!m->account)
744 return MX_OPEN_ERROR;
745
746 char buf[PATH_MAX] = { 0 };
747 struct ConnAccount cac = { { 0 } };
748 struct Url url = { 0 };
749
750 if (pop_parse_path(mailbox_path(m), &cac))
751 {
752 mutt_error(_("%s is an invalid POP path"), mailbox_path(m));
753 return MX_OPEN_ERROR;
754 }
755
756 mutt_account_tourl(&cac, &url);
757 url.path = NULL;
758 url_tostring(&url, buf, sizeof(buf), U_NO_FLAGS);
759
760 buf_strcpy(&m->pathbuf, buf);
762
763 struct PopAccountData *adata = m->account->adata;
764 if (!adata)
765 {
767 m->account->adata = adata;
769 }
770
771 struct Connection *conn = adata->conn;
772 if (!conn)
773 {
774 adata->conn = mutt_conn_new(&cac);
775 conn = adata->conn;
776 if (!conn)
777 return MX_OPEN_ERROR;
778 }
779
780 if (conn->fd < 0)
782
783 if (pop_open_connection(adata) < 0)
784 return MX_OPEN_ERROR;
785
786 adata->bcache = mutt_bcache_open(&cac, NULL);
787
788 /* init (hard-coded) ACL rights */
790#ifdef USE_HCACHE
791 /* flags are managed using header cache, so it only makes sense to
792 * enable them in that case */
794#endif
795
796 while (true)
797 {
798 if (pop_reconnect(m) < 0)
799 return MX_OPEN_ERROR;
800
801 m->size = adata->size;
802
803 mutt_message(_("Fetching list of messages..."));
804
805 const int rc = pop_fetch_headers(m);
806
807 if (rc >= 0)
808 return MX_OPEN_OK;
809
810 if (rc < -1)
811 return MX_OPEN_ERROR;
812 }
813}
814
818static enum MxStatus pop_mbox_check(struct Mailbox *m)
819{
820 if (!m || !m->account)
821 return MX_STATUS_ERROR;
822
824
825 const short c_pop_check_interval = cs_subset_number(NeoMutt->sub, "pop_check_interval");
826 if ((adata->check_time + c_pop_check_interval) > mutt_date_now())
827 return MX_STATUS_OK;
828
829 pop_logout(m);
830
832
833 if (pop_open_connection(adata) < 0)
834 return MX_STATUS_ERROR;
835
836 m->size = adata->size;
837
838 mutt_message(_("Checking for new messages..."));
839
840 int old_msg_count = m->msg_count;
841 int rc = pop_fetch_headers(m);
843 if (m->msg_count > old_msg_count)
845
846 if (rc < 0)
847 return MX_STATUS_ERROR;
848
849 if (rc > 0)
850 return MX_STATUS_NEW_MAIL;
851
852 return MX_STATUS_OK;
853}
854
860static enum MxStatus pop_mbox_sync(struct Mailbox *m)
861{
862 int i, j, rc = 0;
863 char buf[1024] = { 0 };
865#ifdef USE_HCACHE
866 struct HeaderCache *hc = NULL;
867#endif
868
869 adata->check_time = 0;
870
871 int num_deleted = 0;
872 for (i = 0; i < m->msg_count; i++)
873 {
874 if (m->emails[i]->deleted)
875 num_deleted++;
876 }
877
878 while (true)
879 {
880 if (pop_reconnect(m) < 0)
881 return MX_STATUS_ERROR;
882
883#ifdef USE_HCACHE
884 hc = pop_hcache_open(adata, mailbox_path(m));
885#endif
886
887 struct Progress *progress = NULL;
888 if (m->verbose)
889 {
890 progress = progress_new(MUTT_PROGRESS_WRITE, num_deleted);
891 progress_set_message(progress, _("Marking messages deleted..."));
892 }
893
894 for (i = 0, j = 0, rc = 0; (rc == 0) && (i < m->msg_count); i++)
895 {
896 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
897 if (m->emails[i]->deleted && (edata->refno != -1))
898 {
899 j++;
900 progress_update(progress, j, -1);
901 snprintf(buf, sizeof(buf), "DELE %d\r\n", edata->refno);
902 rc = pop_query(adata, buf, sizeof(buf));
903 if (rc == 0)
904 {
905 mutt_bcache_del(adata->bcache, cache_id(edata->uid));
906#ifdef USE_HCACHE
907 hcache_delete_email(hc, edata->uid, strlen(edata->uid));
908#endif
909 }
910 }
911
912#ifdef USE_HCACHE
913 if (m->emails[i]->changed)
914 {
915 hcache_store_email(hc, edata->uid, strlen(edata->uid), m->emails[i], 0);
916 }
917#endif
918 }
919 progress_free(&progress);
920
921#ifdef USE_HCACHE
922 hcache_close(&hc);
923#endif
924
925 if (rc == 0)
926 {
927 mutt_str_copy(buf, "QUIT\r\n", sizeof(buf));
928 rc = pop_query(adata, buf, sizeof(buf));
929 }
930
931 if (rc == 0)
932 {
933 adata->clear_cache = true;
934 pop_clear_cache(adata);
935 adata->status = POP_DISCONNECTED;
936 return MX_STATUS_OK;
937 }
938
939 if (rc == -2)
940 {
941 mutt_error("%s", adata->err_msg);
942 return MX_STATUS_ERROR;
943 }
944 }
945}
946
950static enum MxStatus pop_mbox_close(struct Mailbox *m)
951{
953 if (!adata)
954 return MX_STATUS_OK;
955
956 pop_logout(m);
957
958 if (adata->status != POP_NONE)
959 {
961 }
962
963 adata->status = POP_NONE;
964
965 adata->clear_cache = true;
967
968 mutt_bcache_close(&adata->bcache);
969
970 return MX_STATUS_OK;
971}
972
976static bool pop_msg_open(struct Mailbox *m, struct Message *msg, struct Email *e)
977{
978 char buf[1024] = { 0 };
980 struct PopEmailData *edata = pop_edata_get(e);
981 bool bcache = true;
982 bool success = false;
983 struct Buffer *path = NULL;
984
985 /* see if we already have the message in body cache */
986 msg->fp = mutt_bcache_get(adata->bcache, cache_id(edata->uid));
987 if (msg->fp)
988 return true;
989
990 /* see if we already have the message in our cache in
991 * case $message_cache_dir is unset */
992 struct PopCache *cache = &adata->cache[e->index % POP_CACHE_LEN];
993
994 if (cache->path)
995 {
996 if (cache->index == e->index)
997 {
998 /* yes, so just return a pointer to the message */
999 msg->fp = mutt_file_fopen(cache->path, "r");
1000 if (msg->fp)
1001 return true;
1002
1003 mutt_perror("%s", cache->path);
1004 return false;
1005 }
1006 else
1007 {
1008 /* clear the previous entry */
1009 unlink(cache->path);
1010 FREE(&cache->path);
1011 }
1012 }
1013
1014 path = buf_pool_get();
1015
1016 while (true)
1017 {
1018 if (pop_reconnect(m) < 0)
1019 goto cleanup;
1020
1021 /* verify that massage index is correct */
1022 if (edata->refno < 0)
1023 {
1024 mutt_error(_("The message index is incorrect. Try reopening the mailbox."));
1025 goto cleanup;
1026 }
1027
1028 /* see if we can put in body cache; use our cache as fallback */
1029 msg->fp = mutt_bcache_put(adata->bcache, cache_id(edata->uid));
1030 if (!msg->fp)
1031 {
1032 /* no */
1033 bcache = false;
1035 msg->fp = mutt_file_fopen(buf_string(path), "w+");
1036 if (!msg->fp)
1037 {
1038 mutt_perror("%s", buf_string(path));
1039 goto cleanup;
1040 }
1041 }
1042
1043 snprintf(buf, sizeof(buf), "RETR %d\r\n", edata->refno);
1044
1045 struct Progress *progress = progress_new(MUTT_PROGRESS_NET,
1046 e->body->length + e->body->offset - 1);
1047 progress_set_message(progress, _("Fetching message..."));
1048 const int rc = pop_fetch_data(adata, buf, progress, fetch_message, msg->fp);
1049 progress_free(&progress);
1050
1051 if (rc == 0)
1052 break;
1053
1054 mutt_file_fclose(&msg->fp);
1055
1056 /* if RETR failed (e.g. connection closed), be sure to remove either
1057 * the file in bcache or from POP's own cache since the next iteration
1058 * of the loop will re-attempt to put() the message */
1059 if (!bcache)
1060 unlink(buf_string(path));
1061
1062 if (rc == -2)
1063 {
1064 mutt_error("%s", adata->err_msg);
1065 goto cleanup;
1066 }
1067
1068 if (rc == -3)
1069 {
1070 mutt_error(_("Can't write message to temporary file"));
1071 goto cleanup;
1072 }
1073 }
1074
1075 /* Update the header information. Previously, we only downloaded a
1076 * portion of the headers, those required for the main display. */
1077 if (bcache)
1078 {
1079 mutt_bcache_commit(adata->bcache, cache_id(edata->uid));
1080 }
1081 else
1082 {
1083 cache->index = e->index;
1084 cache->path = buf_strdup(path);
1085 }
1086 rewind(msg->fp);
1087
1088 /* Detach the private data */
1089 e->edata = NULL;
1090
1091 /* we replace envelope, key in subj_hash has to be updated as well */
1092 if (m->subj_hash && e->env->real_subj)
1095 mutt_env_free(&e->env);
1096 e->env = mutt_rfc822_read_header(msg->fp, e, false, false);
1097 if (m->subj_hash && e->env->real_subj)
1099 mutt_label_hash_add(m, e);
1100
1101 /* Reattach the private data */
1102 e->edata = edata;
1104
1105 e->lines = 0;
1106 while (fgets(buf, sizeof(buf), msg->fp) && !feof(msg->fp))
1107 {
1108 e->lines++;
1109 }
1110
1111 e->body->length = ftello(msg->fp) - e->body->offset;
1112
1113 /* This needs to be done in case this is a multipart message */
1114 if (!WithCrypto)
1115 e->security = crypt_query(e->body);
1116
1118 rewind(msg->fp);
1119
1120 success = true;
1121
1122cleanup:
1123 buf_pool_release(&path);
1124 return success;
1125}
1126
1132static int pop_msg_close(struct Mailbox *m, struct Message *msg)
1133{
1134 return mutt_file_fclose(&msg->fp);
1135}
1136
1140static int pop_msg_save_hcache(struct Mailbox *m, struct Email *e)
1141{
1142 int rc = 0;
1143#ifdef USE_HCACHE
1144 struct PopAccountData *adata = pop_adata_get(m);
1145 struct PopEmailData *edata = e->edata;
1146 struct HeaderCache *hc = pop_hcache_open(adata, mailbox_path(m));
1147 rc = hcache_store_email(hc, edata->uid, strlen(edata->uid), e, 0);
1148 hcache_close(&hc);
1149#endif
1150
1151 return rc;
1152}
1153
1157enum MailboxType pop_path_probe(const char *path, const struct stat *st)
1158{
1159 if (mutt_istr_startswith(path, "pop://"))
1160 return MUTT_POP;
1161
1162 if (mutt_istr_startswith(path, "pops://"))
1163 return MUTT_POP;
1164
1165 return MUTT_UNKNOWN;
1166}
1167
1171static int pop_path_canon(struct Buffer *path)
1172{
1173 return 0;
1174}
1175
1179const struct MxOps MxPopOps = {
1180 // clang-format off
1181 .type = MUTT_POP,
1182 .name = "pop",
1183 .is_local = false,
1184 .ac_owns_path = pop_ac_owns_path,
1185 .ac_add = pop_ac_add,
1186 .mbox_open = pop_mbox_open,
1187 .mbox_open_append = NULL,
1188 .mbox_check = pop_mbox_check,
1189 .mbox_check_stats = NULL,
1190 .mbox_sync = pop_mbox_sync,
1191 .mbox_close = pop_mbox_close,
1192 .msg_open = pop_msg_open,
1193 .msg_open_new = NULL,
1194 .msg_commit = NULL,
1195 .msg_close = pop_msg_close,
1196 .msg_padding_size = NULL,
1197 .msg_save_hcache = pop_msg_save_hcache,
1198 .tags_edit = NULL,
1199 .tags_commit = NULL,
1200 .path_probe = pop_path_probe,
1201 .path_canon = pop_path_canon,
1202 .path_is_empty = NULL,
1203 // clang-format on
1204};
Body Caching (local copies of email bodies)
int mutt_bcache_exists(struct BodyCache *bcache, const char *id)
Check if a file exists in the Body Cache.
Definition: bcache.c:294
int mutt_bcache_commit(struct BodyCache *bcache, const char *id)
Move a temporary file into the Body Cache.
Definition: bcache.c:254
struct BodyCache * mutt_bcache_open(struct ConnAccount *account, const char *mailbox)
Open an Email-Body Cache.
Definition: bcache.c:148
int mutt_bcache_list(struct BodyCache *bcache, bcache_list_t want_id, void *data)
Find matching entries in the Body Cache.
Definition: bcache.c:336
FILE * mutt_bcache_get(struct BodyCache *bcache, const char *id)
Open a file in the Body Cache.
Definition: bcache.c:187
void mutt_bcache_close(struct BodyCache **ptr)
Close an Email-Body Cache.
Definition: bcache.c:169
int mutt_bcache_del(struct BodyCache *bcache, const char *id)
Delete a file from the Body Cache.
Definition: bcache.c:271
FILE * mutt_bcache_put(struct BodyCache *bcache, const char *id)
Create a file in the Body Cache.
Definition: bcache.c:214
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition: buffer.c:571
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
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:143
const char * cs_subset_path(const struct ConfigSubset *sub, const char *name)
Get a path config item by name.
Definition: helpers.c:168
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.
Connection Library.
Convenience wrapper for the core headers.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:89
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
Definition: mailbox.c:233
@ NT_MAILBOX_INVALID
Email list was changed.
Definition: mailbox.h:189
#define MUTT_ACL_DELETE
Delete a message.
Definition: mailbox.h:63
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:223
#define MUTT_ACL_WRITE
Write to a message (for flagging or linking threads)
Definition: mailbox.h:71
MailboxType
Supported mailbox formats.
Definition: mailbox.h:41
@ MUTT_POP
'POP3' Mailbox type
Definition: mailbox.h:52
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition: mailbox.h:44
#define MUTT_ACL_SEEN
Change the 'seen' status of a message.
Definition: mailbox.h:70
SecurityFlags crypt_query(struct Body *b)
Check out the type of encryption used.
Definition: crypt.c:687
struct Email * email_new(void)
Create a new Email.
Definition: email.c:80
void email_free(struct Email **ptr)
Free an Email.
Definition: email.c:46
Structs that make up an email.
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_file_sanitize_filename(char *path, bool slash)
Replace unsafe characters in a filename.
Definition: file.c:712
#define mutt_file_fclose(FP)
Definition: file.h:149
#define mutt_file_fopen(PATH, MODE)
Definition: file.h:148
void pop_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free() -.
Definition: adata.c:41
static int pop_bcache_delete(const char *id, struct BodyCache *bcache, void *data)
Delete an entry from the message cache - Implements bcache_list_t -.
Definition: pop.c:256
void pop_edata_free(void **ptr)
Free the private Email data - Implements Email::edata_free() -.
Definition: edata.c:41
static void pop_hcache_namer(const char *path, struct Buffer *dest)
Create a header cache filename for a POP mailbox - Implements hcache_namer_t -.
Definition: pop.c:289
#define mutt_error(...)
Definition: logging2.h:92
#define mutt_message(...)
Definition: logging2.h:91
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
#define mutt_perror(...)
Definition: logging2.h:93
static bool pop_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Implements MxOps::ac_add() -.
Definition: pop.c:711
static bool pop_ac_owns_path(struct Account *a, const char *path)
Check whether an Account owns a Mailbox path - Implements MxOps::ac_owns_path() -.
Definition: pop.c:693
const struct MxOps MxPopOps
POP Mailbox - Implements MxOps -.
Definition: pop.c:1179
static enum MxStatus pop_mbox_check(struct Mailbox *m)
Check for new mail - Implements MxOps::mbox_check() -.
Definition: pop.c:818
static enum MxStatus pop_mbox_close(struct Mailbox *m)
Close a Mailbox - Implements MxOps::mbox_close() -.
Definition: pop.c:950
static enum MxOpenReturns pop_mbox_open(struct Mailbox *m)
Open a Mailbox - Implements MxOps::mbox_open() -.
Definition: pop.c:741
static enum MxStatus pop_mbox_sync(struct Mailbox *m)
Save changes to the Mailbox - Implements MxOps::mbox_sync() -.
Definition: pop.c:860
static int pop_msg_close(struct Mailbox *m, struct Message *msg)
Close an email - Implements MxOps::msg_close() -.
Definition: pop.c:1132
static bool pop_msg_open(struct Mailbox *m, struct Message *msg, struct Email *e)
Open an email message in a Mailbox - Implements MxOps::msg_open() -.
Definition: pop.c:976
static int pop_msg_save_hcache(struct Mailbox *m, struct Email *e)
Save message to the header cache - Implements MxOps::msg_save_hcache() -.
Definition: pop.c:1140
static int pop_path_canon(struct Buffer *path)
Canonicalise a Mailbox path - Implements MxOps::path_canon() -.
Definition: pop.c:1171
enum MailboxType pop_path_probe(const char *path, const struct stat *st)
Is this a POP Mailbox? - Implements MxOps::path_probe() -.
Definition: pop.c:1157
static int fetch_message(const char *line, void *data)
Parse a Message response - Implements pop_fetch_t -.
Definition: pop.c:99
static int fetch_uidl(const char *line, void *data)
Parse UIDL response - Implements pop_fetch_t -.
Definition: pop.c:202
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
Definition: hash.c:335
void mutt_hash_delete(struct HashTable *table, const char *strkey, const void *data)
Remove an element from a Hash Table.
Definition: hash.c:427
struct HeaderCache * hcache_open(const char *path, const char *folder, hcache_namer_t namer, bool create)
Multiplexor for StoreOps::open.
Definition: hcache.c:471
int hcache_delete_email(struct HeaderCache *hc, const char *key, size_t keylen)
Multiplexor for StoreOps::delete_record.
Definition: hcache.c:742
void hcache_close(struct HeaderCache **ptr)
Multiplexor for StoreOps::close.
Definition: hcache.c:545
struct HCacheEntry hcache_fetch_email(struct HeaderCache *hc, const char *key, size_t keylen, uint32_t uidvalidity)
Multiplexor for StoreOps::fetch.
Definition: hcache.c:565
int hcache_store_email(struct HeaderCache *hc, const char *key, size_t keylen, struct Email *e, uint32_t uidvalidity)
Multiplexor for StoreOps::store.
Definition: hcache.c:673
Header cache multiplexor.
void mutt_account_hook(const char *url)
Perform an account hook.
Definition: hook.c:879
Parse and execute user-defined hooks.
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
#define FREE(x)
Definition: memory.h:45
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:456
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:672
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:581
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
#define PATH_MAX
Definition: mutt.h:42
void mutt_account_tourl(struct ConnAccount *cac, struct Url *url)
Fill URL with info from account.
Definition: mutt_account.c:80
ConnAccount object used by POP and IMAP.
void mutt_label_hash_remove(struct Mailbox *m, struct Email *e)
Remove a message's labels from the Hash Table.
Definition: mutt_header.c:445
void mutt_label_hash_add(struct Mailbox *m, struct Email *e)
Add a message's labels to the Hash Table.
Definition: mutt_header.c:432
Representation of the email's header.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
NeoMutt Logging.
struct Connection * mutt_conn_new(const struct ConnAccount *cac)
Create a new Connection.
Definition: mutt_socket.c:49
struct Connection * mutt_conn_find(const struct ConnAccount *cac)
Find a connection from a list.
Definition: mutt_socket.c:90
NeoMutt connections.
void mx_alloc_memory(struct Mailbox *m, int req_size)
Create storage for the emails.
Definition: mx.c:1206
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
Definition: mx.c:1180
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition: mx.c:288
struct Message * mx_msg_open_new(struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
Open a new message.
Definition: mx.c:1040
int mx_msg_commit(struct Mailbox *m, struct Message *msg)
Commit a message to a folder - Wrapper for MxOps::msg_commit()
Definition: mx.c:1159
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
Definition: mx.c:1636
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
Definition: mx.c:598
API for mailboxes.
#define MUTT_ADD_FROM
add a From_ line
Definition: mx.h:39
MxOpenReturns
Return values for mbox_open()
Definition: mxapi.h:76
@ MX_OPEN_ERROR
Open failed with an error.
Definition: mxapi.h:78
@ MX_OPEN_OK
Open succeeded.
Definition: mxapi.h:77
#define MUTT_OPEN_NO_FLAGS
No flags are set.
Definition: mxapi.h:40
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
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
Definition: mxapi.h:66
API for encryption/signing of emails.
#define WithCrypto
Definition: lib.h:116
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
struct PopAccountData * pop_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: adata.c:73
struct PopAccountData * pop_adata_new(void)
Create a new PopAccountData object.
Definition: adata.c:63
Pop-specific Account data.
struct PopEmailData * pop_edata_new(const char *uid)
Create a new PopEmailData for an email.
Definition: edata.c:56
struct PopEmailData * pop_edata_get(struct Email *e)
Get the private data for this Email.
Definition: edata.c:68
Pop-specific Email data.
int pop_open_connection(struct PopAccountData *adata)
Open connection and authenticate.
Definition: lib.c:317
int pop_parse_path(const char *path, struct ConnAccount *cac)
Parse a POP mailbox name.
Definition: lib.c:83
int pop_fetch_data(struct PopAccountData *adata, const char *query, struct Progress *progress, pop_fetch_t callback, void *data)
Read Headers with callback function.
Definition: lib.c:511
void pop_logout(struct Mailbox *m)
Logout from a POP server.
Definition: lib.c:425
int pop_reconnect(struct Mailbox *m)
Reconnect and verify indexes if connection was lost.
Definition: lib.c:609
#define pop_query(adata, buf, buflen)
Definition: private.h:111
#define POP_CACHE_LEN
Definition: private.h:39
@ POP_DISCONNECTED
Disconnected from server.
Definition: private.h:51
@ POP_NONE
No connected to server.
Definition: private.h:49
static void pop_clear_cache(struct PopAccountData *adata)
Delete all cached messages.
Definition: pop.c:493
#define HC_FNAME
Definition: pop.c:70
static const char * cache_id(const char *id)
Make a message-cache-compatible id.
Definition: pop.c:82
static struct HeaderCache * pop_hcache_open(struct PopAccountData *adata, const char *path)
Open the header cache.
Definition: pop.c:300
#define HC_FEXT
Definition: pop.c:71
static int pop_read_header(struct PopAccountData *adata, struct Email *e)
Read header.
Definition: pop.c:119
void pop_fetch_mail(void)
Fetch messages and save them in $spool_file.
Definition: pop.c:513
static int pop_fetch_headers(struct Mailbox *m)
Read headers.
Definition: pop.c:324
Progress Bar.
@ MUTT_PROGRESS_NET
Progress tracks bytes, according to $net_inc
Definition: lib.h:81
@ MUTT_PROGRESS_READ
Progress tracks elements, according to $read_inc
Definition: lib.h:82
@ MUTT_PROGRESS_WRITE
Progress tracks elements, according to $write_inc
Definition: lib.h:83
struct Progress * progress_new(enum ProgressType type, size_t size)
Create a new Progress Bar.
Definition: progress.c:139
void progress_free(struct Progress **ptr)
Free a Progress Bar.
Definition: progress.c:110
void progress_set_message(struct Progress *progress, const char *fmt,...) __attribute__((__format__(__printf__
bool progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:80
QuadOption
Possible values for a quad-option.
Definition: quad.h:36
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:39
Ask the user a question.
enum QuadOption query_quadoption(const char *prompt, struct ConfigSubset *sub, const char *name)
Ask the user a quad-question.
Definition: question.c:365
GUI display the mailboxes in a side panel.
int mutt_socket_close(struct Connection *conn)
Close a socket.
Definition: socket.c:100
Key value store.
A group of associated Mailboxes.
Definition: account.h:36
void(* adata_free)(void **ptr)
Definition: account.h:53
void * adata
Private data (for Mailbox backends)
Definition: account.h:42
Local cache of email bodies.
Definition: bcache.c:51
LOFF_T offset
offset where the actual data begins
Definition: body.h:52
LOFF_T length
length (in bytes) of attachment
Definition: body.h:53
String manipulation buffer.
Definition: buffer.h:36
Login details for a remote server.
Definition: connaccount.h:53
char user[128]
Username.
Definition: connaccount.h:56
char host[128]
Server to login to.
Definition: connaccount.h:54
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:49
int fd
Socket file descriptor.
Definition: connection.h:53
The envelope/body of an email.
Definition: email.h:39
bool read
Email is read.
Definition: email.h:50
struct Envelope * env
Envelope information.
Definition: email.h:68
void * edata
Driver-specific data.
Definition: email.h:74
int lines
How many lines in the body of this message?
Definition: email.h:62
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
bool old
Email is seen, but unread.
Definition: email.h:49
void(* edata_free)(void **ptr)
Definition: email.h:90
bool changed
Email has been edited.
Definition: email.h:77
char * path
Path of Email (for local Mailboxes)
Definition: email.h:70
bool deleted
Email is deleted.
Definition: email.h:78
int index
The absolute (unsorted) message number.
Definition: email.h:113
char *const real_subj
Offset of the real subject.
Definition: envelope.h:71
Wrapper for Email retrieved from the header cache.
Definition: lib.h:99
struct Email * email
Retrieved email.
Definition: lib.h:102
Header Cache.
Definition: lib.h:86
A mailbox.
Definition: mailbox.h:79
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:81
bool append
Mailbox is opened in append mode.
Definition: mailbox.h:109
int msg_count
Total number of messages.
Definition: mailbox.h:88
AclFlags rights
ACL bits, see AclFlags.
Definition: mailbox.h:119
struct HashTable * subj_hash
Hash Table: "subject" -> Email.
Definition: mailbox.h:124
struct Email ** emails
Array of Emails.
Definition: mailbox.h:96
struct Buffer pathbuf
Path of the Mailbox.
Definition: mailbox.h:80
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:127
off_t size
Size of the Mailbox.
Definition: mailbox.h:84
bool verbose
Display status messages?
Definition: mailbox.h:117
A local copy of an email.
Definition: message.h:34
FILE * fp
pointer to the message data
Definition: message.h:35
char * path
path to temp file
Definition: message.h:36
Definition: mxapi.h:91
enum MailboxType type
Mailbox type, e.g. MUTT_IMAP.
Definition: mxapi.h:92
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
POP-specific Account data -.
Definition: adata.h:37
size_t size
Definition: adata.h:50
bool clear_cache
Definition: adata.h:49
time_t check_time
Definition: adata.h:51
unsigned int cmd_top
optional command TOP
Definition: adata.h:46
char err_msg[POP_CMD_RESPONSE]
Definition: adata.h:56
unsigned int status
Definition: adata.h:39
struct Connection * conn
Connection to POP server.
Definition: adata.h:38
struct PopCache cache[POP_CACHE_LEN]
Definition: adata.h:57
struct BodyCache * bcache
body cache
Definition: adata.h:55
unsigned int cmd_uidl
optional command UIDL
Definition: adata.h:45
POP-specific email cache.
Definition: private.h:69
unsigned int index
Definition: private.h:70
char * path
Definition: private.h:71
POP-specific Email data -.
Definition: edata.h:32
int refno
Message number on server.
Definition: edata.h:34
const char * uid
UID of email.
Definition: edata.h:33
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:69
char * user
Username.
Definition: url.h:71
char * host
Host.
Definition: url.h:73
char * path
Path.
Definition: url.h:75
#define buf_mktemp(buf)
Definition: tmp.h:33
#define mutt_file_mkstemp()
Definition: tmp.h:36
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:239
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:124
enum UrlScheme url_check_scheme(const char *str)
Check the protocol of a URL.
Definition: url.c:226
int url_tostring(const struct Url *url, char *dest, size_t len, uint8_t flags)
Output the URL string for a given Url object.
Definition: url.c:423
#define U_NO_FLAGS
Definition: url.h:49
@ U_UNKNOWN
Url wasn't recognised.
Definition: url.h:35
#define U_PATH
Definition: url.h:50