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