dsync-mail.c revision d9b9687bf8cae9cfb070b1b7aadefa683220269f
5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294Timo Sirainen/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */
271ba0b2a103e8040021597a3922f27b40d5b5dcTimo Sirainen/* These should be good enough to identify all normal mails. Received: header
271ba0b2a103e8040021597a3922f27b40d5b5dcTimo Sirainen would make it even better, but those can be somewhat large. Also these
271ba0b2a103e8040021597a3922f27b40d5b5dcTimo Sirainen fields can be looked up using IMAP ENVELOPE, which is more efficient in
271ba0b2a103e8040021597a3922f27b40d5b5dcTimo Sirainen some IMAP servers. */
271ba0b2a103e8040021597a3922f27b40d5b5dcTimo Sirainenstatic const char *hashed_headers[] = {
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenint dsync_mail_get_hdr_hash(struct mail *mail, const char **hdr_hash_r)
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen const unsigned char *data;
271ba0b2a103e8040021597a3922f27b40d5b5dcTimo Sirainen hdr_ctx = mailbox_header_lookup_init(mail->box, hashed_headers);
ccaaf1874bb0c569ca2589444717fde155e1becaTimo Sirainen ret = mail_get_header_stream(mail, hdr_ctx, &hdr_input);
271ba0b2a103e8040021597a3922f27b40d5b5dcTimo Sirainen if (i_stream_read_data(input, &data, &size, 0) == -1)
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen *hdr_hash_r = binary_to_hex(md5_result, sizeof(md5_result));
d9b9687bf8cae9cfb070b1b7aadefa683220269fTimo Sirainenint dsync_mail_fill(struct mail *mail, struct dsync_mail *dmail_r,
d9b9687bf8cae9cfb070b1b7aadefa683220269fTimo Sirainen if (mail_get_special(mail, MAIL_FETCH_GUID, &guid) < 0) {
d9b9687bf8cae9cfb070b1b7aadefa683220269fTimo Sirainen if (mail_get_stream(mail, NULL, NULL, &dmail_r->input) < 0) {
d9b9687bf8cae9cfb070b1b7aadefa683220269fTimo Sirainen if (mail_get_special(mail, MAIL_FETCH_UIDL_BACKEND, &dmail_r->pop3_uidl) < 0) {
d9b9687bf8cae9cfb070b1b7aadefa683220269fTimo Sirainen if (mail_get_special(mail, MAIL_FETCH_POP3_ORDER, &str) < 0) {
d9b9687bf8cae9cfb070b1b7aadefa683220269fTimo Sirainen if (str_to_uint(str, &dmail_r->pop3_order) < 0)
d9b9687bf8cae9cfb070b1b7aadefa683220269fTimo Sirainen if (mail_get_received_date(mail, &dmail_r->received_date) < 0) {
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenconst_string_array_dup(pool_t pool, const ARRAY_TYPE(const_string) *src,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen unsigned int i, count;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen for (i = 0; i < count; i++) {
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenvoid dsync_mail_change_dup(pool_t pool, const struct dsync_mail_change *src,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen dest_r->hdr_hash = p_strdup(pool, src->hdr_hash);