e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen /* fixed size fields */
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen /* variable sized field */
31be5ed1551c98cddeb2295a594f010aaf4b76bcTimo Sirainen global_cache_fields[MAIL_INDEX_CACHE_FIELD_COUNT];
1b4441e3e6f9e78ebeae8218de971959cd55bf60Timo Sirainen "\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\""
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen /* If binary flags are set, it's not checked whether mail is
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen missing CRs. So this flag may be set as an optimization for
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen regular non-binary mails as well if it's known that it contains
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen valid CR+LF line breaks. */
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen /* Mail header or body is known to contain NUL characters. */
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen /* Mail header or body is known to not contain NUL characters. */
884228e5496378bada39a932db67aa3d9478198fTimo Sirainen /* obsolete _HAS_NO_NULS flag, which was being set incorrectly */
1b4441e3e6f9e78ebeae8218de971959cd55bf60Timo Sirainen /* BODY is IMAP_BODY_PLAIN_7BIT_ASCII and rest of BODYSTRUCTURE
1b4441e3e6f9e78ebeae8218de971959cd55bf60Timo Sirainen fields are NIL */
1b4441e3e6f9e78ebeae8218de971959cd55bf60Timo Sirainen MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII = 0x0010
46c903eac3abcc7d32780da76ee6a79c26d185b6Timo Sirainen const char *envelope, *body, *bodystructure, *guid, *filename;
ae1b268ffff743ad9927c304a1344c5cbd7f909dTimo Sirainen /* dont_cache_fields overrides cache_fields */
ae1b268ffff743ad9927c304a1344c5cbd7f909dTimo Sirainen enum mail_fetch_field cache_fetch_fields, dont_cache_fetch_fields;
ecd69c4e8371853667e01b0c16d436ef7f7393e2Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers;
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen /* per-mail variables, here for performance reasons: */
eef4ba0cc3e78f8c26804c1c9251a76580a41f0cTimo Sirainen /* mail created by mailbox_search_*() */
4906414a3e02e7750b0e702ec992afba20a0338aTimo Sirainen /* close() is being called from mail_free() */
87490012895b4f371635ded00add04c9107dcfefJosef 'Jeff' Sipek#define INDEX_MAIL(s) container_of(s, struct index_mail, mail.mail)
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainenindex_mail_alloc(struct mailbox_transaction_context *t,
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
4bab017ff69d6877253dde54b5a5f1f3f5e92fdfTimo Sirainen struct mailbox_header_lookup_ctx *_wanted_headers);
7631f16156aca373004953fe6b01a7f343fb47e0Timo Sirainenvoid index_mail_set_seq(struct mail *mail, uint32_t seq, bool saving);
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainenbool index_mail_set_uid(struct mail *mail, uint32_t uid);
aa247243412a49f9bdebf7255e131dc6ece4ed46Timo Sirainenvoid index_mail_set_uid_cache_updates(struct mail *mail, bool set);
ecd69c4e8371853667e01b0c16d436ef7f7393e2Timo Sirainenvoid index_mail_add_temp_wanted_fields(struct mail *mail,
823af4a2cc4e2ce90d12f9ec362160546aa4c4b8Timo Sirainenvoid index_mail_update_access_parts_pre(struct mail *mail);
823af4a2cc4e2ce90d12f9ec362160546aa4c4b8Timo Sirainenvoid index_mail_update_access_parts_post(struct mail *_mail);
15979d11259a2391c943bb47af4d174df52d9eb9Timo Sirainenvoid index_mail_close_streams(struct index_mail *mail);
489301ee88b2174e3171875e979e667de2c4a174Timo Sirainenvoid index_mail_set_message_parts_corrupted(struct mail *mail, const char *error);
77af0bd168cf3e3ddc3ae68abc82bfad7e9b5ff4Timo Sirainenbool index_mail_want_parse_headers(struct index_mail *mail);
6789ed17e7ca4021713507baf0dcf6979bb42e0cTimo Sirainenvoid index_mail_parse_header_init(struct index_mail *mail,
d2b94d25f842cd1b7acaf4dd7de858f7c6a821c9Timo Sirainenvoid index_mail_parse_header(struct message_part *part,
2aecf7be5834e7f6520f8deaad683a6fa1de4d61Timo Sirainenint index_mail_parse_headers(struct index_mail *mail,
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_headers_get_envelope(struct index_mail *mail);
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_get_first_header(struct mail *_mail, const char *field,
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_get_headers(struct mail *_mail, const char *field,
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainen bool decode_to_utf8, const char *const **value_r);
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_get_header_stream(struct mail *_mail,
573f0491a5733fe21fa062a455acb4790b4e0499Timo Sirainenvoid index_mail_set_read_buffer_size(struct mail *mail, struct istream *input);
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainenenum mail_flags index_mail_get_flags(struct mail *_mail);
a2f250a332dfc1e6cd4ffd196c621eb9dbf7b8a1Timo Sirainenuint64_t index_mail_get_modseq(struct mail *_mail);
f46885a5b78b15a8d2419f6e5d13b643bd85e41fTimo Sirainenuint64_t index_mail_get_pvt_modseq(struct mail *_mail);
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainenconst char *const *index_mail_get_keywords(struct mail *_mail);
a757f31393b9d6fc7760a9dec8363404ab3ae576Timo Sirainenindex_mail_get_keyword_indexes(struct mail *_mail);
c0225f7f6b43d34dc58c17d3304f0fd60ab89894Timo Sirainenint index_mail_get_parts(struct mail *_mail, struct message_part **parts_r);
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_get_received_date(struct mail *_mail, time_t *date_r);
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_get_save_date(struct mail *_mail, time_t *date_r);
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_get_date(struct mail *_mail, time_t *date_r, int *timezone_r);
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_get_virtual_size(struct mail *mail, uoff_t *size_r);
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_get_physical_size(struct mail *mail, uoff_t *size_r);
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_init_stream(struct index_mail *mail,
306b3f41b05da642d87e7ca7a1496efce9f5902fTimo Sirainenint index_mail_get_binary_stream(struct mail *_mail,
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenint index_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainen const char **value_r);
21aaa6affb9f134112b75b5db737309fc35ef1cfMartti Rannanjärviint index_mail_get_backend_mail(struct mail *mail, struct mail **real_mail_r);
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainenvoid index_mail_update_flags(struct mail *mail, enum modify_type modify_type,
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainenvoid index_mail_update_keywords(struct mail *mail, enum modify_type modify_type,
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainenvoid index_mail_update_modseq(struct mail *mail, uint64_t min_modseq);
f46885a5b78b15a8d2419f6e5d13b643bd85e41fTimo Sirainenvoid index_mail_update_pvt_modseq(struct mail *mail, uint64_t min_pvt_modseq);
838e367716bbd5e44b4a1691db9cbf72af53e9f0Timo Sirainenvoid index_mail_set_cache_corrupted(struct mail *mail,
6564208826b0f46a00f010d1b5711d85944c3c88Timo Sirainenint index_mail_opened(struct mail *mail, struct istream **stream);
50de46721446795c42943c572625f2f1a9abfe01Timo Sirainenint index_mail_stream_check_failure(struct index_mail *mail);
d052dcfff0c96a0af17a3158e51f709edf4b93a1Timo Sirainenvoid index_mail_stream_log_failure_for(struct index_mail *mail,
bc15c6934f69be09cca1e9f87f9dc344f77e8b7cTimo Sirainenvoid index_mail_refresh_expunged(struct mail *mail);
01404d41657a104c5ea1c12bb87f9c321e9c1ac4Timo Sirainenstruct index_mail *index_mail_get_index_mail(struct mail *mail);
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenbool index_mail_get_cached_uoff_t(struct index_mail *mail,
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainen enum index_cache_field field, uoff_t *size_r);
83bb013a99f0936995f9c7a1077822662d8fefdbTimo Sirainenbool index_mail_get_cached_virtual_size(struct index_mail *mail,
b2723d68898e4a6a6e6ba2a06926dcaa1911daf5Timo Sirainenbool index_mail_get_cached_body(struct index_mail *mail, const char **value_r);
b2723d68898e4a6a6e6ba2a06926dcaa1911daf5Timo Sirainenbool index_mail_get_cached_bodystructure(struct index_mail *mail,
b2723d68898e4a6a6e6ba2a06926dcaa1911daf5Timo Sirainen const char **value_r);
424633d1a1e22139a5ab9345f807a89d0792ead3Timo Sirainenconst uint32_t *index_mail_get_vsize_extension(struct mail *_mail);
2c4349f25ae850ffff0543bdbbbd7806b9af3c80Timo Sirainenbool index_mail_want_cache(struct index_mail *mail, enum index_cache_field field);
5cda0bfea032000c4a51134c748d9efe6614870bTimo Sirainenvoid index_mail_cache_add(struct index_mail *mail, enum index_cache_field field,
5cda0bfea032000c4a51134c748d9efe6614870bTimo Sirainenvoid index_mail_cache_add_idx(struct index_mail *mail, unsigned int field_idx,
e54512a5189192fe72d1e2c53927c98c5ac920b4Timo Sirainenstruct istream *index_mail_cache_parse_init(struct mail *mail,
2ebeb22b9a8a8bb7fbe2f2e2908478a220792b87Timo Sirainenvoid index_mail_cache_parse_continue(struct mail *mail);
2d1663351e67fd778ed34df09b8ad5fe29da23d9Timo Sirainenvoid index_mail_cache_parse_deinit(struct mail *mail, time_t received_date,
b0a901f1dbe9e05ac1c92a0974af6bce0274f31aTimo Sirainenint index_mail_cache_lookup_field(struct index_mail *mail, buffer_t *buf,
b0a901f1dbe9e05ac1c92a0974af6bce0274f31aTimo Sirainen unsigned int field_idx);
e8dc3747de75e2bf208f0f2dbdbae4a279b5ee6fTimo Sirainenvoid index_mail_save_finish(struct mail_save_context *ctx);
02b78558dc03daa2e7da2010b63f247b49936a38Timo Sirainenconst char *index_mail_cache_reason(struct mail *mail, const char *reason);