pop3c-mail.c revision 120e61ccce21fd33d6b55b6f27346e1690b64bd8
bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2011-2017 Dovecot authors, see the included COPYING file */
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainenpop3c_mail_alloc(struct mailbox_transaction_context *t,
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers)
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen index_mail_init(&mail->imail, t, wanted_fields, wanted_headers);
4c0aff96fc7e6d779be43458f96cbf015849a3deTimo Sirainenstatic void pop3c_mail_close(struct mail *_mail)
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box);
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen /* wait for any prefetch to finish before closing the mail */
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainenstatic int pop3c_mail_get_received_date(struct mail *_mail, time_t *date_r)
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box);
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen if (mbox->storage->set->pop3c_quick_received_date) {
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen /* we don't care about the date, just return the current date */
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen /* FIXME: we could also parse the first Received: header and get
678d0463849ba777106eb7875f27db07a5d8e3dfTimo Sirainen the date from there, but since this code is unlikely to be called
678d0463849ba777106eb7875f27db07a5d8e3dfTimo Sirainen except during migration, I don't think it really matters. */
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen return index_mail_get_date(_mail, date_r, &tz);
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainenstatic int pop3c_mail_get_save_date(struct mail *_mail, time_t *date_r)
77b5fd56e5a06d624f3ab92198272287333114f4Timo Sirainen /* FIXME: we could use a value stored in cache */
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen return pop3c_mail_get_received_date(_mail, date_r);
402e999a878e0cc41a0afb830fea0a93afc75f0dTimo Sirainenstatic int pop3c_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box);
bf7dc750b95039981c0e9d728f313d50cf38a156Martti Rannanjärvi struct message_size hdr_size, body_size;
2a6c02a5e7e5cdf4980befbfaf372603ce338a25Timo Sirainen /* virtual size is already known. it's the same as our
2a6c02a5e7e5cdf4980befbfaf372603ce338a25Timo Sirainen (correct) physical size */
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen if (index_mail_get_physical_size(_mail, size_r) == 0) {
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen if (_mail->lookup_abort == MAIL_LOOKUP_ABORT_READ_MAIL &&
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen (_mail->box->flags & MAILBOX_FLAG_POP3_SESSION) != 0) {
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen /* kludge: we want output for POP3 LIST with
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen pop3_fast_size_lookups=yes. use the remote's LIST values
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen regardless of their correctness */
switch (state) {
case POP3C_COMMAND_STATE_OK:
case POP3C_COMMAND_STATE_ERR:
const char *cmd;
if (new_stream) {
if (get_body)
const char **value_r)
switch (field) {
case MAIL_FETCH_UIDL_BACKEND:
case MAIL_FETCH_GUID:
NULL,