Fetch messages and save them in $spool_file.
531{
533 if (!c_pop_host)
534 {
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;
547
548 char *url = NULL;
551 else
553
556 if (rc)
557 {
558 mutt_error(
_(
"%s is an invalid POP path"), c_pop_host);
559 return;
560 }
561
563 if (!conn)
564 return;
565
568
570 {
572 return;
573 }
574
576
577
580 if (rc == -1)
581 goto fail;
582 if (rc == -2)
583 {
585 goto finish;
586 }
587
588 sscanf(buf, "+OK %d %d", &msgs, &bytes);
589
590
592 if ((msgs > 0) && c_pop_last)
593 {
596 if (rc == -1)
597 goto fail;
598 if (rc == 0)
599 sscanf(buf, "+OK %d", &last);
600 }
601
602 if (msgs <= last)
603 {
605 goto finish;
606 }
607
610
612 {
614 goto finish;
615 }
616 bool old_append = m_spool->
append;
618
621
622 snprintf(msgbuf, sizeof(msgbuf),
623 ngettext("Reading new messages (%d byte)...",
624 "Reading new messages (%d bytes)...", bytes),
625 bytes);
627
628 for (int i = last + 1; i <= msgs; i++)
629 {
631 if (msg)
632 {
633 snprintf(buf, sizeof(buf), "RETR %d\r\n", i);
635 if (rc == -3)
636 rset = 1;
637
639 {
640 rset = 1;
641 rc = -3;
642 }
643
645 }
646 else
647 {
648 rc = -3;
649 }
650
651 if ((rc == 0) && (delanswer ==
MUTT_YES))
652 {
653
654 snprintf(buf, sizeof(buf), "DELE %d\r\n", i);
656 }
657
658 if (rc == -1)
659 {
660 m_spool->
append = old_append;
662 goto fail;
663 }
664 if (rc == -2)
665 {
667 break;
668 }
669 if (rc == -3)
670 {
672 break;
673 }
674
675
676
678 "%s [%d of %d messages read]", msgs - last),
679 msgbuf, i - last, msgs - last);
680 }
681
682 m_spool->
append = old_append;
684
685 if (rset)
686 {
687
689 if (
pop_query(adata, buf,
sizeof(buf)) == -1)
690 goto fail;
691 }
692
693finish:
694
696 if (
pop_query(adata, buf,
sizeof(buf)) == -1)
697 goto fail;
700 return;
701
702fail:
706}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
void pop_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free() -.
#define mutt_message(...)
char * mutt_str_dup(const char *str)
Copy a string, safely.
int mutt_str_asprintf(char **strp, const char *fmt,...)
struct Connection * mutt_conn_find(const struct ConnAccount *cac)
Find a connection from a list.
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
struct Message * mx_msg_open_new(struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
Open a new message.
int mx_msg_commit(struct Mailbox *m, struct Message *msg)
Commit a message to a folder - Wrapper for MxOps::msg_commit()
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
@ MUTT_ADD_FROM
add a From_ line
@ MUTT_OPEN_NONE
No flags are set.
struct PopAccountData * pop_adata_new(void)
Create a new PopAccountData object.
int pop_open_connection(struct PopAccountData *adata)
Open connection and authenticate.
int pop_parse_path(const char *path, struct ConnAccount *cac)
Parse a POP mailbox name.
QuadOption
Possible values for a quad-option.
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
enum QuadOption query_quadoption(const char *prompt, struct ConfigSubset *sub, const char *name)
Ask the user a quad-question.
int mutt_socket_close(struct Connection *conn)
Close a socket.
Login details for a remote server.
bool append
Mailbox is opened in append mode.
A local copy of an email.
FILE * fp
pointer to the message data
enum UrlScheme url_check_scheme(const char *str)
Check the protocol of a URL.
@ U_UNKNOWN
Url wasn't recognised.