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