index-mail.c revision 16c89b1260c9d07c01c83a9219424d3727069b2e
/* Copyright (C) 2002-2003 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "istream.h"
#include "hex-binary.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 },
{ "size.physical", 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;
}
{
}
{
return index_mail_get_cached_uoff_t(mail,
}
{
time_t t;
&t, sizeof(t)))
t = (time_t)-1;
return t;
}
struct mail_sent_date *sent_date)
{
}
}
{
}
{
const char *const *keywords;
return NULL;
}
return keywords;
}
{
return NULL;
}
}
{
return data->received_date;
}
return data->received_date;
}
{
const char *str;
int tz;
}
if (!message_date_parse((const unsigned char *)str,
(size_t)-1,
/* 0 == parse error */
tz = 0;
}
}
}
}
{
}
}
{
return data->virtual_size;
return data->virtual_size;
if (get_cached_msgpart_sizes(mail))
return data->virtual_size;
return (uoff_t)-1;
return data->virtual_size;
}
{
return data->physical_size;
return data->physical_size;
if (get_cached_msgpart_sizes(mail))
return data->physical_size;
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 {
}
cache_flags = 0;
/* we know the NULs now, update them */
} else {
}
else
}
&cache_flags, sizeof(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_cached_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;
if (!data->parsed_bodystructure) {
if (data->save_bodystructure_header ||
/* 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)
{
const void *ext_data;
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_HEADER_MD5:
&ext_data) < 0) {
return NULL;
}
return NULL;
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;
/* only reason we couldn't get header is if view is invalidated */
}
{
}
{
const struct mail_index_record *rec;
return -1;
}
&data->cache_flags,
sizeof(data->cache_flags)))
data->cache_flags = 0;
t_push();
/* if some wanted fields are cached, get them */
}
}
/* see if we have to parse the message */
t_pop();
return 0;
}
{
}
enum mail_flags flags)
{
flags & MAIL_FLAGS_MASK);
return 0;
}
const struct mail_keywords *keywords)
{
keywords);
return 0;
}
{
return 0;
}