94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen#ifndef IMAPC_MAIL_H
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen#define IMAPC_MAIL_H
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen#include "index-mail.h"
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainenstruct imap_arg;
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainenstruct imapc_untagged_reply;
1a878b9d2a823abc6b1c8b1631e50a15d534665fTimo Sirainenstruct imapc_mailbox;
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainen
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainenstruct imapc_mail {
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen struct index_mail imail;
8a26102b8b1e08a774398980a8f92ae8f8575da8Timo Sirainen
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainen enum mail_fetch_field fetching_fields;
b8eb60a9ba83e2f3f6d969e810553eb937be2128Timo Sirainen const char *const *fetching_headers;
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainen unsigned int fetch_count;
2a1d9dda6e05f596b70703b74721847308127e3eTimo Sirainen bool fetch_sent;
14fb3a2f6af1d75aeec6deb766026b4ea6a4db53Timo Sirainen const char *last_fetch_reply;
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainen
b1a2d2042e8c7e99983175eb462b82cc7a8cb70bTimo Sirainen int fd;
8a26102b8b1e08a774398980a8f92ae8f8575da8Timo Sirainen buffer_t *body;
eb1365e61674c54c7c453143356a891fb2e2b3d6Timo Sirainen bool header_fetched;
b1a2d2042e8c7e99983175eb462b82cc7a8cb70bTimo Sirainen bool body_fetched;
b8eb60a9ba83e2f3f6d969e810553eb937be2128Timo Sirainen bool header_list_fetched;
638734376d265a1529985755da671c09cfc22e06Timo Sirainen bool fetch_ignore_if_missing;
14fd61e73569f356c57ccc253cfbbb6d77cccdf9Timo Sirainen bool fetch_failed;
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen};
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen
7dd326f772ed4193e1bfdafdb46fea616970e1acJosef 'Jeff' Sipek#define IMAPC_MAIL(s) container_of(s, struct imapc_mail, imail.mail.mail)
7dd326f772ed4193e1bfdafdb46fea616970e1acJosef 'Jeff' Sipek
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainenextern struct mail_vfuncs imapc_mail_vfuncs;
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainenstruct mail *
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainenimapc_mail_alloc(struct mailbox_transaction_context *t,
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen enum mail_fetch_field wanted_fields,
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
b8eb60a9ba83e2f3f6d969e810553eb937be2128Timo Sirainenint imapc_mail_fetch(struct mail *mail, enum mail_fetch_field fields,
b8eb60a9ba83e2f3f6d969e810553eb937be2128Timo Sirainen const char *const *headers);
e1777cb59a96d8710a6c5cefe6a17c7c15159c9fTimo Sirainenvoid imapc_mail_try_init_stream_from_cache(struct imapc_mail *mail);
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainenbool imapc_mail_prefetch(struct mail *mail);
1a878b9d2a823abc6b1c8b1631e50a15d534665fTimo Sirainenvoid imapc_mail_fetch_flush(struct imapc_mailbox *mbox);
eb1365e61674c54c7c453143356a891fb2e2b3d6Timo Sirainenvoid imapc_mail_init_stream(struct imapc_mail *mail);
5085686ff2b4be28e7d631e1bbfa32afe427b7c7Timo Sirainenbool imapc_mail_has_headers_in_cache(struct index_mail *mail,
5085686ff2b4be28e7d631e1bbfa32afe427b7c7Timo Sirainen struct mailbox_header_lookup_ctx *headers);
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainen
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainenvoid imapc_mail_fetch_update(struct imapc_mail *mail,
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainen const struct imapc_untagged_reply *reply,
e15b305e90c9834734ccf35ed78f0ad29d570ee9Timo Sirainen const struct imap_arg *args);
ffb886eb9c3682bb891206cced9623368035d739Timo Sirainenvoid imapc_mail_update_access_parts(struct index_mail *mail);
1a878b9d2a823abc6b1c8b1631e50a15d534665fTimo Sirainenvoid imapc_mail_command_flush(struct imapc_mailbox *mbox);
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen
94a77d6e5d7600859e4c5e4a7ea19dc3e91998b9Timo Sirainen#endif