index-mail.c revision 98dd8e6e81f11f1e6040ca72f4916242d246c863
/* Copyright (C) 2002-2003 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "istream.h"
#include "str.h"
#include "message-date.h"
#include "message-part-serialize.h"
#include "message-parser.h"
#include "imap-bodystructure.h"
#include "imap-envelope.h"
#include "mail-cache.h"
#include "index-storage.h"
#include "index-mail.h"
{ "date.sent", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
sizeof(struct mail_sent_date), 0 },
{ "date.received", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
sizeof(time_t), 0 },
{ "size.virtual", 0, MAIL_CACHE_FIELD_FIXED_SIZE,
sizeof(uoff_t), 0 },
{ "imap.body", 0, MAIL_CACHE_FIELD_STRING, 0, 0 },
{ "imap.bodystructure", 0, MAIL_CACHE_FIELD_STRING, 0, 0 },
{ "imap.envelope", 0, MAIL_CACHE_FIELD_STRING, 0, 0 },
{ "mime.parts", 0, MAIL_CACHE_FIELD_VARIABLE_SIZE, 0, 0 },
{ "mail.uid", 0, MAIL_CACHE_FIELD_STRING, 0, 0 }
};
{
struct message_part *part;
const char *error;
t_push();
t_pop();
return NULL;
}
&error);
t_pop();
"Corrupted cached message_part data (%s)", error);
return NULL;
}
/* we know the NULs now, update them */
} else {
}
return part;
}
enum index_cache_field field)
{
return NULL;
}
}
enum index_cache_field field,
{
int ret;
t_push();
} else {
}
t_pop();
return ret;
}
enum index_cache_field field)
{
return uoff;
}
{
}
{
time_t t;
&t, sizeof(t)))
t = (time_t)-1;
return t;
}
struct mail_sent_date *sent_date)
{
}
}
{
/*FIXME:data->flags.keywords =
mail_keywords_list_get(mail->ibox->index->keywords);
data->flags.keywords_count = MAIL_KEYWORDS_COUNT;*/
}
{
return NULL;
}
}
{
return data->received_date;
}
return data->received_date;
}
{
const char *str;
int tz;
}
/* 0 == parse error */
tz = 0;
}
}
}
}
{
}
}
{
if (get_msgpart_sizes(mail))
return (uoff_t)-1;
}
struct message_header_line *hdr,
void *context)
{
}
{
const void *buf_data;
if (data->save_bodystructure_body) {
/* bodystructure header is parsed, we want the body's mime
headers too */
} else {
}
/* we know the NULs now, update them */
} else {
}
/* update cache_flags */
/*FIXME:cache_flags =
mail_cache_get_record_flags(mail->trans->cache_view,
mail->data.seq);
if (mail->mail.has_nuls)
cache_flags |= MAIL_INDEX_FLAG_HAS_NULS;
else
cache_flags |= MAIL_INDEX_FLAG_HAS_NO_NULS;
(void)mail_cache_update_record_flags(mail->trans->cache_view,
mail->data.seq,
cache_flags);*/
}
/* see if we want to cache the message part */
return;
t_push();
t_pop();
}
}
struct message_size *hdr_size,
struct message_size *body_size)
{
(void)get_msgpart_sizes(mail);
if (!data->hdr_size_set) {
return NULL;
}
}
if (!data->body_size_set)
}
}
}
enum index_cache_field field)
{
enum mail_cache_decision_type dec;
int bodystructure_cached = FALSE;
/* we haven't parsed the header yet */
return;
}
} else {
}
if (field == MAIL_CACHE_BODYSTRUCTURE ||
if (dec !=
}
}
if (field == MAIL_CACHE_BODY ||
if (!bodystructure_cached && dec !=
}
}
}
enum mail_fetch_field field)
{
switch (field) {
case MAIL_FETCH_IMAP_BODY:
/* 1) get BODY if it exists
2) get it using BODYSTRUCTURE if it exists
3) parse body structure, and save BODY/BODYSTRUCTURE
depending on what we want cached */
}
str_truncate(str, 0);
}
/* broken, continue.. */
"Corrupted BODYSTRUCTURE for mail %u",
}
return data->bodystructure;
return data->bodystructure;
}
return data->bodystructure;
case MAIL_FETCH_IMAP_ENVELOPE:
case MAIL_FETCH_FROM_ENVELOPE:
return NULL;
case MAIL_FETCH_UID_STRING:
data->uid_string =
}
return data->uid_string;
default:
i_unreached();
return NULL;
}
}
void index_mail_init(struct index_transaction_context *t,
struct index_mail *mail,
struct mailbox_header_lookup_ctx *_wanted_headers)
{
struct index_header_lookup_ctx *wanted_headers =
(struct index_header_lookup_ctx *)_wanted_headers;
const struct mail_index_header *hdr;
int ret;
}
{
}
{
const struct mail_index_record *rec;
return -1;
}
cache_flags = 0;//FIXME:mail_cache_get_record_flags(mail->trans->cache_view, seq);
(cache_flags & MAIL_INDEX_FLAG_HAS_NO_NULS) != 0;
t_push();
/* if some wanted fields are cached, get them */
}
}
/* see if we have to parse the message */
t_pop();
return 0;
}
{
}
const struct mail_full_flags *flags,
enum modify_type modify_type)
{
enum mail_flags modify_flags;
/*if (!index_mailbox_fix_keywords(ibox, &modify_flags,
flags->keywords,
flags->keywords_count))
return FALSE;*/
/*if (mail_keywords_has_changes(ibox->index->keywords)) {
storage->callbacks->new_keywords(&ibox->box,
mail_keywords_list_get(ibox->index->keywords),
MAIL_KEYWORDS_COUNT, storage->callback_context);
}*/
return 0;
}
{
return 0;
}