NeoMutt  2025-12-11-980-ge38c27
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));
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 rewind(fp);
177 e->env = mutt_rfc822_read_header(fp, e, false, false);
178 e->body->length = length - e->body->offset + 1;
179 rewind(fp);
180 while (!feof(fp))
181 {
182 e->body->length--;
183 if (!fgets(buf, sizeof(buf), fp))
184 break;
185 }
186 break;
187 }
188 case -2:
189 {
190 mutt_error("%s", adata->err_msg);
191 break;
192 }
193 case -3:
194 {
195 mutt_error(_("Can't write header to temporary file"));
196 break;
197 }
198 }
199
200 mutt_file_fclose(&fp);
201 return rc;
202}
203
211static int fetch_uidl(const char *line, void *data)
212{
213 struct Mailbox *m = data;
215 char *endp = NULL;
216
217 errno = 0;
218 int index = strtol(line, &endp, 10);
219 if ((errno != 0) || (endp == line))
220 return -1;
221 while (*endp == ' ')
222 endp++;
223 line = endp;
224
225 /* uid must be at least be 1 byte */
226 if (strlen(line) == 0)
227 return -1;
228
229 int i;
230 for (i = 0; i < m->msg_count; i++)
231 {
232 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
233 if (mutt_str_equal(line, edata->uid))
234 break;
235 }
236
237 if (i == m->msg_count)
238 {
239 if (m->msg_count >= POP_MAX_MESSAGES)
240 {
241 mutt_debug(LL_DEBUG1, "UIDL response limit reached (%d)\n", POP_MAX_MESSAGES);
242 return -1;
243 }
244
245 mutt_debug(LL_DEBUG1, "new header %d %s\n", index, line);
246
247 mx_alloc_memory(m, i);
248
249 m->msg_count++;
250 m->emails[i] = email_new();
251
252 m->emails[i]->edata = pop_edata_new(line);
254 }
255 else if (m->emails[i]->index != index - 1)
256 {
257 adata->clear_cache = true;
258 }
259
260 m->emails[i]->index = index - 1;
261
262 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
263 edata->refno = index;
264
265 return 0;
266}
267
271static int pop_bcache_delete(const char *id, struct BodyCache *bcache, void *data)
272{
273 struct Mailbox *m = data;
274 if (!m)
275 return -1;
276
278 if (!adata)
279 return -1;
280
281#ifdef USE_HCACHE
282 /* keep hcache file if hcache == bcache */
283 if (mutt_str_equal(HC_FNAME "." HC_FEXT, id))
284 return 0;
285#endif
286
287 for (int i = 0; i < m->msg_count; i++)
288 {
289 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
290 /* if the id we get is known for a header: done (i.e. keep in cache) */
291 if (edata->uid && mutt_str_equal(edata->uid, id))
292 return 0;
293 }
294
295 /* message not found in context -> remove it from cache
296 * return the result of bcache, so we stop upon its first error */
297 return mutt_bcache_del(bcache, cache_id(id));
298}
299
300#ifdef USE_HCACHE
304static void pop_hcache_namer(const struct StoreOps *store_ops, const char *path,
305 struct Buffer *dest)
306{
307 buf_printf(dest, "%s.%s." HC_FEXT, path, store_ops->name);
308}
309
316static struct HeaderCache *pop_hcache_open(struct PopAccountData *adata, const char *path)
317{
318 const char *const c_header_cache = cs_subset_path(NeoMutt->sub, "header_cache");
319 if (!adata || !adata->conn)
320 return hcache_open(c_header_cache, path, NULL, true);
321
322 struct Url url = { 0 };
323 char p[1024] = { 0 };
324
325 account_to_url(&adata->conn->account, &url);
326 url.path = HC_FNAME;
327 url_tostring(&url, p, sizeof(p), U_PATH);
328 return hcache_open(c_header_cache, p, pop_hcache_namer, true);
329}
330#endif
331
340static int pop_fetch_headers(struct Mailbox *m)
341{
342 if (!m)
343 return -1;
344
346 struct Progress *progress = NULL;
347
348#ifdef USE_HCACHE
349 struct HeaderCache *hc = pop_hcache_open(adata, mailbox_path(m));
350#endif
351
352 adata->check_time = mutt_date_now();
353 adata->clear_cache = false;
354
355 for (int i = 0; i < m->msg_count; i++)
356 {
357 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
358 edata->refno = -1;
359 }
360
361 const int old_count = m->msg_count;
362 int rc = pop_fetch_data(adata, "UIDL\r\n", NULL, fetch_uidl, m);
363 const int new_count = m->msg_count;
364 m->msg_count = old_count;
365
366 if (adata->cmd_uidl == 2)
367 {
368 if (rc == 0)
369 {
370 adata->cmd_uidl = 1;
371
372 mutt_debug(LL_DEBUG1, "set UIDL capability\n");
373 }
374
375 if ((rc == -2) && (adata->cmd_uidl == 2))
376 {
377 adata->cmd_uidl = 0;
378
379 mutt_debug(LL_DEBUG1, "unset UIDL capability\n");
380 snprintf(adata->err_msg, sizeof(adata->err_msg), "%s",
381 _("Command UIDL is not supported by server"));
382 }
383 }
384
385 if (m->verbose)
386 {
387 progress = progress_new(MUTT_PROGRESS_READ, new_count - old_count);
388 progress_set_message(progress, _("Fetching message headers..."));
389 }
390
391 if (rc == 0)
392 {
393 int i = 0;
394 int deleted = 0;
395 for (; i < old_count; i++)
396 {
397 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
398 if (edata->refno == -1)
399 {
400 m->emails[i]->deleted = true;
401 deleted++;
402 }
403 }
404 if (deleted > 0)
405 {
406 mutt_error(ngettext("%d message has been lost. Try reopening the mailbox.",
407 "%d messages have been lost. Try reopening the mailbox.", deleted),
408 deleted);
409 }
410
411 bool hcached = false;
412 for (i = old_count; i < new_count; i++)
413 {
414 progress_update(progress, i + 1 - old_count, -1);
415 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
416#ifdef USE_HCACHE
417 struct HCacheEntry hce = hcache_fetch_email(hc, edata->uid, strlen(edata->uid), 0);
418 if (hce.email)
419 {
420 /* Detach the private data */
421 m->emails[i]->edata = NULL;
422
423 int index = m->emails[i]->index;
424 /* - POP dynamically numbers headers and relies on e->refno
425 * to map messages; so restore header and overwrite restored
426 * refno with current refno, same for index
427 * - e->data needs to a separate pointer as it's driver-specific
428 * data freed separately elsewhere
429 * (the old e->data should point inside a malloc'd block from
430 * hcache so there shouldn't be a memleak here) */
431 email_free(&m->emails[i]);
432 m->emails[i] = hce.email;
433 m->emails[i]->index = index;
434
435 /* Reattach the private data */
436 m->emails[i]->edata = edata;
438 rc = 0;
439 hcached = true;
440 }
441 else
442#endif
443 if ((rc = pop_read_header(adata, m->emails[i])) < 0)
444 break;
445#ifdef USE_HCACHE
446 else
447 {
448 hcache_store_email(hc, edata->uid, strlen(edata->uid), m->emails[i], 0);
449 }
450#endif
451
452 /* faked support for flags works like this:
453 * - if 'hcached' is true, we have the message in our hcache:
454 * - if we also have a body: read
455 * - if we don't have a body: old
456 * (if $mark_old is set which is maybe wrong as
457 * $mark_old should be considered for syncing the
458 * folder and not when opening it XXX)
459 * - if 'hcached' is false, we don't have the message in our hcache:
460 * - if we also have a body: read
461 * - if we don't have a body: new */
462 const bool bcached = (mutt_bcache_exists(adata->bcache, cache_id(edata->uid)) == 0);
463 m->emails[i]->old = false;
464 m->emails[i]->read = false;
465 if (hcached)
466 {
467 const bool c_mark_old = cs_subset_bool(NeoMutt->sub, "mark_old");
468 if (bcached)
469 m->emails[i]->read = true;
470 else if (c_mark_old)
471 m->emails[i]->old = true;
472 }
473 else
474 {
475 if (bcached)
476 m->emails[i]->read = true;
477 }
478
479 m->msg_count++;
480 }
481 }
482 progress_free(&progress);
483
484#ifdef USE_HCACHE
485 hcache_close(&hc);
486#endif
487
488 if (rc < 0)
489 {
490 for (int i = m->msg_count; i < new_count; i++)
491 email_free(&m->emails[i]);
492 return rc;
493 }
494
495 /* after putting the result into our structures,
496 * clean up cache, i.e. wipe messages deleted outside
497 * the availability of our cache */
498 const bool c_message_cache_clean = cs_subset_bool(NeoMutt->sub, "message_cache_clean");
499 if (c_message_cache_clean)
501
503 return new_count - old_count;
504}
505
510static void pop_clear_cache(struct PopAccountData *adata)
511{
512 if (!adata->clear_cache)
513 return;
514
515 mutt_debug(LL_DEBUG1, "delete cached messages\n");
516
517 for (int i = 0; i < POP_CACHE_LEN; i++)
518 {
519 if (adata->cache[i].path)
520 {
521 unlink(adata->cache[i].path);
522 FREE(&adata->cache[i].path);
523 }
524 }
525}
526
531{
532 const char *const c_pop_host = cs_subset_string(NeoMutt->sub, "pop_host");
533 if (!c_pop_host)
534 {
535 mutt_error(_("POP host is not defined"));
536 return;
537 }
538
539 char buf[1024] = { 0 };
540 char msgbuf[128] = { 0 };
541 int last = 0;
542 int msgs = 0;
543 int bytes = 0;
544 int rset = 0;
545 int rc;
546 struct ConnAccount cac = { { 0 } };
547
548 char *url = NULL;
549 if (url_check_scheme(c_pop_host) == U_UNKNOWN)
550 mutt_str_asprintf(&url, "pop://%s", c_pop_host);
551 else
552 url = mutt_str_dup(c_pop_host);
553
554 rc = pop_parse_path(url, &cac);
555 FREE(&url);
556 if (rc)
557 {
558 mutt_error(_("%s is an invalid POP path"), c_pop_host);
559 return;
560 }
561
562 struct Connection *conn = mutt_conn_find(&cac);
563 if (!conn)
564 return;
565
567 adata->conn = conn;
568
569 if (pop_open_connection(adata) < 0)
570 {
571 pop_adata_free((void **) &adata);
572 return;
573 }
574
575 mutt_message(_("Checking for new messages..."));
576
577 /* find out how many messages are in the mailbox. */
578 mutt_str_copy(buf, "STAT\r\n", sizeof(buf));
579 rc = pop_query(adata, buf, sizeof(buf));
580 if (rc == -1)
581 goto fail;
582 if (rc == -2)
583 {
584 mutt_error("%s", adata->err_msg);
585 goto finish;
586 }
587
588 sscanf(buf, "+OK %d %d", &msgs, &bytes);
589
590 /* only get unread messages */
591 const bool c_pop_last = cs_subset_bool(NeoMutt->sub, "pop_last");
592 if ((msgs > 0) && c_pop_last)
593 {
594 mutt_str_copy(buf, "LAST\r\n", sizeof(buf));
595 rc = pop_query(adata, buf, sizeof(buf));
596 if (rc == -1)
597 goto fail;
598 if (rc == 0)
599 sscanf(buf, "+OK %d", &last);
600 }
601
602 if (msgs <= last)
603 {
604 mutt_message(_("No new mail in POP mailbox"));
605 goto finish;
606 }
607
608 const char *const c_spool_file = cs_subset_string(NeoMutt->sub, "spool_file");
609 struct Mailbox *m_spool = mx_path_resolve(c_spool_file);
610
611 if (!mx_mbox_open(m_spool, MUTT_OPEN_NONE))
612 {
613 mailbox_free(&m_spool);
614 goto finish;
615 }
616 bool old_append = m_spool->append;
617 m_spool->append = true;
618
619 enum QuadOption delanswer = query_quadoption(_("Delete messages from server?"),
620 NeoMutt->sub, "pop_delete");
621
622 snprintf(msgbuf, sizeof(msgbuf),
623 ngettext("Reading new messages (%d byte)...",
624 "Reading new messages (%d bytes)...", bytes),
625 bytes);
626 mutt_message("%s", msgbuf);
627
628 for (int i = last + 1; i <= msgs; i++)
629 {
630 struct Message *msg = mx_msg_open_new(m_spool, NULL, MUTT_ADD_FROM);
631 if (msg)
632 {
633 snprintf(buf, sizeof(buf), "RETR %d\r\n", i);
634 rc = pop_fetch_data(adata, buf, NULL, fetch_message, msg->fp);
635 if (rc == -3)
636 rset = 1;
637
638 if ((rc == 0) && (mx_msg_commit(m_spool, msg) != 0))
639 {
640 rset = 1;
641 rc = -3;
642 }
643
644 mx_msg_close(m_spool, &msg);
645 }
646 else
647 {
648 rc = -3;
649 }
650
651 if ((rc == 0) && (delanswer == MUTT_YES))
652 {
653 /* delete the message on the server */
654 snprintf(buf, sizeof(buf), "DELE %d\r\n", i);
655 rc = pop_query(adata, buf, sizeof(buf));
656 }
657
658 if (rc == -1)
659 {
660 m_spool->append = old_append;
661 mx_mbox_close(m_spool);
662 goto fail;
663 }
664 if (rc == -2)
665 {
666 mutt_error("%s", adata->err_msg);
667 break;
668 }
669 if (rc == -3)
670 {
671 mutt_error(_("Error while writing mailbox"));
672 break;
673 }
674
675 /* L10N: The plural is picked by the second numerical argument, i.e.
676 the %d right before 'messages', i.e. the total number of messages. */
677 mutt_message(ngettext("%s [%d of %d message read]",
678 "%s [%d of %d messages read]", msgs - last),
679 msgbuf, i - last, msgs - last);
680 }
681
682 m_spool->append = old_append;
683 mx_mbox_close(m_spool);
684
685 if (rset)
686 {
687 /* make sure no messages get deleted */
688 mutt_str_copy(buf, "RSET\r\n", sizeof(buf));
689 if (pop_query(adata, buf, sizeof(buf)) == -1)
690 goto fail;
691 }
692
693finish:
694 /* exit gracefully */
695 mutt_str_copy(buf, "QUIT\r\n", sizeof(buf));
696 if (pop_query(adata, buf, sizeof(buf)) == -1)
697 goto fail;
698 mutt_socket_close(conn);
699 pop_adata_free((void **) &adata);
700 return;
701
702fail:
703 mutt_error(_("Server closed connection"));
704 mutt_socket_close(conn);
705 pop_adata_free((void **) &adata);
706}
707
711static bool pop_ac_owns_path(struct Account *a, const char *path)
712{
713 struct Url *url = url_parse(path);
714 if (!url)
715 return false;
716
717 struct PopAccountData *adata = a->adata;
718 struct ConnAccount *cac = &adata->conn->account;
719
720 const bool rc = mutt_istr_equal(url->host, cac->host) &&
721 mutt_istr_equal(url->user, cac->user);
722 url_free(&url);
723 return rc;
724}
725
729static bool pop_ac_add(struct Account *a, struct Mailbox *m)
730{
731 if (a->adata)
732 return true;
733
734 struct ConnAccount cac = { { 0 } };
735 if (pop_parse_path(mailbox_path(m), &cac) != 0)
736 {
737 mutt_error(_("%s is an invalid POP path"), mailbox_path(m));
738 return false;
739 }
740
742 adata->conn = mutt_conn_new(&cac);
743 if (!adata->conn)
744 {
745 pop_adata_free((void **) &adata);
746 return false;
747 }
748 a->adata = adata;
750
751 return true;
752}
753
759static enum MxOpenReturns pop_mbox_open(struct Mailbox *m)
760{
761 if (!m->account)
762 return MX_OPEN_ERROR;
763
764 char buf[PATH_MAX] = { 0 };
765 struct ConnAccount cac = { { 0 } };
766 struct Url url = { 0 };
767
768 if (pop_parse_path(mailbox_path(m), &cac) != 0)
769 {
770 mutt_error(_("%s is an invalid POP path"), mailbox_path(m));
771 return MX_OPEN_ERROR;
772 }
773
774 account_to_url(&cac, &url);
775 url.path = NULL;
776 url_tostring(&url, buf, sizeof(buf), U_NONE);
777
778 buf_strcpy(&m->pathbuf, buf);
780
781 struct PopAccountData *adata = m->account->adata;
782 if (!adata)
783 {
785 m->account->adata = adata;
787 }
788
789 struct Connection *conn = adata->conn;
790 if (!conn)
791 {
792 adata->conn = mutt_conn_new(&cac);
793 conn = adata->conn;
794 if (!conn)
795 return MX_OPEN_ERROR;
796 }
797
798 if (conn->fd < 0)
800
801 if (pop_open_connection(adata) < 0)
802 return MX_OPEN_ERROR;
803
804 adata->bcache = mutt_bcache_open(&cac, NULL);
805
806 /* init (hard-coded) ACL rights */
808#ifdef USE_HCACHE
809 /* flags are managed using header cache, so it only makes sense to
810 * enable them in that case */
812#endif
813
814 while (true)
815 {
816 if (pop_reconnect(m) < 0)
817 return MX_OPEN_ERROR;
818
819 m->size = adata->size;
820
821 mutt_message(_("Fetching list of messages..."));
822
823 const int rc = pop_fetch_headers(m);
824
825 if (rc >= 0)
826 return MX_OPEN_OK;
827
828 if (rc < -1)
829 return MX_OPEN_ERROR;
830 }
831}
832
836static enum MxStatus pop_mbox_check(struct Mailbox *m)
837{
838 if (!m || !m->account)
839 return MX_STATUS_ERROR;
840
842
843 const short c_pop_check_interval = cs_subset_number(NeoMutt->sub, "pop_check_interval");
844 if ((adata->check_time + c_pop_check_interval) > mutt_date_now())
845 return MX_STATUS_OK;
846
847 pop_logout(m);
848
850
851 if (pop_open_connection(adata) < 0)
852 return MX_STATUS_ERROR;
853
854 m->size = adata->size;
855
856 mutt_message(_("Checking for new messages..."));
857
858 int old_msg_count = m->msg_count;
859 int rc = pop_fetch_headers(m);
861 if (m->msg_count > old_msg_count)
863
864 if (rc < 0)
865 return MX_STATUS_ERROR;
866
867 if (rc > 0)
868 return MX_STATUS_NEW_MAIL;
869
870 return MX_STATUS_OK;
871}
872
878static enum MxStatus pop_mbox_sync(struct Mailbox *m)
879{
880 int i;
881 int j;
882 int rc = 0;
883 char buf[1024] = { 0 };
885#ifdef USE_HCACHE
886 struct HeaderCache *hc = NULL;
887#endif
888
889 adata->check_time = 0;
890
891 int num_deleted = 0;
892 for (i = 0; i < m->msg_count; i++)
893 {
894 if (m->emails[i]->deleted)
895 num_deleted++;
896 }
897
898 while (true)
899 {
900 if (pop_reconnect(m) < 0)
901 return MX_STATUS_ERROR;
902
903#ifdef USE_HCACHE
904 hc = pop_hcache_open(adata, mailbox_path(m));
905#endif
906
907 struct Progress *progress = NULL;
908 if (m->verbose)
909 {
910 progress = progress_new(MUTT_PROGRESS_WRITE, num_deleted);
911 progress_set_message(progress, _("Marking messages deleted..."));
912 }
913
914 for (i = 0, j = 0, rc = 0; (rc == 0) && (i < m->msg_count); i++)
915 {
916 struct PopEmailData *edata = pop_edata_get(m->emails[i]);
917 if (m->emails[i]->deleted && (edata->refno != -1))
918 {
919 j++;
920 progress_update(progress, j, -1);
921 snprintf(buf, sizeof(buf), "DELE %d\r\n", edata->refno);
922 rc = pop_query(adata, buf, sizeof(buf));
923 if (rc == 0)
924 {
925 mutt_bcache_del(adata->bcache, cache_id(edata->uid));
926#ifdef USE_HCACHE
927 hcache_delete_email(hc, edata->uid, strlen(edata->uid));
928#endif
929 }
930 }
931
932#ifdef USE_HCACHE
933 if (m->emails[i]->changed)
934 {
935 hcache_store_email(hc, edata->uid, strlen(edata->uid), m->emails[i], 0);
936 }
937#endif
938 }
939 progress_free(&progress);
940
941#ifdef USE_HCACHE
942 hcache_close(&hc);
943#endif
944
945 if (rc == 0)
946 {
947 mutt_str_copy(buf, "QUIT\r\n", sizeof(buf));
948 rc = pop_query(adata, buf, sizeof(buf));
949 }
950
951 if (rc == 0)
952 {
953 adata->clear_cache = true;
954 pop_clear_cache(adata);
955 adata->status = POP_DISCONNECTED;
956 return MX_STATUS_OK;
957 }
958
959 if (rc == -2)
960 {
961 mutt_error("%s", adata->err_msg);
962 return MX_STATUS_ERROR;
963 }
964 }
965}
966
970static enum MxStatus pop_mbox_close(struct Mailbox *m)
971{
973 if (!adata)
974 return MX_STATUS_OK;
975
976 pop_logout(m);
977
978 if (adata->status != POP_NONE)
979 {
981 }
982
983 adata->status = POP_NONE;
984
985 adata->clear_cache = true;
987
988 mutt_bcache_close(&adata->bcache);
989
990 return MX_STATUS_OK;
991}
992
996static bool pop_msg_open(struct Mailbox *m, struct Message *msg, struct Email *e)
997{
998 char buf[1024] = { 0 };
1000 struct PopEmailData *edata = pop_edata_get(e);
1001 bool bcache = true;
1002 bool success = false;
1003 struct Buffer *path = NULL;
1004
1005 /* see if we already have the message in body cache */
1006 msg->fp = mutt_bcache_get(adata->bcache, cache_id(edata->uid));
1007 if (msg->fp)
1008 return true;
1009
1010 /* see if we already have the message in our cache in
1011 * case $message_cache_dir is unset */
1012 struct PopCache *cache = &adata->cache[e->index % POP_CACHE_LEN];
1013
1014 if (cache->path)
1015 {
1016 if (cache->index == e->index)
1017 {
1018 /* yes, so just return a pointer to the message */
1019 msg->fp = mutt_file_fopen(cache->path, "r");
1020 if (msg->fp)
1021 return true;
1022
1023 mutt_perror("%s", cache->path);
1024 return false;
1025 }
1026 else
1027 {
1028 /* clear the previous entry */
1029 unlink(cache->path);
1030 FREE(&cache->path);
1031 }
1032 }
1033
1034 path = buf_pool_get();
1035
1036 while (true)
1037 {
1038 if (pop_reconnect(m) < 0)
1039 goto cleanup;
1040
1041 /* verify that massage index is correct */
1042 if (edata->refno < 0)
1043 {
1044 mutt_error(_("The message index is incorrect. Try reopening the mailbox."));
1045 goto cleanup;
1046 }
1047
1048 /* see if we can put in body cache; use our cache as fallback */
1049 msg->fp = mutt_bcache_put(adata->bcache, cache_id(edata->uid));
1050 if (!msg->fp)
1051 {
1052 /* no */
1053 bcache = false;
1055 msg->fp = mutt_file_fopen(buf_string(path), "w+");
1056 if (!msg->fp)
1057 {
1058 mutt_perror("%s", buf_string(path));
1059 goto cleanup;
1060 }
1061 }
1062
1063 snprintf(buf, sizeof(buf), "RETR %d\r\n", edata->refno);
1064
1065 struct Progress *progress = progress_new(MUTT_PROGRESS_NET,
1066 e->body->length + e->body->offset - 1);
1067 progress_set_message(progress, _("Fetching message..."));
1068 const int rc = pop_fetch_data(adata, buf, progress, fetch_message, msg->fp);
1069 progress_free(&progress);
1070
1071 if (rc == 0)
1072 break;
1073
1074 mutt_file_fclose(&msg->fp);
1075
1076 /* if RETR failed (e.g. connection closed), be sure to remove either
1077 * the file in bcache or from POP's own cache since the next iteration
1078 * of the loop will re-attempt to put() the message */
1079 if (!bcache)
1080 unlink(buf_string(path));
1081
1082 if (rc == -2)
1083 {
1084 mutt_error("%s", adata->err_msg);
1085 goto cleanup;
1086 }
1087
1088 if (rc == -3)
1089 {
1090 mutt_error(_("Can't write message to temporary file"));
1091 goto cleanup;
1092 }
1093 }
1094
1095 /* Update the header information. Previously, we only downloaded a
1096 * portion of the headers, those required for the main display. */
1097 if (bcache)
1098 {
1099 mutt_bcache_commit(adata->bcache, cache_id(edata->uid));
1100 }
1101 else
1102 {
1103 cache->index = e->index;
1104 cache->path = buf_strdup(path);
1105 }
1106 rewind(msg->fp);
1107
1108 /* Detach the private data */
1109 e->edata = NULL;
1110
1111 /* we replace envelope, key in subj_hash has to be updated as well */
1112 if (m->subj_hash && e->env->real_subj)
1115 mutt_env_free(&e->env);
1116 e->env = mutt_rfc822_read_header(msg->fp, e, false, false);
1117 if (m->subj_hash && e->env->real_subj)
1119 mutt_label_hash_add(m, e);
1120
1121 /* Reattach the private data */
1122 e->edata = edata;
1124
1125 e->lines = 0;
1126 while (fgets(buf, sizeof(buf), msg->fp) && !feof(msg->fp))
1127 {
1128 e->lines++;
1129 }
1130
1131 e->body->length = ftello(msg->fp) - e->body->offset;
1132
1133 /* This needs to be done in case this is a multipart message */
1134 if (!WithCrypto)
1135 e->security = crypt_query(e->body);
1136
1138 rewind(msg->fp);
1139
1140 success = true;
1141
1142cleanup:
1143 buf_pool_release(&path);
1144 return success;
1145}
1146
1152static int pop_msg_close(struct Mailbox *m, struct Message *msg)
1153{
1154 return mutt_file_fclose(&msg->fp);
1155}
1156
1160static int pop_msg_save_hcache(struct Mailbox *m, struct Email *e)
1161{
1162 int rc = 0;
1163#ifdef USE_HCACHE
1164 struct PopAccountData *adata = pop_adata_get(m);
1165 struct PopEmailData *edata = e->edata;
1166 struct HeaderCache *hc = pop_hcache_open(adata, mailbox_path(m));
1167 rc = hcache_store_email(hc, edata->uid, strlen(edata->uid), e, 0);
1168 hcache_close(&hc);
1169#endif
1170
1171 return rc;
1172}
1173
1177enum MailboxType pop_path_probe(const char *path, const struct stat *st)
1178{
1179 if (mutt_istr_startswith(path, "pop://"))
1180 return MUTT_POP;
1181
1182 if (mutt_istr_startswith(path, "pops://"))
1183 return MUTT_POP;
1184
1185 return MUTT_UNKNOWN;
1186}
1187
1191static int pop_path_canon(struct Buffer *path)
1192{
1193 return 0;
1194}
1195
1199const struct MxOps MxPopOps = {
1200 // clang-format off
1201 .type = MUTT_POP,
1202 .name = "pop",
1203 .is_local = false,
1204 .ac_owns_path = pop_ac_owns_path,
1205 .ac_add = pop_ac_add,
1206 .mbox_open = pop_mbox_open,
1207 .mbox_open_append = NULL,
1208 .mbox_check = pop_mbox_check,
1209 .mbox_check_stats = NULL,
1210 .mbox_sync = pop_mbox_sync,
1211 .mbox_close = pop_mbox_close,
1212 .msg_open = pop_msg_open,
1213 .msg_open_new = NULL,
1214 .msg_commit = NULL,
1215 .msg_close = pop_msg_close,
1216 .msg_padding_size = NULL,
1217 .msg_save_hcache = pop_msg_save_hcache,
1218 .tags_edit = NULL,
1219 .tags_commit = NULL,
1220 .path_probe = pop_path_probe,
1221 .path_canon = pop_path_canon,
1222 .path_is_empty = NULL,
1223 // clang-format on
1224};
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:1325
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:271
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:304
#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:729
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:711
const struct MxOps MxPopOps
POP Mailbox - Implements MxOps -.
Definition pop.c:1199
static enum MxStatus pop_mbox_check(struct Mailbox *m)
Check for new mail - Implements MxOps::mbox_check() -.
Definition pop.c:836
static enum MxStatus pop_mbox_close(struct Mailbox *m)
Close a Mailbox - Implements MxOps::mbox_close() -.
Definition pop.c:970
static enum MxOpenReturns pop_mbox_open(struct Mailbox *m)
Open a Mailbox - Implements MxOps::mbox_open() -.
Definition pop.c:759
static enum MxStatus pop_mbox_sync(struct Mailbox *m)
Save changes to the Mailbox - Implements MxOps::mbox_sync() -.
Definition pop.c:878
static int pop_msg_close(struct Mailbox *m, struct Message *msg)
Close an email - Implements MxOps::msg_close() -.
Definition pop.c:1152
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:996
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:1160
static int pop_path_canon(struct Buffer *path)
Canonicalise a Mailbox path - Implements MxOps::path_canon() -.
Definition pop.c:1191
enum MailboxType pop_path_probe(const char *path, const struct stat *st)
Is this a POP Mailbox?
Definition pop.c:1177
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:211
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:769
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:700
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:316
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: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
POP network mailbox.
POP network mailbox.
#define pop_query(adata, buf, buflen)
Definition private.h:109
#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:510
#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:316
#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:530
static int pop_fetch_headers(struct Mailbox *m)
Read headers.
Definition pop.c:340
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